Ignore:
Timestamp:
Jun 24, 2014, 10:16:59 PM (10 years ago)
Author:
rvelices
Message:

upgrade jquery ui from 1.10.1 to 1.10.4

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/themes/default/js/ui/jquery.ui.draggable.js

    r20824 r28780  
    11/*!
    2  * jQuery UI Draggable 1.10.1
     2 * jQuery UI Draggable 1.10.4
    33 * http://jqueryui.com
    44 *
    5  * Copyright 2013 jQuery Foundation and other contributors
     5 * Copyright 2014 jQuery Foundation and other contributors
    66 * Released under the MIT license.
    77 * http://jquery.org/license
     
    1717
    1818$.widget("ui.draggable", $.ui.mouse, {
    19         version: "1.10.1",
     19        version: "1.10.4",
    2020        widgetEventPrefix: "drag",
    2121        options: {
     
    126126
    127127                //Store the helper's css position
    128                 this.cssPosition = this.helper.css("position");
     128                this.cssPosition = this.helper.css( "position" );
    129129                this.scrollParent = this.helper.scrollParent();
     130                this.offsetParent = this.helper.offsetParent();
     131                this.offsetParentCssPosition = this.offsetParent.css( "position" );
    130132
    131133                //The element's absolute position on the page minus margins
     
    135137                        left: this.offset.left - this.margins.left
    136138                };
     139
     140                //Reset scroll cache
     141                this.offset.scroll = false;
    137142
    138143                $.extend(this.offset, {
     
    154159
    155160                //Set a containment if given in the options
    156                 if(o.containment) {
    157                         this._setContainment();
    158                 }
     161                this._setContainment();
    159162
    160163                //Trigger event + callbacks
     
    184187
    185188        _mouseDrag: function(event, noPropagation) {
     189                // reset any necessary cached properties (see #5009)
     190                if ( this.offsetParentCssPosition === "fixed" ) {
     191                        this.offset.parent = this._getParentOffset();
     192                }
    186193
    187194                //Compute the helpers position
     
    215222
    216223                //If we are using droppables, inform the manager about the drop
    217                 var element,
    218                         that = this,
    219                         elementInDom = false,
     224                var that = this,
    220225                        dropped = false;
    221226                if ($.ui.ddmanager && !this.options.dropBehaviour) {
     
    230235
    231236                //if the original element is no longer in the DOM don't bother to continue (see #8269)
    232                 element = this.element[0];
    233                 while ( element && (element = element.parentNode) ) {
    234                         if (element === document ) {
    235                                 elementInDom = true;
    236                         }
    237                 }
    238                 if ( !elementInDom && this.options.helper === "original" ) {
     237                if ( this.options.helper === "original" && !$.contains( this.element[ 0 ].ownerDocument, this.element[ 0 ] ) ) {
    239238                        return false;
    240239                }
     
    282281
    283282        _getHandle: function(event) {
    284 
    285                 var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
    286                 $(this.options.handle, this.element)
    287                         .find("*")
    288                         .addBack()
    289                         .each(function() {
    290                                 if(this === event.target) {
    291                                         handle = true;
    292                                 }
    293                         });
    294 
    295                 return handle;
    296 
     283                return this.options.handle ?
     284                        !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
     285                        true;
    297286        },
    298287
     
    338327
    339328                //Get the offsetParent and cache its position
    340                 this.offsetParent = this.helper.offsetParent();
    341329                var po = this.offsetParent.offset();
    342330
     
    399387                        o = this.options;
    400388
    401                 if(o.containment === "parent") {
    402                         o.containment = this.helper[0].parentNode;
    403                 }
    404                 if(o.containment === "document" || o.containment === "window") {
     389                if ( !o.containment ) {
     390                        this.containment = null;
     391                        return;
     392                }
     393
     394                if ( o.containment === "window" ) {
    405395                        this.containment = [
    406                                 o.containment === "document" ? 0 : $(window).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
    407                                 o.containment === "document" ? 0 : $(window).scrollTop() - this.offset.relative.top - this.offset.parent.top,
    408                                 (o.containment === "document" ? 0 : $(window).scrollLeft()) + $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
    409                                 (o.containment === "document" ? 0 : $(window).scrollTop()) + ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
     396                                $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
     397                                $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
     398                                $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left,
     399                                $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
    410400                        ];
    411                 }
    412 
    413                 if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor !== Array) {
    414                         c = $(o.containment);
    415                         ce = c[0];
    416 
    417                         if(!ce) {
    418                                 return;
    419                         }
    420 
    421                         over = ($(ce).css("overflow") !== "hidden");
    422 
     401                        return;
     402                }
     403
     404                if ( o.containment === "document") {
    423405                        this.containment = [
    424                                 (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0),
    425                                 (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0),
    426                                 (over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left - this.margins.right,
    427                                 (over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top  - this.margins.bottom
     406                                0,
     407                                0,
     408                                $( document ).width() - this.helperProportions.width - this.margins.left,
     409                                ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
    428410                        ];
    429                         this.relative_container = c;
    430 
    431                 } else if(o.containment.constructor === Array) {
     411                        return;
     412                }
     413
     414                if ( o.containment.constructor === Array ) {
    432415                        this.containment = o.containment;
    433                 }
    434 
     416                        return;
     417                }
     418
     419                if ( o.containment === "parent" ) {
     420                        o.containment = this.helper[ 0 ].parentNode;
     421                }
     422
     423                c = $( o.containment );
     424                ce = c[ 0 ];
     425
     426                if( !ce ) {
     427                        return;
     428                }
     429
     430                over = c.css( "overflow" ) !== "hidden";
     431
     432                this.containment = [
     433                        ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
     434                        ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ) ,
     435                        ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) - this.helperProportions.width - this.margins.left - this.margins.right,
     436                        ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) - this.helperProportions.height - this.margins.top  - this.margins.bottom
     437                ];
     438                this.relative_container = c;
    435439        },
    436440
     
    442446
    443447                var mod = d === "absolute" ? 1 : -1,
    444                         scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
     448                        scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent;
     449
     450                //Cache the scroll
     451                if (!this.offset.scroll) {
     452                        this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
     453                }
    445454
    446455                return {
     
    449458                                this.offset.relative.top * mod +                                                                                // Only for relative positioned nodes: Relative offset from element to offset parent
    450459                                this.offset.parent.top * mod -                                                                          // The offsetParent's offset without borders (offset + border)
    451                                 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
     460                                ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top ) * mod )
    452461                        ),
    453462                        left: (
     
    455464                                this.offset.relative.left * mod +                                                                               // Only for relative positioned nodes: Relative offset from element to offset parent
    456465                                this.offset.parent.left * mod   -                                                                               // The offsetParent's offset without borders (offset + border)
    457                                 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
     466                                ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left ) * mod )
    458467                        )
    459468                };
     
    465474                var containment, co, top, left,
    466475                        o = this.options,
    467                         scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
    468                         scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName),
     476                        scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent,
    469477                        pageX = event.pageX,
    470478                        pageY = event.pageY;
     479
     480                //Cache the scroll
     481                if (!this.offset.scroll) {
     482                        this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
     483                }
    471484
    472485                /*
     
    475488                 */
    476489
    477                 if(this.originalPosition) { //If we are not dragging yet, we won't check for options
    478                         if(this.containment) {
    479                         if (this.relative_container){
    480                                 co = this.relative_container.offset();
    481                                 containment = [ this.containment[0] + co.left,
    482                                         this.containment[1] + co.top,
    483                                         this.containment[2] + co.left,
    484                                         this.containment[3] + co.top ];
    485                         }
    486                         else {
    487                                 containment = this.containment;
    488                         }
     490                // If we are not dragging yet, we won't check for options
     491                if ( this.originalPosition ) {
     492                        if ( this.containment ) {
     493                                if ( this.relative_container ){
     494                                        co = this.relative_container.offset();
     495                                        containment = [
     496                                                this.containment[ 0 ] + co.left,
     497                                                this.containment[ 1 ] + co.top,
     498                                                this.containment[ 2 ] + co.left,
     499                                                this.containment[ 3 ] + co.top
     500                                        ];
     501                                }
     502                                else {
     503                                        containment = this.containment;
     504                                }
    489505
    490506                                if(event.pageX - this.offset.click.left < containment[0]) {
     
    519535                                this.offset.relative.top -                                                                                              // Only for relative positioned nodes: Relative offset from element to offset parent
    520536                                this.offset.parent.top +                                                                                                // The offsetParent's offset without borders (offset + border)
    521                                 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
     537                                ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top )
    522538                        ),
    523539                        left: (
     
    526542                                this.offset.relative.left -                                                                                             // Only for relative positioned nodes: Relative offset from element to offset parent
    527543                                this.offset.parent.left +                                                                                               // The offsetParent's offset without borders (offset + border)
    528                                 ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
     544                                ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left )
    529545                        )
    530546                };
     
    601617                                //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid"
    602618                                if(this.shouldRevert) {
    603                                         this.instance.options.revert = true;
     619                                        this.instance.options.revert = this.shouldRevert;
    604620                                }
    605621
     
    848864                        b = t + inst.snapElements[i].height;
    849865
    850                         //Yes, I know, this is insane ;)
    851                         if(!((l-d < x1 && x1 < r+d && t-d < y1 && y1 < b+d) || (l-d < x1 && x1 < r+d && t-d < y2 && y2 < b+d) || (l-d < x2 && x2 < r+d && t-d < y1 && y1 < b+d) || (l-d < x2 && x2 < r+d && t-d < y2 && y2 < b+d))) {
     866                        if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
    852867                                if(inst.snapElements[i].snapping) {
    853868                                        (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
Note: See TracChangeset for help on using the changeset viewer.