materialize-sass 0.100.2.1 → 1.0.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +18 -42
  3. data/Rakefile +17 -17
  4. data/{app/assets → assets}/javascripts/materialize-sprockets.js +8 -12
  5. data/assets/javascripts/materialize.js +11877 -0
  6. data/assets/javascripts/materialize/autocomplete.js +420 -0
  7. data/assets/javascripts/materialize/buttons.js +388 -0
  8. data/assets/javascripts/materialize/cards.js +28 -0
  9. data/assets/javascripts/materialize/carousel.js +791 -0
  10. data/assets/javascripts/materialize/cash.js +992 -0
  11. data/assets/javascripts/materialize/characterCounter.js +180 -0
  12. data/assets/javascripts/materialize/chips.js +555 -0
  13. data/assets/javascripts/materialize/collapsible.js +275 -0
  14. data/assets/javascripts/materialize/datepicker.js +898 -0
  15. data/assets/javascripts/materialize/dropdown.js +530 -0
  16. data/{app/assets → assets}/javascripts/materialize/extras/nouislider.js +1 -1
  17. data/{app/assets → assets}/javascripts/materialize/extras/nouislider.min.js +1 -1
  18. data/assets/javascripts/materialize/forms.js +223 -0
  19. data/assets/javascripts/materialize/global.js +353 -0
  20. data/assets/javascripts/materialize/materialbox.js +432 -0
  21. data/{app/assets → assets}/javascripts/materialize/modal.js +82 -113
  22. data/assets/javascripts/materialize/parallax.js +135 -0
  23. data/assets/javascripts/materialize/pushpin.js +158 -0
  24. data/assets/javascripts/materialize/range.js +305 -0
  25. data/assets/javascripts/materialize/scrollspy.js +322 -0
  26. data/assets/javascripts/materialize/select.js +426 -0
  27. data/assets/javascripts/materialize/sidenav.js +584 -0
  28. data/assets/javascripts/materialize/slider.js +383 -0
  29. data/assets/javascripts/materialize/tabs.js +460 -0
  30. data/assets/javascripts/materialize/tapTarget.js +347 -0
  31. data/assets/javascripts/materialize/timepicker.js +616 -0
  32. data/{app/assets → assets}/javascripts/materialize/toasts.js +42 -46
  33. data/assets/javascripts/materialize/tooltip.js +325 -0
  34. data/assets/javascripts/materialize/velocity.min.js +782 -0
  35. data/{app/assets → assets}/javascripts/materialize/waves.js +0 -0
  36. data/{app/assets → assets}/stylesheets/materialize.scss +5 -6
  37. data/{app/assets → assets}/stylesheets/materialize/components/_badges.scss +1 -1
  38. data/{app/assets → assets}/stylesheets/materialize/components/_buttons.scss +34 -2
  39. data/{app/assets → assets}/stylesheets/materialize/components/_cards.scss +0 -0
  40. data/{app/assets → assets}/stylesheets/materialize/components/_carousel.scss +1 -1
  41. data/{app/assets → assets}/stylesheets/materialize/components/_chips.scss +6 -5
  42. data/{app/assets → assets}/stylesheets/materialize/components/_collapsible.scss +3 -3
  43. data/{app/assets → assets}/stylesheets/materialize/components/_color.scss +0 -0
  44. data/assets/stylesheets/materialize/components/_datepicker.scss +180 -0
  45. data/{app/assets → assets}/stylesheets/materialize/components/_dropdown.scss +16 -15
  46. data/{app/assets → assets}/stylesheets/materialize/components/_global.scss +49 -14
  47. data/{app/assets → assets}/stylesheets/materialize/components/_grid.scss +1 -1
  48. data/{app/assets → assets}/stylesheets/materialize/components/_icons-material-design.scss +0 -0
  49. data/{app/assets → assets}/stylesheets/materialize/components/_materialbox.scss +0 -0
  50. data/assets/stylesheets/materialize/components/_mixins.scss +5 -0
  51. data/{app/assets → assets}/stylesheets/materialize/components/_modal.scss +1 -1
  52. data/{app/assets → assets}/stylesheets/materialize/components/_navbar.scss +0 -0
  53. data/assets/stylesheets/materialize/components/_normalize.scss +447 -0
  54. data/{app/assets → assets}/stylesheets/materialize/components/_preloader.scss +0 -0
  55. data/{app/assets → assets}/stylesheets/materialize/components/_pulse.scss +0 -0
  56. data/{app/assets/stylesheets/materialize/components/_sideNav.scss → assets/stylesheets/materialize/components/_sidenav.scss} +23 -21
  57. data/{app/assets → assets}/stylesheets/materialize/components/_slider.scss +0 -0
  58. data/{app/assets → assets}/stylesheets/materialize/components/_table_of_contents.scss +3 -3
  59. data/{app/assets → assets}/stylesheets/materialize/components/_tabs.scss +2 -2
  60. data/{app/assets → assets}/stylesheets/materialize/components/_tapTarget.scss +0 -0
  61. data/assets/stylesheets/materialize/components/_timepicker.scss +182 -0
  62. data/{app/assets → assets}/stylesheets/materialize/components/_toast.scss +0 -0
  63. data/{app/assets → assets}/stylesheets/materialize/components/_tooltip.scss +1 -0
  64. data/{app/assets → assets}/stylesheets/materialize/components/_transitions.scss +0 -0
  65. data/{app/assets → assets}/stylesheets/materialize/components/_typography.scss +8 -8
  66. data/{app/assets → assets}/stylesheets/materialize/components/_variables.scss +42 -44
  67. data/{app/assets → assets}/stylesheets/materialize/components/_waves.scss +0 -0
  68. data/{app/assets → assets}/stylesheets/materialize/components/forms/_checkboxes.scss +24 -24
  69. data/{app/assets → assets}/stylesheets/materialize/components/forms/_file-input.scss +0 -0
  70. data/{app/assets → assets}/stylesheets/materialize/components/forms/_forms.scss +0 -0
  71. data/{app/assets → assets}/stylesheets/materialize/components/forms/_input-fields.scss +49 -35
  72. data/{app/assets → assets}/stylesheets/materialize/components/forms/_radio-buttons.scss +29 -29
  73. data/{app/assets → assets}/stylesheets/materialize/components/forms/_range.scss +32 -31
  74. data/{app/assets → assets}/stylesheets/materialize/components/forms/_select.scss +20 -11
  75. data/{app/assets → assets}/stylesheets/materialize/components/forms/_switches.scss +0 -0
  76. data/{app/assets → assets}/stylesheets/materialize/extras/nouislider.css +1 -1
  77. data/lib/materialize-sass.rb +13 -23
  78. data/lib/materialize-sass/engine.rb +6 -9
  79. data/lib/materialize-sass/version.rb +1 -1
  80. data/materialize-sass.gemspec +2 -1
  81. metadata +97 -97
  82. data/app/assets/fonts/roboto/Roboto-Bold.woff +0 -0
  83. data/app/assets/fonts/roboto/Roboto-Bold.woff2 +0 -0
  84. data/app/assets/fonts/roboto/Roboto-Light.woff +0 -0
  85. data/app/assets/fonts/roboto/Roboto-Light.woff2 +0 -0
  86. data/app/assets/fonts/roboto/Roboto-Medium.woff +0 -0
  87. data/app/assets/fonts/roboto/Roboto-Medium.woff2 +0 -0
  88. data/app/assets/fonts/roboto/Roboto-Regular.woff +0 -0
  89. data/app/assets/fonts/roboto/Roboto-Regular.woff2 +0 -0
  90. data/app/assets/fonts/roboto/Roboto-Thin.woff +0 -0
  91. data/app/assets/fonts/roboto/Roboto-Thin.woff2 +0 -0
  92. data/app/assets/javascripts/materialize.js +0 -10021
  93. data/app/assets/javascripts/materialize/animation.js +0 -7
  94. data/app/assets/javascripts/materialize/buttons.js +0 -253
  95. data/app/assets/javascripts/materialize/cards.js +0 -28
  96. data/app/assets/javascripts/materialize/carousel.js +0 -543
  97. data/app/assets/javascripts/materialize/character_counter.js +0 -64
  98. data/app/assets/javascripts/materialize/chips.js +0 -315
  99. data/app/assets/javascripts/materialize/collapsible.js +0 -178
  100. data/app/assets/javascripts/materialize/date_picker/picker.date.js +0 -1399
  101. data/app/assets/javascripts/materialize/date_picker/picker.js +0 -1196
  102. data/app/assets/javascripts/materialize/date_picker/picker.time.js +0 -646
  103. data/app/assets/javascripts/materialize/dropdown.js +0 -257
  104. data/app/assets/javascripts/materialize/forms.js +0 -806
  105. data/app/assets/javascripts/materialize/global.js +0 -170
  106. data/app/assets/javascripts/materialize/hammer.min.js +0 -424
  107. data/app/assets/javascripts/materialize/initial.js +0 -10
  108. data/app/assets/javascripts/materialize/jquery.easing.1.4.js +0 -144
  109. data/app/assets/javascripts/materialize/jquery.hammer.js +0 -33
  110. data/app/assets/javascripts/materialize/materialbox.js +0 -263
  111. data/app/assets/javascripts/materialize/parallax.js +0 -54
  112. data/app/assets/javascripts/materialize/pushpin.js +0 -68
  113. data/app/assets/javascripts/materialize/scrollFire.js +0 -49
  114. data/app/assets/javascripts/materialize/scrollspy.js +0 -230
  115. data/app/assets/javascripts/materialize/sideNav.js +0 -395
  116. data/app/assets/javascripts/materialize/slider.js +0 -295
  117. data/app/assets/javascripts/materialize/tabs.js +0 -244
  118. data/app/assets/javascripts/materialize/tapTarget.js +0 -184
  119. data/app/assets/javascripts/materialize/tooltip.js +0 -227
  120. data/app/assets/javascripts/materialize/transitions.js +0 -163
  121. data/app/assets/javascripts/materialize/velocity.min.js +0 -626
  122. data/app/assets/stylesheets/materialize/components/_normalize.scss +0 -424
  123. data/app/assets/stylesheets/materialize/components/_roboto.scss +0 -39
  124. data/app/assets/stylesheets/materialize/components/date_picker/_default.date.scss +0 -469
  125. data/app/assets/stylesheets/materialize/components/date_picker/_default.scss +0 -216
  126. data/app/assets/stylesheets/materialize/components/date_picker/_default.time.scss +0 -267
