Changeset 12525 for trunk/themes/default/js/ui/jquery.ui.draggable.js
- Timestamp:
- Oct 28, 2011, 3:25:54 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/themes/default/js/ui/jquery.ui.draggable.js
r9559 r12525 1 1 /* 2 * jQuery UI Draggable 1.8.1 02 * jQuery UI Draggable 1.8.16 3 3 * 4 4 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) … … 80 80 if (!this.handle) 81 81 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 } 82 94 83 95 return true; … … 154 166 this.helper.addClass("ui-draggable-dragging"); 155 167 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 156 172 return true; 157 173 }, … … 213 229 }, 214 230 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 215 244 cancel: function() { 216 245 … … 242 271 243 272 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); 245 274 246 275 if(!helper.parents('body').length) … … 318 347 this.margins = { 319 348 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) 321 352 }; 322 353 }, … … 334 365 if(o.containment == 'parent') o.containment = this.helper[0].parentNode; 335 366 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, 338 369 (o.containment == 'document' ? 0 : $(window).scrollLeft()) + $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left, 339 370 (o.containment == 'document' ? 0 : $(window).scrollTop()) + ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top … … 341 372 342 373 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(); 345 377 var over = ($(ce).css("overflow") != 'hidden'); 346 378 347 379 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.top380 (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 352 384 ]; 385 this.relative_container = c; 386 353 387 } else if(o.containment.constructor == Array) { 354 388 this.containment = o.containment; … … 392 426 393 427 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; 400 445 } 401 446 402 447 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; 408 454 } 409 455 … … 460 506 461 507 $.extend($.ui.draggable, { 462 version: "1.8.1 0"508 version: "1.8.16" 463 509 }); 464 510 … … 476 522 shouldRevert: sortable.options.revert 477 523 }); 478 sortable. _refreshItems(); //Do a one-time refresh at start to refresh the containerCache524 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). 479 525 sortable._trigger("activate", event, uiSortable); 480 526 } … … 545 591 //by cloning the list group item, appending it to the sortable and using it as inst.currentItem 546 592 //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); 548 594 this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it 549 595 this.instance.options.helper = function() { return ui.helper[0]; }; … … 615 661 }); 616 662 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: 1000625 })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 helpers632 }633 });634 635 663 $.ui.plugin.add("draggable", "opacity", { 636 664 start: function(event, ui) {
Note: See TracChangeset
for help on using the changeset viewer.