jquery-ui-rails 4.0.2 → 4.0.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of jquery-ui-rails might be problematic. Click here for more details.

Files changed (70) hide show
  1. data/History.md +6 -2
  2. data/README.md +4 -0
  3. data/app/assets/images/jquery-ui/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  4. data/app/assets/images/jquery-ui/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  5. data/app/assets/images/jquery-ui/ui-bg_glass_65_ffffff_1x400.png +0 -0
  6. data/app/assets/images/jquery-ui/ui-bg_glass_75_dadada_1x400.png +0 -0
  7. data/app/assets/images/jquery-ui/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  8. data/app/assets/images/jquery-ui/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  9. data/app/assets/images/jquery-ui/ui-icons_222222_256x240.png +0 -0
  10. data/app/assets/images/jquery-ui/ui-icons_2e83ff_256x240.png +0 -0
  11. data/app/assets/images/jquery-ui/ui-icons_454545_256x240.png +0 -0
  12. data/app/assets/images/jquery-ui/ui-icons_888888_256x240.png +0 -0
  13. data/app/assets/images/jquery-ui/ui-icons_cd0a0a_256x240.png +0 -0
  14. data/app/assets/javascripts/jquery.ui.accordion.js +6 -5
  15. data/app/assets/javascripts/jquery.ui.autocomplete.js +26 -30
  16. data/app/assets/javascripts/jquery.ui.button.js +5 -5
  17. data/app/assets/javascripts/jquery.ui.core.js +19 -23
  18. data/app/assets/javascripts/jquery.ui.datepicker-de.js +3 -3
  19. data/app/assets/javascripts/jquery.ui.datepicker-sk.js +3 -3
  20. data/app/assets/javascripts/jquery.ui.datepicker-sr-SR.js +1 -1
  21. data/app/assets/javascripts/jquery.ui.datepicker-sr.js +1 -1
  22. data/app/assets/javascripts/jquery.ui.datepicker.js +27 -33
  23. data/app/assets/javascripts/jquery.ui.dialog.js +61 -20
  24. data/app/assets/javascripts/jquery.ui.draggable.js +95 -83
  25. data/app/assets/javascripts/jquery.ui.droppable.js +4 -3
  26. data/app/assets/javascripts/jquery.ui.effect-blind.js +1 -1
  27. data/app/assets/javascripts/jquery.ui.effect-bounce.js +1 -1
  28. data/app/assets/javascripts/jquery.ui.effect-clip.js +1 -1
  29. data/app/assets/javascripts/jquery.ui.effect-drop.js +1 -1
  30. data/app/assets/javascripts/jquery.ui.effect-explode.js +1 -1
  31. data/app/assets/javascripts/jquery.ui.effect-fade.js +1 -1
  32. data/app/assets/javascripts/jquery.ui.effect-fold.js +1 -1
  33. data/app/assets/javascripts/jquery.ui.effect-highlight.js +1 -1
  34. data/app/assets/javascripts/jquery.ui.effect-pulsate.js +1 -1
  35. data/app/assets/javascripts/jquery.ui.effect-scale.js +1 -1
  36. data/app/assets/javascripts/jquery.ui.effect-shake.js +1 -1
  37. data/app/assets/javascripts/jquery.ui.effect-slide.js +1 -1
  38. data/app/assets/javascripts/jquery.ui.effect-transfer.js +1 -1
  39. data/app/assets/javascripts/jquery.ui.effect.js +93 -72
  40. data/app/assets/javascripts/jquery.ui.menu.js +3 -3
  41. data/app/assets/javascripts/jquery.ui.mouse.js +2 -2
  42. data/app/assets/javascripts/jquery.ui.position.js +6 -6
  43. data/app/assets/javascripts/jquery.ui.progressbar.js +2 -2
  44. data/app/assets/javascripts/jquery.ui.resizable.js +2 -2
  45. data/app/assets/javascripts/jquery.ui.selectable.js +2 -2
  46. data/app/assets/javascripts/jquery.ui.slider.js +89 -66
  47. data/app/assets/javascripts/jquery.ui.sortable.js +65 -30
  48. data/app/assets/javascripts/jquery.ui.spinner.js +3 -2
  49. data/app/assets/javascripts/jquery.ui.tabs.js +2 -2
  50. data/app/assets/javascripts/jquery.ui.tooltip.js +2 -2
  51. data/app/assets/javascripts/jquery.ui.widget.js +1 -1
  52. data/app/assets/stylesheets/jquery.ui.accordion.css.erb +1 -1
  53. data/app/assets/stylesheets/jquery.ui.all.css.erb +1 -1
  54. data/app/assets/stylesheets/jquery.ui.autocomplete.css.erb +1 -1
  55. data/app/assets/stylesheets/jquery.ui.base.css.erb +1 -1
  56. data/app/assets/stylesheets/jquery.ui.button.css.erb +1 -1
  57. data/app/assets/stylesheets/jquery.ui.core.css.erb +2 -1
  58. data/app/assets/stylesheets/jquery.ui.datepicker.css.erb +1 -1
  59. data/app/assets/stylesheets/jquery.ui.dialog.css.erb +1 -1
  60. data/app/assets/stylesheets/jquery.ui.menu.css.erb +3 -1
  61. data/app/assets/stylesheets/jquery.ui.progressbar.css.erb +1 -1
  62. data/app/assets/stylesheets/jquery.ui.resizable.css.erb +1 -1
  63. data/app/assets/stylesheets/jquery.ui.selectable.css.erb +1 -1
  64. data/app/assets/stylesheets/jquery.ui.slider.css.erb +1 -1
  65. data/app/assets/stylesheets/jquery.ui.spinner.css.erb +1 -1
  66. data/app/assets/stylesheets/jquery.ui.tabs.css.erb +2 -2
  67. data/app/assets/stylesheets/jquery.ui.theme.css.erb +2 -2
  68. data/app/assets/stylesheets/jquery.ui.tooltip.css.erb +1 -1
  69. data/lib/jquery/ui/rails/version.rb +1 -1
  70. metadata +3 -3
