stuff_to_do_plugin 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. data/COPYRIGHT.txt +18 -0
  2. data/CREDITS.txt +6 -0
  3. data/GPL.txt +339 -0
  4. data/README.rdoc +61 -0
  5. data/Rakefile +38 -0
  6. data/VERSION +1 -0
  7. data/app/controllers/stuff_to_do_controller.rb +161 -0
  8. data/app/helpers/stuff_to_do_helper.rb +88 -0
  9. data/app/models/stuff_to_do.rb +208 -0
  10. data/app/models/stuff_to_do_filter.rb +32 -0
  11. data/app/models/stuff_to_do_mailer.rb +16 -0
  12. data/app/views/settings/_stuff_to_do_settings.html.erb +27 -0
  13. data/app/views/stuff_to_do/_issue.html.erb +16 -0
  14. data/app/views/stuff_to_do/_item.html.erb +5 -0
  15. data/app/views/stuff_to_do/_left_panes.html.erb +51 -0
  16. data/app/views/stuff_to_do/_panes.html.erb +11 -0
  17. data/app/views/stuff_to_do/_project.html.erb +6 -0
  18. data/app/views/stuff_to_do/_right_panes.html.erb +25 -0
  19. data/app/views/stuff_to_do/_time_grid.html.erb +113 -0
  20. data/app/views/stuff_to_do/_time_grid_form.html.erb +32 -0
  21. data/app/views/stuff_to_do/index.html.erb +44 -0
  22. data/app/views/stuff_to_do_mailer/recommended_below_threshold.erb +3 -0
  23. data/app/views/stuff_to_do_mailer/recommended_below_threshold.text.html.rhtml +1 -0
  24. data/assets/images/b.png +0 -0
  25. data/assets/images/bl.png +0 -0
  26. data/assets/images/br.png +0 -0
  27. data/assets/images/closelabel.gif +0 -0
  28. data/assets/images/loading.gif +0 -0
  29. data/assets/images/tl.png +0 -0
  30. data/assets/images/tr.png +0 -0
  31. data/assets/javascripts/facebox.js +319 -0
  32. data/assets/javascripts/jquery-1.2.6.min.js +32 -0
  33. data/assets/javascripts/jquery-ui.js +2839 -0
  34. data/assets/javascripts/jquery.contextMenu.js +212 -0
  35. data/assets/javascripts/semantic.cache +15 -0
  36. data/assets/javascripts/stuff-to-do.js +270 -0
  37. data/assets/javascripts/ui/build.xml +24 -0
  38. data/assets/javascripts/ui/effects.blind.js +49 -0
  39. data/assets/javascripts/ui/effects.bounce.js +78 -0
  40. data/assets/javascripts/ui/effects.clip.js +54 -0
  41. data/assets/javascripts/ui/effects.core.js +510 -0
  42. data/assets/javascripts/ui/effects.drop.js +50 -0
  43. data/assets/javascripts/ui/effects.explode.js +79 -0
  44. data/assets/javascripts/ui/effects.fold.js +55 -0
  45. data/assets/javascripts/ui/effects.highlight.js +48 -0
  46. data/assets/javascripts/ui/effects.pulsate.js +55 -0
  47. data/assets/javascripts/ui/effects.scale.js +180 -0
  48. data/assets/javascripts/ui/effects.shake.js +57 -0
  49. data/assets/javascripts/ui/effects.slide.js +50 -0
  50. data/assets/javascripts/ui/effects.transfer.js +59 -0
  51. data/assets/javascripts/ui/i18n/ui.datepicker-ar.js +26 -0
  52. data/assets/javascripts/ui/i18n/ui.datepicker-bg.js +25 -0
  53. data/assets/javascripts/ui/i18n/ui.datepicker-ca.js +25 -0
  54. data/assets/javascripts/ui/i18n/ui.datepicker-cs.js +25 -0
  55. data/assets/javascripts/ui/i18n/ui.datepicker-da.js +25 -0
  56. data/assets/javascripts/ui/i18n/ui.datepicker-de.js +25 -0
  57. data/assets/javascripts/ui/i18n/ui.datepicker-eo.js +25 -0
  58. data/assets/javascripts/ui/i18n/ui.datepicker-es.js +25 -0
  59. data/assets/javascripts/ui/i18n/ui.datepicker-fa.js +25 -0
  60. data/assets/javascripts/ui/i18n/ui.datepicker-fi.js +25 -0
  61. data/assets/javascripts/ui/i18n/ui.datepicker-fr.js +25 -0
  62. data/assets/javascripts/ui/i18n/ui.datepicker-he.js +25 -0
  63. data/assets/javascripts/ui/i18n/ui.datepicker-hr.js +25 -0
  64. data/assets/javascripts/ui/i18n/ui.datepicker-hu.js +25 -0
  65. data/assets/javascripts/ui/i18n/ui.datepicker-hy.js +25 -0
  66. data/assets/javascripts/ui/i18n/ui.datepicker-id.js +25 -0
  67. data/assets/javascripts/ui/i18n/ui.datepicker-is.js +25 -0
  68. data/assets/javascripts/ui/i18n/ui.datepicker-it.js +25 -0
  69. data/assets/javascripts/ui/i18n/ui.datepicker-ja.js +26 -0
  70. data/assets/javascripts/ui/i18n/ui.datepicker-ko.js +25 -0
  71. data/assets/javascripts/ui/i18n/ui.datepicker-lt.js +25 -0
  72. data/assets/javascripts/ui/i18n/ui.datepicker-lv.js +25 -0
  73. data/assets/javascripts/ui/i18n/ui.datepicker-nl.js +25 -0
  74. data/assets/javascripts/ui/i18n/ui.datepicker-no.js +25 -0
  75. data/assets/javascripts/ui/i18n/ui.datepicker-pl.js +25 -0
  76. data/assets/javascripts/ui/i18n/ui.datepicker-pt-BR.js +25 -0
  77. data/assets/javascripts/ui/i18n/ui.datepicker-ro.js +25 -0
  78. data/assets/javascripts/ui/i18n/ui.datepicker-ru.js +25 -0
  79. data/assets/javascripts/ui/i18n/ui.datepicker-sk.js +25 -0
  80. data/assets/javascripts/ui/i18n/ui.datepicker-sl.js +26 -0
  81. data/assets/javascripts/ui/i18n/ui.datepicker-sq.js +25 -0
  82. data/assets/javascripts/ui/i18n/ui.datepicker-sv.js +25 -0
  83. data/assets/javascripts/ui/i18n/ui.datepicker-th.js +25 -0
  84. data/assets/javascripts/ui/i18n/ui.datepicker-tr.js +25 -0
  85. data/assets/javascripts/ui/i18n/ui.datepicker-uk.js +25 -0
  86. data/assets/javascripts/ui/i18n/ui.datepicker-zh-CN.js +25 -0
  87. data/assets/javascripts/ui/i18n/ui.datepicker-zh-TW.js +25 -0
  88. data/assets/javascripts/ui/svn.log +11 -0
  89. data/assets/javascripts/ui/ui.accordion.js +400 -0
  90. data/assets/javascripts/ui/ui.core.js +533 -0
  91. data/assets/javascripts/ui/ui.datepicker.js +1754 -0
  92. data/assets/javascripts/ui/ui.dialog.js +630 -0
  93. data/assets/javascripts/ui/ui.draggable.js +696 -0
  94. data/assets/javascripts/ui/ui.droppable.js +314 -0
  95. data/assets/javascripts/ui/ui.progressbar.js +114 -0
  96. data/assets/javascripts/ui/ui.resizable.js +805 -0
  97. data/assets/javascripts/ui/ui.selectable.js +266 -0
  98. data/assets/javascripts/ui/ui.slider.js +552 -0
  99. data/assets/javascripts/ui/ui.sortable.js +1012 -0
  100. data/assets/javascripts/ui/ui.tabs.js +572 -0
  101. data/assets/stylesheets/stuff_to_do.css +216 -0
  102. data/config/locales/bg.yml +18 -0
  103. data/config/locales/ca-fr.yml +18 -0
  104. data/config/locales/cs.yml +16 -0
  105. data/config/locales/da.yml +16 -0
  106. data/config/locales/de.yml +18 -0
  107. data/config/locales/en.yml +24 -0
  108. data/config/locales/es.yml +19 -0
  109. data/config/locales/fr.yml +17 -0
  110. data/config/locales/hu.yml +16 -0
  111. data/config/locales/it.yml +16 -0
  112. data/config/locales/ja.yml +18 -0
  113. data/config/locales/ko.yml +18 -0
  114. data/config/locales/lt.yml +18 -0
  115. data/config/locales/nl.yml +20 -0
  116. data/config/locales/pt-BR.yml +18 -0
  117. data/config/locales/ru.yml +19 -0
  118. data/config/locales/sv.yml +19 -0
  119. data/config/locales/tr.yml +18 -0
  120. data/config/routes.rb +3 -0
  121. data/init.rb +54 -0
  122. data/lang/bg.yml +17 -0
  123. data/lang/ca-fr.yml +17 -0
  124. data/lang/cs.yml +15 -0
  125. data/lang/da.yml +15 -0
  126. data/lang/de.yml +17 -0
  127. data/lang/en.yml +21 -0
  128. data/lang/es.yml +18 -0
  129. data/lang/fr.yml +16 -0
  130. data/lang/hu.yml +15 -0
  131. data/lang/it.yml +15 -0
  132. data/lang/ja.yml +17 -0
  133. data/lang/ko.yml +17 -0
  134. data/lang/lt.yml +17 -0
  135. data/lang/pt-br.yml +17 -0
  136. data/lang/ru.yml +15 -0
  137. data/lang/sv.yml +18 -0
  138. data/lang/tr.yml +17 -0
  139. data/lib/redmine_stuff_to_do/stuff_to_do_compatibility.rb +15 -0
  140. data/lib/stuff_to_do_array_patch.rb +8 -0
  141. data/lib/stuff_to_do_issue_patch.rb +57 -0
  142. data/lib/stuff_to_do_project_patch.rb +31 -0
  143. data/lib/stuff_to_do_user_patch.rb +10 -0
  144. data/rails/init.rb +1 -0
  145. data/spec/controllers/stuff_to_do_controller_add_to_time_grid_spec.rb +58 -0
  146. data/spec/controllers/stuff_to_do_controller_index_spec.rb +155 -0
  147. data/spec/controllers/stuff_to_do_controller_remove_from_time_grid_spec.rb +56 -0
  148. data/spec/controllers/stuff_to_do_controller_reorder_spec.rb +179 -0
  149. data/spec/controllers/stuff_to_do_controller_save_time_entries_spec.rb +56 -0
  150. data/spec/controllers/stuff_to_do_private_methods_spec.rb +82 -0
  151. data/spec/lib/stuff_to_do_issue_patch_spec.rb +60 -0
  152. data/spec/lib/stuff_to_do_project_patch_spec.rb +50 -0
  153. data/spec/lib/stuff_to_do_user_patch_spec.rb +8 -0
  154. data/spec/models/stuff_to_do_filter_spec.rb +3 -0
  155. data/spec/models/stuff_to_do_mailer_spec.rb +42 -0
  156. data/spec/models/stuff_to_do_spec.rb +426 -0
  157. data/spec/sanity_spec.rb +7 -0
  158. data/spec/spec_helper.rb +130 -0
  159. metadata +211 -0
