ad2games-ui_components 2.3.0 → 2.4.0
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 +4 -4
- data/Rakefile +1 -0
- data/app/cells/checkbox_list/checkbox_list_cell.rb +1 -0
- data/app/cells/datagrid_filter/datagrid_filter_cell.rb +1 -0
- data/app/cells/date_range/date_range.coffee +1 -1
- data/app/cells/date_range/date_range.yml +2 -1
- data/app/cells/date_range/date_range_cell.rb +10 -2
- data/app/cells/form_cell_base.rb +1 -0
- data/app/cells/hello_world/hello_world_cell.rb +1 -0
- data/app/cells/markdown_readonly/markdown_readonly_cell.rb +1 -0
- data/app/cells/markdown_textarea/markdown_textarea_cell.rb +1 -0
- data/app/cells/modal/modal_cell.rb +1 -0
- data/app/cells/select/select_cell.rb +4 -3
- data/app/helpers/ui_components/view_helper.rb +1 -0
- data/lib/generators/generate_component.thor +7 -5
- data/lib/tasks/release.rake +1 -0
- data/lib/tasks/styleguide.rake +2 -1
- data/lib/ui_components.rb +1 -0
- data/lib/ui_components/cell.rb +1 -0
- data/lib/ui_components/cell_attributes.rb +1 -0
- data/lib/ui_components/docu_cop.rb +2 -1
- data/lib/ui_components/engine.rb +5 -4
- data/lib/ui_components/form_helper.rb +1 -0
- data/lib/ui_components/version.rb +2 -1
- data/vendor/assets/bower_components/chosen/README.md +16 -4
- data/vendor/assets/bower_components/chosen/bower.json +1 -3
- data/vendor/assets/bower_components/chosen/chosen.css +83 -54
- data/vendor/assets/bower_components/chosen/chosen.jquery.js +183 -131
- data/vendor/assets/bower_components/chosen/package.json +2 -4
- metadata +3 -3
@@ -1,5 +1,6 @@
|
|
1
1
|
(function() {
|
2
2
|
var $, AbstractChosen, Chosen, SelectParser, _ref,
|
3
|
+
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
|
3
4
|
__hasProp = {}.hasOwnProperty,
|
4
5
|
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
5
6
|
|
@@ -109,6 +110,7 @@
|
|
109
110
|
function AbstractChosen(form_field, options) {
|
110
111
|
this.form_field = form_field;
|
111
112
|
this.options = options != null ? options : {};
|
113
|
+
this.label_click_handler = __bind(this.label_click_handler, this);
|
112
114
|
if (!AbstractChosen.browser_is_supported()) {
|
113
115
|
return;
|
114
116
|
}
|
@@ -133,6 +135,7 @@
|
|
133
135
|
this.mouse_on_container = false;
|
134
136
|
this.results_showing = false;
|
135
137
|
this.result_highlighted = null;
|
138
|
+
this.is_rtl = this.options.rtl || /\bchosen-rtl\b/.test(this.form_field.className);
|
136
139
|
this.allow_single_deselect = (this.options.allow_single_deselect != null) && (this.form_field.options[0] != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false;
|
137
140
|
this.disable_search_threshold = this.options.disable_search_threshold || 0;
|
138
141
|
this.disable_search = this.options.disable_search || false;
|
@@ -146,7 +149,8 @@
|
|
146
149
|
this.display_disabled_options = this.options.display_disabled_options != null ? this.options.display_disabled_options : true;
|
147
150
|
this.include_group_label_in_selected = this.options.include_group_label_in_selected || false;
|
148
151
|
this.max_shown_results = this.options.max_shown_results || Number.POSITIVE_INFINITY;
|
149
|
-
|
152
|
+
this.case_sensitive_search = this.options.case_sensitive_search || false;
|
153
|
+
return this.hide_results_on_select = this.options.hide_results_on_select != null ? this.options.hide_results_on_select : true;
|
150
154
|
};
|
151
155
|
|
152
156
|
AbstractChosen.prototype.set_default_text = function() {
|
@@ -157,6 +161,7 @@
|
|
157
161
|
} else {
|
158
162
|
this.default_text = this.options.placeholder_text_single || this.options.placeholder_text || AbstractChosen.default_single_text;
|
159
163
|
}
|
164
|
+
this.default_text = this.escape_html(this.default_text);
|
160
165
|
return this.results_none_found = this.form_field.getAttribute("data-no_results_text") || this.options.no_results_text || AbstractChosen.default_no_result_text;
|
161
166
|
};
|
162
167
|
|
@@ -201,6 +206,14 @@
|
|
201
206
|
}
|
202
207
|
};
|
203
208
|
|
209
|
+
AbstractChosen.prototype.label_click_handler = function(evt) {
|
210
|
+
if (this.is_multiple) {
|
211
|
+
return this.container_mousedown(evt);
|
212
|
+
} else {
|
213
|
+
return this.activate_field();
|
214
|
+
}
|
215
|
+
};
|
216
|
+
|
204
217
|
AbstractChosen.prototype.results_option_build = function(options) {
|
205
218
|
var content, data, data_content, shown_results, _i, _len, _ref;
|
206
219
|
content = '';
|
@@ -333,13 +346,13 @@
|
|
333
346
|
};
|
334
347
|
|
335
348
|
AbstractChosen.prototype.winnow_results = function() {
|
336
|
-
var escapedSearchText, option, regex, results, results_group, searchText, startpos, text,
|
349
|
+
var escapedSearchText, highlightRegex, option, regex, results, results_group, searchText, startpos, text, _i, _len, _ref;
|
337
350
|
this.no_results_clear();
|
338
351
|
results = 0;
|
339
352
|
searchText = this.get_search_text();
|
340
353
|
escapedSearchText = searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
341
|
-
zregex = new RegExp(escapedSearchText, 'i');
|
342
354
|
regex = this.get_search_regex(escapedSearchText);
|
355
|
+
highlightRegex = this.get_highlight_regex(escapedSearchText);
|
343
356
|
_ref = this.results_data;
|
344
357
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
345
358
|
option = _ref[_i];
|
@@ -365,7 +378,7 @@
|
|
365
378
|
}
|
366
379
|
if (option.search_match) {
|
367
380
|
if (searchText.length) {
|
368
|
-
startpos = option.search_text.search(
|
381
|
+
startpos = option.search_text.search(highlightRegex);
|
369
382
|
text = option.search_text.substr(0, startpos + searchText.length) + '</em>' + option.search_text.substr(startpos + searchText.length);
|
370
383
|
option.search_text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
|
371
384
|
}
|
@@ -395,6 +408,13 @@
|
|
395
408
|
return new RegExp(regex_anchor + escaped_search_string, regex_flag);
|
396
409
|
};
|
397
410
|
|
411
|
+
AbstractChosen.prototype.get_highlight_regex = function(escaped_search_string) {
|
412
|
+
var regex_anchor, regex_flag;
|
413
|
+
regex_anchor = this.search_contains ? "" : "\\b";
|
414
|
+
regex_flag = this.case_sensitive_search ? "" : "i";
|
415
|
+
return new RegExp(regex_anchor + escaped_search_string, regex_flag);
|
416
|
+
};
|
417
|
+
|
398
418
|
AbstractChosen.prototype.search_string_match = function(search_string, regex) {
|
399
419
|
var part, parts, _i, _len;
|
400
420
|
if (regex.test(search_string)) {
|
@@ -430,11 +450,55 @@
|
|
430
450
|
|
431
451
|
AbstractChosen.prototype.choices_click = function(evt) {
|
432
452
|
evt.preventDefault();
|
453
|
+
this.activate_field();
|
433
454
|
if (!(this.results_showing || this.is_disabled)) {
|
434
455
|
return this.results_show();
|
435
456
|
}
|
436
457
|
};
|
437
458
|
|
459
|
+
AbstractChosen.prototype.keydown_checker = function(evt) {
|
460
|
+
var stroke, _ref;
|
461
|
+
stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
|
462
|
+
this.search_field_scale();
|
463
|
+
if (stroke !== 8 && this.pending_backstroke) {
|
464
|
+
this.clear_backstroke();
|
465
|
+
}
|
466
|
+
switch (stroke) {
|
467
|
+
case 8:
|
468
|
+
this.backstroke_length = this.get_search_field_value().length;
|
469
|
+
break;
|
470
|
+
case 9:
|
471
|
+
if (this.results_showing && !this.is_multiple) {
|
472
|
+
this.result_select(evt);
|
473
|
+
}
|
474
|
+
this.mouse_on_container = false;
|
475
|
+
break;
|
476
|
+
case 13:
|
477
|
+
if (this.results_showing) {
|
478
|
+
evt.preventDefault();
|
479
|
+
}
|
480
|
+
break;
|
481
|
+
case 27:
|
482
|
+
if (this.results_showing) {
|
483
|
+
evt.preventDefault();
|
484
|
+
}
|
485
|
+
break;
|
486
|
+
case 32:
|
487
|
+
if (this.disable_search) {
|
488
|
+
evt.preventDefault();
|
489
|
+
}
|
490
|
+
break;
|
491
|
+
case 38:
|
492
|
+
evt.preventDefault();
|
493
|
+
this.keyup_arrow();
|
494
|
+
break;
|
495
|
+
case 40:
|
496
|
+
evt.preventDefault();
|
497
|
+
this.keydown_arrow();
|
498
|
+
break;
|
499
|
+
}
|
500
|
+
};
|
501
|
+
|
438
502
|
AbstractChosen.prototype.keyup_checker = function(evt) {
|
439
503
|
var stroke, _ref;
|
440
504
|
stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
|
@@ -442,38 +506,42 @@
|
|
442
506
|
switch (stroke) {
|
443
507
|
case 8:
|
444
508
|
if (this.is_multiple && this.backstroke_length < 1 && this.choices_count() > 0) {
|
445
|
-
|
509
|
+
this.keydown_backstroke();
|
446
510
|
} else if (!this.pending_backstroke) {
|
447
511
|
this.result_clear_highlight();
|
448
|
-
|
512
|
+
this.results_search();
|
449
513
|
}
|
450
514
|
break;
|
451
515
|
case 13:
|
452
516
|
evt.preventDefault();
|
453
517
|
if (this.results_showing) {
|
454
|
-
|
518
|
+
this.result_select(evt);
|
455
519
|
}
|
456
520
|
break;
|
457
521
|
case 27:
|
458
522
|
if (this.results_showing) {
|
459
523
|
this.results_hide();
|
460
524
|
}
|
461
|
-
|
525
|
+
break;
|
462
526
|
case 9:
|
463
|
-
case 38:
|
464
|
-
case 40:
|
465
527
|
case 16:
|
466
|
-
case 91:
|
467
528
|
case 17:
|
468
529
|
case 18:
|
530
|
+
case 38:
|
531
|
+
case 40:
|
532
|
+
case 91:
|
469
533
|
break;
|
470
534
|
default:
|
471
|
-
|
535
|
+
this.results_search();
|
536
|
+
break;
|
472
537
|
}
|
473
538
|
};
|
474
539
|
|
475
540
|
AbstractChosen.prototype.clipboard_event_checker = function(evt) {
|
476
541
|
var _this = this;
|
542
|
+
if (this.is_disabled) {
|
543
|
+
return;
|
544
|
+
}
|
477
545
|
return setTimeout((function() {
|
478
546
|
return _this.results_search();
|
479
547
|
}), 50);
|
@@ -526,6 +594,18 @@
|
|
526
594
|
return tmp.innerHTML;
|
527
595
|
};
|
528
596
|
|
597
|
+
AbstractChosen.prototype.get_single_html = function() {
|
598
|
+
return "<a class=\"chosen-single chosen-default\">\n <span>" + this.default_text + "</span>\n <div><b></b></div>\n</a>\n<div class=\"chosen-drop\">\n <div class=\"chosen-search\">\n <input class=\"chosen-search-input\" type=\"text\" autocomplete=\"off\" />\n </div>\n <ul class=\"chosen-results\"></ul>\n</div>";
|
599
|
+
};
|
600
|
+
|
601
|
+
AbstractChosen.prototype.get_multi_html = function() {
|
602
|
+
return "<ul class=\"chosen-choices\">\n <li class=\"search-field\">\n <input class=\"chosen-search-input\" type=\"text\" autocomplete=\"off\" value=\"" + this.default_text + "\" />\n </li>\n</ul>\n<div class=\"chosen-drop\">\n <ul class=\"chosen-results\"></ul>\n</div>";
|
603
|
+
};
|
604
|
+
|
605
|
+
AbstractChosen.prototype.get_no_results_html = function(terms) {
|
606
|
+
return "<li class=\"no-results\">\n " + this.results_none_found + " <span>" + terms + "</span>\n</li>";
|
607
|
+
};
|
608
|
+
|
529
609
|
AbstractChosen.browser_is_supported = function() {
|
530
610
|
if ("Microsoft Internet Explorer" === window.navigator.appName) {
|
531
611
|
return document.documentMode >= 8;
|
@@ -580,8 +660,7 @@
|
|
580
660
|
|
581
661
|
Chosen.prototype.setup = function() {
|
582
662
|
this.form_field_jq = $(this.form_field);
|
583
|
-
this.current_selectedIndex = this.form_field.selectedIndex;
|
584
|
-
return this.is_rtl = this.form_field_jq.hasClass("chosen-rtl");
|
663
|
+
return this.current_selectedIndex = this.form_field.selectedIndex;
|
585
664
|
};
|
586
665
|
|
587
666
|
Chosen.prototype.set_up_html = function() {
|
@@ -596,17 +675,17 @@
|
|
596
675
|
}
|
597
676
|
container_props = {
|
598
677
|
'class': container_classes.join(' '),
|
599
|
-
'style': "width: " + (this.container_width()) + ";",
|
600
678
|
'title': this.form_field.title
|
601
679
|
};
|
602
680
|
if (this.form_field.id.length) {
|
603
681
|
container_props.id = this.form_field.id.replace(/[^\w]/g, '_') + "_chosen";
|
604
682
|
}
|
605
683
|
this.container = $("<div />", container_props);
|
684
|
+
this.container.width(this.container_width());
|
606
685
|
if (this.is_multiple) {
|
607
|
-
this.container.html(
|
686
|
+
this.container.html(this.get_multi_html());
|
608
687
|
} else {
|
609
|
-
this.container.html(
|
688
|
+
this.container.html(this.get_single_html());
|
610
689
|
}
|
611
690
|
this.form_field_jq.hide().after(this.container);
|
612
691
|
this.dropdown = this.container.find('div.chosen-drop').first();
|
@@ -636,11 +715,9 @@
|
|
636
715
|
var _this = this;
|
637
716
|
this.container.bind('touchstart.chosen', function(evt) {
|
638
717
|
_this.container_mousedown(evt);
|
639
|
-
return evt.preventDefault();
|
640
718
|
});
|
641
719
|
this.container.bind('touchend.chosen', function(evt) {
|
642
720
|
_this.container_mouseup(evt);
|
643
|
-
return evt.preventDefault();
|
644
721
|
});
|
645
722
|
this.container.bind('mousedown.chosen', function(evt) {
|
646
723
|
_this.container_mousedown(evt);
|
@@ -685,7 +762,7 @@
|
|
685
762
|
_this.container_mousedown(evt);
|
686
763
|
});
|
687
764
|
this.form_field_jq.bind("chosen:close.chosen", function(evt) {
|
688
|
-
_this.
|
765
|
+
_this.close_field(evt);
|
689
766
|
});
|
690
767
|
this.search_field.bind('blur.chosen', function(evt) {
|
691
768
|
_this.input_blur(evt);
|
@@ -717,7 +794,10 @@
|
|
717
794
|
};
|
718
795
|
|
719
796
|
Chosen.prototype.destroy = function() {
|
720
|
-
$(this.container[0].ownerDocument).unbind(
|
797
|
+
$(this.container[0].ownerDocument).unbind('click.chosen', this.click_test_action);
|
798
|
+
if (this.form_field_label.length > 0) {
|
799
|
+
this.form_field_label.unbind('click.chosen');
|
800
|
+
}
|
721
801
|
if (this.search_field[0].tabIndex) {
|
722
802
|
this.form_field_jq[0].tabIndex = this.search_field[0].tabIndex;
|
723
803
|
}
|
@@ -727,41 +807,39 @@
|
|
727
807
|
};
|
728
808
|
|
729
809
|
Chosen.prototype.search_field_disabled = function() {
|
730
|
-
this.is_disabled = this.form_field_jq
|
810
|
+
this.is_disabled = this.form_field.disabled || this.form_field_jq.parents('fieldset').is(':disabled');
|
811
|
+
this.container.toggleClass('chosen-disabled', this.is_disabled);
|
812
|
+
this.search_field[0].disabled = this.is_disabled;
|
813
|
+
if (!this.is_multiple) {
|
814
|
+
this.selected_item.unbind('focus.chosen', this.activate_field);
|
815
|
+
}
|
731
816
|
if (this.is_disabled) {
|
732
|
-
this.container.addClass('chosen-disabled');
|
733
|
-
this.search_field[0].disabled = true;
|
734
|
-
if (!this.is_multiple) {
|
735
|
-
this.selected_item.unbind("focus.chosen", this.activate_action);
|
736
|
-
}
|
737
817
|
return this.close_field();
|
738
|
-
} else {
|
739
|
-
this.
|
740
|
-
this.search_field[0].disabled = false;
|
741
|
-
if (!this.is_multiple) {
|
742
|
-
return this.selected_item.bind("focus.chosen", this.activate_action);
|
743
|
-
}
|
818
|
+
} else if (!this.is_multiple) {
|
819
|
+
return this.selected_item.bind('focus.chosen', this.activate_field);
|
744
820
|
}
|
745
821
|
};
|
746
822
|
|
747
823
|
Chosen.prototype.container_mousedown = function(evt) {
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
this.
|
759
|
-
} else if (!this.is_multiple && evt && (($(evt.target)[0] === this.selected_item[0]) || $(evt.target).parents("a.chosen-single").length)) {
|
760
|
-
evt.preventDefault();
|
761
|
-
this.results_toggle();
|
824
|
+
var _ref1;
|
825
|
+
if (this.is_disabled) {
|
826
|
+
return;
|
827
|
+
}
|
828
|
+
if (evt && ((_ref1 = evt.type) === 'mousedown' || _ref1 === 'touchstart') && !this.results_showing) {
|
829
|
+
evt.preventDefault();
|
830
|
+
}
|
831
|
+
if (!((evt != null) && ($(evt.target)).hasClass("search-choice-close"))) {
|
832
|
+
if (!this.active_field) {
|
833
|
+
if (this.is_multiple) {
|
834
|
+
this.search_field.val("");
|
762
835
|
}
|
763
|
-
|
836
|
+
$(this.container[0].ownerDocument).bind('click.chosen', this.click_test_action);
|
837
|
+
this.results_show();
|
838
|
+
} else if (!this.is_multiple && evt && (($(evt.target)[0] === this.selected_item[0]) || $(evt.target).parents("a.chosen-single").length)) {
|
839
|
+
evt.preventDefault();
|
840
|
+
this.results_toggle();
|
764
841
|
}
|
842
|
+
return this.activate_field();
|
765
843
|
}
|
766
844
|
};
|
767
845
|
|
@@ -798,10 +876,14 @@
|
|
798
876
|
this.container.removeClass("chosen-container-active");
|
799
877
|
this.clear_backstroke();
|
800
878
|
this.show_search_field_default();
|
801
|
-
|
879
|
+
this.search_field_scale();
|
880
|
+
return this.search_field.blur();
|
802
881
|
};
|
803
882
|
|
804
883
|
Chosen.prototype.activate_field = function() {
|
884
|
+
if (this.is_disabled) {
|
885
|
+
return;
|
886
|
+
}
|
805
887
|
this.container.addClass("chosen-container-active");
|
806
888
|
this.active_field = true;
|
807
889
|
this.search_field.val(this.search_field.val());
|
@@ -879,7 +961,7 @@
|
|
879
961
|
this.container.addClass("chosen-with-drop");
|
880
962
|
this.results_showing = true;
|
881
963
|
this.search_field.focus();
|
882
|
-
this.search_field.val(this.
|
964
|
+
this.search_field.val(this.get_search_field_value());
|
883
965
|
this.winnow_results();
|
884
966
|
return this.form_field_jq.trigger("chosen:showing_dropdown", {
|
885
967
|
chosen: this
|
@@ -911,19 +993,12 @@
|
|
911
993
|
};
|
912
994
|
|
913
995
|
Chosen.prototype.set_label_behavior = function() {
|
914
|
-
var _this = this;
|
915
996
|
this.form_field_label = this.form_field_jq.parents("label");
|
916
997
|
if (!this.form_field_label.length && this.form_field.id.length) {
|
917
998
|
this.form_field_label = $("label[for='" + this.form_field.id + "']");
|
918
999
|
}
|
919
1000
|
if (this.form_field_label.length > 0) {
|
920
|
-
return this.form_field_label.bind('click.chosen',
|
921
|
-
if (_this.is_multiple) {
|
922
|
-
return _this.container_mousedown(evt);
|
923
|
-
} else {
|
924
|
-
return _this.activate_field();
|
925
|
-
}
|
926
|
-
});
|
1001
|
+
return this.form_field_label.bind('click.chosen', this.label_click_handler);
|
927
1002
|
}
|
928
1003
|
};
|
929
1004
|
|
@@ -992,8 +1067,12 @@
|
|
992
1067
|
|
993
1068
|
Chosen.prototype.choice_destroy = function(link) {
|
994
1069
|
if (this.result_deselect(link[0].getAttribute("data-option-array-index"))) {
|
995
|
-
this.
|
996
|
-
|
1070
|
+
if (this.active_field) {
|
1071
|
+
this.search_field.focus();
|
1072
|
+
} else {
|
1073
|
+
this.show_search_field_default();
|
1074
|
+
}
|
1075
|
+
if (this.is_multiple && this.choices_count() > 0 && this.get_search_field_value().length < 1) {
|
997
1076
|
this.results_hide();
|
998
1077
|
}
|
999
1078
|
link.parents('li').first().remove();
|
@@ -1007,7 +1086,7 @@
|
|
1007
1086
|
this.single_set_selected_text();
|
1008
1087
|
this.show_search_field_default();
|
1009
1088
|
this.results_reset_cleanup();
|
1010
|
-
this.
|
1089
|
+
this.trigger_form_field_change();
|
1011
1090
|
if (this.active_field) {
|
1012
1091
|
return this.results_hide();
|
1013
1092
|
}
|
@@ -1044,13 +1123,13 @@
|
|
1044
1123
|
} else {
|
1045
1124
|
this.single_set_selected_text(this.choice_label(item));
|
1046
1125
|
}
|
1047
|
-
if (!((evt.metaKey || evt.ctrlKey)
|
1126
|
+
if (!(this.is_multiple && (!this.hide_results_on_select || (evt.metaKey || evt.ctrlKey)))) {
|
1048
1127
|
this.results_hide();
|
1128
|
+
this.show_search_field_default();
|
1049
1129
|
}
|
1050
|
-
this.show_search_field_default();
|
1051
1130
|
if (this.is_multiple || this.form_field.selectedIndex !== this.current_selectedIndex) {
|
1052
|
-
this.
|
1053
|
-
|
1131
|
+
this.trigger_form_field_change({
|
1132
|
+
selected: this.form_field.options[item.options_index].value
|
1054
1133
|
});
|
1055
1134
|
}
|
1056
1135
|
this.current_selectedIndex = this.form_field.selectedIndex;
|
@@ -1083,7 +1162,7 @@
|
|
1083
1162
|
if (this.results_showing) {
|
1084
1163
|
this.winnow_results();
|
1085
1164
|
}
|
1086
|
-
this.
|
1165
|
+
this.trigger_form_field_change({
|
1087
1166
|
deselected: this.form_field.options[result_data.options_index].value
|
1088
1167
|
});
|
1089
1168
|
this.search_field_scale();
|
@@ -1103,8 +1182,16 @@
|
|
1103
1182
|
return this.selected_item.addClass("chosen-single-with-deselect");
|
1104
1183
|
};
|
1105
1184
|
|
1185
|
+
Chosen.prototype.get_search_field_value = function() {
|
1186
|
+
return this.search_field.val();
|
1187
|
+
};
|
1188
|
+
|
1106
1189
|
Chosen.prototype.get_search_text = function() {
|
1107
|
-
return
|
1190
|
+
return this.escape_html($.trim(this.get_search_field_value()));
|
1191
|
+
};
|
1192
|
+
|
1193
|
+
Chosen.prototype.escape_html = function(text) {
|
1194
|
+
return $('<div/>').text(text).html();
|
1108
1195
|
};
|
1109
1196
|
|
1110
1197
|
Chosen.prototype.winnow_results_set_highlight = function() {
|
@@ -1118,8 +1205,7 @@
|
|
1118
1205
|
|
1119
1206
|
Chosen.prototype.no_results = function(terms) {
|
1120
1207
|
var no_results_html;
|
1121
|
-
no_results_html =
|
1122
|
-
no_results_html.find("span").first().html(terms);
|
1208
|
+
no_results_html = this.get_no_results_html(terms);
|
1123
1209
|
this.search_results.append(no_results_html);
|
1124
1210
|
return this.form_field_jq.trigger("chosen:no_results", {
|
1125
1211
|
chosen: this
|
@@ -1184,70 +1270,36 @@
|
|
1184
1270
|
return this.pending_backstroke = null;
|
1185
1271
|
};
|
1186
1272
|
|
1187
|
-
Chosen.prototype.keydown_checker = function(evt) {
|
1188
|
-
var stroke, _ref1;
|
1189
|
-
stroke = (_ref1 = evt.which) != null ? _ref1 : evt.keyCode;
|
1190
|
-
this.search_field_scale();
|
1191
|
-
if (stroke !== 8 && this.pending_backstroke) {
|
1192
|
-
this.clear_backstroke();
|
1193
|
-
}
|
1194
|
-
switch (stroke) {
|
1195
|
-
case 8:
|
1196
|
-
this.backstroke_length = this.search_field.val().length;
|
1197
|
-
break;
|
1198
|
-
case 9:
|
1199
|
-
if (this.results_showing && !this.is_multiple) {
|
1200
|
-
this.result_select(evt);
|
1201
|
-
}
|
1202
|
-
this.mouse_on_container = false;
|
1203
|
-
break;
|
1204
|
-
case 13:
|
1205
|
-
if (this.results_showing) {
|
1206
|
-
evt.preventDefault();
|
1207
|
-
}
|
1208
|
-
break;
|
1209
|
-
case 32:
|
1210
|
-
if (this.disable_search) {
|
1211
|
-
evt.preventDefault();
|
1212
|
-
}
|
1213
|
-
break;
|
1214
|
-
case 38:
|
1215
|
-
evt.preventDefault();
|
1216
|
-
this.keyup_arrow();
|
1217
|
-
break;
|
1218
|
-
case 40:
|
1219
|
-
evt.preventDefault();
|
1220
|
-
this.keydown_arrow();
|
1221
|
-
break;
|
1222
|
-
}
|
1223
|
-
};
|
1224
|
-
|
1225
1273
|
Chosen.prototype.search_field_scale = function() {
|
1226
|
-
var
|
1227
|
-
if (this.is_multiple) {
|
1228
|
-
|
1229
|
-
w = 0;
|
1230
|
-
style_block = "position:absolute; left: -1000px; top: -1000px; display:none;";
|
1231
|
-
styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing'];
|
1232
|
-
for (_i = 0, _len = styles.length; _i < _len; _i++) {
|
1233
|
-
style = styles[_i];
|
1234
|
-
style_block += style + ":" + this.search_field.css(style) + ";";
|
1235
|
-
}
|
1236
|
-
div = $('<div />', {
|
1237
|
-
'style': style_block
|
1238
|
-
});
|
1239
|
-
div.text(this.search_field.val());
|
1240
|
-
$('body').append(div);
|
1241
|
-
w = div.width() + 25;
|
1242
|
-
div.remove();
|
1243
|
-
f_width = this.container.outerWidth();
|
1244
|
-
if (w > f_width - 10) {
|
1245
|
-
w = f_width - 10;
|
1246
|
-
}
|
1247
|
-
return this.search_field.css({
|
1248
|
-
'width': w + 'px'
|
1249
|
-
});
|
1274
|
+
var container_width, div, style, style_block, styles, width, _i, _len;
|
1275
|
+
if (!this.is_multiple) {
|
1276
|
+
return;
|
1250
1277
|
}
|
1278
|
+
style_block = {
|
1279
|
+
position: 'absolute',
|
1280
|
+
left: '-1000px',
|
1281
|
+
top: '-1000px',
|
1282
|
+
display: 'none',
|
1283
|
+
whiteSpace: 'pre'
|
1284
|
+
};
|
1285
|
+
styles = ['fontSize', 'fontStyle', 'fontWeight', 'fontFamily', 'lineHeight', 'textTransform', 'letterSpacing'];
|
1286
|
+
for (_i = 0, _len = styles.length; _i < _len; _i++) {
|
1287
|
+
style = styles[_i];
|
1288
|
+
style_block[style] = this.search_field.css(style);
|
1289
|
+
}
|
1290
|
+
div = $('<div />').css(style_block);
|
1291
|
+
div.text(this.get_search_field_value());
|
1292
|
+
$('body').append(div);
|
1293
|
+
width = div.width() + 25;
|
1294
|
+
div.remove();
|
1295
|
+
container_width = this.container.outerWidth();
|
1296
|
+
width = Math.min(container_width - 10, width);
|
1297
|
+
return this.search_field.width(width);
|
1298
|
+
};
|
1299
|
+
|
1300
|
+
Chosen.prototype.trigger_form_field_change = function(extra) {
|
1301
|
+
this.form_field_jq.trigger("input", extra);
|
1302
|
+
return this.form_field_jq.trigger("change", extra);
|
1251
1303
|
};
|
1252
1304
|
|
1253
1305
|
return Chosen;
|