YetiForceCompany/YetiForceCRM

View on GitHub
public_html/layouts/basic/modules/Vtiger/resources/TreeModal.min.js

Summary

Maintainability
A
35 mins
Test Coverage
'use strict';

/* {[The file is published on the basis of YetiForce Public License 6.5 that can be found in the following directory: licenses/LicenseEN.txt or yetiforce.com]} */"use strict";$.Class("Base_TreeModal_JS",{},{/**
         * Event for select row
         */selectEvent:!1,/**
         * Modal container
         */container:!1,/**
         * Jstree element
         */tree:!1,/**
         * Multiple selection
         */multiple:!1,/**
         * Set event for select row
         * @param {function} cb
         */setSelectEvent:function setSelectEvent(cb){this.selectEvent=cb;},/**
         * Generate tree
         */generateTree:function generateTree(){var plugins=[];this.multiple&&(plugins.push("category"),plugins.push("checkbox")),plugins.push("search"),this.tree.jstree($.extend(!0,{core:{data:JSON.parse(this.container.find(".js-tree-value").val()),themes:{name:"proton",responsive:!0}},checkbox:{three_state:!1},plugins:plugins},this.tree.data("params")));},/**
         * Register select events
         */registerSelectEvent:function registerSelectEvent(){var _this=this;this.multiple?this.container.find("[name=\"saveButton\"]").on("click",function(){var id=[],name=[];$.each(_this.tree.jstree("getCategory",!0),function(index,value){id.push("T"+value.id),name.push(value.text);}),_this.selectEvent({id:id.join(),name:name.join(", ")}),app.hideModalWindow(!1,_this.container.parent().attr("id"));}):this.tree.on("select_node.jstree",function(event,data){_this.selectEvent({id:"T"+data.node.id,name:data.node.text}),app.hideModalWindow(!1,_this.container.parent().attr("id"));});},registerSearchEvent:function registerSearchEvent(){var thisInstance=this,valueSearch=this.container.find("#valueSearchTree");valueSearch.on("keypress",function(e){13==e.which&&thisInstance.searchingInTree(valueSearch.val());}),this.container.find("#btnSearchTree").on("click",function(){thisInstance.searchingInTree(valueSearch.val());});},searchingInTree:function searchingInTree(text){this.tree.jstree(!0).search(text);},/**
         * Register base events
         * @param {jQuery} modalContainer
         */registerEvents:function registerEvents(modalContainer){this.container=modalContainer,this.tree=this.container.find(".js-tree-contents"),this.multiple=!(1!=this.container.find(".js-multiple").val()),this.generateTree(),this.registerSearchEvent(),this.registerSelectEvent();}});
//# sourceMappingURL=TreeModal.min.js.map