kea-rails 2.0.0.pre.alpha5 → 2.0.0.pre.alpha6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/kea/bindings/date_picker.js +33 -0
  3. data/app/assets/javascripts/kea/extenders/date.js +10 -0
  4. data/app/assets/javascripts/kea/kea_dependencies.js +1 -0
  5. data/app/assets/stylesheets/kea/kea.css.sass +1 -1
  6. data/lib/kea-rails/version.rb +1 -1
  7. data/vendor/assets/components/pikaday/CHANGELOG.md +68 -0
  8. data/vendor/assets/components/pikaday/LICENSE +36 -0
  9. data/vendor/assets/components/pikaday/README.md +321 -0
  10. data/vendor/assets/components/pikaday/bower.json +29 -0
  11. data/vendor/assets/components/pikaday/component.json +17 -0
  12. data/vendor/assets/{stylesheets → components/pikaday/css}/pikaday.css +39 -7
  13. data/vendor/assets/components/pikaday/css/site.css +42 -0
  14. data/vendor/assets/components/pikaday/examples/amd.html +50 -0
  15. data/vendor/assets/components/pikaday/examples/bound-container.html +52 -0
  16. data/vendor/assets/components/pikaday/examples/calendars.html +57 -0
  17. data/vendor/assets/components/pikaday/examples/container.html +52 -0
  18. data/vendor/assets/components/pikaday/examples/jquery-amd.html +54 -0
  19. data/vendor/assets/components/pikaday/examples/jquery.html +46 -0
  20. data/vendor/assets/components/pikaday/examples/moment.html +53 -0
  21. data/vendor/assets/components/pikaday/examples/positions.html +106 -0
  22. data/vendor/assets/components/pikaday/examples/trigger.html +46 -0
  23. data/vendor/assets/components/pikaday/examples/weeknumbers.html +41 -0
  24. data/vendor/assets/components/pikaday/index.html +43 -0
  25. data/vendor/assets/components/pikaday/package.json +45 -0
  26. data/vendor/assets/{javascripts → components/pikaday}/pikaday.js +185 -52
  27. data/vendor/assets/components/pikaday/plugins/pikaday.jquery.js +52 -0
  28. data/vendor/assets/components/pikaday/scss/pikaday.scss +199 -0
  29. data/vendor/assets/components/pikaday/tests/methods.js +26 -0
  30. data/vendor/assets/components/pikaday/tests/module.js +24 -0
  31. metadata +27 -4
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "pikaday",
3
+ "version": "1.3.2",
4
+ "description": "A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS",
5
+ "keywords": [
6
+ "datepicker",
7
+ "calendar",
8
+ "date"
9
+ ],
10
+ "homepage": "http://dbushell.github.io/Pikaday/",
11
+ "bugs": "https://github.com/dbushell/Pikaday/issues",
12
+ "licenses": [
13
+ {
14
+ "type": "BSD",
15
+ "url": "http://opensource.org/licenses/BSD-3-Clause"
16
+ },
17
+ {
18
+ "type": "MIT",
19
+ "url": "http://opensource.org/licenses/MIT"
20
+ }
21
+ ],
22
+ "main": "pikaday.js",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/dbushell/Pikaday.git"
26
+ },
27
+ "optionalDependencies": {
28
+ "moment": "2.x"
29
+ },
30
+ "devDependencies": {
31
+ "mocha": "~1.18.2",
32
+ "expect.js": "^0.3.1"
33
+ },
34
+ "testling": {
35
+ "harness": "mocha",
36
+ "files": "tests/*.js",
37
+ "browsers": [
38
+ "ie/7..latest",
39
+ "chrome/latest",
40
+ "firefox/3.6", "firefox/latest",
41
+ "safari/latest",
42
+ "opera/latest"
43
+ ]
44
+ }
45
+ }
@@ -1,24 +1,29 @@
1
1
  /*!
2
2
  * Pikaday
3
3
  *
4
- * Copyright © 2013 David Bushell | BSD & MIT license | https://github.com/dbushell/Pikaday
4
+ * Copyright © 2014 David Bushell | BSD & MIT license | https://github.com/dbushell/Pikaday
5
5
  */
6
6
 
