25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

821 lines
20 KiB

  1. /*
  2. * jQuery UI Dialog 1.8
  3. *
  4. * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
  5. * Dual licensed under the MIT (MIT-LICENSE.txt)
  6. * and GPL (GPL-LICENSE.txt) licenses.
  7. *
  8. * http://docs.jquery.com/UI/Dialog
  9. *
  10. * Depends:
  11. * jquery.ui.core.js
  12. * jquery.ui.widget.js
  13. * jquery.ui.button.js
  14. * jquery.ui.draggable.js
  15. * jquery.ui.mouse.js
  16. * jquery.ui.position.js
  17. * jquery.ui.resizable.js
  18. */
  19. (function($) {
  20. var uiDialogClasses =
  21. 'ui-dialog ' +
  22. 'ui-widget ' +
  23. 'ui-widget-content ' +
  24. 'ui-corner-all ';
  25. $.widget("ui.dialog", {
  26. options: {
  27. autoOpen: true,
  28. buttons: {},
  29. closeOnEscape: true,
  30. closeText: 'close',
  31. dialogClass: '',
  32. draggable: true,
  33. hide: null,
  34. height: 'auto',
  35. maxHeight: false,
  36. maxWidth: false,
  37. minHeight: 150,
  38. minWidth: 150,
  39. modal: false,
  40. position: 'center',
  41. resizable: true,
  42. show: null,
  43. stack: true,
  44. title: '',
  45. width: 300,
  46. zIndex: 1000
  47. },
  48. _create: function() {
  49. this.originalTitle = this.element.attr('title');
  50. var self = this,
  51. options = self.options,
  52. title = options.title || self.originalTitle || ' ',
  53. titleId = $.ui.dialog.getTitleId(self.element),
  54. uiDialog = (self.uiDialog = $('<div></div>'))
  55. .appendTo(document.body)
  56. .hide()
  57. .addClass(uiDialogClasses + options.dialogClass)
  58. .css({
  59. zIndex: options.zIndex
  60. })
  61. // setting tabIndex makes the div focusable
  62. // setting outline to 0 prevents a border on focus in Mozilla
  63. .attr('tabIndex', -1).css('outline', 0).keydown(function(event) {
  64. if (options.closeOnEscape && event.keyCode &&
  65. event.keyCode === $.ui.keyCode.ESCAPE) {
  66. self.close(event);
  67. event.preventDefault();
  68. }
  69. })
  70. .attr({
  71. role: 'dialog',
  72. 'aria-labelledby': titleId
  73. })
  74. .mousedown(function(event) {
  75. self.moveToTop(false, event);
  76. }),
  77. uiDialogContent = self.element
  78. .show()
  79. .removeAttr('title')
  80. .addClass(
  81. 'ui-dialog-content ' +
  82. 'ui-widget-content')
  83. .appendTo(uiDialog),
  84. uiDialogTitlebar = (self.uiDialogTitlebar = $('<div></div>'))
  85. .addClass(
  86. 'ui-dialog-titlebar ' +
  87. 'ui-widget-header ' +
  88. 'ui-corner-all ' +
  89. 'ui-helper-clearfix'
  90. )
  91. .prependTo(uiDialog),
  92. uiDialogTitlebarClose = $('<a href="#"></a>')
  93. .addClass(
  94. 'ui-dialog-titlebar-close ' +
  95. 'ui-corner-all'
  96. )
  97. .attr('role', 'button')
  98. .hover(
  99. function() {
  100. uiDialogTitlebarClose.addClass('ui-state-hover');
  101. },
  102. function() {
  103. uiDialogTitlebarClose.removeClass('ui-state-hover');
  104. }
  105. )
  106. .focus(function() {
  107. uiDialogTitlebarClose.addClass('ui-state-focus');
  108. })
  109. .blur(function() {
  110. uiDialogTitlebarClose.removeClass('ui-state-focus');
  111. })
  112. .click(function(event) {
  113. self.close(event);
  114. return false;
  115. })
  116. .appendTo(uiDialogTitlebar),
  117. uiDialogTitlebarCloseText = (self.uiDialogTitlebarCloseText = $('<span></span>'))
  118. .addClass(
  119. 'ui-icon ' +
  120. 'ui-icon-closethick'
  121. )
  122. .text(options.closeText)
  123. .appendTo(uiDialogTitlebarClose),
  124. uiDialogTitle = $('<span></span>')
  125. .addClass('ui-dialog-title')
  126. .attr('id', titleId)
  127. .html(title)
  128. .prependTo(uiDialogTitlebar);
  129. //handling of deprecated beforeclose (vs beforeClose) option
  130. //Ticket #4669 http://dev.jqueryui.com/ticket/4669
  131. //TODO: remove in 1.9pre
  132. if ($.isFunction(options.beforeclose) && !$.isFunction(options.beforeClose)) {
  133. options.beforeClose = options.beforeclose;
  134. }
  135. uiDialogTitlebar.find("*").add(uiDialogTitlebar).disableSelection();
  136. if (options.draggable && $.fn.draggable) {
  137. self._makeDraggable();
  138. }
  139. if (options.resizable && $.fn.resizable) {
  140. self._makeResizable();
  141. }
  142. self._createButtons(options.buttons);
  143. self._isOpen = false;
  144. if ($.fn.bgiframe) {
  145. uiDialog.bgiframe();
  146. }
  147. },
  148. _init: function() {
  149. if ( this.options.autoOpen ) {
  150. this.open();
  151. }
  152. },
  153. destroy: function() {
  154. var self = this;
  155. if (self.overlay) {
  156. self.overlay.destroy();
  157. }
  158. self.uiDialog.hide();
  159. self.element
  160. .unbind('.dialog')
  161. .removeData('dialog')
  162. .removeClass('ui-dialog-content ui-widget-content')
  163. .hide().appendTo('body');
  164. self.uiDialog.remove();
  165. if (self.originalTitle) {
  166. self.element.attr('title', self.originalTitle);
  167. }
  168. return self;
  169. },
  170. widget: function() {
  171. return this.uiDialog;
  172. },
  173. close: function(event) {
  174. var self = this,
  175. maxZ;
  176. if (false === self._trigger('beforeClose', event)) {
  177. return;
  178. }
  179. if (self.overlay) {
  180. self.overlay.destroy();
  181. }
  182. self.uiDialog.unbind('keypress.ui-dialog');
  183. self._isOpen = false;
  184. if (self.options.hide) {
  185. self.uiDialog.hide(self.options.hide, function() {
  186. self._trigger('close', event);
  187. });
  188. } else {
  189. self.uiDialog.hide();
  190. self._trigger('close', event);
  191. }
  192. $.ui.dialog.overlay.resize();
  193. // adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
  194. if (self.options.modal) {
  195. maxZ = 0;
  196. $('.ui-dialog').each(function() {
  197. if (this !== self.uiDialog[0]) {
  198. maxZ = Math.max(maxZ, $(this).css('z-index'));
  199. }
  200. });
  201. $.ui.dialog.maxZ = maxZ;
  202. }
  203. return self;
  204. },
  205. isOpen: function() {
  206. return this._isOpen;
  207. },
  208. // the force parameter allows us to move modal dialogs to their correct
  209. // position on open
  210. moveToTop: function(force, event) {
  211. var self = this,
  212. options = self.options,
  213. saveScroll;
  214. if ((options.modal && !force) ||
  215. (!options.stack && !options.modal)) {
  216. return self._trigger('focus', event);
  217. }
  218. if (options.zIndex > $.ui.dialog.maxZ) {
  219. $.ui.dialog.maxZ = options.zIndex;
  220. }
  221. if (self.overlay) {
  222. $.ui.dialog.maxZ += 1;
  223. self.overlay.$el.css('z-index', $.ui.dialog.overlay.maxZ = $.ui.dialog.maxZ);
  224. }
  225. //Save and then restore scroll since Opera 9.5+ resets when parent z-Index is changed.
  226. // http://ui.jquery.com/bugs/ticket/3193
  227. saveScroll = { scrollTop: self.element.attr('scrollTop'), scrollLeft: self.element.attr('scrollLeft') };
  228. $.ui.dialog.maxZ += 1;
  229. self.uiDialog.css('z-index', $.ui.dialog.maxZ);
  230. self.element.attr(saveScroll);
  231. self._trigger('focus', event);
  232. return self;
  233. },
  234. open: function() {
  235. if (this._isOpen) { return; }
  236. var self = this,
  237. options = self.options,
  238. uiDialog = self.uiDialog;
  239. self.overlay = options.modal ? new $.ui.dialog.overlay(self) : null;
  240. if (uiDialog.next().length) {
  241. uiDialog.appendTo('body');
  242. }
  243. self._size();
  244. self._position(options.position);
  245. uiDialog.show(options.show);
  246. self.moveToTop(true);
  247. // prevent tabbing out of modal dialogs
  248. if (options.modal) {
  249. uiDialog.bind('keypress.ui-dialog', function(event) {
  250. if (event.keyCode !== $.ui.keyCode.TAB) {
  251. return;
  252. }
  253. var tabbables = $(':tabbable', this),
  254. first = tabbables.filter(':first'),
  255. last = tabbables.filter(':last');
  256. if (event.target === last[0] && !event.shiftKey) {
  257. first.focus(1);
  258. return false;
  259. } else if (event.target === first[0] && event.shiftKey) {
  260. last.focus(1);
  261. return false;
  262. }
  263. });
  264. }
  265. // set focus to the first tabbable element in the content area or the first button
  266. // if there are no tabbable elements, set focus on the dialog itself
  267. $([])
  268. .add(uiDialog.find('.ui-dialog-content :tabbable:first'))
  269. .add(uiDialog.find('.ui-dialog-buttonpane :tabbable:first'))
  270. .add(uiDialog)
  271. .filter(':first')
  272. .focus();
  273. self._trigger('open');
  274. self._isOpen = true;
  275. return self;
  276. },
  277. _createButtons: function(buttons) {
  278. var self = this,
  279. hasButtons = false,
  280. uiDialogButtonPane = $('<div></div>')
  281. .addClass(
  282. 'ui-dialog-buttonpane ' +
  283. 'ui-widget-content ' +
  284. 'ui-helper-clearfix'
  285. );
  286. // if we already have a button pane, remove it
  287. self.uiDialog.find('.ui-dialog-buttonpane').remove();
  288. if (typeof buttons === 'object' && buttons !== null) {
  289. $.each(buttons, function() {
  290. return !(hasButtons = true);
  291. });
  292. }
  293. if (hasButtons) {
  294. $.each(buttons, function(name, fn) {
  295. var button = $('<button type="button"></button>')
  296. .text(name)
  297. .click(function() { fn.apply(self.element[0], arguments); })
  298. .appendTo(uiDialogButtonPane);
  299. if ($.fn.button) {
  300. button.button();
  301. }
  302. });
  303. uiDialogButtonPane.appendTo(self.uiDialog);
  304. }
  305. },
  306. _makeDraggable: function() {
  307. var self = this,
  308. options = self.options,
  309. doc = $(document),
  310. heightBeforeDrag;
  311. function filteredUi(ui) {
  312. return {
  313. position: ui.position,
  314. offset: ui.offset
  315. };
  316. }
  317. self.uiDialog.draggable({
  318. cancel: '.ui-dialog-content, .ui-dialog-titlebar-close',
  319. handle: '.ui-dialog-titlebar',
  320. containment: 'document',
  321. start: function(event, ui) {
  322. heightBeforeDrag = options.height === "auto" ? "auto" : $(this).height();
  323. $(this).height($(this).height()).addClass("ui-dialog-dragging");
  324. self._trigger('dragStart', event, filteredUi(ui));
  325. },
  326. drag: function(event, ui) {
  327. self._trigger('drag', event, filteredUi(ui));
  328. },
  329. stop: function(event, ui) {
  330. options.position = [ui.position.left - doc.scrollLeft(),
  331. ui.position.top - doc.scrollTop()];
  332. $(this).removeClass("ui-dialog-dragging").height(heightBeforeDrag);
  333. self._trigger('dragStop', event, filteredUi(ui));
  334. $.ui.dialog.overlay.resize();
  335. }
  336. });
  337. },
  338. _makeResizable: function(handles) {
  339. handles = (handles === undefined ? this.options.resizable : handles);
  340. var self = this,
  341. options = self.options,
  342. // .ui-resizable has position: relative defined in the stylesheet
  343. // but dialogs have to use absolute or fixed positioning
  344. position = self.uiDialog.css('position'),
  345. resizeHandles = (typeof handles === 'string' ?
  346. handles :
  347. 'n,e,s,w,se,sw,ne,nw'
  348. );
  349. function filteredUi(ui) {
  350. return {
  351. originalPosition: ui.originalPosition,
  352. originalSize: ui.originalSize,
  353. position: ui.position,
  354. size: ui.size
  355. };
  356. }
  357. self.uiDialog.resizable({
  358. cancel: '.ui-dialog-content',
  359. containment: 'document',
  360. alsoResize: self.element,
  361. maxWidth: options.maxWidth,
  362. maxHeight: options.maxHeight,
  363. minWidth: options.minWidth,
  364. minHeight: self._minHeight(),
  365. handles: resizeHandles,
  366. start: function(event, ui) {
  367. $(this).addClass("ui-dialog-resizing");
  368. self._trigger('resizeStart', event, filteredUi(ui));
  369. },
  370. resize: function(event, ui) {
  371. self._trigger('resize', event, filteredUi(ui));
  372. },
  373. stop: function(event, ui) {
  374. $(this).removeClass("ui-dialog-resizing");
  375. options.height = $(this).height();
  376. options.width = $(this).width();
  377. self._trigger('resizeStop', event, filteredUi(ui));
  378. $.ui.dialog.overlay.resize();
  379. }
  380. })
  381. .css('position', position)
  382. .find('.ui-resizable-se').addClass('ui-icon ui-icon-grip-diagonal-se');
  383. },
  384. _minHeight: function() {
  385. var options = this.options;
  386. if (options.height === 'auto') {
  387. return options.minHeight;
  388. } else {
  389. return Math.min(options.minHeight, options.height);
  390. }
  391. },
  392. _position: function(position) {
  393. var myAt = [],
  394. offset = [0, 0],
  395. isVisible;
  396. position = position || $.ui.dialog.prototype.options.position;
  397. // deep extending converts arrays to objects in jQuery <= 1.3.2 :-(
  398. // if (typeof position == 'string' || $.isArray(position)) {
  399. // myAt = $.isArray(position) ? position : position.split(' ');
  400. if (typeof position === 'string' || (typeof position === 'object' && '0' in position)) {
  401. myAt = position.split ? position.split(' ') : [position[0], position[1]];
  402. if (myAt.length === 1) {
  403. myAt[1] = myAt[0];
  404. }
  405. $.each(['left', 'top'], function(i, offsetPosition) {
  406. if (+myAt[i] === myAt[i]) {
  407. offset[i] = myAt[i];
  408. myAt[i] = offsetPosition;
  409. }
  410. });
  411. } else if (typeof position === 'object') {
  412. if ('left' in position) {
  413. myAt[0] = 'left';
  414. offset[0] = position.left;
  415. } else if ('right' in position) {
  416. myAt[0] = 'right';
  417. offset[0] = -position.right;
  418. }
  419. if ('top' in position) {
  420. myAt[1] = 'top';
  421. offset[1] = position.top;
  422. } else if ('bottom' in position) {
  423. myAt[1] = 'bottom';
  424. offset[1] = -position.bottom;
  425. }
  426. }
  427. // need to show the dialog to get the actual offset in the position plugin
  428. isVisible = this.uiDialog.is(':visible');
  429. if (!isVisible) {
  430. this.uiDialog.show();
  431. }
  432. this.uiDialog
  433. // workaround for jQuery bug #5781 http://dev.jquery.com/ticket/5781
  434. .css({ top: 0, left: 0 })
  435. .position({
  436. my: myAt.join(' '),
  437. at: myAt.join(' '),
  438. offset: offset.join(' '),
  439. of: window,
  440. collision: 'fit',
  441. // ensure that the titlebar is never outside the document
  442. using: function(pos) {
  443. var topOffset = $(this).css(pos).offset().top;
  444. if (topOffset < 0) {
  445. $(this).css('top', pos.top - topOffset);
  446. }
  447. }
  448. });
  449. if (!isVisible) {
  450. this.uiDialog.hide();
  451. }
  452. },
  453. _setOption: function(key, value){
  454. var self = this,
  455. uiDialog = self.uiDialog,
  456. isResizable = uiDialog.is(':data(resizable)'),
  457. resize = false;
  458. switch (key) {
  459. //handling of deprecated beforeclose (vs beforeClose) option
  460. //Ticket #4669 http://dev.jqueryui.com/ticket/4669
  461. //TODO: remove in 1.9pre
  462. case "beforeclose":
  463. key = "beforeClose";
  464. break;
  465. case "buttons":
  466. self._createButtons(value);
  467. break;
  468. case "closeText":
  469. // convert whatever was passed in to a string, for text() to not throw up
  470. self.uiDialogTitlebarCloseText.text("" + value);
  471. break;
  472. case "dialogClass":
  473. uiDialog
  474. .removeClass(self.options.dialogClass)
  475. .addClass(uiDialogClasses + value);
  476. break;
  477. case "disabled":
  478. if (value) {
  479. uiDialog.addClass('ui-dialog-disabled');
  480. } else {
  481. uiDialog.removeClass('ui-dialog-disabled');
  482. }
  483. break;
  484. case "draggable":
  485. if (value) {
  486. self._makeDraggable();
  487. } else {
  488. uiDialog.draggable('destroy');
  489. }
  490. break;
  491. case "height":
  492. resize = true;
  493. break;
  494. case "maxHeight":
  495. if (isResizable) {
  496. uiDialog.resizable('option', 'maxHeight', value);
  497. }
  498. resize = true;
  499. break;
  500. case "maxWidth":
  501. if (isResizable) {
  502. uiDialog.resizable('option', 'maxWidth', value);
  503. }
  504. resize = true;
  505. break;
  506. case "minHeight":
  507. if (isResizable) {
  508. uiDialog.resizable('option', 'minHeight', value);
  509. }
  510. resize = true;
  511. break;
  512. case "minWidth":
  513. if (isResizable) {
  514. uiDialog.resizable('option', 'minWidth', value);
  515. }
  516. resize = true;
  517. break;
  518. case "position":
  519. self._position(value);
  520. break;
  521. case "resizable":
  522. // currently resizable, becoming non-resizable
  523. if (isResizable && !value) {
  524. uiDialog.resizable('destroy');
  525. }
  526. // currently resizable, changing handles
  527. if (isResizable && typeof value === 'string') {
  528. uiDialog.resizable('option', 'handles', value);
  529. }
  530. // currently non-resizable, becoming resizable
  531. if (!isResizable && value !== false) {
  532. self._makeResizable(value);
  533. }
  534. break;
  535. case "title":
  536. // convert whatever was passed in o a string, for html() to not throw up
  537. $(".ui-dialog-title", self.uiDialogTitlebar).html("" + (value || '&#160;'));
  538. break;
  539. case "width":
  540. resize = true;
  541. break;
  542. }
  543. $.Widget.prototype._setOption.apply(self, arguments);
  544. if (resize) {
  545. self._size();
  546. }
  547. },
  548. _size: function() {
  549. /* If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  550. * divs will both have width and height set, so we need to reset them
  551. */
  552. var options = this.options,
  553. nonContentHeight;
  554. // reset content sizing
  555. // hide for non content measurement because height: 0 doesn't work in IE quirks mode (see #4350)
  556. this.element.css('width', 'auto')
  557. .hide();
  558. // reset wrapper sizing
  559. // determine the height of all the non-content elements
  560. nonContentHeight = this.uiDialog.css({
  561. height: 'auto',
  562. width: options.width
  563. })
  564. .height();
  565. this.element
  566. .css(options.height === 'auto' ? {
  567. minHeight: Math.max(options.minHeight - nonContentHeight, 0),
  568. height: 'auto'
  569. } : {
  570. minHeight: 0,
  571. height: Math.max(options.height - nonContentHeight, 0)
  572. })
  573. .show();
  574. if (this.uiDialog.is(':data(resizable)')) {
  575. this.uiDialog.resizable('option', 'minHeight', this._minHeight());
  576. }
  577. }
  578. });
  579. $.extend($.ui.dialog, {
  580. version: "1.8",
  581. uuid: 0,
  582. maxZ: 0,
  583. getTitleId: function($el) {
  584. var id = $el.attr('id');
  585. if (!id) {
  586. this.uuid += 1;
  587. id = this.uuid;
  588. }
  589. return 'ui-dialog-title-' + id;
  590. },
  591. overlay: function(dialog) {
  592. this.$el = $.ui.dialog.overlay.create(dialog);
  593. }
  594. });
  595. $.extend($.ui.dialog.overlay, {
  596. instances: [],
  597. // reuse old instances due to IE memory leak with alpha transparency (see #5185)
  598. oldInstances: [],
  599. maxZ: 0,
  600. events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','),
  601. function(event) { return event + '.dialog-overlay'; }).join(' '),
  602. create: function(dialog) {
  603. if (this.instances.length === 0) {
  604. // prevent use of anchors and inputs
  605. // we use a setTimeout in case the overlay is created from an
  606. // event that we're going to be cancelling (see #2804)
  607. setTimeout(function() {
  608. // handle $(el).dialog().dialog('close') (see #4065)
  609. if ($.ui.dialog.overlay.instances.length) {
  610. $(document).bind($.ui.dialog.overlay.events, function(event) {
  611. // stop events if the z-index of the target is < the z-index of the overlay
  612. return ($(event.target).zIndex() >= $.ui.dialog.overlay.maxZ);
  613. });
  614. }
  615. }, 1);
  616. // allow closing by pressing the escape key
  617. $(document).bind('keydown.dialog-overlay', function(event) {
  618. if (dialog.options.closeOnEscape && event.keyCode &&
  619. event.keyCode === $.ui.keyCode.ESCAPE) {
  620. dialog.close(event);
  621. event.preventDefault();
  622. }
  623. });
  624. // handle window resize
  625. $(window).bind('resize.dialog-overlay', $.ui.dialog.overlay.resize);
  626. }
  627. var $el = (this.oldInstances.pop() || $('<div></div>').addClass('ui-widget-overlay'))
  628. .appendTo(document.body)
  629. .css({
  630. width: this.width(),
  631. height: this.height()
  632. });
  633. if ($.fn.bgiframe) {
  634. $el.bgiframe();
  635. }
  636. this.instances.push($el);
  637. return $el;
  638. },
  639. destroy: function($el) {
  640. this.oldInstances.push(this.instances.splice($.inArray($el, this.instances), 1)[0]);
  641. if (this.instances.length === 0) {
  642. $([document, window]).unbind('.dialog-overlay');
  643. }
  644. $el.remove();
  645. // adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
  646. var maxZ = 0;
  647. $.each(this.instances, function() {
  648. maxZ = Math.max(maxZ, this.css('z-index'));
  649. });
  650. this.maxZ = maxZ;
  651. },
  652. height: function() {
  653. var scrollHeight,
  654. offsetHeight;
  655. // handle IE 6
  656. if ($.browser.msie && $.browser.version < 7) {
  657. scrollHeight = Math.max(
  658. document.documentElement.scrollHeight,
  659. document.body.scrollHeight
  660. );
  661. offsetHeight = Math.max(
  662. document.documentElement.offsetHeight,
  663. document.body.offsetHeight
  664. );
  665. if (scrollHeight < offsetHeight) {
  666. return $(window).height() + 'px';
  667. } else {
  668. return scrollHeight + 'px';
  669. }
  670. // handle "good" browsers
  671. } else {
  672. return $(document).height() + 'px';
  673. }
  674. },
  675. width: function() {
  676. var scrollWidth,
  677. offsetWidth;
  678. // handle IE 6
  679. if ($.browser.msie && $.browser.version < 7) {
  680. scrollWidth = Math.max(
  681. document.documentElement.scrollWidth,
  682. document.body.scrollWidth
  683. );
  684. offsetWidth = Math.max(
  685. document.documentElement.offsetWidth,
  686. document.body.offsetWidth
  687. );
  688. if (scrollWidth < offsetWidth) {
  689. return $(window).width() + 'px';
  690. } else {
  691. return scrollWidth + 'px';
  692. }
  693. // handle "good" browsers
  694. } else {
  695. return $(document).width() + 'px';
  696. }
  697. },
  698. resize: function() {
  699. /* If the dialog is draggable and the user drags it past the
  700. * right edge of the window, the document becomes wider so we
  701. * need to stretch the overlay. If the user then drags the
  702. * dialog back to the left, the document will become narrower,
  703. * so we need to shrink the overlay to the appropriate size.
  704. * This is handled by shrinking the overlay before setting it
  705. * to the full document size.
  706. */
  707. var $overlays = $([]);
  708. $.each($.ui.dialog.overlay.instances, function() {
  709. $overlays = $overlays.add(this);
  710. });
  711. $overlays.css({
  712. width: 0,
  713. height: 0
  714. }).css({
  715. width: $.ui.dialog.overlay.width(),
  716. height: $.ui.dialog.overlay.height()
  717. });
  718. }
  719. });
  720. $.extend($.ui.dialog.overlay.prototype, {
  721. destroy: function() {
  722. $.ui.dialog.overlay.destroy(this.$el);
  723. }
  724. });
  725. }(jQuery));