selectize-rails 0.7.5 → 0.7.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -41,6 +41,7 @@ See the [demo page of Brian Reavis](http://brianreavis.github.io/selectize.js/)
41
41
 
42
42
  | Version | Notes |
43
43
  | -------:| ----------------------------------------------------------- |
44
+ | 0.7.6 | Update to v0.7.6 of selectize.js |
44
45
  | 0.7.5 | Update to v0.7.5 of selectize.js |
45
46
  | 0.7.4 | Update to v0.7.4 of selectize.js |
46
47
  | 0.7.3 | Update to v0.7.3 of selectize.js |
@@ -1,5 +1,5 @@
1
1
  module Selectize
2
2
  module Rails
3
- VERSION = "0.7.5"
3
+ VERSION = "0.7.6"
4
4
  end
5
5
  end
@@ -258,11 +258,7 @@
258
258
  var field = options.sort;
259
259
  var multiplier = options.direction === 'desc' ? -1 : 1;
260
260
  return function(a, b) {
261
- a = a && String(self.items[a.id][field] || '').toLowerCase();
262
- b = b && String(self.items[b.id][field] || '').toLowerCase();
263
- if (a > b) return 1 * multiplier;
264
- if (b > a) return -1 * multiplier;
265
- return 0;
261
+ return cmp(self.items[a.id][field], self.items[b.id][field]) * multiplier;
266
262
  };
267
263
  })());
268
264
  }
@@ -280,6 +276,17 @@
280
276
  // utilities
281
277
  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
282
278
 
279
+ var cmp = function(a, b) {
280
+ if (typeof a === 'number' && typeof b === 'number') {
281
+ return a > b ? 1 : (a < b ? -1 : 0);
282
+ }
283
+ a = String(a || '').toLowerCase();
284
+ b = String(b || '').toLowerCase();
285
+ if (a > b) return 1;
286
+ if (b > a) return -1;
287
+ return 0;
288
+ };
289
+
283
290
  var extend = function(a, b) {
284
291
  var i, n, k, object;
285
292
  for (i = 1, n = arguments.length; i < n; i++) {
@@ -454,7 +461,7 @@
454
461
  };
455
462
 
456
463
  var utils = {
457
- isArray: Array.isArray || function() {
464
+ isArray: Array.isArray || function(vArg) {
458
465
  return Object.prototype.toString.call(vArg) === '[object Array]';
459
466
  }
460
467
  };
@@ -463,7 +470,7 @@
463
470
  }));
464
471
 
465
472
  /**
466
- * selectize.js (v0.7.5)
473
+ * selectize.js (v0.7.6)
467
474
  * Copyright (c) 2013 Brian Reavis & contributors
468
475
  *
469
476
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
@@ -2627,7 +2634,7 @@
2627
2634
 
2628
2635
  dataAttr: 'data-data',
2629
2636
  optgroupField: 'optgroup',
2630
- sortField: null,
2637
+ sortField: '$order',
2631
2638
  sortDirection: 'asc',
2632
2639
  valueField: 'value',
2633
2640
  labelField: 'text',
@@ -2708,6 +2715,7 @@
2708
2715
  var init_select = function($input, settings_element) {
2709
2716
  var i, n, tagName;
2710
2717
  var $children;
2718
+ var order = 0;
2711
2719
  settings_element.maxItems = !!$input.attr('multiple') ? null : 1;
2712
2720
 
2713
2721
  var readData = function($el) {
@@ -2719,16 +2727,22 @@
2719
2727
  };
2720
2728
 
2721
2729
  var addOption = function($option, group) {
2730
+ var value, option;
2731
+
2722
2732
  $option = $($option);
2723
2733
 
2724
- var value = $option.attr('value') || '';
2734
+ value = $option.attr('value') || '';
2725
2735
  if (!value.length) return;
2726
2736
 
2727
- settings_element.options[value] = readData($option) || {
2737
+ option = readData($option) || {
2728
2738
  'text' : $option.text(),
2729
2739
  'value' : value,
2730
2740
  'optgroup' : group
2731
2741
  };
2742
+
2743
+ option.$order = ++order;
2744
+ settings_element.options[value] = option;
2745
+
2732
2746
  if ($option.is(':selected')) {
2733
2747
  settings_element.items.push(value);
2734
2748
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * selectize.bootstrap2.css (v0.7.5) - Bootstrap 2 Theme
2
+ * selectize.bootstrap2.css (v0.7.6) - Bootstrap 2 Theme
3
3
  * Copyright (c) 2013 Brian Reavis & contributors
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
@@ -1,5 +1,5 @@
1
1
  /**
2
- * selectize.bootstrap3.css (v0.7.5) - Bootstrap 3 Theme
2
+ * selectize.bootstrap3.css (v0.7.6) - Bootstrap 3 Theme
3
3
  * Copyright (c) 2013 Brian Reavis & contributors
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
@@ -1,5 +1,5 @@
1
1
  /**
2
- * selectize.css (v0.7.5)
2
+ * selectize.css (v0.7.6)
3
3
  * Copyright (c) 2013 Brian Reavis & contributors
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
@@ -1,5 +1,5 @@
1
1
  /**
2
- * selectize.default.css (v0.7.5) - Default Theme
2
+ * selectize.default.css (v0.7.6) - Default Theme
3
3
  * Copyright (c) 2013 Brian Reavis & contributors
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
@@ -1,5 +1,5 @@
1
1
  /**
2
- * selectize.legacy.css (v0.7.5) - Default Theme
2
+ * selectize.legacy.css (v0.7.6) - Default Theme
3
3
  * Copyright (c) 2013 Brian Reavis & contributors
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selectize-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
4
+ version: 0.7.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-09 00:00:00.000000000 Z
12
+ date: 2013-09-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler