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,564 @@
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
+ data: [],
16
+ placeholder: '',
17
+ secondaryPlaceholder: '',
18
+ autocompleteOptions: {},
19
+ limit: Infinity,
20
+ onChipAdd: null,
21
+ onChipSelect: null,
22
+ onChipDelete: null
23
+ };
24
+
25
+ /**
26
+ * @typedef {Object} chip
27
+ * @property {String} tag chip tag string
28
+ * @property {String} [image] chip avatar image string
29
+ */
30
+
31
+ /**
32
+ * @class
33
+ *
34
+ */
35
+
36
+ var Chips = function (_Component) {
37
+ _inherits(Chips, _Component);
38
+
39
+ /**
40
+ * Construct Chips instance and set up overlay
41
+ * @constructor
42
+ * @param {Element} el
43
+ * @param {Object} options
44
+ */
45
+ function Chips(el, options) {
46
+ _classCallCheck(this, Chips);
47
+
48
+ var _this = _possibleConstructorReturn(this, (Chips.__proto__ || Object.getPrototypeOf(Chips)).call(this, Chips, el, options));
49
+
50
+ _this.el.M_Chips = _this;
51
+
52
+ /**
53
+ * Options for the modal
54
+ * @member Chips#options
55
+ * @prop {Array} data
56
+ * @prop {String} placeholder
57
+ * @prop {String} secondaryPlaceholder
58
+ * @prop {Object} autocompleteOptions
59
+ */
60
+ _this.options = $.extend({}, Chips.defaults, options);
61
+
62
+ _this.$el.addClass('chips input-field');
63
+ _this.chipsData = [];
64
+ _this.$chips = $();
65
+ _this._setupInput();
66
+ _this.hasAutocomplete = Object.keys(_this.options.autocompleteOptions).length > 0;
67
+
68
+ // Set input id
69
+ if (!_this.$input.attr('id')) {
70
+ _this.$input.attr('id', M.guid());
71
+ }
72
+
73
+ // Render initial chips
74
+ if (_this.options.data.length) {
75
+ _this.chipsData = _this.options.data;
76
+ _this._renderChips(_this.chipsData);
77
+ }
78
+
79
+ // Setup autocomplete if needed
80
+ if (_this.hasAutocomplete) {
81
+ _this._setupAutocomplete();
82
+ }
83
+
84
+ _this._setPlaceholder();
85
+ _this._setupLabel();
86
+ _this._setupEventHandlers();
87
+ return _this;
88
+ }
89
+
90
+ _createClass(Chips, [{
91
+ key: 'getData',
92
+
93
+
94
+ /**
95
+ * Get Chips Data
96
+ */
97
+ value: function getData() {
98
+ return this.chipsData;
99
+ }
100
+
101
+ /**
102
+ * Teardown component
103
+ */
104
+
105
+ }, {
106
+ key: 'destroy',
107
+ value: function destroy() {
108
+ this._removeEventHandlers();
109
+ this.$chips.remove();
110
+ this.el.M_Chips = undefined;
111
+ }
112
+
113
+ /**
114
+ * Setup Event Handlers
115
+ */
116
+
117
+ }, {
118
+ key: '_setupEventHandlers',
119
+ value: function _setupEventHandlers() {
120
+ this._handleChipClickBound = this._handleChipClick.bind(this);
121
+ this._handleInputKeydownBound = this._handleInputKeydown.bind(this);
122
+ this._handleInputFocusBound = this._handleInputFocus.bind(this);
123
+ this._handleInputBlurBound = this._handleInputBlur.bind(this);
124
+
125
+ this.el.addEventListener('click', this._handleChipClickBound);
126
+ document.addEventListener('keydown', Chips._handleChipsKeydown);
127
+ document.addEventListener('keyup', Chips._handleChipsKeyup);
128
+ this.el.addEventListener('blur', Chips._handleChipsBlur, true);
129
+ this.$input[0].addEventListener('focus', this._handleInputFocusBound);
130
+ this.$input[0].addEventListener('blur', this._handleInputBlurBound);
131
+ this.$input[0].addEventListener('keydown', this._handleInputKeydownBound);
132
+ }
133
+
134
+ /**
135
+ * Remove Event Handlers
136
+ */
137
+
138
+ }, {
139
+ key: '_removeEventHandlers',
140
+ value: function _removeEventHandlers() {
141
+ this.el.removeEventListener('click', this._handleChipClickBound);
142
+ document.removeEventListener('keydown', Chips._handleChipsKeydown);
143
+ document.removeEventListener('keyup', Chips._handleChipsKeyup);
144
+ this.el.removeEventListener('blur', Chips._handleChipsBlur, true);
145
+ this.$input[0].removeEventListener('focus', this._handleInputFocusBound);
146
+ this.$input[0].removeEventListener('blur', this._handleInputBlurBound);
147
+ this.$input[0].removeEventListener('keydown', this._handleInputKeydownBound);
148
+ }
149
+
150
+ /**
151
+ * Handle Chip Click
152
+ * @param {Event} e
153
+ */
154
+
155
+ }, {
156
+ key: '_handleChipClick',
157
+ value: function _handleChipClick(e) {
158
+ var $chip = $(e.target).closest('.chip');
159
+ var clickedClose = $(e.target).is('.close');
160
+ if ($chip.length) {
161
+ var index = $chip.index();
162
+ if (clickedClose) {
163
+ // delete chip
164
+ this.deleteChip(index);
165
+ this.$input[0].focus();
166
+ } else {
167
+ // select chip
168
+ this.selectChip(index);
169
+ }
170
+
171
+ // Default handle click to focus on input
172
+ } else {
173
+ this.$input[0].focus();
174
+ }
175
+ }
176
+
177
+ /**
178
+ * Handle Chips Keydown
179
+ * @param {Event} e
180
+ */
181
+
182
+ }, {
183
+ key: '_handleInputFocus',
184
+
185
+
186
+ /**
187
+ * Handle Input Focus
188
+ */
189
+ value: function _handleInputFocus() {
190
+ this.$el.addClass('focus');
191
+ }
192
+
193
+ /**
194
+ * Handle Input Blur
195
+ */
196
+
197
+ }, {
198
+ key: '_handleInputBlur',
199
+ value: function _handleInputBlur() {
200
+ this.$el.removeClass('focus');
201
+ }
202
+
203
+ /**
204
+ * Handle Input Keydown
205
+ * @param {Event} e
206
+ */
207
+
208
+ }, {
209
+ key: '_handleInputKeydown',
210
+ value: function _handleInputKeydown(e) {
211
+ Chips._keydown = true;
212
+
213
+ // enter
214
+ if (e.keyCode === 13) {
215
+ // Override enter if autocompleting.
216
+ if (this.hasAutocomplete && this.autocomplete && this.autocomplete.isOpen) {
217
+ return;
218
+ }
219
+
220
+ e.preventDefault();
221
+ this.addChip({
222
+ tag: this.$input[0].value
223
+ });
224
+ this.$input[0].value = '';
225
+
226
+ // delete or left
227
+ } else if ((e.keyCode === 8 || e.keyCode === 37) && this.$input[0].value === '' && this.chipsData.length) {
228
+ e.preventDefault();
229
+ this.selectChip(this.chipsData.length - 1);
230
+ }
231
+ }
232
+
233
+ /**
234
+ * Render Chip
235
+ * @param {chip} chip
236
+ * @return {Element}
237
+ */
238
+
239
+ }, {
240
+ key: '_renderChip',
241
+ value: function _renderChip(chip) {
242
+ if (!chip.tag) {
243
+ return;
244
+ }
245
+
246
+ var renderedChip = document.createElement('div');
247
+ var closeIcon = document.createElement('i');
248
+ renderedChip.classList.add('chip');
249
+ renderedChip.textContent = chip.tag;
250
+ renderedChip.setAttribute('tabindex', 0);
251
+ $(closeIcon).addClass('material-icons close');
252
+ closeIcon.textContent = 'close';
253
+
254
+ // attach image if needed
255
+ if (chip.image) {
256
+ var img = document.createElement('img');
257
+ img.setAttribute('src', chip.image);
258
+ renderedChip.insertBefore(img, renderedChip.firstChild);
259
+ }
260
+
261
+ renderedChip.appendChild(closeIcon);
262
+ return renderedChip;
263
+ }
264
+
265
+ /**
266
+ * Render Chips
267
+ */
268
+
269
+ }, {
270
+ key: '_renderChips',
271
+ value: function _renderChips() {
272
+ this.$chips.remove();
273
+ for (var i = 0; i < this.chipsData.length; i++) {
274
+ var chipEl = this._renderChip(this.chipsData[i]);
275
+ this.$el.append(chipEl);
276
+ this.$chips.add(chipEl);
277
+ }
278
+
279
+ // move input to end
280
+ this.$el.append(this.$input[0]);
281
+ }
282
+
283
+ /**
284
+ * Setup Autocomplete
285
+ */
286
+
287
+ }, {
288
+ key: '_setupAutocomplete',
289
+ value: function _setupAutocomplete() {
290
+ var _this2 = this;
291
+
292
+ this.options.autocompleteOptions.onAutocomplete = function (val) {
293
+ _this2.addChip({
294
+ tag: val
295
+ });
296
+ _this2.$input[0].value = '';
297
+ _this2.$input[0].focus();
298
+ };
299
+
300
+ this.autocomplete = M.Autocomplete.init(this.$input[0], this.options.autocompleteOptions);
301
+ }
302
+
303
+ /**
304
+ * Setup Input
305
+ */
306
+
307
+ }, {
308
+ key: '_setupInput',
309
+ value: function _setupInput() {
310
+ this.$input = this.$el.find('input');
311
+ if (!this.$input.length) {
312
+ this.$input = $('<input></input>');
313
+ this.$el.append(this.$input);
314
+ }
315
+
316
+ this.$input.addClass('input');
317
+ }
318
+
319
+ /**
320
+ * Setup Label
321
+ */
322
+
323
+ }, {
324
+ key: '_setupLabel',
325
+ value: function _setupLabel() {
326
+ this.$label = this.$el.find('label');
327
+ if (this.$label.length) {
328
+ this.$label[0].setAttribute('for', this.$input.attr('id'));
329
+ }
330
+ }
331
+
332
+ /**
333
+ * Set placeholder
334
+ */
335
+
336
+ }, {
337
+ key: '_setPlaceholder',
338
+ value: function _setPlaceholder() {
339
+ if (this.chipsData !== undefined && !this.chipsData.length && this.options.placeholder) {
340
+ $(this.$input).prop('placeholder', this.options.placeholder);
341
+ } else if ((this.chipsData === undefined || !!this.chipsData.length) && this.options.secondaryPlaceholder) {
342
+ $(this.$input).prop('placeholder', this.options.secondaryPlaceholder);
343
+ }
344
+ }
345
+
346
+ /**
347
+ * Check if chip is valid
348
+ * @param {chip} chip
349
+ */
350
+
351
+ }, {
352
+ key: '_isValid',
353
+ value: function _isValid(chip) {
354
+ if (chip.hasOwnProperty('tag') && chip.tag !== '') {
355
+ var exists = false;
356
+ for (var i = 0; i < this.chipsData.length; i++) {
357
+ if (this.chipsData[i].tag === chip.tag) {
358
+ exists = true;
359
+ break;
360
+ }
361
+ }
362
+ return !exists;
363
+ }
364
+
365
+ return false;
366
+ }
367
+
368
+ /**
369
+ * Add chip
370
+ * @param {chip} chip
371
+ */
372
+
373
+ }, {
374
+ key: 'addChip',
375
+ value: function addChip(chip) {
376
+ if (!this._isValid(chip) || this.chipsData.length >= this.options.limit) {
377
+ return;
378
+ }
379
+
380
+ var renderedChip = this._renderChip(chip);
381
+ this.$chips.add(renderedChip);
382
+ this.chipsData.push(chip);
383
+ $(this.$input).before(renderedChip);
384
+ this._setPlaceholder();
385
+
386
+ // fire chipAdd callback
387
+ if (typeof this.options.onChipAdd === 'function') {
388
+ this.options.onChipAdd.call(this, this.$el, renderedChip);
389
+ }
390
+ }
391
+
392
+ /**
393
+ * Delete chip
394
+ * @param {Number} chip
395
+ */
396
+
397
+ }, {
398
+ key: 'deleteChip',
399
+ value: function deleteChip(chipIndex) {
400
+ var $chip = this.$chips.eq(chipIndex);
401
+ this.$chips.eq(chipIndex).remove();
402
+ this.$chips = this.$chips.filter(function (el) {
403
+ return $(el).index() >= 0;
404
+ });
405
+ this.chipsData.splice(chipIndex, 1);
406
+ this._setPlaceholder();
407
+
408
+ // fire chipDelete callback
409
+ if (typeof this.options.onChipDelete === 'function') {
410
+ this.options.onChipDelete.call(this, this.$el, $chip[0]);
411
+ }
412
+ }
413
+
414
+ /**
415
+ * Select chip
416
+ * @param {Number} chip
417
+ */
418
+
419
+ }, {
420
+ key: 'selectChip',
421
+ value: function selectChip(chipIndex) {
422
+ var $chip = this.$chips.eq(chipIndex);
423
+ this._selectedChip = $chip;
424
+ $chip[0].focus();
425
+
426
+ // fire chipSelect callback
427
+ if (typeof this.options.onChipSelect === 'function') {
428
+ this.options.onChipSelect.call(this, this.$el, $chip[0]);
429
+ }
430
+ }
431
+ }], [{
432
+ key: 'init',
433
+ value: function init(els, options) {
434
+ return _get(Chips.__proto__ || Object.getPrototypeOf(Chips), 'init', this).call(this, this, els, options);
435
+ }
436
+
437
+ /**
438
+ * Get Instance
439
+ */
440
+
441
+ }, {
442
+ key: 'getInstance',
443
+ value: function getInstance(el) {
444
+ var domElem = !!el.jquery ? el[0] : el;
445
+ return domElem.M_Chips;
446
+ }
447
+ }, {
448
+ key: '_handleChipsKeydown',
449
+ value: function _handleChipsKeydown(e) {
450
+ Chips._keydown = true;
451
+
452
+ var $chips = $(e.target).closest('.chips');
453
+ var chipsKeydown = e.target && $chips.length;
454
+
455
+ // Don't handle keydown inputs on input and textarea
456
+ if ($(e.target).is('input, textarea') || !chipsKeydown) {
457
+ return;
458
+ }
459
+
460
+ var currChips = $chips[0].M_Chips;
461
+
462
+ // backspace and delete
463
+ if (e.keyCode === 8 || e.keyCode === 46) {
464
+ e.preventDefault();
465
+
466
+ var selectIndex = currChips.chipsData.length;
467
+ if (currChips._selectedChip) {
468
+ var index = currChips._selectedChip.index();
469
+ currChips.deleteChip(index);
470
+ currChips._selectedChip = null;
471
+
472
+ // Make sure selectIndex doesn't go negative
473
+ selectIndex = Math.max(index - 1, 0);
474
+ }
475
+
476
+ if (currChips.chipsData.length) {
477
+ currChips.selectChip(selectIndex);
478
+ }
479
+
480
+ // left arrow key
481
+ } else if (e.keyCode === 37) {
482
+ if (currChips._selectedChip) {
483
+ var _selectIndex = currChips._selectedChip.index() - 1;
484
+ if (_selectIndex < 0) {
485
+ return;
486
+ }
487
+ currChips.selectChip(_selectIndex);
488
+ }
489
+
490
+ // right arrow key
491
+ } else if (e.keyCode === 39) {
492
+ if (currChips._selectedChip) {
493
+ var _selectIndex2 = currChips._selectedChip.index() + 1;
494
+
495
+ if (_selectIndex2 >= currChips.chipsData.length) {
496
+ currChips.$input[0].focus();
497
+ } else {
498
+ currChips.selectChip(_selectIndex2);
499
+ }
500
+ }
501
+ }
502
+ }
503
+
504
+ /**
505
+ * Handle Chips Keyup
506
+ * @param {Event} e
507
+ */
508
+
509
+ }, {
510
+ key: '_handleChipsKeyup',
511
+ value: function _handleChipsKeyup(e) {
512
+ Chips._keydown = false;
513
+ }
514
+
515
+ /**
516
+ * Handle Chips Blur
517
+ * @param {Event} e
518
+ */
519
+
520
+ }, {
521
+ key: '_handleChipsBlur',
522
+ value: function _handleChipsBlur(e) {
523
+ if (!Chips._keydown) {
524
+ var $chips = $(e.target).closest('.chips');
525
+ var currChips = $chips[0].M_Chips;
526
+
527
+ currChips._selectedChip = null;
528
+ }
529
+ }
530
+ }, {
531
+ key: 'defaults',
532
+ get: function () {
533
+ return _defaults;
534
+ }
535
+ }]);
536
+
537
+ return Chips;
538
+ }(Component);
539
+
540
+ /**
541
+ * @static
542
+ * @memberof Chips
543
+ */
544
+
545
+
546
+ Chips._keydown = false;
547
+
548
+ M.Chips = Chips;
549
+
550
+ if (M.jQueryLoaded) {
551
+ M.initializeJqueryWrapper(Chips, 'chips', 'M_Chips');
552
+ }
553
+
554
+ $(document).ready(function () {
555
+ // Handle removal of static chips.
556
+ $(document.body).on('click', '.chip .close', function () {
557
+ var $chips = $(this).closest('.chips');
558
+ if ($chips.length && $chips[0].M_Chips) {
559
+ return;
560
+ }
561
+ $(this).closest('.chip').remove();
562
+ });
563
+ });
564
+ })(cash);