All Downloads are FREE. Search and download functionalities are using the official Maven repository.

template.js.jstree.jquery.jstree.min.js Maven / Gradle / Ivy

There is a newer version: 6.0.0
Show newest version
/*
 * jsTree 1.0-rc3
 * http://jstree.com/
 *
 * Copyright (c) 2010 Ivan Bozhanov (vakata.com)
 *
 * Licensed same as jquery - under the terms of either the MIT License or the GPL Version 2 License
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * $Date: 2011-02-09 01:17:14 +0200 $
 * $Revision: 236 $
 */
"use strict";(function(){if(jQuery&&jQuery.jstree){return}var c=false,b=false,a=false;(function(g){g.vakata={};g.vakata.css={get_css:function(n,k,l){n=n.toLowerCase();var m=l.cssRules||l.rules,i=0;do{if(m.length&&i>m.length+5){return false}if(m[i].selectorText&&m[i].selectorText.toLowerCase()==n){if(k===true){if(l.removeRule){l.removeRule(i)}if(l.deleteRule){l.deleteRule(i)}return true}else{return m[i]}}}while(m[++i]);return false},add_css:function(j,i){if(g.jstree.css.get_css(j,false,i)){return false}if(i.insertRule){i.insertRule(j+" { }",0)}else{i.addRule(j,null,0)}return g.vakata.css.get_css(j)},remove_css:function(j,i){return g.vakata.css.get_css(j,true,i)},add_sheet:function(j){var i=false,l=true;if(j.str){if(j.title){i=g("style[id='"+j.title+"-stylesheet']")[0]}if(i){l=false}else{i=document.createElement("style");i.setAttribute("type","text/css");if(j.title){i.setAttribute("id",j.title+"-stylesheet")}}if(i.styleSheet){if(l){document.getElementsByTagName("head")[0].appendChild(i);i.styleSheet.cssText=j.str}else{i.styleSheet.cssText=i.styleSheet.cssText+" "+j.str}}else{i.appendChild(document.createTextNode(j.str));document.getElementsByTagName("head")[0].appendChild(i)}return i.sheet||i.styleSheet}if(j.url){if(document.createStyleSheet){try{i=document.createStyleSheet(j.url)}catch(k){}}else{i=document.createElement("link");i.rel="stylesheet";i.type="text/css";i.media="all";i.href=j.url;document.getElementsByTagName("head")[0].appendChild(i);return i.styleSheet}}}};var h=[],f=-1,e={},d={};g.fn.jstree=function(l){var i=(typeof l=="string"),j=Array.prototype.slice.call(arguments,1),k=this;if(i){if(l.substring(0,1)=="_"){return k}this.each(function(){var m=h[g.data(this,"jstree_instance_id")],n=(m&&g.isFunction(m[l]))?m[l].apply(m,j):m;if(typeof n!=="undefined"&&(l.indexOf("is_")===0||(n!==true&&n!==false))){k=n;return false}})}else{this.each(function(){var q=g.data(this,"jstree_instance_id"),n=[],m=l?g.extend({},true,l):{},r=g(this),p=false,o=[];n=n.concat(j);if(r.data("jstree")){n.push(r.data("jstree"))}m=n.length?g.extend.apply(null,[true,m].concat(n)):m;if(typeof q!=="undefined"&&h[q]){h[q].destroy()}q=parseInt(h.push({}),10)-1;g.data(this,"jstree_instance_id",q);m.plugins=g.isArray(m.plugins)?m.plugins:g.jstree.defaults.plugins.slice();m.plugins.unshift("core");m.plugins=m.plugins.sort().join(",,").replace(/(,|^)([^,]+)(,,\2)+(,|$)/g,"$1$2$4").replace(/,,+/g,",").replace(/,$/,"").split(",");p=g.extend(true,{},g.jstree.defaults,m);p.plugins=m.plugins;g.each(e,function(s,t){if(g.inArray(s,p.plugins)===-1){p[s]=null;delete p[s]}else{o.push(s)}});p.plugins=o;h[q]=new g.jstree._instance(q,g(this).addClass("jstree jstree-"+q),p);g.each(h[q]._get_settings().plugins,function(s,t){h[q].data[t]={}});g.each(h[q]._get_settings().plugins,function(s,t){if(e[t]){e[t].__init.apply(h[q])}});setTimeout(function(){if(h[q]){h[q].init()}},0)})}return k};g.jstree={defaults:{plugins:[]},_focused:function(){return h[f]||null},_reference:function(i){if(h[i]){return h[i]}var j=g(i);if(!j.length&&typeof i==="string"){j=g("#"+i)}if(!j.length){return null}return h[j.closest(".jstree").data("jstree_instance_id")]||null},_instance:function(j,i,k){this.data={core:{}};this.get_settings=function(){return g.extend(true,{},k)};this._get_settings=function(){return k};this.get_index=function(){return j};this.get_container=function(){return i};this.get_container_ul=function(){return i.children("ul:eq(0)")};this._set_settings=function(l){k=g.extend(true,{},k,l)}},_fn:{},plugin:function(i,j){j=g.extend({},{__init:g.noop,__destroy:g.noop,_fn:{},defaults:false},j);e[i]=j;g.jstree.defaults[i]=j.defaults;g.each(j._fn,function(k,l){l.plugin=i;l.old=g.jstree._fn[k];g.jstree._fn[k]=function(){var m,o=l,n=Array.prototype.slice.call(arguments),q=new g.Event("before.jstree"),p=false;if(this.data.core.locked===true&&k!=="unlock"&&k!=="is_locked"){return}do{if(o&&o.plugin&&g.inArray(o.plugin,this._get_settings().plugins)!==-1){break}o=o.old}while(o);if(!o){return}if(k.indexOf("_")===0){m=o.apply(this,n)}else{m=this.get_container().triggerHandler(q,{func:k,inst:this,args:n,plugin:o.plugin});if(m===false){return}if(typeof m!=="undefined"){n=m}m=o.apply(g.extend({},this,{__callback:function(r){this.get_container().triggerHandler(k+".jstree",{inst:this,args:n,rslt:r,rlbk:p})},__rollback:function(){p=this.get_rollback();return p},__call_old:function(r){return o.old.apply(this,(r?Array.prototype.slice.call(arguments,1):n))}}),n)}return m};g.jstree._fn[k].old=l.old;g.jstree._fn[k].plugin=i})},rollback:function(i){if(i){if(!g.isArray(i)){i=[i]}g.each(i,function(j,k){h[k.i].set_rollback(k.h,k.d)})}}};g.jstree._fn=g.jstree._instance.prototype={};g(function(){var k=navigator.userAgent.toLowerCase(),j=(k.match(/.+?(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[0,"0"])[1],i=".jstree ul, .jstree li { display:block; margin:0 0 0 0; padding:0 0 0 0; list-style-type:none; } .jstree li { display:block; min-height:18px; line-height:18px; white-space:nowrap; margin-left:18px; min-width:18px; } .jstree-rtl li { margin-left:0; margin-right:18px; } .jstree > ul > li { margin-left:0px; } .jstree-rtl > ul > li { margin-right:0px; } .jstree ins { display:inline-block; text-decoration:none; width:18px; height:18px; margin:0 0 0 0; padding:0; } .jstree a { display:inline-block; line-height:16px; height:16px; color:black; white-space:nowrap; text-decoration:none; padding:1px 2px; margin:0; } .jstree a:focus { outline: none; } .jstree a > ins { height:16px; width:16px; } .jstree a > .jstree-icon { margin-right:3px; } .jstree-rtl a > .jstree-icon { margin-left:3px; margin-right:0; } li.jstree-open > ul { display:block; } li.jstree-closed > ul { display:none; } ";if(/msie/.test(k)&&parseInt(j,10)==6){c=true;try{document.execCommand("BackgroundImageCache",false,true)}catch(l){}i+=".jstree li { height:18px; margin-left:0; margin-right:0; } .jstree li li { margin-left:18px; } .jstree-rtl li li { margin-left:0px; margin-right:18px; } li.jstree-open ul { display:block; } li.jstree-closed ul { display:none !important; } .jstree li a { display:inline; border-width:0 !important; padding:0px 2px !important; } .jstree li a ins { height:16px; width:16px; margin-right:3px; } .jstree-rtl li a ins { margin-right:0px; margin-left:3px; } "}if(/msie/.test(k)&&parseInt(j,10)==7){b=true;i+=".jstree li a { border-width:0 !important; padding:0px 2px !important; } "}if(!/compatible/.test(k)&&/mozilla/.test(k)&&parseFloat(j,10)<1.9){a=true;i+=".jstree ins { display:-moz-inline-box; } .jstree li { line-height:12px; } .jstree a { display:-moz-inline-box; } .jstree .jstree-no-icons .jstree-checkbox { display:-moz-inline-stack !important; } "}g.vakata.css.add_sheet({str:i,title:"jstree"})});g.jstree.plugin("core",{__init:function(){this.data.core.locked=false;this.data.core.to_open=this.get_settings().core.initially_open;this.data.core.to_load=this.get_settings().core.initially_load},defaults:{html_titles:false,animation:500,initially_open:[],initially_load:[],open_parents:true,notify_plugins:true,rtl:false,load_open:false,strings:{loading:"Loading ...",new_node:"New node",multiple_selection:"Multiple selection"}},_fn:{init:function(){this.set_focus();if(this._get_settings().core.rtl){this.get_container().addClass("jstree-rtl").css("direction","rtl")}this.get_container().html("");this.data.core.li_height=this.get_container_ul().find("li.jstree-closed, li.jstree-leaf").eq(0).height()||18;this.get_container().delegate("li > ins","click.jstree",g.proxy(function(j){var i=g(j.target);this.toggle_node(i)},this)).bind("mousedown.jstree",g.proxy(function(){this.set_focus()},this)).bind("dblclick.jstree",function(j){var k;if(document.selection&&document.selection.empty){document.selection.empty()}else{if(window.getSelection){k=window.getSelection();try{k.removeAllRanges();k.collapse()}catch(i){}}}});if(this._get_settings().core.notify_plugins){this.get_container().bind("load_node.jstree",g.proxy(function(k,j){var l=this._get_node(j.rslt.obj),i=this;if(l===-1){l=this.get_container_ul()}if(!l.length){return}l.find("li").each(function(){var m=g(this);if(m.data("jstree")){g.each(m.data("jstree"),function(o,n){if(i.data[o]&&g.isFunction(i["_"+o+"_notify"])){i["_"+o+"_notify"].call(i,m,n)}})}})},this))}if(this._get_settings().core.load_open){this.get_container().bind("load_node.jstree",g.proxy(function(k,j){var l=this._get_node(j.rslt.obj),i=this;if(l===-1){l=this.get_container_ul()}if(!l.length){return}l.find("li.jstree-open:not(:has(ul))").each(function(){i.load_node(this,g.noop,g.noop)})},this))}this.__callback();this.load_node(-1,function(){this.loaded();this.reload_nodes()})},destroy:function(){var j,m=this.get_index(),k=this._get_settings(),l=this;g.each(k.plugins,function(n,p){try{e[p].__destroy.apply(l)}catch(o){}});this.__callback();if(this.is_focused()){for(j in h){if(h.hasOwnProperty(j)&&j!=m){h[j].set_focus();break}}}if(m===f){f=-1}this.get_container().unbind(".jstree").undelegate(".jstree").removeData("jstree_instance_id").find("[class^='jstree']").andSelf().attr("class",function(){return this.className.replace(/jstree[^ ]*|$/ig,"")});g(document).unbind(".jstree-"+m).undelegate(".jstree-"+m);h[m]=null;delete h[m]},_core_notify:function(j,i){if(i.opened){this.open_node(j,false,true)}},lock:function(){this.data.core.locked=true;this.get_container().children("ul").addClass("jstree-locked").css("opacity","0.7");this.__callback({})},unlock:function(){this.data.core.locked=false;this.get_container().children("ul").removeClass("jstree-locked").css("opacity","1");this.__callback({})},is_locked:function(){return this.data.core.locked},save_opened:function(){var i=this;this.data.core.to_open=[];this.get_container_ul().find("li.jstree-open").each(function(){if(this.id){i.data.core.to_open.push("#"+this.id.toString().replace(/^#/,"").replace(/\\\//g,"/").replace(/\//g,"\\/").replace(/\\\./g,".").replace(/\./g,"\\.").replace(/\:/g,"\\:"))}});this.__callback(i.data.core.to_open)},save_loaded:function(){},reload_nodes:function(j){var m=this,i=true,l=[],k=[];if(!j){this.data.core.reopen=false;this.data.core.refreshing=true;this.data.core.to_open=g.map(g.makeArray(this.data.core.to_open),function(o){return"#"+o.toString().replace(/^#/,"").replace(/\\\//g,"/").replace(/\//g,"\\/").replace(/\\\./g,".").replace(/\./g,"\\.").replace(/\:/g,"\\:")});this.data.core.to_load=g.map(g.makeArray(this.data.core.to_load),function(o){return"#"+o.toString().replace(/^#/,"").replace(/\\\//g,"/").replace(/\//g,"\\/").replace(/\\\./g,".").replace(/\./g,"\\.").replace(/\:/g,"\\:")});if(this.data.core.to_open.length){this.data.core.to_load=this.data.core.to_load.concat(this.data.core.to_open)}}if(this.data.core.to_load.length){g.each(this.data.core.to_load,function(n,o){if(o=="#"){return true}if(g(o).length){l.push(o)}else{k.push(o)}});if(l.length){this.data.core.to_load=k;g.each(l,function(n,o){if(!m._is_loaded(o)){m.load_node(o,function(){m.reload_nodes(true)},function(){m.reload_nodes(true)});i=false}})}}if(this.data.core.to_open.length){g.each(this.data.core.to_open,function(n,o){m.open_node(o,false,true)})}if(i){if(this.data.core.reopen){clearTimeout(this.data.core.reopen)}this.data.core.reopen=setTimeout(function(){m.__callback({},m)},50);this.data.core.refreshing=false;this.reopen()}},reopen:function(){var i=this;if(this.data.core.to_open.length){g.each(this.data.core.to_open,function(j,k){i.open_node(k,false,true)})}this.__callback({})},refresh:function(i){var j=this;this.save_opened();if(!i){i=-1}i=this._get_node(i);if(!i){i=-1}if(i!==-1){i.children("UL").remove()}else{this.get_container_ul().empty()}this.load_node(i,function(){j.__callback({obj:i});j.reload_nodes()})},loaded:function(){this.__callback()},set_focus:function(){if(this.is_focused()){return}var i=g.jstree._focused();if(i){i.unset_focus()}this.get_container().addClass("jstree-focused");f=this.get_index();this.__callback()},is_focused:function(){return f==this.get_index()},unset_focus:function(){if(this.is_focused()){this.get_container().removeClass("jstree-focused");f=-1}this.__callback()},_get_node:function(i){var j=g(i,this.get_container());if(j.is(".jstree")||i==-1){return -1}j=j.closest("li",this.get_container());return j.length?j:false},_get_next:function(j,i){j=this._get_node(j);if(j===-1){return this.get_container().find("> ul > li:first-child")}if(!j.length){return false}if(i){return(j.nextAll("li").size()>0)?j.nextAll("li:eq(0)"):false}if(j.hasClass("jstree-open")){return j.find("li:eq(0)")}else{if(j.nextAll("li").size()>0){return j.nextAll("li:eq(0)")}else{return j.parentsUntil(".jstree","li").next("li").eq(0)}}},_get_prev:function(j,i){j=this._get_node(j);if(j===-1){return this.get_container().find("> ul > li:last-child")}if(!j.length){return false}if(i){return(j.prevAll("li").length>0)?j.prevAll("li:eq(0)"):false}if(j.prev("li").length){j=j.prev("li").eq(0);while(j.hasClass("jstree-open")){j=j.children("ul:eq(0)").children("li:last")}return j}else{var k=j.parentsUntil(".jstree","li:eq(0)");return k.length?k:false}},_get_parent:function(i){i=this._get_node(i);if(i==-1||!i.length){return false}var j=i.parentsUntil(".jstree","li:eq(0)");return j.length?j:-1},_get_children:function(i){i=this._get_node(i);if(i===-1){return this.get_container().children("ul:eq(0)").children("li")}if(!i.length){return false}return i.children("ul:eq(0)").children("li")},get_path:function(k,i){var j=[],l=this;k=this._get_node(k);if(k===-1||!k||!k.length){return false}k.parentsUntil(".jstree","li").each(function(){j.push(i?this.id:l.get_text(this))});j.reverse();j.push(i?k.attr("id"):this.get_text(k));return j},_get_string:function(i){return this._get_settings().core.strings[i]||i},is_open:function(i){i=this._get_node(i);return i&&i!==-1&&i.hasClass("jstree-open")},is_closed:function(i){i=this._get_node(i);return i&&i!==-1&&i.hasClass("jstree-closed")},is_leaf:function(i){i=this._get_node(i);return i&&i!==-1&&i.hasClass("jstree-leaf")},correct_state:function(i){i=this._get_node(i);if(!i||i===-1){return false}i.removeClass("jstree-closed jstree-open").addClass("jstree-leaf").children("ul").remove();this.__callback({obj:i})},open_node:function(l,m,j){l=this._get_node(l);if(!l.length){return false}if(!l.hasClass("jstree-closed")){if(m){m.call()}return false}var k=j||c?0:this._get_settings().core.animation,i=this;if(!this._is_loaded(l)){l.children("a").addClass("jstree-loading");this.load_node(l,function(){i.open_node(l,m,j)},m)}else{if(this._get_settings().core.open_parents){l.parentsUntil(".jstree",".jstree-closed").each(function(){i.open_node(this,false,true)})}if(k){l.children("ul").css("display","none")}l.removeClass("jstree-closed").addClass("jstree-open").children("a").removeClass("jstree-loading");if(k){l.children("ul").stop(true,true).slideDown(k,function(){this.style.display="";i.after_open(l)})}else{i.after_open(l)}this.__callback({obj:l});if(m){m.call()}}},after_open:function(i){this.__callback({obj:i})},close_node:function(l,j){l=this._get_node(l);var k=j||c?0:this._get_settings().core.animation,i=this;if(!l.length||!l.hasClass("jstree-open")){return false}if(k){l.children("ul").attr("style","display:block !important")}l.removeClass("jstree-open").addClass("jstree-closed");if(k){l.children("ul").stop(true,true).slideUp(k,function(){this.style.display="";i.after_close(l)})}else{i.after_close(l)}this.__callback({obj:l})},after_close:function(i){this.__callback({obj:i})},toggle_node:function(i){i=this._get_node(i);if(i.hasClass("jstree-closed")){return this.open_node(i)}if(i.hasClass("jstree-open")){return this.close_node(i)}},open_all:function(k,j,i){k=k?this._get_node(k):-1;if(!k||k===-1){k=this.get_container_ul()}if(i){k=k.find("li.jstree-closed")}else{i=k;if(k.is(".jstree-closed")){k=k.find("li.jstree-closed").andSelf()}else{k=k.find("li.jstree-closed")}}var l=this;k.each(function(){var m=this;if(!l._is_loaded(this)){l.open_node(this,function(){l.open_all(m,j,i)},!j)}else{l.open_node(this,false,!j)}});if(i.find("li.jstree-closed").length===0){this.__callback({obj:i})}},close_all:function(j,i){var k=this;j=j?this._get_node(j):this.get_container();if(!j||j===-1){j=this.get_container_ul()}j.find("li.jstree-open").andSelf().each(function(){k.close_node(this,!i)});this.__callback({obj:j})},clean_node:function(i){i=i&&i!=-1?g(i):this.get_container_ul();i=i.is("li")?i.find("li").andSelf():i.find("li");i.removeClass("jstree-last").filter("li:last-child").addClass("jstree-last").end().filter(":has(li)").not(".jstree-open").removeClass("jstree-leaf").addClass("jstree-closed");i.not(".jstree-open, .jstree-closed").addClass("jstree-leaf").children("ul").remove();this.__callback({obj:i})},get_rollback:function(){this.__callback();return{i:this.get_index(),h:this.get_container().children("ul").clone(true),d:this.data}},set_rollback:function(i,j){this.get_container().empty().append(i);this.data=j;this.__callback()},load_node:function(k,i,j){this.__callback({obj:k})},_is_loaded:function(i){return true},create_node:function(n,i,m,p,j){n=this._get_node(n);i=typeof i==="undefined"?"last":i;var o=g("
  • "),l=this._get_settings().core,k;if(n!==-1&&!n.length){return false}if(!j&&!this._is_loaded(n)){this.load_node(n,function(){this.create_node(n,i,m,p,true)});return false}this.__rollback();if(typeof m==="string"){m={data:m}}if(!m){m={}}if(m.attr){o.attr(m.attr)}if(m.metadata){o.data(m.metadata)}if(m.state){o.addClass("jstree-"+m.state)}if(!m.data){m.data=this._get_string("new_node")}if(!g.isArray(m.data)){k=m.data;m.data=[];m.data.push(k)}g.each(m.data,function(r,q){k=g("");if(g.isFunction(q)){q=q.call(this,m)}if(typeof q=="string"){k.attr("href","#")[l.html_titles?"html":"text"](q)}else{if(!q.attr){q.attr={}}if(!q.attr.href){q.attr.href="#"}k.attr(q.attr)[l.html_titles?"html":"text"](q.title);if(q.language){k.addClass(q.language)}}k.prepend(" ");if(!q.icon&&m.icon){q.icon=m.icon}if(q.icon){if(q.icon.indexOf("/")===-1){k.children("ins").addClass(q.icon)}else{k.children("ins").css("background","url('"+q.icon+"') center center no-repeat")}}o.append(k)});o.prepend(" ");if(n===-1){n=this.get_container();if(i==="before"){i="first"}if(i==="after"){i="last"}}switch(i){case"before":n.before(o);k=this._get_parent(n);break;case"after":n.after(o);k=this._get_parent(n);break;case"inside":case"first":if(!n.children("ul").length){n.append("




  • © 2015 - 2025 Weber Informatics LLC | Privacy Policy