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
@@ -1,64 +0,0 @@
1
- (function ($) {
2
-
3
- $.fn.characterCounter = function () {
4
- return this.each(function () {
5
- var $input = $(this);
6
- var $counterElement = $input.parent().find('span[class="character-counter"]');
7
-
8
- // character counter has already been added appended to the parent container
9
- if ($counterElement.length) {
10
- return;
11
- }
12
-
13
- var itHasLengthAttribute = $input.attr('data-length') !== undefined;
14
-
15
- if (itHasLengthAttribute) {
16
- $input.on('input', updateCounter);
17
- $input.on('focus', updateCounter);
18
- $input.on('blur', removeCounterElement);
19
-
20
- addCounterElement($input);
21
- }
22
- });
23
- };
24
-
25
- function updateCounter() {
26
- var maxLength = +$(this).attr('data-length'),
27
- actualLength = +$(this).val().length,
28
- isValidLength = actualLength <= maxLength;
29
-
30
- $(this).parent().find('span[class="character-counter"]').html(actualLength + '/' + maxLength);
31
-
32
- addInputStyle(isValidLength, $(this));
33
- }
34
-
35
- function addCounterElement($input) {
36
- var $counterElement = $input.parent().find('span[class="character-counter"]');
37
-
38
- if ($counterElement.length) {
39
- return;
40
- }
41
-
42
- $counterElement = $('<span/>').addClass('character-counter').css('float', 'right').css('font-size', '12px').css('height', 1);
43
-
44
- $input.parent().append($counterElement);
45
- }
46
-
47
- function removeCounterElement() {
48
- $(this).parent().find('span[class="character-counter"]').html('');
49
- }
50
-
51
- function addInputStyle(isValidLength, $input) {
52
- var inputHasInvalidClass = $input.hasClass('invalid');
53
- if (isValidLength && inputHasInvalidClass) {
54
- $input.removeClass('invalid');
55
- } else if (!isValidLength && !inputHasInvalidClass) {
56
- $input.removeClass('valid');
57
- $input.addClass('invalid');
58
- }
59
- }
60
-
61
- $(document).on('ready turbolinks:load', function () {
62
- $('input, textarea').characterCounter();
63
- });
64
- })(jQuery);
@@ -1,315 +0,0 @@
1
- (function ($) {
2
- var materialChipsDefaults = {
3
- data: [],
4
- placeholder: '',
5
- secondaryPlaceholder: '',
6
- autocompleteOptions: {}
7
- };
8
-
9
- $(document).on('ready turbolinks:load', function () {
10
- // Handle removal of static chips.
11
- $(document).on('click', '.chip .close', function (e) {
12
- var $chips = $(this).closest('.chips');
13
- if ($chips.attr('data-initialized')) {
14
- return;
15
- }
16
- $(this).closest('.chip').remove();
17
- });
18
- });
19
-
20
- $.fn.material_chip = function (options) {
21
- var self = this;
22
- this.$el = $(this);
23
- this.$document = $(document);
24
- this.SELS = {
25
- CHIPS: '.chips',
26
- CHIP: '.chip',
27
- INPUT: 'input',
28
- DELETE: '.material-icons',
29
- SELECTED_CHIP: '.selected'
30
- };
31
-
32
- if ('data' === options) {
33
- return this.$el.data('chips');
34
- }
35
-
36
- var curr_options = $.extend({}, materialChipsDefaults, options);
37
- self.hasAutocomplete = !$.isEmptyObject(curr_options.autocompleteOptions.data);
38
-
39
- // Initialize
40
- this.init = function () {
41
- var i = 0;
42
- var chips;
43
- self.$el.each(function () {
44
- var $chips = $(this);
45
- var chipId = Materialize.guid();
46
- self.chipId = chipId;
47
-
48
- if (!curr_options.data || !(curr_options.data instanceof Array)) {
49
- curr_options.data = [];
50
- }
51
- $chips.data('chips', curr_options.data);
52
- $chips.attr('data-index', i);
53
- $chips.attr('data-initialized', true);
54
-
55
- if (!$chips.hasClass(self.SELS.CHIPS)) {
56
- $chips.addClass('chips');
57
- }
58
-
59
- self.chips($chips, chipId);
60
- i++;
61
- });
62
- };
63
-
64
- this.handleEvents = function () {
65
- var SELS = self.SELS;
66
-
67
- self.$document.off('click.chips-focus', SELS.CHIPS).on('click.chips-focus', SELS.CHIPS, function (e) {
68
- $(e.target).find(SELS.INPUT).focus();
69
- });
70
-
71
- self.$document.off('click.chips-select', SELS.CHIP).on('click.chips-select', SELS.CHIP, function (e) {
72
- var $chip = $(e.target);
73
- if ($chip.length) {
74
- var wasSelected = $chip.hasClass('selected');
75
- var $chips = $chip.closest(SELS.CHIPS);
76
- $(SELS.CHIP).removeClass('selected');
77
-
78
- if (!wasSelected) {
79
- self.selectChip($chip.index(), $chips);
80
- }
81
- }
82
- });
83
-
84
- self.$document.off('keydown.chips').on('keydown.chips', function (e) {
85
- if ($(e.target).is('input, textarea')) {
86
- return;
87
- }
88
-
89
- // delete
90
- var $chip = self.$document.find(SELS.CHIP + SELS.SELECTED_CHIP);
91
- var $chips = $chip.closest(SELS.CHIPS);
92
- var length = $chip.siblings(SELS.CHIP).length;
93
- var index;
94
-
95
- if (!$chip.length) {
96
- return;
97
- }
98
-
99
- if (e.which === 8 || e.which === 46) {
100
- e.preventDefault();
101
-
102
- index = $chip.index();
103
- self.deleteChip(index, $chips);
104
-
105
- var selectIndex = null;
106
- if (index + 1 < length) {
107
- selectIndex = index;
108
- } else if (index === length || index + 1 === length) {
109
- selectIndex = length - 1;
110
- }
111
-
112
- if (selectIndex < 0) selectIndex = null;
113
-
114
- if (null !== selectIndex) {
115
- self.selectChip(selectIndex, $chips);
116
- }
117
- if (!length) $chips.find('input').focus();
118
-
119
- // left
120
- } else if (e.which === 37) {
121
- index = $chip.index() - 1;
122
- if (index < 0) {
123
- return;
124
- }
125
- $(SELS.CHIP).removeClass('selected');
126
- self.selectChip(index, $chips);
127
-
128
- // right
129
- } else if (e.which === 39) {
130
- index = $chip.index() + 1;
131
- $(SELS.CHIP).removeClass('selected');
132
- if (index > length) {
133
- $chips.find('input').focus();
134
- return;
135
- }
136
- self.selectChip(index, $chips);
137
- }
138
- });
139
-
140
- self.$document.off('focusin.chips', SELS.CHIPS + ' ' + SELS.INPUT).on('focusin.chips', SELS.CHIPS + ' ' + SELS.INPUT, function (e) {
141
- var $currChips = $(e.target).closest(SELS.CHIPS);
142
- $currChips.addClass('focus');
143
- $currChips.siblings('label, .prefix').addClass('active');
144
- $(SELS.CHIP).removeClass('selected');
145
- });
146
-
147
- self.$document.off('focusout.chips', SELS.CHIPS + ' ' + SELS.INPUT).on('focusout.chips', SELS.CHIPS + ' ' + SELS.INPUT, function (e) {
148
- var $currChips = $(e.target).closest(SELS.CHIPS);
149
- $currChips.removeClass('focus');
150
-
151
- // Remove active if empty
152
- if ($currChips.data('chips') === undefined || !$currChips.data('chips').length) {
153
- $currChips.siblings('label').removeClass('active');
154
- }
155
- $currChips.siblings('.prefix').removeClass('active');
156
- });
157
-
158
- self.$document.off('keydown.chips-add', SELS.CHIPS + ' ' + SELS.INPUT).on('keydown.chips-add', SELS.CHIPS + ' ' + SELS.INPUT, function (e) {
159
- var $target = $(e.target);
160
- var $chips = $target.closest(SELS.CHIPS);
161
- var chipsLength = $chips.children(SELS.CHIP).length;
162
-
163
- // enter
164
- if (13 === e.which) {
165
- // Override enter if autocompleting.
166
- if (self.hasAutocomplete && $chips.find('.autocomplete-content.dropdown-content').length && $chips.find('.autocomplete-content.dropdown-content').children().length) {
167
- return;
168
- }
169
-
170
- e.preventDefault();
171
- self.addChip({ tag: $target.val() }, $chips);
172
- $target.val('');
173
- return;
174
- }
175
-
176
- // delete or left
177
- if ((8 === e.keyCode || 37 === e.keyCode) && '' === $target.val() && chipsLength) {
178
- e.preventDefault();
179
- self.selectChip(chipsLength - 1, $chips);
180
- $target.blur();
181
- return;
182
- }
183
- });
184
-
185
- // Click on delete icon in chip.
186
- self.$document.off('click.chips-delete', SELS.CHIPS + ' ' + SELS.DELETE).on('click.chips-delete', SELS.CHIPS + ' ' + SELS.DELETE, function (e) {
187
- var $target = $(e.target);
188
- var $chips = $target.closest(SELS.CHIPS);
189
- var $chip = $target.closest(SELS.CHIP);
190
- e.stopPropagation();
191
- self.deleteChip($chip.index(), $chips);
192
- $chips.find('input').focus();
193
- });
194
- };
195
-
196
- this.chips = function ($chips, chipId) {
197
- $chips.empty();
198
- $chips.data('chips').forEach(function (elem) {
199
- $chips.append(self.renderChip(elem));
200
- });
201
- $chips.append($('<input id="' + chipId + '" class="input" placeholder="">'));
202
- self.setPlaceholder($chips);
203
-
204
- // Set for attribute for label
205
- var label = $chips.next('label');
206
- if (label.length) {
207
- label.attr('for', chipId);
208
-
209
- if ($chips.data('chips') !== undefined && $chips.data('chips').length) {
210
- label.addClass('active');
211
- }
212
- }
213
-
214
- // Setup autocomplete if needed.
215
- var input = $('#' + chipId);
216
- if (self.hasAutocomplete) {
217
- curr_options.autocompleteOptions.onAutocomplete = function (val) {
218
- self.addChip({ tag: val }, $chips);
219
- input.val('');
220
- input.focus();
221
- };
222
- input.autocomplete(curr_options.autocompleteOptions);
223
- }
224
- };
225
-
226
- /**
227
- * Render chip jQuery element.
228
- * @param {Object} elem
229
- * @return {jQuery}
230
- */
231
- this.renderChip = function (elem) {
232
- if (!elem.tag) return;
233
-
234
- var $renderedChip = $('<div class="chip"></div>');
235
- $renderedChip.text(elem.tag);
236
- if (elem.image) {
237
- $renderedChip.prepend($('<img />').attr('src', elem.image));
238
- }
239
- $renderedChip.append($('<i class="material-icons close">close</i>'));
240
- return $renderedChip;
241
- };
242
-
243
- this.setPlaceholder = function ($chips) {
244
- if ($chips.data('chips') !== undefined && !$chips.data('chips').length && curr_options.placeholder) {
245
- $chips.find('input').prop('placeholder', curr_options.placeholder);
246
- } else if (($chips.data('chips') === undefined || !!$chips.data('chips').length) && curr_options.secondaryPlaceholder) {
247
- $chips.find('input').prop('placeholder', curr_options.secondaryPlaceholder);
248
- }
249
- };
250
-
251
- this.isValid = function ($chips, elem) {
252
- var chips = $chips.data('chips');
253
- var exists = false;
254
- for (var i = 0; i < chips.length; i++) {
255
- if (chips[i].tag === elem.tag) {
256
- exists = true;
257
- return;
258
- }
259
- }
260
- return '' !== elem.tag && !exists;
261
- };
262
-
263
- this.addChip = function (elem, $chips) {
264
- if (!self.isValid($chips, elem)) {
265
- return;
266
- }
267
- var $renderedChip = self.renderChip(elem);
268
- var newData = [];
269
- var oldData = $chips.data('chips');
270
- for (var i = 0; i < oldData.length; i++) {
271
- newData.push(oldData[i]);
272
- }
273
- newData.push(elem);
274
-
275
- $chips.data('chips', newData);
276
- $renderedChip.insertBefore($chips.find('input'));
277
- $chips.trigger('chip.add', elem);
278
- self.setPlaceholder($chips);
279
- };
280
-
281
- this.deleteChip = function (chipIndex, $chips) {
282
- var chip = $chips.data('chips')[chipIndex];
283
- $chips.find('.chip').eq(chipIndex).remove();
284
-
285
- var newData = [];
286
- var oldData = $chips.data('chips');
287
- for (var i = 0; i < oldData.length; i++) {
288
- if (i !== chipIndex) {
289
- newData.push(oldData[i]);
290
- }
291
- }
292
-
293
- $chips.data('chips', newData);
294
- $chips.trigger('chip.delete', chip);
295
- self.setPlaceholder($chips);
296
- };
297
-
298
- this.selectChip = function (chipIndex, $chips) {
299
- var $chip = $chips.find('.chip').eq(chipIndex);
300
- if ($chip && false === $chip.hasClass('selected')) {
301
- $chip.addClass('selected');
302
- $chips.trigger('chip.select', $chips.data('chips')[chipIndex]);
303
- }
304
- };
305
-
306
- this.getChipsElement = function (index, $chips) {
307
- return $chips.eq(index);
308
- };
309
-
310
- // init
311
- this.init();
312
-
313
- this.handleEvents();
314
- };
315
- })(jQuery);
@@ -1,178 +0,0 @@
1
- (function ($) {
2
- $.fn.collapsible = function (options, methodParam) {
3
- var defaults = {
4
- accordion: undefined,
5
- onOpen: undefined,
6
- onClose: undefined
7
- };
8
-
9
- var methodName = options;
10
- options = $.extend(defaults, options);
11
-
12
- return this.each(function () {
13
-
14
- var $this = $(this);
15
-
16
- var $panel_headers = $(this).find('> li > .collapsible-header');
17
-
18
- var collapsible_type = $this.data("collapsible");
19
-
20
- /****************
21
- Helper Functions
22
- ****************/
23
-
24
- // Accordion Open
25
- function accordionOpen(object) {
26
- $panel_headers = $this.find('> li > .collapsible-header');
27
- if (object.hasClass('active')) {
28
- object.parent().addClass('active');
29
- } else {
30
- object.parent().removeClass('active');
31
- }
32
- if (object.parent().hasClass('active')) {
33
- object.siblings('.collapsible-body').stop(true, false).slideDown({ duration: 350, easing: "easeOutQuart", queue: false, complete: function () {
34
- $(this).css('height', '');
35
- } });
36
- } else {
37
- object.siblings('.collapsible-body').stop(true, false).slideUp({ duration: 350, easing: "easeOutQuart", queue: false, complete: function () {
38
- $(this).css('height', '');
39
- } });
40
- }
41
-
42
- $panel_headers.not(object).removeClass('active').parent().removeClass('active');
43
-
44
- // Close previously open accordion elements.
45
- $panel_headers.not(object).parent().children('.collapsible-body').stop(true, false).each(function () {
46
- if ($(this).is(':visible')) {
47
- $(this).slideUp({
48
- duration: 350,
49
- easing: "easeOutQuart",
50
- queue: false,
51
- complete: function () {
52
- $(this).css('height', '');
53
- execCallbacks($(this).siblings('.collapsible-header'));
54
- }
55
- });
56
- }
57
- });
58
- }
59
-
60
- // Expandable Open
61
- function expandableOpen(object) {
62
- if (object.hasClass('active')) {
63
- object.parent().addClass('active');
64
- } else {
65
- object.parent().removeClass('active');
66
- }
67
- if (object.parent().hasClass('active')) {
68
- object.siblings('.collapsible-body').stop(true, false).slideDown({ duration: 350, easing: "easeOutQuart", queue: false, complete: function () {
69
- $(this).css('height', '');
70
- } });
71
- } else {
72
- object.siblings('.collapsible-body').stop(true, false).slideUp({ duration: 350, easing: "easeOutQuart", queue: false, complete: function () {
73
- $(this).css('height', '');
74
- } });
75
- }
76
- }
77
-
78
- // Open collapsible. object: .collapsible-header
79
- function collapsibleOpen(object, noToggle) {
80
- if (!noToggle) {
81
- object.toggleClass('active');
82
- }
83
-
84
- if (options.accordion || collapsible_type === "accordion" || collapsible_type === undefined) {
85
- // Handle Accordion
86
- accordionOpen(object);
87
- } else {
88
- // Handle Expandables
89
- expandableOpen(object);
90
- }
91
-
92
- execCallbacks(object);
93
- }
94
-
95
- // Handle callbacks
96
- function execCallbacks(object) {
97
- if (object.hasClass('active')) {
98
- if (typeof options.onOpen === "function") {
99
- options.onOpen.call(this, object.parent());
100
- }
101
- } else {
102
- if (typeof options.onClose === "function") {
103
- options.onClose.call(this, object.parent());
104
- }
105
- }
106
- }
107
-
108
- /**
109
- * Check if object is children of panel header
110
- * @param {Object} object Jquery object
111
- * @return {Boolean} true if it is children
112
- */
113
- function isChildrenOfPanelHeader(object) {
114
-
115
- var panelHeader = getPanelHeader(object);
116
-
117
- return panelHeader.length > 0;
118
- }
119
-
120
- /**
121
- * Get panel header from a children element
122
- * @param {Object} object Jquery object
123
- * @return {Object} panel header object
124
- */
125
- function getPanelHeader(object) {
126
-
127
- return object.closest('li > .collapsible-header');
128
- }
129
-
130
- // Turn off any existing event handlers
131
- function removeEventHandlers() {
132
- $this.off('click.collapse', '> li > .collapsible-header');
133
- }
134
-
135
- /***** End Helper Functions *****/
136
-
137
- // Methods
138
- if (methodName === 'destroy') {
139
- removeEventHandlers();
140
- return;
141
- } else if (methodParam >= 0 && methodParam < $panel_headers.length) {
142
- var $curr_header = $panel_headers.eq(methodParam);
143
- if ($curr_header.length && (methodName === 'open' || methodName === 'close' && $curr_header.hasClass('active'))) {
144
- collapsibleOpen($curr_header);
145
- }
146
- return;
147
- }
148
-
149
- removeEventHandlers();
150
-
151
- // Add click handler to only direct collapsible header children
152
- $this.on('click.collapse', '> li > .collapsible-header', function (e) {
153
- var element = $(e.target);
154
-
155
- if (isChildrenOfPanelHeader(element)) {
156
- element = getPanelHeader(element);
157
- }
158
-
159
- collapsibleOpen(element);
160
- });
161
-
162
- // Open first active
163
- if (options.accordion || collapsible_type === "accordion" || collapsible_type === undefined) {
164
- // Handle Accordion
165
- collapsibleOpen($panel_headers.filter('.active').first(), true);
166
- } else {
167
- // Handle Expandables
168
- $panel_headers.filter('.active').each(function () {
169
- collapsibleOpen($(this), true);
170
- });
171
- }
172
- });
173
- };
174
-
175
- $(document).on('ready turbolinks:load', function () {
176
- $('.collapsible').collapsible();
177
- });
178
- })(jQuery);