/packages/jQuery.UI.Combined.1.8.11/Content/Scripts/jquery-ui-1.8.11.js
JavaScript | 2022 lines | 1460 code | 332 blank | 230 comment | 487 complexity | 6c225a6b87e0619fc81082709456c8a9 MD5 | raw file
Large files files are truncated, but you can click here to view the full file
1/*! 2* Note: While Microsoft is not the author of this file, Microsoft is 3* offering you a license subject to the terms of the Microsoft Software 4* License Terms for Microsoft ASP.NET Model View Controller 3. 5* Microsoft reserves all other rights. The notices below are provided 6* for informational purposes only and are not the license terms under 7* which Microsoft distributed this file. 8* 9* jQuery UI 1.8.11 10* 11* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) 12* 13* http://docs.jquery.com/UI 14*/ 15(function( $, undefined ) { 16 17// prevent duplicate loading 18// this is only a problem because we proxy existing functions 19// and we don't want to double proxy them 20$.ui = $.ui || {}; 21if ( $.ui.version ) { 22 return; 23} 24 25$.extend( $.ui, { 26 version: "1.8.11", 27 28 keyCode: { 29 ALT: 18, 30 BACKSPACE: 8, 31 CAPS_LOCK: 20, 32 COMMA: 188, 33 COMMAND: 91, 34 COMMAND_LEFT: 91, // COMMAND 35 COMMAND_RIGHT: 93, 36 CONTROL: 17, 37 DELETE: 46, 38 DOWN: 40, 39 END: 35, 40 ENTER: 13, 41 ESCAPE: 27, 42 HOME: 36, 43 INSERT: 45, 44 LEFT: 37, 45 MENU: 93, // COMMAND_RIGHT 46 NUMPAD_ADD: 107, 47 NUMPAD_DECIMAL: 110, 48 NUMPAD_DIVIDE: 111, 49 NUMPAD_ENTER: 108, 50 NUMPAD_MULTIPLY: 106, 51 NUMPAD_SUBTRACT: 109, 52 PAGE_DOWN: 34, 53 PAGE_UP: 33, 54 PERIOD: 190, 55 RIGHT: 39, 56 SHIFT: 16, 57 SPACE: 32, 58 TAB: 9, 59 UP: 38, 60 WINDOWS: 91 // COMMAND 61 } 62}); 63 64// plugins 65$.fn.extend({ 66 _focus: $.fn.focus, 67 focus: function( delay, fn ) { 68 return typeof delay === "number" ? 69 this.each(function() { 70 var elem = this; 71 setTimeout(function() { 72 $( elem ).focus(); 73 if ( fn ) { 74 fn.call( elem ); 75 } 76 }, delay ); 77 }) : 78 this._focus.apply( this, arguments ); 79 }, 80 81 scrollParent: function() { 82 var scrollParent; 83 if (($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) { 84 scrollParent = this.parents().filter(function() { 85 return (/(relative|absolute|fixed)/).test($.curCSS(this,'position',1)) && (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1)); 86 }).eq(0); 87 } else { 88 scrollParent = this.parents().filter(function() { 89 return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1)); 90 }).eq(0); 91 } 92 93 return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent; 94 }, 95 96 zIndex: function( zIndex ) { 97 if ( zIndex !== undefined ) { 98 return this.css( "zIndex", zIndex ); 99 } 100 101 if ( this.length ) { 102 var elem = $( this[ 0 ] ), position, value; 103 while ( elem.length && elem[ 0 ] !== document ) { 104 // Ignore z-index if position is set to a value where z-index is ignored by the browser 105 // This makes behavior of this function consistent across browsers 106 // WebKit always returns auto if the element is positioned 107 position = elem.css( "position" ); 108 if ( position === "absolute" || position === "relative" || position === "fixed" ) { 109 // IE returns 0 when zIndex is not specified 110 // other browsers return a string 111 // we ignore the case of nested elements with an explicit value of 0 112 // <div style="z-index: -10;"><div style="z-index: 0;"></div></div> 113 value = parseInt( elem.css( "zIndex" ), 10 ); 114 if ( !isNaN( value ) && value !== 0 ) { 115 return value; 116 } 117 } 118 elem = elem.parent(); 119 } 120 } 121 122 return 0; 123 }, 124 125 disableSelection: function() { 126 return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) + 127 ".ui-disableSelection", function( event ) { 128 event.preventDefault(); 129 }); 130 }, 131 132 enableSelection: function() { 133 return this.unbind( ".ui-disableSelection" ); 134 } 135}); 136 137$.each( [ "Width", "Height" ], function( i, name ) { 138 var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ], 139 type = name.toLowerCase(), 140 orig = { 141 innerWidth: $.fn.innerWidth, 142 innerHeight: $.fn.innerHeight, 143 outerWidth: $.fn.outerWidth, 144 outerHeight: $.fn.outerHeight 145 }; 146 147 function reduce( elem, size, border, margin ) { 148 $.each( side, function() { 149 size -= parseFloat( $.curCSS( elem, "padding" + this, true) ) || 0; 150 if ( border ) { 151 size -= parseFloat( $.curCSS( elem, "border" + this + "Width", true) ) || 0; 152 } 153 if ( margin ) { 154 size -= parseFloat( $.curCSS( elem, "margin" + this, true) ) || 0; 155 } 156 }); 157 return size; 158 } 159 160 $.fn[ "inner" + name ] = function( size ) { 161 if ( size === undefined ) { 162 return orig[ "inner" + name ].call( this ); 163 } 164 165 return this.each(function() { 166 $( this ).css( type, reduce( this, size ) + "px" ); 167 }); 168 }; 169 170 $.fn[ "outer" + name] = function( size, margin ) { 171 if ( typeof size !== "number" ) { 172 return orig[ "outer" + name ].call( this, size ); 173 } 174 175 return this.each(function() { 176 $( this).css( type, reduce( this, size, true, margin ) + "px" ); 177 }); 178 }; 179}); 180 181// selectors 182function visible( element ) { 183 return !$( element ).parents().andSelf().filter(function() { 184 return $.curCSS( this, "visibility" ) === "hidden" || 185 $.expr.filters.hidden( this ); 186 }).length; 187} 188 189$.extend( $.expr[ ":" ], { 190 data: function( elem, i, match ) { 191 return !!$.data( elem, match[ 3 ] ); 192 }, 193 194 focusable: function( element ) { 195 var nodeName = element.nodeName.toLowerCase(), 196 tabIndex = $.attr( element, "tabindex" ); 197 if ( "area" === nodeName ) { 198 var map = element.parentNode, 199 mapName = map.name, 200 img; 201 if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) { 202 return false; 203 } 204 img = $( "img[usemap=#" + mapName + "]" )[0]; 205 return !!img && visible( img ); 206 } 207 return ( /input|select|textarea|button|object/.test( nodeName ) 208 ? !element.disabled 209 : "a" == nodeName 210 ? element.href || !isNaN( tabIndex ) 211 : !isNaN( tabIndex )) 212 // the element and all of its ancestors must be visible 213 && visible( element ); 214 }, 215 216 tabbable: function( element ) { 217 var tabIndex = $.attr( element, "tabindex" ); 218 return ( isNaN( tabIndex ) || tabIndex >= 0 ) && $( element ).is( ":focusable" ); 219 } 220}); 221 222// support 223$(function() { 224 var body = document.body, 225 div = body.appendChild( div = document.createElement( "div" ) ); 226 227 $.extend( div.style, { 228 minHeight: "100px", 229 height: "auto", 230 padding: 0, 231 borderWidth: 0 232 }); 233 234 $.support.minHeight = div.offsetHeight === 100; 235 $.support.selectstart = "onselectstart" in div; 236 237 // set display to none to avoid a layout bug in IE 238 // http://dev.jquery.com/ticket/4014 239 body.removeChild( div ).style.display = "none"; 240}); 241 242 243 244 245 246// deprecated 247$.extend( $.ui, { 248 // $.ui.plugin is deprecated. Use the proxy pattern instead. 249 plugin: { 250 add: function( module, option, set ) { 251 var proto = $.ui[ module ].prototype; 252 for ( var i in set ) { 253 proto.plugins[ i ] = proto.plugins[ i ] || []; 254 proto.plugins[ i ].push( [ option, set[ i ] ] ); 255 } 256 }, 257 call: function( instance, name, args ) { 258 var set = instance.plugins[ name ]; 259 if ( !set || !instance.element[ 0 ].parentNode ) { 260 return; 261 } 262 263 for ( var i = 0; i < set.length; i++ ) { 264 if ( instance.options[ set[ i ][ 0 ] ] ) { 265 set[ i ][ 1 ].apply( instance.element, args ); 266 } 267 } 268 } 269 }, 270 271 // will be deprecated when we switch to jQuery 1.4 - use jQuery.contains() 272 contains: function( a, b ) { 273 return document.compareDocumentPosition ? 274 a.compareDocumentPosition( b ) & 16 : 275 a !== b && a.contains( b ); 276 }, 277 278 // only used by resizable 279 hasScroll: function( el, a ) { 280 281 //If overflow is hidden, the element might have extra content, but the user wants to hide it 282 if ( $( el ).css( "overflow" ) === "hidden") { 283 return false; 284 } 285 286 var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop", 287 has = false; 288 289 if ( el[ scroll ] > 0 ) { 290 return true; 291 } 292 293 // TODO: determine which cases actually cause this to happen 294 // if the element doesn't have the scroll set, see if it's possible to 295 // set the scroll 296 el[ scroll ] = 1; 297 has = ( el[ scroll ] > 0 ); 298 el[ scroll ] = 0; 299 return has; 300 }, 301 302 // these are odd functions, fix the API or move into individual plugins 303 isOverAxis: function( x, reference, size ) { 304 //Determines when x coordinate is over "b" element axis 305 return ( x > reference ) && ( x < ( reference + size ) ); 306 }, 307 isOver: function( y, x, top, left, height, width ) { 308 //Determines when x, y coordinates is over "b" element 309 return $.ui.isOverAxis( y, top, height ) && $.ui.isOverAxis( x, left, width ); 310 } 311}); 312 313})( jQuery ); 314/*! 315* Note: While Microsoft is not the author of this file, Microsoft is 316* offering you a license subject to the terms of the Microsoft Software 317* License Terms for Microsoft ASP.NET Model View Controller 3. 318* Microsoft reserves all other rights. The notices below are provided 319* for informational purposes only and are not the license terms under 320* which Microsoft distributed this file. 321* 322* jQuery UI Widget 1.8.11 323* 324* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) 325* 326* http://docs.jquery.com/UI/Widget 327*/ 328(function( $, undefined ) { 329 330// jQuery 1.4+ 331if ( $.cleanData ) { 332 var _cleanData = $.cleanData; 333 $.cleanData = function( elems ) { 334 for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { 335 $( elem ).triggerHandler( "remove" ); 336 } 337 _cleanData( elems ); 338 }; 339} else { 340 var _remove = $.fn.remove; 341 $.fn.remove = function( selector, keepData ) { 342 return this.each(function() { 343 if ( !keepData ) { 344 if ( !selector || $.filter( selector, [ this ] ).length ) { 345 $( "*", this ).add( [ this ] ).each(function() { 346 $( this ).triggerHandler( "remove" ); 347 }); 348 } 349 } 350 return _remove.call( $(this), selector, keepData ); 351 }); 352 }; 353} 354 355$.widget = function( name, base, prototype ) { 356 var namespace = name.split( "." )[ 0 ], 357 fullName; 358 name = name.split( "." )[ 1 ]; 359 fullName = namespace + "-" + name; 360 361 if ( !prototype ) { 362 prototype = base; 363 base = $.Widget; 364 } 365 366 // create selector for plugin 367 $.expr[ ":" ][ fullName ] = function( elem ) { 368 return !!$.data( elem, name ); 369 }; 370 371 $[ namespace ] = $[ namespace ] || {}; 372 $[ namespace ][ name ] = function( options, element ) { 373 // allow instantiation without initializing for simple inheritance 374 if ( arguments.length ) { 375 this._createWidget( options, element ); 376 } 377 }; 378 379 var basePrototype = new base(); 380 // we need to make the options hash a property directly on the new instance 381 // otherwise we'll modify the options hash on the prototype that we're 382 // inheriting from 383// $.each( basePrototype, function( key, val ) { 384// if ( $.isPlainObject(val) ) { 385// basePrototype[ key ] = $.extend( {}, val ); 386// } 387// }); 388 basePrototype.options = $.extend( true, {}, basePrototype.options ); 389 $[ namespace ][ name ].prototype = $.extend( true, basePrototype, { 390 namespace: namespace, 391 widgetName: name, 392 widgetEventPrefix: $[ namespace ][ name ].prototype.widgetEventPrefix || name, 393 widgetBaseClass: fullName 394 }, prototype ); 395 396 $.widget.bridge( name, $[ namespace ][ name ] ); 397}; 398 399$.widget.bridge = function( name, object ) { 400 $.fn[ name ] = function( options ) { 401 var isMethodCall = typeof options === "string", 402 args = Array.prototype.slice.call( arguments, 1 ), 403 returnValue = this; 404 405 // allow multiple hashes to be passed on init 406 options = !isMethodCall && args.length ? 407 $.extend.apply( null, [ true, options ].concat(args) ) : 408 options; 409 410 // prevent calls to internal methods 411 if ( isMethodCall && options.charAt( 0 ) === "_" ) { 412 return returnValue; 413 } 414 415 if ( isMethodCall ) { 416 this.each(function() { 417 var instance = $.data( this, name ), 418 methodValue = instance && $.isFunction( instance[options] ) ? 419 instance[ options ].apply( instance, args ) : 420 instance; 421 // TODO: add this back in 1.9 and use $.error() (see #5972) 422// if ( !instance ) { 423// throw "cannot call methods on " + name + " prior to initialization; " + 424// "attempted to call method '" + options + "'"; 425// } 426// if ( !$.isFunction( instance[options] ) ) { 427// throw "no such method '" + options + "' for " + name + " widget instance"; 428// } 429// var methodValue = instance[ options ].apply( instance, args ); 430 if ( methodValue !== instance && methodValue !== undefined ) { 431 returnValue = methodValue; 432 return false; 433 } 434 }); 435 } else { 436 this.each(function() { 437 var instance = $.data( this, name ); 438 if ( instance ) { 439 instance.option( options || {} )._init(); 440 } else { 441 $.data( this, name, new object( options, this ) ); 442 } 443 }); 444 } 445 446 return returnValue; 447 }; 448}; 449 450$.Widget = function( options, element ) { 451 // allow instantiation without initializing for simple inheritance 452 if ( arguments.length ) { 453 this._createWidget( options, element ); 454 } 455}; 456 457$.Widget.prototype = { 458 widgetName: "widget", 459 widgetEventPrefix: "", 460 options: { 461 disabled: false 462 }, 463 _createWidget: function( options, element ) { 464 // $.widget.bridge stores the plugin instance, but we do it anyway 465 // so that it's stored even before the _create function runs 466 $.data( element, this.widgetName, this ); 467 this.element = $( element ); 468 this.options = $.extend( true, {}, 469 this.options, 470 this._getCreateOptions(), 471 options ); 472 473 var self = this; 474 this.element.bind( "remove." + this.widgetName, function() { 475 self.destroy(); 476 }); 477 478 this._create(); 479 this._trigger( "create" ); 480 this._init(); 481 }, 482 _getCreateOptions: function() { 483 return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ]; 484 }, 485 _create: function() {}, 486 _init: function() {}, 487 488 destroy: function() { 489 this.element 490 .unbind( "." + this.widgetName ) 491 .removeData( this.widgetName ); 492 this.widget() 493 .unbind( "." + this.widgetName ) 494 .removeAttr( "aria-disabled" ) 495 .removeClass( 496 this.widgetBaseClass + "-disabled " + 497 "ui-state-disabled" ); 498 }, 499 500 widget: function() { 501 return this.element; 502 }, 503 504 option: function( key, value ) { 505 var options = key; 506 507 if ( arguments.length === 0 ) { 508 // don't return a reference to the internal hash 509 return $.extend( {}, this.options ); 510 } 511 512 if (typeof key === "string" ) { 513 if ( value === undefined ) { 514 return this.options[ key ]; 515 } 516 options = {}; 517 options[ key ] = value; 518 } 519 520 this._setOptions( options ); 521 522 return this; 523 }, 524 _setOptions: function( options ) { 525 var self = this; 526 $.each( options, function( key, value ) { 527 self._setOption( key, value ); 528 }); 529 530 return this; 531 }, 532 _setOption: function( key, value ) { 533 this.options[ key ] = value; 534 535 if ( key === "disabled" ) { 536 this.widget() 537 [ value ? "addClass" : "removeClass"]( 538 this.widgetBaseClass + "-disabled" + " " + 539 "ui-state-disabled" ) 540 .attr( "aria-disabled", value ); 541 } 542 543 return this; 544 }, 545 546 enable: function() { 547 return this._setOption( "disabled", false ); 548 }, 549 disable: function() { 550 return this._setOption( "disabled", true ); 551 }, 552 553 _trigger: function( type, event, data ) { 554 var callback = this.options[ type ]; 555 556 event = $.Event( event ); 557 event.type = ( type === this.widgetEventPrefix ? 558 type : 559 this.widgetEventPrefix + type ).toLowerCase(); 560 data = data || {}; 561 562 // copy original event properties over to the new event 563 // this would happen if we could call $.event.fix instead of $.Event 564 // but we don't have a way to force an event to be fixed multiple times 565 if ( event.originalEvent ) { 566 for ( var i = $.event.props.length, prop; i; ) { 567 prop = $.event.props[ --i ]; 568 event[ prop ] = event.originalEvent[ prop ]; 569 } 570 } 571 572 this.element.trigger( event, data ); 573 574 return !( $.isFunction(callback) && 575 callback.call( this.element[0], event, data ) === false || 576 event.isDefaultPrevented() ); 577 } 578}; 579 580})( jQuery ); 581/*! 582* Note: While Microsoft is not the author of this file, Microsoft is 583* offering you a license subject to the terms of the Microsoft Software 584* License Terms for Microsoft ASP.NET Model View Controller 3. 585* Microsoft reserves all other rights. The notices below are provided 586* for informational purposes only and are not the license terms under 587* which Microsoft distributed this file. 588* 589* jQuery UI Mouse 1.8.11 590* 591* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) 592* 593* http://docs.jquery.com/UI/Mouse 594* 595* Depends: 596* jquery.ui.widget.js 597*/ 598(function( $, undefined ) { 599 600$.widget("ui.mouse", { 601 options: { 602 cancel: ':input,option', 603 distance: 1, 604 delay: 0 605 }, 606 _mouseInit: function() { 607 var self = this; 608 609 this.element 610 .bind('mousedown.'+this.widgetName, function(event) { 611 return self._mouseDown(event); 612 }) 613 .bind('click.'+this.widgetName, function(event) { 614 if (true === $.data(event.target, self.widgetName + '.preventClickEvent')) { 615 $.removeData(event.target, self.widgetName + '.preventClickEvent'); 616 event.stopImmediatePropagation(); 617 return false; 618 } 619 }); 620 621 this.started = false; 622 }, 623 624 // TODO: make sure destroying one instance of mouse doesn't mess with 625 // other instances of mouse 626 _mouseDestroy: function() { 627 this.element.unbind('.'+this.widgetName); 628 }, 629 630 _mouseDown: function(event) { 631 // don't let more than one widget handle mouseStart 632 // TODO: figure out why we have to use originalEvent 633 event.originalEvent = event.originalEvent || {}; 634 if (event.originalEvent.mouseHandled) { return; } 635 636 // we may have missed mouseup (out of window) 637 (this._mouseStarted && this._mouseUp(event)); 638 639 this._mouseDownEvent = event; 640 641 var self = this, 642 btnIsLeft = (event.which == 1), 643 elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false); 644 if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) { 645 return true; 646 } 647 648 this.mouseDelayMet = !this.options.delay; 649 if (!this.mouseDelayMet) { 650 this._mouseDelayTimer = setTimeout(function() { 651 self.mouseDelayMet = true; 652 }, this.options.delay); 653 } 654 655 if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) { 656 this._mouseStarted = (this._mouseStart(event) !== false); 657 if (!this._mouseStarted) { 658 event.preventDefault(); 659 return true; 660 } 661 } 662 663 // Click event may never have fired (Gecko & Opera) 664 if (true === $.data(event.target, this.widgetName + '.preventClickEvent')) { 665 $.removeData(event.target, this.widgetName + '.preventClickEvent'); 666 } 667 668 // these delegates are required to keep context 669 this._mouseMoveDelegate = function(event) { 670 return self._mouseMove(event); 671 }; 672 this._mouseUpDelegate = function(event) { 673 return self._mouseUp(event); 674 }; 675 $(document) 676 .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate) 677 .bind('mouseup.'+this.widgetName, this._mouseUpDelegate); 678 679 event.preventDefault(); 680 event.originalEvent.mouseHandled = true; 681 return true; 682 }, 683 684 _mouseMove: function(event) { 685 // IE mouseup check - mouseup happened when mouse was out of window 686 if ($.browser.msie && !(document.documentMode >= 9) && !event.button) { 687 return this._mouseUp(event); 688 } 689 690 if (this._mouseStarted) { 691 this._mouseDrag(event); 692 return event.preventDefault(); 693 } 694 695 if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) { 696 this._mouseStarted = 697 (this._mouseStart(this._mouseDownEvent, event) !== false); 698 (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event)); 699 } 700 701 return !this._mouseStarted; 702 }, 703 704 _mouseUp: function(event) { 705 $(document) 706 .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate) 707 .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate); 708 709 if (this._mouseStarted) { 710 this._mouseStarted = false; 711 712 if (event.target == this._mouseDownEvent.target) { 713 $.data(event.target, this.widgetName + '.preventClickEvent', true); 714 } 715 716 this._mouseStop(event); 717 } 718 719 return false; 720 }, 721 722 _mouseDistanceMet: function(event) { 723 return (Math.max( 724 Math.abs(this._mouseDownEvent.pageX - event.pageX), 725 Math.abs(this._mouseDownEvent.pageY - event.pageY) 726 ) >= this.options.distance 727 ); 728 }, 729 730 _mouseDelayMet: function(event) { 731 return this.mouseDelayMet; 732 }, 733 734 // These are placeholder methods, to be overriden by extending plugin 735 _mouseStart: function(event) {}, 736 _mouseDrag: function(event) {}, 737 _mouseStop: function(event) {}, 738 _mouseCapture: function(event) { return true; } 739}); 740 741})(jQuery); 742/* 743* Note: While Microsoft is not the author of this file, Microsoft is 744* offering you a license subject to the terms of the Microsoft Software 745* License Terms for Microsoft ASP.NET Model View Controller 3. 746* Microsoft reserves all other rights. The notices below are provided 747* for informational purposes only and are not the license terms under 748* which Microsoft distributed this file. 749* 750* jQuery UI Position 1.8.11 751* 752* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) 753* 754* http://docs.jquery.com/UI/Position 755*/ 756(function( $, undefined ) { 757 758$.ui = $.ui || {}; 759 760var horizontalPositions = /left|center|right/, 761 verticalPositions = /top|center|bottom/, 762 center = "center", 763 _position = $.fn.position, 764 _offset = $.fn.offset; 765 766$.fn.position = function( options ) { 767 if ( !options || !options.of ) { 768 return _position.apply( this, arguments ); 769 } 770 771 // make a copy, we don't want to modify arguments 772 options = $.extend( {}, options ); 773 774 var target = $( options.of ), 775 targetElem = target[0], 776 collision = ( options.collision || "flip" ).split( " " ), 777 offset = options.offset ? options.offset.split( " " ) : [ 0, 0 ], 778 targetWidth, 779 targetHeight, 780 basePosition; 781 782 if ( targetElem.nodeType === 9 ) { 783 targetWidth = target.width(); 784 targetHeight = target.height(); 785 basePosition = { top: 0, left: 0 }; 786 // TODO: use $.isWindow() in 1.9 787 } else if ( targetElem.setTimeout ) { 788 targetWidth = target.width(); 789 targetHeight = target.height(); 790 basePosition = { top: target.scrollTop(), left: target.scrollLeft() }; 791 } else if ( targetElem.preventDefault ) { 792 // force left top to allow flipping 793 options.at = "left top"; 794 targetWidth = targetHeight = 0; 795 basePosition = { top: options.of.pageY, left: options.of.pageX }; 796 } else { 797 targetWidth = target.outerWidth(); 798 targetHeight = target.outerHeight(); 799 basePosition = target.offset(); 800 } 801 802 // force my and at to have valid horizontal and veritcal positions 803 // if a value is missing or invalid, it will be converted to center 804 $.each( [ "my", "at" ], function() { 805 var pos = ( options[this] || "" ).split( " " ); 806 if ( pos.length === 1) { 807 pos = horizontalPositions.test( pos[0] ) ? 808 pos.concat( [center] ) : 809 verticalPositions.test( pos[0] ) ? 810 [ center ].concat( pos ) : 811 [ center, center ]; 812 } 813 pos[ 0 ] = horizontalPositions.test( pos[0] ) ? pos[ 0 ] : center; 814 pos[ 1 ] = verticalPositions.test( pos[1] ) ? pos[ 1 ] : center; 815 options[ this ] = pos; 816 }); 817 818 // normalize collision option 819 if ( collision.length === 1 ) { 820 collision[ 1 ] = collision[ 0 ]; 821 } 822 823 // normalize offset option 824 offset[ 0 ] = parseInt( offset[0], 10 ) || 0; 825 if ( offset.length === 1 ) { 826 offset[ 1 ] = offset[ 0 ]; 827 } 828 offset[ 1 ] = parseInt( offset[1], 10 ) || 0; 829 830 if ( options.at[0] === "right" ) { 831 basePosition.left += targetWidth; 832 } else if ( options.at[0] === center ) { 833 basePosition.left += targetWidth / 2; 834 } 835 836 if ( options.at[1] === "bottom" ) { 837 basePosition.top += targetHeight; 838 } else if ( options.at[1] === center ) { 839 basePosition.top += targetHeight / 2; 840 } 841 842 basePosition.left += offset[ 0 ]; 843 basePosition.top += offset[ 1 ]; 844 845 return this.each(function() { 846 var elem = $( this ), 847 elemWidth = elem.outerWidth(), 848 elemHeight = elem.outerHeight(), 849 marginLeft = parseInt( $.curCSS( this, "marginLeft", true ) ) || 0, 850 marginTop = parseInt( $.curCSS( this, "marginTop", true ) ) || 0, 851 collisionWidth = elemWidth + marginLeft + 852 ( parseInt( $.curCSS( this, "marginRight", true ) ) || 0 ), 853 collisionHeight = elemHeight + marginTop + 854 ( parseInt( $.curCSS( this, "marginBottom", true ) ) || 0 ), 855 position = $.extend( {}, basePosition ), 856 collisionPosition; 857 858 if ( options.my[0] === "right" ) { 859 position.left -= elemWidth; 860 } else if ( options.my[0] === center ) { 861 position.left -= elemWidth / 2; 862 } 863 864 if ( options.my[1] === "bottom" ) { 865 position.top -= elemHeight; 866 } else if ( options.my[1] === center ) { 867 position.top -= elemHeight / 2; 868 } 869 870 // prevent fractions (see #5280) 871 position.left = Math.round( position.left ); 872 position.top = Math.round( position.top ); 873 874 collisionPosition = { 875 left: position.left - marginLeft, 876 top: position.top - marginTop 877 }; 878 879 $.each( [ "left", "top" ], function( i, dir ) { 880 if ( $.ui.position[ collision[i] ] ) { 881 $.ui.position[ collision[i] ][ dir ]( position, { 882 targetWidth: targetWidth, 883 targetHeight: targetHeight, 884 elemWidth: elemWidth, 885 elemHeight: elemHeight, 886 collisionPosition: collisionPosition, 887 collisionWidth: collisionWidth, 888 collisionHeight: collisionHeight, 889 offset: offset, 890 my: options.my, 891 at: options.at 892 }); 893 } 894 }); 895 896 if ( $.fn.bgiframe ) { 897 elem.bgiframe(); 898 } 899 elem.offset( $.extend( position, { using: options.using } ) ); 900 }); 901}; 902 903$.ui.position = { 904 fit: { 905 left: function( position, data ) { 906 var win = $( window ), 907 over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft(); 908 position.left = over > 0 ? position.left - over : Math.max( position.left - data.collisionPosition.left, position.left ); 909 }, 910 top: function( position, data ) { 911 var win = $( window ), 912 over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop(); 913 position.top = over > 0 ? position.top - over : Math.max( position.top - data.collisionPosition.top, position.top ); 914 } 915 }, 916 917 flip: { 918 left: function( position, data ) { 919 if ( data.at[0] === center ) { 920 return; 921 } 922 var win = $( window ), 923 over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft(), 924 myOffset = data.my[ 0 ] === "left" ? 925 -data.elemWidth : 926 data.my[ 0 ] === "right" ? 927 data.elemWidth : 928 0, 929 atOffset = data.at[ 0 ] === "left" ? 930 data.targetWidth : 931 -data.targetWidth, 932 offset = -2 * data.offset[ 0 ]; 933 position.left += data.collisionPosition.left < 0 ? 934 myOffset + atOffset + offset : 935 over > 0 ? 936 myOffset + atOffset + offset : 937 0; 938 }, 939 top: function( position, data ) { 940 if ( data.at[1] === center ) { 941 return; 942 } 943 var win = $( window ), 944 over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop(), 945 myOffset = data.my[ 1 ] === "top" ? 946 -data.elemHeight : 947 data.my[ 1 ] === "bottom" ? 948 data.elemHeight : 949 0, 950 atOffset = data.at[ 1 ] === "top" ? 951 data.targetHeight : 952 -data.targetHeight, 953 offset = -2 * data.offset[ 1 ]; 954 position.top += data.collisionPosition.top < 0 ? 955 myOffset + atOffset + offset : 956 over > 0 ? 957 myOffset + atOffset + offset : 958 0; 959 } 960 } 961}; 962 963// offset setter from jQuery 1.4 964if ( !$.offset.setOffset ) { 965 $.offset.setOffset = function( elem, options ) { 966 // set position first, in-case top/left are set even on static elem 967 if ( /static/.test( $.curCSS( elem, "position" ) ) ) { 968 elem.style.position = "relative"; 969 } 970 var curElem = $( elem ), 971 curOffset = curElem.offset(), 972 curTop = parseInt( $.curCSS( elem, "top", true ), 10 ) || 0, 973 curLeft = parseInt( $.curCSS( elem, "left", true ), 10) || 0, 974 props = { 975 top: (options.top - curOffset.top) + curTop, 976 left: (options.left - curOffset.left) + curLeft 977 }; 978 979 if ( 'using' in options ) { 980 options.using.call( elem, props ); 981 } else { 982 curElem.css( props ); 983 } 984 }; 985 986 $.fn.offset = function( options ) { 987 var elem = this[ 0 ]; 988 if ( !elem || !elem.ownerDocument ) { return null; } 989 if ( options ) { 990 return this.each(function() { 991 $.offset.setOffset( this, options ); 992 }); 993 } 994 return _offset.call( this ); 995 }; 996} 997 998}( jQuery )); 999/* 1000* Note: While Microsoft is not the author of this file, Microsoft is 1001* offering you a license subject to the terms of the Microsoft Software 1002* License Terms for Microsoft ASP.NET Model View Controller 3. 1003* Microsoft reserves all other rights. The notices below are provided 1004* for informational purposes only and are not the license terms under 1005* which Microsoft distributed this file. 1006* 1007* jQuery UI Draggable 1.8.11 1008* 1009* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) 1010* 1011* http://docs.jquery.com/UI/Draggables 1012* 1013* Depends: 1014* jquery.ui.core.js 1015* jquery.ui.mouse.js 1016* jquery.ui.widget.js 1017*/ 1018(function( $, undefined ) { 1019 1020$.widget("ui.draggable", $.ui.mouse, { 1021 widgetEventPrefix: "drag", 1022 options: { 1023 addClasses: true, 1024 appendTo: "parent", 1025 axis: false, 1026 connectToSortable: false, 1027 containment: false, 1028 cursor: "auto", 1029 cursorAt: false, 1030 grid: false, 1031 handle: false, 1032 helper: "original", 1033 iframeFix: false, 1034 opacity: false, 1035 refreshPositions: false, 1036 revert: false, 1037 revertDuration: 500, 1038 scope: "default", 1039 scroll: true, 1040 scrollSensitivity: 20, 1041 scrollSpeed: 20, 1042 snap: false, 1043 snapMode: "both", 1044 snapTolerance: 20, 1045 stack: false, 1046 zIndex: false 1047 }, 1048 _create: function() { 1049 1050 if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position"))) 1051 this.element[0].style.position = 'relative'; 1052 1053 (this.options.addClasses && this.element.addClass("ui-draggable")); 1054 (this.options.disabled && this.element.addClass("ui-draggable-disabled")); 1055 1056 this._mouseInit(); 1057 1058 }, 1059 1060 destroy: function() { 1061 if(!this.element.data('draggable')) return; 1062 this.element 1063 .removeData("draggable") 1064 .unbind(".draggable") 1065 .removeClass("ui-draggable" 1066 + " ui-draggable-dragging" 1067 + " ui-draggable-disabled"); 1068 this._mouseDestroy(); 1069 1070 return this; 1071 }, 1072 1073 _mouseCapture: function(event) { 1074 1075 var o = this.options; 1076 1077 // among others, prevent a drag on a resizable-handle 1078 if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle')) 1079 return false; 1080 1081 //Quit if we're not on a valid handle 1082 this.handle = this._getHandle(event); 1083 if (!this.handle) 1084 return false; 1085 1086 return true; 1087 1088 }, 1089 1090 _mouseStart: function(event) { 1091 1092 var o = this.options; 1093 1094 //Create and append the visible helper 1095 this.helper = this._createHelper(event); 1096 1097 //Cache the helper size 1098 this._cacheHelperProportions(); 1099 1100 //If ddmanager is used for droppables, set the global draggable 1101 if($.ui.ddmanager) 1102 $.ui.ddmanager.current = this; 1103 1104 /* 1105 * - Position generation - 1106 * This block generates everything position related - it's the core of draggables. 1107 */ 1108 1109 //Cache the margins of the original element 1110 this._cacheMargins(); 1111 1112 //Store the helper's css position 1113 this.cssPosition = this.helper.css("position"); 1114 this.scrollParent = this.helper.scrollParent(); 1115 1116 //The element's absolute position on the page minus margins 1117 this.offset = this.positionAbs = this.element.offset(); 1118 this.offset = { 1119 top: this.offset.top - this.margins.top, 1120 left: this.offset.left - this.margins.left 1121 }; 1122 1123 $.extend(this.offset, { 1124 click: { //Where the click happened, relative to the element 1125 left: event.pageX - this.offset.left, 1126 top: event.pageY - this.offset.top 1127 }, 1128 parent: this._getParentOffset(), 1129 relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper 1130 }); 1131 1132 //Generate the original position 1133 this.originalPosition = this.position = this._generatePosition(event); 1134 this.originalPageX = event.pageX; 1135 this.originalPageY = event.pageY; 1136 1137 //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied 1138 (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt)); 1139 1140 //Set a containment if given in the options 1141 if(o.containment) 1142 this._setContainment(); 1143 1144 //Trigger event + callbacks 1145 if(this._trigger("start", event) === false) { 1146 this._clear(); 1147 return false; 1148 } 1149 1150 //Recache the helper size 1151 this._cacheHelperProportions(); 1152 1153 //Prepare the droppable offsets 1154 if ($.ui.ddmanager && !o.dropBehaviour) 1155 $.ui.ddmanager.prepareOffsets(this, event); 1156 1157 this.helper.addClass("ui-draggable-dragging"); 1158 this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position 1159 return true; 1160 }, 1161 1162 _mouseDrag: function(event, noPropagation) { 1163 1164 //Compute the helpers position 1165 this.position = this._generatePosition(event); 1166 this.positionAbs = this._convertPositionTo("absolute"); 1167 1168 //Call plugins and callbacks and use the resulting position if something is returned 1169 if (!noPropagation) { 1170 var ui = this._uiHash(); 1171 if(this._trigger('drag', event, ui) === false) { 1172 this._mouseUp({}); 1173 return false; 1174 } 1175 this.position = ui.position; 1176 } 1177 1178 if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px'; 1179 if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px'; 1180 if($.ui.ddmanager) $.ui.ddmanager.drag(this, event); 1181 1182 return false; 1183 }, 1184 1185 _mouseStop: function(event) { 1186 1187 //If we are using droppables, inform the manager about the drop 1188 var dropped = false; 1189 if ($.ui.ddmanager && !this.options.dropBehaviour) 1190 dropped = $.ui.ddmanager.drop(this, event); 1191 1192 //if a drop comes from outside (a sortable) 1193 if(this.dropped) { 1194 dropped = this.dropped; 1195 this.dropped = false; 1196 } 1197 1198 //if the original element is removed, don't bother to continue if helper is set to "original" 1199 if((!this.element[0] || !this.element[0].parentNode) && this.options.helper == "original") 1200 return false; 1201 1202 if((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) { 1203 var self = this; 1204 $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() { 1205 if(self._trigger("stop", event) !== false) { 1206 self._clear(); 1207 } 1208 }); 1209 } else { 1210 if(this._trigger("stop", event) !== false) { 1211 this._clear(); 1212 } 1213 } 1214 1215 return false; 1216 }, 1217 1218 cancel: function() { 1219 1220 if(this.helper.is(".ui-draggable-dragging")) { 1221 this._mouseUp({}); 1222 } else { 1223 this._clear(); 1224 } 1225 1226 return this; 1227 1228 }, 1229 1230 _getHandle: function(event) { 1231 1232 var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false; 1233 $(this.options.handle, this.element) 1234 .find("*") 1235 .andSelf() 1236 .each(function() { 1237 if(this == event.target) handle = true; 1238 }); 1239 1240 return handle; 1241 1242 }, 1243 1244 _createHelper: function(event) { 1245 1246 var o = this.options; 1247 var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone() : this.element); 1248 1249 if(!helper.parents('body').length) 1250 helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo)); 1251 1252 if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) 1253 helper.css("position", "absolute"); 1254 1255 return helper; 1256 1257 }, 1258 1259 _adjustOffsetFromHelper: function(obj) { 1260 if (typeof obj == 'string') { 1261 obj = obj.split(' '); 1262 } 1263 if ($.isArray(obj)) { 1264 obj = {left: +obj[0], top: +obj[1] || 0}; 1265 } 1266 if ('left' in obj) { 1267 this.offset.click.left = obj.left + this.margins.left; 1268 } 1269 if ('right' in obj) { 1270 this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; 1271 } 1272 if ('top' in obj) { 1273 this.offset.click.top = obj.top + this.margins.top; 1274 } 1275 if ('bottom' in obj) { 1276 this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top; 1277 } 1278 }, 1279 1280 _getParentOffset: function() { 1281 1282 //Get the offsetParent and cache its position 1283 this.offsetParent = this.helper.offsetParent(); 1284 var po = this.offsetParent.offset(); 1285 1286 // This is a special case where we need to modify a offset calculated on start, since the following happened: 1287 // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent 1288 // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that 1289 // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag 1290 if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) { 1291 po.left += this.scrollParent.scrollLeft(); 1292 po.top += this.scrollParent.scrollTop(); 1293 } 1294 1295 if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information 1296 || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix 1297 po = { top: 0, left: 0 }; 1298 1299 return { 1300 top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0), 1301 left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0) 1302 }; 1303 1304 }, 1305 1306 _getRelativeOffset: function() { 1307 1308 if(this.cssPosition == "relative") { 1309 var p = this.element.position(); 1310 return { 1311 top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(), 1312 left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft() 1313 }; 1314 } else { 1315 return { top: 0, left: 0 }; 1316 } 1317 1318 }, 1319 1320 _cacheMargins: function() { 1321 this.margins = { 1322 left: (parseInt(this.element.css("marginLeft"),10) || 0), 1323 top: (parseInt(this.element.css("marginTop"),10) || 0), 1324 right: (parseInt(this.element.css("marginRight"),10) || 0), 1325 bottom: (parseInt(this.element.css("marginBottom"),10) || 0) 1326 }; 1327 }, 1328 1329 _cacheHelperProportions: function() { 1330 this.helperProportions = { 1331 width: this.helper.outerWidth(), 1332 height: this.helper.outerHeight() 1333 }; 1334 }, 1335 1336 _setContainment: function() { 1337 1338 var o = this.options; 1339 if(o.containment == 'parent') o.containment = this.helper[0].parentNode; 1340 if(o.containment == 'document' || o.containment == 'window') this.containment = [ 1341 (o.containment == 'document' ? 0 : $(window).scrollLeft()) - this.offset.relative.left - this.offset.parent.left, 1342 (o.containment == 'document' ? 0 : $(window).scrollTop()) - this.offset.relative.top - this.offset.parent.top, 1343 (o.containment == 'document' ? 0 : $(window).scrollLeft()) + $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left, 1344 (o.containment == 'document' ? 0 : $(window).scrollTop()) + ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top 1345 ]; 1346 1347 if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) { 1348 var ce = $(o.containment)[0]; if(!ce) return; 1349 var co = $(o.containment).offset(); 1350 var over = ($(ce).css("overflow") != 'hidden'); 1351 1352 this.containment = [ 1353 co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0), 1354 co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0), 1355 co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left - this.margins.right, 1356 co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top - this.margins.bottom 1357 ]; 1358 } else if(o.containment.constructor == Array) { 1359 this.containment = o.containment; 1360 } 1361 1362 }, 1363 1364 _convertPositionTo: function(d, pos) { 1365 1366 if(!pos) pos = this.position; 1367 var mod = d == "absolute" ? 1 : -1; 1368 var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); 1369 1370 return { 1371 top: ( 1372 pos.top // The absolute mouse position 1373 + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent 1374 + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border) 1375 - ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod) 1376 ), 1377 left: ( 1378 pos.left // The absolute mouse position 1379 + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent 1380 + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border) 1381 - ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod) 1382 ) 1383 }; 1384 1385 }, 1386 1387 _generatePosition: function(event) { 1388 1389 var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); 1390 var pageX = event.pageX; 1391 var pageY = event.pageY; 1392 1393 /* 1394 * - Position constraining - 1395 * Constrain the position to a mix of grid, containment. 1396 */ 1397 1398 if(this.originalPosition) { //If we are not dragging yet, we won't check for options 1399 1400 if(this.containment) { 1401 if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left; 1402 if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top; 1403 if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left; 1404 if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top; 1405 } 1406 1407 if(o.grid) { 1408 var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1]; 1409 pageY = this.containment ? (!(top - this.offset.click.top < this.containment[1] || top - this.offset.click.top > this.containment[3]) ? top : (!(top - this.offset.click.top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top; 1410 1411 var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0]; 1412 pageX = this.containment ? (!(left - this.offset.click.left < this.containment[0] || left - this.offset.click.left > this.containment[2]) ? left : (!(left - this.offset.click.left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left; 1413 } 1414 1415 } 1416 1417 return { 1418 top: ( 1419 pageY // The absolute mouse position 1420 - this.offset.click.top // Click offset (relative to the element) 1421 - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent 1422 - this.offset.parent.top // The offsetParent's offset without borders (offset + border) 1423 + ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) )) 1424 ), 1425 left: ( 1426 pageX // The absolute mouse position 1427 - this.offset.click.left // Click offset (relative to the element) 1428 - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent 1429 - this.offset.parent.left // The offsetParent's offset without borders (offset + border) 1430 + ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() )) 1431 ) 1432 }; 1433 1434 }, 1435 1436 _clear: function() { 1437 this.helper.removeClass("ui-draggable-dragging"); 1438 if(this.helper[0] != this.element[0] && !this.cancelHelperRemoval) this.helper.remove(); 1439 //if($.ui.ddmanager) $.ui.ddmanager.current = null; 1440 this.helper = null; 1441 this.cancelHelperRemoval = false; 1442 }, 1443 1444 // From now on bulk stuff - mainly helpers 1445 1446 _trigger: function(type, event, ui) { 1447 ui = ui || this._uiHash(); 1448 $.ui.plugin.call(this, type, [event, ui]); 1449 if(type == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins 1450 return $.Widget.prototype._trigger.call(this, type, event, ui); 1451 }, 1452 1453 plugins: {}, 1454 1455 _uiHash: function(event) { 1456 return { 1457 helper: this.helper, 1458 position: this.position, 1459 originalPosition: this.originalPosition, 1460 offset: this.positionAbs 1461 }; 1462 } 1463 1464}); 1465 1466$.extend($.ui.draggable, { 1467 version: "1.8.11" 1468}); 1469 1470$.ui.plugin.add("draggable", "connectToSortable", { 1471 start: function(event, ui) { 1472 1473 var inst = $(this).data("draggable"), o = inst.options, 1474 uiSortable = $.extend({}, ui, { item: inst.element }); 1475 inst.sortables = []; 1476 $(o.connectToSortable).each(function() { 1477 var sortable = $.data(this, 'sortable'); 1478 if (sortable && !sortable.options.disabled) { 1479 inst.sortables.push({ 1480 instance: sortable, 1481 shouldRevert: sortable.options.revert 1482 }); 1483 sortable.refreshPositions(); // Call the sortable's refreshPositions at drag start to refresh the containerCache since the sortable container cache is used in drag and needs to be up to date (this will ensure it's initialised as well as being kept in step with any changes that might have happened on the page). 1484 sortable._trigger("activate", event, uiSortable); 1485 } 1486 }); 1487 1488 }, 1489 stop: function(event, ui) { 1490 1491 //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper 1492 var inst = $(this).data("draggable"), 1493 uiSortable = $.extend({}, ui, { item: inst.element }); 1494 1495 $.each(inst.sortables, function() { 1496 if(this.instance.isOver) { 1497 1498 this.instance.isOver = 0; 1499 1500 inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance 1501 this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work) 1502 1503 //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: 'valid/invalid' 1504 if(this.shouldRevert) this.instance.options.revert = true; 1505 1506 //Trigger the stop of the sortable 1507 this.instance._mouseStop(event); 1508 1509 this.instance.options.helper = this.instance.options._helper; 1510 1511 //If the helper has been the original item, restore properties in the sortable 1512 if(inst.options.helper == 'original') 1513 this.instance.currentItem.css({ top: 'auto', left: 'auto' }); 1514 1515 } else { 1516 this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance 1517 this.instance._trigger("deactivate", event, uiSortable); 1518 } 1519 1520 }); 1521 1522 }, 1523 drag: function(event, ui) { 1524 1525 var inst = $(this).data("draggable"), self = this; 1526 1527 var checkPos = function(o) { 1528 var dyClick = this.offset.click.top, dxClick = this.offset.click.left; 1529 var helperTop = this.positionAbs.top, helperLeft = this.positionAbs.left; 1530 var itemHeight = o.height, itemWidth = o.width; 1531 var itemTop = o.top, itemLeft = o.left; 1532 1533 return $.ui.isOver(helperTop + dyClick, helperLeft + dxClick, itemTop, itemLeft, itemHeight, itemWidth); 1534 }; 1535 1536 $.each(inst.sortables, function(i) { 1537 1538 //Copy over some variables to allow calling the sortable's native _intersectsWith 1539 this.instance.positionAbs = inst.positionAbs; 1540 this.instance.helperProportions = inst.helperProportions; 1541 this.instance.offset.click = inst.offset.click; 1542 1543 if(this.instance._intersectsWith(this.instance.containerCache)) { 1544 1545 //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once 1546 if(!this.instance.isOver) { 1547 1548 this.instance.isOver = 1; 1549 //Now we fake the start of dragging for the sortable instance, 1550 //by cloning the list group item, appending it to the sortable and using it as inst.currentItem 1551 //We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one) 1552 this.instance.currentItem = $(self).clone().appendTo(this.instance.element).data("sortable-item", true); 1553 this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it 1554 this.instance.options.helper = function() { return ui.helper[0]; }; 1555 1556 event.target = this.instance.currentItem[0]; 1557 this.instance._mouseCapture(event, true); 1558 this.instance._mouseStart(event, true, true); 1559 1560 //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes 1561 this.instance.offset.click.top = inst.offset.click.top; 1562 this.instance.offset.click.left = inst.offset.click.left; 1563 this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left; 1564 this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top; 1565 1566 inst._trigger("toSortable", event); 1567 inst.dropped = this.instance.element; //draggable revert needs that 1568 //hack so receive/update callbacks work (mostly) 1569 inst.currentItem = inst.element; 1570 this.instance.fromOutside = inst; 1571 1572 } 1573 1574 //Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable 1575 if(this.instance.currentItem) this.instance._mouseDrag(event); 1576 1577 } else { 1578 1579 //If it doesn't intersect with the sortable, and it intersected before, 1580 //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval 1581 if(this.instance.isOver) { 1582 1583 this.instance.isOver = 0; 1584 this.instance.cancel…
Large files files are truncated, but you can click here to view the full file