@@ -6,7 +6,7 @@
6
6
  //= require jquery.ui.resizable
7
7
 
8
8
  /*!
9
- * jQuery UI Dialog 1.10.0
9
+ * jQuery UI Dialog 1.10.3
10
10
  * http://jqueryui.com
11
11
  *
12
12
  * Copyright 2013 jQuery Foundation and other contributors
@@ -43,7 +43,7 @@ var sizeRelatedOptions = {
43
43
  };
44
44
 
45
45
  $.widget( "ui.dialog", {
46
- version: "1.10.0",
46
+ version: "1.10.3",
47
47
  options: {
48
48
  appendTo: "body",
49
49
  autoOpen: true,
@@ -214,6 +214,7 @@ $.widget( "ui.dialog", {
214
214
  },
215
215
 
216
216
  open: function() {
217
+ var that = this;
217
218
  if ( this._isOpen ) {
218
219
  if ( this._moveToTop() ) {
219
220
  this._focusTabbable();
@@ -221,19 +222,19 @@ $.widget( "ui.dialog", {
221
222
  return;
222
223
  }
223
224
 
225
+ this._isOpen = true;
224
226
  this.opener = $( this.document[0].activeElement );
225
227
 
226
228
  this._size();
227
229
  this._position();
228
230
  this._createOverlay();
229
231
  this._moveToTop( null, true );
230
- this._show( this.uiDialog, this.options.show );
231
-
232
- this._focusTabbable();
232
+ this._show( this.uiDialog, this.options.show, function() {
233
+ that._focusTabbable();
234
+ that._trigger("focus");
235
+ });
233
236
 
234
- this._isOpen = true;
235
237
  this._trigger("open");
236
- this._trigger("focus");
237
238
  },
238
239
 
239
240
  _focusTabbable: function() {
@@ -402,7 +403,7 @@ $.widget( "ui.dialog", {
402
403
  this.uiDialogButtonPane.remove();
403
404
  this.uiButtonSet.empty();
404
405
 
405
- if ( $.isEmptyObject( buttons ) ) {
406
+ if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) {
406
407
  this.uiDialog.removeClass("ui-dialog-buttons");
407
408
  return;
408
409
  }
@@ -450,6 +451,7 @@ $.widget( "ui.dialog", {
450
451
  containment: "document",
451
452
  start: function( event, ui ) {
452
453
  $( this ).addClass("ui-dialog-dragging");
454
+ that._blockFrames();
453
455
  that._trigger( "dragStart", event, filteredUi( ui ) );
454
456
  },
455
457
  drag: function( event, ui ) {
@@ -461,6 +463,7 @@ $.widget( "ui.dialog", {
461
463
  ui.position.top - that.document.scrollTop()
462
464
  ];
463
465
  $( this ).removeClass("ui-dialog-dragging");
466
+ that._unblockFrames();
464
467
  that._trigger( "dragStop", event, filteredUi( ui ) );
465
468
  }
466
469
  });
@@ -497,6 +500,7 @@ $.widget( "ui.dialog", {
497
500
  handles: resizeHandles,
498
501
  start: function( event, ui ) {
499
502
  $( this ).addClass("ui-dialog-resizing");
503
+ that._blockFrames();
500
504
  that._trigger( "resizeStart", event, filteredUi( ui ) );
501
505
  },
502
506
  resize: function( event, ui ) {
@@ -506,6 +510,7 @@ $.widget( "ui.dialog", {
506
510
  options.height = $( this ).height();
507
511
  options.width = $( this ).width();
508
512
  $( this ).removeClass("ui-dialog-resizing");
513
+ that._unblockFrames();
509
514
  that._trigger( "resizeStop", event, filteredUi( ui ) );
510
515
  }
511
516
  })
@@ -672,11 +677,45 @@ $.widget( "ui.dialog", {
672
677
  }
673
678
  },
674
679
 
680
+ _blockFrames: function() {
681
+ this.iframeBlocks = this.document.find( "iframe" ).map(function() {
682
+ var iframe = $( this );
683
+
684
+ return $( "<div>" )
685
+ .css({
686
+ position: "absolute",
687
+ width: iframe.outerWidth(),
688
+ height: iframe.outerHeight()
689
+ })
690
+ .appendTo( iframe.parent() )
691
+ .offset( iframe.offset() )[0];
692
+ });
693
+ },
694
+
695
+ _unblockFrames: function() {
696
+ if ( this.iframeBlocks ) {
697
+ this.iframeBlocks.remove();
698
+ delete this.iframeBlocks;
699
+ }
700
+ },
701
+
702
+ _allowInteraction: function( event ) {
703
+ if ( $( event.target ).closest(".ui-dialog").length ) {
704
+ return true;
705
+ }
706
+
707
+ // TODO: Remove hack when datepicker implements
708
+ // the .ui-front logic (#8989)
709
+ return !!$( event.target ).closest(".ui-datepicker").length;
710
+ },
711
+
675
712
  _createOverlay: function() {
676
713
  if ( !this.options.modal ) {
677
714
  return;
678
715
  }
679
716
 
717
+ var that = this,
718
+ widgetFullName = this.widgetFullName;
680
719
  if ( !$.ui.dialog.overlayInstances ) {
681
720
  // Prevent use of anchors and inputs.
682
721
  // We use a delay in case the overlay is created from an
@@ -684,13 +723,11 @@ $.widget( "ui.dialog", {
684
723
  this._delay(function() {
685
724
  // Handle .dialog().dialog("close") (#4065)
686
725
  if ( $.ui.dialog.overlayInstances ) {
687
- this._on( this.document, {
688
- focusin: function( event ) {
689
- if ( !$( event.target ).closest(".ui-dialog").length ) {
690
- event.preventDefault();
691
- $(".ui-dialog:visible:last .ui-dialog-content")
692
- .data("ui-dialog")._focusTabbable();
693
- }
726
+ this.document.bind( "focusin.dialog", function( event ) {
727
+ if ( !that._allowInteraction( event ) ) {
728
+ event.preventDefault();
729
+ $(".ui-dialog:visible:last .ui-dialog-content")
730
+ .data( widgetFullName )._focusTabbable();
694
731
  }
695
732
  });
696
733
  }
@@ -699,7 +736,7 @@ $.widget( "ui.dialog", {
699
736
 
700
737
  this.overlay = $("<div>")
701
738
  .addClass("ui-widget-overlay ui-front")
702
- .appendTo( this.document[0].body );
739
+ .appendTo( this._appendTo() );
703
740
  this._on( this.overlay, {
704
741
  mousedown: "_keepFocus"
705
742
  });
@@ -711,11 +748,15 @@ $.widget( "ui.dialog", {
711
748
  return;
712
749
  }
713
750
 
714
- $.ui.dialog.overlayInstances--;
715
- if ( !$.ui.dialog.overlayInstances ) {
716
- this._off( this.document, "focusin" );
751
+ if ( this.overlay ) {
752
+ $.ui.dialog.overlayInstances--;
753
+
754
+ if ( !$.ui.dialog.overlayInstances ) {
755
+ this.document.unbind( "focusin.dialog" );
756
+ }
757
+ this.overlay.remove();
758
+ this.overlay = null;
717
759
  }
718
- this.overlay.remove();
719
760
  }
720
761
  });
721
762
 
@@ -3,7 +3,7 @@
3
3
  //= require jquery.ui.mouse
4
4
 
5
5
  /*!
6
- * jQuery UI Draggable 1.10.0
6
+ * jQuery UI Draggable 1.10.3
7
7
  * http://jqueryui.com
8
8
  *
9
9
  * Copyright 2013 jQuery Foundation and other contributors
@@ -20,7 +20,7 @@
20
20
  (function( $, undefined ) {
21
21
 
22
22
  $.widget("ui.draggable", $.ui.mouse, {
23
- version: "1.10.0",
23
+ version: "1.10.3",
24
24
  widgetEventPrefix: "drag",
25
25
  options: {
26
26
  addClasses: true,
@@ -129,8 +129,10 @@ $.widget("ui.draggable", $.ui.mouse, {
129
129
  this._cacheMargins();
130
130
 
131
131
  //Store the helper's css position
132
- this.cssPosition = this.helper.css("position");
132
+ this.cssPosition = this.helper.css( "position" );
133
133
  this.scrollParent = this.helper.scrollParent();
134
+ this.offsetParent = this.helper.offsetParent();
135
+ this.offsetParentCssPosition = this.offsetParent.css( "position" );
134
136
 
135
137
  //The element's absolute position on the page minus margins
136
138
  this.offset = this.positionAbs = this.element.offset();
@@ -139,6 +141,9 @@ $.widget("ui.draggable", $.ui.mouse, {
139
141
  left: this.offset.left - this.margins.left
140
142
  };
141
143
 
144
+ //Reset scroll cache
145
+ this.offset.scroll = false;
146
+
142
147
  $.extend(this.offset, {
143
148
  click: { //Where the click happened, relative to the element
144
149
  left: event.pageX - this.offset.left,
@@ -157,9 +162,7 @@ $.widget("ui.draggable", $.ui.mouse, {
157
162
  (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
158
163
 
159
164
  //Set a containment if given in the options
160
- if(o.containment) {
161
- this._setContainment();
162
- }
165
+ this._setContainment();
163
166
 
164
167
  //Trigger event + callbacks
165
168
  if(this._trigger("start", event) === false) {
@@ -187,6 +190,10 @@ $.widget("ui.draggable", $.ui.mouse, {
187
190
  },
188
191
 
189
192
  _mouseDrag: function(event, noPropagation) {
193
+ // reset any necessary cached properties (see #5009)
194
+ if ( this.offsetParentCssPosition === "fixed" ) {
195
+ this.offset.parent = this._getParentOffset();
196
+ }
190
197
 
191
198
  //Compute the helpers position
192
199
  this.position = this._generatePosition(event);
@@ -218,9 +225,7 @@ $.widget("ui.draggable", $.ui.mouse, {
218
225
  _mouseStop: function(event) {
219
226
 
220
227
  //If we are using droppables, inform the manager about the drop
221
- var element,
222
- that = this,
223
- elementInDom = false,
228
+ var that = this,
224
229
  dropped = false;
225
230
  if ($.ui.ddmanager && !this.options.dropBehaviour) {
226
231
  dropped = $.ui.ddmanager.drop(this, event);
@@ -233,13 +238,7 @@ $.widget("ui.draggable", $.ui.mouse, {
233
238
  }
234
239
 
235
240
  //if the original element is no longer in the DOM don't bother to continue (see #8269)
236
- element = this.element[0];
237
- while ( element && (element = element.parentNode) ) {
238
- if (element === document ) {
239
- elementInDom = true;
240
- }
241
- }
242
- if ( !elementInDom && this.options.helper === "original" ) {
241
+ if ( this.options.helper === "original" && !$.contains( this.element[ 0 ].ownerDocument, this.element[ 0 ] ) ) {
243
242
  return false;
244
243
  }
245
244
 
@@ -285,19 +284,9 @@ $.widget("ui.draggable", $.ui.mouse, {
285
284
  },
286
285
 
287
286
  _getHandle: function(event) {
288
-
289
- var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
290
- $(this.options.handle, this.element)
291
- .find("*")
292
- .addBack()
293
- .each(function() {
294
- if(this === event.target) {
295
- handle = true;
296
- }
297
- });
298
-
299
- return handle;
300
-
287
+ return this.options.handle ?
288
+ !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
289
+ true;
301
290
  },
302
291
 
303
292
  _createHelper: function(event) {
@@ -341,7 +330,6 @@ $.widget("ui.draggable", $.ui.mouse, {
341
330
  _getParentOffset: function() {
342
331
 
343
332
  //Get the offsetParent and cache its position
344
- this.offsetParent = this.helper.offsetParent();
345
333
  var po = this.offsetParent.offset();
346
334
 
347
335
  // This is a special case where we need to modify a offset calculated on start, since the following happened:
@@ -402,40 +390,56 @@ $.widget("ui.draggable", $.ui.mouse, {
402
390
  var over, c, ce,
403
391
  o = this.options;
404
392
 
405
- if(o.containment === "parent") {
406
- o.containment = this.helper[0].parentNode;
393
+ if ( !o.containment ) {
394
+ this.containment = null;
395
+ return;
407
396
  }
408
- if(o.containment === "document" || o.containment === "window") {
397
+
398
+ if ( o.containment === "window" ) {
409
399
  this.containment = [
410
- o.containment === "document" ? 0 : $(window).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
411
- o.containment === "document" ? 0 : $(window).scrollTop() - this.offset.relative.top - this.offset.parent.top,
412
- (o.containment === "document" ? 0 : $(window).scrollLeft()) + $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
413
- (o.containment === "document" ? 0 : $(window).scrollTop()) + ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
400
+ $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
401
+ $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
402
+ $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left,
403
+ $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
414
404
  ];
405
+ return;
415
406
  }
416
407
 
417
- if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor !== Array) {
418
- c = $(o.containment);
419
- ce = c[0];
420
-
421
- if(!ce) {
422
- return;
423
- }
424
-
425
- over = ($(ce).css("overflow") !== "hidden");
426
-
408
+ if ( o.containment === "document") {
427
409
  this.containment = [
428
- (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0),
429
- (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0),
430
- (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,
431
- (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
410
+ 0,
411
+ 0,
412
+ $( document ).width() - this.helperProportions.width - this.margins.left,
413
+ ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
432
414
  ];
433
- this.relative_container = c;
415
+ return;
416
+ }
434
417
 
435
- } else if(o.containment.constructor === Array) {
418
+ if ( o.containment.constructor === Array ) {
436
419
  this.containment = o.containment;
420
+ return;
437
421
  }
438
422
 
423
+ if ( o.containment === "parent" ) {
424
+ o.containment = this.helper[ 0 ].parentNode;
425
+ }
426
+
427
+ c = $( o.containment );
428
+ ce = c[ 0 ];
429
+
430
+ if( !ce ) {
431
+ return;
432
+ }
433
+
434
+ over = c.css( "overflow" ) !== "hidden";
435
+
436
+ this.containment = [
437
+ ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
438
+ ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ) ,
439
+ ( 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,
440
+ ( 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
441
+ ];
442
+ this.relative_container = c;
439
443
  },
440
444
 
441
445
  _convertPositionTo: function(d, pos) {
@@ -445,20 +449,25 @@ $.widget("ui.draggable", $.ui.mouse, {
445
449
  }
446
450
 
447
451
  var mod = d === "absolute" ? 1 : -1,
448
- 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);
452
+ scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent;
453
+
454
+ //Cache the scroll
455
+ if (!this.offset.scroll) {
456
+ this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
457
+ }
449
458
 
450
459
  return {
451
460
  top: (
452
461
  pos.top + // The absolute mouse position
453
462
  this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
454
463
  this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
455
- ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
464
+ ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top ) * mod )
456
465
  ),
457
466
  left: (
458
467
  pos.left + // The absolute mouse position
459
468
  this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
460
469
  this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
461
- ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
470
+ ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left ) * mod )
462
471
  )
463
472
  };
464
473
 
@@ -468,28 +477,35 @@ $.widget("ui.draggable", $.ui.mouse, {
468
477
 
469
478
  var containment, co, top, left,
470
479
  o = this.options,
471
- scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
472
- scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName),
480
+ scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent,
473
481
  pageX = event.pageX,
474
482
  pageY = event.pageY;
475
483
 
484
+ //Cache the scroll
485
+ if (!this.offset.scroll) {
486
+ this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
487
+ }
488
+
476
489
  /*
477
490
  * - Position constraining -
478
491
  * Constrain the position to a mix of grid, containment.
479
492
  */
