ffoundation_datepicker_rails 0.0.2

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: 31f17cf74b1ac08aea9918ee5168a7b59d4cccb7
4
+ data.tar.gz: 34ac7d25e3451647906d0138bb7fdfa41fbc0eee
5
+ SHA512:
6
+ metadata.gz: d837e68a95fb4468892f26eb06190c56fa147dc7f67c61d57b051b60737abde3b256ebec6f0828f7f0cfac676746ad777b64241a25683d0fa9337bf9129057c4
7
+ data.tar.gz: bf95775a35bfff54bc4fa418bdfdddcbd63f31819953ceb483282ef6e65a2a060076df5d03a3616b35a3d40ed4b5ace1f82079988e525803e17cb594bb7f0729
data/MIT-LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Aliaksandr Buhayeu
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,52 @@
1
+ # FoundationDatepickerRails
2
+
3
+ Packed actual version of `foundation-datepicker` plugin for Rails 3.1+ asset pipeline.
4
+
5
+ Actual javascript plugin belongs to 'najlepsiwebdesigner' and could be found
6
+ at appropriate GitHub repo: https://github.com/najlepsiwebdesigner/foundation-datepicker
7
+
8
+ ## Installation
9
+
10
+ To work properly, this gem does require `Zurb Foundation` css and javascripts included.
11
+
12
+ But this original plugin dependency of `Zurb icon fonts` was removed by inluding small custom
13
+ font with an icons required.
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'ffoundation_datepicker_rails'
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ $ bundle
24
+
25
+ Or install it yourself as:
26
+
27
+ $ gem install ffoundation_datepicker_rails
28
+
29
+ ## Usage
30
+ Add this line into your `application.js` manifest file:
31
+ ```
32
+ //= require foundation-datepicker-rails
33
+ ```
34
+
35
+ And this one to your `application.css.scss` file:
36
+
37
+ ```
38
+ @import "foundation-datepicker-rails";
39
+ ```
40
+
41
+ Restart the application and you are done!
42
+
43
+ ## Contributing
44
+
45
+ 1. Fork it ( https://github.com/aliaksandrb/foundation_datepicker_rails/fork )
46
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
47
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
48
+ 4. Push to the branch (`git push origin my-new-feature`)
49
+ 5. Create a new Pull Request
50
+
51
+ ## License
52
+ MIT
@@ -0,0 +1,6 @@
1
+ require "foundation_datepicker_rails/version"
2
+
3
+ module FoundationDatepickerRails
4
+ class Engine < ::Rails::Engine
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module FoundationDatepickerRails
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
+ <svg xmlns="http://www.w3.org/2000/svg">
4
+ <metadata>Generated by Fontastic.me</metadata>
5
+ <defs>
6
+ <font id="foundation-datepicker-rails" horiz-adv-x="512">
7
+ <font-face font-family="foundation-datepicker-rails" units-per-em="512" ascent="480" descent="-32"/>
8
+ <missing-glyph horiz-adv-x="512" />
9
+
10
+ <glyph glyph-name="fi-arrow-left" unicode="&#97;" d="M252 399l-187-133c-3-2-5-6-5-10 0 0 0 0 0 0 0-5 2-9 5-11l187-132c4-3 9-4 13-1 4 2 7 6 7 11l0 62 167 0c8 0 13 6 13 13l0 116c0 7-5 13-13 13l-167 0 0 62c0 5-3 9-7 11-4 3-10 2-13-1z"/>
11
+ <glyph glyph-name="fi-x" unicode="&#98;" d="M434 160l-96 96 96 96c4 4 4 10 0 14l-68 68c-4 4-10 4-14 0l-96-96-96 96c-4 4-11 4-14 0l-68-68c-2-1-3-4-3-7 0-2 1-5 3-7l96-96-96-96c-2-2-3-5-3-7 0-3 1-6 3-7l68-68c1-2 4-3 7-3 2 0 5 1 7 3l96 96 96-96c2-2 5-3 7-3 3 0 5 1 7 3l68 68c4 4 4 10 0 14z"/>
12
+ <glyph glyph-name="fi-arrow-right" unicode="&#99;" d="M260 113l187 133c3 2 5 6 5 10 0 0 0 0 0 0 0 5-2 9-5 11l-187 132c-4 3-9 4-13 1-4-2-7-6-7-11l0-62-167 0c-8 0-13-6-13-13l0-116c0-7 5-13 13-13l167 0 0-62c0-5 3-9 7-11 4-3 10-2 13 1z"/>
13
+ </font></defs></svg>
@@ -0,0 +1,1202 @@
1
+ /* =========================================================
2
+ * foundation-datepicker.js
3
+ * Copyright 2015 Peter Beno, najlepsiwebdesigner@gmail.com, @benopeter
4
+ * project website http://foundation-datepicker.peterbeno.com
5
+ * ========================================================= */
6
+
7
+ !function( $ ) {
8
+
9
+ function UTCDate(){
10
+ return new Date(Date.UTC.apply(Date, arguments));
11
+ }
12
+ function UTCToday(){
13
+ var today = new Date();
14
+ return UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
15
+ }
16
+
17
+ // Picker object
18
+
19
+ var Datepicker = function(element, options) {
20
+ var that = this;
21
+
22
+ this.element = $(element);
23
+ this.autoShow = options.autoShow || true;
24
+ this.appendTo = options.appendTo || 'body';
25
+ this.closeButton = options.closeButton;
26
+ this.language = options.language||this.element.data('date-language')||"en";
27
+ this.language = this.language in dates ? this.language : this.language.split('-')[0]; //Check if "de-DE" style date is available, if not language should fallback to 2 letter code eg "de"
28
+ this.language = this.language in dates ? this.language : "en";
29
+ this.isRTL = dates[this.language].rtl||false;
30
+ this.format = DPGlobal.parseFormat(options.format||this.element.data('date-format')||dates[this.language].format||'mm/dd/yyyy');
31
+ this.isInline = false;
32
+ this.isInput = this.element.is('input');
33
+ this.component = this.element.is('.date') ? this.element.find('.prefix, .postfix') : false;
34
+ this.hasInput = this.component && this.element.find('input').length;
35
+ this.disableDblClickSelection = options.disableDblClickSelection;
36
+
37
+
38
+ this.onRender = options.onRender || function () {};
39
+ if(this.component && this.component.length === 0)
40
+ this.component = false;
41
+
42
+ this._attachEvents();
43
+
44
+ this.forceParse = true;
45
+ if ('forceParse' in options) {
46
+ this.forceParse = options.forceParse;
47
+ } else if ('dateForceParse' in this.element.data()) {
48
+ this.forceParse = this.element.data('date-force-parse');
49
+ }
50
+
51
+
52
+ this.picker = $(DPGlobal.template)
53
+ .appendTo(this.isInline ? this.element : this.appendTo)
54
+ .on({
55
+ click: $.proxy(this.click, this),
56
+ mousedown: $.proxy(this.mousedown, this)
57
+ });
58
+ if (this.closeButton){
59
+ this.picker.find('a.datepicker-close').show();
60
+ } else {
61
+ this.picker.find('a.datepicker-close').hide();
62
+ }
63
+
64
+ if(this.isInline) {
65
+ this.picker.addClass('datepicker-inline');
66
+ } else {
67
+ this.picker.addClass('datepicker-dropdown dropdown-menu');
68
+ }
69
+ if (this.isRTL){
70
+ this.picker.addClass('datepicker-rtl');
71
+ this.picker.find('.prev i, .next i')
72
+ .toggleClass('fa fa-chevron-left fa-chevron-right').toggleClass('fa-chevron-left fa-chevron-right');
73
+ }
74
+ $(document).on('mousedown', function (e) {
75
+ // Clicked outside the datepicker, hide it
76
+ if ($(e.target).closest('.datepicker.datepicker-inline, .datepicker.datepicker-dropdown').length === 0) {
77
+ that.hide();
78
+ }
79
+ });
80
+
81
+ this.autoclose = true;
82
+ if ('autoclose' in options) {
83
+ this.autoclose = options.autoclose;
84
+ } else if ('dateAutoclose' in this.element.data()) {
85
+ this.autoclose = this.element.data('date-autoclose');
86
+ }
87
+
88
+ this.keyboardNavigation = true;
89
+ if ('keyboardNavigation' in options) {
90
+ this.keyboardNavigation = options.keyboardNavigation;
91
+ } else if ('dateKeyboardNavigation' in this.element.data()) {
92
+ this.keyboardNavigation = this.element.data('date-keyboard-navigation');
93
+ }
94
+
95
+ this.viewMode = this.startViewMode = 0;
96
+ switch(options.startView || this.element.data('date-start-view')){
97
+ case 2:
98
+ case 'decade':
99
+ this.viewMode = this.startViewMode = 2;
100
+ break;
101
+ case 1:
102
+ case 'year':
103
+ this.viewMode = this.startViewMode = 1;
104
+ break;
105
+ }
106
+
107
+ this.todayBtn = (options.todayBtn||this.element.data('date-today-btn')||false);
108
+ this.todayHighlight = (options.todayHighlight||this.element.data('date-today-highlight')||false);
109
+
110
+ this.calendarWeeks = false;
111
+ if ('calendarWeeks' in options) {
112
+ this.calendarWeeks = options.calendarWeeks;
113
+ } else if ('dateCalendarWeeks' in this.element.data()) {
114
+ this.calendarWeeks = this.element.data('date-calendar-weeks');
115
+ }
116
+ if (this.calendarWeeks)
117
+ this.picker.find('tfoot th.today')
118
+ .attr('colspan', function(i, val){
119
+ return parseInt(val) + 1;
120
+ });
121
+
122
+ this.weekStart = ((options.weekStart||this.element.data('date-weekstart')||dates[this.language].weekStart||0) % 7);
123
+ this.weekEnd = ((this.weekStart + 6) % 7);
124
+ this.startDate = -Infinity;
125
+ this.endDate = Infinity;
126
+ this.daysOfWeekDisabled = [];
127
+ this.setStartDate(options.startDate||this.element.data('date-startdate'));
128
+ this.setEndDate(options.endDate||this.element.data('date-enddate'));
129
+ this.setDaysOfWeekDisabled(options.daysOfWeekDisabled||this.element.data('date-days-of-week-disabled'));
130
+
131
+ this.fillDow();
132
+ this.fillMonths();
133
+ this.update();
134
+ this.showMode();
135
+
136
+ if(this.isInline) {
137
+ this.show();
138
+ }
139
+ };
140
+
141
+ Datepicker.prototype = {
142
+ constructor: Datepicker,
143
+
144
+ _events: [],
145
+ _attachEvents: function(){
146
+ this._detachEvents();
147
+ if (this.isInput) { // single input
148
+ this._events = [
149
+ [this.element, {
150
+ focus: (this.autoShow)? $.proxy(this.show, this):function(){},
151
+ keyup: $.proxy(this.update, this),
152
+ keydown: $.proxy(this.keydown, this)
153
+ }]
154
+ ];
155
+ }
156
+ else if (this.component && this.hasInput){ // component: input + button
157
+ this._events = [
158
+ // For components that are not readonly, allow keyboard nav
159
+ [this.element.find('input'), {
160
+ focus: (this.autoShow)? $.proxy(this.show, this):function(){},
161
+ keyup: $.proxy(this.update, this),
162
+ keydown: $.proxy(this.keydown, this)
163
+ }],
164
+ [this.component, {
165
+ click: $.proxy(this.show, this)
166
+ }]
167
+ ];
168
+ }
169
+ else if (this.element.is('div')) { // inline datepicker
170
+ this.isInline = true;
171
+ }
172
+ else {
173
+ this._events = [
174
+ [this.element, {
175
+ click: $.proxy(this.show, this)
176
+ }]
177
+ ];
178
+ }
179
+
180
+ if (this.disableDblClickSelection) {
181
+ this._events[this._events.length] = [
182
+ this.element, {
183
+ dblclick: function (e) {
184
+ e.preventDefault();
185
+ e.stopPropagation();
186
+ $(this).blur()
187
+ }
188
+ }
189
+ ];
190
+ }
191
+
192
+ for (var i=0, el, ev; i<this._events.length; i++){
193
+ el = this._events[i][0];
194
+ ev = this._events[i][1];
195
+ el.on(ev);
196
+ }
197
+ },
198
+ _detachEvents: function(){
199
+ for (var i=0, el, ev; i<this._events.length; i++){
200
+ el = this._events[i][0];
201
+ ev = this._events[i][1];
202
+ el.off(ev);
203
+ }
204
+ this._events = [];
205
+ },
206
+
207
+ show: function(e) {
208
+ this.picker.show();
209
+ this.height = this.component ? this.component.outerHeight() : this.element.outerHeight();
210
+ this.update();
211
+ this.place();
212
+ $(window).on('resize', $.proxy(this.place, this));
213
+ if (e ) {
214
+ e.stopPropagation();
215
+ e.preventDefault();
216
+ }
217
+ this.element.trigger({
218
+ type: 'show',
219
+ date: this.date
220
+ });
221
+ },
222
+
223
+ hide: function(e){
224
+ if(this.isInline) return;
225
+ if (!this.picker.is(':visible')) return;
226
+ this.picker.hide();
227
+ $(window).off('resize', this.place);
228
+ this.viewMode = this.startViewMode;
229
+ this.showMode();
230
+ if (!this.isInput) {
231
+ $(document).off('mousedown', this.hide);
232
+ }
233
+
234
+ if (
235
+ this.forceParse &&
236
+ (
237
+ this.isInput && this.element.val() ||
238
+ this.hasInput && this.element.find('input').val()
239
+ )
240
+ )
241
+ this.setValue();
242
+ this.element.trigger({
243
+ type: 'hide',
244
+ date: this.date
245
+ });
246
+ },
247
+
248
+ remove: function() {
249
+ this._detachEvents();
250
+ this.picker.remove();
251
+ delete this.element.data().datepicker;
252
+ },
253
+
254
+ getDate: function() {
255
+ var d = this.getUTCDate();
256
+ return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
257
+ },
258
+
259
+ getUTCDate: function() {
260
+ return this.date;
261
+ },
262
+
263
+ setDate: function(d) {
264
+ this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
265
+ },
266
+
267
+ setUTCDate: function(d) {
268
+ this.date = d;
269
+ this.setValue();
270
+ },
271
+
272
+ setValue: function() {
273
+ var formatted = this.getFormattedDate();
274
+ if (!this.isInput) {
275
+ if (this.component){
276
+ this.element.find('input').val(formatted);
277
+ }
278
+ this.element.data('date', formatted);
279
+ } else {
280
+ this.element.val(formatted);
281
+ }
282
+ },
283
+
284
+ getFormattedDate: function(format) {
285
+ if (format === undefined)
286
+ format = this.format;
287
+ return DPGlobal.formatDate(this.date, format, this.language);
288
+ },
289
+
290
+ setStartDate: function(startDate){
291
+ this.startDate = startDate||-Infinity;
292
+ if (this.startDate !== -Infinity) {
293
+ this.startDate = DPGlobal.parseDate(this.startDate, this.format, this.language);
294
+ }
295
+ this.update();
296
+ this.updateNavArrows();
297
+ },
298
+
299
+ setEndDate: function(endDate){
300
+ this.endDate = endDate||Infinity;
301
+ if (this.endDate !== Infinity) {
302
+ this.endDate = DPGlobal.parseDate(this.endDate, this.format, this.language);
303
+ }
304
+ this.update();
305
+ this.updateNavArrows();
306
+ },
307
+
308
+ setDaysOfWeekDisabled: function(daysOfWeekDisabled){
309
+ this.daysOfWeekDisabled = daysOfWeekDisabled||[];
310
+ if (!$.isArray(this.daysOfWeekDisabled)) {
311
+ this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
312
+ }
313
+ this.daysOfWeekDisabled = $.map(this.daysOfWeekDisabled, function (d) {
314
+ return parseInt(d, 10);
315
+ });
316
+ this.update();
317
+ this.updateNavArrows();
318
+ },
319
+
320
+ place: function(){
321
+ if(this.isInline) return;
322
+ var zIndex = parseInt(this.element.parents().filter(function() {
323
+ return $(this).css('z-index') != 'auto';
324
+ }).first().css('z-index'))+10;
325
+ var textbox = this.component ? this.component : this.element;
326
+ var offset = textbox.offset();
327
+ var height = textbox.outerHeight() + parseInt(textbox.css('margin-top'));
328
+ var width = textbox.outerWidth() + parseInt(textbox.css('margin-left'));
329
+ var fullOffsetTop = offset.top + height;
330
+ var offsetLeft = offset.left;
331
+ // if the datepicker is going to be below the window, show it on top of the input
332
+ if((fullOffsetTop + this.picker.outerHeight()) >= $(window).scrollTop() + $(window).height()){
333
+ fullOffsetTop = offset.top - this.picker.outerHeight();
334
+ }
335
+
336
+ // if the datepicker is going to go past the right side of the window, we want
337
+ // to set the right position so the datepicker lines up with the textbox
338
+ if(offset.left + this.picker.width() >= $(window).width()){
339
+ offsetLeft = (offset.left + width) - this.picker.width();
340
+ }
341
+ this.picker.css({
342
+ top: fullOffsetTop,
343
+ left: offsetLeft,
344
+ zIndex: zIndex
345
+ });
346
+ },
347
+
348
+ update: function(){
349
+ var date, fromArgs = false;
350
+ if(arguments && arguments.length && (typeof arguments[0] === 'string' || arguments[0] instanceof Date)) {
351
+ date = arguments[0];
352
+ fromArgs = true;
353
+ } else {
354
+ date = this.isInput ? this.element.val() : this.element.data('date') || this.element.find('input').val();
355
+ }
356
+
357
+ this.date = DPGlobal.parseDate(date, this.format, this.language);
358
+
359
+ if(fromArgs) this.setValue();
360
+
361
+ if (this.date < this.startDate) {
362
+ this.viewDate = new Date(this.startDate.valueOf());
363
+ } else if (this.date > this.endDate) {
364
+ this.viewDate = new Date(this.endDate.valueOf());
365
+ } else {
366
+ this.viewDate = new Date(this.date.valueOf());
367
+ }
368
+ this.fill();
369
+ },
370
+
371
+ fillDow: function(){
372
+ var dowCnt = this.weekStart,
373
+ html = '<tr>';
374
+ if(this.calendarWeeks){
375
+ var cell = '<th class="cw">&nbsp;</th>';
376
+ html += cell;
377
+ this.picker.find('.datepicker-days thead tr:first-child').prepend(cell);
378
+ }
379
+ while (dowCnt < this.weekStart + 7) {
380
+ html += '<th class="dow">'+dates[this.language].daysMin[(dowCnt++)%7]+'</th>';
381
+ }
382
+ html += '</tr>';
383
+ this.picker.find('.datepicker-days thead').append(html);
384
+ },
385
+
386
+ fillMonths: function(){
387
+ var html = '',
388
+ i = 0;
389
+ while (i < 12) {
390
+ html += '<span class="month">'+dates[this.language].monthsShort[i++]+'</span>';
391
+ }
392
+ this.picker.find('.datepicker-months td').html(html);
393
+ },
394
+
395
+ fill: function() {
396
+ var d = new Date(this.viewDate.valueOf()),
397
+ year = d.getUTCFullYear(),
398
+ month = d.getUTCMonth(),
399
+ startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
400
+ startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
401
+ endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
402
+ endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
403
+ currentDate = this.date && this.date.valueOf(),
404
+ today = new Date(),
405
+ titleFormat = dates[this.language].titleFormat || dates['en'].titleFormat;
406
+ this.picker.find('.datepicker-days thead th.date-switch')
407
+ .text(DPGlobal.formatDate(new UTCDate(year, month), titleFormat, this.language));
408
+ this.picker.find('tfoot th.today')
409
+ .text(dates[this.language].today)
410
+ .toggle(this.todayBtn !== false);
411
+ this.updateNavArrows();
412
+ this.fillMonths();
413
+ var prevMonth = UTCDate(year, month-1, 28,0,0,0,0),
414
+ day = DPGlobal.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
415
+ prevMonth.setUTCDate(day);
416
+ prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
417
+ var nextMonth = new Date(prevMonth.valueOf());
418
+ nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
419
+ nextMonth = nextMonth.valueOf();
420
+ var html = [];
421
+ var clsName;
422
+ while(prevMonth.valueOf() < nextMonth) {
423
+ if (prevMonth.getUTCDay() == this.weekStart) {
424
+ html.push('<tr>');
425
+ if(this.calendarWeeks){
426
+ // adapted from https://github.com/timrwood/moment/blob/master/moment.js#L128
427
+ var a = new Date(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth(), prevMonth.getUTCDate() - prevMonth.getDay() + 10 - (this.weekStart && this.weekStart%7 < 5 && 7)),
428
+ b = new Date(a.getFullYear(), 0, 4),
429
+ calWeek = ~~((a - b) / 864e5 / 7 + 1.5);
430
+ html.push('<td class="cw">'+ calWeek +'</td>');
431
+ }
432
+ }
433
+ clsName = ' '+this.onRender(prevMonth)+' ';
434
+ if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
435
+ clsName += ' old';
436
+ } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
437
+ clsName += ' new';
438
+ }
439
+ // Compare internal UTC date with local today, not UTC today
440
+ if (this.todayHighlight &&
441
+ prevMonth.getUTCFullYear() == today.getFullYear() &&
442
+ prevMonth.getUTCMonth() == today.getMonth() &&
443
+ prevMonth.getUTCDate() == today.getDate()) {
444
+ clsName += ' today';
445
+ }
446
+ if (currentDate && prevMonth.valueOf() == currentDate) {
447
+ clsName += ' active';
448
+ }
449
+ if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
450
+ $.inArray(prevMonth.getUTCDay(), this.daysOfWeekDisabled) !== -1) {
451
+ clsName += ' disabled';
452
+ }
453
+ html.push('<td class="day'+clsName+'">'+prevMonth.getUTCDate() + '</td>');
454
+ if (prevMonth.getUTCDay() == this.weekEnd) {
455
+ html.push('</tr>');
456
+ }
457
+ prevMonth.setUTCDate(prevMonth.getUTCDate()+1);
458
+ }
459
+ this.picker.find('.datepicker-days tbody').empty().append(html.join(''));
460
+ var currentYear = this.date && this.date.getUTCFullYear();
461
+
462
+ var months = this.picker.find('.datepicker-months')
463
+ .find('th:eq(1)')
464
+ .text(year)
465
+ .end()
466
+ .find('span').removeClass('active');
467
+ if (currentYear && currentYear == year) {
468
+ months.eq(this.date.getUTCMonth()).addClass('active');
469
+ }
470
+ if (year < startYear || year > endYear) {
471
+ months.addClass('disabled');
472
+ }
473
+ if (year == startYear) {
474
+ months.slice(0, startMonth).addClass('disabled');
475
+ }
476
+ if (year == endYear) {
477
+ months.slice(endMonth+1).addClass('disabled');
478
+ }
479
+
480
+ html = '';
481
+ year = parseInt(year/10, 10) * 10;
482
+ var yearCont = this.picker.find('.datepicker-years')
483
+ .find('th:eq(1)')
484
+ .text(year + '-' + (year + 9))
485
+ .end()
486
+ .find('td');
487
+ year -= 1;
488
+ for (var i = -1; i < 11; i++) {
489
+ html += '<span class="year'+(i == -1 || i == 10 ? ' old' : '')+(currentYear == year ? ' active' : '')+(year < startYear || year > endYear ? ' disabled' : '')+'">'+year+'</span>';
490
+ year += 1;
491
+ }
492
+ yearCont.html(html);
493
+ },
494
+
495
+ updateNavArrows: function() {
496
+ var d = new Date(this.viewDate.valueOf()),
497
+ year = d.getUTCFullYear(),
498
+ month = d.getUTCMonth();
499
+ switch (this.viewMode) {
500
+ case 0:
501
+ if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
502
+ this.picker.find('.prev').css({visibility: 'hidden'});
503
+ } else {
504
+ this.picker.find('.prev').css({visibility: 'visible'});
505
+ }
506
+ if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
507
+ this.picker.find('.next').css({visibility: 'hidden'});
508
+ } else {
509
+ this.picker.find('.next').css({visibility: 'visible'});
510
+ }
511
+ break;
512
+ case 1:
513
+ case 2:
514
+ if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
515
+ this.picker.find('.prev').css({visibility: 'hidden'});
516
+ } else {
517
+ this.picker.find('.prev').css({visibility: 'visible'});
518
+ }
519
+ if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
520
+ this.picker.find('.next').css({visibility: 'hidden'});
521
+ } else {
522
+ this.picker.find('.next').css({visibility: 'visible'});
523
+ }
524
+ break;
525
+ }
526
+ },
527
+
528
+ click: function(e) {
529
+ e.stopPropagation();
530
+ e.preventDefault();
531
+
532
+ if ($(e.target).hasClass('datepicker-close') || $(e.target).parent().hasClass('datepicker-close')){
533
+ this.hide();
534
+ }
535
+
536
+ var target = $(e.target).closest('span, td, th');
537
+ if (target.length == 1) {
538
+ switch(target[0].nodeName.toLowerCase()) {
539
+ case 'th':
540
+ switch(target[0].className) {
541
+ case 'date-switch':
542
+ this.showMode(1);
543
+ break;
544
+ case 'prev':
545
+ case 'next':
546
+ var dir = DPGlobal.modes[this.viewMode].navStep * (target[0].className == 'prev' ? -1 : 1);
547
+ switch(this.viewMode){
548
+ case 0:
549
+ this.viewDate = this.moveMonth(this.viewDate, dir);
550
+ break;
551
+ case 1:
552
+ case 2:
553
+ this.viewDate = this.moveYear(this.viewDate, dir);
554
+ break;
555
+ }
556
+ this.fill();
557
+ break;
558
+ case 'today':
559
+ var date = new Date();
560
+ date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
561
+
562
+ this.showMode(-2);
563
+ var which = this.todayBtn == 'linked' ? null : 'view';
564
+ this._setDate(date, which);
565
+ break;
566
+ }
567
+ break;
568
+ case 'span':
569
+ if (!target.is('.disabled')) {
570
+ this.viewDate.setUTCDate(1);
571
+ if (target.is('.month')) {
572
+ var month = target.parent().find('span').index(target);
573
+ this.viewDate.setUTCMonth(month);
574
+ this.element.trigger({
575
+ type: 'changeMonth',
576
+ date: this.viewDate
577
+ });
578
+ } else {
579
+ var year = parseInt(target.text(), 10)||0;
580
+ this.viewDate.setUTCFullYear(year);
581
+ this.element.trigger({
582
+ type: 'changeYear',
583
+ date: this.viewDate
584
+ });
585
+ }
586
+ this.showMode(-1);
587
+ this.fill();
588
+ }
589
+ break;
590
+ case 'td':
591
+ if (target.is('.day') && !target.is('.disabled')){
592
+ var day = parseInt(target.text(), 10)||1;
593
+ var year = this.viewDate.getUTCFullYear(),
594
+ month = this.viewDate.getUTCMonth();
595
+ if (target.is('.old')) {
596
+ if (month === 0) {
597
+ month = 11;
598
+ year -= 1;
599
+ } else {
600
+ month -= 1;
601
+ }
602
+ } else if (target.is('.new')) {
603
+ if (month == 11) {
604
+ month = 0;
605
+ year += 1;
606
+ } else {
607
+ month += 1;
608
+ }
609
+ }
610
+ this._setDate(UTCDate(year, month, day,0,0,0,0));
611
+ }
612
+ break;
613
+ }
614
+ }
615
+ },
616
+
617
+ _setDate: function(date, which){
618
+ if (!which || which == 'date')
619
+ this.date = date;
620
+ if (!which || which == 'view')
621
+ this.viewDate = date;
622
+ this.fill();
623
+ this.setValue();
624
+ this.element.trigger({
625
+ type: 'changeDate',
626
+ date: this.date
627
+ });
628
+ var element;
629
+ if (this.isInput) {
630
+ element = this.element;
631
+ } else if (this.component){
632
+ element = this.element.find('input');
633
+ }
634
+ if (element) {
635
+ element.change();
636
+ if (this.autoclose && (!which || which == 'date')) {
637
+ this.hide();
638
+ }
639
+ }
640
+ },
641
+
642
+ moveMonth: function(date, dir){
643
+ if (!dir) return date;
644
+ var new_date = new Date(date.valueOf()),
645
+ day = new_date.getUTCDate(),
646
+ month = new_date.getUTCMonth(),
647
+ mag = Math.abs(dir),
648
+ new_month, test;
649
+ dir = dir > 0 ? 1 : -1;
650
+ if (mag == 1){
651
+ test = dir == -1
652
+ // If going back one month, make sure month is not current month
653
+ // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
654
+ ? function(){ return new_date.getUTCMonth() == month; }
655
+ // If going forward one month, make sure month is as expected
656
+ // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
657
+ : function(){ return new_date.getUTCMonth() != new_month; };
658
+ new_month = month + dir;
659
+ new_date.setUTCMonth(new_month);
660
+ // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
661
+ if (new_month < 0 || new_month > 11)
662
+ new_month = (new_month + 12) % 12;
663
+ } else {
664
+ // For magnitudes >1, move one month at a time...
665
+ for (var i=0; i<mag; i++)
666
+ // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
667
+ new_date = this.moveMonth(new_date, dir);
668
+ // ...then reset the day, keeping it in the new month
669
+ new_month = new_date.getUTCMonth();
670
+ new_date.setUTCDate(day);
671
+ test = function(){ return new_month != new_date.getUTCMonth(); };
672
+ }
673
+ // Common date-resetting loop -- if date is beyond end of month, make it
674
+ // end of month
675
+ while (test()){
676
+ new_date.setUTCDate(--day);
677
+ new_date.setUTCMonth(new_month);
678
+ }
679
+ return new_date;
680
+ },
681
+
682
+ moveYear: function(date, dir){
683
+ return this.moveMonth(date, dir*12);
684
+ },
685
+
686
+ dateWithinRange: function(date){
687
+ return date >= this.startDate && date <= this.endDate;
688
+ },
689
+
690
+ keydown: function(e){
691
+ if (this.picker.is(':not(:visible)')){
692
+ if (e.keyCode == 27) // allow escape to hide and re-show picker
693
+ this.show();
694
+ return;
695
+ }
696
+ var dateChanged = false,
697
+ dir, day, month,
698
+ newDate, newViewDate;
699
+ switch(e.keyCode){
700
+ case 27: // escape
701
+ this.hide();
702
+ e.preventDefault();
703
+ break;
704
+ case 37: // left
705
+ case 39: // right
706
+ if (!this.keyboardNavigation) break;
707
+ dir = e.keyCode == 37 ? -1 : 1;
708
+ if (e.ctrlKey){
709
+ newDate = this.moveYear(this.date, dir);
710
+ newViewDate = this.moveYear(this.viewDate, dir);
711
+ } else if (e.shiftKey){
712
+ newDate = this.moveMonth(this.date, dir);
713
+ newViewDate = this.moveMonth(this.viewDate, dir);
714
+ } else {
715
+ newDate = new Date(this.date.valueOf());
716
+ newDate.setUTCDate(this.date.getUTCDate() + dir);
717
+ newViewDate = new Date(this.viewDate.valueOf());
718
+ newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
719
+ }
720
+ if (this.dateWithinRange(newDate)){
721
+ this.date = newDate;
722
+ this.viewDate = newViewDate;
723
+ this.setValue();
724
+ this.update();
725
+ e.preventDefault();
726
+ dateChanged = true;
727
+ }
728
+ break;
729
+ case 38: // up
730
+ case 40: // down
731
+ if (!this.keyboardNavigation) break;
732
+ dir = e.keyCode == 38 ? -1 : 1;
733
+ if (e.ctrlKey){
734
+ newDate = this.moveYear(this.date, dir);
735
+ newViewDate = this.moveYear(this.viewDate, dir);
736
+ } else if (e.shiftKey){
737
+ newDate = this.moveMonth(this.date, dir);
738
+ newViewDate = this.moveMonth(this.viewDate, dir);
739
+ } else {
740
+ newDate = new Date(this.date.valueOf());
741
+ newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
742
+ newViewDate = new Date(this.viewDate.valueOf());
743
+ newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
744
+ }
745
+ if (this.dateWithinRange(newDate)){
746
+ this.date = newDate;
747
+ this.viewDate = newViewDate;
748
+ this.setValue();
749
+ this.update();
750
+ e.preventDefault();
751
+ dateChanged = true;
752
+ }
753
+ break;
754
+ case 13: // enter
755
+ this.hide();
756
+ e.preventDefault();
757
+ break;
758
+ case 9: // tab
759
+ this.hide();
760
+ break;
761
+ }
762
+ if (dateChanged){
763
+ this.element.trigger({
764
+ type: 'changeDate',
765
+ date: this.date
766
+ });
767
+ var element;
768
+ if (this.isInput) {
769
+ element = this.element;
770
+ } else if (this.component){
771
+ element = this.element.find('input');
772
+ }
773
+ if (element) {
774
+ element.change();
775
+ }
776
+ }
777
+ },
778
+
779
+ showMode: function(dir) {
780
+ if (dir) {
781
+ this.viewMode = Math.max(0, Math.min(2, this.viewMode + dir));
782
+ }
783
+ /*
784
+ vitalets: fixing bug of very special conditions:
785
+ jquery 1.7.1 + webkit + show inline datepicker in bootstrap popover.
786
+ Method show() does not set display css correctly and datepicker is not shown.
787
+ Changed to .css('display', 'block') solve the problem.
788
+ See https://github.com/vitalets/x-editable/issues/37
789
+
790
+ In jquery 1.7.2+ everything works fine.
791
+ */
792
+ //this.picker.find('>div').hide().filter('.datepicker-'+DPGlobal.modes[this.viewMode].clsName).show();
793
+ this.picker.find('>div').hide().filter('.datepicker-'+DPGlobal.modes[this.viewMode].clsName).css('display', 'block');
794
+ this.updateNavArrows();
795
+ }
796
+ };
797
+
798
+ $.fn.fdatepicker = function ( option ) {
799
+ var args = Array.apply(null, arguments);
800
+ args.shift();
801
+ return this.each(function () {
802
+ var $this = $(this),
803
+ data = $this.data('datepicker'),
804
+ options = typeof option == 'object' && option;
805
+ if (!data) {
806
+ $this.data('datepicker', (data = new Datepicker(this, $.extend({}, $.fn.fdatepicker.defaults,options))));
807
+ }
808
+ if (typeof option == 'string' && typeof data[option] == 'function') {
809
+ data[option].apply(data, args);
810
+ }
811
+ });
812
+ };
813
+
814
+ $.fn.fdatepicker.defaults = {
815
+ onRender: function(date) {
816
+ return '';
817
+ }
818
+ };
819
+ $.fn.fdatepicker.Constructor = Datepicker;
820
+ var dates = $.fn.fdatepicker.dates = {
821
+ 'en': {
822
+ days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
823
+ daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
824
+ daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
825
+ months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
826
+ monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
827
+ today: "Today",
828
+ titleFormat: "MM yyyy"
829
+ },
830
+ 'sk': {
831
+ days: ["Nedeľa", "Pondelok", "Utorok", "Streda", "Štvrtok", "Piatok", "Sobota", "Nedeľa"],
832
+ daysShort: ["Neď", "Pon", "Utr", "Str", "Štv", "Pia", "Sob", "Ned"],
833
+ daysMin: ["Ne", "Po", "Ut", "St", "Št", "Pi", "So", "Ne"],
834
+ months: ["Január", "Február", "Marec", "Apríl", "Máj", "Jún", "Júl", "August", "September", "Október", "November", "December"],
835
+ monthsShort: ["Jan", "Feb", "Mar", "Apr", "Máj", "Jún", "Júl", "Aug", "Sep", "Oct", "Nov", "Dec"],
836
+ today: "Dnes"
837
+ },
838
+ 'tr': {
839
+ days: ["Pazar", "Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma", "Cumartesi", "Pazar"],
840
+ daysShort: ["Pzr", "Pzt", "Sal", "Çarş", "Perş", "Cum", "Cmt", "Pzr"],
841
+ daysMin: ["Pz", "Pt", "Sa", "Ça", "Pe", "Cu", "Ct", "Pz"],
842
+ months: ["Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"],
843
+ monthsShort: ["Oca", "Şub", "Mar", "Nis", "May", "Haz", "Tem", "Ağu", "Eyl", "Eki", "Kas", "Ara"],
844
+ today: "Bugün"
845
+ },
846
+ 'fr': {
847
+ days: ["Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche"],
848
+ daysShort: ["Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam", "Dim"],
849
+ daysMin: ["Di", "Lu", "Ma", "Me", "Je", "Ve", "Sa", "Di"],
850
+ months: ["Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"],
851
+ monthsShort: ["Jan", "Fev", "Mar", "Avr", "Mai", "Jun", "Jul", "Aoû", "Sep", "Oct", "Nov", "Dec"],
852
+ today: "Aujourd'hui"
853
+ },
854
+ 'pl': {
855
+ days: ["Niedziela", "Poniedziałek", "Wtorek", "Środa", "Czwartek", "Piątek", "Sobota", "Niedziela"],
856
+ daysShort: ["Nie", "Pon", "Wt", "Śr", "Czw", "Pt", "Sob", "Nie"],
857
+ daysMin: ["Nd", "Po", "Wt", "Śr", "Czw", "Pt", "So", "Nd"],
858
+ months: ["Styczeń", "Luty", "Marzec", "Kwiecień", "Maj", "Czerwiec", "Lipiec", "Sierpień", "Wrzesień", "Październik", "Listopad", "Grudzień"],
859
+ monthsShort: ["Sty", "Lut", "Mar", "Kwi", "Maj", "Cze", "Lip", "Sie", "Wrz", "Paź", "Lit", "Gru"],
860
+ today: "Dzisiaj"
861
+ },
862
+ 'es': {
863
+ days: ["Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado", "Domingo"],
864
+ daysShort: ["Dom", "Lun", "Mar", "Mie", "Jue", "Vie", "Sab", "Dom"],
865
+ daysMin: ["Do", "Lu", "Ma", "Mi", "Ju", "Vi", "Sa", "Do"],
866
+ months: ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Deciembre"],
867
+ monthsShort: ["Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic"],
868
+ today: "Hoy"
869
+ },
870
+ 'pt': {
871
+ days: ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado", "Domingo"],
872
+ daysShort: ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb", "Dom"],
873
+ daysMin: ["Do", "Se", "Te", "Qu", "Qu", "Se", "Sá", "Do"],
874
+ months: ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"],
875
+ monthsShort: ["Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez"],
876
+ today: "Hoje"
877
+ },
878
+ 'pt_br': {
879
+ days: ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado", "Domingo"],
880
+ daysShort: ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb", "Dom"],
881
+ daysMin: ["D", "S", "T", "Q", "Q", "S", "S", "D"],
882
+ months: ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"],
883
+ monthsShort: ["Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez"],
884
+ today: "Hoje"
885
+ },
886
+ 'it': {
887
+ days: ["Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato", "Domenica"],
888
+ daysShort: ["Dom", "Lun", "Mar", "Mer", "Gio", "Veb", "Sab", "Dom"],
889
+ daysMin: ["Do", "Lu", "Ma", "Me", "Gi", "Ve", "Sa", "Do"],
890
+ months: ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"],
891
+ monthsShort: ["Gen", "Feb", "Mar", "Apr", "Mag", "Giu", "Lug", "Ago", "Set", "Ott", "Nov", "Dic"],
892
+ today: "Oggi"
893
+ },
894
+ 'de': {
895
+ days: ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag"],
896
+ daysShort: ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"],
897
+ daysMin: ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"],
898
+ months: ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"],
899
+ monthsShort: ["Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"],
900
+ today: "Heute"
901
+ },
902
+ 'ro': {
903
+ days: ["Duminica", "Luni", "Marti", "Miercuri", "Joi", "Vineri", "Sambata", "Duminica"],
904
+ daysShort: ["Dum", "Lun", "Mar", "Mie", "Joi", "Vin", "Sam", "Dum"],
905
+ daysMin: ["Du", "Lu", "Ma", "Mi", "Jo", "Vi", "Sa", "Du"],
906
+ months: ["Ianuarie", "Februarie", "Martie", "Aprilie", "Mai", "Iunie", "Iulie", "August", "Septembrie", "Octombrie", "Noiembrie", "Decembrie"],
907
+ monthsShort: ["Ian", "Feb", "Mar", "Apr", "Mai", "Iun", "Iul", "Aug", "Sep", "Oct", "Noi", "Dec"],
908
+ today: "Astazi"
909
+ },
910
+ 'hu': {
911
+ days: ["Vasárnap", "Hétfő", "Kedd", "Szerda", "Csütörtök", "Péntek", "Szombat", "Vasárnap"],
912
+ daysShort: ["Vas", "Hét", "Kedd", "Sze", "Csü", "Pén", "Szo", "Vas"],
913
+ daysMin: ["Va", "Hé", "Ke", "Sz", "Cs", "Pé", "Sz", "Va"],
914
+ months: ["Január", "Február", "Március", "Április", "Május", "Június", "Július", "Augusztus", "Szeptember", "Október", "November", "December"],
915
+ monthsShort: ["Jan", "Feb", "Már", "Ápr", "Máj", "Jún", "Júl", "Aug", "Szep", "Okt", "Nov", "Dec"],
916
+ today: "Ma"
917
+ },
918
+ 'ru': {
919
+ days: ["Воскресенье", "Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота", "Воскресенье"],
920
+ daysShort: ["Вск", "Пнд", "Втр", "Срд", "Чтв", "Птн", "Суб", "Вск"],
921
+ daysMin: ["Вс", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Вс"],
922
+ months: ["Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "Декабрь"],
923
+ monthsShort: ["Янв", "Фев", "Мар", "Апр", "Май", "Июн", "Июл", "Авг", "Сен", "Окт", "Ноя", "Дек"],
924
+ today: "Сегодня"
925
+ },
926
+ 'cs': {
927
+ days: ["Neděle", "Pondělí", "Úterý", "Středa", "Čtvrtek", "Pátek", "Sobota", "Neděle"],
928
+ daysShort: ["Ne", "Po", "Út", "St", "Čt", "Pá", "So", "Ne"],
929
+ daysMin: ["Ne", "Po", "Út", "St", "Čt", "Pá", "So", "Ne"],
930
+ months: ["Leden", "Únor", "Březen", "Duben", "Květen", "Červen", "Červenec", "Srpen", "Září", "Říjen", "Listopad", "Prosinec"],
931
+ monthsShort: ["Led", "Úno", "Bře", "Dub", "Kvě", "Čer", "Čnc", "Srp", "Zář", "Říj", "Lis", "Pro"],
932
+ today: "Dnes"
933
+ },
934
+ 'nl': {
935
+ days: ["Zondag", "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag", "Zondag"],
936
+ daysShort: ["Zon", "Maa", "Din", "Woe", "Don", "Vri", "Zat", "Zon"],
937
+ daysMin: ["Zo", "Ma", "Di", "Wo", "Do", "Vr", "Za", "Zo"],
938
+ months: ["Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December"],
939
+ monthsShort: ["Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec"],
940
+ today: "Vandaag"
941
+ },
942
+ 'el': {
943
+ days: ["Κυριακή", "Δευτέρα", "Τρίτη", "Τετάρτη", "Πέμπτη", "Παρασκευή", "Σάββατο", "Κυριακή"],
944
+ daysShort: ["Κυρ", "Δευ", "Τρί", "Τετ", "Πέμ", "Παρ", "Σάβ", "Κυρ"],
945
+ daysMin: ["Κυ", "Δε", "Τρ", "Τε", "Πέ", "Πα", "Σά", "Κυ"],
946
+ months: ["Ιανουάριος", "Φεβρουάριος", "Μάρτιος", "Απρίλιος", "Μάιος", "Ιούνιος", "Ιούλιος", "Αύγουστος", "Σεπτέμβριος", "Οκτώβριος", "Νοέμβριος", "Δεκέμβριος"],
947
+ monthsShort: ["Ιαν", "Φεβ", "Μαρ", "Απρ", "Μαϊ", "Ιου", "Ιου", "Αυγ", "Σεπ", "Οκτ", "Νοε", "Δεκ"],
948
+ today: "Σήμερα"
949
+ },
950
+ 'uk': {
951
+ days: ["Понедiлок ", "Вiвторок ", "Середа ", "Четвер ", "П'ятниця ", "Субота ", "Недiля"],
952
+ daysShort: ["Пнд", "Втр", "Срд", "Чтв", "Птн", "Сбт", "Ндл"],
953
+ daysMin: ["Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Нд"],
954
+ months: ["Січень", "Лютий", "Березень", "Квітень", "Травень", "Червень", "Липень", "Серпень", "Вересень", "Жовтень", "Листопад", "Грудень"],
955
+ monthsShort: ["Сiч", "Лют", "Бер", "Квiт", "Трав", "Черв", "Лип", "Серп", "Вер", "Жовт", "Лист", "Груд"],
956
+ today: "Сьогодні"
957
+ },
958
+ 'no': {
959
+ days: ["Søndag", "Mandag", "Tirsdag", "Onsdag", "Torsdag", "Fredag", "Lørdag", "Søndag"],
960
+ daysShort: ["Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør", "Søn"],
961
+ daysMin: ["Sø", "Ma", "Ti", "On", "To", "Fr", "Lø", "Sø"],
962
+ months: ["Januar", "Februar", "Mars", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Desember"],
963
+ monthsShort: ["Jan", "Feb", "Mar", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Des"],
964
+ today: "I dag"
965
+ },
966
+ 'sv': {
967
+ days: ["Söndag", "Måndag", "Tisdag", "Onsdag", "Torsdag", "Fredag", "Lördag", "Söndag"],
968
+ daysShort: ["Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör", "Sön"],
969
+ daysMin: ["Sö", "Må", "Ti", "On", "To", "Fr", "Lö", "Sö"],
970
+ months: ["Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December"],
971
+ monthsShort: ["Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec"],
972
+ today: "Idag"
973
+ },
974
+ 'zh-CN': {
975
+ days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],
976
+ daysShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
977
+ daysMin: ["日", "一", "二", "三", "四", "五", "六"],
978
+ months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
979
+ monthsShort: ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"],
980
+ today: '今天'
981
+ },
982
+ 'zh-TW': {
983
+ days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],
984
+ daysShort: ["週日", "週一", "週二", "週三", "週四", "週五", "週六"],
985
+ daysMin: ["日", "一", "二", "三", "四", "五", "六"],
986
+ months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
987
+ monthsShort: ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"],
988
+ today: '今天'
989
+ },
990
+ 'ja': {
991
+ days: ["日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日"],
992
+ daysShort: ["日", "月", "火", "水", "木", "金", "土"],
993
+ daysMin: ["日", "月", "火", "水", "木", "金", "土"],
994
+ months: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
995
+ monthsShort: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
996
+ today: "今日",
997
+ format: "yyyy/mm/dd",
998
+ titleFormat: "yyyy年 MM月"
999
+ }
1000
+ };
1001
+
1002
+ var DPGlobal = {
1003
+ modes: [
1004
+ {
1005
+ clsName: 'days',
1006
+ navFnc: 'Month',
1007
+ navStep: 1
1008
+ },
1009
+ {
1010
+ clsName: 'months',
1011
+ navFnc: 'FullYear',
1012
+ navStep: 1
1013
+ },
1014
+ {
1015
+ clsName: 'years',
1016
+ navFnc: 'FullYear',
1017
+ navStep: 10
1018
+ }],
1019
+ isLeapYear: function (year) {
1020
+ return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0));
1021
+ },
1022
+ getDaysInMonth: function (year, month) {
1023
+ return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
1024
+ },
1025
+ validParts: /dd?|DD?|mm?|MM?|yy(?:yy)?/g,
1026
+ nonpunctuation: /[^ -\/:-@\[\u3400-\u9fff-`{-~\t\n\r]+/g,
1027
+ parseFormat: function(format){
1028
+ // IE treats \0 as a string end in inputs (truncating the value),
1029
+ // so it's a bad format delimiter, anyway
1030
+ var separators = format.replace(this.validParts, '\0').split('\0'),
1031
+ parts = format.match(this.validParts);
1032
+ if (!separators || !separators.length || !parts || parts.length === 0){
1033
+ throw new Error("Invalid date format.");
1034
+ }
1035
+ return {separators: separators, parts: parts};
1036
+ },
1037
+ parseDate: function(date, format, language) {
1038
+ if (date instanceof Date) return date;
1039
+ if (/^[\-+]\d+[dmwy]([\s,]+[\-+]\d+[dmwy])*$/.test(date)) {
1040
+ var part_re = /([\-+]\d+)([dmwy])/,
1041
+ parts = date.match(/([\-+]\d+)([dmwy])/g),
1042
+ part, dir;
1043
+ date = new Date();
1044
+ for (var i=0; i<parts.length; i++) {
1045
+ part = part_re.exec(parts[i]);
1046
+ dir = parseInt(part[1]);
1047
+ switch(part[2]){
1048
+ case 'd':
1049
+ date.setUTCDate(date.getUTCDate() + dir);
1050
+ break;
1051
+ case 'm':
1052
+ date = Datepicker.prototype.moveMonth.call(Datepicker.prototype, date, dir);
1053
+ break;
1054
+ case 'w':
1055
+ date.setUTCDate(date.getUTCDate() + dir * 7);
1056
+ break;
1057
+ case 'y':
1058
+ date = Datepicker.prototype.moveYear.call(Datepicker.prototype, date, dir);
1059
+ break;
1060
+ }
1061
+ }
1062
+ return UTCDate(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), 0, 0, 0);
1063
+ }
1064
+ var parts = date && date.match(this.nonpunctuation) || [],
1065
+ date = new Date(),
1066
+ parsed = {},
1067
+ setters_order = ['yyyy', 'yy', 'M', 'MM', 'm', 'mm', 'd', 'dd'],
1068
+ setters_map = {
1069
+ yyyy: function(d,v){ return d.setUTCFullYear(v); },
1070
+ yy: function(d,v){ return d.setUTCFullYear(2000+v); },
1071
+ m: function(d,v){
1072
+ v -= 1;
1073
+ while (v<0) v += 12;
1074
+ v %= 12;
1075
+ d.setUTCMonth(v);
1076
+ while (d.getUTCMonth() != v)
1077
+ d.setUTCDate(d.getUTCDate()-1);
1078
+ return d;
1079
+ },
1080
+ d: function(d,v){ return d.setUTCDate(v); }
1081
+ },
1082
+ val, filtered, part;
1083
+ setters_map['M'] = setters_map['MM'] = setters_map['mm'] = setters_map['m'];
1084
+ setters_map['dd'] = setters_map['d'];
1085
+ date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
1086
+ var fparts = format.parts.slice();
1087
+ // Remove noop parts
1088
+ if (parts.length != fparts.length) {
1089
+ fparts = $(fparts).filter(function(i,p){
1090
+ return $.inArray(p, setters_order) !== -1;
1091
+ }).toArray();
1092
+ }
1093
+ // Process remainder
1094
+ if (parts.length == fparts.length) {
1095
+ for (var i=0, cnt = fparts.length; i < cnt; i++) {
1096
+ val = parseInt(parts[i], 10);
1097
+ part = fparts[i];
1098
+ if (isNaN(val)) {
1099
+ switch(part) {
1100
+ case 'MM':
1101
+ filtered = $(dates[language].months).filter(function(){
1102
+ var m = this.slice(0, parts[i].length),
1103
+ p = parts[i].slice(0, m.length);
1104
+ return m == p;
1105
+ });
1106
+ val = $.inArray(filtered[0], dates[language].months) + 1;
1107
+ break;
1108
+ case 'M':
1109
+ filtered = $(dates[language].monthsShort).filter(function(){
1110
+ var m = this.slice(0, parts[i].length),
1111
+ p = parts[i].slice(0, m.length);
1112
+ return m == p;
1113
+ });
1114
+ val = $.inArray(filtered[0], dates[language].monthsShort) + 1;
1115
+ break;
1116
+ }
1117
+ }
1118
+ parsed[part] = val;
1119
+ }
1120
+ for (var i=0, s; i<setters_order.length; i++){
1121
+ s = setters_order[i];
1122
+ if (s in parsed && !isNaN(parsed[s]))
1123
+ setters_map[s](date, parsed[s]);
1124
+ }
1125
+ }
1126
+ return date;
1127
+ },
1128
+ formatDate: function(date, format, language){
1129
+ if (!date)
1130
+ return '';
1131
+ if (typeof format === 'string')
1132
+ format = DPGlobal.parseFormat(format);
1133
+ if (format.toDisplay)
1134
+ return format.toDisplay(date, format, language);
1135
+ var val = {
1136
+ d: date.getUTCDate(),
1137
+ D: dates[language].daysShort[date.getUTCDay()],
1138
+ DD: dates[language].days[date.getUTCDay()],
1139
+ m: date.getUTCMonth() + 1,
1140
+ M: dates[language].monthsShort[date.getUTCMonth()],
1141
+ MM: dates[language].months[date.getUTCMonth()],
1142
+ yy: date.getUTCFullYear().toString().substring(2),
1143
+ yyyy: date.getUTCFullYear()
1144
+ };
1145
+ val.dd = (val.d < 10 ? '0' : '') + val.d;
1146
+ val.mm = (val.m < 10 ? '0' : '') + val.m;
1147
+ date = [];
1148
+ var seps = $.extend([], format.separators);
1149
+ for (var i=0, cnt = format.parts.length; i <= cnt; i++){
1150
+ if (seps.length)
1151
+ date.push(seps.shift());
1152
+ date.push(val[format.parts[i]]);
1153
+ }
1154
+ return date.join('');
1155
+ },
1156
+ headTemplate: '<thead>'+
1157
+ '<tr>'+
1158
+ '<th class="prev"><i class="fa fa-chevron-left fi-arrow-left"/></th>'+
1159
+ '<th colspan="5" class="date-switch"></th>'+
1160
+ '<th class="next"><i class="fa fa-chevron-right fi-arrow-right"/></th>'+
1161
+ '</tr>'+
1162
+ '</thead>',
1163
+ contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>',
1164
+ footTemplate: '<tfoot><tr><th colspan="7" class="today"></th></tr></tfoot>',
1165
+ headTemplateDays: '<thead>'+
1166
+ '<tr>'+
1167
+ '<th class="prev"><i class="fa fa-chevron-left fi-arrow-left"/></th>'+
1168
+ '<th colspan="5" class="date-switch"></th>'+
1169
+ '<th class="next"><i class="fa fa-chevron-right fi-arrow-right"/></th>'+
1170
+ '</tr>'+
1171
+ '</thead>',
1172
+ footTemplateDays: '<tfoot><tr><th colspan="7" class="today"></th></tr></tfoot>'
1173
+ };
1174
+ DPGlobal.template = '<div class="datepicker">'+
1175
+
1176
+ '<div class="datepicker-days">'+
1177
+ '<table class=" table-condensed">'+
1178
+ DPGlobal.headTemplateDays+
1179
+ '<tbody></tbody>'+
1180
+ DPGlobal.footTemplateDays+
1181
+ '</table>'+
1182
+ '</div>'+
1183
+ '<div class="datepicker-months">'+
1184
+ '<table class="table-condensed">'+
1185
+ DPGlobal.headTemplate+
1186
+ DPGlobal.contTemplate+
1187
+ DPGlobal.footTemplate+
1188
+ '</table>'+
1189
+ '</div>'+
1190
+ '<div class="datepicker-years">'+
1191
+ '<table class="table-condensed">'+
1192
+ DPGlobal.headTemplate+
1193
+ DPGlobal.contTemplate+
1194
+ DPGlobal.footTemplate+
1195
+ '</table>'+
1196
+ '</div>'+
1197
+ '<a class="button datepicker-close tiny alert right" style="width:auto;"><i class="fa fa-remove fa-times fi-x"></i></a>'+
1198
+ '</div>';
1199
+
1200
+ $.fn.fdatepicker.DPGlobal = DPGlobal;
1201
+
1202
+ }( window.jQuery );