jquery-ui-rails 5.0.1 → 5.0.2

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 (64) hide show
  1. data/History.md +4 -0
  2. data/VERSIONS.md +1 -0
  3. data/app/assets/javascripts/jquery-ui/accordion.js +12 -3
  4. data/app/assets/javascripts/jquery-ui/autocomplete.js +2 -2
  5. data/app/assets/javascripts/jquery-ui/button.js +3 -3
  6. data/app/assets/javascripts/jquery-ui/core.js +2 -2
  7. data/app/assets/javascripts/jquery-ui/datepicker-el.js +1 -1
  8. data/app/assets/javascripts/jquery-ui/datepicker-fa.js +12 -12
  9. data/app/assets/javascripts/jquery-ui/datepicker-fr.js +1 -1
  10. data/app/assets/javascripts/jquery-ui/datepicker.js +3 -3
  11. data/app/assets/javascripts/jquery-ui/dialog.js +2 -2
  12. data/app/assets/javascripts/jquery-ui/draggable.js +290 -183
  13. data/app/assets/javascripts/jquery-ui/droppable.js +4 -4
  14. data/app/assets/javascripts/jquery-ui/effect-blind.js +1 -1
  15. data/app/assets/javascripts/jquery-ui/effect-bounce.js +1 -1
  16. data/app/assets/javascripts/jquery-ui/effect-clip.js +1 -1
  17. data/app/assets/javascripts/jquery-ui/effect-drop.js +2 -2
  18. data/app/assets/javascripts/jquery-ui/effect-explode.js +1 -1
  19. data/app/assets/javascripts/jquery-ui/effect-fade.js +1 -1
  20. data/app/assets/javascripts/jquery-ui/effect-fold.js +1 -1
  21. data/app/assets/javascripts/jquery-ui/effect-highlight.js +1 -1
  22. data/app/assets/javascripts/jquery-ui/effect-puff.js +1 -1
  23. data/app/assets/javascripts/jquery-ui/effect-pulsate.js +1 -1
  24. data/app/assets/javascripts/jquery-ui/effect-scale.js +1 -1
  25. data/app/assets/javascripts/jquery-ui/effect-shake.js +1 -1
  26. data/app/assets/javascripts/jquery-ui/effect-size.js +1 -1
  27. data/app/assets/javascripts/jquery-ui/effect-slide.js +1 -1
  28. data/app/assets/javascripts/jquery-ui/effect-transfer.js +1 -1
  29. data/app/assets/javascripts/jquery-ui/effect.js +4 -4
  30. data/app/assets/javascripts/jquery-ui/menu.js +28 -22
  31. data/app/assets/javascripts/jquery-ui/mouse.js +20 -8
  32. data/app/assets/javascripts/jquery-ui/position.js +1 -1
  33. data/app/assets/javascripts/jquery-ui/progressbar.js +2 -2
  34. data/app/assets/javascripts/jquery-ui/resizable.js +2 -2
  35. data/app/assets/javascripts/jquery-ui/selectable.js +2 -2
  36. data/app/assets/javascripts/jquery-ui/selectmenu.js +49 -5
  37. data/app/assets/javascripts/jquery-ui/slider.js +12 -4
  38. data/app/assets/javascripts/jquery-ui/sortable.js +12 -18
  39. data/app/assets/javascripts/jquery-ui/spinner.js +2 -2
  40. data/app/assets/javascripts/jquery-ui/tabs.js +13 -3
  41. data/app/assets/javascripts/jquery-ui/tooltip.js +38 -28
  42. data/app/assets/javascripts/jquery-ui/widget.js +14 -7
  43. data/app/assets/stylesheets/jquery-ui/accordion.css.erb +1 -1
  44. data/app/assets/stylesheets/jquery-ui/all.css.erb +1 -1
  45. data/app/assets/stylesheets/jquery-ui/autocomplete.css.erb +1 -1
  46. data/app/assets/stylesheets/jquery-ui/base.css.erb +1 -1
  47. data/app/assets/stylesheets/jquery-ui/button.css.erb +1 -1
  48. data/app/assets/stylesheets/jquery-ui/core.css.erb +1 -1
  49. data/app/assets/stylesheets/jquery-ui/datepicker.css.erb +1 -1
  50. data/app/assets/stylesheets/jquery-ui/dialog.css.erb +1 -1
  51. data/app/assets/stylesheets/jquery-ui/draggable.css.erb +1 -1
  52. data/app/assets/stylesheets/jquery-ui/menu.css.erb +1 -1
  53. data/app/assets/stylesheets/jquery-ui/progressbar.css.erb +1 -1
  54. data/app/assets/stylesheets/jquery-ui/resizable.css.erb +1 -1
  55. data/app/assets/stylesheets/jquery-ui/selectable.css.erb +1 -1
  56. data/app/assets/stylesheets/jquery-ui/selectmenu.css.erb +1 -1
  57. data/app/assets/stylesheets/jquery-ui/slider.css.erb +1 -1
  58. data/app/assets/stylesheets/jquery-ui/sortable.css.erb +1 -1
  59. data/app/assets/stylesheets/jquery-ui/spinner.css.erb +1 -1
  60. data/app/assets/stylesheets/jquery-ui/tabs.css.erb +1 -1
  61. data/app/assets/stylesheets/jquery-ui/theme.css.erb +1 -1
  62. data/app/assets/stylesheets/jquery-ui/tooltip.css.erb +1 -1
  63. data/lib/jquery/ui/rails/version.rb +2 -2
  64. metadata +3 -3