@@ -0,0 +1,275 @@
1
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
2
+
3
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
+
5
+ (function ($, Vel) {
6
+ 'use strict';
7
+
8
+ var _defaults = {
9
+ accordion: true,
10
+ onOpenStart: undefined,
11
+ onOpenEnd: undefined,
12
+ onCloseStart: undefined,
13
+ onCloseEnd: undefined,
14
+ inDuration: 300,
15
+ outDuration: 300
16
+ };
17
+
18
+ /**
19
+ * @class
20
+ *
21
+ */
22
+
23
+ var Collapsible = function () {
24
+ /**
25
+ * Construct Collapsible instance
26
+ * @constructor
27
+ * @param {Element} el
28
+ * @param {Object} options
29
+ */
30
+ function Collapsible(el, options) {
31
+ _classCallCheck(this, Collapsible);
32
+
33
+ // If exists, destroy and reinitialize
34
+ if (!!el.M_Collapsible) {
35
+ el.M_Collapsible.destroy();
36
+ }
37
+
38
+ this.el = el;
39
+ this.$el = $(el);
40
+ this.el.M_Collapsible = this;
41
+
42
+ /**
43
+ * Options for the collapsible
44
+ * @member Collapsible#options
45
+ * @prop {Boolean} [accordion=false] - Type of the collapsible
46
+ * @prop {Function} onOpenStart - Callback function called before collapsible is opened
47
+ * @prop {Function} onOpenEnd - Callback function called after collapsible is opened
48
+ * @prop {Function} onCloseStart - Callback function called before collapsible is closed
49
+ * @prop {Function} onCloseEnd - Callback function called after collapsible is closed
50
+ * @prop {Number} inDuration - Transition in duration in milliseconds.
51
+ * @prop {Number} outDuration - Transition duration in milliseconds.
52
+ */
53
+ this.options = $.extend({}, Collapsible.defaults, options);
54
+
55
+ this._setupEventHandlers();
56
+
57
+ // Open first active
58
+ var $activeBodies = this.$el.children('li.active').children('.collapsible-body');
59
+ if (this.options.accordion) {
60
+ // Handle Accordion
61
+ $activeBodies.first().css('display', 'block');
62
+ } else {
63
+ // Handle Expandables
64
+ $activeBodies.css('display', 'block');
65
+ }
66
+ }
67
+
68
+ _createClass(Collapsible, [{
69
+ key: 'destroy',
70
+
71
+
72
+ /**
73
+ * Teardown component
74
+ */
75
+ value: function destroy() {
76
+ this._removeEventHandlers();
77
+ this.el.M_Collapsible = undefined;
78
+ }
79
+
80
+ /**
81
+ * Setup Event Handlers
82
+ */
83
+
84
+ }, {
85
+ key: '_setupEventHandlers',
86
+ value: function _setupEventHandlers() {
87
+ this._handleCollapsibleClickBound = this._handleCollapsibleClick.bind(this);
88
+ this.el.addEventListener('click', this._handleCollapsibleClickBound);
89
+ }
90
+
91
+ /**
92
+ * Remove Event Handlers
93
+ */
94
+
95
+ }, {
96
+ key: '_removeEventHandlers',
97
+ value: function _removeEventHandlers() {
98
+ this.el.removeEventListener('click', this._handleCollapsibleClickBound);
99
+ }
100
+
101
+ /**
102
+ * Handle Collapsible Click
103
+ * @param {Event} e
104
+ */
105
+
106
+ }, {
107
+ key: '_handleCollapsibleClick',
108
+ value: function _handleCollapsibleClick(e) {
109
+ var $header = $(e.target).closest('.collapsible-header');
110
+ if (e.target && $header.length) {
111
+ var $collapsible = $header.closest('.collapsible');
112
+ if ($collapsible[0] === this.el) {
113
+ var $collapsibleLi = $header.closest('li');
114
+ var $collapsibleLis = $collapsible.children('li');
115
+ var isActive = $collapsibleLi[0].classList.contains('active');
116
+ var index = $collapsibleLis.index($collapsibleLi);
117
+
118
+ if (isActive) {
119
+ this.close(index);
120
+ } else {
121
+ this.open(index);
122
+ }
123
+ }
124
+ }
125
+ }
126
+
127
+ /**
128
+ * Animate in collapsible slide
129
+ * @param {Number} index - 0th index of slide
130
+ */
131
+
132
+ }, {
133
+ key: '_animateIn',
134
+ value: function _animateIn(index) {
135
+ var _this = this;
136
+
137
+ var $collapsibleLi = this.$el.children('li').eq(index);
138
+ if ($collapsibleLi.length) {
139
+ var $body = $collapsibleLi.children('.collapsible-body');
140
+ Vel($body[0], 'stop');
141
+ Vel($body[0], 'slideDown', { duration: this.options.inDuration, easing: 'easeInOutCubic', queue: false,
142
+ complete: function () {
143
+ $body[0].style.height = '';
144
+ $body[0].style.overflow = '';
145
+ $body[0].style.padding = '';
146
+ $body[0].style.margin = '';
147
+
148
+ // onOpenEnd callback
149
+ if (typeof _this.options.onOpenEnd === 'function') {
150
+ _this.options.onOpenEnd.call(_this, $collapsibleLi[0]);
151
+ }
152
+ } });
153
+ }
154
+ }
155
+
156
+ /**
157
+ * Animate out collapsible slide
158
+ * @param {Number} index - 0th index of slide to open
159
+ */
160
+
161
+ }, {
162
+ key: '_animateOut',
163
+ value: function _animateOut(index) {
164
+ var _this2 = this;
165
+
166
+ var $collapsibleLi = this.$el.children('li').eq(index);
167
+ if ($collapsibleLi.length) {
168
+ var $body = $collapsibleLi.children('.collapsible-body');
169
+ Vel($body[0], 'stop');
170
+ Vel($body[0], 'slideUp', { duration: this.options.outDuration, easing: 'easeInOutCubic', queue: false,
171
+ complete: function () {
172
+ $body[0].style.height = '';
173
+ $body[0].style.overflow = '';
174
+ $body[0].style.padding = '';
175
+ $body[0].style.margin = '';
176
+
177
+ // onCloseEnd callback
178
+ if (typeof _this2.options.onCloseEnd === 'function') {
179
+ _this2.options.onCloseEnd.call(_this2, $collapsibleLi[0]);
180
+ }
181
+ } });
182
+ }
183
+ }
184
+
185
+ /**
186
+ * Open Collapsible
187
+ * @param {Number} index - 0th index of slide
188
+ */
189
+
190
+ }, {
191
+ key: 'open',
192
+ value: function open(index) {
193
+ var _this3 = this;
194
+
195
+ var $collapsibleLi = this.$el.children('li').eq(index);
196
+ if ($collapsibleLi.length && !$collapsibleLi[0].classList.contains('active')) {
197
+
198
+ // onOpenStart callback
199
+ if (typeof this.options.onOpenStart === 'function') {
200
+ this.options.onOpenStart.call(this, $collapsibleLi[0]);
201
+ }
202
+
203
+ // Handle accordion behavior
204
+ if (this.options.accordion) {
205
+ var $collapsibleLis = this.$el.children('li');
206
+ var $activeLis = this.$el.children('li.active');
207
+ $activeLis.each(function (el) {
208
+ var index = $collapsibleLis.index($(el));
209
+ _this3.close(index);
210
+ });
211
+ }
212
+
213
+ // Animate in
214
+ $collapsibleLi[0].classList.add('active');
215
+ this._animateIn(index);
216
+ }
217
+ }
218
+
219
+ /**
220
+ * Close Collapsible
221
+ * @param {Number} index - 0th index of slide
222
+ */
223
+
224
+ }, {
225
+ key: 'close',
226
+ value: function close(index) {
227
+ var $collapsibleLi = this.$el.children('li').eq(index);
228
+ if ($collapsibleLi.length && $collapsibleLi[0].classList.contains('active')) {
229
+
230
+ // onCloseStart callback
231
+ if (typeof this.options.onCloseStart === 'function') {
232
+ this.options.onCloseStart.call(this, $collapsibleLi[0]);
233
+ }
234
+
235
+ // Animate out
236
+ $collapsibleLi[0].classList.remove('active');
237
+ this._animateOut(index);
238
+ }
239
+ }
240
+ }], [{
241
+ key: 'init',
242
+ value: function init($els, options) {
243
+ var arr = [];
244
+ $els.each(function () {
245
+ arr.push(new Collapsible(this, options));
246
+ });
247
+ return arr;
248
+ }
249
+
250
+ /**
251
+ * Get Instance
252
+ */
253
+
254
+ }, {
255
+ key: 'getInstance',
256
+ value: function getInstance(el) {
257
+ var domElem = !!el.jquery ? el[0] : el;
258
+ return domElem.M_Collapsible;
259
+ }
260
+ }, {
261
+ key: 'defaults',
262
+ get: function () {
263
+ return _defaults;
264
+ }
265
+ }]);
266
+
267
+ return Collapsible;
268
+ }();
269
+
270
+ M.Collapsible = Collapsible;
271
+
272
+ if (M.jQueryLoaded) {
273
+ M.initializeJqueryWrapper(Collapsible, 'collapsible', 'M_Collapsible');
274
+ }
275
+ })(cash, M.Vel);
@@ -0,0 +1,898 @@
1
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
2
+
3
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
+
5
+ (function ($, Vel) {
6
+ 'use strict';
7
+
8
+ var _defaults = {
9
+
10
+ // the default output format for the input field value
11
+ format: 'YYYY-MM-DD',
12
+
13
+ // the toString function which gets passed a current date object and format
14
+ // and returns a string
15
+ toString: null,
16
+
17
+ // Used to create date object from current input string
18
+ parse: null,
19
+
20
+ // The initial date to view when first opened
21
+ defaultDate: null,
22
+
23
+ // Make the `defaultDate` the initial selected value
24
+ setDefaultDate: false,
25
+
26
+ disableWeekends: false,
27
+
28
+ disableDayFn: null,
29
+
30
+ // First day of week (0: Sunday, 1: Monday etc)
31
+ firstDay: 0,
32
+
33
+ // The earliest date that can be selected
34
+ minDate: null,
35
+ // Thelatest date that can be selected
36
+ maxDate: null,
37
+
38
+ // Number of years either side, or array of upper/lower range
39
+ yearRange: 10,
40
+
41
+ // used internally (don't config outside)
42
+ minYear: 0,
43
+ maxYear: 9999,
44
+ minMonth: undefined,
45
+ maxMonth: undefined,
46
+
47
+ startRange: null,
48
+ endRange: null,
49
+
50
+ isRTL: false,
51
+
52
+ // Render the month after year in the calendar title
53
+ showMonthAfterYear: false,
54
+
55
+ // Render days of the calendar grid that fall in the next or previous month
56
+ showDaysInNextAndPreviousMonths: false,
57
+
58
+ // Specify a DOM element to render the calendar in
59
+ container: null,
60
+
61
+ // internationalization
62
+ i18n: {
63
+ clear: 'Clear',
64
+ today: 'Today',
65
+ done: 'Ok',
66
+ previousMonth: '‹',
67
+ nextMonth: '›',
68
+ months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
69
+ monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
70
+ weekdaysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
71
+ weekdays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
72
+ weekdaysAbbrev: ['S', 'M', 'T', 'W', 'T', 'F', 'S']
73
+ },
74
+
75
+ // events array
76
+ events: [],
77
+
78
+ // callback function
79
+ onSelect: null,
80
+ onOpen: null,
81
+ onClose: null,
82
+ onDraw: null
83
+ };
84
+
85
+ /**
86
+ * @class
87
+ *
88
+ */
89
+
90
+ var Datepicker = function () {
91
+ /**
92
+ * Construct Datepicker instance and set up overlay
93
+ * @constructor
94
+ * @param {Element} el
95
+ * @param {Object} options
96
+ */
97
+ function Datepicker(el, options) {
98
+ _classCallCheck(this, Datepicker);
99
+
100
+ // If exists, destroy and reinitialize
101
+ if (!!el.M_Datepicker) {
102
+ el.M_Datepicker.destroy();
103
+ }
104
+
105
+ this.el = el;
106
+ this.$el = $(el);
107
+ this.el.M_Datepicker = this;
108
+
109
+ this.options = $.extend({}, Datepicker.defaults, options);
110
+
111
+ this.id = M.guid();
112
+
113
+ this._setupVariables();
114
+ this._insertHTMLIntoDOM();
115
+ this._setupModal();
116
+
117
+ this._setupEventHandlers();
118
+
119
+ if (!this.options.defaultDate) {
120
+ this.options.defaultDate = new Date(Date.parse(this.el.value));
121
+ this.options.setDefaultDate = true;
122
+ }
123
+
124
+ var defDate = this.options.defaultDate;
125
+
126
+ if (Datepicker._isDate(defDate)) {
127
+ if (this.options.setDefaultDate) {
128
+ this.setDate(defDate, true);
129
+ } else {
130
+ this.gotoDate(defDate);
131
+ }
132
+ } else {
133
+ this.gotoDate(new Date());
134
+ }
135
+
136
+ /**
137
+ * Describes open/close state of datepicker
138
+ * @type {Boolean}
139
+ */
140
+ this.isOpen = false;
141
+ }
142
+
143
+ _createClass(Datepicker, [{
144
+ key: 'destroy',
145
+
146
+
147
+ /**
148
+ * Teardown component
149
+ */
150
+ value: function destroy() {}
151
+ }, {
152
+ key: '_insertHTMLIntoDOM',
153
+ value: function _insertHTMLIntoDOM() {
154
+ this.clearBtn.innerHTML = this.options.i18n.clear;
155
+ this.todayBtn.innerHTML = this.options.i18n.today;
156
+ this.doneBtn.innerHTML = this.options.i18n.done;
157
+
158
+ var containerEl = document.querySelector(this.options.container);
159
+ if (this.options.container && !!containerEl) {
160
+ this.$modalEl.appendTo(containerEl);
161
+ } else {
162
+ this.$modalEl.insertBefore(this.el);
163
+ }
164
+ }
165
+ }, {
166
+ key: '_setupModal',
167
+ value: function _setupModal() {
168
+ var _this = this;
169
+
170
+ this.modalEl.id = 'modal-' + this.id;
171
+ this.modal = new M.Modal(this.modalEl, {
172
+ complete: function () {
173
+ _this.isOpen = false;
174
+ }
175
+ });
176
+ }
177
+ }, {
178
+ key: 'toString',
179
+ value: function toString(format) {
180
+ format = format || this.options.format;
181
+ if (!Datepicker._isDate(this.date)) {
182
+ return '';
183
+ }
184
+ if (this.options.toString) {
185
+ return this.options.toString(this.date, format);
186
+ }
187
+ return this.date.toDateString();
188
+ }
189
+ }, {
190
+ key: 'setDate',
191
+ value: function setDate(date, preventOnSelect) {
192
+ if (!date) {
193
+ this.date = null;
194
+ this._renderDateDisplay();
195
+ return this.draw();
196
+ }
197
+ if (typeof date === 'string') {
198
+ date = new Date(Date.parse(date));
199
+ }
200
+ if (!Datepicker._isDate(date)) {
201
+ return;
202
+ }
203
+
204
+ var min = this.options.minDate,
205
+ max = this.options.maxDate;
206
+
207
+ if (Datepicker._isDate(min) && date < min) {
208
+ date = min;
209
+ } else if (Datepicker._isDate(max) && date > max) {
210
+ date = max;
211
+ }
212
+
213
+ this.date = new Date(date.getTime());
214
+
215
+ this._renderDateDisplay();
216
+
217
+ Datepicker._setToStartOfDay(this.date);
218
+ this.gotoDate(this.date);
219
+
220
+ if (!preventOnSelect && typeof this.options.onSelect === 'function') {
221
+ this.options.onSelect.call(this, this.getDate());
222
+ }
223
+ }
224
+ }, {
225
+ key: 'setInputValue',
226
+ value: function setInputValue() {
227
+ this.el.value = this.toString();
228
+ this.$el.trigger('change', { firedBy: this });
229
+ }
230
+ }, {
231
+ key: '_renderDateDisplay',
232
+ value: function _renderDateDisplay() {
233
+ var displayDate = Datepicker._isDate(this.date) ? this.date : new Date();
234
+ var i18n = this.options.i18n;
235
+ var day = i18n.weekdaysShort[displayDate.getDay()];
236
+ var month = i18n.monthsShort[displayDate.getMonth()];
237
+ var date = displayDate.getDate();
238
+ this.yearTextEl.innerHTML = displayDate.getFullYear();
239
+ this.dateTextEl.innerHTML = day + ', ' + month + ' ' + date;
240
+ }
241
+
242
+ /**
243
+ * change view to a specific date
244
+ */
245
+
246
+ }, {
247
+ key: 'gotoDate',
248
+ value: function gotoDate(date) {
249
+ var newCalendar = true;
250
+
251
+ if (!Datepicker._isDate(date)) {
252
+ return;
253
+ }
254
+
255
+ if (this.calendars) {
256
+ var firstVisibleDate = new Date(this.calendars[0].year, this.calendars[0].month, 1),
257
+ lastVisibleDate = new Date(this.calendars[this.calendars.length - 1].year, this.calendars[this.calendars.length - 1].month, 1),
258
+ visibleDate = date.getTime();
259
+ // get the end of the month
260
+ lastVisibleDate.setMonth(lastVisibleDate.getMonth() + 1);
261
+ lastVisibleDate.setDate(lastVisibleDate.getDate() - 1);
262
+ newCalendar = visibleDate < firstVisibleDate.getTime() || lastVisibleDate.getTime() < visibleDate;
263
+ }
264
+
265
+ if (newCalendar) {
266
+ this.calendars = [{
267
+ month: date.getMonth(),
268
+ year: date.getFullYear()
269
+ }];
270
+ // if (this.options.mainCalendar === 'right') {
271
+ // this.calendars[0].month += 1 - this.options.numberOfMonths;
272
+ // }
273
+ }
274
+
275
+ this.adjustCalendars();
276
+ }
277
+ }, {
278
+ key: 'adjustCalendars',
279
+ value: function adjustCalendars() {
280
+ this.calendars[0] = this.adjustCalendar(this.calendars[0]);
281
+ // for (let c = 1; c < this.options.numberOfMonths; c++) {
282
+ // this.calendars[c] = this.adjustCalendar({
283
+ // month: this.calendars[0].month + c,
284
+ // year: this.calendars[0].year
285
+ // });
286
+ // }
287
+ this.draw();
288
+ }
289
+ }, {
290
+ key: 'adjustCalendar',
291
+ value: function adjustCalendar(calendar) {
292
+ if (calendar.month < 0) {
293
+ calendar.year -= Math.ceil(Math.abs(calendar.month) / 12);
294
+ calendar.month += 12;
295
+ }
296
+ if (calendar.month > 11) {
297
+ calendar.year += Math.floor(Math.abs(calendar.month) / 12);
298
+ calendar.month -= 12;
299
+ }
300
+ return calendar;
301
+ }
302
+ }, {
303
+ key: 'nextMonth',
304
+ value: function nextMonth() {
305
+ this.calendars[0].month++;
306
+ this.adjustCalendars();
307
+ }
308
+ }, {
309
+ key: 'prevMonth',
310
+ value: function prevMonth() {
311
+ this.calendars[0].month--;
312
+ this.adjustCalendars();
313
+ }
314
+ }, {
315
+ key: 'render',
316
+ value: function render(year, month, randId) {
317
+ var opts = this.options,
318
+ now = new Date(),
319
+ days = Datepicker._getDaysInMonth(year, month),
320
+ before = new Date(year, month, 1).getDay(),
321
+ data = [],
322
+ row = [];
323
+ Datepicker._setToStartOfDay(now);
324
+ if (opts.firstDay > 0) {
325
+ before -= opts.firstDay;
326
+ if (before < 0) {
327
+ before += 7;
328
+ }
329
+ }
330
+ var previousMonth = month === 0 ? 11 : month - 1,
331
+ nextMonth = month === 11 ? 0 : month + 1,
332
+ yearOfPreviousMonth = month === 0 ? year - 1 : year,
333
+ yearOfNextMonth = month === 11 ? year + 1 : year,
334
+ daysInPreviousMonth = Datepicker._getDaysInMonth(yearOfPreviousMonth, previousMonth);
335
+ var cells = days + before,
336
+ after = cells;
337
+ while (after > 7) {
338
+ after -= 7;
339
+ }
340
+ cells += 7 - after;
341
+ var isWeekSelected = false;
342
+ for (var i = 0, r = 0; i < cells; i++) {
343
+ var day = new Date(year, month, 1 + (i - before)),
344
+ isSelected = Datepicker._isDate(this.date) ? Datepicker._compareDates(day, this.date) : false,
345
+ isToday = Datepicker._compareDates(day, now),
346
+ hasEvent = opts.events.indexOf(day.toDateString()) !== -1 ? true : false,
347
+ isEmpty = i < before || i >= days + before,
348
+ dayNumber = 1 + (i - before),
349
+ monthNumber = month,
350
+ yearNumber = year,
351
+ isStartRange = opts.startRange && Datepicker._compareDates(opts.startRange, day),
352
+ isEndRange = opts.endRange && Datepicker._compareDates(opts.endRange, day),
353
+ isInRange = opts.startRange && opts.endRange && opts.startRange < day && day < opts.endRange,
354
+ isDisabled = opts.minDate && day < opts.minDate || opts.maxDate && day > opts.maxDate || opts.disableWeekends && Datepicker._isWeekend(day) || opts.disableDayFn && opts.disableDayFn(day);
355
+
356
+ if (isEmpty) {
357
+ if (i < before) {
358
+ dayNumber = daysInPreviousMonth + dayNumber;
359
+ monthNumber = previousMonth;
360
+ yearNumber = yearOfPreviousMonth;
361
+ } else {
362
+ dayNumber = dayNumber - days;
363
+ monthNumber = nextMonth;
364
+ yearNumber = yearOfNextMonth;
365
+ }
366
+ }
367
+
368
+ var dayConfig = {
369
+ day: dayNumber,
370
+ month: monthNumber,
371
+ year: yearNumber,
372
+ hasEvent: hasEvent,
373
+ isSelected: isSelected,
374
+ isToday: isToday,
375
+ isDisabled: isDisabled,
376
+ isEmpty: isEmpty,
377
+ isStartRange: isStartRange,
378
+ isEndRange: isEndRange,
379
+ isInRange: isInRange,
380
+ showDaysInNextAndPreviousMonths: opts.showDaysInNextAndPreviousMonths
381
+ };
382
+
383
+ row.push(this.renderDay(dayConfig));
384
+
385
+ if (++r === 7) {
386
+ data.push(this.renderRow(row, opts.isRTL, isWeekSelected));
387
+ row = [];
388
+ r = 0;
389
+ isWeekSelected = false;
390
+ }
391
+ }
392
+ return this.renderTable(opts, data, randId);
393
+ }
394
+ }, {
395
+ key: 'renderDay',
396
+ value: function renderDay(opts) {
397
+ var arr = [];
398
+ var ariaSelected = 'false';
399
+ if (opts.isEmpty) {
400
+ if (opts.showDaysInNextAndPreviousMonths) {
401
+ arr.push('is-outside-current-month');
402
+ arr.push('is-selection-disabled');
403
+ } else {
404
+ return '<td class="is-empty"></td>';
405
+ }
406
+ }
407
+ if (opts.isDisabled) {
408
+ arr.push('is-disabled');
409
+ }
410
+
411
+ if (opts.isToday) {
412
+ arr.push('is-today');
413
+ }
414
+ if (opts.isSelected) {
415
+ arr.push('is-selected');
416
+ ariaSelected = 'true';
417
+ }
418
+ if (opts.hasEvent) {
419
+ arr.push('has-event');
420
+ }
421
+ if (opts.isInRange) {
422
+ arr.push('is-inrange');
423
+ }
424
+ if (opts.isStartRange) {
425
+ arr.push('is-startrange');
426
+ }
427
+ if (opts.isEndRange) {
428
+ arr.push('is-endrange');
429
+ }
430
+ return '<td data-day="' + opts.day + '" class="' + arr.join(' ') + '" aria-selected="' + ariaSelected + '">' + '<button class="datepicker-day-button" type="button" ' + 'data-pika-year="' + opts.year + '" data-pika-month="' + opts.month + '" data-pika-day="' + opts.day + '">' + opts.day + '</button>' + '</td>';
431
+ }
432
+ }, {
433
+ key: 'renderRow',
434
+ value: function renderRow(days, isRTL, isRowSelected) {
435
+ return '<tr class="pika-row' + (isRowSelected ? ' is-selected' : '') + '">' + (isRTL ? days.reverse() : days).join('') + '</tr>';
436
+ }
437
+ }, {
438
+ key: 'renderTable',
439
+ value: function renderTable(opts, data, randId) {
440
+ return '<div class="datepicker-table-wrapper"><table cellpadding="0" cellspacing="0" class="datepicker-table" role="grid" aria-labelledby="' + randId + '">' + this.renderHead(opts) + this.renderBody(data) + '</table></div>';
441
+ }
442
+ }, {
443
+ key: 'renderHead',
444
+ value: function renderHead(opts) {
445
+ var i = void 0,
446
+ arr = [];
447
+ for (i = 0; i < 7; i++) {
448
+ arr.push('<th scope="col"><abbr title="' + this.renderDayName(opts, i) + '">' + this.renderDayName(opts, i, true) + '</abbr></th>');
449
+ }
450
+ return '<thead><tr>' + (opts.isRTL ? arr.reverse() : arr).join('') + '</tr></thead>';
451
+ }
452
+ }, {
453
+ key: 'renderBody',
454
+ value: function renderBody(rows) {
455
+ return '<tbody>' + rows.join('') + '</tbody>';
456
+ }
457
+ }, {
458
+ key: 'renderTitle',
459
+ value: function renderTitle(instance, c, year, month, refYear, randId) {
460
+ var i = void 0,
461
+ j = void 0,
462
+ arr = void 0,
463
+ opts = this.options,
464
+ isMinYear = year === opts.minYear,
465
+ isMaxYear = year === opts.maxYear,
466
+ html = '<div id="' + randId + '" class="datepicker-controls" role="heading" aria-live="assertive">',
467
+ monthHtml = void 0,
468
+ yearHtml = void 0,
469
+ prev = true,
470
+ next = true;
471
+
472
+ for (arr = [], i = 0; i < 12; i++) {
473
+ arr.push('<option value="' + (year === refYear ? i - c : 12 + i - c) + '"' + (i === month ? ' selected="selected"' : '') + (isMinYear && i < opts.minMonth || isMaxYear && i > opts.maxMonth ? 'disabled="disabled"' : '') + '>' + opts.i18n.months[i] + '</option>');
474
+ }
475
+
476
+ // monthHtml = '<div class="pika-label">' + opts.i18n.months[month] + '<select class="pika-select pika-select-month" tabindex="-1">' + arr.join('') + '</select></div>';
477
+ monthHtml = '<select class="pika-select pika-select-month" tabindex="-1">' + arr.join('') + '</select>';
478
+
479
+ if ($.isArray(opts.yearRange)) {
480
+ i = opts.yearRange[0];
481
+ j = opts.yearRange[1] + 1;
482
+ } else {
483
+ i = year - opts.yearRange;
484
+ j = 1 + year + opts.yearRange;
485
+ }
486
+
487
+ for (arr = []; i < j && i <= opts.maxYear; i++) {
488
+ if (i >= opts.minYear) {
489
+ arr.push('<option value="' + i + '"' + (i === year ? ' selected="selected"' : '') + '>' + i + '</option>');
490
+ }
491
+ }
492
+ // yearHtml = '<div class="pika-label">' + year + opts.yearSuffix + '<select class="pika-select pika-select-year" tabindex="-1">' + arr.join('') + '</select></div>';
493
+ yearHtml = '<select class="pika-select pika-select-year" tabindex="-1">' + arr.join('') + '</select>';
494
+
495
+ var leftArrow = '<svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z"/><path d="M0-.5h24v24H0z" fill="none"/></svg>';
496
+ html += '<button class="month-prev' + (prev ? '' : ' is-disabled') + '" type="button">' + leftArrow + '</button>';
497
+
498
+ html += '<div class="selects-container">';
499
+ if (opts.showMonthAfterYear) {
500
+ html += yearHtml + monthHtml;
501
+ } else {
502
+ html += monthHtml + yearHtml;
503
+ }
504
+ html += '</div>';
505
+
506
+ if (isMinYear && (month === 0 || opts.minMonth >= month)) {
507
+ prev = false;
508
+ }
509
+
510
+ if (isMaxYear && (month === 11 || opts.maxMonth <= month)) {
511
+ next = false;
512
+ }
513
+
514
+ // if (c === (this.options.numberOfMonths - 1) ) {
515
+ var rightArrow = '<svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z"/><path d="M0-.25h24v24H0z" fill="none"/></svg>';
516
+ html += '<button class="month-next' + (next ? '' : ' is-disabled') + '" type="button">' + rightArrow + '</button>';
517
+ // }
518
+
519
+ return html += '</div>';
520
+ }
521
+
522
+ /**
523
+ * refresh the HTML
524
+ */
525
+
526
+ }, {
527
+ key: 'draw',
528
+ value: function draw(force) {
529
+ if (!this.isOpen && !force) {
530
+ return;
531
+ }
532
+ var opts = this.options,
533
+ minYear = opts.minYear,
534
+ maxYear = opts.maxYear,
535
+ minMonth = opts.minMonth,
536
+ maxMonth = opts.maxMonth,
537
+ html = '',
538
+ randId = void 0;
539
+
540
+ if (this._y <= minYear) {
541
+ this._y = minYear;
542
+ if (!isNaN(minMonth) && this._m < minMonth) {
543
+ this._m = minMonth;
544
+ }
545
+ }
546
+ if (this._y >= maxYear) {
547
+ this._y = maxYear;
548
+ if (!isNaN(maxMonth) && this._m > maxMonth) {
549
+ this._m = maxMonth;
550
+ }
551
+ }
552
+
553
+ randId = 'pika-title-' + Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 2);
554
+
555
+ for (var c = 0; c < 1; c++) {
556
+ this._renderDateDisplay();
557
+ html += this.renderTitle(this, c, this.calendars[c].year, this.calendars[c].month, this.calendars[0].year, randId) + this.render(this.calendars[c].year, this.calendars[c].month, randId);
558
+ }
559
+
560
+ this.calendarEl.innerHTML = html;
561
+
562
+ // Init Materialize Select
563
+ new M.Select(this.calendarEl.querySelector('.pika-select-year'), { classes: 'select-year' });
564
+ new M.Select(this.calendarEl.querySelector('.pika-select-month'), { classes: 'select-month' });
565
+
566
+ if (typeof this.options.onDraw === 'function') {
567
+ this.options.onDraw(this);
568
+ }
569
+ }
570
+
571
+ /**
572
+ * Setup Event Handlers
573
+ */
574
+
575
+ }, {
576
+ key: '_setupEventHandlers',
577
+ value: function _setupEventHandlers() {
578
+ this._handleInputKeydownBound = this._handleInputKeydown.bind(this);
579
+ this._handleInputClickBound = this._handleInputClick.bind(this);
580
+ this._handleInputChangeBound = this._handleInputChange.bind(this);
581
+ this._handleCalendarClickBound = this._handleCalendarClick.bind(this);
582
+ this._finishSelectionBound = this._finishSelection.bind(this);
583
+ this._handleTodayClickBound = this._handleTodayClick.bind(this);
584
+ this._handleClearClickBound = this._handleClearClick.bind(this);
585
+
586
+ this.el.addEventListener('click', this._handleInputClickBound);
587
+ this.el.addEventListener('keydown', this._handleInputKeydownBound);
588
+ this.el.addEventListener('change', this._handleInputChangeBound);
589
+ this.calendarEl.addEventListener('click', this._handleCalendarClickBound);
590
+ this.doneBtn.addEventListener('click', this._finishSelectionBound);
591
+ this.todayBtn.addEventListener('click', this._handleTodayClickBound);
592
+ this.clearBtn.addEventListener('click', this._handleClearClickBound);
593
+ }
594
+ }, {
595
+ key: '_setupVariables',
596
+ value: function _setupVariables() {
597
+ this.$modalEl = $(Datepicker._template);
598
+ this.modalEl = this.$modalEl[0];
599
+
600
+ this.calendarEl = this.modalEl.querySelector('.pika-single');
601
+
602
+ this.yearTextEl = this.modalEl.querySelector('.year-text');
603
+ this.dateTextEl = this.modalEl.querySelector('.date-text');
604
+ this.clearBtn = this.modalEl.querySelector('.datepicker-clear');
605
+ this.todayBtn = this.modalEl.querySelector('.datepicker-today');
606
+ this.doneBtn = this.modalEl.querySelector('.datepicker-done');
607
+ }
608
+
609
+ /**
610
+ * Remove Event Handlers
611
+ */
612
+
613
+ }, {
614
+ key: '_removeEventHandlers',
615
+ value: function _removeEventHandlers() {
616
+ this.el.removeEventListener('click', this._handleInputClickBound);
617
+ this.el.removeEventListener('keydown', this._handleInputKeydownBound);
618
+ this.el.removeEventListener('change', this._handleInputChangeBound);
619
+ this.calendarEl.removeEventListener('click', this._handleCalendarClickBound);
620
+ }
621
+ }, {
622
+ key: '_handleInputClick',
623
+ value: function _handleInputClick() {
624
+ this.open();
625
+ }
626
+ }, {
627
+ key: '_handleInputKeydown',
628
+ value: function _handleInputKeydown(e) {
629
+ if (e.which === M.keys.ENTER) {
630
+ e.preventDefault();
631
+ this.open();
632
+ }
633
+ }
634
+ }, {
635
+ key: '_handleCalendarClick',
636
+ value: function _handleCalendarClick(e) {
637
+ if (!this.isOpen) {
638
+ return;
639
+ }
640
+
641
+ var $target = $(e.target);
642
+ if (!$target.hasClass('is-disabled')) {
643
+ if ($target.hasClass('datepicker-day-button') && !$target.hasClass('is-empty') && !$target.parent().hasClass('is-disabled')) {
644
+ this.setDate(new Date(e.target.getAttribute('data-pika-year'), e.target.getAttribute('data-pika-month'), e.target.getAttribute('data-pika-day')));
645
+ } else if ($target.closest('.month-prev').length) {
646
+ this.prevMonth();
647
+ } else if ($target.closest('.month-next').length) {
648
+ this.nextMonth();
649
+ }
650
+ }
651
+ // if (!$target.hasClass('pika-select')) {
652
+ // // if this is touch event prevent mouse events emulation
653
+ // // if (e.preventDefault) {
654
+ // // e.preventDefault();
655
+ // // } else {
656
+ // // e.returnValue = false;
657
+ // // return false;
658
+ // // }
659
+ // } else {
660
+ // this._c = true;
661
+ // }
662
+ }
663
+ }, {
664
+ key: '_handleTodayClick',
665
+ value: function _handleTodayClick() {
666
+ this.date = new Date();
667
+ this.setInputValue();
668
+ this.close();
669
+ }
670
+ }, {
671
+ key: '_handleClearClick',
672
+ value: function _handleClearClick() {
673
+ this.date = null;
674
+ this.setInputValue();
675
+ this.close();
676
+ }
677
+
678
+ // _onChange(e) {
679
+ // e = e || window.event;
680
+ // let target = e.target || e.srcElement;
681
+ // if (!target) {
682
+ // return;
683
+ // }
684
+ // if (hasClass(target, 'pika-select-month')) {
685
+ // self.gotoMonth(target.value);
686
+ // }
687
+ // else if (hasClass(target, 'pika-select-year')) {
688
+ // self.gotoYear(target.value);
689
+ // }
690
+ // }
691
+
692
+ // _onKeyChange(e) {
693
+ // e = e || window.event;
694
+
695
+ // if (self.isVisible()) {
696
+
697
+ // switch(e.keyCode){
698
+ // case 13:
699
+ // case 27:
700
+ // if (opts.field) {
701
+ // opts.field.blur();
702
+ // }
703
+ // break;
704
+ // case 37:
705
+ // e.preventDefault();
706
+ // self.adjustDate('subtract', 1);
707
+ // break;
708
+ // case 38:
709
+ // self.adjustDate('subtract', 7);
710
+ // break;
711
+ // case 39:
712
+ // self.adjustDate('add', 1);
713
+ // break;
714
+ // case 40:
715
+ // self.adjustDate('add', 7);
716
+ // break;
717
+ // }
718
+ // }
719
+ // }
720
+
721
+ }, {
722
+ key: '_handleInputChange',
723
+ value: function _handleInputChange(e) {
724
+ var date = void 0;
725
+
726
+ // Prevent change event from being fired when triggered by the plugin
727
+ if (e.firedBy === this) {
728
+ return;
729
+ }
730
+ if (this.options.parse) {
731
+ date = this.options.parse(this.el.value, this.options.format);
732
+ } else {
733
+ date = new Date(Date.parse(this.el.value));
734
+ }
735
+
736
+ if (Datepicker._isDate(date)) {
737
+ this.setDate(date);
738
+ }
739
+ // if (!self._v) {
740
+ // self.show();
741
+ // }
742
+ }
743
+
744
+ // _onInputBlur() {
745
+ // // IE allows pika div to gain focus; catch blur the input field
746
+ // let pEl = document.activeElement;
747
+ // do {
748
+ // if (hasClass(pEl, 'pika-single')) {
749
+ // return;
750
+ // }
751
+ // }
752
+ // while ((pEl = pEl.parentNode));
753
+
754
+ // if (!self._c) {
755
+ // self._b = sto(function() {
756
+ // self.hide();
757
+ // }, 50);
758
+ // }
759
+ // self._c = false;
760
+ // }
761
+
762
+
763
+ }, {
764
+ key: 'renderDayName',
765
+ value: function renderDayName(opts, day, abbr) {
766
+ day += opts.firstDay;
767
+ while (day >= 7) {
768
+ day -= 7;
769
+ }
770
+ return abbr ? opts.i18n.weekdaysAbbrev[day] : opts.i18n.weekdays[day];
771
+ }
772
+
773
+ /**
774
+ * Set input value to the selected date and close Datepicker
775
+ */
776
+
777
+ }, {
778
+ key: '_finishSelection',
779
+ value: function _finishSelection() {
780
+ this.setInputValue();
781
+ this.close();
782
+ }
783
+
784
+ /**
785
+ * Open Datepicker
786
+ */
787
+
788
+ }, {
789
+ key: 'open',
790
+ value: function open() {
791
+ if (this.isOpen) {
792
+ return;
793
+ }
794
+
795
+ this.isOpen = true;
796
+ if (typeof this.options.onOpen === 'function') {
797
+ this.options.onOpen.call(this);
798
+ }
799
+ this.draw();
800
+ this.modal.open();
801
+ return this;
802
+ }
803
+
804
+ /**
805
+ * Close Datepicker
806
+ */
807
+
808
+ }, {
809
+ key: 'close',
810
+ value: function close() {
811
+ if (!this.isOpen) {
812
+ return;
813
+ }
814
+
815
+ this.isOpen = false;
816
+ if (typeof this.options.onClose === 'function') {
817
+ this.options.onClose.call(this);
818
+ }
819
+ this.modal.close();
820
+ return this;
821
+ }
822
+ }], [{
823
+ key: 'init',
824
+ value: function init($els, options) {
825
+ var arr = [];
826
+ $els.each(function () {
827
+ arr.push(new Datepicker(this, options));
828
+ });
829
+ return arr;
830
+ }
831
+ }, {
832
+ key: '_isDate',
833
+ value: function _isDate(obj) {
834
+ return (/Date/.test(Object.prototype.toString.call(obj)) && !isNaN(obj.getTime())
835
+ );
836
+ }
837
+ }, {
838
+ key: '_isWeekend',
839
+ value: function _isWeekend(date) {
840
+ var day = date.getDay();
841
+ return day === 0 || day === 6;
842
+ }
843
+ }, {
844
+ key: '_setToStartOfDay',
845
+ value: function _setToStartOfDay(date) {
846
+ if (Datepicker._isDate(date)) date.setHours(0, 0, 0, 0);
847
+ }
848
+ }, {
849
+ key: '_getDaysInMonth',
850
+ value: function _getDaysInMonth(year, month) {
851
+ return [31, Datepicker._isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
852
+ }
853
+ }, {
854
+ key: '_isLeapYear',
855
+ value: function _isLeapYear(year) {
856
+ // solution by Matti Virkkunen: http://stackoverflow.com/a/4881951
857
+ return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
858
+ }
859
+ }, {
860
+ key: '_compareDates',
861
+ value: function _compareDates(a, b) {
862
+ // weak date comparison (use setToStartOfDay(date) to ensure correct result)
863
+ return a.getTime() === b.getTime();
864
+ }
865
+ }, {
866
+ key: '_setToStartOfDay',
867
+ value: function _setToStartOfDay(date) {
868
+ if (Datepicker._isDate(date)) date.setHours(0, 0, 0, 0);
869
+ }
870
+
871
+ /**
872
+ * Get Instance
873
+ */
874
+
875
+ }, {
876
+ key: 'getInstance',
877
+ value: function getInstance(el) {
878
+ var domElem = !!el.jquery ? el[0] : el;
879
+ return domElem.M_Datepicker;
880
+ }
881
+ }, {
882
+ key: 'defaults',
883
+ get: function () {
884
+ return _defaults;
885
+ }
886
+ }]);
887
+
888
+ return Datepicker;
889
+ }();
890
+
891
+ Datepicker._template = ['<div class= "modal datepicker-modal">', '<div class="modal-content datepicker-container">', '<div class="datepicker-date-display">', '<span class="year-text"></span>', '<span class="date-text"></span>', '</div>', '<div class="datepicker-calendar-container">', '<div class="pika-single"></div>', '<div class="datepicker-footer">', '<button class="btn-flat datepicker-clear waves-effect" type="button"></button>', '<div class="confirmation-btns">', '<button class="btn-flat datepicker-today waves-effect" type="button"></button>', '<button class="btn-flat datepicker-done waves-effect" type="button"></button>', '</div>', '</div>', '</div>', '</div>', '</div>'].join('');
892
+
893
+ M.Datepicker = Datepicker;
894
+
895
+ if (M.jQueryLoaded) {
896
+ M.initializeJqueryWrapper(Datepicker, 'datepicker', 'M_Datepicker');
897
+ }
898
+ })(cash, M.Vel);