jquery-ui-rails 3.0.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

Files changed (61) hide show
  1. data/History.md +10 -0
  2. data/README.md +1 -1
  3. data/Rakefile +4 -5
  4. data/lib/jquery/ui/rails/version.rb +1 -1
  5. data/vendor/assets/javascripts/jquery.ui.accordion.js +130 -290
  6. data/vendor/assets/javascripts/jquery.ui.autocomplete.js +30 -18
  7. data/vendor/assets/javascripts/jquery.ui.button.js +9 -8
  8. data/vendor/assets/javascripts/jquery.ui.core.js +19 -53
  9. data/vendor/assets/javascripts/jquery.ui.datepicker-be.js +23 -0
  10. data/vendor/assets/javascripts/jquery.ui.datepicker-fr-CA.js +23 -0
  11. data/vendor/assets/javascripts/jquery.ui.datepicker-ky.js +24 -0
  12. data/vendor/assets/javascripts/jquery.ui.datepicker-nb.js +22 -0
  13. data/vendor/assets/javascripts/jquery.ui.datepicker-nn.js +22 -0
  14. data/vendor/assets/javascripts/jquery.ui.datepicker.js +1076 -878
  15. data/vendor/assets/javascripts/jquery.ui.dialog.js +456 -547
  16. data/vendor/assets/javascripts/jquery.ui.draggable.js +317 -207
  17. data/vendor/assets/javascripts/jquery.ui.droppable.js +177 -100
  18. data/vendor/assets/javascripts/jquery.ui.effect-blind.js +2 -2
  19. data/vendor/assets/javascripts/jquery.ui.effect-bounce.js +2 -2
  20. data/vendor/assets/javascripts/jquery.ui.effect-clip.js +2 -2
  21. data/vendor/assets/javascripts/jquery.ui.effect-drop.js +2 -2
  22. data/vendor/assets/javascripts/jquery.ui.effect-explode.js +2 -2
  23. data/vendor/assets/javascripts/jquery.ui.effect-fade.js +2 -2
  24. data/vendor/assets/javascripts/jquery.ui.effect-fold.js +2 -2
  25. data/vendor/assets/javascripts/jquery.ui.effect-highlight.js +2 -2
  26. data/vendor/assets/javascripts/jquery.ui.effect-pulsate.js +2 -2
  27. data/vendor/assets/javascripts/jquery.ui.effect-scale.js +2 -2
  28. data/vendor/assets/javascripts/jquery.ui.effect-shake.js +2 -2
  29. data/vendor/assets/javascripts/jquery.ui.effect-slide.js +2 -2
  30. data/vendor/assets/javascripts/jquery.ui.effect-transfer.js +3 -3
  31. data/vendor/assets/javascripts/jquery.ui.effect.js +91 -99
  32. data/vendor/assets/javascripts/jquery.ui.menu.js +20 -9
  33. data/vendor/assets/javascripts/jquery.ui.mouse.js +25 -25
  34. data/vendor/assets/javascripts/jquery.ui.position.js +39 -59
  35. data/vendor/assets/javascripts/jquery.ui.progressbar.js +73 -33
  36. data/vendor/assets/javascripts/jquery.ui.resizable.js +461 -294
  37. data/vendor/assets/javascripts/jquery.ui.selectable.js +67 -51
  38. data/vendor/assets/javascripts/jquery.ui.slider.js +100 -95
  39. data/vendor/assets/javascripts/jquery.ui.sortable.js +411 -257
  40. data/vendor/assets/javascripts/jquery.ui.spinner.js +19 -5
  41. data/vendor/assets/javascripts/jquery.ui.tabs.js +47 -567
  42. data/vendor/assets/javascripts/jquery.ui.tooltip.js +14 -10
  43. data/vendor/assets/javascripts/jquery.ui.widget.js +33 -40
  44. data/vendor/assets/stylesheets/jquery.ui.accordion.css.erb +30 -8
  45. data/vendor/assets/stylesheets/jquery.ui.all.css.erb +2 -2
  46. data/vendor/assets/stylesheets/jquery.ui.autocomplete.css.erb +2 -5
  47. data/vendor/assets/stylesheets/jquery.ui.base.css.erb +2 -2
  48. data/vendor/assets/stylesheets/jquery.ui.button.css.erb +100 -26
  49. data/vendor/assets/stylesheets/jquery.ui.core.css.erb +65 -12
  50. data/vendor/assets/stylesheets/jquery.ui.datepicker.css.erb +166 -55
  51. data/vendor/assets/stylesheets/jquery.ui.dialog.css.erb +61 -14
  52. data/vendor/assets/stylesheets/jquery.ui.menu.css.erb +61 -14
  53. data/vendor/assets/stylesheets/jquery.ui.progressbar.css.erb +20 -4
  54. data/vendor/assets/stylesheets/jquery.ui.resizable.css.erb +70 -13
  55. data/vendor/assets/stylesheets/jquery.ui.selectable.css.erb +7 -3
  56. data/vendor/assets/stylesheets/jquery.ui.slider.css.erb +63 -15
  57. data/vendor/assets/stylesheets/jquery.ui.spinner.css.erb +52 -10
  58. data/vendor/assets/stylesheets/jquery.ui.tabs.css.erb +44 -10
  59. data/vendor/assets/stylesheets/jquery.ui.theme.css.erb +196 -38
  60. data/vendor/assets/stylesheets/jquery.ui.tooltip.css.erb +4 -6
  61. metadata +8 -3
@@ -6,10 +6,10 @@
6
6
  //= require jquery.ui.resizable
7
7
 
8
8
  /*!
9
- * jQuery UI Dialog 1.9.2
9
+ * jQuery UI Dialog 1.10.0
10
10
  * http://jqueryui.com
11
11
  *
12
- * Copyright 2012 jQuery Foundation and other contributors
12
+ * Copyright 2013 jQuery Foundation and other contributors
13
13
  * Released under the MIT license.
14
14
  * http://jquery.org/license
15
15
  *
@@ -26,8 +26,7 @@
26
26
  */