480
493
 
481
- if(this.originalPosition) { //If we are not dragging yet, we won't check for options
482
- if(this.containment) {
483
- if (this.relative_container){
484
- co = this.relative_container.offset();
485
- containment = [ this.containment[0] + co.left,
486
- this.containment[1] + co.top,
487
- this.containment[2] + co.left,
488
- this.containment[3] + co.top ];
489
- }
490
- else {
491
- containment = this.containment;
492
- }
494
+ // If we are not dragging yet, we won't check for options
495
+ if ( this.originalPosition ) {
496
+ if ( this.containment ) {
497
+ if ( this.relative_container ){
498
+ co = this.relative_container.offset();
499
+ containment = [
500
+ this.containment[ 0 ] + co.left,
501
+ this.containment[ 1 ] + co.top,
502
+ this.containment[ 2 ] + co.left,
503
+ this.containment[ 3 ] + co.top
504
+ ];
505
+ }
506
+ else {
507
+ containment = this.containment;
508
+ }
493
509
 
494
510
  if(event.pageX - this.offset.click.left < containment[0]) {
495
511
  pageX = containment[0] + this.offset.click.left;
@@ -522,14 +538,14 @@ $.widget("ui.draggable", $.ui.mouse, {
522
538
  this.offset.click.top - // Click offset (relative to the element)
523
539
  this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
524
540
  this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
525
- ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
541
+ ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top )
526
542
  ),
527
543
  left: (
528
544
  pageX - // The absolute mouse position
529
545
  this.offset.click.left - // Click offset (relative to the element)
530
546
  this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
531
547
  this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
532
- ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
548
+ ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left )
533
549
  )
534
550
  };
535
551
 
@@ -604,7 +620,7 @@ $.ui.plugin.add("draggable", "connectToSortable", {
604
620
 
605
621
  //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid"
606
622
  if(this.shouldRevert) {
607
- this.instance.options.revert = true;
623
+ this.instance.options.revert = this.shouldRevert;
608
624
  }
609
625
 
610
626
  //Trigger the stop of the sortable
@@ -647,7 +663,7 @@ $.ui.plugin.add("draggable", "connectToSortable", {
647
663
  this.instance.offset.click = inst.offset.click;
648
664
  if (this !== thisSortable &&
649
665
  this.instance._intersectsWith(this.instance.containerCache) &&
650
- $.ui.contains(thisSortable.instance.element[0], this.instance.element[0])
666
+ $.contains(thisSortable.instance.element[0], this.instance.element[0])
651
667
  ) {
652
668
  innermostIntersecting = false;
653
669
  }
@@ -851,8 +867,7 @@ $.ui.plugin.add("draggable", "snap", {
851
867
  t = inst.snapElements[i].top;
852
868
  b = t + inst.snapElements[i].height;
853
869
 
854
- //Yes, I know, this is insane ;)
855
- 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))) {
870
+ if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
856
871
  if(inst.snapElements[i].snapping) {
857
872
  (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
858
873
  }
@@ -912,22 +927,19 @@ $.ui.plugin.add("draggable", "snap", {
912
927
 
913
928
  $.ui.plugin.add("draggable", "stack", {
914
929
  start: function() {
915
-
916
930
  var min,
917
- o = $(this).data("ui-draggable").options,
931
+ o = this.data("ui-draggable").options,
918
932
  group = $.makeArray($(o.stack)).sort(function(a,b) {
919
933
  return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
920
934
  });
921
935
 
922
936
  if (!group.length) { return; }
923
937
 
924
- min = parseInt(group[0].style.zIndex, 10) || 0;
938
+ min = parseInt($(group[0]).css("zIndex"), 10) || 0;
925
939
  $(group).each(function(i) {
926
- this.style.zIndex = min + i;
940
+ $(this).css("zIndex", min + i);
927
941
  });
928
-
929
- this[0].style.zIndex = min + group.length;
930
-
942
+ this.css("zIndex", (min + group.length));
931
943
  }
932
944
  });
933
945