data/History.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # master
2
2
 
3
+ # 5.0.2
4
+
5
+ * Update to jQuery UI 1.11.2
6
+
3
7
  # 5.0.1
4
8
 
5
9
  * Update to jQuery UI 1.11.1
data/VERSIONS.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  | Gem | jQuery UI |
4
4
  |--------|-----------|
5
+ | 5.0.2 | 1.11.2 |
5
6
  | 5.0.1 | 1.11.1 |
6
7
  | 5.0.0 | 1.11.0 |
7
8
  | 4.2.1 | 1.10.4 |
@@ -2,7 +2,7 @@
2
2
  //= require jquery-ui/widget
3
3
 
4
4
  /*!
5
- * jQuery UI Accordion 1.11.1
5
+ * jQuery UI Accordion 1.11.2
6
6
  * http://jqueryui.com
7
7
  *
8
8
  * Copyright 2014 jQuery Foundation and other contributors
@@ -28,7 +28,7 @@
28
28
  }(function( $ ) {
29
29
 
30
30
  return $.widget( "ui.accordion", {
31
- version: "1.11.1",
31
+ version: "1.11.2",
32
32
  options: {
33
33
  active: 0,
34
34
  animate: {},
@@ -262,13 +262,22 @@ return $.widget( "ui.accordion", {
262
262
  },
263
263
 
264
264
  _processPanels: function() {
265
+ var prevHeaders = this.headers,
266
+ prevPanels = this.panels;
267
+
265
268
  this.headers = this.element.find( this.options.header )
266
269
  .addClass( "ui-accordion-header ui-state-default ui-corner-all" );
267
270
 
268
- this.headers.next()
271
+ this.panels = this.headers.next()
269
272
  .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
270
273
  .filter( ":not(.ui-accordion-content-active)" )
271
274
  .hide();
275
+
276
+ // Avoid memory leaks (#10056)
277
+ if ( prevPanels ) {
278
+ this._off( prevHeaders.not( this.headers ) );
279
+ this._off( prevPanels.not( this.panels ) );
280
+ }
272
281
  },
273
282
 
274
283
  _refresh: function() {
@@ -4,7 +4,7 @@
4
4
  //= require jquery-ui/position
5
5
 
6
6
  /*!
7
- * jQuery UI Autocomplete 1.11.1
7
+ * jQuery UI Autocomplete 1.11.2
8
8
  * http://jqueryui.com
9
9
  *
10
10
  * Copyright 2014 jQuery Foundation and other contributors
@@ -32,7 +32,7 @@
32
32
  }(function( $ ) {
33
33
 
34
34
  $.widget( "ui.autocomplete", {
35
- version: "1.11.1",
35
+ version: "1.11.2",
36
36
  defaultElement: "<input>",
37
37
  options: {
38
38
  appendTo: null,
@@ -2,7 +2,7 @@
2
2
  //= require jquery-ui/widget
3
3
 
4
4
  /*!
5
- * jQuery UI Button 1.11.1
5
+ * jQuery UI Button 1.11.2
6
6
  * http://jqueryui.com
7
7
  *
8
8
  * Copyright 2014 jQuery Foundation and other contributors
@@ -55,7 +55,7 @@ var lastActive,
55
55
  };
56
56
 
57
57
  $.widget( "ui.button", {
58
- version: "1.11.1",
58
+ version: "1.11.2",
59
59
  defaultElement: "<button>",
60
60
  options: {
61
61
  disabled: null,
@@ -351,7 +351,7 @@ $.widget( "ui.button", {
351
351
  });
352
352
 
353
353
  $.widget( "ui.buttonset", {
354
- version: "1.11.1",
354
+ version: "1.11.2",
355
355
  options: {
356
356
  items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
357
357
  },
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * jQuery UI Core 1.11.1
2
+ * jQuery UI Core 1.11.2
3
3
  * http://jqueryui.com
4
4
  *
5
5
  * Copyright 2014 jQuery Foundation and other contributors
@@ -24,7 +24,7 @@
24
24
  $.ui = $.ui || {};
25
25
 
26
26
  $.extend( $.ui, {
27
- version: "1.11.1",
27
+ version: "1.11.2",
28
28
 
29
29
  keyCode: {
30
30
  BACKSPACE: 8,
@@ -16,7 +16,7 @@ datepicker.regional['el'] = {
16
16
  closeText: 'Κλείσιμο',
17
17
  prevText: 'Προηγούμενος',
18
18
  nextText: 'Επόμενος',
19
- currentText: 'Τρέχων Μήνας',
19
+ currentText: 'Σήμερα',
20
20
  monthNames: ['Ιανουάριος','Φεβρουάριος','Μάρτιος','Απρίλιος','Μάιος','Ιούνιος',
21
21
  'Ιούλιος','Αύγουστος','Σεπτέμβριος','Οκτώβριος','Νοέμβριος','Δεκέμβριος'],
22
22
  monthNamesShort: ['Ιαν','Φεβ','Μαρ','Απρ','Μαι','Ιουν',
@@ -19,18 +19,18 @@ datepicker.regional['fa'] = {
19
19
  nextText: 'بعدی&#x3E;',
20
20
  currentText: 'امروز',
21
21
  monthNames: [
22
- 'فروردين',
23
- 'ارديبهشت',
24
- 'خرداد',
25
- 'تير',
26
- 'مرداد',
27
- 'شهريور',
28
- 'مهر',
29
- 'آبان',
30
- 'آذر',
31
- 'دی',
32
- 'بهمن',
33
- 'اسفند'
22
+ 'ژانویه',
23
+ 'فوریه',
24
+ 'مارس',
25
+ 'آوریل',
26
+ 'مه',
27
+ 'ژوئن',
28
+ 'ژوئیه',
29
+ 'اوت',
30
+ 'سپتامبر',
31
+ 'اکتبر',
32
+ 'نوامبر',
33
+ 'دسامبر'
34
34
  ],
35
35
  monthNamesShort: ['1','2','3','4','5','6','7','8','9','10','11','12'],
36
36
  dayNames: [
@@ -21,7 +21,7 @@ datepicker.regional['fr'] = {
21
21
  currentText: 'Aujourd\'hui',
22
22
  monthNames: ['janvier', 'février', 'mars', 'avril', 'mai', 'juin',
23
23
  'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'],
24
- monthNamesShort: ['janv.', 'févr.', 'mars', 'avril', 'mai', 'juin',
24
+ monthNamesShort: ['janv.', 'févr.', 'mars', 'avr.', 'mai', 'juin',
25
25
  'juil.', 'août', 'sept.', 'oct.', 'nov.', 'déc.'],
26
26
  dayNames: ['dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'],
27
27
  dayNamesShort: ['dim.', 'lun.', 'mar.', 'mer.', 'jeu.', 'ven.', 'sam.'],
@@ -1,7 +1,7 @@
1
1
  //= require jquery-ui/core
2
2
 
3
3
  /*!
4
- * jQuery UI Datepicker 1.11.1
4
+ * jQuery UI Datepicker 1.11.2
5
5
  * http://jqueryui.com
6
6
  *
7
7
  * Copyright 2014 jQuery Foundation and other contributors
@@ -25,7 +25,7 @@
25
25
  }
26
26
  }(function( $ ) {
27
27
 
28
- $.extend($.ui, { datepicker: { version: "1.11.1" } });
28
+ $.extend($.ui, { datepicker: { version: "1.11.2" } });
29
29
 
30
30
  var datepicker_instActive;
31
31
 
@@ -2075,7 +2075,7 @@ $.fn.datepicker = function(options){
2075
2075
  $.datepicker = new Datepicker(); // singleton instance
2076
2076
  $.datepicker.initialized = false;
2077
2077
  $.datepicker.uuid = new Date().getTime();
2078
- $.datepicker.version = "1.11.1";
2078
+ $.datepicker.version = "1.11.2";
2079
2079
 
2080
2080
  return $.datepicker;
2081
2081
 
@@ -6,7 +6,7 @@
6
6
  //= require jquery-ui/resizable
7
7
 
8
8
  /*!
9
- * jQuery UI Dialog 1.11.1
9
+ * jQuery UI Dialog 1.11.2
10
10
  * http://jqueryui.com
11
11
  *
12
12
  * Copyright 2014 jQuery Foundation and other contributors
@@ -37,7 +37,7 @@
37
37
  }(function( $ ) {
38
38
 
39
39
  return $.widget( "ui.dialog", {
40
- version: "1.11.1",
40
+ version: "1.11.2",
41
41
  options: {
42
42
  appendTo: "body",
43
43
  autoOpen: true,
@@ -3,7 +3,7 @@
3
3
  //= require jquery-ui/mouse
4
4
 
5
5
  /*!
6
- * jQuery UI Draggable 1.11.1
6
+ * jQuery UI Draggable 1.11.2
7
7
  * http://jqueryui.com
8
8
  *
9
9
  * Copyright 2014 jQuery Foundation and other contributors
@@ -30,7 +30,7 @@
30
30
  }(function( $ ) {
31
31
 
32
32
  $.widget("ui.draggable", $.ui.mouse, {
33
- version: "1.11.1",
33
+ version: "1.11.2",
34
34
  widgetEventPrefix: "drag",
35
35
  options: {
36
36
  addClasses: true,
@@ -65,8 +65,8 @@ $.widget("ui.draggable", $.ui.mouse, {
65
65
  },
66
66
  _create: function() {
67
67
 
68
- if (this.options.helper === "original" && !(/^(?:r|a|f)/).test(this.element.css("position"))) {
69
- this.element[0].style.position = "relative";
68
+ if ( this.options.helper === "original" ) {
69
+ this._setPositionRelative();
70
70
  }
71
71
  if (this.options.addClasses){
72
72
  this.element.addClass("ui-draggable");
@@ -98,20 +98,9 @@ $.widget("ui.draggable", $.ui.mouse, {
98
98
  },
99
99
 
100
100
  _mouseCapture: function(event) {
101
+ var o = this.options;
101
102
 
102
- var document = this.document[ 0 ],
103
- o = this.options;
104
-
105
- // support: IE9
106
- // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
107
- try {
108
- // Support: IE9+
109
- // If the <body> is blurred, IE will switch windows, see #9520
110
- if ( document.activeElement && document.activeElement.nodeName.toLowerCase() !== "body" ) {
111
- // Blur any element that currently has focus, see #4261
112
- $( document.activeElement ).blur();
113
- }
114
- } catch ( error ) {}
103
+ this._blurActiveElement( event );
115
104
 
116
105
  // among others, prevent a drag on a resizable-handle
117
106
  if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
@@ -124,20 +113,54 @@ $.widget("ui.draggable", $.ui.mouse, {
124
113
  return false;
125
114
  }
126
115
 
127
- $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
128
- $("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>")
129
- .css({
130
- width: this.offsetWidth + "px", height: this.offsetHeight + "px",
131
- position: "absolute", opacity: "0.001", zIndex: 1000
132
- })
133
- .css($(this).offset())
134
- .appendTo("body");
135
- });
116
+ this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix );
136
117
 
137
118
  return true;
138
119
 
139
120
  },
140
121
 
122
+ _blockFrames: function( selector ) {
123
+ this.iframeBlocks = this.document.find( selector ).map(function() {
124
+ var iframe = $( this );
125
+
126
+ return $( "<div>" )
127
+ .css( "position", "absolute" )
128
+ .appendTo( iframe.parent() )
129
+ .outerWidth( iframe.outerWidth() )
130
+ .outerHeight( iframe.outerHeight() )
131
+ .offset( iframe.offset() )[ 0 ];
132
+ });
133
+ },
134
+
135
+ _unblockFrames: function() {
136
+ if ( this.iframeBlocks ) {
137
+ this.iframeBlocks.remove();
138
+ delete this.iframeBlocks;
139
+ }
140
+ },
141
+
142
+ _blurActiveElement: function( event ) {
143
+ var document = this.document[ 0 ];
144
+
145
+ // Only need to blur if the event occurred on the draggable itself, see #10527
146
+ if ( !this.handleElement.is( event.target ) ) {
147
+ return;
148
+ }
149
+
150
+ // support: IE9
151
+ // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
152
+ try {
153
+
154
+ // Support: IE9, IE10
155
+ // If the <body> is blurred, IE will switch windows, see #9520
156
+ if ( document.activeElement && document.activeElement.nodeName.toLowerCase() !== "body" ) {
157
+
158
+ // Blur any element that currently has focus, see #4261
159
+ $( document.activeElement ).blur();
160
+ }
161
+ } catch ( error ) {}
162
+ },
163
+
141
164
  _mouseStart: function(event) {
142
165
 
143
166
  var o = this.options;
@@ -167,26 +190,13 @@ $.widget("ui.draggable", $.ui.mouse, {
167
190
  this.cssPosition = this.helper.css( "position" );
168
191
  this.scrollParent = this.helper.scrollParent( true );
169
192
  this.offsetParent = this.helper.offsetParent();
170
- this.offsetParentCssPosition = this.offsetParent.css( "position" );
193
+ this.hasFixedAncestor = this.helper.parents().filter(function() {
194
+ return $( this ).css( "position" ) === "fixed";
195
+ }).length > 0;
171
196
 
172
197
  //The element's absolute position on the page minus margins
173
- this.offset = this.positionAbs = this.element.offset();
174
- this.offset = {
175
- top: this.offset.top - this.margins.top,
176
- left: this.offset.left - this.margins.left
177
- };
178
-
179
- //Reset scroll cache
180
- this.offset.scroll = false;
181
-
182
- $.extend(this.offset, {
183
- click: { //Where the click happened, relative to the element
184
- left: event.pageX - this.offset.left,
185
- top: event.pageY - this.offset.top
186
- },
187
- parent: this._getParentOffset(),
188
- relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
189
- });
198
+ this.positionAbs = this.element.offset();
199
+ this._refreshOffsets( event );
190
200
 
191
201
  //Generate the original position
192
202
  this.originalPosition = this.position = this._generatePosition( event, false );
@@ -213,6 +223,10 @@ $.widget("ui.draggable", $.ui.mouse, {
213
223
  $.ui.ddmanager.prepareOffsets(this, event);
214
224
  }
215
225
 
226
+ // Reset helper's right/bottom css if they're set and set explicit width/height instead
227
+ // as this prevents resizing of elements with right/bottom set (see #7772)
228
+ this._normalizeRightBottom();
229
+
216
230
  this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
217
231
 
218
232
  //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
@@ -223,9 +237,24 @@ $.widget("ui.draggable", $.ui.mouse, {
223
237
  return true;
224
238
  },
225
239
 
240
+ _refreshOffsets: function( event ) {
241
+ this.offset = {
242
+ top: this.positionAbs.top - this.margins.top,
243
+ left: this.positionAbs.left - this.margins.left,
244
+ scroll: false,
245
+ parent: this._getParentOffset(),
246
+ relative: this._getRelativeOffset()
247
+ };
248
+
249
+ this.offset.click = {
250
+ left: event.pageX - this.offset.left,
251
+ top: event.pageY - this.offset.top
252
+ };
253
+ },
254
+
226
255
  _mouseDrag: function(event, noPropagation) {
227
256
  // reset any necessary cached properties (see #5009)
228
- if ( this.offsetParentCssPosition === "fixed" ) {
257
+ if ( this.hasFixedAncestor ) {
229
258
  this.offset.parent = this._getParentOffset();
230
259
  }
231
260
 
@@ -283,19 +312,19 @@ $.widget("ui.draggable", $.ui.mouse, {
283
312
  return false;
284
313
  },
285
314
 
286
- _mouseUp: function(event) {
287
- //Remove frame helpers
288
- $("div.ui-draggable-iframeFix").each(function() {
289
- this.parentNode.removeChild(this);
290
- });
315
+ _mouseUp: function( event ) {
316
+ this._unblockFrames();
291
317
 
292
318
  //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
293
319
  if ( $.ui.ddmanager ) {
294
320
  $.ui.ddmanager.dragStop(this, event);
295
321
  }
296
322
 
297
- // The interaction is over; whether or not the click resulted in a drag, focus the element
298
- this.element.focus();
323
+ // Only need to focus if the event occurred on the draggable itself, see #10527
324
+ if ( this.handleElement.is( event.target ) ) {
325
+ // The interaction is over; whether or not the click resulted in a drag, focus the element
326
+ this.element.focus();
327
+ }
299
328
 
300
329
  return $.ui.mouse.prototype._mouseUp.call(this, event);
301
330
  },
@@ -331,12 +360,24 @@ $.widget("ui.draggable", $.ui.mouse, {
331
360
  _createHelper: function(event) {
332
361
 
333
362
  var o = this.options,
334
- helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[ 0 ], [ event ])) : (o.helper === "clone" ? this.element.clone().removeAttr("id") : this.element);
363
+ helperIsFunction = $.isFunction( o.helper ),
364
+ helper = helperIsFunction ?
365
+ $( o.helper.apply( this.element[ 0 ], [ event ] ) ) :
366
+ ( o.helper === "clone" ?
367
+ this.element.clone().removeAttr( "id" ) :
368
+ this.element );
335
369
 
336
370
  if (!helper.parents("body").length) {
337
371
  helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
338
372
  }
339
373
 
374
+ // http://bugs.jqueryui.com/ticket/9446
375
+ // a helper function can return the original element
376
+ // which wouldn't have been set to relative in _create
377
+ if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) {
378
+ this._setPositionRelative();
379
+ }
380
+
340
381
  if (helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
341
382
  helper.css("position", "absolute");
342
383
  }
@@ -345,6 +386,12 @@ $.widget("ui.draggable", $.ui.mouse, {
345
386
 
346
387
  },
347
388
 
389
+ _setPositionRelative: function() {
390
+ if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) {
391
+ this.element[ 0 ].style.position = "relative";
392
+ }
393
+ },
394
+
348
395
  _adjustOffsetFromHelper: function(obj) {
349
396
  if (typeof obj === "string") {
350
397
  obj = obj.split(" ");
@@ -429,7 +476,7 @@ $.widget("ui.draggable", $.ui.mouse, {
429
476
 
430
477
  _setContainment: function() {
431
478
 
432
- var over, c, ce,
479
+ var isUserScrollable, c, ce,
433
480
  o = this.options,
434
481
  document = this.document[ 0 ];
435
482
 
@@ -476,13 +523,23 @@ $.widget("ui.draggable", $.ui.mouse, {
476
523
  return;
477
524
  }
478
525
 
479
- over = c.css( "overflow" ) !== "hidden";
526
+ isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) );
480
527
 
481
528
  this.containment = [
482
529
  ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
483
530
  ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ),
484
- ( 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,
485
- ( 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
531
+ ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
532
+ ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) -
533
+ ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) -
534
+ this.helperProportions.width -
535
+ this.margins.left -
536
+ this.margins.right,
537
+ ( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
538
+ ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) -
539
+ ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) -
540
+ this.helperProportions.height -
541
+ this.margins.top -
542
+ this.margins.bottom
486
543
  ];
487
544
  this.relativeContainer = c;
488
545
  },
@@ -612,16 +669,29 @@ $.widget("ui.draggable", $.ui.mouse, {
612
669
  }
613
670
  },
614
671
 
672
+ _normalizeRightBottom: function() {
673
+ if ( this.options.axis !== "y" && this.helper.css( "right" ) !== "auto" ) {
674
+ this.helper.width( this.helper.width() );
675
+ this.helper.css( "right", "auto" );
676
+ }
677
+ if ( this.options.axis !== "x" && this.helper.css( "bottom" ) !== "auto" ) {
678
+ this.helper.height( this.helper.height() );
679
+ this.helper.css( "bottom", "auto" );
680
+ }
681
+ },
682
+
615
683
  // From now on bulk stuff - mainly helpers
616
684
 
617
- _trigger: function(type, event, ui) {
685
+ _trigger: function( type, event, ui ) {
618
686
  ui = ui || this._uiHash();
619
687
  $.ui.plugin.call( this, type, [ event, ui, this ], true );
620
- //The absolute position has to be recalculated after plugins
621
- if (type === "drag") {
622
- this.positionAbs = this._convertPositionTo("absolute");
688
+
689
+ // Absolute position and offset (see #6884 ) have to be recalculated after plugins
690
+ if ( /^(drag|start|stop)/.test( type ) ) {
691
+ this.positionAbs = this._convertPositionTo( "absolute" );
692
+ ui.offset = this.positionAbs;
623
693
  }
624
- return $.Widget.prototype._trigger.call(this, type, event, ui);
694
+ return $.Widget.prototype._trigger.call( this, type, event, ui );
625
695
  },
626
696
 
627
697
  plugins: {},
@@ -637,160 +707,197 @@ $.widget("ui.draggable", $.ui.mouse, {
637
707
 
638
708
  });
639
709
 
640
- $.ui.plugin.add("draggable", "connectToSortable", {
641
- start: function( event, ui, inst ) {
710
+ $.ui.plugin.add( "draggable", "connectToSortable", {
711
+ start: function( event, ui, draggable ) {
712
+ var uiSortable = $.extend( {}, ui, {
713
+ item: draggable.element
714
+ });
642
715
 
643
- var o = inst.options,
644
- uiSortable = $.extend({}, ui, { item: inst.element });
645
- inst.sortables = [];
646
- $(o.connectToSortable).each(function() {
716
+ draggable.sortables = [];
717
+ $( draggable.options.connectToSortable ).each(function() {
647
718
  var sortable = $( this ).sortable( "instance" );
648
- if (sortable && !sortable.options.disabled) {
649
- inst.sortables.push({
650
- instance: sortable,
651
- shouldRevert: sortable.options.revert
652
- });
653
- 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).
719
+
720
+ if ( sortable && !sortable.options.disabled ) {
721
+ draggable.sortables.push( sortable );
722
+
723
+ // refreshPositions is called at drag start to refresh the containerCache
724
+ // which is used in drag. This ensures it's initialized and synchronized
725
+ // with any changes that might have happened on the page since initialization.
726
+ sortable.refreshPositions();
654
727
  sortable._trigger("activate", event, uiSortable);
655
728
  }
656
729
  });
657
-
658
730
  },
659
- stop: function( event, ui, inst ) {
660
-
661
- //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
731
+ stop: function( event, ui, draggable ) {
662
732
  var uiSortable = $.extend( {}, ui, {
663
- item: inst.element
733
+ item: draggable.element
664
734
  });
665
735
 
666
- $.each(inst.sortables, function() {
667
- if (this.instance.isOver) {
736
+ draggable.cancelHelperRemoval = false;
668
737
 
669
- this.instance.isOver = 0;
738
+ $.each( draggable.sortables, function() {
739
+ var sortable = this;
670
740
 
671
- inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
672
- this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
741
+ if ( sortable.isOver ) {
742
+ sortable.isOver = 0;
673
743
 
674
- //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid"
675
- if (this.shouldRevert) {
676
- this.instance.options.revert = this.shouldRevert;
677
- }
678
-
679
- //Trigger the stop of the sortable
680
- this.instance._mouseStop(event);
744
+ // Allow this sortable to handle removing the helper
745
+ draggable.cancelHelperRemoval = true;
746
+ sortable.cancelHelperRemoval = false;
681
747
 
682
- this.instance.options.helper = this.instance.options._helper;
748
+ // Use _storedCSS To restore properties in the sortable,
749
+ // as this also handles revert (#9675) since the draggable
750
+ // may have modified them in unexpected ways (#8809)
751
+ sortable._storedCSS = {
752
+ position: sortable.placeholder.css( "position" ),
753
+ top: sortable.placeholder.css( "top" ),
754
+ left: sortable.placeholder.css( "left" )
755
+ };
683
756
 
684
- //If the helper has been the original item, restore properties in the sortable
685
- if (inst.options.helper === "original") {
686
- this.instance.currentItem.css({ top: "auto", left: "auto" });
687
- }
757
+ sortable._mouseStop(event);
688
758
 
759
+ // Once drag has ended, the sortable should return to using
760
+ // its original helper, not the shared helper from draggable
761
+ sortable.options.helper = sortable.options._helper;
689
762
  } else {
690
- this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
691
- this.instance._trigger("deactivate", event, uiSortable);
692
- }
763
+ // Prevent this Sortable from removing the helper.
764
+ // However, don't set the draggable to remove the helper
765
+ // either as another connected Sortable may yet handle the removal.
766
+ sortable.cancelHelperRemoval = true;
693
767
 
768
+ sortable._trigger( "deactivate", event, uiSortable );
769
+ }
694
770
  });
695
-
696
771
  },
697
- drag: function( event, ui, inst ) {
698
-
699
- var that = this;
700
-
701
- $.each(inst.sortables, function() {
702
-
772
+ drag: function( event, ui, draggable ) {
773
+ $.each( draggable.sortables, function() {
703
774
  var innermostIntersecting = false,
704
- thisSortable = this;
775
+ sortable = this;
705
776
 
706
- //Copy over some variables to allow calling the sortable's native _intersectsWith
707
- this.instance.positionAbs = inst.positionAbs;
708
- this.instance.helperProportions = inst.helperProportions;
709
- this.instance.offset.click = inst.offset.click;
777
+ // Copy over variables that sortable's _intersectsWith uses
778
+ sortable.positionAbs = draggable.positionAbs;
779
+ sortable.helperProportions = draggable.helperProportions;
780
+ sortable.offset.click = draggable.offset.click;
710
781
 
711
- if (this.instance._intersectsWith(this.instance.containerCache)) {
782
+ if ( sortable._intersectsWith( sortable.containerCache ) ) {
712
783
  innermostIntersecting = true;
713
- $.each(inst.sortables, function() {
714
- this.instance.positionAbs = inst.positionAbs;
715
- this.instance.helperProportions = inst.helperProportions;
716
- this.instance.offset.click = inst.offset.click;
717
- if (this !== thisSortable &&
718
- this.instance._intersectsWith(this.instance.containerCache) &&
719
- $.contains(thisSortable.instance.element[0], this.instance.element[0])
720
- ) {
784
+
785
+ $.each( draggable.sortables, function() {
786
+ // Copy over variables that sortable's _intersectsWith uses
787
+ this.positionAbs = draggable.positionAbs;
788
+ this.helperProportions = draggable.helperProportions;
789
+ this.offset.click = draggable.offset.click;
790
+
791
+ if ( this !== sortable &&
792
+ this._intersectsWith( this.containerCache ) &&
793
+ $.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) {
721
794
  innermostIntersecting = false;
722
795
  }
796
+
723
797
  return innermostIntersecting;
724
798
  });
725
799
  }
726
800
 
727
- if (innermostIntersecting) {
728
- //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
729
- if (!this.instance.isOver) {
730
-
731
- this.instance.isOver = 1;
732
- //Now we fake the start of dragging for the sortable instance,
733
- //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
734
- //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)
735
- this.instance.currentItem = $(that).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item", true);
736
- this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
737
- this.instance.options.helper = function() { return ui.helper[0]; };
738
-
739
- event.target = this.instance.currentItem[0];
740
- this.instance._mouseCapture(event, true);
741
- this.instance._mouseStart(event, true, true);
742
-
743
- //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
744
- this.instance.offset.click.top = inst.offset.click.top;
745
- this.instance.offset.click.left = inst.offset.click.left;
746
- this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
747
- this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
748
-
749
- inst._trigger("toSortable", event);
750
- inst.dropped = this.instance.element; //draggable revert needs that
751
- //hack so receive/update callbacks work (mostly)
752
- inst.currentItem = inst.element;
753
- this.instance.fromOutside = inst;
754
-
801
+ if ( innermostIntersecting ) {
802
+ // If it intersects, we use a little isOver variable and set it once,
803
+ // so that the move-in stuff gets fired only once.
804
+ if ( !sortable.isOver ) {
805
+ sortable.isOver = 1;
806
+
807
+ sortable.currentItem = ui.helper
808
+ .appendTo( sortable.element )
809
+ .data( "ui-sortable-item", true );
810
+
811
+ // Store helper option to later restore it
812
+ sortable.options._helper = sortable.options.helper;
813
+
814
+ sortable.options.helper = function() {
815
+ return ui.helper[ 0 ];
816
+ };
817
+
818
+ // Fire the start events of the sortable with our passed browser event,
819
+ // and our own helper (so it doesn't create a new one)
820
+ event.target = sortable.currentItem[ 0 ];
821
+ sortable._mouseCapture( event, true );
822
+ sortable._mouseStart( event, true, true );
823
+
824
+ // Because the browser event is way off the new appended portlet,
825
+ // modify necessary variables to reflect the changes
826
+ sortable.offset.click.top = draggable.offset.click.top;
827
+ sortable.offset.click.left = draggable.offset.click.left;
828
+ sortable.offset.parent.left -= draggable.offset.parent.left -
829
+ sortable.offset.parent.left;
830
+ sortable.offset.parent.top -= draggable.offset.parent.top -
831
+ sortable.offset.parent.top;
832
+
833
+ draggable._trigger( "toSortable", event );
834
+
835
+ // Inform draggable that the helper is in a valid drop zone,
836
+ // used solely in the revert option to handle "valid/invalid".
837
+ draggable.dropped = sortable.element;
838
+
839
+ // Need to refreshPositions of all sortables in the case that
840
+ // adding to one sortable changes the location of the other sortables (#9675)
841
+ $.each( draggable.sortables, function() {
842
+ this.refreshPositions();
843
+ });
844
+
845
+ // hack so receive/update callbacks work (mostly)
846
+ draggable.currentItem = draggable.element;
847
+ sortable.fromOutside = draggable;
755
848
  }
756
849
 
757
- //Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable
758
- if (this.instance.currentItem) {
759
- this.instance._mouseDrag(event);
850
+ if ( sortable.currentItem ) {
851
+ sortable._mouseDrag( event );
852
+ // Copy the sortable's position because the draggable's can potentially reflect
853
+ // a relative position, while sortable is always absolute, which the dragged
854
+ // element has now become. (#8809)
855
+ ui.position = sortable.position;
760
856
  }
761
-
762
857
  } else {
858
+ // If it doesn't intersect with the sortable, and it intersected before,
859
+ // we fake the drag stop of the sortable, but make sure it doesn't remove
860
+ // the helper by using cancelHelperRemoval.
861
+ if ( sortable.isOver ) {
763
862
 
764
- //If it doesn't intersect with the sortable, and it intersected before,
765
- //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
766
- if (this.instance.isOver) {
767
-
768
- this.instance.isOver = 0;
769
- this.instance.cancelHelperRemoval = true;
863
+ sortable.isOver = 0;
864
+ sortable.cancelHelperRemoval = true;
770
865
 
771
- //Prevent reverting on this forced stop
772
- this.instance.options.revert = false;
866
+ // Calling sortable's mouseStop would trigger a revert,
867
+ // so revert must be temporarily false until after mouseStop is called.
868
+ sortable.options._revert = sortable.options.revert;
869
+ sortable.options.revert = false;
773
870
 
774
- // The out event needs to be triggered independently
775
- this.instance._trigger("out", event, this.instance._uiHash(this.instance));
871
+ sortable._trigger( "out", event, sortable._uiHash( sortable ) );
872
+ sortable._mouseStop( event, true );
776
873
 
777
- this.instance._mouseStop(event, true);
778
- this.instance.options.helper = this.instance.options._helper;
874
+ // restore sortable behaviors that were modfied
875
+ // when the draggable entered the sortable area (#9481)
876
+ sortable.options.revert = sortable.options._revert;
877
+ sortable.options.helper = sortable.options._helper;
779
878
 
780
- //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
781
- this.instance.currentItem.remove();
782
- if (this.instance.placeholder) {
783
- this.instance.placeholder.remove();
879
+ if ( sortable.placeholder ) {
880
+ sortable.placeholder.remove();
784
881
  }
785
882
 
786
- inst._trigger("fromSortable", event);
787
- inst.dropped = false; //draggable revert needs that
788
- }
883
+ // Recalculate the draggable's offset considering the sortable
884
+ // may have modified them in unexpected ways (#8809)
885
+ draggable._refreshOffsets( event );
886
+ ui.position = draggable._generatePosition( event, true );
789
887
 
790
- }
888
+ draggable._trigger( "fromSortable", event );
791
889
 
792
- });
890
+ // Inform draggable that the helper is no longer in a valid drop zone
891
+ draggable.dropped = false;
793
892
 
893
+ // Need to refreshPositions of all sortables just in case removing
894
+ // from one sortable changes the location of other sortables (#9675)
895
+ $.each( draggable.sortables, function() {
896
+ this.refreshPositions();
897
+ });
898
+ }
899
+ }
900
+ });
794
901
  }
795
902
  });
796
903
 
@@ -920,9 +1027,9 @@ $.ui.plugin.add("draggable", "snap", {
920
1027
 
921
1028
  for (i = inst.snapElements.length - 1; i >= 0; i--){
922
1029
 
923
- l = inst.snapElements[i].left;
1030
+ l = inst.snapElements[i].left - inst.margins.left;
924
1031
  r = l + inst.snapElements[i].width;
925
- t = inst.snapElements[i].top;
1032
+ t = inst.snapElements[i].top - inst.margins.top;
926
1033
  b = t + inst.snapElements[i].height;
927
1034
 
928
1035
  if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
@@ -939,16 +1046,16 @@ $.ui.plugin.add("draggable", "snap", {
939
1046
  ls = Math.abs(l - x2) <= d;
940
1047
  rs = Math.abs(r - x1) <= d;
941
1048
  if (ts) {
942
- ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
1049
+ ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top;
943
1050
  }
944
1051
  if (bs) {
945
- ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
1052
+ ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top;
946
1053
  }
947
1054
  if (ls) {
948
- ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
1055
+ ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left;
949
1056
  }
950
1057
  if (rs) {
951
- ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
1058
+ ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left;
952
1059
  }
953
1060
  }
954
1061
 
@@ -960,16 +1067,16 @@ $.ui.plugin.add("draggable", "snap", {
960
1067
  ls = Math.abs(l - x1) <= d;
961
1068
  rs = Math.abs(r - x2) <= d;
962
1069
  if (ts) {
963
- ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
1070
+ ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top;
964
1071
  }
965
1072
  if (bs) {
966
- ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
1073
+ ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top;
967
1074
  }
968
1075
  if (ls) {
969
- ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
1076
+ ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left;
970
1077
  }
971
1078
  if (rs) {
972
- ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
1079
+ ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left;
973
1080
  }
974
1081
  }
975
1082