mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2025-01-10 12:25:40 +00:00
5 lines
108 KiB
JavaScript
5 lines
108 KiB
JavaScript
|
/*! jsTree - v3.0.4 - 2014-09-10 - (MIT) */
|
||
|
(function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?e(require("jquery")):e(jQuery)})(function(e,t){"use strict";if(!e.jstree){var i=0,s=!1,r=!1,n=!1,a=[],d=e("script:last").attr("src"),o=document,c=o.createElement("LI"),l,h;c.setAttribute("role","treeitem"),l=o.createElement("I"),l.className="jstree-icon jstree-ocl",c.appendChild(l),l=o.createElement("A"),l.className="jstree-anchor",l.setAttribute("href","#"),h=o.createElement("I"),h.className="jstree-icon jstree-themeicon",l.appendChild(h),c.appendChild(l),l=h=null,e.jstree={version:"3.0.4",defaults:{plugins:[]},plugins:{},path:d&&-1!==d.indexOf("/")?d.replace(/\/[^\/]+$/,""):"",idregex:/[\\:&!^|()\[\]<>@*'+~#";.,=\- \/${}%]/g},e.jstree.create=function(t,s){var r=new e.jstree.core(++i),n=s;return s=e.extend(!0,{},e.jstree.defaults,s),n&&n.plugins&&(s.plugins=n.plugins),e.each(s.plugins,function(e,t){"core"!==e&&(r=r.plugin(t,s[t]))}),r.init(t,s),r},e.jstree.destroy=function(){e(".jstree:jstree").jstree("destroy"),e(document).off(".jstree")},e.jstree.core=function(e){this._id=e,this._cnt=0,this._wrk=null,this._data={core:{themes:{name:!1,dots:!1,icons:!1},selected:[],last_error:{},working:!1,worker_queue:[],focused:null}}},e.jstree.reference=function(i){var s=null,r=null;if(i&&i.id&&(i=i.id),!r||!r.length)try{r=e(i)}catch(n){}if(!r||!r.length)try{r=e("#"+i.replace(e.jstree.idregex,"\\$&"))}catch(n){}return r&&r.length&&(r=r.closest(".jstree")).length&&(r=r.data("jstree"))?s=r:e(".jstree").each(function(){var r=e(this).data("jstree");return r&&r._model.data[i]?(s=r,!1):t}),s},e.fn.jstree=function(i){var s="string"==typeof i,r=Array.prototype.slice.call(arguments,1),n=null;return this.each(function(){var a=e.jstree.reference(this),d=s&&a?a[i]:null;return n=s&&d?d.apply(a,r):null,a||s||i!==t&&!e.isPlainObject(i)||e(this).data("jstree",new e.jstree.create(this,i)),(a&&!s||i===!0)&&(n=a||!1),null!==n&&n!==t?!1:t}),null!==n&&n!==t?n:this},e.expr[":"].jstree=e.expr.createPseudo(function(i){return function(i){return e(i).hasClass("jstree")&&e(i).data("jstree")!==t}}),e.jstree.defaults.core={data:!1,strings:!1,check_callback:!1,error:e.noop,animation:200,multiple:!0,themes:{name:!1,url:!1,dir:!1,dots:!0,icons:!0,stripes:!1,variant:!1,responsive:!1},expand_selected_onload:!0,worker:!0,force_text:!1},e.jstree.core.prototype={plugin:function(t,i){var s=e.jstree.plugins[t];return s?(this._data[t]={},s.prototype=this,new s(i,this)):this},init:function(t,i){this._model={data:{"#":{id:"#",parent:null,parents:[],children:[],children_d:[],state:{loaded:!1}}},changed:[],force_full_redraw:!1,redraw_timeout:!1,default_state:{loaded:!0,opened:!1,selected:!1,disabled:!1}},this.element=e(t).addClass("jstree jstree-"+this._id),this.settings=i,this.element.bind("destroyed",e.proxy(this.teardown,this)),this._data.core.ready=!1,this._data.core.loaded=!1,this._data.core.rtl="rtl"===this.element.css("direction"),this.element[this._data.core.rtl?"addClass":"removeClass"]("jstree-rtl"),this.element.attr("role","tree"),this.bind(),this.trigger("init"),this._data.core.original_container_html=this.element.find(" > ul > li").clone(!0),this._data.core.original_container_html.find("li").addBack().contents().filter(function(){return 3===this.nodeType&&(!this.nodeValue||/^\s+$/.test(this.nodeValue))}).remove(),this.element.html("<ul class='jstree-container-ul jstree-children'><li class='jstree-initial-node jstree-loading jstree-leaf jstree-last'><i class='jstree-icon jstree-ocl'></i><a class='jstree-anchor' href='#'><i class='jstree-icon jstree-themeicon-hidden'></i>"+this.get_string("Loading ...")+"</a></li></ul>"),this._data.core.li_height=this.get_container_ul().children("li:eq(0)").height()||24,this.trigger("loading"),this.load_node("#")},destroy:function(e){e||this.element.empty(),this.element.unbind("destroyed",this.teardown),this.teardown()},teardown:function(){this.unbind(),this.element.removeClass("jstree").removeData("jstree").find("[class^='jstree']").addBack().attr("class",function(){return this.className.replace(/jstree[^ ]*|$/gi,"")}),thi
|
||
|
},toggle_node:function(i){var s,r;if(e.isArray(i)){for(i=i.slice(),s=0,r=i.length;r>s;s++)this.toggle_node(i[s]);return!0}return this.is_closed(i)?this.open_node(i):this.is_open(i)?this.close_node(i):t},open_all:function(e,t,i){if(e||(e="#"),e=this.get_node(e),!e)return!1;var s="#"===e.id?this.get_container_ul():this.get_node(e,!0),r,n,a;if(!s.length){for(r=0,n=e.children_d.length;n>r;r++)this.is_closed(this._model.data[e.children_d[r]])&&(this._model.data[e.children_d[r]].state.opened=!0);return this.trigger("open_all",{node:e})}i=i||s,a=this,s=this.is_closed(e)?s.find(".jstree-closed").addBack():s.find(".jstree-closed"),s.each(function(){a.open_node(this,function(e,s){s&&this.is_parent(e)&&this.open_all(e,t,i)},t||0)}),0===i.find(".jstree-closed").length&&this.trigger("open_all",{node:this.get_node(i)})},close_all:function(t,i){if(t||(t="#"),t=this.get_node(t),!t)return!1;var s="#"===t.id?this.get_container_ul():this.get_node(t,!0),r=this,n,a;if(!s.length){for(n=0,a=t.children_d.length;a>n;n++)this._model.data[t.children_d[n]].state.opened=!1;return this.trigger("close_all",{node:t})}s=this.is_open(t)?s.find(".jstree-open").addBack():s.find(".jstree-open"),e(s.get().reverse()).each(function(){r.close_node(this,i||0)}),this.trigger("close_all",{node:t})},is_disabled:function(e){return e=this.get_node(e),e&&e.state&&e.state.disabled},enable_node:function(i){var s,r;if(e.isArray(i)){for(i=i.slice(),s=0,r=i.length;r>s;s++)this.enable_node(i[s]);return!0}return i=this.get_node(i),i&&"#"!==i.id?(i.state.disabled=!1,this.get_node(i,!0).children(".jstree-anchor").removeClass("jstree-disabled"),this.trigger("enable_node",{node:i}),t):!1},disable_node:function(i){var s,r;if(e.isArray(i)){for(i=i.slice(),s=0,r=i.length;r>s;s++)this.disable_node(i[s]);return!0}return i=this.get_node(i),i&&"#"!==i.id?(i.state.disabled=!0,this.get_node(i,!0).children(".jstree-anchor").addClass("jstree-disabled"),this.trigger("disable_node",{node:i}),t):!1},activate_node:function(e,i){if(this.is_disabled(e))return!1;if(this._data.core.last_clicked=this._data.core.last_clicked&&this._data.core.last_clicked.id!==t?this.get_node(this._data.core.last_clicked.id):null,this._data.core.last_clicked&&!this._data.core.last_clicked.state.selected&&(this._data.core.last_clicked=null),!this._data.core.last_clicked&&this._data.core.selected.length&&(this._data.core.last_clicked=this.get_node(this._data.core.selected[this._data.core.selected.length-1])),this.settings.core.multiple&&(i.metaKey||i.ctrlKey||i.shiftKey)&&(!i.shiftKey||this._data.core.last_clicked&&this.get_parent(e)&&this.get_parent(e)===this._data.core.last_clicked.parent))if(i.shiftKey){var s=this.get_node(e).id,r=this._data.core.last_clicked.id,n=this.get_node(this._data.core.last_clicked.parent).children,a=!1,d,o;for(d=0,o=n.length;o>d;d+=1)n[d]===s&&(a=!a),n[d]===r&&(a=!a),a||n[d]===s||n[d]===r?this.select_node(n[d],!1,!1,i):this.deselect_node(n[d],!1,i)}else this.is_selected(e)?this.deselect_node(e,!1,i):this.select_node(e,!1,!1,i);else!this.settings.core.multiple&&(i.metaKey||i.ctrlKey||i.shiftKey)&&this.is_selected(e)?this.deselect_node(e,!1,i):(this.deselect_all(!0),this.select_node(e,!1,!1,i),this._data.core.last_clicked=this.get_node(e));this.trigger("activate_node",{node:this.get_node(e)})},hover_node:function(e){if(e=this.get_node(e,!0),!e||!e.length||e.children(".jstree-hovered").length)return!1;var t=this.element.find(".jstree-hovered"),i=this.element;t&&t.length&&this.dehover_node(t),e.children(".jstree-anchor").addClass("jstree-hovered"),this.trigger("hover_node",{node:this.get_node(e)}),setTimeout(function(){i.attr("aria-activedescendant",e[0].id),e.attr("aria-selected",!0)},0)},dehover_node:function(e){return e=this.get_node(e,!0),e&&e.length&&e.children(".jstree-hovered").length?(e.attr("aria-selected",!1).children(".jstree-anchor").removeClass("jstree-hovered"),this.trigger("dehover_node",{node:this.get_node(e)}),t):!1},select_node:function(i,s,r,n){var a,d,o,c;if(e.isArray(i)){for(i=i.slice(),d=0,o=i.length;o>d;d++)this.select_node(i[d],s,r,n);return!0}return i=this.get_node(i),
|
||
|
this._data[c?"core":"checkbox"].selected=e.vakata.array_unique(d),-1!==o.indexOf("down")&&r.length&&r.find(".jstree-anchor").removeClass(c?"jstree-clicked":"jstree-checked")},this)),-1!==this.settings.checkbox.cascade.indexOf("up")&&this.element.on("delete_node.jstree",e.proxy(function(e,t){var i=this.get_node(t.parent),s=this._model.data,r,n,a,d,o=this.settings.checkbox.tie_selection;while(i&&"#"!==i.id){for(a=0,r=0,n=i.children.length;n>r;r++)a+=s[i.children[r]].state[o?"selected":"checked"];if(a!==n)break;i.state[o?"selected":"checked"]=!0,this._data[o?"core":"checkbox"].selected.push(i.id),d=this.get_node(i,!0),d&&d.length&&d.children(".jstree-anchor").addClass(o?"jstree-clicked":"jstree-checked"),i=this.get_node(i.parent)}},this)).on("move_node.jstree",e.proxy(function(t,i){var s=i.is_multi,r=i.old_parent,n=this.get_node(i.parent),a=this._model.data,d,o,c,l,h,_=this.settings.checkbox.tie_selection;if(!s){d=this.get_node(r);while(d&&"#"!==d.id){for(o=0,c=0,l=d.children.length;l>c;c++)o+=a[d.children[c]].state[_?"selected":"checked"];if(o!==l)break;d.state[_?"selected":"checked"]=!0,this._data[_?"core":"checkbox"].selected.push(d.id),h=this.get_node(d,!0),h&&h.length&&h.children(".jstree-anchor").addClass(_?"jstree-clicked":"jstree-checked"),d=this.get_node(d.parent)}}d=n;while(d&&"#"!==d.id){for(o=0,c=0,l=d.children.length;l>c;c++)o+=a[d.children[c]].state[_?"selected":"checked"];if(o===l)d.state[_?"selected":"checked"]||(d.state[_?"selected":"checked"]=!0,this._data[_?"core":"checkbox"].selected.push(d.id),h=this.get_node(d,!0),h&&h.length&&h.children(".jstree-anchor").addClass(_?"jstree-clicked":"jstree-checked"));else{if(!d.state[_?"selected":"checked"])break;d.state[_?"selected":"checked"]=!1,this._data[_?"core":"checkbox"].selected=e.vakata.array_remove_item(this._data[_?"core":"checkbox"].selected,d.id),h=this.get_node(d,!0),h&&h.length&&h.children(".jstree-anchor").removeClass(_?"jstree-clicked":"jstree-checked")}d=this.get_node(d.parent)}},this))},this._undetermined=function(){var t,i,s=this._model.data,r=this.settings.checkbox.tie_selection,n=this._data[r?"core":"checkbox"].selected,a=[],d=this;for(t=0,i=n.length;i>t;t++)s[n[t]]&&s[n[t]].parents&&(a=a.concat(s[n[t]].parents));for(this.element.find(".jstree-closed").not(":has(.jstree-children)").each(function(){var e=d.get_node(this),r;if(e.state.loaded)for(t=0,i=e.children_d.length;i>t;t++)r=s[e.children_d[t]],!r.state.loaded&&r.original&&r.original.state&&r.original.state.undetermined&&r.original.state.undetermined===!0&&(a.push(r.id),a=a.concat(r.parents));else e.original&&e.original.state&&e.original.state.undetermined&&e.original.state.undetermined===!0&&(a.push(e.id),a=a.concat(e.parents))}),a=e.vakata.array_unique(a),a=e.vakata.array_remove_item(a,"#"),this.element.find(".jstree-undetermined").removeClass("jstree-undetermined"),t=0,i=a.length;i>t;t++)s[a[t]].state[r?"selected":"checked"]||(n=this.get_node(a[t],!0),n&&n.length&&n.children(".jstree-anchor").children(".jstree-checkbox").addClass("jstree-undetermined"))},this.redraw_node=function(t,i,r){if(t=s.redraw_node.call(this,t,i,r)){var n,a,d=null;for(n=0,a=t.childNodes.length;a>n;n++)if(t.childNodes[n]&&t.childNodes[n].className&&-1!==t.childNodes[n].className.indexOf("jstree-anchor")){d=t.childNodes[n];break}d&&(!this.settings.checkbox.tie_selection&&this._model.data[t.id].state.checked&&(d.className+=" jstree-checked"),d.insertBefore(_.cloneNode(!1),d.childNodes[0]))}return r||-1===this.settings.checkbox.cascade.indexOf("undetermined")||(this._data.checkbox.uto&&clearTimeout(this._data.checkbox.uto),this._data.checkbox.uto=setTimeout(e.proxy(this._undetermined,this),50)),t},this.show_checkboxes=function(){this._data.core.themes.checkboxes=!0,this.get_container_ul().removeClass("jstree-no-checkboxes")},this.hide_checkboxes=function(){this._data.core.themes.checkboxes=!1,this.get_container_ul().addClass("jstree-no-checkboxes")},this.toggle_checkboxes=function(){this._data.core.themes.checkboxes?this.hide_checkboxes():this.show_checkboxes()},this.is_undetermined=function(t){t=this.get_node(t);var i
|
||
|
},!0)},this)):(n=e.extend({},n),n.data||(n.data={}),n.data.str=i,e.ajax(n).fail(e.proxy(function(){this._data.core.last_error={error:"ajax",plugin:"search",id:"search_01",reason:"Could not load search parents",data:JSON.stringify(n)},this.settings.core.error.call(this,this._data.core.last_error)},this)).done(e.proxy(function(t){t&&t.d&&(t=t.d),this._load_nodes(e.isArray(t)?e.vakata.array_unique(t):[],function(){this.search(i,!0)},!0)},this)))},this.clear_search=function(){this._data.search.dom.children(".jstree-anchor").removeClass("jstree-search"),this.settings.search.close_opened_onclear&&this.close_node(this._data.search.opn,0),this.trigger("clear_search",{nodes:this._data.search.dom,str:this._data.search.str,res:this._data.search.res}),this._data.search.str="",this._data.search.res=[],this._data.search.opn=[],this._data.search.dom=e()},this._search_open=function(t){var i=this;e.each(t.concat([]),function(s,r){if("#"===r)return!0;try{r=e("#"+r.replace(e.jstree.idregex,"\\$&"),i.element)}catch(n){}r&&r.length&&i.is_closed(r)&&(i._data.search.opn.push(r[0].id),i.open_node(r,function(){i._search_open(t)},0))})}},function(e){e.vakata.search=function(e,t,i){i=i||{},i.fuzzy!==!1&&(i.fuzzy=!0),e=i.caseSensitive?e:e.toLowerCase();var s=i.location||0,r=i.distance||100,n=i.threshold||.6,a=e.length,d,o,c,l;return a>32&&(i.fuzzy=!1),i.fuzzy&&(d=1<<a-1,o=function(){var t={},i=0;for(i=0;a>i;i++)t[e.charAt(i)]=0;for(i=0;a>i;i++)t[e.charAt(i)]|=1<<a-i-1;return t}(),c=function(e,t){var i=e/a,n=Math.abs(s-t);return r?i+n/r:n?1:i}),l=function(t){if(t=i.caseSensitive?t:t.toLowerCase(),e===t||-1!==t.indexOf(e))return{isMatch:!0,score:0};if(!i.fuzzy)return{isMatch:!1,score:1};var r,l,h=t.length,_=n,u=t.indexOf(e,s),g,f,p=a+h,m,v,j,k,y,x=1,b=[];for(-1!==u&&(_=Math.min(c(0,u),_),u=t.lastIndexOf(e,s+a),-1!==u&&(_=Math.min(c(0,u),_))),u=-1,r=0;a>r;r++){g=0,f=p;while(f>g)_>=c(r,s+f)?g=f:p=f,f=Math.floor((p-g)/2+g);for(p=f,v=Math.max(1,s-f+1),j=Math.min(s+f,h)+a,k=Array(j+2),k[j+1]=(1<<r)-1,l=j;l>=v;l--)if(y=o[t.charAt(l-1)],k[l]=0===r?(1|k[l+1]<<1)&y:(1|k[l+1]<<1)&y|(1|(m[l+1]|m[l])<<1)|m[l+1],k[l]&d&&(x=c(r,l-1),_>=x)){if(_=x,u=l-1,b.push(u),!(u>s))break;v=Math.max(1,2*s-u)}if(c(r+1,s)>_)break;m=k}return{isMatch:u>=0,score:x}},t===!0?{search:l}:l(t)}}(e),e.jstree.defaults.sort=function(e,t){return this.get_text(e)>this.get_text(t)?1:-1},e.jstree.plugins.sort=function(t,i){this.bind=function(){i.bind.call(this),this.element.on("model.jstree",e.proxy(function(e,t){this.sort(t.parent,!0)},this)).on("rename_node.jstree create_node.jstree",e.proxy(function(e,t){this.sort(t.parent||t.node.parent,!1),this.redraw_node(t.parent||t.node.parent,!0)},this)).on("move_node.jstree copy_node.jstree",e.proxy(function(e,t){this.sort(t.parent,!1),this.redraw_node(t.parent,!0)},this))},this.sort=function(t,i){var s,r;if(t=this.get_node(t),t&&t.children&&t.children.length&&(t.children.sort(e.proxy(this.settings.sort,this)),i))for(s=0,r=t.children_d.length;r>s;s++)this.sort(t.children_d[s],!1)}};var u=!1;e.jstree.defaults.state={key:"jstree",events:"changed.jstree open_node.jstree close_node.jstree",ttl:!1,filter:!1},e.jstree.plugins.state=function(t,i){this.bind=function(){i.bind.call(this);var t=e.proxy(function(){this.element.on(this.settings.state.events,e.proxy(function(){u&&clearTimeout(u),u=setTimeout(e.proxy(function(){this.save_state()},this),100)},this))},this);this.element.on("ready.jstree",e.proxy(function(e,i){this.element.one("restore_state.jstree",t),this.restore_state()||t()},this))},this.save_state=function(){var t={state:this.get_state(),ttl:this.settings.state.ttl,sec:+new Date};e.vakata.storage.set(this.settings.state.key,JSON.stringify(t))},this.restore_state=function(){var t=e.vakata.storage.get(this.settings.state.key);if(t)try{t=JSON.parse(t)}catch(i){return!1}return t&&t.ttl&&t.sec&&+new Date-t.sec>t.ttl?!1:(t&&t.state&&(t=t.state),t&&e.isFunction(this.settings.state.filter)&&(t=this.settings.state.filter.call(this,t)),t?(this.element.one("set_state.jstree",function(i,s){s.instance.trigger("restore_state",{state:e.extend(!0,{},t)})}),this.
|