7
7
  (function (root, factory)
8
8
  {
9
9
  'use strict';
10
10
 
11
- if (typeof define === 'function' && define.amd) {
11
+ var moment;
12
+ if (typeof exports === 'object') {
13
+ // CommonJS module
14
+ // Load moment.js as an optional dependency
15
+ try { moment = require('moment'); } catch (e) {}
16
+ module.exports = factory(moment);
17
+ } else if (typeof define === 'function' && define.amd) {
12
18
  // AMD. Register as an anonymous module.
13
19
  define(function (req)
14
20
  {
15
21
  // Load moment.js as an optional dependency
16
22
  var id = 'moment';
17
- var moment = req.defined && req.defined(id) ? req(id) : undefined;
18
- return factory(moment || root.moment);
23
+ try { moment = req(id); } catch (e) {}
24
+ return factory(moment);
19
25
  });
20
26
  } else {
21
- // Browser global
22
27
  root.Pikaday = factory(root.moment);
23
28
  }
24
29
  }(this, function (moment)
@@ -102,6 +107,12 @@
102
107
  return (/Date/).test(Object.prototype.toString.call(obj)) && !isNaN(obj.getTime());
103
108
  },
104
109
 
110
+ isWeekend = function(date)
111
+ {
112
+ var day = date.getDay();
113
+ return day === 0 || day === 6;
114
+ },
115
+
105
116
  isLeapYear = function(year)
106
117
  {
107
118
  // solution by Matti Virkkunen: http://stackoverflow.com/a/4881951
@@ -129,7 +140,7 @@
129
140
  var prop, hasProp;
130
141
  for (prop in from) {
131
142
  hasProp = to[prop] !== undefined;
132
- if (hasProp && typeof from[prop] === 'object' && from[prop].nodeName === undefined) {
143
+ if (hasProp && typeof from[prop] === 'object' && from[prop] !== null && from[prop].nodeName === undefined) {
133
144
  if (isDate(from[prop])) {
134
145
  if (overwrite) {
135
146
  to[prop] = new Date(from[prop].getTime());
@@ -149,6 +160,17 @@
149
160
  return to;
150
161
  },
151
162
 
163
+ adjustCalendar = function(calendar) {
164
+ if (calendar.month < 0) {
165
+ calendar.year -= Math.ceil(Math.abs(calendar.month)/12);
166
+ calendar.month += 12;
167
+ }
168
+ if (calendar.month > 11) {
169
+ calendar.year += Math.floor(Math.abs(calendar.month)/12);
170
+ calendar.month -= 12;
171
+ }
172
+ return calendar;
173
+ },
152
174
 
153
175
  /**
154
176
  * defaults and localisation
@@ -161,6 +183,13 @@
161
183
  // automatically show/hide the picker on `field` focus (default `true` if `field` is set)
162
184
  bound: undefined,
163
185
 
186
+ // position of the datepicker, relative to the field (default to bottom & left)
187
+ // ('bottom' & 'left' keywords are not used, 'top' & 'right' are modifier on the bottom/left position)
188
+ position: 'bottom left',
189
+
190
+ // automatically fit in the viewport even if it means repositioning from the position option
191
+ reposition: true,
192
+
164
193
  // the default output format for `.toString()` and `field` value
165
194
  format: 'YYYY-MM-DD',
166
195
 
@@ -181,6 +210,9 @@
181
210
  // number of years either side, or array of upper/lower range
182
211
  yearRange: 10,
183
212
 
213
+ // show week numbers at head of row
214
+ showWeekNumber: false,
215
+
184
216
  // used internally (don't config outside)
185
217
  minYear: 0,
186
218
  maxYear: 9999,
@@ -195,9 +227,16 @@
195
227
  // Render the month after year in the calendar title
196
228
  showMonthAfterYear: false,
197
229
 
198
- // how many months are visible (not implemented yet)
230
+ // how many months are visible
199
231
  numberOfMonths: 1,
200
232
 
233
+ // when numberOfMonths is used, this will help you to choose where the main calendar will be (default `left`, can be set to `right`)
234
+ // only used for the first display or when a selected date is not visible
235
+ mainCalendar: 'left',
236
+
237
+ // Specify a DOM element to render the calendar in
238
+ container: undefined,
239
+
201
240
  // internationalization
202
241
  i18n: {
203
242
  previousMonth : 'Previous Month',
@@ -227,7 +266,7 @@
227
266
  return abbr ? opts.i18n.weekdaysShort[day] : opts.i18n.weekdays[day];
228
267
  },
229
268
 
230
- renderDay = function(i, isSelected, isToday, isDisabled, isEmpty)
269
+ renderDay = function(d, m, y, isSelected, isToday, isDisabled, isEmpty)
231
270
  {
232
271
  if (isEmpty) {
233
272
  return '<td class="is-empty"></td>';
@@ -242,7 +281,19 @@
242
281
  if (isSelected) {
243
282
  arr.push('is-selected');
244
283
  }
245
- return '<td data-day="' + i + '" class="' + arr.join(' ') + '"><button class="pika-button" type="button">' + i + '</button>' + '</td>';
284
+ return '<td data-day="' + d + '" class="' + arr.join(' ') + '">' +
285
+ '<button class="pika-button pika-day" type="button" ' +
286
+ 'data-pika-year="' + y + '" data-pika-month="' + m + '" data-pika-day="' + d + '">' +
287
+ d +
288
+ '</button>' +
289
+ '</td>';
290
+ },
291
+
292
+ renderWeek = function (d, m, y) {
293
+ // Lifted from http://javascript.about.com/library/blweekyear.htm, lightly modified.
294
+ var onejan = new Date(y, 0, 1),
295
+ weekNum = Math.ceil((((new Date(y, m, d) - onejan) / 86400000) + onejan.getDay()+1)/7);
296
+ return '<td class="pika-week">' + weekNum + '</td>';
246
297
  },
247
298
 
248
299
  renderRow = function(days, isRTL)
@@ -258,18 +309,19 @@
258
309
  renderHead = function(opts)
259
310
  {
260
311
  var i, arr = [];
312
+ if (opts.showWeekNumber) {
313
+ arr.push('<th></th>');
314
+ }
261
315
  for (i = 0; i < 7; i++) {
262
316
  arr.push('<th scope="col"><abbr title="' + renderDayName(opts, i) + '">' + renderDayName(opts, i, true) + '</abbr></th>');
263
317
  }
264
318
  return '<thead>' + (opts.isRTL ? arr.reverse() : arr).join('') + '</thead>';
265
319
  },
266
320
 
267
- renderTitle = function(instance)
321
+ renderTitle = function(instance, c, year, month, refYear)
268
322
  {
269
323
  var i, j, arr,
270
324
  opts = instance._o,
271
- month = instance._m,
272
- year = instance._y,
273
325
  isMinYear = year === opts.minYear,
274
326
  isMaxYear = year === opts.maxYear,
275
327
  html = '<div class="pika-title">',
@@ -279,7 +331,7 @@
279
331
  next = true;
280
332
 
281
333
  for (arr = [], i = 0; i < 12; i++) {
282
- arr.push('<option value="' + i + '"' +
334
+ arr.push('<option value="' + (year === refYear ? i - c : 12 + i - c) + '"' +
283
335
  (i === month ? ' selected': '') +
284
336
  ((isMinYear && i < opts.minMonth) || (isMaxYear && i > opts.maxMonth) ? 'disabled' : '') + '>' +
285
337
  opts.i18n.months[i] + '</option>');
@@ -315,8 +367,12 @@
315
367
  next = false;
316
368
  }
317
369
 
318
- html += '<button class="pika-prev' + (prev ? '' : ' is-disabled') + '" type="button">' + opts.i18n.previousMonth + '</button>';
319
- html += '<button class="pika-next' + (next ? '' : ' is-disabled') + '" type="button">' + opts.i18n.nextMonth + '</button>';
370
+ if (c === 0) {
371
+ html += '<button class="pika-prev' + (prev ? '' : ' is-disabled') + '" type="button">' + opts.i18n.previousMonth + '</button>';
372
+ }
373
+ if (c === (instance._o.numberOfMonths - 1) ) {
374
+ html += '<button class="pika-next' + (next ? '' : ' is-disabled') + '" type="button">' + opts.i18n.nextMonth + '</button>';
375
+ }
320
376
 
321
377
  return html += '</div>';
322
378
  },
@@ -348,10 +404,13 @@
348
404
 
349
405
  if (!hasClass(target, 'is-disabled')) {
350
406
  if (hasClass(target, 'pika-button') && !hasClass(target, 'is-empty')) {
351
- self.setDate(new Date(self._y, self._m, parseInt(target.innerHTML, 10)));
407
+ self.setDate(new Date(target.getAttribute('data-pika-year'), target.getAttribute('data-pika-month'), target.getAttribute('data-pika-day')));
352
408
  if (opts.bound) {
353
409
  sto(function() {
354
410
  self.hide();
411
+ if (opts.field) {
412
+ opts.field.blur();
413
+ }
355
414
  }, 100);
356
415
  }
357
416
  return;
@@ -422,6 +481,15 @@
422
481
 
423
482
  self._onInputBlur = function()
424
483
  {
484
+ // IE allows pika div to gain focus; catch blur the input field
485
+ var pEl = document.activeElement;
486
+ do {
487
+ if (hasClass(pEl, 'pika-single')) {
488
+ return;
489
+ }
490
+ }
491
+ while ((pEl = pEl.parentNode));
492
+
425
493
  if (!self._c) {
426
494
  self._b = sto(function() {
427
495
  self.hide();
@@ -445,12 +513,12 @@
445
513
  }
446
514
  }
447
515
  do {
448
- if (hasClass(pEl, 'pika-single')) {
516
+ if (hasClass(pEl, 'pika-single') || pEl === opts.trigger) {
449
517
  return;
450
518
  }
451
519
  }
452
520
  while ((pEl = pEl.parentNode));
453
- if (self._v && target !== opts.trigger) {
521
+ if (self._v && target !== opts.trigger && pEl !== opts.trigger) {
454
522
  self.hide();
455
523
  }
456
524
  };
@@ -462,7 +530,9 @@
462
530
  addEvent(self.el, 'change', self._onChange);
463
531
 
464
532
  if (opts.field) {
465
- if (opts.bound) {
533
+ if (opts.container) {
534
+ opts.container.appendChild(self.el);
535
+ } else if (opts.bound) {
466
536
  document.body.appendChild(self.el);
467
537
  } else {
468
538
  opts.field.parentNode.insertBefore(self.el, opts.field.nextSibling);
@@ -500,7 +570,6 @@
500
570
  } else {
501
571
  this.show();
502
572
  }
503
-
504
573
  };
505
574
 
506
575
 
@@ -529,6 +598,10 @@
529
598
 
530
599
  opts.trigger = (opts.trigger && opts.trigger.nodeName) ? opts.trigger : opts.field;
531
600
 
601
+ opts.disableWeekends = !!opts.disableWeekends;
602
+
603
+ opts.disableDayFn = (typeof opts.disableDayFn) == "function" ? opts.disableDayFn : null;
604
+
532
605
  var nom = parseInt(opts.numberOfMonths, 10) || 1;
533
606
  opts.numberOfMonths = nom > 4 ? 4 : nom;
534
607
 
@@ -585,10 +658,10 @@
585
658
  /**
586
659
  * set the current selection from a Moment.js object (if available)
587
660
  */
588
- setMoment: function(date)
661
+ setMoment: function(date, preventOnSelect)
589
662
  {
590
663
  if (hasMoment && moment.isMoment(date)) {
591
- this.setDate(date.toDate());
664
+ this.setDate(date.toDate(), preventOnSelect);
592
665
  }
593
666
  },
594
667
 
@@ -607,6 +680,12 @@
607
680
  {
608
681
  if (!date) {
609
682
  this._d = null;
683
+
684
+ if (this._o.field) {
685
+ this._o.field.value = '';
686
+ fireEvent(this._o.field, 'change', { firedBy: this });
687
+ }
688
+
610
689
  return this.draw();
611
690
  }
612
691
  if (typeof date === 'string') {
@@ -643,11 +722,43 @@
643
722
  */
644
723
  gotoDate: function(date)
645
724
  {
725
+ var newCalendar = true;
726
+
646
727
  if (!isDate(date)) {
647
728
  return;
648
729
  }
649
- this._y = date.getFullYear();
650
- this._m = date.getMonth();
730
+
731
+ if (this.calendars) {
732
+ var firstVisibleDate = new Date(this.calendars[0].year, this.calendars[0].month, 1),
733
+ lastVisibleDate = new Date(this.calendars[this.calendars.length-1].year, this.calendars[this.calendars.length-1].month, 1),
734
+ visibleDate = date.getTime();
735
+ // get the end of the month
736
+ lastVisibleDate.setMonth(lastVisibleDate.getMonth()+1);
737
+ lastVisibleDate.setDate(lastVisibleDate.getDate()-1);
738
+ newCalendar = (visibleDate < firstVisibleDate.getTime() || lastVisibleDate.getTime() < visibleDate);
739
+ }
740
+
741
+ if (newCalendar) {
742
+ this.calendars = [{
743
+ month: date.getMonth(),
744
+ year: date.getFullYear()
745
+ }];
746
+ if (this._o.mainCalendar === 'right') {
747
+ this.calendars[0].month += 1 - this._o.numberOfMonths;
748
+ }
749
+ }
750
+
751
+ this.adjustCalendars();
752
+ },
753
+
754
+ adjustCalendars: function() {
755
+ this.calendars[0] = adjustCalendar(this.calendars[0]);
756
+ for (var c = 1; c < this._o.numberOfMonths; c++) {
757
+ this.calendars[c] = adjustCalendar({
758
+ month: this.calendars[0].month + c,
759
+ year: this.calendars[0].year
760
+ });
761
+ }
651
762
  this.draw();
652
763
  },
653
764
 
@@ -661,28 +772,22 @@
661
772
  */
662
773
  gotoMonth: function(month)
663
774
  {
664
- if (!isNaN( (month = parseInt(month, 10)) )) {
665
- this._m = month < 0 ? 0 : month > 11 ? 11 : month;
666
- this.draw();
775
+ if (!isNaN(month)) {
776
+ this.calendars[0].month = parseInt(month, 10);
777
+ this.adjustCalendars();
667
778
  }
668
779
  },
669
780
 
670
781
  nextMonth: function()
671
782
  {
672
- if (++this._m > 11) {
673
- this._m = 0;
674
- this._y++;
675
- }
676
- this.draw();
783
+ this.calendars[0].month++;
784
+ this.adjustCalendars();
677
785
  },
678
786
 
679
787
  prevMonth: function()
680
788
  {
681
- if (--this._m < 0) {
682
- this._m = 11;
683
- this._y--;
684
- }
685
- this.draw();
789
+ this.calendars[0].month--;
790
+ this.adjustCalendars();
686
791
  },
687
792
 
688
793
  /**
@@ -691,8 +796,8 @@
691
796
  gotoYear: function(year)
692
797
  {
693
798
  if (!isNaN(year)) {
694
- this._y = parseInt(year, 10);
695
- this.draw();
799
+ this.calendars[0].year = parseInt(year, 10);
800
+ this.adjustCalendars();
696
801
  }
697
802
  },
698
803
 
@@ -724,7 +829,8 @@
724
829
  minYear = opts.minYear,
725
830
  maxYear = opts.maxYear,
726
831
  minMonth = opts.minMonth,
727
- maxMonth = opts.maxMonth;
832
+ maxMonth = opts.maxMonth,
833
+ html = '';
728
834
 
729
835
  if (this._y <= minYear) {
730
836
  this._y = minYear;
@@ -739,10 +845,13 @@
739
845
  }
740
846
  }
741
847
 
742
- this.el.innerHTML = renderTitle(this) + this.render(this._y, this._m);
848
+ for (var c = 0; c < opts.numberOfMonths; c++) {
849
+ html += '<div class="pika-lendar">' + renderTitle(this, c, this.calendars[c].year, this.calendars[c].month, this.calendars[0].year) + this.render(this.calendars[c].year, this.calendars[c].month) + '</div>';
850
+ }
851
+
852
+ this.el.innerHTML = html;
743
853
 
744
854
  if (opts.bound) {
745
- this.adjustPosition();
746
855
  if(opts.field.type !== 'hidden') {
747
856
  sto(function() {
748
857
  opts.trigger.focus();
@@ -760,6 +869,7 @@
760
869
 
761
870
  adjustPosition: function()
762
871
  {
872
+ if (this._o.container) return;
763
873
  var field = this._o.trigger, pEl = field,
764
874
  width = this.el.offsetWidth, height = this.el.offsetHeight,
765
875
  viewportWidth = window.innerWidth || document.documentElement.clientWidth,
@@ -780,13 +890,29 @@
780
890
  }
781
891
  }
782
892
 
783
- if (left + width > viewportWidth) {
893
+ // default position is bottom & left
894
+ if ((this._o.reposition && left + width > viewportWidth) ||
895
+ (
896
+ this._o.position.indexOf('right') > -1 &&
897
+ left - width + field.offsetWidth > 0
898
+ )
899
+ ) {
784
900
  left = left - width + field.offsetWidth;
785
901
  }
786
- if (top + height > viewportHeight + scrollTop) {
902
+ if ((this._o.reposition && top + height > viewportHeight + scrollTop) ||
903
+ (
904
+ this._o.position.indexOf('top') > -1 &&
905
+ top - height - field.offsetHeight > 0
906
+ )
907
+ ) {
787
908
  top = top - height - field.offsetHeight;
788
909
  }
789
- this.el.style.cssText = 'position:absolute;left:' + left + 'px;top:' + top + 'px;';
910
+
911
+ this.el.style.cssText = [
912
+ 'position: absolute',
913
+ 'left: ' + left + 'px',
914
+ 'top: ' + top + 'px'
915
+ ].join(';');
790
916
  },
791
917
 
792
918
  /**
@@ -816,14 +942,20 @@
816
942
  for (var i = 0, r = 0; i < cells; i++)
817
943
  {
818
944
  var day = new Date(year, month, 1 + (i - before)),
819
- isDisabled = (opts.minDate && day < opts.minDate) || (opts.maxDate && day > opts.maxDate),
820
945
  isSelected = isDate(this._d) ? compareDates(day, this._d) : false,
821
946
  isToday = compareDates(day, now),
822
- isEmpty = i < before || i >= (days + before);
947
+ isEmpty = i < before || i >= (days + before),
948
+ isDisabled = (opts.minDate && day < opts.minDate) ||
949
+ (opts.maxDate && day > opts.maxDate) ||
950
+ (opts.disableWeekends && isWeekend(day)) ||
951
+ (opts.disableDayFn && opts.disableDayFn(day));
823
952
 
824
- row.push(renderDay(1 + (i - before), isSelected, isToday, isDisabled, isEmpty));
953
+ row.push(renderDay(1 + (i - before), month, year, isSelected, isToday, isDisabled, isEmpty));
825
954
 
826
955
  if (++r === 7) {
956
+ if (opts.showWeekNumber) {
957
+ row.unshift(renderWeek(i - before, month, year));
958
+ }
827
959
  data.push(renderRow(row, opts.isRTL));
828
960
  row = [];
829
961
  r = 0;
@@ -840,12 +972,13 @@
840
972
  show: function()
841
973
  {
842
974
  if (!this._v) {
843
- if (this._o.bound) {
844
- addEvent(document, 'click', this._onClick);
845
- }
846
975
  removeClass(this.el, 'is-hidden');
847
976
  this._v = true;
848
977
  this.draw();
978
+ if (this._o.bound) {
979
+ addEvent(document, 'click', this._onClick);
980
+ this.adjustPosition();
981
+ }
849
982
  if (typeof this._o.onOpen === 'function') {
850
983
  this._o.onOpen.call(this);
851
984
  }
@@ -893,4 +1026,4 @@
893
1026
 
894
1027
  return Pikaday;
895
1028
 
896
- }));
1029
+ }));
@@ -0,0 +1,52 @@
1
+ /*!
2
+ * Pikaday jQuery plugin.
3
+ *
4
+ * Copyright © 2013 David Bushell | BSD & MIT license | https://github.com/dbushell/Pikaday
5
+ */
6
+
7
+ (function (root, factory)
8
+ {
9
+ 'use strict';
10
+
11
+ if (typeof exports === 'object') {
12
+ // CommonJS module
13
+ factory(require('jquery'), require('../pikaday'));
14
+ } else if (typeof define === 'function' && define.amd) {
15
+ // AMD. Register as an anonymous module.
16
+ define(['jquery', 'pikaday'], factory);
17
+ } else {
18
+ // Browser globals
19
+ factory(root.jQuery, root.Pikaday);
20
+ }
21
+ }(this, function ($, Pikaday)
22
+ {
23
+ 'use strict';
24
+
25
+ $.fn.pikaday = function()
26
+ {
27
+ var args = arguments;
28
+
29
+ if (!args || !args.length) {
30
+ args = [{ }];
31
+ }
32
+
33
+ return this.each(function()
34
+ {
35
+ var self = $(this),
36
+ plugin = self.data('pikaday');
37
+
38
+ if (!(plugin instanceof Pikaday)) {
39
+ if (typeof args[0] === 'object') {
40
+ var options = $.extend({}, args[0]);
41
+ options.field = self[0];
42
+ self.data('pikaday', new Pikaday(options));
43
+ }
44
+ } else {
45
+ if (typeof args[0] === 'string' && typeof plugin[args[0]] === 'function') {
46
+ plugin[args[0]].apply(plugin, Array.prototype.slice.call(args,1));
47
+ }
48
+ }
49
+ });
50
+ };
51
+
52
+ }));