materialize-sass 0.97.0 → 1.0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +5 -5
  2. data/.gitattributes +1 -0
  3. data/.gitignore +3 -0
  4. data/README.md +48 -10
  5. data/Rakefile +129 -1
  6. data/assets/javascripts/materialize/anime.min.js +417 -0
  7. data/assets/javascripts/materialize/autocomplete.js +504 -0
  8. data/assets/javascripts/materialize/buttons.js +409 -0
  9. data/assets/javascripts/materialize/cards.js +34 -0
  10. data/assets/javascripts/materialize/carousel.js +797 -0
  11. data/assets/javascripts/materialize/cash.js +990 -0
  12. data/assets/javascripts/materialize/characterCounter.js +180 -0
  13. data/assets/javascripts/materialize/chips.js +564 -0
  14. data/assets/javascripts/materialize/collapsible.js +337 -0
  15. data/assets/javascripts/materialize/component.js +57 -0
  16. data/assets/javascripts/materialize/datepicker.js +935 -0
  17. data/assets/javascripts/materialize/dropdown.js +659 -0
  18. data/assets/javascripts/materialize/extras/nouislider.js +2147 -0
  19. data/assets/javascripts/materialize/extras/nouislider.min.js +1 -0
  20. data/assets/javascripts/materialize/forms.js +244 -0
  21. data/assets/javascripts/materialize/global.js +408 -0
  22. data/assets/javascripts/materialize/materialbox.js +513 -0
  23. data/assets/javascripts/materialize/modal.js +449 -0
  24. data/assets/javascripts/materialize/parallax.js +173 -0
  25. data/assets/javascripts/materialize/pushpin.js +179 -0
  26. data/assets/javascripts/materialize/range.js +310 -0
  27. data/assets/javascripts/materialize/scrollspy.js +328 -0
  28. data/assets/javascripts/materialize/select.js +497 -0
  29. data/assets/javascripts/materialize/sidenav.js +655 -0
  30. data/assets/javascripts/materialize/slider.js +424 -0
  31. data/assets/javascripts/materialize/tabs.js +476 -0
  32. data/assets/javascripts/materialize/tapTarget.js +364 -0
  33. data/assets/javascripts/materialize/timepicker.js +647 -0
  34. data/assets/javascripts/materialize/toasts.js +355 -0
  35. data/assets/javascripts/materialize/tooltip.js +351 -0
  36. data/{app/assets → assets}/javascripts/materialize/waves.js +42 -47
  37. data/assets/javascripts/materialize-sprockets.js +29 -0
  38. data/assets/javascripts/materialize.js +12374 -0
  39. data/assets/stylesheets/materialize/components/_badges.scss +55 -0
  40. data/assets/stylesheets/materialize/components/_buttons.scss +322 -0
  41. data/{app/assets → assets}/stylesheets/materialize/components/_cards.scss +72 -29
  42. data/assets/stylesheets/materialize/components/_carousel.scss +90 -0
  43. data/assets/stylesheets/materialize/components/_chips.scss +90 -0
  44. data/{app/assets → assets}/stylesheets/materialize/components/_collapsible.scss +23 -17
  45. data/assets/stylesheets/materialize/components/_color-classes.scss +32 -0
  46. data/{app/assets/stylesheets/materialize/components/_color.scss → assets/stylesheets/materialize/components/_color-variables.scss} +22 -64
  47. data/assets/stylesheets/materialize/components/_datepicker.scss +191 -0
  48. data/assets/stylesheets/materialize/components/_dropdown.scss +85 -0
  49. data/{app/assets → assets}/stylesheets/materialize/components/_global.scss +197 -144
  50. data/{app/assets → assets}/stylesheets/materialize/components/_grid.scss +57 -18
  51. data/assets/stylesheets/materialize/components/_icons-material-design.scss +5 -0
  52. data/{app/assets → assets}/stylesheets/materialize/components/_materialbox.scss +15 -13
  53. data/{app/assets → assets}/stylesheets/materialize/components/_modal.scss +18 -14
  54. data/{app/assets → assets}/stylesheets/materialize/components/_navbar.scss +89 -25
  55. data/assets/stylesheets/materialize/components/_normalize.scss +447 -0
  56. data/{app/assets → assets}/stylesheets/materialize/components/_preloader.scss +5 -3
  57. data/assets/stylesheets/materialize/components/_pulse.scss +34 -0
  58. data/assets/stylesheets/materialize/components/_sidenav.scss +208 -0
  59. data/{app/assets → assets}/stylesheets/materialize/components/_slider.scss +2 -2
  60. data/{app/assets → assets}/stylesheets/materialize/components/_table_of_contents.scss +5 -5
  61. data/assets/stylesheets/materialize/components/_tabs.scss +99 -0
  62. data/assets/stylesheets/materialize/components/_tapTarget.scss +103 -0
  63. data/assets/stylesheets/materialize/components/_timepicker.scss +183 -0
  64. data/{app/assets → assets}/stylesheets/materialize/components/_toast.scss +17 -22
  65. data/assets/stylesheets/materialize/components/_tooltip.scss +32 -0
  66. data/assets/stylesheets/materialize/components/_transitions.scss +13 -0
  67. data/{app/assets → assets}/stylesheets/materialize/components/_typography.scss +11 -9
  68. data/assets/stylesheets/materialize/components/_variables.scss +349 -0
  69. data/assets/stylesheets/materialize/components/_waves.scss +114 -0
  70. data/assets/stylesheets/materialize/components/forms/_checkboxes.scss +200 -0
  71. data/assets/stylesheets/materialize/components/forms/_file-input.scss +44 -0
  72. data/assets/stylesheets/materialize/components/forms/_forms.scss +22 -0
  73. data/assets/stylesheets/materialize/components/forms/_input-fields.scss +354 -0
  74. data/assets/stylesheets/materialize/components/forms/_radio-buttons.scss +115 -0
  75. data/assets/stylesheets/materialize/components/forms/_range.scss +161 -0
  76. data/assets/stylesheets/materialize/components/forms/_select.scss +190 -0
  77. data/assets/stylesheets/materialize/components/forms/_switches.scss +89 -0
  78. data/assets/stylesheets/materialize/extras/nouislider.css +406 -0
  79. data/{app/assets → assets}/stylesheets/materialize.scss +13 -10
  80. data/lib/materialize-sass/engine.rb +11 -6
  81. data/lib/materialize-sass/helpers.rb +38 -0
  82. data/lib/materialize-sass/version.rb +1 -1
  83. data/lib/materialize-sass.rb +13 -28
  84. data/materialize-sass.gemspec +5 -5
  85. metadata +97 -105
  86. data/app/assets/fonts/material-design-icons/LICENSE.txt +0 -428
  87. data/app/assets/fonts/material-design-icons/Material-Design-Icons.eot +0 -0
  88. data/app/assets/fonts/material-design-icons/Material-Design-Icons.svg +0 -769
  89. data/app/assets/fonts/material-design-icons/Material-Design-Icons.ttf +0 -0
  90. data/app/assets/fonts/material-design-icons/Material-Design-Icons.woff +0 -0
  91. data/app/assets/fonts/material-design-icons/Material-Design-Icons.woff2 +0 -0
  92. data/app/assets/fonts/roboto/Roboto-Bold.ttf +0 -0
  93. data/app/assets/fonts/roboto/Roboto-Bold.woff +0 -0
  94. data/app/assets/fonts/roboto/Roboto-Bold.woff2 +0 -0
  95. data/app/assets/fonts/roboto/Roboto-Light.ttf +0 -0
  96. data/app/assets/fonts/roboto/Roboto-Light.woff +0 -0
  97. data/app/assets/fonts/roboto/Roboto-Light.woff2 +0 -0
  98. data/app/assets/fonts/roboto/Roboto-Medium.ttf +0 -0
  99. data/app/assets/fonts/roboto/Roboto-Medium.woff +0 -0
  100. data/app/assets/fonts/roboto/Roboto-Medium.woff2 +0 -0
  101. data/app/assets/fonts/roboto/Roboto-Regular.ttf +0 -0
  102. data/app/assets/fonts/roboto/Roboto-Regular.woff +0 -0
  103. data/app/assets/fonts/roboto/Roboto-Regular.woff2 +0 -0
  104. data/app/assets/fonts/roboto/Roboto-Thin.ttf +0 -0
  105. data/app/assets/fonts/roboto/Roboto-Thin.woff +0 -0
  106. data/app/assets/fonts/roboto/Roboto-Thin.woff2 +0 -0
  107. data/app/assets/javascripts/materialize/animation.js +0 -9
  108. data/app/assets/javascripts/materialize/buttons.js +0 -61
  109. data/app/assets/javascripts/materialize/cards.js +0 -27
  110. data/app/assets/javascripts/materialize/character_counter.js +0 -59
  111. data/app/assets/javascripts/materialize/collapsible.js +0 -139
  112. data/app/assets/javascripts/materialize/date_picker/picker.date.js +0 -1430
  113. data/app/assets/javascripts/materialize/date_picker/picker.js +0 -1123
  114. data/app/assets/javascripts/materialize/dropdown.js +0 -178
  115. data/app/assets/javascripts/materialize/forms.js +0 -456
  116. data/app/assets/javascripts/materialize/global.js +0 -36
  117. data/app/assets/javascripts/materialize/hammer.min.js +0 -1
  118. data/app/assets/javascripts/materialize/init.js +0 -136
  119. data/app/assets/javascripts/materialize/jquery.easing.1.3.js +0 -205
  120. data/app/assets/javascripts/materialize/jquery.hammer.js +0 -33
  121. data/app/assets/javascripts/materialize/jquery.timeago.min.js +0 -1
  122. data/app/assets/javascripts/materialize/leanModal.js +0 -178
  123. data/app/assets/javascripts/materialize/materialbox.js +0 -249
  124. data/app/assets/javascripts/materialize/parallax.js +0 -58
  125. data/app/assets/javascripts/materialize/prism.js +0 -8
  126. data/app/assets/javascripts/materialize/pushpin.js +0 -62
  127. data/app/assets/javascripts/materialize/scrollFire.js +0 -44
  128. data/app/assets/javascripts/materialize/scrollspy.js +0 -284
  129. data/app/assets/javascripts/materialize/sideNav.js +0 -312
  130. data/app/assets/javascripts/materialize/slider.js +0 -301
  131. data/app/assets/javascripts/materialize/tabs.js +0 -136
  132. data/app/assets/javascripts/materialize/toasts.js +0 -125
  133. data/app/assets/javascripts/materialize/tooltip.js +0 -166
  134. data/app/assets/javascripts/materialize/transitions.js +0 -154
  135. data/app/assets/javascripts/materialize/velocity.min.js +0 -4
  136. data/app/assets/javascripts/materialize-sprockets.js +0 -27
  137. data/app/assets/javascripts/materialize.js +0 -6159
  138. data/app/assets/stylesheets/materialize/components/_buttons.scss +0 -157
  139. data/app/assets/stylesheets/materialize/components/_dropdown.scss +0 -40
  140. data/app/assets/stylesheets/materialize/components/_form.scss +0 -886
  141. data/app/assets/stylesheets/materialize/components/_icons-material-design.scss +0 -3257
  142. data/app/assets/stylesheets/materialize/components/_mixins.scss +0 -5
  143. data/app/assets/stylesheets/materialize/components/_normalize.scss +0 -427
  144. data/app/assets/stylesheets/materialize/components/_prefixer.scss +0 -376
  145. data/app/assets/stylesheets/materialize/components/_roboto.scss +0 -38
  146. data/app/assets/stylesheets/materialize/components/_sideNav.scss +0 -111
  147. data/app/assets/stylesheets/materialize/components/_tabs.scss +0 -47
  148. data/app/assets/stylesheets/materialize/components/_tooltip.scss +0 -34
  149. data/app/assets/stylesheets/materialize/components/_variables.scss +0 -152
  150. data/app/assets/stylesheets/materialize/components/_waves.scss +0 -167
  151. data/app/assets/stylesheets/materialize/components/date_picker/_default.date.scss +0 -435
  152. data/app/assets/stylesheets/materialize/components/date_picker/_default.scss +0 -201
  153. data/app/assets/stylesheets/materialize/components/date_picker/_default.time.scss +0 -125
