1 line
94 KiB
JavaScript
1 line
94 KiB
JavaScript
|
"use strict";(function($){$.vakata={};$.vakata.css={get_css:function(rule_name,delete_flag,sheet){rule_name=rule_name.toLowerCase();var css_rules=sheet.cssRules||sheet.rules,j=0;do{if(css_rules.length&&j>css_rules.length+5){return false}if(css_rules[j].selectorText&&css_rules[j].selectorText.toLowerCase()==rule_name){if(delete_flag===true){if(sheet.removeRule){sheet.removeRule(j)}if(sheet.deleteRule){sheet.deleteRule(j)}return true}else{return css_rules[j]}}}while(css_rules[++j]);return false},add_css:function(rule_name,sheet){if($.jstree.css.get_css(rule_name,false,sheet)){return false}if(sheet.insertRule){sheet.insertRule(rule_name+" { }",0)}else{sheet.addRule(rule_name,null,0)}return $.vakata.css.get_css(rule_name)},remove_css:function(rule_name,sheet){return $.vakata.css.get_css(rule_name,true,sheet)},add_sheet:function(opts){var tmp;if(opts.str){tmp=document.createElement("style");tmp.setAttribute("type","text/css");if(tmp.styleSheet){document.getElementsByTagName("head")[0].appendChild(tmp);tmp.styleSheet.cssText=opts.str}else{tmp.appendChild(document.createTextNode(opts.str));document.getElementsByTagName("head")[0].appendChild(tmp)}return tmp.sheet||tmp.styleSheet}if(opts.url){if(document.createStyleSheet){try{tmp=document.createStyleSheet(opts.url)}catch(e){}}else{tmp=document.createElement("link");tmp.rel="stylesheet";tmp.type="text/css";tmp.media="all";tmp.href=opts.url;document.getElementsByTagName("head")[0].appendChild(tmp);return tmp.styleSheet}}}}})(jQuery);(function($){var instances=[],focused_instance=-1,plugins={},prepared_move={},is_ie6=false;$.fn.jstree=function(settings){var isMethodCall=(typeof settings=="string"),args=Array.prototype.slice.call(arguments,1),returnValue=this;if(!isMethodCall&&$.meta){args.push($.metadata.get(this).jstree)}settings=!isMethodCall&&args.length?$.extend.apply(null,[true,settings].concat(args)):settings;if(isMethodCall&&settings.substring(0,1)=="_"){return returnValue}if(isMethodCall){this.each(function(){var instance=instances[$.data(this,"jstree-instance-id")],methodValue=(instance&&$.isFunction(instance[settings]))?instance[settings].apply(instance,args):instance;if(typeof methodValue!=="undefined"&&(settings.indexOf("is_"===0)||(methodValue!==true&&methodValue!==false))){returnValue=methodValue;return false}})}else{this.each(function(){var instance_id=$.data(this,"jstree-instance-id"),s=false;if(typeof instance_id!=="undefined"&&instances[instance_id]){instances[instance_id].destroy()}instance_id=parseInt(instances.push({}),10)-1;$.data(this,"jstree-instance-id",instance_id);if(!settings){settings={}}settings.plugins=$.isArray(settings.plugins)?settings.plugins:$.jstree.defaults.plugins;if($.inArray("core",settings.plugins)===-1){settings.plugins.unshift("core")}s=$.extend(true,{},$.jstree.defaults,settings);s.plugins=settings.plugins;$.each(plugins,function(i,val){if($.inArray(i,s.plugins)===-1){s[i]=null;delete s[i]}});instances[instance_id]=new $.jstree._instance(instance_id,$(this).addClass("jstree jstree-"+instance_id),s);$.each(instances[instance_id]._get_settings().plugins,function(i,val){instances[instance_id].data[val]={}});$.each(instances[instance_id]._get_settings().plugins,function(i,val){if(plugins[val]){plugins[val].__init.apply(instances[instance_id])}});instances[instance_id].init()})}return returnValue};$.jstree={defaults:{plugins:[]},_focused:function(){return instances[focused_instance]||null},_reference:function(needle){if(instances[needle]){return instances[needle]}var o=$(needle);if(!o.length&&typeof needle==="string"){o=$("#"+needle)}if(!o.length){return null}return instances[o.closest(".jstree").data("jstree-instance-id")]||null},_instance:function(index,container,settings){this.data={core:{}};this.get_settings=function(){return $.extend(true,{},settings)};this._get_settings=function(){return settings};this.get_index=function(){return index};this.get_container=function(){return container};this._set_settings=function(s){settings=$.extend(true,{},settings,s)}},_fn:{},plugin:function(pname,pdata){pdata=$.extend({},{__init:$.noop,__destroy:$.no
|