publify_core 10.0.1 → 10.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +32 -1
  3. data/app/assets/javascripts/markup_help_popup.js +25 -0
  4. data/app/assets/javascripts/optional_field_toggle.js +7 -0
  5. data/app/assets/javascripts/preview_comment.js +10 -0
  6. data/app/assets/javascripts/publify.js +3 -0
  7. data/app/assets/javascripts/publify_admin.js +1 -25
  8. data/app/assets/javascripts/spinnable.js +7 -2
  9. data/app/assets/stylesheets/administration_structure.css.scss +1 -1
  10. data/app/assets/stylesheets/publify.css.scss +43 -0
  11. data/app/assets/stylesheets/publify_admin.css.scss +0 -1
  12. data/app/controllers/admin/articles_controller.rb +3 -3
  13. data/app/controllers/admin/dashboard_controller.rb +0 -4
  14. data/app/controllers/admin/themes_controller.rb +1 -9
  15. data/app/controllers/articles_controller.rb +3 -1
  16. data/app/controllers/comments_controller.rb +1 -1
  17. data/app/helpers/admin/feedback_helper.rb +1 -1
  18. data/app/helpers/base_helper.rb +20 -12
  19. data/app/models/archives_sidebar.rb +1 -1
  20. data/app/models/content.rb +8 -3
  21. data/app/models/redirect.rb +2 -2
  22. data/app/models/tag_sidebar.rb +25 -3
  23. data/app/models/text_filter.rb +1 -1
  24. data/app/uploaders/resource_uploader.rb +1 -1
  25. data/app/views/admin/articles/_form.html.erb +2 -2
  26. data/app/views/admin/articles/index.html.erb +4 -5
  27. data/app/views/admin/dashboard/_comment.html.erb +1 -1
  28. data/app/views/admin/dashboard/_drafts.html.erb +1 -1
  29. data/app/views/admin/feedback/_ham.html.erb +1 -1
  30. data/app/views/admin/feedback/article.html.erb +1 -1
  31. data/app/views/admin/feedback/edit.html.erb +1 -1
  32. data/app/views/admin/feedback/index.html.erb +2 -2
  33. data/app/views/admin/migrations/show.html.erb +1 -1
  34. data/app/views/admin/notes/_form.html.erb +2 -3
  35. data/app/views/admin/notes/_note.html.erb +2 -2
  36. data/app/views/admin/notes/edit.html.erb +0 -1
  37. data/app/views/admin/pages/_pages.html.erb +1 -1
  38. data/app/views/admin/post_types/_index_and_form.html.erb +2 -2
  39. data/app/views/admin/redirects/_index_and_form.html.erb +2 -2
  40. data/app/views/admin/seo/show.html.erb +1 -1
  41. data/app/views/admin/settings/display.html.erb +1 -1
  42. data/app/views/admin/settings/feedback.html.erb +1 -1
  43. data/app/views/admin/settings/index.html.erb +1 -1
  44. data/app/views/admin/settings/write.html.erb +1 -1
  45. data/app/views/admin/tags/_index_and_form.html.erb +1 -1
  46. data/app/views/admin/users/_form.html.erb +1 -1
  47. data/app/views/articles/_comment_form.html.erb +9 -7
  48. data/app/views/articles/_comment_preview.html.erb +1 -1
  49. data/app/views/articles/_trackback.html.erb +3 -3
  50. data/app/views/articles/comment_failed.js.erb +1 -1
  51. data/app/views/articles/read.html.erb +4 -2
  52. data/app/views/comments/_comment.html.erb +1 -1
  53. data/app/views/comments/preview.js.erb +1 -1
  54. data/app/views/devise/passwords/edit.html.erb +3 -3
  55. data/app/views/devise/passwords/new.html.erb +1 -1
  56. data/app/views/devise/registrations/new.html.erb +2 -2
  57. data/app/views/devise/sessions/new.html.erb +2 -2
  58. data/app/views/devise/shared/_links.html.erb +3 -3
  59. data/app/views/layouts/accounts.html.erb +3 -3
  60. data/app/views/layouts/administration.html.erb +4 -6
  61. data/app/views/layouts/default.html.erb +1 -1
  62. data/app/views/layouts/editor.html.erb +3 -3
  63. data/app/views/notes/index.html.erb +1 -1
  64. data/app/views/notification_mailer/comment.html.erb +1 -1
  65. data/app/views/search_sidebar/_content.html.erb +2 -3
  66. data/app/views/settings/install.html.erb +2 -2
  67. data/app/views/shared/_page_header.html.erb +5 -5
  68. data/app/views/tag_sidebar/_content.html.erb +2 -2
  69. data/config/locales/ar.yml +0 -1
  70. data/config/locales/da.yml +0 -1
  71. data/config/locales/de.yml +0 -1
  72. data/config/locales/en.yml +0 -1
  73. data/config/locales/es-MX.yml +0 -1
  74. data/config/locales/fr.yml +0 -1
  75. data/config/locales/he.yml +0 -1
  76. data/config/locales/it.yml +0 -1
  77. data/config/locales/ja.yml +0 -1
  78. data/config/locales/lt.yml +0 -1
  79. data/config/locales/nb.yml +0 -1
  80. data/config/locales/nl.yml +0 -1
  81. data/config/locales/pl.yml +0 -1
  82. data/config/locales/pt-BR.yml +0 -1
  83. data/config/locales/ro.yml +0 -1
  84. data/config/locales/ru.yml +0 -1
  85. data/config/locales/zh-CN.yml +0 -1
  86. data/config/locales/zh-TW.yml +0 -1
  87. data/lib/publify_core/testing_support/feed_assertions.rb +1 -4
  88. data/lib/publify_core/version.rb +1 -1
  89. data/lib/theme.rb +18 -7
  90. metadata +30 -15
  91. data/app/assets/javascripts/datetimepicker.js +0 -1470
  92. data/app/assets/stylesheets/datetimepicker.css +0 -306
@@ -1,1470 +0,0 @@
1
- /**
2
- * @preserve jQuery DateTimePicker plugin v2.3.4
3
- * @homepage http://xdsoft.net/jqplugins/datetimepicker/
4
- * (c) 2014, Chupurnov Valeriy.
5
- */
6
- (function( $ ) {
7
- 'use strict';
8
- var default_options = {
9
- i18n:{
10
- bg:{ // Bulgarian
11
- months:[
12
- "Януари", "Февруари", "Март", "Април", "Май", "Юни", "Юли", "Август", "Септември", "Октомври", "Ноември", "Декември"
13
- ],
14
- dayOfWeek:[
15
- "Нд", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"
16
- ]
17
- },
18
- fa:{ // Persian/Farsi
19
- months:[
20
- 'فروردین', 'اردیبهشت', 'خرداد', 'تیر', 'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند'
21
- ],
22
- dayOfWeek:[
23
- 'یکشنبه', 'دوشنبه', 'سه شنبه', 'چهارشنبه', 'پنجشنبه', 'جمعه', 'شنبه'
24
- ]
25
- },
26
- ru:{ // Russian
27
- months:[
28
- 'Январь','Февраль','Март','Апрель','Май','Июнь','Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь'
29
- ],
30
- dayOfWeek:[
31
- "Вск", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"
32
- ]
33
- },
34
- uk:{ // Ukrainian
35
- months:[
36
- 'Січень','Лютий','Березень','Квітень','Травень','Червень','Липень','Серпень','Вересень','Жовтень','Листопад','Грудень'
37
- ],
38
- dayOfWeek:[
39
- "Ндл", "Пнд", "Втр", "Срд", "Чтв", "Птн", "Сбт"
40
- ]
41
- },
42
- en:{ // English
43
- months: [
44
- "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
45
- ],
46
- dayOfWeek: [
47
- "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
48
- ]
49
- },
50
- el:{ // Ελληνικά
51
- months: [
52
- "Ιανουάριος", "Φεβρουάριος", "Μάρτιος", "Απρίλιος", "Μάιος", "Ιούνιος", "Ιούλιος", "Αύγουστος", "Σεπτέμβριος", "Οκτώβριος", "Νοέμβριος", "Δεκέμβριος"
53
- ],
54
- dayOfWeek: [
55
- "Κυρ", "Δευ", "Τρι", "Τετ", "Πεμ", "Παρ", "Σαβ"
56
- ]
57
- },
58
- de:{ // German
59
- months:[
60
- 'Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'
61
- ],
62
- dayOfWeek:[
63
- "So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"
64
- ]
65
- },
66
- nl:{ // Dutch
67
- months:[
68
- "januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"
69
- ],
70
- dayOfWeek:[
71
- "zo", "ma", "di", "wo", "do", "vr", "za"
72
- ]
73
- },
74
- tr:{ // Turkish
75
- months:[
76
- "Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"
77
- ],
78
- dayOfWeek:[
79
- "Paz", "Pts", "Sal", "Çar", "Per", "Cum", "Cts"
80
- ]
81
- },
82
- fr:{ //French
83
- months:[
84
- "Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"
85
- ],
86
- dayOfWeek:[
87
- "Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam"
88
- ]
89
- },
90
- es:{ // Spanish
91
- months: [
92
- "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"
93
- ],
94
- dayOfWeek: [
95
- "Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb"
96
- ]
97
- },
98
- th:{ // Thai
99
- months:[
100
- 'มกราคม','กุมภาพันธ์','มีนาคม','เมษายน','พฤษภาคม','มิถุนายน','กรกฎาคม','สิงหาคม','กันยายน','ตุลาคม','พฤศจิกายน','ธันวาคม'
101
- ],
102
- dayOfWeek:[
103
- 'อา.','จ.','อ.','พ.','พฤ.','ศ.','ส.'
104
- ]
105
- },
106
- pl:{ // Polish
107
- months: [
108
- "styczeń", "luty", "marzec", "kwiecień", "maj", "czerwiec", "lipiec", "sierpień", "wrzesień", "październik", "listopad", "grudzień"
109
- ],
110
- dayOfWeek: [
111
- "nd", "pn", "wt", "śr", "cz", "pt", "sb"
112
- ]
113
- },
114
- pt:{ // Portuguese
115
- months: [
116
- "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"
117
- ],
118
- dayOfWeek: [
119
- "Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab"
120
- ]
121
- },
122
- ch:{ // Simplified Chinese
123
- months: [
124
- "一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"
125
- ],
126
- dayOfWeek: [
127
- "日", "一","二","三","四","五","六"
128
- ]
129
- },
130
- se:{ // Swedish
131
- months: [
132
- "Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September","Oktober", "November", "December"
133
- ],
134
- dayOfWeek: [
135
- "Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör"
136
- ]
137
- },
138
- kr:{ // Korean
139
- months: [
140
- "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"
141
- ],
142
- dayOfWeek: [
143
- "일", "월", "화", "수", "목", "금", "토"
144
- ]
145
- },
146
- it:{ // Italian
147
- months: [
148
- "Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"
149
- ],
150
- dayOfWeek: [
151
- "Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab"
152
- ]
153
- },
154
- da:{ // Dansk
155
- months: [
156
- "January", "Februar", "Marts", "April", "Maj", "Juni", "July", "August", "September", "Oktober", "November", "December"
157
- ],
158
- dayOfWeek: [
159
- "Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør"
160
- ]
161
- },
162
- no:{ // Norwegian
163
- months: [
164
- "Januar", "Februar", "Mars", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Desember"
165
- ],
166
- dayOfWeek: [
167
- "Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør"
168
- ]
169
- },
170
- ja:{ // Japanese
171
- months: [
172
- "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"
173
- ],
174
- dayOfWeek: [
175
- "日", "月", "火", "水", "木", "金", "土"
176
- ]
177
- },
178
- vi:{ // Vietnamese
179
- months: [
180
- "Tháng 1", "Tháng 2", "Tháng 3", "Tháng 4", "Tháng 5", "Tháng 6", "Tháng 7", "Tháng 8", "Tháng 9", "Tháng 10", "Tháng 11", "Tháng 12"
181
- ],
182
- dayOfWeek: [
183
- "CN", "T2", "T3", "T4", "T5", "T6", "T7"
184
- ]
185
- },
186
- sl:{ // Slovenščina
187
- months: [
188
- "Januar", "Februar", "Marec", "April", "Maj", "Junij", "Julij", "Avgust", "September", "Oktober", "November", "December"
189
- ],
190
- dayOfWeek: [
191
- "Ned", "Pon", "Tor", "Sre", "Čet", "Pet", "Sob"
192
- ]
193
- },
194
- cs:{ // Čeština
195
- months: [
196
- "Leden", "Únor", "Březen", "Duben", "Květen", "Červen", "Červenec", "Srpen", "Září", "Říjen", "Listopad", "Prosinec"
197
- ],
198
- dayOfWeek: [
199
- "Ne", "Po", "Út", "St", "Čt", "Pá", "So"
200
- ]
201
- },
202
- hu:{ // Hungarian
203
- months: [
204
- "Január", "Február", "Március", "Április", "Május", "Június", "Július", "Augusztus", "Szeptember", "Október", "November", "December"
205
- ],
206
- dayOfWeek: [
207
- "Va", "Hé", "Ke", "Sze", "Cs", "Pé", "Szo"
208
- ]
209
- }
210
- },
211
- value:'',
212
- lang:'en',
213
-
214
- format: 'Y/m/d H:i',
215
- formatTime: 'H:i',
216
- formatDate: 'Y/m/d',
217
-
218
- startDate: false, // new Date(), '1986/12/08', '-1970/01/05','-1970/01/05',
219
-
220
- step:60,
221
- monthChangeSpinner:true,
222
- closeOnDateSelect:false,
223
- closeOnWithoutClick:true,
224
- closeOnInputClick: true,
225
-
226
- timepicker:true,
227
- datepicker:true,
228
- weeks:false,
229
-
230
- defaultTime:false, // use formatTime format (ex. '10:00' for formatTime: 'H:i')
231
- defaultDate:false, // use formatDate format (ex new Date() or '1986/12/08' or '-1970/01/05' or '-1970/01/05')
232
-
233
- minDate:false,
234
- maxDate:false,
235
- minTime:false,
236
- maxTime:false,
237
-
238
- allowTimes:[],
239
- opened:false,
240
- initTime:true,
241
- inline:false,
242
-
243
- onSelectDate:function() {},
244
- onSelectTime:function() {},
245
- onChangeMonth:function() {},
246
- onChangeDateTime:function() {},
247
- onShow:function() {},
248
- onClose:function() {},
249
- onGenerate:function() {},
250
-
251
- withoutCopyright:true,
252
-
253
- inverseButton:false,
254
- hours12:false,
255
- next: 'xdsoft_next',
256
- prev : 'xdsoft_prev',
257
- dayOfWeekStart:0,
258
-
259
- timeHeightInTimePicker:25,
260
- timepickerScrollbar:true,
261
-
262
- todayButton:true, // 2.1.0
263
- defaultSelect:true, // 2.1.0
264
-
265
- scrollMonth:true,
266
- scrollTime:true,
267
- scrollInput:true,
268
-
269
- lazyInit:false,
270
-
271
- mask:false,
272
- validateOnBlur:true,
273
- allowBlank:true,
274
-
275
- yearStart:1950,
276
- yearEnd:2050,
277
-
278
- style:'',
279
- id:'',
280
-
281
- fixed: false,
282
-
283
- roundTime:'round', // ceil, floor
284
- className:'',
285
-
286
- weekends : [],
287
- yearOffset:0,
288
- beforeShowDay: null
289
- };
290
-
291
- // fix for ie8
292
- if ( !Array.prototype.indexOf ) {
293
- Array.prototype.indexOf = function(obj, start) {
294
- for (var i = (start || 0), j = this.length; i < j; i++) {
295
- if (this[i] === obj) { return i; }
296
- }
297
- return -1;
298
- }
299
- }
300
-
301
- Date.prototype.countDaysInMonth = function(){
302
- return new Date(this.getFullYear(), this.getMonth()+1, 0).getDate();
303
- };
304
-
305
- $.fn.xdsoftScroller = function( _percent ) {
306
- return this.each(function() {
307
- var timeboxparent = $(this);
308
- if( !$(this).hasClass('xdsoft_scroller_box') ) {
309
- var pointerEventToXY = function( e ) {
310
- var out = {x:0, y:0};
311
- if( e.type == 'touchstart' || e.type == 'touchmove' || e.type == 'touchend' || e.type == 'touchcancel' ) {
312
- var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
313
- out.x = touch.pageX;
314
- out.y = touch.pageY;
315
- }else if (e.type == 'mousedown' || e.type == 'mouseup' || e.type == 'mousemove' || e.type == 'mouseover'|| e.type=='mouseout' || e.type=='mouseenter' || e.type=='mouseleave') {
316
- out.x = e.pageX;
317
- out.y = e.pageY;
318
- }
319
- return out;
320
- },
321
- move = 0,
322
- timebox = timeboxparent.children().eq(0),
323
- parentHeight = timeboxparent[0].clientHeight,
324
- height = timebox[0].offsetHeight,
325
- scrollbar = $('<div class="xdsoft_scrollbar"></div>'),
326
- scroller = $('<div class="xdsoft_scroller"></div>'),
327
- maximumOffset = 100,
328
- start = false;
329
-
330
- scrollbar.append(scroller);
331
-
332
- timeboxparent.addClass('xdsoft_scroller_box').append(scrollbar);
333
- scroller.on('mousedown.xdsoft_scroller',function ( event ) {
334
- if( !parentHeight )
335
- timeboxparent.trigger('resize_scroll.xdsoft_scroller',[_percent]);
336
- var pageY = event.pageY,
337
- top = parseInt(scroller.css('margin-top')),
338
- h1 = scrollbar[0].offsetHeight;
339
- $(document.body).addClass('xdsoft_noselect');
340
- $([document.body,window]).on('mouseup.xdsoft_scroller',function arguments_callee() {
341
- $([document.body,window]).off('mouseup.xdsoft_scroller',arguments_callee)
342
- .off('mousemove.xdsoft_scroller',move)
343
- .removeClass('xdsoft_noselect');
344
- });
345
- $(document.body).on('mousemove.xdsoft_scroller',move = function(event) {
346
- var offset = event.pageY-pageY+top;
347
- if( offset<0 )
348
- offset = 0;
349
- if( offset+scroller[0].offsetHeight>h1 )
350
- offset = h1-scroller[0].offsetHeight;
351
- timeboxparent.trigger('scroll_element.xdsoft_scroller',[maximumOffset?offset/maximumOffset:0]);
352
- });
353
- });
354
-
355
- timeboxparent
356
- .on('scroll_element.xdsoft_scroller',function( event,percent ) {
357
- if( !parentHeight )
358
- timeboxparent.trigger('resize_scroll.xdsoft_scroller',[percent,true]);
359
- percent = percent>1?1:(percent<0||isNaN(percent))?0:percent;
360
- scroller.css('margin-top',maximumOffset*percent);
361
- timebox.css('marginTop',-parseInt((height-parentHeight)*percent))
362
- })
363
- .on('resize_scroll.xdsoft_scroller',function( event,_percent,noTriggerScroll ) {
364
- parentHeight = timeboxparent[0].clientHeight;
365
- height = timebox[0].offsetHeight;
366
- var percent = parentHeight/height,
367
- sh = percent*scrollbar[0].offsetHeight;
368
- if( percent>1 )
369
- scroller.hide();
370
- else{
371
- scroller.show();
372
- scroller.css('height',parseInt(sh>10?sh:10));
373
- maximumOffset = scrollbar[0].offsetHeight-scroller[0].offsetHeight;
374
- if( noTriggerScroll!==true )
375
- timeboxparent.trigger('scroll_element.xdsoft_scroller',[_percent?_percent:Math.abs(parseInt(timebox.css('marginTop')))/(height-parentHeight)]);
376
- }
377
- });
378
- timeboxparent.mousewheel&&timeboxparent.mousewheel(function(event, delta, deltaX, deltaY) {
379
- var top = Math.abs(parseInt(timebox.css('marginTop')));
380
- timeboxparent.trigger('scroll_element.xdsoft_scroller',[(top-delta*20)/(height-parentHeight)]);
381
- event.stopPropagation();
382
- return false;
383
- });
384
- timeboxparent.on('touchstart',function( event ) {
385
- start = pointerEventToXY(event);
386
- });
387
- timeboxparent.on('touchmove',function( event ) {
388
- if( start ) {
389
- var coord = pointerEventToXY(event), top = Math.abs(parseInt(timebox.css('marginTop')));
390
- timeboxparent.trigger('scroll_element.xdsoft_scroller',[(top-(coord.y-start.y))/(height-parentHeight)]);
391
- event.stopPropagation();
392
- event.preventDefault();
393
- start = pointerEventToXY(event);
394
- }
395
- });
396
- timeboxparent.on('touchend touchcancel',function( event ) {
397
- start = false;
398
- });
399
- }
400
- timeboxparent.trigger('resize_scroll.xdsoft_scroller',[_percent]);
401
- });
402
- };
403
- $.fn.datetimepicker = function( opt ) {
404
- var KEY0 = 48,
405
- KEY9 = 57,
406
- _KEY0 = 96,
407
- _KEY9 = 105,
408
- CTRLKEY = 17,
409
- DEL = 46,
410
- ENTER = 13,
411
- ESC = 27,
412
- BACKSPACE = 8,
413
- ARROWLEFT = 37,
414
- ARROWUP = 38,
415
- ARROWRIGHT = 39,
416
- ARROWDOWN = 40,
417
- TAB = 9,
418
- F5 = 116,
419
- AKEY = 65,
420
- CKEY = 67,
421
- VKEY = 86,
422
- ZKEY = 90,
423
- YKEY = 89,
424
- ctrlDown = false,
425
- options = ($.isPlainObject(opt)||!opt)?$.extend(true,{},default_options,opt):$.extend({},default_options),
426
-
427
- lazyInitTimer = 0,
428
-
429
- lazyInit = function( input ){
430
- input
431
- .on('open.xdsoft focusin.xdsoft mousedown.xdsoft',function initOnActionCallback(event) {
432
- if( input.is(':disabled')||input.is(':hidden')||!input.is(':visible')||input.data( 'xdsoft_datetimepicker') )
433
- return;
434
-
435
- clearTimeout(lazyInitTimer);
436
-
437
- lazyInitTimer = setTimeout(function() {
438
-
439
- if( !input.data( 'xdsoft_datetimepicker') )
440
- createDateTimePicker(input);
441
-
442
- input
443
- .off('open.xdsoft focusin.xdsoft mousedown.xdsoft',initOnActionCallback)
444
- .trigger('open.xdsoft');
445
- },100);
446
-
447
- });
448
- },
449
-
450
- createDateTimePicker = function( input ) {
451
-
452
- var datetimepicker = $('<div '+(options.id?'id="'+options.id+'"':'')+' '+(options.style?'style="'+options.style+'"':'')+' class="xdsoft_datetimepicker xdsoft_noselect '+(options.weeks?' xdsoft_showweeks':'')+options.className+'"></div>'),
453
- xdsoft_copyright = $('<div class="xdsoft_copyright"><a target="_blank" href="http://xdsoft.net/jqplugins/datetimepicker/">xdsoft.net</a></div>'),
454
- datepicker = $('<div class="xdsoft_datepicker active"></div>'),
455
- mounth_picker = $('<div class="xdsoft_mounthpicker"><button type="button" class="xdsoft_prev"></button><button type="button" class="xdsoft_today_button"></button><div class="xdsoft_label xdsoft_month"><span></span></div><div class="xdsoft_label xdsoft_year"><span></span></div><button type="button" class="xdsoft_next"></button></div>'),
456
- calendar = $('<div class="xdsoft_calendar"></div>'),
457
- timepicker = $('<div class="xdsoft_timepicker active"><button type="button" class="xdsoft_prev"></button><div class="xdsoft_time_box"></div><button type="button" class="xdsoft_next"></button></div>'),
458
- timeboxparent = timepicker.find('.xdsoft_time_box').eq(0),
459
- timebox = $('<div class="xdsoft_time_variant"></div>'),
460
- scrollbar = $('<div class="xdsoft_scrollbar"></div>'),
461
- scroller = $('<div class="xdsoft_scroller"></div>'),
462
- monthselect =$('<div class="xdsoft_select xdsoft_monthselect"><div></div></div>'),
463
- yearselect =$('<div class="xdsoft_select xdsoft_yearselect"><div></div></div>');
464
-
465
- //constructor lego
466
- mounth_picker
467
- .find('.xdsoft_month span')
468
- .after(monthselect);
469
- mounth_picker
470
- .find('.xdsoft_year span')
471
- .after(yearselect);
472
-
473
- mounth_picker
474
- .find('.xdsoft_month,.xdsoft_year')
475
- .on('mousedown.xdsoft',function(event) {
476
- mounth_picker
477
- .find('.xdsoft_select')
478
- .hide();
479
-
480
- var select = $(this).find('.xdsoft_select').eq(0),
481
- val = 0,
482
- top = 0;
483
-
484
- if( _xdsoft_datetime.currentTime )
485
- val = _xdsoft_datetime.currentTime[$(this).hasClass('xdsoft_month')?'getMonth':'getFullYear']();
486
-
487
- select.show();
488
-
489
- for(var items = select.find('div.xdsoft_option'),i = 0;i<items.length;i++) {
490
- if( items.eq(i).data('value')==val ) {
491
- break;
492
- }else top+=items[0].offsetHeight;
493
- }
494
-
495
- select.xdsoftScroller(top/(select.children()[0].offsetHeight-(select[0].clientHeight)));
496
- event.stopPropagation();
497
-
498
- return false;
499
- });
500
-
501
- mounth_picker
502
- .find('.xdsoft_select')
503
- .xdsoftScroller()
504
- .on('mousedown.xdsoft',function( event ) {
505
- event.stopPropagation();
506
- event.preventDefault();
507
- })
508
- .on('mousedown.xdsoft','.xdsoft_option',function( event ) {
509
- if( _xdsoft_datetime&&_xdsoft_datetime.currentTime )
510
- _xdsoft_datetime.currentTime[$(this).parent().parent().hasClass('xdsoft_monthselect')?'setMonth':'setFullYear']($(this).data('value'));
511
-
512
- $(this).parent().parent().hide();
513
-
514
- datetimepicker.trigger('xchange.xdsoft');
515
- options.onChangeMonth&&options.onChangeMonth.call&&options.onChangeMonth.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input'));
516
- });
517
-
518
-
519
- // set options
520
- datetimepicker.setOptions = function( _options ) {
521
- options = $.extend(true,{},options,_options);
522
-
523
- if( _options.allowTimes && $.isArray(_options.allowTimes) && _options.allowTimes.length ){
524
- options['allowTimes'] = $.extend(true,[],_options.allowTimes);
525
- }
526
-
527
- if( _options.weekends && $.isArray(_options.weekends) && _options.weekends.length ){
528
- options['weekends'] = $.extend(true,[],_options.weekends);
529
- }
530
-
531
- if( (options.open||options.opened)&&(!options.inline) ) {
532
- input.trigger('open.xdsoft');
533
- }
534
-
535
- if( options.inline ) {
536
- triggerAfterOpen = true;
537
- datetimepicker.addClass('xdsoft_inline');
538
- input.after(datetimepicker).hide();
539
- }
540
-
541
- if( options.inverseButton ) {
542
- options.next = 'xdsoft_prev';
543
- options.prev = 'xdsoft_next';
544
- }
545
-
546
- if( options.datepicker )
547
- datepicker.addClass('active');
548
- else
549
- datepicker.removeClass('active');
550
-
551
- if( options.timepicker )
552
- timepicker.addClass('active');
553
- else
554
- timepicker.removeClass('active');
555
-
556
- if( options.value ){
557
- input&&input.val&&input.val(options.value);
558
- _xdsoft_datetime.setCurrentTime(options.value);
559
- }
560
-
561
- if( isNaN(options.dayOfWeekStart) )
562
- options.dayOfWeekStart = 0;
563
- else
564
- options.dayOfWeekStart = parseInt(options.dayOfWeekStart)%7;
565
-
566
- if( !options.timepickerScrollbar )
567
- scrollbar.hide();
568
-
569
- if( options.minDate && /^-(.*)$/.test(options.minDate) ){
570
- options.minDate = _xdsoft_datetime.strToDateTime(options.minDate).dateFormat( options.formatDate );
571
- }
572
-
573
- if( options.maxDate && /^\+(.*)$/.test(options.maxDate) ) {
574
- options.maxDate = _xdsoft_datetime.strToDateTime(options.maxDate).dateFormat( options.formatDate );
575
- }
576
-
577
- mounth_picker
578
- .find('.xdsoft_today_button')
579
- .css('visibility',!options.todayButton?'hidden':'visible');
580
-
581
- if( options.mask ) {
582
- var e,
583
- getCaretPos = function ( input ) {
584
- try{
585
- if ( document.selection && document.selection.createRange ) {
586
- var range = document.selection.createRange();
587
- return range.getBookmark().charCodeAt(2) - 2;
588
- }else
589
- if ( input.setSelectionRange )
590
- return input.selectionStart;
591
- }catch(e) {
592
- return 0;
593
- }
594
- },
595
- setCaretPos = function ( node,pos ) {
596
- node = (typeof node == "string" || node instanceof String) ? document.getElementById(node) : node;
597
- if(!node) {
598
- return false;
599
- }else if(node.createTextRange) {
600
- var textRange = node.createTextRange();
601
- textRange.collapse(true);
602
- textRange.moveEnd(pos);
603
- textRange.moveStart(pos);
604
- textRange.select();
605
- return true;
606
- }else if(node.setSelectionRange) {
607
- node.setSelectionRange(pos,pos);
608
- return true;
609
- }
610
- return false;
611
- },
612
- isValidValue = function ( mask,value ) {
613
- var reg = mask
614
- .replace(/([\[\]\/\{\}\(\)\-\.\+]{1})/g,'\\$1')
615
- .replace(/_/g,'{digit+}')
616
- .replace(/([0-9]{1})/g,'{digit$1}')
617
- .replace(/\{digit([0-9]{1})\}/g,'[0-$1_]{1}')
618
- .replace(/\{digit[\+]\}/g,'[0-9_]{1}');
619
- return RegExp(reg).test(value);
620
- };
621
- input.off('keydown.xdsoft');
622
- switch(true) {
623
- case ( options.mask===true ):
624
-
625
- options.mask = options.format
626
- .replace(/Y/g,'9999')
627
- .replace(/F/g,'9999')
628
- .replace(/m/g,'19')
629
- .replace(/d/g,'39')
630
- .replace(/H/g,'29')
631
- .replace(/i/g,'59')
632
- .replace(/s/g,'59');
633
-
634
- case ( $.type(options.mask) == 'string' ):
635
-
636
- if( !isValidValue( options.mask,input.val() ) )
637
- input.val(options.mask.replace(/[0-9]/g,'_'));
638
-
639
- input.on('keydown.xdsoft',function( event ) {
640
- var val = this.value,
641
- key = event.which;
642
-
643
- switch(true) {
644
- case (( key>=KEY0&&key<=KEY9 )||( key>=_KEY0&&key<=_KEY9 ))||(key==BACKSPACE||key==DEL):
645
- var pos = getCaretPos(this),
646
- digit = ( key!=BACKSPACE&&key!=DEL )?String.fromCharCode((_KEY0 <= key && key <= _KEY9)? key-KEY0 : key):'_';
647
-
648
- if( (key==BACKSPACE||key==DEL)&&pos ) {
649
- pos--;
650
- digit='_';
651
- }
652
-
653
- while( /[^0-9_]/.test(options.mask.substr(pos,1))&&pos<options.mask.length&&pos>0 )
654
- pos+=( key==BACKSPACE||key==DEL )?-1:1;
655
-
656
- val = val.substr(0,pos)+digit+val.substr(pos+1);
657
- if( $.trim(val)=='' ){
658
- val = options.mask.replace(/[0-9]/g,'_');
659
- }else{
660
- if( pos==options.mask.length )
661
- break;
662
- }
663
-
664
- pos+=(key==BACKSPACE||key==DEL)?0:1;
665
- while( /[^0-9_]/.test(options.mask.substr(pos,1))&&pos<options.mask.length&&pos>0 )
666
- pos+=(key==BACKSPACE||key==DEL)?-1:1;
667
-
668
- if( isValidValue( options.mask,val ) ) {
669
- this.value = val;
670
- setCaretPos(this,pos);
671
- }else if( $.trim(val)=='' )
672
- this.value = options.mask.replace(/[0-9]/g,'_');
673
- else{
674
- input.trigger('error_input.xdsoft');
675
- }
676
- break;
677
- case ( !!~([AKEY,CKEY,VKEY,ZKEY,YKEY].indexOf(key))&&ctrlDown ):
678
- case !!~([ESC,ARROWUP,ARROWDOWN,ARROWLEFT,ARROWRIGHT,F5,CTRLKEY,TAB,ENTER].indexOf(key)):
679
- return true;
680
- }
681
- event.preventDefault();
682
- return false;
683
- });
684
- break;
685
- }
686
- }
687
- if( options.validateOnBlur ) {
688
- input
689
- .off('blur.xdsoft')
690
- .on('blur.xdsoft', function() {
691
- if( options.allowBlank && !$.trim($(this).val()).length ) {
692
- $(this).val(null);
693
- datetimepicker.data('xdsoft_datetime').empty();
694
- }else if( !Date.parseDate( $(this).val(), options.format ) ) {
695
- $(this).val((_xdsoft_datetime.now()).dateFormat( options.format ));
696
- datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
697
- }
698
- else{
699
- datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
700
- }
701
- datetimepicker.trigger('changedatetime.xdsoft');
702
- });
703
- }
704
- options.dayOfWeekStartPrev = (options.dayOfWeekStart==0)?6:options.dayOfWeekStart-1;
705
-
706
- datetimepicker
707
- .trigger('xchange.xdsoft')
708
- .trigger('afterOpen.xdsoft')
709
- };
710
-
711
- datetimepicker
712
- .data('options',options)
713
- .on('mousedown.xdsoft',function( event ) {
714
- event.stopPropagation();
715
- event.preventDefault();
716
- yearselect.hide();
717
- monthselect.hide();
718
- return false;
719
- });
720
-
721
- var scroll_element = timepicker.find('.xdsoft_time_box');
722
- scroll_element.append(timebox);
723
- scroll_element.xdsoftScroller();
724
-
725
- datetimepicker.on('afterOpen.xdsoft',function() {
726
- scroll_element.xdsoftScroller();
727
- });
728
-
729
- datetimepicker
730
- .append(datepicker)
731
- .append(timepicker);
732
-
733
- if( options.withoutCopyright!==true )
734
- datetimepicker
735
- .append(xdsoft_copyright);
736
-
737
- datepicker
738
- .append(mounth_picker)
739
- .append(calendar);
740
-
741
- $('body').append(datetimepicker);
742
-
743
- var _xdsoft_datetime = new function() {
744
- var _this = this;
745
- _this.now = function( norecursion ) {
746
- var d = new Date();
747
-
748
- if( !norecursion && options.defaultDate ){
749
- var date = _this.strtodate(options.defaultDate);
750
- d.setFullYear( date.getFullYear() );
751
- d.setMonth( date.getMonth() );
752
- d.setDate( date.getDate() );
753
- }
754
-
755
- if( options.yearOffset ){
756
- d.setFullYear(d.getFullYear()+options.yearOffset);
757
- }
758
-
759
- if( !norecursion && options.defaultTime ){
760
- var time = _this.strtotime(options.defaultTime);
761
- d.setHours( time.getHours() );
762
- d.setMinutes( time.getMinutes() );
763
- }
764
-
765
- return d;
766
- };
767
-
768
-
769
- _this.isValidDate = function (d) {
770
- if ( Object.prototype.toString.call(d) !== "[object Date]" )
771
- return false;
772
- return !isNaN(d.getTime());
773
- };
774
-
775
- _this.setCurrentTime = function( dTime ) {
776
- _this.currentTime = (typeof dTime == 'string')? _this.strToDateTime(dTime) : _this.isValidDate(dTime) ? dTime: _this.now();
777
- datetimepicker.trigger('xchange.xdsoft');
778
- };
779
-
780
- _this.empty = function() {
781
- _this.currentTime = null;
782
- };
783
-
784
- _this.getCurrentTime = function( dTime) {
785
- return _this.currentTime;
786
- };
787
-
788
- _this.nextMonth = function() {
789
- var month = _this.currentTime.getMonth()+1;
790
- if( month==12 ) {
791
- _this.currentTime.setFullYear(_this.currentTime.getFullYear()+1);
792
- month = 0;
793
- }
794
- _this.currentTime.setDate(
795
- Math.min(
796
- Date.daysInMonth[month],
797
- _this.currentTime.getDate()
798
- )
799
- );
800
- _this.currentTime.setMonth(month);
801
- options.onChangeMonth&&options.onChangeMonth.call&&options.onChangeMonth.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input'));
802
- datetimepicker.trigger('xchange.xdsoft');
803
- return month;
804
- };
805
-
806
- _this.prevMonth = function() {
807
- var month = _this.currentTime.getMonth()-1;
808
- if( month==-1 ) {
809
- _this.currentTime.setFullYear(_this.currentTime.getFullYear()-1);
810
- month = 11;
811
- }
812
- _this.currentTime.setDate(
813
- Math.min(
814
- Date.daysInMonth[month],
815
- _this.currentTime.getDate()
816
- )
817
- );
818
- _this.currentTime.setMonth(month);
819
- options.onChangeMonth&&options.onChangeMonth.call&&options.onChangeMonth.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input'));
820
- datetimepicker.trigger('xchange.xdsoft');
821
- return month;
822
- };
823
-
824
- _this.strToDateTime = function( sDateTime ) {
825
- if( sDateTime && sDateTime instanceof Date && _this.isValidDate(sDateTime) )
826
- return sDateTime;
827
-
828
- var tmpDate = [],timeOffset,currentTime;
829
-
830
- if( ( tmpDate = /^(\+|\-)(.*)$/.exec(sDateTime) ) && ( tmpDate[2]=Date.parseDate(tmpDate[2], options.formatDate) ) ) {
831
- timeOffset = tmpDate[2].getTime()-(tmpDate[2].getTimezoneOffset())*60000;
832
- currentTime = new Date((_xdsoft_datetime.now()).getTime()+parseInt(tmpDate[1]+'1')*timeOffset);
833
- }else
834
- currentTime = sDateTime?Date.parseDate(sDateTime, options.format):_this.now();
835
-
836
- if( !_this.isValidDate(currentTime) )
837
- currentTime = _this.now();
838
-
839
- return currentTime;
840
- };
841
-
842
- _this.strtodate = function( sDate ) {
843
- if( sDate && sDate instanceof Date && _this.isValidDate(sDate) )
844
- return sDate;
845
-
846
- var currentTime = sDate?Date.parseDate(sDate, options.formatDate):_this.now(true);
847
- if( !_this.isValidDate(currentTime) )
848
- currentTime = _this.now(true);
849
-
850
- return currentTime;
851
- };
852
-
853
- _this.strtotime = function( sTime ) {
854
- if( sTime && sTime instanceof Date && _this.isValidDate(sTime) )
855
- return sTime;
856
-
857
- var currentTime = sTime?Date.parseDate(sTime, options.formatTime):_this.now();
858
- if( !_this.isValidDate(currentTime) )
859
- currentTime = _this.now(true);
860
-
861
- return currentTime;
862
- };
863
-
864
- _this.str = function() {
865
- return _this.currentTime.dateFormat(options.format);
866
- };
867
-
868
- _this.currentTime = this.now();
869
- };
870
- mounth_picker
871
- .find('.xdsoft_today_button')
872
- .on('mousedown.xdsoft',function() {
873
- datetimepicker.data('changed',true);
874
- _xdsoft_datetime.setCurrentTime(0);
875
- datetimepicker.trigger('afterOpen.xdsoft');
876
- }).on('dblclick.xdsoft',function(){
877
- input.val( _xdsoft_datetime.str() );
878
- datetimepicker.trigger('close.xdsoft');
879
- });
880
- mounth_picker
881
- .find('.xdsoft_prev,.xdsoft_next')
882
- .on('mousedown.xdsoft',function() {
883
- var $this = $(this),
884
- timer = 0,
885
- stop = false;
886
-
887
- (function arguments_callee1(v) {
888
- var month = _xdsoft_datetime.currentTime.getMonth();
889
- if( $this.hasClass( options.next ) ) {
890
- _xdsoft_datetime.nextMonth();
891
- }else if( $this.hasClass( options.prev ) ) {
892
- _xdsoft_datetime.prevMonth();
893
- }
894
- if (options.monthChangeSpinner) {
895
- !stop&&(timer = setTimeout(arguments_callee1,v?v:100));
896
- }
897
- })(500);
898
-
899
- $([document.body,window]).on('mouseup.xdsoft',function arguments_callee2() {
900
- clearTimeout(timer);
901
- stop = true;
902
- $([document.body,window]).off('mouseup.xdsoft',arguments_callee2);
903
- });
904
- });
905
-
906
- timepicker
907
- .find('.xdsoft_prev,.xdsoft_next')
908
- .on('mousedown.xdsoft',function() {
909
- var $this = $(this),
910
- timer = 0,
911
- stop = false,
912
- period = 110;
913
- (function arguments_callee4(v) {
914
- var pheight = timeboxparent[0].clientHeight,
915
- height = timebox[0].offsetHeight,
916
- top = Math.abs(parseInt(timebox.css('marginTop')));
917
- if( $this.hasClass(options.next) && (height-pheight)- options.timeHeightInTimePicker>=top ) {
918
- timebox.css('marginTop','-'+(top+options.timeHeightInTimePicker)+'px')
919
- }else if( $this.hasClass(options.prev) && top-options.timeHeightInTimePicker>=0 ) {
920
- timebox.css('marginTop','-'+(top-options.timeHeightInTimePicker)+'px')
921
- }
922
- timeboxparent.trigger('scroll_element.xdsoft_scroller',[Math.abs(parseInt(timebox.css('marginTop'))/(height-pheight))]);
923
- period= ( period>10 )?10:period-10;
924
- !stop&&(timer = setTimeout(arguments_callee4,v?v:period));
925
- })(500);
926
- $([document.body,window]).on('mouseup.xdsoft',function arguments_callee5() {
927
- clearTimeout(timer);
928
- stop = true;
929
- $([document.body,window])
930
- .off('mouseup.xdsoft',arguments_callee5);
931
- });
932
- });
933
-
934
- var xchangeTimer = 0;
935
- // base handler - generating a calendar and timepicker
936
- datetimepicker
937
- .on('xchange.xdsoft',function( event ) {
938
- clearTimeout(xchangeTimer);
939
- xchangeTimer = setTimeout(function(){
940
- var table = '',
941
- start = new Date(_xdsoft_datetime.currentTime.getFullYear(),_xdsoft_datetime.currentTime.getMonth(),1, 12, 0, 0),
942
- i = 0,
943
- today = _xdsoft_datetime.now();
944
-
945
- while( start.getDay()!=options.dayOfWeekStart )
946
- start.setDate(start.getDate()-1);
947
-
948
- //generate calendar
949
- table+='<table><thead><tr>';
950
-
951
- if(options.weeks) {
952
- table+='<th></th>';
953
- }
954
-
955
- // days
956
- for(var j = 0; j<7; j++) {
957
- table+='<th>'+options.i18n[options.lang].dayOfWeek[(j+options.dayOfWeekStart)%7]+'</th>';
958
- }
959
-
960
- table+='</tr></thead>';
961
- table+='<tbody>';
962
- var maxDate = false, minDate = false;
963
-
964
- if( options.maxDate!==false ) {
965
- maxDate = _xdsoft_datetime.strtodate(options.maxDate);
966
- maxDate = new Date(maxDate.getFullYear(),maxDate.getMonth(),maxDate.getDate(),23,59,59,999);
967
- }
968
-
969
- if( options.minDate!==false ) {
970
- minDate = _xdsoft_datetime.strtodate(options.minDate);
971
- minDate = new Date(minDate.getFullYear(),minDate.getMonth(),minDate.getDate());
972
- }
973
-
974
- var d,y,m,w,classes = [],customDateSettings,newRow=true;
975
-
976
- while( i<_xdsoft_datetime.currentTime.countDaysInMonth()||start.getDay()!=options.dayOfWeekStart||_xdsoft_datetime.currentTime.getMonth()==start.getMonth() ) {
977
- classes = [];
978
- i++;
979
-
980
- d = start.getDate(); y = start.getFullYear(); m = start.getMonth(); w = start.getWeekOfYear();
981
-
982
- classes.push('xdsoft_date');
983
-
984
- if ( options.beforeShowDay && options.beforeShowDay.call ) {
985
- customDateSettings = options.beforeShowDay.call(datetimepicker, start);
986
- } else {
987
- customDateSettings = null;
988
- }
989
-
990
- if( ( maxDate!==false && start > maxDate )||( minDate!==false && start < minDate )||(customDateSettings && customDateSettings[0] === false) ){
991
- classes.push('xdsoft_disabled');
992
- }
993
-
994
- if ( customDateSettings && customDateSettings[1] != "" ) {
995
- classes.push(customDateSettings[1]);
996
- }
997
-
998
- if( _xdsoft_datetime.currentTime.getMonth()!=m ) classes.push('xdsoft_other_month');
999
-
1000
- if( (options.defaultSelect||datetimepicker.data('changed')) && _xdsoft_datetime.currentTime.dateFormat( options.formatDate )==start.dateFormat( options.formatDate ) ) {
1001
- classes.push('xdsoft_current');
1002
- }
1003
-
1004
- if( today.dateFormat( options.formatDate )==start.dateFormat( options.formatDate ) ) {
1005
- classes.push('xdsoft_today');
1006
- }
1007
-
1008
- if( start.getDay()==0||start.getDay()==6||~options.weekends.indexOf(start.dateFormat( options.formatDate )) ) {
1009
- classes.push('xdsoft_weekend');
1010
- }
1011
-
1012
- if(options.beforeShowDay && typeof options.beforeShowDay == 'function') {
1013
- classes.push(options.beforeShowDay(start))
1014
- }
1015
-
1016
- if(newRow) {
1017
- table+='<tr>';
1018
- newRow = false;
1019
-
1020
- if(options.weeks) {
1021
- table+='<th>'+w+'</th>';
1022
- }
1023
- }
1024
-
1025
- table+='<td data-date="'+d+'" data-month="'+m+'" data-year="'+y+'"'+' class="xdsoft_date xdsoft_day_of_week'+start.getDay()+' '+ classes.join(' ')+'">'+
1026
- '<div>'+d+'</div>'+
1027
- '</td>';
1028
-
1029
- if( start.getDay()==options.dayOfWeekStartPrev ) {
1030
- table+='</tr>';
1031
- newRow = true;
1032
- }
1033
-
1034
- start.setDate(d+1);
1035
- }
1036
- table+='</tbody></table>';
1037
-
1038
- calendar.html(table);
1039
-
1040
- mounth_picker.find('.xdsoft_label span').eq(0).text(options.i18n[options.lang].months[_xdsoft_datetime.currentTime.getMonth()]);
1041
- mounth_picker.find('.xdsoft_label span').eq(1).text(_xdsoft_datetime.currentTime.getFullYear());
1042
-
1043
- // generate timebox
1044
- var time = '',
1045
- h = '',
1046
- m ='',
1047
- line_time = function line_time( h,m ) {
1048
- var now = _xdsoft_datetime.now();
1049
- now.setHours(h);
1050
- h = parseInt(now.getHours());
1051
- now.setMinutes(m);
1052
- m = parseInt(now.getMinutes());
1053
-
1054
- classes = [];
1055
- if( (options.maxTime!==false&&_xdsoft_datetime.strtotime(options.maxTime).getTime()<now.getTime())||(options.minTime!==false&&_xdsoft_datetime.strtotime(options.minTime).getTime()>now.getTime()))
1056
- classes.push('xdsoft_disabled');
1057
- if( (options.initTime||options.defaultSelect||datetimepicker.data('changed')) && parseInt(_xdsoft_datetime.currentTime.getHours())==parseInt(h)&&(options.step>59||Math[options.roundTime](_xdsoft_datetime.currentTime.getMinutes()/options.step)*options.step==parseInt(m))) {
1058
- if( options.defaultSelect||datetimepicker.data('changed')) {
1059
- classes.push('xdsoft_current');
1060
- } else if( options.initTime ) {
1061
- classes.push('xdsoft_init_time');
1062
- }
1063
- }
1064
- if( parseInt(today.getHours())==parseInt(h)&&parseInt(today.getMinutes())==parseInt(m))
1065
- classes.push('xdsoft_today');
1066
- time+= '<div class="xdsoft_time '+classes.join(' ')+'" data-hour="'+h+'" data-minute="'+m+'">'+now.dateFormat(options.formatTime)+'</div>';
1067
- };
1068
-
1069
- if( !options.allowTimes || !$.isArray(options.allowTimes) || !options.allowTimes.length ) {
1070
- for( var i=0,j=0;i<(options.hours12?12:24);i++ ) {
1071
- for( j=0;j<60;j+=options.step ) {
1072
- h = (i<10?'0':'')+i;
1073
- m = (j<10?'0':'')+j;
1074
- line_time( h,m );
1075
- }
1076
- }
1077
- }else{
1078
- for( var i=0;i<options.allowTimes.length;i++ ) {
1079
- h = _xdsoft_datetime.strtotime(options.allowTimes[i]).getHours();
1080
- m = _xdsoft_datetime.strtotime(options.allowTimes[i]).getMinutes();
1081
- line_time( h,m );
1082
- }
1083
- }
1084
-
1085
- timebox.html(time);
1086
-
1087
- var opt = '',
1088
- i = 0;
1089
-
1090
- for( i = parseInt(options.yearStart,10)+options.yearOffset;i<= parseInt(options.yearEnd,10)+options.yearOffset;i++ ) {
1091
- opt+='<div class="xdsoft_option '+(_xdsoft_datetime.currentTime.getFullYear()==i?'xdsoft_current':'')+'" data-value="'+i+'">'+i+'</div>';
1092
- }
1093
- yearselect.children().eq(0)
1094
- .html(opt);
1095
-
1096
- for( i = 0,opt = '';i<= 11;i++ ) {
1097
- opt+='<div class="xdsoft_option '+(_xdsoft_datetime.currentTime.getMonth()==i?'xdsoft_current':'')+'" data-value="'+i+'">'+options.i18n[options.lang].months[i]+'</div>';
1098
- }
1099
- monthselect.children().eq(0).html(opt);
1100
- $(datetimepicker)
1101
- .trigger('generate.xdsoft');
1102
- },10);
1103
- event.stopPropagation();
1104
- })
1105
- .on('afterOpen.xdsoft',function() {
1106
- if( options.timepicker ) {
1107
- var classType;
1108
- if( timebox.find('.xdsoft_current').length ) {
1109
- classType = '.xdsoft_current';
1110
- } else if( timebox.find('.xdsoft_init_time').length ) {
1111
- classType = '.xdsoft_init_time';
1112
- }
1113
-
1114
- if( classType ) {
1115
- var pheight = timeboxparent[0].clientHeight,
1116
- height = timebox[0].offsetHeight,
1117
- top = timebox.find(classType).index()*options.timeHeightInTimePicker+1;
1118
- if( (height-pheight)<top )
1119
- top = height-pheight;
1120
- timeboxparent.trigger('scroll_element.xdsoft_scroller',[parseInt(top)/(height-pheight)]);
1121
- }else{
1122
- timeboxparent.trigger('scroll_element.xdsoft_scroller',[0]);
1123
- }
1124
- }
1125
- });
1126
-
1127
- var timerclick = 0;
1128
-
1129
- calendar
1130
- .on('click.xdsoft', 'td', function (xdevent) {
1131
- xdevent.stopPropagation(); // Prevents closing of Pop-ups, Modals and Flyouts in Bootstrap
1132
- timerclick++;
1133
- var $this = $(this),
1134
- currentTime = _xdsoft_datetime.currentTime;
1135
-
1136
- if( currentTime===undefined||currentTime===null ){
1137
- _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
1138
- currentTime = _xdsoft_datetime.currentTime;
1139
- }
1140
-
1141
- if( $this.hasClass('xdsoft_disabled') )
1142
- return false;
1143
-
1144
- currentTime.setDate( 1 );
1145
- currentTime.setFullYear( $this.data('year') );
1146
- currentTime.setMonth( $this.data('month') );
1147
- currentTime.setDate( $this.data('date') );
1148
-
1149
- datetimepicker.trigger('select.xdsoft',[currentTime]);
1150
-
1151
- input.val( _xdsoft_datetime.str() );
1152
- if( (timerclick>1||(options.closeOnDateSelect===true||( options.closeOnDateSelect===0&&!options.timepicker )))&&!options.inline ) {
1153
- datetimepicker.trigger('close.xdsoft');
1154
- }
1155
-
1156
- if( options.onSelectDate && options.onSelectDate.call ) {
1157
- options.onSelectDate.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input'));
1158
- }
1159
-
1160
- datetimepicker.data('changed',true);
1161
- datetimepicker.trigger('xchange.xdsoft');
1162
- datetimepicker.trigger('changedatetime.xdsoft');
1163
- setTimeout(function(){
1164
- timerclick = 0;
1165
- },200);
1166
- });
1167
-
1168
- timebox
1169
- .on('click.xdsoft', 'div', function (xdevent) {
1170
- xdevent.stopPropagation(); // NAJ: Prevents closing of Pop-ups, Modals and Flyouts
1171
- var $this = $(this),
1172
- currentTime = _xdsoft_datetime.currentTime;
1173
-
1174
- if( currentTime===undefined||currentTime===null ){
1175
- _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
1176
- currentTime = _xdsoft_datetime.currentTime;
1177
- }
1178
-
1179
- if( $this.hasClass('xdsoft_disabled') )
1180
- return false;
1181
- currentTime.setHours($this.data('hour'));
1182
- currentTime.setMinutes($this.data('minute'));
1183
- datetimepicker.trigger('select.xdsoft',[currentTime]);
1184
-
1185
- datetimepicker.data('input').val( _xdsoft_datetime.str() );
1186
-
1187
- !options.inline&&datetimepicker.trigger('close.xdsoft');
1188
-
1189
- if( options.onSelectTime&&options.onSelectTime.call ) {
1190
- options.onSelectTime.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input'));
1191
- }
1192
- datetimepicker.data('changed',true);
1193
- datetimepicker.trigger('xchange.xdsoft');
1194
- datetimepicker.trigger('changedatetime.xdsoft');
1195
- });
1196
-
1197
- datetimepicker.mousewheel&&datepicker.mousewheel(function(event, delta, deltaX, deltaY) {
1198
- if( !options.scrollMonth )
1199
- return true;
1200
- if( delta<0 )
1201
- _xdsoft_datetime.nextMonth();
1202
- else
1203
- _xdsoft_datetime.prevMonth();
1204
- return false;
1205
- });
1206
-
1207
- datetimepicker.mousewheel&&timeboxparent.unmousewheel().mousewheel(function(event, delta, deltaX, deltaY) {
1208
- if( !options.scrollTime )
1209
- return true;
1210
- var pheight = timeboxparent[0].clientHeight,
1211
- height = timebox[0].offsetHeight,
1212
- top = Math.abs(parseInt(timebox.css('marginTop'))),
1213
- fl = true;
1214
- if( delta<0 && (height-pheight)-options.timeHeightInTimePicker>=top ) {
1215
- timebox.css('marginTop','-'+(top+options.timeHeightInTimePicker)+'px');
1216
- fl = false;
1217
- }else if( delta>0&&top-options.timeHeightInTimePicker>=0 ) {
1218
- timebox.css('marginTop','-'+(top-options.timeHeightInTimePicker)+'px');
1219
- fl = false;
1220
- }
1221
- timeboxparent.trigger('scroll_element.xdsoft_scroller',[Math.abs(parseInt(timebox.css('marginTop'))/(height-pheight))]);
1222
- event.stopPropagation();
1223
- return fl;
1224
- });
1225
-
1226
- var triggerAfterOpen = false;
1227
- datetimepicker
1228
- .on('changedatetime.xdsoft',function() {
1229
- if( options.onChangeDateTime&&options.onChangeDateTime.call ) {
1230
- var $input = datetimepicker.data('input');
1231
- options.onChangeDateTime.call(datetimepicker, _xdsoft_datetime.currentTime, $input);
1232
- delete options.value;
1233
- $input.trigger('change');
1234
- }
1235
- })
1236
- .on('generate.xdsoft',function() {
1237
- if( options.onGenerate&&options.onGenerate.call )
1238
- options.onGenerate.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input'));
1239
- if( triggerAfterOpen ){
1240
- datetimepicker.trigger('afterOpen.xdsoft');
1241
- triggerAfterOpen = false;
1242
- }
1243
- })
1244
- .on( 'click.xdsoft', function( xdevent )
1245
- {
1246
- xdevent.stopPropagation(); // Prevents closing of Pop-ups, Modals and Flyouts in Bootstrap
1247
- });
1248
-
1249
- var current_time_index = 0;
1250
- input.mousewheel&&input.mousewheel(function( event, delta, deltaX, deltaY ) {
1251
- if( !options.scrollInput )
1252
- return true;
1253
- if( !options.datepicker && options.timepicker ) {
1254
- current_time_index = timebox.find('.xdsoft_current').length?timebox.find('.xdsoft_current').eq(0).index():0;
1255
- if( current_time_index+delta>=0&&current_time_index+delta<timebox.children().length )
1256
- current_time_index+=delta;
1257
- timebox.children().eq(current_time_index).length&&timebox.children().eq(current_time_index).trigger('mousedown');
1258
- return false;
1259
- }else if( options.datepicker && !options.timepicker ) {
1260
- datepicker.trigger( event, [delta, deltaX, deltaY]);
1261
- input.val&&input.val( _xdsoft_datetime.str() );
1262
- datetimepicker.trigger('changedatetime.xdsoft');
1263
- return false;
1264
- }
1265
- });
1266
- var setPos = function() {
1267
- var offset = datetimepicker.data('input').offset(), top = offset.top+datetimepicker.data('input')[0].offsetHeight-1, left = offset.left, position = "absolute";
1268
- if (options.fixed) {
1269
- top -= $(window).scrollTop();
1270
- left -= $(window).scrollLeft();
1271
- position = "fixed";
1272
- }else {
1273
- if( top+datetimepicker[0].offsetHeight>$(window).height()+$(window).scrollTop() )
1274
- top = offset.top-datetimepicker[0].offsetHeight+1;
1275
- if (top < 0)
1276
- top = 0;
1277
- if( left+datetimepicker[0].offsetWidth>$(window).width() )
1278
- left = offset.left-datetimepicker[0].offsetWidth+datetimepicker.data('input')[0].offsetWidth;
1279
- }
1280
- datetimepicker.css({
1281
- left:left,
1282
- top:top,
1283
- position: position
1284
- });
1285
- };
1286
- datetimepicker
1287
- .on('open.xdsoft', function() {
1288
- var onShow = true;
1289
- if( options.onShow&&options.onShow.call) {
1290
- onShow = options.onShow.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input'));
1291
- }
1292
- if( onShow!==false ) {
1293
- datetimepicker.show();
1294
- setPos();
1295
- $(window)
1296
- .off('resize.xdsoft',setPos)
1297
- .on('resize.xdsoft',setPos);
1298
-
1299
- if( options.closeOnWithoutClick ) {
1300
- $([document.body,window]).on('mousedown.xdsoft',function arguments_callee6() {
1301
- datetimepicker.trigger('close.xdsoft');
1302
- $([document.body,window]).off('mousedown.xdsoft',arguments_callee6);
1303
- });
1304
- }
1305
- }
1306
- })
1307
- .on('close.xdsoft', function( event ) {
1308
- var onClose = true;
1309
- if( options.onClose&&options.onClose.call ) {
1310
- onClose=options.onClose.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input'));
1311
- }
1312
- if( onClose!==false&&!options.opened&&!options.inline ) {
1313
- datetimepicker.hide();
1314
- }
1315
- event.stopPropagation();
1316
- })
1317
- .data('input',input);
1318
-
1319
- var timer = 0,
1320
- timer1 = 0;
1321
-
1322
- datetimepicker.data('xdsoft_datetime',_xdsoft_datetime);
1323
- datetimepicker.setOptions(options);
1324
-
1325
- function getCurrentValue(){
1326
-
1327
- var ct = false;
1328
-
1329
- if ( options.startDate ) {
1330
- ct = _xdsoft_datetime.strToDateTime(options.startDate);
1331
- } else {
1332
- ct = options.value?options.value:(input&&input.val&&input.val())?input.val():'';
1333
- ct = Date.parseDate(ct, options.format);
1334
- }
1335
-
1336
- if ( ct && _xdsoft_datetime.isValidDate(ct) ) {
1337
- datetimepicker.data('changed',true);
1338
- } else {
1339
- ct = '';
1340
- }
1341
-
1342
- return ct?ct:0;
1343
- }
1344
- //debugger
1345
- _xdsoft_datetime.setCurrentTime( getCurrentValue() );
1346
-
1347
- input
1348
- .data( 'xdsoft_datetimepicker',datetimepicker )
1349
- .on('open.xdsoft focusin.xdsoft mousedown.xdsoft',function(event) {
1350
- if( input.is(':disabled')||input.is(':hidden')||!input.is(':visible')||(input.data('xdsoft_datetimepicker').is(':visible') && options.closeOnInputClick) )
1351
- return;
1352
- clearTimeout(timer);
1353
- timer = setTimeout(function() {
1354
- if( input.is(':disabled')||input.is(':hidden')||!input.is(':visible') )
1355
- return;
1356
-
1357
- triggerAfterOpen = true;
1358
- _xdsoft_datetime.setCurrentTime(getCurrentValue());
1359
-
1360
- datetimepicker.trigger('open.xdsoft');
1361
- },100);
1362
- })
1363
- .on('keydown.xdsoft',function( event ) {
1364
- var val = this.value,
1365
- key = event.which;
1366
- switch(true) {
1367
- case !!~([ENTER].indexOf(key)):
1368
- var elementSelector = $("input:visible,textarea:visible");
1369
- datetimepicker.trigger('close.xdsoft');
1370
- elementSelector.eq(elementSelector.index(this) + 1).focus();
1371
- return false;
1372
- case !!~[TAB].indexOf(key):
1373
- datetimepicker.trigger('close.xdsoft');
1374
- return true;
1375
- }
1376
- });
1377
- },
1378
- destroyDateTimePicker = function( input ) {
1379
- var datetimepicker = input.data('xdsoft_datetimepicker');
1380
- if( datetimepicker ) {
1381
- datetimepicker.data('xdsoft_datetime',null);
1382
- datetimepicker.remove();
1383
- input
1384
- .data( 'xdsoft_datetimepicker',null )
1385
- .off( 'open.xdsoft focusin.xdsoft focusout.xdsoft mousedown.xdsoft blur.xdsoft keydown.xdsoft' );
1386
- $(window).off('resize.xdsoft');
1387
- $([window,document.body]).off('mousedown.xdsoft');
1388
- input.unmousewheel&&input.unmousewheel();
1389
- }
1390
- };
1391
- $(document)
1392
- .off('keydown.xdsoftctrl keyup.xdsoftctrl')
1393
- .on('keydown.xdsoftctrl',function(e) {
1394
- if ( e.keyCode == CTRLKEY )
1395
- ctrlDown = true;
1396
- })
1397
- .on('keyup.xdsoftctrl',function(e) {
1398
- if ( e.keyCode == CTRLKEY )
1399
- ctrlDown = false;
1400
- });
1401
- return this.each(function() {
1402
- var datetimepicker;
1403
- if( datetimepicker = $(this).data('xdsoft_datetimepicker') ) {
1404
- if( $.type(opt) === 'string' ) {
1405
- switch(opt) {
1406
- case 'show':
1407
- $(this).select().focus();
1408
- datetimepicker.trigger( 'open.xdsoft' );
1409
- break;
1410
- case 'hide':
1411
- datetimepicker.trigger('close.xdsoft');
1412
- break;
1413
- case 'destroy':
1414
- destroyDateTimePicker($(this));
1415
- break;
1416
- case 'reset':
1417
- this.value = this.defaultValue;
1418
- if(!this.value || !datetimepicker.data('xdsoft_datetime').isValidDate(Date.parseDate(this.value, options.format)))
1419
- datetimepicker.data('changed',false);
1420
- datetimepicker.data('xdsoft_datetime').setCurrentTime(this.value);
1421
- break;
1422
- }
1423
- }else{
1424
- datetimepicker
1425
- .setOptions(opt);
1426
- }
1427
- return 0;
1428
- }else
1429
- if( ($.type(opt) !== 'string') ){
1430
- if( !options.lazyInit||options.open||options.inline ){
1431
- createDateTimePicker($(this));
1432
- }else
1433
- lazyInit($(this));
1434
- }
1435
- });
1436
- };
1437
- $.fn.datetimepicker.defaults = default_options;
1438
- })( jQuery );
1439
-
1440
- /*
1441
- * Copyright (c) 2013 Brandon Aaron (http://brandonaaron.net)
1442
- *
1443
- * Licensed under the MIT License (LICENSE.txt).
1444
- *
1445
- * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
1446
- * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
1447
- * Thanks to: Seamus Leahy for adding deltaX and deltaY
1448
- *
1449
- * Version: 3.1.3
1450
- *
1451
- * Requires: 1.2.2+
1452
- */
1453
- (function(factory) {if(typeof define==='function'&&define.amd) {define(['jquery'],factory)}else if(typeof exports==='object') {module.exports=factory}else{factory(jQuery)}}(function($) {var toFix=['wheel','mousewheel','DOMMouseScroll','MozMousePixelScroll'];var toBind='onwheel'in document||document.documentMode>=9?['wheel']:['mousewheel','DomMouseScroll','MozMousePixelScroll'];var lowestDelta,lowestDeltaXY;if($.event.fixHooks) {for(var i=toFix.length;i;) {$.event.fixHooks[toFix[--i]]=$.event.mouseHooks}}$.event.special.mousewheel={setup:function() {if(this.addEventListener) {for(var i=toBind.length;i;) {this.addEventListener(toBind[--i],handler,false)}}else{this.onmousewheel=handler}},teardown:function() {if(this.removeEventListener) {for(var i=toBind.length;i;) {this.removeEventListener(toBind[--i],handler,false)}}else{this.onmousewheel=null}}};$.fn.extend({mousewheel:function(fn) {return fn?this.bind("mousewheel",fn):this.trigger("mousewheel")},unmousewheel:function(fn) {return this.unbind("mousewheel",fn)}});function handler(event) {var orgEvent=event||window.event,args=[].slice.call(arguments,1),delta=0,deltaX=0,deltaY=0,absDelta=0,absDeltaXY=0,fn;event=$.event.fix(orgEvent);event.type="mousewheel";if(orgEvent.wheelDelta) {delta=orgEvent.wheelDelta}if(orgEvent.detail) {delta=orgEvent.detail*-1}if(orgEvent.deltaY) {deltaY=orgEvent.deltaY*-1;delta=deltaY}if(orgEvent.deltaX) {deltaX=orgEvent.deltaX;delta=deltaX*-1}if(orgEvent.wheelDeltaY!==undefined) {deltaY=orgEvent.wheelDeltaY}if(orgEvent.wheelDeltaX!==undefined) {deltaX=orgEvent.wheelDeltaX*-1}absDelta=Math.abs(delta);if(!lowestDelta||absDelta<lowestDelta) {lowestDelta=absDelta}absDeltaXY=Math.max(Math.abs(deltaY),Math.abs(deltaX));if(!lowestDeltaXY||absDeltaXY<lowestDeltaXY) {lowestDeltaXY=absDeltaXY}fn=delta>0?'floor':'ceil';delta=Math[fn](delta/lowestDelta);deltaX=Math[fn](deltaX/lowestDeltaXY);deltaY=Math[fn](deltaY/lowestDeltaXY);args.unshift(event,delta,deltaX,deltaY);return($.event.dispatch||$.event.handle).apply(this,args)}}));
1454
-
1455
-
1456
- // Parse and Format Library
1457
- //http://www.xaprb.com/blog/2005/12/12/javascript-closures-for-runtime-efficiency/
1458
- /*
1459
- * Copyright (C) 2004 Baron Schwartz <baron at sequent dot org>
1460
- *
1461
- * This program is free software; you can redistribute it and/or modify it
1462
- * under the terms of the GNU Lesser General Public License as published by the
1463
- * Free Software Foundation, version 2.1.
1464
- *
1465
- * This program is distributed in the hope that it will be useful, but WITHOUT
1466
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1467
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
1468
- * details.
1469
- */
1470
- Date.parseFunctions={count:0};Date.parseRegexes=[];Date.formatFunctions={count:0};Date.prototype.dateFormat=function(b){if(b=="unixtime"){return parseInt(this.getTime()/1000);}if(Date.formatFunctions[b]==null){Date.createNewFormat(b);}var a=Date.formatFunctions[b];return this[a]();};Date.createNewFormat=function(format){var funcName="format"+Date.formatFunctions.count++;Date.formatFunctions[format]=funcName;var code="Date.prototype."+funcName+" = function() {return ";var special=false;var ch="";for(var i=0;i<format.length;++i){ch=format.charAt(i);if(!special&&ch=="\\"){special=true;}else{if(special){special=false;code+="'"+String.escape(ch)+"' + ";}else{code+=Date.getFormatCode(ch);}}}eval(code.substring(0,code.length-3)+";}");};Date.getFormatCode=function(a){switch(a){case"d":return"String.leftPad(this.getDate(), 2, '0') + ";case"D":return"Date.dayNames[this.getDay()].substring(0, 3) + ";case"j":return"this.getDate() + ";case"l":return"Date.dayNames[this.getDay()] + ";case"S":return"this.getSuffix() + ";case"w":return"this.getDay() + ";case"z":return"this.getDayOfYear() + ";case"W":return"this.getWeekOfYear() + ";case"F":return"Date.monthNames[this.getMonth()] + ";case"m":return"String.leftPad(this.getMonth() + 1, 2, '0') + ";case"M":return"Date.monthNames[this.getMonth()].substring(0, 3) + ";case"n":return"(this.getMonth() + 1) + ";case"t":return"this.getDaysInMonth() + ";case"L":return"(this.isLeapYear() ? 1 : 0) + ";case"Y":return"this.getFullYear() + ";case"y":return"('' + this.getFullYear()).substring(2, 4) + ";case"a":return"(this.getHours() < 12 ? 'am' : 'pm') + ";case"A":return"(this.getHours() < 12 ? 'AM' : 'PM') + ";case"g":return"((this.getHours() %12) ? this.getHours() % 12 : 12) + ";case"G":return"this.getHours() + ";case"h":return"String.leftPad((this.getHours() %12) ? this.getHours() % 12 : 12, 2, '0') + ";case"H":return"String.leftPad(this.getHours(), 2, '0') + ";case"i":return"String.leftPad(this.getMinutes(), 2, '0') + ";case"s":return"String.leftPad(this.getSeconds(), 2, '0') + ";case"O":return"this.getGMTOffset() + ";case"T":return"this.getTimezone() + ";case"Z":return"(this.getTimezoneOffset() * -60) + ";default:return"'"+String.escape(a)+"' + ";}};Date.parseDate=function(a,c){if(c=="unixtime"){return new Date(!isNaN(parseInt(a))?parseInt(a)*1000:0);}if(Date.parseFunctions[c]==null){Date.createParser(c);}var b=Date.parseFunctions[c];return Date[b](a);};Date.createParser=function(format){var funcName="parse"+Date.parseFunctions.count++;var regexNum=Date.parseRegexes.length;var currentGroup=1;Date.parseFunctions[format]=funcName;var code="Date."+funcName+" = function(input) {\nvar y = -1, m = -1, d = -1, h = -1, i = -1, s = -1, z = -1;\nvar d = new Date();\ny = d.getFullYear();\nm = d.getMonth();\nd = d.getDate();\nvar results = input.match(Date.parseRegexes["+regexNum+"]);\nif (results && results.length > 0) {";var regex="";var special=false;var ch="";for(var i=0;i<format.length;++i){ch=format.charAt(i);if(!special&&ch=="\\"){special=true;}else{if(special){special=false;regex+=String.escape(ch);}else{obj=Date.formatCodeToRegex(ch,currentGroup);currentGroup+=obj.g;regex+=obj.s;if(obj.g&&obj.c){code+=obj.c;}}}}code+="if (y > 0 && z > 0){\nvar doyDate = new Date(y,0);\ndoyDate.setDate(z);\nm = doyDate.getMonth();\nd = doyDate.getDate();\n}";code+="if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n{return new Date(y, m, d, h, i, s);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n{return new Date(y, m, d, h, i);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0)\n{return new Date(y, m, d, h);}\nelse if (y > 0 && m >= 0 && d > 0)\n{return new Date(y, m, d);}\nelse if (y > 0 && m >= 0)\n{return new Date(y, m);}\nelse if (y > 0)\n{return new Date(y);}\n}return null;}";Date.parseRegexes[regexNum]=new RegExp("^"+regex+"$");eval(code);};Date.formatCodeToRegex=function(b,a){switch(b){case"D":return{g:0,c:null,s:"(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)"};case"j":case"d":return{g:1,c:"d = parseInt(results["+a+"], 10);\n",s:"(\\d{1,2})"};case"l":return{g:0,c:null,s:"(?:"+Date.dayNames.join("|")+")"};case"S":return{g:0,c:null,s:"(?:st|nd|rd|th)"};case"w":return{g:0,c:null,s:"\\d"};case"z":return{g:1,c:"z = parseInt(results["+a+"], 10);\n",s:"(\\d{1,3})"};case"W":return{g:0,c:null,s:"(?:\\d{2})"};case"F":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+a+"].substring(0, 3)], 10);\n",s:"("+Date.monthNames.join("|")+")"};case"M":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+a+"]], 10);\n",s:"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"};case"n":case"m":return{g:1,c:"m = parseInt(results["+a+"], 10) - 1;\n",s:"(\\d{1,2})"};case"t":return{g:0,c:null,s:"\\d{1,2}"};case"L":return{g:0,c:null,s:"(?:1|0)"};case"Y":return{g:1,c:"y = parseInt(results["+a+"], 10);\n",s:"(\\d{4})"};case"y":return{g:1,c:"var ty = parseInt(results["+a+"], 10);\ny = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",s:"(\\d{1,2})"};case"a":return{g:1,c:"if (results["+a+"] == 'am') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",s:"(am|pm)"};case"A":return{g:1,c:"if (results["+a+"] == 'AM') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",s:"(AM|PM)"};case"g":case"G":case"h":case"H":return{g:1,c:"h = parseInt(results["+a+"], 10);\n",s:"(\\d{1,2})"};case"i":return{g:1,c:"i = parseInt(results["+a+"], 10);\n",s:"(\\d{2})"};case"s":return{g:1,c:"s = parseInt(results["+a+"], 10);\n",s:"(\\d{2})"};case"O":return{g:0,c:null,s:"[+-]\\d{4}"};case"T":return{g:0,c:null,s:"[A-Z]{3}"};case"Z":return{g:0,c:null,s:"[+-]\\d{1,5}"};default:return{g:0,c:null,s:String.escape(b)};}};Date.prototype.getTimezone=function(){return this.toString().replace(/^.*? ([A-Z]{3}) [0-9]{4}.*$/,"$1").replace(/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/,"$1$2$3");};Date.prototype.getGMTOffset=function(){return(this.getTimezoneOffset()>0?"-":"+")+String.leftPad(Math.floor(Math.abs(this.getTimezoneOffset())/60),2,"0")+String.leftPad(Math.abs(this.getTimezoneOffset())%60,2,"0");};Date.prototype.getDayOfYear=function(){var a=0;Date.daysInMonth[1]=this.isLeapYear()?29:28;for(var b=0;b<this.getMonth();++b){a+=Date.daysInMonth[b];}return a+this.getDate();};Date.prototype.getWeekOfYear=function(){var b=this.getDayOfYear()+(4-this.getDay());var a=new Date(this.getFullYear(),0,1);var c=(7-a.getDay()+4);return String.leftPad(Math.ceil((b-c)/7)+1,2,"0");};Date.prototype.isLeapYear=function(){var a=this.getFullYear();return((a&3)==0&&(a%100||(a%400==0&&a)));};Date.prototype.getFirstDayOfMonth=function(){var a=(this.getDay()-(this.getDate()-1))%7;return(a<0)?(a+7):a;};Date.prototype.getLastDayOfMonth=function(){var a=(this.getDay()+(Date.daysInMonth[this.getMonth()]-this.getDate()))%7;return(a<0)?(a+7):a;};Date.prototype.getDaysInMonth=function(){Date.daysInMonth[1]=this.isLeapYear()?29:28;return Date.daysInMonth[this.getMonth()];};Date.prototype.getSuffix=function(){switch(this.getDate()){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th";}};String.escape=function(a){return a.replace(/('|\\)/g,"\\$1");};String.leftPad=function(d,b,c){var a=new String(d);if(c==null){c=" ";}while(a.length<b){a=c+a;}return a;};Date.daysInMonth=[31,28,31,30,31,30,31,31,30,31,30,31];Date.monthNames=["January","February","March","April","May","June","July","August","September","October","November","December"];Date.dayNames=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];Date.y2kYear=50;Date.monthNumbers={Jan:0,Feb:1,Mar:2,Apr:3,May:4,Jun:5,Jul:6,Aug:7,Sep:8,Oct:9,Nov:10,Dec:11};Date.patterns={ISO8601LongPattern:"Y-m-d H:i:s",ISO8601ShortPattern:"Y-m-d",ShortDatePattern:"n/j/Y",LongDatePattern:"l, F d, Y",FullDateTimePattern:"l, F d, Y g:i:s A",MonthDayPattern:"F d",ShortTimePattern:"g:i A",LongTimePattern:"g:i:s A",SortableDateTimePattern:"Y-m-d\\TH:i:s",UniversalSortableDateTimePattern:"Y-m-d H:i:sO",YearMonthPattern:"F, Y"};