@@ -0,0 +1,647 @@
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
+ var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
4
+
5
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
+
7
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
+
9
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
10
+
11
+ (function ($) {
12
+ 'use strict';
13
+
14
+ var _defaults = {
15
+ dialRadius: 135,
16
+ outerRadius: 105,
17
+ innerRadius: 70,
18
+ tickRadius: 20,
19
+ duration: 350,
20
+ container: null,
21
+ defaultTime: 'now', // default time, 'now' or '13:14' e.g.
22
+ fromNow: 0, // Millisecond offset from the defaultTime
23
+ showClearBtn: false,
24
+
25
+ // internationalization
26
+ i18n: {
27
+ cancel: 'Cancel',
28
+ clear: 'Clear',
29
+ done: 'Ok'
30
+ },
31
+
32
+ autoClose: false, // auto close when minute is selected
33
+ twelveHour: true, // change to 12 hour AM/PM clock from 24 hour
34
+ vibrate: true, // vibrate the device when dragging clock hand
35
+
36
+ // Callbacks
37
+ onOpenStart: null,
38
+ onOpenEnd: null,
39
+ onCloseStart: null,
40
+ onCloseEnd: null,
41
+ onSelect: null
42
+ };
43
+
44
+ /**
45
+ * @class
46
+ *
47
+ */
48
+
49
+ var Timepicker = function (_Component) {
50
+ _inherits(Timepicker, _Component);
51
+
52
+ function Timepicker(el, options) {
53
+ _classCallCheck(this, Timepicker);
54
+
55
+ var _this = _possibleConstructorReturn(this, (Timepicker.__proto__ || Object.getPrototypeOf(Timepicker)).call(this, Timepicker, el, options));
56
+
57
+ _this.el.M_Timepicker = _this;
58
+
59
+ _this.options = $.extend({}, Timepicker.defaults, options);
60
+
61
+ _this.id = M.guid();
62
+ _this._insertHTMLIntoDOM();
63
+ _this._setupModal();
64
+ _this._setupVariables();
65
+ _this._setupEventHandlers();
66
+
67
+ _this._clockSetup();
68
+ _this._pickerSetup();
69
+ return _this;
70
+ }
71
+
72
+ _createClass(Timepicker, [{
73
+ key: 'destroy',
74
+
75
+
76
+ /**
77
+ * Teardown component
78
+ */
79
+ value: function destroy() {
80
+ this._removeEventHandlers();
81
+ this.modal.destroy();
82
+ $(this.modalEl).remove();
83
+ this.el.M_Timepicker = undefined;
84
+ }
85
+
86
+ /**
87
+ * Setup Event Handlers
88
+ */
89
+
90
+ }, {
91
+ key: '_setupEventHandlers',
92
+ value: function _setupEventHandlers() {
93
+ this._handleInputKeydownBound = this._handleInputKeydown.bind(this);
94
+ this._handleInputClickBound = this._handleInputClick.bind(this);
95
+ this._handleClockClickStartBound = this._handleClockClickStart.bind(this);
96
+ this._handleDocumentClickMoveBound = this._handleDocumentClickMove.bind(this);
97
+ this._handleDocumentClickEndBound = this._handleDocumentClickEnd.bind(this);
98
+
99
+ this.el.addEventListener('click', this._handleInputClickBound);
100
+ this.el.addEventListener('keydown', this._handleInputKeydownBound);
101
+ this.plate.addEventListener('mousedown', this._handleClockClickStartBound);
102
+ this.plate.addEventListener('touchstart', this._handleClockClickStartBound);
103
+
104
+ $(this.spanHours).on('click', this.showView.bind(this, 'hours'));
105
+ $(this.spanMinutes).on('click', this.showView.bind(this, 'minutes'));
106
+ }
107
+ }, {
108
+ key: '_removeEventHandlers',
109
+ value: function _removeEventHandlers() {
110
+ this.el.removeEventListener('click', this._handleInputClickBound);
111
+ this.el.removeEventListener('keydown', this._handleInputKeydownBound);
112
+ }
113
+ }, {
114
+ key: '_handleInputClick',
115
+ value: function _handleInputClick() {
116
+ this.open();
117
+ }
118
+ }, {
119
+ key: '_handleInputKeydown',
120
+ value: function _handleInputKeydown(e) {
121
+ if (e.which === M.keys.ENTER) {
122
+ e.preventDefault();
123
+ this.open();
124
+ }
125
+ }
126
+ }, {
127
+ key: '_handleClockClickStart',
128
+ value: function _handleClockClickStart(e) {
129
+ e.preventDefault();
130
+ var clockPlateBR = this.plate.getBoundingClientRect();
131
+ var offset = { x: clockPlateBR.left, y: clockPlateBR.top };
132
+
133
+ this.x0 = offset.x + this.options.dialRadius;
134
+ this.y0 = offset.y + this.options.dialRadius;
135
+ this.moved = false;
136
+ var clickPos = Timepicker._Pos(e);
137
+ this.dx = clickPos.x - this.x0;
138
+ this.dy = clickPos.y - this.y0;
139
+
140
+ // Set clock hands
141
+ this.setHand(this.dx, this.dy, false);
142
+
143
+ // Mousemove on document
144
+ document.addEventListener('mousemove', this._handleDocumentClickMoveBound);
145
+ document.addEventListener('touchmove', this._handleDocumentClickMoveBound);
146
+
147
+ // Mouseup on document
148
+ document.addEventListener('mouseup', this._handleDocumentClickEndBound);
149
+ document.addEventListener('touchend', this._handleDocumentClickEndBound);
150
+ }
151
+ }, {
152
+ key: '_handleDocumentClickMove',
153
+ value: function _handleDocumentClickMove(e) {
154
+ e.preventDefault();
155
+ var clickPos = Timepicker._Pos(e);
156
+ var x = clickPos.x - this.x0;
157
+ var y = clickPos.y - this.y0;
158
+ this.moved = true;
159
+ this.setHand(x, y, false, true);
160
+ }
161
+ }, {
162
+ key: '_handleDocumentClickEnd',
163
+ value: function _handleDocumentClickEnd(e) {
164
+ var _this2 = this;
165
+
166
+ e.preventDefault();
167
+ document.removeEventListener('mouseup', this._handleDocumentClickEndBound);
168
+ document.removeEventListener('touchend', this._handleDocumentClickEndBound);
169
+ var clickPos = Timepicker._Pos(e);
170
+ var x = clickPos.x - this.x0;
171
+ var y = clickPos.y - this.y0;
172
+ if (this.moved && x === this.dx && y === this.dy) {
173
+ this.setHand(x, y);
174
+ }
175
+
176
+ if (this.currentView === 'hours') {
177
+ this.showView('minutes', this.options.duration / 2);
178
+ } else if (this.options.autoClose) {
179
+ $(this.minutesView).addClass('timepicker-dial-out');
180
+ setTimeout(function () {
181
+ _this2.done();
182
+ }, this.options.duration / 2);
183
+ }
184
+
185
+ if (typeof this.options.onSelect === 'function') {
186
+ this.options.onSelect.call(this, this.hours, this.minutes);
187
+ }
188
+
189
+ // Unbind mousemove event
190
+ document.removeEventListener('mousemove', this._handleDocumentClickMoveBound);
191
+ document.removeEventListener('touchmove', this._handleDocumentClickMoveBound);
192
+ }
193
+ }, {
194
+ key: '_insertHTMLIntoDOM',
195
+ value: function _insertHTMLIntoDOM() {
196
+ this.$modalEl = $(Timepicker._template);
197
+ this.modalEl = this.$modalEl[0];
198
+ this.modalEl.id = 'modal-' + this.id;
199
+
200
+ // Append popover to input by default
201
+ var containerEl = document.querySelector(this.options.container);
202
+ if (this.options.container && !!containerEl) {
203
+ this.$modalEl.appendTo(containerEl);
204
+ } else {
205
+ this.$modalEl.insertBefore(this.el);
206
+ }
207
+ }
208
+ }, {
209
+ key: '_setupModal',
210
+ value: function _setupModal() {
211
+ var _this3 = this;
212
+
213
+ this.modal = M.Modal.init(this.modalEl, {
214
+ onOpenStart: this.options.onOpenStart,
215
+ onOpenEnd: this.options.onOpenEnd,
216
+ onCloseStart: this.options.onCloseStart,
217
+ onCloseEnd: function () {
218
+ if (typeof _this3.options.onCloseEnd === 'function') {
219
+ _this3.options.onCloseEnd.call(_this3);
220
+ }
221
+ _this3.isOpen = false;
222
+ }
223
+ });
224
+ }
225
+ }, {
226
+ key: '_setupVariables',
227
+ value: function _setupVariables() {
228
+ this.currentView = 'hours';
229
+ this.vibrate = navigator.vibrate ? 'vibrate' : navigator.webkitVibrate ? 'webkitVibrate' : null;
230
+
231
+ this._canvas = this.modalEl.querySelector('.timepicker-canvas');
232
+ this.plate = this.modalEl.querySelector('.timepicker-plate');
233
+
234
+ this.hoursView = this.modalEl.querySelector('.timepicker-hours');
235
+ this.minutesView = this.modalEl.querySelector('.timepicker-minutes');
236
+ this.spanHours = this.modalEl.querySelector('.timepicker-span-hours');
237
+ this.spanMinutes = this.modalEl.querySelector('.timepicker-span-minutes');
238
+ this.spanAmPm = this.modalEl.querySelector('.timepicker-span-am-pm');
239
+ this.footer = this.modalEl.querySelector('.timepicker-footer');
240
+ this.amOrPm = 'PM';
241
+ }
242
+ }, {
243
+ key: '_pickerSetup',
244
+ value: function _pickerSetup() {
245
+ var $clearBtn = $('<button class="btn-flat timepicker-clear waves-effect" style="visibility: hidden;" type="button" tabindex="' + (this.options.twelveHour ? '3' : '1') + '">' + this.options.i18n.clear + '</button>').appendTo(this.footer).on('click', this.clear.bind(this));
246
+ if (this.options.showClearBtn) {
247
+ $clearBtn.css({ visibility: '' });
248
+ }
249
+
250
+ var confirmationBtnsContainer = $('<div class="confirmation-btns"></div>');
251
+ $('<button class="btn-flat timepicker-close waves-effect" type="button" tabindex="' + (this.options.twelveHour ? '3' : '1') + '">' + this.options.i18n.cancel + '</button>').appendTo(confirmationBtnsContainer).on('click', this.close.bind(this));
252
+ $('<button class="btn-flat timepicker-close waves-effect" type="button" tabindex="' + (this.options.twelveHour ? '3' : '1') + '">' + this.options.i18n.done + '</button>').appendTo(confirmationBtnsContainer).on('click', this.done.bind(this));
253
+ confirmationBtnsContainer.appendTo(this.footer);
254
+ }
255
+ }, {
256
+ key: '_clockSetup',
257
+ value: function _clockSetup() {
258
+ if (this.options.twelveHour) {
259
+ this.$amBtn = $('<div class="am-btn">AM</div>');
260
+ this.$pmBtn = $('<div class="pm-btn">PM</div>');
261
+ this.$amBtn.on('click', this._handleAmPmClick.bind(this)).appendTo(this.spanAmPm);
262
+ this.$pmBtn.on('click', this._handleAmPmClick.bind(this)).appendTo(this.spanAmPm);
263
+ }
264
+
265
+ this._buildHoursView();
266
+ this._buildMinutesView();
267
+ this._buildSVGClock();
268
+ }
269
+ }, {
270
+ key: '_buildSVGClock',
271
+ value: function _buildSVGClock() {
272
+ // Draw clock hands and others
273
+ var dialRadius = this.options.dialRadius;
274
+ var tickRadius = this.options.tickRadius;
275
+ var diameter = dialRadius * 2;
276
+
277
+ var svg = Timepicker._createSVGEl('svg');
278
+ svg.setAttribute('class', 'timepicker-svg');
279
+ svg.setAttribute('width', diameter);
280
+ svg.setAttribute('height', diameter);
281
+ var g = Timepicker._createSVGEl('g');
282
+ g.setAttribute('transform', 'translate(' + dialRadius + ',' + dialRadius + ')');
283
+ var bearing = Timepicker._createSVGEl('circle');
284
+ bearing.setAttribute('class', 'timepicker-canvas-bearing');
285
+ bearing.setAttribute('cx', 0);
286
+ bearing.setAttribute('cy', 0);
287
+ bearing.setAttribute('r', 4);
288
+ var hand = Timepicker._createSVGEl('line');
289
+ hand.setAttribute('x1', 0);
290
+ hand.setAttribute('y1', 0);
291
+ var bg = Timepicker._createSVGEl('circle');
292
+ bg.setAttribute('class', 'timepicker-canvas-bg');
293
+ bg.setAttribute('r', tickRadius);
294
+ g.appendChild(hand);
295
+ g.appendChild(bg);
296
+ g.appendChild(bearing);
297
+ svg.appendChild(g);
298
+ this._canvas.appendChild(svg);
299
+
300
+ this.hand = hand;
301
+ this.bg = bg;
302
+ this.bearing = bearing;
303
+ this.g = g;
304
+ }
305
+ }, {
306
+ key: '_buildHoursView',
307
+ value: function _buildHoursView() {
308
+ var $tick = $('<div class="timepicker-tick"></div>');
309
+ // Hours view
310
+ if (this.options.twelveHour) {
311
+ for (var i = 1; i < 13; i += 1) {
312
+ var tick = $tick.clone();
313
+ var radian = i / 6 * Math.PI;
314
+ var radius = this.options.outerRadius;
315
+ tick.css({
316
+ left: this.options.dialRadius + Math.sin(radian) * radius - this.options.tickRadius + 'px',
317
+ top: this.options.dialRadius - Math.cos(radian) * radius - this.options.tickRadius + 'px'
318
+ });
319
+ tick.html(i === 0 ? '00' : i);
320
+ this.hoursView.appendChild(tick[0]);
321
+ // tick.on(mousedownEvent, mousedown);
322
+ }
323
+ } else {
324
+ for (var _i = 0; _i < 24; _i += 1) {
325
+ var _tick = $tick.clone();
326
+ var _radian = _i / 6 * Math.PI;
327
+ var inner = _i > 0 && _i < 13;
328
+ var _radius = inner ? this.options.innerRadius : this.options.outerRadius;
329
+ _tick.css({
330
+ left: this.options.dialRadius + Math.sin(_radian) * _radius - this.options.tickRadius + 'px',
331
+ top: this.options.dialRadius - Math.cos(_radian) * _radius - this.options.tickRadius + 'px'
332
+ });
333
+ _tick.html(_i === 0 ? '00' : _i);
334
+ this.hoursView.appendChild(_tick[0]);
335
+ // tick.on(mousedownEvent, mousedown);
336
+ }
337
+ }
338
+ }
339
+ }, {
340
+ key: '_buildMinutesView',
341
+ value: function _buildMinutesView() {
342
+ var $tick = $('<div class="timepicker-tick"></div>');
343
+ // Minutes view
344
+ for (var i = 0; i < 60; i += 5) {
345
+ var tick = $tick.clone();
346
+ var radian = i / 30 * Math.PI;
347
+ tick.css({
348
+ left: this.options.dialRadius + Math.sin(radian) * this.options.outerRadius - this.options.tickRadius + 'px',
349
+ top: this.options.dialRadius - Math.cos(radian) * this.options.outerRadius - this.options.tickRadius + 'px'
350
+ });
351
+ tick.html(Timepicker._addLeadingZero(i));
352
+ this.minutesView.appendChild(tick[0]);
353
+ }
354
+ }
355
+ }, {
356
+ key: '_handleAmPmClick',
357
+ value: function _handleAmPmClick(e) {
358
+ var $btnClicked = $(e.target);
359
+ this.amOrPm = $btnClicked.hasClass('am-btn') ? 'AM' : 'PM';
360
+ this._updateAmPmView();
361
+ }
362
+ }, {
363
+ key: '_updateAmPmView',
364
+ value: function _updateAmPmView() {
365
+ if (this.options.twelveHour) {
366
+ this.$amBtn.toggleClass('text-primary', this.amOrPm === 'AM');
367
+ this.$pmBtn.toggleClass('text-primary', this.amOrPm === 'PM');
368
+ }
369
+ }
370
+ }, {
371
+ key: '_updateTimeFromInput',
372
+ value: function _updateTimeFromInput() {
373
+ // Get the time
374
+ var value = ((this.el.value || this.options.defaultTime || '') + '').split(':');
375
+ if (this.options.twelveHour && !(typeof value[1] === 'undefined')) {
376
+ if (value[1].toUpperCase().indexOf('AM') > 0) {
377
+ this.amOrPm = 'AM';
378
+ } else {
379
+ this.amOrPm = 'PM';
380
+ }
381
+ value[1] = value[1].replace('AM', '').replace('PM', '');
382
+ }
383
+ if (value[0] === 'now') {
384
+ var now = new Date(+new Date() + this.options.fromNow);
385
+ value = [now.getHours(), now.getMinutes()];
386
+ if (this.options.twelveHour) {
387
+ this.amOrPm = value[0] >= 12 && value[0] < 24 ? 'PM' : 'AM';
388
+ }
389
+ }
390
+ this.hours = +value[0] || 0;
391
+ this.minutes = +value[1] || 0;
392
+ this.spanHours.innerHTML = this.hours;
393
+ this.spanMinutes.innerHTML = Timepicker._addLeadingZero(this.minutes);
394
+
395
+ this._updateAmPmView();
396
+ }
397
+ }, {
398
+ key: 'showView',
399
+ value: function showView(view, delay) {
400
+ if (view === 'minutes' && $(this.hoursView).css('visibility') === 'visible') {
401
+ // raiseCallback(this.options.beforeHourSelect);
402
+ }
403
+ var isHours = view === 'hours',
404
+ nextView = isHours ? this.hoursView : this.minutesView,
405
+ hideView = isHours ? this.minutesView : this.hoursView;
406
+ this.currentView = view;
407
+
408
+ $(this.spanHours).toggleClass('text-primary', isHours);
409
+ $(this.spanMinutes).toggleClass('text-primary', !isHours);
410
+
411
+ // Transition view
412
+ hideView.classList.add('timepicker-dial-out');
413
+ $(nextView).css('visibility', 'visible').removeClass('timepicker-dial-out');
414
+
415
+ // Reset clock hand
416
+ this.resetClock(delay);
417
+
418
+ // After transitions ended
419
+ clearTimeout(this.toggleViewTimer);
420
+ this.toggleViewTimer = setTimeout(function () {
421
+ $(hideView).css('visibility', 'hidden');
422
+ }, this.options.duration);
423
+ }
424
+ }, {
425
+ key: 'resetClock',
426
+ value: function resetClock(delay) {
427
+ var view = this.currentView,
428
+ value = this[view],
429
+ isHours = view === 'hours',
430
+ unit = Math.PI / (isHours ? 6 : 30),
431
+ radian = value * unit,
432
+ radius = isHours && value > 0 && value < 13 ? this.options.innerRadius : this.options.outerRadius,
433
+ x = Math.sin(radian) * radius,
434
+ y = -Math.cos(radian) * radius,
435
+ self = this;
436
+
437
+ if (delay) {
438
+ $(this.canvas).addClass('timepicker-canvas-out');
439
+ setTimeout(function () {
440
+ $(self.canvas).removeClass('timepicker-canvas-out');
441
+ self.setHand(x, y);
442
+ }, delay);
443
+ } else {
444
+ this.setHand(x, y);
445
+ }
446
+ }
447
+ }, {
448
+ key: 'setHand',
449
+ value: function setHand(x, y, roundBy5) {
450
+ var _this4 = this;
451
+
452
+ var radian = Math.atan2(x, -y),
453
+ isHours = this.currentView === 'hours',
454
+ unit = Math.PI / (isHours || roundBy5 ? 6 : 30),
455
+ z = Math.sqrt(x * x + y * y),
456
+ inner = isHours && z < (this.options.outerRadius + this.options.innerRadius) / 2,
457
+ radius = inner ? this.options.innerRadius : this.options.outerRadius;
458
+
459
+ if (this.options.twelveHour) {
460
+ radius = this.options.outerRadius;
461
+ }
462
+
463
+ // Radian should in range [0, 2PI]
464
+ if (radian < 0) {
465
+ radian = Math.PI * 2 + radian;
466
+ }
467
+
468
+ // Get the round value
469
+ var value = Math.round(radian / unit);
470
+
471
+ // Get the round radian
472
+ radian = value * unit;
473
+
474
+ // Correct the hours or minutes
475
+ if (this.options.twelveHour) {
476
+ if (isHours) {
477
+ if (value === 0) value = 12;
478
+ } else {
479
+ if (roundBy5) value *= 5;
480
+ if (value === 60) value = 0;
481
+ }
482
+ } else {
483
+ if (isHours) {
484
+ if (value === 12) {
485
+ value = 0;
486
+ }
487
+ value = inner ? value === 0 ? 12 : value : value === 0 ? 0 : value + 12;
488
+ } else {
489
+ if (roundBy5) {
490
+ value *= 5;
491
+ }
492
+ if (value === 60) {
493
+ value = 0;
494
+ }
495
+ }
496
+ }
497
+
498
+ // Once hours or minutes changed, vibrate the device
499
+ if (this[this.currentView] !== value) {
500
+ if (this.vibrate && this.options.vibrate) {
501
+ // Do not vibrate too frequently
502
+ if (!this.vibrateTimer) {
503
+ navigator[this.vibrate](10);
504
+ this.vibrateTimer = setTimeout(function () {
505
+ _this4.vibrateTimer = null;
506
+ }, 100);
507
+ }
508
+ }
509
+ }
510
+
511
+ this[this.currentView] = value;
512
+ if (isHours) {
513
+ this['spanHours'].innerHTML = value;
514
+ } else {
515
+ this['spanMinutes'].innerHTML = Timepicker._addLeadingZero(value);
516
+ }
517
+
518
+ // Set clock hand and others' position
519
+ var cx1 = Math.sin(radian) * (radius - this.options.tickRadius),
520
+ cy1 = -Math.cos(radian) * (radius - this.options.tickRadius),
521
+ cx2 = Math.sin(radian) * radius,
522
+ cy2 = -Math.cos(radian) * radius;
523
+ this.hand.setAttribute('x2', cx1);
524
+ this.hand.setAttribute('y2', cy1);
525
+ this.bg.setAttribute('cx', cx2);
526
+ this.bg.setAttribute('cy', cy2);
527
+ }
528
+ }, {
529
+ key: 'open',
530
+ value: function open() {
531
+ if (this.isOpen) {
532
+ return;
533
+ }
534
+
535
+ this.isOpen = true;
536
+ this._updateTimeFromInput();
537
+ this.showView('hours');
538
+
539
+ this.modal.open();
540
+ }
541
+ }, {
542
+ key: 'close',
543
+ value: function close() {
544
+ if (!this.isOpen) {
545
+ return;
546
+ }
547
+
548
+ this.isOpen = false;
549
+ this.modal.close();
550
+ }
551
+
552
+ /**
553
+ * Finish timepicker selection.
554
+ */
555
+
556
+ }, {
557
+ key: 'done',
558
+ value: function done(e, clearValue) {
559
+ // Set input value
560
+ var last = this.el.value;
561
+ var value = clearValue ? '' : Timepicker._addLeadingZero(this.hours) + ':' + Timepicker._addLeadingZero(this.minutes);
562
+ this.time = value;
563
+ if (!clearValue && this.options.twelveHour) {
564
+ value = value + ' ' + this.amOrPm;
565
+ }
566
+ this.el.value = value;
567
+
568
+ // Trigger change event
569
+ if (value !== last) {
570
+ this.$el.trigger('change');
571
+ }
572
+
573
+ this.close();
574
+ this.el.focus();
575
+ }
576
+ }, {
577
+ key: 'clear',
578
+ value: function clear() {
579
+ this.done(null, true);
580
+ }
581
+ }], [{
582
+ key: 'init',
583
+ value: function init(els, options) {
584
+ return _get(Timepicker.__proto__ || Object.getPrototypeOf(Timepicker), 'init', this).call(this, this, els, options);
585
+ }
586
+ }, {
587
+ key: '_addLeadingZero',
588
+ value: function _addLeadingZero(num) {
589
+ return (num < 10 ? '0' : '') + num;
590
+ }
591
+ }, {
592
+ key: '_createSVGEl',
593
+ value: function _createSVGEl(name) {
594
+ var svgNS = 'http://www.w3.org/2000/svg';
595
+ return document.createElementNS(svgNS, name);
596
+ }
597
+
598
+ /**
599
+ * @typedef {Object} Point
600
+ * @property {number} x The X Coordinate
601
+ * @property {number} y The Y Coordinate
602
+ */
603
+
604
+ /**
605
+ * Get x position of mouse or touch event
606
+ * @param {Event} e
607
+ * @return {Point} x and y location
608
+ */
609
+
610
+ }, {
611
+ key: '_Pos',
612
+ value: function _Pos(e) {
613
+ if (e.targetTouches && e.targetTouches.length >= 1) {
614
+ return { x: e.targetTouches[0].clientX, y: e.targetTouches[0].clientY };
615
+ }
616
+ // mouse event
617
+ return { x: e.clientX, y: e.clientY };
618
+ }
619
+
620
+ /**
621
+ * Get Instance
622
+ */
623
+
624
+ }, {
625
+ key: 'getInstance',
626
+ value: function getInstance(el) {
627
+ var domElem = !!el.jquery ? el[0] : el;
628
+ return domElem.M_Timepicker;
629
+ }
630
+ }, {
631
+ key: 'defaults',
632
+ get: function () {
633
+ return _defaults;
634
+ }
635
+ }]);
636
+
637
+ return Timepicker;
638
+ }(Component);
639
+
640
+ Timepicker._template = ['<div class= "modal timepicker-modal">', '<div class="modal-content timepicker-container">', '<div class="timepicker-digital-display">', '<div class="timepicker-text-container">', '<div class="timepicker-display-column">', '<span class="timepicker-span-hours text-primary"></span>', ':', '<span class="timepicker-span-minutes"></span>', '</div>', '<div class="timepicker-display-column timepicker-display-am-pm">', '<div class="timepicker-span-am-pm"></div>', '</div>', '</div>', '</div>', '<div class="timepicker-analog-display">', '<div class="timepicker-plate">', '<div class="timepicker-canvas"></div>', '<div class="timepicker-dial timepicker-hours"></div>', '<div class="timepicker-dial timepicker-minutes timepicker-dial-out"></div>', '</div>', '<div class="timepicker-footer"></div>', '</div>', '</div>', '</div>'].join('');
641
+
642
+ M.Timepicker = Timepicker;
643
+
644
+ if (M.jQueryLoaded) {
645
+ M.initializeJqueryWrapper(Timepicker, 'timepicker', 'M_Timepicker');
646
+ }
647
+ })(cash);