powerdns-admin/app/static/global/plugins/bootstrap-gtreetable/bootstrap-gtreetable.min.js

9 lines
22 KiB
JavaScript
Raw Normal View History

2015-12-13 09:34:12 +00:00
/* =========================================================
* bootstrap-gtreetable v2.2.1-alpha
* https://github.com/gilek/bootstrap-gtreetable
* =========================================================
* Copyright 2014 Maciej Kłak
* Licensed under MIT (https://github.com/gilek/bootstrap-gtreetable/blob/master/LICENSE)
* ========================================================= */
!function(a){function b(b,c){this.options=c,this.$tree=a(b),this.language=void 0===this.options.languages[this.options.language]?this.options.languages["en-US"]:a.extend({},this.options.languages["en-US"],this.options.languages[this.options.language]),this._isNodeDragging=!1,this._lastId=0,this.actions=[],null!==this.options.defaultActions&&(this.actions=this.options.defaultActions),void 0!==this.options.actions&&this.actions.push.apply(this.actions,this.options.actions),this.options.cache>0&&(this.cacheManager=new d(this));var e=this.language;if(this.template=void 0!==this.options.template?this.options.template:'<table class="table gtreetable"><tr class="'+this.options.classes.node+" "+this.options.classes.collapsed+'"><td><span>${draggableIcon}${indent}${ecIcon}${selectedIcon}${typeIcon}${name}</span><span class="hide '+this.options.classes.action+'">${input}${saveButton} ${cancelButton}</span><div class="btn-group pull-right '+this.options.classes.buttons+'">${actionsButton}${actionsList}</div></td></tr></table>',this.templateParts=void 0!==this.options.templateParts?this.options.templateParts:{draggableIcon:this.options.draggable===!0?'<span class="'+this.options.classes.handleIcon+'">&zwnj;</span><span class="'+this.options.classes.draggablePointer+'">&zwnj;</span>':"",indent:'<span class="'+this.options.classes.indent+'">&zwnj;</span>',ecIcon:'<span class="'+this.options.classes.ceIcon+' icon"></span>',selectedIcon:'<span class="'+this.options.classes.selectedIcon+' icon"></span>',typeIcon:'<span class="'+this.options.classes.typeIcon+'"></span>',name:'<span class="'+this.options.classes.name+'"></span>',input:'<input type="text" name="name" value="" style="width: '+this.options.inputWidth+'" class="form-control" />',saveButton:'<button type="button" class="btn btn-sm btn-success '+this.options.classes.saveButton+'">'+e.save+"</button>",cancelButton:'<button type="button" class="btn btn-sm '+this.options.classes.cancelButton+'">'+e.cancel+"</button>",actionsButton:'<button type="button" class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown">'+e.action+' <span class="caret"></span></button>',actionsList:""},this.actions.length>0){var f='<ul class="dropdown-menu" role="menu"><li role="presentation" class="dropdown-header">'+e.action+"</li>";a.each(this.actions,function(a,b){if(b.divider===!0)f+='<li class="divider"></li>';else{var c=b.name.match(/\$\{([\w\W]+)\}/),d=null!==c&&void 0!==c[1]&&void 0!==e.actions[c[1]]?e.actions[c[1]]:b.name;f+='<li role="presentation"><a href="#notarget" class="node-action-'+a+'" tabindex="-1">'+d+"</a></li>"}}),f+="</ul>",this.templateParts.actionsList=f}var g=this.template;a.each(this.templateParts,function(a,b){g=g.replace("${"+a+"}",b)}),this.options.template=g,0===this.$tree.find("tbody").length&&this.$tree.append("<tbody></tbody>"),this.options.readonly||this.$tree.addClass("gtreetable-fullAccess"),this.$nodeTemplate=a(void 0!==this.options.templateSelector?this.options.templateSelector:this.options.template).find("."+this.options.classes.node),this.options.draggable===!0&&this.isNodeDragging(!1),this.init()}function c(a,b){this.manager=b,this.level=parseInt(a.level),this.parent=a.parent,this.name=a.name,this.type=a.type,this.id=a.id,this.insertPosition=void 0,this.movePosition=void 0,this.relatedNodeId=void 0,this._isExpanded=!1,this._isLoading=!1,this._isSaved=void 0===a.id?!1:!0,this._isSelected=!1,this._isHovered=!1,this._isEditable=!1,this.init()}function d(a){this._cached={},this.manager=a}function e(c,d){var e=null;return this.each(function(){var f=a(this),g=f.data("bs.gtreetable"),h=a.extend({},a.fn.gtreetable.defaults,f.data(),"object"==typeof c&&c);g||(g=new b(this,h),f.data("bs.gtreetable",g)),"string"==typeof c&&(e=g[c](d))}),e||(e=this),e}b.prototype={getNode:function(a){return a.data("bs.gtreetable.gtreetablenode")},getNodeById:function(a){return this.getNode(this.$tree.find("."+this.options.classes.node+"[data-id='"+a+"']"))},getSelectedNodes:function(){var b=[],c=this;return a.each(this.$tree.find("."+this.options.classes.selected),function(){b.push