| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 /* 2 * jQuery UI Resizable 1.6 3 * 4 * Copyright (c) 2008 AUTHORS.txt (http://ui.jquery.com/about) 5 * Dual licensed under the MIT (MIT-LICENSE.txt) 6 * and GPL (GPL-LICENSE.txt) licenses. 7 * 8 * http://docs.jquery.com/UI/Resizables 9 * 10 * Depends: 11 * ui.core.js 12 */ 13 (function($) { 14 15 $.widget("ui.resizable", $.extend({}, $.ui.mouse, { 16 17 _init: function() { 18 19 var self = this, o = this.options; 20 21 var elpos = this.element.css('position'); 22 23 this.originalElement = this.element; 24 25 // simulate .ui-resizable { position: relative; } 26 this.element.addClass("ui-resizable").css({ position: /static/.test(elpos) ? 'relative' : elpos }); 27 28 $.extend(o, { 29 _aspectRatio: !!(o.aspectRatio), 30 helper: o.helper || o.ghost || o.animate ? o.helper || 'ui-resizable-helper' : null, 31 knobHandles: o.knobHandles === true ? 'ui-resizable-knob-handle' : o.knobHandles 32 }); 33 34 //Default Theme 35 var aBorder = '1px solid #DEDEDE'; 36 37 o.defaultTheme = { 38 'ui-resizable': { display: 'block' }, 39 'ui-resizable-handle': { position: 'absolute', background: '#F2F2F2', fontSize: '0.1px' }, 40 'ui-resizable-n': { cursor: 'n-resize', height: '4px', left: '0px', right: '0px', borderTop: aBorder }, 41 'ui-resizable-s': { cursor: 's-resize', height: '4px', left: '0px', right: '0px', borderBottom: aBorder }, 42 'ui-resizable-e': { cursor: 'e-resize', width: '4px', top: '0px', bottom: '0px', borderRight: aBorder }, 43 'ui-resizable-w': { cursor: 'w-resize', width: '4px', top: '0px', bottom: '0px', borderLeft: aBorder }, 44 'ui-resizable-se': { cursor: 'se-resize', width: '4px', height: '4px', borderRight: aBorder, borderBottom: aBorder }, 45 'ui-resizable-sw': { cursor: 'sw-resize', width: '4px', height: '4px', borderBottom: aBorder, borderLeft: aBorder }, 46 'ui-resizable-ne': { cursor: 'ne-resize', width: '4px', height: '4px', borderRight: aBorder, borderTop: aBorder }, 47 'ui-resizable-nw': { cursor: 'nw-resize', width: '4px', height: '4px', borderLeft: aBorder, borderTop: aBorder } 48 }; 49 50 o.knobTheme = { 51 'ui-resizable-handle': { background: '#F2F2F2', border: '1px solid #808080', height: '8px', width: '8px' }, 52 'ui-resizable-n': { cursor: 'n-resize', top: '0px', left: '45%' }, 53 'ui-resizable-s': { cursor: 's-resize', bottom: '0px', left: '45%' }, 54 'ui-resizable-e': { cursor: 'e-resize', right: '0px', top: '45%' }, 55 'ui-resizable-w': { cursor: 'w-resize', left: '0px', top: '45%' }, 56 'ui-resizable-se': { cursor: 'se-resize', right: '0px', bottom: '0px' }, 57 'ui-resizable-sw': { cursor: 'sw-resize', left: '0px', bottom: '0px' }, 58 'ui-resizable-nw': { cursor: 'nw-resize', left: '0px', top: '0px' }, 59 'ui-resizable-ne': { cursor: 'ne-resize', right: '0px', top: '0px' } 60 }; 61 62 o._nodeName = this.element[0].nodeName; 63 64 //Wrap the element if it cannot hold child nodes 65 if(o._nodeName.match(/canvas|textarea|input|select|button|img/i)) { 66 var el = this.element; 67 68 //Opera fixing relative position 69 if (/relative/.test(el.css('position')) && $.browser.opera) 70 el.css({ position: 'relative', top: 'auto', left: 'auto' }); 71 72 //Create a wrapper element and set the wrapper to the new current internal element 73 el.wrap( 74 $('<div class="ui-wrapper" style="overflow: hidden;"></div>').css( { 75 position: el.css('position'), 76 width: el.outerWidth(), 77 height: el.outerHeight(), 78 top: el.css('top'), 79 left: el.css('left') 80 }) 81 ); 82 83 var oel = this.element; this.element = this.element.parent(); 84 85 // store instance on wrapper 86 this.element.data('resizable', this); 87 88 //Move margins to the wrapper 89 this.element.css({ marginLeft: oel.css("marginLeft"), marginTop: oel.css("marginTop"), 90 marginRight: oel.css("marginRight"), marginBottom: oel.css("marginBottom") 91 }); 92 93 oel.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0}); 94 95 //Prevent Safari textarea resize 96 if ($.browser.safari && o.preventDefault) oel.css('resize', 'none'); 97 98 o.proportionallyResize = oel.css({ position: 'static', zoom: 1, display: 'block' }); 99 100 // avoid IE jump 101 this.element.css({ margin: oel.css('margin') }); 102 103 // fix handlers offset 104 this._proportionallyResize(); 105 } 106 107 if(!o.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' }; 108 if(o.handles.constructor == String) { 109 110 o.zIndex = o.zIndex || 1000; 111 112 if(o.handles == 'all') o.handles = 'n,e,s,w,se,sw,ne,nw'; 113 114 var n = o.handles.split(","); o.handles = {}; 115 116 // insertions are applied when don't have theme loaded 117 var insertionsDefault = { 118 handle: 'position: absolute; display: none; overflow:hidden;', 119 n: 'top: 0pt; width:100%;', 120 e: 'right: 0pt; height:100%;', 121 s: 'bottom: 0pt; width:100%;', 122 w: 'left: 0pt; height:100%;', 123 se: 'bottom: 0pt; right: 0px;', 124 sw: 'bottom: 0pt; left: 0px;', 125 ne: 'top: 0pt; right: 0px;', 126 nw: 'top: 0pt; left: 0px;' 127 }; 128 129 for(var i = 0; i < n.length; i++) { 130 var handle = $.trim(n[i]), dt = o.defaultTheme, hname = 'ui-resizable-'+handle, loadDefault = !$.ui.css(hname) && !o.knobHandles, userKnobClass = $.ui.css('ui-resizable-knob-handle'), 131 allDefTheme = $.extend(dt[hname], dt['ui-resizable-handle']), allKnobTheme = $.extend(o.knobTheme[hname], !userKnobClass ? o.knobTheme['ui-resizable-handle'] : {}); 132 133 // increase zIndex of sw, se, ne, nw axis 134 var applyZIndex = /sw|se|ne|nw/.test(handle) ? { zIndex: ++o.zIndex } : {}; 135 136 var defCss = (loadDefault ? insertionsDefault[handle] : ''), 137 axis = $(['<div class="ui-resizable-handle ', hname, '" style="', defCss, insertionsDefault.handle, '"></div>'].join('')).css( applyZIndex ); 138 o.handles[handle] = '.ui-resizable-'+handle; 139 140 this.element.append( 141 //Theme detection, if not loaded, load o.defaultTheme 142 axis.css( loadDefault ? allDefTheme : {} ) 143 // Load the knobHandle css, fix width, height, top, left... 144 .css( o.knobHandles ? allKnobTheme : {} ).addClass(o.knobHandles ? 'ui-resizable-knob-handle' : '').addClass(o.knobHandles) 145 ); 146 } 147 148 if (o.knobHandles) this.element.addClass('ui-resizable-knob').css( !$.ui.css('ui-resizable-knob') ? { /*border: '1px #fff dashed'*/ } : {} ); 149 } 150 151 this._renderAxis = function(target) { 152 target = target || this.element; 153 154 for(var i in o.handles) { 155 if(o.handles[i].constructor == String) 156 o.handles[i] = $(o.handles[i], this.element).show(); 157 158 if (o.transparent) 159 o.handles[i].css({opacity:0}); 160 161 //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls) 162 if (this.element.is('.ui-wrapper') && 163 o._nodeName.match(/textarea|input|select|button/i)) { 164 165 var axis = $(o.handles[i], this.element), padWrapper = 0; 166 167 //Checking the correct pad and border 168 padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth(); 169 170 //The padding type i have to apply... 171 var padPos = [ 'padding', 172 /ne|nw|n/.test(i) ? 'Top' : 173 /se|sw|s/.test(i) ? 'Bottom' : 174 /^e$/.test(i) ? 'Right' : 'Left' ].join(""); 175 176 if (!o.transparent) 177 target.css(padPos, padWrapper); 178 179 this._proportionallyResize(); 180 } 181 if(!$(o.handles[i]).length) continue; 182 } 183 }; 184 185 this._renderAxis(this.element); 186 o._handles = $('.ui-resizable-handle', self.element); 187 188 if (o.disableSelection) 189 o._handles.disableSelection(); 190 191 //Matching axis name 192 o._handles.mouseover(function() { 193 if (!o.resizing) { 194 if (this.className) 195 var axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i); 196 //Axis, default = se 197 self.axis = o.axis = axis && axis[1] ? axis[1] : 'se'; 198 } 199 }); 200 201 //If we want to auto hide the elements 202 if (o.autoHide) { 203 o._handles.hide(); 204 $(self.element).addClass("ui-resizable-autohide").hover(function() { 205 $(this).removeClass("ui-resizable-autohide"); 206 o._handles.show(); 207 }, 208 function(){ 209 if (!o.resizing) { 210 $(this).addClass("ui-resizable-autohide"); 211 o._handles.hide(); 212 } 213 }); 214 } 215 216 this._mouseInit(); 217 }, 218 219 destroy: function() { 220 var el = this.element, wrapped = el.children(".ui-resizable").get(0); 221 222 this._mouseDestroy(); 223 224 var _destroy = function(exp) { 225 $(exp).removeClass("ui-resizable ui-resizable-disabled") 226 .removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove(); 227 }; 228 229 _destroy(el); 230 231 if (el.is('.ui-wrapper') && wrapped) { 232 el.parent().append( 233 $(wrapped).css({ 234 position: el.css('position'), 235 width: el.outerWidth(), 236 height: el.outerHeight(), 237 top: el.css('top'), 238 left: el.css('left') 239 }) 240 ).end().remove(); 241 242 _destroy(wrapped); 243 } 244 }, 245 246 _mouseCapture: function(event) { 247 248 if(this.options.disabled) return false; 249 250 var handle = false; 251 for(var i in this.options.handles) { 252 if($(this.options.handles[i])[0] == event.target) handle = true; 253 } 254 if (!handle) return false; 255 256 return true; 257 258 }, 259 260 _mouseStart: function(event) { 261 262 var o = this.options, iniPos = this.element.position(), el = this.element, 263 ie6 = $.browser.msie && $.browser.version < 7; 264 o.resizing = true; 265 o.documentScroll = { top: $(document).scrollTop(), left: $(document).scrollLeft() }; 266 267 // bugfix #1749 268 if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) { 269 270 // sOffset decides if document scrollOffset will be added to the top/left of the resizable element 271 var sOffset = $.browser.msie && !o.containment && (/absolute/).test(el.css('position')) && !(/relative/).test(el.parent().css('position')); 272 var dscrollt = sOffset ? this.documentScroll.top : 0, dscrolll = sOffset ? this.documentScroll.left : 0; 273 274 el.css({ position: 'absolute', top: (iniPos.top + dscrollt), left: (iniPos.left + dscrolll) }); 275 } 276 277 //Opera fixing relative position 278 if ($.browser.opera && (/relative/).test(el.css('position'))) 279 el.css({ position: 'relative', top: 'auto', left: 'auto' }); 280 281 this._renderProxy(); 282 283 var curleft = num(this.helper.css('left')), curtop = num(this.helper.css('top')); 284 285 if (o.containment) { 286 curleft += $(o.containment).scrollLeft()||0; 287 curtop += $(o.containment).scrollTop()||0; 288 } 289 290 //Store needed variables 291 this.offset = this.helper.offset(); 292 this.position = { left: curleft, top: curtop }; 293 this.size = o.helper || ie6 ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() }; 294 this.originalSize = o.helper || ie6 ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() }; 295 this.originalPosition = { left: curleft, top: curtop }; 296 this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() }; 297 this.originalMousePosition = { left: event.pageX, top: event.pageY }; 298 299 //Aspect Ratio 300 o.aspectRatio = (typeof o.aspectRatio == 'number') ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height)||1); 301 302 if (o.preserveCursor) { 303 var cursor = $('.ui-resizable-' + this.axis).css('cursor'); 304 $('body').css('cursor', cursor == 'auto' ? this.axis + '-resize' : cursor); 305 } 306 307 this._propagate("start", event); 308 return true; 309 }, 310 311 _mouseDrag: function(event) { 312 313 //Increase performance, avoid regex 314 var el = this.helper, o = this.options, props = {}, 315 self = this, smp = this.originalMousePosition, a = this.axis; 316 317 var dx = (event.pageX-smp.left)||0, dy = (event.pageY-smp.top)||0; 318 var trigger = this._change[a]; 319 if (!trigger) return false; 320 321 // Calculate the attrs that will be change 322 var data = trigger.apply(this, [event, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff; 323 324 if (o._aspectRatio || event.shiftKey) 325 data = this._updateRatio(data, event); 326 327 data = this._respectSize(data, event); 328 329 // plugins callbacks need to be called first 330 this._propagate("resize", event); 331 332 el.css({ 333 top: this.position.top + "px", left: this.position.left + "px", 334 width: this.size.width + "px", height: this.size.height + "px" 335 }); 336 337 if (!o.helper && o.proportionallyResize) 338 this._proportionallyResize(); 339 340 this._updateCache(data); 341 342 // calling the user callback at the end 343 this.element.triggerHandler("resize", [event, this.ui()], this.options["resize"]); 344 345 return false; 346 }, 347 348 _mouseStop: function(event) { 349 350 this.options.resizing = false; 351 var o = this.options, self = this; 352 353 if(o.helper) { 354 var pr = o.proportionallyResize, ista = pr && (/textarea/i).test(pr.get(0).nodeName), 355 soffseth = ista && $.ui.hasScroll(pr.get(0), 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height, 356 soffsetw = ista ? 0 : self.sizeDiff.width; 357 358 var s = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) }, 359 left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null, 360 top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null; 361 362 if (!o.animate) 363 this.element.css($.extend(s, { top: top, left: left })); 364 365 if (o.helper && !o.animate) this._proportionallyResize(); 366 } 367 368 if (o.preserveCursor) 369 $('body').css('cursor', 'auto'); 370 371 this._propagate("stop", event); 372 373 if (o.helper) this.helper.remove(); 374 375 return false; 376 }, 377 378 _updateCache: function(data) { 379 var o = this.options; 380 this.offset = this.helper.offset(); 381 if (data.left) this.position.left = data.left; 382 if (data.top) this.position.top = data.top; 383 if (data.height) this.size.height = data.height; 384 if (data.width) this.size.width = data.width; 385 }, 386 387 _updateRatio: function(data, event) { 388 389 var o = this.options, cpos = this.position, csize = this.size, a = this.axis; 390 391 if (data.height) data.width = (csize.height * o.aspectRatio); 392 else if (data.width) data.height = (csize.width / o.aspectRatio); 393 394 if (a == 'sw') { 395 data.left = cpos.left + (csize.width - data.width); 396 data.top = null; 397 } 398 if (a == 'nw') { 399 data.top = cpos.top + (csize.height - data.height); 400 data.left = cpos.left + (csize.width - data.width); 401 } 402 403 return data; 404 }, 405 406 _respectSize: function(data, event) { 407 408 var el = this.helper, o = this.options, pRatio = o._aspectRatio || event.shiftKey, a = this.axis, 409 ismaxw = data.width && o.maxWidth && o.maxWidth < data.width, ismaxh = data.height && o.maxHeight && o.maxHeight < data.height, 410 isminw = data.width && o.minWidth && o.minWidth > data.width, isminh = data.height && o.minHeight && o.minHeight > data.height; 411 412 if (isminw) data.width = o.minWidth; 413 if (isminh) data.height = o.minHeight; 414 if (ismaxw) data.width = o.maxWidth; 415 if (ismaxh) data.height = o.maxHeight; 416 417 var dw = this.originalPosition.left + this.originalSize.width, dh = this.position.top + this.size.height; 418 var cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a); 419 420 if (isminw && cw) data.left = dw - o.minWidth; 421 if (ismaxw && cw) data.left = dw - o.maxWidth; 422 if (isminh && ch) data.top = dh - o.minHeight; 423 if (ismaxh && ch) data.top = dh - o.maxHeight; 424 425 // fixing jump error on top/left - bug #2330 426 var isNotwh = !data.width && !data.height; 427 if (isNotwh && !data.left && data.top) data.top = null; 428 else if (isNotwh && !data.top && data.left) data.left = null; 429 430 return data; 431 }, 432 433 _proportionallyResize: function() { 434 var o = this.options; 435 if (!o.proportionallyResize) return; 436 var prel = o.proportionallyResize, el = this.helper || this.element; 437 438 if (!o.borderDif) { 439 var b = [prel.css('borderTopWidth'), prel.css('borderRightWidth'), prel.css('borderBottomWidth'), prel.css('borderLeftWidth')], 440 p = [prel.css('paddingTop'), prel.css('paddingRight'), prel.css('paddingBottom'), prel.css('paddingLeft')]; 441 442 o.borderDif = $.map(b, function(v, i) { 443 var border = parseInt(v,10)||0, padding = parseInt(p[i],10)||0; 444 return border + padding; 445 }); 446 } 447 prel.css({ 448 height: (el.height() - o.borderDif[0] - o.borderDif[2]) + "px", 449 width: (el.width() - o.borderDif[1] - o.borderDif[3]) + "px" 450 }); 451 }, 452 453 _renderProxy: function() { 454 var el = this.element, o = this.options; 455 this.elementOffset = el.offset(); 456 457 if(o.helper) { 458 this.helper = this.helper || $('<div style="overflow:hidden;"></div>'); 459 460 // fix ie6 offset 461 var ie6 = $.browser.msie && $.browser.version < 7, ie6offset = (ie6 ? 1 : 0), 462 pxyoffset = ( ie6 ? 2 : -1 ); 463 464 this.helper.addClass(o.helper).css({ 465 width: el.outerWidth() + pxyoffset, 466 height: el.outerHeight() + pxyoffset, 467 position: 'absolute', 468 left: this.elementOffset.left - ie6offset +'px', 469 top: this.elementOffset.top - ie6offset +'px', 470 zIndex: ++o.zIndex 471 }); 472 473 this.helper.appendTo("body"); 474 475 if (o.disableSelection) 476 this.helper.disableSelection(); 477 478 } else { 479 this.helper = el; 480 } 481 }, 482 483 _change: { 484 e: function(event, dx, dy) { 485 return { width: this.originalSize.width + dx }; 486 }, 487 w: function(event, dx, dy) { 488 var o = this.options, cs = this.originalSize, sp = this.originalPosition; 489 return { left: sp.left + dx, width: cs.width - dx }; 490 }, 491 n: function(event, dx, dy) { 492 var o = this.options, cs = this.originalSize, sp = this.originalPosition; 493 return { top: sp.top + dy, height: cs.height - dy }; 494 }, 495 s: function(event, dx, dy) { 496 return { height: this.originalSize.height + dy }; 497 }, 498 se: function(event, dx, dy) { 499 return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy])); 500 }, 501 sw: function(event, dx, dy) { 502 return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy])); 503 }, 504 ne: function(event, dx, dy) { 505 return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy])); 506 }, 507 nw: function(event, dx, dy) { 508 return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy])); 509 } 510 }, 511 512 _propagate: function(n, event) { 513 $.ui.plugin.call(this, n, [event, this.ui()]); 514 if (n != "resize") this.element.triggerHandler(["resize", n].join(""), [event, this.ui()], this.options[n]); 515 }, 516 517 plugins: {}, 518 519 ui: function() { 520 return { 521 originalElement: this.originalElement, 522 element: this.element, 523 helper: this.helper, 524 position: this.position, 525 size: this.size, 526 options: this.options, 527 originalSize: this.originalSize, 528 originalPosition: this.originalPosition 529 }; 530 } 531 532 })); 533 534 $.extend($.ui.resizable, { 535 version: "1.6", 536 defaults: { 537 alsoResize: false, 538 animate: false, 539 animateDuration: "slow", 540 animateEasing: "swing", 541 aspectRatio: false, 542 autoHide: false, 543 cancel: ":input", 544 containment: false, 545 disableSelection: true, 546 distance: 1, 547 delay: 0, 548 ghost: false, 549 grid: false, 550 knobHandles: false, 551 maxHeight: null, 552 maxWidth: null, 553 minHeight: 10, 554 minWidth: 10, 555 preserveCursor: true, 556 preventDefault: true, 557 proportionallyResize: false, 558 transparent: false 559 } 560 }); 561 562 /* 563 * Resizable Extensions 564 */ 565 566 $.ui.plugin.add("resizable", "alsoResize", { 567 568 start: function(event, ui) { 569 var o = ui.options, self = $(this).data("resizable"), 570 571 _store = function(exp) { 572 $(exp).each(function() { 573 $(this).data("resizable-alsoresize", { 574 width: parseInt($(this).width(), 10), height: parseInt($(this).height(), 10), 575 left: parseInt($(this).css('left'), 10), top: parseInt($(this).css('top'), 10) 576 }); 577 }); 578 }; 579 580 if (typeof(o.alsoResize) == 'object' && !o.alsoResize.parentNode) { 581 if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); } 582 else { $.each(o.alsoResize, function(exp, c) { _store(exp); }); } 583 }else{ 584 _store(o.alsoResize); 585 } 586 }, 587 588 resize: function(event, ui){ 589 var o = ui.options, self = $(this).data("resizable"), os = self.originalSize, op = self.originalPosition; 590 591 var delta = { 592 height: (self.size.height - os.height) || 0, width: (self.size.width - os.width) || 0, 593 top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0 594 }, 595 596 _alsoResize = function(exp, c) { 597 $(exp).each(function() { 598 var start = $(this).data("resizable-alsoresize"), style = {}, css = c && c.length ? c : ['width', 'height', 'top', 'left']; 599 600 $.each(css || ['width', 'height', 'top', 'left'], function(i, prop) { 601 var sum = (start[prop]||0) + (delta[prop]||0); 602 if (sum && sum >= 0) 603 style[prop] = sum || null; 604 }); 605 $(this).css(style); 606 }); 607 }; 608 609 if (typeof(o.alsoResize) == 'object' && !o.alsoResize.parentNode) { 610 $.each(o.alsoResize, function(exp, c) { _alsoResize(exp, c); }); 611 }else{ 612 _alsoResize(o.alsoResize); 613 } 614 }, 615 616 stop: function(event, ui){ 617 $(this).removeData("resizable-alsoresize-start"); 618 } 619 }); 620 621 $.ui.plugin.add("resizable", "animate", { 622 623 stop: function(event, ui) { 624 var o = ui.options, self = $(this).data("resizable"); 625 626 var pr = o.proportionallyResize, ista = pr && (/textarea/i).test(pr.get(0).nodeName), 627 soffseth = ista && $.ui.hasScroll(pr.get(0), 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height, 628 soffsetw = ista ? 0 : self.sizeDiff.width; 629 630 var style = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) }, 631 left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null, 632 top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null; 633 634 self.element.animate( 635 $.extend(style, top && left ? { top: top, left: left } : {}), { 636 duration: o.animateDuration, 637 easing: o.animateEasing, 638 step: function() { 639 640 var data = { 641 width: parseInt(self.element.css('width'), 10), 642 height: parseInt(self.element.css('height'), 10), 643 top: parseInt(self.element.css('top'), 10), 644 left: parseInt(self.element.css('left'), 10) 645 }; 646 647 if (pr) pr.css({ width: data.width, height: data.height }); 648 649 // propagating resize, and updating values for each animation step 650 self._updateCache(data); 651 self._propagate("animate", event); 652 653 } 654 } 655 ); 656 } 657 658 }); 659 660 $.ui.plugin.add("resizable", "containment", { 661 662 start: function(event, ui) { 663 var o = ui.options, self = $(this).data("resizable"), el = self.element; 664 var oc = o.containment, ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc; 665 if (!ce) return; 666 667 self.containerElement = $(ce); 668 669 if (/document/.test(oc) || oc == document) { 670 self.containerOffset = { left: 0, top: 0 }; 671 self.containerPosition = { left: 0, top: 0 }; 672 673 self.parentData = { 674 element: $(document), left: 0, top: 0, 675 width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight 676 }; 677 } 678 679 // i'm a node, so compute top, left, right, bottom 680 else{ 681 var element = $(ce), p = []; 682 $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); }); 683 684 self.containerOffset = element.offset(); 685 self.containerPosition = element.position(); 686 self.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) }; 687 688 var co = self.containerOffset, ch = self.containerSize.height, cw = self.containerSize.width, 689 width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch); 690 691 self.parentData = { 692 element: ce, left: co.left, top: co.top, width: width, height: height 693 }; 694 } 695 }, 696 697 resize: function(event, ui) { 698 var o = ui.options, self = $(this).data("resizable"), 699 ps = self.containerSize, co = self.containerOffset, cs = self.size, cp = self.position, 700 pRatio = o._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = self.containerElement; 701 702 if (ce[0] != document && (/static/).test(ce.css('position'))) cop = co; 703 704 if (cp.left < (o.helper ? co.left : 0)) { 705 self.size.width = self.size.width + (o.helper ? (self.position.left - co.left) : (self.position.left - cop.left)); 706 if (pRatio) self.size.height = self.size.width / o.aspectRatio; 707 self.position.left = o.helper ? co.left : 0; 708 } 709 710 if (cp.top < (o.helper ? co.top : 0)) { 711 self.size.height = self.size.height + (o.helper ? (self.position.top - co.top) : self.position.top); 712 if (pRatio) self.size.width = self.size.height * o.aspectRatio; 713 self.position.top = o.helper ? co.top : 0; 714 } 715 716 self.offset.left = self.parentData.left+self.position.left; 717 self.offset.top = self.parentData.top+self.position.top; 718 719 var woset = Math.abs( (o.helper ? self.offset.left - cop.left : (self.offset.left - cop.left)) + self.sizeDiff.width ), 720 hoset = Math.abs( (o.helper ? self.offset.top - cop.top : (self.offset.top - co.top)) + self.sizeDiff.height ); 721 722 var isParent = self.containerElement.get(0) == self.element.parent().get(0), 723 isOffsetRelative = /relative|absolute/.test(self.containerElement.css('position')); 724 725 if(isParent && isOffsetRelative) woset -= self.parentData.left; 726 727 if (woset + self.size.width >= self.parentData.width) { 728 self.size.width = self.parentData.width - woset; 729 if (pRatio) self.size.height = self.size.width / o.aspectRatio; 730 } 731 732 if (hoset + self.size.height >= self.parentData.height) { 733 self.size.height = self.parentData.height - hoset; 734 if (pRatio) self.size.width = self.size.height * o.aspectRatio; 735 } 736 }, 737 738 stop: function(event, ui){ 739 var o = ui.options, self = $(this).data("resizable"), cp = self.position, 740 co = self.containerOffset, cop = self.containerPosition, ce = self.containerElement; 741 742 var helper = $(self.helper), ho = helper.offset(), w = helper.outerWidth() - self.sizeDiff.width, h = helper.outerHeight() - self.sizeDiff.height; 743 744 if (o.helper && !o.animate && (/relative/).test(ce.css('position'))) 745 $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h }); 746 747 if (o.helper && !o.animate && (/static/).test(ce.css('position'))) 748 $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h }); 749 750 } 751 }); 752 753 $.ui.plugin.add("resizable", "ghost", { 754 755 start: function(event, ui) { 756 var o = ui.options, self = $(this).data("resizable"), pr = o.proportionallyResize, cs = self.size; 757 758 if (!pr) self.ghost = self.element.clone(); 759 else self.ghost = pr.clone(); 760 761 self.ghost.css( 762 { opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 } 763 ) 764 .addClass('ui-resizable-ghost').addClass(typeof o.ghost == 'string' ? o.ghost : ''); 765 766 self.ghost.appendTo(self.helper); 767 768 }, 769 770 resize: function(event, ui){ 771 var o = ui.options, self = $(this).data("resizable"), pr = o.proportionallyResize; 772 773 if (self.ghost) self.ghost.css({ position: 'relative', height: self.size.height, width: self.size.width }); 774 775 }, 776 777 stop: function(event, ui){ 778 var o = ui.options, self = $(this).data("resizable"), pr = o.proportionallyResize; 779 if (self.ghost && self.helper) self.helper.get(0).removeChild(self.ghost.get(0)); 780 } 781 782 }); 783 784 $.ui.plugin.add("resizable", "grid", { 785 786 resize: function(event, ui) { 787 var o = ui.options, self = $(this).data("resizable"), cs = self.size, os = self.originalSize, op = self.originalPosition, a = self.axis, ratio = o._aspectRatio || event.shiftKey; 788 o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid; 789 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); 790 791 if (/^(se|s|e)$/.test(a)) { 792 self.size.width = os.width + ox; 793 self.size.height = os.height + oy; 794 } 795 else if (/^(ne)$/.test(a)) { 796 self.size.width = os.width + ox; 797 self.size.height = os.height + oy; 798 self.position.top = op.top - oy; 799 } 800 else if (/^(sw)$/.test(a)) { 801 self.size.width = os.width + ox; 802 self.size.height = os.height + oy; 803 self.position.left = op.left - ox; 804 } 805 else { 806 self.size.width = os.width + ox; 807 self.size.height = os.height + oy; 808 self.position.top = op.top - oy; 809 self.position.left = op.left - ox; 810 } 811 } 812 813 }); 814 815 var num = function(v) { 816 return parseInt(v, 10) || 0; 817 }; 818 819 })(jQuery);
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |