# HG changeset patch # User Thierry Florac # Date 1528108358 -7200 # Node ID a4497eed4ff79256c02af6857c284619e56d4924 # Parent 1bde2a1c19021443b2440b718b485e09b92b9058 Merged updates from PyAMS_skin package diff -r 1bde2a1c1902 -r a4497eed4ff7 src/ztfy/myams/resources/js/ext/bootstrap-treeview.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ztfy/myams/resources/js/ext/bootstrap-treeview.js Mon Jun 04 12:32:38 2018 +0200 @@ -0,0 +1,1260 @@ +/* ========================================================= + * bootstrap-treeview.js v1.3.0-b1-tf + * ========================================================= + * Copyright 2013 Jonathan Miles + * Project URL : http://www.jondmiles.com/bootstrap-treeview + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================================================= */ + +(function ($, window, document, undefined) { + + /*global jQuery, console*/ + + 'use strict'; + + var pluginName = 'treeview'; + + var _default = {}; + + _default.settings = { + + injectStyle: true, + + levels: 2, + + expandIcon: 'glyphicon glyphicon-plus', + collapseIcon: 'glyphicon glyphicon-minus', + emptyIcon: 'glyphicon', + nodeIcon: '', + selectedIcon: '', + checkedIcon: 'glyphicon glyphicon-check', + uncheckedIcon: 'glyphicon glyphicon-unchecked', + + color: undefined, // '#000000', + backColor: undefined, // '#FFFFFF', + borderColor: undefined, // '#dddddd', + onhoverColor: '#F5F5F5', + selectedColor: '#FFFFFF', + selectedBackColor: '#428bca', + unselectableBackColor: undefined, //'#FFFFFF', + searchResultColor: '#D9534F', + searchResultBackColor: undefined, //'#FFFFFF', + + enableLinks: false, + highlightSelected: true, + highlightSearchResults: true, + showBorder: true, + showIcon: true, + showCheckbox: false, + showTags: false, + toggleUnselectable: true, + multiSelect: false, + + // Event handlers + onNodeChecked: undefined, + onNodeCollapsed: undefined, + onNodeDisabled: undefined, + onNodeEnabled: undefined, + onNodeExpanded: undefined, + onNodeSelected: undefined, + onNodeUnchecked: undefined, + onNodeUnselected: undefined, + onSearchComplete: undefined, + onSearchCleared: undefined + }; + + _default.options = { + silent: false, + ignoreChildren: false + }; + + _default.searchOptions = { + ignoreCase: true, + exactMatch: false, + revealResults: true + }; + + var Tree = function (element, options) { + + this.$element = $(element); + this.elementId = element.id; + this.styleId = this.elementId + '-style'; + + this.init(options); + + return { + + // Options (public access) + options: this.options, + + // Initialize / destroy methods + init: $.proxy(this.init, this), + remove: $.proxy(this.remove, this), + + // Get methods + getNode: $.proxy(this.getNode, this), + getParent: $.proxy(this.getParent, this), + getSiblings: $.proxy(this.getSiblings, this), + getSelected: $.proxy(this.getSelected, this), + getUnselected: $.proxy(this.getUnselected, this), + getExpanded: $.proxy(this.getExpanded, this), + getCollapsed: $.proxy(this.getCollapsed, this), + getChecked: $.proxy(this.getChecked, this), + getUnchecked: $.proxy(this.getUnchecked, this), + getDisabled: $.proxy(this.getDisabled, this), + getEnabled: $.proxy(this.getEnabled, this), + + // Select methods + selectNode: $.proxy(this.selectNode, this), + unselectNode: $.proxy(this.unselectNode, this), + toggleNodeSelected: $.proxy(this.toggleNodeSelected, this), + + // Expand / collapse methods + collapseAll: $.proxy(this.collapseAll, this), + collapseNode: $.proxy(this.collapseNode, this), + expandAll: $.proxy(this.expandAll, this), + expandNode: $.proxy(this.expandNode, this), + toggleNodeExpanded: $.proxy(this.toggleNodeExpanded, this), + revealNode: $.proxy(this.revealNode, this), + + // Expand / collapse methods + checkAll: $.proxy(this.checkAll, this), + checkNode: $.proxy(this.checkNode, this), + uncheckAll: $.proxy(this.uncheckAll, this), + uncheckNode: $.proxy(this.uncheckNode, this), + toggleNodeChecked: $.proxy(this.toggleNodeChecked, this), + + // Disable / enable methods + disableAll: $.proxy(this.disableAll, this), + disableNode: $.proxy(this.disableNode, this), + enableAll: $.proxy(this.enableAll, this), + enableNode: $.proxy(this.enableNode, this), + toggleNodeDisabled: $.proxy(this.toggleNodeDisabled, this), + + // Search methods + search: $.proxy(this.search, this), + clearSearch: $.proxy(this.clearSearch, this) + }; + }; + + Tree.prototype.init = function (options) { + + this.tree = []; + this.nodes = []; + + if (options.data) { + if (typeof options.data === 'string') { + options.data = $.parseJSON(options.data); + } + this.tree = $.extend(true, [], options.data); + delete options.data; + } + this.options = $.extend({}, _default.settings, options); + + this.destroy(); + this.subscribeEvents(); + this.setInitialStates({ nodes: this.tree }, 0); + this.render(); + }; + + Tree.prototype.remove = function () { + this.destroy(); + $.removeData(this, pluginName); + $('#' + this.styleId).remove(); + }; + + Tree.prototype.destroy = function () { + + if (!this.initialized) return; + + this.$wrapper.remove(); + this.$wrapper = null; + + // Switch off events + this.unsubscribeEvents(); + + // Reset this.initialized flag + this.initialized = false; + }; + + Tree.prototype.unsubscribeEvents = function () { + + this.$element.off('click'); + this.$element.off('nodeChecked'); + this.$element.off('nodeCollapsed'); + this.$element.off('nodeDisabled'); + this.$element.off('nodeEnabled'); + this.$element.off('nodeExpanded'); + this.$element.off('nodeSelected'); + this.$element.off('nodeUnchecked'); + this.$element.off('nodeUnselected'); + this.$element.off('searchComplete'); + this.$element.off('searchCleared'); + }; + + Tree.prototype.subscribeEvents = function () { + + this.unsubscribeEvents(); + + this.$element.on('click', $.proxy(this.clickHandler, this)); + + if (typeof (this.options.onNodeChecked) === 'function') { + this.$element.on('nodeChecked', this.options.onNodeChecked); + } + + if (typeof (this.options.onNodeCollapsed) === 'function') { + this.$element.on('nodeCollapsed', this.options.onNodeCollapsed); + } + + if (typeof (this.options.onNodeDisabled) === 'function') { + this.$element.on('nodeDisabled', this.options.onNodeDisabled); + } + + if (typeof (this.options.onNodeEnabled) === 'function') { + this.$element.on('nodeEnabled', this.options.onNodeEnabled); + } + + if (typeof (this.options.onNodeExpanded) === 'function') { + this.$element.on('nodeExpanded', this.options.onNodeExpanded); + } + + if (typeof (this.options.onNodeSelected) === 'function') { + this.$element.on('nodeSelected', this.options.onNodeSelected); + } + + if (typeof (this.options.onNodeUnchecked) === 'function') { + this.$element.on('nodeUnchecked', this.options.onNodeUnchecked); + } + + if (typeof (this.options.onNodeUnselected) === 'function') { + this.$element.on('nodeUnselected', this.options.onNodeUnselected); + } + + if (typeof (this.options.onSearchComplete) === 'function') { + this.$element.on('searchComplete', this.options.onSearchComplete); + } + + if (typeof (this.options.onSearchCleared) === 'function') { + this.$element.on('searchCleared', this.options.onSearchCleared); + } + }; + + /* + Recurse the tree structure and ensure all nodes have + valid initial states. User defined states will be preserved. + For performance we also take this opportunity to + index nodes in a flattened structure + */ + Tree.prototype.setInitialStates = function (node, level) { + + if (!node.nodes) return; + level += 1; + + var parent = node; + var _this = this; + $.each(node.nodes, function checkStates(index, node) { + + // nodeId : unique, incremental identifier + node.nodeId = _this.nodes.length; + + // parentId : transversing up the tree + node.parentId = parent.nodeId; + + // if not provided set selectable default value + if (!node.hasOwnProperty('selectable')) { + node.selectable = true; + } + + // where provided we should preserve states + node.state = node.state || {}; + + // set checked state; unless set always false + if (!node.state.hasOwnProperty('checked')) { + node.state.checked = false; + } + + // set enabled state; unless set always false + if (!node.state.hasOwnProperty('disabled')) { + node.state.disabled = false; + } + + // set expanded state; if not provided based on levels + if (!node.state.hasOwnProperty('expanded')) { + if (!node.state.disabled && + (level < _this.options.levels) && + (node.nodes && node.nodes.length > 0)) { + node.state.expanded = true; + } + else { + node.state.expanded = false; + } + } + + // set selected state; unless set always false + if (!node.state.hasOwnProperty('selected')) { + node.state.selected = false; + } + + // index nodes in a flattened structure for use later + _this.nodes.push(node); + + // recurse child nodes and transverse the tree + if (node.nodes) { + _this.setInitialStates(node, level); + } + }); + }; + + Tree.prototype.clickHandler = function (event) { + + if (!this.options.enableLinks) event.preventDefault(); + + var target = $(event.target); + var node = this.findNode(target); + if (!node || node.state.disabled) return; + + var classList = target.attr('class') ? target.attr('class').split(' ') : []; + if ((classList.indexOf('expand-icon') !== -1)) { + + this.toggleExpandedState(node, _default.options); + this.render(); + } + else if ((classList.indexOf('check-icon') !== -1)) { + + this.toggleCheckedState(node, _default.options); + this.render(); + } + else { + + if (node.selectable) { + this.toggleSelectedState(node, _default.options); + } else if (this.options.toggleUnselectable) { + this.toggleExpandedState(node, _default.options); + } + + this.render(); + } + }; + + // Looks up the DOM for the closest parent list item to retrieve the + // data attribute nodeid, which is used to lookup the node in the flattened structure. + Tree.prototype.findNode = function (target) { + + var nodeId = target.closest('li.list-group-item').attr('data-nodeid'); + var node = this.nodes[nodeId]; + + if (!node) { + console.log('Error: node does not exist'); + } + return node; + }; + + Tree.prototype.toggleExpandedState = function (node, options) { + if (!node) return; + this.setExpandedState(node, !node.state.expanded, options); + }; + + Tree.prototype.setExpandedState = function (node, state, options) { + + if (state === node.state.expanded) return; + + if (state && node.nodes) { + + // Expand a node + node.state.expanded = true; + if (!options.silent) { + this.$element.trigger('nodeExpanded', $.extend(true, {}, node)); + } + } + else if (!state) { + + // Collapse a node + node.state.expanded = false; + if (!options.silent) { + this.$element.trigger('nodeCollapsed', $.extend(true, {}, node)); + } + + // Collapse child nodes + if (node.nodes && !options.ignoreChildren) { + $.each(node.nodes, $.proxy(function (index, node) { + this.setExpandedState(node, false, options); + }, this)); + } + } + }; + + Tree.prototype.toggleSelectedState = function (node, options) { + if (!node) return; + this.setSelectedState(node, !node.state.selected, options); + }; + + Tree.prototype.setSelectedState = function (node, state, options) { + + if (state === node.state.selected) return; + + if (state) { + + // If multiSelect false, unselect previously selected + if (!this.options.multiSelect) { + $.each(this.findNodes('true', 'g', 'state.selected'), $.proxy(function (index, node) { + this.setSelectedState(node, false, options); + }, this)); + } + + // Continue selecting node + node.state.selected = true; + if (!options.silent) { + this.$element.trigger('nodeSelected', $.extend(true, {}, node)); + } + } + else { + + // Unselect node + node.state.selected = false; + if (!options.silent) { + this.$element.trigger('nodeUnselected', $.extend(true, {}, node)); + } + } + }; + + Tree.prototype.toggleCheckedState = function (node, options) { + if (!node) return; + this.setCheckedState(node, !node.state.checked, options); + }; + + Tree.prototype.setCheckedState = function (node, state, options) { + + if (state === node.state.checked) return; + + if (state) { + + // Check node + node.state.checked = true; + + if (!options.silent) { + this.$element.trigger('nodeChecked', $.extend(true, {}, node)); + } + } + else { + + // Uncheck node + node.state.checked = false; + if (!options.silent) { + this.$element.trigger('nodeUnchecked', $.extend(true, {}, node)); + } + } + }; + + Tree.prototype.setDisabledState = function (node, state, options) { + + if (state === node.state.disabled) return; + + if (state) { + + // Disable node + node.state.disabled = true; + + // Disable all other states + this.setExpandedState(node, false, options); + this.setSelectedState(node, false, options); + this.setCheckedState(node, false, options); + + if (!options.silent) { + this.$element.trigger('nodeDisabled', $.extend(true, {}, node)); + } + } + else { + + // Enabled node + node.state.disabled = false; + if (!options.silent) { + this.$element.trigger('nodeEnabled', $.extend(true, {}, node)); + } + } + }; + + Tree.prototype.render = function () { + + if (!this.initialized) { + + // Setup first time only components + this.$element.addClass(pluginName); + this.$wrapper = $(this.template.list); + + this.injectStyle(); + + this.initialized = true; + } + + this.$element.empty().append(this.$wrapper.empty()); + + // Build tree + this.buildTree(this.tree, 0); + }; + + // Starting from the root node, and recursing down the + // structure we build the tree one node at a time + Tree.prototype.buildTree = function (nodes, level) { + + if (!nodes) return; + level += 1; + + var _this = this; + $.each(nodes, function addNodes(id, node) { + + var treeItem = $(_this.template.item) + .addClass('node-' + _this.elementId) + .addClass(node.state.checked ? 'node-checked' : '') + .addClass(node.state.disabled ? 'node-disabled': '') + .addClass(node.state.selected ? 'node-selected' : '') + .addClass(node.searchResult ? 'search-result' : '') + .attr('data-nodeid', node.nodeId) + .attr('style', _this.buildStyleOverride(node)); + + // Add indent/spacer to mimic tree structure + for (var i = 0; i < (level - 1); i++) { + treeItem.append(_this.template.indent); + } + + // Add expand, collapse or empty spacer icons + var classList = []; + if (node.nodes) { + classList.push('expand-icon'); + if (node.state.expanded) { + classList.push(_this.options.collapseIcon); + } + else { + classList.push(_this.options.expandIcon); + } + } + else { + classList.push(_this.options.emptyIcon); + } + + treeItem + .append($(_this.template.icon) + .addClass(classList.join(' ')) + ); + + + // Add node icon + if (_this.options.showIcon) { + + var classList = ['node-icon']; + + classList.push(node.icon || _this.options.nodeIcon); + if (node.state.selected) { + classList.pop(); + classList.push(node.selectedIcon || _this.options.selectedIcon || + node.icon || _this.options.nodeIcon); + } + + treeItem + .append($(_this.template.icon) + .addClass(classList.join(' ')) + ); + } + + // Add check / unchecked icon + if (_this.options.showCheckbox) { + + var classList = ['check-icon']; + if (node.state.checked) { + classList.push(_this.options.checkedIcon); + } + else { + classList.push(_this.options.uncheckedIcon); + } + + treeItem + .append($(_this.template.icon) + .addClass(classList.join(' ')) + ); + } + + // Add text + if (_this.options.enableLinks) { + // Add hyperlink + treeItem + .append($(_this.template.link) + .attr('href', node.href) + .append(node.text) + ); + } + else { + // otherwise just text + treeItem + .append(node.text); + } + + // Add tags as badges + if (_this.options.showTags && node.tags) { + $.each(node.tags, function addTag(id, tag) { + treeItem + .append($(_this.template.badge) + .append(tag) + ); + }); + } + + // Add item to the tree + _this.$wrapper.append(treeItem); + + // Recursively add child ndoes + if (node.nodes && node.state.expanded && !node.state.disabled) { + return _this.buildTree(node.nodes, level); + } + }); + }; + + // Define any node level style override for + // 1. selectedNode + // 2. node|data assigned color overrides + Tree.prototype.buildStyleOverride = function (node) { + + if (node.state.disabled) return ''; + + var color = node.color; + var backColor = node.backColor; + + if (!node.selectable) { + if (this.options.unselectableColor) { + color = this.options.unselectableColor; + } + if (this.options.unselectableBackColor) { + backColor = this.options.unselectableBackColor; + } + } + + if (this.options.highlightSelected && node.state.selected) { + if (this.options.selectedColor) { + color = this.options.selectedColor; + } + if (this.options.selectedBackColor) { + backColor = this.options.selectedBackColor; + } + } + + if (this.options.highlightSearchResults && node.searchResult && !node.state.disabled) { + if (this.options.searchResultColor) { + color = this.options.searchResultColor; + } + if (this.options.searchResultBackColor) { + backColor = this.options.searchResultBackColor; + } + } + + return 'color:' + color + + ';background-color:' + backColor + ';'; + }; + + // Add inline style into head + Tree.prototype.injectStyle = function () { + + if (this.options.injectStyle && !document.getElementById(this.styleId)) { + $('').appendTo('head'); + } + }; + + // Construct trees style based on user options + Tree.prototype.buildStyle = function () { + + var style = '.node-' + this.elementId + '{'; + + if (this.options.color) { + style += 'color:' + this.options.color + ';'; + } + + if (this.options.backColor) { + style += 'background-color:' + this.options.backColor + ';'; + } + + if (!this.options.showBorder) { + style += 'border:none;'; + } + else if (this.options.borderColor) { + style += 'border:1px solid ' + this.options.borderColor + ';'; + } + style += '}'; + + if (this.options.onhoverColor) { + style += '.node-' + this.elementId + ':not(.node-disabled):hover{' + + 'background-color:' + this.options.onhoverColor + ';' + + '}'; + } + + return this.css + style; + }; + + Tree.prototype.template = { + list: '', + item: '
  • ', + indent: '', + icon: '', + link: '', + badge: '' + }; + + Tree.prototype.css = '.treeview .list-group-item{cursor:pointer}.treeview span.indent{margin-left:10px;margin-right:10px}.treeview span.icon{width:12px;margin-right:5px}.treeview .node-disabled{color:silver;cursor:not-allowed}' + + + /** + Returns a single node object that matches the given node id. + @param {Number} nodeId - A node's unique identifier + @return {Object} node - Matching node + */ + Tree.prototype.getNode = function (nodeId) { + return this.nodes[nodeId]; + }; + + /** + Returns the parent node of a given node, if valid otherwise returns undefined. + @param {Object|Number} identifier - A valid node or node id + @returns {Object} node - The parent node + */ + Tree.prototype.getParent = function (identifier) { + var node = this.identifyNode(identifier); + return this.nodes[node.parentId]; + }; + + /** + Returns an array of sibling nodes for a given node, if valid otherwise returns undefined. + @param {Object|Number} identifier - A valid node or node id + @returns {Array} nodes - Sibling nodes + */ + Tree.prototype.getSiblings = function (identifier) { + var node = this.identifyNode(identifier); + var parent = this.getParent(node); + var nodes = parent ? parent.nodes : this.tree; + return nodes.filter(function (obj) { + return obj.nodeId !== node.nodeId; + }); + }; + + /** + Returns an array of selected nodes. + @returns {Array} nodes - Selected nodes + */ + Tree.prototype.getSelected = function () { + return this.findNodes('true', 'g', 'state.selected'); + }; + + /** + Returns an array of unselected nodes. + @returns {Array} nodes - Unselected nodes + */ + Tree.prototype.getUnselected = function () { + return this.findNodes('false', 'g', 'state.selected'); + }; + + /** + Returns an array of expanded nodes. + @returns {Array} nodes - Expanded nodes + */ + Tree.prototype.getExpanded = function () { + return this.findNodes('true', 'g', 'state.expanded'); + }; + + /** + Returns an array of collapsed nodes. + @returns {Array} nodes - Collapsed nodes + */ + Tree.prototype.getCollapsed = function () { + return this.findNodes('false', 'g', 'state.expanded'); + }; + + /** + Returns an array of checked nodes. + @returns {Array} nodes - Checked nodes + */ + Tree.prototype.getChecked = function () { + return this.findNodes('true', 'g', 'state.checked'); + }; + + /** + Returns an array of unchecked nodes. + @returns {Array} nodes - Unchecked nodes + */ + Tree.prototype.getUnchecked = function () { + return this.findNodes('false', 'g', 'state.checked'); + }; + + /** + Returns an array of disabled nodes. + @returns {Array} nodes - Disabled nodes + */ + Tree.prototype.getDisabled = function () { + return this.findNodes('true', 'g', 'state.disabled'); + }; + + /** + Returns an array of enabled nodes. + @returns {Array} nodes - Enabled nodes + */ + Tree.prototype.getEnabled = function () { + return this.findNodes('false', 'g', 'state.disabled'); + }; + + + /** + Set a node state to selected + @param {Object|Number} identifiers - A valid node, node id or array of node identifiers + @param {optional Object} options + */ + Tree.prototype.selectNode = function (identifiers, options) { + this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) { + this.setSelectedState(node, true, options); + }, this)); + + this.render(); + }; + + /** + Set a node state to unselected + @param {Object|Number} identifiers - A valid node, node id or array of node identifiers + @param {optional Object} options + */ + Tree.prototype.unselectNode = function (identifiers, options) { + this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) { + this.setSelectedState(node, false, options); + }, this)); + + this.render(); + }; + + /** + Toggles a node selected state; selecting if unselected, unselecting if selected. + @param {Object|Number} identifiers - A valid node, node id or array of node identifiers + @param {optional Object} options + */ + Tree.prototype.toggleNodeSelected = function (identifiers, options) { + this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) { + this.toggleSelectedState(node, options); + }, this)); + + this.render(); + }; + + + /** + Collapse all tree nodes + @param {optional Object} options + */ + Tree.prototype.collapseAll = function (options) { + var identifiers = this.findNodes('true', 'g', 'state.expanded'); + this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) { + this.setExpandedState(node, false, options); + }, this)); + + this.render(); + }; + + /** + Collapse a given tree node + @param {Object|Number} identifiers - A valid node, node id or array of node identifiers + @param {optional Object} options + */ + Tree.prototype.collapseNode = function (identifiers, options) { + this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) { + this.setExpandedState(node, false, options); + }, this)); + + this.render(); + }; + + /** + Expand all tree nodes + @param {optional Object} options + */ + Tree.prototype.expandAll = function (options) { + options = $.extend({}, _default.options, options); + + if (options && options.levels) { + this.expandLevels(this.tree, options.levels, options); + } + else { + var identifiers = this.findNodes('false', 'g', 'state.expanded'); + this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) { + this.setExpandedState(node, true, options); + }, this)); + } + + this.render(); + }; + + /** + Expand a given tree node + @param {Object|Number} identifiers - A valid node, node id or array of node identifiers + @param {optional Object} options + */ + Tree.prototype.expandNode = function (identifiers, options) { + this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) { + this.setExpandedState(node, true, options); + if (node.nodes && (options && options.levels)) { + this.expandLevels(node.nodes, options.levels-1, options); + } + }, this)); + + this.render(); + }; + + Tree.prototype.expandLevels = function (nodes, level, options) { + options = $.extend({}, _default.options, options); + + $.each(nodes, $.proxy(function (index, node) { + this.setExpandedState(node, (level > 0) ? true : false, options); + if (node.nodes) { + this.expandLevels(node.nodes, level-1, options); + } + }, this)); + }; + + /** + Reveals a given tree node, expanding the tree from node to root. + @param {Object|Number|Array} identifiers - A valid node, node id or array of node identifiers + @param {optional Object} options + */ + Tree.prototype.revealNode = function (identifiers, options) { + this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) { + var parentNode = this.getParent(node); + while (parentNode) { + this.setExpandedState(parentNode, true, options); + parentNode = this.getParent(parentNode); + }; + }, this)); + + this.render(); + }; + + /** + Toggles a nodes expanded state; collapsing if expanded, expanding if collapsed. + @param {Object|Number} identifiers - A valid node, node id or array of node identifiers + @param {optional Object} options + */ + Tree.prototype.toggleNodeExpanded = function (identifiers, options) { + this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) { + this.toggleExpandedState(node, options); + }, this)); + + this.render(); + }; + + + /** + Check all tree nodes + @param {optional Object} options + */ + Tree.prototype.checkAll = function (options) { + var identifiers = this.findNodes('false', 'g', 'state.checked'); + this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) { + this.setCheckedState(node, true, options); + }, this)); + + this.render(); + }; + + /** + Check a given tree node + @param {Object|Number} identifiers - A valid node, node id or array of node identifiers + @param {optional Object} options + */ + Tree.prototype.checkNode = function (identifiers, options) { + this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) { + this.setCheckedState(node, true, options); + }, this)); + + this.render(); + }; + + /** + Uncheck all tree nodes + @param {optional Object} options + */ + Tree.prototype.uncheckAll = function (options) { + var identifiers = this.findNodes('true', 'g', 'state.checked'); + this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) { + this.setCheckedState(node, false, options); + }, this)); + + this.render(); + }; + + /** + Uncheck a given tree node + @param {Object|Number} identifiers - A valid node, node id or array of node identifiers + @param {optional Object} options + */ + Tree.prototype.uncheckNode = function (identifiers, options) { + this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) { + this.setCheckedState(node, false, options); + }, this)); + + this.render(); + }; + + /** + Toggles a nodes checked state; checking if unchecked, unchecking if checked. + @param {Object|Number} identifiers - A valid node, node id or array of node identifiers + @param {optional Object} options + */ + Tree.prototype.toggleNodeChecked = function (identifiers, options) { + this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) { + this.toggleCheckedState(node, options); + }, this)); + + this.render(); + }; + + + /** + Disable all tree nodes + @param {optional Object} options + */ + Tree.prototype.disableAll = function (options) { + var identifiers = this.findNodes('false', 'g', 'state.disabled'); + this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) { + this.setDisabledState(node, true, options); + }, this)); + + this.render(); + }; + + /** + Disable a given tree node + @param {Object|Number} identifiers - A valid node, node id or array of node identifiers + @param {optional Object} options + */ + Tree.prototype.disableNode = function (identifiers, options) { + this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) { + this.setDisabledState(node, true, options); + }, this)); + + this.render(); + }; + + /** + Enable all tree nodes + @param {optional Object} options + */ + Tree.prototype.enableAll = function (options) { + var identifiers = this.findNodes('true', 'g', 'state.disabled'); + this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) { + this.setDisabledState(node, false, options); + }, this)); + + this.render(); + }; + + /** + Enable a given tree node + @param {Object|Number} identifiers - A valid node, node id or array of node identifiers + @param {optional Object} options + */ + Tree.prototype.enableNode = function (identifiers, options) { + this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) { + this.setDisabledState(node, false, options); + }, this)); + + this.render(); + }; + + /** + Toggles a nodes disabled state; disabling is enabled, enabling if disabled. + @param {Object|Number} identifiers - A valid node, node id or array of node identifiers + @param {optional Object} options + */ + Tree.prototype.toggleNodeDisabled = function (identifiers, options) { + this.forEachIdentifier(identifiers, options, $.proxy(function (node, options) { + this.setDisabledState(node, !node.state.disabled, options); + }, this)); + + this.render(); + }; + + + /** + Common code for processing multiple identifiers + */ + Tree.prototype.forEachIdentifier = function (identifiers, options, callback) { + + options = $.extend({}, _default.options, options); + + if (!(identifiers instanceof Array)) { + identifiers = [identifiers]; + } + + $.each(identifiers, $.proxy(function (index, identifier) { + callback(this.identifyNode(identifier), options); + }, this)); + }; + + /* + Identifies a node from either a node id or object + */ + Tree.prototype.identifyNode = function (identifier) { + return ((typeof identifier) === 'number') ? + this.nodes[identifier] : + identifier; + }; + + /** + Searches the tree for nodes (text) that match given criteria + @param {String} pattern - A given string to match against + @param {optional Object} options - Search criteria options + @return {Array} nodes - Matching nodes + */ + Tree.prototype.search = function (pattern, options) { + options = $.extend({}, _default.searchOptions, options); + + this.clearSearch({ render: false }); + + var results = []; + if (pattern && pattern.length > 0) { + + if (options.exactMatch) { + pattern = '^' + pattern + '$'; + } + + var modifier = 'g'; + if (options.ignoreCase) { + modifier += 'i'; + } + + results = this.findNodes(pattern, modifier); + + // Add searchResult property to all matching nodes + // This will be used to apply custom styles + // and when identifying result to be cleared + $.each(results, function (index, node) { + node.searchResult = true; + }) + } + + // If revealResults, then render is triggered from revealNode + // otherwise we just call render. + if (options.revealResults) { + this.revealNode(results); + } + else { + this.render(); + } + + this.$element.trigger('searchComplete', $.extend(true, {}, results)); + + return results; + }; + + /** + Clears previous search results + */ + Tree.prototype.clearSearch = function (options) { + + options = $.extend({}, { render: true }, options); + + var results = $.each(this.findNodes('true', 'g', 'searchResult'), function (index, node) { + node.searchResult = false; + }); + + if (options.render) { + this.render(); + } + + this.$element.trigger('searchCleared', $.extend(true, {}, results)); + }; + + /** + Find nodes that match a given criteria + @param {String} pattern - A given string to match against + @param {optional String} modifier - Valid RegEx modifiers + @param {optional String} attribute - Attribute to compare pattern against + @return {Array} nodes - Nodes that match your criteria + */ + Tree.prototype.findNodes = function (pattern, modifier, attribute) { + + modifier = modifier || 'g'; + attribute = attribute || 'text'; + + var _this = this; + return $.grep(this.nodes, function (node) { + var val = _this.getNodeValue(node, attribute); + if (typeof val === 'string') { + return val.match(new RegExp(pattern, modifier)); + } + }); + }; + + /** + Recursive find for retrieving nested attributes values + All values are return as strings, unless invalid + @param {Object} obj - Typically a node, could be any object + @param {String} attr - Identifies an object property using dot notation + @return {String} value - Matching attributes string representation + */ + Tree.prototype.getNodeValue = function (obj, attr) { + var index = attr.indexOf('.'); + if (index > 0) { + var _obj = obj[attr.substring(0, index)]; + var _attr = attr.substring(index + 1, attr.length); + return this.getNodeValue(_obj, _attr); + } + else { + if (obj.hasOwnProperty(attr)) { + return obj[attr].toString(); + } + else { + return undefined; + } + } + }; + + var logError = function (message) { + if (window.console) { + window.console.error(message); + } + }; + + // Prevent against multiple instantiations, + // handle updates and method calls + $.fn[pluginName] = function (options, args) { + + var result; + + this.each(function () { + var _this = $.data(this, pluginName); + if (typeof options === 'string') { + if (!_this) { + logError('Not initialized, can not call method : ' + options); + } + else if (!$.isFunction(_this[options]) || options.charAt(0) === '_') { + logError('No such method : ' + options); + } + else { + if (!(args instanceof Array)) { + args = [ args ]; + } + result = _this[options].apply(_this, args); + } + } + else if (typeof options === 'boolean') { + result = _this; + } + else { + $.data(this, pluginName, new Tree(this, $.extend(true, {}, options))); + } + }); + + return result || this; + }; + +})(jQuery, window, document); diff -r 1bde2a1c1902 -r a4497eed4ff7 src/ztfy/myams/resources/js/ext/bootstrap-treeview.min.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ztfy/myams/resources/js/ext/bootstrap-treeview.min.js Mon Jun 04 12:32:38 2018 +0200 @@ -0,0 +1,1 @@ +!function(e,t,o,s){"use strict";var n={};n.settings={injectStyle:!0,levels:2,expandIcon:"glyphicon glyphicon-plus",collapseIcon:"glyphicon glyphicon-minus",emptyIcon:"glyphicon",nodeIcon:"",selectedIcon:"",checkedIcon:"glyphicon glyphicon-check",uncheckedIcon:"glyphicon glyphicon-unchecked",color:void 0,backColor:void 0,borderColor:void 0,onhoverColor:"#F5F5F5",selectedColor:"#FFFFFF",selectedBackColor:"#428bca",unselectableBackColor:void 0,searchResultColor:"#D9534F",searchResultBackColor:void 0,enableLinks:!1,highlightSelected:!0,highlightSearchResults:!0,showBorder:!0,showIcon:!0,showCheckbox:!1,showTags:!1,toggleUnselectable:!0,multiSelect:!1,onNodeChecked:void 0,onNodeCollapsed:void 0,onNodeDisabled:void 0,onNodeEnabled:void 0,onNodeExpanded:void 0,onNodeSelected:void 0,onNodeUnchecked:void 0,onNodeUnselected:void 0,onSearchComplete:void 0,onSearchCleared:void 0},n.options={silent:!1,ignoreChildren:!1},n.searchOptions={ignoreCase:!0,exactMatch:!1,revealResults:!0};var i=function(t,o){return this.$element=e(t),this.elementId=t.id,this.styleId=this.elementId+"-style",this.init(o),{options:this.options,init:e.proxy(this.init,this),remove:e.proxy(this.remove,this),getNode:e.proxy(this.getNode,this),getParent:e.proxy(this.getParent,this),getSiblings:e.proxy(this.getSiblings,this),getSelected:e.proxy(this.getSelected,this),getUnselected:e.proxy(this.getUnselected,this),getExpanded:e.proxy(this.getExpanded,this),getCollapsed:e.proxy(this.getCollapsed,this),getChecked:e.proxy(this.getChecked,this),getUnchecked:e.proxy(this.getUnchecked,this),getDisabled:e.proxy(this.getDisabled,this),getEnabled:e.proxy(this.getEnabled,this),selectNode:e.proxy(this.selectNode,this),unselectNode:e.proxy(this.unselectNode,this),toggleNodeSelected:e.proxy(this.toggleNodeSelected,this),collapseAll:e.proxy(this.collapseAll,this),collapseNode:e.proxy(this.collapseNode,this),expandAll:e.proxy(this.expandAll,this),expandNode:e.proxy(this.expandNode,this),toggleNodeExpanded:e.proxy(this.toggleNodeExpanded,this),revealNode:e.proxy(this.revealNode,this),checkAll:e.proxy(this.checkAll,this),checkNode:e.proxy(this.checkNode,this),uncheckAll:e.proxy(this.uncheckAll,this),uncheckNode:e.proxy(this.uncheckNode,this),toggleNodeChecked:e.proxy(this.toggleNodeChecked,this),disableAll:e.proxy(this.disableAll,this),disableNode:e.proxy(this.disableNode,this),enableAll:e.proxy(this.enableAll,this),enableNode:e.proxy(this.enableNode,this),toggleNodeDisabled:e.proxy(this.toggleNodeDisabled,this),search:e.proxy(this.search,this),clearSearch:e.proxy(this.clearSearch,this)}};i.prototype.init=function(t){this.tree=[],this.nodes=[],t.data&&("string"==typeof t.data&&(t.data=e.parseJSON(t.data)),this.tree=e.extend(!0,[],t.data),delete t.data),this.options=e.extend({},n.settings,t),this.destroy(),this.subscribeEvents(),this.setInitialStates({nodes:this.tree},0),this.render()},i.prototype.remove=function(){this.destroy(),e.removeData(this,"treeview"),e("#"+this.styleId).remove()},i.prototype.destroy=function(){this.initialized&&(this.$wrapper.remove(),this.$wrapper=null,this.unsubscribeEvents(),this.initialized=!1)},i.prototype.unsubscribeEvents=function(){this.$element.off("click"),this.$element.off("nodeChecked"),this.$element.off("nodeCollapsed"),this.$element.off("nodeDisabled"),this.$element.off("nodeEnabled"),this.$element.off("nodeExpanded"),this.$element.off("nodeSelected"),this.$element.off("nodeUnchecked"),this.$element.off("nodeUnselected"),this.$element.off("searchComplete"),this.$element.off("searchCleared")},i.prototype.subscribeEvents=function(){this.unsubscribeEvents(),this.$element.on("click",e.proxy(this.clickHandler,this)),"function"==typeof this.options.onNodeChecked&&this.$element.on("nodeChecked",this.options.onNodeChecked),"function"==typeof this.options.onNodeCollapsed&&this.$element.on("nodeCollapsed",this.options.onNodeCollapsed),"function"==typeof this.options.onNodeDisabled&&this.$element.on("nodeDisabled",this.options.onNodeDisabled),"function"==typeof this.options.onNodeEnabled&&this.$element.on("nodeEnabled",this.options.onNodeEnabled),"function"==typeof this.options.onNodeExpanded&&this.$element.on("nodeExpanded",this.options.onNodeExpanded),"function"==typeof this.options.onNodeSelected&&this.$element.on("nodeSelected",this.options.onNodeSelected),"function"==typeof this.options.onNodeUnchecked&&this.$element.on("nodeUnchecked",this.options.onNodeUnchecked),"function"==typeof this.options.onNodeUnselected&&this.$element.on("nodeUnselected",this.options.onNodeUnselected),"function"==typeof this.options.onSearchComplete&&this.$element.on("searchComplete",this.options.onSearchComplete),"function"==typeof this.options.onSearchCleared&&this.$element.on("searchCleared",this.options.onSearchCleared)},i.prototype.setInitialStates=function(t,o){if(t.nodes){o+=1;var s=t,n=this;e.each(t.nodes,function(e,t){t.nodeId=n.nodes.length,t.parentId=s.nodeId,t.hasOwnProperty("selectable")||(t.selectable=!0),t.state=t.state||{},t.state.hasOwnProperty("checked")||(t.state.checked=!1),t.state.hasOwnProperty("disabled")||(t.state.disabled=!1),t.state.hasOwnProperty("expanded")||(!t.state.disabled&&o0?t.state.expanded=!0:t.state.expanded=!1),t.state.hasOwnProperty("selected")||(t.state.selected=!1),n.nodes.push(t),t.nodes&&n.setInitialStates(t,o)})}},i.prototype.clickHandler=function(t){this.options.enableLinks||t.preventDefault();var o=e(t.target),s=this.findNode(o);if(s&&!s.state.disabled){var i=o.attr("class")?o.attr("class").split(" "):[];-1!==i.indexOf("expand-icon")?(this.toggleExpandedState(s,n.options),this.render()):-1!==i.indexOf("check-icon")?(this.toggleCheckedState(s,n.options),this.render()):(s.selectable?this.toggleSelectedState(s,n.options):this.options.toggleUnselectable&&this.toggleExpandedState(s,n.options),this.render())}},i.prototype.findNode=function(e){var t=e.closest("li.list-group-item").attr("data-nodeid"),o=this.nodes[t];return o||console.log("Error: node does not exist"),o},i.prototype.toggleExpandedState=function(e,t){e&&this.setExpandedState(e,!e.state.expanded,t)},i.prototype.setExpandedState=function(t,o,s){o!==t.state.expanded&&(o&&t.nodes?(t.state.expanded=!0,s.silent||this.$element.trigger("nodeExpanded",e.extend(!0,{},t))):o||(t.state.expanded=!1,s.silent||this.$element.trigger("nodeCollapsed",e.extend(!0,{},t)),t.nodes&&!s.ignoreChildren&&e.each(t.nodes,e.proxy(function(e,t){this.setExpandedState(t,!1,s)},this))))},i.prototype.toggleSelectedState=function(e,t){e&&this.setSelectedState(e,!e.state.selected,t)},i.prototype.setSelectedState=function(t,o,s){o!==t.state.selected&&(o?(this.options.multiSelect||e.each(this.findNodes("true","g","state.selected"),e.proxy(function(e,t){this.setSelectedState(t,!1,s)},this)),t.state.selected=!0,s.silent||this.$element.trigger("nodeSelected",e.extend(!0,{},t))):(t.state.selected=!1,s.silent||this.$element.trigger("nodeUnselected",e.extend(!0,{},t))))},i.prototype.toggleCheckedState=function(e,t){e&&this.setCheckedState(e,!e.state.checked,t)},i.prototype.setCheckedState=function(t,o,s){o!==t.state.checked&&(o?(t.state.checked=!0,s.silent||this.$element.trigger("nodeChecked",e.extend(!0,{},t))):(t.state.checked=!1,s.silent||this.$element.trigger("nodeUnchecked",e.extend(!0,{},t))))},i.prototype.setDisabledState=function(t,o,s){o!==t.state.disabled&&(o?(t.state.disabled=!0,this.setExpandedState(t,!1,s),this.setSelectedState(t,!1,s),this.setCheckedState(t,!1,s),s.silent||this.$element.trigger("nodeDisabled",e.extend(!0,{},t))):(t.state.disabled=!1,s.silent||this.$element.trigger("nodeEnabled",e.extend(!0,{},t))))},i.prototype.render=function(){this.initialized||(this.$element.addClass("treeview"),this.$wrapper=e(this.template.list),this.injectStyle(),this.initialized=!0),this.$element.empty().append(this.$wrapper.empty()),this.buildTree(this.tree,0)},i.prototype.buildTree=function(t,o){if(t){o+=1;var s=this;e.each(t,function(t,n){for(var i=e(s.template.item).addClass("node-"+s.elementId).addClass(n.state.checked?"node-checked":"").addClass(n.state.disabled?"node-disabled":"").addClass(n.state.selected?"node-selected":"").addClass(n.searchResult?"search-result":"").attr("data-nodeid",n.nodeId).attr("style",s.buildStyleOverride(n)),d=0;d '+this.buildStyle()+" ").appendTo("head")},i.prototype.buildStyle=function(){var e=".node-"+this.elementId+"{";return this.options.color&&(e+="color:"+this.options.color+";"),this.options.backColor&&(e+="background-color:"+this.options.backColor+";"),this.options.showBorder?this.options.borderColor&&(e+="border:1px solid "+this.options.borderColor+";"):e+="border:none;",e+="}",this.options.onhoverColor&&(e+=".node-"+this.elementId+":not(.node-disabled):hover{background-color:"+this.options.onhoverColor+";}"),this.css+e},i.prototype.template={list:'
      ',item:'
    • ',indent:'',icon:'',link:'',badge:''},i.prototype.css=".treeview .list-group-item{cursor:pointer}.treeview span.indent{margin-left:10px;margin-right:10px}.treeview span.icon{width:12px;margin-right:5px}.treeview .node-disabled{color:silver;cursor:not-allowed}",i.prototype.getNode=function(e){return this.nodes[e]},i.prototype.getParent=function(e){var t=this.identifyNode(e);return this.nodes[t.parentId]},i.prototype.getSiblings=function(e){var t=this.identifyNode(e),o=this.getParent(t);return(o?o.nodes:this.tree).filter(function(e){return e.nodeId!==t.nodeId})},i.prototype.getSelected=function(){return this.findNodes("true","g","state.selected")},i.prototype.getUnselected=function(){return this.findNodes("false","g","state.selected")},i.prototype.getExpanded=function(){return this.findNodes("true","g","state.expanded")},i.prototype.getCollapsed=function(){return this.findNodes("false","g","state.expanded")},i.prototype.getChecked=function(){return this.findNodes("true","g","state.checked")},i.prototype.getUnchecked=function(){return this.findNodes("false","g","state.checked")},i.prototype.getDisabled=function(){return this.findNodes("true","g","state.disabled")},i.prototype.getEnabled=function(){return this.findNodes("false","g","state.disabled")},i.prototype.selectNode=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.setSelectedState(e,!0,t)},this)),this.render()},i.prototype.unselectNode=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.setSelectedState(e,!1,t)},this)),this.render()},i.prototype.toggleNodeSelected=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.toggleSelectedState(e,t)},this)),this.render()},i.prototype.collapseAll=function(t){var o=this.findNodes("true","g","state.expanded");this.forEachIdentifier(o,t,e.proxy(function(e,t){this.setExpandedState(e,!1,t)},this)),this.render()},i.prototype.collapseNode=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.setExpandedState(e,!1,t)},this)),this.render()},i.prototype.expandAll=function(t){if((t=e.extend({},n.options,t))&&t.levels)this.expandLevels(this.tree,t.levels,t);else{var o=this.findNodes("false","g","state.expanded");this.forEachIdentifier(o,t,e.proxy(function(e,t){this.setExpandedState(e,!0,t)},this))}this.render()},i.prototype.expandNode=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.setExpandedState(e,!0,t),e.nodes&&t&&t.levels&&this.expandLevels(e.nodes,t.levels-1,t)},this)),this.render()},i.prototype.expandLevels=function(t,o,s){s=e.extend({},n.options,s),e.each(t,e.proxy(function(e,t){this.setExpandedState(t,o>0,s),t.nodes&&this.expandLevels(t.nodes,o-1,s)},this))},i.prototype.revealNode=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){for(var o=this.getParent(e);o;)this.setExpandedState(o,!0,t),o=this.getParent(o)},this)),this.render()},i.prototype.toggleNodeExpanded=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.toggleExpandedState(e,t)},this)),this.render()},i.prototype.checkAll=function(t){var o=this.findNodes("false","g","state.checked");this.forEachIdentifier(o,t,e.proxy(function(e,t){this.setCheckedState(e,!0,t)},this)),this.render()},i.prototype.checkNode=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.setCheckedState(e,!0,t)},this)),this.render()},i.prototype.uncheckAll=function(t){var o=this.findNodes("true","g","state.checked");this.forEachIdentifier(o,t,e.proxy(function(e,t){this.setCheckedState(e,!1,t)},this)),this.render()},i.prototype.uncheckNode=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.setCheckedState(e,!1,t)},this)),this.render()},i.prototype.toggleNodeChecked=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.toggleCheckedState(e,t)},this)),this.render()},i.prototype.disableAll=function(t){var o=this.findNodes("false","g","state.disabled");this.forEachIdentifier(o,t,e.proxy(function(e,t){this.setDisabledState(e,!0,t)},this)),this.render()},i.prototype.disableNode=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.setDisabledState(e,!0,t)},this)),this.render()},i.prototype.enableAll=function(t){var o=this.findNodes("true","g","state.disabled");this.forEachIdentifier(o,t,e.proxy(function(e,t){this.setDisabledState(e,!1,t)},this)),this.render()},i.prototype.enableNode=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.setDisabledState(e,!1,t)},this)),this.render()},i.prototype.toggleNodeDisabled=function(t,o){this.forEachIdentifier(t,o,e.proxy(function(e,t){this.setDisabledState(e,!e.state.disabled,t)},this)),this.render()},i.prototype.forEachIdentifier=function(t,o,s){o=e.extend({},n.options,o),t instanceof Array||(t=[t]),e.each(t,e.proxy(function(e,t){s(this.identifyNode(t),o)},this))},i.prototype.identifyNode=function(e){return"number"==typeof e?this.nodes[e]:e},i.prototype.search=function(t,o){o=e.extend({},n.searchOptions,o),this.clearSearch({render:!1});var s=[];if(t&&t.length>0){o.exactMatch&&(t="^"+t+"$");var i="g";o.ignoreCase&&(i+="i"),s=this.findNodes(t,i),e.each(s,function(e,t){t.searchResult=!0})}return o.revealResults?this.revealNode(s):this.render(),this.$element.trigger("searchComplete",e.extend(!0,{},s)),s},i.prototype.clearSearch=function(t){t=e.extend({},{render:!0},t);var o=e.each(this.findNodes("true","g","searchResult"),function(e,t){t.searchResult=!1});t.render&&this.render(),this.$element.trigger("searchCleared",e.extend(!0,{},o))},i.prototype.findNodes=function(t,o,s){o=o||"g",s=s||"text";var n=this;return e.grep(this.nodes,function(e){var i=n.getNodeValue(e,s);if("string"==typeof i)return i.match(new RegExp(t,o))})},i.prototype.getNodeValue=function(e,t){var o=t.indexOf(".");if(o>0){var s=e[t.substring(0,o)],n=t.substring(o+1,t.length);return this.getNodeValue(s,n)}return e.hasOwnProperty(t)?e[t].toString():void 0};var d=function(e){t.console&&t.console.error(e)};e.fn.treeview=function(t,o){var s;return this.each(function(){var n=e.data(this,"treeview");"string"==typeof t?n?e.isFunction(n[t])&&"_"!==t.charAt(0)?(o instanceof Array||(o=[o]),s=n[t].apply(n,o)):d("No such method : "+t):d("Not initialized, can not call method : "+t):"boolean"==typeof t?s=n:e.data(this,"treeview",new i(this,e.extend(!0,{},t)))}),s||this}}(jQuery,window,document); diff -r 1bde2a1c1902 -r a4497eed4ff7 src/ztfy/myams/resources/js/ext/jquery-dndupload.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ztfy/myams/resources/js/ext/jquery-dndupload.js Mon Jun 04 12:32:38 2018 +0200 @@ -0,0 +1,209 @@ +/* globals MyAMS */ + +(function($, globals) { + + 'use strict'; + + $.dndupload = { + defaults: { + action: 'upload-files', + fieldname: 'files', + autosubmit: true + } + }; + + var ams = MyAMS; + + var isAdvancedUpload = function() { + var div = document.createElement('div'); + return (('draggable' in div) || ('ondragstart' in div && 'ondrop' in div)) && ('FormData' in window) && ('FileReader' in window); + } (); + + // Initialize upload form + function init(input, settings) { + $(input).each(function() { + var widget = $(this); + if (widget.data('ams-dndupload-initialiazed')) { + return; + } + settings = $.extend(true, {}, $.dndupload.defaults, settings); + + var uploader = widget.get(0); + if (uploader.tagName !== 'FORM') { + widget.removeClass('dndupload') + .html('
      '.replace(/{action}/, settings.action)); + widget = $('form', widget); + } + var template = '
      \n' + + ' \n' + + ' \n' + + ' \n' + + ' \n'.replace(/{label}/, ams.plugins.i18n.dndupload.FILES_SELECTED) + + ' \n'.replace(/{label}/, ams.plugins.i18n.dndupload.DRAG_FILE) + + ' \n'.replace(/{label}/, ams.plugins.i18n.dndupload.UPLOAD) + + '
      \n' + + '
      {label}
      \n'.replace(/{label}/, ams.plugins.i18n.dndupload.UPLOADING) + + '
      {label}\n'.replace(/{label}/, ams.plugins.i18n.dndupload.DONE) + + ' {label}\n'.replace(/{label}/, ams.plugins.i18n.dndupload.UPLOAD_MORE) + + '
      \n' + + '
      {label}. \n'.replace(/{label}/, ams.plugins.i18n.dndupload.ERROR) + + ' {label}\n'.replace(/{label}/, ams.plugins.i18n.dndupload.TRY_AGAIN) + + '
      '; + widget.html(template); + + var form = widget, + input = form.find('input[type="file"]'), + label = form.find('label'), + error = form.find('.box__error span'), + restart = form.find('.box__restart'), + droppedFiles = false; + + var showFiles = function(files) { + label.text(files.length > 1 ? (input.attr('data-multiple-caption') || '').replace(/{count}/, files.length) : files[0].name); + }; + + input.on('change', function(ev) { + showFiles(ev.target.files); + if (settings.autosubmit) { + form.trigger('submit'); + } + }); + + if (isAdvancedUpload) { + form.addClass('has-advanced-upload') + .on('drag dragstart dragend dragover dragenter dragleave drop', function(ev) { + ev.preventDefault(); + ev.stopPropagation(); + }) + .on('dragover dragenter', function() { + form.addClass('is-dragover'); + }) + .on('dragleave dragend drop', function() { + form.removeClass('is-dragover'); + }) + .on('drop', function(ev) { + droppedFiles = ev.originalEvent.dataTransfer.files; + showFiles(droppedFiles); + if (settings.autosubmit) { + form.trigger('submit'); + } + }); + } + + form.on('submit', function(ev) { + if (form.hasClass('is-uploading')) { + return false; + } + form.addClass('is-uploading') + .removeClass('is-error'); + if (isAdvancedUpload) { + ev.preventDefault(); + var ajaxData = new FormData(form.get(0)); + if (droppedFiles) { + $.each(droppedFiles, function(i, file) { + ajaxData.append(input.attr('name'), file); + }); + } + $.ajax({ + url: form.attr('action'), + type: form.attr('method'), + data: ajaxData, + dataType: 'json', + cache: false, + contentType: false, + processData: false, + success: function(data) { + if (typeof(data) === 'string') { + data = JSON.parse(data); + } + ams.ajax.handleJSON(data); + }, + complete: function() { + form.removeClass('is-uploading'); + } + }); + } else { + var iframeName = 'uploadiframe_' + new Date().getTime(), + iframe = $('").hide().attr("name",F).appendTo(e("body"))),w=e.extend({},w,{iframe:!0,iframeTarget:T,success:function(a,t,n,s){if(e(s).parents(".modal-dialog").exists())i.dialog.close(s);else{var r,o=s.data("ams-submit-button");o&&(r=o.data("ams-form-submit-callback")),r||(r=i.getFunctionByName(g.amsFormSubmitCallback)||i.form._submitCallback);try{r.call(s,a,t,n,s)}finally{i.form.resetAfterSubmit(s),i.form.resetChanged(s)}}}})}else w=e.extend({},w,{error:function(e,a,t,n){C&&i.executeFunctionByName(g.amsFormSubmitError||"MyAMS.form.finalizeSubmitOnError",n,C),i.form.resetAfterSubmit(n)},success:function(e,a,t,n){var s,r=n.data("ams-submit-button");r&&(s=r.data("ams-form-submit-callback")),s||(s=i.getFunctionByName(g.amsFormSubmitCallback)||i.form._submitCallback);try{s.call(n,e,a,t,n)}finally{i.form.resetAfterSubmit(n),i.form.resetChanged(n)}},iframe:S});var N=e.extend({},w,r,b,s);if(u&&function(e,a){function n(){clearInterval(s),i.form.resetAfterSubmit(t,o),o.html(o.data("ams-progress-content")),i.executeFunctionByName(p,t,o),i.form.resetChanged(t)}var s;o.button("loading"),s=setInterval(function(){i.ajax.post(e,{progress_id:a},{error:n},i.getFunctionByName(h)||function(e,a){if("success"===a)if("running"===e.status)if(e.message)o.text(e.message);else{var t=o.data("ams-progress-text")||i.i18n.PROGRESS;e.current?t+=": "+e.current+"/ "+(e.length||100):t+="...",o.text(t)}else"finished"===e.status&&n();else n()})},f)}(u,d.progress_id),e(t).ajaxSubmit(N),F){var R=e(t).parents(".modal-dialog"),O=R.exists()&&o.exists()&&o.data("ams-keep-modal");R.exists()&&!0!==O?i.dialog.close(t):u||setTimeout(function(){i.form.resetAfterSubmit(t,o),i.form.resetChanged(t)},o.data("ams-form-reset-timeout")||2e3)}}if(!0!==t.data("ams-form-ignore-uploads")&&e('INPUT[type="file"]',t).length>0){i.ajax.check(e.progressBar,i.baseURL+"ext/jquery-progressbar"+i.devext+".js");var o=e.extend({},{uuid:e.progressBar.submit(t)});r(t,o)}else r(t,{})}),!1},initSubmit:function(a,t){var n=e(this),i='';t||(t=n.data("ams-form-submit-message")),t&&(i+=""+t+""),e(a).html('
      '+i+"
      "),e(a).parents(".hidden").removeClass("hidden")},resetAfterSubmit:function(e){if(e.is(":visible")){var a=e.data("ams-submit-button");a&&a.button("reset"),i.form.finalizeSubmitFooter.call(e)}e.data("submitted",!1),e.removeData("ams-submit-button")},finalizeSubmitOnError:function(a){e("i",a).removeClass("fa-spin").removeClass("fa-gear").addClass("fa-ambulance")},initSubmitFooter:function(a){var t=e(this),n='';a||(a=e(this).data("ams-form-submit-message")),a&&(n+=''+a+"");var i=e("footer",t);e("button",i).hide(),i.append('
      '+n+"
      ")},finalizeSubmitFooter:function(){var a=e(this),t=e("footer",a);t&&(e(".row",t).remove(),e("button",t).show())},_submitCallback:function(a,t,n,s){var r;s.is(":visible")&&(i.form.finalizeSubmitFooter.call(s),(r=s.data("ams-submit-button"))&&r.button("reset"));var o,c=s.data();if(c.amsFormDatatype)o=c.amsFormDatatype;else{var l=i.ajax.getResponse(n);o=l.contentType,a=l.data}var d;switch(d=e(r?r.data("ams-form-submit-target")||c.amsFormSubmitTarget||"#content":c.amsFormSubmitTarget||"#content"),o){case"json":i.ajax.handleJSON(a,s,d);break;case"script":case"xml":break;case"html":case"text":default:i.form.resetChanged(s),r&&!0!==r.data("ams-keep-modal")&&i.dialog.close(s),d.exists()||(d=e("body")),d.parents(".hidden").removeClass("hidden"),e(".alert",d.parents(".alerts-container")).remove(),d.css({opacity:"0.0"}).html(a).delay(50).animate({opacity:"1.0"},300),i.initContent(d),i.form.setFocus(d)}var m=n.getResponseHeader("X-AMS-Callback");if(m){var u=n.getResponseHeader("X-AMS-Callback-Options");i.executeFunctionByName(m,s,void 0===u?{}:JSON.parse(u),n)}},_getSubmitValidators:function(a){var t=[],n=a.data("ams-form-validator");return n&&t.push([a,n]),e("[data-ams-form-validator]",a).each(function(){var a=e(this);t.push([a,a.data("ams-form-validator")])}),t},_checkSubmitValidators:function(e){var a=i.form._getSubmitValidators(e);if(!a.length)return!0;for(var t=[],n=!0,s=0;s0&&(t=t.concat(n))}if(t.length>0){var d=1===t.length?i.i18n.ERROR_OCCURED:i.i18n.ERRORS_OCCURED;return i.skin.alert(e,"danger",d,t),!1}return n},showErrors:function(a,t){var n;if("string"==typeof t)i.skin.alert(a,"error",i.i18n.ERROR_OCCURED,t);else if(t instanceof Array)n=1===t.length?i.i18n.ERROR_OCCURED:i.i18n.ERRORS_OCCURED,i.skin.alert(a,"error",n,t);else{e(".state-error",a).removeClass("state-error"),n=t.error_header||(t.widgets&&t.widgets.length>1?i.i18n.ERRORS_OCCURED:i.i18n.ERROR_OCCURED);var s,r=[];if(t.messages)for(s=0;s"+o.header+"
      "+o.message):r.push(o.message||o)}if(t.widgets)for(s=0;s'+c.message+""),c.label&&r.push(c.label+" : "+c.message);var d=l.parents(".tab-pane").index()+1;if(d>0){var m=e(".nav-tabs",e(l).parents(".tabforms"));e("li:nth-child("+d+")",m).removeClassPrefix("state-").addClass("state-error"),e("li.state-error:first a",a).click()}}i.skin.alert(e("fieldset:first",a),t.error_level||"error",n,r,t.error_message)}}},n.dialog={_shown_callbacks:[],registerShownCallback:function(e,a){var t;a&&(t=a.objectOrParentWithClass("modal-dialog"));var n;t&&t.exists()?void 0===(n=t.data("shown-callbacks"))&&(n=[],t.data("shown-callbacks",n)):n=i.dialog._shown_callbacks,n.indexOf(e)<0&&n.push(e)},_hide_callbacks:[],registerHideCallback:function(e,a){var t;a&&(t=a.objectOrParentWithClass("modal-dialog"));var n;t&&t.exists()?void 0===(n=t.data("hide-callbacks"))&&(n=[],t.data("hide-callbacks",n)):n=i.dialog._hide_callbacks,n.indexOf(e)<0&&n.push(e)},open:function(a,t){i.ajax.check(e.fn.modalmanager,i.baseURL+"ext/bootstrap-modalmanager"+i.devext+".js",function(){i.ajax.check(e.fn.modal.defaults,i.baseURL+"ext/bootstrap-modal"+i.devext+".js",function(n){n&&(e(document).off("click.modal"),e.fn.modal.defaults.spinner=e.fn.modalmanager.defaults.spinner='
      ');var s,r;if("string"==typeof a)s={},r=a;else{s=a.data(),r=a.attr("href")||s.amsUrl;var o=i.getFunctionByName(r);"function"==typeof o&&(r=o.call(a))}r&&(e("body").modalmanager("loading"),0===r.indexOf("#")?e(r).modal("show"):e.ajax({url:r,type:"get",cache:void 0!==s.amsAllowCache&&s.amsAllowCache,data:t,success:function(t,n,o){e("body").modalmanager("removeLoading");var c=i.ajax.getResponse(o),l=c.contentType,d=c.data;switch(l){case"json":i.ajax.handleJSON(d,e(e(a).data("ams-json-target")||"#content"));break;case"script":case"xml":break;case"html":case"text":default:var m=e(d),u=e(".modal-dialog",m.wrap("
      ").parent()),f=u.data(),h={backdrop:"static",overflow:f.amsModalOverflow||".modal-viewport",maxHeight:void 0===f.amsModalMaxHeight?function(){return e(window).height()-e(".modal-header",m).outerHeight(!0)-e("footer",m).outerHeight(!0)-85}:i.getFunctionByName(f.amsModalMaxHeight)},p=e.extend({},h,f.amsModalOptions);p=i.executeFunctionByName(f.amsModalInitCallback,u,p)||p,e("
      ").addClass("modal fade").append(m).modal(p).on("shown",i.dialog.shown).on("hidden",i.dialog.hidden),i.initContent(m),!1!==s.amsLogEvent&&i.stats.logPageview(r)}}}))})})},shown:function(a){function t(a){var t=e(".scrollmarker.top",s),n=s.scrollTop();n>0?t.show():t.hide();var i=e(".scrollmarker.bottom",s);r+n>=s.get(0).scrollHeight?i.hide():i.show()}var n=a.target,s=e(".modal-viewport",n);if(s.exists()){var r=parseInt(s.css("max-height")),o=e.scrollbarWidth();"hidden"!==s.css("overflow")&&s.height()===r?(e("
      ").addClass("scrollmarker").addClass("top").css("top",0).css("width",s.width()-o).hide().appendTo(s),e("
      ").addClass("scrollmarker").addClass("bottom").css("top",r-20).css("width",s.width()-o).appendTo(s),s.scroll(t),s.off("resize").on("resize",t)):e(".scrollmarker",s).remove()}e("[data-ams-shown-callback]",n).each(function(){var a=i.getFunctionByName(e(this).data("ams-shown-callback"));a&&a.call(n,this)});var c,l=e(".modal-dialog",n).data("shown-callbacks");if(l)for(c=0;c=0&&t.hide()}},hidden:function(a){var t=a.target;i.skin.cleanContainer(t),e("[data-ams-hidden-callback]",t).each(function(){var a=i.getFunctionByName(e(this).data("ams-hidden-callback"));a&&a.call(t,this)});var n,s=e(".modal-dialog",t).data("hide-callbacks");if(s)for(n=0;n"+a.error_message+"",icon:"fa fa-warning animated shake",timeout:1e4});break;case"modal":e(this).data("select2").dropdown.hide(),i.dialog.open(a.location);break;default:return{results:a.results||a,more:a.has_more||!1,context:a.context}}},select2QueryMethodSuccessCallback:function(a,t,n){var s=a.result;if("string"==typeof s)try{s=JSON.parse(s)}catch(e){}switch(s.status){case"error":i.skin.messageBox("error",{title:i.i18n.ERROR_OCCURED,content:"

      "+s.error_message+"

      ",icon:"fa fa-warning animated shake",timeout:1e4});break;case"modal":e(this).data("select2").dropdown.hide(),i.dialog.open(s.location);break;default:n.callback({results:s.results||s,more:s.has_more||!1,context:s.context})}},contextMenuHandler:function(e,a){var t=a.data();if("modal"===t.toggle)i.dialog.open(a);else{var n=a.attr("href")||t.amsUrl;if(!n||n.startsWith("javascript")||a.attr("target"))return;i.event.stop();var s=i.getFunctionByName(n);"function"==typeof s&&(n=s.call(a,e)),"function"==typeof n?n.call(a,e):(n=n.replace(/\%23/,"#"),(e=a.data("ams-target"))?i.form.confirmChangedForm(e,function(){i.skin.loadURL(n,e,a.data("ams-link-options"),a.data("ams-link-callback"))}):i.form.confirmChangedForm(function(){n.startsWith("#")?n!==location.hash&&(i.root.hasClass("mobile-view-activated")?(i.root.removeClass("hidden-menu"),window.setTimeout(function(){window.location.hash=n},150)):window.location.hash=n):window.location=n}))}},datetimepickerDialogHiddenCallback:function(){e(".datepicker, .timepicker, .datetimepicker",this).datetimepicker("destroy")}},n.plugins={init:function(a){function t(e,a){if(o.hasOwnProperty(e)){var t=o[e];t.css=t.css||a.css,t.callbacks.push({callback:a.callback,context:a.context}),a.register&&(t.register=!0),!1===a.async&&(t.async=!1)}else o[e]={src:a.src,css:a.css,callbacks:[{callback:a.callback,context:a.context}],register:a.register,async:a.async};a.css&&i.getCSS(a.css,e+"_css")}function n(e){var t,n,s=c.callbacks;if(s&&s.length){for(t=0;t=0)){var d=i.plugins.enabled[l];if(d)switch(typeof d){case"function":d(a);break;default:for(var m=0;m=0)t&&t.warn&&t.warn("Plugin "+a+" is already registered!");else if("object"==typeof e){var s=e.src;s?i.ajax.check(e.callback,s,function(t){t&&(i.plugins.enabled[a]=i.getFunctionByName(e.callback),e.css&&i.getCSS(e.css,a+"_css"),n&&i.executeFunctionByName(n))}):(i.plugins.enabled[a]=i.getFunctionByName(e.callback),e.css&&i.getCSS(e.css,a+"_css"),n&&i.executeFunctionByName(n))}else"function"==typeof e&&(i.plugins.enabled[a]=e,n&&i.executeFunctionByName(n))},enabled:{hint:function(a){var t=e(".hint:not(:parents(.nohints))",a);t.length>0&&i.ajax.check(e.fn.tipsy,i.baseURL+"ext/jquery-tipsy"+i.devext+".js",function(){i.getCSS(i.baseURL+"../css/ext/jquery-tipsy"+i.devext+".css","jquery-tipsy"),t.each(function(){var a=e(this),t=a.data(),n={html:t.amsHintHtml,title:i.getFunctionByName(t.amsHintTitleGetter)||function(){var a=e(this),n=a.attr("original-title")||a.attr(t.amsHintTitleAttr||"title")||(t.amsHintHtml?a.html():a.text());return n=n.replace(/\?_="/,"?_="+(new Date).getTime()+'"')},opacity:t.amsHintOpacity||.95,gravity:t.amsHintGravity||"sw",offset:t.amsHintOffset||0},s=e.extend({},n,t.amsHintOptions);s=i.executeFunctionByName(t.amsHintInitCallback,a,s)||s;var r=a.tipsy(s);i.executeFunctionByName(t.amsHintAfterInitCallback,a,r,s)})})},contextMenu:function(a){var t=e(".context-menu",a);t.length>0&&t.each(function(){var a=e(this),t=a.data(),n={menuSelector:t.amsContextmenuSelector,menuSelected:i.helpers.contextMenuHandler},s=e.extend({},n,t.amsContextmenuOptions);s=i.executeFunctionByName(t.amsContextmenuInitCallback,a,s)||s;var r=a.contextMenu(s);i.executeFunctionByName(t.amsContextmenuAfterInitCallback,a,r,s)})},switcher:function(a){e("LEGEND.switcher",a).each(function(){var a=e(this),t=a.parent("fieldset"),n=a.data();n.amsSwitcher||(e('').prependTo(e(this)).addClass("open"===n.amsSwitcherState?n.amsSwitcherMinusClass||"fa-minus":n.amsSwitcherPlusClass||"fa-plus"),a.on("click",function(i){i.preventDefault();var s={};if(a.trigger("ams.switcher.before-switch",[a,s]),!s.veto)if(t.hasClass("switched")){t.removeClass("switched"),e(".fa",a).removeClass(n.amsSwitcherPlusClass||"fa-plus").addClass(n.amsSwitcherMinusClass||"fa-minus"),a.trigger("ams.switcher.opened",[a]);var r=a.attr("id");r&&e('legend.switcher[data-ams-switcher-sync="'+r+'"]',t).each(function(){var a=e(this);a.parents("fieldset").hasClass("switched")&&a.click()})}else t.addClass("switched"),e(".fa",a).removeClass(n.amsSwitcherMinusClass||"fa-minus").addClass(n.amsSwitcherPlusClass||"fa-plus"),a.trigger("ams.switcher.closed",[a])}),"open"!==n.amsSwitcherState&&t.addClass("switched"),a.data("ams-switcher","on"))})},checker:function(a){e("LEGEND.checker",a).each(function(){var a=e(this),t=a.parent("fieldset"),n=a.data();if(!n.amsChecker){var s=e(''),r=n.amsCheckerFieldname||"checker_"+i.generateId(),o=r.replace(/\./,"_"),c=n.amsCheckerHiddenPrefix,l=null,d=n.amsCheckerHiddenValueOn||"true",m=n.amsCheckerHiddenValueOff||"false",u=n.amsCheckerMarker||!1;c?l=e('').attr("name",c+r).val("on"===n.amsCheckerState?d:m).prependTo(a):u&&e('').attr("name",u).attr("value",1).prependTo(a);var f=e('').attr("name",r).attr("id",o).data("ams-checker-hidden-input",l).data("ams-checker-init",!0).val(n.amsCheckerValue||!0).attr("checked","on"===n.amsCheckerState?"checked":null);n.amsCheckerReadonly?f.attr("disabled","disabled"):f.on("change",function(s){s.preventDefault();var r={},o=e(this).is(":checked");if(a.trigger("ams.checker.before-switch",[a,r]),r.veto)e(this).prop("checked",!o);else if(i.executeFunctionByName(n.amsCheckerChangeHandler,a,o),!n.amsCheckerCancelDefault){var c=f.data("ams-checker-hidden-input");o?("disable"===n.amsCheckerMode?t.removeAttr("disabled"):t.removeClass("switched"),c&&c.val(d),e("[data-required]",t).attr("required","required"),a.trigger("ams.checker.opened",[a])):("disable"===n.amsCheckerMode?t.prop("disabled","disabled"):t.addClass("switched"),c&&c.val(m),e("[data-required]",t).removeAttr("required"),a.trigger("ams.checker.closed",[a]))}}),f.appendTo(s),e(">label",a).attr("for",f.attr("id")),s.append("").prependTo(a);var h=e("[required]",t);h.attr("data-required",!0),"on"===n.amsCheckerState?f.attr("checked",!0):("disable"===n.amsCheckerMode?t.attr("disabled","disabled"):t.addClass("switched"),h.removeAttr("required")),a.data("ams-checker","on")}})},slider:function(a){var t=e(".slider",a);t.length>0&&i.ajax.check(e.fn.slider,i.baseURL+"ext/bootstrap-slider-2.0.0"+i.devext+".js",function(){t.each(function(){var a=e(this),t=a.data(),n=e.extend({},{},a.data.amsSliderOptions);n=i.executeFunctionByName(t.amsSliderInitCallback,a,n)||n;var s=a.slider(n);i.executeFunctionByName(t.amsSliderAfterInitCallback,a,s,n)})})},draggable:function(a){var t=e(".draggable",a);t.length>0&&t.each(function(){var a=e(this),t=a.data(),n={containment:t.amsDraggableContainment,helper:i.getFunctionByName(t.amsDraggableHelper)||t.amsDraggableHelper,start:i.getFunctionByName(t.amsDraggableStart),stop:i.getFunctionByName(t.amsDraggableStop)},s=e.extend({},n,t.amsDraggableOptions);s=i.executeFunctionByName(t.amsDraggableInitCallback,a,s)||s;var r=a.draggable(s);a.disableSelection(),i.executeFunctionByName(t.amsDraggableAfterInitCallback,a,r,s)})},sortable:function(a){var t=e(".sortable",a);t.length>0&&t.each(function(){var a=e(this),t=a.data(),n={items:t.amsSortableItems,handle:t.amsSortableHandle,helper:t.amsSortableHelper,connectWith:t.amsSortableConnectwith,start:i.getFunctionByName(t.amsSortableStart),over:i.getFunctionByName(t.amsSortableOver),containment:t.amsSortableContainment,placeholder:t.amsSortablePlaceholder,stop:i.getFunctionByName(t.amsSortableStop)},s=e.extend({},n,t.amsSortableOptions);s=i.executeFunctionByName(t.amsSortableInitCallback,a,s)||s;var r=a.sortable(s);a.disableSelection(),i.executeFunctionByName(t.amsSortableAfterInitCallback,a,r,s)})},resizable:function(a){var t=e(".resizable",a);t.length>0&&t.each(function(){var a=e(this),t=a.data(),n={autoHide:!1===t.amsResizableAutohide||t.amsResizableAutohide,containment:t.amsResizableContainment,grid:t.amsResizableGrid,handles:t.amsResizableHandles,start:i.getFunctionByName(t.amsResizableStart),stop:i.getFunctionByName(t.amsResizableStop)},s=e.extend({},n,t.amsResizableOptions);s=i.executeFunctionByName(t.amsResizableInitCallback,a,s)||s;var r=a.resizable(s);a.disableSelection(),i.executeFunctionByName(t.amsResizableAfterInitCallback,a,r,s)})},typeahead:function(a){var t=e(".typeahead",a);t.length>0&&i.ajax.check(e.fn.typeahead,i.baseURL+"ext/jquery-typeahead"+i.devext+".js",function(){t.each(function(){var a=e(this),t=a.data(),n=e.extend({},{},t.amsTypeaheadOptions);n=i.executeFunctionByName(t.amsTypeaheadInitCallback,a,n)||n;var s=a.typeahead(n);i.executeFunctionByName(t.amsTypeaheadAfterInitCallback,a,s,n)})})},select2:function(a){var t=e(".select2",a);t.length>0&&i.ajax.check(e.fn.select2,i.baseURL+"ext/jquery-select2-3.5.2"+i.devext+".js",function(){t.each(function(){var a=e(this),t=a.data(),n={placeholder:t.amsSelect2Placeholder,multiple:t.amsSelect2Multiple,minimumInputLength:t.amsSelect2MinimumInputLength||0,maximumSelectionSize:t.amsSelect2MaximumSelectionSize,openOnEnter:void 0===t.amsSelect2EnterOpen||t.amsSelect2EnterOpen,allowClear:void 0===t.amsSelect2AllowClear||t.amsSelect2AllowClear,width:t.amsSelect2Width||"100%",initSelection:i.getFunctionByName(t.amsSelect2InitSelection),formatSelection:void 0===t.amsSelect2FormatSelection?i.helpers.select2FormatSelection:i.getFunctionByName(t.amsSelect2FormatSelection),formatResult:i.getFunctionByName(t.amsSelect2FormatResult),formatMatches:void 0===t.amsSelect2FormatMatches?function(e){return 1===e?i.i18n.SELECT2_MATCH:e+i.i18n.SELECT2_MATCHES}:i.getFunctionByName(t.amsSelect2FormatMatches),formatNoMatches:void 0===t.amsSelect2FormatResult?function(e){return i.i18n.SELECT2_NOMATCHES}:i.getFunctionByName(t.amsSelect2FormatResult),formatInputTooShort:void 0===t.amsSelect2FormatInputTooShort?function(e,a){var t=a-e.length;return i.i18n.SELECT2_INPUT_TOOSHORT.replace(/\{0\}/,t).replace(/\{1\}/,1===t?"":i.i18n.SELECT2_PLURAL)}:i.getFunctionByName(t.amsSelect2FormatInputTooShort),formatInputTooLong:void 0===t.amsSelect2FormatInputTooLong?function(e,a){var t=e.length-a;return i.i18n.SELECT2_INPUT_TOOLONG.replace(/\{0\}/,t).replace(/\{1\}/,1===t?"":i.i18n.SELECT2_PLURAL)}:i.getFunctionByName(t.amsSelect2FormatInputTooLong),formatSelectionTooBig:void 0===t.amsSelect2FormatSelectionTooBig?function(e){return i.i18n.SELECT2_SELECTION_TOOBIG.replace(/\{0\}/,e).replace(/\{1\}/,1===e?"":i.i18n.SELECT2_PLURAL)}:i.getFunctionByName(t.amsSelect2FormatSelectionTooBig),formatLoadMore:void 0===t.amsSelect2FormatLoadMore?function(e){return i.i18n.SELECT2_LOADMORE}:i.getFunctionByName(t.amsSelect2FormatLoadMore),formatSearching:void 0===t.amsSelect2FormatSearching?function(){return i.i18n.SELECT2_SEARCHING}:i.getFunctionByName(t.amsSelect2FormatSearching),separator:t.amsSelect2Separator||",",tokenSeparators:t.amsSelect2TokensSeparators||[","],tokenizer:i.getFunctionByName(t.amsSelect2Tokenizer)};switch(a.context.type){case"text":case"hidden":if(!n.initSelection){var s=a.data("ams-select2-values");s&&(n.initSelection=function(a,t){var i=[];e(a.val().split(n.separator)).each(function(){i.push({id:this,text:s[this]||this})}),t(i)})}}a.attr("readonly")?"hidden"===a.attr("type")&&(n.query=function(){return[]}):t.amsSelect2Query?(n.query=i.getFunctionByName(t.amsSelect2Query),n.minimumInputLength=t.amsSelect2MinimumInputLength||1):t.amsSelect2QueryUrl?(n.ajax={url:t.amsSelect2QueryUrl,quietMillis:t.amsSelect2QuietMillis||200,type:t.amsSelect2QueryType||"POST",dataType:t.amsSelect2QueryDatatype||"json",data:function(a,n,i){var s={};return s[t.amsSelect2QueryParamName||"query"]=a,s[t.amsSelect2PageParamName||"page"]=n,s[t.amsSelect2ContextParamName||"context"]=i,e.extend({},s,t.amsSelect2QueryOptions)},results:i.helpers.select2QueryUrlResultsCallback},n.minimumInputLength=t.amsSelect2MinimumInputLength||1):t.amsSelect2QueryMethod?(n.query=function(n){var s={url:t.amsSelect2MethodTarget||i.jsonrpc.getAddr(),type:t.amsSelect2MethodType||"POST",cache:!1,method:t.amsSelect2QueryMethod,params:t.amsSelect2QueryParams||{},success:function(e,t){return i.helpers.select2QueryMethodSuccessCallback.call(a,e,t,n)},error:i.error.show};s.params[t.amsSelect2QueryParamName||"query"]=n.term,s.params[t.amsSelect2PageParamName||"page"]=n.page,s.params[t.amsSelect2ContextParamName||"context"]=n.context,s=e.extend({},s,t.amsSelect2QueryOptions),s=i.executeFunctionByName(t.amsSelect2QueryInitCallback,a,s)||s,i.ajax.check(e.jsonRpc,i.baseURL+"ext/jquery-jsonrpc"+i.devext+".js",function(){e.jsonRpc(s)})},n.minimumInputLength=t.amsSelect2MinimumInputLength||1):t.amsSelect2Tags?n.tags=t.amsSelect2Tags:t.amsSelect2Data&&(n.data=t.amsSelect2Data),t.amsSelect2EnableFreeTags&&(n.createSearchChoice=function(e){return{id:e,text:(t.amsSelect2FreeTagsPrefix||i.i18n.SELECT2_FREETAG_PREFIX)+e}});var r=e.extend({},n,t.amsSelect2Options);r=i.executeFunctionByName(t.amsSelect2InitCallback,a,r)||r;var o=a.select2(r);i.executeFunctionByName(t.amsSelect2AfterInitCallback,a,o,r),a.hasClass("ordered")&&i.ajax.check(e.fn.select2Sortable,i.baseURL+"ext/jquery-select2-sortable"+i.devext+".js",function(){a.select2Sortable({bindOrder:"sortableStop"})}),a.on("change",function(){void 0!==e(a.get(0).form).data("validator")&&e(a).valid()})})})},maskedit:function(a){var t=e("[data-mask]",a);t.length>0&&i.ajax.check(e.fn.mask,i.baseURL+"ext/jquery-maskedinput-1.4.1"+i.devext+".js",function(){t.each(function(){var a=e(this),t=a.data(),n={placeholder:void 0===t.amsMaskeditPlaceholder?"X":t.amsMaskeditPlaceholder,complete:i.getFunctionByName(t.amsMaskeditComplete)},s=e.extend({},n,t.amsMaskeditOptions);s=i.executeFunctionByName(t.amsMaskeditInitCallback,a,s)||s;var r=a.mask(a.attr("data-mask"),s);i.executeFunctionByName(t.amsMaskeditAfterInitCallback,a,r,s)})})},inputmask:function(a){var t=e("[data-input-mask]",a);t.length>0&&i.ajax.check(e.fn.inputmask,i.baseURL+"ext/jquery-inputmask-bundle-3.2.8"+i.devext+".js",function(){t.each(function(){var a,t=e(this),n=t.data();a="object"==typeof n.inputMask?n.inputMask:{mask:n.inputMask.toString()};var s=e.extend({},a,n.amsInputmaskOptions);s=i.executeFunctionByName(n.amsInputmaskInitCallback,t,s)||s;var r=t.inputmask(s);i.executeFunctionByName(n.amsInputmaskAfterInitCallback,t,r,s)})})},datepicker:function(a){var t=e(".datepicker",a);t.length>0&&i.ajax.check(e.fn.datetimepicker,i.baseURL+"ext/jquery-datetimepicker"+i.devext+".js",function(a){a&&(i.getCSS(i.baseURL+"../css/ext/jquery-datetimepicker"+i.devext+".css","jquery-datetimepicker"),i.dialog.registerHideCallback(i.helpers.datetimepickerDialogHiddenCallback)),t.each(function(){var a=e(this),t=a.data(),n={lang:t.amsDatetimepickerLang||i.lang,format:t.amsDatetimepickerFormat||"d/m/y",datepicker:!0,dayOfWeekStart:1,timepicker:!1,closeOnDateSelect:void 0===t.amsDatetimepickerCloseOnSelect||t.amsDatetimepickerCloseOnSelect,weeks:t.amsDatetimepickerWeeks},s=e.extend({},n,t.amsDatetimepickerOptions);s=i.executeFunctionByName(t.amsDatetimepickerInitCallback,a,s)||s;var r=a.datetimepicker(s);i.executeFunctionByName(t.amsDatetimepickerAfterInitCallback,a,r,s)})})},datetimepicker:function(a){var t=e(".datetimepicker",a);t.length>0&&i.ajax.check(e.fn.datetimepicker,i.baseURL+"ext/jquery-datetimepicker"+i.devext+".js",function(a){a&&(i.getCSS(i.baseURL+"../css/ext/jquery-datetimepicker"+i.devext+".css","jquery-datetimepicker"),i.dialog.registerHideCallback(i.helpers.datetimepickerDialogHiddenCallback)),t.each(function(){var a=e(this),t=a.data(),n={lang:t.amsDatetimepickerLang||i.lang,format:t.amsDatetimepickerFormat||"d/m/y H:i",datepicker:!0,dayOfWeekStart:1,timepicker:!0,closeOnDateSelect:void 0===t.amsDatetimepickerCloseOnSelect||t.amsDatetimepickerCloseOnSelect,closeOnTimeSelect:void 0===t.amsDatetimepickerCloseOnSelect||t.amsDatetimepickerCloseOnSelect,weeks:t.amsDatetimepickerWeeks},s=e.extend({},n,t.amsDatetimepickerOptions);s=i.executeFunctionByName(t.amsDatetimepickerInitCallback,a,s)||s;var r=a.datetimepicker(s);i.executeFunctionByName(t.amsDatetimepickerAfterInitCallback,a,r,s)})})},timepicker:function(a){var t=e(".timepicker",a);t.length>0&&i.ajax.check(e.fn.datetimepicker,i.baseURL+"ext/jquery-datetimepicker"+i.devext+".js",function(a){a&&(i.getCSS(i.baseURL+"../css/ext/jquery-datetimepicker"+i.devext+".css","jquery-datetimepicker"),i.dialog.registerHideCallback(i.helpers.datetimepickerDialogHiddenCallback)),t.each(function(){var a=e(this),t=a.data(),n={lang:t.amsDatetimepickerLang||i.lang,format:t.amsDatetimepickerFormat||"H:i",datepicker:!1,timepicker:!0,closeOnTimeSelect:void 0===t.amsDatetimepickerCloseOnSelect||t.amsDatetimepickerCloseOnSelect},s=e.extend({},n,t.amsDatetimepickerOptions);s=i.executeFunctionByName(t.amsDatetimepickerInitCallback,a,s)||s;var r=a.datetimepicker(s);i.executeFunctionByName(t.amsDatetimepickerAfterInitCallback,a,r,s)})})},colorpicker:function(a){var t=e(".colorpicker",a);t.length>0&&i.ajax.check(e.fn.minicolors,i.baseURL+"ext/jquery-minicolors"+i.devext+".js",function(a){a&&i.getCSS(i.baseURL+"../css/ext/jquery-minicolors"+i.devext+".css","jquery-minicolors"),t.each(function(){var a=e(this),t=a.data(),n={position:t.amsColorpickerPosition||a.closest("label.input").data("ams-colorpicker-position")||"bottom left"},s=e.extend({},n,t.amsColorpickerOptions);s=i.executeFunctionByName(t.amsColorpickerInitCallback,a,s)||s;var r=a.minicolors(s);i.executeFunctionByName(t.amsDatetimepickerAfterInitCallback,a,r,s)})})},validate:function(a){var t=e("FORM:not([novalidate])",a);t.length>0&&i.ajax.check(e.fn.validate,i.baseURL+"ext/jquery-validate-1.11.1"+i.devext+".js",function(a){if(a&&(e.validator.setDefaults({highlight:function(a){e(a).closest(".form-group, label:not(:parents(.form-group))").addClass("state-error")},unhighlight:function(a){e(a).closest(".form-group, label:not(:parents(.form-group))").removeClass("state-error")},errorElement:"span",errorClass:"state-error",errorPlacement:function(e,a){var t=a.parents("label:first");t.length?e.insertAfter(t):e.insertAfter(a)}}),i.plugins.i18n)){for(var n in i.plugins.i18n.validate)if(i.plugins.i18n.validate.hasOwnProperty(n)){var s=i.plugins.i18n.validate[n];"string"==typeof s&&s.indexOf("{0}")>-1&&(i.plugins.i18n.validate[n]=e.validator.format(s))}e.extend(e.validator.messages,i.plugins.i18n.validate)}t.each(function(){var a=e(this),t=a.data(),n={ignore:null,submitHandler:void 0!==a.attr("data-async")?void 0===t.amsFormSubmitHandler?function(){return e(".state-error",a).removeClass("state-error"),i.ajax.check(e.fn.ajaxSubmit,i.baseURL+"ext/jquery-form-3.49"+i.devext+".js"),i.form.submit(a)}:i.getFunctionByName(t.amsFormSubmitHandler):void 0,invalidHandler:void 0!==a.attr("data-async")?void 0===t.amsFormInvalidHandler?function(t,n){e(".state-error",a).removeClass("state-error");for(var i=0;i0){var o=e(".nav-tabs",e(s.element).parents(".tabforms"));e("li:nth-child("+r+")",o).removeClassPrefix("state-").addClass("state-error"),e("li.state-error:first a",o).click()}}}:i.getFunctionByName(t.amsFormInvalidHandler):void 0};e("[data-ams-validate-rules]",a).each(function(a){0===a&&(n.rules={}),n.rules[e(this).attr("name")]=e(this).data("ams-validate-rules")});var s=e.extend({},n,t.amsValidateOptions);s=i.executeFunctionByName(t.amsValidateInitCallback,a,s)||s;var r=a.validate(s);i.executeFunctionByName(t.amsValidateAfterInitCallback,a,r,s)})})},datatable:function(a){var t=e(".datatable",a);t.length>0&&i.ajax.check(e.fn.dataTable,i.baseURL+"ext/jquery-dataTables-1.9.4"+i.devext+".js",function(a){i.ajax.check(e.fn.dataTableExt.oPagination.bootstrap_full,i.baseURL+"myams-dataTables"+i.devext+".js",function(){e(t).each(function(){var a,t=e(this),n=t.data(),s=(n.amsDatatableExtensions||"").split(/\s+/),r=n.amsDatatableSdom||"W"+(s.indexOf("colreorder")>=0||s.indexOf("colreorderwithresize")>=0?"R":"")+"<'dt-top-row'"+(s.indexOf("colvis")>=0?"C":"")+(!1===n.amsDatatablePagination||!1===n.amsDatatablePaginationSize?"":"L")+(!1===n.amsDatatableGlobalFilter?"":"F")+">r<'dt-wrapper't"+(s.indexOf("scroller")>=0?"S":"")+"><'dt-row dt-bottom-row'<'row'<'col-sm-6'"+(!1===n.amsDatatableInformation?"":"i")+"><'col-sm-6 text-right'p>>",o=n.amsDatatableSorting;if("string"==typeof o){var c=o.split(";");for(o=[],a=0;a=0,bPaginate:!1!==n.amsDatatablePagination,bInfo:!1!==n.amsDatatableInfo,bSort:!1!==n.amsDatatableSort,aaSorting:o,aoColumns:m.length>0?m:void 0,bDeferRender:!0,bAutoWidth:!1,iDisplayLength:n.amsDatatableDisplayLength||25,sPaginationType:n.amsDatatablePaginationType||"bootstrap_full",sDom:r,oLanguage:i.plugins.i18n.datatables,fnInitComplete:function(a,t){e(".ColVis_Button").addClass("btn btn-default btn-sm").html((i.plugins.i18n.datatables.sColumns||"Columns")+' ')}},b=e.extend({},g,n.amsDatatableOptions),v=[],x=[],y=[];if(s.length>0)for(a=0;a0)for(a=0;a0)for(a=0;a0&&i.ajax.check(e.fn.tableDnD,i.baseURL+"ext/jquery-tablednd"+i.devext+".js",function(a){t.each(function(){var a=e(this),t=a.data();t.amsTabledndDragHandle?e("tr",a).addClass("no-drag-handle"):e(a).on("mouseover","tr",function(){e(this.cells[0]).addClass("drag-handle")}).on("mouseout","tr",function(){e(this.cells[0]).removeClass("drag-handle")});var n={onDragClass:t.amsTabledndDragClass||"dragging-row",onDragStart:i.getFunctionByName(t.amsTabledndDragStart),dragHandle:t.amsTabledndDragHandle,scrollAmount:t.amsTabledndScrollAmount,onAllowDrop:t.amsTabledndAllowDrop,onDrop:i.getFunctionByName(t.amsTabledndDrop)||function(n,s){var r=t.amsTabledndDropTarget;if(r){e(s).data("ams-disabled-handlers","click");var o=[];e(n.rows).each(function(){var a=e(this).data("ams-element-name");a&&o.push(a)});var c=i.getFunctionByName(r);if("function"==typeof c)c.call(a,n,o);else{if(!r.startsWith(window.location.protocol)){var l=t.amsLocation;l&&(r=l+"/"+r)}i.ajax.post(r,{names:JSON.stringify(o)})}setTimeout(function(){e(s).removeData("ams-disabled-handlers")},50)}return!1}},s=e.extend({},n,t.amsTabledndOptions);s=i.executeFunctionByName(t.amsTabledndInitCallback,a,s)||s;var r=a.tableDnD(s);i.executeFunctionByName(t.amsTabledndAfterInitCallback,a,r,s)})})},wizard:function(a){var t=e(".wizard",a);t.length>0&&i.ajax.check(e.fn.bootstrapWizard,i.baseURL+"ext/bootstrap-wizard-1.4.2"+i.devext+".js",function(a){t.each(function(){var a=e(this),t=a.data(),n={withVisible:void 0===t.amsWizardWithVisible||t.amsWizardWithVisible,tabClass:t.amsWizardTabClass,firstSelector:t.amsWizardFirstSelector,previousSelector:t.amsWizardPreviousSelector,nextSelector:t.amsWizardNextSelector,lastSelector:t.amsWizardLastSelector,finishSelector:t.amsWizardFinishSelector,backSelector:t.amsWizardBackSelector,onInit:i.getFunctionByName(t.amsWizardInit),onShow:i.getFunctionByName(t.amsWizardShow),onNext:i.getFunctionByName(t.amsWizardNext),onPrevious:i.getFunctionByName(t.amsWizardPrevious),onFirst:i.getFunctionByName(t.amsWizardFirst),onLast:i.getFunctionByName(t.amsWizardLast),onBack:i.getFunctionByName(t.amsWizardBack),onFinish:i.getFunctionByName(t.amsWizardFinish),onTabChange:i.getFunctionByName(t.amsWizardTabChange),onTabClick:i.getFunctionByName(t.amsWizardTabClick),onTabShow:i.getFunctionByName(t.amsWizardTabShow)},s=e.extend({},n,t.amsWizardOptions);s=i.executeFunctionByName(t.amsWizardInitCallback,a,s)||s;var r=a.bootstrapWizard(s);i.executeFunctionByName(t.amsWizardAfterInitCallback,a,r,s)})})},tinymce:function(a){function t(){e(".tinymce",e(this)).each(function(){var a=tinymce.get(e(this).attr("id"));a&&a.remove()})}var n=e(".tinymce",a);if(n.length>0){var s=i.baseURL+"ext/tinymce"+(i.devmode?"/dev":"");i.ajax.check(window.tinymce,s+"/tinymce"+i.devext+".js",function(a){function r(){n.each(function(){var a=e(this),t=a.data(),n={theme:t.amsTinymceTheme||"modern",language:i.lang,plugins:["advlist autosave autolink lists link image charmap print preview hr anchor pagebreak","searchreplace wordcount visualblocks visualchars code fullscreen","insertdatetime media nonbreaking save table contextmenu directionality","emoticons paste textcolor colorpicker textpattern autoresize"],toolbar1:t.amsTinymceToolbar1||"undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent",toolbar2:t.amsTinymceToolbar2||"forecolor backcolor emoticons | charmap link image media | fullscreen preview print | code",content_css:t.amsTinymceContentCss,formats:t.amsTinymceFormats,style_formats:t.amsTinymceStyleFormats,block_formats:t.amsTinymceBlockFormats,valid_classes:t.amsTinymceValidClasses,image_advtab:!0,image_list:i.getFunctionByName(t.amsTinymceImageList)||t.amsTinymceImageList,image_class_list:t.amsTinymceImageClassList,link_list:i.getFunctionByName(t.amsTinymceLinkList)||t.amsTinymceLinkList,link_class_list:t.amsTinymceLinkClassList,height:50,min_height:50,autoresize_min_height:50,autoresize_max_height:500,resize:!0};if(t.amsTinymceExternalPlugins){var s=t.amsTinymceExternalPlugins.split(/\s+/);for(var r in s){var o=a.data("ams-tinymce-plugin-"+s[r]);tinymce.PluginManager.load(s[r],i.getSource(o))}}var c=e.extend({},n,t.amsTinymceOptions);c=i.executeFunctionByName(t.amsTinymceInitCallback,a,c)||c;var l=a.tinymce(c);i.executeFunctionByName(t.amsTinymceAfterInitCallback,a,l,c)})}a?i.getScript(s+"/jquery.tinymce"+i.devext+".js",function(){tinymce.baseURL=s,tinymce.suffix=i.devext,i.skin.registerCleanCallback(t),r()}):r()})}},imgareaselect:function(a){var t=e(".imgareaselect",a);t.length>0&&i.ajax.check(e.fn.imgAreaSelect,i.baseURL+"ext/jquery-imgareaselect-0.9.11-rc1"+i.devext+".js",function(a){a&&i.getCSS(i.baseURL+"../css/ext/jquery-imgareaselect"+i.devext+".css"),t.each(function(){var a=e(this),t=a.data(),n=t.amsImgareaselectParent?a.parents(t.amsImgareaselectParent):"body",s={instance:!0,handles:!0,parent:n,x1:t.amsImgareaselectX1||0,y1:t.amsImgareaselectY1||0,x2:t.amsImgareaselectX2||t.amsImgareaselectImageWidth,y2:t.amsImgareaselectY2||t.amsImgareaselectImageHeight,imageWidth:t.amsImgareaselectImageWidth,imageHeight:t.amsImgareaselectImageHeight,minWidth:128,minHeight:128,aspectRatio:t.amsImgareaselectRatio,onSelectEnd:i.getFunctionByName(t.amsImgareaselectSelectEnd)||function(a,i){var s=t.amsImgareaselectTargetField||"image_";e('input[name="'+s+'x1"]',n).val(i.x1),e('input[name="'+s+'y1"]',n).val(i.y1),e('input[name="'+s+'x2"]',n).val(i.x2),e('input[name="'+s+'y2"]',n).val(i.y2)}},r=e.extend({},s,t.amsImgareaselectOptions);r=i.executeFunctionByName(t.amsImgareaselectInitCallback,a,r)||r;var o=a.imgAreaSelect(r);i.executeFunctionByName(t.amsImgareaselectAfterInitCallback,a,o,r),setTimeout(function(){o.update()},250)})})},fancybox:function(a){var t=e(".fancybox",a);t.length>0&&i.ajax.check(e.fn.fancybox,i.baseURL+"ext/jquery-fancybox-2.1.5"+i.devext+".js",function(a){a&&i.getCSS(i.baseURL+"../css/ext/jquery-fancybox-2.1.5"+i.devext+".css"),t.each(function(){var a=e(this),t=a.data(),n=a;t.amsFancyboxElements&&(n=e(t.amsFancyboxElements,a));var s=(t.amsFancyboxHelpers||"").split(/\s+/);if(s.length>0)for(var r=0;r0)for(r=0;r0&&i.ajax.check(i.graphs,i.baseURL+"myams-graphs"+i.devext+".js",function(){i.graphs.init(t)})},scrollbars:function(a){var t=e(".scrollbar",a);t.length>0&&i.ajax.check(e.event.special.mousewheel,i.baseURL+"ext/jquery-mousewheel.min.js",function(){i.ajax.check(e.fn.mCustomScrollbar,i.baseURL+"ext/jquery-mCustomScrollbar"+i.devext+".js",function(a){a&&i.getCSS(i.baseURL+"../css/ext/jquery-mCustomScrollbar.css","jquery-mCustomScrollbar"),t.each(function(){var a=e(this),t=a.data(),n={theme:t.amsScrollbarTheme||"light"},s=e.extend({},n,t.amsScrollbarOptions);s=i.executeFunctionByName(t.amsScrollbarInitCallback,a,s)||s;var r=a.mCustomScrollbar(s);i.executeFunctionByName(t.amsScrollbarAfterInitCallback,a,r,s)})})})}}},n.callbacks={init:function(a){e("[data-ams-callback]",a).each(function(){var a=this,n=e(a).data(),s=i.getFunctionByName(n.amsCallback);void 0===s?n.amsCallbackSource?i.getScript(n.amsCallbackSource,function(){i.executeFunctionByName(n.amsCallback,a,n.amsCallbackOptions)}):t&&t.warn&&t.warn("Undefined callback: "+n.amsCallback):s.call(a,n.amsCallbackOptions)})},alert:function(a){var t=e(this).data(),n=e.extend({},a,t.amsAlertOptions),s=e(t.amsAlertParent||n.parent||this),r=t.amsAlertStatus||n.status||"info",o=t.amsAlertHeader||n.header,c=t.amsAlertMessage||n.message,l=t.amsAlertSubtitle||n.subtitle,d=void 0===t.amsAlertMargin?void 0!==n.margin&&n.margin:t.amsAlertMargin;i.skin.alert(s,r,o,c,l,d)},messageBox:function(a){var t=e(this).data(),n=e.extend({},a,t.amsMessageboxOptions),s=e.extend({},n,{title:t.amsMessageboxTitle||n.title||"",content:t.amsMessageboxContent||n.content||"",icon:t.amsMessageboxIcon||n.icon,number:t.amsMessageboxNumber||n.number,timeout:t.amsMessageboxTimeout||n.timeout}),r=t.amsMessageboxStatus||n.status||"info",o=i.getFunctionByName(t.amsMessageboxCallback||n.callback);i.skin.messageBox(r,s,o)},smallBox:function(a){var t=e(this).data(),n=e.extend({},a,t.amsSmallboxOptions),s=e.extend({},n,{title:t.amsSmallboxTitle||n.title||"",content:t.amsSmallboxContent||n.content||"",icon:t.amsSmallboxIcon||n.icon,iconSmall:t.amsSmallboxIconSmall||n.iconSmall,timeout:t.amsSmallboxTimeout||n.timeout}),r=t.amsSmallboxStatus||n.status||"info",o=i.getFunctionByName(t.amsSmallboxCallback||n.callback);i.skin.smallBox(r,s,o)}},n.events={init:function(a){e("[data-ams-events-handlers]",a).each(function(){var a=e(this),t=a.data("ams-events-handlers");if(t)for(var n in t)t.hasOwnProperty(n)&&a.on(n,i.getFunctionByName(t[n]))})}},n.container={changeOrder:function(a,t){e('input[name="'+e(this).data("ams-input-name")+'"]',e(this)).val(t.join(";"))},deleteElement:function(a){return function(){var a=e(this);n.skin.bigBox({title:i.i18n.WARNING,content:'  '+i.i18n.DELETE_WARNING,status:"info",buttons:i.i18n.BTN_OK_CANCEL},function(e){if(e===i.i18n.BTN_OK){var t=a.parents("table").first(),s=t.data("ams-location")||"",r=a.parents("tr").first(),o=r.data("ams-delete-target")||t.data("ams-delete-target")||"delete-element.json",c=r.data("ams-element-name");n.ajax.post(s+"/"+o,{object_name:c},function(e,a){"success"===e.status?(t.hasClass("datatable")?t.dataTable().fnDeleteRow(r[0]):r.remove(),e.handle_json&&n.ajax.handleJSON(e)):n.ajax.handleJSON(e)})}})}}},n.skin={_setPageHeight:function(){var a=e("#main").height(),t=(i.leftPanel.height(),e(window).height()-i.navbarHeight);a>t?i.root.css("min-height",a+i.navbarHeight):i.root.css("min-height",t),i.leftPanel.css("min-height",t),i.leftPanel.css("max-height",t)},_checkMobileWidth:function(){e(window).width()<979?i.root.addClass("mobile-view-activated"):i.root.hasClass("mobile-view-activated")&&i.root.removeClass("mobile-view-activated")},_showShortcutButtons:function(){i.shortcuts.animate({height:"show"},200,"easeOutCirc"),i.root.addClass("shortcut-on")},_hideShortcutButtons:function(){i.shortcuts.animate({height:"hide"},300,"easeOutCirc"),i.root.removeClass("shortcut-on")},checkNotification:function(){var a=e("#activity > .badge");parseInt(a.text())>0?a.removeClass("hidden").addClass("bg-color-red bounceIn animated"):a.addClass("hidden").removeClass("bg-color-red bounceIn animated")},refreshNotificationsPanel:function(a){var t=e(this);t.addClass("disabled"),e("i",t).addClass("fa-spin"),e('input[name="activity"]:checked',"#user-activity").change(),e("i",t).removeClass("fa-spin"),t.removeClass("disabled")},_initDesktopWidgets:function(t){if(i.enableWidgets){var n=e(".ams-widget",t);n.length>0&&i.ajax.check(e.fn.MyAMSWidget,i.baseURL+"myams-widgets"+i.devext+".js",function(){n.each(function(){var a=e(this),t=a.data(),n=e.extend({},{deleteSettingsKey:"#deletesettingskey-options",deletePositionKey:"#deletepositionkey-options"},t.amsWidgetOptions);n=i.executeFunctionByName(t.amsWidgetInitcallback,a,n)||n,a.MyAMSWidget(n)}),a.MyAMSWidget.initWidgetsGrid(e(".ams-widget-grid",t))})}},_initMobileWidgets:function(e){i.enableMobile&&i.enableWidgets&&i.skin._initDesktopWidgets(e)},alert:function(a,t,n,s,r,o){"error"===t&&(t="danger"),e(".alert-"+t,a).not(".persistent").remove();var c='

      '+n+"

      "+(r?"

      "+r+"

      ":"");if("string"==typeof s)c+="
      • "+s+"
      ";else if(s){c+="
        ";for(var l in s)e.isNumeric(l)&&(c+="
      • "+s[l]+"
      • ");c+="
      "}e(c+="
      ").prependTo(a);a.exists&&i.ajax.check(e.scrollTo,i.baseURL+"ext/jquery-scrollTo.min.js",function(){e.scrollTo(a,{offset:{top:-50}})})},bigBox:function(e,a){i.ajax.check(i.notify,i.baseURL+"myams-notify"+i.devext+".js",function(){i.notify.messageBox(e,a)})},messageBox:function(e,a,t){"object"==typeof e&&(t=a,a=e||{},e="info"),i.ajax.check(i.notify,i.baseURL+"myams-notify"+i.devext+".js",function(){switch(e){case"error":case"danger":a.color="#C46A69";break;case"warning":a.color="#C79121";break;case"success":a.color="#739E73";break;default:a.color=a.color||"#3276B1"}a.sound=!1,i.notify.bigBox(a,t)})},smallBox:function(e,a,t){"object"==typeof e&&(t=a,a=e||{},e="info"),i.ajax.check(i.notify,i.baseURL+"myams-notify"+i.devext+".js",function(){switch(e){case"error":case"danger":a.color="#C46A69";break;case"warning":a.color="#C79121";break;case"success":a.color="#739E73";break;default:a.color=a.color||"#3276B1"}a.sound=!1,i.notify.smallBox(a,t)})},_drawBreadCrumb:function(){var a=e("OL.breadcrumb","#ribbon");e("li",a).not(".parent").remove(),e("li",a).exists()||a.append(e("
    • ").append(e("").text(i.i18n.HOME).addClass("padding-right-5").attr("href",e('nav a[href!="#"]:first').attr("href")))),e("LI.active >A","nav").each(function(){var t=e(this),n=e.trim(t.clone().children(".badge").remove().end().text()),i=e("
    • ").append(t.attr("href").replace(/^#/,"")?e("").html(n).attr("href",t.attr("href")):n);a.append(i)})},checkURL:function(){function a(a){e(".active",n).removeClass("active"),a.addClass("open").addClass("active"),a.parents("li").addClass("open active").children("ul").addClass("active").show(),a.parents("li:first").removeClass("open"),a.parents("ul").addClass(a.attr("href").replace(/^#/,"")?"active":"").show()}var t,n=e("nav"),s=location.hash,r=s.replace(/^#/,"");if(r){var o=e("#content");o.exists()||(o=e("body")),(t=e('A[href="'+s+'"]',n)).exists()&&a(t),i.skin.loadURL(r,o,{afterLoadCallback:function(){var a=e("html head title").data("ams-title-prefix");document.title=(a?a+" > ":"")+(e("[data-ams-page-title]:first",o).data("ams-page-title")||t.attr("title")||document.title)}})}else{var c=e("[data-ams-active-menu]").data("ams-active-menu");(t=c?e('A[href="'+c+'"]',n):e('>UL >LI >A[href!="#"]',n).first()).exists()&&(a(t),c?i.skin._drawBreadCrumb():window.location.hash=t.attr("href"))}},_clean_callbacks:[],registerCleanCallback:function(e){var a=i.skin._clean_callbacks;a.indexOf(e)<0&&a.push(e)},unregisterCleanCallback:function(e){var a=i.skin._clean_callbacks,t=a.indexOf(e);t>=0&&a.splice(t,1)},cleanContainer:function(e){for(var a=i.skin._clean_callbacks,t=0;t '+i.i18n.LOADING+" "),t[0]===e("#content")[0]){i.skin._drawBreadCrumb();var a=e("html head title").data("ams-title-prefix");document.title=(a?a+" > ":"")+e(".breadcrumb LI:last-child").text(),e("html, body").animate({scrollTop:0},"fast")}else t.animate({scrollTop:0},"fast")},success:function(a,r,o){if(s)i.executeFunctionByName(s,this,a,r,o,n);else{var c=i.ajax.getResponse(o),l=c.contentType,d=c.data;switch(e(".loading",t).remove(),l){case"json":i.ajax.handleJSON(d,t);break;case"script":case"xml":break;case"html":case"text":default:t.parents(".hidden").removeClass("hidden"),e(".alert",t.parents(".alerts-container")).remove(),t.css({opacity:"0.0"}).html(a).removeClass("hidden").delay(50).animate({opacity:"1.0"},300),i.initContent(t),i.form.setFocus(t)}n&&n.afterLoadCallback&&i.executeFunctionByName(n.afterLoadCallback,this),i.stats.logPageview()}},error:function(e,a,n){t.html('

      '+i.i18n.ERROR+n+"

      "+e.responseText)},async:void 0===n.async||n.async},o=e.extend({},r,n);e.ajax(o)},setLanguage:function(e){var a=e.lang;switch(e.handler_type||"json"){case"json":var t=e.method||"setUserLanguage";i.jsonrpc.post(t,{lang:a},function(){window.location.reload(!0)});break;case"ajax":var n=e.href||"setUserLanguage";i.ajax.post(n,{lang:a},function(){window.location.reload(!0)})}},logout:function(){window.location=i.loginURL}},n.stats={logPageview:function(e){if(void 0!==a._gaq){var t=a.window.location;a._gaq.push(["_trackPageview",e||t.pathname+t.hash])}},logEvent:function(e,t,n){void 0!==a._gaq&&("object"==typeof e&&(t=e.action,n=e.label,e=e.category),a._gaq.push(["_trackEvent",e,t,n]))}},n.initPage=function(){var a=e("body");i.root=a,i.leftPanel=e("#left-panel"),i.shortcuts=e("#shortcut"),i.plugins.initData(a);var t=e.ajaxSettings.xhr;e.ajaxSetup({progress:i.ajax.progress,progressUpload:i.ajax.progress,xhr:function(){var e=t();if(e&&"function"==typeof e.addEventListener){var a=this;a&&a.progress&&e.addEventListener("progress",function(e){a.progress(e)},!1)}return e}}),e(document).ajaxStart(i.ajax.start),e(document).ajaxStop(i.ajax.stop),e(document).ajaxError(i.error.ajax),i.isMobile?(i.root.addClass("mobile-detected"),i.device="mobile",i.enableFastclick&&i.ajax.check(e.fn.noClickDelay,i.baseURL+"/ext/jquery-smartclick"+i.devext+".js",function(){e("NAV UL A").noClickDelay(),e("A","#hide-menu").noClickDelay()})):(i.root.addClass("desktop-detected"),i.device="desktop"),e("#hide-menu >:first-child > A").click(function(e){a.toggleClass("hidden-menu"),e.preventDefault()}),e("#show-shortcut").click(function(e){i.shortcuts.is(":visible")?i.skin._hideShortcutButtons():i.skin._showShortcutButtons(),e.preventDefault()}),i.shortcuts.click(function(e){i.skin._hideShortcutButtons()}),e(document).mouseup(function(e){i.shortcuts.is(e.target)||0!==i.shortcuts.has(e.target).length||i.skin._hideShortcutButtons()}),e("#search-mobile").click(function(){i.root.addClass("search-mobile")}),e("#cancel-search-js").click(function(){i.root.removeClass("search-mobile")}),e("#activity").click(function(a){var t=e(this),n=t.next(".ajax-dropdown");n.is(":visible")?(n.fadeOut(150),t.removeClass("active")):(n.css("left",t.position().left-n.innerWidth()/2+t.innerWidth()/2).fadeIn(150),t.addClass("active")),a.preventDefault()}),i.skin.checkNotification(),e(document).mouseup(function(a){var t=e(".ajax-dropdown");t.is(a.target)||0!==t.has(a.target).length||t.fadeOut(150).prev().removeClass("active")}),e('input[name="activity"]').change(function(a){var t=e(this).data("ams-url");if(t){a.preventDefault(),a.stopPropagation();var n=i.getFunctionByName(t);if("function"==typeof n&&(t=n.call(this)),"function"==typeof t)t.call(this);else{var s=e(".ajax-notifications");i.skin.loadURL(t,s)}}}),e("a","#logout").click(function(a){a.preventDefault(),a.stopPropagation(),i.loginURL=e(this).attr("href"),i.skin.bigBox({title:" "+i.i18n.LOGOUT+" "+e("#show-shortcut").text()+" ?",content:i.i18n.LOGOUT_COMMENT,buttons:i.i18n.BTN_YES_NO},function(e){e===i.i18n.BTN_YES&&(i.root.addClass("animated fadeOutUp"),setTimeout(i.skin.logout,1e3))})});var n=e("nav");e("UL",n).myams_menu({accordion:!1!==n.data("ams-menu-accordion"),speed:i.menuSpeed}),e(".minifyme").click(function(a){e("BODY").toggleClass("minified"),e(this).effect("highlight",{},500),a.preventDefault()}),e("#refresh").click(function(e){i.skin.bigBox({title:" "+i.i18n.CLEAR_STORAGE_TITLE,content:i.i18n.CLEAR_STORAGE_CONTENT,buttons:"["+i.i18n.BTN_CANCEL+"]["+i.i18n.BTN_OK+"]"},function(e){e===i.i18n.BTN_OK&&localStorage&&(localStorage.clear(),location.reload())}),e.preventDefault()}),a.on("click",function(a){var t=e(this);t.is(a.target)||0!==t.has(a.target).length||0!==e(".popover").has(a.target).length||t.popover("hide")}),i.ajax.check(e.resize,i.baseURL+"ext/jquery-resize"+i.devext+".js",function(){e("#main").resize(function(){i.skin._setPageHeight(),i.skin._checkMobileWidth()}),n.resize(function(){i.skin._setPageHeight()})}),i.ajaxNav&&(e(document).on("click",'a[href="#"]',function(e){e.preventDefault()}),e(document).on("click",'a[href!="#"]:not([data-toggle]), [data-ams-url]:not([data-toggle])',function(a){var t=e(a.currentTarget),n=t.data("ams-disabled-handlers");if(!0!==n&&"click"!==n&&"all"!==n){var s=t.attr("href")||t.data("ams-url");if(s&&!s.startsWith("javascript")&&!t.attr("target")&&!0!==t.data("ams-context-menu")){a.preventDefault(),a.stopPropagation();var r=i.getFunctionByName(s);if("function"==typeof r&&(s=r.call(t)),"function"==typeof s)s.call(t);else if(s=s.replace(/\%23/,"#"),a.ctrlKey)window.open(s);else{var o=t.data("ams-target");o?i.form.confirmChangedForm(o,function(){i.skin.loadURL(s,o,t.data("ams-link-options"),t.data("ams-link-callback"))}):i.form.confirmChangedForm(function(){s.startsWith("#")?s!==location.hash&&(i.root.hasClass("mobile-view-activated")?(i.root.removeClass("hidden-menu"),window.setTimeout(function(){window.location.hash=s},50)):window.location.hash=s):window.location=s})}}}}),e(document).on("click",'a[target="_blank"]',function(a){a.preventDefault();var t=e(a.currentTarget);window.open(t.attr("href")),i.stats.logEvent(t.data("ams-stats-category")||"Navigation",t.data("ams-stats-action")||"External",t.data("ams-stats-label")||t.attr("href"))}),e(document).on("click",'a[target="_top"]',function(a){a.preventDefault(),i.form.confirmChangedForm(function(){window.location=e(a.currentTarget).attr("href")})}),e(window).on("hashchange",i.skin.checkURL)),e(document).off("click.modal").on("click",'[data-toggle="modal"]',function(a){var t=e(this),n=t.data("ams-disabled-handlers");!0!==n&&"click"!==n&&"all"!==n&&!0!==t.data("ams-context-menu")&&(!0===t.data("ams-stop-propagation")&&a.stopPropagation(),a.preventDefault(),i.dialog.open(t),t.parents("#shortcut").exists()&&setTimeout(i.skin._hideShortcutButtons,300))}),e(document).on("click",'button[type="submit"], button.submit',function(){var a=e(this);e(a.get(0).form).data("ams-submit-button",a)}),e(document).on("click",'input[type="checkbox"][readonly]',function(){return!1}),e(document).on("click","[data-ams-click-handler]",function(a){var t=e(this),n=t.data("ams-disabled-handlers");if(!0!==n&&"click"!==n&&"all"!==n){var s=t.data();if(s.amsClickHandler){!0!==s.amsStopPropagation&&!0!==s.amsClickStopPropagation||a.stopPropagation(),!0!==s.amsClickKeepDefault&&a.preventDefault();var r=i.getFunctionByName(s.amsClickHandler);void 0!==r&&r.call(t,s.amsClickHandlerOptions)}}}),e(document).on("change","[data-ams-change-handler]",function(a){var t=e(this);if(!t.prop("readonly")){var n=t.data("ams-disabled-handlers");if(!0!==n&&"change"!==n&&"all"!==n){var s=t.data();if(s.amsChangeHandler){!0!==s.amsChangeKeepDefault&&a.preventDefault();var r=i.getFunctionByName(s.amsChangeHandler);void 0!==r&&r.call(t,s.amsChangeHandlerOptions)}}}}),e(document).on("reset","form",function(a){var t=e(this);setTimeout(function(){e(".alert-danger, SPAN.state-error",t).not(".persistent").remove(),e("LABEL.state-error",t).removeClass("state-error"),e('INPUT.select2[type="hidden"]',t).each(function(){var a=e(this),t=a.data("select2");a.select2("val",a.data("ams-select2-input-value").split(t.opts.separator))}),t.find(".select2").trigger("change"),e("[data-ams-reset-callback]",t).each(function(){var a=e(this),n=a.data(),s=i.getFunctionByName(n.amsResetCallback);void 0!==s&&s.call(t,a,n.amsResetCallbackOptions)})},10),i.form.setFocus(t)}),e(document).on("reset","[data-ams-reset-handler]",function(a){var t=e(this),n=t.data();if(n.amsResetHandler){!0!==n.amsResetKeepDefault&&a.preventDefault();var s=i.getFunctionByName(n.amsResetHandler);void 0!==s&&s.call(t,n.amsResetHandlerOptions)}}),e(document).on("change",'input[type="file"]',function(a){a.preventDefault();var t=e(this),n=t.parent(".button");n.exists()&&n.parent().hasClass("input-file")&&n.next('input[type="text"]').val(t.val())}),e(document).on("focusin",function(a){e(a.target).closest(".mce-window").length&&a.stopImmediatePropagation()}),e("a[data-toggle=tab]",".nav-tabs").on("click",function(a){if(e(this).parent("li").hasClass("disabled"))return a.preventDefault(),!1}),e(document).on("show.bs.tab",function(a){var t=e(a.target),n=t.data();if(n.amsUrl){if(n.amsTabLoaded)return;try{t.append(''),i.skin.loadURL(n.amsUrl,t.attr("href"),{afterLoadCallback:function(){n.amsTabLoadOnce&&t.data("ams-tab-loaded",!0)}})}finally{e("i",t).remove()}}}),e(document).on("hide.bs.modal",function(a){var t=e(a.target);i.form.confirmChangedForm(t,function(){return t.data("modal").isShown=!0,!0},function(){return a.preventDefault(),!1})}),i.initContent(document),i.ajaxNav&&n.exists()&&i.skin.checkURL(),i.form.setFocus(document),e(window).on("beforeunload",i.form.checkBeforeUnload)},n.initContent=function(a){e(".tipsy").remove(),e("[rel=tooltip]",a).tooltip(),e("[rel=popover]",a).popover(),e("[rel=popover-hover]",a).popover({trigger:"hover"}),i.plugins.init(a),i.callbacks.init(a),i.events.init(a),i.form.init(a),"desktop"===i.device?i.skin._initDesktopWidgets(a):i.skin._initMobileWidgets(a),i.skin._setPageHeight()},n.i18n={INFO:"Information",WARNING:"!! WARNING !!",ERROR:"ERROR: ",LOADING:"Loading...",PROGRESS:"Processing",WAIT:"Please wait!",FORM_SUBMITTED:"This form was already submitted...",NO_SERVER_RESPONSE:"No response from server!",ERROR_OCCURED:"An error occured!",ERRORS_OCCURED:"Some errors occured!",BAD_LOGIN_TITLE:"Bad login!",BAD_LOGIN_MESSAGE:"Your anthentication credentials didn't allow you to open a session; please check your credentials or contact administrator.",CONFIRM:"Confirm",CONFIRM_REMOVE:"Removing this content can't be undone. Do you confirm?",CLEAR_STORAGE_TITLE:"Clear Local Storage",CLEAR_STORAGE_CONTENT:"Would you like to RESET all your saved widgets and clear LocalStorage?",BTN_OK:"OK",BTN_CANCEL:"Cancel",BTN_OK_CANCEL:"[OK][Cancel]",BTN_YES:"Yes",BTN_NO:"No",BTN_YES_NO:"[Yes][No]",CLIPBOARD_COPY:"Copy to clipboard with Ctrl+C, and Enter",CLIPBOARD_CHARACTER_COPY_OK:"Character copied to clipboard",CLIPBOARD_TEXT_COPY_OK:"Text copied to clipboard",FORM_CHANGED_WARNING:"Some changes were not saved. These updates will be lost if you leave this page.",DELETE_WARNING:"This change can't be undone. Are you sure that you want to delete this element?",NO_UPDATE:"No changes were applied.",DATA_UPDATED:"Data successfully updated.",HOME:"Home",LOGOUT:"Logout?",LOGOUT_COMMENT:"You can improve your security further after logging out by closing this opened browser",SELECT2_PLURAL:"s",SELECT2_MATCH:"One result is available, press enter to select it.",SELECT2_MATCHES:" results are available, use up and down arrow keys to navigate.",SELECT2_NOMATCHES:"No matches found",SELECT2_SEARCHING:"Searching...",SELECT2_LOADMORE:"Loading more results...",SELECT2_INPUT_TOOSHORT:"Please enter {0} more character{1}",SELECT2_INPUT_TOOLONG:"Please delete {0} character{1}",SELECT2_SELECTION_TOOBIG:"You can only select {0} item{1}",SELECT2_FREETAG_PREFIX:"Free text: ",DT_COLUMNS:"Columns"},n.plugins.i18n={widgets:{},validate:{},datatables:{},fancybox:{ERROR:"Can't load requested content.",RETRY:"Please check URL or try again later.",CLOSE:"Close",NEXT:"Next",PREVIOUS:"Previous"}},e(document).ready(function(){var a=(e=jQuery.noConflict())("HTML"),t=a.attr("lang")||a.attr("xml:lang");t&&!t.startsWith("en")?(n.lang=t,n.getScript(n.baseURL+"i18n/myams_"+t.substr(0,2)+".js",function(){n.initPage()})):n.initPage()})}(jQuery,this); +"use strict";!function(e,a){var t=a.console;String.prototype.startsWith=function(e){var a=this.length,t=e.length;return!(a0},void 0===e.scrollbarWidth&&(e.scrollbarWidth=function(){var a=e('
      ').appendTo("body"),t=a.children(),n=t.innerWidth()-t.height(99).innerWidth();return a.remove(),n}),e.fn.extend({exists:function(){return e(this).length>0},objectOrParentWithClass:function(e){return this.hasClass(e)?this:this.parents("."+e)},listattr:function(a){var t=[];return this.each(function(){t.push(e(this).attr(a))}),t},style:function(e,a,t){if(void 0!==this.get(0)){var n=this.get(0).style;return void 0!==e?void 0!==a?(t=void 0!==t?t:"",n.setProperty(e,a,t),this):n.getPropertyValue(e):n}},removeClassPrefix:function(a){return this.each(function(t,n){var s=n.className.split(" ").map(function(e){return e.startsWith(a)?"":e});n.className=e.trim(s.join(" "))}),this},contextMenu:function(a){function t(t,n,s){var i=e(window)[n](),r=e(a.menuSelector)[n](),o=t;return t+r>i&&r',openedSign:''},a),n=e(this);n.find("LI").each(function(){var a=e(this);if(a.find("UL").size()>0){a.find("A:first").append(""+t.closedSign+"");var n=a.find("A:first");"#"===n.attr("href")&&n.click(function(){return!1})}}),n.find("LI.active").each(function(){var a=e(this).parents("UL"),n=a.parent("LI");a.slideDown(t.speed),n.find("b:first").html(t.openedSign),n.addClass("open")}),n.find("LI A").on("click",function(){var a=e(this);if(!a.hasClass("active")){var s=a.attr("href").replace(/^#/,""),i=a.parent().find("UL");if(t.accordion){var r=a.parent().parents("UL"),o=n.find("UL:visible");o.each(function(a){var n=!0;if(r.each(function(e){if(r[e]===o[a])return n=!1,!1}),n&&i!==o[a]){var l=e(o[a]);!s&&l.hasClass("active")||l.slideUp(t.speed,function(){e(this).parent("LI").removeClass("open").find("B:first").delay(t.speed).html(t.closedSign)})}})}var l=a.parent().find("UL:first");s||!l.is(":visible")||l.hasClass("active")?l.slideDown(t.speed,function(){a.parent("LI").addClass("open").find("B:first").delay(t.speed).html(t.openedSign)}):l.slideUp(t.speed,function(){a.parent("LI").removeClass("open").find("B:first").delay(t.speed).html(t.closedSign)})}})}}),e.UTF8={encode:function(e){e=e.replace(/\r\n/g,"\n");for(var a="",t=0;t127&&n<2048?(a+=String.fromCharCode(n>>6|192),a+=String.fromCharCode(63&n|128)):(a+=String.fromCharCode(n>>12|224),a+=String.fromCharCode(n>>6&63|128),a+=String.fromCharCode(63&n|128))}return a},decode:function(e){for(var a="",t=0,n=0,s=0,i=0;t191&&n<224?(s=e.charCodeAt(t+1),a+=String.fromCharCode((31&n)<<6|63&s),t+=2):(s=e.charCodeAt(t+1),i=e.charCodeAt(t+2),a+=String.fromCharCode((15&n)<<12|(63&s)<<6|63&i),t+=3);return a}},void 0===a.MyAMS&&(a.MyAMS={devmode:!0,devext:"",lang:"en",throttleDelay:350,menuSpeed:235,navbarHeight:49,ajaxNav:!0,enableWidgets:!0,enableMobile:!1,enableFastclick:!1,warnOnFormChange:!1,ismobile:/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase())});var n=a.MyAMS,s=n;n.baseURL=function(){var a=e('script[src*="/myams.js"], script[src*="/myams.min.js"]').attr("src");return s.devmode=a.indexOf(".min.js")<0,s.devext=s.devmode?"":".min",a.substring(0,a.lastIndexOf("/")+1)}(),n.log=function(){t&&t.debug&&t.debug(this,arguments)},n.getQueryVar=function(e,a){if(e.indexOf("?")<0)return!1;e.endsWith("&")||(e+="&");var t=new RegExp(".*?[&\\?]"+a+"=(.*?)&.*"),n=e.replace(t,"$1");return n!==e&&n},n.rgb2hex=function(a){return"#"+e.map(a.match(/\b(\d+)\b/g),function(e){return("0"+parseInt(e).toString(16)).slice(-2)}).join("")},n.generateId=function(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return e()+e()+e()+e()},n.generateUUID=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var t=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===a?t:3&t|8).toString(16)})},n.getObject=function(e,a){if(e){if("string"!=typeof e)return e;var t=e.split(".");a=void 0===a||null===a?window:a;for(var n=0;n").attr("data-ams-id",t).text('@import "'+s.getSource(a)+'";'),n)var l=setInterval(function(){try{o[0].sheet.cssRules;n.call(window,!0,i),clearInterval(l)}catch(e){}},10);o.appendTo(r)}else n&&n.call(window,!1,i)},n.event={stop:function(e){e||(e=window.event),e&&"string"!=typeof e&&(e.stopPropagation?(e.stopPropagation(),e.preventDefault()):(e.cancelBubble=!0,e.returnValue=!1))}},n.browser={getInternetExplorerVersion:function(){var e=-1;if("Microsoft Internet Explorer"===navigator.appName){var a=navigator.userAgent;null!==new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})").exec(a)&&(e=parseFloat(RegExp.$1))}return e},checkVersion:function(){var e="You're not using Windows Internet Explorer.",t=this.getInternetExplorerVersion();t>-1&&(e=t>=8?"You're using a recent copy of Windows Internet Explorer.":"You should upgrade your copy of Windows Internet Explorer."),a.alert&&a.alert(e)},isIE8orlower:function(){var e="0",a=this.getInternetExplorerVersion();return a>-1&&(e=a>=9?0:1),e},copyToClipboard:function(i){function r(i){var r=!1;if(window.clipboardData&&window.clipboardData.setData)r=clipboardData.setData("Text",i);else if(document.queryCommandSupported&&document.queryCommandSupported("copy")){var o=e("