27
27
  (function( $, undefined ) {
28
28
 
29
- var uiDialogClasses = "ui-dialog ui-widget ui-widget-content ui-corner-all ",
30
- sizeRelatedOptions = {
29
+ var sizeRelatedOptions = {
31
30
  buttons: true,
32
31
  height: true,
33
32
  maxHeight: true,
@@ -43,19 +42,20 @@ var uiDialogClasses = "ui-dialog ui-widget ui-widget-content ui-corner-all ",
43
42
  minWidth: true
44
43
  };
45
44
 
46
- $.widget("ui.dialog", {
47
- version: "1.9.2",
45
+ $.widget( "ui.dialog", {
46
+ version: "1.10.0",
48
47
  options: {
48
+ appendTo: "body",
49
49
  autoOpen: true,
50
- buttons: {},
50
+ buttons: [],
51
51
  closeOnEscape: true,
52
52
  closeText: "close",
53
53
  dialogClass: "",
54
54
  draggable: true,
55
55
  hide: null,
56
56
  height: "auto",
57
- maxHeight: false,
58
- maxWidth: false,
57
+ maxHeight: null,
58
+ maxWidth: null,
59
59
  minHeight: 150,
60
60
  minWidth: 150,
61
61
  modal: false,
@@ -64,7 +64,7 @@ $.widget("ui.dialog", {
64
64
  at: "center",
65
65
  of: window,
66
66
  collision: "fit",
67
- // ensure that the titlebar is never outside the document
67
+ // Ensure the titlebar is always visible
68
68
  using: function( pos ) {
69
69
  var topOffset = $( this ).css( pos ).offset().top;
70
70
  if ( topOffset < 0 ) {
@@ -74,137 +74,56 @@ $.widget("ui.dialog", {
74
74
  },
75
75
  resizable: true,
76
76
  show: null,
77
- stack: true,
78
- title: "",
77
+ title: null,
79
78
  width: 300,
80
- zIndex: 1000
79
+
80
+ // callbacks
81
+ beforeClose: null,
82
+ close: null,
83
+ drag: null,
84
+ dragStart: null,
85
+ dragStop: null,
86
+ focus: null,
87
+ open: null,
88
+ resize: null,
89
+ resizeStart: null,
90
+ resizeStop: null
81
91
  },
82
92
 
83
93
  _create: function() {
84
- this.originalTitle = this.element.attr( "title" );
85
- // #5742 - .attr() might return a DOMElement
86
- if ( typeof this.originalTitle !== "string" ) {
87
- this.originalTitle = "";
88
- }
89
- this.oldPosition = {
94
+ this.originalCss = {
95
+ display: this.element[0].style.display,
96
+ width: this.element[0].style.width,
97
+ minHeight: this.element[0].style.minHeight,
98
+ maxHeight: this.element[0].style.maxHeight,
99
+ height: this.element[0].style.height
100
+ };
101
+ this.originalPosition = {
90
102
  parent: this.element.parent(),
91
103
  index: this.element.parent().children().index( this.element )
92
104
  };
105
+ this.originalTitle = this.element.attr("title");
93
106
  this.options.title = this.options.title || this.originalTitle;
94
- var that = this,
95
- options = this.options,
96
107
 
97
- title = options.title || "&#160;",
98
- uiDialog,
99
- uiDialogTitlebar,
100
- uiDialogTitlebarClose,
101
- uiDialogTitle,
102
- uiDialogButtonPane;
103
-
104
- uiDialog = ( this.uiDialog = $( "<div>" ) )
105
- .addClass( uiDialogClasses + options.dialogClass )
106
- .css({
107
- display: "none",
108
- outline: 0, // TODO: move to stylesheet
109
- zIndex: options.zIndex
110
- })
111
- // setting tabIndex makes the div focusable
112
- .attr( "tabIndex", -1)
113
- .keydown(function( event ) {
114
- if ( options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
115
- event.keyCode === $.ui.keyCode.ESCAPE ) {
116
- that.close( event );
117
- event.preventDefault();
118
- }
119
- })
120
- .mousedown(function( event ) {
121
- that.moveToTop( false, event );
122
- })
123
- .appendTo( "body" );
124
-
125
- this.element
126
- .show()
127
- .removeAttr( "title" )
128
- .addClass( "ui-dialog-content ui-widget-content" )
129
- .appendTo( uiDialog );
130
-
131
- uiDialogTitlebar = ( this.uiDialogTitlebar = $( "<div>" ) )
132
- .addClass( "ui-dialog-titlebar ui-widget-header " +
133
- "ui-corner-all ui-helper-clearfix" )
134
- .bind( "mousedown", function() {
135
- // Dialog isn't getting focus when dragging (#8063)
136
- uiDialog.focus();
137
- })
138
- .prependTo( uiDialog );
139
-
140
- uiDialogTitlebarClose = $( "<a href='#'></a>" )
141
- .addClass( "ui-dialog-titlebar-close ui-corner-all" )
142
- .attr( "role", "button" )
143
- .click(function( event ) {
144
- event.preventDefault();
145
- that.close( event );
146
- })
147
- .appendTo( uiDialogTitlebar );
148
-
149
- ( this.uiDialogTitlebarCloseText = $( "<span>" ) )
150
- .addClass( "ui-icon ui-icon-closethick" )
151
- .text( options.closeText )
152
- .appendTo( uiDialogTitlebarClose );
153
-
154
- uiDialogTitle = $( "<span>" )
155
- .uniqueId()
156
- .addClass( "ui-dialog-title" )
157
- .html( title )
158
- .prependTo( uiDialogTitlebar );
159
-
160
- uiDialogButtonPane = ( this.uiDialogButtonPane = $( "<div>" ) )
161
- .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" );
162
-
163
- ( this.uiButtonSet = $( "<div>" ) )
164
- .addClass( "ui-dialog-buttonset" )
165
- .appendTo( uiDialogButtonPane );
166
-
167
- uiDialog.attr({
168
- role: "dialog",
169
- "aria-labelledby": uiDialogTitle.attr( "id" )
170
- });
108
+ this._createWrapper();
109
+
110
+ this.element
111
+ .show()
112
+ .removeAttr("title")
113
+ .addClass("ui-dialog-content ui-widget-content")
114
+ .appendTo( this.uiDialog );
171
115
 
172
- uiDialogTitlebar.find( "*" ).add( uiDialogTitlebar ).disableSelection();
173
- this._hoverable( uiDialogTitlebarClose );
174
- this._focusable( uiDialogTitlebarClose );
116
+ this._createTitlebar();
117
+ this._createButtonPane();
175
118
 
176
- if ( options.draggable && $.fn.draggable ) {
119
+ if ( this.options.draggable && $.fn.draggable ) {
177
120
  this._makeDraggable();
178
121
  }
179
- if ( options.resizable && $.fn.resizable ) {
122
+ if ( this.options.resizable && $.fn.resizable ) {
180
123
  this._makeResizable();
181
124
  }
182
125
 
183
- this._createButtons( options.buttons );
184
126
  this._isOpen = false;
185
-
186
- if ( $.fn.bgiframe ) {
187
- uiDialog.bgiframe();
188
- }
189
-
190
- // prevent tabbing out of modal dialogs
191
- this._on( uiDialog, { keydown: function( event ) {
192
- if ( !options.modal || event.keyCode !== $.ui.keyCode.TAB ) {
193
- return;
194
- }
195
-
196
- var tabbables = $( ":tabbable", uiDialog ),
197
- first = tabbables.filter( ":first" ),
198
- last = tabbables.filter( ":last" );
199
-
200
- if ( event.target === last[0] && !event.shiftKey ) {
201
- first.focus( 1 );
202
- return false;
203
- } else if ( event.target === first[0] && event.shiftKey ) {
204
- last.focus( 1 );
205
- return false;
206
- }
207
- }});
208
127
  },
209
128
 
210
129
  _init: function() {
@@ -213,30 +132,39 @@ $.widget("ui.dialog", {
213
132
  }
214
133
  },
215
134
 
135
+ _appendTo: function() {
136
+ var element = this.options.appendTo;
137
+ if ( element && (element.jquery || element.nodeType) ) {
138
+ return $( element );
139
+ }
140
+ return this.document.find( element || "body" ).eq( 0 );
141
+ },
142
+
216
143
  _destroy: function() {
217
144
  var next,
218
- oldPosition = this.oldPosition;
145
+ originalPosition = this.originalPosition;
146
+
147
+ this._destroyOverlay();
219
148
 
220
- if ( this.overlay ) {
221
- this.overlay.destroy();
222
- }
223
- this.uiDialog.hide();
224
149
  this.element
225
- .removeClass( "ui-dialog-content ui-widget-content" )
226
- .hide()
227
- .appendTo( "body" );
228
- this.uiDialog.remove();
150
+ .removeUniqueId()
151
+ .removeClass("ui-dialog-content ui-widget-content")
152
+ .css( this.originalCss )
153
+ // Without detaching first, the following becomes really slow
154
+ .detach();
155
+
156
+ this.uiDialog.stop( true, true ).remove();
229
157
 
230
158
  if ( this.originalTitle ) {
231
159
  this.element.attr( "title", this.originalTitle );
232
160
  }
233
161
 
234
- next = oldPosition.parent.children().eq( oldPosition.index );
162
+ next = originalPosition.parent.children().eq( originalPosition.index );
235
163
  // Don't try to place the dialog next to itself (#8613)
236
- if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
164
+ if ( next.length && next[0] !== this.element[0] ) {
237
165
  next.before( this.element );
238
166
  } else {
239
- oldPosition.parent.append( this.element );
167
+ originalPosition.parent.append( this.element );
240
168
  }
241
169
  },
242
170
 
@@ -244,160 +172,265 @@ $.widget("ui.dialog", {
244
172
  return this.uiDialog;
245
173
  },
246
174
 
247
- close: function( event ) {
248
- var that = this,
249
- maxZ, thisZ;
175
+ disable: $.noop,
176
+ enable: $.noop,
250
177
 
251
- if ( !this._isOpen ) {
252
- return;
253
- }
178
+ close: function( event ) {
179
+ var that = this;
254
180
 
255
- if ( false === this._trigger( "beforeClose", event ) ) {
181
+ if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
256
182
  return;
257
183
  }
258
184
 
259
185
  this._isOpen = false;
186
+ this._destroyOverlay();
260
187
 
261
- if ( this.overlay ) {
262
- this.overlay.destroy();
263
- }
264
-
265
- if ( this.options.hide ) {
266
- this._hide( this.uiDialog, this.options.hide, function() {
267
- that._trigger( "close", event );
268
- });
269
- } else {
270
- this.uiDialog.hide();
271
- this._trigger( "close", event );
272
- }
273
-
274
- $.ui.dialog.overlay.resize();
275
-
276
- // adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
277
- if ( this.options.modal ) {
278
- maxZ = 0;
279
- $( ".ui-dialog" ).each(function() {
280
- if ( this !== that.uiDialog[0] ) {
281
- thisZ = $( this ).css( "z-index" );
282
- if ( !isNaN( thisZ ) ) {
283
- maxZ = Math.max( maxZ, thisZ );
284
- }
285
- }
286
- });
287
- $.ui.dialog.maxZ = maxZ;
188
+ if ( !this.opener.filter(":focusable").focus().length ) {
189
+ // Hiding a focused element doesn't trigger blur in WebKit
190
+ // so in case we have nothing to focus on, explicitly blur the active element
191
+ // https://bugs.webkit.org/show_bug.cgi?id=47182
192
+ $( this.document[0].activeElement ).blur();
288
193
  }
289
194
 
290
- return this;
195
+ this._hide( this.uiDialog, this.options.hide, function() {
196
+ that._trigger( "close", event );
197
+ });
291
198
  },
292
199
 
293
200
  isOpen: function() {
294
201
  return this._isOpen;
295
202
  },
296
203
 
297
- // the force parameter allows us to move modal dialogs to their correct
298
- // position on open
299
- moveToTop: function( force, event ) {
300
- var options = this.options,
301
- saveScroll;
302
-
303
- if ( ( options.modal && !force ) ||
304
- ( !options.stack && !options.modal ) ) {
305
- return this._trigger( "focus", event );
306
- }
204
+ moveToTop: function() {
205
+ this._moveToTop();
206
+ },
307
207
 
308
- if ( options.zIndex > $.ui.dialog.maxZ ) {
309
- $.ui.dialog.maxZ = options.zIndex;
310
- }
311
- if ( this.overlay ) {
312
- $.ui.dialog.maxZ += 1;
313
- $.ui.dialog.overlay.maxZ = $.ui.dialog.maxZ;
314
- this.overlay.$el.css( "z-index", $.ui.dialog.overlay.maxZ );
208
+ _moveToTop: function( event, silent ) {
209
+ var moved = !!this.uiDialog.nextAll(":visible").insertBefore( this.uiDialog ).length;
210
+ if ( moved && !silent ) {
211
+ this._trigger( "focus", event );
315
212
  }
316
-
317
- // Save and then restore scroll
318
- // Opera 9.5+ resets when parent z-index is changed.
319
- // http://bugs.jqueryui.com/ticket/3193
320
- saveScroll = {
321
- scrollTop: this.element.scrollTop(),
322
- scrollLeft: this.element.scrollLeft()
323
- };
324
- $.ui.dialog.maxZ += 1;
325
- this.uiDialog.css( "z-index", $.ui.dialog.maxZ );
326
- this.element.attr( saveScroll );
327
- this._trigger( "focus", event );
328
-
329
- return this;
213
+ return moved;
330
214
  },
331
215
 
332
216
  open: function() {
333
217
  if ( this._isOpen ) {
218
+ if ( this._moveToTop() ) {
219
+ this._focusTabbable();
220
+ }
334
221
  return;
335
222
  }
336
223
 
337
- var hasFocus,
338
- options = this.options,
339
- uiDialog = this.uiDialog;
224
+ this.opener = $( this.document[0].activeElement );
340
225
 
341
226
  this._size();
342
- this._position( options.position );
343
- uiDialog.show( options.show );
344
- this.overlay = options.modal ? new $.ui.dialog.overlay( this ) : null;
345
- this.moveToTop( true );
346
-
347
- // set focus to the first tabbable element in the content area or the first button
348
- // if there are no tabbable elements, set focus on the dialog itself
349
- hasFocus = this.element.find( ":tabbable" );
227
+ this._position();
228
+ this._createOverlay();
229
+ this._moveToTop( null, true );
230
+ this._show( this.uiDialog, this.options.show );
231
+
232
+ this._focusTabbable();
233
+
234
+ this._isOpen = true;
235
+ this._trigger("open");
236
+ this._trigger("focus");
237
+ },
238
+
239
+ _focusTabbable: function() {
240
+ // Set focus to the first match:
241
+ // 1. First element inside the dialog matching [autofocus]
242
+ // 2. Tabbable element inside the content element
243
+ // 3. Tabbable element inside the buttonpane
244
+ // 4. The close button
245
+ // 5. The dialog itself
246
+ var hasFocus = this.element.find("[autofocus]");
350
247
  if ( !hasFocus.length ) {
351
- hasFocus = this.uiDialogButtonPane.find( ":tabbable" );
352
- if ( !hasFocus.length ) {
353
- hasFocus = uiDialog;
354
- }
248
+ hasFocus = this.element.find(":tabbable");
249
+ }
250
+ if ( !hasFocus.length ) {
251
+ hasFocus = this.uiDialogButtonPane.find(":tabbable");
252
+ }
253
+ if ( !hasFocus.length ) {
254
+ hasFocus = this.uiDialogTitlebarClose.filter(":tabbable");
255
+ }
256
+ if ( !hasFocus.length ) {
257
+ hasFocus = this.uiDialog;
355
258
  }
356
259
  hasFocus.eq( 0 ).focus();
260
+ },
357
261
 
358
- this._isOpen = true;
359
- this._trigger( "open" );
262
+ _keepFocus: function( event ) {
263
+ function checkFocus() {
264
+ var activeElement = this.document[0].activeElement,
265
+ isActive = this.uiDialog[0] === activeElement ||
266
+ $.contains( this.uiDialog[0], activeElement );
267
+ if ( !isActive ) {
268
+ this._focusTabbable();
269
+ }
270
+ }
271
+ event.preventDefault();
272
+ checkFocus.call( this );
273
+ // support: IE
274
+ // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
275
+ // so we check again later
276
+ this._delay( checkFocus );
277
+ },
360
278
 
361
- return this;
279
+ _createWrapper: function() {
280
+ this.uiDialog = $("<div>")
281
+ .addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " +
282
+ this.options.dialogClass )
283
+ .hide()
284
+ .attr({
285
+ // Setting tabIndex makes the div focusable
286
+ tabIndex: -1,
287
+ role: "dialog"
288
+ })
289
+ .appendTo( this._appendTo() );
290
+
291
+ this._on( this.uiDialog, {
292
+ keydown: function( event ) {
293
+ if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
294
+ event.keyCode === $.ui.keyCode.ESCAPE ) {
295
+ event.preventDefault();
296
+ this.close( event );
297
+ return;
298
+ }
299
+
300
+ // prevent tabbing out of dialogs
301
+ if ( event.keyCode !== $.ui.keyCode.TAB ) {
302
+ return;
303
+ }
304
+ var tabbables = this.uiDialog.find(":tabbable"),
305
+ first = tabbables.filter(":first"),
306
+ last = tabbables.filter(":last");
307
+
308
+ if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) {
309
+ first.focus( 1 );
310
+ event.preventDefault();
311
+ } else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) {
312
+ last.focus( 1 );
313
+ event.preventDefault();
314
+ }
315
+ },
316
+ mousedown: function( event ) {
317
+ if ( this._moveToTop( event ) ) {
318
+ this._focusTabbable();
319
+ }
320
+ }
321
+ });
322
+
323
+ // We assume that any existing aria-describedby attribute means
324
+ // that the dialog content is marked up properly
325
+ // otherwise we brute force the content as the description
326
+ if ( !this.element.find("[aria-describedby]").length ) {
327
+ this.uiDialog.attr({
328
+ "aria-describedby": this.element.uniqueId().attr("id")
329
+ });
330
+ }
362
331
  },
363
332
 
364
- _createButtons: function( buttons ) {
333
+ _createTitlebar: function() {
334
+ var uiDialogTitle;
335
+
336
+ this.uiDialogTitlebar = $("<div>")
337
+ .addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix")
338
+ .prependTo( this.uiDialog );
339
+ this._on( this.uiDialogTitlebar, {
340
+ mousedown: function( event ) {
341
+ // Don't prevent click on close button (#8838)
342
+ // Focusing a dialog that is partially scrolled out of view
343
+ // causes the browser to scroll it into view, preventing the click event
344
+ if ( !$( event.target ).closest(".ui-dialog-titlebar-close") ) {
345
+ // Dialog isn't getting focus when dragging (#8063)
346
+ this.uiDialog.focus();
347
+ }
348
+ }
349
+ });
350
+
351
+ this.uiDialogTitlebarClose = $("<button></button>")
352
+ .button({
353
+ label: this.options.closeText,
354
+ icons: {
355
+ primary: "ui-icon-closethick"
356
+ },
357
+ text: false
358
+ })
359
+ .addClass("ui-dialog-titlebar-close")
360
+ .appendTo( this.uiDialogTitlebar );
361
+ this._on( this.uiDialogTitlebarClose, {
362
+ click: function( event ) {
363
+ event.preventDefault();
364
+ this.close( event );
365
+ }
366
+ });
367
+
368
+ uiDialogTitle = $("<span>")
369
+ .uniqueId()
370
+ .addClass("ui-dialog-title")
371
+ .prependTo( this.uiDialogTitlebar );
372
+ this._title( uiDialogTitle );
373
+
374
+ this.uiDialog.attr({
375
+ "aria-labelledby": uiDialogTitle.attr("id")
376
+ });
377
+ },
378
+
379
+ _title: function( title ) {
380
+ if ( !this.options.title ) {
381
+ title.html("&#160;");
382
+ }
383
+ title.text( this.options.title );
384
+ },
385
+
386
+ _createButtonPane: function() {
387
+ this.uiDialogButtonPane = $("<div>")
388
+ .addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix");
389
+
390
+ this.uiButtonSet = $("<div>")
391
+ .addClass("ui-dialog-buttonset")
392
+ .appendTo( this.uiDialogButtonPane );
393
+
394
+ this._createButtons();
395
+ },
396
+
397
+ _createButtons: function() {
365
398
  var that = this,
366
- hasButtons = false;
399
+ buttons = this.options.buttons;
367
400
 
368
401
  // if we already have a button pane, remove it
369
402
  this.uiDialogButtonPane.remove();
370
403
  this.uiButtonSet.empty();
371
404
 
372
- if ( typeof buttons === "object" && buttons !== null ) {
373
- $.each( buttons, function() {
374
- return !(hasButtons = true);
375
- });
376
- }
377
- if ( hasButtons ) {
378
- $.each( buttons, function( name, props ) {
379
- var button, click;
380
- props = $.isFunction( props ) ?
381
- { click: props, text: name } :
382
- props;
383
- // Default to a non-submitting button
384
- props = $.extend( { type: "button" }, props );
385
- // Change the context for the click callback to be the main element
386
- click = props.click;
387
- props.click = function() {
388
- click.apply( that.element[0], arguments );
389
- };
390
- button = $( "<button></button>", props )
391
- .appendTo( that.uiButtonSet );
392
- if ( $.fn.button ) {
393
- button.button();
394
- }
395
- });
396
- this.uiDialog.addClass( "ui-dialog-buttons" );
397
- this.uiDialogButtonPane.appendTo( this.uiDialog );
398
- } else {
399
- this.uiDialog.removeClass( "ui-dialog-buttons" );
405
+ if ( $.isEmptyObject( buttons ) ) {
406
+ this.uiDialog.removeClass("ui-dialog-buttons");
407
+ return;
400
408
  }
409
+
410
+ $.each( buttons, function( name, props ) {
411
+ var click, buttonOptions;
412
+ props = $.isFunction( props ) ?
413
+ { click: props, text: name } :
414
+ props;
415
+ // Default to a non-submitting button
416
+ props = $.extend( { type: "button" }, props );
417
+ // Change the context for the click callback to be the main element
418
+ click = props.click;
419
+ props.click = function() {
420
+ click.apply( that.element[0], arguments );
421
+ };
422
+ buttonOptions = {
423
+ icons: props.icons,
424
+ text: props.showText
425
+ };
426
+ delete props.icons;
427
+ delete props.showText;
428
+ $( "<button></button>", props )
429
+ .button( buttonOptions )
430
+ .appendTo( that.uiButtonSet );
431
+ });
432
+ this.uiDialog.addClass("ui-dialog-buttons");
433
+ this.uiDialogButtonPane.appendTo( this.uiDialog );
401
434
  },
402
435
 
403
436
  _makeDraggable: function() {
@@ -416,8 +449,7 @@ $.widget("ui.dialog", {
416
449
  handle: ".ui-dialog-titlebar",
417
450
  containment: "document",
418
451
  start: function( event, ui ) {
419
- $( this )
420
- .addClass( "ui-dialog-dragging" );
452
+ $( this ).addClass("ui-dialog-dragging");
421
453
  that._trigger( "dragStart", event, filteredUi( ui ) );
422
454
  },
423
455
  drag: function( event, ui ) {
@@ -428,22 +460,20 @@ $.widget("ui.dialog", {
428
460
  ui.position.left - that.document.scrollLeft(),
429
461
  ui.position.top - that.document.scrollTop()
430
462
  ];
431
- $( this )
432
- .removeClass( "ui-dialog-dragging" );
463
+ $( this ).removeClass("ui-dialog-dragging");
433
464
  that._trigger( "dragStop", event, filteredUi( ui ) );
434
- $.ui.dialog.overlay.resize();
435
465
  }
436
466
  });
437
467
  },
438
468
 
439
- _makeResizable: function( handles ) {
440
- handles = (handles === undefined ? this.options.resizable : handles);
469
+ _makeResizable: function() {
441
470
  var that = this,
442
471
  options = this.options,
472
+ handles = options.resizable,
443
473
  // .ui-resizable has position: relative defined in the stylesheet
444
474
  // but dialogs have to use absolute or fixed positioning
445
- position = this.uiDialog.css( "position" ),
446
- resizeHandles = typeof handles === 'string' ?
475
+ position = this.uiDialog.css("position"),
476
+ resizeHandles = typeof handles === "string" ?
447
477
  handles :
448
478
  "n,e,s,w,se,sw,ne,nw";
449
479
 
@@ -466,76 +496,37 @@ $.widget("ui.dialog", {
466
496
  minHeight: this._minHeight(),
467
497
  handles: resizeHandles,
468
498
  start: function( event, ui ) {
469
- $( this ).addClass( "ui-dialog-resizing" );
499
+ $( this ).addClass("ui-dialog-resizing");
470
500
  that._trigger( "resizeStart", event, filteredUi( ui ) );
471
501
  },
472
502
  resize: function( event, ui ) {
473
503
  that._trigger( "resize", event, filteredUi( ui ) );
474
504
  },
475
505
  stop: function( event, ui ) {
476
- $( this ).removeClass( "ui-dialog-resizing" );
477
506
  options.height = $( this ).height();
478
507
  options.width = $( this ).width();
508
+ $( this ).removeClass("ui-dialog-resizing");
479
509
  that._trigger( "resizeStop", event, filteredUi( ui ) );
480
- $.ui.dialog.overlay.resize();
481
510
  }
482
511
  })
483
- .css( "position", position )
484
- .find( ".ui-resizable-se" )
485
- .addClass( "ui-icon ui-icon-grip-diagonal-se" );
512
+ .css( "position", position );
486
513
  },
487
514
 
488
515
  _minHeight: function() {
489
516
  var options = this.options;
490
517
 
491
- if ( options.height === "auto" ) {
492
- return options.minHeight;
493
- } else {
494
- return Math.min( options.minHeight, options.height );
495
- }
518
+ return options.height === "auto" ?
519
+ options.minHeight :
520
+ Math.min( options.minHeight, options.height );
496
521
  },
497
522
 
498
- _position: function( position ) {
499
- var myAt = [],
500
- offset = [ 0, 0 ],
501
- isVisible;
502
-
503
- if ( position ) {
504
- // deep extending converts arrays to objects in jQuery <= 1.3.2 :-(
505
- // if (typeof position == 'string' || $.isArray(position)) {
506
- // myAt = $.isArray(position) ? position : position.split(' ');
507
-
508
- if ( typeof position === "string" || (typeof position === "object" && "0" in position ) ) {
509
- myAt = position.split ? position.split( " " ) : [ position[ 0 ], position[ 1 ] ];
510
- if ( myAt.length === 1 ) {
511
- myAt[ 1 ] = myAt[ 0 ];
512
- }
513
-
514
- $.each( [ "left", "top" ], function( i, offsetPosition ) {
515
- if ( +myAt[ i ] === myAt[ i ] ) {
516
- offset[ i ] = myAt[ i ];
517
- myAt[ i ] = offsetPosition;
518
- }
519
- });
520
-
521
- position = {
522
- my: myAt[0] + (offset[0] < 0 ? offset[0] : "+" + offset[0]) + " " +
523
- myAt[1] + (offset[1] < 0 ? offset[1] : "+" + offset[1]),
524
- at: myAt.join( " " )
525
- };
526
- }
527
-
528
- position = $.extend( {}, $.ui.dialog.prototype.options.position, position );
529
- } else {
530
- position = $.ui.dialog.prototype.options.position;
531
- }
532
-
533
- // need to show the dialog to get the actual offset in the position plugin
534
- isVisible = this.uiDialog.is( ":visible" );
523
+ _position: function() {
524
+ // Need to show the dialog to get the actual offset in the position plugin
525
+ var isVisible = this.uiDialog.is(":visible");
535
526
  if ( !isVisible ) {
536
527
  this.uiDialog.show();
537
528
  }
538
- this.uiDialog.position( position );
529
+ this.uiDialog.position( this.options.position );
539
530
  if ( !isVisible ) {
540
531
  this.uiDialog.hide();
541
532
  }
@@ -543,8 +534,8 @@ $.widget("ui.dialog", {
543
534
 
544
535
  _setOptions: function( options ) {
545
536
  var that = this,
546
- resizableOptions = {},
547
- resize = false;
537
+ resize = false,
538
+ resizableOptions = {};
548
539
 
549
540
  $.each( options, function( key, value ) {
550
541
  that._setOption( key, value );
@@ -559,88 +550,94 @@ $.widget("ui.dialog", {
559
550
 
560
551
  if ( resize ) {
561
552
  this._size();
553
+ this._position();
562
554
  }
563
- if ( this.uiDialog.is( ":data(resizable)" ) ) {
555
+ if ( this.uiDialog.is(":data(ui-resizable)") ) {
564
556
  this.uiDialog.resizable( "option", resizableOptions );
565
557
  }
566
558
  },
567
559
 
568
560
  _setOption: function( key, value ) {
561
+ /*jshint maxcomplexity:15*/
569
562
  var isDraggable, isResizable,
570
563
  uiDialog = this.uiDialog;
571
564
 
572
- switch ( key ) {
573
- case "buttons":
574
- this._createButtons( value );
575
- break;
576
- case "closeText":
577
- // ensure that we always pass a string
578
- this.uiDialogTitlebarCloseText.text( "" + value );
579
- break;
580
- case "dialogClass":
581
- uiDialog
582
- .removeClass( this.options.dialogClass )
583
- .addClass( uiDialogClasses + value );
584
- break;
585
- case "disabled":
586
- if ( value ) {
587
- uiDialog.addClass( "ui-dialog-disabled" );
588
- } else {
589
- uiDialog.removeClass( "ui-dialog-disabled" );
590
- }
591
- break;
592
- case "draggable":
593
- isDraggable = uiDialog.is( ":data(draggable)" );
594
- if ( isDraggable && !value ) {
595
- uiDialog.draggable( "destroy" );
596
- }
565
+ if ( key === "dialogClass" ) {
566
+ uiDialog
567
+ .removeClass( this.options.dialogClass )
568
+ .addClass( value );
569
+ }
597
570
 
598
- if ( !isDraggable && value ) {
599
- this._makeDraggable();
600
- }
601
- break;
602
- case "position":
603
- this._position( value );
604
- break;
605
- case "resizable":
606
- // currently resizable, becoming non-resizable
607
- isResizable = uiDialog.is( ":data(resizable)" );
608
- if ( isResizable && !value ) {
609
- uiDialog.resizable( "destroy" );
610
- }
571
+ if ( key === "disabled" ) {
572
+ return;
573
+ }
611
574
 
612
- // currently resizable, changing handles
613
- if ( isResizable && typeof value === "string" ) {
614
- uiDialog.resizable( "option", "handles", value );
615
- }
575
+ this._super( key, value );
616
576
 
617
- // currently non-resizable, becoming resizable
618
- if ( !isResizable && value !== false ) {
619
- this._makeResizable( value );
620
- }
621
- break;
622
- case "title":
623
- // convert whatever was passed in o a string, for html() to not throw up
624
- $( ".ui-dialog-title", this.uiDialogTitlebar )
625
- .html( "" + ( value || "&#160;" ) );
626
- break;
577
+ if ( key === "appendTo" ) {
578
+ this.uiDialog.appendTo( this._appendTo() );
627
579
  }
628
580
 
629
- this._super( key, value );
581
+ if ( key === "buttons" ) {
582
+ this._createButtons();
583
+ }
584
+
585
+ if ( key === "closeText" ) {
586
+ this.uiDialogTitlebarClose.button({
587
+ // Ensure that we always pass a string
588
+ label: "" + value
589
+ });
590
+ }
591
+
592
+ if ( key === "draggable" ) {
593
+ isDraggable = uiDialog.is(":data(ui-draggable)");
594
+ if ( isDraggable && !value ) {
595
+ uiDialog.draggable("destroy");
596
+ }
597
+
598
+ if ( !isDraggable && value ) {
599
+ this._makeDraggable();
600
+ }
601
+ }
602
+
603
+ if ( key === "position" ) {
604
+ this._position();
605
+ }
606
+
607
+ if ( key === "resizable" ) {
608
+ // currently resizable, becoming non-resizable
609
+ isResizable = uiDialog.is(":data(ui-resizable)");
610
+ if ( isResizable && !value ) {
611
+ uiDialog.resizable("destroy");
612
+ }
613
+
614
+ // currently resizable, changing handles
615
+ if ( isResizable && typeof value === "string" ) {
616
+ uiDialog.resizable( "option", "handles", value );
617
+ }
618
+
619
+ // currently non-resizable, becoming resizable
620
+ if ( !isResizable && value !== false ) {
621
+ this._makeResizable();
622
+ }
623
+ }
624
+
625
+ if ( key === "title" ) {
626
+ this._title( this.uiDialogTitlebar.find(".ui-dialog-title") );
627
+ }
630
628
  },
631
629
 
632
630
  _size: function() {
633
- /* If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
634
- * divs will both have width and height set, so we need to reset them
635
- */
636
- var nonContentHeight, minContentHeight, autoHeight,
637
- options = this.options,
638
- isVisible = this.uiDialog.is( ":visible" );
631
+ // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
632
+ // divs will both have width and height set, so we need to reset them
633
+ var nonContentHeight, minContentHeight, maxContentHeight,
634
+ options = this.options;
639
635
 
640
- // reset content sizing
636
+ // Reset content sizing
641
637
  this.element.show().css({
642
638
  width: "auto",
643
639
  minHeight: 0,
640
+ maxHeight: "none",
644
641
  height: 0
645
642
  });
646
643
 
@@ -656,210 +653,122 @@ $.widget("ui.dialog", {
656
653
  })
657
654
  .outerHeight();
658
655
  minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
656
+ maxContentHeight = typeof options.maxHeight === "number" ?
657
+ Math.max( 0, options.maxHeight - nonContentHeight ) :
658
+ "none";
659
659
 
660
660
  if ( options.height === "auto" ) {
661
- // only needed for IE6 support
662
- if ( $.support.minHeight ) {
663
- this.element.css({
664
- minHeight: minContentHeight,
665
- height: "auto"
666
- });
667
- } else {
668
- this.uiDialog.show();
669
- autoHeight = this.element.css( "height", "auto" ).height();
670
- if ( !isVisible ) {
671
- this.uiDialog.hide();
672
- }
673
- this.element.height( Math.max( autoHeight, minContentHeight ) );
674
- }
661
+ this.element.css({
662
+ minHeight: minContentHeight,
663
+ maxHeight: maxContentHeight,
664
+ height: "auto"
665
+ });
675
666
  } else {
676
- this.element.height( Math.max( options.height - nonContentHeight, 0 ) );
667
+ this.element.height( Math.max( 0, options.height - nonContentHeight ) );
677
668
  }
678
669
 
679
- if (this.uiDialog.is( ":data(resizable)" ) ) {
670
+ if (this.uiDialog.is(":data(ui-resizable)") ) {
680
671
  this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
681
672
  }
682
- }
683
- });
684
-
685
- $.extend($.ui.dialog, {
686
- uuid: 0,
687
- maxZ: 0,
688
-
689
- getTitleId: function($el) {
690
- var id = $el.attr( "id" );
691
- if ( !id ) {
692
- this.uuid += 1;
693
- id = this.uuid;
694
- }
695
- return "ui-dialog-title-" + id;
696
673
  },
697
674
 
698
- overlay: function( dialog ) {
699
- this.$el = $.ui.dialog.overlay.create( dialog );
700
- }
701
- });
675
+ _createOverlay: function() {
676
+ if ( !this.options.modal ) {
677
+ return;
678
+ }
702
679
 
703
- $.extend( $.ui.dialog.overlay, {
704
- instances: [],
705
- // reuse old instances due to IE memory leak with alpha transparency (see #5185)
706
- oldInstances: [],
707
- maxZ: 0,
708
- events: $.map(
709
- "focus,mousedown,mouseup,keydown,keypress,click".split( "," ),
710
- function( event ) {
711
- return event + ".dialog-overlay";
712
- }
713
- ).join( " " ),
714
- create: function( dialog ) {
715
- if ( this.instances.length === 0 ) {
716
- // prevent use of anchors and inputs
717
- // we use a setTimeout in case the overlay is created from an
718
- // event that we're going to be cancelling (see #2804)
719
- setTimeout(function() {
720
- // handle $(el).dialog().dialog('close') (see #4065)
721
- if ( $.ui.dialog.overlay.instances.length ) {
722
- $( document ).bind( $.ui.dialog.overlay.events, function( event ) {
723
- // stop events if the z-index of the target is < the z-index of the overlay
724
- // we cannot return true when we don't want to cancel the event (#3523)
725
- if ( $( event.target ).zIndex() < $.ui.dialog.overlay.maxZ ) {
726
- return false;
680
+ if ( !$.ui.dialog.overlayInstances ) {
681
+ // Prevent use of anchors and inputs.
682
+ // We use a delay in case the overlay is created from an
683
+ // event that we're going to be cancelling. (#2804)
684
+ this._delay(function() {
685
+ // Handle .dialog().dialog("close") (#4065)
686
+ 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
+ }
727
694
  }
728
695
  });
729
696
  }
730
- }, 1 );
731
-
732
- // handle window resize
733
- $( window ).bind( "resize.dialog-overlay", $.ui.dialog.overlay.resize );
697
+ });
734
698
  }
735
699
 
736
- var $el = ( this.oldInstances.pop() || $( "<div>" ).addClass( "ui-widget-overlay" ) );
737
-
738
- // allow closing by pressing the escape key
739
- $( document ).bind( "keydown.dialog-overlay", function( event ) {
740
- var instances = $.ui.dialog.overlay.instances;
741
- // only react to the event if we're the top overlay
742
- if ( instances.length !== 0 && instances[ instances.length - 1 ] === $el &&
743
- dialog.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
744
- event.keyCode === $.ui.keyCode.ESCAPE ) {
745
-
746
- dialog.close( event );
747
- event.preventDefault();
748
- }
700
+ this.overlay = $("<div>")
701
+ .addClass("ui-widget-overlay ui-front")
702
+ .appendTo( this.document[0].body );
703
+ this._on( this.overlay, {
704
+ mousedown: "_keepFocus"
749
705
  });
750
-
751
- $el.appendTo( document.body ).css({
752
- width: this.width(),
753
- height: this.height()
754
- });
755
-
756
- if ( $.fn.bgiframe ) {
757
- $el.bgiframe();
758
- }
759
-
760
- this.instances.push( $el );
761
- return $el;
706
+ $.ui.dialog.overlayInstances++;
762
707
  },
763
708
 
764
- destroy: function( $el ) {
765
- var indexOf = $.inArray( $el, this.instances ),
766
- maxZ = 0;
767
-
768
- if ( indexOf !== -1 ) {
769
- this.oldInstances.push( this.instances.splice( indexOf, 1 )[ 0 ] );
709
+ _destroyOverlay: function() {
710
+ if ( !this.options.modal ) {
711
+ return;
770
712
  }
771
713
 
772
- if ( this.instances.length === 0 ) {
773
- $( [ document, window ] ).unbind( ".dialog-overlay" );
714
+ $.ui.dialog.overlayInstances--;
715
+ if ( !$.ui.dialog.overlayInstances ) {
716
+ this._off( this.document, "focusin" );
774
717
  }
718
+ this.overlay.remove();
719
+ }
720
+ });
775
721
 
776
- $el.height( 0 ).width( 0 ).remove();
722
+ $.ui.dialog.overlayInstances = 0;
723
+
724
+ // DEPRECATED
725
+ if ( $.uiBackCompat !== false ) {
726
+ // position option with array notation
727
+ // just override with old implementation
728
+ $.widget( "ui.dialog", $.ui.dialog, {
729
+ _position: function() {
730
+ var position = this.options.position,
731
+ myAt = [],
732
+ offset = [ 0, 0 ],
733
+ isVisible;
734
+
735
+ if ( position ) {
736
+ if ( typeof position === "string" || (typeof position === "object" && "0" in position ) ) {
737
+ myAt = position.split ? position.split(" ") : [ position[0], position[1] ];
738
+ if ( myAt.length === 1 ) {
739
+ myAt[1] = myAt[0];
740
+ }
777
741
 
778
- // adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
779
- $.each( this.instances, function() {
780
- maxZ = Math.max( maxZ, this.css( "z-index" ) );
781
- });
782
- this.maxZ = maxZ;
783
- },
742
+ $.each( [ "left", "top" ], function( i, offsetPosition ) {
743
+ if ( +myAt[ i ] === myAt[ i ] ) {
744
+ offset[ i ] = myAt[ i ];
745
+ myAt[ i ] = offsetPosition;
746
+ }
747
+ });
784
748
 
785
- height: function() {
786
- var scrollHeight,
787
- offsetHeight;
788
- // handle IE
789
- if ( $.ui.ie ) {
790
- scrollHeight = Math.max(
791
- document.documentElement.scrollHeight,
792
- document.body.scrollHeight
793
- );
794
- offsetHeight = Math.max(
795
- document.documentElement.offsetHeight,
796
- document.body.offsetHeight
797
- );
798
-
799
- if ( scrollHeight < offsetHeight ) {
800
- return $( window ).height() + "px";
749
+ position = {
750
+ my: myAt[0] + (offset[0] < 0 ? offset[0] : "+" + offset[0]) + " " +
751
+ myAt[1] + (offset[1] < 0 ? offset[1] : "+" + offset[1]),
752
+ at: myAt.join(" ")
753
+ };
754
+ }
755
+
756
+ position = $.extend( {}, $.ui.dialog.prototype.options.position, position );
801
757
  } else {
802
- return scrollHeight + "px";
758
+ position = $.ui.dialog.prototype.options.position;
803
759
  }
804
- // handle "good" browsers
805
- } else {
806
- return $( document ).height() + "px";
807
- }
808
- },
809
760
 
810
- width: function() {
811
- var scrollWidth,
812
- offsetWidth;
813
- // handle IE
814
- if ( $.ui.ie ) {
815
- scrollWidth = Math.max(
816
- document.documentElement.scrollWidth,
817
- document.body.scrollWidth
818
- );
819
- offsetWidth = Math.max(
820
- document.documentElement.offsetWidth,
821
- document.body.offsetWidth
822
- );
823
-
824
- if ( scrollWidth < offsetWidth ) {
825
- return $( window ).width() + "px";
826
- } else {
827
- return scrollWidth + "px";
761
+ // need to show the dialog to get the actual offset in the position plugin
762
+ isVisible = this.uiDialog.is(":visible");
763
+ if ( !isVisible ) {
764
+ this.uiDialog.show();
765
+ }
766
+ this.uiDialog.position( position );
767
+ if ( !isVisible ) {
768
+ this.uiDialog.hide();
828
769
  }
829
- // handle "good" browsers
830
- } else {
831
- return $( document ).width() + "px";
832
770
  }
833
- },
834
-
835
- resize: function() {
836
- /* If the dialog is draggable and the user drags it past the
837
- * right edge of the window, the document becomes wider so we
838
- * need to stretch the overlay. If the user then drags the
839
- * dialog back to the left, the document will become narrower,
840
- * so we need to shrink the overlay to the appropriate size.
841
- * This is handled by shrinking the overlay before setting it
842
- * to the full document size.
843
- */
844
- var $overlays = $( [] );
845
- $.each( $.ui.dialog.overlay.instances, function() {
846
- $overlays = $overlays.add( this );
847
- });
848
-
849
- $overlays.css({
850
- width: 0,
851
- height: 0
852
- }).css({
853
- width: $.ui.dialog.overlay.width(),
854
- height: $.ui.dialog.overlay.height()
855
- });
856
- }
857
- });
858
-
859
- $.extend( $.ui.dialog.overlay.prototype, {
860
- destroy: function() {
861
- $.ui.dialog.overlay.destroy( this.$el );
862
- }
863
- });
771
+ });
772
+ }
864
773
 
865
774
  }( jQuery ) );