PageSourceSearch

https://support.zabbix.com/includes/ajs/list/ItemDescriptor.js

js zabbix.com collected 2026-10-02 02:21:40 UTC 7,234 bytes, 237 lines download raw bytes

1function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2/**
3 * @module jira/ajs/list/item-descriptor
4 */
5define('jira/ajs/list/item-descriptor', ['jira/ajs/descriptor', 'jquery'], function (Descriptor, jQuery) {
6  'use strict';
7
8  /**
9   * The item descriptor is used in {@see QueryableDropdownSelect} to define characteristics and
10   * display of items added to suggestions dropdown and in the case of {@see QueryableDropdownSelect}
11   * and {@see SelectModel} also.
12   *
13   * @class ItemDescriptor
14   * @extends Descriptor
15   */
16  return Descriptor.extend({
17    /**
18     * @param options
19     * @constructs
20     */
21    init: function init(options) {
22      if (options && _typeof(options.meta) === "object") {
23        // normalise
24        options.meta = JSON.stringify(options.meta);
25      }
26      this._super(options);
27    },
28    /**
29     * Defines properties required during invocation to form a valid descriptor.
30     *
31     * @property {Object} REQUIRED_PROPERTIES
32     */
33    REQUIRED_PROPERTIES: {
34      label: true
35    },
36    /**
37     * Defines default properties
38     *
39     * @return {Object}
40     */
41    _getDefaultOptions: function _getDefaultOptions() {
42      return {
43        showLabel: true
44      };
45    },
46    /**
47     * Gets styleClass, in the case of {@link QueryableDropdownSelect} these are the classNames that will be applied to the
48     * <a> surrounding suggestion.
49     *
50     * @return {String}
51     */
52    styleClass: function styleClass() {
53      return this.properties.styleClass;
54    },
55    /**
56     * Misc data useful to rendering etc stored here. We store it as a string so that i can be pulled from data attributes.
57     *
58     * @return {JSON}
59     */
60    meta: function meta() {
61      if (this.properties.meta) {
62        return JSON.parse(this.properties.meta);
63      }
64    },
65    /**
66     * Gets value, in the case of a {@link QueryableDropdownSelect} this will be the value set on the <option>
67     *
68     * @return {String}
69     */
70    value: function value() {
71      return this.properties.value;
72    },
73    /**
74     * Gets invalid, in the case of a {@link QueryableDropdownSelect}, a span will be added to label as a hover over the invalid
75     * icon;
76     *
77     * @return {String}
78     */
79    invalid: function invalid() {
80      return this.properties.invalid;
81    },
82    /**
83     * Gets label suffix, in the case of {@link QueryableDropdownSelect} where we mirror the users input as a suggestion we
84     * use this to append some help text such as (Add Label).
85     *
86     * @deprecated not i18n friendly, use *fieldText* and *label* instead
87     * @return {String}
88     */
89    labelSuffix: function labelSuffix(value) {
90      if (typeof value !== "undefined") {
91        this.properties.labelSuffix = value;
92      }
93      return this.properties.labelSuffix;
94    },
95    /**
96     * Gets title, in the case of {@link MultiSelect} we use this as the title tag applied to {@link MultiSelect.Lozenge} element
97     *
98     * @return {String}
99     */
100    title: function title() {
101      return this.properties.title;
102    },
103    /**
104     * Gets label, in the case of {@link QueryableDropdownSelect} this is the label displayed in the suggestion items, unless
105     * the html property of this descriptor has been set.
106     *
107     * @return {String}
108     */
109    label: function label() {
110      return this.properties.label;
111    },
112    disabled: function disabled(_disabled) {
113      if (_disabled) {
114        this.properties.disabled = _disabled;
115      } else {
116        return this.properties.disabled;
117      }
118    },
119    /**
120     * Asks whether or not to allow duplicates of this descriptor. This is used in {@link QueryableDropdownSelect} where there
121     * is a suggetion appended that mirrors user input. In this case if we have another suggestion in the list that is
122     * the same as this one, we do not want to show this one.
123     */
124    allowDuplicate: function allowDuplicate() {
125      return this.properties.allowDuplicate;
126    },
127    /**
128     * @param {Boolean} value
129     * @return {Boolean}
130     */
131    removeOnUnSelect: function removeOnUnSelect(value) {
132      if (typeof value !== "undefined") {
133        this.properties.removeOnUnSelect = value;
134      }
135      return this.properties.removeOnUnSelect;
136    },
137    /**
138     * Gets icon url
139     *
140     * @return {String}
141     */
142    icon: function icon() {
143      return this.properties.icon;
144    },
145    /**
146     * Gets icon type
147     *
148     * @return {String}
149     */
150    iconType: function iconType() {
151      return this.properties.iconType;
152    },
153    /**
154     * Gets the fallback icon url
155     *
156     * @return {String}
157     */
158    fallbackIcon: function fallbackIcon() {
159      return this.properties.fallbackIcon;
160    },
161    /**
162     * Gets or sets selected state.
163     *
164     * @param {Boolean} value
165     * @return {Boolean}
166     */
167    selected: function selected(value) {
168      if (typeof value !== "undefined") {
169        this.properties.selected = value;
170      }
171      return this.properties.selected;
172    },
173    /**
174     * Gets or sets model. The model in the case of {@link QueryableDropdownSelect} is the jQuery wrapped <option> element
175     *
176     * @param $model
177     */
178    model: function model($model) {
179      if ($model) {
180        this.properties.model = $model;
181      } else {
182        return this.properties.model;
183      }
184    },
185    /**
186     * Gets the keywords attribute
187     *
188     * @return {String}
189     */
190    keywords: function keywords() {
191      return this.properties.keywords;
192    },
193    /**
194     * Gets the href attribute
195     *
196     * @return {String}
197     */
198    href: function href() {
199      return this.properties.href;
200    },
201    /**
202     * {@link List} looks at this to determine if it should do the highlighting/filtering or it has already been done
203     * @return {Boolean}
204     */
205    highlighted: function highlighted(value) {
206      if (value === false) {
207        if (this.properties.html) {
208          this.properties.label = jQuery("<div>" + this.properties.html + "</div>").text();
209          this.properties.html = null;
210        }
211        this.properties.highlighted = false;
212      }
213      return this.properties.highlighted && this.properties.html;
214    },
215    /**
216     * Gets html, in the case of {@link QueryableDropdownSelect} this html will be shown as the suggestion item instead of [label]
217     *
218     * @return {String}
219     */
220    html: function html() {
221      return this.properties.html;
222    },
223    /**
224     * @return {String} the text displayed in field when this item is selected
225     */
226    fieldText: function fieldText() {
227      return this.properties.fieldText;
228    },
229    /**
230     * @return true if this {@link ItemDescriptor} should not be selected in the dropdown, even if it's an exact text match for a query.
231     */
232    noExactMatch: function noExactMatch() {
233      return this.properties.noExactMatch;
234    }
235  });
236});
237AJS.namespace('AJS.ItemDescriptor', null, require('jira/ajs/list/item-descriptor'));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.