jquery-datetimepicker-rails 2.0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ac18bf686ea46e59eef4ddb6e4abc4b1e5b1c834
4
+ data.tar.gz: c255e8d35674dc62addc8cf5e3ed0962c02541f4
5
+ SHA512:
6
+ metadata.gz: 587c5f7d6de64b7a1c3f56662148398a8e527db004db1e8076871ffd2d3ffa5ab1a39486c883eb1ac31e83862693689a13023a6535bc2e1eb412c6c574f1ee60
7
+ data.tar.gz: 1fe762a3a4adf1fb95ba35fec9f9776827c2d216cf1b6f7be0ed307bc9f165d5a468896f197df1da8537cfc6aabeda92e569f71705179cc90e425f2c1d993e83
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jquery-datetimepicker-rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Novikov Andrey
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ jQuery date and time picker for rails
2
+ =====================================
3
+
4
+ [jQuery Date and Time picker plugin] [plugin] by [@xdan] [author] for Ruby on Rails asset pipeline.
5
+
6
+ Installation
7
+ ------------
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'jquery-datetimepicker-rails'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Add this line to `app/assets/stylesheets/application.css`:
18
+
19
+ *= require jquery.datetimepicker
20
+
21
+ Add this line to `app/assets/javascripts/application.js`:
22
+
23
+ //= require jquery.datetimepicker
24
+
25
+ You can autoinitialize datetime picker on page load for elements with class `datetimepicker` by also adding to js manifest:
26
+
27
+ //= require jquery.datetimepicker/init
28
+
29
+ Usage
30
+ -----
31
+
32
+ $('.datetimepicker').datetimepicker();
33
+
34
+ See the official [documentation] for examples and options.
35
+
36
+ Contributing
37
+ ------------
38
+
39
+ 1. Fork it
40
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
41
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
42
+ 4. Push to the branch (`git push origin my-new-feature`)
43
+ 5. Create new Pull Request
44
+
45
+ ### Version policy
46
+
47
+ This gem version number is in form of **X.Y.Z.P**, where **X.Y.Z** is a version of original [plugin] and **P** is a gem-specific patch level.
48
+
49
+ [plugin]: https://github.com/xdan/datetimepicker
50
+ [author]: https://github.com/xdan
51
+ [documentation]: http://xdsoft.net/jqplugins/datetimepicker/ "Official site docs"
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jquery/datetimepicker/rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'jquery-datetimepicker-rails'
8
+ spec.version = Jquery::Datetimepicker::Rails::VERSION
9
+ spec.authors = ['Andrey Novikov']
10
+ spec.email = ['envek@envek.name']
11
+ spec.description = %q{A date and time picker for jQuery and Rails}
12
+ spec.summary = %q{This gem packages the datetimepicker jQuery plugin for Rails 3.1+ asset pipeline}
13
+ spec.homepage = 'https://github.com/Envek/jquery-datetimepicker-rails'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.3'
22
+ spec.add_development_dependency 'rake'
23
+ end
@@ -0,0 +1,933 @@
1
+ /**
2
+ * @preserve jQuery DateTimePicker plugin v2.0.2
3
+ * @homepage http://xdsoft.net/jqplugins/datetimepicker/
4
+ * (c) 2013, Chupurnov Valeriy.
5
+ */
6
+ (function( $ ){
7
+ $.fn.xdsoftScroller = function( _percent ){
8
+ return this.each(function(){
9
+ var timeboxparent = $(this);
10
+ if( !$(this).hasClass('xdsoft_scroller_box') ){
11
+ var pointerEventToXY = function( e ){
12
+ var out = {x:0, y:0};
13
+ if(e.type == 'touchstart' || e.type == 'touchmove' || e.type == 'touchend' || e.type == 'touchcancel'){
14
+ var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
15
+ out.x = touch.pageX;
16
+ out.y = touch.pageY;
17
+ }else if (e.type == 'mousedown' || e.type == 'mouseup' || e.type == 'mousemove' || e.type == 'mouseover'|| e.type=='mouseout' || e.type=='mouseenter' || e.type=='mouseleave') {
18
+ out.x = e.pageX;
19
+ out.y = e.pageY;
20
+ }
21
+ return out;
22
+ },
23
+ move = 0,
24
+ timebox = timeboxparent.children().eq(0),
25
+ parentHeight = timeboxparent[0].offsetHeight-2,
26
+ height = timebox[0].offsetHeight,
27
+ scrollbar = $('<div class="xdsoft_scrollbar"></div>'),
28
+ scroller = $('<div class="xdsoft_scroller"></div>'),
29
+ maximumOffset = 100,
30
+ start = false;
31
+
32
+ scrollbar.append(scroller);
33
+
34
+ timeboxparent.addClass('xdsoft_scroller_box').append(scrollbar);
35
+ scroller.on('mousedown.xdsoft_scroller',function( event ){
36
+ var pageY = event.pageY,
37
+ top = parseInt(scroller.css('margin-top')),
38
+ h1 = scrollbar[0].offsetHeight;
39
+ $(document.body).addClass('xdsoft_noselect');
40
+ $([document.body,window]).on('mouseup.xdsoft_scroller',function(){
41
+ $([document.body,window]).off('mouseup.xdsoft_scroller',arguments.callee)
42
+ .off('mousemove.xdsoft_scroller',move)
43
+ .removeClass('xdsoft_noselect');
44
+ });
45
+ $(document.body).on('mousemove.xdsoft_scroller',move = function(event){
46
+ var offset = event.pageY-pageY+top;
47
+ if( offset<0 )
48
+ offset = 0;
49
+ if( offset+scroller[0].offsetHeight>h1 )
50
+ offset = h1-scroller[0].offsetHeight;
51
+ timeboxparent.trigger('scroll_element.xdsoft_scroller',[maximumOffset?offset/maximumOffset:0]);
52
+ });
53
+ });
54
+
55
+ timeboxparent
56
+ .on('scroll_element.xdsoft_scroller',function( event,percent ){
57
+ percent = percent>1?1:(percent<0||isNaN(percent))?0:percent;
58
+ scroller.css('margin-top',maximumOffset*percent);
59
+ timebox.css('marginTop',-parseInt((height-parentHeight)*percent))
60
+ })
61
+ .on('resize_scroll.xdsoft_scroller',function( event,_percent ){
62
+ parentHeight = timeboxparent[0].offsetHeight-2;
63
+ height = timebox[0].offsetHeight;
64
+ var percent = parentHeight/height,
65
+ sh = percent*scrollbar[0].offsetHeight;
66
+ if( percent>1 )
67
+ scroller.hide();
68
+ else{
69
+ scroller.show();
70
+ scroller.css('height',parseInt(sh>10?sh:10));
71
+ maximumOffset = scrollbar[0].offsetHeight-scroller[0].offsetHeight;
72
+ timeboxparent.trigger('scroll_element.xdsoft_scroller',[_percent?_percent:Math.abs(parseInt(timebox.css('marginTop')))/(height-parentHeight)]);
73
+ }
74
+ })
75
+ timeboxparent.mousewheel&&timeboxparent.mousewheel(function(event, delta, deltaX, deltaY) {
76
+ var top = Math.abs(parseInt(timebox.css('marginTop')));
77
+ timeboxparent.trigger('scroll_element.xdsoft_scroller',[(top-delta*20)/(height-parentHeight)]);
78
+ event.stopPropagation();
79
+ return false;
80
+ });
81
+ timeboxparent.on('touchstart',function( event ){
82
+ start = pointerEventToXY(event);
83
+ });
84
+ timeboxparent.on('touchmove',function( event ){
85
+ if( start ){
86
+ var coord = pointerEventToXY(event), top = Math.abs(parseInt(timebox.css('marginTop')));
87
+ timeboxparent.trigger('scroll_element.xdsoft_scroller',[(top-(coord.y-start.y))/(height-parentHeight)]);
88
+ event.stopPropagation();
89
+ event.preventDefault();
90
+ };
91
+ });
92
+ timeboxparent.on('touchend touchcancel',function( event ){
93
+ start = false;
94
+ });
95
+ }
96
+ timeboxparent.trigger('resize_scroll.xdsoft_scroller',[_percent]);
97
+ });
98
+ };
99
+ $.fn.datetimepicker = function( opt ){
100
+ var CTRLKEY = 17,
101
+ DEL = 46,
102
+ ENTER = 13,
103
+ ESC = 27,
104
+ BACKSPACE = 8,
105
+ ARROWLEFT = 37,
106
+ ARROWUP = 38,
107
+ ARROWRIGHT = 39,
108
+ ARROWDOWN = 40,
109
+ TAB = 9,
110
+ F5 = 116,
111
+ AKEY = 65,
112
+ CKEY = 67,
113
+ VKEY = 86,
114
+ ZKEY = 90,
115
+ YKEY = 89,
116
+ ctrlDown = false,
117
+ default_options = {
118
+ i18n:{
119
+ ru:{
120
+ months:[
121
+ 'Январь','Февраль','Март','Апрель','Май','Июнь','Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь'
122
+ ],
123
+ dayOfWeek:[
124
+ "Вск", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"
125
+ ]
126
+ },
127
+ en:{
128
+ months: [
129
+ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
130
+ ],
131
+ dayOfWeek: [
132
+ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
133
+ ]
134
+ },
135
+ de:{
136
+ months:[
137
+ 'Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'
138
+ ],
139
+ dayOfWeek:[
140
+ "So.", "Mo", "Di", "Mi", "Do", "Fr", "Sa."
141
+ ]
142
+ },
143
+ nl:{
144
+ months:[
145
+ "januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"
146
+ ],
147
+ dayOfWeek:[
148
+ "zo", "ma", "di", "wo", "do", "vr", "za"
149
+ ]
150
+ }
151
+ },
152
+ value:'',
153
+ lang:'en',
154
+ format:'Y/m/d H:i',
155
+ formatTime:'H:i',
156
+ formatDate:'Y/m/d',
157
+ step:60,
158
+ closeOnDateSelect:0,
159
+ closeOnWithoutClick:true,
160
+ timepicker:true,
161
+ datepicker:true,
162
+ minDate:false,
163
+ maxDate:false,
164
+ minTime:false,
165
+ maxTime:false,
166
+ allowTimes:[],
167
+ opened:false,
168
+ inline:false,
169
+ onSelectDate:function(){},
170
+ onSelectTime:function(){},
171
+ onChangeMonth:function(){},
172
+ onChangeDateTime:function(){},
173
+ onShow:function(){},
174
+ onClose:function(){},
175
+ withoutCopyright:true,
176
+ inverseButton:false,
177
+ hours12:false,
178
+ next: 'xdsoft_next',
179
+ prev : 'xdsoft_prev',
180
+ dayOfWeekStart:0,
181
+ timeHeightInTimePicker:25,
182
+ timepickerScrollbar:true,
183
+ scrollMonth:true,
184
+ scrollTime:true,
185
+ scrollInput:true,
186
+ mask:false,
187
+ validateOnBlur:true,
188
+ yearStart:1950,
189
+ yearEnd:2050,
190
+ style:'',
191
+ id:'',
192
+ className:''
193
+ },
194
+ options = ($.isPlainObject(opt)||!opt)?$.extend({},default_options,opt):$.extend({},default_options),
195
+ createDateTimePicker = function( input ){
196
+ var datetimepicker = $('<div '+(options.id?'id="'+options.id+'"':'')+' '+(options.style?'style="'+options.style+'"':'')+' class="xdsoft_datetimepicker '+options.className+'"></div>'),
197
+ xdsoft_copyright = $('<div class="xdsoft_copyright"><a target="_blank" href="http://xdsoft.net/jqplugins/datetimepicker/">xdsoft.net</a></div>'),
198
+ datepicker = $('<div class="xdsoft_datepicker active"></div>'),
199
+ mounth_picker = $('<div class="xdsoft_mounthpicker"><button type="button" class="xdsoft_prev"></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>'),
200
+ calendar = $('<div class="xdsoft_calendar"></div>'),
201
+ 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>'),
202
+ timeboxparent = timepicker.find('.xdsoft_time_box').eq(0),
203
+ timebox = $('<div class="xdsoft_time_variant"></div>'),
204
+ scrollbar = $('<div class="xdsoft_scrollbar"></div>'),
205
+ scroller = $('<div class="xdsoft_scroller"></div>'),
206
+ monthselect =$('<div class="xdsoft_select xdsoft_monthselect"><div></div></div>'),
207
+ yearselect =$('<div class="xdsoft_select xdsoft_yearselect"><div></div></div>');
208
+
209
+ //constructor lego
210
+ mounth_picker
211
+ .find('.xdsoft_month span')
212
+ .after(monthselect);
213
+ mounth_picker
214
+ .find('.xdsoft_year span')
215
+ .after(yearselect);
216
+
217
+ mounth_picker
218
+ .find('.xdsoft_month,.xdsoft_year')
219
+ .on('mousedown.xdsoft',function(event) {
220
+ mounth_picker
221
+ .find('.xdsoft_select')
222
+ .hide();
223
+ var select = $(this).find('.xdsoft_select').eq(0),
224
+ xd = datetimepicker.data('xdsoft_datetime'),
225
+ val = 0,
226
+ top = 0;
227
+
228
+ if( xd&&xd.currentTime )
229
+ val = xd.currentTime[$(this).hasClass('xdsoft_month')?'getMonth':'getFullYear']();
230
+
231
+ select.show();
232
+ for(var items = select.find('div.xdsoft_option'),i = 0;i<items.length;i++){
233
+ if( items.eq(i).data('value')==val ){
234
+ break;
235
+ }else top+=items[0].offsetHeight;
236
+ }
237
+
238
+ select.xdsoftScroller(top/(select.children()[0].offsetHeight-(select[0].offsetHeight-2)));
239
+ event.stopPropagation();
240
+ return false;
241
+ });
242
+
243
+ mounth_picker
244
+ .find('.xdsoft_select')
245
+ .xdsoftScroller()
246
+ .on('mousedown.xdsoft',function( event ) {
247
+ event.stopPropagation();
248
+ event.preventDefault();
249
+ })
250
+ .on('mousedown.xdsoft','.xdsoft_option',function( event ){
251
+ var xd = datetimepicker.data('xdsoft_datetime');
252
+ if( xd&&xd.currentTime )
253
+ xd.currentTime[$(this).parent().parent().hasClass('xdsoft_monthselect')?'setMonth':'setFullYear']($(this).data('value'));
254
+ $(this).parent().parent().hide();
255
+ datetimepicker.trigger('xchange.xdsoft');
256
+ });
257
+
258
+
259
+ // set options
260
+ datetimepicker.setOptions = function( _options ){
261
+ options = $.extend({},options,_options);
262
+ if( (options.open||options.opened)&&(!options.inline) ){
263
+ input.trigger('open.xdsoft');
264
+ }
265
+
266
+ if( options.inline ){
267
+ datetimepicker.addClass('xdsoft_inline');
268
+ input.after(datetimepicker).hide();
269
+ datetimepicker.trigger('afterOpen.xdsoft');
270
+ }
271
+
272
+ if( options.inverseButton ){
273
+ options.next = 'xdsoft_prev';
274
+ options.prev = 'xdsoft_next';
275
+ }
276
+
277
+ if( !options.datepicker && options.timepicker )
278
+ datepicker.removeClass('active');
279
+
280
+ if( options.datepicker && !options.timepicker )
281
+ timepicker.removeClass('active');
282
+
283
+ if( options.value )
284
+ input&&input.val&&input.val(options.value);
285
+
286
+ if( isNaN(options.dayOfWeekStart)||parseInt(options.dayOfWeekStart)<0||parseInt(options.dayOfWeekStart)>6 )
287
+ options.dayOfWeekStart = 0;
288
+ else
289
+ options.dayOfWeekStart = parseInt(options.dayOfWeekStart);
290
+
291
+ if( !options.timepickerScrollbar )
292
+ scrollbar.hide();
293
+
294
+ var tmpDate = [];
295
+ if( options.minDate && ( tmpDate = /^-(.*)$/.exec(options.minDate) ) && (tmpDate=Date.parseDate(tmpDate[1], options.formatDate)) ){
296
+ options.minDate = new Date((new Date).getTime()-tmpDate.getTime()).dateFormat( options.formatDate );
297
+ }
298
+ if( options.maxDate && ( tmpDate = /^\+(.*)$/.exec(options.maxDate) ) && (tmpDate=Date.parseDate(tmpDate[1], options.formatDate)) ){
299
+ options.maxDate = new Date((new Date).getTime()+tmpDate.getTime()).dateFormat( options.formatDate );
300
+ }
301
+ if( options.mask ){
302
+ var e,
303
+ getCaretPos = function( input ) {
304
+ try{
305
+ if ( document.selection && document.selection.createRange ) {
306
+ var range = document.selection.createRange();
307
+ return range.getBookmark().charCodeAt(2) - 2;
308
+ }else
309
+ if ( input.setSelectionRange )
310
+ return input.selectionStart;
311
+ }catch(e){
312
+ return 0;
313
+ }
314
+ },
315
+ setCaretPos = function (node,pos){
316
+ var node = (typeof node == "string" || node instanceof String) ? document.getElementById(node) : node;
317
+ if(!node){
318
+ return false;
319
+ }else if(node.createTextRange){
320
+ var textRange = node.createTextRange();
321
+ textRange.collapse(true);
322
+ textRange.moveEnd(pos);
323
+ textRange.moveStart(pos);
324
+ textRange.select();
325
+ return true;
326
+ }else if(node.setSelectionRange){
327
+ node.setSelectionRange(pos,pos);
328
+ return true;
329
+ }
330
+ return false;
331
+ },
332
+ isValidValue = function( mask,value ){
333
+ var reg = mask
334
+ .replace(/([\[\]\/\{\}\(\)\-\.\+]{1})/g,'\\$1')
335
+ .replace(/_/g,'{digit+}')
336
+ .replace(/([0-9]{1})/g,'{digit$1}')
337
+ .replace(/\{digit([0-9]{1})\}/g,'[0-$1_]{1}')
338
+ .replace(/\{digit[\+]\}/g,'[0-9_]{1}');
339
+ return RegExp(reg).test(value);
340
+ };
341
+ input.off('keydown.xdsoft');
342
+ switch(true){
343
+ case ( options.mask===true ):
344
+ options.mask = (new Date()).dateFormat( options.format );
345
+ options.mask = options.mask.replace(/[0-9]/g,'_');
346
+ case ( $.type(options.mask) == 'string' ):
347
+ if( !isValidValue( options.mask,input.val() ) )
348
+ input.val(options.mask.replace(/[0-9]/g,'_'));
349
+
350
+ input.on('keydown.xdsoft',function( event ){
351
+ var val = this.value,
352
+ key = event.which;
353
+ switch(true){
354
+ case ((key>=48&&key<=57)||(key>=96&&key<=105))||(key==BACKSPACE||key==DEL):
355
+ var pos = getCaretPos(this),
356
+ digit = ( key!=BACKSPACE&&key!=DEL )?String.fromCharCode(key):'_';
357
+ if( (key==BACKSPACE||key==DEL)&&pos ){
358
+ pos--;
359
+ digit='_';
360
+ }
361
+ while( /[^0-9_]/.test(options.mask.substr(pos,1))&&pos<options.mask.length&&pos>0 )
362
+ pos+=( key==BACKSPACE||key==DEL )?-1:1;
363
+
364
+ val = val.substr(0,pos)+digit+val.substr(pos+1);
365
+ if( $.trim(val)=='' )
366
+ val = options.mask.replace(/[0-9]/g,'_');
367
+ else
368
+ if( pos==options.mask.length )
369
+ break;
370
+
371
+ pos+=(key==BACKSPACE||key==DEL)?0:1;
372
+ while( /[^0-9_]/.test(options.mask.substr(pos,1))&&pos<options.mask.length&&pos>0 )
373
+ pos+=(key==BACKSPACE||key==DEL)?-1:1;
374
+ if( isValidValue( options.mask,val ) ){
375
+ this.value = val;
376
+ setCaretPos(this,pos);
377
+ }else if( $.trim(val)=='' )
378
+ this.value = options.mask.replace(/[0-9]/g,'_');
379
+ else{
380
+ input.trigger('error_input.xdsoft');
381
+ }
382
+ break;
383
+ case ( ~[AKEY,CKEY,VKEY,ZKEY,YKEY].indexOf(key)&&ctrlDown ):
384
+ case ~[ESC,ARROWUP,ARROWDOWN,ARROWLEFT,ARROWRIGHT,F5,CTRLKEY].indexOf(key):
385
+ return true;
386
+ case ~[ENTER].indexOf(key):
387
+ var elementSelector = "input:visible,textarea:visible";
388
+ $(elementSelector ).eq($(elementSelector ).index(this) + 1).focus();
389
+ return false;
390
+ case ~[TAB].indexOf(key):return true;
391
+ }
392
+ event.preventDefault();
393
+ return false;
394
+ });
395
+ break;
396
+ }
397
+ }
398
+ if( options.validateOnBlur ){
399
+ input
400
+ .off('blur.xdsoft')
401
+ .on('blur.xdsoft', function(){
402
+ if( !Date.parseDate( $(this).val(), options.format ) )
403
+ $(this).val((new Date()).dateFormat( options.format ));
404
+ });
405
+ }
406
+ options.dayOfWeekStartPrev = (options.dayOfWeekStart==0)?6:options.dayOfWeekStart-1;
407
+ datetimepicker
408
+ .trigger('xchange.xdsoft');
409
+ };
410
+
411
+ datetimepicker
412
+ .data('options',options)
413
+ .on('mousedown.xdsoft',function( event ){
414
+ event.stopPropagation();
415
+ event.preventDefault();
416
+ yearselect.hide();
417
+ monthselect.hide();
418
+ return false;
419
+ });
420
+
421
+ var scroll_element = timepicker.find('.xdsoft_time_box');
422
+ scroll_element.append(timebox);
423
+ scroll_element.xdsoftScroller();
424
+ datetimepicker.on('afterOpen.xdsoft',function(){
425
+ scroll_element.xdsoftScroller();
426
+ });
427
+
428
+ datetimepicker
429
+ .append(datepicker)
430
+ .append(timepicker);
431
+
432
+ if( options.withoutCopyright!==true )
433
+ datetimepicker
434
+ .append(xdsoft_copyright);
435
+
436
+ datepicker
437
+ .append(mounth_picker)
438
+ .append(calendar);
439
+
440
+ $('body').append(datetimepicker);
441
+
442
+ var XDSoftDateTime = function(){
443
+ var _this = this;
444
+ _this.now = function(){
445
+ return new Date();
446
+ };
447
+
448
+ _this.currentTime = this.now();
449
+ _this.isValidDate = function (d) {
450
+ if ( Object.prototype.toString.call(d) !== "[object Date]" )
451
+ return false;
452
+ return !isNaN(d.getTime());
453
+ };
454
+
455
+ _this.setCurrentTime = function( dTime){
456
+ _this.currentTime = (typeof dTime == 'string')? _this.strtodatetime(dTime) : _this.isValidDate(dTime) ? dTime: _this.now();
457
+ datetimepicker.trigger('xchange.xdsoft');
458
+ };
459
+
460
+ _this.getCurrentTime = function( dTime){
461
+ return _this.currentTime;
462
+ };
463
+
464
+ _this.nextMonth = function(){
465
+ var month = _this.currentTime.getMonth()+1;
466
+ if( month==12 ){
467
+ _this.currentTime.setFullYear(_this.currentTime.getFullYear()+1);
468
+ month = 0;
469
+ }
470
+ _this.currentTime.setMonth(month);
471
+ options.onChangeMonth&&options.onChangeMonth.call&&options.onChangeMonth.call(datetimepicker,datetimepicker.data('xdsoft_datetime').currentTime,datetimepicker.data('input'));
472
+ datetimepicker.trigger('xchange.xdsoft');
473
+ return month;
474
+ };
475
+
476
+ _this.prevMonth = function(){
477
+ var month = _this.currentTime.getMonth()-1;
478
+ if( month==-1 ){
479
+ _this.currentTime.setFullYear(_this.currentTime.getFullYear()-1);
480
+ month = 11;
481
+ }
482
+ _this.currentTime.setMonth(month);
483
+ options.onChangeMonth&&options.onChangeMonth.call&&options.onChangeMonth.call(datetimepicker,datetimepicker.data('xdsoft_datetime').currentTime,datetimepicker.data('input'));
484
+ datetimepicker.trigger('xchange.xdsoft');
485
+ return month;
486
+ };
487
+
488
+ _this.strtodatetime = function( sDateTime ){
489
+ var currentTime = sDateTime?Date.parseDate(sDateTime, options.format):new Date;
490
+ if( !_this.isValidDate(currentTime) )
491
+ currentTime = new Date;
492
+ return currentTime;
493
+ };
494
+
495
+ _this.strtodate = function( sDate ){
496
+ var currentTime = sDate?Date.parseDate(sDate, options.formatDate):new Date;
497
+ if( !_this.isValidDate(currentTime) )
498
+ currentTime = new Date;
499
+ return currentTime;
500
+ };
501
+
502
+ _this.strtotime = function( sTime ){
503
+ var currentTime = sTime?Date.parseDate(sTime, options.formatTime):new Date;
504
+ if( !_this.isValidDate(currentTime) )
505
+ currentTime = new Date;
506
+ return currentTime;
507
+ };
508
+
509
+ _this.str = function(){
510
+ return _this.currentTime.dateFormat(options.format);
511
+ };
512
+ };
513
+
514
+ mounth_picker
515
+ .find('.xdsoft_prev,.xdsoft_next')
516
+ .on('mousedown.xdsoft',function(){
517
+ var $this = $(this),
518
+ timer = 0,
519
+ stop = false;
520
+
521
+ (function(v){
522
+ var month = datetimepicker.data('xdsoft_datetime')
523
+ .currentTime.getMonth();
524
+ if( $this.hasClass( options.next ) ){
525
+ datetimepicker.data('xdsoft_datetime').nextMonth();
526
+ }else if( $this.hasClass( options.prev ) ){
527
+ datetimepicker.data('xdsoft_datetime').prevMonth();
528
+ }
529
+ !stop&&(timer = setTimeout(arguments.callee,v?v:100));
530
+ })(500);
531
+
532
+ $([document.body,window]).on('mouseup.xdsoft',function(){
533
+ clearTimeout(timer);
534
+ stop = true;
535
+ $([document.body,window]).off('mouseup.xdsoft',arguments.callee);
536
+ });
537
+ });
538
+
539
+ timepicker
540
+ .find('.xdsoft_prev,.xdsoft_next')
541
+ .on('mousedown.xdsoft',function(){
542
+ var $this = $(this),
543
+ timer = 0,
544
+ stop = false,
545
+ period = 110;
546
+ (function(v){
547
+ var pheight = timeboxparent[0].offsetHeight-2,
548
+ height = timebox[0].offsetHeight,
549
+ top = Math.abs(parseInt(timebox.css('marginTop')));
550
+ if( $this.hasClass(options.next) && (height-pheight)- options.timeHeightInTimePicker>=top ){
551
+ timebox.css('marginTop','-'+(top+options.timeHeightInTimePicker)+'px')
552
+ }else if( $this.hasClass(options.prev) && top-options.timeHeightInTimePicker>=0 ){
553
+ timebox.css('marginTop','-'+(top-options.timeHeightInTimePicker)+'px')
554
+ }
555
+ timeboxparent.trigger('scroll_element.xdsoft_scroller',[Math.abs(parseInt(timebox.css('marginTop'))/(height-pheight))]);
556
+ period= ( period>10 )?10:period-10;
557
+ !stop&&(timer = setTimeout(arguments.callee,v?v:period));
558
+ })(500);
559
+ $([document.body,window]).on('mouseup.xdsoft',function(){
560
+ clearTimeout(timer);
561
+ stop = true;
562
+ $([document.body,window])
563
+ .off('mouseup.xdsoft',arguments.callee);
564
+ });
565
+ });
566
+
567
+ // base handler - generating a calendar and timepicker
568
+ datetimepicker
569
+ .on('xchange.xdsoft',function(event){
570
+ var xd = $(this).data('xdsoft_datetime'),
571
+ table = '',
572
+ start = new Date(xd.currentTime.getFullYear(),xd.currentTime.getMonth(),1),
573
+ i = 0,
574
+ today = new Date;
575
+
576
+ while( start.getDay()!=options.dayOfWeekStart )
577
+ start.setDate(start.getDate()-1);
578
+
579
+ //generate calendar
580
+ table+='<table><thead><tr>';
581
+
582
+ // days
583
+ for(var j = 0; j<7; j++){
584
+ table+='<th>'+options.i18n[options.lang].dayOfWeek[(j+options.dayOfWeekStart)>6?0:j+options.dayOfWeekStart]+'</th>';
585
+ }
586
+
587
+ table+='</tr></thead>';
588
+ table+='<tbody><tr>';
589
+ while( i<xd.currentTime.getDaysInMonth()||start.getDay()!=options.dayOfWeekStart||xd.currentTime.getMonth()==start.getMonth() ){
590
+ i++;
591
+ table+='<td data-date="'+start.getDate()+'" data-month="'+start.getMonth()+'" data-year="'+start.getFullYear()+'"'+
592
+ ' class="'+
593
+ (
594
+ (options.maxDate!==false&&Math.round(xd.strtodate(options.maxDate).getTime()/86400000)<Math.round(start.getTime()/86400000))||
595
+ (options.minDate!==false&&Math.round(xd.strtodate(options.minDate).getTime()/86400000)>Math.round(start.getTime()/86400000))
596
+ ?'xdsoft_disabled ':' ')+
597
+ (xd.currentTime.getMonth()!=start.getMonth()?' xdsoft_other_month ':' ')+
598
+ (xd.currentTime.dateFormat('d.m.Y')==start.dateFormat('d.m.Y')?' xdsoft_current ':' ')+
599
+ (today.dateFormat('d.m.Y')==start.dateFormat('d.m.Y')?' xdsoft_today ':' ')
600
+ +'"><div>'+start.getDate()+'</div></td>';
601
+ if( start.getDay()==options.dayOfWeekStartPrev )
602
+ table+='</tr>';
603
+ start.setDate(start.getDate()+1);
604
+ }
605
+ table+='</tbody></table>';
606
+
607
+ calendar.html(table);
608
+
609
+ mounth_picker.find('.xdsoft_label span').eq(0).text(options.i18n[options.lang].months[xd.currentTime.getMonth()]);
610
+ mounth_picker.find('.xdsoft_label span').eq(1).text(xd.currentTime.getFullYear());
611
+
612
+ // generate timebox
613
+ var time = '',
614
+ h = '',
615
+ m ='',
616
+ line_time = function line_time( h,m ){
617
+ var now = new Date();
618
+ now.setHours(h);
619
+ h = parseInt(now.getHours());
620
+ now.setMinutes(m);
621
+ m = parseInt(now.getMinutes());
622
+ time+= '<div class="'+
623
+ (
624
+ (options.maxTime!==false&&xd.strtotime(options.maxTime).getTime()<now.getTime())||
625
+ (options.minTime!==false&&xd.strtotime(options.minTime).getTime()>now.getTime())
626
+ ?'xdsoft_disabled ':' ')+
627
+ (
628
+ (parseInt(xd.currentTime.getHours())==parseInt(h)
629
+ &&
630
+ parseInt(xd.currentTime.getMinutes()/options.step)*options.step==parseInt(m)
631
+ )?' xdsoft_current ':'')+
632
+ ((parseInt(today.getHours())==parseInt(h)&&parseInt(today.getMinutes())==parseInt(m))?' xdsoft_today ':'')+
633
+ '" data-hour="'+h+'" data-minute="'+m+'">'+now.dateFormat(options.formatTime)+'</div>';
634
+ };
635
+ if( !options.allowTimes || !$.isArray(options.allowTimes) || !options.allowTimes.length ){
636
+ for(var i=0,j=0;i<(options.hours12?12:24);i++){
637
+ for(j=0;j<60;j+=options.step){
638
+ h = (i<10?'0':'')+i;
639
+ m = (j<10?'0':'')+j;
640
+ line_time( h,m );
641
+ }
642
+ }
643
+ }else{
644
+ for(var i=0;i<options.allowTimes.length;i++){
645
+ h = xd.strtotime(options.allowTimes[i]).getHours();
646
+ m = xd.strtotime(options.allowTimes[i]).getMinutes();
647
+ line_time( h,m );
648
+ }
649
+ }
650
+ timebox.html(time);
651
+
652
+ var opt = '',
653
+ i = 0;
654
+
655
+ for( i = parseInt(options.yearStart,10);i<= parseInt(options.yearEnd,10);i++ ){
656
+ opt+='<div class="xdsoft_option '+(xd.currentTime.getFullYear()==i?'xdsoft_current':'')+'" data-value="'+i+'">'+i+'</div>';
657
+ }
658
+ yearselect.children().eq(0)
659
+ .html(opt);
660
+
661
+ for( i = 0,opt = '';i<= 11;i++ ){
662
+ opt+='<div class="xdsoft_option '+(xd.currentTime.getMonth()==i?'xdsoft_current':'')+'" data-value="'+i+'">'+options.i18n[options.lang].months[i]+'</div>';
663
+ }
664
+ monthselect.children().eq(0).html(opt);
665
+ event.stopPropagation();
666
+ })
667
+ .on('afterOpen.xdsoft',function(){
668
+ if( options.timepicker && timebox.find('.xdsoft_current').length ){
669
+ var pheight = timeboxparent[0].offsetHeight-2,
670
+ height = timebox[0].offsetHeight,
671
+ top = timebox.find('.xdsoft_current').index()*options.timeHeightInTimePicker+1;
672
+ if( (height-pheight)<top )
673
+ top = height-pheight;
674
+ timebox.css('marginTop','-'+parseInt(top)+'px');
675
+ timeboxparent.trigger('scroll_element.xdsoft_scroller',[parseInt(top)/(height-pheight)]);
676
+ }
677
+ });
678
+ calendar
679
+ .on('mousedown.xdsoft','td',function(){
680
+ var $this = $(this),
681
+ currentTime = datetimepicker.data('xdsoft_datetime').currentTime;
682
+ if( $this.hasClass('xdsoft_disabled') )
683
+ return false;
684
+ currentTime.setFullYear( $this.data('year') );
685
+ currentTime.setMonth( $this.data('month') );
686
+ currentTime.setDate( $this.data('date') );
687
+ datetimepicker.trigger('select.xdsoft',[currentTime]);
688
+
689
+ input.val( datetimepicker.data('xdsoft_datetime').str() );
690
+ if( (options.closeOnDateSelect===true||( options.closeOnDateSelect===0&&!options.timepicker ))&&!options.inline ){
691
+ datetimepicker.trigger('close.xdsoft');
692
+ }
693
+
694
+ if( options.onSelectDate && options.onSelectDate.call ){
695
+ options.onSelectDate.call(datetimepicker,datetimepicker.data('xdsoft_datetime').currentTime,datetimepicker.data('input'));
696
+ }
697
+
698
+ datetimepicker.trigger('xchange.xdsoft');
699
+ datetimepicker.trigger('changedatetime.xdsoft');
700
+ });
701
+
702
+ timebox
703
+ .on('mousedown.xdsoft','div',function(){
704
+ var $this = $(this),
705
+ currentTime = datetimepicker.data('xdsoft_datetime').currentTime;
706
+ if( $this.hasClass('xdsoft_disabled') )
707
+ return false;
708
+ currentTime.setHours($this.data('hour'));
709
+ currentTime.setMinutes($this.data('minute'));
710
+ datetimepicker.trigger('select.xdsoft',[currentTime]);
711
+
712
+ datetimepicker.data('input').val( datetimepicker.data('xdsoft_datetime').str() );
713
+
714
+ !options.inline&&datetimepicker.trigger('close.xdsoft');
715
+
716
+ if( options.onSelectTime&&options.onSelectTime.call ){
717
+ options.onSelectTime.call(datetimepicker,datetimepicker.data('xdsoft_datetime').currentTime,datetimepicker.data('input'));
718
+ }
719
+
720
+ datetimepicker.trigger('xchange.xdsoft');
721
+ datetimepicker.trigger('changedatetime.xdsoft');
722
+ });
723
+
724
+ datetimepicker.mousewheel&&datepicker.mousewheel(function(event, delta, deltaX, deltaY) {
725
+ if( !options.scrollMonth )
726
+ return true;
727
+ if( delta<0 )
728
+ datetimepicker.data('xdsoft_datetime').nextMonth();
729
+ else
730
+ datetimepicker.data('xdsoft_datetime').prevMonth();
731
+ return false;
732
+ });
733
+
734
+ datetimepicker.mousewheel&&timeboxparent.unmousewheel().mousewheel(function(event, delta, deltaX, deltaY) {
735
+ if( !options.scrollTime )
736
+ return true;
737
+ var pheight = timeboxparent[0].offsetHeight-2,
738
+ height = timebox[0].offsetHeight,
739
+ top = Math.abs(parseInt(timebox.css('marginTop'))),
740
+ fl = true;
741
+ if( delta<0 && (height-pheight)-options.timeHeightInTimePicker>=top ){
742
+ timebox.css('marginTop','-'+(top+options.timeHeightInTimePicker)+'px');
743
+ fl = false;
744
+ }else if( delta>0&&top-options.timeHeightInTimePicker>=0 ){
745
+ timebox.css('marginTop','-'+(top-options.timeHeightInTimePicker)+'px');
746
+ fl = false;
747
+ }
748
+ timeboxparent.trigger('scroll_element.xdsoft_scroller',[Math.abs(parseInt(timebox.css('marginTop'))/(height-pheight))]);
749
+ event.stopPropagation();
750
+ return fl;
751
+ });
752
+
753
+ datetimepicker
754
+ .on('changedatetime.xdsoft',function(){
755
+ if( options.onChangeDateTime&&options.onChangeDateTime.call )
756
+ options.onChangeDateTime.call(datetimepicker,datetimepicker.data('xdsoft_datetime').currentTime,datetimepicker.data('input'));
757
+ });
758
+
759
+ var current_time_index = 0;
760
+ input.mousewheel&&input.mousewheel(function( event, delta, deltaX, deltaY ){
761
+ if( !options.scrollInput )
762
+ return true;
763
+ if( !options.datepicker && options.timepicker ){
764
+ current_time_index = timebox.find('.xdsoft_current').length?timebox.find('.xdsoft_current').eq(0).index():0;
765
+ if( current_time_index+delta>=0&&current_time_index+delta<timebox.children().length )
766
+ current_time_index+=delta;
767
+ timebox.children().eq(current_time_index).length&&timebox.children().eq(current_time_index).trigger('mousedown');
768
+ return false;
769
+ }else if( options.datepicker && !options.timepicker ){
770
+ datepicker.trigger( event, [delta, deltaX, deltaY]);
771
+ input.val&&input.val( datetimepicker.data('xdsoft_datetime').str() );
772
+ datetimepicker.trigger('changedatetime.xdsoft');
773
+ return false;
774
+ }
775
+ });
776
+ var setPos = function(){
777
+ var offset = datetimepicker.data('input').offset(), top = offset.top+datetimepicker.data('input')[0].offsetHeight-1, left = offset.left;
778
+ if( top+datetimepicker[0].offsetHeight>$('body').height() )
779
+ top = offset.top-datetimepicker[0].offsetHeight+1;
780
+ if( left+datetimepicker[0].offsetWidth>$('body').width() )
781
+ left = offset.left-datetimepicker[0].offsetWidth+datetimepicker.data('input')[0].offsetWidth;
782
+ datetimepicker.css({
783
+ left:offset.left,
784
+ top:top
785
+ });
786
+ };
787
+ datetimepicker
788
+ .on('open.xdsoft', function(){
789
+ var onShow = true;
790
+ if( options.onShow&&options.onShow.call){
791
+ onShow = options.onShow.call(datetimepicker,datetimepicker.data('xdsoft_datetime').currentTime,datetimepicker.data('input'));
792
+ }
793
+ if( onShow!==false ){
794
+ datetimepicker.show();
795
+ datetimepicker.trigger('afterOpen.xdsoft');
796
+ setPos();
797
+ $(window)
798
+ .off('resize.xdsoft',setPos)
799
+ .on('resize.xdsoft',setPos);
800
+
801
+ if( options.closeOnWithoutClick ){
802
+ $([document.body,window]).on('mousedown.xdsoft',function(){
803
+ datetimepicker.trigger('close.xdsoft');
804
+ $([document.body,window]).off('mousedown.xdsoft',arguments.callee);
805
+ });
806
+ }
807
+ }
808
+ })
809
+ .on('close.xdsoft', function( event ){
810
+ var onClose = true;
811
+ if( options.onClose&&options.onClose.call ){
812
+ onClose=options.onClose.call(datetimepicker,datetimepicker.data('xdsoft_datetime').currentTime,datetimepicker.data('input'));
813
+ }
814
+ if( onClose!==false&&!options.opened&&!options.inline ){
815
+ datetimepicker.hide();
816
+ }
817
+ event.stopPropagation();
818
+ })
819
+ .data('input',input);
820
+
821
+ var _xdsoft_datetime = new XDSoftDateTime,
822
+ timer = 0,
823
+ timer1 = 0;
824
+
825
+ datetimepicker.data('xdsoft_datetime',_xdsoft_datetime);
826
+ datetimepicker.setOptions(options);
827
+ _xdsoft_datetime.setCurrentTime( options.value?options.value:(input&&input.val&&input.val())?input.val():new Date );
828
+
829
+ datetimepicker.trigger('afterOpen.xdsoft');
830
+
831
+ input
832
+ .data( 'xdsoft_datetimepicker',datetimepicker )
833
+ .on('open.xdsoft focusin.xdsoft mousedown.xdsoft',function(event){
834
+ if( input.is(':disabled')||input.is(':hidden')||!input.is(':visible') )
835
+ return;
836
+ clearTimeout(timer);
837
+ timer = setTimeout(function(){
838
+ if( input.is(':disabled')||input.is(':hidden')||!input.is(':visible') )
839
+ return;
840
+ _xdsoft_datetime.setCurrentTime((input&&input.val&&input.val())?input.val():new Date);
841
+ datetimepicker.trigger('open.xdsoft');
842
+ },100);
843
+ })
844
+ .on('focusout.xdsoft',function(event){
845
+ clearTimeout(timer1);
846
+ timer1 = setTimeout(function(){
847
+ datetimepicker.trigger('close.xdsoft');
848
+ },100);
849
+ });
850
+ },
851
+ destroyDateTimePicker = function( input ){
852
+ var datetimepicker = input.data('xdsoft_datetimepicker');
853
+ if( datetimepicker ){
854
+ var _xdsoft_datetime = datetimepicker.data('xdsoft_datetime');
855
+ delete _xdsoft_datetime;
856
+ datetimepicker.remove();
857
+ delete datetimepicker;
858
+ input
859
+ .data( 'xdsoft_datetimepicker',null )
860
+ .off( 'open.xdsoft focusin.xdsoft focusout.xdsoft mousedown.xdsoft blur.xdsoft' );
861
+ $(window).off('resize.xdsoft');
862
+ $([window,document.body]).off('mousedown.xdsoft');
863
+ input.unmousewheel&&input.unmousewheel();
864
+ delete options;
865
+ }
866
+ };
867
+ $(document)
868
+ .off('keydown.xdsoftctrl keyup.xdsoftctrl')
869
+ .on('keydown.xdsoftctrl',function(e){
870
+ if ( e.keyCode == CTRLKEY )
871
+ ctrlDown = true;
872
+ })
873
+ .on('keyup.xdsoftctrl',function(e){
874
+ if ( e.keyCode == CTRLKEY )
875
+ ctrlDown = false;
876
+ });
877
+ return this.each(function(){
878
+ var datetimepicker;
879
+ if( datetimepicker = $(this).data('xdsoft_datetimepicker') ){
880
+ if( $.type(opt) === 'string' ){
881
+ switch(opt){
882
+ case 'show':
883
+ $(this).select().focus();
884
+ datetimepicker.trigger( 'open.xdsoft' );
885
+ break;
886
+ case 'hide':
887
+ datetimepicker.trigger('close.xdsoft');
888
+ break;
889
+ case 'destroy':
890
+ destroyDateTimePicker($(this));
891
+ break;
892
+ }
893
+ }else{
894
+ datetimepicker
895
+ .setOptions(options);
896
+ }
897
+ return 0;
898
+ }else
899
+ ($.type(opt) !== 'string')&&createDateTimePicker($(this));
900
+ });
901
+ };
902
+ })( jQuery );
903
+
904
+ //http://www.xaprb.com/blog/2005/12/12/javascript-closures-for-runtime-efficiency/
905
+ /*
906
+ * Copyright (C) 2004 Baron Schwartz <baron at sequent dot org>
907
+ *
908
+ * This program is free software; you can redistribute it and/or modify it
909
+ * under the terms of the GNU Lesser General Public License as published by the
910
+ * Free Software Foundation, version 2.1.
911
+ *
912
+ * This program is distributed in the hope that it will be useful, but WITHOUT
913
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
914
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
915
+ * details.
916
+ */
917
+ Date.parseFunctions={count:0};Date.parseRegexes=[];Date.formatFunctions={count:0};Date.prototype.dateFormat=function(format){if(Date.formatFunctions[format]==null){Date.createNewFormat(format)}var func=Date.formatFunctions[format];return this[func]()};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(character){switch(character){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(character)+"' + "}};Date.parseDate=function(input,format){if(Date.parseFunctions[format]==null){Date.createParser(format)}var func=Date.parseFunctions[format];return Date[func](input)};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){\n"+"var y = -1, m = -1, d = -1, h = -1, i = -1, s = -1;\n"+"var d = new Date();\n"+"y = d.getFullYear();\n"+"m = d.getMonth();\n"+"d = d.getDate();\n"+"var results = input.match(Date.parseRegexes["+regexNum+"]);\n"+"if (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 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n"+"{return new Date(y, m, d, h, i, s);}\n"+"else if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n"+"{return new Date(y, m, d, h, i);}\n"+"else if (y > 0 && m >= 0 && d > 0 && h >= 0)\n"+"{return new Date(y, m, d, h);}\n"+"else if (y > 0 && m >= 0 && d > 0)\n"+"{return new Date(y, m, d);}\n"+"else if (y > 0 && m >= 0)\n"+"{return new Date(y, m);}\n"+"else if (y > 0)\n"+"{return new Date(y);}\n"+"}return null;}";Date.parseRegexes[regexNum]=new RegExp("^"+regex+"$");eval(code)};Date.formatCodeToRegex=function(character,currentGroup){switch(character){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["+currentGroup+"], 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:0,c:null,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["+currentGroup+"].substring(0, 3)], 10);\n",s:"("+Date.monthNames.join("|")+")"};case"M":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+currentGroup+"]], 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["+currentGroup+"], 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["+currentGroup+"], 10);\n",s:"(\\d{4})"};case"y":return{g:1,c:"var ty = parseInt(results["+currentGroup+"], 10);\n"+"y = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",s:"(\\d{1,2})"};case"a":return{g:1,c:"if (results["+currentGroup+"] == 'am') {\n"+"if (h == 12) { h = 0; }\n"+"} else { if (h < 12) { h += 12; }}",s:"(am|pm)"};case"A":return{g:1,c:"if (results["+currentGroup+"] == 'AM') {\n"+"if (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["+currentGroup+"], 10);\n",s:"(\\d{1,2})"};case"i":return{g:1,c:"i = parseInt(results["+currentGroup+"], 10);\n",s:"(\\d{2})"};case"s":return{g:1,c:"s = parseInt(results["+currentGroup+"], 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(character)}}};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(this.getTimezoneOffset()/60),2,"0")+String.leftPad(this.getTimezoneOffset()%60,2,"0")};Date.prototype.getDayOfYear=function(){var num=0;Date.daysInMonth[1]=this.isLeapYear()?29:28;for(var i=0;i<this.getMonth();++i){num+=Date.daysInMonth[i]}return num+this.getDate()-1};Date.prototype.getWeekOfYear=function(){var now=this.getDayOfYear()+(4-this.getDay());var jan1=new Date(this.getFullYear(),0,1);var then=(7-jan1.getDay()+4);document.write(then);return String.leftPad(((now-then)/7)+1,2,"0")};Date.prototype.isLeapYear=function(){var year=this.getFullYear();return((year&3)==0&&(year%100||(year%400==0&&year)))};Date.prototype.getFirstDayOfMonth=function(){var day=(this.getDay()-(this.getDate()-1))%7;return(day<0)?(day+7):day};Date.prototype.getLastDayOfMonth=function(){var day=(this.getDay()+(Date.daysInMonth[this.getMonth()]-this.getDate()))%7;return(day<0)?(day+7):day};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(string){return string.replace(/('|\\)/g,"\\$1")};String.leftPad=function(val,size,ch){var result=new String(val);if(ch==null){ch=" "}while(result.length<size){result=ch+result}return result};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"};
918
+
919
+ //https://github.com/brandonaaron/jquery-mousewheel/blob/master/jquery.mousewheel.js
920
+ /*
921
+ * Copyright (c) 2013 Brandon Aaron (http://brandonaaron.net)
922
+ *
923
+ * Licensed under the MIT License (LICENSE.txt).
924
+ *
925
+ * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
926
+ * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
927
+ * Thanks to: Seamus Leahy for adding deltaX and deltaY
928
+ *
929
+ * Version: 3.1.3
930
+ *
931
+ * Requires: 1.2.2+
932
+ */
933
+ (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)}}));