Révision 503b3f7b
Ajouté par Assos Assos il y a environ 10 ans
drupal7/sites/all/modules/jquery_update/replace/ui/ui/jquery.ui.resizable.js | ||
---|---|---|
1 |
/* |
|
2 |
* jQuery UI Resizable 1.8.11 |
|
1 |
/*! |
|
2 |
* jQuery UI Resizable 1.10.2 |
|
3 |
* http://jqueryui.com |
|
3 | 4 |
* |
4 |
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
5 |
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
5 |
* Copyright 2013 jQuery Foundation and other contributors
|
|
6 |
* Released under the MIT license.
|
|
6 | 7 |
* http://jquery.org/license |
7 | 8 |
* |
8 |
* http://docs.jquery.com/UI/Resizables
|
|
9 |
* http://api.jqueryui.com/resizable/
|
|
9 | 10 |
* |
10 | 11 |
* Depends: |
11 | 12 |
* jquery.ui.core.js |
... | ... | |
14 | 15 |
*/ |
15 | 16 |
(function( $, undefined ) { |
16 | 17 |
|
18 |
function num(v) { |
|
19 |
return parseInt(v, 10) || 0; |
|
20 |
} |
|
21 |
|
|
22 |
function isNumber(value) { |
|
23 |
return !isNaN(parseInt(value, 10)); |
|
24 |
} |
|
25 |
|
|
17 | 26 |
$.widget("ui.resizable", $.ui.mouse, { |
27 |
version: "1.10.2", |
|
18 | 28 |
widgetEventPrefix: "resize", |
19 | 29 |
options: { |
20 | 30 |
alsoResize: false, |
... | ... | |
32 | 42 |
maxWidth: null, |
33 | 43 |
minHeight: 10, |
34 | 44 |
minWidth: 10, |
35 |
zIndex: 1000 |
|
45 |
// See #7960 |
|
46 |
zIndex: 90, |
|
47 |
|
|
48 |
// callbacks |
|
49 |
resize: null, |
|
50 |
start: null, |
|
51 |
stop: null |
|
36 | 52 |
}, |
37 | 53 |
_create: function() { |
38 | 54 |
|
39 |
var self = this, o = this.options; |
|
55 |
var n, i, handle, axis, hname, |
|
56 |
that = this, |
|
57 |
o = this.options; |
|
40 | 58 |
this.element.addClass("ui-resizable"); |
41 | 59 |
|
42 | 60 |
$.extend(this, { |
... | ... | |
44 | 62 |
aspectRatio: o.aspectRatio, |
45 | 63 |
originalElement: this.element, |
46 | 64 |
_proportionallyResizeElements: [], |
47 |
_helper: o.helper || o.ghost || o.animate ? o.helper || 'ui-resizable-helper' : null
|
|
65 |
_helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
|
|
48 | 66 |
}); |
49 | 67 |
|
50 | 68 |
//Wrap the element if it cannot hold child nodes |
51 | 69 |
if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) { |
52 | 70 |
|
53 |
//Opera fix for relative positioning |
|
54 |
if (/relative/.test(this.element.css('position')) && $.browser.opera) |
|
55 |
this.element.css({ position: 'relative', top: 'auto', left: 'auto' }); |
|
56 |
|
|
57 | 71 |
//Create a wrapper element and set the wrapper to the new current internal element |
58 | 72 |
this.element.wrap( |
59 |
$('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({
|
|
60 |
position: this.element.css('position'),
|
|
73 |
$("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
|
|
74 |
position: this.element.css("position"),
|
|
61 | 75 |
width: this.element.outerWidth(), |
62 | 76 |
height: this.element.outerHeight(), |
63 |
top: this.element.css('top'),
|
|
64 |
left: this.element.css('left')
|
|
77 |
top: this.element.css("top"),
|
|
78 |
left: this.element.css("left")
|
|
65 | 79 |
}) |
66 | 80 |
); |
67 | 81 |
|
68 | 82 |
//Overwrite the original this.element |
69 | 83 |
this.element = this.element.parent().data( |
70 |
"resizable", this.element.data('resizable')
|
|
84 |
"ui-resizable", this.element.data("ui-resizable")
|
|
71 | 85 |
); |
72 | 86 |
|
73 | 87 |
this.elementIsWrapper = true; |
... | ... | |
77 | 91 |
this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0}); |
78 | 92 |
|
79 | 93 |
//Prevent Safari textarea resize |
80 |
this.originalResizeStyle = this.originalElement.css('resize');
|
|
81 |
this.originalElement.css('resize', 'none');
|
|
94 |
this.originalResizeStyle = this.originalElement.css("resize");
|
|
95 |
this.originalElement.css("resize", "none");
|
|
82 | 96 |
|
83 | 97 |
//Push the actual element to our proportionallyResize internal array |
84 |
this._proportionallyResizeElements.push(this.originalElement.css({ position: 'static', zoom: 1, display: 'block' }));
|
|
98 |
this._proportionallyResizeElements.push(this.originalElement.css({ position: "static", zoom: 1, display: "block" }));
|
|
85 | 99 |
|
86 | 100 |
// avoid IE jump (hard set the margin) |
87 |
this.originalElement.css({ margin: this.originalElement.css('margin') });
|
|
101 |
this.originalElement.css({ margin: this.originalElement.css("margin") });
|
|
88 | 102 |
|
89 | 103 |
// fix handlers offset |
90 | 104 |
this._proportionallyResize(); |
91 | 105 |
|
92 | 106 |
} |
93 | 107 |
|
94 |
this.handles = o.handles || (!$('.ui-resizable-handle', this.element).length ? "e,s,se" : { n: '.ui-resizable-n', e: '.ui-resizable-e', s: '.ui-resizable-s', w: '.ui-resizable-w', se: '.ui-resizable-se', sw: '.ui-resizable-sw', ne: '.ui-resizable-ne', nw: '.ui-resizable-nw' }); |
|
95 |
if(this.handles.constructor == String) { |
|
108 |
this.handles = o.handles || (!$(".ui-resizable-handle", this.element).length ? "e,s,se" : { n: ".ui-resizable-n", e: ".ui-resizable-e", s: ".ui-resizable-s", w: ".ui-resizable-w", se: ".ui-resizable-se", sw: ".ui-resizable-sw", ne: ".ui-resizable-ne", nw: ".ui-resizable-nw" }); |
|
109 |
if(this.handles.constructor === String) { |
|
110 |
|
|
111 |
if ( this.handles === "all") { |
|
112 |
this.handles = "n,e,s,w,se,sw,ne,nw"; |
|
113 |
} |
|
96 | 114 |
|
97 |
if(this.handles == 'all') this.handles = 'n,e,s,w,se,sw,ne,nw';
|
|
98 |
var n = this.handles.split(","); this.handles = {};
|
|
115 |
n = this.handles.split(",");
|
|
116 |
this.handles = {}; |
|
99 | 117 |
|
100 |
for(var i = 0; i < n.length; i++) {
|
|
118 |
for(i = 0; i < n.length; i++) { |
|
101 | 119 |
|
102 |
var handle = $.trim(n[i]), hname = 'ui-resizable-'+handle; |
|
103 |
var axis = $('<div class="ui-resizable-handle ' + hname + '"></div>'); |
|
120 |
handle = $.trim(n[i]); |
|
121 |
hname = "ui-resizable-"+handle; |
|
122 |
axis = $("<div class='ui-resizable-handle " + hname + "'></div>"); |
|
104 | 123 |
|
105 |
// increase zIndex of sw, se, ne, nw axis |
|
106 |
//TODO : this modifies original option |
|
107 |
if(/sw|se|ne|nw/.test(handle)) axis.css({ zIndex: ++o.zIndex }); |
|
124 |
// Apply zIndex to all handles - see #7960 |
|
125 |
axis.css({ zIndex: o.zIndex }); |
|
108 | 126 |
|
109 | 127 |
//TODO : What's going on here? |
110 |
if ('se' == handle) {
|
|
111 |
axis.addClass('ui-icon ui-icon-gripsmall-diagonal-se');
|
|
112 |
};
|
|
128 |
if ("se" === handle) {
|
|
129 |
axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
|
|
130 |
} |
|
113 | 131 |
|
114 | 132 |
//Insert into internal handles object and append to element |
115 |
this.handles[handle] = '.ui-resizable-'+handle;
|
|
133 |
this.handles[handle] = ".ui-resizable-"+handle;
|
|
116 | 134 |
this.element.append(axis); |
117 | 135 |
} |
118 | 136 |
|
... | ... | |
120 | 138 |
|
121 | 139 |
this._renderAxis = function(target) { |
122 | 140 |
|
141 |
var i, axis, padPos, padWrapper; |
|
142 |
|
|
123 | 143 |
target = target || this.element; |
124 | 144 |
|
125 |
for(var i in this.handles) {
|
|
145 |
for(i in this.handles) { |
|
126 | 146 |
|
127 |
if(this.handles[i].constructor == String)
|
|
147 |
if(this.handles[i].constructor === String) {
|
|
128 | 148 |
this.handles[i] = $(this.handles[i], this.element).show(); |
149 |
} |
|
129 | 150 |
|
130 | 151 |
//Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls) |
131 | 152 |
if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) { |
132 | 153 |
|
133 |
var axis = $(this.handles[i], this.element), padWrapper = 0;
|
|
154 |
axis = $(this.handles[i], this.element);
|
|
134 | 155 |
|
135 | 156 |
//Checking the correct pad and border |
136 | 157 |
padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth(); |
137 | 158 |
|
138 | 159 |
//The padding type i have to apply... |
139 |
var padPos = [ 'padding',
|
|
140 |
/ne|nw|n/.test(i) ? 'Top' :
|
|
141 |
/se|sw|s/.test(i) ? 'Bottom' :
|
|
142 |
/^e$/.test(i) ? 'Right' : 'Left' ].join("");
|
|
160 |
padPos = [ "padding",
|
|
161 |
/ne|nw|n/.test(i) ? "Top" :
|
|
162 |
/se|sw|s/.test(i) ? "Bottom" :
|
|
163 |
/^e$/.test(i) ? "Right" : "Left" ].join("");
|
|
143 | 164 |
|
144 | 165 |
target.css(padPos, padWrapper); |
145 | 166 |
|
... | ... | |
148 | 169 |
} |
149 | 170 |
|
150 | 171 |
//TODO: What's that good for? There's not anything to be executed left |
151 |
if(!$(this.handles[i]).length) |
|
172 |
if(!$(this.handles[i]).length) {
|
|
152 | 173 |
continue; |
153 |
|
|
174 |
} |
|
154 | 175 |
} |
155 | 176 |
}; |
156 | 177 |
|
157 | 178 |
//TODO: make renderAxis a prototype function |
158 | 179 |
this._renderAxis(this.element); |
159 | 180 |
|
160 |
this._handles = $('.ui-resizable-handle', this.element)
|
|
181 |
this._handles = $(".ui-resizable-handle", this.element)
|
|
161 | 182 |
.disableSelection(); |
162 | 183 |
|
163 | 184 |
//Matching axis name |
164 | 185 |
this._handles.mouseover(function() { |
165 |
if (!self.resizing) { |
|
166 |
if (this.className) |
|
167 |
var axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i); |
|
186 |
if (!that.resizing) { |
|
187 |
if (this.className) { |
|
188 |
axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i); |
|
189 |
} |
|
168 | 190 |
//Axis, default = se |
169 |
self.axis = axis && axis[1] ? axis[1] : 'se';
|
|
191 |
that.axis = axis && axis[1] ? axis[1] : "se";
|
|
170 | 192 |
} |
171 | 193 |
}); |
172 | 194 |
|
... | ... | |
175 | 197 |
this._handles.hide(); |
176 | 198 |
$(this.element) |
177 | 199 |
.addClass("ui-resizable-autohide") |
178 |
.hover(function() { |
|
200 |
.mouseenter(function() { |
|
201 |
if (o.disabled) { |
|
202 |
return; |
|
203 |
} |
|
179 | 204 |
$(this).removeClass("ui-resizable-autohide"); |
180 |
self._handles.show(); |
|
181 |
}, |
|
182 |
function(){ |
|
183 |
if (!self.resizing) { |
|
205 |
that._handles.show(); |
|
206 |
}) |
|
207 |
.mouseleave(function(){ |
|
208 |
if (o.disabled) { |
|
209 |
return; |
|
210 |
} |
|
211 |
if (!that.resizing) { |
|
184 | 212 |
$(this).addClass("ui-resizable-autohide"); |
185 |
self._handles.hide();
|
|
213 |
that._handles.hide();
|
|
186 | 214 |
} |
187 | 215 |
}); |
188 | 216 |
} |
... | ... | |
192 | 220 |
|
193 | 221 |
}, |
194 | 222 |
|
195 |
destroy: function() { |
|
223 |
_destroy: function() {
|
|
196 | 224 |
|
197 | 225 |
this._mouseDestroy(); |
198 | 226 |
|
199 |
var _destroy = function(exp) { |
|
200 |
$(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing") |
|
201 |
.removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove(); |
|
202 |
}; |
|
227 |
var wrapper, |
|
228 |
_destroy = function(exp) { |
|
229 |
$(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing") |
|
230 |
.removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove(); |
|
231 |
}; |
|
203 | 232 |
|
204 | 233 |
//TODO: Unwrap at same DOM position |
205 | 234 |
if (this.elementIsWrapper) { |
206 | 235 |
_destroy(this.element); |
207 |
var wrapper = this.element; |
|
208 |
wrapper.after( |
|
209 |
this.originalElement.css({ |
|
210 |
position: wrapper.css('position'), |
|
211 |
width: wrapper.outerWidth(), |
|
212 |
height: wrapper.outerHeight(), |
|
213 |
top: wrapper.css('top'), |
|
214 |
left: wrapper.css('left') |
|
215 |
}) |
|
216 |
).remove(); |
|
236 |
wrapper = this.element; |
|
237 |
this.originalElement.css({ |
|
238 |
position: wrapper.css("position"), |
|
239 |
width: wrapper.outerWidth(), |
|
240 |
height: wrapper.outerHeight(), |
|
241 |
top: wrapper.css("top"), |
|
242 |
left: wrapper.css("left") |
|
243 |
}).insertAfter( wrapper ); |
|
244 |
wrapper.remove(); |
|
217 | 245 |
} |
218 | 246 |
|
219 |
this.originalElement.css('resize', this.originalResizeStyle);
|
|
247 |
this.originalElement.css("resize", this.originalResizeStyle);
|
|
220 | 248 |
_destroy(this.originalElement); |
221 | 249 |
|
222 | 250 |
return this; |
223 | 251 |
}, |
224 | 252 |
|
225 | 253 |
_mouseCapture: function(event) { |
226 |
var handle = false; |
|
227 |
for (var i in this.handles) { |
|
228 |
if ($(this.handles[i])[0] == event.target) { |
|
229 |
handle = true; |
|
254 |
var i, handle, |
|
255 |
capture = false; |
|
256 |
|
|
257 |
for (i in this.handles) { |
|
258 |
handle = $(this.handles[i])[0]; |
|
259 |
if (handle === event.target || $.contains(handle, event.target)) { |
|
260 |
capture = true; |
|
230 | 261 |
} |
231 | 262 |
} |
232 | 263 |
|
233 |
return !this.options.disabled && handle;
|
|
264 |
return !this.options.disabled && capture;
|
|
234 | 265 |
}, |
235 | 266 |
|
236 | 267 |
_mouseStart: function(event) { |
237 | 268 |
|
238 |
var o = this.options, iniPos = this.element.position(), el = this.element; |
|
269 |
var curleft, curtop, cursor, |
|
270 |
o = this.options, |
|
271 |
iniPos = this.element.position(), |
|
272 |
el = this.element; |
|
239 | 273 |
|
240 | 274 |
this.resizing = true; |
241 |
this.documentScroll = { top: $(document).scrollTop(), left: $(document).scrollLeft() }; |
|
242 | 275 |
|
243 | 276 |
// bugfix for http://dev.jquery.com/ticket/1749 |
244 |
if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) { |
|
245 |
el.css({ position: 'absolute', top: iniPos.top, left: iniPos.left }); |
|
277 |
if ( (/absolute/).test( el.css("position") ) ) { |
|
278 |
el.css({ position: "absolute", top: el.css("top"), left: el.css("left") }); |
|
279 |
} else if (el.is(".ui-draggable")) { |
|
280 |
el.css({ position: "absolute", top: iniPos.top, left: iniPos.left }); |
|
246 | 281 |
} |
247 | 282 |
|
248 |
//Opera fixing relative position |
|
249 |
if ($.browser.opera && (/relative/).test(el.css('position'))) |
|
250 |
el.css({ position: 'relative', top: 'auto', left: 'auto' }); |
|
251 |
|
|
252 | 283 |
this._renderProxy(); |
253 | 284 |
|
254 |
var curleft = num(this.helper.css('left')), curtop = num(this.helper.css('top')); |
|
285 |
curleft = num(this.helper.css("left")); |
|
286 |
curtop = num(this.helper.css("top")); |
|
255 | 287 |
|
256 | 288 |
if (o.containment) { |
257 | 289 |
curleft += $(o.containment).scrollLeft() || 0; |
... | ... | |
268 | 300 |
this.originalMousePosition = { left: event.pageX, top: event.pageY }; |
269 | 301 |
|
270 | 302 |
//Aspect Ratio |
271 |
this.aspectRatio = (typeof o.aspectRatio == 'number') ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
|
|
303 |
this.aspectRatio = (typeof o.aspectRatio === "number") ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
|
|
272 | 304 |
|
273 |
var cursor = $('.ui-resizable-' + this.axis).css('cursor');
|
|
274 |
$('body').css('cursor', cursor == 'auto' ? this.axis + '-resize' : cursor);
|
|
305 |
cursor = $(".ui-resizable-" + this.axis).css("cursor");
|
|
306 |
$("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
|
|
275 | 307 |
|
276 | 308 |
el.addClass("ui-resizable-resizing"); |
277 | 309 |
this._propagate("start", event); |
... | ... | |
281 | 313 |
_mouseDrag: function(event) { |
282 | 314 |
|
283 | 315 |
//Increase performance, avoid regex |
284 |
var el = this.helper, o = this.options, props = {}, |
|
285 |
self = this, smp = this.originalMousePosition, a = this.axis; |
|
286 |
|
|
287 |
var dx = (event.pageX-smp.left)||0, dy = (event.pageY-smp.top)||0; |
|
288 |
var trigger = this._change[a]; |
|
289 |
if (!trigger) return false; |
|
316 |
var data, |
|
317 |
el = this.helper, props = {}, |
|
318 |
smp = this.originalMousePosition, |
|
319 |
a = this.axis, |
|
320 |
prevTop = this.position.top, |
|
321 |
prevLeft = this.position.left, |
|
322 |
prevWidth = this.size.width, |
|
323 |
prevHeight = this.size.height, |
|
324 |
dx = (event.pageX-smp.left)||0, |
|
325 |
dy = (event.pageY-smp.top)||0, |
|
326 |
trigger = this._change[a]; |
|
327 |
|
|
328 |
if (!trigger) { |
|
329 |
return false; |
|
330 |
} |
|
290 | 331 |
|
291 | 332 |
// Calculate the attrs that will be change |
292 |
var data = trigger.apply(this, [event, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff;
|
|
333 |
data = trigger.apply(this, [event, dx, dy]);
|
|
293 | 334 |
|
294 |
if (this._aspectRatio || event.shiftKey) |
|
335 |
// Put this in the mouseDrag handler since the user can start pressing shift while resizing |
|
336 |
this._updateVirtualBoundaries(event.shiftKey); |
|
337 |
if (this._aspectRatio || event.shiftKey) { |
|
295 | 338 |
data = this._updateRatio(data, event); |
339 |
} |
|
296 | 340 |
|
297 | 341 |
data = this._respectSize(data, event); |
298 | 342 |
|
343 |
this._updateCache(data); |
|
344 |
|
|
299 | 345 |
// plugins callbacks need to be called first |
300 | 346 |
this._propagate("resize", event); |
301 | 347 |
|
302 |
el.css({ |
|
303 |
top: this.position.top + "px", left: this.position.left + "px", |
|
304 |
width: this.size.width + "px", height: this.size.height + "px" |
|
305 |
}); |
|
348 |
if (this.position.top !== prevTop) { |
|
349 |
props.top = this.position.top + "px"; |
|
350 |
} |
|
351 |
if (this.position.left !== prevLeft) { |
|
352 |
props.left = this.position.left + "px"; |
|
353 |
} |
|
354 |
if (this.size.width !== prevWidth) { |
|
355 |
props.width = this.size.width + "px"; |
|
356 |
} |
|
357 |
if (this.size.height !== prevHeight) { |
|
358 |
props.height = this.size.height + "px"; |
|
359 |
} |
|
360 |
el.css(props); |
|
306 | 361 |
|
307 |
if (!this._helper && this._proportionallyResizeElements.length) |
|
362 |
if (!this._helper && this._proportionallyResizeElements.length) {
|
|
308 | 363 |
this._proportionallyResize(); |
364 |
} |
|
309 | 365 |
|
310 |
this._updateCache(data);
|
|
311 |
|
|
312 |
// calling the user callback at the end
|
|
313 |
this._trigger('resize', event, this.ui());
|
|
366 |
// Call the user callback if the element was resized
|
|
367 |
if ( ! $.isEmptyObject(props) ) { |
|
368 |
this._trigger("resize", event, this.ui());
|
|
369 |
}
|
|
314 | 370 |
|
315 | 371 |
return false; |
316 | 372 |
}, |
... | ... | |
318 | 374 |
_mouseStop: function(event) { |
319 | 375 |
|
320 | 376 |
this.resizing = false; |
321 |
var o = this.options, self = this; |
|
377 |
var pr, ista, soffseth, soffsetw, s, left, top, |
|
378 |
o = this.options, that = this; |
|
322 | 379 |
|
323 | 380 |
if(this._helper) { |
324 |
var pr = this._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName), |
|
325 |
soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height, |
|
326 |
soffsetw = ista ? 0 : self.sizeDiff.width; |
|
327 | 381 |
|
328 |
var s = { width: (self.helper.width() - soffsetw), height: (self.helper.height() - soffseth) }, |
|
329 |
left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null, |
|
330 |
top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null; |
|
382 |
pr = this._proportionallyResizeElements; |
|
383 |
ista = pr.length && (/textarea/i).test(pr[0].nodeName); |
|
384 |
soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height; |
|
385 |
soffsetw = ista ? 0 : that.sizeDiff.width; |
|
331 | 386 |
|
332 |
if (!o.animate) |
|
387 |
s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) }; |
|
388 |
left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null; |
|
389 |
top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null; |
|
390 |
|
|
391 |
if (!o.animate) { |
|
333 | 392 |
this.element.css($.extend(s, { top: top, left: left })); |
393 |
} |
|
334 | 394 |
|
335 |
self.helper.height(self.size.height);
|
|
336 |
self.helper.width(self.size.width);
|
|
395 |
that.helper.height(that.size.height);
|
|
396 |
that.helper.width(that.size.width);
|
|
337 | 397 |
|
338 |
if (this._helper && !o.animate) this._proportionallyResize(); |
|
398 |
if (this._helper && !o.animate) { |
|
399 |
this._proportionallyResize(); |
|
400 |
} |
|
339 | 401 |
} |
340 | 402 |
|
341 |
$('body').css('cursor', 'auto');
|
|
403 |
$("body").css("cursor", "auto");
|
|
342 | 404 |
|
343 | 405 |
this.element.removeClass("ui-resizable-resizing"); |
344 | 406 |
|
345 | 407 |
this._propagate("stop", event); |
346 | 408 |
|
347 |
if (this._helper) this.helper.remove(); |
|
409 |
if (this._helper) { |
|
410 |
this.helper.remove(); |
|
411 |
} |
|
412 |
|
|
348 | 413 |
return false; |
349 | 414 |
|
350 | 415 |
}, |
351 | 416 |
|
417 |
_updateVirtualBoundaries: function(forceAspectRatio) { |
|
418 |
var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b, |
|
419 |
o = this.options; |
|
420 |
|
|
421 |
b = { |
|
422 |
minWidth: isNumber(o.minWidth) ? o.minWidth : 0, |
|
423 |
maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity, |
|
424 |
minHeight: isNumber(o.minHeight) ? o.minHeight : 0, |
|
425 |
maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity |
|
426 |
}; |
|
427 |
|
|
428 |
if(this._aspectRatio || forceAspectRatio) { |
|
429 |
// We want to create an enclosing box whose aspect ration is the requested one |
|
430 |
// First, compute the "projected" size for each dimension based on the aspect ratio and other dimension |
|
431 |
pMinWidth = b.minHeight * this.aspectRatio; |
|
432 |
pMinHeight = b.minWidth / this.aspectRatio; |
|
433 |
pMaxWidth = b.maxHeight * this.aspectRatio; |
|
434 |
pMaxHeight = b.maxWidth / this.aspectRatio; |
|
435 |
|
|
436 |
if(pMinWidth > b.minWidth) { |
|
437 |
b.minWidth = pMinWidth; |
|
438 |
} |
|
439 |
if(pMinHeight > b.minHeight) { |
|
440 |
b.minHeight = pMinHeight; |
|
441 |
} |
|
442 |
if(pMaxWidth < b.maxWidth) { |
|
443 |
b.maxWidth = pMaxWidth; |
|
444 |
} |
|
445 |
if(pMaxHeight < b.maxHeight) { |
|
446 |
b.maxHeight = pMaxHeight; |
|
447 |
} |
|
448 |
} |
|
449 |
this._vBoundaries = b; |
|
450 |
}, |
|
451 |
|
|
352 | 452 |
_updateCache: function(data) { |
353 |
var o = this.options; |
|
354 | 453 |
this.offset = this.helper.offset(); |
355 |
if (isNumber(data.left)) this.position.left = data.left; |
|
356 |
if (isNumber(data.top)) this.position.top = data.top; |
|
357 |
if (isNumber(data.height)) this.size.height = data.height; |
|
358 |
if (isNumber(data.width)) this.size.width = data.width; |
|
454 |
if (isNumber(data.left)) { |
|
455 |
this.position.left = data.left; |
|
456 |
} |
|
457 |
if (isNumber(data.top)) { |
|
458 |
this.position.top = data.top; |
|
459 |
} |
|
460 |
if (isNumber(data.height)) { |
|
461 |
this.size.height = data.height; |
|
462 |
} |
|
463 |
if (isNumber(data.width)) { |
|
464 |
this.size.width = data.width; |
|
465 |
} |
|
359 | 466 |
}, |
360 | 467 |
|
361 |
_updateRatio: function(data, event) {
|
|
468 |
_updateRatio: function( data ) {
|
|
362 | 469 |
|
363 |
var o = this.options, cpos = this.position, csize = this.size, a = this.axis; |
|
470 |
var cpos = this.position, |
|
471 |
csize = this.size, |
|
472 |
a = this.axis; |
|
364 | 473 |
|
365 |
if (data.height) data.width = (csize.height * this.aspectRatio); |
|
366 |
else if (data.width) data.height = (csize.width / this.aspectRatio); |
|
474 |
if (isNumber(data.height)) { |
|
475 |
data.width = (data.height * this.aspectRatio); |
|
476 |
} else if (isNumber(data.width)) { |
|
477 |
data.height = (data.width / this.aspectRatio); |
|
478 |
} |
|
367 | 479 |
|
368 |
if (a == 'sw') {
|
|
480 |
if (a === "sw") {
|
|
369 | 481 |
data.left = cpos.left + (csize.width - data.width); |
370 | 482 |
data.top = null; |
371 | 483 |
} |
372 |
if (a == 'nw') {
|
|
484 |
if (a === "nw") {
|
|
373 | 485 |
data.top = cpos.top + (csize.height - data.height); |
374 | 486 |
data.left = cpos.left + (csize.width - data.width); |
375 | 487 |
} |
... | ... | |
377 | 489 |
return data; |
378 | 490 |
}, |
379 | 491 |
|
380 |
_respectSize: function(data, event) { |
|
381 |
|
|
382 |
var el = this.helper, o = this.options, pRatio = this._aspectRatio || event.shiftKey, a = this.axis, |
|
383 |
ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height), |
|
384 |
isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height); |
|
385 |
|
|
386 |
if (isminw) data.width = o.minWidth; |
|
387 |
if (isminh) data.height = o.minHeight; |
|
388 |
if (ismaxw) data.width = o.maxWidth; |
|
389 |
if (ismaxh) data.height = o.maxHeight; |
|
390 |
|
|
391 |
var dw = this.originalPosition.left + this.originalSize.width, dh = this.position.top + this.size.height; |
|
392 |
var cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a); |
|
492 |
_respectSize: function( data ) { |
|
493 |
|
|
494 |
var o = this._vBoundaries, |
|
495 |
a = this.axis, |
|
496 |
ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height), |
|
497 |
isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height), |
|
498 |
dw = this.originalPosition.left + this.originalSize.width, |
|
499 |
dh = this.position.top + this.size.height, |
|
500 |
cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a); |
|
501 |
if (isminw) { |
|
502 |
data.width = o.minWidth; |
|
503 |
} |
|
504 |
if (isminh) { |
|
505 |
data.height = o.minHeight; |
|
506 |
} |
|
507 |
if (ismaxw) { |
|
508 |
data.width = o.maxWidth; |
|
509 |
} |
|
510 |
if (ismaxh) { |
|
511 |
data.height = o.maxHeight; |
|
512 |
} |
|
393 | 513 |
|
394 |
if (isminw && cw) data.left = dw - o.minWidth; |
|
395 |
if (ismaxw && cw) data.left = dw - o.maxWidth; |
|
396 |
if (isminh && ch) data.top = dh - o.minHeight; |
|
397 |
if (ismaxh && ch) data.top = dh - o.maxHeight; |
|
514 |
if (isminw && cw) { |
|
515 |
data.left = dw - o.minWidth; |
|
516 |
} |
|
517 |
if (ismaxw && cw) { |
|
518 |
data.left = dw - o.maxWidth; |
|
519 |
} |
|
520 |
if (isminh && ch) { |
|
521 |
data.top = dh - o.minHeight; |
|
522 |
} |
|
523 |
if (ismaxh && ch) { |
|
524 |
data.top = dh - o.maxHeight; |
|
525 |
} |
|
398 | 526 |
|
399 | 527 |
// fixing jump error on top/left - bug #2330 |
400 |
var isNotwh = !data.width && !data.height; |
|
401 |
if (isNotwh && !data.left && data.top) data.top = null; |
|
402 |
else if (isNotwh && !data.top && data.left) data.left = null; |
|
528 |
if (!data.width && !data.height && !data.left && data.top) { |
|
529 |
data.top = null; |
|
530 |
} else if (!data.width && !data.height && !data.top && data.left) { |
|
531 |
data.left = null; |
|
532 |
} |
|
403 | 533 |
|
404 | 534 |
return data; |
405 | 535 |
}, |
406 | 536 |
|
407 | 537 |
_proportionallyResize: function() { |
408 | 538 |
|
409 |
var o = this.options; |
|
410 |
if (!this._proportionallyResizeElements.length) return; |
|
411 |
var element = this.helper || this.element; |
|
539 |
if (!this._proportionallyResizeElements.length) { |
|
540 |
return; |
|
541 |
} |
|
542 |
|
|
543 |
var i, j, borders, paddings, prel, |
|
544 |
element = this.helper || this.element; |
|
412 | 545 |
|
413 |
for (var i=0; i < this._proportionallyResizeElements.length; i++) {
|
|
546 |
for ( i=0; i < this._proportionallyResizeElements.length; i++) { |
|
414 | 547 |
|
415 |
var prel = this._proportionallyResizeElements[i];
|
|
548 |
prel = this._proportionallyResizeElements[i]; |
|
416 | 549 |
|
417 | 550 |
if (!this.borderDif) { |
418 |
var b = [prel.css('borderTopWidth'), prel.css('borderRightWidth'), prel.css('borderBottomWidth'), prel.css('borderLeftWidth')], |
|
419 |
p = [prel.css('paddingTop'), prel.css('paddingRight'), prel.css('paddingBottom'), prel.css('paddingLeft')]; |
|
551 |
this.borderDif = []; |
|
552 |
borders = [prel.css("borderTopWidth"), prel.css("borderRightWidth"), prel.css("borderBottomWidth"), prel.css("borderLeftWidth")]; |
|
553 |
paddings = [prel.css("paddingTop"), prel.css("paddingRight"), prel.css("paddingBottom"), prel.css("paddingLeft")]; |
|
420 | 554 |
|
421 |
this.borderDif = $.map(b, function(v, i) { |
|
422 |
var border = parseInt(v,10)||0, padding = parseInt(p[i],10)||0; |
|
423 |
return border + padding; |
|
424 |
}); |
|
555 |
for ( j = 0; j < borders.length; j++ ) { |
|
556 |
this.borderDif[ j ] = ( parseInt( borders[ j ], 10 ) || 0 ) + ( parseInt( paddings[ j ], 10 ) || 0 ); |
|
557 |
} |
|
425 | 558 |
} |
426 | 559 |
|
427 |
if ($.browser.msie && !(!($(element).is(':hidden') || $(element).parents(':hidden').length))) |
|
428 |
continue; |
|
429 |
|
|
430 | 560 |
prel.css({ |
431 | 561 |
height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0, |
432 | 562 |
width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0 |
433 | 563 |
}); |
434 | 564 |
|
435 |
};
|
|
565 |
} |
|
436 | 566 |
|
437 | 567 |
}, |
438 | 568 |
|
... | ... | |
443 | 573 |
|
444 | 574 |
if(this._helper) { |
445 | 575 |
|
446 |
this.helper = this.helper || $('<div style="overflow:hidden;"></div>'); |
|
447 |
|
|
448 |
// fix ie6 offset TODO: This seems broken |
|
449 |
var ie6 = $.browser.msie && $.browser.version < 7, ie6offset = (ie6 ? 1 : 0), |
|
450 |
pxyoffset = ( ie6 ? 2 : -1 ); |
|
576 |
this.helper = this.helper || $("<div style='overflow:hidden;'></div>"); |
|
451 | 577 |
|
452 | 578 |
this.helper.addClass(this._helper).css({ |
453 |
width: this.element.outerWidth() + pxyoffset,
|
|
454 |
height: this.element.outerHeight() + pxyoffset,
|
|
455 |
position: 'absolute',
|
|
456 |
left: this.elementOffset.left - ie6offset +'px',
|
|
457 |
top: this.elementOffset.top - ie6offset +'px',
|
|
579 |
width: this.element.outerWidth() - 1,
|
|
580 |
height: this.element.outerHeight() - 1,
|
|
581 |
position: "absolute",
|
|
582 |
left: this.elementOffset.left +"px",
|
|
583 |
top: this.elementOffset.top +"px",
|
|
458 | 584 |
zIndex: ++o.zIndex //TODO: Don't modify option |
459 | 585 |
}); |
460 | 586 |
|
... | ... | |
469 | 595 |
}, |
470 | 596 |
|
471 | 597 |
_change: { |
472 |
e: function(event, dx, dy) {
|
|
598 |
e: function(event, dx) { |
|
473 | 599 |
return { width: this.originalSize.width + dx }; |
474 | 600 |
}, |
475 |
w: function(event, dx, dy) {
|
|
476 |
var o = this.options, cs = this.originalSize, sp = this.originalPosition;
|
|
601 |
w: function(event, dx) { |
|
602 |
var cs = this.originalSize, sp = this.originalPosition; |
|
477 | 603 |
return { left: sp.left + dx, width: cs.width - dx }; |
478 | 604 |
}, |
479 | 605 |
n: function(event, dx, dy) { |
480 |
var o = this.options, cs = this.originalSize, sp = this.originalPosition;
|
|
606 |
var cs = this.originalSize, sp = this.originalPosition; |
|
481 | 607 |
return { top: sp.top + dy, height: cs.height - dy }; |
482 | 608 |
}, |
483 | 609 |
s: function(event, dx, dy) { |
... | ... | |
499 | 625 |
|
500 | 626 |
_propagate: function(n, event) { |
501 | 627 |
$.ui.plugin.call(this, n, [event, this.ui()]); |
502 |
(n != "resize" && this._trigger(n, event, this.ui())); |
|
628 |
(n !== "resize" && this._trigger(n, event, this.ui()));
|
|
503 | 629 |
}, |
504 | 630 |
|
505 | 631 |
plugins: {}, |
... | ... | |
518 | 644 |
|
519 | 645 |
}); |
520 | 646 |
|
521 |
$.extend($.ui.resizable, { |
|
522 |
version: "1.8.11" |
|
523 |
}); |
|
524 |
|
|
525 | 647 |
/* |
526 | 648 |
* Resizable Extensions |
527 | 649 |
*/ |
528 | 650 |
|
529 |
$.ui.plugin.add("resizable", "alsoResize", { |
|
530 |
|
|
531 |
start: function (event, ui) { |
|
532 |
var self = $(this).data("resizable"), o = self.options; |
|
533 |
|
|
534 |
var _store = function (exp) { |
|
535 |
$(exp).each(function() { |
|
536 |
var el = $(this); |
|
537 |
el.data("resizable-alsoresize", { |
|
538 |
width: parseInt(el.width(), 10), height: parseInt(el.height(), 10), |
|
539 |
left: parseInt(el.css('left'), 10), top: parseInt(el.css('top'), 10), |
|
540 |
position: el.css('position') // to reset Opera on stop() |
|
541 |
}); |
|
542 |
}); |
|
543 |
}; |
|
544 |
|
|
545 |
if (typeof(o.alsoResize) == 'object' && !o.alsoResize.parentNode) { |
|
546 |
if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); } |
|
547 |
else { $.each(o.alsoResize, function (exp) { _store(exp); }); } |
|
548 |
}else{ |
|
549 |
_store(o.alsoResize); |
|
550 |
} |
|
551 |
}, |
|
552 |
|
|
553 |
resize: function (event, ui) { |
|
554 |
var self = $(this).data("resizable"), o = self.options, os = self.originalSize, op = self.originalPosition; |
|
555 |
|
|
556 |
var delta = { |
|
557 |
height: (self.size.height - os.height) || 0, width: (self.size.width - os.width) || 0, |
|
558 |
top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0 |
|
559 |
}, |
|
560 |
|
|
561 |
_alsoResize = function (exp, c) { |
|
562 |
$(exp).each(function() { |
|
563 |
var el = $(this), start = $(this).data("resizable-alsoresize"), style = {}, |
|
564 |
css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ['width', 'height'] : ['width', 'height', 'top', 'left']; |
|
565 |
|
|
566 |
$.each(css, function (i, prop) { |
|
567 |
var sum = (start[prop]||0) + (delta[prop]||0); |
|
568 |
if (sum && sum >= 0) |
|
569 |
style[prop] = sum || null; |
|
570 |
}); |
|
571 |
|
|
572 |
// Opera fixing relative position |
|
573 |
if ($.browser.opera && /relative/.test(el.css('position'))) { |
|
574 |
self._revertToRelativePosition = true; |
|
575 |
el.css({ position: 'absolute', top: 'auto', left: 'auto' }); |
|
576 |
} |
|
577 |
|
|
578 |
el.css(style); |
|
579 |
}); |
|
580 |
}; |
|
581 |
|
|
582 |
if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType) { |
|
583 |
$.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); }); |
|
584 |
}else{ |
|
585 |
_alsoResize(o.alsoResize); |
|
586 |
} |
|
587 |
}, |
|
588 |
|
|
589 |
stop: function (event, ui) { |
|
590 |
var self = $(this).data("resizable"), o = self.options; |
|
591 |
|
|
592 |
var _reset = function (exp) { |
|
593 |
$(exp).each(function() { |
|
594 |
var el = $(this); |
|
595 |
// reset position for Opera - no need to verify it was changed |
|
596 |
el.css({ position: el.data("resizable-alsoresize").position }); |
|
597 |
}); |
|
598 |
}; |
|
599 |
|
|
600 |
if (self._revertToRelativePosition) { |
|
601 |
self._revertToRelativePosition = false; |
|
602 |
if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType) { |
|
603 |
$.each(o.alsoResize, function (exp) { _reset(exp); }); |
|
604 |
}else{ |
|
605 |
_reset(o.alsoResize); |
|
606 |
} |
|
607 |
} |
|
608 |
|
|
609 |
$(this).removeData("resizable-alsoresize"); |
|
610 |
} |
|
611 |
}); |
|
612 |
|
|
613 | 651 |
$.ui.plugin.add("resizable", "animate", { |
614 | 652 |
|
615 |
stop: function(event, ui) {
|
|
616 |
var self = $(this).data("resizable"), o = self.options;
|
|
617 |
|
|
618 |
var pr = self._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
|
|
619 |
soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
|
|
620 |
soffsetw = ista ? 0 : self.sizeDiff.width;
|
|
621 |
|
|
622 |
var style = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) },
|
|
623 |
left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null,
|
|
624 |
top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
|
|
625 |
|
|
626 |
self.element.animate(
|
|
653 |
stop: function( event ) {
|
|
654 |
var that = $(this).data("ui-resizable"),
|
|
655 |
o = that.options, |
|
656 |
pr = that._proportionallyResizeElements,
|
|
657 |
ista = pr.length && (/textarea/i).test(pr[0].nodeName),
|
|
658 |
soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height,
|
|
659 |
soffsetw = ista ? 0 : that.sizeDiff.width, |
|
660 |
style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
|
|
661 |
left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null,
|
|
662 |
top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
|
|
663 |
|
|
664 |
that.element.animate(
|
|
627 | 665 |
$.extend(style, top && left ? { top: top, left: left } : {}), { |
628 | 666 |
duration: o.animateDuration, |
629 | 667 |
easing: o.animateEasing, |
630 | 668 |
step: function() { |
631 | 669 |
|
632 | 670 |
var data = { |
633 |
width: parseInt(self.element.css('width'), 10),
|
|
634 |
height: parseInt(self.element.css('height'), 10),
|
|
635 |
top: parseInt(self.element.css('top'), 10),
|
|
636 |
left: parseInt(self.element.css('left'), 10)
|
|
671 |
width: parseInt(that.element.css("width"), 10),
|
|
672 |
height: parseInt(that.element.css("height"), 10),
|
|
673 |
top: parseInt(that.element.css("top"), 10),
|
|
674 |
left: parseInt(that.element.css("left"), 10)
|
|
637 | 675 |
}; |
638 | 676 |
|
639 |
if (pr && pr.length) $(pr[0]).css({ width: data.width, height: data.height }); |
|
677 |
if (pr && pr.length) { |
|
678 |
$(pr[0]).css({ width: data.width, height: data.height }); |
|
679 |
} |
|
640 | 680 |
|
641 | 681 |
// propagating resize, and updating values for each animation step |
642 |
self._updateCache(data);
|
|
643 |
self._propagate("resize", event);
|
|
682 |
that._updateCache(data);
|
|
683 |
that._propagate("resize", event);
|
|
644 | 684 |
|
645 | 685 |
} |
646 | 686 |
} |
... | ... | |
651 | 691 |
|
652 | 692 |
$.ui.plugin.add("resizable", "containment", { |
653 | 693 |
|
654 |
start: function(event, ui) { |
|
655 |
var self = $(this).data("resizable"), o = self.options, el = self.element; |
|
656 |
var oc = o.containment, ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc; |
|
657 |
if (!ce) return; |
|
694 |
start: function() { |
|
695 |
var element, p, co, ch, cw, width, height, |
|
696 |
that = $(this).data("ui-resizable"), |
|
697 |
o = that.options, |
|
698 |
el = that.element, |
|
699 |
oc = o.containment, |
|
700 |
ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc; |
|
701 |
|
|
702 |
if (!ce) { |
|
703 |
return; |
|
704 |
} |
|
658 | 705 |
|
659 |
self.containerElement = $(ce);
|
|
706 |
that.containerElement = $(ce);
|
|
660 | 707 |
|
661 |
if (/document/.test(oc) || oc == document) { |
|
662 |
self.containerOffset = { left: 0, top: 0 };
|
|
663 |
self.containerPosition = { left: 0, top: 0 };
|
|
708 |
if (/document/.test(oc) || oc === document) {
|
|
709 |
that.containerOffset = { left: 0, top: 0 };
|
|
710 |
that.containerPosition = { left: 0, top: 0 };
|
|
664 | 711 |
|
665 |
self.parentData = {
|
|
712 |
that.parentData = {
|
|
666 | 713 |
element: $(document), left: 0, top: 0, |
667 | 714 |
width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight |
668 | 715 |
}; |
... | ... | |
670 | 717 |
|
671 | 718 |
// i'm a node, so compute top, left, right, bottom |
672 | 719 |
else { |
673 |
var element = $(ce), p = []; |
|
720 |
element = $(ce); |
|
721 |
p = []; |
|
674 | 722 |
$([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); }); |
675 | 723 |
|
676 |
self.containerOffset = element.offset();
|
|
677 |
self.containerPosition = element.position();
|
|
678 |
self.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
|
|
724 |
that.containerOffset = element.offset();
|
|
725 |
that.containerPosition = element.position();
|
|
726 |
that.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
|
|
679 | 727 |
|
680 |
var co = self.containerOffset, ch = self.containerSize.height, cw = self.containerSize.width, |
|
681 |
width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch); |
|
728 |
co = that.containerOffset; |
|
729 |
ch = that.containerSize.height; |
|
730 |
cw = that.containerSize.width; |
|
731 |
width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ); |
|
732 |
height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch); |
|
682 | 733 |
|
683 |
self.parentData = {
|
|
734 |
that.parentData = {
|
|
684 | 735 |
element: ce, left: co.left, top: co.top, width: width, height: height |
685 | 736 |
}; |
686 | 737 |
} |
687 | 738 |
}, |
688 | 739 |
|
689 |
resize: function(event, ui) { |
|
690 |
var self = $(this).data("resizable"), o = self.options, |
|
691 |
ps = self.containerSize, co = self.containerOffset, cs = self.size, cp = self.position, |
|
692 |
pRatio = self._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = self.containerElement; |
|
740 |
resize: function( event ) { |
|
741 |
var woset, hoset, isParent, isOffsetRelative, |
|
742 |
that = $(this).data("ui-resizable"), |
|
743 |
o = that.options, |
|
744 |
co = that.containerOffset, cp = that.position, |
|
745 |
pRatio = that._aspectRatio || event.shiftKey, |
|
746 |
cop = { top:0, left:0 }, ce = that.containerElement; |
|
693 | 747 |
|
694 |
if (ce[0] != document && (/static/).test(ce.css('position'))) cop = co; |
|
748 |
if (ce[0] !== document && (/static/).test(ce.css("position"))) { |
|
749 |
cop = co; |
|
750 |
} |
|
695 | 751 |
|
696 |
if (cp.left < (self._helper ? co.left : 0)) { |
|
697 |
self.size.width = self.size.width + (self._helper ? (self.position.left - co.left) : (self.position.left - cop.left)); |
|
698 |
if (pRatio) self.size.height = self.size.width / o.aspectRatio; |
|
699 |
self.position.left = o.helper ? co.left : 0; |
|
752 |
if (cp.left < (that._helper ? co.left : 0)) { |
|
753 |
that.size.width = that.size.width + (that._helper ? (that.position.left - co.left) : (that.position.left - cop.left)); |
|
754 |
if (pRatio) { |
|
755 |
that.size.height = that.size.width / that.aspectRatio; |
|
756 |
} |
|
757 |
that.position.left = o.helper ? co.left : 0; |
|
700 | 758 |
} |
701 | 759 |
|
702 |
if (cp.top < (self._helper ? co.top : 0)) { |
|
703 |
self.size.height = self.size.height + (self._helper ? (self.position.top - co.top) : self.position.top); |
|
704 |
if (pRatio) self.size.width = self.size.height * o.aspectRatio; |
|
705 |
self.position.top = self._helper ? co.top : 0; |
|
760 |
if (cp.top < (that._helper ? co.top : 0)) { |
|
761 |
that.size.height = that.size.height + (that._helper ? (that.position.top - co.top) : that.position.top); |
|
762 |
if (pRatio) { |
|
763 |
that.size.width = that.size.height * that.aspectRatio; |
|
764 |
} |
|
765 |
that.position.top = that._helper ? co.top : 0; |
|
706 | 766 |
} |
707 | 767 |
|
708 |
self.offset.left = self.parentData.left+self.position.left;
|
|
709 |
self.offset.top = self.parentData.top+self.position.top;
|
|
768 |
that.offset.left = that.parentData.left+that.position.left;
|
|
769 |
that.offset.top = that.parentData.top+that.position.top;
|
|
710 | 770 |
|
711 |
var woset = Math.abs( (self._helper ? self.offset.left - cop.left : (self.offset.left - cop.left)) + self.sizeDiff.width ),
|
|
712 |
hoset = Math.abs( (self._helper ? self.offset.top - cop.top : (self.offset.top - co.top)) + self.sizeDiff.height );
|
|
771 |
woset = Math.abs( (that._helper ? that.offset.left - cop.left : (that.offset.left - cop.left)) + that.sizeDiff.width );
|
|
772 |
hoset = Math.abs( (that._helper ? that.offset.top - cop.top : (that.offset.top - co.top)) + that.sizeDiff.height );
|
|
713 | 773 |
|
714 |
var isParent = self.containerElement.get(0) == self.element.parent().get(0),
|
|
715 |
isOffsetRelative = /relative|absolute/.test(self.containerElement.css('position'));
|
|
774 |
isParent = that.containerElement.get(0) === that.element.parent().get(0);
|
|
775 |
isOffsetRelative = /relative|absolute/.test(that.containerElement.css("position"));
|
|
716 | 776 |
|
717 |
if(isParent && isOffsetRelative) woset -= self.parentData.left; |
|
777 |
if(isParent && isOffsetRelative) { |
|
778 |
woset -= that.parentData.left; |
|
779 |
} |
|
718 | 780 |
|
719 |
if (woset + self.size.width >= self.parentData.width) { |
|
720 |
self.size.width = self.parentData.width - woset; |
|
721 |
if (pRatio) self.size.height = self.size.width / self.aspectRatio; |
|
781 |
if (woset + that.size.width >= that.parentData.width) { |
|
782 |
that.size.width = that.parentData.width - woset; |
|
783 |
if (pRatio) { |
|
784 |
that.size.height = that.size.width / that.aspectRatio; |
|
785 |
} |
|
722 | 786 |
} |
723 | 787 |
|
724 |
if (hoset + self.size.height >= self.parentData.height) { |
|
725 |
self.size.height = self.parentData.height - hoset; |
|
726 |
if (pRatio) self.size.width = self.size.height * self.aspectRatio; |
|
788 |
if (hoset + that.size.height >= that.parentData.height) { |
|
789 |
that.size.height = that.parentData.height - hoset; |
|
790 |
if (pRatio) { |
|
791 |
that.size.width = that.size.height * that.aspectRatio; |
|
792 |
} |
|
727 | 793 |
} |
728 | 794 |
}, |
729 | 795 |
|
730 |
stop: function(event, ui){ |
|
731 |
var self = $(this).data("resizable"), o = self.options, cp = self.position, |
|
732 |
co = self.containerOffset, cop = self.containerPosition, ce = self.containerElement; |
|
733 |
|
|
734 |
var helper = $(self.helper), ho = helper.offset(), w = helper.outerWidth() - self.sizeDiff.width, h = helper.outerHeight() - self.sizeDiff.height; |
|
735 |
|
|
736 |
if (self._helper && !o.animate && (/relative/).test(ce.css('position'))) |
|
796 |
stop: function(){ |
|
797 |
var that = $(this).data("ui-resizable"), |
|
798 |
o = that.options, |
|
799 |
co = that.containerOffset, |
|
800 |
cop = that.containerPosition, |
|
801 |
ce = that.containerElement, |
|
802 |
helper = $(that.helper), |
|
803 |
ho = helper.offset(), |
|
804 |
w = helper.outerWidth() - that.sizeDiff.width, |
|
805 |
h = helper.outerHeight() - that.sizeDiff.height; |
|
806 |
|
|
807 |
if (that._helper && !o.animate && (/relative/).test(ce.css("position"))) { |
|
737 | 808 |
$(this).css({ left: ho.left - cop.left - co.left, width: w, height: h }); |
809 |
} |
|
738 | 810 |
|
739 |
if (self._helper && !o.animate && (/static/).test(ce.css('position')))
|
|
811 |
if (that._helper && !o.animate && (/static/).test(ce.css("position"))) {
|
|
740 | 812 |
$(this).css({ left: ho.left - cop.left - co.left, width: w, height: h }); |
813 |
} |
|
814 |
|
|
815 |
} |
|
816 |
}); |
|
817 |
|
|
818 |
$.ui.plugin.add("resizable", "alsoResize", { |
|
819 |
|
|
820 |
start: function () { |
|
821 |
var that = $(this).data("ui-resizable"), |
|
822 |
o = that.options, |
|
823 |
_store = function (exp) { |
|
824 |
$(exp).each(function() { |
|
825 |
var el = $(this); |
|
826 |
el.data("ui-resizable-alsoresize", { |
|
827 |
width: parseInt(el.width(), 10), height: parseInt(el.height(), 10), |
|
828 |
left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10) |
|
829 |
}); |
|
830 |
}); |
|
831 |
}; |
|
832 |
|
|
833 |
if (typeof(o.alsoResize) === "object" && !o.alsoResize.parentNode) { |
|
834 |
if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); } |
|
835 |
else { $.each(o.alsoResize, function (exp) { _store(exp); }); } |
|
836 |
}else{ |
|
837 |
_store(o.alsoResize); |
|
838 |
} |
|
839 |
}, |
|
840 |
|
|
841 |
resize: function (event, ui) { |
|
842 |
var that = $(this).data("ui-resizable"), |
|
843 |
o = that.options, |
|
844 |
os = that.originalSize, |
|
845 |
op = that.originalPosition, |
|
846 |
delta = { |
|
847 |
height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0, |
|
848 |
top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0 |
|
849 |
}, |
|
850 |
|
|
851 |
_alsoResize = function (exp, c) { |
|
852 |
$(exp).each(function() { |
|
853 |
var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {}, |
|
854 |
css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ["width", "height"] : ["width", "height", "top", "left"]; |
|
855 |
|
|
856 |
$.each(css, function (i, prop) { |
|
857 |
var sum = (start[prop]||0) + (delta[prop]||0); |
|
858 |
if (sum && sum >= 0) { |
|
859 |
style[prop] = sum || null; |
|
860 |
} |
|
861 |
}); |
|
862 |
|
|
863 |
el.css(style); |
|
864 |
}); |
|
865 |
}; |
|
741 | 866 |
|
867 |
if (typeof(o.alsoResize) === "object" && !o.alsoResize.nodeType) { |
|
868 |
$.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); }); |
|
869 |
}else{ |
|
870 |
_alsoResize(o.alsoResize); |
|
871 |
} |
|
872 |
}, |
|
873 |
|
|
874 |
stop: function () { |
|
875 |
$(this).removeData("resizable-alsoresize"); |
|
742 | 876 |
} |
743 | 877 |
}); |
744 | 878 |
|
745 | 879 |
$.ui.plugin.add("resizable", "ghost", { |
746 | 880 |
|
747 |
start: function(event, ui) {
|
|
881 |
start: function() { |
|
748 | 882 |
|
749 |
var self = $(this).data("resizable"), o = self.options, cs = self.size;
|
|
883 |
var that = $(this).data("ui-resizable"), o = that.options, cs = that.size;
|
|
750 | 884 |
|
751 |
self.ghost = self.originalElement.clone();
|
|
752 |
self.ghost
|
|
753 |
.css({ opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
|
|
754 |
.addClass('ui-resizable-ghost')
|
|
755 |
.addClass(typeof o.ghost == 'string' ? o.ghost : '');
|
|
885 |
that.ghost = that.originalElement.clone();
|
|
886 |
that.ghost
|
|
887 |
.css({ opacity: 0.25, display: "block", position: "relative", height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
|
|
888 |
.addClass("ui-resizable-ghost")
|
|
889 |
.addClass(typeof o.ghost === "string" ? o.ghost : "");
|
|
756 | 890 |
|
757 |
self.ghost.appendTo(self.helper);
|
|
891 |
that.ghost.appendTo(that.helper);
|
|
758 | 892 |
|
759 | 893 |
}, |
760 | 894 |
|
761 |
resize: function(event, ui){ |
|
762 |
var self = $(this).data("resizable"), o = self.options; |
|
763 |
if (self.ghost) self.ghost.css({ position: 'relative', height: self.size.height, width: self.size.width }); |
|
895 |
resize: function(){ |
|
896 |
var that = $(this).data("ui-resizable"); |
|
897 |
if (that.ghost) { |
|
898 |
that.ghost.css({ position: "relative", height: that.size.height, width: that.size.width }); |
|
899 |
} |
|
764 | 900 |
}, |
765 | 901 |
|
766 |
stop: function(event, ui){ |
|
767 |
var self = $(this).data("resizable"), o = self.options; |
|
768 |
if (self.ghost && self.helper) self.helper.get(0).removeChild(self.ghost.get(0)); |
|
902 |
stop: function() { |
|
903 |
var that = $(this).data("ui-resizable"); |
|
904 |
if (that.ghost && that.helper) { |
|
905 |
that.helper.get(0).removeChild(that.ghost.get(0)); |
|
906 |
} |
|
769 | 907 |
} |
770 | 908 |
|
771 | 909 |
}); |
772 | 910 |
|
773 | 911 |
$.ui.plugin.add("resizable", "grid", { |
774 | 912 |
|
775 |
resize: function(event, ui) { |
|
776 |
var self = $(this).data("resizable"), o = self.options, cs = self.size, os = self.originalSize, op = self.originalPosition, a = self.axis, ratio = o._aspectRatio || event.shiftKey; |
|
777 |
o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid; |
|
778 |
var ox = Math.round((cs.width - os.width) / (o.grid[0]||1)) * (o.grid[0]||1), oy = Math.round((cs.height - os.height) / (o.grid[1]||1)) * (o.grid[1]||1); |
|
779 |
|
|
780 |
if (/^(se|s|e)$/.test(a)) { |
|
781 |
self.size.width = os.width + ox; |
|
782 |
self.size.height = os.height + oy; |
|
913 |
resize: function() { |
|
914 |
var that = $(this).data("ui-resizable"), |
|
915 |
o = that.options, |
|
916 |
cs = that.size, |
|
917 |
os = that.originalSize, |
|
918 |
op = that.originalPosition, |
|
919 |
a = that.axis, |
|
920 |
grid = typeof o.grid === "number" ? [o.grid, o.grid] : o.grid, |
|
921 |
gridX = (grid[0]||1), |
|
922 |
gridY = (grid[1]||1), |
|
923 |
ox = Math.round((cs.width - os.width) / gridX) * gridX, |
|
924 |
oy = Math.round((cs.height - os.height) / gridY) * gridY, |
|
925 |
newWidth = os.width + ox, |
|
926 |
newHeight = os.height + oy, |
|
927 |
isMaxWidth = o.maxWidth && (o.maxWidth < newWidth), |
|
928 |
isMaxHeight = o.maxHeight && (o.maxHeight < newHeight), |
|
929 |
isMinWidth = o.minWidth && (o.minWidth > newWidth), |
|
930 |
isMinHeight = o.minHeight && (o.minHeight > newHeight); |
|
931 |
|
|
932 |
o.grid = grid; |
|
933 |
|
|
934 |
if (isMinWidth) { |
|
935 |
newWidth = newWidth + gridX; |
|
783 | 936 |
} |
784 |
else if (/^(ne)$/.test(a)) { |
|
785 |
self.size.width = os.width + ox; |
|
786 |
self.size.height = os.height + oy; |
|
787 |
self.position.top = op.top - oy; |
|
937 |
if (isMinHeight) { |
|
938 |
newHeight = newHeight + gridY; |
|
788 | 939 |
} |
789 |
else if (/^(sw)$/.test(a)) { |
|
790 |
self.size.width = os.width + ox; |
|
791 |
self.size.height = os.height + oy; |
|
792 |
self.position.left = op.left - ox; |
|
940 |
if (isMaxWidth) { |
|
941 |
newWidth = newWidth - gridX; |
|
793 | 942 |
} |
794 |
else { |
|
795 |
self.size.width = os.width + ox; |
|
796 |
self.size.height = os.height + oy; |
|
797 |
self.position.top = op.top - oy; |
|
798 |
self.position.left = op.left - ox; |
|
943 |
if (isMaxHeight) { |
|
944 |
newHeight = newHeight - gridY; |
|
945 |
} |
|
946 |
|
|
947 |
if (/^(se|s|e)$/.test(a)) { |
|
948 |
that.size.width = newWidth; |
|
949 |
that.size.height = newHeight; |
|
950 |
} else if (/^(ne)$/.test(a)) { |
|
951 |
that.size.width = newWidth; |
|
952 |
that.size.height = newHeight; |
|
953 |
that.position.top = op.top - oy; |
|
954 |
} else if (/^(sw)$/.test(a)) { |
|
955 |
that.size.width = newWidth; |
|
956 |
that.size.height = newHeight; |
|
957 |
that.position.left = op.left - ox; |
|
958 |
} else { |
|
959 |
that.size.width = newWidth; |
|
960 |
that.size.height = newHeight; |
|
961 |
that.position.top = op.top - oy; |
|
962 |
that.position.left = op.left - ox; |
|
799 | 963 |
} |
800 | 964 |
} |
801 | 965 |
|
802 | 966 |
}); |
803 | 967 |
|
804 |
var num = function(v) { |
|
805 |
return parseInt(v, 10) || 0; |
|
806 |
}; |
|
807 |
|
|
808 |
var isNumber = function(value) { |
|
809 |
return !isNaN(parseInt(value, 10)); |
|
810 |
}; |
|
811 |
|
|
812 | 968 |
})(jQuery); |
Formats disponibles : Unified diff
Weekly update of contrib modules