selectize-rails 0.12.1 → 0.12.2

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: a772e162910436e4fc4436c5a2aadc7d40ed2ea8
4
- data.tar.gz: 5327679656c41365c95b85d52053efc4b335262e
3
+ metadata.gz: b7e84f5ce126f32fbabf41a9e52abf21ee50f21a
4
+ data.tar.gz: 2116854e115d27fd63d4de6c5204247d69fa2e21
5
5
  SHA512:
6
- metadata.gz: b3ac3a20d13c34b3122e62053e474e441ecedced844cae7578ad57a1fbafee0effaeeb68dd1add0260520bbc2298a14e17051957854c6d8dd16724a6976bb5c7
7
- data.tar.gz: 2d90885729dfb7374622316b04eec5656a931eb52b79b82ba5896b153e0fad7e0778814c49e8ffc021ecc0fc5f576e908aaf75a5a1ac476168fb2419d8c779d3
6
+ metadata.gz: 27112eea339556194297538b0b2594479e67f3c291a8a5ca21a58c53456ce7b3a7113a9f61be5fe1cb7e696f2e7954da736415798c04fe6d7fa22274290916e7
7
+ data.tar.gz: 9e01c04d222aeee330d023e6e45ba27a17e8059476ddb447f64c169139359ccdd044e7dbbcba6f760c2860b3d797540c489d8e20adea8349c222d4c631c7b81e
data/README.md CHANGED
@@ -1,68 +1,70 @@
1
- # selectize-rails [![Gem Version](https://badge.fury.io/rb/selectize-rails.png)](http://badge.fury.io/rb/selectize-rails)
2
-
3
- selectize-rails provides the [selectize.js](http://brianreavis.github.io/selectize.js/)
4
- plugin as a Rails engine to use it within the asset pipeline.
5
-
6
- ## Installation
7
-
8
- Add this to your Gemfile:
9
-
10
- ```ruby
11
- gem "selectize-rails"
12
- ```
13
-
14
- and run `bundle install`.
15
-
16
- ## Usage
17
-
18
- In your `application.js`, include the following:
19
-
20
- ```js
21
- //= require selectize
22
- ```
23
-
24
- In your `application.css`, include the following:
25
-
26
- ```css
27
- *= require selectize
28
- *= require selectize.default
29
- ```
30
-
31
- ### Themes
32
-
33
- To include additional theme's you can replace the `selectize.default` for one of the [theme files](https://github.com/brianreavis/selectize.js/tree/master/dist/css)
34
-
35
-
36
- ## Examples
37
-
38
- See the [demo page of Brian Reavis](http://brianreavis.github.io/selectize.js/) for examples how to use the plugin
39
-
40
- ## Changes
41
-
42
- | Version | Notes |
43
- | --------:| ----------------------------------------------------------- |
44
- | 0.12.0 | Update to v0.12.0 of selectize.js |
45
- | 0.11.2 | Update to v0.11.2 of selectize.js |
46
- | 0.11.0 | Update to v0.11.0 of selectize.js |
47
- | 0.9.1 | Update to v0.9.1 of selectize.js |
48
- | 0.9.0 | Update to v0.9.0 of selectize.js |
49
- | 0.8.5 | Update to v0.8.5 of selectize.js |
50
- | 0.8.4 | Update to v0.8.4 of selectize.js |
51
- | 0.8.3 | Update to v0.8.3 of selectize.js |
52
-
53
- [older](CHANGELOG.md)
54
-
55
- ## License
56
-
57
- * The [selectize.js](http://brianreavis.github.io/selectize.js/) plugin is licensed under the
58
- [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
59
- * The [selectize-rails](https://github.com/manuelvanrijn/selectize-rails) project is
60
- licensed under the [MIT License](http://opensource.org/licenses/mit-license.html)
61
-
62
- ## Contributing
63
-
64
- 1. Fork it
65
- 2. Create your feature branch (`git checkout -b my-new-feature`)
66
- 3. Commit your changes (`git commit -am 'Add some feature'`)
67
- 4. Push to the branch (`git push origin my-new-feature`)
68
- 5. Create new Pull Request
1
+ # selectize-rails [![Gem Version](https://badge.fury.io/rb/selectize-rails.png)](http://badge.fury.io/rb/selectize-rails)
2
+
3
+ selectize-rails provides the [selectize.js](http://brianreavis.github.io/selectize.js/)
4
+ plugin as a Rails engine to use it within the asset pipeline.
5
+
6
+ ## Installation
7
+
8
+ Add this to your Gemfile:
9
+
10
+ ```ruby
11
+ gem "selectize-rails"
12
+ ```
13
+
14
+ and run `bundle install`.
15
+
16
+ ## Usage
17
+
18
+ In your `application.js`, include the following:
19
+
20
+ ```js
21
+ //= require selectize
22
+ ```
23
+
24
+ In your `application.css`, include the following:
25
+
26
+ ```css
27
+ *= require selectize
28
+ *= require selectize.default
29
+ ```
30
+
31
+ ### Themes
32
+
33
+ To include additional theme's you can replace the `selectize.default` for one of the [theme files](https://github.com/brianreavis/selectize.js/tree/master/dist/css)
34
+
35
+
36
+ ## Examples
37
+
38
+ See the [demo page of Brian Reavis](http://brianreavis.github.io/selectize.js/) for examples how to use the plugin
39
+
40
+ ## Changes
41
+
42
+ | Version | Notes |
43
+ | --------:| ----------------------------------------------------------- |
44
+ | 0.12.2 | Update to v0.12.2 of selectize.js |
45
+ | 0.12.1 | Update to v0.12.1 of selectize.js |
46
+ | 0.12.0 | Update to v0.12.0 of selectize.js |
47
+ | 0.11.2 | Update to v0.11.2 of selectize.js |
48
+ | 0.11.0 | Update to v0.11.0 of selectize.js |
49
+ | 0.9.1 | Update to v0.9.1 of selectize.js |
50
+ | 0.9.0 | Update to v0.9.0 of selectize.js |
51
+ | 0.8.5 | Update to v0.8.5 of selectize.js |
52
+ | 0.8.4 | Update to v0.8.4 of selectize.js |
53
+ | 0.8.3 | Update to v0.8.3 of selectize.js |
54
+
55
+ [older](CHANGELOG.md)
56
+
57
+ ## License
58
+
59
+ * The [selectize.js](http://brianreavis.github.io/selectize.js/) plugin is licensed under the
60
+ [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
61
+ * The [selectize-rails](https://github.com/manuelvanrijn/selectize-rails) project is
62
+ licensed under the [MIT License](http://opensource.org/licenses/mit-license.html)
63
+
64
+ ## Contributing
65
+
66
+ 1. Fork it
67
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
68
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
69
+ 4. Push to the branch (`git push origin my-new-feature`)
70
+ 5. Create new Pull Request
@@ -1,5 +1,5 @@
1
1
  module Selectize
2
2
  module Rails
3
- VERSION = "0.12.1"
3
+ VERSION = "0.12.2"
4
4
  end
5
5
  end
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.name = "selectize-rails"
8
8
  spec.version = Selectize::Rails::VERSION
9
9
  spec.authors = ["Manuel van Rijn"]
10
- spec.email = ["manuel@manuelles.nl"]
10
+ spec.email = ["manuel@manuelvanrijn.nl"]
11
11
  spec.description = %q{A small gem for putting selectize.js into the Rails asset pipeline}
12
12
  spec.summary = %q{an asset gemification of the selectize.js plugin}
13
13
  spec.homepage = "https://github.com/manuelvanrijn/selectize-rails"
@@ -1,8 +1,8 @@
1
1
  #!/bin/bash
2
2
 
3
3
  # Checkout vendor repo
4
- echo "Cloning brianreavis/selectize.js github repo into tmp_vendor"
5
- git clone https://github.com/brianreavis/selectize.js.git tmp_vendor
4
+ echo "Cloning selectize/selectize.js github repo into tmp_vendor"
5
+ git clone https://github.com/selectize/selectize.js.git tmp_vendor
6
6
 
7
7
  # Copy files
8
8
  echo "Copying selectize.js"
@@ -114,13 +114,14 @@
114
114
  * @returns {function}
115
115
  */
116
116
  Sifter.prototype.getScoreFunction = function(search, options) {
117
- var self, fields, tokens, token_count;
117
+ var self, fields, tokens, token_count, nesting;
118
118
 
119
119
  self = this;
120
120
  search = self.prepareSearch(search, options);
121
121
  tokens = search.tokens;
122
122
  fields = search.options.fields;
123
123
  token_count = tokens.length;
124
+ nesting = search.options.nesting;
124
125
 
125
126
  /**
126
127
  * Calculates how close of a match the
@@ -157,12 +158,12 @@
157
158
  }
158
159
  if (field_count === 1) {
159
160
  return function(token, data) {
160
- return scoreValue(data[fields[0]], token);
161
+ return scoreValue(getattr(data, fields[0], nesting), token);
161
162
  };
162
163
  }
163
164
  return function(token, data) {
164
165
  for (var i = 0, sum = 0; i < field_count; i++) {
165
- sum += scoreValue(data[fields[i]], token);
166
+ sum += scoreValue(getattr(data, fields[i], nesting), token);
166
167
  }
167
168
  return sum / field_count;
168
169
  };
@@ -223,7 +224,7 @@
223
224
  */
224
225
  get_field = function(name, result) {
225
226
  if (name === '$score') return result.score;
226
- return self.items[result.id][name];
227
+ return getattr(self.items[result.id], name, options.nesting);
227
228
  };
228
229
 
229
230
  // parse options
@@ -412,6 +413,21 @@
412
413
  return a;
413
414
  };
414
415
 
416
+ /**
417
+ * A property getter resolving dot-notation
418
+ * @param {Object} obj The root object to fetch property on
419
+ * @param {String} name The optionally dotted property name to fetch
420
+ * @param {Boolean} nesting Handle nesting or not
421
+ * @return {Object} The resolved property value
422
+ */
423
+ var getattr = function(obj, name, nesting) {
424
+ if (!obj || !name) return;
425
+ if (!nesting) return obj[name];
426
+ var names = name.split(".");
427
+ while(names.length && (obj = obj[names.shift()]));
428
+ return obj;
429
+ };
430
+
415
431
  var trim = function(str) {
416
432
  return (str + '').replace(/^\s+|\s+$|/g, '');
417
433
  };
@@ -420,25 +436,36 @@
420
436
  return (str + '').replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1');
421
437
  };
422
438
 
423
- var is_array = Array.isArray || ($ && $.isArray) || function(object) {
439
+ var is_array = Array.isArray || (typeof $ !== 'undefined' && $.isArray) || function(object) {
424
440
  return Object.prototype.toString.call(object) === '[object Array]';
425
441
  };
426
442
 
427
443
  var DIACRITICS = {
428
- 'a': '[aÀÁÂÃÄÅàáâãäåĀāąĄ]',
429
- 'c': '[cÇçćĆčČ]',
430
- 'd': '[dđĐďĎ]',
431
- 'e': '[eÈÉÊËèéêëěĚĒēęĘ]',
432
- 'i': '[iÌÍÎÏìíîïĪī]',
433
- 'l': '[lłŁ]',
434
- 'n': '[nÑñňŇńŃ]',
435
- 'o': '[oÒÓÔÕÕÖØòóôõöøŌō]',
436
- 'r': '[rřŘ]',
437
- 's': '[sŠšśŚ]',
438
- 't': '[tťŤ]',
439
- 'u': '[uÙÚÛÜùúûüůŮŪū]',
440
- 'y': '[yŸÿýÝ]',
441
- 'z': '[zŽžżŻźŹ]'
444
+ 'a': '[aḀḁĂăÂâǍǎȺⱥȦȧẠạÄäÀàÁáĀāÃãÅåąĄÃąĄ]',
445
+ 'b': '[b␢βΒB฿𐌁ᛒ]',
446
+ 'c': '[cĆćĈĉČčĊċC̄c̄ÇçḈḉȻȼƇƈɕᴄCc]',
447
+ 'd': '[dĎďḊḋḐḑḌḍḒḓḎḏĐđD̦d̦ƉɖƊɗƋƌᵭᶁᶑȡᴅDdð]',
448
+ 'e': '[eÉéÈèÊêḘḙĚěĔĕẼẽḚḛẺẻĖėËëĒēȨȩĘęᶒɆɇȄȅẾếỀềỄễỂểḜḝḖḗḔḕȆȇẸẹỆệⱸᴇEeɘǝƏƐε]',
449
+ 'f': '[fƑƒḞḟ]',
450
+ 'g': '[gɢ₲ǤǥĜĝĞğĢģƓɠĠġ]',
451
+ 'h': '[hĤĥĦħḨḩẖẖḤḥḢḣɦʰǶƕ]',
452
+ 'i': '[iÍíÌìĬĭÎîǏǐÏïḮḯĨĩĮįĪīỈỉȈȉȊȋỊịḬḭƗɨɨ̆ᵻᶖİiIıɪIi]',
453
+ 'j': '[jȷĴĵɈɉʝɟʲ]',
454
+ 'k': '[kƘƙꝀꝁḰḱǨǩḲḳḴḵκϰ₭]',
455
+ 'l': '[lŁłĽľĻļĹĺḶḷḸḹḼḽḺḻĿŀȽƚⱠⱡⱢɫɬᶅɭȴʟLl]',
456
+ 'n': '[nŃńǸǹŇňÑñṄṅŅņṆṇṊṋṈṉN̈n̈ƝɲȠƞᵰᶇɳȵɴNnŊŋ]',
457
+ 'o': '[oØøÖöÓóÒòÔôǑǒŐőŎŏȮȯỌọƟɵƠơỎỏŌōÕõǪǫȌȍՕօ]',
458
+ 'p': '[pṔṕṖṗⱣᵽƤƥᵱ]',
459
+ 'q': '[qꝖꝗʠɊɋꝘꝙq̃]',
460
+ 'r': '[rŔŕɌɍŘřŖŗṘṙȐȑȒȓṚṛⱤɽ]',
461
+ 's': '[sŚśṠṡṢṣꞨꞩŜŝŠšŞşȘșS̈s̈]',
462
+ 't': '[tŤťṪṫŢţṬṭƮʈȚțṰṱṮṯƬƭ]',
463
+ 'u': '[uŬŭɄʉỤụÜüÚúÙùÛûǓǔŰűŬŭƯưỦủŪūŨũŲųȔȕ∪]',
464
+ 'v': '[vṼṽṾṿƲʋꝞꝟⱱʋ]',
465
+ 'w': '[wẂẃẀẁŴŵẄẅẆẇẈẉ]',
466
+ 'x': '[xẌẍẊẋχ]',
467
+ 'y': '[yÝýỲỳŶŷŸÿỸỹẎẏỴỵɎɏƳƴ]',
468
+ 'z': '[zŹźẐẑŽžŻżẒẓẔẕƵƶ]'
442
469
  };
443
470
 
444
471
  var asciifold = (function() {
@@ -608,7 +635,7 @@
608
635
  }));
609
636
 
610
637
  /**
611
- * selectize.js (v0.12.1)
638
+ * selectize.js (v0.12.2)
612
639
  * Copyright (c) 2013–2015 Brian Reavis & contributors
613
640
  *
614
641
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
@@ -1053,6 +1080,15 @@
1053
1080
  update();
1054
1081
  };
1055
1082
 
1083
+ var domToString = function(d) {
1084
+ var tmp = document.createElement('div');
1085
+
1086
+ tmp.appendChild(d.cloneNode(true));
1087
+
1088
+ return tmp.innerHTML;
1089
+ };
1090
+
1091
+
1056
1092
  var Selectize = function($input, settings) {
1057
1093
  var key, i, n, dir, input, self = this;
1058
1094
  input = $input[0];
@@ -1602,7 +1638,7 @@
1602
1638
  * Invokes the user-provide option provider / loader.
1603
1639
  *
1604
1640
  * Note: this function is debounced in the Selectize
1605
- * constructor (by `settings.loadDelay` milliseconds)
1641
+ * constructor (by `settings.loadThrottle` milliseconds)
1606
1642
  *
1607
1643
  * @param {string} value
1608
1644
  */
@@ -1677,7 +1713,7 @@
1677
1713
  self.refreshState();
1678
1714
 
1679
1715
  // IE11 bug: element still marked as active
1680
- (dest || document.body).focus();
1716
+ dest && dest.focus();
1681
1717
 
1682
1718
  self.ignoreFocus = false;
1683
1719
  self.trigger('blur');
@@ -2115,10 +2151,10 @@
2115
2151
  optgroup = '';
2116
2152
  }
2117
2153
  if (!groups.hasOwnProperty(optgroup)) {
2118
- groups[optgroup] = [];
2154
+ groups[optgroup] = document.createDocumentFragment();
2119
2155
  groups_order.push(optgroup);
2120
2156
  }
2121
- groups[optgroup].push(option_html);
2157
+ groups[optgroup].appendChild(option_html);
2122
2158
  }
2123
2159
  }
2124
2160
 
@@ -2132,23 +2168,26 @@
2132
2168
  }
2133
2169
 
2134
2170
  // render optgroup headers & join groups
2135
- html = [];
2171
+ html = document.createDocumentFragment();
2136
2172
  for (i = 0, n = groups_order.length; i < n; i++) {
2137
2173
  optgroup = groups_order[i];
2138
- if (self.optgroups.hasOwnProperty(optgroup) && groups[optgroup].length) {
2174
+ if (self.optgroups.hasOwnProperty(optgroup) && groups[optgroup].childNodes.length) {
2139
2175
  // render the optgroup header and options within it,
2140
2176
  // then pass it to the wrapper template
2141
- html_children = self.render('optgroup_header', self.optgroups[optgroup]) || '';
2142
- html_children += groups[optgroup].join('');
2143
- html.push(self.render('optgroup', $.extend({}, self.optgroups[optgroup], {
2144
- html: html_children
2177
+ html_children = document.createDocumentFragment();
2178
+ html_children.appendChild(self.render('optgroup_header', self.optgroups[optgroup]));
2179
+ html_children.appendChild(groups[optgroup]);
2180
+
2181
+ html.appendChild(self.render('optgroup', $.extend({}, self.optgroups[optgroup], {
2182
+ html: domToString(html_children),
2183
+ dom: html_children
2145
2184
  })));
2146
2185
  } else {
2147
- html.push(groups[optgroup].join(''));
2186
+ html.appendChild(groups[optgroup]);
2148
2187
  }
2149
2188
  }
2150
2189
 
2151
- $dropdown_content.html(html.join(''));
2190
+ $dropdown_content.html(html);
2152
2191
 
2153
2192
  // highlight matching terms inline
2154
2193
  if (self.settings.highlight && results.query.length && results.tokens.length) {
@@ -2236,7 +2275,7 @@
2236
2275
  */
2237
2276
  registerOption: function(data) {
2238
2277
  var key = hash_key(data[this.settings.valueField]);
2239
- if (!key || this.options.hasOwnProperty(key)) return false;
2278
+ if (typeof key === 'undefined' || key === null || this.options.hasOwnProperty(key)) return false;
2240
2279
  data.$order = data.$order || ++this.order;
2241
2280
  this.options[key] = data;
2242
2281
  return key;
@@ -2539,7 +2578,7 @@
2539
2578
  var self = this;
2540
2579
  var $item, i, idx;
2541
2580
 
2542
- $item = (typeof value === 'object') ? value : self.getItem(value);
2581
+ $item = (value instanceof $) ? value : self.getItem(value);
2543
2582
  value = hash_key($item.attr('data-value'));
2544
2583
  i = self.items.indexOf(value);
2545
2584
 
@@ -3099,26 +3138,26 @@
3099
3138
  }
3100
3139
 
3101
3140
  // render markup
3102
- html = self.settings.render[templateName].apply(this, [data, escape_html]);
3141
+ html = $(self.settings.render[templateName].apply(this, [data, escape_html]));
3103
3142
 
3104
3143
  // add mandatory attributes
3105
3144
  if (templateName === 'option' || templateName === 'option_create') {
3106
- html = html.replace(regex_tag, '<$1 data-selectable');
3145
+ html.attr('data-selectable', '');
3107
3146
  }
3108
- if (templateName === 'optgroup') {
3147
+ else if (templateName === 'optgroup') {
3109
3148
  id = data[self.settings.optgroupValueField] || '';
3110
- html = html.replace(regex_tag, '<$1 data-group="' + escape_replace(escape_html(id)) + '"');
3149
+ html.attr('data-group', id);
3111
3150
  }
3112
3151
  if (templateName === 'option' || templateName === 'item') {
3113
- html = html.replace(regex_tag, '<$1 data-value="' + escape_replace(escape_html(value || '')) + '"');
3152
+ html.attr('data-value', value || '');
3114
3153
  }
3115
3154
 
3116
3155
  // update cache
3117
3156
  if (cache) {
3118
- self.renderCache[templateName][value] = html;
3157
+ self.renderCache[templateName][value] = html[0];
3119
3158
  }
3120
3159
 
3121
- return html;
3160
+ return html[0];
3122
3161
  },
3123
3162
 
3124
3163
  /**
@@ -3301,7 +3340,7 @@
3301
3340
  var addOption = function($option, group) {
3302
3341
  $option = $($option);
3303
3342
 
3304
- var value = hash_key($option.attr('value'));
3343
+ var value = hash_key($option.val());
3305
3344
  if (!value && !settings.allowEmptyOption) return;
3306
3345
 
3307
3346
  // if the option already exists, it's probably been
@@ -3580,60 +3619,114 @@
3580
3619
  });
3581
3620
 
3582
3621
  Selectize.define('remove_button', function(options) {
3583
- if (this.settings.mode === 'single') return;
3584
-
3585
3622
  options = $.extend({
3586
- label : '&times;',
3587
- title : 'Remove',
3588
- className : 'remove',
3589
- append : true
3590
- }, options);
3623
+ label : '&times;',
3624
+ title : 'Remove',
3625
+ className : 'remove',
3626
+ append : true
3627
+ }, options);
3628
+
3629
+ var singleClose = function(thisRef, options) {
3630
+
3631
+ options.className = 'remove-single';
3632
+
3633
+ var self = thisRef;
3634
+ var html = '<a href="javascript:void(0)" class="' + options.className + '" tabindex="-1" title="' + escape_html(options.title) + '">' + options.label + '</a>';
3635
+
3636
+ /**
3637
+ * Appends an element as a child (with raw HTML).
3638
+ *
3639
+ * @param {string} html_container
3640
+ * @param {string} html_element
3641
+ * @return {string}
3642
+ */
3643
+ var append = function(html_container, html_element) {
3644
+ return html_container + html_element;
3645
+ };
3591
3646
 
3592
- var self = this;
3593
- var html = '<a href="javascript:void(0)" class="' + options.className + '" tabindex="-1" title="' + escape_html(options.title) + '">' + options.label + '</a>';
3647
+ thisRef.setup = (function() {
3648
+ var original = self.setup;
3649
+ return function() {
3650
+ // override the item rendering method to add the button to each
3651
+ if (options.append) {
3652
+ var id = $(self.$input.context).attr('id');
3653
+ var selectizer = $('#'+id);
3654
+
3655
+ var render_item = self.settings.render.item;
3656
+ self.settings.render.item = function(data) {
3657
+ return append(render_item.apply(thisRef, arguments), html);
3658
+ };
3659
+ }
3594
3660
 
3595
- /**
3596
- * Appends an element as a child (with raw HTML).
3597
- *
3598
- * @param {string} html_container
3599
- * @param {string} html_element
3600
- * @return {string}
3601
- */
3602
- var append = function(html_container, html_element) {
3603
- var pos = html_container.search(/(<\/[^>]+>\s*)$/);
3604
- return html_container.substring(0, pos) + html_element + html_container.substring(pos);
3605
- };
3661
+ original.apply(thisRef, arguments);
3662
+
3663
+ // add event listener
3664
+ thisRef.$control.on('click', '.' + options.className, function(e) {
3665
+ e.preventDefault();
3666
+ if (self.isLocked) return;
3667
+
3668
+ self.clear();
3669
+ });
3606
3670
 
3607
- this.setup = (function() {
3608
- var original = self.setup;
3609
- return function() {
3610
- // override the item rendering method to add the button to each
3611
- if (options.append) {
3612
- var render_item = self.settings.render.item;
3613
- self.settings.render.item = function(data) {
3614
- return append(render_item.apply(this, arguments), html);
3615
3671
  };
3616
- }
3672
+ })();
3673
+ };
3617
3674
 
3618
- original.apply(this, arguments);
3675
+ var multiClose = function(thisRef, options) {
3676
+
3677
+ var self = thisRef;
3678
+ var html = '<a href="javascript:void(0)" class="' + options.className + '" tabindex="-1" title="' + escape_html(options.title) + '">' + options.label + '</a>';
3679
+
3680
+ /**
3681
+ * Appends an element as a child (with raw HTML).
3682
+ *
3683
+ * @param {string} html_container
3684
+ * @param {string} html_element
3685
+ * @return {string}
3686
+ */
3687
+ var append = function(html_container, html_element) {
3688
+ var pos = html_container.search(/(<\/[^>]+>\s*)$/);
3689
+ return html_container.substring(0, pos) + html_element + html_container.substring(pos);
3690
+ };
3619
3691
 
3620
- // add event listener
3621
- this.$control.on('click', '.' + options.className, function(e) {
3622
- e.preventDefault();
3623
- if (self.isLocked) return;
3692
+ thisRef.setup = (function() {
3693
+ var original = self.setup;
3694
+ return function() {
3695
+ // override the item rendering method to add the button to each
3696
+ if (options.append) {
3697
+ var render_item = self.settings.render.item;
3698
+ self.settings.render.item = function(data) {
3699
+ return append(render_item.apply(thisRef, arguments), html);
3700
+ };
3701
+ }
3624
3702
 
3625
- var $item = $(e.currentTarget).parent();
3626
- self.setActiveItem($item);
3627
- if (self.deleteSelection()) {
3628
- self.setCaret(self.items.length);
3629
- }
3630
- });
3703
+ original.apply(thisRef, arguments);
3631
3704
 
3705
+ // add event listener
3706
+ thisRef.$control.on('click', '.' + options.className, function(e) {
3707
+ e.preventDefault();
3708
+ if (self.isLocked) return;
3709
+
3710
+ var $item = $(e.currentTarget).parent();
3711
+ self.setActiveItem($item);
3712
+ if (self.deleteSelection()) {
3713
+ self.setCaret(self.items.length);
3714
+ }
3715
+ });
3716
+
3717
+ };
3718
+ })();
3632
3719
  };
3633
- })();
3634
3720
 
3721
+ if (this.settings.mode === 'single') {
3722
+ singleClose(this, options);
3723
+ return;
3724
+ } else {
3725
+ multiClose(this, options);
3726
+ }
3635
3727
  });
3636
3728
 
3729
+
3637
3730
  Selectize.define('restore_on_backspace', function(options) {
3638
3731
  var self = this;
3639
3732
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * selectize.bootstrap2.css (v0.12.1) - Bootstrap 2 Theme
2
+ * selectize.bootstrap2.css (v0.12.2) - Bootstrap 2 Theme
3
3
  * Copyright (c) 2013–2015 Brian Reavis & contributors
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
@@ -108,6 +108,12 @@
108
108
  .selectize-control.plugin-remove_button .disabled [data-value] .remove {
109
109
  border-left-color: #e0e0e0;
110
110
  }
111
+ .selectize-control.plugin-remove_button .remove-single {
112
+ position: absolute;
113
+ right: 28px;
114
+ top: 6px;
115
+ font-size: 23px;
116
+ }
111
117
  .selectize-control {
112
118
  position: relative;
113
119
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * selectize.bootstrap3.css (v0.12.1) - Bootstrap 3 Theme
2
+ * selectize.bootstrap3.css (v0.12.2) - Bootstrap 3 Theme
3
3
  * Copyright (c) 2013–2015 Brian Reavis & contributors
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
@@ -108,6 +108,12 @@
108
108
  .selectize-control.plugin-remove_button .disabled [data-value] .remove {
109
109
  border-left-color: rgba(77, 77, 77, 0);
110
110
  }
111
+ .selectize-control.plugin-remove_button .remove-single {
112
+ position: absolute;
113
+ right: 28px;
114
+ top: 6px;
115
+ font-size: 23px;
116
+ }
111
117
  .selectize-control {
112
118
  position: relative;
113
119
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * selectize.css (v0.12.1)
2
+ * selectize.css (v0.12.2)
3
3
  * Copyright (c) 2013–2015 Brian Reavis & contributors
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
@@ -109,6 +109,12 @@
109
109
  .selectize-control.plugin-remove_button .disabled [data-value] .remove {
110
110
  border-left-color: #ffffff;
111
111
  }
112
+ .selectize-control.plugin-remove_button .remove-single {
113
+ position: absolute;
114
+ right: 28px;
115
+ top: 6px;
116
+ font-size: 23px;
117
+ }
112
118
  .selectize-control {
113
119
  position: relative;
114
120
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * selectize.default.css (v0.12.1) - Default Theme
2
+ * selectize.default.css (v0.12.2) - Default Theme
3
3
  * Copyright (c) 2013–2015 Brian Reavis & contributors
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
@@ -108,6 +108,12 @@
108
108
  .selectize-control.plugin-remove_button .disabled [data-value] .remove {
109
109
  border-left-color: #aaaaaa;
110
110
  }
111
+ .selectize-control.plugin-remove_button .remove-single {
112
+ position: absolute;
113
+ right: 28px;
114
+ top: 6px;
115
+ font-size: 23px;
116
+ }
111
117
  .selectize-control {
112
118
  position: relative;
113
119
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * selectize.legacy.css (v0.12.1) - Default Theme
2
+ * selectize.legacy.css (v0.12.2) - Default Theme
3
3
  * Copyright (c) 2013–2015 Brian Reavis & contributors
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
@@ -108,6 +108,12 @@
108
108
  .selectize-control.plugin-remove_button .disabled [data-value] .remove {
109
109
  border-left-color: #b4b4b4;
110
110
  }
111
+ .selectize-control.plugin-remove_button .remove-single {
112
+ position: absolute;
113
+ right: 28px;
114
+ top: 6px;
115
+ font-size: 23px;
116
+ }
111
117
  .selectize-control {
112
118
  position: relative;
113
119
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selectize-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 0.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel van Rijn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-19 00:00:00.000000000 Z
11
+ date: 2016-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -40,7 +40,7 @@ dependencies:
40
40
  version: '0'
41
41
  description: A small gem for putting selectize.js into the Rails asset pipeline
42
42
  email:
43
- - manuel@manuelles.nl
43
+ - manuel@manuelvanrijn.nl
44
44
  executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
@@ -83,9 +83,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  version: '0'
84
84
  requirements: []
85
85
  rubyforge_project:
86
- rubygems_version: 2.4.5
86
+ rubygems_version: 2.5.1
87
87
  signing_key:
88
88
  specification_version: 4
89
89
  summary: an asset gemification of the selectize.js plugin
90
90
  test_files: []
91
- has_rdoc: