2012-11-23 16:31:57 +00:00
|
|
|
"use strict";(function(){if(jQuery&&jQuery.jstree)return;var is_ie6=false,is_ie7=false,is_ff2=false;(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=false,is_new=true;if(opts.str){if(opts.title)tmp=$("style[id='"+opts.title+"-stylesheet']")[0];if(tmp){is_new=false}else{tmp=document.createElement("style");tmp.setAttribute('type',"text/css");if(opts.title)tmp.setAttribute("id",opts.title+"-stylesheet")};if(tmp.styleSheet){if(is_new){document.getElementsByTagName("head")[0].appendChild(tmp);tmp.styleSheet.cssText=opts.str}else tmp.styleSheet.cssText=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}}};var instances=[],focused_instance=-1,plugins={},prepared_move={};$.fn.jstree=function(settings){var isMethodCall=(typeof settings=='string'),args=Array.prototype.slice.call(arguments,1),returnValue=this;if(isMethodCall){if(settings.substring(0,1)=='_')return returnValue;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"),a=[],b=settings?$.extend({},true,settings):{},c=$(this),s=false,t=[];a=a.concat(args);if(c.data("jstree"))a.push(c.data("jstree"));b=a.length?$.extend.apply(null,[true,b].concat(a)):b;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);b.plugins=$.isArray(b.plugins)?b.plugins:$.jstree.defaults.plugins.slice();b.plugins.unshift("core");b.plugins=b.plugins.sort().join(",,").replace(/(,|^)([^,]+)(,,\2)+(,|$)/g,"$1$2$4").replace(/,,+/g,",").replace(/,$/,"").split(",");s=$.extend(true,{},$.jstree.defaults,b);s.plugins=b.plugins;$.each(plugins,function(i,val){if($.inArray(i,s.plugins)===-1){s[i]=null;delete s[i]}else t.push(i)});s.plugins=t;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])});setTimeout(function(){if(instances[instance_id])instances[instance_id].init()},0)});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,co
|
|
|
|
function exec(i,event){var f=$.jstree._focused(),tmp;if(f&&f.data&&f.data.hotkeys&&f.data.hotkeys.enabled){tmp=f._get_settings().hotkeys[i];if(tmp)return tmp.call(f,event)}};$.jstree.plugin("hotkeys",{__init:function(){if(typeof $.hotkeys==="undefined")throw"jsTree hotkeys: jQuery hotkeys plugin not included.";if(!this.data.ui)throw"jsTree hotkeys: jsTree UI plugin not included.";$.each(this._get_settings().hotkeys,function(i,v){if(v!==false&&$.inArray(i,bound)==-1){$(document).bind("keydown",i,function(event){return exec(i,event)});bound.push(i)}});this.get_container().bind("lock.jstree",$.proxy(function(){if(this.data.hotkeys.enabled){this.data.hotkeys.enabled=false;this.data.hotkeys.revert=true}},this)).bind("unlock.jstree",$.proxy(function(){if(this.data.hotkeys.revert)this.data.hotkeys.enabled=true},this));this.enable_hotkeys()},defaults:{up:function(){var o=this.data.ui.hovered||this.data.ui.last_selected||-1;this.hover_node(this._get_prev(o));return false},"ctrl+up":function(){var o=this.data.ui.hovered||this.data.ui.last_selected||-1;this.hover_node(this._get_prev(o));return false},"shift+up":function(){var o=this.data.ui.hovered||this.data.ui.last_selected||-1;this.hover_node(this._get_prev(o));return false},down:function(){var o=this.data.ui.hovered||this.data.ui.last_selected||-1;this.hover_node(this._get_next(o));return false},"ctrl+down":function(){var o=this.data.ui.hovered||this.data.ui.last_selected||-1;this.hover_node(this._get_next(o));return false},"shift+down":function(){var o=this.data.ui.hovered||this.data.ui.last_selected||-1;this.hover_node(this._get_next(o));return false},left:function(){var o=this.data.ui.hovered||this.data.ui.last_selected;if(o)if(o.hasClass("jstree-open")){this.close_node(o)}else this.hover_node(this._get_prev(o));return false},"ctrl+left":function(){var o=this.data.ui.hovered||this.data.ui.last_selected;if(o)if(o.hasClass("jstree-open")){this.close_node(o)}else this.hover_node(this._get_prev(o));return false},"shift+left":function(){var o=this.data.ui.hovered||this.data.ui.last_selected;if(o)if(o.hasClass("jstree-open")){this.close_node(o)}else this.hover_node(this._get_prev(o));return false},right:function(){var o=this.data.ui.hovered||this.data.ui.last_selected;if(o&&o.length)if(o.hasClass("jstree-closed")){this.open_node(o)}else this.hover_node(this._get_next(o));return false},"ctrl+right":function(){var o=this.data.ui.hovered||this.data.ui.last_selected;if(o&&o.length)if(o.hasClass("jstree-closed")){this.open_node(o)}else this.hover_node(this._get_next(o));return false},"shift+right":function(){var o=this.data.ui.hovered||this.data.ui.last_selected;if(o&&o.length)if(o.hasClass("jstree-closed")){this.open_node(o)}else this.hover_node(this._get_next(o));return false},space:function(){if(this.data.ui.hovered)this.data.ui.hovered.children("a:eq(0)").click();return false},"ctrl+space":function(event){event.type="click";if(this.data.ui.hovered)this.data.ui.hovered.children("a:eq(0)").trigger(event);return false},"shift+space":function(event){event.type="click";if(this.data.ui.hovered)this.data.ui.hovered.children("a:eq(0)").trigger(event);return false},f2:function(){this.rename(this.data.ui.hovered||this.data.ui.last_selected)},del:function(){this.remove(this.data.ui.hovered||this._get_node(null))}},_fn:{enable_hotkeys:function(){this.data.hotkeys.enabled=true},disable_hotkeys:function(){this.data.hotkeys.enabled=false}}})})(jQuery);(function($){$.jstree.plugin("json_data",{__init:function(){var s=this._get_settings().json_data;if(s.progressive_unload)this.get_container().bind("after_close.jstree",function(e,data){data.rslt.obj.children("ul").remove()})},defaults:{data:false,ajax:false,correct_state:true,progressive_render:false,progressive_unload:false},_fn:{load_node:function(obj,s_call,e_call){var _this=this;this.load_node_json(obj,function(){_this.__callback({obj:_this._get_node(obj)});s_call.call(this)},e_call)},_is_loaded:function(obj){var s=this._get_settings().json_data;obj=this._get_node(obj);return obj==-1||!obj||(!s.ajax&&!s.progressive_render&&!$.isFunction(s.data)
|