1 |
503b3f7b
|
Assos Assos
|
|
2 |
|
|
|
3 |
|
|
|
4 |
85ad3d82
|
Assos Assos
|
|
5 |
503b3f7b
|
Assos Assos
|
|
6 |
|
|
|
7 |
85ad3d82
|
Assos Assos
|
|
8 |
|
|
|
9 |
503b3f7b
|
Assos Assos
|
|
10 |
85ad3d82
|
Assos Assos
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
(function( $, undefined ) {
|
17 |
|
|
|
18 |
503b3f7b
|
Assos Assos
|
function num(v) {
|
19 |
|
|
return parseInt(v, 10) || 0;
|
20 |
|
|
}
|
21 |
|
|
|
22 |
|
|
function isNumber(value) {
|
23 |
|
|
return !isNaN(parseInt(value, 10));
|
24 |
|
|
}
|
25 |
|
|
|
26 |
85ad3d82
|
Assos Assos
|
$.widget("ui.resizable", $.ui.mouse, {
|
27 |
503b3f7b
|
Assos Assos
|
version: "1.10.2",
|
28 |
85ad3d82
|
Assos Assos
|
widgetEventPrefix: "resize",
|
29 |
|
|
options: {
|
30 |
|
|
alsoResize: false,
|
31 |
|
|
animate: false,
|
32 |
|
|
animateDuration: "slow",
|
33 |
|
|
animateEasing: "swing",
|
34 |
|
|
aspectRatio: false,
|
35 |
|
|
autoHide: false,
|
36 |
|
|
containment: false,
|
37 |
|
|
ghost: false,
|
38 |
|
|
grid: false,
|
39 |
|
|
handles: "e,s,se",
|
40 |
|
|
helper: false,
|
41 |
|
|
maxHeight: null,
|
42 |
|
|
maxWidth: null,
|
43 |
|
|
minHeight: 10,
|
44 |
|
|
minWidth: 10,
|
45 |
503b3f7b
|
Assos Assos
|
|
46 |
|
|
zIndex: 90,
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
resize: null,
|
50 |
|
|
start: null,
|
51 |
|
|
stop: null
|
52 |
85ad3d82
|
Assos Assos
|
},
|
53 |
|
|
_create: function() {
|
54 |
|
|
|
55 |
503b3f7b
|
Assos Assos
|
var n, i, handle, axis, hname,
|
56 |
|
|
that = this,
|
57 |
|
|
o = this.options;
|
58 |
85ad3d82
|
Assos Assos
|
this.element.addClass("ui-resizable");
|
59 |
|
|
|
60 |
|
|
$.extend(this, {
|
61 |
|
|
_aspectRatio: !!(o.aspectRatio),
|
62 |
|
|
aspectRatio: o.aspectRatio,
|
63 |
|
|
originalElement: this.element,
|
64 |
|
|
_proportionallyResizeElements: [],
|
65 |
503b3f7b
|
Assos Assos
|
_helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
|
66 |
85ad3d82
|
Assos Assos
|
});
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
this.element.wrap(
|
73 |
503b3f7b
|
Assos Assos
|
$("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
|
74 |
|
|
position: this.element.css("position"),
|
75 |
85ad3d82
|
Assos Assos
|
width: this.element.outerWidth(),
|
76 |
|
|
height: this.element.outerHeight(),
|
77 |
503b3f7b
|
Assos Assos
|
top: this.element.css("top"),
|
78 |
|
|
left: this.element.css("left")
|
79 |
85ad3d82
|
Assos Assos
|
})
|
80 |
|
|
);
|
81 |
|
|
|
82 |
|
|
|
83 |
|
|
this.element = this.element.parent().data(
|
84 |
503b3f7b
|
Assos Assos
|
"ui-resizable", this.element.data("ui-resizable")
|
85 |
85ad3d82
|
Assos Assos
|
);
|
86 |
|
|
|
87 |
|
|
this.elementIsWrapper = true;
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
|
91 |
|
|
this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
|
92 |
|
|
|
93 |
|
|
|
94 |
503b3f7b
|
Assos Assos
|
this.originalResizeStyle = this.originalElement.css("resize");
|
95 |
|
|
this.originalElement.css("resize", "none");
|
96 |
85ad3d82
|
Assos Assos
|
|
97 |
|
|
|
98 |
503b3f7b
|
Assos Assos
|
this._proportionallyResizeElements.push(this.originalElement.css({ position: "static", zoom: 1, display: "block" }));
|
99 |
85ad3d82
|
Assos Assos
|
|
100 |
|
|
|
101 |
503b3f7b
|
Assos Assos
|
this.originalElement.css({ margin: this.originalElement.css("margin") });
|
102 |
85ad3d82
|
Assos Assos
|
|
103 |
|
|
|
104 |
|
|
this._proportionallyResize();
|
105 |
|
|
|
106 |
|
|
}
|
107 |
|
|
|
108 |
503b3f7b
|
Assos Assos
|
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 |
|
|
}
|
114 |
85ad3d82
|
Assos Assos
|
|
115 |
503b3f7b
|
Assos Assos
|
n = this.handles.split(",");
|
116 |
|
|
this.handles = {};
|
117 |
85ad3d82
|
Assos Assos
|
|
118 |
503b3f7b
|
Assos Assos
|
for(i = 0; i < n.length; i++) {
|
119 |
85ad3d82
|
Assos Assos
|
|
120 |
503b3f7b
|
Assos Assos
|
handle = $.trim(n[i]);
|
121 |
|
|
hname = "ui-resizable-"+handle;
|
122 |
|
|
axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
|
123 |
85ad3d82
|
Assos Assos
|
|
124 |
503b3f7b
|
Assos Assos
|
|
125 |
|
|
axis.css({ zIndex: o.zIndex });
|
126 |
85ad3d82
|
Assos Assos
|
|
127 |
|
|
|
128 |
503b3f7b
|
Assos Assos
|
if ("se" === handle) {
|
129 |
|
|
axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
|
130 |
|
|
}
|
131 |
85ad3d82
|
Assos Assos
|
|
132 |
|
|
|
133 |
503b3f7b
|
Assos Assos
|
this.handles[handle] = ".ui-resizable-"+handle;
|
134 |
85ad3d82
|
Assos Assos
|
this.element.append(axis);
|
135 |
|
|
}
|
136 |
|
|
|
137 |
|
|
}
|
138 |
|
|
|
139 |
|
|
this._renderAxis = function(target) {
|
140 |
|
|
|
141 |
503b3f7b
|
Assos Assos
|
var i, axis, padPos, padWrapper;
|
142 |
|
|
|
143 |
85ad3d82
|
Assos Assos
|
target = target || this.element;
|
144 |
|
|
|
145 |
503b3f7b
|
Assos Assos
|
for(i in this.handles) {
|
146 |
85ad3d82
|
Assos Assos
|
|
147 |
503b3f7b
|
Assos Assos
|
if(this.handles[i].constructor === String) {
|
148 |
85ad3d82
|
Assos Assos
|
this.handles[i] = $(this.handles[i], this.element).show();
|
149 |
503b3f7b
|
Assos Assos
|
}
|
150 |
85ad3d82
|
Assos Assos
|
|
151 |
|
|
|
152 |
|
|
if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
|
153 |
|
|
|
154 |
503b3f7b
|
Assos Assos
|
axis = $(this.handles[i], this.element);
|
155 |
85ad3d82
|
Assos Assos
|
|
156 |
|
|
|
157 |
|
|
padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
|
158 |
|
|
|
159 |
|
|
|
160 |
503b3f7b
|
Assos Assos
|
padPos = [ "padding",
|
161 |
|
|
/ne|nw|n/.test(i) ? "Top" :
|
162 |
|
|
/se|sw|s/.test(i) ? "Bottom" :
|
163 |
|
|
/^e$/.test(i) ? "Right" : "Left" ].join("");
|
164 |
85ad3d82
|
Assos Assos
|
|
165 |
|
|
target.css(padPos, padWrapper);
|
166 |
|
|
|
167 |
|
|
this._proportionallyResize();
|
168 |
|
|
|
169 |
|
|
}
|
170 |
|
|
|
171 |
|
|
|
172 |
503b3f7b
|
Assos Assos
|
if(!$(this.handles[i]).length) {
|
173 |
85ad3d82
|
Assos Assos
|
continue;
|
174 |
503b3f7b
|
Assos Assos
|
}
|
175 |
85ad3d82
|
Assos Assos
|
}
|
176 |
|
|
};
|
177 |
|
|
|
178 |
|
|
|
179 |
|
|
this._renderAxis(this.element);
|
180 |
|
|
|
181 |
503b3f7b
|
Assos Assos
|
this._handles = $(".ui-resizable-handle", this.element)
|
182 |
85ad3d82
|
Assos Assos
|
.disableSelection();
|
183 |
|
|
|
184 |
|
|
|
185 |
|
|
this._handles.mouseover(function() {
|
186 |
503b3f7b
|
Assos Assos
|
if (!that.resizing) {
|
187 |
|
|
if (this.className) {
|
188 |
|
|
axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
|
189 |
|
|
}
|
190 |
85ad3d82
|
Assos Assos
|
|
191 |
503b3f7b
|
Assos Assos
|
that.axis = axis && axis[1] ? axis[1] : "se";
|
192 |
85ad3d82
|
Assos Assos
|
}
|
193 |
|
|
});
|
194 |
|
|
|
195 |
|
|
|
196 |
|
|
if (o.autoHide) {
|
197 |
|
|
this._handles.hide();
|
198 |
|
|
$(this.element)
|
199 |
|
|
.addClass("ui-resizable-autohide")
|
200 |
503b3f7b
|
Assos Assos
|
.mouseenter(function() {
|
201 |
|
|
if (o.disabled) {
|
202 |
|
|
return;
|
203 |
|
|
}
|
204 |
85ad3d82
|
Assos Assos
|
$(this).removeClass("ui-resizable-autohide");
|
205 |
503b3f7b
|
Assos Assos
|
that._handles.show();
|
206 |
|
|
})
|
207 |
|
|
.mouseleave(function(){
|
208 |
|
|
if (o.disabled) {
|
209 |
|
|
return;
|
210 |
|
|
}
|
211 |
|
|
if (!that.resizing) {
|
212 |
85ad3d82
|
Assos Assos
|
$(this).addClass("ui-resizable-autohide");
|
213 |
503b3f7b
|
Assos Assos
|
that._handles.hide();
|
214 |
85ad3d82
|
Assos Assos
|
}
|
215 |
|
|
});
|
216 |
|
|
}
|
217 |
|
|
|
218 |
|
|
|
219 |
|
|
this._mouseInit();
|
220 |
|
|
|
221 |
|
|
},
|
222 |
|
|
|
223 |
503b3f7b
|
Assos Assos
|
_destroy: function() {
|
224 |
85ad3d82
|
Assos Assos
|
|
225 |
|
|
this._mouseDestroy();
|
226 |
|
|
|
227 |
503b3f7b
|
Assos Assos
|
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 |
|
|
};
|
232 |
85ad3d82
|
Assos Assos
|
|
233 |
|
|
|
234 |
|
|
if (this.elementIsWrapper) {
|
235 |
|
|
_destroy(this.element);
|
236 |
503b3f7b
|
Assos Assos
|
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();
|
245 |
85ad3d82
|
Assos Assos
|
}
|
246 |
|
|
|
247 |
503b3f7b
|
Assos Assos
|
this.originalElement.css("resize", this.originalResizeStyle);
|
248 |
85ad3d82
|
Assos Assos
|
_destroy(this.originalElement);
|
249 |
|
|
|
250 |
|
|
return this;
|
251 |
|
|
},
|
252 |
|
|
|
253 |
|
|
_mouseCapture: function(event) {
|
254 |
503b3f7b
|
Assos Assos
|
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;
|
261 |
85ad3d82
|
Assos Assos
|
}
|
262 |
|
|
}
|
263 |
|
|
|
264 |
503b3f7b
|
Assos Assos
|
return !this.options.disabled && capture;
|
265 |
85ad3d82
|
Assos Assos
|
},
|
266 |
|
|
|
267 |
|
|
_mouseStart: function(event) {
|
268 |
|
|
|
269 |
503b3f7b
|
Assos Assos
|
var curleft, curtop, cursor,
|
270 |
|
|
o = this.options,
|
271 |
|
|
iniPos = this.element.position(),
|
272 |
|
|
el = this.element;
|
273 |
85ad3d82
|
Assos Assos
|
|
274 |
|
|
this.resizing = true;
|
275 |
|
|
|
276 |
|
|
|
277 |
503b3f7b
|
Assos Assos
|
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 });
|
281 |
85ad3d82
|
Assos Assos
|
}
|
282 |
|
|
|
283 |
|
|
this._renderProxy();
|
284 |
|
|
|
285 |
503b3f7b
|
Assos Assos
|
curleft = num(this.helper.css("left"));
|
286 |
|
|
curtop = num(this.helper.css("top"));
|
287 |
85ad3d82
|
Assos Assos
|
|
288 |
|
|
if (o.containment) {
|
289 |
|
|
curleft += $(o.containment).scrollLeft() || 0;
|
290 |
|
|
curtop += $(o.containment).scrollTop() || 0;
|
291 |
|
|
}
|
292 |
|
|
|
293 |
|
|
|
294 |
|
|
this.offset = this.helper.offset();
|
295 |
|
|
this.position = { left: curleft, top: curtop };
|
296 |
|
|
this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
|
297 |
|
|
this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
|
298 |
|
|
this.originalPosition = { left: curleft, top: curtop };
|
299 |
|
|
this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
|
300 |
|
|
this.originalMousePosition = { left: event.pageX, top: event.pageY };
|
301 |
|
|
|
302 |
|
|
|
303 |
503b3f7b
|
Assos Assos
|
this.aspectRatio = (typeof o.aspectRatio === "number") ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
|
304 |
85ad3d82
|
Assos Assos
|
|
305 |
503b3f7b
|
Assos Assos
|
cursor = $(".ui-resizable-" + this.axis).css("cursor");
|
306 |
|
|
$("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
|
307 |
85ad3d82
|
Assos Assos
|
|
308 |
|
|
el.addClass("ui-resizable-resizing");
|
309 |
|
|
this._propagate("start", event);
|
310 |
|
|
return true;
|
311 |
|
|
},
|
312 |
|
|
|
313 |
|
|
_mouseDrag: function(event) {
|
314 |
|
|
|
315 |
|
|
|
316 |
503b3f7b
|
Assos Assos
|
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 |
|
|
}
|
331 |
85ad3d82
|
Assos Assos
|
|
332 |
|
|
|
333 |
503b3f7b
|
Assos Assos
|
data = trigger.apply(this, [event, dx, dy]);
|
334 |
85ad3d82
|
Assos Assos
|
|
335 |
503b3f7b
|
Assos Assos
|
|
336 |
|
|
this._updateVirtualBoundaries(event.shiftKey);
|
337 |
|
|
if (this._aspectRatio || event.shiftKey) {
|
338 |
85ad3d82
|
Assos Assos
|
data = this._updateRatio(data, event);
|
339 |
503b3f7b
|
Assos Assos
|
}
|
340 |
85ad3d82
|
Assos Assos
|
|
341 |
|
|
data = this._respectSize(data, event);
|
342 |
|
|
|
343 |
503b3f7b
|
Assos Assos
|
this._updateCache(data);
|
344 |
|
|
|
345 |
85ad3d82
|
Assos Assos
|
|
346 |
|
|
this._propagate("resize", event);
|
347 |
|
|
|
348 |
503b3f7b
|
Assos Assos
|
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);
|
361 |
85ad3d82
|
Assos Assos
|
|
362 |
503b3f7b
|
Assos Assos
|
if (!this._helper && this._proportionallyResizeElements.length) {
|
363 |
85ad3d82
|
Assos Assos
|
this._proportionallyResize();
|
364 |
503b3f7b
|
Assos Assos
|
}
|
365 |
85ad3d82
|
Assos Assos
|
|
366 |
503b3f7b
|
Assos Assos
|
|
367 |
|
|
if ( ! $.isEmptyObject(props) ) {
|
368 |
|
|
this._trigger("resize", event, this.ui());
|
369 |
|
|
}
|
370 |
85ad3d82
|
Assos Assos
|
|
371 |
|
|
return false;
|
372 |
|
|
},
|
373 |
|
|
|
374 |
|
|
_mouseStop: function(event) {
|
375 |
|
|
|
376 |
|
|
this.resizing = false;
|
377 |
503b3f7b
|
Assos Assos
|
var pr, ista, soffseth, soffsetw, s, left, top,
|
378 |
|
|
o = this.options, that = this;
|
379 |
85ad3d82
|
Assos Assos
|
|
380 |
|
|
if(this._helper) {
|
381 |
|
|
|
382 |
503b3f7b
|
Assos Assos
|
pr = this._proportionallyResizeElements;
|
383 |
|
|
ista = pr.length && (/textarea/i).test(pr[0].nodeName);
|
384 |
|
|
soffseth = ista && $.ui.hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height;
|
385 |
|
|
soffsetw = ista ? 0 : that.sizeDiff.width;
|
386 |
85ad3d82
|
Assos Assos
|
|
387 |
503b3f7b
|
Assos Assos
|
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) {
|
392 |
85ad3d82
|
Assos Assos
|
this.element.css($.extend(s, { top: top, left: left }));
|
393 |
503b3f7b
|
Assos Assos
|
}
|
394 |
85ad3d82
|
Assos Assos
|
|
395 |
503b3f7b
|
Assos Assos
|
that.helper.height(that.size.height);
|
396 |
|
|
that.helper.width(that.size.width);
|
397 |
85ad3d82
|
Assos Assos
|
|
398 |
503b3f7b
|
Assos Assos
|
if (this._helper && !o.animate) {
|
399 |
|
|
this._proportionallyResize();
|
400 |
|
|
}
|
401 |
85ad3d82
|
Assos Assos
|
}
|
402 |
|
|
|
403 |
503b3f7b
|
Assos Assos
|
$("body").css("cursor", "auto");
|
404 |
85ad3d82
|
Assos Assos
|
|
405 |
|
|
this.element.removeClass("ui-resizable-resizing");
|
406 |
|
|
|
407 |
|
|
this._propagate("stop", event);
|
408 |
|
|
|
409 |
503b3f7b
|
Assos Assos
|
if (this._helper) {
|
410 |
|
|
this.helper.remove();
|
411 |
|
|
}
|
412 |
|
|
|
413 |
85ad3d82
|
Assos Assos
|
return false;
|
414 |
|
|
|
415 |
|
|
},
|
416 |
|
|
|
417 |
503b3f7b
|
Assos Assos
|
_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 |
|
|
|
430 |
|
|
|
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 |
|
|
|
452 |
85ad3d82
|
Assos Assos
|
_updateCache: function(data) {
|
453 |
|
|
this.offset = this.helper.offset();
|
454 |
503b3f7b
|
Assos Assos
|
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 |
|
|
}
|
466 |
85ad3d82
|
Assos Assos
|
},
|
467 |
|
|
|
468 |
503b3f7b
|
Assos Assos
|
_updateRatio: function( data ) {
|
469 |
85ad3d82
|
Assos Assos
|
|
470 |
503b3f7b
|
Assos Assos
|
var cpos = this.position,
|
471 |
|
|
csize = this.size,
|
472 |
|
|
a = this.axis;
|
473 |
85ad3d82
|
Assos Assos
|
|
474 |
503b3f7b
|
Assos Assos
|
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 |
|
|
}
|
479 |
85ad3d82
|
Assos Assos
|
|
480 |
503b3f7b
|
Assos Assos
|
if (a === "sw") {
|
481 |
85ad3d82
|
Assos Assos
|
data.left = cpos.left + (csize.width - data.width);
|
482 |
|
|
data.top = null;
|
483 |
|
|
}
|
484 |
503b3f7b
|
Assos Assos
|
if (a === "nw") {
|
485 |
85ad3d82
|
Assos Assos
|
data.top = cpos.top + (csize.height - data.height);
|
486 |
|
|
data.left = cpos.left + (csize.width - data.width);
|
487 |
|
|
}
|
488 |
|
|
|
489 |
|
|
return data;
|
490 |
|
|
},
|
491 |
|
|
|
492 |
503b3f7b
|
Assos Assos
|
_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 |
|
|
}
|
513 |
85ad3d82
|
Assos Assos
|
|
514 |
503b3f7b
|
Assos Assos
|
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 |
|
|
}
|
526 |
85ad3d82
|
Assos Assos
|
|
527 |
|
|
|
528 |
503b3f7b
|
Assos Assos
|
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 |
|
|
}
|
533 |
85ad3d82
|
Assos Assos
|
|
534 |
|
|
return data;
|
535 |
|
|
},
|
536 |
|
|
|
537 |
|
|
_proportionallyResize: function() {
|
538 |
|
|
|
539 |
503b3f7b
|
Assos Assos
|
if (!this._proportionallyResizeElements.length) {
|
540 |
|
|
return;
|
541 |
|
|
}
|
542 |
|
|
|
543 |
|
|
var i, j, borders, paddings, prel,
|
544 |
|
|
element = this.helper || this.element;
|
545 |
85ad3d82
|
Assos Assos
|
|
546 |
503b3f7b
|
Assos Assos
|
for ( i=0; i < this._proportionallyResizeElements.length; i++) {
|
547 |
85ad3d82
|
Assos Assos
|
|
548 |
503b3f7b
|
Assos Assos
|
prel = this._proportionallyResizeElements[i];
|
549 |
85ad3d82
|
Assos Assos
|
|
550 |
|
|
if (!this.borderDif) {
|
551 |
503b3f7b
|
Assos Assos
|
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")];
|
554 |
85ad3d82
|
Assos Assos
|
|
555 |
503b3f7b
|
Assos Assos
|
for ( j = 0; j < borders.length; j++ ) {
|
556 |
|
|
this.borderDif[ j ] = ( parseInt( borders[ j ], 10 ) || 0 ) + ( parseInt( paddings[ j ], 10 ) || 0 );
|
557 |
|
|
}
|
558 |
85ad3d82
|
Assos Assos
|
}
|
559 |
|
|
|
560 |
|
|
prel.css({
|
561 |
|
|
height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
|
562 |
|
|
width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
|
563 |
|
|
});
|
564 |
|
|
|
565 |
503b3f7b
|
Assos Assos
|
}
|
566 |
85ad3d82
|
Assos Assos
|
|
567 |
|
|
},
|
568 |
|
|
|
569 |
|
|
_renderProxy: function() {
|
570 |
|
|
|
571 |
|
|
var el = this.element, o = this.options;
|
572 |
|
|
this.elementOffset = el.offset();
|
573 |
|
|
|
574 |
|
|
if(this._helper) {
|
575 |
|
|
|
576 |
503b3f7b
|
Assos Assos
|
this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
|
577 |
85ad3d82
|
Assos Assos
|
|
578 |
|
|
this.helper.addClass(this._helper).css({
|
579 |
503b3f7b
|
Assos Assos
|
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",
|
584 |
85ad3d82
|
Assos Assos
|
zIndex: ++o.zIndex
|
585 |
|
|
});
|
586 |
|
|
|
587 |
|
|
this.helper
|
588 |
|
|
.appendTo("body")
|
589 |
|
|
.disableSelection();
|
590 |
|
|
|
591 |
|
|
} else {
|
592 |
|
|
this.helper = this.element;
|
593 |
|
|
}
|
594 |
|
|
|
595 |
|
|
},
|
596 |
|
|
|
597 |
|
|
_change: {
|
598 |
503b3f7b
|
Assos Assos
|
e: function(event, dx) {
|
599 |
85ad3d82
|
Assos Assos
|
return { width: this.originalSize.width + dx };
|
600 |
|
|
},
|
601 |
503b3f7b
|
Assos Assos
|
w: function(event, dx) {
|
602 |
|
|
var cs = this.originalSize, sp = this.originalPosition;
|
603 |
85ad3d82
|
Assos Assos
|
return { left: sp.left + dx, width: cs.width - dx };
|
604 |
|
|
},
|
605 |
|
|
n: function(event, dx, dy) {
|
606 |
503b3f7b
|
Assos Assos
|
var cs = this.originalSize, sp = this.originalPosition;
|
607 |
85ad3d82
|
Assos Assos
|
return { top: sp.top + dy, height: cs.height - dy };
|
608 |
|
|
},
|
609 |
|
|
s: function(event, dx, dy) {
|
610 |
|
|
return { height: this.originalSize.height + dy };
|
611 |
|
|
},
|
612 |
|
|
se: function(event, dx, dy) {
|
613 |
|
|
return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
|
614 |
|
|
},
|
615 |
|
|
sw: function(event, dx, dy) {
|
616 |
|
|
return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
|
617 |
|
|
},
|
618 |
|
|
ne: function(event, dx, dy) {
|
619 |
|
|
return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
|
620 |
|
|
},
|
621 |
|
|
nw: function(event, dx, dy) {
|
622 |
|
|
return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
|
623 |
|
|
}
|
624 |
|
|
},
|
625 |
|
|
|
626 |
|
|
_propagate: function(n, event) {
|
627 |
|
|
$.ui.plugin.call(this, n, [event, this.ui()]);
|
628 |
503b3f7b
|
Assos Assos
|
(n !== "resize" && this._trigger(n, event, this.ui()));
|
629 |
85ad3d82
|
Assos Assos
|
},
|
630 |
|
|
|
631 |
|
|
plugins: {},
|
632 |
|
|
|
633 |
|
|
ui: function() {
|
634 |
|
|
return {
|
635 |
|
|
originalElement: this.originalElement,
|
636 |
|
|
element: this.element,
|
637 |
|
|
helper: this.helper,
|
638 |
|
|
position: this.position,
|
639 |
|
|
size: this.size,
|
640 |
|
|
originalSize: this.originalSize,
|
641 |
|
|
originalPosition: this.originalPosition
|
642 |
|
|
};
|
643 |
|
|
}
|
644 |
|
|
|
645 |
|
|
});
|
646 |
|
|
|
647 |
|
|
|
648 |
|
|
|
649 |
|
|
|
650 |
|
|
|
651 |
|
|
$.ui.plugin.add("resizable", "animate", {
|
652 |
|
|
|
653 |
503b3f7b
|
Assos Assos
|
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") ? 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(
|
665 |
85ad3d82
|
Assos Assos
|
$.extend(style, top && left ? { top: top, left: left } : {}), {
|
666 |
|
|
duration: o.animateDuration,
|
667 |
|
|
easing: o.animateEasing,
|
668 |
|
|
step: function() {
|
669 |
|
|
|
670 |
|
|
var data = {
|
671 |
503b3f7b
|
Assos Assos
|
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)
|
675 |
85ad3d82
|
Assos Assos
|
};
|
676 |
|
|
|
677 |
503b3f7b
|
Assos Assos
|
if (pr && pr.length) {
|
678 |
|
|
$(pr[0]).css({ width: data.width, height: data.height });
|
679 |
|
|
}
|
680 |
85ad3d82
|
Assos Assos
|
|
681 |
|
|
|
682 |
503b3f7b
|
Assos Assos
|
that._updateCache(data);
|
683 |
|
|
that._propagate("resize", event);
|
684 |
85ad3d82
|
Assos Assos
|
|
685 |
|
|
}
|
686 |
|
|
}
|
687 |
|
|
);
|
688 |
|
|
}
|
689 |
|
|
|
690 |
|
|
});
|
691 |
|
|
|
692 |
|
|
$.ui.plugin.add("resizable", "containment", {
|
693 |
|
|
|
694 |
503b3f7b
|
Assos Assos
|
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 |
|
|
}
|
705 |
85ad3d82
|
Assos Assos
|
|
706 |
503b3f7b
|
Assos Assos
|
that.containerElement = $(ce);
|
707 |
85ad3d82
|
Assos Assos
|
|
708 |
503b3f7b
|
Assos Assos
|
if (/document/.test(oc) || oc === document) {
|
709 |
|
|
that.containerOffset = { left: 0, top: 0 };
|
710 |
|
|
that.containerPosition = { left: 0, top: 0 };
|
711 |
85ad3d82
|
Assos Assos
|
|
712 |
503b3f7b
|
Assos Assos
|
that.parentData = {
|
713 |
85ad3d82
|
Assos Assos
|
element: $(document), left: 0, top: 0,
|
714 |
|
|
width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
|
715 |
|
|
};
|
716 |
|
|
}
|
717 |
|
|
|
718 |
|
|
|
719 |
|
|
else {
|
720 |
503b3f7b
|
Assos Assos
|
element = $(ce);
|
721 |
|
|
p = [];
|
722 |
85ad3d82
|
Assos Assos
|
$([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
|
723 |
|
|
|
724 |
503b3f7b
|
Assos Assos
|
that.containerOffset = element.offset();
|
725 |
|
|
that.containerPosition = element.position();
|
726 |
|
|
that.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
|
727 |
85ad3d82
|
Assos Assos
|
|
728 |
503b3f7b
|
Assos Assos
|
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);
|
733 |
85ad3d82
|
Assos Assos
|
|
734 |
503b3f7b
|
Assos Assos
|
that.parentData = {
|
735 |
85ad3d82
|
Assos Assos
|
element: ce, left: co.left, top: co.top, width: width, height: height
|
736 |
|
|
};
|
737 |
|
|
}
|
738 |
|
|
},
|
739 |
|
|
|
740 |
503b3f7b
|
Assos Assos
|
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;
|
747 |
85ad3d82
|
Assos Assos
|
|
748 |
503b3f7b
|
Assos Assos
|
if (ce[0] !== document && (/static/).test(ce.css("position"))) {
|
749 |
|
|
cop = co;
|
750 |
|
|
}
|
751 |
85ad3d82
|
Assos Assos
|
|
752 |
503b3f7b
|
Assos Assos
|
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;
|
758 |
85ad3d82
|
Assos Assos
|
}
|
759 |
|
|
|
760 |
503b3f7b
|
Assos Assos
|
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;
|
766 |
85ad3d82
|
Assos Assos
|
}
|
767 |
|
|
|
768 |
503b3f7b
|
Assos Assos
|
that.offset.left = that.parentData.left+that.position.left;
|
769 |
|
|
that.offset.top = that.parentData.top+that.position.top;
|
770 |
85ad3d82
|
Assos Assos
|
|
771 |
503b3f7b
|
Assos Assos
|
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 );
|
773 |
85ad3d82
|
Assos Assos
|
|
774 |
503b3f7b
|
Assos Assos
|
isParent = that.containerElement.get(0) === that.element.parent().get(0);
|
775 |
|
|
isOffsetRelative = /relative|absolute/.test(that.containerElement.css("position"));
|
776 |
85ad3d82
|
Assos Assos
|
|
777 |
503b3f7b
|
Assos Assos
|
if(isParent && isOffsetRelative) {
|
778 |
|
|
woset -= that.parentData.left;
|
779 |
|
|
}
|
780 |
85ad3d82
|
Assos Assos
|
|
781 |
503b3f7b
|
Assos Assos
|
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 |
|
|
}
|
786 |
85ad3d82
|
Assos Assos
|
}
|
787 |
|
|
|
788 |
503b3f7b
|
Assos Assos
|
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 |
|
|
}
|
793 |
85ad3d82
|
Assos Assos
|
}
|
794 |
|
|
},
|
795 |
|
|
|
796 |
503b3f7b
|
Assos Assos
|
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"))) {
|
808 |
85ad3d82
|
Assos Assos
|
$(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
|
809 |
503b3f7b
|
Assos Assos
|
}
|
810 |
85ad3d82
|
Assos Assos
|
|
811 |
503b3f7b
|
Assos Assos
|
if (that._helper && !o.animate && (/static/).test(ce.css("position"))) {
|
812 |
85ad3d82
|
Assos Assos
|
$(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
|
813 |
503b3f7b
|
Assos Assos
|
}
|
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 |
|
|
};
|
866 |
85ad3d82
|
Assos Assos
|
|
867 |
503b3f7b
|
Assos Assos
|
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");
|
876 |
85ad3d82
|
Assos Assos
|
}
|
877 |
|
|
});
|
878 |
|
|
|
879 |
|
|
$.ui.plugin.add("resizable", "ghost", {
|
880 |
|
|
|
881 |
503b3f7b
|
Assos Assos
|
start: function() {
|
882 |
85ad3d82
|
Assos Assos
|
|
883 |
503b3f7b
|
Assos Assos
|
var that = $(this).data("ui-resizable"), o = that.options, cs = that.size;
|
884 |
85ad3d82
|
Assos Assos
|
|
885 |
503b3f7b
|
Assos Assos
|
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 : "");
|
890 |
85ad3d82
|
Assos Assos
|
|
891 |
503b3f7b
|
Assos Assos
|
that.ghost.appendTo(that.helper);
|
892 |
85ad3d82
|
Assos Assos
|
|
893 |
|
|
},
|
894 |
|
|
|
895 |
503b3f7b
|
Assos Assos
|
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 |
|
|
}
|
900 |
85ad3d82
|
Assos Assos
|
},
|
901 |
|
|
|
902 |
503b3f7b
|
Assos Assos
|
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 |
|
|
}
|
907 |
85ad3d82
|
Assos Assos
|
}
|
908 |
|
|
|
909 |
|
|
});
|
910 |
|
|
|
911 |
|
|
$.ui.plugin.add("resizable", "grid", {
|
912 |
|
|
|
913 |
503b3f7b
|
Assos Assos
|
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;
|
936 |
85ad3d82
|
Assos Assos
|
}
|
937 |
503b3f7b
|
Assos Assos
|
if (isMinHeight) {
|
938 |
|
|
newHeight = newHeight + gridY;
|
939 |
85ad3d82
|
Assos Assos
|
}
|
940 |
503b3f7b
|
Assos Assos
|
if (isMaxWidth) {
|
941 |
|
|
newWidth = newWidth - gridX;
|
942 |
85ad3d82
|
Assos Assos
|
}
|
943 |
503b3f7b
|
Assos Assos
|
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;
|
963 |
85ad3d82
|
Assos Assos
|
}
|
964 |
|
|
}
|
965 |
|
|
|
966 |
|
|
});
|
967 |
|
|
|
968 |
|
|
})(jQuery); |