select2-rails 3.4.8 → 3.4.9

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -36,7 +36,12 @@ Add the following to your `app/assets/javascripts/application.js`:
36
36
 
37
37
  Possible languages:
38
38
 
39
- ar, ca, cs, da, de, el, es, et, eu, fi, fr, gl, he, hr, hu, id, is, it, ja, ko, lt, lv, mk, nl, no, pl, pt-BR, pt-PT, ro, ru, sk, sv, tr, ua, vi, zh-CN, zh-TW
39
+ ar, ca, cs, da, de, el, es, et, eu, fi, fr, gl, he, hr, hu, id, is, it, ja, ko, lt, lv, mk, ms, nl, no, pl, pt-BR, pt-PT, ro, ru, sk, sv, tr, ua, vi, zh-CN, zh-TW
40
+
41
+ ## Example
42
+ Code [here](https://github.com/argerim/select_2_example)
43
+
44
+ Heroku app [here](http://select-2-example.herokuapp.com/)
40
45
 
41
46
  ## Version
42
47
  From `v2.1.0` on, `select2-rails`'s version will match the version of `Select2` it uses.
@@ -53,4 +58,4 @@ If you want to contribute, please:
53
58
 
54
59
  ## License
55
60
 
56
- Selec2-Rails is released under the [MIT License](http://www.opensource.org/licenses/MIT).
61
+ Selec2-Rails is released under the [MIT License](http://www.opensource.org/licenses/MIT).
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  Copyright 2012 Igor Vaynberg
3
3
 
4
- Version: 3.4.2 Timestamp: Mon Aug 12 15:04:12 PDT 2013
4
+ Version: 3.4.3 Timestamp: Tue Sep 17 06:47:14 PDT 2013
5
5
 
6
6
  This software is licensed under the Apache License, Version 2.0 (the "Apache License") or the GNU
7
7
  General Public License version 2 (the "GPL License"). You may choose either license to govern your
@@ -688,15 +688,19 @@ the specific language governing permissions and limitations under the Apache Lic
688
688
  this.opts.element
689
689
  .data("select2", this)
690
690
  .attr("tabindex", "-1")
691
- .before(this.container);
691
+ .before(this.container)
692
+ .on("click.select2", killEvent); // do not leak click events
693
+
692
694
  this.container.data("select2", this);
693
695
 
694
696
  this.dropdown = this.container.find(".select2-drop");
695
- this.dropdown.addClass(evaluate(opts.dropdownCssClass));
696
- this.dropdown.data("select2", this);
697
697
 
698
698
  syncCssClasses(this.dropdown, this.opts.element, this.opts.adaptDropdownCssClass);
699
699
 
700
+ this.dropdown.addClass(evaluate(opts.dropdownCssClass));
701
+ this.dropdown.data("select2", this);
702
+ this.dropdown.on("click", killEvent);
703
+
700
704
  this.results = results = this.container.find(resultsSelector);
701
705
  this.search = search = this.container.find("input.select2-input");
702
706
 
@@ -707,6 +711,8 @@ the specific language governing permissions and limitations under the Apache Lic
707
711
  // initialize the container
708
712
  this.initContainer();
709
713
 
714
+ this.container.on("click", killEvent);
715
+
710
716
  installFilteredMouseMove(this.results);
711
717
  this.dropdown.on("mousemove-filtered touchstart touchmove touchend", resultsSelector, this.bind(this.highlightUnderEvent));
712
718
 
@@ -968,10 +974,11 @@ the specific language governing permissions and limitations under the Apache Lic
968
974
  opts.initSelection = function (element, callback) {
969
975
  var data = [];
970
976
  $(splitVal(element.val(), opts.separator)).each(function () {
971
- var id = this, text = this, tags=opts.tags;
977
+ var obj = { id: this, text: this },
978
+ tags = opts.tags;
972
979
  if ($.isFunction(tags)) tags=tags();
973
- $(tags).each(function() { if (equal(this.id, id)) { text = this.text; return false; } });
974
- data.push({id: id, text: text});
980
+ $(tags).each(function() { if (equal(this.id, obj.id)) { obj = this; return false; } });
981
+ data.push(obj);
975
982
  });
976
983
 
977
984
  callback(data);
@@ -1320,7 +1327,7 @@ the specific language governing permissions and limitations under the Apache Lic
1320
1327
  $("#select2-drop-mask").hide();
1321
1328
  this.dropdown.removeAttr("id"); // only the active dropdown has the select2-drop id
1322
1329
  this.dropdown.hide();
1323
- this.container.removeClass("select2-dropdown-open");
1330
+ this.container.removeClass("select2-dropdown-open").removeClass("select2-container-active");
1324
1331
  this.results.empty();
1325
1332
 
1326
1333
 
@@ -1395,7 +1402,7 @@ the specific language governing permissions and limitations under the Apache Lic
1395
1402
 
1396
1403
  // abstract
1397
1404
  findHighlightableChoices: function() {
1398
- return this.results.find(".select2-result-selectable:not(.select2-selected):not(.select2-disabled)");
1405
+ return this.results.find(".select2-result-selectable:not(.select2-disabled)");
1399
1406
  },
1400
1407
 
1401
1408
  // abstract
@@ -1926,10 +1933,7 @@ the specific language governing permissions and limitations under the Apache Lic
1926
1933
  killEvent(e);
1927
1934
  return;
1928
1935
  case KEY.TAB:
1929
- // if selectOnBlur == true, select the currently highlighted option
1930
- if (this.opts.selectOnBlur) {
1931
- this.selectHighlighted({noFocus: true});
1932
- }
1936
+ this.selectHighlighted({noFocus: true});
1933
1937
  return;
1934
1938
  case KEY.ESC:
1935
1939
  this.cancel(e);
@@ -2046,6 +2050,11 @@ the specific language governing permissions and limitations under the Apache Lic
2046
2050
  clear: function(triggerChange) {
2047
2051
  var data=this.selection.data("select2-data");
2048
2052
  if (data) { // guard against queued quick consecutive clicks
2053
+ var evt = $.Event("select2-clearing");
2054
+ this.opts.element.trigger(evt);
2055
+ if (evt.isDefaultPrevented()) {
2056
+ return;
2057
+ }
2049
2058
  var placeholderOption = this.getPlaceholderOption();
2050
2059
  this.opts.element.val(placeholderOption ? placeholderOption.val() : "");
2051
2060
  this.selection.find(".select2-chosen").empty();
@@ -2083,7 +2092,7 @@ the specific language governing permissions and limitations under the Apache Lic
2083
2092
 
2084
2093
  isPlaceholderOptionSelected: function() {
2085
2094
  var placeholderOption;
2086
- if (!this.opts.placeholder) return false; // no placeholder specified so no option should be considered
2095
+ if (!this.getPlaceholder()) return false; // no placeholder specified so no option should be considered
2087
2096
  return ((placeholderOption = this.getPlaceholderOption()) !== undefined && placeholderOption.is(':selected'))
2088
2097
  || (this.opts.element.val() === "")
2089
2098
  || (this.opts.element.val() === undefined)
@@ -2216,7 +2225,7 @@ the specific language governing permissions and limitations under the Apache Lic
2216
2225
  this.close();
2217
2226
 
2218
2227
  if (!options || !options.noFocus)
2219
- this.selection.focus();
2228
+ this.focusser.focus();
2220
2229
 
2221
2230
  if (!equal(old, this.id(data))) { this.triggerChange({added:data,removed:oldData}); }
2222
2231
  },
@@ -2442,7 +2451,7 @@ the specific language governing permissions and limitations under the Apache Lic
2442
2451
  this.selection = selection = this.container.find(selector);
2443
2452
 
2444
2453
  var _this = this;
2445
- this.selection.on("click", ".select2-search-choice", function (e) {
2454
+ this.selection.on("click", ".select2-search-choice:not(.select2-locked)", function (e) {
2446
2455
  //killEvent(e);
2447
2456
  _this.search[0].focus();
2448
2457
  _this.selectChoice($(this));
@@ -2521,10 +2530,7 @@ the specific language governing permissions and limitations under the Apache Lic
2521
2530
  killEvent(e);
2522
2531
  return;
2523
2532
  case KEY.TAB:
2524
- // if selectOnBlur == true, select the currently highlighted option
2525
- if (this.opts.selectOnBlur) {
2526
- this.selectHighlighted({noFocus:true});
2527
- }
2533
+ this.selectHighlighted({noFocus:true});
2528
2534
  this.close();
2529
2535
  return;
2530
2536
  case KEY.ESC:
@@ -2842,9 +2848,7 @@ the specific language governing permissions and limitations under the Apache Lic
2842
2848
  return;
2843
2849
  }
2844
2850
 
2845
- index = indexOf(this.id(data), val);
2846
-
2847
- if (index >= 0) {
2851
+ while((index = indexOf(this.id(data), val)) >= 0) {
2848
2852
  val.splice(index, 1);
2849
2853
  this.setVal(val);
2850
2854
  if (this.select) this.postprocessResults();
@@ -2925,7 +2929,7 @@ the specific language governing permissions and limitations under the Apache Lic
2925
2929
  searchWidth = minimumWidth;
2926
2930
  }
2927
2931
 
2928
- this.search.width(searchWidth);
2932
+ this.search.width(Math.floor(searchWidth));
2929
2933
  },
2930
2934
 
2931
2935
  // multi
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Select2 Malay translation.
3
+ *
4
+ * Author: Kepoweran <kepoweran@gmail.com>
5
+ */
6
+ (function ($) {
7
+ "use strict";
8
+
9
+ $.extend($.fn.select2.defaults, {
10
+ formatNoMatches: function () { return "Tiada padanan yang ditemui"; },
11
+ formatInputTooShort: function (input, min) { var n = min - input.length; return "Sila masukkan " + n + " aksara lagi"; },
12
+ formatInputTooLong: function (input, max) { var n = input.length - max; return "Sila hapuskan " + n + " aksara"; },
13
+ formatSelectionTooBig: function (limit) { return "Anda hanya boleh memilih " + limit + " pilihan"; },
14
+ formatLoadMore: function (pageNumber) { return "Sedang memuatkan keputusan..."; },
15
+ formatSearching: function () { return "Mencari..."; }
16
+ });
17
+ })(jQuery);
@@ -10,6 +10,6 @@
10
10
  formatInputTooLong: function (input, max) { var n = input.length - max; return "Vul " + n + " karakter" + (n == 1? "" : "s") + " minder in"; },
11
11
  formatSelectionTooBig: function (limit) { return "Maximaal " + limit + " item" + (limit == 1 ? "" : "s") + " toegestaan"; },
12
12
  formatLoadMore: function (pageNumber) { return "Meer resultaten laden..."; },
13
- formatSearching: function () { return "Zoeken..."; },
13
+ formatSearching: function () { return "Zoeken..."; }
14
14
  });
15
15
  })(jQuery);
@@ -1,5 +1,5 @@
1
1
  /*
2
- Version: 3.4.2 Timestamp: Mon Aug 12 15:04:12 PDT 2013
2
+ Version: 3.4.3 Timestamp: Tue Sep 17 06:47:14 PDT 2013
3
3
  */
4
4
  .select2-container {
5
5
  margin: 0;
@@ -45,7 +45,6 @@ Version: 3.4.2 Timestamp: Mon Aug 12 15:04:12 PDT 2013
45
45
 
46
46
  -webkit-touch-callout: none;
47
47
  -webkit-user-select: none;
48
- -khtml-user-select: none;
49
48
  -moz-user-select: none;
50
49
  -ms-user-select: none;
51
50
  user-select: none;
@@ -54,8 +53,6 @@ Version: 3.4.2 Timestamp: Mon Aug 12 15:04:12 PDT 2013
54
53
  background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.5, #fff));
55
54
  background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 50%);
56
55
  background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 50%);
57
- background-image: -o-linear-gradient(bottom, #eee 0%, #fff 50%);
58
- background-image: -ms-linear-gradient(top, #fff 0%, #eee 50%);
59
56
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#ffffff', endColorstr = '#eeeeee', GradientType = 0);
60
57
  background-image: linear-gradient(top, #fff 0%, #eee 50%);
61
58
  }
@@ -68,8 +65,6 @@ Version: 3.4.2 Timestamp: Mon Aug 12 15:04:12 PDT 2013
68
65
  background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.9, #fff));
69
66
  background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 90%);
70
67
  background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 90%);
71
- background-image: -o-linear-gradient(bottom, #eee 0%, #fff 90%);
72
- background-image: -ms-linear-gradient(top, #eee 0%, #fff 90%);
73
68
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0);
74
69
  background-image: linear-gradient(top, #eee 0%, #fff 90%);
75
70
  }
@@ -129,7 +124,6 @@ Version: 3.4.2 Timestamp: Mon Aug 12 15:04:12 PDT 2013
129
124
  z-index: 9998;
130
125
  /* styles required for IE to work */
131
126
  background-color: #fff;
132
- opacity: 0;
133
127
  filter: alpha(opacity=0);
134
128
  }
135
129
 
@@ -197,8 +191,6 @@ Version: 3.4.2 Timestamp: Mon Aug 12 15:04:12 PDT 2013
197
191
  background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #ccc), color-stop(0.6, #eee));
198
192
  background-image: -webkit-linear-gradient(center bottom, #ccc 0%, #eee 60%);
199
193
  background-image: -moz-linear-gradient(center bottom, #ccc 0%, #eee 60%);
200
- background-image: -o-linear-gradient(bottom, #ccc 0%, #eee 60%);
201
- background-image: -ms-linear-gradient(top, #ccc 0%, #eee 60%);
202
194
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#eeeeee', endColorstr = '#cccccc', GradientType = 0);
203
195
  background-image: linear-gradient(top, #ccc 0%, #eee 60%);
204
196
  }
@@ -245,8 +237,6 @@ Version: 3.4.2 Timestamp: Mon Aug 12 15:04:12 PDT 2013
245
237
  background: image-url('select2.png') no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
246
238
  background: image-url('select2.png') no-repeat 100% -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
247
239
  background: image-url('select2.png') no-repeat 100% -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
248
- background: image-url('select2.png') no-repeat 100% -22px, -o-linear-gradient(bottom, #fff 85%, #eee 99%);
249
- background: image-url('select2.png') no-repeat 100% -22px, -ms-linear-gradient(top, #fff 85%, #eee 99%);
250
240
  background: image-url('select2.png') no-repeat 100% -22px, linear-gradient(top, #fff 85%, #eee 99%);
251
241
  }
252
242
 
@@ -259,8 +249,6 @@ Version: 3.4.2 Timestamp: Mon Aug 12 15:04:12 PDT 2013
259
249
  background: image-url('select2-spinner.gif') no-repeat 100%, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
260
250
  background: image-url('select2-spinner.gif') no-repeat 100%, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
261
251
  background: image-url('select2-spinner.gif') no-repeat 100%, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
262
- background: image-url('select2-spinner.gif') no-repeat 100%, -o-linear-gradient(bottom, #fff 85%, #eee 99%);
263
- background: image-url('select2-spinner.gif') no-repeat 100%, -ms-linear-gradient(top, #fff 85%, #eee 99%);
264
252
  background: image-url('select2-spinner.gif') no-repeat 100%, linear-gradient(top, #fff 85%, #eee 99%);
265
253
  }
266
254
 
@@ -285,8 +273,6 @@ Version: 3.4.2 Timestamp: Mon Aug 12 15:04:12 PDT 2013
285
273
  background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #fff), color-stop(0.5, #eee));
286
274
  background-image: -webkit-linear-gradient(center bottom, #fff 0%, #eee 50%);
287
275
  background-image: -moz-linear-gradient(center bottom, #fff 0%, #eee 50%);
288
- background-image: -o-linear-gradient(bottom, #fff 0%, #eee 50%);
289
- background-image: -ms-linear-gradient(top, #fff 0%, #eee 50%);
290
276
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0);
291
277
  background-image: linear-gradient(top, #fff 0%, #eee 50%);
292
278
  }
@@ -299,8 +285,6 @@ Version: 3.4.2 Timestamp: Mon Aug 12 15:04:12 PDT 2013
299
285
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #fff), color-stop(0.5, #eee));
300
286
  background-image: -webkit-linear-gradient(center top, #fff 0%, #eee 50%);
301
287
  background-image: -moz-linear-gradient(center top, #fff 0%, #eee 50%);
302
- background-image: -o-linear-gradient(top, #fff 0%, #eee 50%);
303
- background-image: -ms-linear-gradient(bottom, #fff 0%, #eee 50%);
304
288
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0);
305
289
  background-image: linear-gradient(bottom, #fff 0%, #eee 50%);
306
290
  }
@@ -357,7 +341,6 @@ Version: 3.4.2 Timestamp: Mon Aug 12 15:04:12 PDT 2013
357
341
 
358
342
  -webkit-touch-callout: none;
359
343
  -webkit-user-select: none;
360
- -khtml-user-select: none;
361
344
  -moz-user-select: none;
362
345
  -ms-user-select: none;
363
346
  user-select: none;
@@ -455,8 +438,6 @@ disabled look for disabled choices in the results dropdown
455
438
  background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eee), color-stop(15%, #fff));
456
439
  background-image: -webkit-linear-gradient(top, #eee 1%, #fff 15%);
457
440
  background-image: -moz-linear-gradient(top, #eee 1%, #fff 15%);
458
- background-image: -o-linear-gradient(top, #eee 1%, #fff 15%);
459
- background-image: -ms-linear-gradient(top, #eee 1%, #fff 15%);
460
441
  background-image: linear-gradient(top, #eee 1%, #fff 15%);
461
442
  }
462
443
 
@@ -526,7 +507,6 @@ disabled look for disabled choices in the results dropdown
526
507
 
527
508
  -webkit-touch-callout: none;
528
509
  -webkit-user-select: none;
529
- -khtml-user-select: none;
530
510
  -moz-user-select: none;
531
511
  -ms-user-select: none;
532
512
  user-select: none;
@@ -536,8 +516,6 @@ disabled look for disabled choices in the results dropdown
536
516
  background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eee));
537
517
  background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
538
518
  background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
539
- background-image: -o-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
540
- background-image: -ms-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
541
519
  background-image: linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
542
520
  }
543
521
  .select2-container-multi .select2-choices .select2-search-choice .select2-chosen {
data/lib/select2-rails.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "select2-rails/version"
2
+ require 'sass-rails'
2
3
 
3
4
  module Select2
4
5
  module Rails
@@ -42,13 +42,13 @@ class SourceFile < Thor
42
42
  def fetch_tags
43
43
  http = HTTPClient.new
44
44
  response = JSON.parse(http.get("https://api.github.com/repos/ivaynberg/select2/tags").body)
45
- response.map{|tag| tag["name"]}.sort
45
+ response.map{|tag| tag["name"]}.sort
46
46
  end
47
47
  def languages
48
- [ "ar", "bg", "ca", "cs", "da", "de", "el", "es", "et", "eu", "fa", "fi", "fr", "gl", "he", "hr",
49
- "hu", "id", "is", "it", "ja", "ko", "lt", "lv", "mk", "nl", "no", "pl", "pt-BR",
48
+ [ "ar", "bg", "ca", "cs", "da", "de", "el", "es", "et", "eu", "fa", "fi", "fr", "gl", "he", "hr",
49
+ "hu", "id", "is", "it", "ja", "ko", "lt", "lv", "mk", "ms", "nl", "no", "pl", "pt-BR",
50
50
  "pt-PT", "ro", "ru", "sk", "sv", "th", "tr", "ua", "vi", "zh-CN", "zh-TW"
51
- ].sort
51
+ ].sort
52
52
  end
53
53
  def select msg, elements
54
54
  elements.each_with_index do |element, index|
@@ -1,5 +1,5 @@
1
1
  module Select2
2
2
  module Rails
3
- VERSION = "3.4.8"
3
+ VERSION = "3.4.9"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: select2-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.8
4
+ version: 3.4.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-08-12 00:00:00.000000000 Z
13
+ date: 2013-09-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thor
@@ -135,6 +135,7 @@ files:
135
135
  - app/assets/javascripts/select2_locale_lt.js
136
136
  - app/assets/javascripts/select2_locale_lv.js
137
137
  - app/assets/javascripts/select2_locale_mk.js
138
+ - app/assets/javascripts/select2_locale_ms.js
138
139
  - app/assets/javascripts/select2_locale_nl.js
139
140
  - app/assets/javascripts/select2_locale_no.js
140
141
  - app/assets/javascripts/select2_locale_pl.js
@@ -182,3 +183,4 @@ signing_key:
182
183
  specification_version: 3
183
184
  summary: Integrate Select2 javascript library with Rails asset pipeline
184
185
  test_files: []
186
+ has_rdoc: