imagine_cms 4.1.4 → 4.2.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.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +2 -1
  3. data/app/assets/images/interface/form_loading.gif +0 -0
  4. data/app/assets/images/management/btn-top-delete.png +0 -0
  5. data/app/assets/images/management/btn-top-edit.png +0 -0
  6. data/app/assets/images/management/btn-top-exterminate.png +0 -0
  7. data/app/assets/images/management/btn-top-new.png +0 -0
  8. data/app/assets/images/management/btn-top-preview.png +0 -0
  9. data/app/assets/images/management/btn-top-properties.png +0 -0
  10. data/app/assets/javascripts/codemirror/modes-custom/imagine_cms.js +87 -0
  11. data/app/assets/javascripts/imagine_cms/core.js +510 -0
  12. data/app/assets/javascripts/imagine_cms/legacy/misc.js +537 -0
  13. data/app/assets/javascripts/imagine_cms/legacy/rollovers.js +193 -0
  14. data/app/assets/javascripts/imagine_cms/legacy/slideshow.js +116 -0
  15. data/app/assets/javascripts/imagine_cms/legacy/textfieldhints.js +55 -0
  16. data/app/assets/javascripts/imagine_cms.js +14 -1
  17. data/app/assets/javascripts/imagine_cms_compat.js +26 -0
  18. data/app/assets/javascripts/jquery-ui.js +16608 -0
  19. data/app/assets/javascripts/tag-it.js +591 -0
  20. data/app/assets/stylesheets/imagine_cms.css.scss +26 -10
  21. data/app/assets/stylesheets/imagine_controls.css.scss +8 -0
  22. data/app/assets/stylesheets/jquery-ui.css +1225 -0
  23. data/app/assets/stylesheets/jquery-ui.structure.css +833 -0
  24. data/app/assets/stylesheets/jquery-ui.theme.css +410 -0
  25. data/app/assets/stylesheets/jquery.tagit.css +69 -0
  26. data/app/assets/stylesheets/management.css.scss +7 -0
  27. data/app/assets/stylesheets/tagit.ui-imagine.css +100 -0
  28. data/app/controllers/cms/content_controller.rb +28 -45
  29. data/app/controllers/management/cms_controller.rb +116 -94
  30. data/app/helpers/cms_application_helper.rb +76 -39
  31. data/app/models/cms_page.rb +32 -14
  32. data/app/models/cms_page_object.rb +1 -1
  33. data/app/models/cms_page_tag.rb +2 -2
  34. data/app/models/cms_template.rb +1 -1
  35. data/app/models/user.rb +6 -6
  36. data/app/models/user_group.rb +1 -1
  37. data/app/views/cms/content/_photo_gallery.html.erb +12 -12
  38. data/app/views/cms/content/_search.html.erb +2 -2
  39. data/app/views/cms/content/_search_result.html.erb +16 -10
  40. data/app/views/layouts/management.html.erb +18 -17
  41. data/app/views/management/cms/_edit_page.html.erb +47 -33
  42. data/app/views/management/cms/_gallery_index.html.erb +4 -4
  43. data/app/views/management/cms/_image.html.erb +3 -3
  44. data/app/views/management/cms/_image_details.html.erb +9 -8
  45. data/app/views/management/cms/_list_page.html.erb +2 -2
  46. data/app/views/management/cms/_list_page_select.html.erb +1 -1
  47. data/app/views/management/cms/_page_list.html.erb +69 -48
  48. data/app/views/management/cms/_page_list_source_folder.html.erb +2 -2
  49. data/app/views/management/cms/_template_options.html.erb +4 -4
  50. data/app/views/management/cms/_template_reference.html.erb +13 -15
  51. data/app/views/management/cms/edit_page_content.html.erb +3 -3
  52. data/app/views/management/cms/edit_snippet.html.erb +19 -41
  53. data/app/views/management/cms/edit_template.html.erb +15 -38
  54. data/app/views/management/cms/pages.html.erb +17 -29
  55. data/app/views/management/cms/snippets.html.erb +2 -2
  56. data/app/views/management/cms/templates.html.erb +2 -2
  57. data/app/views/management/cms/toolbar_edit.html.erb +2 -0
  58. data/app/views/management/cms/toolbar_preview.html.erb +2 -2
  59. data/config/initializers/config_file.rb +1 -1
  60. data/imagine_cms.gemspec +7 -4
  61. data/lib/extensions/action_controller_extensions.rb +50 -19
  62. data/lib/imagine_cms/engine.rb +12 -8
  63. data/lib/imagine_cms/version.rb +1 -1
  64. data/lib/prototype_legacy_helper/lib/prototype_legacy_helper.rb +2 -2
  65. data/lib/tasks/imagine_cms_tasks.rake +8 -0
  66. metadata +69 -91
  67. data/app/assets/images/management/btn_archive.gif +0 -0
  68. data/app/assets/images/management/btn_delete.gif +0 -0
  69. data/app/assets/images/management/btn_duplicate.gif +0 -0
  70. data/app/assets/images/management/btn_edit.gif +0 -0
  71. data/app/assets/images/management/btn_new_page.gif +0 -0
  72. data/app/assets/images/management/btn_preview.gif +0 -0
  73. data/app/assets/images/management/btn_properties.gif +0 -0
  74. data/app/assets/images/management/btn_restore.gif +0 -0
  75. data/app/assets/images/management/btn_top_delete.gif +0 -0
  76. data/app/assets/images/management/btn_top_duplicate.gif +0 -0
  77. data/app/assets/images/management/btn_top_edit.gif +0 -0
  78. data/app/assets/images/management/btn_top_new.gif +0 -0
  79. data/app/assets/images/management/btn_top_preview.gif +0 -0
  80. data/app/assets/images/management/btn_top_properties.gif +0 -0
  81. data/app/assets/javascripts/codepress/codepress.html +0 -36
  82. data/app/assets/javascripts/codepress/codepress.js +0 -130
  83. data/app/assets/javascripts/codepress/engines/gecko.js +0 -240
  84. data/app/assets/javascripts/codepress/engines/khtml.js +0 -0
  85. data/app/assets/javascripts/codepress/engines/msie.js +0 -263
  86. data/app/assets/javascripts/codepress/engines/older.js +0 -0
  87. data/app/assets/javascripts/codepress/engines/opera.js +0 -259
  88. data/app/assets/javascripts/codepress/languages/css.js +0 -23
  89. data/app/assets/javascripts/codepress/languages/generic.js +0 -25
  90. data/app/assets/javascripts/codepress/languages/html.js +0 -63
  91. data/app/assets/javascripts/codepress/languages/java.js +0 -24
  92. data/app/assets/javascripts/codepress/languages/javascript.js +0 -30
  93. data/app/assets/javascripts/codepress/languages/perl.js +0 -27
  94. data/app/assets/javascripts/codepress/languages/php.js +0 -60
  95. data/app/assets/javascripts/codepress/languages/ruby.js +0 -26
  96. data/app/assets/javascripts/codepress/languages/sql.js +0 -30
  97. data/app/assets/javascripts/codepress/languages/text.js +0 -9
  98. data/app/assets/javascripts/imagine.js +0 -1393
  99. data/app/assets/stylesheets/codepress/codepress.css +0 -7
  100. data/app/assets/stylesheets/codepress/languages/css.css +0 -10
  101. data/app/assets/stylesheets/codepress/languages/generic.css +0 -9
  102. data/app/assets/stylesheets/codepress/languages/html.css +0 -18
  103. data/app/assets/stylesheets/codepress/languages/java.css +0 -7
  104. data/app/assets/stylesheets/codepress/languages/javascript.css +0 -8
  105. data/app/assets/stylesheets/codepress/languages/perl.css +0 -11
  106. data/app/assets/stylesheets/codepress/languages/php.css +0 -12
  107. data/app/assets/stylesheets/codepress/languages/ruby.css +0 -10
  108. data/app/assets/stylesheets/codepress/languages/sql.css +0 -10
  109. data/app/assets/stylesheets/codepress/languages/text.css +0 -5
@@ -1,1393 +0,0 @@
1
- /********************************
2
- * default settings, override *
3
- * in application.js *
4
- ********************************/
5
-
6
- // Fixes gallery reordering (Scriptaculous Sortable)
7
- Position.includeScrollOffsets = true;
8
-
9
- var defaultXMenuOffset = 0;
10
- var defaultYMenuOffset = 0;
11
- var defaultXOffset = 0;
12
- var defaultYOffset = 0;
13
- var showRolloverEffect = Effect.Appear;
14
- var showRolloverEffectOptions = { duration: 0.2 };
15
- var showRolloverMenuEffect = Effect.BlindDown;
16
- var showRolloverMenuEffectOptions = { duration: 0.2 };
17
- var hideRolloverDelay = 120;
18
- var hideRolloverEffect = Effect.Fade;
19
- var hideRolloverEffectOptions = { duration: 0.3 };
20
- var hideRolloverMenuEffect = Effect.BlindUp;
21
- var hideRolloverMenuEffectOptions = { duration: 0.2 };
22
-
23
-
24
- /********************************
25
- * framework code follows *
26
- ********************************/
27
-
28
- var currentEffect = [];
29
-
30
- function getElementPosition(sourceObj) {
31
- if (sourceObj.style.left && sourceObj.style.top) {
32
- // for the W3C-compliant crowd
33
- return [parseInt(sourceObj.style.left), parseInt(sourceObj.style.top)];
34
- } else {
35
- // for the other awful browsers...
36
- x = sourceObj.offsetLeft;
37
- y = sourceObj.offsetTop;
38
- temp = sourceObj;
39
- while (temp = temp.offsetParent) {
40
- x += temp.offsetLeft;
41
- y += temp.offsetTop;
42
- }
43
-
44
- return [x, y];
45
- }
46
- }
47
-
48
- /********************************
49
- * rollover/menu functions *
50
- ********************************/
51
-
52
- var hideRolloverTimeouts = [];
53
- var hoveredButtons = [];
54
-
55
- function showRollover(target, xMenuOffset, yMenuOffset, xOffset, yOffset) {
56
- try {
57
- if (hideRolloverTimeouts[target]) {
58
- clearTimeout(hideRolloverTimeouts[target]);
59
- hideRolloverTimeouts[target] = null;
60
- return;
61
- }
62
-
63
- if (hoveredButtons[target]) {
64
- return;
65
- }
66
-
67
- var el = $(target + '_hover');
68
- var sourceObj = $(target + '_std');
69
-
70
- var coords = getElementPosition(sourceObj);
71
- if (typeof(xMenuOffset) == 'undefined') xMenuOffset = defaultXMenuOffset;
72
- if (typeof(yMenuOffset) == 'undefined') yMenuOffset = defaultYMenuOffset;
73
- if (typeof(xOffset) == 'undefined') xOffset = defaultXOffset;
74
- if (typeof(yOffset) == 'undefined') yOffset = defaultYOffset;
75
-
76
- el.style.position = 'absolute';
77
- el.style.left = coords[0] + xOffset + 'px';
78
- el.style.top = coords[1] + yOffset + 'px';
79
- el.style.margin = '0';
80
- el.style.zIndex = '100';
81
-
82
- if (currentEffect[el.id]) currentEffect[el.id].cancel();
83
- currentEffect[el.id] = showRolloverEffect(el.id, showRolloverEffectOptions);
84
-
85
- if (el = $(target + '_menu')) {
86
- el.style.display = 'none';
87
- el.style.position = 'absolute';
88
- el.style.left = (coords[0] + xMenuOffset) + 'px';
89
- el.style.top = (coords[1] + yMenuOffset) + 'px';
90
- el.style.margin = '0';
91
- el.style.zIndex = '100';
92
-
93
- for (var i = 0; i < el.childNodes.length; i++) {
94
- if (el.childNodes[i].tagName == 'DIV') {
95
- el.style.width = el.childNodes[i].style.width;
96
- el.style.height = el.childNodes[i].style.height;
97
- break;
98
- }
99
- }
100
- if (currentEffect[el.id]) currentEffect[el.id].cancel();
101
- currentEffect[el.id] = showRolloverMenuEffect(el.id, showRolloverMenuEffectOptions);
102
- }
103
-
104
- hoveredButtons[target] = true;
105
- } catch (e) { }
106
- }
107
-
108
- function hideRollover(target) {
109
- try {
110
- hideRolloverTimeouts[target] = setTimeout('hideRolloverComplete("' + target + '");', hideRolloverDelay);
111
- } catch (e) {}
112
- }
113
-
114
- function hideRolloverComplete(target) {
115
- try {
116
- hideRolloverTimeouts[target] = null;
117
-
118
- if (el = $(target + '_hover')) {
119
- if (currentEffect[el.id]) currentEffect[el.id].cancel();
120
- currentEffect[el.id] = hideRolloverEffect(el.id, hideRolloverEffectOptions);
121
- }
122
-
123
- if (el = $(target + '_menu')) {
124
- if (currentEffect[el.id]) currentEffect[el.id].cancel();
125
- currentEffect[el.id] = hideRolloverMenuEffect(el.id, hideRolloverMenuEffectOptions);
126
- }
127
-
128
- hoveredButtons[target] = false;
129
- } catch (e) {}
130
- }
131
-
132
-
133
- var hideSimpleRolloverTimeouts = [];
134
- function showSimpleRollover(target, xOffset, yOffset) {
135
- try {
136
- // if we were planning to hide this element in the future, no need for that now
137
- if (hideSimpleRolloverTimeouts[target]) {
138
- clearTimeout(hideSimpleRolloverTimeouts[target]);
139
- hideSimpleRolloverTimeouts[target] = null;
140
- return;
141
- }
142
-
143
- // if other elements are waiting to be hidden, get it over with now
144
- $H(hideSimpleRolloverTimeouts)._each(function (pair) {
145
- clearTimeout(pair[1]);
146
- hideSimpleRolloverComplete(pair[0]);
147
- });
148
- } catch (e) {}
149
-
150
- try {
151
- var el = document.getElementById(target + '_std');
152
- el.oldsrc = el.src;
153
- el.src = el.src.replace(/(_hover)?.gif$/, '_hover.gif');
154
- if (!(is.ie && is.mac)) showSimpleRolloverMenu(target, xOffset, yOffset);
155
- } catch (e) {}
156
- }
157
-
158
- function showSimpleRolloverMenu(target, xOffset, yOffset, useRelative) {
159
- try {
160
- if (hideSimpleRolloverTimeouts[target]) {
161
- clearTimeout(hideSimpleRolloverTimeouts[target]);
162
- hideSimpleRolloverTimeouts[target] = null;
163
- return;
164
- }
165
-
166
- var el = document.getElementById(target + '_std');
167
- if (el) {
168
- var coords = getElementPosition(el);
169
-
170
- if (typeof(xOffset) == 'undefined') xOffset = 0;
171
- if (typeof(yOffset) == 'undefined') yOffset = 30;
172
- if (typeof(useRelative) == 'undefined') useRelative = false;
173
-
174
- if (el = document.getElementById(target + '_menu')) {
175
- el.style.zIndex = 100;
176
- el.style.position = 'absolute';
177
- if (useRelative) {
178
- el.style.left = xOffset + 'px';
179
- el.style.top = yOffset + 'px';
180
- } else {
181
- el.style.left = (coords[0] + xOffset) + 'px';
182
- el.style.top = (coords[1] + yOffset) + 'px';
183
- }
184
- el.style.display = '';
185
- }
186
- }
187
- } catch (e) {}
188
- }
189
-
190
- function hideSimpleRollover(target) {
191
- try {
192
- hideSimpleRolloverTimeouts[target] = setTimeout('hideSimpleRolloverComplete("' + target + '")', 200);
193
- } catch (e) {}
194
- }
195
-
196
- function hideSimpleRolloverComplete(target) {
197
- try {
198
- var el = document.getElementById(target + '_std');
199
- if (el.oldsrc) el.src = el.oldsrc;
200
- hideSimpleRolloverMenuComplete(target);
201
- } catch (e) {}
202
- }
203
-
204
- function hideSimpleRolloverMenu(target) {
205
- try {
206
- hideSimpleRolloverTimeouts[target] = setTimeout('hideSimpleRolloverMenuComplete("' + target + '")', 200);
207
- } catch (e) {}
208
- }
209
-
210
- function hideSimpleRolloverMenuComplete(target) {
211
- try {
212
- hideSimpleRolloverTimeouts[target] = null;
213
-
214
- var el = document.getElementById(target + '_std');
215
- var coords = getElementPosition(el);
216
-
217
- if (el = document.getElementById(target + '_menu')) {
218
- el.style.display = 'none';
219
- }
220
- } catch (e) {}
221
- }
222
-
223
-
224
- /********************************
225
- * slideshow functions *
226
- ********************************/
227
-
228
- var currentSlideIndex = 0;
229
- var maxSlideIndex = -1;
230
-
231
- function getNumSlides() {
232
- if (maxSlideIndex > -1) return maxSlideIndex;
233
- maxSlideIndex = 0;
234
-
235
- while ($('img_slideshow' + maxSlideIndex)) maxSlideIndex++;
236
- return maxSlideIndex;
237
- }
238
-
239
- function nextSlide(delay, transition) {
240
- if (typeof(transition) == 'undefined') transition = 'SlideAppear';
241
- changeSlide(delay, transition, 1);
242
- }
243
-
244
- function prevSlide(delay, transition) {
245
- if (typeof(transition) == 'undefined') transition = 'SlideAppear';
246
- changeSlide(delay, transition, -1);
247
- }
248
-
249
- // controls elements named img_slideshowX
250
- // uses a global named currentSlideIndex to keep track of its state
251
- // uses a global named maxSlideIndex to cache the discovered maximum slide index
252
- function changeSlide(delay, transition, increment) {
253
- try {
254
- if (typeof(delay) == 'undefined') delay = -1;
255
- if (typeof(transition) == 'undefined') transition = 'SlideAppear';
256
-
257
- // this element is used for positioning
258
- origimg = $('img_slideshow');
259
-
260
- nextSlideIndex = currentSlideIndex + increment;
261
- if (!$('img_slideshow' + nextSlideIndex)) {
262
- if (increment > 0) {
263
- nextSlideIndex = 0;
264
- } else {
265
- nextSlideIndex = getNumSlides() - 1;
266
- }
267
- }
268
-
269
- if ((curimg = $('img_slideshow' + currentSlideIndex)) &&
270
- (nextimg = $('img_slideshow' + nextSlideIndex))) {
271
- // push old images back
272
- for (var i = 0; i < getNumSlides(); i++) {
273
- $('img_slideshow' + i).style.zIndex = ((increment > 0) ? i : (getNumSlides() - i));
274
- }
275
- nextimg.style.zIndex = '90';
276
- nextimg.style.margin = '0';
277
-
278
- // really shouldn't have to do this, but I just can't figure it out...
279
- curimg.style.zIndex = '89';
280
-
281
- // drag the new image over the main image
282
- var coords = getElementPosition(origimg);
283
- nextimg.style.position = 'absolute';
284
- nextimg.style.left = coords[0] + 'px';
285
- nextimg.style.top = coords[1] + 'px';
286
-
287
- eval('Effect.' + transition + '(nextimg.id, { duration: 1.8 });');
288
- setTimeout('$("' + curimg.id + '").style.display = "none"', 1900);
289
- if (delay > 0) setTimeout('changeSlide(' + delay + ', "' + transition + '", ' + increment + ');', delay);
290
-
291
- currentSlideIndex = nextSlideIndex;
292
- }
293
- } catch (e) {}
294
- }
295
-
296
- // positions slide navigation elements (named btn_slidenext and btn_slideprev)
297
- // relative to img_slideshow (x and y are the relative offsets)
298
- function positionSlideNav(x, y) {
299
- try {
300
- img = $('img_slideshow');
301
- nav = $('div_slidenav');
302
-
303
- // move the buttons to their proper places
304
- nav.style.zIndex = '95';
305
- nav.style.position = 'relative';
306
- nav.style.left = x + 'px';
307
- nav.style.top = y + 'px';
308
- } catch (e) {}
309
- }
310
-
311
-
312
- /********************************
313
- * dialog/popup functions *
314
- ********************************/
315
-
316
- function openDialog(url, w, h, opts) {
317
- window.open(url, '_blank', (w && h ? 'width=' + w + ',height=' + h : '') + (typeof(opts) == 'undefined' ? '' : ',' + opts));
318
- }
319
-
320
- // resize the window to fit the content
321
- function autoResize(masterDiv) {
322
- if (typeof(masterDiv) == 'undefined') {
323
- masterDiv = $('masterDiv');
324
- } else {
325
- masterDiv = $(masterDiv);
326
- }
327
- var max = Math.min(screen.height - 100, 800);
328
- var ht = Math.min(masterDiv.scrollHeight, max);
329
-
330
- if (typeof(window.innerWidth) == 'number') {
331
- //Non-IE
332
- myWidth = window.innerWidth;
333
- myHeight = window.innerHeight;
334
- } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
335
- //IE 6+ in 'standards compliant mode'
336
- myWidth = document.documentElement.clientWidth;
337
- myHeight = document.documentElement.clientHeight;
338
- } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
339
- //IE 4 compatible
340
- myWidth = document.body.clientWidth;
341
- myHeight = document.body.clientHeight;
342
- }
343
-
344
- resizeBy(0, ht - myHeight);
345
- }
346
-
347
-
348
- // the opposite... resize the content to fit the window
349
- function autoResizeDiv(masterDiv, adjustment) {
350
- if (typeof(masterDiv) == 'undefined') {
351
- masterDiv = $('masterDiv');
352
- } else {
353
- masterDiv = $(masterDiv);
354
- }
355
- if (typeof(adjustment) == 'undefined') adjustment = 0;
356
-
357
- var max = Math.min(screen.height - 100, 800);
358
- var ht = Math.min(masterDiv.scrollHeight, max);
359
-
360
- if (typeof(window.innerWidth) == 'number') {
361
- //Non-IE
362
- myWidth = window.innerWidth;
363
- myHeight = window.innerHeight;
364
- } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
365
- //IE 6+ in 'standards compliant mode'
366
- myWidth = document.documentElement.clientWidth;
367
- myHeight = document.documentElement.clientHeight;
368
- } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
369
- //IE 4 compatible
370
- myWidth = document.body.clientWidth;
371
- myHeight = document.body.clientHeight;
372
- }
373
-
374
- masterDiv.style.height = myHeight - 200 + adjustment + 'px';
375
- }
376
-
377
-
378
- /********************************
379
- * date picker functions *
380
- ********************************/
381
-
382
- function showDatePicker(object, method_prefix) {
383
- // anchor picker to the icon
384
- var coords = getElementPosition($('date_picker_' + object + '_' + method_prefix + 'icon'));
385
- var el = $('date_picker_' + object + '_' + method_prefix + 'main');
386
- el.hide();
387
- el.style.position = 'absolute';
388
- el.show();
389
- }
390
-
391
- function hideDatePicker(object, method_prefix) {
392
- $('date_picker_' + object + '_' + method_prefix + 'main').hide();
393
- }
394
-
395
- function dpPrevMonth(object, method_prefix, min_year) {
396
- try {
397
- if ($(object + '_' + method_prefix + '_month_sel').value > 1) {
398
- $(object + '_' + method_prefix + '_month_sel').value--;
399
- } else if ($(object + '_' + method_prefix + '_year_sel').value > min_year) {
400
- $(object + '_' + method_prefix + '_month_sel').value = 12;
401
- $(object + '_' + method_prefix + '_year_sel').value--;
402
- }
403
- } catch (e) {}
404
- }
405
-
406
- function dpNextMonth(object, method_prefix, max_year) {
407
- try {
408
- if ($(object + '_' + method_prefix + '_month_sel').value < 12) {
409
- $(object + '_' + method_prefix + '_month_sel').value++;
410
- } else if ($(object + '_' + method_prefix + '_year_sel').value < max_year) {
411
- $(object + '_' + method_prefix + '_month_sel').value = 1;
412
- $(object + '_' + method_prefix + '_year_sel').value++;
413
- }
414
- } catch (e) {}
415
- }
416
-
417
-
418
- /********************************
419
- * custom effects *
420
- ********************************/
421
-
422
- Effect.BlindRight = function(element) {
423
- element = $(element);
424
- var oldWidth = Element.getStyle(element, 'width');
425
- var elementDimensions = Element.getDimensions(element);
426
- return new Effect.Scale(element, 100,
427
- Object.extend({
428
- scaleContent: false,
429
- scaleY: false,
430
- scaleFrom: 0,
431
- scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
432
- restoreAfterFinish: true,
433
- afterSetup: function(effect) { with(Element) {
434
- makeClipping(effect.element);
435
- setStyle(effect.element, {width: '0px'});
436
- show(effect.element);
437
- }}
438
- }, arguments[1] || {})
439
- );
440
- }
441
-
442
- Effect.SlideAppear = function(element) {
443
- element = $(element);
444
- new Effect.Appear(element, arguments[2] || arguments[1] || {});
445
- new Effect.BlindRight(element, arguments[1] || {});
446
- }
447
-
448
-
449
- /********************************
450
- * column browser interface *
451
- ********************************/
452
-
453
- var cbNumColumns = 0;
454
- var cbColWidth = '200px';
455
- var cbColHeight = '240px';
456
- var cbBorderWidth = '1px';
457
- var cbColWidthFull = 202;
458
-
459
- function cbAddColumn() {
460
- var currentWidth = parseInt($('columnBrowser').style.width, 10);
461
- // if (currentWidth < ((cbNumColumns+1) * cbColWidthFull)) {
462
- $('columnBrowser').style.width = '' + ((cbNumColumns+1) * cbColWidthFull) + 'px';
463
- $('columnBrowserContainer').scrollLeft = $('columnBrowserContainer').scrollWidth;
464
- // }
465
- $('columnBrowser').innerHTML += "<div id=\"columnBrowserLevel" + cbNumColumns + "\" style=\"width: " + cbColWidth + "; height: " + cbColHeight + "; overflow: auto; float: left; border-width: " + cbBorderWidth + " " + cbBorderWidth + " " + cbBorderWidth + " " + (cbNumColumns == 0 ? cbBorderWidth : '0') + "; border-style: solid; border-color: gray;\">Loading...</div>";
466
- cbNumColumns++;
467
- }
468
-
469
- function getScrollbarPosition(el) {
470
- el = $(el);
471
- return { x: el.scrollLeft, y: el.scrollTop };
472
- }
473
-
474
- function setScrollbarPosition(el, coords) {
475
- el = $(el);
476
- el.scrollLeft = coords.x;
477
- el.scrollTop = coords.y;
478
- }
479
-
480
- function cbSelectItem(el, currentLevel, urlForNextLevel) {
481
- var el = $(el);
482
- coords = getScrollbarPosition(el.parentNode);
483
-
484
- // remove all higher levels and unselect all other same-level divs
485
- for (var i = currentLevel + 1; i <= cbNumColumns; i++) {
486
- d = $('columnBrowserLevel' + i);
487
- if (d) d.parentNode.removeChild(d);
488
- }
489
- cbNumColumns = currentLevel + 1;
490
-
491
- prefix = 'cb_item_';
492
- $A(el.parentNode.childNodes).each(function (d) {
493
- if (d.id && d.id.substring(0, prefix.length) == prefix) {
494
- d.className = 'cb_item';
495
- }
496
- })
497
-
498
- // select and expand current dept div
499
- el.className = 'cb_item cb_item_selected';
500
-
501
- cbAddColumn();
502
- el = $(el.id);
503
- new Ajax.Updater('columnBrowserLevel' + (currentLevel+1), urlForNextLevel, {method: 'GET', asynchronous:true, evalScripts:true});
504
-
505
- setScrollbarPosition(el.parentNode, coords);
506
- }
507
-
508
-
509
- /********************************
510
- * text field hints *
511
- ********************************/
512
-
513
- function addLoadEvent(func) {
514
- var oldonload = window.onload;
515
- if (typeof window.onload != 'function') {
516
- window.onload = func;
517
- } else {
518
- window.onload = function() {
519
- oldonload();
520
- func();
521
- }
522
- }
523
- }
524
-
525
- function addUnloadEvent(func) {
526
- var oldonunload = window.onunload;
527
- if (typeof window.onunload != 'function') {
528
- window.onunload = func;
529
- } else {
530
- window.onunload = function() {
531
- oldonunload();
532
- func();
533
- }
534
- }
535
- }
536
-
537
- var textFieldHints = new Array();
538
- function setupTextFieldHints() {
539
- textFieldHints.each(function (a) {
540
- $A(document.getElementsByName(a.name)).each(function (el) {
541
- var clearHint = function () {
542
- el.value = '';
543
- el.style.color = el.style.origColor ? el.style.origColor : 'black';
544
- el.onfocus = el.oldOnFocus;
545
- el.oldOnBlur = el.onblur;
546
- el.onblur = function () {
547
- if (typeof(el.oldOnBlur) == 'function') el.oldOnBlur();
548
- setHint();
549
- }
550
- };
551
- var setHint = function () {
552
- if (!el.value || el.value == a.hint) {
553
- el.value = a.hint;
554
- el.style.origColor = el.style.color;
555
- el.style.color = 'gray';
556
- if (typeof(el.oldOnBlur) != 'undefined') el.onblur = el.oldOnBlur;
557
- el.oldOnFocus = el.onfocus;
558
- el.onfocus = function () {
559
- if (typeof(el.oldOnFocus) == 'function') el.oldOnFocus();
560
- clearHint();
561
- }
562
- }
563
- }
564
- setHint();
565
- })
566
- });
567
- }
568
- addLoadEvent(setupTextFieldHints);
569
-
570
- function teardownTextFieldHints() {
571
- textFieldHints.each(function (a) {
572
- var el = document.getElementsByName(a.name)[0];
573
- if (el.value == a.hint) {
574
- el.value = '';
575
- el.style.color = el.origColor ? el.origColor : 'black';
576
- el.onfocus = null;
577
- }
578
- });
579
- }
580
-
581
- function addTextFieldHint(name, hint) {
582
- if (textFieldHints.select(function (a) { return a.name == name }).length == 0) {
583
- textFieldHints.push({ name: name, hint: hint });
584
- }
585
- }
586
-
587
-
588
- /********************************
589
- * horizontal tab interface *
590
- ********************************/
591
-
592
- function setPageVisibility() {
593
- var opts = $A($('page_select').options);
594
- opts.each(function (opt) {
595
- $(opt.value).hide();
596
- });
597
- $($F('page_select')).show();
598
- }
599
-
600
-
601
- /********************************
602
- * vertical tab interface *
603
- ********************************/
604
-
605
- function selectTab(tabName, tabArray, tabBtnPrefix, tabDivPrefix, hiddenTextFieldId) {
606
- tabArray._each(function (tab) {
607
- $(tabBtnPrefix + tab).className = 'tab_normal';
608
- $(tabDivPrefix + tab).style.display = 'none';
609
- })
610
- $('pmtbtn_' + tabName).className = 'tab_selected';
611
- $('pmtinfo_' + tabName).style.display = '';
612
- $(hiddenTextFieldId).value = tabName;
613
- }
614
-
615
-
616
- /********************************
617
- * cms support *
618
- ********************************/
619
-
620
- // support for autocompletes
621
- var attrlist = [];
622
- var taglist = [];
623
-
624
- var dialogStack = [];
625
- function showDojoDialog(id, titleText) {
626
- if (!is.ie) changeOverflowAutoToHidden();
627
-
628
- dlg = dojo.widget.byId(id);
629
- if (!dlg) dlg = dojo.widget.createWidget(id);
630
- if (!dlg) return false;
631
-
632
- dlg.closeWindow = function () { hideDojoDialog(id); };
633
- dlg.show();
634
-
635
- if (typeof(titleText) != 'undefined') {
636
- try {
637
- document.getElementById('propertiesDialog').getElementsByTagName('div')[0].getElementsByTagName('div')[4].innerHTML = titleText;
638
- } catch (e) {}
639
- }
640
-
641
- if (dialogStack.length > 0) dojo.widget.byId(dialogStack[dialogStack.length-1]).hide();
642
- dialogStack.push(id);
643
- }
644
-
645
- function hideDojoDialog(id) {
646
- dialogStack.pop();
647
-
648
- dojo.widget.byId(id).hide();
649
- if (!is.ie) changeOverflowHiddenToAuto();
650
-
651
- if (dialogStack.length > 0) {
652
- dojo.widget.byId(dialogStack[dialogStack.length-1]).show();
653
- }
654
- }
655
-
656
- function editProperties(url, titleText) {
657
- $('properties_dialog_content').innerHTML = 'Loading...';
658
- new Ajax.Updater('properties_dialog_content', url, {method:'get', asynchronous:true, evalScripts:true});
659
-
660
- showDojoDialog('properties_dialog', titleText);
661
- }
662
-
663
- function cancelEditProperties() {
664
- hideDojoDialog('properties_dialog');
665
- }
666
-
667
- function insertImage(url) {
668
- var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
669
- imageNode = dojo.withGlobal(curInst.window, "getSelectedElement", dojo.html.selection);
670
- if (!imageNode) {
671
- imageNode = dojo.withGlobal(curInst.window, "getAncestorElement", dojo.html.selection, ['img']);
672
- }
673
- if (imageNode) {
674
- dojo.require("dojo.widget.Editor2Plugin.InsertImageDialog");
675
- w = dojo.widget.createWidget("Editor2InsertImageDialog");
676
- w.show();
677
- } else {
678
- $('insert_image_dialog_content').innerHTML = 'Loading...';
679
- new Ajax.Updater('insert_image_dialog_content', url, {method:'get', asynchronous:true, evalScripts:true});
680
- showDojoDialog('insert_image_dialog');
681
- }
682
- try { if (cropper) cropper.remove(); } catch (e) {}
683
- }
684
-
685
- function cancelInsertImage() {
686
- hideDojoDialog('insert_image_dialog');
687
- try { if (cropper) cropper.remove(); } catch (e) {}
688
- }
689
-
690
- function insertFile(url) {
691
- var curInst = dojo.widget.Editor2Manager.getCurrentInstance();
692
- curInst.saveSelection(); //save selection (none-activeX IE)
693
- var html = dojo.withGlobal(curInst.window, "getSelectedText", dojo.html.selection);
694
- if (html == null || html.length == 0) {
695
- alert("Please select some text to create a file link.");
696
- return false; //do not show the dialog
697
- }
698
-
699
- $('insert_file_dialog_content').innerHTML = 'Loading...';
700
- new Ajax.Updater('insert_file_dialog_content', url, {method:'get', asynchronous:true, evalScripts:true});
701
- showDojoDialog('insert_file_dialog');
702
- }
703
-
704
- function cancelInsertFile() {
705
- hideDojoDialog('insert_file_dialog');
706
- }
707
-
708
- function selectThumbnail(url) {
709
- $('select_thumbnail_dialog_content').innerHTML = 'Loading...';
710
- new Ajax.Updater('select_thumbnail_dialog_content', url, {asynchronous:true, evalScripts:true});
711
- showDojoDialog('select_thumbnail_dialog');
712
- }
713
-
714
- function cancelSelectThumbnail() {
715
- hideDojoDialog('select_thumbnail_dialog');
716
- }
717
-
718
- var gallerySize = [];
719
- function changeGalleryImage(galleryName, index) {
720
- var target = galleryName + '_image_' + index;
721
- var caption = galleryName + '_caption_' + index;
722
- if (!$(target)) return false;
723
-
724
- var queue = Effect.Queues.get('global');
725
- queue.each(function(e) { e.cancel() });
726
-
727
- for (var i = 0; i < gallerySize[galleryName]; i++) {
728
- el = $(galleryName + '_image_' + i);
729
- if (el.id != target && el.style.display != 'none') Effect.Fade(el, { duration: 0.6 });
730
-
731
- el = $(galleryName + '_thumb_' + i);
732
- if (el) {
733
- if (i == index) {
734
- el.oldOnmouseover = el.onmouseover;
735
- el.oldOnmouseout = el.onmouseout;
736
- el.onmouseover = null;
737
- el.onmouseout = null;
738
- el.addClassName('current');
739
- } else {
740
- el.removeClassName('current');
741
- if (!el.onmouseover) el.onmouseover = el.oldOnmouseover;
742
- if (!el.onmouseout) el.onmouseout = el.oldOnmouseout;
743
- }
744
- }
745
- }
746
-
747
- Effect.Appear(target, { duration: 0.6 });
748
-
749
- if($(caption).innerHTML != '') {
750
- $(galleryName + '_caption').style.display = 'block';
751
- $(galleryName + '_caption').innerHTML = $(caption).innerHTML;
752
- } else {
753
- $(galleryName + '_caption').style.display = 'none';
754
- }
755
-
756
- prevIndex = index == 0 ? gallerySize[galleryName] - 1 : index-1;
757
- nextIndex = index == gallerySize[galleryName] - 1 ? 0 : index+1;
758
- $(galleryName + '_prev_button').onclick = function () { changeGalleryImage(galleryName, prevIndex) };
759
- $(galleryName + '_next_button').onclick = function () { changeGalleryImage(galleryName, nextIndex) };
760
- }
761
-
762
- var galleryTimeouts = [];
763
- function advanceGallerySlideshow(galleryName, delay) {
764
- $(galleryName + '_next_button').onclick();
765
- galleryTimeouts[galleryName] = setTimeout(function() { advanceGallerySlideshow(galleryName, delay); }, delay);
766
- }
767
-
768
-
769
- // this doesn't seem to work... argh
770
- function disableEnterKey(e) {
771
- // get event if not passed
772
- if (!e) var e = window.event;
773
-
774
- var numCharCode;
775
-
776
- // get character code of key pressed
777
- if (e.keyCode) {
778
- numCharCode = e.keyCode;
779
- } else if (e.which) {
780
- numCharCode = e.which;
781
- }
782
-
783
- if (numCharCode == 13) {
784
- e.cancelBubble = true;
785
- if (e.stopPropagation) e.stopPropagation();
786
- return false;
787
- }
788
- }
789
-
790
- var overflowAutoDivs = [];
791
- function changeOverflowAutoToHidden() {
792
- var divs = [];
793
- $$('div').each(function (div) {
794
- if (div.style.overflow == 'auto') {
795
- divs.push(div);
796
- div.style.overflow = 'hidden';
797
- }
798
- });
799
- overflowAutoDivs.push(divs);
800
- }
801
-
802
- function changeOverflowHiddenToAuto() {
803
- $A(overflowAutoDivs.pop).each(function (div) {
804
- div.style.overflow = 'auto';
805
- });
806
- }
807
-
808
- var pageBrowserFieldID = null;
809
- function showPageBrowser(field_id) {
810
- pageBrowserFieldID = field_id;
811
- path = $(field_id).value;
812
-
813
- $('page_browser').innerHTML = 'Loading...'
814
- new Ajax.Updater('page_browser', '/manage/cms/select_page?path=' + path, {asynchronous:true, evalScripts:true});
815
- $('page_browser_selection').value = path;
816
- showDojoDialog('page_browser_dialog');
817
- }
818
-
819
- function closePageBrowser() {
820
- hideDojoDialog('page_browser_dialog');
821
- $(pageBrowserFieldID).value = $('page_browser_selection').value;
822
- }
823
-
824
- var cmsPageObjects = [];
825
- function scanForPageObjects(page_id, parent_key, version) {
826
- found = [];
827
-
828
- var regex = /<%=\s*insert_object\(?\s*['"]([-\w\s\d]+)['"],\s*:(\w+)\s*(.*?)\)?\s*%>/gm;
829
- if (!$('page_objects_' + parent_key).value) return;
830
-
831
- var matches = $('page_objects_' + parent_key).value.match(regex);
832
- $A(matches).each(function (match) {
833
- // regex2 should be exactly the same as regex. Global regexes have a lastIndex which is not reset.
834
- var regex2 = /<%=\s*insert_object\(?\s*['"]([-\w\s\d]+)['"],\s*:(\w+)\s*(.*?)\)?\s*%>/gm;
835
- if (regex2.test(match)) {
836
- name = match.replace(regex2, "$1");
837
- type = match.replace(regex2, "$2");
838
- opts = match.replace(regex2, "$3");
839
- found[name] = type;
840
- }
841
- });
842
-
843
- // remove the cruft
844
- $H(cmsPageObjects).each(function(pair) {
845
- if (cmsPageObjects[pair.key] != found[pair.key]) {
846
- type = cmsPageObjects[pair.key];
847
- obj_key = type + '_container_obj-' + pair.value + '-' + pair.key.replace(/[^\w]/g, '_');
848
- if ($(obj_key)) {
849
- $(obj_key).parentNode.removeChild($(obj_key));
850
- }
851
- cmsPageObjects[pair.key] = null;
852
- }
853
- });
854
-
855
- // bring in the new
856
- $H(found).each(function (obj) {
857
- name = obj.key
858
- type = obj.value
859
- if (!cmsPageObjects[name]) {
860
- cmsPageObjects[name] = type;
861
- new Ajax.Request('/manage/cms/insert_page_object_config/' + page_id + '?version= ' + version +
862
- '&name=' + name + '&type=' + type + '&parent_key=' + parent_key,
863
- { method:'get', asynchronous: true, evalScripts: true });
864
- }
865
- });
866
- }
867
-
868
- function blockUserInput() {
869
- var dims = { width: document.body.scrollWidth, height: document.body.scrollHeight };
870
- $('preview_cover').show();
871
- $('preview_cover').style.position = 'absolute';
872
- $('preview_cover').style.left = '0px';
873
- $('preview_cover').style.top = '0px';
874
- $('preview_cover').style.width = dims.width + 'px';
875
- $('preview_cover').style.height = dims.height + 'px';
876
- }
877
-
878
- function insertAtCaret(obj, text) {
879
- if(document.selection) {
880
- obj.focus();
881
- var orig = obj.value.replace(/\r\n/g, "\n");
882
- var range = document.selection.createRange();
883
-
884
- if(range.parentElement() != obj) {
885
- return false;
886
- }
887
-
888
- range.text = text;
889
-
890
- var actual = tmp = obj.value.replace(/\r\n/g, "\n");
891
-
892
- for(var diff = 0; diff < orig.length; diff++) {
893
- if(orig.charAt(diff) != actual.charAt(diff)) break;
894
- }
895
-
896
- for(var index = 0, start = 0;
897
- tmp.match(text)
898
- && (tmp = tmp.replace(text, ""))
899
- && index <= diff;
900
- index = start + text.length
901
- ) {
902
- start = actual.indexOf(text, index);
903
- }
904
- } else if(obj.selectionStart) {
905
- var start = obj.selectionStart;
906
- var end = obj.selectionEnd;
907
-
908
- obj.value = obj.value.substr(0, start)
909
- + text
910
- + obj.value.substr(end, obj.value.length);
911
- }
912
-
913
- if(start != null) {
914
- setCaretTo(obj, start + text.length);
915
- } else {
916
- obj.value += text;
917
- }
918
- }
919
-
920
- function setCaretTo(obj, pos) {
921
- if(obj.createTextRange) {
922
- var range = obj.createTextRange();
923
- range.move('character', pos);
924
- range.select();
925
- } else if(obj.selectionStart) {
926
- obj.focus();
927
- obj.setSelectionRange(pos, pos);
928
- }
929
- }
930
-
931
-
932
-
933
- // utility function to fix # of decimal places
934
- function setPrecision(val, p, dontPad, addCommas) {
935
- if (typeof(p) == 'undefined') p = 2;
936
- if (typeof(dontPad) == 'undefined') dontPad = false;
937
- if (typeof(addCommas) == 'undefined') addCommas = true;
938
-
939
- if (val.toString() == 'NaN') return '';
940
- var m = Math.pow(10, p);
941
- var ret = parseInt(Math.round(val * m), 10) / m;
942
- var idx = (''+ret).indexOf('.');
943
- if (idx < 0) {
944
- ret += '.';
945
- idx = (''+ret).indexOf('.');
946
- }
947
-
948
- if (!dontPad && (''+ret).substring(idx).length <= p) {
949
- for (var i = (''+ret).substring(idx).length; i <= p; i++) {
950
- ret += '0';
951
- }
952
- }
953
-
954
- if (addCommas) {
955
- var pieces = (''+ret).split('.');
956
- if (p > 0) {
957
- ret = '.' + pieces[1];
958
- } else {
959
- ret = pieces[1];
960
- }
961
- for (var i = 0; i < pieces[0].length; i++) {
962
- if (i % 3 == 2) {
963
- ret = ',' + pieces[0].charAt(pieces[0].length - i - 1) + ret;
964
- } else {
965
- ret = pieces[0].charAt(pieces[0].length - i - 1) + ret;
966
- }
967
- }
968
- ret = ret.replace(/^,/, '');
969
- }
970
-
971
- return ret;
972
- }
973
-
974
-
975
- function setReportDates(interval) {
976
- startDateField = $('report_start_date');
977
- endDateField = $('report_end_date');
978
- today = startDate = endDate = new Date();
979
-
980
- switch (interval) {
981
- case 'yesterday':
982
- startDate = new Date('' + (today.getMonth()+1) + '/' + (today.getDate()-1) + '/' + today.getYear());
983
- endDate = startDate;
984
- break;
985
-
986
- case 'last_month':
987
- startDate = new Date('' + today.getMonth() + '/1/' + today.getYear());
988
- endDate = new Date('' + (today.getMonth()+1) + '/0/' + today.getYear());
989
- break;
990
-
991
- case 'last_quarter':
992
- startMonth = Math.floor(today.getMonth() / 3) * 3 - 3;
993
- startYear = today.getYear();
994
- if (startMonth < 0) {
995
- startMonth += 12;
996
- startYear--;
997
- }
998
- endMonth = startMonth + 3;
999
- endYear = startYear;
1000
- if (endMonth > 11) {
1001
- endMonth -= 12;
1002
- endYear++;
1003
- }
1004
- startDate = new Date('' + (startMonth+1) + '/1/' + startYear);
1005
- endDate = new Date('' + (endMonth+1) + '/0/' + endYear);
1006
- break;
1007
-
1008
- case 'last_year':
1009
- startDate = new Date('1/1/' + (today.getYear()-1));
1010
- endDate = new Date('12/31/' + (today.getYear()-1));
1011
- break;
1012
-
1013
- case 'today':
1014
- startDate = new Date('' + (today.getMonth()+1 )+ '/' + today.getDate() + '/' + today.getYear());
1015
- endDate = startDate;
1016
- break;
1017
-
1018
- case 'this_month':
1019
- startDate = new Date('' + (today.getMonth()+1) + '/1/' + today.getYear());
1020
- endDate = new Date('' + (today.getMonth()+2) + '/0/' + today.getYear());
1021
- break;
1022
-
1023
- case 'this_quarter':
1024
- startMonth = Math.floor(today.getMonth() / 3) * 3;
1025
- endMonth = startMonth + 3;
1026
- endYear = startYear;
1027
- if (endMonth > 11) {
1028
- endMonth -= 12;
1029
- endYear++;
1030
- }
1031
- startDate = new Date('' + (startMonth+1) + '/1/' + today.getYear());
1032
- endDate = new Date('' + (endMonth+1) + '/0/' + endYear);
1033
- break;
1034
-
1035
- case 'this_year':
1036
- startDate = new Date('1/1/' + today.getYear());
1037
- endDate = new Date('12/31/' + today.getYear());
1038
- break;
1039
-
1040
- case 'all_time':
1041
- startDate = new Date('1/1/' + (today.getYear()-5));
1042
- endDate = new Date('12/31/' + (today.getYear()+50));
1043
- break;
1044
-
1045
- default:
1046
- // same as "today"
1047
- startDate = new Date('' + (today.getMonth()+1 )+ '/' + today.getDate() + '/' + today.getYear());
1048
- endDate = startDate;
1049
- break;
1050
- }
1051
-
1052
- startDateField.value = startDate.format('mm/dd/yyyy');
1053
- endDateField.value = endDate.format('mm/dd/yyyy');
1054
- }
1055
-
1056
-
1057
-
1058
- /*
1059
- Date Format 1.1
1060
- (c) 2007 Steven Levithan <stevenlevithan.com>
1061
- MIT license
1062
- With code by Scott Trenda (Z and o flags, and enhanced brevity)
1063
- */
1064
-
1065
- /*** dateFormat
1066
- Accepts a date, a mask, or a date and a mask.
1067
- Returns a formatted version of the given date.
1068
- The date defaults to the current date/time.
1069
- The mask defaults ``"ddd mmm d yyyy HH:MM:ss"``.
1070
- */
1071
- var dateFormat = function () {
1072
- var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloZ]|"[^"]*"|'[^']*'/g,
1073
- timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
1074
- timezoneClip = /[^-+\dA-Z]/g,
1075
- pad = function (value, length) {
1076
- value = String(value);
1077
- length = parseInt(length) || 2;
1078
- while (value.length < length)
1079
- value = "0" + value;
1080
- return value;
1081
- };
1082
-
1083
- // Regexes and supporting functions are cached through closure
1084
- return function (date, mask) {
1085
- // Treat the first argument as a mask if it doesn't contain any numbers
1086
- if (
1087
- arguments.length == 1 &&
1088
- (typeof date == "string" || date instanceof String) &&
1089
- !/\d/.test(date)
1090
- ) {
1091
- mask = date;
1092
- date = undefined;
1093
- }
1094
-
1095
- date = date ? new Date(date) : new Date();
1096
- if (isNaN(date))
1097
- throw "invalid date";
1098
-
1099
- var dF = dateFormat;
1100
- mask = String(dF.masks[mask] || mask || dF.masks["default"]);
1101
-
1102
- var d = date.getDate(),
1103
- D = date.getDay(),
1104
- m = date.getMonth(),
1105
- y = date.getFullYear()+1900,
1106
- H = date.getHours(),
1107
- M = date.getMinutes(),
1108
- s = date.getSeconds(),
1109
- L = date.getMilliseconds(),
1110
- o = date.getTimezoneOffset(),
1111
- flags = {
1112
- d: d,
1113
- dd: pad(d),
1114
- ddd: dF.i18n.dayNames[D],
1115
- dddd: dF.i18n.dayNames[D + 7],
1116
- m: m + 1,
1117
- mm: pad(m + 1),
1118
- mmm: dF.i18n.monthNames[m],
1119
- mmmm: dF.i18n.monthNames[m + 12],
1120
- yy: String(y).slice(2),
1121
- yyyy: y,
1122
- h: H % 12 || 12,
1123
- hh: pad(H % 12 || 12),
1124
- H: H,
1125
- HH: pad(H),
1126
- M: M,
1127
- MM: pad(M),
1128
- s: s,
1129
- ss: pad(s),
1130
- l: pad(L, 3),
1131
- L: pad(L > 99 ? Math.round(L / 10) : L),
1132
- t: H < 12 ? "a" : "p",
1133
- tt: H < 12 ? "am" : "pm",
1134
- T: H < 12 ? "A" : "P",
1135
- TT: H < 12 ? "AM" : "PM",
1136
- Z: (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
1137
- o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4)
1138
- };
1139
-
1140
- return mask.replace(token, function ($0) {
1141
- return ($0 in flags) ? flags[$0] : $0.slice(1, $0.length - 1);
1142
- });
1143
- };
1144
- }();
1145
-
1146
- // Some common format strings
1147
- dateFormat.masks = {
1148
- "default": "ddd mmm d yyyy HH:MM:ss",
1149
- shortDate: "m/d/yy",
1150
- mediumDate: "mmm d, yyyy",
1151
- longDate: "mmmm d, yyyy",
1152
- fullDate: "dddd, mmmm d, yyyy",
1153
- shortTime: "h:MM TT",
1154
- mediumTime: "h:MM:ss TT",
1155
- longTime: "h:MM:ss TT Z",
1156
- isoDate: "yyyy-mm-dd",
1157
- isoTime: "HH:MM:ss",
1158
- isoDateTime: "yyyy-mm-dd'T'HH:MM:ss",
1159
- isoFullDateTime: "yyyy-mm-dd'T'HH:MM:ss.lo"
1160
- };
1161
-
1162
- // Internationalization strings
1163
- dateFormat.i18n = {
1164
- dayNames: [
1165
- "Sun", "Mon", "Tue", "Wed", "Thr", "Fri", "Sat",
1166
- "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
1167
- ],
1168
- monthNames: [
1169
- "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
1170
- "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
1171
- ]
1172
- };
1173
-
1174
- // For convenience...
1175
- Date.prototype.format = function (mask) {
1176
- return dateFormat(this, mask);
1177
- }
1178
-
1179
-
1180
- // Ultimate client-side JavaScript client sniff. Version 3.03
1181
- // (C) Netscape Communications 1999. Permission granted to reuse and distribute.
1182
- // Revised 17 May 99 to add is.nav5up and is.ie5up (see below).
1183
- // Revised 21 Nov 00 to add is.gecko and is.ie5_5 Also Changed is.nav5 and is.nav5up to is.nav6 and is.nav6up
1184
- // Revised 22 Feb 01 to correct Javascript Detection for IE 5.x, Opera 4,
1185
- // correct Opera 5 detection
1186
- // add support for winME and win2k
1187
- // synch with browser-type-oo.js
1188
- // Revised 26 Mar 01 to correct Opera detection
1189
- // Revised 02 Oct 01 to add IE6 detection
1190
-
1191
- // Everything you always wanted to know about your JavaScript client
1192
- // but were afraid to ask ... "Is" is the constructor function for "is" object,
1193
- // which has properties indicating:
1194
- // (1) browser vendor:
1195
- // is.nav, is.ie, is.opera, is.hotjava, is.webtv, is.TVNavigator, is.AOLTV
1196
- // (2) browser version number:
1197
- // is.major (integer indicating major version number: 2, 3, 4 ...)
1198
- // is.minor (float indicating full version number: 2.02, 3.01, 4.04 ...)
1199
- // (3) browser vendor AND major version number
1200
- // is.nav2, is.nav3, is.nav4, is.nav4up, is.nav6, is.nav6up, is.gecko, is.ie3,
1201
- // is.ie4, is.ie4up, is.ie5, is.ie5up, is.ie5_5, is.ie5_5up, is.ie6, is.ie6up, is.hotjava3, is.hotjava3up
1202
- // (4) JavaScript version number:
1203
- // is.js (float indicating full JavaScript version number: 1, 1.1, 1.2 ...)
1204
- // (5) OS platform and version:
1205
- // is.win, is.win16, is.win32, is.win31, is.win95, is.winnt, is.win98, is.winme, is.win2k
1206
- // is.os2
1207
- // is.mac, is.mac68k, is.macppc
1208
- // is.unix
1209
- // is.sun, is.sun4, is.sun5, is.suni86
1210
- // is.irix, is.irix5, is.irix6
1211
- // is.hpux, is.hpux9, is.hpux10
1212
- // is.aix, is.aix1, is.aix2, is.aix3, is.aix4
1213
- // is.linux, is.sco, is.unixware, is.mpras, is.reliant
1214
- // is.dec, is.sinix, is.freebsd, is.bsd
1215
- // is.vms
1216
- //
1217
- // See http://www.it97.de/JavaScript/JS_tutorial/bstat/navobj.html and
1218
- // http://www.it97.de/JavaScript/JS_tutorial/bstat/Browseraol.html
1219
- // for detailed lists of userAgent strings.
1220
- //
1221
- // Note: you don't want your Nav4 or IE4 code to "turn off" or
1222
- // stop working when Nav5 and IE5 (or later) are released, so
1223
- // in conditional code forks, use is.nav4up ("Nav4 or greater")
1224
- // and is.ie4up ("IE4 or greater") instead of is.nav4 or is.ie4
1225
- // to check version in code which you want to work on future
1226
- // versions.
1227
-
1228
-
1229
- function Is ()
1230
- { // convert all characters to lowercase to simplify testing
1231
- var agt=navigator.userAgent.toLowerCase();
1232
-
1233
- // *** BROWSER VERSION ***
1234
- // Note: On IE5, these return 4, so use is.ie5up to detect IE5.
1235
-
1236
- this.major = parseInt(navigator.appVersion);
1237
- this.minor = parseFloat(navigator.appVersion);
1238
-
1239
- // Note: Opera and WebTV spoof Navigator. We do strict client detection.
1240
- // If you want to allow spoofing, take out the tests for opera and webtv.
1241
- this.nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
1242
- && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
1243
- && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
1244
- this.nav2 = (this.nav && (this.major == 2));
1245
- this.nav3 = (this.nav && (this.major == 3));
1246
- this.nav4 = (this.nav && (this.major == 4));
1247
- this.nav4up = (this.nav && (this.major >= 4));
1248
- this.navonly = (this.nav && ((agt.indexOf(";nav") != -1) ||
1249
- (agt.indexOf("; nav") != -1)) );
1250
- this.nav6 = (this.nav && (this.major == 5));
1251
- this.nav6up = (this.nav && (this.major >= 5));
1252
- this.gecko = (agt.indexOf('gecko') != -1);
1253
-
1254
-
1255
- this.ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
1256
- this.ie3 = (this.ie && (this.major < 4));
1257
- this.ie4 = (this.ie && (this.major == 4) && (agt.indexOf("msie 4")!=-1) );
1258
- this.ie4up = (this.ie && (this.major >= 4));
1259
- this.ie5 = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")!=-1) );
1260
- this.ie5_5 = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.5") !=-1));
1261
- this.ie5up = (this.ie && !this.ie3 && !this.ie4);
1262
- this.ie5_5up =(this.ie && !this.ie3 && !this.ie4 && !this.ie5);
1263
- this.ie6 = (this.ie && (this.major == 4) && (agt.indexOf("msie 6.")!=-1) );
1264
- this.ie6up = (this.ie && !this.ie3 && !this.ie4 && !this.ie5 && !this.ie5_5);
1265
- this.ie7 = (this.ie && (this.major == 4) && (agt.indexOf("msie 7.")!=-1) );
1266
- this.ie7up = (this.ie && !this.ie3 && !this.ie4 && !this.ie5 && !this.ie5_5 && !this.ie6);
1267
-
1268
- // KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
1269
- // or if this is the first browser window opened. Thus the
1270
- // variables is.aol, is.aol3, and is.aol4 aren't 100% reliable.
1271
- this.aol = (agt.indexOf("aol") != -1);
1272
- this.aol3 = (this.aol && this.ie3);
1273
- this.aol4 = (this.aol && this.ie4);
1274
- this.aol5 = (agt.indexOf("aol 5") != -1);
1275
- this.aol6 = (agt.indexOf("aol 6") != -1);
1276
-
1277
- this.opera = (agt.indexOf("opera") != -1);
1278
- this.opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
1279
- this.opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
1280
- this.opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
1281
- this.opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
1282
- this.opera5up = (this.opera && !this.opera2 && !this.opera3 && !this.opera4);
1283
-
1284
- this.webtv = (agt.indexOf("webtv") != -1);
1285
-
1286
- this.TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1));
1287
- this.AOLTV = this.TVNavigator;
1288
-
1289
- this.hotjava = (agt.indexOf("hotjava") != -1);
1290
- this.hotjava3 = (this.hotjava && (this.major == 3));
1291
- this.hotjava3up = (this.hotjava && (this.major >= 3));
1292
-
1293
- // *** JAVASCRIPT VERSION CHECK ***
1294
- if (this.nav2 || this.ie3) this.js = 1.0;
1295
- else if (this.nav3) this.js = 1.1;
1296
- else if (this.opera5up) this.js = 1.3;
1297
- else if (this.opera) this.js = 1.1;
1298
- else if ((this.nav4 && (this.minor <= 4.05)) || this.ie4) this.js = 1.2;
1299
- else if ((this.nav4 && (this.minor > 4.05)) || this.ie5) this.js = 1.3;
1300
- else if (this.hotjava3up) this.js = 1.4;
1301
- else if (this.nav6 || this.gecko) this.js = 1.5;
1302
- // NOTE: In the future, update this code when newer versions of JS
1303
- // are released. For now, we try to provide some upward compatibility
1304
- // so that future versions of Nav and IE will show they are at
1305
- // *least* JS 1.x capable. Always check for JS version compatibility
1306
- // with > or >=.
1307
- else if (this.nav6up) this.js = 1.5;
1308
- // note ie5up on mac is 1.4
1309
- else if (this.ie5up) this.js = 1.3
1310
-
1311
- // HACK: no idea for other browsers; always check for JS version with > or >=
1312
- else this.js = 0.0;
1313
-
1314
- // *** PLATFORM ***
1315
- this.win = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
1316
- // NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all
1317
- // Win32, so you can't distinguish between Win95 and WinNT.
1318
- this.win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));
1319
-
1320
- // is this a 16 bit compiled version?
1321
- this.win16 = ((agt.indexOf("win16")!=-1) ||
1322
- (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) ||
1323
- (agt.indexOf("windows 16-bit")!=-1) );
1324
-
1325
- this.win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
1326
- (agt.indexOf("windows 16-bit")!=-1));
1327
-
1328
- // NOTE: Reliable detection of Win98 may not be possible. It appears that:
1329
- // - On Nav 4.x and before you'll get plain "Windows" in userAgent.
1330
- // - On Mercury client, the 32-bit version will return "Win98", but
1331
- // the 16-bit version running on Win98 will still return "Win95".
1332
- this.win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
1333
- this.winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
1334
- this.win32 = (this.win95 || this.winnt || this.win98 ||
1335
- ((this.major >= 4) && (navigator.platform == "Win32")) ||
1336
- (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));
1337
-
1338
- this.winme = ((agt.indexOf("win 9x 4.90")!=-1));
1339
- this.win2k = ((agt.indexOf("windows nt 5.0")!=-1));
1340
-
1341
- this.os2 = ((agt.indexOf("os/2")!=-1) ||
1342
- (navigator.appVersion.indexOf("OS/2")!=-1) ||
1343
- (agt.indexOf("ibm-webexplorer")!=-1));
1344
-
1345
- this.mac = (agt.indexOf("mac")!=-1);
1346
- // hack ie5 js version for mac
1347
- if (this.mac && this.ie5up) this.js = 1.4;
1348
- this.mac68k = (this.mac && ((agt.indexOf("68k")!=-1) ||
1349
- (agt.indexOf("68000")!=-1)));
1350
- this.macppc = (this.mac && ((agt.indexOf("ppc")!=-1) ||
1351
- (agt.indexOf("powerpc")!=-1)));
1352
-
1353
- this.sun = (agt.indexOf("sunos")!=-1);
1354
- this.sun4 = (agt.indexOf("sunos 4")!=-1);
1355
- this.sun5 = (agt.indexOf("sunos 5")!=-1);
1356
- this.suni86= (this.sun && (agt.indexOf("i86")!=-1));
1357
- this.irix = (agt.indexOf("irix") !=-1); // SGI
1358
- this.irix5 = (agt.indexOf("irix 5") !=-1);
1359
- this.irix6 = ((agt.indexOf("irix 6") !=-1) || (agt.indexOf("irix6") !=-1));
1360
- this.hpux = (agt.indexOf("hp-ux")!=-1);
1361
- this.hpux9 = (this.hpux && (agt.indexOf("09.")!=-1));
1362
- this.hpux10= (this.hpux && (agt.indexOf("10.")!=-1));
1363
- this.aix = (agt.indexOf("aix") !=-1); // IBM
1364
- this.aix1 = (agt.indexOf("aix 1") !=-1);
1365
- this.aix2 = (agt.indexOf("aix 2") !=-1);
1366
- this.aix3 = (agt.indexOf("aix 3") !=-1);
1367
- this.aix4 = (agt.indexOf("aix 4") !=-1);
1368
- this.linux = (agt.indexOf("inux")!=-1);
1369
- this.sco = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1);
1370
- this.unixware = (agt.indexOf("unix_system_v")!=-1);
1371
- this.mpras = (agt.indexOf("ncr")!=-1);
1372
- this.reliant = (agt.indexOf("reliantunix")!=-1);
1373
- this.dec = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) ||
1374
- (agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) ||
1375
- (agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1));
1376
- this.sinix = (agt.indexOf("sinix")!=-1);
1377
- this.freebsd = (agt.indexOf("freebsd")!=-1);
1378
- this.bsd = (agt.indexOf("bsd")!=-1);
1379
- this.unix = ((agt.indexOf("x11")!=-1) || this.sun || this.irix || this.hpux ||
1380
- this.sco ||this.unixware || this.mpras || this.reliant ||
1381
- this.dec || this.sinix || this.aix || this.linux || this.bsd || this.freebsd);
1382
-
1383
- this.vms = ((agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1));
1384
- }
1385
-
1386
- var is;
1387
- var isIE3Mac = false;
1388
- // this section is designed specifically for IE3 for the Mac
1389
-
1390
- if ((navigator.appVersion.indexOf("Mac")!=-1) && (navigator.userAgent.indexOf("MSIE")!=-1) &&
1391
- (parseInt(navigator.appVersion)==3))
1392
- isIE3Mac = true;
1393
- else is = new Is();