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,497 @@
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
+ classes: '',
16
+ dropdownOptions: {}
17
+ };
18
+
19
+ /**
20
+ * @class
21
+ *
22
+ */
23
+
24
+ var FormSelect = function (_Component) {
25
+ _inherits(FormSelect, _Component);
26
+
27
+ /**
28
+ * Construct FormSelect instance
29
+ * @constructor
30
+ * @param {Element} el
31
+ * @param {Object} options
32
+ */
33
+ function FormSelect(el, options) {
34
+ _classCallCheck(this, FormSelect);
35
+
36
+ // Don't init if browser default version
37
+ var _this = _possibleConstructorReturn(this, (FormSelect.__proto__ || Object.getPrototypeOf(FormSelect)).call(this, FormSelect, el, options));
38
+
39
+ if (_this.$el.hasClass('browser-default')) {
40
+ return _possibleConstructorReturn(_this);
41
+ }
42
+
43
+ _this.el.M_FormSelect = _this;
44
+
45
+ /**
46
+ * Options for the select
47
+ * @member FormSelect#options
48
+ */
49
+ _this.options = $.extend({}, FormSelect.defaults, options);
50
+
51
+ _this.isMultiple = _this.$el.prop('multiple');
52
+
53
+ // Setup
54
+ _this.el.tabIndex = -1;
55
+ _this._keysSelected = {};
56
+ _this._valueDict = {}; // Maps key to original and generated option element.
57
+ _this._setupDropdown();
58
+
59
+ _this._setupEventHandlers();
60
+ return _this;
61
+ }
62
+
63
+ _createClass(FormSelect, [{
64
+ key: 'destroy',
65
+
66
+
67
+ /**
68
+ * Teardown component
69
+ */
70
+ value: function destroy() {
71
+ this._removeEventHandlers();
72
+ this._removeDropdown();
73
+ this.el.M_FormSelect = undefined;
74
+ }
75
+
76
+ /**
77
+ * Setup Event Handlers
78
+ */
79
+
80
+ }, {
81
+ key: '_setupEventHandlers',
82
+ value: function _setupEventHandlers() {
83
+ var _this2 = this;
84
+
85
+ this._handleSelectChangeBound = this._handleSelectChange.bind(this);
86
+ this._handleOptionClickBound = this._handleOptionClick.bind(this);
87
+ this._handleInputClickBound = this._handleInputClick.bind(this);
88
+
89
+ $(this.dropdownOptions).find('li:not(.optgroup)').each(function (el) {
90
+ el.addEventListener('click', _this2._handleOptionClickBound);
91
+ });
92
+ this.el.addEventListener('change', this._handleSelectChangeBound);
93
+ this.input.addEventListener('click', this._handleInputClickBound);
94
+ }
95
+
96
+ /**
97
+ * Remove Event Handlers
98
+ */
99
+
100
+ }, {
101
+ key: '_removeEventHandlers',
102
+ value: function _removeEventHandlers() {
103
+ var _this3 = this;
104
+
105
+ $(this.dropdownOptions).find('li:not(.optgroup)').each(function (el) {
106
+ el.removeEventListener('click', _this3._handleOptionClickBound);
107
+ });
108
+ this.el.removeEventListener('change', this._handleSelectChangeBound);
109
+ this.input.removeEventListener('click', this._handleInputClickBound);
110
+ }
111
+
112
+ /**
113
+ * Handle Select Change
114
+ * @param {Event} e
115
+ */
116
+
117
+ }, {
118
+ key: '_handleSelectChange',
119
+ value: function _handleSelectChange(e) {
120
+ this._setValueToInput();
121
+ }
122
+
123
+ /**
124
+ * Handle Option Click
125
+ * @param {Event} e
126
+ */
127
+
128
+ }, {
129
+ key: '_handleOptionClick',
130
+ value: function _handleOptionClick(e) {
131
+ e.preventDefault();
132
+ var option = $(e.target).closest('li')[0];
133
+ var key = option.id;
134
+ if (!$(option).hasClass('disabled') && !$(option).hasClass('optgroup') && key.length) {
135
+ var selected = true;
136
+
137
+ if (this.isMultiple) {
138
+ // Deselect placeholder option if still selected.
139
+ var placeholderOption = $(this.dropdownOptions).find('li.disabled.selected');
140
+ if (placeholderOption.length) {
141
+ placeholderOption.removeClass('selected');
142
+ placeholderOption.find('input[type="checkbox"]').prop('checked', false);
143
+ this._toggleEntryFromArray(placeholderOption[0].id);
144
+ }
145
+ selected = this._toggleEntryFromArray(key);
146
+ } else {
147
+ $(this.dropdownOptions).find('li').removeClass('selected');
148
+ $(option).toggleClass('selected', selected);
149
+ this._keysSelected = {};
150
+ this._keysSelected[option.id] = true;
151
+ }
152
+
153
+ // Set selected on original select option
154
+ // Only trigger if selected state changed
155
+ var prevSelected = $(this._valueDict[key].el).prop('selected');
156
+ if (prevSelected !== selected) {
157
+ $(this._valueDict[key].el).prop('selected', selected);
158
+ this.$el.trigger('change');
159
+ }
160
+ }
161
+
162
+ e.stopPropagation();
163
+ }
164
+
165
+ /**
166
+ * Handle Input Click
167
+ */
168
+
169
+ }, {
170
+ key: '_handleInputClick',
171
+ value: function _handleInputClick() {
172
+ if (this.dropdown && this.dropdown.isOpen) {
173
+ this._setValueToInput();
174
+ this._setSelectedStates();
175
+ }
176
+ }
177
+
178
+ /**
179
+ * Setup dropdown
180
+ */
181
+
182
+ }, {
183
+ key: '_setupDropdown',
184
+ value: function _setupDropdown() {
185
+ var _this4 = this;
186
+
187
+ this.wrapper = document.createElement('div');
188
+ $(this.wrapper).addClass('select-wrapper ' + this.options.classes);
189
+ this.$el.before($(this.wrapper));
190
+ // Move actual select element into overflow hidden wrapper
191
+ var $hideSelect = $('<div class="hide-select"></div>');
192
+ $(this.wrapper).append($hideSelect);
193
+ $hideSelect[0].appendChild(this.el);
194
+
195
+ if (this.el.disabled) {
196
+ this.wrapper.classList.add('disabled');
197
+ }
198
+
199
+ // Create dropdown
200
+ this.$selectOptions = this.$el.children('option, optgroup');
201
+ this.dropdownOptions = document.createElement('ul');
202
+ this.dropdownOptions.id = 'select-options-' + M.guid();
203
+ $(this.dropdownOptions).addClass('dropdown-content select-dropdown ' + (this.isMultiple ? 'multiple-select-dropdown' : ''));
204
+
205
+ // Create dropdown structure.
206
+ if (this.$selectOptions.length) {
207
+ this.$selectOptions.each(function (el) {
208
+ if ($(el).is('option')) {
209
+ // Direct descendant option.
210
+ var optionEl = void 0;
211
+ if (_this4.isMultiple) {
212
+ optionEl = _this4._appendOptionWithIcon(_this4.$el, el, 'multiple');
213
+ } else {
214
+ optionEl = _this4._appendOptionWithIcon(_this4.$el, el);
215
+ }
216
+
217
+ _this4._addOptionToValueDict(el, optionEl);
218
+ } else if ($(el).is('optgroup')) {
219
+ // Optgroup.
220
+ var selectOptions = $(el).children('option');
221
+ $(_this4.dropdownOptions).append($('<li class="optgroup"><span>' + el.getAttribute('label') + '</span></li>')[0]);
222
+
223
+ selectOptions.each(function (el) {
224
+ var optionEl = _this4._appendOptionWithIcon(_this4.$el, el, 'optgroup-option');
225
+ _this4._addOptionToValueDict(el, optionEl);
226
+ });
227
+ }
228
+ });
229
+ }
230
+
231
+ $(this.wrapper).append(this.dropdownOptions);
232
+
233
+ // Add input dropdown
234
+ this.input = document.createElement('input');
235
+ $(this.input).addClass('select-dropdown dropdown-trigger');
236
+ this.input.setAttribute('type', 'text');
237
+ this.input.setAttribute('readonly', 'true');
238
+ this.input.setAttribute('data-target', this.dropdownOptions.id);
239
+ if (this.el.disabled) {
240
+ $(this.input).prop('disabled', 'true');
241
+ }
242
+
243
+ $(this.wrapper).prepend(this.input);
244
+ this._setValueToInput();
245
+
246
+ // Add caret
247
+ var dropdownIcon = $('<svg class="caret" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
248
+ $(this.wrapper).prepend(dropdownIcon[0]);
249
+
250
+ // Initialize dropdown
251
+ if (!this.el.disabled) {
252
+ var dropdownOptions = $.extend({}, this.options.dropdownOptions);
253
+ var userOnOpenEnd = dropdownOptions.onOpenEnd;
254
+
255
+ // Add callback for centering selected option when dropdown content is scrollable
256
+ dropdownOptions.onOpenEnd = function (el) {
257
+ var selectedOption = $(_this4.dropdownOptions).find('.selected').first();
258
+
259
+ if (selectedOption.length) {
260
+ // Focus selected option in dropdown
261
+ M.keyDown = true;
262
+ _this4.dropdown.focusedIndex = selectedOption.index();
263
+ _this4.dropdown._focusFocusedItem();
264
+ M.keyDown = false;
265
+
266
+ // Handle scrolling to selected option
267
+ if (_this4.dropdown.isScrollable) {
268
+ var scrollOffset = selectedOption[0].getBoundingClientRect().top - _this4.dropdownOptions.getBoundingClientRect().top; // scroll to selected option
269
+ scrollOffset -= _this4.dropdownOptions.clientHeight / 2; // center in dropdown
270
+ _this4.dropdownOptions.scrollTop = scrollOffset;
271
+ }
272
+ }
273
+
274
+ // Handle user declared onOpenEnd if needed
275
+ if (userOnOpenEnd && typeof userOnOpenEnd === 'function') {
276
+ userOnOpenEnd.call(_this4.dropdown, _this4.el);
277
+ }
278
+ };
279
+
280
+ if (this.isMultiple) {
281
+ dropdownOptions.closeOnClick = false;
282
+ }
283
+ this.dropdown = M.Dropdown.init(this.input, dropdownOptions);
284
+ }
285
+
286
+ // Add initial selections
287
+ this._setSelectedStates();
288
+ }
289
+
290
+ /**
291
+ * Add option to value dict
292
+ * @param {Element} el original option element
293
+ * @param {Element} optionEl generated option element
294
+ */
295
+
296
+ }, {
297
+ key: '_addOptionToValueDict',
298
+ value: function _addOptionToValueDict(el, optionEl) {
299
+ var index = Object.keys(this._valueDict).length;
300
+ var key = this.dropdownOptions.id + index;
301
+ var obj = {};
302
+ optionEl.id = key;
303
+
304
+ obj.el = el;
305
+ obj.optionEl = optionEl;
306
+ this._valueDict[key] = obj;
307
+ }
308
+
309
+ /**
310
+ * Remove dropdown
311
+ */
312
+
313
+ }, {
314
+ key: '_removeDropdown',
315
+ value: function _removeDropdown() {
316
+ $(this.wrapper).find('.caret').remove();
317
+ $(this.input).remove();
318
+ $(this.dropdownOptions).remove();
319
+ $(this.wrapper).before(this.$el);
320
+ $(this.wrapper).remove();
321
+ }
322
+
323
+ /**
324
+ * Setup dropdown
325
+ * @param {Element} select select element
326
+ * @param {Element} option option element from select
327
+ * @param {String} type
328
+ * @return {Element} option element added
329
+ */
330
+
331
+ }, {
332
+ key: '_appendOptionWithIcon',
333
+ value: function _appendOptionWithIcon(select, option, type) {
334
+ // Add disabled attr if disabled
335
+ var disabledClass = option.disabled ? 'disabled ' : '';
336
+ var optgroupClass = type === 'optgroup-option' ? 'optgroup-option ' : '';
337
+ var multipleCheckbox = this.isMultiple ? '<label><input type="checkbox"' + disabledClass + '"/><span>' + option.innerHTML + '</span></label>' : option.innerHTML;
338
+ var liEl = $('<li></li>');
339
+ var spanEl = $('<span></span>');
340
+ spanEl.html(multipleCheckbox);
341
+ liEl.addClass(disabledClass + ' ' + optgroupClass);
342
+ liEl.append(spanEl);
343
+
344
+ // add icons
345
+ var iconUrl = option.getAttribute('data-icon');
346
+ if (!!iconUrl) {
347
+ var imgEl = $('<img alt="" src="' + iconUrl + '">');
348
+ liEl.prepend(imgEl);
349
+ }
350
+
351
+ // Check for multiple type.
352
+ $(this.dropdownOptions).append(liEl[0]);
353
+ return liEl[0];
354
+ }
355
+
356
+ /**
357
+ * Toggle entry from option
358
+ * @param {String} key Option key
359
+ * @return {Boolean} if entry was added or removed
360
+ */
361
+
362
+ }, {
363
+ key: '_toggleEntryFromArray',
364
+ value: function _toggleEntryFromArray(key) {
365
+ var notAdded = !this._keysSelected.hasOwnProperty(key);
366
+ var $optionLi = $(this._valueDict[key].optionEl);
367
+
368
+ if (notAdded) {
369
+ this._keysSelected[key] = true;
370
+ } else {
371
+ delete this._keysSelected[key];
372
+ }
373
+
374
+ $optionLi.toggleClass('selected', notAdded);
375
+
376
+ // Set checkbox checked value
377
+ $optionLi.find('input[type="checkbox"]').prop('checked', notAdded);
378
+
379
+ // use notAdded instead of true (to detect if the option is selected or not)
380
+ $optionLi.prop('selected', notAdded);
381
+
382
+ return notAdded;
383
+ }
384
+
385
+ /**
386
+ * Set text value to input
387
+ */
388
+
389
+ }, {
390
+ key: '_setValueToInput',
391
+ value: function _setValueToInput() {
392
+ var values = [];
393
+ var options = this.$el.find('option');
394
+
395
+ options.each(function (el) {
396
+ if ($(el).prop('selected')) {
397
+ var text = $(el).text();
398
+ values.push(text);
399
+ }
400
+ });
401
+
402
+ if (!values.length) {
403
+ var firstDisabled = this.$el.find('option:disabled').eq(0);
404
+ if (firstDisabled.length && firstDisabled[0].value === '') {
405
+ values.push(firstDisabled.text());
406
+ }
407
+ }
408
+
409
+ this.input.value = values.join(', ');
410
+ }
411
+
412
+ /**
413
+ * Set selected state of dropdown to match actual select element
414
+ */
415
+
416
+ }, {
417
+ key: '_setSelectedStates',
418
+ value: function _setSelectedStates() {
419
+ this._keysSelected = {};
420
+
421
+ for (var key in this._valueDict) {
422
+ var option = this._valueDict[key];
423
+ var optionIsSelected = $(option.el).prop('selected');
424
+ $(option.optionEl).find('input[type="checkbox"]').prop('checked', optionIsSelected);
425
+ if (optionIsSelected) {
426
+ this._activateOption($(this.dropdownOptions), $(option.optionEl));
427
+ this._keysSelected[key] = true;
428
+ } else {
429
+ $(option.optionEl).removeClass('selected');
430
+ }
431
+ }
432
+ }
433
+
434
+ /**
435
+ * Make option as selected and scroll to selected position
436
+ * @param {jQuery} collection Select options jQuery element
437
+ * @param {Element} newOption element of the new option
438
+ */
439
+
440
+ }, {
441
+ key: '_activateOption',
442
+ value: function _activateOption(collection, newOption) {
443
+ if (newOption) {
444
+ if (!this.isMultiple) {
445
+ collection.find('li.selected').removeClass('selected');
446
+ }
447
+ var option = $(newOption);
448
+ option.addClass('selected');
449
+ }
450
+ }
451
+
452
+ /**
453
+ * Get Selected Values
454
+ * @return {Array} Array of selected values
455
+ */
456
+
457
+ }, {
458
+ key: 'getSelectedValues',
459
+ value: function getSelectedValues() {
460
+ var selectedValues = [];
461
+ for (var key in this._keysSelected) {
462
+ selectedValues.push(this._valueDict[key].el.value);
463
+ }
464
+ return selectedValues;
465
+ }
466
+ }], [{
467
+ key: 'init',
468
+ value: function init(els, options) {
469
+ return _get(FormSelect.__proto__ || Object.getPrototypeOf(FormSelect), 'init', this).call(this, this, els, options);
470
+ }
471
+
472
+ /**
473
+ * Get Instance
474
+ */
475
+
476
+ }, {
477
+ key: 'getInstance',
478
+ value: function getInstance(el) {
479
+ var domElem = !!el.jquery ? el[0] : el;
480
+ return domElem.M_FormSelect;
481
+ }
482
+ }, {
483
+ key: 'defaults',
484
+ get: function () {
485
+ return _defaults;
486
+ }
487
+ }]);
488
+
489
+ return FormSelect;
490
+ }(Component);
491
+
492
+ M.FormSelect = FormSelect;
493
+
494
+ if (M.jQueryLoaded) {
495
+ M.initializeJqueryWrapper(FormSelect, 'formSelect', 'M_FormSelect');
496
+ }
497
+ })(cash);