active_frontend 14.0.68 → 14.0.69

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b25f622d68447b81d1a8cb26267c3a9f030ffc6d
4
- data.tar.gz: 621772b755be94bd5b7c0e08641067ce0f493b59
3
+ metadata.gz: 0733efbe467ee1f300a256f64489a898521a045d
4
+ data.tar.gz: c27e6b9c2796793ac339eff852fc4ffa1dd2a7b2
5
5
  SHA512:
6
- metadata.gz: 876a37c6c47e09a66ec45a843036169bcc42c091e81271342ee4e45e1534b375e3a9c99e6dbb2be611261fc1e4edfb0726d456705510a4f669cbc1ce37347310
7
- data.tar.gz: c6a8b3d24a4c0112376fabb94b0e5ef1505322bba2338e1ef336f65989b7281ed868ffd938502183f28fa78da12a37785e53fca9b6fafb172460812e1eea18e9
6
+ metadata.gz: 0c11087d00cc9329c686fdc9932f26e38304454f740bb192b2ee13afa4295153166cd44ab0db5819170bc28d79d0d660adf74765eed890d540e1aea5060aaf89
7
+ data.tar.gz: c3f1156a906b9110e63111be1a23c8b8ae4d279bfd5e443239ca20629313a3e5b23482925a62ec2fc78748e71905a715486ffd22edbb38cfb30402ea2053df0c
@@ -1,3 +1,3 @@
1
1
  module ActiveFrontend
2
- VERSION = '14.0.68'.freeze
2
+ VERSION = '14.0.69'.freeze
3
3
  end
@@ -8,10 +8,12 @@
8
8
  this.$element = $(element);
9
9
  this.settings = {
10
10
  choices: this.$element.data('choices'),
11
+ fuzzySearch: this.$element.data('fuzzySearch'),
11
12
  text: {
12
13
  all: this.$element.data('text-all') || Choicepicker.DEFAULTS.text.all,
13
14
  choiceless: this.$element.data('text-choiceless') || Choicepicker.DEFAULTS.text.choiceless,
14
15
  none: this.$element.data('text-none') || Choicepicker.DEFAULTS.text.none,
16
+ placeholder: this.$element.data('text-placeholder') || Choicepicker.DEFAULTS.text.placeholder,
15
17
  selectAll: this.$element.data('text-select-all') || Choicepicker.DEFAULTS.text.selectAll
16
18
  },
17
19
  type: this.$element.data('type')
@@ -20,24 +22,28 @@
20
22
 
21
23
  this.$checkAll = false;
22
24
  this.$selector = 'bsChoicepicker-label-' + this.randomNumber() + '-';
25
+ this.$fuzzyId = 'bsChoicepicker-fuzzy-' + this.randomNumber();
23
26
  this.$widget = $(this.initWidget()).on('click', $.proxy(this.clickWidget, this));
24
27
 
25
28
  this.init();
26
29
  };
27
30
 
28
31
  if (!$.fn.dropdown) throw new Error('Choicepicker requires dropdown.js');
32
+ if (!$.fn.list) throw new Error('Choicepicker requires list.js');
29
33
 
30
34
  Choicepicker.VERSION = '1.0.0';
31
35
  Choicepicker.DEFAULTS = {
32
36
  callback: function (choice) {},
33
37
  choices: [],
34
38
  choiceClass: 'form-align-vertical',
39
+ fuzzySearch: true,
35
40
  item: '<li></li>',
36
41
  menu: '<ul class="choicepicker dropmenu caret"><span></span></ul>',
37
42
  text: {
38
43
  all: 'All',
39
44
  choiceless: 'No choices available',
40
45
  none: 'None',
46
+ placeholder: 'Filter options...',
41
47
  selectAll: 'Select all'
42
48
  },
43
49
  type: 'checkbox'
@@ -72,9 +78,16 @@
72
78
  var _self = this;
73
79
  var menu = $(this.options.menu);
74
80
 
81
+ if (this.options.fuzzySearch) {
82
+ menu.attr('data-toggle', 'list')
83
+ .attr('data-input', '#' + this.$fuzzyId)
84
+ .find('span')
85
+ .append(this.fuzzyTemplate());
86
+ }
87
+
75
88
  if (this.options.type === 'checkbox') {
76
89
  menu.find('span')
77
- .append(this.titleTemplate());
90
+ .append(this.allTemplate());
78
91
  }
79
92
 
80
93
  $.each(this.options.choices, function (index, hash) {
@@ -176,7 +189,20 @@
176
189
  return $('<label for="' + selector + '">');
177
190
  };
178
191
 
179
- Choicepicker.prototype.titleTemplate = function () {
192
+ Choicepicker.prototype.fuzzyTemplate = function () {
193
+ var container = $('<div class="form-input form-size-s">');
194
+ var textbox = $('<input type="text" placeholder="' + this.options.text.placeholder + '" id="' + this.$fuzzyId + '" autofocus>');
195
+
196
+ container.append(textbox);
197
+
198
+ var item = $(this.options.item);
199
+ item.addClass('choicepicker-fuzzy list-skip-filter')
200
+ .append(container);
201
+
202
+ return item;
203
+ };
204
+
205
+ Choicepicker.prototype.allTemplate = function () {
180
206
  var selector = this.checkAllSelector();
181
207
  var boxLabel = $('<label for="' + selector + '">');
182
208
  var textLabel = boxLabel.clone();
@@ -191,7 +217,8 @@
191
217
  container.append(boxLabel);
192
218
 
193
219
  var item = $(this.options.item);
194
- item.append(container)
220
+ item.addClass('list-skip-filter')
221
+ .append(container)
195
222
  .append(textLabel.text(this.options.text.selectAll));
196
223
 
197
224
  return item;
@@ -13,7 +13,7 @@
13
13
  this.options = $.extend({}, List.DEFAULTS, this.settings, options);
14
14
 
15
15
  this.$input = $(this.options.input);
16
- this.$lis = this.$element.children();
16
+ this.$lis = this.listLis();
17
17
  this.$len = this.$lis.length;
18
18
 
19
19
  this.init();
@@ -41,6 +41,7 @@
41
41
 
42
42
  for (var i = 0; i < _self.$len; i++) {
43
43
  var li = $(_self.$lis[i]);
44
+ if (li.hasClass('list-skip-filter')) { continue; }
44
45
 
45
46
  if (li.text().toLowerCase().indexOf(filter) >= 0) {
46
47
  li.removeClass('hidden');
@@ -51,9 +52,16 @@
51
52
  }
52
53
 
53
54
  if (_self.options.placeholder !== null) {
55
+ var emptyLi = '<li class="bsListEmpty">' + _self.options.emptyText + '</li>';
54
56
  list.find('.bsListEmpty').remove();
55
57
 
56
- if (visible === 0) list.append('<li class="bsListEmpty">' + _self.options.emptyText + '</li>');
58
+ if (visible === 0) {
59
+ if (_self.hasSpan()) {
60
+ list.find('span').append(emptyLi);
61
+ } else {
62
+ list.append(emptyLi);
63
+ }
64
+ }
57
65
  }
58
66
 
59
67
  _self.options.callback(visible);
@@ -62,6 +70,20 @@
62
70
  });
63
71
  };
64
72
 
73
+ List.prototype.hasSpan = function () {
74
+ return this.$element.children().first().is('span');
75
+ };
76
+
77
+ List.prototype.listLis = function () {
78
+ var kids = this.$element.children();
79
+
80
+ if (this.hasSpan()) {
81
+ kids = kids.children();
82
+ }
83
+
84
+ return kids;
85
+ };
86
+
65
87
  // LIST PLUGIN DEFINITION
66
88
  // ======================
67
89
 
@@ -14,8 +14,8 @@
14
14
  overflow-x: auto;
15
15
 
16
16
  > li {
17
- border-bottom: 1px solid;
18
- border-bottom-color: inherit;
17
+ border-top: 1px solid;
18
+ border-top-color: inherit;
19
19
  clear: both;
20
20
  display: block;
21
21
  font-weight: inherit;
@@ -23,7 +23,10 @@
23
23
  padding: 16px 20px 14px;
24
24
  margin: 0;
25
25
 
26
- &:last-child { border-bottom: 0; }
26
+ &:first-child { border-top: 0; }
27
+
28
+ &.hidden { display: none; }
29
+ &.choicepicker-fuzzy { padding: 10px 10px 5px; }
27
30
 
28
31
  > label {
29
32
  font-weight: text-weight(normal);
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.68
4
+ version: 14.0.69
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-02-13 00:00:00.000000000 Z
11
+ date: 2017-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails