Ignore:
Timestamp:
Oct 28, 2011, 3:25:54 PM (12 years ago)
Author:
patdenice
Message:

feature:2487
Update jQuery to 1.6.4 and jQuery UI to 1.8.16

File:
1 edited

Legend:

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

    r9559 r12525  
    11/*
    2  * jQuery UI Draggable 1.8.10
     2 * jQuery UI Draggable 1.8.16
    33 *
    44 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
     
    8080                if (!this.handle)
    8181                        return false;
     82               
     83                if ( o.iframeFix ) {
     84                        $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
     85                                $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>')
     86                                .css({
     87                                        width: this.offsetWidth+"px", height: this.offsetHeight+"px",
     88                                        position: "absolute", opacity: "0.001", zIndex: 1000
     89                                })
     90                                .css($(this).offset())
     91                                .appendTo("body");
     92                        });
     93                }
    8294
    8395                return true;
     
    154166                this.helper.addClass("ui-draggable-dragging");
    155167                this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
     168               
     169                //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
     170                if ( $.ui.ddmanager ) $.ui.ddmanager.dragStart(this, event);
     171               
    156172                return true;
    157173        },
     
    213229        },
    214230       
     231        _mouseUp: function(event) {
     232                if (this.options.iframeFix === true) {
     233                        $("div.ui-draggable-iframeFix").each(function() {
     234                                this.parentNode.removeChild(this);
     235                        }); //Remove frame helpers
     236                }
     237               
     238                //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
     239                if( $.ui.ddmanager ) $.ui.ddmanager.dragStop(this, event);
     240               
     241                return $.ui.mouse.prototype._mouseUp.call(this, event);
     242        },
     243       
    215244        cancel: function() {
    216245               
     
    242271
    243272                var o = this.options;
    244                 var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone() : this.element);
     273                var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone().removeAttr('id') : this.element);
    245274
    246275                if(!helper.parents('body').length)
     
    318347                this.margins = {
    319348                        left: (parseInt(this.element.css("marginLeft"),10) || 0),
    320                         top: (parseInt(this.element.css("marginTop"),10) || 0)
     349                        top: (parseInt(this.element.css("marginTop"),10) || 0),
     350                        right: (parseInt(this.element.css("marginRight"),10) || 0),
     351                        bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
    321352                };
    322353        },
     
    334365                if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
    335366                if(o.containment == 'document' || o.containment == 'window') this.containment = [
    336                         (o.containment == 'document' ? 0 : $(window).scrollLeft()) - this.offset.relative.left - this.offset.parent.left,
    337                         (o.containment == 'document' ? 0 : $(window).scrollTop()) - this.offset.relative.top - this.offset.parent.top,
     367                        o.containment == 'document' ? 0 : $(window).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
     368                        o.containment == 'document' ? 0 : $(window).scrollTop() - this.offset.relative.top - this.offset.parent.top,
    338369                        (o.containment == 'document' ? 0 : $(window).scrollLeft()) + $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
    339370                        (o.containment == 'document' ? 0 : $(window).scrollTop()) + ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
     
    341372
    342373                if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) {
    343                         var ce = $(o.containment)[0]; if(!ce) return;
    344                         var co = $(o.containment).offset();
     374                        var c = $(o.containment);
     375                        var ce = c[0]; if(!ce) return;
     376                        var co = c.offset();
    345377                        var over = ($(ce).css("overflow") != 'hidden');
    346378
    347379                        this.containment = [
    348                                 co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
    349                                 co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
    350                                 co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
    351                                 co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
     380                                (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0),
     381                                (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0),
     382                                (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,
     383                                (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
    352384                        ];
     385                        this.relative_container = c;
     386
    353387                } else if(o.containment.constructor == Array) {
    354388                        this.containment = o.containment;
     
    392426
    393427                if(this.originalPosition) { //If we are not dragging yet, we won't check for options
    394 
    395                         if(this.containment) {
    396                                 if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left;
    397                                 if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top;
    398                                 if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left;
    399                                 if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top;
     428                         var containment;
     429                         if(this.containment) {
     430                                 if (this.relative_container){
     431                                     var co = this.relative_container.offset();
     432                                     containment = [ this.containment[0] + co.left,
     433                                                     this.containment[1] + co.top,
     434                                                     this.containment[2] + co.left,
     435                                                     this.containment[3] + co.top ];
     436                                 }
     437                                 else {
     438                                     containment = this.containment;
     439                                 }
     440
     441                                if(event.pageX - this.offset.click.left < containment[0]) pageX = containment[0] + this.offset.click.left;
     442                                if(event.pageY - this.offset.click.top < containment[1]) pageY = containment[1] + this.offset.click.top;
     443                                if(event.pageX - this.offset.click.left > containment[2]) pageX = containment[2] + this.offset.click.left;
     444                                if(event.pageY - this.offset.click.top > containment[3]) pageY = containment[3] + this.offset.click.top;
    400445                        }
    401446
    402447                        if(o.grid) {
    403                                 var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
    404                                 pageY = this.containment ? (!(top - this.offset.click.top < this.containment[1] || top - this.offset.click.top > this.containment[3]) ? top : (!(top - this.offset.click.top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
    405 
    406                                 var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
    407                                 pageX = this.containment ? (!(left - this.offset.click.left < this.containment[0] || left - this.offset.click.left > this.containment[2]) ? left : (!(left - this.offset.click.left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
     448                                //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
     449                                var top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
     450                                pageY = containment ? (!(top - this.offset.click.top < containment[1] || top - this.offset.click.top > containment[3]) ? top : (!(top - this.offset.click.top < containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
     451
     452                                var left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
     453                                pageX = containment ? (!(left - this.offset.click.left < containment[0] || left - this.offset.click.left > containment[2]) ? left : (!(left - this.offset.click.left < containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
    408454                        }
    409455
     
    460506
    461507$.extend($.ui.draggable, {
    462         version: "1.8.10"
     508        version: "1.8.16"
    463509});
    464510
     
    476522                                        shouldRevert: sortable.options.revert
    477523                                });
    478                                 sortable._refreshItems();       //Do a one-time refresh at start to refresh the containerCache
     524                                sortable.refreshPositions();    // Call the sortable's refreshPositions at drag start to refresh the containerCache since the sortable container cache is used in drag and needs to be up to date (this will ensure it's initialised as well as being kept in step with any changes that might have happened on the page).
    479525                                sortable._trigger("activate", event, uiSortable);
    480526                        }
     
    545591                                        //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
    546592                                        //We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one)
    547                                         this.instance.currentItem = $(self).clone().appendTo(this.instance.element).data("sortable-item", true);
     593                                        this.instance.currentItem = $(self).clone().removeAttr('id').appendTo(this.instance.element).data("sortable-item", true);
    548594                                        this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
    549595                                        this.instance.options.helper = function() { return ui.helper[0]; };
     
    615661});
    616662
    617 $.ui.plugin.add("draggable", "iframeFix", {
    618         start: function(event, ui) {
    619                 var o = $(this).data('draggable').options;
    620                 $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
    621                         $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>')
    622                         .css({
    623                                 width: this.offsetWidth+"px", height: this.offsetHeight+"px",
    624                                 position: "absolute", opacity: "0.001", zIndex: 1000
    625                         })
    626                         .css($(this).offset())
    627                         .appendTo("body");
    628                 });
    629         },
    630         stop: function(event, ui) {
    631                 $("div.ui-draggable-iframeFix").each(function() { this.parentNode.removeChild(this); }); //Remove frame helpers
    632         }
    633 });
    634 
    635663$.ui.plugin.add("draggable", "opacity", {
    636664        start: function(event, ui) {
Note: See TracChangeset for help on using the changeset viewer.