JXMovies/CMS/JXCMS.CMS.Movie/Admin/Content/js/jquery-treegrid/jquery.treegrid.min.js

1 line
10 KiB
JavaScript
Raw Normal View History

2020-02-09 19:10:05 +08:00
(function($){var methods={initTree:function(options){var settings=$.extend({},this.treegrid.defaults,options);return this.each(function(){var $this=$(this);$this.treegrid("setTreeContainer",$(this));$this.treegrid("setSettings",settings);settings.getRootNodes.apply(this,[$(this)]).treegrid("initNode",settings)})},initNode:function(settings){return this.each(function(){var $this=$(this);$this.treegrid("setTreeContainer",settings.getTreeGridContainer.apply(this));$this.treegrid("getChildNodes").treegrid("initNode",settings);$this.treegrid("initExpander").treegrid("initIndent").treegrid("initEvents").treegrid("initState").treegrid("initSettingsEvents")})},initEvents:function(){var $this=$(this);$this.on("change",function(){var $this=$(this);$this.treegrid("render");if($this.treegrid("getSetting","saveState")){$this.treegrid("saveState")}});$this.on("collapse",function(){var $this=$(this);$this.removeClass("treegrid-expanded");$this.addClass("treegrid-collapsed")});$this.on("expand",function(){var $this=$(this);$this.removeClass("treegrid-collapsed");$this.addClass("treegrid-expanded")});return $this},initSettingsEvents:function(){var $this=$(this);$this.on("change",function(){var $this=$(this);if(typeof $this.treegrid("getSetting","onChange")==="function"){$this.treegrid("getSetting","onChange").apply($this)}});$this.on("collapse",function(){var $this=$(this);if(typeof $this.treegrid("getSetting","onCollapse")==="function"){$this.treegrid("getSetting","onCollapse").apply($this)}});$this.on("expand",function(){var $this=$(this);if(typeof $this.treegrid("getSetting","onExpand")==="function"){$this.treegrid("getSetting","onExpand").apply($this)}});return $this},initExpander:function(){var $this=$(this);var cell=$this.find("td").get($this.treegrid("getSetting","treeColumn"));var tpl=$this.treegrid("getSetting","expanderTemplate");var expander=$this.treegrid("getSetting","getExpander").apply(this);if(expander){expander.remove()}$(tpl).prependTo(cell).click(function(){$($(this).closest("tr")).treegrid("toggle")});return $this},initIndent:function(){var $this=$(this);$this.find(".treegrid-indent").remove();for(var i=0;i<$(this).treegrid("getDepth");i++){$($this.treegrid("getSetting","indentTemplate")).insertBefore($this.find(".treegrid-expander"))}return $this},initState:function(){var $this=$(this);if($this.treegrid("getSetting","saveState")&&!$this.treegrid("isFirstInit")){$this.treegrid("restoreState")}else{if($this.treegrid("getSetting","initialState")==="expanded"){$this.treegrid("expand")}else{$this.treegrid("collapse")}}return $this},isFirstInit:function(){var tree=$(this).treegrid("getTreeContainer");if(tree.data("first_init")===undefined){tree.data("first_init",$.cookie(tree.treegrid("getSetting","saveStateName"))===undefined)}return tree.data("first_init")},saveState:function(){var $this=$(this);if($this.treegrid("getSetting","saveStateMethod")==="cookie"){var stateArrayString=$.cookie($this.treegrid("getSetting","saveStateName"))||"";var stateArray=stateArrayString===""?[]:stateArrayString.split(",");var nodeId=$this.treegrid("getNodeId");if($this.treegrid("isExpanded")){if($.inArray(nodeId,stateArray)===-1){stateArray.push(nodeId)}}else if($this.treegrid("isCollapsed")){if($.inArray(nodeId,stateArray)!==-1){stateArray.splice($.inArray(nodeId,stateArray),1)}}$.cookie($this.treegrid("getSetting","saveStateName"),stateArray.join(","))}return $this},restoreState:function(){var $this=$(this);if($this.treegrid("getSetting","saveStateMethod")==="cookie"){var stateArray=$.cookie($this.treegrid("getSetting","saveStateName")).split(",");if($.inArray($this.treegrid("getNodeId"),stateArray)!==-1){$this.treegrid("expand")}else{$this.treegrid("collapse")}}return $this},getSetting:function(name){if(!$(this).treegrid("getTreeContainer")){return null}return $(this).treegrid("getTreeContainer").data("settings")[name]},setSettings:function(settings){$(this).treegrid("getTreeContainer").data("settings",settings)},getTreeContainer:function(){return $(this).data("treegrid")},setTreeContainer:function(container){return $(this).data("treegri