@@ -0,0 +1,630 @@
1
+ /*
2
+ * jQuery UI Dialog @VERSION
3
+ *
4
+ * Copyright (c) 2008 AUTHORS.txt (http://ui.jquery.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
+ * ui.core.js
12
+ * ui.draggable.js
13
+ * ui.resizable.js
14
+ */
15
+ (function($) {
16
+
17
+ var setDataSwitch = {
18
+ dragStart: "start.draggable",
19
+ drag: "drag.draggable",
20
+ dragStop: "stop.draggable",
21
+ maxHeight: "maxHeight.resizable",
22
+ minHeight: "minHeight.resizable",
23
+ maxWidth: "maxWidth.resizable",
24
+ minWidth: "minWidth.resizable",
25
+ resizeStart: "start.resizable",
26
+ resize: "drag.resizable",
27
+ resizeStop: "stop.resizable"
28
+ };
29
+
30
+ $.widget("ui.dialog", {
31
+
32
+ _init: function() {
33
+ this.originalTitle = this.element.attr('title');
34
+ this.options.title = this.options.title || this.originalTitle;
35
+
36
+ var self = this,
37
+ options = this.options,
38
+
39
+ uiDialogContent = this.element
40
+ .appendTo(document.body)
41
+ .removeAttr('title')
42
+ .addClass(
43
+ 'ui-dialog-content ' +
44
+ 'ui-widget-content')
45
+ .wrap('<div></div>')
46
+ .wrap('<div></div>'),
47
+
48
+ uiDialogContainer = (this.uiDialogContainer = uiDialogContent.parent())
49
+ .addClass('ui-dialog-container')
50
+ .css({
51
+ position: 'relative',
52
+ width: '100%',
53
+ height: '100%'
54
+ }),
55
+
56
+ uiDialogTitlebar = (this.uiDialogTitlebar = $('<div></div>'))
57
+ .addClass(
58
+ 'ui-dialog-titlebar ' +
59
+ 'ui-widget-header ' +
60
+ 'ui-corner-all ' +
61
+ 'ui-helper-clearfix'
62
+ )
63
+ .mousedown(function() {
64
+ self.moveToTop();
65
+ })
66
+ .prependTo(uiDialogContainer),
67
+
68
+ uiDialogTitlebarClose = $('<a href="#"/>')
69
+ .addClass(
70
+ 'ui-dialog-titlebar-close ' +
71
+ 'ui-corner-all'
72
+ )
73
+ .attr('role', 'button')
74
+ .hover(
75
+ function() {
76
+ $(this).addClass('ui-dialog-titlebar-close-hover');
77
+ },
78
+ function() {
79
+ $(this).removeClass('ui-dialog-titlebar-close-hover');
80
+ }
81
+ )
82
+ .mousedown(function(ev) {
83
+ ev.stopPropagation();
84
+ })
85
+ .click(function() {
86
+ self.close();
87
+ return false;
88
+ })
89
+ .appendTo(uiDialogTitlebar),
90
+
91
+ uiDialogTitlebarCloseText = (this.uiDialogTitlebarCloseText = $('<span/>'))
92
+ .addClass(
93
+ 'ui-icon ' +
94
+ 'ui-icon-closethick'
95
+ )
96
+ .text(options.closeText)
97
+ .appendTo(uiDialogTitlebarClose),
98
+
99
+ title = options.title || '&nbsp;',
100
+ titleId = $.ui.dialog.getTitleId(this.element),
101
+ uiDialogTitle = $('<span/>')
102
+ .addClass('ui-dialog-title')
103
+ .attr('id', titleId)
104
+ .html(title)
105
+ .prependTo(uiDialogTitlebar),
106
+
107
+ uiDialog = (this.uiDialog = uiDialogContainer.parent())
108
+ .hide()
109
+ .addClass(
110
+ 'ui-dialog ' +
111
+ 'ui-widget ' +
112
+ 'ui-widget-content ' +
113
+ 'ui-corner-all'
114
+ )
115
+ .addClass(options.dialogClass)
116
+ .css({
117
+ position: 'absolute',
118
+ width: options.width,
119
+ height: options.height,
120
+ overflow: 'hidden',
121
+ zIndex: options.zIndex
122
+ })
123
+ // setting tabIndex makes the div focusable
124
+ // setting outline to 0 prevents a border on focus in Mozilla
125
+ .attr('tabIndex', -1).css('outline', 0).keydown(function(ev) {
126
+ (options.closeOnEscape && ev.keyCode
127
+ && ev.keyCode == $.ui.keyCode.ESCAPE && self.close());
128
+ })
129
+ .attr({
130
+ role: 'dialog',
131
+ 'aria-labelledby': titleId
132
+ })
133
+ .mouseup(function() {
134
+ self.moveToTop();
135
+ }),
136
+
137
+ uiDialogButtonPane = (this.uiDialogButtonPane = $('<div></div>'))
138
+ .addClass(
139
+ 'ui-dialog-buttonpane ' +
140
+ 'ui-widget-content ' +
141
+ 'ui-helper-clearfix'
142
+ )
143
+ .css({
144
+ position: 'absolute',
145
+ bottom: 0
146
+ })
147
+ .appendTo(uiDialog);
148
+
149
+ uiDialogTitlebar.find("*").add(uiDialogTitlebar).disableSelection();
150
+
151
+ (options.draggable && $.fn.draggable && this._makeDraggable());
152
+ (options.resizable && $.fn.resizable && this._makeResizable());
153
+
154
+ this._createButtons(options.buttons);
155
+ this._isOpen = false;
156
+
157
+ (options.bgiframe && $.fn.bgiframe && uiDialog.bgiframe());
158
+ (options.autoOpen && this.open());
159
+ },
160
+
161
+ destroy: function() {
162
+ (this.overlay && this.overlay.destroy());
163
+ this.uiDialog.hide();
164
+ this.element
165
+ .unbind('.dialog')
166
+ .removeData('dialog')
167
+ .removeClass('ui-dialog-content ui-widget-content')
168
+ .hide().appendTo('body');
169
+ this.uiDialog.remove();
170
+
171
+ (this.originalTitle && this.element.attr('title', this.originalTitle));
172
+ },
173
+
174
+ close: function() {
175
+ if (false === this._trigger('beforeclose', null, { options: this.options })) {
176
+ return;
177
+ }
178
+
179
+ (this.overlay && this.overlay.destroy());
180
+ this.uiDialog
181
+ .hide(this.options.hide)
182
+ .unbind('keypress.ui-dialog');
183
+
184
+ this._trigger('close', null, { options: this.options });
185
+ $.ui.dialog.overlay.resize();
186
+
187
+ this._isOpen = false;
188
+ },
189
+
190
+ isOpen: function() {
191
+ return this._isOpen;
192
+ },
193
+
194
+ // the force parameter allows us to move modal dialogs to their correct
195
+ // position on open
196
+ moveToTop: function(force) {
197
+
198
+ if ((this.options.modal && !force)
199
+ || (!this.options.stack && !this.options.modal)) {
200
+ return this._trigger('focus', null, { options: this.options });
201
+ }
202
+
203
+ var maxZ = this.options.zIndex, options = this.options;
204
+ $('.ui-dialog:visible').each(function() {
205
+ maxZ = Math.max(maxZ, parseInt($(this).css('z-index'), 10) || options.zIndex);
206
+ });
207
+ (this.overlay && this.overlay.$el.css('z-index', ++maxZ));
208
+
209
+ //Save and then restore scroll since Opera 9.5+ resets when parent z-Index is changed.
210
+ // http://ui.jquery.com/bugs/ticket/3193
211
+ var saveScroll = { scrollTop: this.element.attr('scrollTop'), scrollLeft: this.element.attr('scrollLeft') };
212
+ this.uiDialog.css('z-index', ++maxZ);
213
+ this.element.attr(saveScroll);
214
+ this._trigger('focus', null, { options: this.options });
215
+ },
216
+
217
+ open: function() {
218
+ if (this._isOpen) { return; }
219
+
220
+ this.overlay = this.options.modal ? new $.ui.dialog.overlay(this) : null;
221
+ (this.uiDialog.next().length && this.uiDialog.appendTo('body'));
222
+ this._position(this.options.position);
223
+ this.uiDialog.show(this.options.show);
224
+ (this.options.autoResize && this._size());
225
+ this.moveToTop(true);
226
+
227
+ // prevent tabbing out of modal dialogs
228
+ (this.options.modal && this.uiDialog.bind('keypress.ui-dialog', function(event) {
229
+ if (event.keyCode != $.ui.keyCode.TAB) {
230
+ return;
231
+ }
232
+
233
+ var tabbables = $(':tabbable', this),
234
+ first = tabbables.filter(':first')[0],
235
+ last = tabbables.filter(':last')[0];
236
+
237
+ if (event.target == last && !event.shiftKey) {
238
+ setTimeout(function() {
239
+ first.focus();
240
+ }, 1);
241
+ } else if (event.target == first && event.shiftKey) {
242
+ setTimeout(function() {
243
+ last.focus();
244
+ }, 1);
245
+ }
246
+ }));
247
+
248
+ this.uiDialog.find(':tabbable:first').focus();
249
+ this._trigger('open', null, { options: this.options });
250
+ this._isOpen = true;
251
+ },
252
+
253
+ _createButtons: function(buttons) {
254
+ var self = this,
255
+ hasButtons = false,
256
+ uiDialogButtonPane = this.uiDialogButtonPane;
257
+
258
+ // remove any existing buttons
259
+ uiDialogButtonPane.empty().hide();
260
+
261
+ $.each(buttons, function() { return !(hasButtons = true); });
262
+ if (hasButtons) {
263
+ uiDialogButtonPane.show();
264
+ $.each(buttons, function(name, fn) {
265
+ $('<button type="button"></button>')
266
+ .addClass(
267
+ 'ui-state-default ' +
268
+ 'ui-corner-all'
269
+ )
270
+ .text(name)
271
+ .click(function() { fn.apply(self.element[0], arguments); })
272
+ .appendTo(uiDialogButtonPane);
273
+ });
274
+ }
275
+ },
276
+
277
+ _makeDraggable: function() {
278
+ var self = this,
279
+ options = this.options;
280
+
281
+ this.uiDialog.draggable({
282
+ cancel: '.ui-dialog-content',
283
+ helper: options.dragHelper,
284
+ handle: '.ui-dialog-titlebar',
285
+ start: function() {
286
+ self.moveToTop();
287
+ (options.dragStart && options.dragStart.apply(self.element[0], arguments));
288
+ },
289
+ drag: function() {
290
+ (options.drag && options.drag.apply(self.element[0], arguments));
291
+ },
292
+ stop: function() {
293
+ (options.dragStop && options.dragStop.apply(self.element[0], arguments));
294
+ $.ui.dialog.overlay.resize();
295
+ }
296
+ });
297
+ },
298
+
299
+ _makeResizable: function(handles) {
300
+ handles = (handles === undefined ? this.options.resizable : handles);
301
+ var self = this,
302
+ options = this.options,
303
+ resizeHandles = typeof handles == 'string'
304
+ ? handles
305
+ : 'n,e,s,w,se,sw,ne,nw';
306
+
307
+ this.uiDialog.resizable({
308
+ cancel: '.ui-dialog-content',
309
+ helper: options.resizeHelper,
310
+ maxWidth: options.maxWidth,
311
+ maxHeight: options.maxHeight,
312
+ minWidth: options.minWidth,
313
+ minHeight: options.minHeight,
314
+ start: function() {
315
+ (options.resizeStart && options.resizeStart.apply(self.element[0], arguments));
316
+ },
317
+ resize: function() {
318
+ (options.autoResize && self._size.apply(self));
319
+ (options.resize && options.resize.apply(self.element[0], arguments));
320
+ },
321
+ handles: resizeHandles,
322
+ stop: function() {
323
+ (options.autoResize && self._size.apply(self));
324
+ (options.resizeStop && options.resizeStop.apply(self.element[0], arguments));
325
+ $.ui.dialog.overlay.resize();
326
+ }
327
+ });
328
+ },
329
+
330
+ _position: function(pos) {
331
+ var wnd = $(window), doc = $(document),
332
+ pTop = doc.scrollTop(), pLeft = doc.scrollLeft(),
333
+ minTop = pTop;
334
+
335
+ if ($.inArray(pos, ['center','top','right','bottom','left']) >= 0) {
336
+ pos = [
337
+ pos == 'right' || pos == 'left' ? pos : 'center',
338
+ pos == 'top' || pos == 'bottom' ? pos : 'middle'
339
+ ];
340
+ }
341
+ if (pos.constructor != Array) {
342
+ pos = ['center', 'middle'];
343
+ }
344
+ if (pos[0].constructor == Number) {
345
+ pLeft += pos[0];
346
+ } else {
347
+ switch (pos[0]) {
348
+ case 'left':
349
+ pLeft += 0;
350
+ break;
351
+ case 'right':
352
+ pLeft += wnd.width() - this.uiDialog.width();
353
+ break;
354
+ default:
355
+ case 'center':
356
+ pLeft += (wnd.width() - this.uiDialog.width()) / 2;
357
+ }
358
+ }
359
+ if (pos[1].constructor == Number) {
360
+ pTop += pos[1];
361
+ } else {
362
+ switch (pos[1]) {
363
+ case 'top':
364
+ pTop += 0;
365
+ break;
366
+ case 'bottom':
367
+ pTop += wnd.height() - this.uiDialog.height();
368
+ break;
369
+ default:
370
+ case 'middle':
371
+ pTop += (wnd.height() - this.uiDialog.height()) / 2;
372
+ }
373
+ }
374
+
375
+ // prevent the dialog from being too high (make sure the titlebar
376
+ // is accessible)
377
+ pTop = Math.max(pTop, minTop);
378
+ this.uiDialog.css({top: pTop, left: pLeft});
379
+ },
380
+
381
+ _setData: function(key, value){
382
+ (setDataSwitch[key] && this.uiDialog.data(setDataSwitch[key], value));
383
+ switch (key) {
384
+ case "buttons":
385
+ this._createButtons(value);
386
+ break;
387
+ case "closeText":
388
+ this.uiDialogTitlebarCloseText.text(value);
389
+ break;
390
+ case "draggable":
391
+ (value
392
+ ? this._makeDraggable()
393
+ : this.uiDialog.draggable('destroy'));
394
+ break;
395
+ case "height":
396
+ this.uiDialog.height(value);
397
+ break;
398
+ case "position":
399
+ this._position(value);
400
+ break;
401
+ case "resizable":
402
+ var uiDialog = this.uiDialog,
403
+ isResizable = this.uiDialog.is(':data(resizable)');
404
+
405
+ // currently resizable, becoming non-resizable
406
+ (isResizable && !value && uiDialog.resizable('destroy'));
407
+
408
+ // currently resizable, changing handles
409
+ (isResizable && typeof value == 'string' &&
410
+ uiDialog.resizable('option', 'handles', value));
411
+
412
+ // currently non-resizable, becoming resizable
413
+ (isResizable || this._makeResizable(value));
414
+
415
+ break;
416
+ case "title":
417
+ $(".ui-dialog-title", this.uiDialogTitlebar).html(value || '&nbsp;');
418
+ break;
419
+ case "width":
420
+ this.uiDialog.width(value);
421
+ break;
422
+ }
423
+
424
+ $.widget.prototype._setData.apply(this, arguments);
425
+ },
426
+
427
+ _size: function() {
428
+ var container = this.uiDialogContainer,
429
+ titlebar = this.uiDialogTitlebar,
430
+ content = this.element,
431
+ tbMargin = (parseInt(content.css('margin-top'), 10) || 0)
432
+ + (parseInt(content.css('margin-bottom'), 10) || 0),
433
+ lrMargin = (parseInt(content.css('margin-left'), 10) || 0)
434
+ + (parseInt(content.css('margin-right'), 10) || 0);
435
+ content.height(container.height() - titlebar.outerHeight() - tbMargin);
436
+ content.width(container.width() - lrMargin);
437
+ }
438
+
439
+ });
440
+
441
+ $.extend($.ui.dialog, {
442
+ version: "@VERSION",
443
+ defaults: {
444
+ autoOpen: true,
445
+ autoResize: true,
446
+ bgiframe: false,
447
+ buttons: {},
448
+ closeOnEscape: true,
449
+ closeText: 'close',
450
+ draggable: true,
451
+ height: 200,
452
+ minHeight: 100,
453
+ minWidth: 150,
454
+ modal: false,
455
+ overlay: {},
456
+ position: 'center',
457
+ resizable: true,
458
+ stack: true,
459
+ width: 300,
460
+ zIndex: 1000
461
+ },
462
+
463
+ getter: 'isOpen',
464
+
465
+ uuid: 0,
466
+
467
+ getTitleId: function($el) {
468
+ return 'ui-dialog-title-' + ($el.attr('id') || ++this.uuid);
469
+ },
470
+
471
+ overlay: function(dialog) {
472
+ this.$el = $.ui.dialog.overlay.create(dialog);
473
+ }
474
+ });
475
+
476
+ $.extend($.ui.dialog.overlay, {
477
+ instances: [],
478
+ events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','),
479
+ function(event) { return event + '.dialog-overlay'; }).join(' '),
480
+ create: function(dialog) {
481
+ if (this.instances.length === 0) {
482
+ // prevent use of anchors and inputs
483
+ // we use a setTimeout in case the overlay is created from an
484
+ // event that we're going to be cancelling (see #2804)
485
+ setTimeout(function() {
486
+ $('a, :input').bind($.ui.dialog.overlay.events, function() {
487
+ // allow use of the element if inside a dialog and
488
+ // - there are no modal dialogs
489
+ // - there are modal dialogs, but we are in front of the topmost modal
490
+ var allow = false;
491
+ var $dialog = $(this).parents('.ui-dialog');
492
+ if ($dialog.length) {
493
+ var $overlays = $('.ui-dialog-overlay');
494
+ if ($overlays.length) {
495
+ var maxZ = parseInt($overlays.css('z-index'), 10);
496
+ $overlays.each(function() {
497
+ maxZ = Math.max(maxZ, parseInt($(this).css('z-index'), 10));
498
+ });
499
+ allow = parseInt($dialog.css('z-index'), 10) > maxZ;
500
+ } else {
501
+ allow = true;
502
+ }
503
+ }
504
+ return allow;
505
+ });
506
+ }, 1);
507
+
508
+ // allow closing by pressing the escape key
509
+ $(document).bind('keydown.dialog-overlay', function(event) {
510
+ (dialog.options.closeOnEscape && event.keyCode
511
+ && event.keyCode == $.ui.keyCode.ESCAPE && dialog.close());
512
+ });
513
+
514
+ // handle window resize
515
+ $(window).bind('resize.dialog-overlay', $.ui.dialog.overlay.resize);
516
+ }
517
+
518
+ var $el = $('<div></div>').appendTo(document.body)
519
+ .addClass('ui-dialog-overlay').css($.extend({
520
+ borderWidth: 0, margin: 0, padding: 0,
521
+ position: 'absolute', top: 0, left: 0,
522
+ width: this.width(),
523
+ height: this.height()
524
+ }, dialog.options.overlay));
525
+
526
+ (dialog.options.bgiframe && $.fn.bgiframe && $el.bgiframe());
527
+
528
+ this.instances.push($el);
529
+ return $el;
530
+ },
531
+
532
+ destroy: function($el) {
533
+ this.instances.splice($.inArray(this.instances, $el), 1);
534
+
535
+ if (this.instances.length === 0) {
536
+ $('a, :input').add([document, window]).unbind('.dialog-overlay');
537
+ }
538
+
539
+ $el.remove();
540
+ },
541
+
542
+ height: function() {
543
+ // handle IE 6
544
+ if ($.browser.msie && $.browser.version < 7) {
545
+ var scrollHeight = Math.max(
546
+ document.documentElement.scrollHeight,
547
+ document.body.scrollHeight
548
+ );
549
+ var offsetHeight = Math.max(
550
+ document.documentElement.offsetHeight,
551
+ document.body.offsetHeight
552
+ );
553
+
554
+ if (scrollHeight < offsetHeight) {
555
+ return $(window).height() + 'px';
556
+ } else {
557
+ return scrollHeight + 'px';
558
+ }
559
+ // handle Opera
560
+ } else if ($.browser.opera) {
561
+ return Math.max(
562
+ window.innerHeight,
563
+ $(document).height()
564
+ ) + 'px';
565
+ // handle "good" browsers
566
+ } else {
567
+ return $(document).height() + 'px';
568
+ }
569
+ },
570
+
571
+ width: function() {
572
+ // handle IE 6
573
+ if ($.browser.msie && $.browser.version < 7) {
574
+ var scrollWidth = Math.max(
575
+ document.documentElement.scrollWidth,
576
+ document.body.scrollWidth
577
+ );
578
+ var offsetWidth = Math.max(
579
+ document.documentElement.offsetWidth,
580
+ document.body.offsetWidth
581
+ );
582
+
583
+ if (scrollWidth < offsetWidth) {
584
+ return $(window).width() + 'px';
585
+ } else {
586
+ return scrollWidth + 'px';
587
+ }
588
+ // handle Opera
589
+ } else if ($.browser.opera) {
590
+ return Math.max(
591
+ window.innerWidth,
592
+ $(document).width()
593
+ ) + 'px';
594
+ // handle "good" browsers
595
+ } else {
596
+ return $(document).width() + 'px';
597
+ }
598
+ },
599
+
600
+ resize: function() {
601
+ /* If the dialog is draggable and the user drags it past the
602
+ * right edge of the window, the document becomes wider so we
603
+ * need to stretch the overlay. If the user then drags the
604
+ * dialog back to the left, the document will become narrower,
605
+ * so we need to shrink the overlay to the appropriate size.
606
+ * This is handled by shrinking the overlay before setting it
607
+ * to the full document size.
608
+ */
609
+ var $overlays = $([]);
610
+ $.each($.ui.dialog.overlay.instances, function() {
611
+ $overlays = $overlays.add(this);
612
+ });
613
+
614
+ $overlays.css({
615
+ width: 0,
616
+ height: 0
617
+ }).css({
618
+ width: $.ui.dialog.overlay.width(),
619
+ height: $.ui.dialog.overlay.height()
620
+ });
621
+ }
622
+ });
623
+
624
+ $.extend($.ui.dialog.overlay.prototype, {
625
+ destroy: function() {
626
+ $.ui.dialog.overlay.destroy(this.$el);
627
+ }
628
+ });
629
+
630
+ })(jQuery);