vendor: 4,136 bytes, lines 1-143
1/*! jQuery UI - v1.12.0 - 2016-09-13 2* http://jqueryui.com 3* Includes: widget.js, position.js, data.js, disable-selection.js, focusable.js, form-reset-mixin.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/draggable.js, widgets/droppable.js, widgets/resizable.js, widgets/sortable.js, widgets/button.js, widgets/checkboxradio.js, widgets/controlgroup.js, widgets/mouse.js, widgets/slider.js, widgets/spinner.js 4* Copyright jQuery Foundation and other contributors; Licensed MIT */ 5 6(function( factory ) { 7 if ( typeof define === "function" && define.amd ) { 8 9 // AMD. Register as an anonymous module. 10 define([ "jquery" ], factory ); 11 } else { 12 13 // Browser globals 14 factory( jQuery ); 15 } 16}(function( $ ) { 17 18$.ui = $.ui || {}; 19 20var version = $.ui.version = "1.12.0"; 21 22 23/*! 24 * jQuery UI Widget 1.12.0 25 * http://jqueryui.com 26 * 27 * Copyright jQuery Foundation and other contributors 28 * Released under the MIT license. 29 * http://jquery.org/license 30 */ 31 32//>>label: Widget 33//>>group: Core 34//>>description: Provides a factory for creating stateful widgets with a common API. 35//>>docs: http://api.jqueryui.com/jQuery.widget/ 36//>>demos: http://jqueryui.com/widget/ 37 38 39 40var widgetUuid = 0; 41var widgetSlice = Array.prototype.slice; 42 43$.cleanData = ( function( orig ) { 44 return function( elems ) { 45 var events, elem, i; 46 for ( i = 0; ( elem = elems[ i ] ) != null; i++ ) { 47 try { 48 49 // Only trigger remove when necessary to save time 50 events = $._data( elem, "events" ); 51 if ( events && events.remove ) { 52 $( elem ).triggerHandler( "remove" ); 53 } 54 55 // Http://bugs.jquery.com/ticket/8235 56 } catch ( e ) {} 57 } 58 orig( elems ); 59 }; 60} )( $.cleanData ); 61 62$.widget = function( name, base, prototype ) { 63 var existingConstructor, constructor, basePrototype; 64 65 // ProxiedPrototype allows the provided prototype to remain unmodified 66 // so that it can be used as a mixin for multiple widgets (#8876) 67 var proxiedPrototype = {}; 68 69 var namespace = name.split( "." )[ 0 ]; 70 name = name.split( "." )[ 1 ]; 71 var fullName = namespace + "-" + name; 72 73 if ( !prototype ) { 74 prototype = base; 75 base = $.Widget; 76 } 77 78 if ( $.isArray( prototype ) ) { 79 prototype = $.extend.apply( null, [ {} ].concat( prototype ) ); 80 } 81 82 // Create selector for plugin 83 $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) { 84 return !!$.data( elem, fullName ); 85 }; 86 87 $[ namespace ] = $[ namespace ] || {}; 88 existingConstructor = $[ namespace ][ name ]; 89 constructor = $[ namespace ][ name ] = function( options, element ) { 90 91 // Allow instantiation without "new" keyword 92 if ( !this._createWidget ) { 93 return new constructor( options, element ); 94 } 95 96 // Allow instantiation without initializing for simple inheritance 97 // must use "new" keyword (the code above always passes args) 98 if ( arguments.length ) { 99 this._createWidget( options, element ); 100 } 101 }; 102 103 // Extend with the existing constructor to carry over any static properties 104 $.extend( constructor, existingConstructor, { 105 version: prototype.version, 106 107 // Copy the object used to create the prototype in case we need to 108 // redefine the widget later 109 _proto: $.extend( {}, prototype ), 110 111 // Track widgets that inherit from this widget in case this widget is 112 // redefined after a widget inherits from it 113 _childConstructors: [] 114 } ); 115 116 basePrototype = new base(); 117 118 // We need to make the options hash a property directly on the new instance 119 // otherwise we'll modify the options hash on the prototype that we're 120 // inheriting from 121 basePrototype.options = $.widget.extend( {}, basePrototype.options ); 122 $.each( prototype, function( prop, value ) { 123 if ( !$.isFunction( value ) ) { 124 proxiedPrototype[ prop ] = value; 125 return; 126 } 127 proxiedPrototype[ prop ] = ( function() { 128 function _super() { 129 return base.prototype[ prop ].apply( this, arguments ); 130 } 131 132 function _superApply( args ) { 133 return base.prototype[ prop ].apply( this, args ); 134 } 135 136 return function() { 137 var __super = this._super; 138 var __superApply = this._superApply; 139 var returnValue; 140 141 this._super = _super; 142 this._superApply = _superApply; 143
vendor: 4,870 bytes, lines 144-323
144 returnValue = value.apply( this, arguments ); 145 146 this._super = __super; 147 this._superApply = __superApply; 148 149 return returnValue; 150 }; 151 } )(); 152 } ); 153 constructor.prototype = $.widget.extend( basePrototype, { 154 155 // TODO: remove support for widgetEventPrefix 156 // always use the name + a colon as the prefix, e.g., draggable:start 157 // don't prefix for widgets that aren't DOM-based 158 widgetEventPrefix: existingConstructor ? ( basePrototype.widgetEventPrefix || name ) : name 159 }, proxiedPrototype, { 160 constructor: constructor, 161 namespace: namespace, 162 widgetName: name, 163 widgetFullName: fullName 164 } ); 165 166 // If this widget is being redefined then we need to find all widgets that 167 // are inheriting from it and redefine all of them so that they inherit from 168 // the new version of this widget. We're essentially trying to replace one 169 // level in the prototype chain. 170 if ( existingConstructor ) { 171 $.each( existingConstructor._childConstructors, function( i, child ) { 172 var childPrototype = child.prototype; 173 174 // Redefine the child widget using the same prototype that was 175 // originally used, but inherit from the new version of the base 176 $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, 177 child._proto ); 178 } ); 179 180 // Remove the list of existing child constructors from the old constructor 181 // so the old child constructors can be garbage collected 182 delete existingConstructor._childConstructors; 183 } else { 184 base._childConstructors.push( constructor ); 185 } 186 187 $.widget.bridge( name, constructor ); 188 189 return constructor; 190}; 191 192$.widget.extend = function( target ) { 193 var input = widgetSlice.call( arguments, 1 ); 194 var inputIndex = 0; 195 var inputLength = input.length; 196 var key; 197 var value; 198 199 for ( ; inputIndex < inputLength; inputIndex++ ) { 200 for ( key in input[ inputIndex ] ) { 201 value = input[ inputIndex ][ key ]; 202 if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) { 203 204 // Clone objects 205 if ( $.isPlainObject( value ) ) { 206 target[ key ] = $.isPlainObject( target[ key ] ) ? 207 $.widget.extend( {}, target[ key ], value ) : 208 209 // Don't extend strings, arrays, etc. with objects 210 $.widget.extend( {}, value ); 211 212 // Copy everything else by reference 213 } else { 214 target[ key ] = value; 215 } 216 } 217 } 218 } 219 return target; 220}; 221 222$.widget.bridge = function( name, object ) { 223 var fullName = object.prototype.widgetFullName || name; 224 $.fn[ name ] = function( options ) { 225 var isMethodCall = typeof options === "string"; 226 var args = widgetSlice.call( arguments, 1 ); 227 var returnValue = this; 228 229 if ( isMethodCall ) { 230 this.each( function() { 231 var methodValue; 232 var instance = $.data( this, fullName ); 233 234 if ( options === "instance" ) { 235 returnValue = instance; 236 return false; 237 } 238 239 if ( !instance ) { 240 return $.error( "cannot call methods on " + name + 241 " prior to initialization; " + 242 "attempted to call method '" + options + "'" ); 243 } 244 245 if ( !$.isFunction( instance[ options ] ) || options.charAt( 0 ) === "_" ) { 246 return $.error( "no such method '" + options + "' for " + name + 247 " widget instance" ); 248 } 249 250 methodValue = instance[ options ].apply( instance, args ); 251 252 if ( methodValue !== instance && methodValue !== undefined ) { 253 returnValue = methodValue && methodValue.jquery ? 254 returnValue.pushStack( methodValue.get() ) : 255 methodValue; 256 return false; 257 } 258 } ); 259 } else { 260 261 // Allow multiple hashes to be passed on init 262 if ( args.length ) { 263 options = $.widget.extend.apply( null, [ options ].concat( args ) ); 264 } 265 266 this.each( function() { 267 var instance = $.data( this, fullName ); 268 if ( instance ) { 269 instance.option( options || {} ); 270 if ( instance._init ) { 271 instance._init(); 272 } 273 } else { 274 $.data( this, fullName, new object( options, this ) ); 275 } 276 } ); 277 } 278 279 return returnValue; 280 }; 281}; 282 283$.Widget = function( /* options, element */ ) {}; 284$.Widget._childConstructors = []; 285 286$.Widget.prototype = { 287 widgetName: "widget", 288 widgetEventPrefix: "", 289 defaultElement: "<div>", 290 291 options: { 292 classes: {}, 293 disabled: false, 294 295 // Callbacks 296 create: null 297 }, 298 299 _createWidget: function( options, element ) { 300 element = $( element || this.defaultElement || this )[ 0 ]; 301 this.element = $( element ); 302 this.uuid = widgetUuid++; 303 this.eventNamespace = "." + this.widgetName + this.uuid; 304 305 this.bindings = $(); 306 this.hoverable = $(); 307 this.focusable = $(); 308 this.classesElementLookup = {}; 309 310 if ( element !== this ) { 311 $.data( element, this.widgetFullName, this ); 312 this._on( true, this.element, { 313 remove: function( event ) { 314 if ( event.target === element ) { 315 this.destroy(); 316 } 317 } 318 } ); 319 this.document = $( element.style ? 320 321 // Element within the document 322 element.ownerDocument : 323
vendor: 5,199 bytes, lines 324-529
324 // Element is window or document 325 element.document || element ); 326 this.window = $( this.document[ 0 ].defaultView || this.document[ 0 ].parentWindow ); 327 } 328 329 this.options = $.widget.extend( {}, 330 this.options, 331 this._getCreateOptions(), 332 options ); 333 334 this._create(); 335 336 if ( this.options.disabled ) { 337 this._setOptionDisabled( this.options.disabled ); 338 } 339 340 this._trigger( "create", null, this._getCreateEventData() ); 341 this._init(); 342 }, 343 344 _getCreateOptions: function() { 345 return {}; 346 }, 347 348 _getCreateEventData: $.noop, 349 350 _create: $.noop, 351 352 _init: $.noop, 353 354 destroy: function() { 355 var that = this; 356 357 this._destroy(); 358 $.each( this.classesElementLookup, function( key, value ) { 359 that._removeClass( value, key ); 360 } ); 361 362 // We can probably remove the unbind calls in 2.0 363 // all event bindings should go through this._on() 364 this.element 365 .off( this.eventNamespace ) 366 .removeData( this.widgetFullName ); 367 this.widget() 368 .off( this.eventNamespace ) 369 .removeAttr( "aria-disabled" ); 370 371 // Clean up events and states 372 this.bindings.off( this.eventNamespace ); 373 }, 374 375 _destroy: $.noop, 376 377 widget: function() { 378 return this.element; 379 }, 380 381 option: function( key, value ) { 382 var options = key; 383 var parts; 384 var curOption; 385 var i; 386 387 if ( arguments.length === 0 ) { 388 389 // Don't return a reference to the internal hash 390 return $.widget.extend( {}, this.options ); 391 } 392 393 if ( typeof key === "string" ) { 394 395 // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } } 396 options = {}; 397 parts = key.split( "." ); 398 key = parts.shift(); 399 if ( parts.length ) { 400 curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] ); 401 for ( i = 0; i < parts.length - 1; i++ ) { 402 curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {}; 403 curOption = curOption[ parts[ i ] ]; 404 } 405 key = parts.pop(); 406 if ( arguments.length === 1 ) { 407 return curOption[ key ] === undefined ? null : curOption[ key ]; 408 } 409 curOption[ key ] = value; 410 } else { 411 if ( arguments.length === 1 ) { 412 return this.options[ key ] === undefined ? null : this.options[ key ]; 413 } 414 options[ key ] = value; 415 } 416 } 417 418 this._setOptions( options ); 419 420 return this; 421 }, 422 423 _setOptions: function( options ) { 424 var key; 425 426 for ( key in options ) { 427 this._setOption( key, options[ key ] ); 428 } 429 430 return this; 431 }, 432 433 _setOption: function( key, value ) { 434 if ( key === "classes" ) { 435 this._setOptionClasses( value ); 436 } 437 438 this.options[ key ] = value; 439 440 if ( key === "disabled" ) { 441 this._setOptionDisabled( value ); 442 } 443 444 return this; 445 }, 446 447 _setOptionClasses: function( value ) { 448 var classKey, elements, currentElements; 449 450 for ( classKey in value ) { 451 currentElements = this.classesElementLookup[ classKey ]; 452 if ( value[ classKey ] === this.options.classes[ classKey ] || 453 !currentElements || 454 !currentElements.length ) { 455 continue; 456 } 457 458 // We are doing this to create a new jQuery object because the _removeClass() call 459 // on the next line is going to destroy the reference to the current elements being 460 // tracked. We need to save a copy of this collection so that we can add the new classes 461 // below. 462 elements = $( currentElements.get() ); 463 this._removeClass( currentElements, classKey ); 464 465 // We don't use _addClass() here, because that uses this.options.classes 466 // for generating the string of classes. We want to use the value passed in from 467 // _setOption(), this is the new value of the classes option which was passed to 468 // _setOption(). We pass this value directly to _classes(). 469 elements.addClass( this._classes( { 470 element: elements, 471 keys: classKey, 472 classes: value, 473 add: true 474 } ) ); 475 } 476 }, 477 478 _setOptionDisabled: function( value ) { 479 this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, !!value ); 480 481 // If the widget is becoming disabled, then nothing is interactive 482 if ( value ) { 483 this._removeClass( this.hoverable, null, "ui-state-hover" ); 484 this._removeClass( this.focusable, null, "ui-state-focus" ); 485 } 486 }, 487 488 enable: function() { 489 return this._setOptions( { disabled: false } ); 490 }, 491 492 disable: function() { 493 return this._setOptions( { disabled: true } ); 494 }, 495 496 _classes: function( options ) { 497 var full = []; 498 var that = this; 499 500 options = $.extend( { 501 element: this.element, 502 classes: this.options.classes || {} 503 }, options ); 504 505 function processClassString( classes, checkOption ) { 506 var current, i; 507 for ( i = 0; i < classes.length; i++ ) { 508 current = that.classesElementLookup[ classes[ i ] ] || $(); 509 if ( options.add ) { 510 current = $( $.unique( current.get().concat( options.element.get() ) ) ); 511 } else { 512 current = $( current.not( options.element ).get() ); 513 } 514 that.classesElementLookup[ classes[ i ] ] = current; 515 full.push( classes[ i ] ); 516 if ( checkOption && options.classes[ classes[ i ] ] ) { 517 full.push( options.classes[ classes[ i ] ] ); 518 } 519 } 520 } 521 522 if ( options.keys ) { 523 processClassString( options.keys.match( /\S+/g ) || [], true ); 524 } 525 if ( options.extra ) { 526 processClassString( options.extra.match( /\S+/g ) || [] ); 527 } 528 529 return full.join( " "
vendor: 5,535 bytes, lines 529-727
529 ); 530 }, 531 532 _removeClass: function( element, keys, extra ) { 533 return this._toggleClass( element, keys, extra, false ); 534 }, 535 536 _addClass: function( element, keys, extra ) { 537 return this._toggleClass( element, keys, extra, true ); 538 }, 539 540 _toggleClass: function( element, keys, extra, add ) { 541 add = ( typeof add === "boolean" ) ? add : extra; 542 var shift = ( typeof element === "string" || element === null ), 543 options = { 544 extra: shift ? keys : extra, 545 keys: shift ? element : keys, 546 element: shift ? this.element : element, 547 add: add 548 }; 549 options.element.toggleClass( this._classes( options ), add ); 550 return this; 551 }, 552 553 _on: function( suppressDisabledCheck, element, handlers ) { 554 var delegateElement; 555 var instance = this; 556 557 // No suppressDisabledCheck flag, shuffle arguments 558 if ( typeof suppressDisabledCheck !== "boolean" ) { 559 handlers = element; 560 element = suppressDisabledCheck; 561 suppressDisabledCheck = false; 562 } 563 564 // No element argument, shuffle and use this.element 565 if ( !handlers ) { 566 handlers = element; 567 element = this.element; 568 delegateElement = this.widget(); 569 } else { 570 element = delegateElement = $( element ); 571 this.bindings = this.bindings.add( element ); 572 } 573 574 $.each( handlers, function( event, handler ) { 575 function handlerProxy() { 576 577 // Allow widgets to customize the disabled handling 578 // - disabled as an array instead of boolean 579 // - disabled class as method for disabling individual parts 580 if ( !suppressDisabledCheck && 581 ( instance.options.disabled === true || 582 $( this ).hasClass( "ui-state-disabled" ) ) ) { 583 return; 584 } 585 return ( typeof handler === "string" ? instance[ handler ] : handler ) 586 .apply( instance, arguments ); 587 } 588 589 // Copy the guid so direct unbinding works 590 if ( typeof handler !== "string" ) { 591 handlerProxy.guid = handler.guid = 592 handler.guid || handlerProxy.guid || $.guid++; 593 } 594 595 var match = event.match( /^([\w:-]*)\s*(.*)$/ ); 596 var eventName = match[ 1 ] + instance.eventNamespace; 597 var selector = match[ 2 ]; 598 599 if ( selector ) { 600 delegateElement.on( eventName, selector, handlerProxy ); 601 } else { 602 element.on( eventName, handlerProxy ); 603 } 604 } ); 605 }, 606 607 _off: function( element, eventName ) { 608 eventName = ( eventName || "" ).split( " " ).join( this.eventNamespace + " " ) + 609 this.eventNamespace; 610 element.off( eventName ).off( eventName ); 611 612 // Clear the stack to avoid memory leaks (#10056) 613 this.bindings = $( this.bindings.not( element ).get() ); 614 this.focusable = $( this.focusable.not( element ).get() ); 615 this.hoverable = $( this.hoverable.not( element ).get() ); 616 }, 617 618 _delay: function( handler, delay ) { 619 function handlerProxy() { 620 return ( typeof handler === "string" ? instance[ handler ] : handler ) 621 .apply( instance, arguments ); 622 } 623 var instance = this; 624 return setTimeout( handlerProxy, delay || 0 ); 625 }, 626 627 _hoverable: function( element ) { 628 this.hoverable = this.hoverable.add( element ); 629 this._on( element, { 630 mouseenter: function( event ) { 631 this._addClass( $( event.currentTarget ), null, "ui-state-hover" ); 632 }, 633 mouseleave: function( event ) { 634 this._removeClass( $( event.currentTarget ), null, "ui-state-hover" ); 635 } 636 } ); 637 }, 638 639 _focusable: function( element ) { 640 this.focusable = this.focusable.add( element ); 641 this._on( element, { 642 focusin: function( event ) { 643 this._addClass( $( event.currentTarget ), null, "ui-state-focus" ); 644 }, 645 focusout: function( event ) { 646 this._removeClass( $( event.currentTarget ), null, "ui-state-focus" ); 647 } 648 } ); 649 }, 650 651 _trigger: function( type, event, data ) { 652 var prop, orig; 653 var callback = this.options[ type ]; 654 655 data = data || {}; 656 event = $.Event( event ); 657 event.type = ( type === this.widgetEventPrefix ? 658 type : 659 this.widgetEventPrefix + type ).toLowerCase(); 660 661 // The original event may come from any element 662 // so we need to reset the target on the new event 663 event.target = this.element[ 0 ]; 664 665 // Copy original event properties over to the new event 666 orig = event.originalEvent; 667 if ( orig ) { 668 for ( prop in orig ) { 669 if ( !( prop in event ) ) { 670 event[ prop ] = orig[ prop ]; 671 } 672 } 673 } 674 675 this.element.trigger( event, data ); 676 return !( $.isFunction( callback ) && 677 callback.apply( this.element[ 0 ], [ event ].concat( data ) ) === false || 678 event.isDefaultPrevented() ); 679 } 680}; 681 682$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { 683 $.Widget.prototype[ "_" + method ] = function( element, options, callback ) { 684 if ( typeof options === "string" ) { 685 options = { effect: options }; 686 } 687 688 var hasOptions; 689 var effectName = !options ? 690 method : 691 options === true || typeof options === "number" ? 692 defaultEffect : 693 options.effect || defaultEffect; 694 695 options = options || {}; 696 if ( typeof options === "number" ) { 697 options = { duration: options }; 698 } 699 700 hasOptions = !$.isEmptyObject( options ); 701 options.complete = callback; 702 703 if ( options.delay ) { 704 element.delay( options.delay ); 705 } 706 707 if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) { 708 element[ method ]( options ); 709 } else if ( effectName !== method && element[ effectName ] ) { 710 element[ effectName ]( options.duration, options.easing, callback ); 711 } else { 712 element.queue( function( next ) { 713 $( this )[ method ](); 714 if ( callback ) { 715 callback.call( element[ 0 ] ); 716 } 717 next(); 718 } ); 719 } 720 }; 721} ); 722 723var widget = $.widget; 724 725 726/*! 727 * jQuery UI Position 1.12.
vendor: 4,892 bytes, lines 727-910
7270 728 * http://jqueryui.com 729 * 730 * Copyright jQuery Foundation and other contributors 731 * Released under the MIT license. 732 * http://jquery.org/license 733 * 734 * http://api.jqueryui.com/position/ 735 */ 736 737//>>label: Position 738//>>group: Core 739//>>description: Positions elements relative to other elements. 740//>>docs: http://api.jqueryui.com/position/ 741//>>demos: http://jqueryui.com/position/ 742 743 744( function() { 745var cachedScrollbarWidth, supportsOffsetFractions, 746 max = Math.max, 747 abs = Math.abs, 748 round = Math.round, 749 rhorizontal = /left|center|right/, 750 rvertical = /top|center|bottom/, 751 roffset = /[\+\-]\d+(\.[\d]+)?%?/, 752 rposition = /^\w+/, 753 rpercent = /%$/, 754 _position = $.fn.position; 755 756// Support: IE <=9 only 757supportsOffsetFractions = function() { 758 var element = $( "<div>" ) 759 .css( "position", "absolute" ) 760 .appendTo( "body" ) 761 .offset( { 762 top: 1.5, 763 left: 1.5 764 } ), 765 support = element.offset().top === 1.5; 766 767 element.remove(); 768 769 supportsOffsetFractions = function() { 770 return support; 771 }; 772 773 return support; 774}; 775 776function getOffsets( offsets, width, height ) { 777 return [ 778 parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ), 779 parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 ) 780 ]; 781} 782 783function parseCss( element, property ) { 784 return parseInt( $.css( element, property ), 10 ) || 0; 785} 786 787function getDimensions( elem ) { 788 var raw = elem[ 0 ]; 789 if ( raw.nodeType === 9 ) { 790 return { 791 width: elem.width(), 792 height: elem.height(), 793 offset: { top: 0, left: 0 } 794 }; 795 } 796 if ( $.isWindow( raw ) ) { 797 return { 798 width: elem.width(), 799 height: elem.height(), 800 offset: { top: elem.scrollTop(), left: elem.scrollLeft() } 801 }; 802 } 803 if ( raw.preventDefault ) { 804 return { 805 width: 0, 806 height: 0, 807 offset: { top: raw.pageY, left: raw.pageX } 808 }; 809 } 810 return { 811 width: elem.outerWidth(), 812 height: elem.outerHeight(), 813 offset: elem.offset() 814 }; 815} 816 817$.position = { 818 scrollbarWidth: function() { 819 if ( cachedScrollbarWidth !== undefined ) { 820 return cachedScrollbarWidth; 821 } 822 var w1, w2, 823 div = $( "<div " + 824 "style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'>" + 825 "<div style='height:100px;width:auto;'></div></div>" ), 826 innerDiv = div.children()[ 0 ]; 827 828 $( "body" ).append( div ); 829 w1 = innerDiv.offsetWidth; 830 div.css( "overflow", "scroll" ); 831 832 w2 = innerDiv.offsetWidth; 833 834 if ( w1 === w2 ) { 835 w2 = div[ 0 ].clientWidth; 836 } 837 838 div.remove(); 839 840 return ( cachedScrollbarWidth = w1 - w2 ); 841 }, 842 getScrollInfo: function( within ) { 843 var overflowX = within.isWindow || within.isDocument ? "" : 844 within.element.css( "overflow-x" ), 845 overflowY = within.isWindow || within.isDocument ? "" : 846 within.element.css( "overflow-y" ), 847 hasOverflowX = overflowX === "scroll" || 848 ( overflowX === "auto" && within.width < within.element[ 0 ].scrollWidth ), 849 hasOverflowY = overflowY === "scroll" || 850 ( overflowY === "auto" && within.height < within.element[ 0 ].scrollHeight ); 851 return { 852 width: hasOverflowY ? $.position.scrollbarWidth() : 0, 853 height: hasOverflowX ? $.position.scrollbarWidth() : 0 854 }; 855 }, 856 getWithinInfo: function( element ) { 857 var withinElement = $( element || window ), 858 isWindow = $.isWindow( withinElement[ 0 ] ), 859 isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9, 860 hasOffset = !isWindow && !isDocument; 861 return { 862 element: withinElement, 863 isWindow: isWindow, 864 isDocument: isDocument, 865 offset: hasOffset ? $( element ).offset() : { left: 0, top: 0 }, 866 scrollLeft: withinElement.scrollLeft(), 867 scrollTop: withinElement.scrollTop(), 868 width: withinElement.outerWidth(), 869 height: withinElement.outerHeight() 870 }; 871 } 872}; 873 874$.fn.position = function( options ) { 875 if ( !options || !options.of ) { 876 return _position.apply( this, arguments ); 877 } 878 879 // Make a copy, we don't want to modify arguments 880 options = $.extend( {}, options ); 881 882 var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions, 883 target = $( options.of ), 884 within = $.position.getWithinInfo( options.within ), 885 scrollInfo = $.position.getScrollInfo( within ), 886 collision = ( options.collision || "flip" ).split( " " ), 887 offsets = {}; 888 889 dimensions = getDimensions( target ); 890 if ( target[ 0 ].preventDefault ) { 891 892 // Force left top to allow flipping 893 options.at = "left top"; 894 } 895 targetWidth = dimensions.width; 896 targetHeight = dimensions.height; 897 targetOffset = dimensions.offset; 898 899 // Clone to reuse original targetOffset later 900 basePosition = $.extend( {}, targetOffset ); 901 902 // Force my and at to have valid horizontal and vertical positions 903 // if a value is missing or invalid, it will be converted to center 904 $.each( [ "my", "at" ], function() { 905 var pos = ( options[ this ] || "" ).split( " " ), 906 horizontalOffset, 907 verticalOffset; 908 909 if ( pos.length === 1 ) { 910 pos = rhorizontal.test( pos[ 0 ] ) ?
vendor: 4,807 bytes, lines 911-1069
911 pos.concat( [ "center" ] ) : 912 rvertical.test( pos[ 0 ] ) ? 913 [ "center" ].concat( pos ) : 914 [ "center", "center" ]; 915 } 916 pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center"; 917 pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center"; 918 919 // Calculate offsets 920 horizontalOffset = roffset.exec( pos[ 0 ] ); 921 verticalOffset = roffset.exec( pos[ 1 ] ); 922 offsets[ this ] = [ 923 horizontalOffset ? horizontalOffset[ 0 ] : 0, 924 verticalOffset ? verticalOffset[ 0 ] : 0 925 ]; 926 927 // Reduce to just the positions without the offsets 928 options[ this ] = [ 929 rposition.exec( pos[ 0 ] )[ 0 ], 930 rposition.exec( pos[ 1 ] )[ 0 ] 931 ]; 932 } ); 933 934 // Normalize collision option 935 if ( collision.length === 1 ) { 936 collision[ 1 ] = collision[ 0 ]; 937 } 938 939 if ( options.at[ 0 ] === "right" ) { 940 basePosition.left += targetWidth; 941 } else if ( options.at[ 0 ] === "center" ) { 942 basePosition.left += targetWidth / 2; 943 } 944 945 if ( options.at[ 1 ] === "bottom" ) { 946 basePosition.top += targetHeight; 947 } else if ( options.at[ 1 ] === "center" ) { 948 basePosition.top += targetHeight / 2; 949 } 950 951 atOffset = getOffsets( offsets.at, targetWidth, targetHeight ); 952 basePosition.left += atOffset[ 0 ]; 953 basePosition.top += atOffset[ 1 ]; 954 955 return this.each( function() { 956 var collisionPosition, using, 957 elem = $( this ), 958 elemWidth = elem.outerWidth(), 959 elemHeight = elem.outerHeight(), 960 marginLeft = parseCss( this, "marginLeft" ), 961 marginTop = parseCss( this, "marginTop" ), 962 collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + 963 scrollInfo.width, 964 collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + 965 scrollInfo.height, 966 position = $.extend( {}, basePosition ), 967 myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() ); 968 969 if ( options.my[ 0 ] === "right" ) { 970 position.left -= elemWidth; 971 } else if ( options.my[ 0 ] === "center" ) { 972 position.left -= elemWidth / 2; 973 } 974 975 if ( options.my[ 1 ] === "bottom" ) { 976 position.top -= elemHeight; 977 } else if ( options.my[ 1 ] === "center" ) { 978 position.top -= elemHeight / 2; 979 } 980 981 position.left += myOffset[ 0 ]; 982 position.top += myOffset[ 1 ]; 983 984 // If the browser doesn't support fractions, then round for consistent results 985 if ( !supportsOffsetFractions() ) { 986 position.left = round( position.left ); 987 position.top = round( position.top ); 988 } 989 990 collisionPosition = { 991 marginLeft: marginLeft, 992 marginTop: marginTop 993 }; 994 995 $.each( [ "left", "top" ], function( i, dir ) { 996 if ( $.ui.position[ collision[ i ] ] ) { 997 $.ui.position[ collision[ i ] ][ dir ]( position, { 998 targetWidth: targetWidth, 999 targetHeight: targetHeight, 1000 elemWidth: elemWidth, 1001 elemHeight: elemHeight, 1002 collisionPosition: collisionPosition, 1003 collisionWidth: collisionWidth, 1004 collisionHeight: collisionHeight, 1005 offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ], 1006 my: options.my, 1007 at: options.at, 1008 within: within, 1009 elem: elem 1010 } ); 1011 } 1012 } ); 1013 1014 if ( options.using ) { 1015 1016 // Adds feedback as second argument to using callback, if present 1017 using = function( props ) { 1018 var left = targetOffset.left - position.left, 1019 right = left + targetWidth - elemWidth, 1020 top = targetOffset.top - position.top, 1021 bottom = top + targetHeight - elemHeight, 1022 feedback = { 1023 target: { 1024 element: target, 1025 left: targetOffset.left, 1026 top: targetOffset.top, 1027 width: targetWidth, 1028 height: targetHeight 1029 }, 1030 element: { 1031 element: elem, 1032 left: position.left, 1033 top: position.top, 1034 width: elemWidth, 1035 height: elemHeight 1036 }, 1037 horizontal: right < 0 ? "left" : left > 0 ? "right" : "center", 1038 vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle" 1039 }; 1040 if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) { 1041 feedback.horizontal = "center"; 1042 } 1043 if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) { 1044 feedback.vertical = "middle"; 1045 } 1046 if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) { 1047 feedback.important = "horizontal"; 1048 } else { 1049 feedback.important = "vertical"; 1050 } 1051 options.using.call( this, props, feedback ); 1052 }; 1053 } 1054 1055 elem.offset( $.extend( position, { using: using } ) ); 1056 } ); 1057}; 1058 1059$.ui.position = { 1060 fit: { 1061 left: function( position, data ) { 1062 var within = data.within, 1063 withinOffset = within.isWindow ? within.scrollLeft : within.offset.left, 1064 outerWidth = within.width, 1065 collisionPosLeft = position.left - data.collisionPosition.marginLeft, 1066 overLeft = withinOffset - collisionPosLeft, 1067 overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset, 1068 newOverRight; 1069
vendor: 5,709 bytes, lines 1070-1250
1070 // Element is wider than within 1071 if ( data.collisionWidth > outerWidth ) { 1072 1073 // Element is initially over the left side of within 1074 if ( overLeft > 0 && overRight <= 0 ) { 1075 newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - 1076 withinOffset; 1077 position.left += overLeft - newOverRight; 1078 1079 // Element is initially over right side of within 1080 } else if ( overRight > 0 && overLeft <= 0 ) { 1081 position.left = withinOffset; 1082 1083 // Element is initially over both left and right sides of within 1084 } else { 1085 if ( overLeft > overRight ) { 1086 position.left = withinOffset + outerWidth - data.collisionWidth; 1087 } else { 1088 position.left = withinOffset; 1089 } 1090 } 1091 1092 // Too far left -> align with left edge 1093 } else if ( overLeft > 0 ) { 1094 position.left += overLeft; 1095 1096 // Too far right -> align with right edge 1097 } else if ( overRight > 0 ) { 1098 position.left -= overRight; 1099 1100 // Adjust based on position and margin 1101 } else { 1102 position.left = max( position.left - collisionPosLeft, position.left ); 1103 } 1104 }, 1105 top: function( position, data ) { 1106 var within = data.within, 1107 withinOffset = within.isWindow ? within.scrollTop : within.offset.top, 1108 outerHeight = data.within.height, 1109 collisionPosTop = position.top - data.collisionPosition.marginTop, 1110 overTop = withinOffset - collisionPosTop, 1111 overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset, 1112 newOverBottom; 1113 1114 // Element is taller than within 1115 if ( data.collisionHeight > outerHeight ) { 1116 1117 // Element is initially over the top of within 1118 if ( overTop > 0 && overBottom <= 0 ) { 1119 newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - 1120 withinOffset; 1121 position.top += overTop - newOverBottom; 1122 1123 // Element is initially over bottom of within 1124 } else if ( overBottom > 0 && overTop <= 0 ) { 1125 position.top = withinOffset; 1126 1127 // Element is initially over both top and bottom of within 1128 } else { 1129 if ( overTop > overBottom ) { 1130 position.top = withinOffset + outerHeight - data.collisionHeight; 1131 } else { 1132 position.top = withinOffset; 1133 } 1134 } 1135 1136 // Too far up -> align with top 1137 } else if ( overTop > 0 ) { 1138 position.top += overTop; 1139 1140 // Too far down -> align with bottom edge 1141 } else if ( overBottom > 0 ) { 1142 position.top -= overBottom; 1143 1144 // Adjust based on position and margin 1145 } else { 1146 position.top = max( position.top - collisionPosTop, position.top ); 1147 } 1148 } 1149 }, 1150 flip: { 1151 left: function( position, data ) { 1152 var within = data.within, 1153 withinOffset = within.offset.left + within.scrollLeft, 1154 outerWidth = within.width, 1155 offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left, 1156 collisionPosLeft = position.left - data.collisionPosition.marginLeft, 1157 overLeft = collisionPosLeft - offsetLeft, 1158 overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft, 1159 myOffset = data.my[ 0 ] === "left" ? 1160 -data.elemWidth : 1161 data.my[ 0 ] === "right" ? 1162 data.elemWidth : 1163 0, 1164 atOffset = data.at[ 0 ] === "left" ? 1165 data.targetWidth : 1166 data.at[ 0 ] === "right" ? 1167 -data.targetWidth : 1168 0, 1169 offset = -2 * data.offset[ 0 ], 1170 newOverRight, 1171 newOverLeft; 1172 1173 if ( overLeft < 0 ) { 1174 newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - 1175 outerWidth - withinOffset; 1176 if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) { 1177 position.left += myOffset + atOffset + offset; 1178 } 1179 } else if ( overRight > 0 ) { 1180 newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + 1181 atOffset + offset - offsetLeft; 1182 if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) { 1183 position.left += myOffset + atOffset + offset; 1184 } 1185 } 1186 }, 1187 top: function( position, data ) { 1188 var within = data.within, 1189 withinOffset = within.offset.top + within.scrollTop, 1190 outerHeight = within.height, 1191 offsetTop = within.isWindow ? within.scrollTop : within.offset.top, 1192 collisionPosTop = position.top - data.collisionPosition.marginTop, 1193 overTop = collisionPosTop - offsetTop, 1194 overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop, 1195 top = data.my[ 1 ] === "top", 1196 myOffset = top ? 1197 -data.elemHeight : 1198 data.my[ 1 ] === "bottom" ? 1199 data.elemHeight : 1200 0, 1201 atOffset = data.at[ 1 ] === "top" ? 1202 data.targetHeight : 1203 data.at[ 1 ] === "bottom" ? 1204 -data.targetHeight : 1205 0, 1206 offset = -2 * data.offset[ 1 ], 1207 newOverTop, 1208 newOverBottom; 1209 if ( overTop < 0 ) { 1210 newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - 1211 outerHeight - withinOffset; 1212 if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) { 1213 position.top += myOffset + atOffset + offset; 1214 } 1215 } else if ( overBottom > 0 ) { 1216 newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + 1217 offset - offsetTop; 1218 if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) { 1219 position.top += myOffset + atOffset + offset; 1220 } 1221 } 1222 } 1223 }, 1224 flipfit: { 1225 left: function() { 1226 $.ui.position.flip.left.apply( this, arguments ); 1227 $.ui.position.fit.left.apply( this, arguments ); 1228 }, 1229 top: function() { 1230 $.ui.position.flip.top.apply( this, arguments ); 1231 $.ui.position.fit.top.apply( this, arguments ); 1232 } 1233 } 1234}; 1235 1236} )(); 1237 1238var position = $.ui.position; 1239 1240 1241/*! 1242 * jQuery UI :data 1.12.0 1243 * http://jqueryui.com 1244 * 1245 * Copyright jQuery Foundation and other contributors 1246 * Released under the MIT license. 1247 * http://jquery.org/license 1248 */ 1249 1250//>>label: :data Selector
vendor: 10,167 bytes, lines 1251-1671
1251//>>group: Core 1252//>>description: Selects elements which have data stored under the specified key. 1253//>>docs: http://api.jqueryui.com/data-selector/ 1254 1255 1256var data = $.extend( $.expr[ ":" ], { 1257 data: $.expr.createPseudo ? 1258 $.expr.createPseudo( function( dataName ) { 1259 return function( elem ) { 1260 return !!$.data( elem, dataName ); 1261 }; 1262 } ) : 1263 1264 // Support: jQuery <1.8 1265 function( elem, i, match ) { 1266 return !!$.data( elem, match[ 3 ] ); 1267 } 1268} ); 1269 1270/*! 1271 * jQuery UI Disable Selection 1.12.0 1272 * http://jqueryui.com 1273 * 1274 * Copyright jQuery Foundation and other contributors 1275 * Released under the MIT license. 1276 * http://jquery.org/license 1277 */ 1278 1279//>>label: disableSelection 1280//>>group: Core 1281//>>description: Disable selection of text content within the set of matched elements. 1282//>>docs: http://api.jqueryui.com/disableSelection/ 1283 1284// This file is deprecated 1285 1286 1287var disableSelection = $.fn.extend( { 1288 disableSelection: ( function() { 1289 var eventType = "onselectstart" in document.createElement( "div" ) ? 1290 "selectstart" : 1291 "mousedown"; 1292 1293 return function() { 1294 return this.on( eventType + ".ui-disableSelection", function( event ) { 1295 event.preventDefault(); 1296 } ); 1297 }; 1298 } )(), 1299 1300 enableSelection: function() { 1301 return this.off( ".ui-disableSelection" ); 1302 } 1303} ); 1304 1305 1306/*! 1307 * jQuery UI Focusable 1.12.0 1308 * http://jqueryui.com 1309 * 1310 * Copyright jQuery Foundation and other contributors 1311 * Released under the MIT license. 1312 * http://jquery.org/license 1313 */ 1314 1315//>>label: :focusable Selector 1316//>>group: Core 1317//>>description: Selects elements which can be focused. 1318//>>docs: http://api.jqueryui.com/focusable-selector/ 1319 1320 1321 1322// Selectors 1323$.ui.focusable = function( element, hasTabindex ) { 1324 var map, mapName, img, focusableIfVisible, fieldset, 1325 nodeName = element.nodeName.toLowerCase(); 1326 1327 if ( "area" === nodeName ) { 1328 map = element.parentNode; 1329 mapName = map.name; 1330 if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) { 1331 return false; 1332 } 1333 img = $( "img[usemap='#" + mapName + "']" ); 1334 return img.length > 0 && img.is( ":visible" ); 1335 } 1336 1337 if ( /^(input|select|textarea|button|object)$/.test( nodeName ) ) { 1338 focusableIfVisible = !element.disabled; 1339 1340 if ( focusableIfVisible ) { 1341 1342 // Form controls within a disabled fieldset are disabled. 1343 // However, controls within the fieldset's legend do not get disabled. 1344 // Since controls generally aren't placed inside legends, we skip 1345 // this portion of the check. 1346 fieldset = $( element ).closest( "fieldset" )[ 0 ]; 1347 if ( fieldset ) { 1348 focusableIfVisible = !fieldset.disabled; 1349 } 1350 } 1351 } else if ( "a" === nodeName ) { 1352 focusableIfVisible = element.href || hasTabindex; 1353 } else { 1354 focusableIfVisible = hasTabindex; 1355 } 1356 1357 return focusableIfVisible && $( element ).is( ":visible" ) && visible( $( element ) ); 1358}; 1359 1360// Support: IE 8 only 1361// IE 8 doesn't resolve inherit to visible/hidden for computed values 1362function visible( element ) { 1363 var visibility = element.css( "visibility" ); 1364 while ( visibility === "inherit" ) { 1365 element = element.parent(); 1366 visibility = element.css( "visibility" ); 1367 } 1368 return visibility !== "hidden"; 1369} 1370 1371$.extend( $.expr[ ":" ], { 1372 focusable: function( element ) { 1373 return $.ui.focusable( element, $.attr( element, "tabindex" ) != null ); 1374 } 1375} ); 1376 1377var focusable = $.ui.focusable; 1378 1379 1380 1381 1382// Support: IE8 Only 1383// IE8 does not support the form attribute and when it is supplied. It overwrites the form prop 1384// with a string, so we need to find the proper form. 1385var form = $.fn.form = function() { 1386 return typeof this[ 0 ].form === "string" ? this.closest( "form" ) : $( this[ 0 ].form ); 1387}; 1388 1389 1390/*! 1391 * jQuery UI Form Reset Mixin 1.12.0 1392 * http://jqueryui.com 1393 * 1394 * Copyright jQuery Foundation and other contributors 1395 * Released under the MIT license. 1396 * http://jquery.org/license 1397 */ 1398 1399//>>label: Form Reset Mixin 1400//>>group: Core 1401//>>description: Refresh input widgets when their form is reset 1402//>>docs: http://api.jqueryui.com/form-reset-mixin/ 1403 1404 1405 1406var formResetMixin = $.ui.formResetMixin = { 1407 _formResetHandler: function() { 1408 var form = $( this ); 1409 1410 // Wait for the form reset to actually happen before refreshing 1411 setTimeout( function() { 1412 var instances = form.data( "ui-form-reset-instances" ); 1413 $.each( instances, function() { 1414 this.refresh(); 1415 } ); 1416 } ); 1417 }, 1418 1419 _bindFormResetHandler: function() { 1420 this.form = this.element.form(); 1421 if ( !this.form.length ) { 1422 return; 1423 } 1424 1425 var instances = this.form.data( "ui-form-reset-instances" ) || []; 1426 if ( !instances.length ) { 1427 1428 // We don't use _on() here because we use a single event handler per form 1429 this.form.on( "reset.ui-form-reset", this._formResetHandler ); 1430 } 1431 instances.push( this ); 1432 this.form.data( "ui-form-reset-instances", instances ); 1433 }, 1434 1435 _unbindFormResetHandler: function() { 1436 if ( !this.form.length ) { 1437 return; 1438 } 1439 1440 var instances = this.form.data( "ui-form-reset-instances" ); 1441 instances.splice( $.inArray( this, instances ), 1 ); 1442 if ( instances.length ) { 1443 this.form.data( "ui-form-reset-instances", instances ); 1444 } else { 1445 this.form 1446 .removeData( "ui-form-reset-instances" ) 1447 .off( "reset.ui-form-reset" ); 1448 } 1449 } 1450}; 1451 1452 1453/*! 1454 * jQuery UI Keycode 1.12.0 1455 * http://jqueryui.com 1456 * 1457 * Copyright jQuery Foundation and other contributors 1458 * Released under the MIT license. 1459 * http://jquery.org/license 1460 */ 1461 1462//>>label: Keycode 1463//>>group: Core 1464//>>description: Provide keycodes as keynames 1465//>>docs: http://api.jqueryui.com/jQuery.ui.keyCode/ 1466 1467 1468var keycode = $.ui.keyCode = { 1469 BACKSPACE: 8, 1470 COMMA: 188, 1471 DELETE: 46, 1472 DOWN: 40, 1473 END: 35, 1474 ENTER: 13, 1475 ESCAPE: 27, 1476 HOME: 36, 1477 LEFT: 37, 1478 PAGE_DOWN: 34, 1479 PAGE_UP: 33, 1480 PERIOD: 190, 1481 RIGHT: 39, 1482 SPACE: 32, 1483 TAB: 9, 1484 UP: 38 1485}; 1486 1487 1488 1489 1490// Internal use only 1491var escapeSelector = $.ui.escapeSelector = ( function() { 1492 var selectorEscape = /([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g; 1493 return function( selector ) { 1494 return selector.replace( selectorEscape, "\\$1" ); 1495 }; 1496} )(); 1497 1498 1499/*! 1500 * jQuery UI Labels 1.12.0 1501 * http://jqueryui.com 1502 * 1503 * Copyright jQuery Foundation and other contributors 1504 * Released under the MIT license. 1505 * http://jquery.org/license 1506 */ 1507 1508//>>label: labels 1509//>>group: Core 1510//>>description: Find all the labels associated with a given input 1511//>>docs: http://api.jqueryui.com/labels/ 1512 1513 1514 1515var labels = $.fn.labels = function() { 1516 var ancestor, selector, id, labels, ancestors; 1517 1518 // Check control.labels first 1519 if ( this[ 0 ].labels && this[ 0 ].labels.length ) { 1520 return this.pushStack( this[ 0 ].labels ); 1521 } 1522 1523 // Support: IE <= 11, FF <= 37, Android <= 2.3 only 1524 // Above browsers do not support control.labels. Everything below is to support them 1525 // as well as document fragments. control.labels does not work on document fragments 1526 labels = this.eq( 0 ).parents( "label" ); 1527 1528 // Look for the label based on the id 1529 id = this.attr( "id" ); 1530 if ( id ) { 1531 1532 // We don't search against the document in case the element 1533 // is disconnected from the DOM 1534 ancestor = this.eq( 0 ).parents().last(); 1535 1536 // Get a full set of top level ancestors 1537 ancestors = ancestor.add( ancestor.length ? ancestor.siblings() : this.siblings() ); 1538 1539 // Create a selector for the label based on the id 1540 selector = "label[for='" + $.ui.escapeSelector( id ) + "']"; 1541 1542 labels = labels.add( ancestors.find( selector ).addBack( selector ) ); 1543 1544 } 1545 1546 // Return whatever we have found for labels 1547 return this.pushStack( labels ); 1548}; 1549 1550 1551/*! 1552 * jQuery UI Scroll Parent 1.12.0 1553 * http://jqueryui.com 1554 * 1555 * Copyright jQuery Foundation and other contributors 1556 * Released under the MIT license. 1557 * http://jquery.org/license 1558 */ 1559 1560//>>label: scrollParent 1561//>>group: Core 1562//>>description: Get the closest ancestor element that is scrollable. 1563//>>docs: http://api.jqueryui.com/scrollParent/ 1564 1565 1566 1567var scrollParent = $.fn.scrollParent = function( includeHidden ) { 1568 var position = this.css( "position" ), 1569 excludeStaticParent = position === "absolute", 1570 overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/, 1571 scrollParent = this.parents().filter( function() { 1572 var parent = $( this ); 1573 if ( excludeStaticParent && parent.css( "position" ) === "static" ) { 1574 return false; 1575 } 1576 return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + 1577 parent.css( "overflow-x" ) ); 1578 } ).eq( 0 ); 1579 1580 return position === "fixed" || !scrollParent.length ? 1581 $( this[ 0 ].ownerDocument || document ) : 1582 scrollParent; 1583}; 1584 1585 1586/*! 1587 * jQuery UI Tabbable 1.12.0 1588 * http://jqueryui.com 1589 * 1590 * Copyright jQuery Foundation and other contributors 1591 * Released under the MIT license. 1592 * http://jquery.org/license 1593 */ 1594 1595//>>label: :tabbable Selector 1596//>>group: Core 1597//>>description: Selects elements which can be tabbed to. 1598//>>docs: http://api.jqueryui.com/tabbable-selector/ 1599 1600 1601 1602var tabbable = $.extend( $.expr[ ":" ], { 1603 tabbable: function( element ) { 1604 var tabIndex = $.attr( element, "tabindex" ), 1605 hasTabindex = tabIndex != null; 1606 return ( !hasTabindex || tabIndex >= 0 ) && $.ui.focusable( element, hasTabindex ); 1607 } 1608} ); 1609 1610 1611/*! 1612 * jQuery UI Unique ID 1.12.0 1613 * http://jqueryui.com 1614 * 1615 * Copyright jQuery Foundation and other contributors 1616 * Released under the MIT license. 1617 * http://jquery.org/license 1618 */ 1619 1620//>>label: uniqueId 1621//>>group: Core 1622//>>description: Functions to generate and remove uniqueId's 1623//>>docs: http://api.jqueryui.com/uniqueId/ 1624 1625 1626 1627var uniqueId = $.fn.extend( { 1628 uniqueId: ( function() { 1629 var uuid = 0; 1630 1631 return function() { 1632 return this.each( function() { 1633 if ( !this.id ) { 1634 this.id = "ui-id-" + ( ++uuid ); 1635 } 1636 } ); 1637 }; 1638 } )(), 1639 1640 removeUniqueId: function() { 1641 return this.each( function() { 1642 if ( /^ui-id-\d+$/.test( this.id ) ) { 1643 $( this ).removeAttr( "id" ); 1644 } 1645 } ); 1646 } 1647} ); 1648 1649 1650 1651 1652// This file is deprecated 1653var ie = $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() ); 1654 1655/*! 1656 * jQuery UI Mouse 1.12.0 1657 * http://jqueryui.com 1658 * 1659 * Copyright jQuery Foundation and other contributors 1660 * Released under the MIT license. 1661 * http://jquery.org/license 1662 */ 1663 1664//>>label: Mouse 1665//>>group: Widgets 1666//>>description: Abstracts mouse-based interactions to assist in creating certain widgets. 1667//>>docs: http://api.jqueryui.com/mouse/ 1668 1669 1670 1671var mouseHandled = false;
vendor: 4,578 bytes, lines 1672-1827
1672$( document ).on( "mouseup", function() { 1673 mouseHandled = false; 1674} ); 1675 1676var widgetsMouse = $.widget( "ui.mouse", { 1677 version: "1.12.0", 1678 options: { 1679 cancel: "input, textarea, button, select, option", 1680 distance: 1, 1681 delay: 0 1682 }, 1683 _mouseInit: function() { 1684 var that = this; 1685 1686 this.element 1687 .on( "mousedown." + this.widgetName, function( event ) { 1688 return that._mouseDown( event ); 1689 } ) 1690 .on( "click." + this.widgetName, function( event ) { 1691 if ( true === $.data( event.target, that.widgetName + ".preventClickEvent" ) ) { 1692 $.removeData( event.target, that.widgetName + ".preventClickEvent" ); 1693 event.stopImmediatePropagation(); 1694 return false; 1695 } 1696 } ); 1697 1698 this.started = false; 1699 }, 1700 1701 // TODO: make sure destroying one instance of mouse doesn't mess with 1702 // other instances of mouse 1703 _mouseDestroy: function() { 1704 this.element.off( "." + this.widgetName ); 1705 if ( this._mouseMoveDelegate ) { 1706 this.document 1707 .off( "mousemove." + this.widgetName, this._mouseMoveDelegate ) 1708 .off( "mouseup." + this.widgetName, this._mouseUpDelegate ); 1709 } 1710 }, 1711 1712 _mouseDown: function( event ) { 1713 1714 // don't let more than one widget handle mouseStart 1715 if ( mouseHandled ) { 1716 return; 1717 } 1718 1719 this._mouseMoved = false; 1720 1721 // We may have missed mouseup (out of window) 1722 ( this._mouseStarted && this._mouseUp( event ) ); 1723 1724 this._mouseDownEvent = event; 1725 1726 var that = this, 1727 btnIsLeft = ( event.which === 1 ), 1728 1729 // event.target.nodeName works around a bug in IE 8 with 1730 // disabled inputs (#7620) 1731 elIsCancel = ( typeof this.options.cancel === "string" && event.target.nodeName ? 1732 $( event.target ).closest( this.options.cancel ).length : false ); 1733 if ( !btnIsLeft || elIsCancel || !this._mouseCapture( event ) ) { 1734 return true; 1735 } 1736 1737 this.mouseDelayMet = !this.options.delay; 1738 if ( !this.mouseDelayMet ) { 1739 this._mouseDelayTimer = setTimeout( function() { 1740 that.mouseDelayMet = true; 1741 }, this.options.delay ); 1742 } 1743 1744 if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) { 1745 this._mouseStarted = ( this._mouseStart( event ) !== false ); 1746 if ( !this._mouseStarted ) { 1747 event.preventDefault(); 1748 return true; 1749 } 1750 } 1751 1752 // Click event may never have fired (Gecko & Opera) 1753 if ( true === $.data( event.target, this.widgetName + ".preventClickEvent" ) ) { 1754 $.removeData( event.target, this.widgetName + ".preventClickEvent" ); 1755 } 1756 1757 // These delegates are required to keep context 1758 this._mouseMoveDelegate = function( event ) { 1759 return that._mouseMove( event ); 1760 }; 1761 this._mouseUpDelegate = function( event ) { 1762 return that._mouseUp( event ); 1763 }; 1764 1765 this.document 1766 .on( "mousemove." + this.widgetName, this._mouseMoveDelegate ) 1767 .on( "mouseup." + this.widgetName, this._mouseUpDelegate ); 1768 1769 event.preventDefault(); 1770 1771 mouseHandled = true; 1772 return true; 1773 }, 1774 1775 _mouseMove: function( event ) { 1776 1777 // Only check for mouseups outside the document if you've moved inside the document 1778 // at least once. This prevents the firing of mouseup in the case of IE<9, which will 1779 // fire a mousemove event if content is placed under the cursor. See #7778 1780 // Support: IE <9 1781 if ( this._mouseMoved ) { 1782 1783 // IE mouseup check - mouseup happened when mouse was out of window 1784 if ( $.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && 1785 !event.button ) { 1786 return this._mouseUp( event ); 1787 1788 // Iframe mouseup check - mouseup occurred in another document 1789 } else if ( !event.which ) { 1790 1791 // Support: Safari <=8 - 9 1792 // Safari sets which to 0 if you press any of the following keys 1793 // during a drag (#14461) 1794 if ( event.originalEvent.altKey || event.originalEvent.ctrlKey || 1795 event.originalEvent.metaKey || event.originalEvent.shiftKey ) { 1796 this.ignoreMissingWhich = true; 1797 } else if ( !this.ignoreMissingWhich ) { 1798 return this._mouseUp( event ); 1799 } 1800 } 1801 } 1802 1803 if ( event.which || event.button ) { 1804 this._mouseMoved = true; 1805 } 1806 1807 if ( this._mouseStarted ) { 1808 this._mouseDrag( event ); 1809 return event.preventDefault(); 1810 } 1811 1812 if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) { 1813 this._mouseStarted = 1814 ( this._mouseStart( this._mouseDownEvent, event ) !== false ); 1815 ( this._mouseStarted ? this._mouseDrag( event ) : this._mouseUp( event ) ); 1816 } 1817 1818 return !this._mouseStarted; 1819 }, 1820 1821 _mouseUp: function( event ) { 1822 this.document 1823 .off( "mousemove." + this.widgetName, this._mouseMoveDelegate ) 1824 .off( "mouseup." + this.widgetName, this._mouseUpDelegate ); 1825 1826 if ( this._mouseStarted ) { 1827 this._mouseStarted = false;
vendor: 4,636 bytes, lines 1828-2031
1828 1829 if ( event.target === this._mouseDownEvent.target ) { 1830 $.data( event.target, this.widgetName + ".preventClickEvent", true ); 1831 } 1832 1833 this._mouseStop( event ); 1834 } 1835 1836 if ( this._mouseDelayTimer ) { 1837 clearTimeout( this._mouseDelayTimer ); 1838 delete this._mouseDelayTimer; 1839 } 1840 1841 this.ignoreMissingWhich = false; 1842 mouseHandled = false; 1843 event.preventDefault(); 1844 }, 1845 1846 _mouseDistanceMet: function( event ) { 1847 return ( Math.max( 1848 Math.abs( this._mouseDownEvent.pageX - event.pageX ), 1849 Math.abs( this._mouseDownEvent.pageY - event.pageY ) 1850 ) >= this.options.distance 1851 ); 1852 }, 1853 1854 _mouseDelayMet: function( /* event */ ) { 1855 return this.mouseDelayMet; 1856 }, 1857 1858 // These are placeholder methods, to be overriden by extending plugin 1859 _mouseStart: function( /* event */ ) {}, 1860 _mouseDrag: function( /* event */ ) {}, 1861 _mouseStop: function( /* event */ ) {}, 1862 _mouseCapture: function( /* event */ ) { return true; } 1863} ); 1864 1865 1866 1867 1868// $.ui.plugin is deprecated. Use $.widget() extensions instead. 1869var plugin = $.ui.plugin = { 1870 add: function( module, option, set ) { 1871 var i, 1872 proto = $.ui[ module ].prototype; 1873 for ( i in set ) { 1874 proto.plugins[ i ] = proto.plugins[ i ] || []; 1875 proto.plugins[ i ].push( [ option, set[ i ] ] ); 1876 } 1877 }, 1878 call: function( instance, name, args, allowDisconnected ) { 1879 var i, 1880 set = instance.plugins[ name ]; 1881 1882 if ( !set ) { 1883 return; 1884 } 1885 1886 if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || 1887 instance.element[ 0 ].parentNode.nodeType === 11 ) ) { 1888 return; 1889 } 1890 1891 for ( i = 0; i < set.length; i++ ) { 1892 if ( instance.options[ set[ i ][ 0 ] ] ) { 1893 set[ i ][ 1 ].apply( instance.element, args ); 1894 } 1895 } 1896 } 1897}; 1898 1899 1900 1901var safeActiveElement = $.ui.safeActiveElement = function( document ) { 1902 var activeElement; 1903 1904 // Support: IE 9 only 1905 // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe> 1906 try { 1907 activeElement = document.activeElement; 1908 } catch ( error ) { 1909 activeElement = document.body; 1910 } 1911 1912 // Support: IE 9 - 11 only 1913 // IE may return null instead of an element 1914 // Interestingly, this only seems to occur when NOT in an iframe 1915 if ( !activeElement ) { 1916 activeElement = document.body; 1917 } 1918 1919 // Support: IE 11 only 1920 // IE11 returns a seemingly empty object in some cases when accessing 1921 // document.activeElement from an <iframe> 1922 if ( !activeElement.nodeName ) { 1923 activeElement = document.body; 1924 } 1925 1926 return activeElement; 1927}; 1928 1929 1930 1931var safeBlur = $.ui.safeBlur = function( element ) { 1932 1933 // Support: IE9 - 10 only 1934 // If the <body> is blurred, IE will switch windows, see #9420 1935 if ( element && element.nodeName.toLowerCase() !== "body" ) { 1936 $( element ).trigger( "blur" ); 1937 } 1938}; 1939 1940 1941/*! 1942 * jQuery UI Draggable 1.12.0 1943 * http://jqueryui.com 1944 * 1945 * Copyright jQuery Foundation and other contributors 1946 * Released under the MIT license. 1947 * http://jquery.org/license 1948 */ 1949 1950//>>label: Draggable 1951//>>group: Interactions 1952//>>description: Enables dragging functionality for any element. 1953//>>docs: http://api.jqueryui.com/draggable/ 1954//>>demos: http://jqueryui.com/draggable/ 1955//>>css.structure: ../../themes/base/draggable.css 1956 1957 1958 1959$.widget( "ui.draggable", $.ui.mouse, { 1960 version: "1.12.0", 1961 widgetEventPrefix: "drag", 1962 options: { 1963 addClasses: true, 1964 appendTo: "parent", 1965 axis: false, 1966 connectToSortable: false, 1967 containment: false, 1968 cursor: "auto", 1969 cursorAt: false, 1970 grid: false, 1971 handle: false, 1972 helper: "original", 1973 iframeFix: false, 1974 opacity: false, 1975 refreshPositions: false, 1976 revert: false, 1977 revertDuration: 500, 1978 scope: "default", 1979 scroll: true, 1980 scrollSensitivity: 20, 1981 scrollSpeed: 20, 1982 snap: false, 1983 snapMode: "both", 1984 snapTolerance: 20, 1985 stack: false, 1986 zIndex: false, 1987 1988 // Callbacks 1989 drag: null, 1990 start: null, 1991 stop: null 1992 }, 1993 _create: function() { 1994 1995 if ( this.options.helper === "original" ) { 1996 this._setPositionRelative(); 1997 } 1998 if ( this.options.addClasses ) { 1999 this._addClass( "ui-draggable" ); 2000 } 2001 this._setHandleClassName(); 2002 2003 this._mouseInit(); 2004 }, 2005 2006 _setOption: function( key, value ) { 2007 this._super( key, value ); 2008 if ( key === "handle" ) { 2009 this._removeHandleClassName(); 2010 this._setHandleClassName(); 2011 } 2012 }, 2013 2014 _destroy: function() { 2015 if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) { 2016 this.destroyOnClear = true; 2017 return; 2018 } 2019 this._removeHandleClassName(); 2020 this._mouseDestroy(); 2021 }, 2022 2023 _mouseCapture: function( event ) { 2024 var o = this.options; 2025 2026 this._blurActiveElement( event ); 2027 2028 // Among others, prevent a drag on a resizable-handle 2029 if ( this.helper || o.disabled || 2030 $( event.target ).closest( ".ui-resizable-handle" ).length > 0 ) { 2031 return false;
vendor: 1,058 bytes, lines 2032-2074
2032 } 2033 2034 //Quit if we're not on a valid handle 2035 this.handle = this._getHandle( event ); 2036 if ( !this.handle ) { 2037 return false; 2038 } 2039 2040 this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix ); 2041 2042 return true; 2043 2044 }, 2045 2046 _blockFrames: function( selector ) { 2047 this.iframeBlocks = this.document.find( selector ).map( function() { 2048 var iframe = $( this ); 2049 2050 return $( "<div>" ) 2051 .css( "position", "absolute" ) 2052 .appendTo( iframe.parent() ) 2053 .outerWidth( iframe.outerWidth() ) 2054 .outerHeight( iframe.outerHeight() ) 2055 .offset( iframe.offset() )[ 0 ]; 2056 } ); 2057 }, 2058 2059 _unblockFrames: function() { 2060 if ( this.iframeBlocks ) { 2061 this.iframeBlocks.remove(); 2062 delete this.iframeBlocks; 2063 } 2064 }, 2065 2066 _blurActiveElement: function( event ) { 2067 var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ), 2068 target = $( event.target ); 2069 2070 // Only blur if the event occurred on an element that is: 2071 // 1) within the draggable handle 2072 // 2) but not within the currently focused element 2073 // See #10527, #12472 2074 if ( this._getHandle( event ) &&
vendor: 32,180 bytes, lines 2074-3173
2074 target.closest( activeElement ).length ) { 2075 return; 2076 } 2077 2078 // Blur any element that currently has focus, see #4261 2079 $.ui.safeBlur( activeElement ); 2080 }, 2081 2082 _mouseStart: function( event ) { 2083 2084 var o = this.options; 2085 2086 //Create and append the visible helper 2087 this.helper = this._createHelper( event ); 2088 2089 this._addClass( this.helper, "ui-draggable-dragging" ); 2090 2091 //Cache the helper size 2092 this._cacheHelperProportions(); 2093 2094 //If ddmanager is used for droppables, set the global draggable 2095 if ( $.ui.ddmanager ) { 2096 $.ui.ddmanager.current = this; 2097 } 2098 2099 /* 2100 * - Position generation - 2101 * This block generates everything position related - it's the core of draggables. 2102 */ 2103 2104 //Cache the margins of the original element 2105 this._cacheMargins(); 2106 2107 //Store the helper's css position 2108 this.cssPosition = this.helper.css( "position" ); 2109 this.scrollParent = this.helper.scrollParent( true ); 2110 this.offsetParent = this.helper.offsetParent(); 2111 this.hasFixedAncestor = this.helper.parents().filter( function() { 2112 return $( this ).css( "position" ) === "fixed"; 2113 } ).length > 0; 2114 2115 //The element's absolute position on the page minus margins 2116 this.positionAbs = this.element.offset(); 2117 this._refreshOffsets( event ); 2118 2119 //Generate the original position 2120 this.originalPosition = this.position = this._generatePosition( event, false ); 2121 this.originalPageX = event.pageX; 2122 this.originalPageY = event.pageY; 2123 2124 //Adjust the mouse offset relative to the helper if "cursorAt" is supplied 2125 ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) ); 2126 2127 //Set a containment if given in the options 2128 this._setContainment(); 2129 2130 //Trigger event + callbacks 2131 if ( this._trigger( "start", event ) === false ) { 2132 this._clear(); 2133 return false; 2134 } 2135 2136 //Recache the helper size 2137 this._cacheHelperProportions(); 2138 2139 //Prepare the droppable offsets 2140 if ( $.ui.ddmanager && !o.dropBehaviour ) { 2141 $.ui.ddmanager.prepareOffsets( this, event ); 2142 } 2143 2144 // Execute the drag once - this causes the helper not to be visible before getting its 2145 // correct position 2146 this._mouseDrag( event, true ); 2147 2148 // If the ddmanager is used for droppables, inform the manager that dragging has started 2149 // (see #5003) 2150 if ( $.ui.ddmanager ) { 2151 $.ui.ddmanager.dragStart( this, event ); 2152 } 2153 2154 return true; 2155 }, 2156 2157 _refreshOffsets: function( event ) { 2158 this.offset = { 2159 top: this.positionAbs.top - this.margins.top, 2160 left: this.positionAbs.left - this.margins.left, 2161 scroll: false, 2162 parent: this._getParentOffset(), 2163 relative: this._getRelativeOffset() 2164 }; 2165 2166 this.offset.click = { 2167 left: event.pageX - this.offset.left, 2168 top: event.pageY - this.offset.top 2169 }; 2170 }, 2171 2172 _mouseDrag: function( event, noPropagation ) { 2173 2174 // reset any necessary cached properties (see #5009) 2175 if ( this.hasFixedAncestor ) { 2176 this.offset.parent = this._getParentOffset(); 2177 } 2178 2179 //Compute the helpers position 2180 this.position = this._generatePosition( event, true ); 2181 this.positionAbs = this._convertPositionTo( "absolute" ); 2182 2183 //Call plugins and callbacks and use the resulting position if something is returned 2184 if ( !noPropagation ) { 2185 var ui = this._uiHash(); 2186 if ( this._trigger( "drag", event, ui ) === false ) { 2187 this._mouseUp( new $.Event( "mouseup", event ) ); 2188 return false; 2189 } 2190 this.position = ui.position; 2191 } 2192 2193 this.helper[ 0 ].style.left = this.position.left + "px"; 2194 this.helper[ 0 ].style.top = this.position.top + "px"; 2195 2196 if ( $.ui.ddmanager ) { 2197 $.ui.ddmanager.drag( this, event ); 2198 } 2199 2200 return false; 2201 }, 2202 2203 _mouseStop: function( event ) { 2204 2205 //If we are using droppables, inform the manager about the drop 2206 var that = this, 2207 dropped = false; 2208 if ( $.ui.ddmanager && !this.options.dropBehaviour ) { 2209 dropped = $.ui.ddmanager.drop( this, event ); 2210 } 2211 2212 //if a drop comes from outside (a sortable) 2213 if ( this.dropped ) { 2214 dropped = this.dropped; 2215 this.dropped = false; 2216 } 2217 2218 if ( ( this.options.revert === "invalid" && !dropped ) || 2219 ( this.options.revert === "valid" && dropped ) || 2220 this.options.revert === true || ( $.isFunction( this.options.revert ) && 2221 this.options.revert.call( this.element, dropped ) ) 2222 ) { 2223 $( this.helper ).animate( 2224 this.originalPosition, 2225 parseInt( this.options.revertDuration, 10 ), 2226 function() { 2227 if ( that._trigger( "stop", event ) !== false ) { 2228 that._clear(); 2229 } 2230 } 2231 ); 2232 } else { 2233 if ( this._trigger( "stop", event ) !== false ) { 2234 this._clear(); 2235 } 2236 } 2237 2238 return false; 2239 }, 2240 2241 _mouseUp: function( event ) { 2242 this._unblockFrames(); 2243 2244 // If the ddmanager is used for droppables, inform the manager that dragging has stopped 2245 // (see #5003) 2246 if ( $.ui.ddmanager ) { 2247 $.ui.ddmanager.dragStop( this, event ); 2248 } 2249 2250 // Only need to focus if the event occurred on the draggable itself, see #10527 2251 if ( this.handleElement.is( event.target ) ) { 2252 2253 // The interaction is over; whether or not the click resulted in a drag, 2254 // focus the element 2255 this.element.trigger( "focus" ); 2256 } 2257 2258 return $.ui.mouse.prototype._mouseUp.call( this, event ); 2259 }, 2260 2261 cancel: function() { 2262 2263 if ( this.helper.is( ".ui-draggable-dragging" ) ) { 2264 this._mouseUp( new $.Event( "mouseup", { target: this.element[ 0 ] } ) ); 2265 } else { 2266 this._clear(); 2267 } 2268 2269 return this; 2270 2271 }, 2272 2273 _getHandle: function( event ) { 2274 return this.options.handle ? 2275 !!$( event.target ).closest( this.element.find( this.options.handle ) ).length : 2276 true; 2277 }, 2278 2279 _setHandleClassName: function() { 2280 this.handleElement = this.options.handle ? 2281 this.element.find( this.options.handle ) : this.element; 2282 this._addClass( this.handleElement, "ui-draggable-handle" ); 2283 }, 2284 2285 _removeHandleClassName: function() { 2286 this._removeClass( this.handleElement, "ui-draggable-handle" ); 2287 }, 2288 2289 _createHelper: function( event ) { 2290 2291 var o = this.options, 2292 helperIsFunction = $.isFunction( o.helper ), 2293 helper = helperIsFunction ? 2294 $( o.helper.apply( this.element[ 0 ], [ event ] ) ) : 2295 ( o.helper === "clone" ? 2296 this.element.clone().removeAttr( "id" ) : 2297 this.element ); 2298 2299 if ( !helper.parents( "body" ).length ) { 2300 helper.appendTo( ( o.appendTo === "parent" ? 2301 this.element[ 0 ].parentNode : 2302 o.appendTo ) ); 2303 } 2304 2305 // Http://bugs.jqueryui.com/ticket/9446 2306 // a helper function can return the original element 2307 // which wouldn't have been set to relative in _create 2308 if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) { 2309 this._setPositionRelative(); 2310 } 2311 2312 if ( helper[ 0 ] !== this.element[ 0 ] && 2313 !( /(fixed|absolute)/ ).test( helper.css( "position" ) ) ) { 2314 helper.css( "position", "absolute" ); 2315 } 2316 2317 return helper; 2318 2319 }, 2320 2321 _setPositionRelative: function() { 2322 if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) { 2323 this.element[ 0 ].style.position = "relative"; 2324 } 2325 }, 2326 2327 _adjustOffsetFromHelper: function( obj ) { 2328 if ( typeof obj === "string" ) { 2329 obj = obj.split( " " ); 2330 } 2331 if ( $.isArray( obj ) ) { 2332 obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 }; 2333 } 2334 if ( "left" in obj ) { 2335 this.offset.click.left = obj.left + this.margins.left; 2336 } 2337 if ( "right" in obj ) { 2338 this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; 2339 } 2340 if ( "top" in obj ) { 2341 this.offset.click.top = obj.top + this.margins.top; 2342 } 2343 if ( "bottom" in obj ) { 2344 this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top; 2345 } 2346 }, 2347 2348 _isRootNode: function( element ) { 2349 return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ]; 2350 }, 2351 2352 _getParentOffset: function() { 2353 2354 //Get the offsetParent and cache its position 2355 var po = this.offsetParent.offset(), 2356 document = this.document[ 0 ]; 2357 2358 // This is a special case where we need to modify a offset calculated on start, since the 2359 // following happened: 2360 // 1. The position of the helper is absolute, so it's position is calculated based on the 2361 // next positioned parent 2362 // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't 2363 // the document, which means that the scroll is included in the initial calculation of the 2364 // offset of the parent, and never recalculated upon drag 2365 if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== document && 2366 $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) { 2367 po.left += this.scrollParent.scrollLeft(); 2368 po.top += this.scrollParent.scrollTop(); 2369 } 2370 2371 if ( this._isRootNode( this.offsetParent[ 0 ] ) ) { 2372 po = { top: 0, left: 0 }; 2373 } 2374 2375 return { 2376 top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ), 2377 left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 ) 2378 }; 2379 2380 }, 2381 2382 _getRelativeOffset: function() { 2383 if ( this.cssPosition !== "relative" ) { 2384 return { top: 0, left: 0 }; 2385 } 2386 2387 var p = this.element.position(), 2388 scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ); 2389 2390 return { 2391 top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) + 2392 ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ), 2393 left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) + 2394 ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 ) 2395 }; 2396 2397 }, 2398 2399 _cacheMargins: function() { 2400 this.margins = { 2401 left: ( parseInt( this.element.css( "marginLeft" ), 10 ) || 0 ), 2402 top: ( parseInt( this.element.css( "marginTop" ), 10 ) || 0 ), 2403 right: ( parseInt( this.element.css( "marginRight" ), 10 ) || 0 ), 2404 bottom: ( parseInt( this.element.css( "marginBottom" ), 10 ) || 0 ) 2405 }; 2406 }, 2407 2408 _cacheHelperProportions: function() { 2409 this.helperProportions = { 2410 width: this.helper.outerWidth(), 2411 height: this.helper.outerHeight() 2412 }; 2413 }, 2414 2415 _setContainment: function() { 2416 2417 var isUserScrollable, c, ce, 2418 o = this.options, 2419 document = this.document[ 0 ]; 2420 2421 this.relativeContainer = null; 2422 2423 if ( !o.containment ) { 2424 this.containment = null; 2425 return; 2426 } 2427 2428 if ( o.containment === "window" ) { 2429 this.containment = [ 2430 $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left, 2431 $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top, 2432 $( window ).scrollLeft() + $( window ).width() - 2433 this.helperProportions.width - this.margins.left, 2434 $( window ).scrollTop() + 2435 ( $( window ).height() || document.body.parentNode.scrollHeight ) - 2436 this.helperProportions.height - this.margins.top 2437 ]; 2438 return; 2439 } 2440 2441 if ( o.containment === "document" ) { 2442 this.containment = [ 2443 0, 2444 0, 2445 $( document ).width() - this.helperProportions.width - this.margins.left, 2446 ( $( document ).height() || document.body.parentNode.scrollHeight ) - 2447 this.helperProportions.height - this.margins.top 2448 ]; 2449 return; 2450 } 2451 2452 if ( o.containment.constructor === Array ) { 2453 this.containment = o.containment; 2454 return; 2455 } 2456 2457 if ( o.containment === "parent" ) { 2458 o.containment = this.helper[ 0 ].parentNode; 2459 } 2460 2461 c = $( o.containment ); 2462 ce = c[ 0 ]; 2463 2464 if ( !ce ) { 2465 return; 2466 } 2467 2468 isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) ); 2469 2470 this.containment = [ 2471 ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + 2472 ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ), 2473 ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + 2474 ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ), 2475 ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - 2476 ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) - 2477 ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) - 2478 this.helperProportions.width - 2479 this.margins.left - 2480 this.margins.right, 2481 ( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - 2482 ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) - 2483 ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) - 2484 this.helperProportions.height - 2485 this.margins.top - 2486 this.margins.bottom 2487 ]; 2488 this.relativeContainer = c; 2489 }, 2490 2491 _convertPositionTo: function( d, pos ) { 2492 2493 if ( !pos ) { 2494 pos = this.position; 2495 } 2496 2497 var mod = d === "absolute" ? 1 : -1, 2498 scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ); 2499 2500 return { 2501 top: ( 2502 2503 // The absolute mouse position 2504 pos.top + 2505 2506 // Only for relative positioned nodes: Relative offset from element to offset parent 2507 this.offset.relative.top * mod + 2508 2509 // The offsetParent's offset without borders (offset + border) 2510 this.offset.parent.top * mod - 2511 ( ( this.cssPosition === "fixed" ? 2512 -this.offset.scroll.top : 2513 ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod ) 2514 ), 2515 left: ( 2516 2517 // The absolute mouse position 2518 pos.left + 2519 2520 // Only for relative positioned nodes: Relative offset from element to offset parent 2521 this.offset.relative.left * mod + 2522 2523 // The offsetParent's offset without borders (offset + border) 2524 this.offset.parent.left * mod - 2525 ( ( this.cssPosition === "fixed" ? 2526 -this.offset.scroll.left : 2527 ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod ) 2528 ) 2529 }; 2530 2531 }, 2532 2533 _generatePosition: function( event, constrainPosition ) { 2534 2535 var containment, co, top, left, 2536 o = this.options, 2537 scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ), 2538 pageX = event.pageX, 2539 pageY = event.pageY; 2540 2541 // Cache the scroll 2542 if ( !scrollIsRootNode || !this.offset.scroll ) { 2543 this.offset.scroll = { 2544 top: this.scrollParent.scrollTop(), 2545 left: this.scrollParent.scrollLeft() 2546 }; 2547 } 2548 2549 /* 2550 * - Position constraining - 2551 * Constrain the position to a mix of grid, containment. 2552 */ 2553 2554 // If we are not dragging yet, we won't check for options 2555 if ( constrainPosition ) { 2556 if ( this.containment ) { 2557 if ( this.relativeContainer ) { 2558 co = this.relativeContainer.offset(); 2559 containment = [ 2560 this.containment[ 0 ] + co.left, 2561 this.containment[ 1 ] + co.top, 2562 this.containment[ 2 ] + co.left, 2563 this.containment[ 3 ] + co.top 2564 ]; 2565 } else { 2566 containment = this.containment; 2567 } 2568 2569 if ( event.pageX - this.offset.click.left < containment[ 0 ] ) { 2570 pageX = containment[ 0 ] + this.offset.click.left; 2571 } 2572 if ( event.pageY - this.offset.click.top < containment[ 1 ] ) { 2573 pageY = containment[ 1 ] + this.offset.click.top; 2574 } 2575 if ( event.pageX - this.offset.click.left > containment[ 2 ] ) { 2576 pageX = containment[ 2 ] + this.offset.click.left; 2577 } 2578 if ( event.pageY - this.offset.click.top > containment[ 3 ] ) { 2579 pageY = containment[ 3 ] + this.offset.click.top; 2580 } 2581 } 2582 2583 if ( o.grid ) { 2584 2585 //Check for grid elements set to 0 to prevent divide by 0 error causing invalid 2586 // argument errors in IE (see ticket #6950) 2587 top = o.grid[ 1 ] ? this.originalPageY + Math.round( ( pageY - 2588 this.originalPageY ) / o.grid[ 1 ] ) * o.grid[ 1 ] : this.originalPageY; 2589 pageY = containment ? ( ( top - this.offset.click.top >= containment[ 1 ] || 2590 top - this.offset.click.top > containment[ 3 ] ) ? 2591 top : 2592 ( ( top - this.offset.click.top >= containment[ 1 ] ) ? 2593 top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : top; 2594 2595 left = o.grid[ 0 ] ? this.originalPageX + 2596 Math.round( ( pageX - this.originalPageX ) / o.grid[ 0 ] ) * o.grid[ 0 ] : 2597 this.originalPageX; 2598 pageX = containment ? ( ( left - this.offset.click.left >= containment[ 0 ] || 2599 left - this.offset.click.left > containment[ 2 ] ) ? 2600 left : 2601 ( ( left - this.offset.click.left >= containment[ 0 ] ) ? 2602 left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : left; 2603 } 2604 2605 if ( o.axis === "y" ) { 2606 pageX = this.originalPageX; 2607 } 2608 2609 if ( o.axis === "x" ) { 2610 pageY = this.originalPageY; 2611 } 2612 } 2613 2614 return { 2615 top: ( 2616 2617 // The absolute mouse position 2618 pageY - 2619 2620 // Click offset (relative to the element) 2621 this.offset.click.top - 2622 2623 // Only for relative positioned nodes: Relative offset from element to offset parent 2624 this.offset.relative.top - 2625 2626 // The offsetParent's offset without borders (offset + border) 2627 this.offset.parent.top + 2628 ( this.cssPosition === "fixed" ? 2629 -this.offset.scroll.top : 2630 ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) 2631 ), 2632 left: ( 2633 2634 // The absolute mouse position 2635 pageX - 2636 2637 // Click offset (relative to the element) 2638 this.offset.click.left - 2639 2640 // Only for relative positioned nodes: Relative offset from element to offset parent 2641 this.offset.relative.left - 2642 2643 // The offsetParent's offset without borders (offset + border) 2644 this.offset.parent.left + 2645 ( this.cssPosition === "fixed" ? 2646 -this.offset.scroll.left : 2647 ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) 2648 ) 2649 }; 2650 2651 }, 2652 2653 _clear: function() { 2654 this._removeClass( this.helper, "ui-draggable-dragging" ); 2655 if ( this.helper[ 0 ] !== this.element[ 0 ] && !this.cancelHelperRemoval ) { 2656 this.helper.remove(); 2657 } 2658 this.helper = null; 2659 this.cancelHelperRemoval = false; 2660 if ( this.destroyOnClear ) { 2661 this.destroy(); 2662 } 2663 }, 2664 2665 // From now on bulk stuff - mainly helpers 2666 2667 _trigger: function( type, event, ui ) { 2668 ui = ui || this._uiHash(); 2669 $.ui.plugin.call( this, type, [ event, ui, this ], true ); 2670 2671 // Absolute position and offset (see #6884 ) have to be recalculated after plugins 2672 if ( /^(drag|start|stop)/.test( type ) ) { 2673 this.positionAbs = this._convertPositionTo( "absolute" ); 2674 ui.offset = this.positionAbs; 2675 } 2676 return $.Widget.prototype._trigger.call( this, type, event, ui ); 2677 }, 2678 2679 plugins: {}, 2680 2681 _uiHash: function() { 2682 return { 2683 helper: this.helper, 2684 position: this.position, 2685 originalPosition: this.originalPosition, 2686 offset: this.positionAbs 2687 }; 2688 } 2689 2690} ); 2691 2692$.ui.plugin.add( "draggable", "connectToSortable", { 2693 start: function( event, ui, draggable ) { 2694 var uiSortable = $.extend( {}, ui, { 2695 item: draggable.element 2696 } ); 2697 2698 draggable.sortables = []; 2699 $( draggable.options.connectToSortable ).each( function() { 2700 var sortable = $( this ).sortable( "instance" ); 2701 2702 if ( sortable && !sortable.options.disabled ) { 2703 draggable.sortables.push( sortable ); 2704 2705 // RefreshPositions is called at drag start to refresh the containerCache 2706 // which is used in drag. This ensures it's initialized and synchronized 2707 // with any changes that might have happened on the page since initialization. 2708 sortable.refreshPositions(); 2709 sortable._trigger( "activate", event, uiSortable ); 2710 } 2711 } ); 2712 }, 2713 stop: function( event, ui, draggable ) { 2714 var uiSortable = $.extend( {}, ui, { 2715 item: draggable.element 2716 } ); 2717 2718 draggable.cancelHelperRemoval = false; 2719 2720 $.each( draggable.sortables, function() { 2721 var sortable = this; 2722 2723 if ( sortable.isOver ) { 2724 sortable.isOver = 0; 2725 2726 // Allow this sortable to handle removing the helper 2727 draggable.cancelHelperRemoval = true; 2728 sortable.cancelHelperRemoval = false; 2729 2730 // Use _storedCSS To restore properties in the sortable, 2731 // as this also handles revert (#9675) since the draggable 2732 // may have modified them in unexpected ways (#8809) 2733 sortable._storedCSS = { 2734 position: sortable.placeholder.css( "position" ), 2735 top: sortable.placeholder.css( "top" ), 2736 left: sortable.placeholder.css( "left" ) 2737 }; 2738 2739 sortable._mouseStop( event ); 2740 2741 // Once drag has ended, the sortable should return to using 2742 // its original helper, not the shared helper from draggable 2743 sortable.options.helper = sortable.options._helper; 2744 } else { 2745 2746 // Prevent this Sortable from removing the helper. 2747 // However, don't set the draggable to remove the helper 2748 // either as another connected Sortable may yet handle the removal. 2749 sortable.cancelHelperRemoval = true; 2750 2751 sortable._trigger( "deactivate", event, uiSortable ); 2752 } 2753 } ); 2754 }, 2755 drag: function( event, ui, draggable ) { 2756 $.each( draggable.sortables, function() { 2757 var innermostIntersecting = false, 2758 sortable = this; 2759 2760 // Copy over variables that sortable's _intersectsWith uses 2761 sortable.positionAbs = draggable.positionAbs; 2762 sortable.helperProportions = draggable.helperProportions; 2763 sortable.offset.click = draggable.offset.click; 2764 2765 if ( sortable._intersectsWith( sortable.containerCache ) ) { 2766 innermostIntersecting = true; 2767 2768 $.each( draggable.sortables, function() { 2769 2770 // Copy over variables that sortable's _intersectsWith uses 2771 this.positionAbs = draggable.positionAbs; 2772 this.helperProportions = draggable.helperProportions; 2773 this.offset.click = draggable.offset.click; 2774 2775 if ( this !== sortable && 2776 this._intersectsWith( this.containerCache ) && 2777 $.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) { 2778 innermostIntersecting = false; 2779 } 2780 2781 return innermostIntersecting; 2782 } ); 2783 } 2784 2785 if ( innermostIntersecting ) { 2786 2787 // If it intersects, we use a little isOver variable and set it once, 2788 // so that the move-in stuff gets fired only once. 2789 if ( !sortable.isOver ) { 2790 sortable.isOver = 1; 2791 2792 // Store draggable's parent in case we need to reappend to it later. 2793 draggable._parent = ui.helper.parent(); 2794 2795 sortable.currentItem = ui.helper 2796 .appendTo( sortable.element ) 2797 .data( "ui-sortable-item", true ); 2798 2799 // Store helper option to later restore it 2800 sortable.options._helper = sortable.options.helper; 2801 2802 sortable.options.helper = function() { 2803 return ui.helper[ 0 ]; 2804 }; 2805 2806 // Fire the start events of the sortable with our passed browser event, 2807 // and our own helper (so it doesn't create a new one) 2808 event.target = sortable.currentItem[ 0 ]; 2809 sortable._mouseCapture( event, true ); 2810 sortable._mouseStart( event, true, true ); 2811 2812 // Because the browser event is way off the new appended portlet, 2813 // modify necessary variables to reflect the changes 2814 sortable.offset.click.top = draggable.offset.click.top; 2815 sortable.offset.click.left = draggable.offset.click.left; 2816 sortable.offset.parent.left -= draggable.offset.parent.left - 2817 sortable.offset.parent.left; 2818 sortable.offset.parent.top -= draggable.offset.parent.top - 2819 sortable.offset.parent.top; 2820 2821 draggable._trigger( "toSortable", event ); 2822 2823 // Inform draggable that the helper is in a valid drop zone, 2824 // used solely in the revert option to handle "valid/invalid". 2825 draggable.dropped = sortable.element; 2826 2827 // Need to refreshPositions of all sortables in the case that 2828 // adding to one sortable changes the location of the other sortables (#9675) 2829 $.each( draggable.sortables, function() { 2830 this.refreshPositions(); 2831 } ); 2832 2833 // Hack so receive/update callbacks work (mostly) 2834 draggable.currentItem = draggable.element; 2835 sortable.fromOutside = draggable; 2836 } 2837 2838 if ( sortable.currentItem ) { 2839 sortable._mouseDrag( event ); 2840 2841 // Copy the sortable's position because the draggable's can potentially reflect 2842 // a relative position, while sortable is always absolute, which the dragged 2843 // element has now become. (#8809) 2844 ui.position = sortable.position; 2845 } 2846 } else { 2847 2848 // If it doesn't intersect with the sortable, and it intersected before, 2849 // we fake the drag stop of the sortable, but make sure it doesn't remove 2850 // the helper by using cancelHelperRemoval. 2851 if ( sortable.isOver ) { 2852 2853 sortable.isOver = 0; 2854 sortable.cancelHelperRemoval = true; 2855 2856 // Calling sortable's mouseStop would trigger a revert, 2857 // so revert must be temporarily false until after mouseStop is called. 2858 sortable.options._revert = sortable.options.revert; 2859 sortable.options.revert = false; 2860 2861 sortable._trigger( "out", event, sortable._uiHash( sortable ) ); 2862 sortable._mouseStop( event, true ); 2863 2864 // Restore sortable behaviors that were modfied 2865 // when the draggable entered the sortable area (#9481) 2866 sortable.options.revert = sortable.options._revert; 2867 sortable.options.helper = sortable.options._helper; 2868 2869 if ( sortable.placeholder ) { 2870 sortable.placeholder.remove(); 2871 } 2872 2873 // Restore and recalculate the draggable's offset considering the sortable 2874 // may have modified them in unexpected ways. (#8809, #10669) 2875 ui.helper.appendTo( draggable._parent ); 2876 draggable._refreshOffsets( event ); 2877 ui.position = draggable._generatePosition( event, true ); 2878 2879 draggable._trigger( "fromSortable", event ); 2880 2881 // Inform draggable that the helper is no longer in a valid drop zone 2882 draggable.dropped = false; 2883 2884 // Need to refreshPositions of all sortables just in case removing 2885 // from one sortable changes the location of other sortables (#9675) 2886 $.each( draggable.sortables, function() { 2887 this.refreshPositions(); 2888 } ); 2889 } 2890 } 2891 } ); 2892 } 2893} ); 2894 2895$.ui.plugin.add( "draggable", "cursor", { 2896 start: function( event, ui, instance ) { 2897 var t = $( "body" ), 2898 o = instance.options; 2899 2900 if ( t.css( "cursor" ) ) { 2901 o._cursor = t.css( "cursor" ); 2902 } 2903 t.css( "cursor", o.cursor ); 2904 }, 2905 stop: function( event, ui, instance ) { 2906 var o = instance.options; 2907 if ( o._cursor ) { 2908 $( "body" ).css( "cursor", o._cursor ); 2909 } 2910 } 2911} ); 2912 2913$.ui.plugin.add( "draggable", "opacity", { 2914 start: function( event, ui, instance ) { 2915 var t = $( ui.helper ), 2916 o = instance.options; 2917 if ( t.css( "opacity" ) ) { 2918 o._opacity = t.css( "opacity" ); 2919 } 2920 t.css( "opacity", o.opacity ); 2921 }, 2922 stop: function( event, ui, instance ) { 2923 var o = instance.options; 2924 if ( o._opacity ) { 2925 $( ui.helper ).css( "opacity", o._opacity ); 2926 } 2927 } 2928} ); 2929 2930$.ui.plugin.add( "draggable", "scroll", { 2931 start: function( event, ui, i ) { 2932 if ( !i.scrollParentNotHidden ) { 2933 i.scrollParentNotHidden = i.helper.scrollParent( false ); 2934 } 2935 2936 if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] && 2937 i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) { 2938 i.overflowOffset = i.scrollParentNotHidden.offset(); 2939 } 2940 }, 2941 drag: function( event, ui, i ) { 2942 2943 var o = i.options, 2944 scrolled = false, 2945 scrollParent = i.scrollParentNotHidden[ 0 ], 2946 document = i.document[ 0 ]; 2947 2948 if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) { 2949 if ( !o.axis || o.axis !== "x" ) { 2950 if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY < 2951 o.scrollSensitivity ) { 2952 scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed; 2953 } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) { 2954 scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed; 2955 } 2956 } 2957 2958 if ( !o.axis || o.axis !== "y" ) { 2959 if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX < 2960 o.scrollSensitivity ) { 2961 scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed; 2962 } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) { 2963 scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed; 2964 } 2965 } 2966 2967 } else { 2968 2969 if ( !o.axis || o.axis !== "x" ) { 2970 if ( event.pageY - $( document ).scrollTop() < o.scrollSensitivity ) { 2971 scrolled = $( document ).scrollTop( $( document ).scrollTop() - o.scrollSpeed ); 2972 } else if ( $( window ).height() - ( event.pageY - $( document ).scrollTop() ) < 2973 o.scrollSensitivity ) { 2974 scrolled = $( document ).scrollTop( $( document ).scrollTop() + o.scrollSpeed ); 2975 } 2976 } 2977 2978 if ( !o.axis || o.axis !== "y" ) { 2979 if ( event.pageX - $( document ).scrollLeft() < o.scrollSensitivity ) { 2980 scrolled = $( document ).scrollLeft( 2981 $( document ).scrollLeft() - o.scrollSpeed 2982 ); 2983 } else if ( $( window ).width() - ( event.pageX - $( document ).scrollLeft() ) < 2984 o.scrollSensitivity ) { 2985 scrolled = $( document ).scrollLeft( 2986 $( document ).scrollLeft() + o.scrollSpeed 2987 ); 2988 } 2989 } 2990 2991 } 2992 2993 if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) { 2994 $.ui.ddmanager.prepareOffsets( i, event ); 2995 } 2996 2997 } 2998} ); 2999 3000$.ui.plugin.add( "draggable", "snap", { 3001 start: function( event, ui, i ) { 3002 3003 var o = i.options; 3004 3005 i.snapElements = []; 3006 3007 $( o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap ) 3008 .each( function() { 3009 var $t = $( this ), 3010 $o = $t.offset(); 3011 if ( this !== i.element[ 0 ] ) { 3012 i.snapElements.push( { 3013 item: this, 3014 width: $t.outerWidth(), height: $t.outerHeight(), 3015 top: $o.top, left: $o.left 3016 } ); 3017 } 3018 } ); 3019 3020 }, 3021 drag: function( event, ui, inst ) { 3022 3023 var ts, bs, ls, rs, l, r, t, b, i, first, 3024 o = inst.options, 3025 d = o.snapTolerance, 3026 x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width, 3027 y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height; 3028 3029 for ( i = inst.snapElements.length - 1; i >= 0; i-- ) { 3030 3031 l = inst.snapElements[ i ].left - inst.margins.left; 3032 r = l + inst.snapElements[ i ].width; 3033 t = inst.snapElements[ i ].top - inst.margins.top; 3034 b = t + inst.snapElements[ i ].height; 3035 3036 if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || 3037 !$.contains( inst.snapElements[ i ].item.ownerDocument, 3038 inst.snapElements[ i ].item ) ) { 3039 if ( inst.snapElements[ i ].snapping ) { 3040 ( inst.options.snap.release && 3041 inst.options.snap.release.call( 3042 inst.element, 3043 event, 3044 $.extend( inst._uiHash(), { snapItem: inst.snapElements[ i ].item } ) 3045 ) ); 3046 } 3047 inst.snapElements[ i ].snapping = false; 3048 continue; 3049 } 3050 3051 if ( o.snapMode !== "inner" ) { 3052 ts = Math.abs( t - y2 ) <= d; 3053 bs = Math.abs( b - y1 ) <= d; 3054 ls = Math.abs( l - x2 ) <= d; 3055 rs = Math.abs( r - x1 ) <= d; 3056 if ( ts ) { 3057 ui.position.top = inst._convertPositionTo( "relative", { 3058 top: t - inst.helperProportions.height, 3059 left: 0 3060 } ).top; 3061 } 3062 if ( bs ) { 3063 ui.position.top = inst._convertPositionTo( "relative", { 3064 top: b, 3065 left: 0 3066 } ).top; 3067 } 3068 if ( ls ) { 3069 ui.position.left = inst._convertPositionTo( "relative", { 3070 top: 0, 3071 left: l - inst.helperProportions.width 3072 } ).left; 3073 } 3074 if ( rs ) { 3075 ui.position.left = inst._convertPositionTo( "relative", { 3076 top: 0, 3077 left: r 3078 } ).left; 3079 } 3080 } 3081 3082 first = ( ts || bs || ls || rs ); 3083 3084 if ( o.snapMode !== "outer" ) { 3085 ts = Math.abs( t - y1 ) <= d; 3086 bs = Math.abs( b - y2 ) <= d; 3087 ls = Math.abs( l - x1 ) <= d; 3088 rs = Math.abs( r - x2 ) <= d; 3089 if ( ts ) { 3090 ui.position.top = inst._convertPositionTo( "relative", { 3091 top: t, 3092 left: 0 3093 } ).top; 3094 } 3095 if ( bs ) { 3096 ui.position.top = inst._convertPositionTo( "relative", { 3097 top: b - inst.helperProportions.height, 3098 left: 0 3099 } ).top; 3100 } 3101 if ( ls ) { 3102 ui.position.left = inst._convertPositionTo( "relative", { 3103 top: 0, 3104 left: l 3105 } ).left; 3106 } 3107 if ( rs ) { 3108 ui.position.left = inst._convertPositionTo( "relative", { 3109 top: 0, 3110 left: r - inst.helperProportions.width 3111 } ).left; 3112 } 3113 } 3114 3115 if ( !inst.snapElements[ i ].snapping && ( ts || bs || ls || rs || first ) ) { 3116 ( inst.options.snap.snap && 3117 inst.options.snap.snap.call( 3118 inst.element, 3119 event, 3120 $.extend( inst._uiHash(), { 3121 snapItem: inst.snapElements[ i ].item 3122 } ) ) ); 3123 } 3124 inst.snapElements[ i ].snapping = ( ts || bs || ls || rs || first ); 3125 3126 } 3127 3128 } 3129} ); 3130 3131$.ui.plugin.add( "draggable", "stack", { 3132 start: function( event, ui, instance ) { 3133 var min, 3134 o = instance.options, 3135 group = $.makeArray( $( o.stack ) ).sort( function( a, b ) { 3136 return ( parseInt( $( a ).css( "zIndex" ), 10 ) || 0 ) - 3137 ( parseInt( $( b ).css( "zIndex" ), 10 ) || 0 ); 3138 } ); 3139 3140 if ( !group.length ) { return; } 3141 3142 min = parseInt( $( group[ 0 ] ).css( "zIndex" ), 10 ) || 0; 3143 $( group ).each( function( i ) { 3144 $( this ).css( "zIndex", min + i ); 3145 } ); 3146 this.css( "zIndex", ( min + group.length ) ); 3147 } 3148} ); 3149 3150$.ui.plugin.add( "draggable", "zIndex", { 3151 start: function( event, ui, instance ) { 3152 var t = $( ui.helper ), 3153 o = instance.options; 3154 3155 if ( t.css( "zIndex" ) ) { 3156 o._zIndex = t.css( "zIndex" ); 3157 } 3158 t.css( "zIndex", o.zIndex ); 3159 }, 3160 stop: function( event, ui, instance ) { 3161 var o = instance.options; 3162 3163 if ( o._zIndex ) { 3164 $( ui.helper ).css( "zIndex", o._zIndex ); 3165 } 3166 } 3167} ); 3168 3169var widgetsDraggable = $.ui.draggable; 3170 3171 3172/*! 3173 * jQuery UI Droppable 1.12.
31730 3174 * http://jqueryui.com 3175 * 3176 * Copyright jQuery Foundation and other contributors 3177 * Released under the MIT license. 3178 * http://jquery.org/license 3179 */ 3180 3181//>>label: Droppable 3182//>>group: Interactions 3183//>>description: Enables drop targets for draggable elements. 3184//>>docs: http://api.jqueryui.com/droppable/ 3185//>>demos: http://jqueryui.com/droppable/ 3186 3187 3188 3189$.widget( "ui.droppable", { 3190 version: "1.12.0
vendor: 12,139 bytes, lines 3190-3654
3190", 3191 widgetEventPrefix: "drop", 3192 options: { 3193 accept: "*", 3194 addClasses: true, 3195 greedy: false, 3196 scope: "default", 3197 tolerance: "intersect", 3198 3199 // Callbacks 3200 activate: null, 3201 deactivate: null, 3202 drop: null, 3203 out: null, 3204 over: null 3205 }, 3206 _create: function() { 3207 3208 var proportions, 3209 o = this.options, 3210 accept = o.accept; 3211 3212 this.isover = false; 3213 this.isout = true; 3214 3215 this.accept = $.isFunction( accept ) ? accept : function( d ) { 3216 return d.is( accept ); 3217 }; 3218 3219 this.proportions = function( /* valueToWrite */ ) { 3220 if ( arguments.length ) { 3221 3222 // Store the droppable's proportions 3223 proportions = arguments[ 0 ]; 3224 } else { 3225 3226 // Retrieve or derive the droppable's proportions 3227 return proportions ? 3228 proportions : 3229 proportions = { 3230 width: this.element[ 0 ].offsetWidth, 3231 height: this.element[ 0 ].offsetHeight 3232 }; 3233 } 3234 }; 3235 3236 this._addToManager( o.scope ); 3237 3238 o.addClasses && this._addClass( "ui-droppable" ); 3239 3240 }, 3241 3242 _addToManager: function( scope ) { 3243 3244 // Add the reference and positions to the manager 3245 $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || []; 3246 $.ui.ddmanager.droppables[ scope ].push( this ); 3247 }, 3248 3249 _splice: function( drop ) { 3250 var i = 0; 3251 for ( ; i < drop.length; i++ ) { 3252 if ( drop[ i ] === this ) { 3253 drop.splice( i, 1 ); 3254 } 3255 } 3256 }, 3257 3258 _destroy: function() { 3259 var drop = $.ui.ddmanager.droppables[ this.options.scope ]; 3260 3261 this._splice( drop ); 3262 }, 3263 3264 _setOption: function( key, value ) { 3265 3266 if ( key === "accept" ) { 3267 this.accept = $.isFunction( value ) ? value : function( d ) { 3268 return d.is( value ); 3269 }; 3270 } else if ( key === "scope" ) { 3271 var drop = $.ui.ddmanager.droppables[ this.options.scope ]; 3272 3273 this._splice( drop ); 3274 this._addToManager( value ); 3275 } 3276 3277 this._super( key, value ); 3278 }, 3279 3280 _activate: function( event ) { 3281 var draggable = $.ui.ddmanager.current; 3282 3283 this._addActiveClass(); 3284 if ( draggable ) { 3285 this._trigger( "activate", event, this.ui( draggable ) ); 3286 } 3287 }, 3288 3289 _deactivate: function( event ) { 3290 var draggable = $.ui.ddmanager.current; 3291 3292 this._removeActiveClass(); 3293 if ( draggable ) { 3294 this._trigger( "deactivate", event, this.ui( draggable ) ); 3295 } 3296 }, 3297 3298 _over: function( event ) { 3299 3300 var draggable = $.ui.ddmanager.current; 3301 3302 // Bail if draggable and droppable are same element 3303 if ( !draggable || ( draggable.currentItem || 3304 draggable.element )[ 0 ] === this.element[ 0 ] ) { 3305 return; 3306 } 3307 3308 if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || 3309 draggable.element ) ) ) { 3310 this._addHoverClass(); 3311 this._trigger( "over", event, this.ui( draggable ) ); 3312 } 3313 3314 }, 3315 3316 _out: function( event ) { 3317 3318 var draggable = $.ui.ddmanager.current; 3319 3320 // Bail if draggable and droppable are same element 3321 if ( !draggable || ( draggable.currentItem || 3322 draggable.element )[ 0 ] === this.element[ 0 ] ) { 3323 return; 3324 } 3325 3326 if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || 3327 draggable.element ) ) ) { 3328 this._removeHoverClass(); 3329 this._trigger( "out", event, this.ui( draggable ) ); 3330 } 3331 3332 }, 3333 3334 _drop: function( event, custom ) { 3335 3336 var draggable = custom || $.ui.ddmanager.current, 3337 childrenIntersection = false; 3338 3339 // Bail if draggable and droppable are same element 3340 if ( !draggable || ( draggable.currentItem || 3341 draggable.element )[ 0 ] === this.element[ 0 ] ) { 3342 return false; 3343 } 3344 3345 this.element 3346 .find( ":data(ui-droppable)" ) 3347 .not( ".ui-draggable-dragging" ) 3348 .each( function() { 3349 var inst = $( this ).droppable( "instance" ); 3350 if ( 3351 inst.options.greedy && 3352 !inst.options.disabled && 3353 inst.options.scope === draggable.options.scope && 3354 inst.accept.call( 3355 inst.element[ 0 ], ( draggable.currentItem || draggable.element ) 3356 ) && 3357 intersect( 3358 draggable, 3359 $.extend( inst, { offset: inst.element.offset() } ), 3360 inst.options.tolerance, event 3361 ) 3362 ) { 3363 childrenIntersection = true; 3364 return false; } 3365 } ); 3366 if ( childrenIntersection ) { 3367 return false; 3368 } 3369 3370 if ( this.accept.call( this.element[ 0 ], 3371 ( draggable.currentItem || draggable.element ) ) ) { 3372 this._removeActiveClass(); 3373 this._removeHoverClass(); 3374 3375 this._trigger( "drop", event, this.ui( draggable ) ); 3376 return this.element; 3377 } 3378 3379 return false; 3380 3381 }, 3382 3383 ui: function( c ) { 3384 return { 3385 draggable: ( c.currentItem || c.element ), 3386 helper: c.helper, 3387 position: c.position, 3388 offset: c.positionAbs 3389 }; 3390 }, 3391 3392 // Extension points just to make backcompat sane and avoid duplicating logic 3393 // TODO: Remove in 1.13 along with call to it below 3394 _addHoverClass: function() { 3395 this._addClass( "ui-droppable-hover" ); 3396 }, 3397 3398 _removeHoverClass: function() { 3399 this._removeClass( "ui-droppable-hover" ); 3400 }, 3401 3402 _addActiveClass: function() { 3403 this._addClass( "ui-droppable-active" ); 3404 }, 3405 3406 _removeActiveClass: function() { 3407 this._removeClass( "ui-droppable-active" ); 3408 } 3409} ); 3410 3411var intersect = $.ui.intersect = ( function() { 3412 function isOverAxis( x, reference, size ) { 3413 return ( x >= reference ) && ( x < ( reference + size ) ); 3414 } 3415 3416 return function( draggable, droppable, toleranceMode, event ) { 3417 3418 if ( !droppable.offset ) { 3419 return false; 3420 } 3421 3422 var x1 = ( draggable.positionAbs || 3423 draggable.position.absolute ).left + draggable.margins.left, 3424 y1 = ( draggable.positionAbs || 3425 draggable.position.absolute ).top + draggable.margins.top, 3426 x2 = x1 + draggable.helperProportions.width, 3427 y2 = y1 + draggable.helperProportions.height, 3428 l = droppable.offset.left, 3429 t = droppable.offset.top, 3430 r = l + droppable.proportions().width, 3431 b = t + droppable.proportions().height; 3432 3433 switch ( toleranceMode ) { 3434 case "fit": 3435 return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b ); 3436 case "intersect": 3437 return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half 3438 x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half 3439 t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half 3440 y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half 3441 case "pointer": 3442 return isOverAxis( event.pageY, t, droppable.proportions().height ) && 3443 isOverAxis( event.pageX, l, droppable.proportions().width ); 3444 case "touch": 3445 return ( 3446 ( y1 >= t && y1 <= b ) || // Top edge touching 3447 ( y2 >= t && y2 <= b ) || // Bottom edge touching 3448 ( y1 < t && y2 > b ) // Surrounded vertically 3449 ) && ( 3450 ( x1 >= l && x1 <= r ) || // Left edge touching 3451 ( x2 >= l && x2 <= r ) || // Right edge touching 3452 ( x1 < l && x2 > r ) // Surrounded horizontally 3453 ); 3454 default: 3455 return false; 3456 } 3457 }; 3458} )(); 3459 3460/* 3461 This manager tracks offsets of draggables and droppables 3462*/ 3463$.ui.ddmanager = { 3464 current: null, 3465 droppables: { "default": [] }, 3466 prepareOffsets: function( t, event ) { 3467 3468 var i, j, 3469 m = $.ui.ddmanager.droppables[ t.options.scope ] || [], 3470 type = event ? event.type : null, // workaround for #2317 3471 list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack(); 3472 3473 droppablesLoop: for ( i = 0; i < m.length; i++ ) { 3474 3475 // No disabled and non-accepted 3476 if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ], 3477 ( t.currentItem || t.element ) ) ) ) { 3478 continue; 3479 } 3480 3481 // Filter out elements in the current dragged item 3482 for ( j = 0; j < list.length; j++ ) { 3483 if ( list[ j ] === m[ i ].element[ 0 ] ) { 3484 m[ i ].proportions().height = 0; 3485 continue droppablesLoop; 3486 } 3487 } 3488 3489 m[ i ].visible = m[ i ].element.css( "display" ) !== "none"; 3490 if ( !m[ i ].visible ) { 3491 continue; 3492 } 3493 3494 // Activate the droppable if used directly from draggables 3495 if ( type === "mousedown" ) { 3496 m[ i ]._activate.call( m[ i ], event ); 3497 } 3498 3499 m[ i ].offset = m[ i ].element.offset(); 3500 m[ i ].proportions( { 3501 width: m[ i ].element[ 0 ].offsetWidth, 3502 height: m[ i ].element[ 0 ].offsetHeight 3503 } ); 3504 3505 } 3506 3507 }, 3508 drop: function( draggable, event ) { 3509 3510 var dropped = false; 3511 3512 // Create a copy of the droppables in case the list changes during the drop (#9116) 3513 $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() { 3514 3515 if ( !this.options ) { 3516 return; 3517 } 3518 if ( !this.options.disabled && this.visible && 3519 intersect( draggable, this, this.options.tolerance, event ) ) { 3520 dropped = this._drop.call( this, event ) || dropped; 3521 } 3522 3523 if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ], 3524 ( draggable.currentItem || draggable.element ) ) ) { 3525 this.isout = true; 3526 this.isover = false; 3527 this._deactivate.call( this, event ); 3528 } 3529 3530 } ); 3531 return dropped; 3532 3533 }, 3534 dragStart: function( draggable, event ) { 3535 3536 // Listen for scrolling so that if the dragging causes scrolling the position of the 3537 // droppables can be recalculated (see #5003) 3538 draggable.element.parentsUntil( "body" ).on( "scroll.droppable", function() { 3539 if ( !draggable.options.refreshPositions ) { 3540 $.ui.ddmanager.prepareOffsets( draggable, event ); 3541 } 3542 } ); 3543 }, 3544 drag: function( draggable, event ) { 3545 3546 // If you have a highly dynamic page, you might try this option. It renders positions 3547 // every time you move the mouse. 3548 if ( draggable.options.refreshPositions ) { 3549 $.ui.ddmanager.prepareOffsets( draggable, event ); 3550 } 3551 3552 // Run through all droppables and check their positions based on specific tolerance options 3553 $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() { 3554 3555 if ( this.options.disabled || this.greedyChild || !this.visible ) { 3556 return; 3557 } 3558 3559 var parentInstance, scope, parent, 3560 intersects = intersect( draggable, this, this.options.tolerance, event ), 3561 c = !intersects && this.isover ? 3562 "isout" : 3563 ( intersects && !this.isover ? "isover" : null ); 3564 if ( !c ) { 3565 return; 3566 } 3567 3568 if ( this.options.greedy ) { 3569 3570 // find droppable parents with same scope 3571 scope = this.options.scope; 3572 parent = this.element.parents( ":data(ui-droppable)" ).filter( function() { 3573 return $( this ).droppable( "instance" ).options.scope === scope; 3574 } ); 3575 3576 if ( parent.length ) { 3577 parentInstance = $( parent[ 0 ] ).droppable( "instance" ); 3578 parentInstance.greedyChild = ( c === "isover" ); 3579 } 3580 } 3581 3582 // We just moved into a greedy child 3583 if ( parentInstance && c === "isover" ) { 3584 parentInstance.isover = false; 3585 parentInstance.isout = true; 3586 parentInstance._out.call( parentInstance, event ); 3587 } 3588 3589 this[ c ] = true; 3590 this[ c === "isout" ? "isover" : "isout" ] = false; 3591 this[ c === "isover" ? "_over" : "_out" ].call( this, event ); 3592 3593 // We just moved out of a greedy child 3594 if ( parentInstance && c === "isout" ) { 3595 parentInstance.isout = false; 3596 parentInstance.isover = true; 3597 parentInstance._over.call( parentInstance, event ); 3598 } 3599 } ); 3600 3601 }, 3602 dragStop: function( draggable, event ) { 3603 draggable.element.parentsUntil( "body" ).off( "scroll.droppable" ); 3604 3605 // Call prepareOffsets one final time since IE does not fire return scroll events when 3606 // overflow was caused by drag (see #5003) 3607 if ( !draggable.options.refreshPositions ) { 3608 $.ui.ddmanager.prepareOffsets( draggable, event ); 3609 } 3610 } 3611}; 3612 3613// DEPRECATED 3614// TODO: switch return back to widget declaration at top of file when this is removed 3615if ( $.uiBackCompat !== false ) { 3616 3617 // Backcompat for activeClass and hoverClass options 3618 $.widget( "ui.droppable", $.ui.droppable, { 3619 options: { 3620 hoverClass: false, 3621 activeClass: false 3622 }, 3623 _addActiveClass: function() { 3624 this._super(); 3625 if ( this.options.activeClass ) { 3626 this.element.addClass( this.options.activeClass ); 3627 } 3628 }, 3629 _removeActiveClass: function() { 3630 this._super(); 3631 if ( this.options.activeClass ) { 3632 this.element.removeClass( this.options.activeClass ); 3633 } 3634 }, 3635 _addHoverClass: function() { 3636 this._super(); 3637 if ( this.options.hoverClass ) { 3638 this.element.addClass( this.options.hoverClass ); 3639 } 3640 }, 3641 _removeHoverClass: function() { 3642 this._super(); 3643 if ( this.options.hoverClass ) { 3644 this.element.removeClass( this.options.hoverClass ); 3645 } 3646 } 3647 } ); 3648} 3649 3650var widgetsDroppable = $.ui.droppable; 3651 3652 3653/*! 3654 * jQuery UI
3654Resizable 1.12.0 3655 * http://jqueryui.com 3656 * 3657 * Copyright jQuery Foundation and other contributors 3658 * Released under the MIT license. 3659 * http://jquery.org/license 3660 */ 3661 3662//>>label: Resizable 3663//>>group: Interactions 3664//>>description: Enables resize functionality for any element. 3665//>>docs: http://api.jqueryui.com/resizable/ 3666//>>demos: http://jqueryui.com/resizable/ 3667//>>css.structure: ../../themes/base/core.css 3668//>>css.structure: ../../themes/base/resizable.css 3669//>>css.theme: ../../themes/base/theme.css 3670 3671 3672 3673$.widget( "ui.resizable", $.ui.mouse, { 3674 version: "1.12.0
vendor: 29,111 bytes, lines 3674-4838
3674", 3675 widgetEventPrefix: "resize", 3676 options: { 3677 alsoResize: false, 3678 animate: false, 3679 animateDuration: "slow", 3680 animateEasing: "swing", 3681 aspectRatio: false, 3682 autoHide: false, 3683 classes: { 3684 "ui-resizable-se": "ui-icon ui-icon-gripsmall-diagonal-se" 3685 }, 3686 containment: false, 3687 ghost: false, 3688 grid: false, 3689 handles: "e,s,se", 3690 helper: false, 3691 maxHeight: null, 3692 maxWidth: null, 3693 minHeight: 10, 3694 minWidth: 10, 3695 3696 // See #7960 3697 zIndex: 90, 3698 3699 // Callbacks 3700 resize: null, 3701 start: null, 3702 stop: null 3703 }, 3704 3705 _num: function( value ) { 3706 return parseFloat( value ) || 0; 3707 }, 3708 3709 _isNumber: function( value ) { 3710 return !isNaN( parseFloat( value ) ); 3711 }, 3712 3713 _hasScroll: function( el, a ) { 3714 3715 if ( $( el ).css( "overflow" ) === "hidden" ) { 3716 return false; 3717 } 3718 3719 var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop", 3720 has = false; 3721 3722 if ( el[ scroll ] > 0 ) { 3723 return true; 3724 } 3725 3726 // TODO: determine which cases actually cause this to happen 3727 // if the element doesn't have the scroll set, see if it's possible to 3728 // set the scroll 3729 el[ scroll ] = 1; 3730 has = ( el[ scroll ] > 0 ); 3731 el[ scroll ] = 0; 3732 return has; 3733 }, 3734 3735 _create: function() { 3736 3737 var margins, 3738 o = this.options, 3739 that = this; 3740 this._addClass( "ui-resizable" ); 3741 3742 $.extend( this, { 3743 _aspectRatio: !!( o.aspectRatio ), 3744 aspectRatio: o.aspectRatio, 3745 originalElement: this.element, 3746 _proportionallyResizeElements: [], 3747 _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null 3748 } ); 3749 3750 // Wrap the element if it cannot hold child nodes 3751 if ( this.element[ 0 ].nodeName.match( /^(canvas|textarea|input|select|button|img)$/i ) ) { 3752 3753 this.element.wrap( 3754 $( "<div class='ui-wrapper' style='overflow: hidden;'></div>" ).css( { 3755 position: this.element.css( "position" ), 3756 width: this.element.outerWidth(), 3757 height: this.element.outerHeight(), 3758 top: this.element.css( "top" ), 3759 left: this.element.css( "left" ) 3760 } ) 3761 ); 3762 3763 this.element = this.element.parent().data( 3764 "ui-resizable", this.element.resizable( "instance" ) 3765 ); 3766 3767 this.elementIsWrapper = true; 3768 3769 margins = { 3770 marginTop: this.originalElement.css( "marginTop" ), 3771 marginRight: this.originalElement.css( "marginRight" ), 3772 marginBottom: this.originalElement.css( "marginBottom" ), 3773 marginLeft: this.originalElement.css( "marginLeft" ) 3774 }; 3775 3776 this.element.css( margins ); 3777 this.originalElement.css( "margin", 0 ); 3778 3779 // support: Safari 3780 // Prevent Safari textarea resize 3781 this.originalResizeStyle = this.originalElement.css( "resize" ); 3782 this.originalElement.css( "resize", "none" ); 3783 3784 this._proportionallyResizeElements.push( this.originalElement.css( { 3785 position: "static", 3786 zoom: 1, 3787 display: "block" 3788 } ) ); 3789 3790 // Support: IE9 3791 // avoid IE jump (hard set the margin) 3792 this.originalElement.css( margins ); 3793 3794 this._proportionallyResize(); 3795 } 3796 3797 this._setupHandles(); 3798 3799 if ( o.autoHide ) { 3800 $( this.element ) 3801 .on( "mouseenter", function() { 3802 if ( o.disabled ) { 3803 return; 3804 } 3805 that._removeClass( "ui-resizable-autohide" ); 3806 that._handles.show(); 3807 } ) 3808 .on( "mouseleave", function() { 3809 if ( o.disabled ) { 3810 return; 3811 } 3812 if ( !that.resizing ) { 3813 that._addClass( "ui-resizable-autohide" ); 3814 that._handles.hide(); 3815 } 3816 } ); 3817 } 3818 3819 this._mouseInit(); 3820 }, 3821 3822 _destroy: function() { 3823 3824 this._mouseDestroy(); 3825 3826 var wrapper, 3827 _destroy = function( exp ) { 3828 $( exp ) 3829 .removeData( "resizable" ) 3830 .removeData( "ui-resizable" ) 3831 .off( ".resizable" ) 3832 .find( ".ui-resizable-handle" ) 3833 .remove(); 3834 }; 3835 3836 // TODO: Unwrap at same DOM position 3837 if ( this.elementIsWrapper ) { 3838 _destroy( this.element ); 3839 wrapper = this.element; 3840 this.originalElement.css( { 3841 position: wrapper.css( "position" ), 3842 width: wrapper.outerWidth(), 3843 height: wrapper.outerHeight(), 3844 top: wrapper.css( "top" ), 3845 left: wrapper.css( "left" ) 3846 } ).insertAfter( wrapper ); 3847 wrapper.remove(); 3848 } 3849 3850 this.originalElement.css( "resize", this.originalResizeStyle ); 3851 _destroy( this.originalElement ); 3852 3853 return this; 3854 }, 3855 3856 _setOption: function( key, value ) { 3857 this._super( key, value ); 3858 3859 switch ( key ) { 3860 case "handles": 3861 this._removeHandles(); 3862 this._setupHandles(); 3863 break; 3864 default: 3865 break; 3866 } 3867 }, 3868 3869 _setupHandles: function() { 3870 var o = this.options, handle, i, n, hname, axis, that = this; 3871 this.handles = o.handles || 3872 ( !$( ".ui-resizable-handle", this.element ).length ? 3873 "e,s,se" : { 3874 n: ".ui-resizable-n", 3875 e: ".ui-resizable-e", 3876 s: ".ui-resizable-s", 3877 w: ".ui-resizable-w", 3878 se: ".ui-resizable-se", 3879 sw: ".ui-resizable-sw", 3880 ne: ".ui-resizable-ne", 3881 nw: ".ui-resizable-nw" 3882 } ); 3883 3884 this._handles = $(); 3885 if ( this.handles.constructor === String ) { 3886 3887 if ( this.handles === "all" ) { 3888 this.handles = "n,e,s,w,se,sw,ne,nw"; 3889 } 3890 3891 n = this.handles.split( "," ); 3892 this.handles = {}; 3893 3894 for ( i = 0; i < n.length; i++ ) { 3895 3896 handle = $.trim( n[ i ] ); 3897 hname = "ui-resizable-" + handle; 3898 axis = $( "<div>" ); 3899 this._addClass( axis, "ui-resizable-handle " + hname ); 3900 3901 axis.css( { zIndex: o.zIndex } ); 3902 3903 this.handles[ handle ] = ".ui-resizable-" + handle; 3904 this.element.append( axis ); 3905 } 3906 3907 } 3908 3909 this._renderAxis = function( target ) { 3910 3911 var i, axis, padPos, padWrapper; 3912 3913 target = target || this.element; 3914 3915 for ( i in this.handles ) { 3916 3917 if ( this.handles[ i ].constructor === String ) { 3918 this.handles[ i ] = this.element.children( this.handles[ i ] ).first().show(); 3919 } else if ( this.handles[ i ].jquery || this.handles[ i ].nodeType ) { 3920 this.handles[ i ] = $( this.handles[ i ] ); 3921 this._on( this.handles[ i ], { "mousedown": that._mouseDown } ); 3922 } 3923 3924 if ( this.elementIsWrapper && 3925 this.originalElement[ 0 ] 3926 .nodeName 3927 .match( /^(textarea|input|select|button)$/i ) ) { 3928 axis = $( this.handles[ i ], this.element ); 3929 3930 padWrapper = /sw|ne|nw|se|n|s/.test( i ) ? 3931 axis.outerHeight() : 3932 axis.outerWidth(); 3933 3934 padPos = [ "padding", 3935 /ne|nw|n/.test( i ) ? "Top" : 3936 /se|sw|s/.test( i ) ? "Bottom" : 3937 /^e$/.test( i ) ? "Right" : "Left" ].join( "" ); 3938 3939 target.css( padPos, padWrapper ); 3940 3941 this._proportionallyResize(); 3942 } 3943 3944 this._handles = this._handles.add( this.handles[ i ] ); 3945 } 3946 }; 3947 3948 // TODO: make renderAxis a prototype function 3949 this._renderAxis( this.element ); 3950 3951 this._handles = this._handles.add( this.element.find( ".ui-resizable-handle" ) ); 3952 this._handles.disableSelection(); 3953 3954 this._handles.on( "mouseover", function() { 3955 if ( !that.resizing ) { 3956 if ( this.className ) { 3957 axis = this.className.match( /ui-resizable-(se|sw|ne|nw|n|e|s|w)/i ); 3958 } 3959 that.axis = axis && axis[ 1 ] ? axis[ 1 ] : "se"; 3960 } 3961 } ); 3962 3963 if ( o.autoHide ) { 3964 this._handles.hide(); 3965 this._addClass( "ui-resizable-autohide" ); 3966 } 3967 }, 3968 3969 _removeHandles: function() { 3970 this._handles.remove(); 3971 }, 3972 3973 _mouseCapture: function( event ) { 3974 var i, handle, 3975 capture = false; 3976 3977 for ( i in this.handles ) { 3978 handle = $( this.handles[ i ] )[ 0 ]; 3979 if ( handle === event.target || $.contains( handle, event.target ) ) { 3980 capture = true; 3981 } 3982 } 3983 3984 return !this.options.disabled && capture; 3985 }, 3986 3987 _mouseStart: function( event ) { 3988 3989 var curleft, curtop, cursor, 3990 o = this.options, 3991 el = this.element; 3992 3993 this.resizing = true; 3994 3995 this._renderProxy(); 3996 3997 curleft = this._num( this.helper.css( "left" ) ); 3998 curtop = this._num( this.helper.css( "top" ) ); 3999 4000 if ( o.containment ) { 4001 curleft += $( o.containment ).scrollLeft() || 0; 4002 curtop += $( o.containment ).scrollTop() || 0; 4003 } 4004 4005 this.offset = this.helper.offset(); 4006 this.position = { left: curleft, top: curtop }; 4007 4008 this.size = this._helper ? { 4009 width: this.helper.width(), 4010 height: this.helper.height() 4011 } : { 4012 width: el.width(), 4013 height: el.height() 4014 }; 4015 4016 this.originalSize = this._helper ? { 4017 width: el.outerWidth(), 4018 height: el.outerHeight() 4019 } : { 4020 width: el.width(), 4021 height: el.height() 4022 }; 4023 4024 this.sizeDiff = { 4025 width: el.outerWidth() - el.width(), 4026 height: el.outerHeight() - el.height() 4027 }; 4028 4029 this.originalPosition = { left: curleft, top: curtop }; 4030 this.originalMousePosition = { left: event.pageX, top: event.pageY }; 4031 4032 this.aspectRatio = ( typeof o.aspectRatio === "number" ) ? 4033 o.aspectRatio : 4034 ( ( this.originalSize.width / this.originalSize.height ) || 1 ); 4035 4036 cursor = $( ".ui-resizable-" + this.axis ).css( "cursor" ); 4037 $( "body" ).css( "cursor", cursor === "auto" ? this.axis + "-resize" : cursor ); 4038 4039 this._addClass( "ui-resizable-resizing" ); 4040 this._propagate( "start", event ); 4041 return true; 4042 }, 4043 4044 _mouseDrag: function( event ) { 4045 4046 var data, props, 4047 smp = this.originalMousePosition, 4048 a = this.axis, 4049 dx = ( event.pageX - smp.left ) || 0, 4050 dy = ( event.pageY - smp.top ) || 0, 4051 trigger = this._change[ a ]; 4052 4053 this._updatePrevProperties(); 4054 4055 if ( !trigger ) { 4056 return false; 4057 } 4058 4059 data = trigger.apply( this, [ event, dx, dy ] ); 4060 4061 this._updateVirtualBoundaries( event.shiftKey ); 4062 if ( this._aspectRatio || event.shiftKey ) { 4063 data = this._updateRatio( data, event ); 4064 } 4065 4066 data = this._respectSize( data, event ); 4067 4068 this._updateCache( data ); 4069 4070 this._propagate( "resize", event ); 4071 4072 props = this._applyChanges(); 4073 4074 if ( !this._helper && this._proportionallyResizeElements.length ) { 4075 this._proportionallyResize(); 4076 } 4077 4078 if ( !$.isEmptyObject( props ) ) { 4079 this._updatePrevProperties(); 4080 this._trigger( "resize", event, this.ui() ); 4081 this._applyChanges(); 4082 } 4083 4084 return false; 4085 }, 4086 4087 _mouseStop: function( event ) { 4088 4089 this.resizing = false; 4090 var pr, ista, soffseth, soffsetw, s, left, top, 4091 o = this.options, that = this; 4092 4093 if ( this._helper ) { 4094 4095 pr = this._proportionallyResizeElements; 4096 ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName ); 4097 soffseth = ista && this._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height; 4098 soffsetw = ista ? 0 : that.sizeDiff.width; 4099 4100 s = { 4101 width: ( that.helper.width() - soffsetw ), 4102 height: ( that.helper.height() - soffseth ) 4103 }; 4104 left = ( parseFloat( that.element.css( "left" ) ) + 4105 ( that.position.left - that.originalPosition.left ) ) || null; 4106 top = ( parseFloat( that.element.css( "top" ) ) + 4107 ( that.position.top - that.originalPosition.top ) ) || null; 4108 4109 if ( !o.animate ) { 4110 this.element.css( $.extend( s, { top: top, left: left } ) ); 4111 } 4112 4113 that.helper.height( that.size.height ); 4114 that.helper.width( that.size.width ); 4115 4116 if ( this._helper && !o.animate ) { 4117 this._proportionallyResize(); 4118 } 4119 } 4120 4121 $( "body" ).css( "cursor", "auto" ); 4122 4123 this._removeClass( "ui-resizable-resizing" ); 4124 4125 this._propagate( "stop", event ); 4126 4127 if ( this._helper ) { 4128 this.helper.remove(); 4129 } 4130 4131 return false; 4132 4133 }, 4134 4135 _updatePrevProperties: function() { 4136 this.prevPosition = { 4137 top: this.position.top, 4138 left: this.position.left 4139 }; 4140 this.prevSize = { 4141 width: this.size.width, 4142 height: this.size.height 4143 }; 4144 }, 4145 4146 _applyChanges: function() { 4147 var props = {}; 4148 4149 if ( this.position.top !== this.prevPosition.top ) { 4150 props.top = this.position.top + "px"; 4151 } 4152 if ( this.position.left !== this.prevPosition.left ) { 4153 props.left = this.position.left + "px"; 4154 } 4155 if ( this.size.width !== this.prevSize.width ) { 4156 props.width = this.size.width + "px"; 4157 } 4158 if ( this.size.height !== this.prevSize.height ) { 4159 props.height = this.size.height + "px"; 4160 } 4161 4162 this.helper.css( props ); 4163 4164 return props; 4165 }, 4166 4167 _updateVirtualBoundaries: function( forceAspectRatio ) { 4168 var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b, 4169 o = this.options; 4170 4171 b = { 4172 minWidth: this._isNumber( o.minWidth ) ? o.minWidth : 0, 4173 maxWidth: this._isNumber( o.maxWidth ) ? o.maxWidth : Infinity, 4174 minHeight: this._isNumber( o.minHeight ) ? o.minHeight : 0, 4175 maxHeight: this._isNumber( o.maxHeight ) ? o.maxHeight : Infinity 4176 }; 4177 4178 if ( this._aspectRatio || forceAspectRatio ) { 4179 pMinWidth = b.minHeight * this.aspectRatio; 4180 pMinHeight = b.minWidth / this.aspectRatio; 4181 pMaxWidth = b.maxHeight * this.aspectRatio; 4182 pMaxHeight = b.maxWidth / this.aspectRatio; 4183 4184 if ( pMinWidth > b.minWidth ) { 4185 b.minWidth = pMinWidth; 4186 } 4187 if ( pMinHeight > b.minHeight ) { 4188 b.minHeight = pMinHeight; 4189 } 4190 if ( pMaxWidth < b.maxWidth ) { 4191 b.maxWidth = pMaxWidth; 4192 } 4193 if ( pMaxHeight < b.maxHeight ) { 4194 b.maxHeight = pMaxHeight; 4195 } 4196 } 4197 this._vBoundaries = b; 4198 }, 4199 4200 _updateCache: function( data ) { 4201 this.offset = this.helper.offset(); 4202 if ( this._isNumber( data.left ) ) { 4203 this.position.left = data.left; 4204 } 4205 if ( this._isNumber( data.top ) ) { 4206 this.position.top = data.top; 4207 } 4208 if ( this._isNumber( data.height ) ) { 4209 this.size.height = data.height; 4210 } 4211 if ( this._isNumber( data.width ) ) { 4212 this.size.width = data.width; 4213 } 4214 }, 4215 4216 _updateRatio: function( data ) { 4217 4218 var cpos = this.position, 4219 csize = this.size, 4220 a = this.axis; 4221 4222 if ( this._isNumber( data.height ) ) { 4223 data.width = ( data.height * this.aspectRatio ); 4224 } else if ( this._isNumber( data.width ) ) { 4225 data.height = ( data.width / this.aspectRatio ); 4226 } 4227 4228 if ( a === "sw" ) { 4229 data.left = cpos.left + ( csize.width - data.width ); 4230 data.top = null; 4231 } 4232 if ( a === "nw" ) { 4233 data.top = cpos.top + ( csize.height - data.height ); 4234 data.left = cpos.left + ( csize.width - data.width ); 4235 } 4236 4237 return data; 4238 }, 4239 4240 _respectSize: function( data ) { 4241 4242 var o = this._vBoundaries, 4243 a = this.axis, 4244 ismaxw = this._isNumber( data.width ) && o.maxWidth && ( o.maxWidth < data.width ), 4245 ismaxh = this._isNumber( data.height ) && o.maxHeight && ( o.maxHeight < data.height ), 4246 isminw = this._isNumber( data.width ) && o.minWidth && ( o.minWidth > data.width ), 4247 isminh = this._isNumber( data.height ) && o.minHeight && ( o.minHeight > data.height ), 4248 dw = this.originalPosition.left + this.originalSize.width, 4249 dh = this.originalPosition.top + this.originalSize.height, 4250 cw = /sw|nw|w/.test( a ), ch = /nw|ne|n/.test( a ); 4251 if ( isminw ) { 4252 data.width = o.minWidth; 4253 } 4254 if ( isminh ) { 4255 data.height = o.minHeight; 4256 } 4257 if ( ismaxw ) { 4258 data.width = o.maxWidth; 4259 } 4260 if ( ismaxh ) { 4261 data.height = o.maxHeight; 4262 } 4263 4264 if ( isminw && cw ) { 4265 data.left = dw - o.minWidth; 4266 } 4267 if ( ismaxw && cw ) { 4268 data.left = dw - o.maxWidth; 4269 } 4270 if ( isminh && ch ) { 4271 data.top = dh - o.minHeight; 4272 } 4273 if ( ismaxh && ch ) { 4274 data.top = dh - o.maxHeight; 4275 } 4276 4277 // Fixing jump error on top/left - bug #2330 4278 if ( !data.width && !data.height && !data.left && data.top ) { 4279 data.top = null; 4280 } else if ( !data.width && !data.height && !data.top && data.left ) { 4281 data.left = null; 4282 } 4283 4284 return data; 4285 }, 4286 4287 _getPaddingPlusBorderDimensions: function( element ) { 4288 var i = 0, 4289 widths = [], 4290 borders = [ 4291 element.css( "borderTopWidth" ), 4292 element.css( "borderRightWidth" ), 4293 element.css( "borderBottomWidth" ), 4294 element.css( "borderLeftWidth" ) 4295 ], 4296 paddings = [ 4297 element.css( "paddingTop" ), 4298 element.css( "paddingRight" ), 4299 element.css( "paddingBottom" ), 4300 element.css( "paddingLeft" ) 4301 ]; 4302 4303 for ( ; i < 4; i++ ) { 4304 widths[ i ] = ( parseFloat( borders[ i ] ) || 0 ); 4305 widths[ i ] += ( parseFloat( paddings[ i ] ) || 0 ); 4306 } 4307 4308 return { 4309 height: widths[ 0 ] + widths[ 2 ], 4310 width: widths[ 1 ] + widths[ 3 ] 4311 }; 4312 }, 4313 4314 _proportionallyResize: function() { 4315 4316 if ( !this._proportionallyResizeElements.length ) { 4317 return; 4318 } 4319 4320 var prel, 4321 i = 0, 4322 element = this.helper || this.element; 4323 4324 for ( ; i < this._proportionallyResizeElements.length; i++ ) { 4325 4326 prel = this._proportionallyResizeElements[ i ]; 4327 4328 // TODO: Seems like a bug to cache this.outerDimensions 4329 // considering that we are in a loop. 4330 if ( !this.outerDimensions ) { 4331 this.outerDimensions = this._getPaddingPlusBorderDimensions( prel ); 4332 } 4333 4334 prel.css( { 4335 height: ( element.height() - this.outerDimensions.height ) || 0, 4336 width: ( element.width() - this.outerDimensions.width ) || 0 4337 } ); 4338 4339 } 4340 4341 }, 4342 4343 _renderProxy: function() { 4344 4345 var el = this.element, o = this.options; 4346 this.elementOffset = el.offset(); 4347 4348 if ( this._helper ) { 4349 4350 this.helper = this.helper || $( "<div style='overflow:hidden;'></div>" ); 4351 4352 this._addClass( this.helper, this._helper ); 4353 this.helper.css( { 4354 width: this.element.outerWidth(), 4355 height: this.element.outerHeight(), 4356 position: "absolute", 4357 left: this.elementOffset.left + "px", 4358 top: this.elementOffset.top + "px", 4359 zIndex: ++o.zIndex //TODO: Don't modify option 4360 } ); 4361 4362 this.helper 4363 .appendTo( "body" ) 4364 .disableSelection(); 4365 4366 } else { 4367 this.helper = this.element; 4368 } 4369 4370 }, 4371 4372 _change: { 4373 e: function( event, dx ) { 4374 return { width: this.originalSize.width + dx }; 4375 }, 4376 w: function( event, dx ) { 4377 var cs = this.originalSize, sp = this.originalPosition; 4378 return { left: sp.left + dx, width: cs.width - dx }; 4379 }, 4380 n: function( event, dx, dy ) { 4381 var cs = this.originalSize, sp = this.originalPosition; 4382 return { top: sp.top + dy, height: cs.height - dy }; 4383 }, 4384 s: function( event, dx, dy ) { 4385 return { height: this.originalSize.height + dy }; 4386 }, 4387 se: function( event, dx, dy ) { 4388 return $.extend( this._change.s.apply( this, arguments ), 4389 this._change.e.apply( this, [ event, dx, dy ] ) ); 4390 }, 4391 sw: function( event, dx, dy ) { 4392 return $.extend( this._change.s.apply( this, arguments ), 4393 this._change.w.apply( this, [ event, dx, dy ] ) ); 4394 }, 4395 ne: function( event, dx, dy ) { 4396 return $.extend( this._change.n.apply( this, arguments ), 4397 this._change.e.apply( this, [ event, dx, dy ] ) ); 4398 }, 4399 nw: function( event, dx, dy ) { 4400 return $.extend( this._change.n.apply( this, arguments ), 4401 this._change.w.apply( this, [ event, dx, dy ] ) ); 4402 } 4403 }, 4404 4405 _propagate: function( n, event ) { 4406 $.ui.plugin.call( this, n, [ event, this.ui() ] ); 4407 ( n !== "resize" && this._trigger( n, event, this.ui() ) ); 4408 }, 4409 4410 plugins: {}, 4411 4412 ui: function() { 4413 return { 4414 originalElement: this.originalElement, 4415 element: this.element, 4416 helper: this.helper, 4417 position: this.position, 4418 size: this.size, 4419 originalSize: this.originalSize, 4420 originalPosition: this.originalPosition 4421 }; 4422 } 4423 4424} ); 4425 4426/* 4427 * Resizable Extensions 4428 */ 4429 4430$.ui.plugin.add( "resizable", "animate", { 4431 4432 stop: function( event ) { 4433 var that = $( this ).resizable( "instance" ), 4434 o = that.options, 4435 pr = that._proportionallyResizeElements, 4436 ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName ), 4437 soffseth = ista && that._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height, 4438 soffsetw = ista ? 0 : that.sizeDiff.width, 4439 style = { 4440 width: ( that.size.width - soffsetw ), 4441 height: ( that.size.height - soffseth ) 4442 }, 4443 left = ( parseFloat( that.element.css( "left" ) ) + 4444 ( that.position.left - that.originalPosition.left ) ) || null, 4445 top = ( parseFloat( that.element.css( "top" ) ) + 4446 ( that.position.top - that.originalPosition.top ) ) || null; 4447 4448 that.element.animate( 4449 $.extend( style, top && left ? { top: top, left: left } : {} ), { 4450 duration: o.animateDuration, 4451 easing: o.animateEasing, 4452 step: function() { 4453 4454 var data = { 4455 width: parseFloat( that.element.css( "width" ) ), 4456 height: parseFloat( that.element.css( "height" ) ), 4457 top: parseFloat( that.element.css( "top" ) ), 4458 left: parseFloat( that.element.css( "left" ) ) 4459 }; 4460 4461 if ( pr && pr.length ) { 4462 $( pr[ 0 ] ).css( { width: data.width, height: data.height } ); 4463 } 4464 4465 // Propagating resize, and updating values for each animation step 4466 that._updateCache( data ); 4467 that._propagate( "resize", event ); 4468 4469 } 4470 } 4471 ); 4472 } 4473 4474} ); 4475 4476$.ui.plugin.add( "resizable", "containment", { 4477 4478 start: function() { 4479 var element, p, co, ch, cw, width, height, 4480 that = $( this ).resizable( "instance" ), 4481 o = that.options, 4482 el = that.element, 4483 oc = o.containment, 4484 ce = ( oc instanceof $ ) ? 4485 oc.get( 0 ) : 4486 ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc; 4487 4488 if ( !ce ) { 4489 return; 4490 } 4491 4492 that.containerElement = $( ce ); 4493 4494 if ( /document/.test( oc ) || oc === document ) { 4495 that.containerOffset = { 4496 left: 0, 4497 top: 0 4498 }; 4499 that.containerPosition = { 4500 left: 0, 4501 top: 0 4502 }; 4503 4504 that.parentData = { 4505 element: $( document ), 4506 left: 0, 4507 top: 0, 4508 width: $( document ).width(), 4509 height: $( document ).height() || document.body.parentNode.scrollHeight 4510 }; 4511 } else { 4512 element = $( ce ); 4513 p = []; 4514 $( [ "Top", "Right", "Left", "Bottom" ] ).each( function( i, name ) { 4515 p[ i ] = that._num( element.css( "padding" + name ) ); 4516 } ); 4517 4518 that.containerOffset = element.offset(); 4519 that.containerPosition = element.position(); 4520 that.containerSize = { 4521 height: ( element.innerHeight() - p[ 3 ] ), 4522 width: ( element.innerWidth() - p[ 1 ] ) 4523 }; 4524 4525 co = that.containerOffset; 4526 ch = that.containerSize.height; 4527 cw = that.containerSize.width; 4528 width = ( that._hasScroll ( ce, "left" ) ? ce.scrollWidth : cw ); 4529 height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ; 4530 4531 that.parentData = { 4532 element: ce, 4533 left: co.left, 4534 top: co.top, 4535 width: width, 4536 height: height 4537 }; 4538 } 4539 }, 4540 4541 resize: function( event ) { 4542 var woset, hoset, isParent, isOffsetRelative, 4543 that = $( this ).resizable( "instance" ), 4544 o = that.options, 4545 co = that.containerOffset, 4546 cp = that.position, 4547 pRatio = that._aspectRatio || event.shiftKey, 4548 cop = { 4549 top: 0, 4550 left: 0 4551 }, 4552 ce = that.containerElement, 4553 continueResize = true; 4554 4555 if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) { 4556 cop = co; 4557 } 4558 4559 if ( cp.left < ( that._helper ? co.left : 0 ) ) { 4560 that.size.width = that.size.width + 4561 ( that._helper ? 4562 ( that.position.left - co.left ) : 4563 ( that.position.left - cop.left ) ); 4564 4565 if ( pRatio ) { 4566 that.size.height = that.size.width / that.aspectRatio; 4567 continueResize = false; 4568 } 4569 that.position.left = o.helper ? co.left : 0; 4570 } 4571 4572 if ( cp.top < ( that._helper ? co.top : 0 ) ) { 4573 that.size.height = that.size.height + 4574 ( that._helper ? 4575 ( that.position.top - co.top ) : 4576 that.position.top ); 4577 4578 if ( pRatio ) { 4579 that.size.width = that.size.height * that.aspectRatio; 4580 continueResize = false; 4581 } 4582 that.position.top = that._helper ? co.top : 0; 4583 } 4584 4585 isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 ); 4586 isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) ); 4587 4588 if ( isParent && isOffsetRelative ) { 4589 that.offset.left = that.parentData.left + that.position.left; 4590 that.offset.top = that.parentData.top + that.position.top; 4591 } else { 4592 that.offset.left = that.element.offset().left; 4593 that.offset.top = that.element.offset().top; 4594 } 4595 4596 woset = Math.abs( that.sizeDiff.width + 4597 ( that._helper ? 4598 that.offset.left - cop.left : 4599 ( that.offset.left - co.left ) ) ); 4600 4601 hoset = Math.abs( that.sizeDiff.height + 4602 ( that._helper ? 4603 that.offset.top - cop.top : 4604 ( that.offset.top - co.top ) ) ); 4605 4606 if ( woset + that.size.width >= that.parentData.width ) { 4607 that.size.width = that.parentData.width - woset; 4608 if ( pRatio ) { 4609 that.size.height = that.size.width / that.aspectRatio; 4610 continueResize = false; 4611 } 4612 } 4613 4614 if ( hoset + that.size.height >= that.parentData.height ) { 4615 that.size.height = that.parentData.height - hoset; 4616 if ( pRatio ) { 4617 that.size.width = that.size.height * that.aspectRatio; 4618 continueResize = false; 4619 } 4620 } 4621 4622 if ( !continueResize ) { 4623 that.position.left = that.prevPosition.left; 4624 that.position.top = that.prevPosition.top; 4625 that.size.width = that.prevSize.width; 4626 that.size.height = that.prevSize.height; 4627 } 4628 }, 4629 4630 stop: function() { 4631 var that = $( this ).resizable( "instance" ), 4632 o = that.options, 4633 co = that.containerOffset, 4634 cop = that.containerPosition, 4635 ce = that.containerElement, 4636 helper = $( that.helper ), 4637 ho = helper.offset(), 4638 w = helper.outerWidth() - that.sizeDiff.width, 4639 h = helper.outerHeight() - that.sizeDiff.height; 4640 4641 if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) { 4642 $( this ).css( { 4643 left: ho.left - cop.left - co.left, 4644 width: w, 4645 height: h 4646 } ); 4647 } 4648 4649 if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) { 4650 $( this ).css( { 4651 left: ho.left - cop.left - co.left, 4652 width: w, 4653 height: h 4654 } ); 4655 } 4656 } 4657} ); 4658 4659$.ui.plugin.add( "resizable", "alsoResize", { 4660 4661 start: function() { 4662 var that = $( this ).resizable( "instance" ), 4663 o = that.options; 4664 4665 $( o.alsoResize ).each( function() { 4666 var el = $( this ); 4667 el.data( "ui-resizable-alsoresize", { 4668 width: parseFloat( el.width() ), height: parseFloat( el.height() ), 4669 left: parseFloat( el.css( "left" ) ), top: parseFloat( el.css( "top" ) ) 4670 } ); 4671 } ); 4672 }, 4673 4674 resize: function( event, ui ) { 4675 var that = $( this ).resizable( "instance" ), 4676 o = that.options, 4677 os = that.originalSize, 4678 op = that.originalPosition, 4679 delta = { 4680 height: ( that.size.height - os.height ) || 0, 4681 width: ( that.size.width - os.width ) || 0, 4682 top: ( that.position.top - op.top ) || 0, 4683 left: ( that.position.left - op.left ) || 0 4684 }; 4685 4686 $( o.alsoResize ).each( function() { 4687 var el = $( this ), start = $( this ).data( "ui-resizable-alsoresize" ), style = {}, 4688 css = el.parents( ui.originalElement[ 0 ] ).length ? 4689 [ "width", "height" ] : 4690 [ "width", "height", "top", "left" ]; 4691 4692 $.each( css, function( i, prop ) { 4693 var sum = ( start[ prop ] || 0 ) + ( delta[ prop ] || 0 ); 4694 if ( sum && sum >= 0 ) { 4695 style[ prop ] = sum || null; 4696 } 4697 } ); 4698 4699 el.css( style ); 4700 } ); 4701 }, 4702 4703 stop: function() { 4704 $( this ).removeData( "ui-resizable-alsoresize" ); 4705 } 4706} ); 4707 4708$.ui.plugin.add( "resizable", "ghost", { 4709 4710 start: function() { 4711 4712 var that = $( this ).resizable( "instance" ), cs = that.size; 4713 4714 that.ghost = that.originalElement.clone(); 4715 that.ghost.css( { 4716 opacity: 0.25, 4717 display: "block", 4718 position: "relative", 4719 height: cs.height, 4720 width: cs.width, 4721 margin: 0, 4722 left: 0, 4723 top: 0 4724 } ); 4725 4726 that._addClass( that.ghost, "ui-resizable-ghost" ); 4727 4728 // DEPRECATED 4729 // TODO: remove after 1.12 4730 if ( $.uiBackCompat !== false && typeof that.options.ghost === "string" ) { 4731 4732 // Ghost option 4733 that.ghost.addClass( this.options.ghost ); 4734 } 4735 4736 that.ghost.appendTo( that.helper ); 4737 4738 }, 4739 4740 resize: function() { 4741 var that = $( this ).resizable( "instance" ); 4742 if ( that.ghost ) { 4743 that.ghost.css( { 4744 position: "relative", 4745 height: that.size.height, 4746 width: that.size.width 4747 } ); 4748 } 4749 }, 4750 4751 stop: function() { 4752 var that = $( this ).resizable( "instance" ); 4753 if ( that.ghost && that.helper ) { 4754 that.helper.get( 0 ).removeChild( that.ghost.get( 0 ) ); 4755 } 4756 } 4757 4758} ); 4759 4760$.ui.plugin.add( "resizable", "grid", { 4761 4762 resize: function() { 4763 var outerDimensions, 4764 that = $( this ).resizable( "instance" ), 4765 o = that.options, 4766 cs = that.size, 4767 os = that.originalSize, 4768 op = that.originalPosition, 4769 a = that.axis, 4770 grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid, 4771 gridX = ( grid[ 0 ] || 1 ), 4772 gridY = ( grid[ 1 ] || 1 ), 4773 ox = Math.round( ( cs.width - os.width ) / gridX ) * gridX, 4774 oy = Math.round( ( cs.height - os.height ) / gridY ) * gridY, 4775 newWidth = os.width + ox, 4776 newHeight = os.height + oy, 4777 isMaxWidth = o.maxWidth && ( o.maxWidth < newWidth ), 4778 isMaxHeight = o.maxHeight && ( o.maxHeight < newHeight ), 4779 isMinWidth = o.minWidth && ( o.minWidth > newWidth ), 4780 isMinHeight = o.minHeight && ( o.minHeight > newHeight ); 4781 4782 o.grid = grid; 4783 4784 if ( isMinWidth ) { 4785 newWidth += gridX; 4786 } 4787 if ( isMinHeight ) { 4788 newHeight += gridY; 4789 } 4790 if ( isMaxWidth ) { 4791 newWidth -= gridX; 4792 } 4793 if ( isMaxHeight ) { 4794 newHeight -= gridY; 4795 } 4796 4797 if ( /^(se|s|e)$/.test( a ) ) { 4798 that.size.width = newWidth; 4799 that.size.height = newHeight; 4800 } else if ( /^(ne)$/.test( a ) ) { 4801 that.size.width = newWidth; 4802 that.size.height = newHeight; 4803 that.position.top = op.top - oy; 4804 } else if ( /^(sw)$/.test( a ) ) { 4805 that.size.width = newWidth; 4806 that.size.height = newHeight; 4807 that.position.left = op.left - ox; 4808 } else { 4809 if ( newHeight - gridY <= 0 || newWidth - gridX <= 0 ) { 4810 outerDimensions = that._getPaddingPlusBorderDimensions( this ); 4811 } 4812 4813 if ( newHeight - gridY > 0 ) { 4814 that.size.height = newHeight; 4815 that.position.top = op.top - oy; 4816 } else { 4817 newHeight = gridY - outerDimensions.height; 4818 that.size.height = newHeight; 4819 that.position.top = op.top + os.height - newHeight; 4820 } 4821 if ( newWidth - gridX > 0 ) { 4822 that.size.width = newWidth; 4823 that.position.left = op.left - ox; 4824 } else { 4825 newWidth = gridX - outerDimensions.width; 4826 that.size.width = newWidth; 4827 that.position.left = op.left + os.width - newWidth; 4828 } 4829 } 4830 } 4831 4832} ); 4833 4834var widgetsResizable = $.ui.resizable; 4835 4836 4837/*! 4838 * jQuery UI
4838Sortable 1.12.0 4839 * http://jqueryui.com 4840 * 4841 * Copyright jQuery Foundation and other contributors 4842 * Released under the MIT license. 4843 * http://jquery.org/license 4844 */ 4845 4846//>>label: Sortable 4847//>>group: Interactions 4848//>>description: Enables items in a list to be sorted using the mouse. 4849//>>docs: http://api.jqueryui.com/sortable/ 4850//>>demos: http://jqueryui.com/sortable/ 4851//>>css.structure: ../../themes/base/sortable.css 4852 4853 4854 4855var widgetsSortable = $.widget( "ui.sortable", $.ui.mouse, { 4856 version: "1.12.0
vendor: 12,895 bytes, lines 4856-5339
4856", 4857 widgetEventPrefix: "sort", 4858 ready: false, 4859 options: { 4860 appendTo: "parent", 4861 axis: false, 4862 connectWith: false, 4863 containment: false, 4864 cursor: "auto", 4865 cursorAt: false, 4866 dropOnEmpty: true, 4867 forcePlaceholderSize: false, 4868 forceHelperSize: false, 4869 grid: false, 4870 handle: false, 4871 helper: "original", 4872 items: "> *", 4873 opacity: false, 4874 placeholder: false, 4875 revert: false, 4876 scroll: true, 4877 scrollSensitivity: 20, 4878 scrollSpeed: 20, 4879 scope: "default", 4880 tolerance: "intersect", 4881 zIndex: 1000, 4882 4883 // Callbacks 4884 activate: null, 4885 beforeStop: null, 4886 change: null, 4887 deactivate: null, 4888 out: null, 4889 over: null, 4890 receive: null, 4891 remove: null, 4892 sort: null, 4893 start: null, 4894 stop: null, 4895 update: null 4896 }, 4897 4898 _isOverAxis: function( x, reference, size ) { 4899 return ( x >= reference ) && ( x < ( reference + size ) ); 4900 }, 4901 4902 _isFloating: function( item ) { 4903 return ( /left|right/ ).test( item.css( "float" ) ) || 4904 ( /inline|table-cell/ ).test( item.css( "display" ) ); 4905 }, 4906 4907 _create: function() { 4908 this.containerCache = {}; 4909 this._addClass( "ui-sortable" ); 4910 4911 //Get the items 4912 this.refresh(); 4913 4914 //Let's determine the parent's offset 4915 this.offset = this.element.offset(); 4916 4917 //Initialize mouse events for interaction 4918 this._mouseInit(); 4919 4920 this._setHandleClassName(); 4921 4922 //We're ready to go 4923 this.ready = true; 4924 4925 }, 4926 4927 _setOption: function( key, value ) { 4928 this._super( key, value ); 4929 4930 if ( key === "handle" ) { 4931 this._setHandleClassName(); 4932 } 4933 }, 4934 4935 _setHandleClassName: function() { 4936 var that = this; 4937 this._removeClass( this.element.find( ".ui-sortable-handle" ), "ui-sortable-handle" ); 4938 $.each( this.items, function() { 4939 that._addClass( 4940 this.instance.options.handle ? 4941 this.item.find( this.instance.options.handle ) : 4942 this.item, 4943 "ui-sortable-handle" 4944 ); 4945 } ); 4946 }, 4947 4948 _destroy: function() { 4949 this._mouseDestroy(); 4950 4951 for ( var i = this.items.length - 1; i >= 0; i-- ) { 4952 this.items[ i ].item.removeData( this.widgetName + "-item" ); 4953 } 4954 4955 return this; 4956 }, 4957 4958 _mouseCapture: function( event, overrideHandle ) { 4959 var currentItem = null, 4960 validHandle = false, 4961 that = this; 4962 4963 if ( this.reverting ) { 4964 return false; 4965 } 4966 4967 if ( this.options.disabled || this.options.type === "static" ) { 4968 return false; 4969 } 4970 4971 //We have to refresh the items data once first 4972 this._refreshItems( event ); 4973 4974 //Find out if the clicked node (or one of its parents) is a actual item in this.items 4975 $( event.target ).parents().each( function() { 4976 if ( $.data( this, that.widgetName + "-item" ) === that ) { 4977 currentItem = $( this ); 4978 return false; 4979 } 4980 } ); 4981 if ( $.data( event.target, that.widgetName + "-item" ) === that ) { 4982 currentItem = $( event.target ); 4983 } 4984 4985 if ( !currentItem ) { 4986 return false; 4987 } 4988 if ( this.options.handle && !overrideHandle ) { 4989 $( this.options.handle, currentItem ).find( "*" ).addBack().each( function() { 4990 if ( this === event.target ) { 4991 validHandle = true; 4992 } 4993 } ); 4994 if ( !validHandle ) { 4995 return false; 4996 } 4997 } 4998 4999 this.currentItem = currentItem; 5000 this._removeCurrentsFromItems(); 5001 return true; 5002 5003 }, 5004 5005 _mouseStart: function( event, overrideHandle, noActivation ) { 5006 5007 var i, body, 5008 o = this.options; 5009 5010 this.currentContainer = this; 5011 5012 //We only need to call refreshPositions, because the refreshItems call has been moved to 5013 // mouseCapture 5014 this.refreshPositions(); 5015 5016 //Create and append the visible helper 5017 this.helper = this._createHelper( event ); 5018 5019 //Cache the helper size 5020 this._cacheHelperProportions(); 5021 5022 /* 5023 * - Position generation - 5024 * This block generates everything position related - it's the core of draggables. 5025 */ 5026 5027 //Cache the margins of the original element 5028 this._cacheMargins(); 5029 5030 //Get the next scrolling parent 5031 this.scrollParent = this.helper.scrollParent(); 5032 5033 //The element's absolute position on the page minus margins 5034 this.offset = this.currentItem.offset(); 5035 this.offset = { 5036 top: this.offset.top - this.margins.top, 5037 left: this.offset.left - this.margins.left 5038 }; 5039 5040 $.extend( this.offset, { 5041 click: { //Where the click happened, relative to the element 5042 left: event.pageX - this.offset.left, 5043 top: event.pageY - this.offset.top 5044 }, 5045 parent: this._getParentOffset(), 5046 5047 // This is a relative to absolute position minus the actual position calculation - 5048 // only used for relative positioned helper 5049 relative: this._getRelativeOffset() 5050 } ); 5051 5052 // Only after we got the offset, we can change the helper's position to absolute 5053 // TODO: Still need to figure out a way to make relative sorting possible 5054 this.helper.css( "position", "absolute" ); 5055 this.cssPosition = this.helper.css( "position" ); 5056 5057 //Generate the original position 5058 this.originalPosition = this._generatePosition( event ); 5059 this.originalPageX = event.pageX; 5060 this.originalPageY = event.pageY; 5061 5062 //Adjust the mouse offset relative to the helper if "cursorAt" is supplied 5063 ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) ); 5064 5065 //Cache the former DOM position 5066 this.domPosition = { 5067 prev: this.currentItem.prev()[ 0 ], 5068 parent: this.currentItem.parent()[ 0 ] 5069 }; 5070 5071 // If the helper is not the original, hide the original so it's not playing any role during 5072 // the drag, won't cause anything bad this way 5073 if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) { 5074 this.currentItem.hide(); 5075 } 5076 5077 //Create the placeholder 5078 this._createPlaceholder(); 5079 5080 //Set a containment if given in the options 5081 if ( o.containment ) { 5082 this._setContainment(); 5083 } 5084 5085 if ( o.cursor && o.cursor !== "auto" ) { // cursor option 5086 body = this.document.find( "body" ); 5087 5088 // Support: IE 5089 this.storedCursor = body.css( "cursor" ); 5090 body.css( "cursor", o.cursor ); 5091 5092 this.storedStylesheet = 5093 $( "<style>*{ cursor: " + o.cursor + " !important; }</style>" ).appendTo( body ); 5094 } 5095 5096 if ( o.opacity ) { // opacity option 5097 if ( this.helper.css( "opacity" ) ) { 5098 this._storedOpacity = this.helper.css( "opacity" ); 5099 } 5100 this.helper.css( "opacity", o.opacity ); 5101 } 5102 5103 if ( o.zIndex ) { // zIndex option 5104 if ( this.helper.css( "zIndex" ) ) { 5105 this._storedZIndex = this.helper.css( "zIndex" ); 5106 } 5107 this.helper.css( "zIndex", o.zIndex ); 5108 } 5109 5110 //Prepare scrolling 5111 if ( this.scrollParent[ 0 ] !== this.document[ 0 ] && 5112 this.scrollParent[ 0 ].tagName !== "HTML" ) { 5113 this.overflowOffset = this.scrollParent.offset(); 5114 } 5115 5116 //Call callbacks 5117 this._trigger( "start", event, this._uiHash() ); 5118 5119 //Recache the helper size 5120 if ( !this._preserveHelperProportions ) { 5121 this._cacheHelperProportions(); 5122 } 5123 5124 //Post "activate" events to possible containers 5125 if ( !noActivation ) { 5126 for ( i = this.containers.length - 1; i >= 0; i-- ) { 5127 this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) ); 5128 } 5129 } 5130 5131 //Prepare possible droppables 5132 if ( $.ui.ddmanager ) { 5133 $.ui.ddmanager.current = this; 5134 } 5135 5136 if ( $.ui.ddmanager && !o.dropBehaviour ) { 5137 $.ui.ddmanager.prepareOffsets( this, event ); 5138 } 5139 5140 this.dragging = true; 5141 5142 this._addClass( this.helper, "ui-sortable-helper" ); 5143 5144 // Execute the drag once - this causes the helper not to be visiblebefore getting its 5145 // correct position 5146 this._mouseDrag( event ); 5147 return true; 5148 5149 }, 5150 5151 _mouseDrag: function( event ) { 5152 var i, item, itemElement, intersection, 5153 o = this.options, 5154 scrolled = false; 5155 5156 //Compute the helpers position 5157 this.position = this._generatePosition( event ); 5158 this.positionAbs = this._convertPositionTo( "absolute" ); 5159 5160 if ( !this.lastPositionAbs ) { 5161 this.lastPositionAbs = this.positionAbs; 5162 } 5163 5164 //Do scrolling 5165 if ( this.options.scroll ) { 5166 if ( this.scrollParent[ 0 ] !== this.document[ 0 ] && 5167 this.scrollParent[ 0 ].tagName !== "HTML" ) { 5168 5169 if ( ( this.overflowOffset.top + this.scrollParent[ 0 ].offsetHeight ) - 5170 event.pageY < o.scrollSensitivity ) { 5171 this.scrollParent[ 0 ].scrollTop = 5172 scrolled = this.scrollParent[ 0 ].scrollTop + o.scrollSpeed; 5173 } else if ( event.pageY - this.overflowOffset.top < o.scrollSensitivity ) { 5174 this.scrollParent[ 0 ].scrollTop = 5175 scrolled = this.scrollParent[ 0 ].scrollTop - o.scrollSpeed; 5176 } 5177 5178 if ( ( this.overflowOffset.left + this.scrollParent[ 0 ].offsetWidth ) - 5179 event.pageX < o.scrollSensitivity ) { 5180 this.scrollParent[ 0 ].scrollLeft = scrolled = 5181 this.scrollParent[ 0 ].scrollLeft + o.scrollSpeed; 5182 } else if ( event.pageX - this.overflowOffset.left < o.scrollSensitivity ) { 5183 this.scrollParent[ 0 ].scrollLeft = scrolled = 5184 this.scrollParent[ 0 ].scrollLeft - o.scrollSpeed; 5185 } 5186 5187 } else { 5188 5189 if ( event.pageY - this.document.scrollTop() < o.scrollSensitivity ) { 5190 scrolled = this.document.scrollTop( this.document.scrollTop() - o.scrollSpeed ); 5191 } else if ( this.window.height() - ( event.pageY - this.document.scrollTop() ) < 5192 o.scrollSensitivity ) { 5193 scrolled = this.document.scrollTop( this.document.scrollTop() + o.scrollSpeed ); 5194 } 5195 5196 if ( event.pageX - this.document.scrollLeft() < o.scrollSensitivity ) { 5197 scrolled = this.document.scrollLeft( 5198 this.document.scrollLeft() - o.scrollSpeed 5199 ); 5200 } else if ( this.window.width() - ( event.pageX - this.document.scrollLeft() ) < 5201 o.scrollSensitivity ) { 5202 scrolled = this.document.scrollLeft( 5203 this.document.scrollLeft() + o.scrollSpeed 5204 ); 5205 } 5206 5207 } 5208 5209 if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) { 5210 $.ui.ddmanager.prepareOffsets( this, event ); 5211 } 5212 } 5213 5214 //Regenerate the absolute position used for position checks 5215 this.positionAbs = this._convertPositionTo( "absolute" ); 5216 5217 //Set the helper position 5218 if ( !this.options.axis || this.options.axis !== "y" ) { 5219 this.helper[ 0 ].style.left = this.position.left + "px"; 5220 } 5221 if ( !this.options.axis || this.options.axis !== "x" ) { 5222 this.helper[ 0 ].style.top = this.position.top + "px"; 5223 } 5224 5225 //Rearrange 5226 for ( i = this.items.length - 1; i >= 0; i-- ) { 5227 5228 //Cache variables and intersection, continue if no intersection 5229 item = this.items[ i ]; 5230 itemElement = item.item[ 0 ]; 5231 intersection = this._intersectsWithPointer( item ); 5232 if ( !intersection ) { 5233 continue; 5234 } 5235 5236 // Only put the placeholder inside the current Container, skip all 5237 // items from other containers. This works because when moving 5238 // an item from one container to another the 5239 // currentContainer is switched before the placeholder is moved. 5240 // 5241 // Without this, moving items in "sub-sortables" can cause 5242 // the placeholder to jitter between the outer and inner container. 5243 if ( item.instance !== this.currentContainer ) { 5244 continue; 5245 } 5246 5247 // Cannot intersect with itself 5248 // no useless actions that have been done before 5249 // no action if the item moved is the parent of the item checked 5250 if ( itemElement !== this.currentItem[ 0 ] && 5251 this.placeholder[ intersection === 1 ? "next" : "prev" ]()[ 0 ] !== itemElement && 5252 !$.contains( this.placeholder[ 0 ], itemElement ) && 5253 ( this.options.type === "semi-dynamic" ? 5254 !$.contains( this.element[ 0 ], itemElement ) : 5255 true 5256 ) 5257 ) { 5258 5259 this.direction = intersection === 1 ? "down" : "up"; 5260 5261 if ( this.options.tolerance === "pointer" || this._intersectsWithSides( item ) ) { 5262 this._rearrange( event, item ); 5263 } else { 5264 break; 5265 } 5266 5267 this._trigger( "change", event, this._uiHash() ); 5268 break; 5269 } 5270 } 5271 5272 //Post events to containers 5273 this._contactContainers( event ); 5274 5275 //Interconnect with droppables 5276 if ( $.ui.ddmanager ) { 5277 $.ui.ddmanager.drag( this, event ); 5278 } 5279 5280 //Call callbacks 5281 this._trigger( "sort", event, this._uiHash() ); 5282 5283 this.lastPositionAbs = this.positionAbs; 5284 return false; 5285 5286 }, 5287 5288 _mouseStop: function( event, noPropagation ) { 5289 5290 if ( !event ) { 5291 return; 5292 } 5293 5294 //If we are using droppables, inform the manager about the drop 5295 if ( $.ui.ddmanager && !this.options.dropBehaviour ) { 5296 $.ui.ddmanager.drop( this, event ); 5297 } 5298 5299 if ( this.options.revert ) { 5300 var that = this, 5301 cur = this.placeholder.offset(), 5302 axis = this.options.axis, 5303 animation = {}; 5304 5305 if ( !axis || axis === "x" ) { 5306 animation.left = cur.left - this.offset.parent.left - this.margins.left + 5307 ( this.offsetParent[ 0 ] === this.document[ 0 ].body ? 5308 0 : 5309 this.offsetParent[ 0 ].scrollLeft 5310 ); 5311 } 5312 if ( !axis || axis === "y" ) { 5313 animation.top = cur.top - this.offset.parent.top - this.margins.top + 5314 ( this.offsetParent[ 0 ] === this.document[ 0 ].body ? 5315 0 : 5316 this.offsetParent[ 0 ].scrollTop 5317 ); 5318 } 5319 this.reverting = true; 5320 $( this.helper ).animate( 5321 animation, 5322 parseInt( this.options.revert, 10 ) || 500, 5323 function() { 5324 that._clear( event ); 5325 } 5326 ); 5327 } else { 5328 this._clear( event, noPropagation ); 5329 } 5330 5331 return false; 5332 5333 }, 5334 5335 cancel: function() { 5336 5337 if ( this.dragging ) { 5338 5339 this._mouseUp(
5339{ target: null }
vendor: 32,347 bytes, lines 5339-6374
5339 ); 5340 5341 if ( this.options.helper === "original" ) { 5342 this.currentItem.css( this._storedCSS ); 5343 this._removeClass( this.currentItem, "ui-sortable-helper" ); 5344 } else { 5345 this.currentItem.show(); 5346 } 5347 5348 //Post deactivating events to containers 5349 for ( var i = this.containers.length - 1; i >= 0; i-- ) { 5350 this.containers[ i ]._trigger( "deactivate", null, this._uiHash( this ) ); 5351 if ( this.containers[ i ].containerCache.over ) { 5352 this.containers[ i ]._trigger( "out", null, this._uiHash( this ) ); 5353 this.containers[ i ].containerCache.over = 0; 5354 } 5355 } 5356 5357 } 5358 5359 if ( this.placeholder ) { 5360 5361 //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, 5362 // it unbinds ALL events from the original node! 5363 if ( this.placeholder[ 0 ].parentNode ) { 5364 this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] ); 5365 } 5366 if ( this.options.helper !== "original" && this.helper && 5367 this.helper[ 0 ].parentNode ) { 5368 this.helper.remove(); 5369 } 5370 5371 $.extend( this, { 5372 helper: null, 5373 dragging: false, 5374 reverting: false, 5375 _noFinalSort: null 5376 } ); 5377 5378 if ( this.domPosition.prev ) { 5379 $( this.domPosition.prev ).after( this.currentItem ); 5380 } else { 5381 $( this.domPosition.parent ).prepend( this.currentItem ); 5382 } 5383 } 5384 5385 return this; 5386 5387 }, 5388 5389 serialize: function( o ) { 5390 5391 var items = this._getItemsAsjQuery( o && o.connected ), 5392 str = []; 5393 o = o || {}; 5394 5395 $( items ).each( function() { 5396 var res = ( $( o.item || this ).attr( o.attribute || "id" ) || "" ) 5397 .match( o.expression || ( /(.+)[\-=_](.+)/ ) ); 5398 if ( res ) { 5399 str.push( 5400 ( o.key || res[ 1 ] + "[]" ) + 5401 "=" + ( o.key && o.expression ? res[ 1 ] : res[ 2 ] ) ); 5402 } 5403 } ); 5404 5405 if ( !str.length && o.key ) { 5406 str.push( o.key + "=" ); 5407 } 5408 5409 return str.join( "&" ); 5410 5411 }, 5412 5413 toArray: function( o ) { 5414 5415 var items = this._getItemsAsjQuery( o && o.connected ), 5416 ret = []; 5417 5418 o = o || {}; 5419 5420 items.each( function() { 5421 ret.push( $( o.item || this ).attr( o.attribute || "id" ) || "" ); 5422 } ); 5423 return ret; 5424 5425 }, 5426 5427 /* Be careful with the following core functions */ 5428 _intersectsWith: function( item ) { 5429 5430 var x1 = this.positionAbs.left, 5431 x2 = x1 + this.helperProportions.width, 5432 y1 = this.positionAbs.top, 5433 y2 = y1 + this.helperProportions.height, 5434 l = item.left, 5435 r = l + item.width, 5436 t = item.top, 5437 b = t + item.height, 5438 dyClick = this.offset.click.top, 5439 dxClick = this.offset.click.left, 5440 isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && 5441 ( y1 + dyClick ) < b ), 5442 isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && 5443 ( x1 + dxClick ) < r ), 5444 isOverElement = isOverElementHeight && isOverElementWidth; 5445 5446 if ( this.options.tolerance === "pointer" || 5447 this.options.forcePointerForContainers || 5448 ( this.options.tolerance !== "pointer" && 5449 this.helperProportions[ this.floating ? "width" : "height" ] > 5450 item[ this.floating ? "width" : "height" ] ) 5451 ) { 5452 return isOverElement; 5453 } else { 5454 5455 return ( l < x1 + ( this.helperProportions.width / 2 ) && // Right Half 5456 x2 - ( this.helperProportions.width / 2 ) < r && // Left Half 5457 t < y1 + ( this.helperProportions.height / 2 ) && // Bottom Half 5458 y2 - ( this.helperProportions.height / 2 ) < b ); // Top Half 5459 5460 } 5461 }, 5462 5463 _intersectsWithPointer: function( item ) { 5464 var verticalDirection, horizontalDirection, 5465 isOverElementHeight = ( this.options.axis === "x" ) || 5466 this._isOverAxis( 5467 this.positionAbs.top + this.offset.click.top, item.top, item.height ), 5468 isOverElementWidth = ( this.options.axis === "y" ) || 5469 this._isOverAxis( 5470 this.positionAbs.left + this.offset.click.left, item.left, item.width ), 5471 isOverElement = isOverElementHeight && isOverElementWidth; 5472 5473 if ( !isOverElement ) { 5474 return false; 5475 } 5476 5477 verticalDirection = this._getDragVerticalDirection(); 5478 horizontalDirection = this._getDragHorizontalDirection(); 5479 5480 return this.floating ? 5481 ( ( horizontalDirection === "right" || verticalDirection === "down" ) ? 2 : 1 ) 5482 : ( verticalDirection && ( verticalDirection === "down" ? 2 : 1 ) ); 5483 5484 }, 5485 5486 _intersectsWithSides: function( item ) { 5487 5488 var isOverBottomHalf = this._isOverAxis( this.positionAbs.top + 5489 this.offset.click.top, item.top + ( item.height / 2 ), item.height ), 5490 isOverRightHalf = this._isOverAxis( this.positionAbs.left + 5491 this.offset.click.left, item.left + ( item.width / 2 ), item.width ), 5492 verticalDirection = this._getDragVerticalDirection(), 5493 horizontalDirection = this._getDragHorizontalDirection(); 5494 5495 if ( this.floating && horizontalDirection ) { 5496 return ( ( horizontalDirection === "right" && isOverRightHalf ) || 5497 ( horizontalDirection === "left" && !isOverRightHalf ) ); 5498 } else { 5499 return verticalDirection && ( ( verticalDirection === "down" && isOverBottomHalf ) || 5500 ( verticalDirection === "up" && !isOverBottomHalf ) ); 5501 } 5502 5503 }, 5504 5505 _getDragVerticalDirection: function() { 5506 var delta = this.positionAbs.top - this.lastPositionAbs.top; 5507 return delta !== 0 && ( delta > 0 ? "down" : "up" ); 5508 }, 5509 5510 _getDragHorizontalDirection: function() { 5511 var delta = this.positionAbs.left - this.lastPositionAbs.left; 5512 return delta !== 0 && ( delta > 0 ? "right" : "left" ); 5513 }, 5514 5515 refresh: function( event ) { 5516 this._refreshItems( event ); 5517 this._setHandleClassName(); 5518 this.refreshPositions(); 5519 return this; 5520 }, 5521 5522 _connectWith: function() { 5523 var options = this.options; 5524 return options.connectWith.constructor === String ? 5525 [ options.connectWith ] : 5526 options.connectWith; 5527 }, 5528 5529 _getItemsAsjQuery: function( connected ) { 5530 5531 var i, j, cur, inst, 5532 items = [], 5533 queries = [], 5534 connectWith = this._connectWith(); 5535 5536 if ( connectWith && connected ) { 5537 for ( i = connectWith.length - 1; i >= 0; i-- ) { 5538 cur = $( connectWith[ i ], this.document[ 0 ] ); 5539 for ( j = cur.length - 1; j >= 0; j-- ) { 5540 inst = $.data( cur[ j ], this.widgetFullName ); 5541 if ( inst && inst !== this && !inst.options.disabled ) { 5542 queries.push( [ $.isFunction( inst.options.items ) ? 5543 inst.options.items.call( inst.element ) : 5544 $( inst.options.items, inst.element ) 5545 .not( ".ui-sortable-helper" ) 5546 .not( ".ui-sortable-placeholder" ), inst ] ); 5547 } 5548 } 5549 } 5550 } 5551 5552 queries.push( [ $.isFunction( this.options.items ) ? 5553 this.options.items 5554 .call( this.element, null, { options: this.options, item: this.currentItem } ) : 5555 $( this.options.items, this.element ) 5556 .not( ".ui-sortable-helper" ) 5557 .not( ".ui-sortable-placeholder" ), this ] ); 5558 5559 function addItems() { 5560 items.push( this ); 5561 } 5562 for ( i = queries.length - 1; i >= 0; i-- ) { 5563 queries[ i ][ 0 ].each( addItems ); 5564 } 5565 5566 return $( items ); 5567 5568 }, 5569 5570 _removeCurrentsFromItems: function() { 5571 5572 var list = this.currentItem.find( ":data(" + this.widgetName + "-item)" ); 5573 5574 this.items = $.grep( this.items, function( item ) { 5575 for ( var j = 0; j < list.length; j++ ) { 5576 if ( list[ j ] === item.item[ 0 ] ) { 5577 return false; 5578 } 5579 } 5580 return true; 5581 } ); 5582 5583 }, 5584 5585 _refreshItems: function( event ) { 5586 5587 this.items = []; 5588 this.containers = [ this ]; 5589 5590 var i, j, cur, inst, targetData, _queries, item, queriesLength, 5591 items = this.items, 5592 queries = [ [ $.isFunction( this.options.items ) ? 5593 this.options.items.call( this.element[ 0 ], event, { item: this.currentItem } ) : 5594 $( this.options.items, this.element ), this ] ], 5595 connectWith = this._connectWith(); 5596 5597 //Shouldn't be run the first time through due to massive slow-down 5598 if ( connectWith && this.ready ) { 5599 for ( i = connectWith.length - 1; i >= 0; i-- ) { 5600 cur = $( connectWith[ i ], this.document[ 0 ] ); 5601 for ( j = cur.length - 1; j >= 0; j-- ) { 5602 inst = $.data( cur[ j ], this.widgetFullName ); 5603 if ( inst && inst !== this && !inst.options.disabled ) { 5604 queries.push( [ $.isFunction( inst.options.items ) ? 5605 inst.options.items 5606 .call( inst.element[ 0 ], event, { item: this.currentItem } ) : 5607 $( inst.options.items, inst.element ), inst ] ); 5608 this.containers.push( inst ); 5609 } 5610 } 5611 } 5612 } 5613 5614 for ( i = queries.length - 1; i >= 0; i-- ) { 5615 targetData = queries[ i ][ 1 ]; 5616 _queries = queries[ i ][ 0 ]; 5617 5618 for ( j = 0, queriesLength = _queries.length; j < queriesLength; j++ ) { 5619 item = $( _queries[ j ] ); 5620 5621 // Data for target checking (mouse manager) 5622 item.data( this.widgetName + "-item", targetData ); 5623 5624 items.push( { 5625 item: item, 5626 instance: targetData, 5627 width: 0, height: 0, 5628 left: 0, top: 0 5629 } ); 5630 } 5631 } 5632 5633 }, 5634 5635 refreshPositions: function( fast ) { 5636 5637 // Determine whether items are being displayed horizontally 5638 this.floating = this.items.length ? 5639 this.options.axis === "x" || this._isFloating( this.items[ 0 ].item ) : 5640 false; 5641 5642 //This has to be redone because due to the item being moved out/into the offsetParent, 5643 // the offsetParent's position will change 5644 if ( this.offsetParent && this.helper ) { 5645 this.offset.parent = this._getParentOffset(); 5646 } 5647 5648 var i, item, t, p; 5649 5650 for ( i = this.items.length - 1; i >= 0; i-- ) { 5651 item = this.items[ i ]; 5652 5653 //We ignore calculating positions of all connected containers when we're not over them 5654 if ( item.instance !== this.currentContainer && this.currentContainer && 5655 item.item[ 0 ] !== this.currentItem[ 0 ] ) { 5656 continue; 5657 } 5658 5659 t = this.options.toleranceElement ? 5660 $( this.options.toleranceElement, item.item ) : 5661 item.item; 5662 5663 if ( !fast ) { 5664 item.width = t.outerWidth(); 5665 item.height = t.outerHeight(); 5666 } 5667 5668 p = t.offset(); 5669 item.left = p.left; 5670 item.top = p.top; 5671 } 5672 5673 if ( this.options.custom && this.options.custom.refreshContainers ) { 5674 this.options.custom.refreshContainers.call( this ); 5675 } else { 5676 for ( i = this.containers.length - 1; i >= 0; i-- ) { 5677 p = this.containers[ i ].element.offset(); 5678 this.containers[ i ].containerCache.left = p.left; 5679 this.containers[ i ].containerCache.top = p.top; 5680 this.containers[ i ].containerCache.width = 5681 this.containers[ i ].element.outerWidth(); 5682 this.containers[ i ].containerCache.height = 5683 this.containers[ i ].element.outerHeight(); 5684 } 5685 } 5686 5687 return this; 5688 }, 5689 5690 _createPlaceholder: function( that ) { 5691 that = that || this; 5692 var className, 5693 o = that.options; 5694 5695 if ( !o.placeholder || o.placeholder.constructor === String ) { 5696 className = o.placeholder; 5697 o.placeholder = { 5698 element: function() { 5699 5700 var nodeName = that.currentItem[ 0 ].nodeName.toLowerCase(), 5701 element = $( "<" + nodeName + ">", that.document[ 0 ] ); 5702 5703 that._addClass( element, "ui-sortable-placeholder", 5704 className || that.currentItem[ 0 ].className ) 5705 ._removeClass( element, "ui-sortable-helper" ); 5706 5707 if ( nodeName === "tbody" ) { 5708 that._createTrPlaceholder( 5709 that.currentItem.find( "tr" ).eq( 0 ), 5710 $( "<tr>", that.document[ 0 ] ).appendTo( element ) 5711 ); 5712 } else if ( nodeName === "tr" ) { 5713 that._createTrPlaceholder( that.currentItem, element ); 5714 } else if ( nodeName === "img" ) { 5715 element.attr( "src", that.currentItem.attr( "src" ) ); 5716 } 5717 5718 if ( !className ) { 5719 element.css( "visibility", "hidden" ); 5720 } 5721 5722 return element; 5723 }, 5724 update: function( container, p ) { 5725 5726 // 1. If a className is set as 'placeholder option, we don't force sizes - 5727 // the class is responsible for that 5728 // 2. The option 'forcePlaceholderSize can be enabled to force it even if a 5729 // class name is specified 5730 if ( className && !o.forcePlaceholderSize ) { 5731 return; 5732 } 5733 5734 //If the element doesn't have a actual height by itself (without styles coming 5735 // from a stylesheet), it receives the inline height from the dragged item 5736 if ( !p.height() ) { 5737 p.height( 5738 that.currentItem.innerHeight() - 5739 parseInt( that.currentItem.css( "paddingTop" ) || 0, 10 ) - 5740 parseInt( that.currentItem.css( "paddingBottom" ) || 0, 10 ) ); 5741 } 5742 if ( !p.width() ) { 5743 p.width( 5744 that.currentItem.innerWidth() - 5745 parseInt( that.currentItem.css( "paddingLeft" ) || 0, 10 ) - 5746 parseInt( that.currentItem.css( "paddingRight" ) || 0, 10 ) ); 5747 } 5748 } 5749 }; 5750 } 5751 5752 //Create the placeholder 5753 that.placeholder = $( o.placeholder.element.call( that.element, that.currentItem ) ); 5754 5755 //Append it after the actual current item 5756 that.currentItem.after( that.placeholder ); 5757 5758 //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317) 5759 o.placeholder.update( that, that.placeholder ); 5760 5761 }, 5762 5763 _createTrPlaceholder: function( sourceTr, targetTr ) { 5764 var that = this; 5765 5766 sourceTr.children().each( function() { 5767 $( "<td> </td>", that.document[ 0 ] ) 5768 .attr( "colspan", $( this ).attr( "colspan" ) || 1 ) 5769 .appendTo( targetTr ); 5770 } ); 5771 }, 5772 5773 _contactContainers: function( event ) { 5774 var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, 5775 floating, axis, 5776 innermostContainer = null, 5777 innermostIndex = null; 5778 5779 // Get innermost container that intersects with item 5780 for ( i = this.containers.length - 1; i >= 0; i-- ) { 5781 5782 // Never consider a container that's located within the item itself 5783 if ( $.contains( this.currentItem[ 0 ], this.containers[ i ].element[ 0 ] ) ) { 5784 continue; 5785 } 5786 5787 if ( this._intersectsWith( this.containers[ i ].containerCache ) ) { 5788 5789 // If we've already found a container and it's more "inner" than this, then continue 5790 if ( innermostContainer && 5791 $.contains( 5792 this.containers[ i ].element[ 0 ], 5793 innermostContainer.element[ 0 ] ) ) { 5794 continue; 5795 } 5796 5797 innermostContainer = this.containers[ i ]; 5798 innermostIndex = i; 5799 5800 } else { 5801 5802 // container doesn't intersect. trigger "out" event if necessary 5803 if ( this.containers[ i ].containerCache.over ) { 5804 this.containers[ i ]._trigger( "out", event, this._uiHash( this ) ); 5805 this.containers[ i ].containerCache.over = 0; 5806 } 5807 } 5808 5809 } 5810 5811 // If no intersecting containers found, return 5812 if ( !innermostContainer ) { 5813 return; 5814 } 5815 5816 // Move the item into the container if it's not there already 5817 if ( this.containers.length === 1 ) { 5818 if ( !this.containers[ innermostIndex ].containerCache.over ) { 5819 this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) ); 5820 this.containers[ innermostIndex ].containerCache.over = 1; 5821 } 5822 } else { 5823 5824 // When entering a new container, we will find the item with the least distance and 5825 // append our item near it 5826 dist = 10000; 5827 itemWithLeastDistance = null; 5828 floating = innermostContainer.floating || this._isFloating( this.currentItem ); 5829 posProperty = floating ? "left" : "top"; 5830 sizeProperty = floating ? "width" : "height"; 5831 axis = floating ? "pageX" : "pageY"; 5832 5833 for ( j = this.items.length - 1; j >= 0; j-- ) { 5834 if ( !$.contains( 5835 this.containers[ innermostIndex ].element[ 0 ], this.items[ j ].item[ 0 ] ) 5836 ) { 5837 continue; 5838 } 5839 if ( this.items[ j ].item[ 0 ] === this.currentItem[ 0 ] ) { 5840 continue; 5841 } 5842 5843 cur = this.items[ j ].item.offset()[ posProperty ]; 5844 nearBottom = false; 5845 if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) { 5846 nearBottom = true; 5847 } 5848 5849 if ( Math.abs( event[ axis ] - cur ) < dist ) { 5850 dist = Math.abs( event[ axis ] - cur ); 5851 itemWithLeastDistance = this.items[ j ]; 5852 this.direction = nearBottom ? "up" : "down"; 5853 } 5854 } 5855 5856 //Check if dropOnEmpty is enabled 5857 if ( !itemWithLeastDistance && !this.options.dropOnEmpty ) { 5858 return; 5859 } 5860 5861 if ( this.currentContainer === this.containers[ innermostIndex ] ) { 5862 if ( !this.currentContainer.containerCache.over ) { 5863 this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() ); 5864 this.currentContainer.containerCache.over = 1; 5865 } 5866 return; 5867 } 5868 5869 itemWithLeastDistance ? 5870 this._rearrange( event, itemWithLeastDistance, null, true ) : 5871 this._rearrange( event, null, this.containers[ innermostIndex ].element, true ); 5872 this._trigger( "change", event, this._uiHash() ); 5873 this.containers[ innermostIndex ]._trigger( "change", event, this._uiHash( this ) ); 5874 this.currentContainer = this.containers[ innermostIndex ]; 5875 5876 //Update the placeholder 5877 this.options.placeholder.update( this.currentContainer, this.placeholder ); 5878 5879 this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) ); 5880 this.containers[ innermostIndex ].containerCache.over = 1; 5881 } 5882 5883 }, 5884 5885 _createHelper: function( event ) { 5886 5887 var o = this.options, 5888 helper = $.isFunction( o.helper ) ? 5889 $( o.helper.apply( this.element[ 0 ], [ event, this.currentItem ] ) ) : 5890 ( o.helper === "clone" ? this.currentItem.clone() : this.currentItem ); 5891 5892 //Add the helper to the DOM if that didn't happen already 5893 if ( !helper.parents( "body" ).length ) { 5894 $( o.appendTo !== "parent" ? 5895 o.appendTo : 5896 this.currentItem[ 0 ].parentNode )[ 0 ].appendChild( helper[ 0 ] ); 5897 } 5898 5899 if ( helper[ 0 ] === this.currentItem[ 0 ] ) { 5900 this._storedCSS = { 5901 width: this.currentItem[ 0 ].style.width, 5902 height: this.currentItem[ 0 ].style.height, 5903 position: this.currentItem.css( "position" ), 5904 top: this.currentItem.css( "top" ), 5905 left: this.currentItem.css( "left" ) 5906 }; 5907 } 5908 5909 if ( !helper[ 0 ].style.width || o.forceHelperSize ) { 5910 helper.width( this.currentItem.width() ); 5911 } 5912 if ( !helper[ 0 ].style.height || o.forceHelperSize ) { 5913 helper.height( this.currentItem.height() ); 5914 } 5915 5916 return helper; 5917 5918 }, 5919 5920 _adjustOffsetFromHelper: function( obj ) { 5921 if ( typeof obj === "string" ) { 5922 obj = obj.split( " " ); 5923 } 5924 if ( $.isArray( obj ) ) { 5925 obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 }; 5926 } 5927 if ( "left" in obj ) { 5928 this.offset.click.left = obj.left + this.margins.left; 5929 } 5930 if ( "right" in obj ) { 5931 this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; 5932 } 5933 if ( "top" in obj ) { 5934 this.offset.click.top = obj.top + this.margins.top; 5935 } 5936 if ( "bottom" in obj ) { 5937 this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top; 5938 } 5939 }, 5940 5941 _getParentOffset: function() { 5942 5943 //Get the offsetParent and cache its position 5944 this.offsetParent = this.helper.offsetParent(); 5945 var po = this.offsetParent.offset(); 5946 5947 // This is a special case where we need to modify a offset calculated on start, since the 5948 // following happened: 5949 // 1. The position of the helper is absolute, so it's position is calculated based on the 5950 // next positioned parent 5951 // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't 5952 // the document, which means that the scroll is included in the initial calculation of the 5953 // offset of the parent, and never recalculated upon drag 5954 if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== this.document[ 0 ] && 5955 $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) { 5956 po.left += this.scrollParent.scrollLeft(); 5957 po.top += this.scrollParent.scrollTop(); 5958 } 5959 5960 // This needs to be actually done for all browsers, since pageX/pageY includes this 5961 // information with an ugly IE fix 5962 if ( this.offsetParent[ 0 ] === this.document[ 0 ].body || 5963 ( this.offsetParent[ 0 ].tagName && 5964 this.offsetParent[ 0 ].tagName.toLowerCase() === "html" && $.ui.ie ) ) { 5965 po = { top: 0, left: 0 }; 5966 } 5967 5968 return { 5969 top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ), 5970 left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 ) 5971 }; 5972 5973 }, 5974 5975 _getRelativeOffset: function() { 5976 5977 if ( this.cssPosition === "relative" ) { 5978 var p = this.currentItem.position(); 5979 return { 5980 top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) + 5981 this.scrollParent.scrollTop(), 5982 left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) + 5983 this.scrollParent.scrollLeft() 5984 }; 5985 } else { 5986 return { top: 0, left: 0 }; 5987 } 5988 5989 }, 5990 5991 _cacheMargins: function() { 5992 this.margins = { 5993 left: ( parseInt( this.currentItem.css( "marginLeft" ), 10 ) || 0 ), 5994 top: ( parseInt( this.currentItem.css( "marginTop" ), 10 ) || 0 ) 5995 }; 5996 }, 5997 5998 _cacheHelperProportions: function() { 5999 this.helperProportions = { 6000 width: this.helper.outerWidth(), 6001 height: this.helper.outerHeight() 6002 }; 6003 }, 6004 6005 _setContainment: function() { 6006 6007 var ce, co, over, 6008 o = this.options; 6009 if ( o.containment === "parent" ) { 6010 o.containment = this.helper[ 0 ].parentNode; 6011 } 6012 if ( o.containment === "document" || o.containment === "window" ) { 6013 this.containment = [ 6014 0 - this.offset.relative.left - this.offset.parent.left, 6015 0 - this.offset.relative.top - this.offset.parent.top, 6016 o.containment === "document" ? 6017 this.document.width() : 6018 this.window.width() - this.helperProportions.width - this.margins.left, 6019 ( o.containment === "document" ? 6020 ( this.document.height() || document.body.parentNode.scrollHeight ) : 6021 this.window.height() || this.document[ 0 ].body.parentNode.scrollHeight 6022 ) - this.helperProportions.height - this.margins.top 6023 ]; 6024 } 6025 6026 if ( !( /^(document|window|parent)$/ ).test( o.containment ) ) { 6027 ce = $( o.containment )[ 0 ]; 6028 co = $( o.containment ).offset(); 6029 over = ( $( ce ).css( "overflow" ) !== "hidden" ); 6030 6031 this.containment = [ 6032 co.left + ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) + 6033 ( parseInt( $( ce ).css( "paddingLeft" ), 10 ) || 0 ) - this.margins.left, 6034 co.top + ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) + 6035 ( parseInt( $( ce ).css( "paddingTop" ), 10 ) || 0 ) - this.margins.top, 6036 co.left + ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - 6037 ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) - 6038 ( parseInt( $( ce ).css( "paddingRight" ), 10 ) || 0 ) - 6039 this.helperProportions.width - this.margins.left, 6040 co.top + ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - 6041 ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) - 6042 ( parseInt( $( ce ).css( "paddingBottom" ), 10 ) || 0 ) - 6043 this.helperProportions.height - this.margins.top 6044 ]; 6045 } 6046 6047 }, 6048 6049 _convertPositionTo: function( d, pos ) { 6050 6051 if ( !pos ) { 6052 pos = this.position; 6053 } 6054 var mod = d === "absolute" ? 1 : -1, 6055 scroll = this.cssPosition === "absolute" && 6056 !( this.scrollParent[ 0 ] !== this.document[ 0 ] && 6057 $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? 6058 this.offsetParent : 6059 this.scrollParent, 6060 scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName ); 6061 6062 return { 6063 top: ( 6064 6065 // The absolute mouse position 6066 pos.top + 6067 6068 // Only for relative positioned nodes: Relative offset from element to offset parent 6069 this.offset.relative.top * mod + 6070 6071 // The offsetParent's offset without borders (offset + border) 6072 this.offset.parent.top * mod - 6073 ( ( this.cssPosition === "fixed" ? 6074 -this.scrollParent.scrollTop() : 6075 ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod ) 6076 ), 6077 left: ( 6078 6079 // The absolute mouse position 6080 pos.left + 6081 6082 // Only for relative positioned nodes: Relative offset from element to offset parent 6083 this.offset.relative.left * mod + 6084 6085 // The offsetParent's offset without borders (offset + border) 6086 this.offset.parent.left * mod - 6087 ( ( this.cssPosition === "fixed" ? 6088 -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : 6089 scroll.scrollLeft() ) * mod ) 6090 ) 6091 }; 6092 6093 }, 6094 6095 _generatePosition: function( event ) { 6096 6097 var top, left, 6098 o = this.options, 6099 pageX = event.pageX, 6100 pageY = event.pageY, 6101 scroll = this.cssPosition === "absolute" && 6102 !( this.scrollParent[ 0 ] !== this.document[ 0 ] && 6103 $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? 6104 this.offsetParent : 6105 this.scrollParent, 6106 scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName ); 6107 6108 // This is another very weird special case that only happens for relative elements: 6109 // 1. If the css position is relative 6110 // 2. and the scroll parent is the document or similar to the offset parent 6111 // we have to refresh the relative offset during the scroll so there are no jumps 6112 if ( this.cssPosition === "relative" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] && 6113 this.scrollParent[ 0 ] !== this.offsetParent[ 0 ] ) ) { 6114 this.offset.relative = this._getRelativeOffset(); 6115 } 6116 6117 /* 6118 * - Position constraining - 6119 * Constrain the position to a mix of grid, containment. 6120 */ 6121 6122 if ( this.originalPosition ) { //If we are not dragging yet, we won't check for options 6123 6124 if ( this.containment ) { 6125 if ( event.pageX - this.offset.click.left < this.containment[ 0 ] ) { 6126 pageX = this.containment[ 0 ] + this.offset.click.left; 6127 } 6128 if ( event.pageY - this.offset.click.top < this.containment[ 1 ] ) { 6129 pageY = this.containment[ 1 ] + this.offset.click.top; 6130 } 6131 if ( event.pageX - this.offset.click.left > this.containment[ 2 ] ) { 6132 pageX = this.containment[ 2 ] + this.offset.click.left; 6133 } 6134 if ( event.pageY - this.offset.click.top > this.containment[ 3 ] ) { 6135 pageY = this.containment[ 3 ] + this.offset.click.top; 6136 } 6137 } 6138 6139 if ( o.grid ) { 6140 top = this.originalPageY + Math.round( ( pageY - this.originalPageY ) / 6141 o.grid[ 1 ] ) * o.grid[ 1 ]; 6142 pageY = this.containment ? 6143 ( ( top - this.offset.click.top >= this.containment[ 1 ] && 6144 top - this.offset.click.top <= this.containment[ 3 ] ) ? 6145 top : 6146 ( ( top - this.offset.click.top >= this.containment[ 1 ] ) ? 6147 top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : 6148 top; 6149 6150 left = this.originalPageX + Math.round( ( pageX - this.originalPageX ) / 6151 o.grid[ 0 ] ) * o.grid[ 0 ]; 6152 pageX = this.containment ? 6153 ( ( left - this.offset.click.left >= this.containment[ 0 ] && 6154 left - this.offset.click.left <= this.containment[ 2 ] ) ? 6155 left : 6156 ( ( left - this.offset.click.left >= this.containment[ 0 ] ) ? 6157 left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : 6158 left; 6159 } 6160 6161 } 6162 6163 return { 6164 top: ( 6165 6166 // The absolute mouse position 6167 pageY - 6168 6169 // Click offset (relative to the element) 6170 this.offset.click.top - 6171 6172 // Only for relative positioned nodes: Relative offset from element to offset parent 6173 this.offset.relative.top - 6174 6175 // The offsetParent's offset without borders (offset + border) 6176 this.offset.parent.top + 6177 ( ( this.cssPosition === "fixed" ? 6178 -this.scrollParent.scrollTop() : 6179 ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) ) 6180 ), 6181 left: ( 6182 6183 // The absolute mouse position 6184 pageX - 6185 6186 // Click offset (relative to the element) 6187 this.offset.click.left - 6188 6189 // Only for relative positioned nodes: Relative offset from element to offset parent 6190 this.offset.relative.left - 6191 6192 // The offsetParent's offset without borders (offset + border) 6193 this.offset.parent.left + 6194 ( ( this.cssPosition === "fixed" ? 6195 -this.scrollParent.scrollLeft() : 6196 scrollIsRootNode ? 0 : scroll.scrollLeft() ) ) 6197 ) 6198 }; 6199 6200 }, 6201 6202 _rearrange: function( event, i, a, hardRefresh ) { 6203 6204 a ? a[ 0 ].appendChild( this.placeholder[ 0 ] ) : 6205 i.item[ 0 ].parentNode.insertBefore( this.placeholder[ 0 ], 6206 ( this.direction === "down" ? i.item[ 0 ] : i.item[ 0 ].nextSibling ) ); 6207 6208 //Various things done here to improve the performance: 6209 // 1. we create a setTimeout, that calls refreshPositions 6210 // 2. on the instance, we have a counter variable, that get's higher after every append 6211 // 3. on the local scope, we copy the counter variable, and check in the timeout, 6212 // if it's still the same 6213 // 4. this lets only the last addition to the timeout stack through 6214 this.counter = this.counter ? ++this.counter : 1; 6215 var counter = this.counter; 6216 6217 this._delay( function() { 6218 if ( counter === this.counter ) { 6219 6220 //Precompute after each DOM insertion, NOT on mousemove 6221 this.refreshPositions( !hardRefresh ); 6222 } 6223 } ); 6224 6225 }, 6226 6227 _clear: function( event, noPropagation ) { 6228 6229 this.reverting = false; 6230 6231 // We delay all events that have to be triggered to after the point where the placeholder 6232 // has been removed and everything else normalized again 6233 var i, 6234 delayedTriggers = []; 6235 6236 // We first have to update the dom position of the actual currentItem 6237 // Note: don't do it if the current item is already removed (by a user), or it gets 6238 // reappended (see #4088) 6239 if ( !this._noFinalSort && this.currentItem.parent().length ) { 6240 this.placeholder.before( this.currentItem ); 6241 } 6242 this._noFinalSort = null; 6243 6244 if ( this.helper[ 0 ] === this.currentItem[ 0 ] ) { 6245 for ( i in this._storedCSS ) { 6246 if ( this._storedCSS[ i ] === "auto" || this._storedCSS[ i ] === "static" ) { 6247 this._storedCSS[ i ] = ""; 6248 } 6249 } 6250 this.currentItem.css( this._storedCSS ); 6251 this._removeClass( this.currentItem, "ui-sortable-helper" ); 6252 } else { 6253 this.currentItem.show(); 6254 } 6255 6256 if ( this.fromOutside && !noPropagation ) { 6257 delayedTriggers.push( function( event ) { 6258 this._trigger( "receive", event, this._uiHash( this.fromOutside ) ); 6259 } ); 6260 } 6261 if ( ( this.fromOutside || 6262 this.domPosition.prev !== 6263 this.currentItem.prev().not( ".ui-sortable-helper" )[ 0 ] || 6264 this.domPosition.parent !== this.currentItem.parent()[ 0 ] ) && !noPropagation ) { 6265 6266 // Trigger update callback if the DOM position has changed 6267 delayedTriggers.push( function( event ) { 6268 this._trigger( "update", event, this._uiHash() ); 6269 } ); 6270 } 6271 6272 // Check if the items Container has Changed and trigger appropriate 6273 // events. 6274 if ( this !== this.currentContainer ) { 6275 if ( !noPropagation ) { 6276 delayedTriggers.push( function( event ) { 6277 this._trigger( "remove", event, this._uiHash() ); 6278 } ); 6279 delayedTriggers.push( ( function( c ) { 6280 return function( event ) { 6281 c._trigger( "receive", event, this._uiHash( this ) ); 6282 }; 6283 } ).call( this, this.currentContainer ) ); 6284 delayedTriggers.push( ( function( c ) { 6285 return function( event ) { 6286 c._trigger( "update", event, this._uiHash( this ) ); 6287 }; 6288 } ).call( this, this.currentContainer ) ); 6289 } 6290 } 6291 6292 //Post events to containers 6293 function delayEvent( type, instance, container ) { 6294 return function( event ) { 6295 container._trigger( type, event, instance._uiHash( instance ) ); 6296 }; 6297 } 6298 for ( i = this.containers.length - 1; i >= 0; i-- ) { 6299 if ( !noPropagation ) { 6300 delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) ); 6301 } 6302 if ( this.containers[ i ].containerCache.over ) { 6303 delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) ); 6304 this.containers[ i ].containerCache.over = 0; 6305 } 6306 } 6307 6308 //Do what was originally in plugins 6309 if ( this.storedCursor ) { 6310 this.document.find( "body" ).css( "cursor", this.storedCursor ); 6311 this.storedStylesheet.remove(); 6312 } 6313 if ( this._storedOpacity ) { 6314 this.helper.css( "opacity", this._storedOpacity ); 6315 } 6316 if ( this._storedZIndex ) { 6317 this.helper.css( "zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex ); 6318 } 6319 6320 this.dragging = false; 6321 6322 if ( !noPropagation ) { 6323 this._trigger( "beforeStop", event, this._uiHash() ); 6324 } 6325 6326 //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, 6327 // it unbinds ALL events from the original node! 6328 this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] ); 6329 6330 if ( !this.cancelHelperRemoval ) { 6331 if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) { 6332 this.helper.remove(); 6333 } 6334 this.helper = null; 6335 } 6336 6337 if ( !noPropagation ) { 6338 for ( i = 0; i < delayedTriggers.length; i++ ) { 6339 6340 // Trigger all delayed events 6341 delayedTriggers[ i ].call( this, event ); 6342 } 6343 this._trigger( "stop", event, this._uiHash() ); 6344 } 6345 6346 this.fromOutside = false; 6347 return !this.cancelHelperRemoval; 6348 6349 }, 6350 6351 _trigger: function() { 6352 if ( $.Widget.prototype._trigger.apply( this, arguments ) === false ) { 6353 this.cancel(); 6354 } 6355 }, 6356 6357 _uiHash: function( _inst ) { 6358 var inst = _inst || this; 6359 return { 6360 helper: inst.helper, 6361 placeholder: inst.placeholder || $( [] ), 6362 position: inst.position, 6363 originalPosition: inst.originalPosition, 6364 offset: inst.positionAbs, 6365 item: inst.currentItem, 6366 sender: _inst ? _inst.element : null 6367 }; 6368 } 6369 6370} ); 6371 6372 6373/*! 6374 * jQuery UI
vendor: 13,365 bytes, lines 6374-6839
6374Controlgroup 1.12.0 6375 * http://jqueryui.com 6376 * 6377 * Copyright jQuery Foundation and other contributors 6378 * Released under the MIT license. 6379 * http://jquery.org/license 6380 */ 6381 6382//>>label: Controlgroup 6383//>>group: Widgets 6384//>>description: Visually groups form control widgets 6385//>>docs: http://api.jqueryui.com/controlgroup/ 6386//>>demos: http://jqueryui.com/controlgroup/ 6387//>>css.structure: ../../themes/base/core.css 6388//>>css.structure: ../../themes/base/controlgroup.css 6389//>>css.theme: ../../themes/base/theme.css 6390 6391 6392var controlgroupCornerRegex = /ui-corner-([a-z]){2,6}/g; 6393 6394var widgetsControlgroup = $.widget( "ui.controlgroup", { 6395 version: "1.12.0", 6396 defaultElement: "<div>", 6397 options: { 6398 direction: "horizontal", 6399 disabled: null, 6400 onlyVisible: true, 6401 items: { 6402 "button": "input[type=button], input[type=submit], input[type=reset], button, a", 6403 "controlgroupLabel": ".ui-controlgroup-label", 6404 "checkboxradio": "input[type='checkbox'], input[type='radio']", 6405 "selectmenu": "select", 6406 "spinner": ".ui-spinner-input" 6407 } 6408 }, 6409 6410 _create: function() { 6411 this._enhance(); 6412 }, 6413 6414 // To support the enhanced option in jQuery Mobile, we isolate DOM manipulation 6415 _enhance: function() { 6416 this.element.attr( "role", "toolbar" ); 6417 this.refresh(); 6418 }, 6419 6420 _destroy: function() { 6421 this._callChildMethod( "destroy" ); 6422 this.childWidgets.removeData( "ui-controlgroup-data" ); 6423 this.element.removeAttr( "role" ); 6424 if ( this.options.items.controlgroupLabel ) { 6425 this.element 6426 .find( this.options.items.controlgroupLabel ) 6427 .find( ".ui-controlgroup-label-contents" ) 6428 .contents().unwrap(); 6429 } 6430 }, 6431 6432 _initWidgets: function() { 6433 var that = this, 6434 childWidgets = []; 6435 6436 // First we iterate over each of the items options 6437 $.each( this.options.items, function( widget, selector ) { 6438 var labels; 6439 var options = {}; 6440 6441 // Make sure the widget has a selector set 6442 if ( !selector ) { 6443 return; 6444 } 6445 6446 if ( widget === "controlgroupLabel" ) { 6447 labels = that.element.find( selector ); 6448 labels.each( function() { 6449 var element = $( this ); 6450 6451 if ( element.children( ".ui-controlgroup-label-contents" ).length ) { 6452 return; 6453 } 6454 element.contents() 6455 .wrapAll( "<span class='ui-controlgroup-label-contents'></span>" ); 6456 } ); 6457 that._addClass( labels, null, "ui-widget ui-widget-content ui-state-default" ); 6458 childWidgets = childWidgets.concat( labels.get() ); 6459 return; 6460 } 6461 6462 // Make sure the widget actually exists 6463 if ( !$.fn[ widget ] ) { 6464 return; 6465 } 6466 6467 // We assume everything is in the middle to start because we can't determine 6468 // first / last elements until all enhancments are done. 6469 if ( that[ "_" + widget + "Options" ] ) { 6470 options = that[ "_" + widget + "Options" ]( "middle" ); 6471 } 6472 6473 // Find instances of this widget inside controlgroup and init them 6474 that.element 6475 .find( selector ) 6476 .each( function() { 6477 var element = $( this ); 6478 var instance = element[ widget ]( "instance" ); 6479 6480 // We need to clone the default options for this type of widget to avoid 6481 // polluting the variable options which has a wider scope than a single widget. 6482 var instanceOptions = $.widget.extend( {}, options ); 6483 6484 // If the button is the child of a spinner ignore it 6485 // TODO: Find a more generic solution 6486 if ( widget === "button" && element.parent( ".ui-spinner" ).length ) { 6487 return; 6488 } 6489 6490 // Create the widget if it doesn't exist 6491 if ( !instance ) { 6492 instance = element[ widget ]()[ widget ]( "instance" ); 6493 } 6494 if ( instance ) { 6495 instanceOptions.classes = 6496 that._resolveClassesValues( instanceOptions.classes, instance ); 6497 } 6498 element[ widget ]( instanceOptions ); 6499 6500 // Store an instance of the controlgroup to be able to reference 6501 // from the outermost element for changing options and refresh 6502 var widgetElement = element[ widget ]( "widget" ); 6503 $.data( widgetElement[ 0 ], "ui-controlgroup-data", 6504 instance ? instance : element[ widget ]( "instance" ) ); 6505 6506 childWidgets.push( widgetElement[ 0 ] ); 6507 } ); 6508 } ); 6509 6510 this.childWidgets = $( $.unique( childWidgets ) ); 6511 this._addClass( this.childWidgets, "ui-controlgroup-item" ); 6512 }, 6513 6514 _callChildMethod: function( method ) { 6515 this.childWidgets.each( function() { 6516 var element = $( this ), 6517 data = element.data( "ui-controlgroup-data" ); 6518 if ( data && data[ method ] ) { 6519 data[ method ](); 6520 } 6521 } ); 6522 }, 6523 6524 _updateCornerClass: function( element, position ) { 6525 var remove = "ui-corner-top ui-corner-bottom ui-corner-left ui-corner-right ui-corner-all"; 6526 var add = this._buildSimpleOptions( position, "label" ).classes.label; 6527 6528 this._removeClass( element, null, remove ); 6529 this._addClass( element, null, add ); 6530 }, 6531 6532 _buildSimpleOptions: function( position, key ) { 6533 var direction = this.options.direction === "vertical"; 6534 var result = { 6535 classes: {} 6536 }; 6537 result.classes[ key ] = { 6538 "middle": "", 6539 "first": "ui-corner-" + ( direction ? "top" : "left" ), 6540 "last": "ui-corner-" + ( direction ? "bottom" : "right" ), 6541 "only": "ui-corner-all" 6542 }[ position ]; 6543 6544 return result; 6545 }, 6546 6547 _spinnerOptions: function( position ) { 6548 var options = this._buildSimpleOptions( position, "ui-spinner" ); 6549 6550 options.classes[ "ui-spinner-up" ] = ""; 6551 options.classes[ "ui-spinner-down" ] = ""; 6552 6553 return options; 6554 }, 6555 6556 _buttonOptions: function( position ) { 6557 return this._buildSimpleOptions( position, "ui-button" ); 6558 }, 6559 6560 _checkboxradioOptions: function( position ) { 6561 return this._buildSimpleOptions( position, "ui-checkboxradio-label" ); 6562 }, 6563 6564 _selectmenuOptions: function( position ) { 6565 var direction = this.options.direction === "vertical"; 6566 return { 6567 width: direction ? "auto" : false, 6568 classes: { 6569 middle: { 6570 "ui-selectmenu-button-open": "", 6571 "ui-selectmenu-button-closed": "" 6572 }, 6573 first: { 6574 "ui-selectmenu-button-open": "ui-corner-" + ( direction ? "top" : "tl" ), 6575 "ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "top" : "left" ) 6576 }, 6577 last: { 6578 "ui-selectmenu-button-open": direction ? "" : "ui-corner-tr", 6579 "ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "bottom" : "right" ) 6580 }, 6581 only: { 6582 "ui-selectmenu-button-open": "ui-corner-top", 6583 "ui-selectmenu-button-closed": "ui-corner-all" 6584 } 6585 6586 }[ position ] 6587 }; 6588 }, 6589 6590 _resolveClassesValues: function( classes, instance ) { 6591 var result = {}; 6592 $.each( classes, function( key ) { 6593 var current = instance.options.classes[ key ] || ""; 6594 current = current.replace( controlgroupCornerRegex, "" ).trim(); 6595 result[ key ] = ( current + " " + classes[ key ] ).replace( /\s+/g, " " ); 6596 } ); 6597 return result; 6598 }, 6599 6600 _setOption: function( key, value ) { 6601 if ( key === "direction" ) { 6602 this._removeClass( "ui-controlgroup-" + this.options.direction ); 6603 } 6604 6605 this._super( key, value ); 6606 if ( key === "disabled" ) { 6607 this._callChildMethod( value ? "disable" : "enable" ); 6608 return; 6609 } 6610 6611 this.refresh(); 6612 }, 6613 6614 refresh: function() { 6615 var children, 6616 that = this; 6617 6618 this._addClass( "ui-controlgroup ui-controlgroup-" + this.options.direction ); 6619 6620 if ( this.options.direction === "horizontal" ) { 6621 this._addClass( null, "ui-helper-clearfix" ); 6622 } 6623 this._initWidgets(); 6624 6625 children = this.childWidgets; 6626 6627 // We filter here because we need to track all childWidgets not just the visible ones 6628 if ( this.options.onlyVisible ) { 6629 children = children.filter( ":visible" ); 6630 } 6631 6632 if ( children.length ) { 6633 6634 // We do this last because we need to make sure all enhancment is done 6635 // before determining first and last 6636 $.each( [ "first", "last" ], function( index, value ) { 6637 var instance = children[ value ]().data( "ui-controlgroup-data" ); 6638 6639 if ( instance && that[ "_" + instance.widgetName + "Options" ] ) { 6640 var options = that[ "_" + instance.widgetName + "Options" ]( 6641 children.length === 1 ? "only" : value 6642 ); 6643 options.classes = that._resolveClassesValues( options.classes, instance ); 6644 instance.element[ instance.widgetName ]( options ); 6645 } else { 6646 that._updateCornerClass( children[ value ](), value ); 6647 } 6648 } ); 6649 6650 // Finally call the refresh method on each of the child widgets. 6651 this._callChildMethod( "refresh" ); 6652 } 6653 } 6654} ); 6655 6656/*! 6657 * jQuery UI Checkboxradio 1.12.0 6658 * http://jqueryui.com 6659 * 6660 * Copyright jQuery Foundation and other contributors 6661 * Released under the MIT license. 6662 * http://jquery.org/license 6663 */ 6664 6665//>>label: Checkboxradio 6666//>>group: Widgets 6667//>>description: Enhances a form with multiple themeable checkboxes or radio buttons. 6668//>>docs: http://api.jqueryui.com/checkboxradio/ 6669//>>demos: http://jqueryui.com/checkboxradio/ 6670//>>css.structure: ../../themes/base/core.css 6671//>>css.structure: ../../themes/base/button.css 6672//>>css.structure: ../../themes/base/checkboxradio.css 6673//>>css.theme: ../../themes/base/theme.css 6674 6675 6676 6677$.widget( "ui.checkboxradio", [ $.ui.formResetMixin, { 6678 version: "1.12.0", 6679 options: { 6680 disabled: null, 6681 label: null, 6682 icon: true, 6683 classes: { 6684 "ui-checkboxradio-label": "ui-corner-all", 6685 "ui-checkboxradio-icon": "ui-corner-all" 6686 } 6687 }, 6688 6689 _getCreateOptions: function() { 6690 var disabled, labels; 6691 var that = this; 6692 var options = this._super() || {}; 6693 6694 // We read the type here, because it makes more sense to throw a element type error first, 6695 // rather then the error for lack of a label. Often if its the wrong type, it 6696 // won't have a label (e.g. calling on a div, btn, etc) 6697 this._readType(); 6698 6699 labels = this.element.labels(); 6700 6701 // If there are multiple labels, use the last one 6702 this.label = $( labels[ labels.length - 1 ] ); 6703 if ( !this.label.length ) { 6704 $.error( "No label found for checkboxradio widget" ); 6705 } 6706 6707 this.originalLabel = ""; 6708 6709 // We need to get the label text but this may also need to make sure it does not contain the 6710 // input itself. 6711 this.label.contents().not( this.element ).each( function() { 6712 6713 // The label contents could be text, html, or a mix. We concat each element to get a 6714 // string representation of the label, without the input as part of it. 6715 that.originalLabel += this.nodeType === 3 ? $( this ).text() : this.outerHTML; 6716 } ); 6717 6718 // Set the label option if we found label text 6719 if ( this.originalLabel ) { 6720 options.label = this.originalLabel; 6721 } 6722 6723 disabled = this.element[ 0 ].disabled; 6724 if ( disabled != null ) { 6725 options.disabled = disabled; 6726 } 6727 return options; 6728 }, 6729 6730 _create: function() { 6731 var checked = this.element[ 0 ].checked; 6732 6733 this._bindFormResetHandler(); 6734 6735 if ( this.options.disabled == null ) { 6736 this.options.disabled = this.element[ 0 ].disabled; 6737 } 6738 6739 this._setOption( "disabled", this.options.disabled ); 6740 this._addClass( "ui-checkboxradio", "ui-helper-hidden-accessible" ); 6741 this._addClass( this.label, "ui-checkboxradio-label", "ui-button ui-widget" ); 6742 6743 if ( this.type === "radio" ) { 6744 this._addClass( this.label, "ui-checkboxradio-radio-label" ); 6745 } 6746 6747 if ( this.options.label && this.options.label !== this.originalLabel ) { 6748 this._updateLabel(); 6749 } else if ( this.originalLabel ) { 6750 this.options.label = this.originalLabel; 6751 } 6752 6753 this._enhance(); 6754 6755 if ( checked ) { 6756 this._addClass( this.label, "ui-checkboxradio-checked", "ui-state-active" ); 6757 if ( this.icon ) { 6758 this._addClass( this.icon, null, "ui-state-hover" ); 6759 } 6760 } 6761 6762 this._on( { 6763 change: "_toggleClasses", 6764 focus: function() { 6765 this._addClass( this.label, null, "ui-state-focus ui-visual-focus" ); 6766 }, 6767 blur: function() { 6768 this._removeClass( this.label, null, "ui-state-focus ui-visual-focus" ); 6769 } 6770 } ); 6771 }, 6772 6773 _readType: function() { 6774 var nodeName = this.element[ 0 ].nodeName.toLowerCase(); 6775 this.type = this.element[ 0 ].type; 6776 if ( nodeName !== "input" || !/radio|checkbox/.test( this.type ) ) { 6777 $.error( "Can't create checkboxradio on element.nodeName=" + nodeName + 6778 " and element.type=" + this.type ); 6779 } 6780 }, 6781 6782 // Support jQuery Mobile enhanced option 6783 _enhance: function() { 6784 this._updateIcon( this.element[ 0 ].checked ); 6785 }, 6786 6787 widget: function() { 6788 return this.label; 6789 }, 6790 6791 _getRadioGroup: function() { 6792 var group; 6793 var name = this.element[ 0 ].name; 6794 var nameSelector = "input[name='" + $.ui.escapeSelector( name ) + "']"; 6795 6796 if ( !name ) { 6797 return $( [] ); 6798 } 6799 6800 if ( this.form.length ) { 6801 group = $( this.form[ 0 ].elements ).filter( nameSelector ); 6802 } else { 6803 6804 // Not inside a form, check all inputs that also are not inside a form 6805 group = $( nameSelector ).filter( function() { 6806 return $( this ).form().length === 0; 6807 } ); 6808 } 6809 6810 return group.not( this.element ); 6811 }, 6812 6813 _toggleClasses: function() { 6814 var checked = this.element[ 0 ].checked; 6815 this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked ); 6816 6817 if ( this.options.icon && this.type === "checkbox" ) { 6818 this._toggleClass( this.icon, null, "ui-icon-check ui-state-checked", checked ) 6819 ._toggleClass( this.icon, null, "ui-icon-blank", !checked ); 6820 } 6821 6822 if ( this.type === "radio" ) { 6823 this._getRadioGroup() 6824 .each( function() { 6825 var instance = $( this ).checkboxradio( "instance" ); 6826 6827 if ( instance ) { 6828 instance._removeClass( instance.label, 6829 "ui-checkboxradio-checked", "ui-state-active" ); 6830 } 6831 } ); 6832 } 6833 }, 6834 6835 _destroy: function() { 6836 this._unbindFormResetHandler(); 6837 6838 if ( this.icon ) { 6839 this.icon.remove();
vendor: 4,339 bytes, lines 6840-7005
6840 this.iconSpace.remove(); 6841 } 6842 }, 6843 6844 _setOption: function( key, value ) { 6845 6846 // We don't allow the value to be set to nothing 6847 if ( key === "label" && !value ) { 6848 return; 6849 } 6850 6851 this._super( key, value ); 6852 6853 if ( key === "disabled" ) { 6854 this._toggleClass( this.label, null, "ui-state-disabled", value ); 6855 this.element[ 0 ].disabled = value; 6856 6857 // Don't refresh when setting disabled 6858 return; 6859 } 6860 this.refresh(); 6861 }, 6862 6863 _updateIcon: function( checked ) { 6864 var toAdd = "ui-icon ui-icon-background "; 6865 6866 if ( this.options.icon ) { 6867 if ( !this.icon ) { 6868 this.icon = $( "<span>" ); 6869 this.iconSpace = $( "<span> </span>" ); 6870 this._addClass( this.iconSpace, "ui-checkboxradio-icon-space" ); 6871 } 6872 6873 if ( this.type === "checkbox" ) { 6874 toAdd += checked ? "ui-icon-check ui-state-checked" : "ui-icon-blank"; 6875 this._removeClass( this.icon, null, checked ? "ui-icon-blank" : "ui-icon-check" ); 6876 } else { 6877 toAdd += "ui-icon-blank"; 6878 } 6879 this._addClass( this.icon, "ui-checkboxradio-icon", toAdd ); 6880 if ( !checked ) { 6881 this._removeClass( this.icon, null, "ui-icon-check ui-state-checked" ); 6882 } 6883 this.icon.prependTo( this.label ).after( this.iconSpace ); 6884 } else if ( this.icon !== undefined ) { 6885 this.icon.remove(); 6886 this.iconSpace.remove(); 6887 delete this.icon; 6888 } 6889 }, 6890 6891 _updateLabel: function() { 6892 6893 // Remove the contents of the label ( minus the icon, icon space, and input ) 6894 this.label.contents().not( this.element.add( this.icon ).add( this.iconSpace ) ).remove(); 6895 this.label.append( this.options.label ); 6896 }, 6897 6898 refresh: function() { 6899 var checked = this.element[ 0 ].checked, 6900 isDisabled = this.element[ 0 ].disabled; 6901 6902 this._updateIcon( checked ); 6903 this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked ); 6904 if ( this.options.label !== null ) { 6905 this._updateLabel(); 6906 } 6907 6908 if ( isDisabled !== this.options.disabled ) { 6909 this._setOptions( { "disabled": isDisabled } ); 6910 } 6911 } 6912 6913} ] ); 6914 6915var widgetsCheckboxradio = $.ui.checkboxradio; 6916 6917 6918/*! 6919 * jQuery UI Button 1.12.0 6920 * http://jqueryui.com 6921 * 6922 * Copyright jQuery Foundation and other contributors 6923 * Released under the MIT license. 6924 * http://jquery.org/license 6925 */ 6926 6927//>>label: Button 6928//>>group: Widgets 6929//>>description: Enhances a form with themeable buttons. 6930//>>docs: http://api.jqueryui.com/button/ 6931//>>demos: http://jqueryui.com/button/ 6932//>>css.structure: ../../themes/base/core.css 6933//>>css.structure: ../../themes/base/button.css 6934//>>css.theme: ../../themes/base/theme.css 6935 6936 6937 6938$.widget( "ui.button", { 6939 version: "1.12.0", 6940 defaultElement: "<button>", 6941 options: { 6942 classes: { 6943 "ui-button": "ui-corner-all" 6944 }, 6945 disabled: null, 6946 icon: null, 6947 iconPosition: "beginning", 6948 label: null, 6949 showLabel: true 6950 }, 6951 6952 _getCreateOptions: function() { 6953 var disabled, 6954 6955 // This is to support cases like in jQuery Mobile where the base widget does have 6956 // an implementation of _getCreateOptions 6957 options = this._super() || {}; 6958 6959 this.isInput = this.element.is( "input" ); 6960 6961 disabled = this.element[ 0 ].disabled; 6962 if ( disabled != null ) { 6963 options.disabled = disabled; 6964 } 6965 6966 this.originalLabel = this.isInput ? this.element.val() : this.element.html(); 6967 if ( this.originalLabel ) { 6968 options.label = this.originalLabel; 6969 } 6970 6971 return options; 6972 }, 6973 6974 _create: function() { 6975 if ( !this.option.showLabel & !this.options.icon ) { 6976 this.options.showLabel = true; 6977 } 6978 6979 // We have to check the option again here even though we did in _getCreateOptions, 6980 // because null may have been passed on init which would override what was set in 6981 // _getCreateOptions 6982 if ( this.options.disabled == null ) { 6983 this.options.disabled = this.element[ 0 ].disabled || false; 6984 } 6985 6986 this.hasTitle = !!this.element.attr( "title" ); 6987 6988 // Check to see if the label needs to be set or if its already correct 6989 if ( this.options.label && this.options.label !== this.originalLabel ) { 6990 if ( this.isInput ) { 6991 this.element.val( this.options.label ); 6992 } else { 6993 this.element.html( this.options.label ); 6994 } 6995 } 6996 this._addClass( "ui-button", "ui-widget" ); 6997 this._setOption( "disabled", this.options.disabled ); 6998 this._enhance(); 6999 7000 if ( this.element.is( "a" ) ) { 7001 this._on( { 7002 "keyup": function( event ) { 7003 if ( event.keyCode === $.ui.keyCode.SPACE ) { 7004 event.preventDefault(); 7005
vendor: 7,310 bytes, lines 7006-7283
7006 // Support: PhantomJS <= 1.9, IE 8 Only 7007 // If a native click is available use it so we actually cause navigation 7008 // otherwise just trigger a click event 7009 if ( this.element[ 0 ].click ) { 7010 this.element[ 0 ].click(); 7011 } else { 7012 this.element.trigger( "click" ); 7013 } 7014 } 7015 } 7016 } ); 7017 } 7018 }, 7019 7020 _enhance: function() { 7021 if ( !this.element.is( "button" ) ) { 7022 this.element.attr( "role", "button" ); 7023 } 7024 7025 if ( this.options.icon ) { 7026 this._updateIcon( "icon", this.options.icon ); 7027 this._updateTooltip(); 7028 } 7029 }, 7030 7031 _updateTooltip: function() { 7032 this.title = this.element.attr( "title" ); 7033 7034 if ( !this.options.showLabel && !this.title ) { 7035 this.element.attr( "title", this.options.label ); 7036 } 7037 }, 7038 7039 _updateIcon: function( option, value ) { 7040 var icon = option !== "iconPosition", 7041 position = icon ? this.options.iconPosition : value, 7042 displayBlock = position === "top" || position === "bottom"; 7043 7044 // Create icon 7045 if ( !this.icon ) { 7046 this.icon = $( "<span>" ); 7047 7048 this._addClass( this.icon, "ui-button-icon", "ui-icon" ); 7049 7050 if ( !this.options.showLabel ) { 7051 this._addClass( "ui-button-icon-only" ); 7052 } 7053 } else if ( icon ) { 7054 7055 // If we are updating the icon remove the old icon class 7056 this._removeClass( this.icon, null, this.options.icon ); 7057 } 7058 7059 // If we are updating the icon add the new icon class 7060 if ( icon ) { 7061 this._addClass( this.icon, null, value ); 7062 } 7063 7064 this._attachIcon( position ); 7065 7066 // If the icon is on top or bottom we need to add the ui-widget-icon-block class and remove 7067 // the iconSpace if there is one. 7068 if ( displayBlock ) { 7069 this._addClass( this.icon, null, "ui-widget-icon-block" ); 7070 if ( this.iconSpace ) { 7071 this.iconSpace.remove(); 7072 } 7073 } else { 7074 7075 // Position is beginning or end so remove the ui-widget-icon-block class and add the 7076 // space if it does not exist 7077 if ( !this.iconSpace ) { 7078 this.iconSpace = $( "<span> </span>" ); 7079 this._addClass( this.iconSpace, "ui-button-icon-space" ); 7080 } 7081 this._removeClass( this.icon, null, "ui-wiget-icon-block" ); 7082 this._attachIconSpace( position ); 7083 } 7084 }, 7085 7086 _destroy: function() { 7087 this.element.removeAttr( "role" ); 7088 7089 if ( this.icon ) { 7090 this.icon.remove(); 7091 } 7092 if ( this.iconSpace ) { 7093 this.iconSpace.remove(); 7094 } 7095 if ( !this.hasTitle ) { 7096 this.element.removeAttr( "title" ); 7097 } 7098 }, 7099 7100 _attachIconSpace: function( iconPosition ) { 7101 this.icon[ /^(?:end|bottom)/.test( iconPosition ) ? "before" : "after" ]( this.iconSpace ); 7102 }, 7103 7104 _attachIcon: function( iconPosition ) { 7105 this.element[ /^(?:end|bottom)/.test( iconPosition ) ? "append" : "prepend" ]( this.icon ); 7106 }, 7107 7108 _setOptions: function( options ) { 7109 var newShowLabel = options.showLabel === undefined ? 7110 this.options.showLabel : 7111 options.showLabel, 7112 newIcon = options.icon === undefined ? this.options.icon : options.icon; 7113 7114 if ( !newShowLabel && !newIcon ) { 7115 options.showLabel = true; 7116 } 7117 this._super( options ); 7118 }, 7119 7120 _setOption: function( key, value ) { 7121 if ( key === "icon" ) { 7122 if ( value ) { 7123 this._updateIcon( key, value ); 7124 } else if ( this.icon ) { 7125 this.icon.remove(); 7126 if ( this.iconSpace ) { 7127 this.iconSpace.remove(); 7128 } 7129 } 7130 } 7131 7132 if ( key === "iconPosition" ) { 7133 this._updateIcon( key, value ); 7134 } 7135 7136 // Make sure we can't end up with a button that has neither text nor icon 7137 if ( key === "showLabel" ) { 7138 this._toggleClass( "ui-button-icon-only", null, !value ); 7139 this._updateTooltip(); 7140 } 7141 7142 if ( key === "label" ) { 7143 if ( this.isInput ) { 7144 this.element.val( value ); 7145 } else { 7146 7147 // If there is an icon, append it, else nothing then append the value 7148 // this avoids removal of the icon when setting label text 7149 this.element.html( value ); 7150 if ( this.icon ) { 7151 this._attachIcon( this.options.iconPosition ); 7152 this._attachIconSpace( this.options.iconPosition ); 7153 } 7154 } 7155 } 7156 7157 this._super( key, value ); 7158 7159 if ( key === "disabled" ) { 7160 this._toggleClass( null, "ui-state-disabled", value ); 7161 this.element[ 0 ].disabled = value; 7162 if ( value ) { 7163 this.element.blur(); 7164 } 7165 } 7166 }, 7167 7168 refresh: function() { 7169 7170 // Make sure to only check disabled if its an element that supports this otherwise 7171 // check for the disabled class to determine state 7172 var isDisabled = this.element.is( "input, button" ) ? 7173 this.element[ 0 ].disabled : this.element.hasClass( "ui-button-disabled" ); 7174 7175 if ( isDisabled !== this.options.disabled ) { 7176 this._setOptions( { disabled: isDisabled } ); 7177 } 7178 7179 this._updateTooltip(); 7180 } 7181} ); 7182 7183// DEPRECATED 7184if ( $.uiBackCompat !== false ) { 7185 7186 // Text and Icons options 7187 $.widget( "ui.button", $.ui.button, { 7188 options: { 7189 text: true, 7190 icons: { 7191 primary: null, 7192 secondary: null 7193 } 7194 }, 7195 7196 _create: function() { 7197 if ( this.options.showLabel && !this.options.text ) { 7198 this.options.showLabel = this.options.text; 7199 } 7200 if ( !this.options.showLabel && this.options.text ) { 7201 this.options.text = this.options.showLabel; 7202 } 7203 if ( !this.options.icon && ( this.options.icons.primary || 7204 this.options.icons.secondary ) ) { 7205 if ( this.options.icons.primary ) { 7206 this.options.icon = this.options.icons.primary; 7207 } else { 7208 this.options.icon = this.options.icons.secondary; 7209 this.options.iconPosition = "end"; 7210 } 7211 } else if ( this.options.icon ) { 7212 this.options.icons.primary = this.options.icon; 7213 } 7214 this._super(); 7215 }, 7216 7217 _setOption: function( key, value ) { 7218 if ( key === "text" ) { 7219 this._super( "showLabel", value ); 7220 return; 7221 } 7222 if ( key === "showLabel" ) { 7223 this.options.text = value; 7224 } 7225 if ( key === "icon" ) { 7226 this.options.icons.primary = value; 7227 } 7228 if ( key === "icons" ) { 7229 if ( value.primary ) { 7230 this._super( "icon", value.primary ); 7231 this._super( "iconPosition", "beginning" ); 7232 } else if ( value.secondary ) { 7233 this._super( "icon", value.secondary ); 7234 this._super( "iconPosition", "end" ); 7235 } 7236 } 7237 this._superApply( arguments ); 7238 } 7239 } ); 7240 7241 $.fn.button = ( function( orig ) { 7242 return function() { 7243 if ( !this.length || ( this.length && this[ 0 ].tagName !== "INPUT" ) || 7244 ( this.length && this[ 0 ].tagName === "INPUT" && ( 7245 this.attr( "type" ) !== "checkbox" && this.attr( "type" ) !== "radio" 7246 ) ) ) { 7247 return orig.apply( this, arguments ); 7248 } 7249 if ( !$.ui.checkboxradio ) { 7250 $.error( "Checkboxradio widget missing" ); 7251 } 7252 if ( arguments.length === 0 ) { 7253 return this.checkboxradio( { 7254 "icon": false 7255 } ); 7256 } 7257 return this.checkboxradio.apply( this, arguments ); 7258 }; 7259 } )( $.fn.button ); 7260 7261 $.fn.buttonset = function() { 7262 if ( !$.ui.controlgroup ) { 7263 $.error( "Controlgroup widget missing" ); 7264 } 7265 if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" && arguments[ 2 ] ) { 7266 return this.controlgroup.apply( this, 7267 [ arguments[ 0 ], "items.button", arguments[ 2 ] ] ); 7268 } 7269 if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" ) { 7270 return this.controlgroup.apply( this, [ arguments[ 0 ], "items.button" ] ); 7271 } 7272 if ( typeof arguments[ 0 ] === "object" && arguments[ 0 ].items ) { 7273 arguments[ 0 ].items = { 7274 button: arguments[ 0 ].items 7275 }; 7276 } 7277 return this.controlgroup.apply( this, arguments ); 7278 }; 7279} 7280 7281var widgetsButton = $.ui.button; 7282 7283
vendor: 2,587 bytes, lines 7284-7387
7284/*! 7285 * jQuery UI Slider 1.12.0 7286 * http://jqueryui.com 7287 * 7288 * Copyright jQuery Foundation and other contributors 7289 * Released under the MIT license. 7290 * http://jquery.org/license 7291 */ 7292 7293//>>label: Slider 7294//>>group: Widgets 7295//>>description: Displays a flexible slider with ranges and accessibility via keyboard. 7296//>>docs: http://api.jqueryui.com/slider/ 7297//>>demos: http://jqueryui.com/slider/ 7298//>>css.structure: ../../themes/base/core.css 7299//>>css.structure: ../../themes/base/slider.css 7300//>>css.theme: ../../themes/base/theme.css 7301 7302 7303 7304var widgetsSlider = $.widget( "ui.slider", $.ui.mouse, { 7305 version: "1.12.0", 7306 widgetEventPrefix: "slide", 7307 7308 options: { 7309 animate: false, 7310 classes: { 7311 "ui-slider": "ui-corner-all", 7312 "ui-slider-handle": "ui-corner-all", 7313 7314 // Note: ui-widget-header isn't the most fittingly semantic framework class for this 7315 // element, but worked best visually with a variety of themes 7316 "ui-slider-range": "ui-corner-all ui-widget-header" 7317 }, 7318 distance: 0, 7319 max: 100, 7320 min: 0, 7321 orientation: "horizontal", 7322 range: false, 7323 step: 1, 7324 value: 0, 7325 values: null, 7326 7327 // Callbacks 7328 change: null, 7329 slide: null, 7330 start: null, 7331 stop: null 7332 }, 7333 7334 // Number of pages in a slider 7335 // (how many times can you page up/down to go through the whole range) 7336 numPages: 5, 7337 7338 _create: function() { 7339 this._keySliding = false; 7340 this._mouseSliding = false; 7341 this._animateOff = true; 7342 this._handleIndex = null; 7343 this._detectOrientation(); 7344 this._mouseInit(); 7345 this._calculateNewMax(); 7346 7347 this._addClass( "ui-slider ui-slider-" + this.orientation, 7348 "ui-widget ui-widget-content" ); 7349 7350 this._refresh(); 7351 7352 this._animateOff = false; 7353 }, 7354 7355 _refresh: function() { 7356 this._createRange(); 7357 this._createHandles(); 7358 this._setupEvents(); 7359 this._refreshValue(); 7360 }, 7361 7362 _createHandles: function() { 7363 var i, handleCount, 7364 options = this.options, 7365 existingHandles = this.element.find( ".ui-slider-handle" ), 7366 handle = "<span tabindex='0'></span>", 7367 handles = []; 7368 7369 handleCount = ( options.values && options.values.length ) || 1; 7370 7371 if ( existingHandles.length > handleCount ) { 7372 existingHandles.slice( handleCount ).remove(); 7373 existingHandles = existingHandles.slice( 0, handleCount ); 7374 } 7375 7376 for ( i = existingHandles.length; i < handleCount; i++ ) { 7377 handles.push( handle ); 7378 } 7379 7380 this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) ); 7381 7382 this._addClass( this.handles, "ui-slider-handle", "ui-state-default" ); 7383 7384 this.handle = this.handles.eq( 0 ); 7385 7386 this.handles.each( function( i ) { 7387 $( this ).data( "ui-slider-handle-index", i
vendor: 16,660 bytes, lines 7387-8019
7387 ); 7388 } ); 7389 }, 7390 7391 _createRange: function() { 7392 var options = this.options; 7393 7394 if ( options.range ) { 7395 if ( options.range === true ) { 7396 if ( !options.values ) { 7397 options.values = [ this._valueMin(), this._valueMin() ]; 7398 } else if ( options.values.length && options.values.length !== 2 ) { 7399 options.values = [ options.values[ 0 ], options.values[ 0 ] ]; 7400 } else if ( $.isArray( options.values ) ) { 7401 options.values = options.values.slice( 0 ); 7402 } 7403 } 7404 7405 if ( !this.range || !this.range.length ) { 7406 this.range = $( "<div>" ) 7407 .appendTo( this.element ); 7408 7409 this._addClass( this.range, "ui-slider-range" ); 7410 } else { 7411 this._removeClass( this.range, "ui-slider-range-min ui-slider-range-max" ); 7412 7413 // Handle range switching from true to min/max 7414 this.range.css( { 7415 "left": "", 7416 "bottom": "" 7417 } ); 7418 } 7419 if ( options.range === "min" || options.range === "max" ) { 7420 this._addClass( this.range, "ui-slider-range-" + options.range ); 7421 } 7422 } else { 7423 if ( this.range ) { 7424 this.range.remove(); 7425 } 7426 this.range = null; 7427 } 7428 }, 7429 7430 _setupEvents: function() { 7431 this._off( this.handles ); 7432 this._on( this.handles, this._handleEvents ); 7433 this._hoverable( this.handles ); 7434 this._focusable( this.handles ); 7435 }, 7436 7437 _destroy: function() { 7438 this.handles.remove(); 7439 if ( this.range ) { 7440 this.range.remove(); 7441 } 7442 7443 this._mouseDestroy(); 7444 }, 7445 7446 _mouseCapture: function( event ) { 7447 var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle, 7448 that = this, 7449 o = this.options; 7450 7451 if ( o.disabled ) { 7452 return false; 7453 } 7454 7455 this.elementSize = { 7456 width: this.element.outerWidth(), 7457 height: this.element.outerHeight() 7458 }; 7459 this.elementOffset = this.element.offset(); 7460 7461 position = { x: event.pageX, y: event.pageY }; 7462 normValue = this._normValueFromMouse( position ); 7463 distance = this._valueMax() - this._valueMin() + 1; 7464 this.handles.each( function( i ) { 7465 var thisDistance = Math.abs( normValue - that.values( i ) ); 7466 if ( ( distance > thisDistance ) || 7467 ( distance === thisDistance && 7468 ( i === that._lastChangedValue || that.values( i ) === o.min ) ) ) { 7469 distance = thisDistance; 7470 closestHandle = $( this ); 7471 index = i; 7472 } 7473 } ); 7474 7475 allowed = this._start( event, index ); 7476 if ( allowed === false ) { 7477 return false; 7478 } 7479 this._mouseSliding = true; 7480 7481 this._handleIndex = index; 7482 7483 this._addClass( closestHandle, null, "ui-state-active" ); 7484 closestHandle.trigger( "focus" ); 7485 7486 offset = closestHandle.offset(); 7487 mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" ); 7488 this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : { 7489 left: event.pageX - offset.left - ( closestHandle.width() / 2 ), 7490 top: event.pageY - offset.top - 7491 ( closestHandle.height() / 2 ) - 7492 ( parseInt( closestHandle.css( "borderTopWidth" ), 10 ) || 0 ) - 7493 ( parseInt( closestHandle.css( "borderBottomWidth" ), 10 ) || 0 ) + 7494 ( parseInt( closestHandle.css( "marginTop" ), 10 ) || 0 ) 7495 }; 7496 7497 if ( !this.handles.hasClass( "ui-state-hover" ) ) { 7498 this._slide( event, index, normValue ); 7499 } 7500 this._animateOff = true; 7501 return true; 7502 }, 7503 7504 _mouseStart: function() { 7505 return true; 7506 }, 7507 7508 _mouseDrag: function( event ) { 7509 var position = { x: event.pageX, y: event.pageY }, 7510 normValue = this._normValueFromMouse( position ); 7511 7512 this._slide( event, this._handleIndex, normValue ); 7513 7514 return false; 7515 }, 7516 7517 _mouseStop: function( event ) { 7518 this._removeClass( this.handles, null, "ui-state-active" ); 7519 this._mouseSliding = false; 7520 7521 this._stop( event, this._handleIndex ); 7522 this._change( event, this._handleIndex ); 7523 7524 this._handleIndex = null; 7525 this._clickOffset = null; 7526 this._animateOff = false; 7527 7528 return false; 7529 }, 7530 7531 _detectOrientation: function() { 7532 this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal"; 7533 }, 7534 7535 _normValueFromMouse: function( position ) { 7536 var pixelTotal, 7537 pixelMouse, 7538 percentMouse, 7539 valueTotal, 7540 valueMouse; 7541 7542 if ( this.orientation === "horizontal" ) { 7543 pixelTotal = this.elementSize.width; 7544 pixelMouse = position.x - this.elementOffset.left - 7545 ( this._clickOffset ? this._clickOffset.left : 0 ); 7546 } else { 7547 pixelTotal = this.elementSize.height; 7548 pixelMouse = position.y - this.elementOffset.top - 7549 ( this._clickOffset ? this._clickOffset.top : 0 ); 7550 } 7551 7552 percentMouse = ( pixelMouse / pixelTotal ); 7553 if ( percentMouse > 1 ) { 7554 percentMouse = 1; 7555 } 7556 if ( percentMouse < 0 ) { 7557 percentMouse = 0; 7558 } 7559 if ( this.orientation === "vertical" ) { 7560 percentMouse = 1 - percentMouse; 7561 } 7562 7563 valueTotal = this._valueMax() - this._valueMin(); 7564 valueMouse = this._valueMin() + percentMouse * valueTotal; 7565 7566 return this._trimAlignValue( valueMouse ); 7567 }, 7568 7569 _uiHash: function( index, value, values ) { 7570 var uiHash = { 7571 handle: this.handles[ index ], 7572 handleIndex: index, 7573 value: value !== undefined ? value : this.value() 7574 }; 7575 7576 if ( this._hasMultipleValues() ) { 7577 uiHash.value = value !== undefined ? value : this.values( index ); 7578 uiHash.values = values || this.values(); 7579 } 7580 7581 return uiHash; 7582 }, 7583 7584 _hasMultipleValues: function() { 7585 return this.options.values && this.options.values.length; 7586 }, 7587 7588 _start: function( event, index ) { 7589 return this._trigger( "start", event, this._uiHash( index ) ); 7590 }, 7591 7592 _slide: function( event, index, newVal ) { 7593 var allowed, otherVal, 7594 currentValue = this.value(), 7595 newValues = this.values(); 7596 7597 if ( this._hasMultipleValues() ) { 7598 otherVal = this.values( index ? 0 : 1 ); 7599 currentValue = this.values( index ); 7600 7601 if ( this.options.values.length === 2 && this.options.range === true ) { 7602 newVal = index === 0 ? Math.min( otherVal, newVal ) : Math.max( otherVal, newVal ); 7603 } 7604 7605 newValues[ index ] = newVal; 7606 } 7607 7608 if ( newVal === currentValue ) { 7609 return; 7610 } 7611 7612 allowed = this._trigger( "slide", event, this._uiHash( index, newVal, newValues ) ); 7613 7614 // A slide can be canceled by returning false from the slide callback 7615 if ( allowed === false ) { 7616 return; 7617 } 7618 7619 if ( this._hasMultipleValues() ) { 7620 this.values( index, newVal ); 7621 } else { 7622 this.value( newVal ); 7623 } 7624 }, 7625 7626 _stop: function( event, index ) { 7627 this._trigger( "stop", event, this._uiHash( index ) ); 7628 }, 7629 7630 _change: function( event, index ) { 7631 if ( !this._keySliding && !this._mouseSliding ) { 7632 7633 //store the last changed value index for reference when handles overlap 7634 this._lastChangedValue = index; 7635 this._trigger( "change", event, this._uiHash( index ) ); 7636 } 7637 }, 7638 7639 value: function( newValue ) { 7640 if ( arguments.length ) { 7641 this.options.value = this._trimAlignValue( newValue ); 7642 this._refreshValue(); 7643 this._change( null, 0 ); 7644 return; 7645 } 7646 7647 return this._value(); 7648 }, 7649 7650 values: function( index, newValue ) { 7651 var vals, 7652 newValues, 7653 i; 7654 7655 if ( arguments.length > 1 ) { 7656 this.options.values[ index ] = this._trimAlignValue( newValue ); 7657 this._refreshValue(); 7658 this._change( null, index ); 7659 return; 7660 } 7661 7662 if ( arguments.length ) { 7663 if ( $.isArray( arguments[ 0 ] ) ) { 7664 vals = this.options.values; 7665 newValues = arguments[ 0 ]; 7666 for ( i = 0; i < vals.length; i += 1 ) { 7667 vals[ i ] = this._trimAlignValue( newValues[ i ] ); 7668 this._change( null, i ); 7669 } 7670 this._refreshValue(); 7671 } else { 7672 if ( this._hasMultipleValues() ) { 7673 return this._values( index ); 7674 } else { 7675 return this.value(); 7676 } 7677 } 7678 } else { 7679 return this._values(); 7680 } 7681 }, 7682 7683 _setOption: function( key, value ) { 7684 var i, 7685 valsLength = 0; 7686 7687 if ( key === "range" && this.options.range === true ) { 7688 if ( value === "min" ) { 7689 this.options.value = this._values( 0 ); 7690 this.options.values = null; 7691 } else if ( value === "max" ) { 7692 this.options.value = this._values( this.options.values.length - 1 ); 7693 this.options.values = null; 7694 } 7695 } 7696 7697 if ( $.isArray( this.options.values ) ) { 7698 valsLength = this.options.values.length; 7699 } 7700 7701 this._super( key, value ); 7702 7703 switch ( key ) { 7704 case "orientation": 7705 this._detectOrientation(); 7706 this._removeClass( "ui-slider-horizontal ui-slider-vertical" ) 7707 ._addClass( "ui-slider-" + this.orientation ); 7708 this._refreshValue(); 7709 if ( this.options.range ) { 7710 this._refreshRange( value ); 7711 } 7712 7713 // Reset positioning from previous orientation 7714 this.handles.css( value === "horizontal" ? "bottom" : "left", "" ); 7715 break; 7716 case "value": 7717 this._animateOff = true; 7718 this._refreshValue(); 7719 this._change( null, 0 ); 7720 this._animateOff = false; 7721 break; 7722 case "values": 7723 this._animateOff = true; 7724 this._refreshValue(); 7725 7726 // Start from the last handle to prevent unreachable handles (#9046) 7727 for ( i = valsLength - 1; i >= 0; i-- ) { 7728 this._change( null, i ); 7729 } 7730 this._animateOff = false; 7731 break; 7732 case "step": 7733 case "min": 7734 case "max": 7735 this._animateOff = true; 7736 this._calculateNewMax(); 7737 this._refreshValue(); 7738 this._animateOff = false; 7739 break; 7740 case "range": 7741 this._animateOff = true; 7742 this._refresh(); 7743 this._animateOff = false; 7744 break; 7745 } 7746 }, 7747 7748 _setOptionDisabled: function( value ) { 7749 this._super( value ); 7750 7751 this._toggleClass( null, "ui-state-disabled", !!value ); 7752 }, 7753 7754 //internal value getter 7755 // _value() returns value trimmed by min and max, aligned by step 7756 _value: function() { 7757 var val = this.options.value; 7758 val = this._trimAlignValue( val ); 7759 7760 return val; 7761 }, 7762 7763 //internal values getter 7764 // _values() returns array of values trimmed by min and max, aligned by step 7765 // _values( index ) returns single value trimmed by min and max, aligned by step 7766 _values: function( index ) { 7767 var val, 7768 vals, 7769 i; 7770 7771 if ( arguments.length ) { 7772 val = this.options.values[ index ]; 7773 val = this._trimAlignValue( val ); 7774 7775 return val; 7776 } else if ( this._hasMultipleValues() ) { 7777 7778 // .slice() creates a copy of the array 7779 // this copy gets trimmed by min and max and then returned 7780 vals = this.options.values.slice(); 7781 for ( i = 0; i < vals.length; i += 1 ) { 7782 vals[ i ] = this._trimAlignValue( vals[ i ] ); 7783 } 7784 7785 return vals; 7786 } else { 7787 return []; 7788 } 7789 }, 7790 7791 // Returns the step-aligned value that val is closest to, between (inclusive) min and max 7792 _trimAlignValue: function( val ) { 7793 if ( val <= this._valueMin() ) { 7794 return this._valueMin(); 7795 } 7796 if ( val >= this._valueMax() ) { 7797 return this._valueMax(); 7798 } 7799 var step = ( this.options.step > 0 ) ? this.options.step : 1, 7800 valModStep = ( val - this._valueMin() ) % step, 7801 alignValue = val - valModStep; 7802 7803 if ( Math.abs( valModStep ) * 2 >= step ) { 7804 alignValue += ( valModStep > 0 ) ? step : ( -step ); 7805 } 7806 7807 // Since JavaScript has problems with large floats, round 7808 // the final value to 5 digits after the decimal point (see #4124) 7809 return parseFloat( alignValue.toFixed( 5 ) ); 7810 }, 7811 7812 _calculateNewMax: function() { 7813 var max = this.options.max, 7814 min = this._valueMin(), 7815 step = this.options.step, 7816 aboveMin = Math.round( ( max - min ) / step ) * step; 7817 max = aboveMin + min; 7818 if ( max > this.options.max ) { 7819 7820 //If max is not divisible by step, rounding off may increase its value 7821 max -= step; 7822 } 7823 this.max = parseFloat( max.toFixed( this._precision() ) ); 7824 }, 7825 7826 _precision: function() { 7827 var precision = this._precisionOf( this.options.step ); 7828 if ( this.options.min !== null ) { 7829 precision = Math.max( precision, this._precisionOf( this.options.min ) ); 7830 } 7831 return precision; 7832 }, 7833 7834 _precisionOf: function( num ) { 7835 var str = num.toString(), 7836 decimal = str.indexOf( "." ); 7837 return decimal === -1 ? 0 : str.length - decimal - 1; 7838 }, 7839 7840 _valueMin: function() { 7841 return this.options.min; 7842 }, 7843 7844 _valueMax: function() { 7845 return this.max; 7846 }, 7847 7848 _refreshRange: function( orientation ) { 7849 if ( orientation === "vertical" ) { 7850 this.range.css( { "width": "", "left": "" } ); 7851 } 7852 if ( orientation === "horizontal" ) { 7853 this.range.css( { "height": "", "bottom": "" } ); 7854 } 7855 }, 7856 7857 _refreshValue: function() { 7858 var lastValPercent, valPercent, value, valueMin, valueMax, 7859 oRange = this.options.range, 7860 o = this.options, 7861 that = this, 7862 animate = ( !this._animateOff ) ? o.animate : false, 7863 _set = {}; 7864 7865 if ( this._hasMultipleValues() ) { 7866 this.handles.each( function( i ) { 7867 valPercent = ( that.values( i ) - that._valueMin() ) / ( that._valueMax() - 7868 that._valueMin() ) * 100; 7869 _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%"; 7870 $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate ); 7871 if ( that.options.range === true ) { 7872 if ( that.orientation === "horizontal" ) { 7873 if ( i === 0 ) { 7874 that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { 7875 left: valPercent + "%" 7876 }, o.animate ); 7877 } 7878 if ( i === 1 ) { 7879 that.range[ animate ? "animate" : "css" ]( { 7880 width: ( valPercent - lastValPercent ) + "%" 7881 }, { 7882 queue: false, 7883 duration: o.animate 7884 } ); 7885 } 7886 } else { 7887 if ( i === 0 ) { 7888 that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { 7889 bottom: ( valPercent ) + "%" 7890 }, o.animate ); 7891 } 7892 if ( i === 1 ) { 7893 that.range[ animate ? "animate" : "css" ]( { 7894 height: ( valPercent - lastValPercent ) + "%" 7895 }, { 7896 queue: false, 7897 duration: o.animate 7898 } ); 7899 } 7900 } 7901 } 7902 lastValPercent = valPercent; 7903 } ); 7904 } else { 7905 value = this.value(); 7906 valueMin = this._valueMin(); 7907 valueMax = this._valueMax(); 7908 valPercent = ( valueMax !== valueMin ) ? 7909 ( value - valueMin ) / ( valueMax - valueMin ) * 100 : 7910 0; 7911 _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%"; 7912 this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate ); 7913 7914 if ( oRange === "min" && this.orientation === "horizontal" ) { 7915 this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { 7916 width: valPercent + "%" 7917 }, o.animate ); 7918 } 7919 if ( oRange === "max" && this.orientation === "horizontal" ) { 7920 this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { 7921 width: ( 100 - valPercent ) + "%" 7922 }, o.animate ); 7923 } 7924 if ( oRange === "min" && this.orientation === "vertical" ) { 7925 this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { 7926 height: valPercent + "%" 7927 }, o.animate ); 7928 } 7929 if ( oRange === "max" && this.orientation === "vertical" ) { 7930 this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { 7931 height: ( 100 - valPercent ) + "%" 7932 }, o.animate ); 7933 } 7934 } 7935 }, 7936 7937 _handleEvents: { 7938 keydown: function( event ) { 7939 var allowed, curVal, newVal, step, 7940 index = $( event.target ).data( "ui-slider-handle-index" ); 7941 7942 switch ( event.keyCode ) { 7943 case $.ui.keyCode.HOME: 7944 case $.ui.keyCode.END: 7945 case $.ui.keyCode.PAGE_UP: 7946 case $.ui.keyCode.PAGE_DOWN: 7947 case $.ui.keyCode.UP: 7948 case $.ui.keyCode.RIGHT: 7949 case $.ui.keyCode.DOWN: 7950 case $.ui.keyCode.LEFT: 7951 event.preventDefault(); 7952 if ( !this._keySliding ) { 7953 this._keySliding = true; 7954 this._addClass( $( event.target ), null, "ui-state-active" ); 7955 allowed = this._start( event, index ); 7956 if ( allowed === false ) { 7957 return; 7958 } 7959 } 7960 break; 7961 } 7962 7963 step = this.options.step; 7964 if ( this._hasMultipleValues() ) { 7965 curVal = newVal = this.values( index ); 7966 } else { 7967 curVal = newVal = this.value(); 7968 } 7969 7970 switch ( event.keyCode ) { 7971 case $.ui.keyCode.HOME: 7972 newVal = this._valueMin(); 7973 break; 7974 case $.ui.keyCode.END: 7975 newVal = this._valueMax(); 7976 break; 7977 case $.ui.keyCode.PAGE_UP: 7978 newVal = this._trimAlignValue( 7979 curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages ) 7980 ); 7981 break; 7982 case $.ui.keyCode.PAGE_DOWN: 7983 newVal = this._trimAlignValue( 7984 curVal - ( ( this._valueMax() - this._valueMin() ) / this.numPages ) ); 7985 break; 7986 case $.ui.keyCode.UP: 7987 case $.ui.keyCode.RIGHT: 7988 if ( curVal === this._valueMax() ) { 7989 return; 7990 } 7991 newVal = this._trimAlignValue( curVal + step ); 7992 break; 7993 case $.ui.keyCode.DOWN: 7994 case $.ui.keyCode.LEFT: 7995 if ( curVal === this._valueMin() ) { 7996 return; 7997 } 7998 newVal = this._trimAlignValue( curVal - step ); 7999 break; 8000 } 8001 8002 this._slide( event, index, newVal ); 8003 }, 8004 keyup: function( event ) { 8005 var index = $( event.target ).data( "ui-slider-handle-index" ); 8006 8007 if ( this._keySliding ) { 8008 this._keySliding = false; 8009 this._stop( event, index ); 8010 this._change( event, index ); 8011 this._removeClass( $( event.target ), null, "ui-state-active" ); 8012 } 8013 } 8014 } 8015} ); 8016 8017 8018/*! 8019 * jQuery UI S
8019pinner 1.12.0 8020 * http://jqueryui.com 8021 * 8022 * Copyright jQuery Foundation and other contributors 8023 * Released under the MIT license. 8024 * http://jquery.org/license 8025 */ 8026 8027//>>label: Spinner 8028//>>group: Widgets 8029//>>description: Displays buttons to easily input numbers via the keyboard or mouse. 8030//>>docs: http://api.jqueryui.com/spinner/ 8031//>>demos: http://jqueryui.com/spinner/ 8032//>>css.structure: ../../themes/base/core.css 8033//>>css.structure: ../../themes/base/spinner.css 8034//>>css.theme: ../../themes/base/theme.css 8035 8036 8037 8038function spinnerModifer( fn ) { 8039 return function() { 8040 var previous = this.element.val(); 8041 fn.apply( this, arguments ); 8042 this._refresh(); 8043 if ( previous !== this.element.val() ) { 8044 this._trigger( "change" ); 8045 } 8046 }; 8047} 8048 8049$.widget( "ui.spinner", { 8050 version: "1.12.0
vendor: 13,132 bytes, lines 8050-8575
8050", 8051 defaultElement: "<input>", 8052 widgetEventPrefix: "spin", 8053 options: { 8054 classes: { 8055 "ui-spinner": "ui-corner-all", 8056 "ui-spinner-down": "ui-corner-br", 8057 "ui-spinner-up": "ui-corner-tr" 8058 }, 8059 culture: null, 8060 icons: { 8061 down: "ui-icon-triangle-1-s", 8062 up: "ui-icon-triangle-1-n" 8063 }, 8064 incremental: true, 8065 max: null, 8066 min: null, 8067 numberFormat: null, 8068 page: 10, 8069 step: 1, 8070 8071 change: null, 8072 spin: null, 8073 start: null, 8074 stop: null 8075 }, 8076 8077 _create: function() { 8078 8079 // handle string values that need to be parsed 8080 this._setOption( "max", this.options.max ); 8081 this._setOption( "min", this.options.min ); 8082 this._setOption( "step", this.options.step ); 8083 8084 // Only format if there is a value, prevents the field from being marked 8085 // as invalid in Firefox, see #9573. 8086 if ( this.value() !== "" ) { 8087 8088 // Format the value, but don't constrain. 8089 this._value( this.element.val(), true ); 8090 } 8091 8092 this._draw(); 8093 this._on( this._events ); 8094 this._refresh(); 8095 8096 // Turning off autocomplete prevents the browser from remembering the 8097 // value when navigating through history, so we re-enable autocomplete 8098 // if the page is unloaded before the widget is destroyed. #7790 8099 this._on( this.window, { 8100 beforeunload: function() { 8101 this.element.removeAttr( "autocomplete" ); 8102 } 8103 } ); 8104 }, 8105 8106 _getCreateOptions: function() { 8107 var options = this._super(); 8108 var element = this.element; 8109 8110 $.each( [ "min", "max", "step" ], function( i, option ) { 8111 var value = element.attr( option ); 8112 if ( value != null && value.length ) { 8113 options[ option ] = value; 8114 } 8115 } ); 8116 8117 return options; 8118 }, 8119 8120 _events: { 8121 keydown: function( event ) { 8122 if ( this._start( event ) && this._keydown( event ) ) { 8123 event.preventDefault(); 8124 } 8125 }, 8126 keyup: "_stop", 8127 focus: function() { 8128 this.previous = this.element.val(); 8129 }, 8130 blur: function( event ) { 8131 if ( this.cancelBlur ) { 8132 delete this.cancelBlur; 8133 return; 8134 } 8135 8136 this._stop(); 8137 this._refresh(); 8138 if ( this.previous !== this.element.val() ) { 8139 this._trigger( "change", event ); 8140 } 8141 }, 8142 mousewheel: function( event, delta ) { 8143 if ( !delta ) { 8144 return; 8145 } 8146 if ( !this.spinning && !this._start( event ) ) { 8147 return false; 8148 } 8149 8150 this._spin( ( delta > 0 ? 1 : -1 ) * this.options.step, event ); 8151 clearTimeout( this.mousewheelTimer ); 8152 this.mousewheelTimer = this._delay( function() { 8153 if ( this.spinning ) { 8154 this._stop( event ); 8155 } 8156 }, 100 ); 8157 event.preventDefault(); 8158 }, 8159 "mousedown .ui-spinner-button": function( event ) { 8160 var previous; 8161 8162 // We never want the buttons to have focus; whenever the user is 8163 // interacting with the spinner, the focus should be on the input. 8164 // If the input is focused then this.previous is properly set from 8165 // when the input first received focus. If the input is not focused 8166 // then we need to set this.previous based on the value before spinning. 8167 previous = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] ) ? 8168 this.previous : this.element.val(); 8169 function checkFocus() { 8170 var isActive = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] ); 8171 if ( !isActive ) { 8172 this.element.trigger( "focus" ); 8173 this.previous = previous; 8174 8175 // support: IE 8176 // IE sets focus asynchronously, so we need to check if focus 8177 // moved off of the input because the user clicked on the button. 8178 this._delay( function() { 8179 this.previous = previous; 8180 } ); 8181 } 8182 } 8183 8184 // Ensure focus is on (or stays on) the text field 8185 event.preventDefault(); 8186 checkFocus.call( this ); 8187 8188 // Support: IE 8189 // IE doesn't prevent moving focus even with event.preventDefault() 8190 // so we set a flag to know when we should ignore the blur event 8191 // and check (again) if focus moved off of the input. 8192 this.cancelBlur = true; 8193 this._delay( function() { 8194 delete this.cancelBlur; 8195 checkFocus.call( this ); 8196 } ); 8197 8198 if ( this._start( event ) === false ) { 8199 return; 8200 } 8201 8202 this._repeat( null, $( event.currentTarget ) 8203 .hasClass( "ui-spinner-up" ) ? 1 : -1, event ); 8204 }, 8205 "mouseup .ui-spinner-button": "_stop", 8206 "mouseenter .ui-spinner-button": function( event ) { 8207 8208 // button will add ui-state-active if mouse was down while mouseleave and kept down 8209 if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) { 8210 return; 8211 } 8212 8213 if ( this._start( event ) === false ) { 8214 return false; 8215 } 8216 this._repeat( null, $( event.currentTarget ) 8217 .hasClass( "ui-spinner-up" ) ? 1 : -1, event ); 8218 }, 8219 8220 // TODO: do we really want to consider this a stop? 8221 // shouldn't we just stop the repeater and wait until mouseup before 8222 // we trigger the stop event? 8223 "mouseleave .ui-spinner-button": "_stop" 8224 }, 8225 8226 // Support mobile enhanced option and make backcompat more sane 8227 _enhance: function() { 8228 this.uiSpinner = this.element 8229 .attr( "autocomplete", "off" ) 8230 .wrap( "<span>" ) 8231 .parent() 8232 8233 // Add buttons 8234 .append( 8235 "<a></a><a></a>" 8236 ); 8237 }, 8238 8239 _draw: function() { 8240 this._enhance(); 8241 8242 this._addClass( this.uiSpinner, "ui-spinner", "ui-widget ui-widget-content" ); 8243 this._addClass( "ui-spinner-input" ); 8244 8245 this.element.attr( "role", "spinbutton" ); 8246 8247 // Button bindings 8248 this.buttons = this.uiSpinner.children( "a" ) 8249 .attr( "tabIndex", -1 ) 8250 .attr( "aria-hidden", true ) 8251 .button( { 8252 classes: { 8253 "ui-button": "" 8254 } 8255 } ); 8256 8257 // TODO: Right now button does not support classes this is already updated in button PR 8258 this._removeClass( this.buttons, "ui-corner-all" ); 8259 8260 this._addClass( this.buttons.first(), "ui-spinner-button ui-spinner-up" ); 8261 this._addClass( this.buttons.last(), "ui-spinner-button ui-spinner-down" ); 8262 this.buttons.first().button( { 8263 "icon": this.options.icons.up, 8264 "showLabel": false 8265 } ); 8266 this.buttons.last().button( { 8267 "icon": this.options.icons.down, 8268 "showLabel": false 8269 } ); 8270 8271 // IE 6 doesn't understand height: 50% for the buttons 8272 // unless the wrapper has an explicit height 8273 if ( this.buttons.height() > Math.ceil( this.uiSpinner.height() * 0.5 ) && 8274 this.uiSpinner.height() > 0 ) { 8275 this.uiSpinner.height( this.uiSpinner.height() ); 8276 } 8277 }, 8278 8279 _keydown: function( event ) { 8280 var options = this.options, 8281 keyCode = $.ui.keyCode; 8282 8283 switch ( event.keyCode ) { 8284 case keyCode.UP: 8285 this._repeat( null, 1, event ); 8286 return true; 8287 case keyCode.DOWN: 8288 this._repeat( null, -1, event ); 8289 return true; 8290 case keyCode.PAGE_UP: 8291 this._repeat( null, options.page, event ); 8292 return true; 8293 case keyCode.PAGE_DOWN: 8294 this._repeat( null, -options.page, event ); 8295 return true; 8296 } 8297 8298 return false; 8299 }, 8300 8301 _start: function( event ) { 8302 if ( !this.spinning && this._trigger( "start", event ) === false ) { 8303 return false; 8304 } 8305 8306 if ( !this.counter ) { 8307 this.counter = 1; 8308 } 8309 this.spinning = true; 8310 return true; 8311 }, 8312 8313 _repeat: function( i, steps, event ) { 8314 i = i || 500; 8315 8316 clearTimeout( this.timer ); 8317 this.timer = this._delay( function() { 8318 this._repeat( 40, steps, event ); 8319 }, i ); 8320 8321 this._spin( steps * this.options.step, event ); 8322 }, 8323 8324 _spin: function( step, event ) { 8325 var value = this.value() || 0; 8326 8327 if ( !this.counter ) { 8328 this.counter = 1; 8329 } 8330 8331 value = this._adjustValue( value + step * this._increment( this.counter ) ); 8332 8333 if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false ) { 8334 this._value( value ); 8335 this.counter++; 8336 } 8337 }, 8338 8339 _increment: function( i ) { 8340 var incremental = this.options.incremental; 8341 8342 if ( incremental ) { 8343 return $.isFunction( incremental ) ? 8344 incremental( i ) : 8345 Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 ); 8346 } 8347 8348 return 1; 8349 }, 8350 8351 _precision: function() { 8352 var precision = this._precisionOf( this.options.step ); 8353 if ( this.options.min !== null ) { 8354 precision = Math.max( precision, this._precisionOf( this.options.min ) ); 8355 } 8356 return precision; 8357 }, 8358 8359 _precisionOf: function( num ) { 8360 var str = num.toString(), 8361 decimal = str.indexOf( "." ); 8362 return decimal === -1 ? 0 : str.length - decimal - 1; 8363 }, 8364 8365 _adjustValue: function( value ) { 8366 var base, aboveMin, 8367 options = this.options; 8368 8369 // Make sure we're at a valid step 8370 // - find out where we are relative to the base (min or 0) 8371 base = options.min !== null ? options.min : 0; 8372 aboveMin = value - base; 8373 8374 // - round to the nearest step 8375 aboveMin = Math.round( aboveMin / options.step ) * options.step; 8376 8377 // - rounding is based on 0, so adjust back to our base 8378 value = base + aboveMin; 8379 8380 // Fix precision from bad JS floating point math 8381 value = parseFloat( value.toFixed( this._precision() ) ); 8382 8383 // Clamp the value 8384 if ( options.max !== null && value > options.max ) { 8385 return options.max; 8386 } 8387 if ( options.min !== null && value < options.min ) { 8388 return options.min; 8389 } 8390 8391 return value; 8392 }, 8393 8394 _stop: function( event ) { 8395 if ( !this.spinning ) { 8396 return; 8397 } 8398 8399 clearTimeout( this.timer ); 8400 clearTimeout( this.mousewheelTimer ); 8401 this.counter = 0; 8402 this.spinning = false; 8403 this._trigger( "stop", event ); 8404 }, 8405 8406 _setOption: function( key, value ) { 8407 var prevValue, first, last; 8408 8409 if ( key === "culture" || key === "numberFormat" ) { 8410 prevValue = this._parse( this.element.val() ); 8411 this.options[ key ] = value; 8412 this.element.val( this._format( prevValue ) ); 8413 return; 8414 } 8415 8416 if ( key === "max" || key === "min" || key === "step" ) { 8417 if ( typeof value === "string" ) { 8418 value = this._parse( value ); 8419 } 8420 } 8421 if ( key === "icons" ) { 8422 first = this.buttons.first().find( ".ui-icon" ); 8423 this._removeClass( first, null, this.options.icons.up ); 8424 this._addClass( first, null, value.up ); 8425 last = this.buttons.last().find( ".ui-icon" ); 8426 this._removeClass( last, null, this.options.icons.down ); 8427 this._addClass( last, null, value.down ); 8428 } 8429 8430 this._super( key, value ); 8431 }, 8432 8433 _setOptionDisabled: function( value ) { 8434 this._super( value ); 8435 8436 this._toggleClass( this.uiSpinner, null, "ui-state-disabled", !!value ); 8437 this.element.prop( "disabled", !!value ); 8438 this.buttons.button( value ? "disable" : "enable" ); 8439 }, 8440 8441 _setOptions: spinnerModifer( function( options ) { 8442 this._super( options ); 8443 } ), 8444 8445 _parse: function( val ) { 8446 if ( typeof val === "string" && val !== "" ) { 8447 val = window.Globalize && this.options.numberFormat ? 8448 Globalize.parseFloat( val, 10, this.options.culture ) : +val; 8449 } 8450 return val === "" || isNaN( val ) ? null : val; 8451 }, 8452 8453 _format: function( value ) { 8454 if ( value === "" ) { 8455 return ""; 8456 } 8457 return window.Globalize && this.options.numberFormat ? 8458 Globalize.format( value, this.options.numberFormat, this.options.culture ) : 8459 value; 8460 }, 8461 8462 _refresh: function() { 8463 this.element.attr( { 8464 "aria-valuemin": this.options.min, 8465 "aria-valuemax": this.options.max, 8466 8467 // TODO: what should we do with values that can't be parsed? 8468 "aria-valuenow": this._parse( this.element.val() ) 8469 } ); 8470 }, 8471 8472 isValid: function() { 8473 var value = this.value(); 8474 8475 // Null is invalid 8476 if ( value === null ) { 8477 return false; 8478 } 8479 8480 // If value gets adjusted, it's invalid 8481 return value === this._adjustValue( value ); 8482 }, 8483 8484 // Update the value without triggering change 8485 _value: function( value, allowAny ) { 8486 var parsed; 8487 if ( value !== "" ) { 8488 parsed = this._parse( value ); 8489 if ( parsed !== null ) { 8490 if ( !allowAny ) { 8491 parsed = this._adjustValue( parsed ); 8492 } 8493 value = this._format( parsed ); 8494 } 8495 } 8496 this.element.val( value ); 8497 this._refresh(); 8498 }, 8499 8500 _destroy: function() { 8501 this.element 8502 .prop( "disabled", false ) 8503 .removeAttr( "autocomplete role aria-valuemin aria-valuemax aria-valuenow" ); 8504 8505 this.uiSpinner.replaceWith( this.element ); 8506 }, 8507 8508 stepUp: spinnerModifer( function( steps ) { 8509 this._stepUp( steps ); 8510 } ), 8511 _stepUp: function( steps ) { 8512 if ( this._start() ) { 8513 this._spin( ( steps || 1 ) * this.options.step ); 8514 this._stop(); 8515 } 8516 }, 8517 8518 stepDown: spinnerModifer( function( steps ) { 8519 this._stepDown( steps ); 8520 } ), 8521 _stepDown: function( steps ) { 8522 if ( this._start() ) { 8523 this._spin( ( steps || 1 ) * -this.options.step ); 8524 this._stop(); 8525 } 8526 }, 8527 8528 pageUp: spinnerModifer( function( pages ) { 8529 this._stepUp( ( pages || 1 ) * this.options.page ); 8530 } ), 8531 8532 pageDown: spinnerModifer( function( pages ) { 8533 this._stepDown( ( pages || 1 ) * this.options.page ); 8534 } ), 8535 8536 value: function( newVal ) { 8537 if ( !arguments.length ) { 8538 return this._parse( this.element.val() ); 8539 } 8540 spinnerModifer( this._value ).call( this, newVal ); 8541 }, 8542 8543 widget: function() { 8544 return this.uiSpinner; 8545 } 8546} ); 8547 8548// DEPRECATED 8549// TODO: switch return back to widget declaration at top of file when this is removed 8550if ( $.uiBackCompat !== false ) { 8551 8552 // Backcompat for spinner html extension points 8553 $.widget( "ui.spinner", $.ui.spinner, { 8554 _enhance: function() { 8555 this.uiSpinner = this.element 8556 .attr( "autocomplete", "off" ) 8557 .wrap( this._uiSpinnerHtml() ) 8558 .parent() 8559 8560 // Add buttons 8561 .append( this._buttonHtml() ); 8562 }, 8563 _uiSpinnerHtml: function() { 8564 return "<span>"; 8565 }, 8566 8567 _buttonHtml: function() { 8568 return "<a></a><a></a>"; 8569 } 8570 } ); 8571} 8572 8573var widgetsSpinner = $.ui.spinner; 8574 8575
8576 8577 8578}));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.