selectivity-rails 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -1
- data/lib/selectivity/rails/version.rb +1 -1
- data/vendor/assets/javascripts/selectivity.js +178 -177
- data/vendor/assets/stylesheets/selectivity/backdrop.sass +1 -1
- data/vendor/assets/stylesheets/selectivity/dropdown.sass +1 -1
- data/vendor/assets/stylesheets/selectivity/variables.sass +3 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d6fd940dbd97aefb1ab70204f5839d382dd52cd
|
4
|
+
data.tar.gz: 2d3e622f5e83a098c8b2277b15f121044a8beb9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90b7c165924ce6187bfa6373fbdcc15ed32ac01824fca61ccf64588b83de5d80c2a4f631cf035e66e70d68aee80569f0d8c1718779d9148973be2824fb8f5aad
|
7
|
+
data.tar.gz: 429d603a78f6d69de34f0c6e05cfafae9aca5ee93926b221450d0f4bc8c0a0fce05d2933a06328dcf64283ec0039b701232ddffc1c2a98615a42f4a7840acadc
|
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
[![Gem Version](https://badge.fury.io/rb/selectivity-rails.svg)](http://badge.fury.io/rb/selectivity-rails)
|
2
2
|
[![Code Climate](https://codeclimate.com/github/msx2/selectivity-rails/badges/gpa.svg)](https://codeclimate.com/github/msx2/selectivity-rails)
|
3
3
|
[![Join the chat at https://gitter.im/msx2/selectivity-rails](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/msx2/selectivity-rails?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
4
|
-
[![EL Passion](https://img.shields.io/badge/Supported%20by-EL%20Passion-36b452.svg)](https://github.com/elpassion)
|
5
4
|
|
6
5
|
# Selectivity.js for Rails' Asset Pipeline
|
7
6
|
|
@@ -531,11 +531,6 @@ function Selectivity(options) {
|
|
531
531
|
*/
|
532
532
|
this.options = {};
|
533
533
|
|
534
|
-
/**
|
535
|
-
* Results from a search query.
|
536
|
-
*/
|
537
|
-
this.results = [];
|
538
|
-
|
539
534
|
/**
|
540
535
|
* Array of search input listeners.
|
541
536
|
*
|
@@ -563,8 +558,6 @@ function Selectivity(options) {
|
|
563
558
|
this.data(options.data || null, { triggerChange: false });
|
564
559
|
}
|
565
560
|
|
566
|
-
this._$searchInputs = [];
|
567
|
-
|
568
561
|
this.$el.on('selectivity-close', this._closed.bind(this));
|
569
562
|
|
570
563
|
EventDelegator.call(this);
|
@@ -661,6 +654,8 @@ $.extend(Selectivity.prototype, EventDelegator.prototype, {
|
|
661
654
|
|
662
655
|
if (this.$searchInput) {
|
663
656
|
this.$searchInput.focus();
|
657
|
+
} else if (this.dropdown) {
|
658
|
+
this.dropdown.focus();
|
664
659
|
}
|
665
660
|
},
|
666
661
|
|
@@ -690,59 +685,29 @@ $.extend(Selectivity.prototype, EventDelegator.prototype, {
|
|
690
685
|
* action of searching when something is typed.
|
691
686
|
*
|
692
687
|
* @param $input jQuery container for the input element.
|
693
|
-
* @param options Optional options object. May contain the following property:
|
694
|
-
* noSearch - If false, no event handlers are setup to initiate searching when
|
695
|
-
* the user types in the input field. This is useful if you want to
|
696
|
-
* use the input only to handle keyboard support.
|
697
688
|
*/
|
698
|
-
initSearchInput: function($input
|
689
|
+
initSearchInput: function($input) {
|
699
690
|
|
700
|
-
this._$searchInputs.push($input);
|
701
691
|
this.$searchInput = $input;
|
702
692
|
|
703
693
|
this.searchInputListeners.forEach(function(listener) {
|
704
694
|
listener(this, $input);
|
705
695
|
}.bind(this));
|
706
696
|
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
}.bind(this));
|
713
|
-
}
|
714
|
-
},
|
715
|
-
|
716
|
-
/**
|
717
|
-
* Loads a follow-up page with results after a search.
|
718
|
-
*
|
719
|
-
* This method should only be called after a call to search() when the callback has indicated
|
720
|
-
* more results are available.
|
721
|
-
*/
|
722
|
-
loadMore: function() {
|
723
|
-
|
724
|
-
this.options.query({
|
725
|
-
callback: function(response) {
|
726
|
-
if (response && response.results) {
|
727
|
-
this._addResults(
|
728
|
-
Selectivity.processItems(response.results),
|
729
|
-
{ hasMore: !!response.more }
|
730
|
-
);
|
731
|
-
} else {
|
732
|
-
throw new Error('callback must be passed a response object');
|
733
|
-
}
|
734
|
-
}.bind(this),
|
735
|
-
error: this._addResults.bind(this, []),
|
736
|
-
offset: this.results.length,
|
737
|
-
selectivity: this,
|
738
|
-
term: this.term
|
739
|
-
});
|
697
|
+
$input.on('keyup', function(event) {
|
698
|
+
if (!event.isDefaultPrevented()) {
|
699
|
+
this.search();
|
700
|
+
}
|
701
|
+
}.bind(this));
|
740
702
|
},
|
741
703
|
|
742
704
|
/**
|
743
705
|
* Opens the dropdown.
|
744
706
|
*
|
745
707
|
* @param options Optional options object. May contain the following property:
|
708
|
+
* search - Boolean whether the dropdown should be initialized by performing a
|
709
|
+
* search for the empty string (ie. display all results). Default is
|
710
|
+
* true.
|
746
711
|
* showSearchInput - Boolean whether a search input should be shown in the
|
747
712
|
* dropdown. Default is false.
|
748
713
|
*/
|
@@ -755,13 +720,17 @@ $.extend(Selectivity.prototype, EventDelegator.prototype, {
|
|
755
720
|
var Dropdown = this.options.dropdown || Selectivity.Dropdown;
|
756
721
|
if (Dropdown) {
|
757
722
|
this.dropdown = new Dropdown({
|
723
|
+
items: this.items,
|
758
724
|
position: this.options.positionDropdown,
|
725
|
+
query: this.options.query,
|
759
726
|
selectivity: this,
|
760
727
|
showSearchInput: options.showSearchInput
|
761
728
|
});
|
762
729
|
}
|
763
730
|
|
764
|
-
|
731
|
+
if (options.search !== false) {
|
732
|
+
this.search('');
|
733
|
+
}
|
765
734
|
}
|
766
735
|
}
|
767
736
|
},
|
@@ -777,17 +746,7 @@ $.extend(Selectivity.prototype, EventDelegator.prototype, {
|
|
777
746
|
},
|
778
747
|
|
779
748
|
/**
|
780
|
-
*
|
781
|
-
*/
|
782
|
-
removeSearchInput: function() {
|
783
|
-
|
784
|
-
this._$searchInputs.pop();
|
785
|
-
|
786
|
-
this.$searchInput = this._$searchInputs[this._$searchInputs.length - 1] || null;
|
787
|
-
},
|
788
|
-
|
789
|
-
/**
|
790
|
-
* Searches for results based on the term entered in the search input.
|
749
|
+
* Searches for results based on the term given or the term entered in the search input.
|
791
750
|
*
|
792
751
|
* If an items array has been passed with the options to the Selectivity instance, a local
|
793
752
|
* search will be performed among those items. Otherwise, the query function specified in the
|
@@ -798,47 +757,15 @@ $.extend(Selectivity.prototype, EventDelegator.prototype, {
|
|
798
757
|
*/
|
799
758
|
search: function(term) {
|
800
759
|
|
801
|
-
var self = this;
|
802
|
-
function setResults(results, resultOptions) {
|
803
|
-
self._setResults(results, $.extend({ term: term }, resultOptions));
|
804
|
-
}
|
805
|
-
|
806
760
|
if (term === undefined) {
|
807
|
-
|
808
|
-
return;
|
809
|
-
}
|
810
|
-
|
811
|
-
term = self.$searchInput.val();
|
761
|
+
term = (this.$searchInput ? this.$searchInput.val() : '');
|
812
762
|
}
|
813
763
|
|
814
|
-
|
815
|
-
term = Selectivity.transformText(term);
|
816
|
-
var matcher = self.matcher;
|
817
|
-
setResults(self.items.map(function(item) {
|
818
|
-
return matcher(item, term);
|
819
|
-
}).filter(function(item) {
|
820
|
-
return !!item;
|
821
|
-
}));
|
822
|
-
} else if (self.options.query) {
|
823
|
-
self.options.query({
|
824
|
-
callback: function(response) {
|
825
|
-
if (response && response.results) {
|
826
|
-
setResults(
|
827
|
-
Selectivity.processItems(response.results),
|
828
|
-
{ hasMore: !!response.more }
|
829
|
-
);
|
830
|
-
} else {
|
831
|
-
throw new Error('callback must be passed a response object');
|
832
|
-
}
|
833
|
-
},
|
834
|
-
error: self._showError.bind(self),
|
835
|
-
offset: 0,
|
836
|
-
selectivity: self,
|
837
|
-
term: term
|
838
|
-
});
|
839
|
-
}
|
764
|
+
this.open({ search: false });
|
840
765
|
|
841
|
-
|
766
|
+
if (this.dropdown) {
|
767
|
+
this.dropdown.search(term);
|
768
|
+
}
|
842
769
|
},
|
843
770
|
|
844
771
|
/**
|
@@ -1086,21 +1013,6 @@ $.extend(Selectivity.prototype, EventDelegator.prototype, {
|
|
1086
1013
|
}
|
1087
1014
|
},
|
1088
1015
|
|
1089
|
-
/**
|
1090
|
-
* @private
|
1091
|
-
*/
|
1092
|
-
_addResults: function(results, options) {
|
1093
|
-
|
1094
|
-
this.results = this.results.concat(results);
|
1095
|
-
|
1096
|
-
if (this.dropdown) {
|
1097
|
-
this.dropdown.showResults(
|
1098
|
-
this.filterResults(results),
|
1099
|
-
$.extend({ add: true }, options)
|
1100
|
-
);
|
1101
|
-
}
|
1102
|
-
},
|
1103
|
-
|
1104
1016
|
/**
|
1105
1017
|
* @private
|
1106
1018
|
*/
|
@@ -1136,37 +1048,20 @@ $.extend(Selectivity.prototype, EventDelegator.prototype, {
|
|
1136
1048
|
if ($.type(id) === 'string') {
|
1137
1049
|
return id;
|
1138
1050
|
} else {
|
1139
|
-
if (Selectivity.findById(this._data || [], id)
|
1140
|
-
Selectivity.findNestedById(this.results, id)) {
|
1051
|
+
if (Selectivity.findById(this._data || [], id)) {
|
1141
1052
|
return id;
|
1142
1053
|
} else {
|
1054
|
+
var dropdown = this.dropdown;
|
1055
|
+
while (dropdown) {
|
1056
|
+
if (Selectivity.findNestedById(dropdown.results, id)) {
|
1057
|
+
return id;
|
1058
|
+
}
|
1059
|
+
// FIXME: reference to submenu doesn't belong in base module
|
1060
|
+
dropdown = dropdown.submenu;
|
1061
|
+
}
|
1143
1062
|
return '' + id;
|
1144
1063
|
}
|
1145
1064
|
}
|
1146
|
-
},
|
1147
|
-
|
1148
|
-
/**
|
1149
|
-
* @private
|
1150
|
-
*/
|
1151
|
-
_setResults: function(results, options) {
|
1152
|
-
|
1153
|
-
this.results = results;
|
1154
|
-
|
1155
|
-
if (this.dropdown) {
|
1156
|
-
this.dropdown.showResults(this.filterResults(results), options || {});
|
1157
|
-
}
|
1158
|
-
},
|
1159
|
-
|
1160
|
-
/**
|
1161
|
-
* @private
|
1162
|
-
*/
|
1163
|
-
_showError: function(error, options) {
|
1164
|
-
|
1165
|
-
this.results = [];
|
1166
|
-
|
1167
|
-
if (this.dropdown) {
|
1168
|
-
this.dropdown.showError(error, options);
|
1169
|
-
}
|
1170
1065
|
}
|
1171
1066
|
|
1172
1067
|
});
|
@@ -2312,6 +2207,13 @@ function SelectivityDropdown(options) {
|
|
2312
2207
|
*/
|
2313
2208
|
this.$results = this.$('.selectivity-results-container');
|
2314
2209
|
|
2210
|
+
/**
|
2211
|
+
* jQuery container for the search input.
|
2212
|
+
*
|
2213
|
+
* May be null as long as there is no visible search input. It is set by initSearchInput().
|
2214
|
+
*/
|
2215
|
+
this.$searchInput = null;
|
2216
|
+
|
2315
2217
|
/**
|
2316
2218
|
* Boolean indicating whether more results are available than currently displayed in the
|
2317
2219
|
* dropdown.
|
@@ -2406,10 +2308,6 @@ $.extend(SelectivityDropdown.prototype, EventDelegator.prototype, {
|
|
2406
2308
|
if (!this._closed) {
|
2407
2309
|
this._closed = true;
|
2408
2310
|
|
2409
|
-
if (this.options.showSearchInput) {
|
2410
|
-
this.selectivity.removeSearchInput();
|
2411
|
-
}
|
2412
|
-
|
2413
2311
|
this.$el.remove();
|
2414
2312
|
|
2415
2313
|
this.removeCloseHandler();
|
@@ -2432,6 +2330,16 @@ $.extend(SelectivityDropdown.prototype, EventDelegator.prototype, {
|
|
2432
2330
|
'mouseenter .selectivity-result-item': '_resultHovered'
|
2433
2331
|
},
|
2434
2332
|
|
2333
|
+
/**
|
2334
|
+
* Applies focus to the input.
|
2335
|
+
*/
|
2336
|
+
focus: function() {
|
2337
|
+
|
2338
|
+
if (this.$searchInput) {
|
2339
|
+
this.$searchInput.focus();
|
2340
|
+
}
|
2341
|
+
},
|
2342
|
+
|
2435
2343
|
/**
|
2436
2344
|
* Highlights a result item.
|
2437
2345
|
*
|
@@ -2468,6 +2376,57 @@ $.extend(SelectivityDropdown.prototype, EventDelegator.prototype, {
|
|
2468
2376
|
this.loadMoreHighlighted = true;
|
2469
2377
|
},
|
2470
2378
|
|
2379
|
+
/**
|
2380
|
+
* Initializes the search input element.
|
2381
|
+
*
|
2382
|
+
* Sets the $searchInput property, invokes all search input listeners and attaches the default
|
2383
|
+
* action of searching when something is typed.
|
2384
|
+
*
|
2385
|
+
* @param $input jQuery container for the input element.
|
2386
|
+
*/
|
2387
|
+
initSearchInput: function($input) {
|
2388
|
+
|
2389
|
+
this.$searchInput = $input;
|
2390
|
+
|
2391
|
+
this.selectivity.searchInputListeners.forEach(function(listener) {
|
2392
|
+
listener(this, $input);
|
2393
|
+
}.bind(this));
|
2394
|
+
|
2395
|
+
$input.on('keyup', function(event) {
|
2396
|
+
if (!event.isDefaultPrevented()) {
|
2397
|
+
this.search();
|
2398
|
+
}
|
2399
|
+
}.bind(this));
|
2400
|
+
},
|
2401
|
+
|
2402
|
+
/**
|
2403
|
+
* Loads a follow-up page with results after a search.
|
2404
|
+
*
|
2405
|
+
* This method should only be called after a call to search() when the callback has indicated
|
2406
|
+
* more results are available.
|
2407
|
+
*/
|
2408
|
+
loadMore: function() {
|
2409
|
+
|
2410
|
+
this.options.query({
|
2411
|
+
callback: function(response) {
|
2412
|
+
if (response && response.results) {
|
2413
|
+
this._showResults(
|
2414
|
+
Selectivity.processItems(response.results),
|
2415
|
+
{ add: true, hasMore: !!response.more }
|
2416
|
+
);
|
2417
|
+
} else {
|
2418
|
+
throw new Error('callback must be passed a response object');
|
2419
|
+
}
|
2420
|
+
}.bind(this),
|
2421
|
+
error: function() {
|
2422
|
+
this._showResults([], { add: true });
|
2423
|
+
}.bind(this),
|
2424
|
+
offset: this.results.length,
|
2425
|
+
selectivity: this.selectivity,
|
2426
|
+
term: this.term
|
2427
|
+
});
|
2428
|
+
},
|
2429
|
+
|
2471
2430
|
/**
|
2472
2431
|
* Positions the dropdown inside the DOM.
|
2473
2432
|
*/
|
@@ -2510,6 +2469,57 @@ $.extend(SelectivityDropdown.prototype, EventDelegator.prototype, {
|
|
2510
2469
|
}, this).join('');
|
2511
2470
|
},
|
2512
2471
|
|
2472
|
+
/**
|
2473
|
+
* Searches for results based on the term given or the term entered in the search input.
|
2474
|
+
*
|
2475
|
+
* If an items array has been passed with the options to the Selectivity instance, a local
|
2476
|
+
* search will be performed among those items. Otherwise, the query function specified in the
|
2477
|
+
* options will be used to perform the search. If neither is defined, nothing happens.
|
2478
|
+
*
|
2479
|
+
* @param term Optional term to search for. If ommitted, the value of the search input element
|
2480
|
+
* is used as term.
|
2481
|
+
*/
|
2482
|
+
search: function(term) {
|
2483
|
+
|
2484
|
+
var self = this;
|
2485
|
+
function setResults(results, resultOptions) {
|
2486
|
+
self._showResults(results, $.extend({ term: term }, resultOptions));
|
2487
|
+
}
|
2488
|
+
|
2489
|
+
if (term === undefined) {
|
2490
|
+
term = (self.$searchInput ? self.$searchInput.val() : '');
|
2491
|
+
}
|
2492
|
+
|
2493
|
+
if (self.options.items) {
|
2494
|
+
term = Selectivity.transformText(term);
|
2495
|
+
var matcher = self.selectivity.matcher;
|
2496
|
+
setResults(self.options.items.map(function(item) {
|
2497
|
+
return matcher(item, term);
|
2498
|
+
}).filter(function(item) {
|
2499
|
+
return !!item;
|
2500
|
+
}));
|
2501
|
+
} else if (self.options.query) {
|
2502
|
+
self.options.query({
|
2503
|
+
callback: function(response) {
|
2504
|
+
if (response && response.results) {
|
2505
|
+
setResults(
|
2506
|
+
Selectivity.processItems(response.results),
|
2507
|
+
{ hasMore: !!response.more }
|
2508
|
+
);
|
2509
|
+
} else {
|
2510
|
+
throw new Error('callback must be passed a response object');
|
2511
|
+
}
|
2512
|
+
},
|
2513
|
+
error: self.showError.bind(self),
|
2514
|
+
offset: 0,
|
2515
|
+
selectivity: self.selectivity,
|
2516
|
+
term: term
|
2517
|
+
});
|
2518
|
+
}
|
2519
|
+
|
2520
|
+
self.term = term;
|
2521
|
+
},
|
2522
|
+
|
2513
2523
|
/**
|
2514
2524
|
* Selects the highlighted item.
|
2515
2525
|
*/
|
@@ -2529,12 +2539,11 @@ $.extend(SelectivityDropdown.prototype, EventDelegator.prototype, {
|
|
2529
2539
|
*/
|
2530
2540
|
selectItem: function(id) {
|
2531
2541
|
|
2532
|
-
var
|
2533
|
-
var item = Selectivity.findNestedById(selectivity.results, id);
|
2542
|
+
var item = Selectivity.findNestedById(this.results, id);
|
2534
2543
|
if (item) {
|
2535
2544
|
var options = { id: id, item: item };
|
2536
|
-
if (selectivity.triggerEvent('selectivity-selecting', options)) {
|
2537
|
-
selectivity.triggerEvent('selectivity-selected', options);
|
2545
|
+
if (this.selectivity.triggerEvent('selectivity-selecting', options)) {
|
2546
|
+
this.selectivity.triggerEvent('selectivity-selected', options);
|
2538
2547
|
}
|
2539
2548
|
}
|
2540
2549
|
},
|
@@ -2682,7 +2691,7 @@ $.extend(SelectivityDropdown.prototype, EventDelegator.prototype, {
|
|
2682
2691
|
|
2683
2692
|
this.$('.selectivity-load-more').replaceWith(this.selectivity.template('loading'));
|
2684
2693
|
|
2685
|
-
this.
|
2694
|
+
this.loadMore();
|
2686
2695
|
|
2687
2696
|
this.selectivity.focus();
|
2688
2697
|
|
@@ -2750,6 +2759,14 @@ $.extend(SelectivityDropdown.prototype, EventDelegator.prototype, {
|
|
2750
2759
|
}
|
2751
2760
|
},
|
2752
2761
|
|
2762
|
+
/**
|
2763
|
+
* @private
|
2764
|
+
*/
|
2765
|
+
_showResults: function(results, options) {
|
2766
|
+
|
2767
|
+
this.showResults(this.selectivity.filterResults(results), options || {});
|
2768
|
+
},
|
2769
|
+
|
2753
2770
|
/**
|
2754
2771
|
* @private
|
2755
2772
|
*/
|
@@ -3302,7 +3319,7 @@ var callSuper = Selectivity.inherits(MultipleSelectivity, {
|
|
3302
3319
|
*/
|
3303
3320
|
getDataForValue: function(value) {
|
3304
3321
|
|
3305
|
-
return value.map(this.getItemForId
|
3322
|
+
return value.map(this.getItemForId, this).filter(function(item) { return !!item; });
|
3306
3323
|
},
|
3307
3324
|
|
3308
3325
|
/**
|
@@ -3436,7 +3453,7 @@ var callSuper = Selectivity.inherits(MultipleSelectivity, {
|
|
3436
3453
|
if (data === null) {
|
3437
3454
|
return [];
|
3438
3455
|
} else if ($.type(data) === 'array') {
|
3439
|
-
return data.map(this.validateItem
|
3456
|
+
return data.map(this.validateItem, this);
|
3440
3457
|
} else {
|
3441
3458
|
throw new Error('Data for MultiSelectivity instance should be array');
|
3442
3459
|
}
|
@@ -3765,7 +3782,7 @@ function SingleSelectivity(options) {
|
|
3765
3782
|
}
|
3766
3783
|
|
3767
3784
|
if (options.showSearchInputInDropdown === false) {
|
3768
|
-
this.initSearchInput(this.$('.selectivity-single-select-input')
|
3785
|
+
this.initSearchInput(this.$('.selectivity-single-select-input'));
|
3769
3786
|
}
|
3770
3787
|
}
|
3771
3788
|
|
@@ -3806,13 +3823,8 @@ var callSuper = Selectivity.inherits(SingleSelectivity, {
|
|
3806
3823
|
|
3807
3824
|
callSuper(this, 'close');
|
3808
3825
|
|
3809
|
-
var $input = this.$('.selectivity-single-select-input');
|
3810
|
-
if (!this.$searchInput) {
|
3811
|
-
this.initSearchInput($input, { noSearch: true });
|
3812
|
-
}
|
3813
|
-
|
3814
3826
|
if (!options || options.keepFocus !== false) {
|
3815
|
-
|
3827
|
+
this.$searchInput.focus();
|
3816
3828
|
}
|
3817
3829
|
|
3818
3830
|
this._closing = false;
|
@@ -3849,6 +3861,8 @@ var callSuper = Selectivity.inherits(SingleSelectivity, {
|
|
3849
3861
|
*/
|
3850
3862
|
open: function(options) {
|
3851
3863
|
|
3864
|
+
this._opening = true;
|
3865
|
+
|
3852
3866
|
var showSearchInput = (this.options.showSearchInputInDropdown !== false);
|
3853
3867
|
|
3854
3868
|
callSuper(this, 'open', $.extend({ showSearchInput: showSearchInput }, options));
|
@@ -3856,6 +3870,8 @@ var callSuper = Selectivity.inherits(SingleSelectivity, {
|
|
3856
3870
|
if (!showSearchInput) {
|
3857
3871
|
this.focus();
|
3858
3872
|
}
|
3873
|
+
|
3874
|
+
this._opening = false;
|
3859
3875
|
},
|
3860
3876
|
|
3861
3877
|
/**
|
@@ -3929,7 +3945,8 @@ var callSuper = Selectivity.inherits(SingleSelectivity, {
|
|
3929
3945
|
*/
|
3930
3946
|
_focused: function() {
|
3931
3947
|
|
3932
|
-
if (this.enabled && !this._closing && this.
|
3948
|
+
if (this.enabled && !this._closing && !this._opening &&
|
3949
|
+
this.options.showDropdown !== false) {
|
3933
3950
|
this.open();
|
3934
3951
|
}
|
3935
3952
|
},
|
@@ -4010,13 +4027,6 @@ var callSuper = Selectivity.inherits(SelectivitySubmenu, SelectivityDropdown, {
|
|
4010
4027
|
*/
|
4011
4028
|
close: function() {
|
4012
4029
|
|
4013
|
-
if (this.options.restoreOptions) {
|
4014
|
-
this.selectivity.setOptions(this.options.restoreOptions);
|
4015
|
-
}
|
4016
|
-
if (this.options.restoreResults) {
|
4017
|
-
this.selectivity.results = this.options.restoreResults;
|
4018
|
-
}
|
4019
|
-
|
4020
4030
|
if (this.submenu) {
|
4021
4031
|
this.submenu.close();
|
4022
4032
|
}
|
@@ -4082,12 +4092,11 @@ var callSuper = Selectivity.inherits(SelectivitySubmenu, SelectivityDropdown, {
|
|
4082
4092
|
*/
|
4083
4093
|
selectItem: function(id) {
|
4084
4094
|
|
4085
|
-
var
|
4086
|
-
var item = Selectivity.findNestedById(selectivity.results, id);
|
4095
|
+
var item = Selectivity.findNestedById(this.results, id);
|
4087
4096
|
if (item && !item.submenu) {
|
4088
4097
|
var options = { id: id, item: item };
|
4089
|
-
if (selectivity.triggerEvent('selectivity-selecting', options)) {
|
4090
|
-
selectivity.triggerEvent('selectivity-selected', options);
|
4098
|
+
if (this.selectivity.triggerEvent('selectivity-selecting', options)) {
|
4099
|
+
this.selectivity.triggerEvent('selectivity-selected', options);
|
4091
4100
|
}
|
4092
4101
|
}
|
4093
4102
|
},
|
@@ -4156,6 +4165,7 @@ var callSuper = Selectivity.inherits(SelectivitySubmenu, SelectivityDropdown, {
|
|
4156
4165
|
var $dropdownEl = this.$el;
|
4157
4166
|
|
4158
4167
|
this.submenu = new Dropdown({
|
4168
|
+
items: item.submenu.items || null,
|
4159
4169
|
parentMenu: this,
|
4160
4170
|
position: item.submenu.positionDropdown || function($el) {
|
4161
4171
|
var dropdownPosition = $dropdownEl.position();
|
@@ -4165,21 +4175,12 @@ var callSuper = Selectivity.inherits(SelectivitySubmenu, SelectivityDropdown, {
|
|
4165
4175
|
top: $item.position().top + dropdownPosition.top + 'px'
|
4166
4176
|
}).width(width);
|
4167
4177
|
},
|
4168
|
-
|
4169
|
-
items: selectivity.items,
|
4170
|
-
query: selectivity.options.query || null
|
4171
|
-
},
|
4172
|
-
restoreResults: selectivity.results,
|
4178
|
+
query: item.submenu.query || null,
|
4173
4179
|
selectivity: selectivity,
|
4174
4180
|
showSearchInput: item.submenu.showSearchInput
|
4175
4181
|
});
|
4176
4182
|
|
4177
|
-
|
4178
|
-
items: item.submenu.items || null,
|
4179
|
-
query: item.submenu.query || null
|
4180
|
-
});
|
4181
|
-
|
4182
|
-
selectivity.search('');
|
4183
|
+
this.submenu.search('');
|
4183
4184
|
}
|
4184
4185
|
}
|
4185
4186
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selectivity-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konrad Jurkowski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|