bnbweb/back/assets/js/tree.min.js

8 lines
9.1 KiB
JavaScript
Raw Normal View History

2022-11-14 15:49:28 +00:00
/*
* Fuel UX Tree
* https://github.com/ExactTarget/fuelux
*
* Copyright (c) 2014 ExactTarget
* Licensed under the BSD New license.
*/
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){function b(a,b,c){b.addClass("tree-selected"),"item"===b.data("type")&&c.hasClass(a.options["unselected-icon"])&&c.removeClass(a.options["unselected-icon"]).addClass(a.options["selected-icon"])}function c(a,b,c){b.removeClass("tree-selected"),"item"===b.data("type")&&c.hasClass(a.options["selected-icon"])&&c.removeClass(a.options["selected-icon"]).addClass(a.options["unselected-icon"])}function d(d,e,f){a.each(f.$elements,function(b,c){var d=a(c);d[0]!==e.$element[0]&&f.dataForEvent.push(a(d).data())}),e.$element.hasClass("tree-selected")?(c(d,e.$element,e.$icon),f.eventType="deselected"):(b(d,e.$element,e.$icon),f.eventType="selected",f.dataForEvent.push(e.elementData))}function e(a,d,e){if(e.$elements[0]!==d.$element[0]){a.deselectAll(a.$element);b(a,d.$element,d.$icon),e.eventType="selected",e.dataForEvent=[d.elementData]}else c(a,d.$element,d.$icon),e.eventType="deselected",e.dataForEvent=[]}var f=a.fn.tree,g=function(b,c){this.$element=a(b),this.options=a.extend({},a.fn.tree.defaults,c),this.options.itemSelect&&this.$element.on("click.fu.tree",".tree-item",a.proxy(function(a){this.selectItem(a.currentTarget)},this)),this.$element.on("click.fu.tree",".tree-branch-header",a.proxy(function(a){this.options.folderSelect||this.toggleFolder(a.currentTarget)},this)),this.$element.on("click.fu.tree",".tree-overflow",a.proxy(function(b){this.populate(a(b.currentTarget))},this)),this.options.folderSelect&&(this.$element.addClass("tree-folder-select"),this.$element.off("click.fu.tree",".tree-branch-name"),this.$element.on("click.fu.tree",".icon-caret",a.proxy(function(b){this.toggleFolder(a(b.currentTarget).next())},this)),this.$element.on("click.fu.tree",".tree-branch-header",a.proxy(function(b){this.selectFolder(a(b.currentTarget))},this))),this.render()};g.prototype={constructor:g,deselectAll:function(b){b=b||this.$element;var d=a(b).find(".tree-selected"),e=this;return d.each(function(b,d){c(e,a(d),a(d).find("."+a.trim(e.options["base-icon"]).replace(/(\s+)/g,".")))}),d},destroy:function(){return this.$element.find("li:not([data-template])").remove(),this.$element.remove(),this.$element[0].outerHTML},render:function(){this.populate(this.$element)},populate:function(b,c){var d=this,e=b.hasClass("tree-overflow"),f=b.hasClass("tree")?b:b.parent(),g=f.hasClass("tree");e&&!g&&(f=f.parent());var h=f.data();e&&(h.overflow=b.data()),c=c||!1,e&&(g?b.replaceWith(f.find("> .tree-loader").remove()):b.remove());var i=f.find(".tree-loader:last");c===!1&&i.removeClass("hide hidden"),this.options.dataSource(h?h:{},function(b){a.each(b.data,function(b,c){var e;if("folder"===c.type){e=d.$element.find("[data-template=treebranch]:eq(0)").clone().removeClass("hide hidden").removeData("template").removeAttr("data-template"),e.data(c),e.find(".tree-branch-name > .tree-label").html(c.text||c.name);var h=e.find(".tree-branch-header");"icon-class"in c&&h.find("i").addClass(c["icon-class"]),"additionalParameters"in c&&"item-selected"in c.additionalParameters&&1==c.additionalParameters["item-selected"]&&setTimeout(function(){h.trigger("click")},0)}else"item"===c.type?(e=d.$element.find("[data-template=treeitem]:eq(0)").clone().removeClass("hide hidden").removeData("template").removeAttr("data-template"),e.find(".tree-item-name > .tree-label").html(c.text||c.name),e.data(c),"additionalParameters"in c&&"item-selected"in c.additionalParameters&&1==c.additionalParameters["item-selected"]&&(e.addClass("tree-selected"),e.find("i").removeClass(d.options["unselected-icon"]).addClass(d.options["selected-icon"]))):"overflow"===c.type&&(e=d.$element.find("[data-template=treeoverflow]:eq(0)").clone().removeClass("hide hidden").removeData("template").removeAttr("data-template"),e.find(".tree-overflow-name > .tree-label").html(c.text||c.name),e.data(c));var i=c.attr||c.dataAttributes||[];a.each(i,function(a,b){switch(a){case"cssClass":case"class":case"className":e.addClass(b);break;case"data-icon":e.find(".icon