[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 (function($, Chosen, AbstractChosen) { 2 $.fn.jchosen = function (options) { 3 if (!AbstractChosen.browser_is_supported()) { 4 return this; 5 } 6 return this.each(function (input_field) { 7 var $this, chosen; 8 $this = $(this); 9 chosen = $this.data('chosen'); 10 if (options === 'destroy') { 11 if (chosen instanceof JoomlaChosen) { 12 chosen.destroy(); 13 } 14 return; 15 } 16 if (!(chosen instanceof JoomlaChosen)) { 17 $this.data('chosen', new JoomlaChosen(this, options)); 18 } 19 }); 20 }; 21 22 JoomlaChosen = (function (_super) { 23 var __hasProp = {}.hasOwnProperty, 24 __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; }; 25 __extends(JoomlaChosen, _super); 26 27 function JoomlaChosen() { 28 _ref = JoomlaChosen.__super__.constructor.apply(this, arguments); 29 return _ref; 30 } 31 32 JoomlaChosen.prototype.setup = function () { 33 var return_value; 34 return_value = JoomlaChosen.__super__.setup.apply(this, arguments); 35 this.allow_custom_value = this.form_field_jq.hasClass("chosen-custom-value") || this.options.allow_custom_value; 36 this.custom_value_prefix = this.form_field_jq.attr("data-custom_value_prefix") || this.custom_value_prefix; 37 38 return return_value; 39 }; 40 41 JoomlaChosen.prototype.set_default_text = function () { 42 this.custom_group_text = this.form_field.getAttribute("data-custom_group_text") || this.options.custom_group_text || "Custom Value"; 43 44 return JoomlaChosen.__super__.set_default_text.apply(this, arguments); 45 }; 46 47 JoomlaChosen.prototype.result_select = function (evt) { 48 var group, option, value; 49 50 if (!this.result_highlight && (!this.is_multiple) && this.allow_custom_value) { 51 value = this.search_field.val(); 52 group = this.add_unique_custom_group(); 53 option = $('<option value="' + this.custom_value_prefix + value + '">' + value + '</option>'); 54 group.append(option); 55 this.form_field_jq.append(group); 56 this.form_field.options[this.form_field.options.length - 1].selected = true; 57 if (!evt.metaKey) { 58 this.results_hide(); 59 } 60 return this.results_build(); 61 } 62 63 return JoomlaChosen.__super__.result_select.apply(this, arguments); 64 }; 65 66 JoomlaChosen.prototype.find_custom_group = function () { 67 var found, group, _i, _len, _ref; 68 _ref = $('optgroup', this.form_field); 69 for (_i = 0, _len = _ref.length; _i < _len; _i++) { 70 group = _ref[_i]; 71 if (group.getAttribute('label') === this.custom_group_text) { 72 found = group; 73 } 74 } 75 return found; 76 }; 77 78 JoomlaChosen.prototype.add_unique_custom_group = function () { 79 var group; 80 group = this.find_custom_group(); 81 if (!group) { 82 group = $('<optgroup label="' + this.custom_group_text + '"></optgroup>'); 83 } 84 return $(group); 85 }; 86 87 /** 88 * We choose to override this function so deliberately don't call super 89 */ 90 JoomlaChosen.prototype.container_width = function () { 91 if (this.options.width != null) { 92 return this.options.width; 93 } else { 94 // Original: return "" + this.form_field.offsetWidth + "px"; 95 return this.form_field_jq.css("width") || "" + this.form_field.offsetWidth + "px"; 96 } 97 }; 98 99 return JoomlaChosen; 100 101 })(Chosen); 102 })(jQuery, document.Chosen, document.AbstractChosen);
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |