/* ** Zabbix ** Copyright (C) 2001-2023 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. **/ /** * CMacroValue element control. */ (function($) { 'use strict'; const ZBX_MACRO_TYPE_TEXT = 0; const ZBX_MACRO_TYPE_SECRET = 1; const ZBX_MACRO_TYPE_VAULT = 2; const ZBX_STYLE_MACRO_VALUE_TEXT = 'macro-value-text'; const ZBX_STYLE_MACRO_VALUE_SECRET = 'macro-value-secret'; const ZBX_STYLE_MACRO_VALUE_VAULT = 'macro-value-vault'; const ZBX_STYLE_ICON_SECRET = 'icon-secret'; function btnUndoFocusEventHandle() { $(this) .closest('.macro-input-group') .find('.btn-undo') .toggleClass('is-focused'); } function btnUndoClickEventHandle() { var $this = $(this), $container = $this.closest('.macro-input-group'), $input_container = $('.input-secret, .textarea-flexible', $container), $input = $('.input-secret input[type=password], .textarea-flexible', $container), $dropdown_value = $('.dropdown-value', $container); $input_container.replaceWith( $('
') .addClass('input-secret') .append( $('') .attr({ id: $input.attr('id'), name: $input.attr('name'), type: 'password', value: '******', placeholder: $input.attr('placeholder'), maxlength: $input.attr('maxlength'), disabled: true }) .on('focus blur', btnUndoFocusEventHandle) ) .append($('