Source
* @param {boolean} trigger_change (optional) Either to trigger element on-change event once data added. True by default.
/*
** Zabbix
** Copyright (C) 2001-2024 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
(function($) {
var ZBX_STYLE_CLASS = 'multiselect-control';
const MS_ACTION_POPUP = 0;
const MS_ACTION_AUTOSUGGEST = 1;
const FILTER_PRESELECT_ACCEPT_ID = 'id';
/**
* Multi select helper.
*
* @param string options['object_name'] backend data source
* @param object options['objectOptions'] parameters to be added the request URL (optional)
*
* @see jQuery.multiSelect()
*/
$.fn.multiSelectHelper = function(options) {
options = $.extend({objectOptions: {}}, options);
var curl = new Curl('jsrpc.php');
curl.setArgument('type', PAGE_TYPE_TEXT_RETURN_JSON);
curl.setArgument('method', 'multiselect.get');
curl.setArgument('object_name', options.object_name);
for (var key in options.objectOptions) {
curl.setArgument(key, options.objectOptions[key]);
}
options.url = curl.getUrl();
return this.each(function() {
$(this).empty();
this.dataset.params = JSON.stringify(options);
$(this).multiSelect();
});
};
/*
* Multiselect methods
*/
var methods = {
/**
* Get multi select selected data.
*