active_frontend 14.0.93 → 14.0.94

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: af843a72305e6ee29a39a7fc9ab681fbbea72292
4
- data.tar.gz: 5cd49422bba1f8e1db8b09fa60e5ee61514d8bf9
3
+ metadata.gz: 404cbb36552a8c5ccaae42e733d42d0812bb24de
4
+ data.tar.gz: ed60de040681002c9bcd868321441717eae96577
5
5
  SHA512:
6
- metadata.gz: 1a208cad10e2136faf1c0a608b4d165858a66f1bfd1ae926c7617cd03b388080efdcaa35efda9eb41689eda3526fe1aa0fc6763714ed21030853486db603dcbd
7
- data.tar.gz: bd2286d86bd4178cd2c3add1ef2c4bc59d9eded79ec808f705a96489478d43de85bca42c5297fad61e8c190a5ed8a1799e4c46449153d1396a3389d1bdcca5fc
6
+ metadata.gz: 331ad53386cac40bd770b597bcb1e99b2ab172d736d1d5f4e6e79b7fb87b2c4190610dc2a2cbbfc624368f36d7edbd1af1fca8df0282d1a098fe1151372315cb
7
+ data.tar.gz: 346e1f58d2f0e53e2df0ca8cad93e3b32beda3d568845bd2dfed73163424e19c974b7cc789477e73ee8ec60d8a0918e913acb41be4a4b985381557d803b520d9
@@ -1,3 +1,3 @@
1
1
  module ActiveFrontend
2
- VERSION = '14.0.93'.freeze
2
+ VERSION = '14.0.94'.freeze
3
3
  end
@@ -19,6 +19,7 @@
19
19
  };
20
20
  this.options = $.extend({}, Selectpicker.DEFAULTS, this.settings, options);
21
21
 
22
+ this.$optgroups = this.getOptgroups();
22
23
  this.$options = this.getOptions();
23
24
  this.$selected = this.getSelectedOptionVal();
24
25
  this.$fuzzyId = 'bsSelectpicker-fuzzy-' + this.randomNumber();
@@ -80,6 +81,7 @@
80
81
  Selectpicker.prototype.initWidget = function () {
81
82
  var _self = this;
82
83
  var menu = $(this.options.menu);
84
+ var optgroups = this.parseOptgroupsToHash();
83
85
 
84
86
  if (this.options.fuzzySearch && this.hasFuzzyAmount()) {
85
87
  menu.attr('data-toggle', 'list')
@@ -89,6 +91,12 @@
89
91
  }
90
92
 
91
93
  $.each(this.parseOptionsToHash(), function (index, hash) {
94
+ var optgroup = optgroups[hash.value];
95
+
96
+ if (optgroup !== undefined) {
97
+ menu.find('span').append(_self.optgroupTemplate(optgroup));
98
+ }
99
+
92
100
  var item = $(_self.options.item);
93
101
 
94
102
  item.append(_self.optionTemplate(hash));
@@ -156,6 +164,20 @@
156
164
  return Math.floor((Math.random() * 100000) + 1);
157
165
  };
158
166
 
167
+ Selectpicker.prototype.parseOptgroupsToHash = function () {
168
+ var _self = this;
169
+ var hash = {};
170
+
171
+ this.$optgroups.each(function() {
172
+ var optgroup = $(this);
173
+ var first_option = optgroup.find('option').first().val();
174
+
175
+ hash[first_option] = optgroup.attr('label');
176
+ });
177
+
178
+ return hash;
179
+ };
180
+
159
181
  Selectpicker.prototype.parseOptionsToHash = function () {
160
182
  var _self = this;
161
183
  var array = [];
@@ -181,6 +203,10 @@
181
203
  return array;
182
204
  };
183
205
 
206
+ Selectpicker.prototype.getOptgroups = function () {
207
+ return this.$element.find('optgroup');
208
+ };
209
+
184
210
  Selectpicker.prototype.getOptions = function () {
185
211
  return this.$element.find('option');
186
212
  };
@@ -223,6 +249,10 @@
223
249
  (hash.selected ? (' ' + this.options.optionSelectedClass) : '');
224
250
  };
225
251
 
252
+ Selectpicker.prototype.optgroupTemplate = function (label) {
253
+ return '<li class="optgroup">' + label + '</li>';
254
+ };
255
+
226
256
  Selectpicker.prototype.optionTemplate = function (hash) {
227
257
  return '<a href="#" class="' +
228
258
  this.optionClass(hash) +
@@ -35,6 +35,12 @@
35
35
  &.hidden { display: none; }
36
36
  &.selectpicker-fuzzy { padding: 10px 10px 5px; }
37
37
  &.bsListEmpty { padding: 16px 20px; }
38
+ &.optgroup {
39
+ background: color(light-haze);
40
+ font-size: text-size(xs);
41
+ font-weight: text-weight(semibold);
42
+ padding: 5px 10px;
43
+ }
38
44
  }
39
45
  }
40
46
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_frontend
3
3
  version: !ruby/object:Gem::Version
4
- version: 14.0.93
4
+ version: 14.0.94
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-27 00:00:00.000000000 Z
11
+ date: 2017-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails