(function(factory){"use strict";if(typeof define==='function'&&define.amd){define(['jquery'],factory);} else if(typeof module!=='undefined'&&module.exports){module.exports=factory(require('jquery'));} else{factory(jQuery);}}(function($,undefined){"use strict";if($.jstree){return;} var instance_counter=0,ccp_node=false,ccp_mode=false,ccp_inst=false,themes_loaded=[],src=$('script:last').attr('src'),document=window.document;var setImmediate=window.setImmediate;var Promise=window.Promise;if(!setImmediate&&Promise){setImmediate=function(cb,arg){Promise.resolve(arg).then(cb);};} $.jstree={version:'3.3.9',defaults:{plugins:[]},plugins:{},path:src&&src.indexOf('/')!==-1?src.replace(/\/[^\/]+$/,''):'',idregex:/[\\:&!^|()\[\]<>@*'+~#";.,=\- \/${}%?`]/g,root:'#'};$.jstree.create=function(el,options){var tmp=new $.jstree.core(++instance_counter),opt=options;options=$.extend(true,{},$.jstree.defaults,options);if(opt&&opt.plugins){options.plugins=opt.plugins;} $.each(options.plugins,function(i,k){if(i!=='core'){tmp=tmp.plugin(k,options[k]);}});$(el).data('jstree',tmp);tmp.init(el,options);return tmp;};$.jstree.destroy=function(){$('.jstree:jstree').jstree('destroy');$(document).off('.jstree');};$.jstree.core=function(id){this._id=id;this._cnt=0;this._wrk=null;this._data={core:{themes:{name:false,dots:false,icons:false,ellipsis:false},selected:[],last_error:{},working:false,worker_queue:[],focused:null}};};$.jstree.reference=function(needle){var tmp=null,obj=null;if(needle&&needle.id&&(!needle.tagName||!needle.nodeType)){needle=needle.id;} if(!obj||!obj.length){try{obj=$(needle);}catch(ignore){}} if(!obj||!obj.length){try{obj=$('#'+needle.replace($.jstree.idregex,'\\$&'));}catch(ignore){}} if(obj&&obj.length&&(obj=obj.closest('.jstree')).length&&(obj=obj.data('jstree'))){tmp=obj;} else{$('.jstree').each(function(){var inst=$(this).data('jstree');if(inst&&inst._model.data[needle]){tmp=inst;return false;}});} return tmp;};$.fn.jstree=function(arg){var is_method=(typeof arg==='string'),args=Array.prototype.slice.call(arguments,1),result=null;if(arg===true&&!this.length){return false;} this.each(function(){var instance=$.jstree.reference(this),method=is_method&&instance?instance[arg]:null;result=is_method&&method?method.apply(instance,args):null;if(!instance&&!is_method&&(arg===undefined||$.isPlainObject(arg))){$.jstree.create(this,arg);} if((instance&&!is_method)||arg===true){result=instance||false;} if(result!==null&&result!==undefined){return false;}});return result!==null&&result!==undefined?result:this;};$.expr.pseudos.jstree=$.expr.createPseudo(function(search){return function(a){return $(a).hasClass('jstree')&&$(a).data('jstree')!==undefined;};});$.jstree.defaults.core={data:false,strings:false,check_callback:false,error:$.noop,animation:200,multiple:true,themes:{name:false,url:false,dir:false,dots:true,icons:true,ellipsis:false,stripes:false,variant:false,responsive:false},expand_selected_onload:true,worker:true,force_text:false,dblclick_toggle:true,loaded_state:false,restore_focus:true,keyboard:{'ctrl-space':function(e){e.type="click";$(e.currentTarget).trigger(e);},'enter':function(e){e.type="click";$(e.currentTarget).trigger(e);},'left':function(e){e.preventDefault();if(this.is_open(e.currentTarget)){this.close_node(e.currentTarget);} else{var o=this.get_parent(e.currentTarget);if(o&&o.id!==$.jstree.root){this.get_node(o,true).children('.jstree-anchor').focus();}}},'up':function(e){e.preventDefault();var o=this.get_prev_dom(e.currentTarget);if(o&&o.length){o.children('.jstree-anchor').focus();}},'right':function(e){e.preventDefault();if(this.is_closed(e.currentTarget)){this.open_node(e.currentTarget,function(o){this.get_node(o,true).children('.jstree-anchor').focus();});} else if(this.is_open(e.currentTarget)){var o=this.get_node(e.currentTarget,true).children('.jstree-children')[0];if(o){$(this._firstChild(o)).children('.jstree-anchor').focus();}}},'down':function(e){e.preventDefault();var o=this.get_next_dom(e.currentTarget);if(o&&o.length){o.children('.jstree-anchor').focus();}},'*':function(e){this.open_all();},'home':function(e){e.preventDefault();var o=this._firstChild(this.get_container_ul()[0]);if(o){$(o).children('.jstree-anchor').filter(':visible').focus();}},'end':function(e){e.preventDefault();this.element.find('.jstree-anchor').filter(':visible').last().focus();},'f2':function(e){e.preventDefault();this.edit(e.currentTarget);}}};$.jstree.core.prototype={plugin:function(deco,opts){var Child=$.jstree.plugins[deco];if(Child){this._data[deco]={};Child.prototype=this;return new Child(opts,this);} return this;},init:function(el,options){this._model={data:{},changed:[],force_full_redraw:false,redraw_timeout:false,default_state:{loaded:true,opened:false,selected:false,disabled:false}};this._model.data[$.jstree.root]={id:$.jstree.root,parent:null,parents:[],children:[],children_d:[],state:{loaded:false}};this.element=$(el).addClass('jstree jstree-'+this._id);this.settings=options;this._data.core.ready=false;this._data.core.loaded=false;this._data.core.rtl=(this.element.css("direction")==="rtl");this.element[this._data.core.rtl?'addClass':'removeClass']("jstree-rtl");this.element.attr('role','tree');if(this.settings.core.multiple){this.element.attr('aria-multiselectable',true);} if(!this.element.attr('tabindex')){this.element.attr('tabindex','0');} this.bind();this.trigger("init");this._data.core.original_container_html=this.element.find(" > ul > li").clone(true);this._data.core.original_container_html.find("li").addBack().contents().filter(function(){return this.nodeType===3&&(!this.nodeValue||/^\s+$/.test(this.nodeValue));}).remove();this.element.html("<"+"ul class='jstree-container-ul jstree-children' role='group'><"+"li id='j"+this._id+"_loading' class='jstree-initial-node jstree-loading jstree-leaf jstree-last' role='treeitem'><"+"a class='jstree-anchor' href='#'>"+this.get_string("Loading ...")+"");this.element.attr('aria-activedescendant','j'+this._id+'_loading');this._data.core.li_height=this.get_container_ul().children("li").first().outerHeight()||24;this._data.core.node=this._create_prototype_node();this.trigger("loading");this.load_node($.jstree.root);},destroy:function(keep_html){this.trigger("destroy");if(this._wrk){try{window.URL.revokeObjectURL(this._wrk);this._wrk=null;} catch(ignore){}} if(!keep_html){this.element.empty();} this.teardown();},_create_prototype_node:function(){var _node=document.createElement('LI'),_temp1,_temp2;_node.setAttribute('role','treeitem');_temp1=document.createElement('I');_temp1.className='jstree-icon jstree-ocl';_temp1.setAttribute('role','presentation');_node.appendChild(_temp1);_temp1=document.createElement('A');_temp1.className='jstree-anchor';_temp1.setAttribute('href','#');_temp1.setAttribute('tabindex','-1');_temp2=document.createElement('I');_temp2.className='jstree-icon jstree-themeicon';_temp2.setAttribute('role','presentation');_temp1.appendChild(_temp2);_node.appendChild(_temp1);_temp1=_temp2=null;return _node;},_kbevent_to_func:function(e){var keys={8:"Backspace",9:"Tab",13:"Enter",19:"Pause",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"Print",45:"Insert",46:"Delete",96:"Numpad0",97:"Numpad1",98:"Numpad2",99:"Numpad3",100:"Numpad4",101:"Numpad5",102:"Numpad6",103:"Numpad7",104:"Numpad8",105:"Numpad9",'-13':"NumpadEnter",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"Numlock",145:"Scrolllock",16:'Shift',17:'Ctrl',18:'Alt',48:'0',49:'1',50:'2',51:'3',52:'4',53:'5',54:'6',55:'7',56:'8',57:'9',59:';',61:'=',65:'a',66:'b',67:'c',68:'d',69:'e',70:'f',71:'g',72:'h',73:'i',74:'j',75:'k',76:'l',77:'m',78:'n',79:'o',80:'p',81:'q',82:'r',83:'s',84:'t',85:'u',86:'v',87:'w',88:'x',89:'y',90:'z',107:'+',109:'-',110:'.',186:';',187:'=',188:',',189:'-',190:'.',191:'/',192:'`',219:'[',220:'\\',221:']',222:"'",111:'/',106:'*',173:'-'};var parts=[];if(e.ctrlKey){parts.push('ctrl');} if(e.altKey){parts.push('alt');} if(e.shiftKey){parts.push('shift');} parts.push(keys[e.which]||e.which);parts=parts.sort().join('-').toLowerCase();if(parts==='shift-shift'||parts==='ctrl-ctrl'||parts==='alt-alt'){return null;} var kb=this.settings.core.keyboard,i,tmp;for(i in kb){if(kb.hasOwnProperty(i)){tmp=i;if(tmp!=='-'&&tmp!=='+'){tmp=tmp.replace('--','-MINUS').replace('+-','-MINUS').replace('++','-PLUS').replace('-+','-PLUS');tmp=tmp.split(/-|\+/).sort().join('-').replace('MINUS','-').replace('PLUS','+').toLowerCase();} if(tmp===parts){return kb[i];}}} return null;},teardown:function(){this.unbind();this.element.removeClass('jstree').removeData('jstree').find("[class^='jstree']").addBack().attr("class",function(){return this.className.replace(/jstree[^ ]*|$/ig,'');});this.element=null;},bind:function(){var word='',tout=null,was_click=0;this.element.on("dblclick.jstree",function(e){if(e.target.tagName&&e.target.tagName.toLowerCase()==="input"){return true;} if(document.selection&&document.selection.empty){document.selection.empty();} else{if(window.getSelection){var sel=window.getSelection();try{sel.removeAllRanges();sel.collapse();}catch(ignore){}}}}).on("mousedown.jstree",$.proxy(function(e){if(e.target===this.element[0]){e.preventDefault();was_click=+(new Date());}},this)).on("mousedown.jstree",".jstree-ocl",function(e){e.preventDefault();}).on("click.jstree",".jstree-ocl",$.proxy(function(e){this.toggle_node(e.target);},this)).on("dblclick.jstree",".jstree-anchor",$.proxy(function(e){if(e.target.tagName&&e.target.tagName.toLowerCase()==="input"){return true;} if(this.settings.core.dblclick_toggle){this.toggle_node(e.target);}},this)).on("click.jstree",".jstree-anchor",$.proxy(function(e){e.preventDefault();if(e.currentTarget!==document.activeElement){$(e.currentTarget).focus();} this.activate_node(e.currentTarget,e);},this)).on('keydown.jstree','.jstree-anchor',$.proxy(function(e){if(e.target.tagName&&e.target.tagName.toLowerCase()==="input"){return true;} if(this._data.core.rtl){if(e.which===37){e.which=39;} else if(e.which===39){e.which=37;}} var f=this._kbevent_to_func(e);if(f){var r=f.call(this,e);if(r===false||r===true){return r;}}},this)).on("load_node.jstree",$.proxy(function(e,data){if(data.status){if(data.node.id===$.jstree.root&&!this._data.core.loaded){this._data.core.loaded=true;if(this._firstChild(this.get_container_ul()[0])){this.element.attr('aria-activedescendant',this._firstChild(this.get_container_ul()[0]).id);} this.trigger("loaded");} if(!this._data.core.ready){setTimeout($.proxy(function(){if(this.element&&!this.get_container_ul().find('.jstree-loading').length){this._data.core.ready=true;if(this._data.core.selected.length){if(this.settings.core.expand_selected_onload){var tmp=[],i,j;for(i=0,j=this._data.core.selected.length;i1){col.slice(ind).each($.proxy(function(i,v){if($(v).text().toLowerCase().indexOf(word)===0){$(v).focus();end=true;return false;}},this));if(end){return;} col.slice(0,ind).each($.proxy(function(i,v){if($(v).text().toLowerCase().indexOf(word)===0){$(v).focus();end=true;return false;}},this));if(end){return;}} if(new RegExp('^'+chr.replace(/[-\/\\^$*+?.()|[\]{}]/g,'\\$&')+'+$').test(word)){col.slice(ind+1).each($.proxy(function(i,v){if($(v).text().toLowerCase().charAt(0)===chr){$(v).focus();end=true;return false;}},this));if(end){return;} col.slice(0,ind+1).each($.proxy(function(i,v){if($(v).text().toLowerCase().charAt(0)===chr){$(v).focus();end=true;return false;}},this));if(end){return;}}},this)).on("init.jstree",$.proxy(function(){var s=this.settings.core.themes;this._data.core.themes.dots=s.dots;this._data.core.themes.stripes=s.stripes;this._data.core.themes.icons=s.icons;this._data.core.themes.ellipsis=s.ellipsis;this.set_theme(s.name||"default",s.url);this.set_theme_variant(s.variant);},this)).on("loading.jstree",$.proxy(function(){this[this._data.core.themes.dots?"show_dots":"hide_dots"]();this[this._data.core.themes.icons?"show_icons":"hide_icons"]();this[this._data.core.themes.stripes?"show_stripes":"hide_stripes"]();this[this._data.core.themes.ellipsis?"show_ellipsis":"hide_ellipsis"]();},this)).on('blur.jstree','.jstree-anchor',$.proxy(function(e){this._data.core.focused=null;$(e.currentTarget).filter('.jstree-hovered').trigger('mouseleave');this.element.attr('tabindex','0');},this)).on('focus.jstree','.jstree-anchor',$.proxy(function(e){var tmp=this.get_node(e.currentTarget);if(tmp&&tmp.id){this._data.core.focused=tmp.id;} this.element.find('.jstree-hovered').not(e.currentTarget).trigger('mouseleave');$(e.currentTarget).trigger('mouseenter');this.element.attr('tabindex','-1');},this)).on('focus.jstree',$.proxy(function(){if(+(new Date())-was_click>500&&!this._data.core.focused&&this.settings.core.restore_focus){was_click=0;var act=this.get_node(this.element.attr('aria-activedescendant'),true);if(act){act.find('> .jstree-anchor').focus();}}},this)).on('mouseenter.jstree','.jstree-anchor',$.proxy(function(e){this.hover_node(e.currentTarget);},this)).on('mouseleave.jstree','.jstree-anchor',$.proxy(function(e){this.dehover_node(e.currentTarget);},this));},unbind:function(){this.element.off('.jstree');$(document).off('.jstree-'+this._id);},trigger:function(ev,data){if(!data){data={};} data.instance=this;this.element.triggerHandler(ev.replace('.jstree','')+'.jstree',data);},get_container:function(){return this.element;},get_container_ul:function(){return this.element.children(".jstree-children").first();},get_string:function(key){var a=this.settings.core.strings;if($.isFunction(a)){return a.call(this,key);} if(a&&a[key]){return a[key];} return key;},_firstChild:function(dom){dom=dom?dom.firstChild:null;while(dom!==null&&dom.nodeType!==1){dom=dom.nextSibling;} return dom;},_nextSibling:function(dom){dom=dom?dom.nextSibling:null;while(dom!==null&&dom.nodeType!==1){dom=dom.nextSibling;} return dom;},_previousSibling:function(dom){dom=dom?dom.previousSibling:null;while(dom!==null&&dom.nodeType!==1){dom=dom.previousSibling;} return dom;},get_node:function(obj,as_dom){if(obj&&obj.id){obj=obj.id;} if(obj instanceof $&&obj.length&&obj[0].id){obj=obj[0].id;} var dom;try{if(this._model.data[obj]){obj=this._model.data[obj];} else if(typeof obj==="string"&&this._model.data[obj.replace(/^#/,'')]){obj=this._model.data[obj.replace(/^#/,'')];} else if(typeof obj==="string"&&(dom=$('#'+obj.replace($.jstree.idregex,'\\$&'),this.element)).length&&this._model.data[dom.closest('.jstree-node').attr('id')]){obj=this._model.data[dom.closest('.jstree-node').attr('id')];} else if((dom=this.element.find(obj)).length&&this._model.data[dom.closest('.jstree-node').attr('id')]){obj=this._model.data[dom.closest('.jstree-node').attr('id')];} else if((dom=this.element.find(obj)).length&&dom.hasClass('jstree')){obj=this._model.data[$.jstree.root];} else{return false;} if(as_dom){obj=obj.id===$.jstree.root?this.element:$('#'+obj.id.replace($.jstree.idregex,'\\$&'),this.element);} return obj;}catch(ex){return false;}},get_path:function(obj,glue,ids){obj=obj.parents?obj:this.get_node(obj);if(!obj||obj.id===$.jstree.root||!obj.parents){return false;} var i,j,p=[];p.push(ids?obj.id:obj.text);for(i=0,j=obj.parents.length;i0);},is_loaded:function(obj){obj=this.get_node(obj);return obj&&obj.state.loaded;},is_loading:function(obj){obj=this.get_node(obj);return obj&&obj.state&&obj.state.loading;},is_open:function(obj){obj=this.get_node(obj);return obj&&obj.state.opened;},is_closed:function(obj){obj=this.get_node(obj);return obj&&this.is_parent(obj)&&!obj.state.opened;},is_leaf:function(obj){return!this.is_parent(obj);},load_node:function(obj,callback){var k,l,i,j,c;if($.isArray(obj)){this._load_nodes(obj.slice(),callback);return true;} obj=this.get_node(obj);if(!obj){if(callback){callback.call(this,obj,false);} return false;} if(obj.state.loaded){obj.state.loaded=false;for(i=0,j=obj.parents.length;i').html(tmp);data.text=this.settings.core.force_text?tmp.text():tmp.html();tmp=d.data();data.data=tmp?$.extend(true,{},tmp):null;data.state.opened=d.hasClass('jstree-open');data.state.selected=d.children('a').hasClass('jstree-clicked');data.state.disabled=d.children('a').hasClass('jstree-disabled');if(data.data&&data.data.jstree){for(i in data.data.jstree){if(data.data.jstree.hasOwnProperty(i)){data.state[i]=data.data.jstree[i];}}} tmp=d.children("a").children(".jstree-themeicon");if(tmp.length){data.icon=tmp.hasClass('jstree-themeicon-hidden')?false:tmp.attr('rel');} if(data.state.icon!==undefined){data.icon=data.state.icon;} if(data.icon===undefined||data.icon===null||data.icon===""){data.icon=true;} tmp=d.children("ul").children("li");do{tid='j'+this._id+'_'+(++this._cnt);}while(m[tid]);data.id=data.li_attr.id?data.li_attr.id.toString():tid;if(tmp.length){tmp.each($.proxy(function(i,v){c=this._parse_model_from_html($(v),data.id,ps);e=this._model.data[c];data.children.push(c);if(e.children_d.length){data.children_d=data.children_d.concat(e.children_d);}},this));data.children_d=data.children_d.concat(data.children);} else{if(d.hasClass('jstree-closed')){data.state.loaded=false;}} if(data.li_attr['class']){data.li_attr['class']=data.li_attr['class'].replace('jstree-closed','').replace('jstree-open','');} if(data.a_attr['class']){data.a_attr['class']=data.a_attr['class'].replace('jstree-clicked','').replace('jstree-disabled','');} m[data.id]=data;if(data.state.selected){this._data.core.selected.push(data.id);} return data.id;},_parse_model_from_flat_json:function(d,p,ps){if(!ps){ps=[];} else{ps=ps.concat();} if(p){ps.unshift(p);} var tid=d.id.toString(),m=this._model.data,df=this._model.default_state,i,j,c,e,tmp={id:tid,text:d.text||'',icon:d.icon!==undefined?d.icon:true,parent:p,parents:ps,children:d.children||[],children_d:d.children_d||[],data:d.data,state:{},li_attr:{id:false},a_attr:{href:'#'},original:false};for(i in df){if(df.hasOwnProperty(i)){tmp.state[i]=df[i];}} if(d&&d.data&&d.data.jstree&&d.data.jstree.icon){tmp.icon=d.data.jstree.icon;} if(tmp.icon===undefined||tmp.icon===null||tmp.icon===""){tmp.icon=true;} if(d&&d.data){tmp.data=d.data;if(d.data.jstree){for(i in d.data.jstree){if(d.data.jstree.hasOwnProperty(i)){tmp.state[i]=d.data.jstree[i];}}}} if(d&&typeof d.state==='object'){for(i in d.state){if(d.state.hasOwnProperty(i)){tmp.state[i]=d.state[i];}}} if(d&&typeof d.li_attr==='object'){for(i in d.li_attr){if(d.li_attr.hasOwnProperty(i)){tmp.li_attr[i]=d.li_attr[i];}}} if(!tmp.li_attr.id){tmp.li_attr.id=tid;} if(d&&typeof d.a_attr==='object'){for(i in d.a_attr){if(d.a_attr.hasOwnProperty(i)){tmp.a_attr[i]=d.a_attr[i];}}} if(d&&d.children&&d.children===true){tmp.state.loaded=false;tmp.children=[];tmp.children_d=[];} m[tmp.id]=tmp;for(i=0,j=tmp.children.length;i<"+"li class='jstree-initial-node jstree-loading jstree-leaf jstree-last' role='treeitem' id='j"+this._id+"_loading'><"+"a class='jstree-anchor' href='#'>"+this.get_string("Loading ...")+"");this.element.attr('aria-activedescendant','j'+this._id+'_loading');} this.load_node($.jstree.root,function(o,s){if(s){this.get_container_ul()[0].className=c;if(this._firstChild(this.get_container_ul()[0])){this.element.attr('aria-activedescendant',this._firstChild(this.get_container_ul()[0]).id);} this.set_state($.extend(true,{},this._data.core.state),function(){this.trigger('refresh');});} this._data.core.state=null;});},refresh_node:function(obj){obj=this.get_node(obj);if(!obj||obj.id===$.jstree.root){return false;} var opened=[],to_load=[],s=this._data.core.selected.concat([]);to_load.push(obj.id);if(obj.state.opened===true){opened.push(obj.id);} this.get_node(obj,true).find('.jstree-open').each(function(){to_load.push(this.id);opened.push(this.id);});this._load_nodes(to_load,$.proxy(function(nodes){this.open_node(opened,false,0);this.select_node(s);this.trigger('refresh_node',{'node':obj,'nodes':nodes});},this),false,true);},set_id:function(obj,id){obj=this.get_node(obj);if(!obj||obj.id===$.jstree.root){return false;} var i,j,m=this._model.data,old=obj.id;id=id.toString();m[obj.parent].children[$.inArray(obj.id,m[obj.parent].children)]=id;for(i=0,j=obj.parents.length;ipar.children.length){pos=par.children.length;} if(!node.id){node.id=true;} if(!this.check("create_node",node,par,pos)){this.settings.core.error.call(this,this._data.core.last_error);return false;} if(node.id===true){delete node.id;} node=this._parse_model_from_json(node,par.id,par.parents.concat());if(!node){return false;} tmp=this.get_node(node);dpc=[];dpc.push(node);dpc=dpc.concat(tmp.children_d);this.trigger('model',{"nodes":dpc,"parent":par.id});par.children_d=par.children_d.concat(dpc);for(i=0,j=par.parents.length;i=pos?i+1:i]=par.children[i];} tmp[pos]=node.id;par.children=tmp;this.redraw_node(par,true);this.trigger('create_node',{"node":this.get_node(node),"parent":par.id,"position":pos});if(callback){callback.call(this,this.get_node(node));} return node.id;},rename_node:function(obj,val){var t1,t2,old;if($.isArray(obj)){obj=obj.slice();for(t1=0,t2=obj.length;t1new_par.children.length){pos=new_par.children.length;} if(!this.check("move_node",obj,new_par,pos,{'core':true,'origin':origin,'is_multi':(old_ins&&old_ins._id&&old_ins._id!==this._id),'is_foreign':(!old_ins||!old_ins._id)})){this.settings.core.error.call(this,this._data.core.last_error);return false;} if(obj.parent===new_par.id){dpc=new_par.children.concat();tmp=$.inArray(obj.id,dpc);if(tmp!==-1){dpc=$.vakata.array_remove(dpc,tmp);if(pos>tmp){pos--;}} tmp=[];for(i=0,j=dpc.length;i=pos?i+1:i]=dpc[i];} tmp[pos]=obj.id;new_par.children=tmp;this._node_changed(new_par.id);this.redraw(new_par.id===$.jstree.root);} else{tmp=obj.children_d.concat();tmp.push(obj.id);for(i=0,j=obj.parents.length;i=pos?i+1:i]=new_par.children[i];} dpc[pos]=obj.id;new_par.children=dpc;new_par.children_d.push(obj.id);new_par.children_d=new_par.children_d.concat(obj.children_d);obj.parent=new_par.id;tmp=new_par.parents.concat();tmp.unshift(new_par.id);p=obj.parents.length;obj.parents=tmp;tmp=tmp.concat();for(i=0,j=obj.children_d.length;inew_par.children.length){pos=new_par.children.length;} if(!this.check("copy_node",obj,new_par,pos,{'core':true,'origin':origin,'is_multi':(old_ins&&old_ins._id&&old_ins._id!==this._id),'is_foreign':(!old_ins||!old_ins._id)})){this.settings.core.error.call(this,this._data.core.last_error);return false;} node=old_ins?old_ins.get_json(obj,{no_id:true,no_data:true,no_state:true}):obj;if(!node){return false;} if(node.id===true){delete node.id;} node=this._parse_model_from_json(node,new_par.id,new_par.parents.concat());if(!node){return false;} tmp=this.get_node(node);if(obj&&obj.state&&obj.state.loaded===false){tmp.state.loaded=false;} dpc=[];dpc.push(node);dpc=dpc.concat(tmp.children_d);this.trigger('model',{"nodes":dpc,"parent":new_par.id});for(i=0,j=new_par.parents.length;i=pos?i+1:i]=new_par.children[i];} dpc[pos]=tmp.id;new_par.children=dpc;new_par.children_d.push(tmp.id);new_par.children_d=new_par.children_d.concat(tmp.children_d);if(new_par.id===$.jstree.root){this._model.force_full_redraw=true;} if(!this._model.force_full_redraw){this._node_changed(new_par.id);} if(!skip_redraw){this.redraw(new_par.id===$.jstree.root);} if(callback){callback.call(this,tmp,new_par,pos);} this.trigger('copy_node',{"node":tmp,"original":obj,"parent":new_par.id,"position":pos,"old_parent":old_par,"old_position":old_ins&&old_ins._id&&old_par&&old_ins._model.data[old_par]&&old_ins._model.data[old_par].children?$.inArray(obj.id,old_ins._model.data[old_par].children):-1,'is_multi':(old_ins&&old_ins._id&&old_ins._id!==this._id),'is_foreign':(!old_ins||!old_ins._id),'old_instance':old_ins,'new_instance':this});return tmp.id;},cut:function(obj){if(!obj){obj=this._data.core.selected.concat();} if(!$.isArray(obj)){obj=[obj];} if(!obj.length){return false;} var tmp=[],o,t1,t2;for(t1=0,t2=obj.length;t1');t=default_text;h1=$("<"+"div />",{css:{"position":"absolute","top":"-200px","left":(rtl?"0px":"-1000px"),"visibility":"hidden"}}).appendTo(document.body);h2=$("<"+"input />",{"value":t,"class":"jstree-rename-input","css":{"padding":"0","border":"1px solid silver","box-sizing":"border-box","display":"inline-block","height":(this._data.core.li_height)+"px","lineHeight":(this._data.core.li_height)+"px","width":"150px"},"blur":$.proxy(function(e){e.stopImmediatePropagation();e.preventDefault();var i=s.children(".jstree-rename-input"),v=i.val(),f=this.settings.core.force_text,nv;if(v===""){v=t;} h1.remove();s.replaceWith(a);s.remove();t=f?t:$('
').append($.parseHTML(t)).html();obj=this.get_node(obj);this.set_text(obj,t);nv=!!this.rename_node(obj,f?$('
').text(v).text():$('
').append($.parseHTML(v)).html());if(!nv){this.set_text(obj,t);} this._data.core.focused=tmp.id;setTimeout($.proxy(function(){var node=this.get_node(tmp.id,true);if(node.length){this._data.core.focused=tmp.id;node.children('.jstree-anchor').focus();}},this),0);if(callback){callback.call(this,tmp,nv,cancel);} h2=null;},this),"keydown":function(e){var key=e.which;if(key===27){cancel=true;this.value=t;} if(key===27||key===13||key===37||key===38||key===39||key===40||key===32){e.stopImmediatePropagation();} if(key===27||key===13){e.preventDefault();this.blur();}},"click":function(e){e.stopImmediatePropagation();},"mousedown":function(e){e.stopImmediatePropagation();},"keyup":function(e){h2.width(Math.min(h1.text("pW"+this.value).width(),w));},"keypress":function(e){if(e.which===13){return false;}}});fn={fontFamily:a.css('fontFamily')||'',fontSize:a.css('fontSize')||'',fontWeight:a.css('fontWeight')||'',fontStyle:a.css('fontStyle')||'',fontStretch:a.css('fontStretch')||'',fontVariant:a.css('fontVariant')||'',letterSpacing:a.css('letterSpacing')||'',wordSpacing:a.css('wordSpacing')||''};s.attr('class',a.attr('class')).append(a.contents().clone()).append(h2);a.replaceWith(s);h1.css(fn);h2.css(fn).width(Math.min(h1.text("pW"+h2[0].value).width(),w))[0].select();$(document).one('mousedown.jstree touchstart.jstree dnd_start.vakata',function(e){if(h2&&e.target!==h2){$(h2).blur();}});},set_theme:function(theme_name,theme_url){if(!theme_name){return false;} if(theme_url===true){var dir=this.settings.core.themes.dir;if(!dir){dir=$.jstree.path+'/themes';} theme_url=dir+'/'+theme_name+'/style.css';} if(theme_url&&$.inArray(theme_url,themes_loaded)===-1){$('head').append('<'+'link rel="stylesheet" href="'+theme_url+'" type="text/css" />');themes_loaded.push(theme_url);} if(this._data.core.themes.name){this.element.removeClass('jstree-'+this._data.core.themes.name);} this._data.core.themes.name=theme_name;this.element.addClass('jstree-'+theme_name);this.element[this.settings.core.themes.responsive?'addClass':'removeClass']('jstree-'+theme_name+'-responsive');this.trigger('set_theme',{'theme':theme_name});},get_theme:function(){return this._data.core.themes.name;},set_theme_variant:function(variant_name){if(this._data.core.themes.variant){this.element.removeClass('jstree-'+this._data.core.themes.name+'-'+this._data.core.themes.variant);} this._data.core.themes.variant=variant_name;if(variant_name){this.element.addClass('jstree-'+this._data.core.themes.name+'-'+this._data.core.themes.variant);}},get_theme_variant:function(){return this._data.core.themes.variant;},show_stripes:function(){this._data.core.themes.stripes=true;this.get_container_ul().addClass("jstree-striped");this.trigger('show_stripes');},hide_stripes:function(){this._data.core.themes.stripes=false;this.get_container_ul().removeClass("jstree-striped");this.trigger('hide_stripes');},toggle_stripes:function(){if(this._data.core.themes.stripes){this.hide_stripes();}else{this.show_stripes();}},show_dots:function(){this._data.core.themes.dots=true;this.get_container_ul().removeClass("jstree-no-dots");this.trigger('show_dots');},hide_dots:function(){this._data.core.themes.dots=false;this.get_container_ul().addClass("jstree-no-dots");this.trigger('hide_dots');},toggle_dots:function(){if(this._data.core.themes.dots){this.hide_dots();}else{this.show_dots();}},show_icons:function(){this._data.core.themes.icons=true;this.get_container_ul().removeClass("jstree-no-icons");this.trigger('show_icons');},hide_icons:function(){this._data.core.themes.icons=false;this.get_container_ul().addClass("jstree-no-icons");this.trigger('hide_icons');},toggle_icons:function(){if(this._data.core.themes.icons){this.hide_icons();}else{this.show_icons();}},show_ellipsis:function(){this._data.core.themes.ellipsis=true;this.get_container_ul().addClass("jstree-ellipsis");this.trigger('show_ellipsis');},hide_ellipsis:function(){this._data.core.themes.ellipsis=false;this.get_container_ul().removeClass("jstree-ellipsis");this.trigger('hide_ellipsis');},toggle_ellipsis:function(){if(this._data.core.themes.ellipsis){this.hide_ellipsis();}else{this.show_ellipsis();}},set_icon:function(obj,icon){var t1,t2,dom,old;if($.isArray(obj)){obj=obj.slice();for(t1=0,t2=obj.length;t1=0&&a.call(b,c[e],+e,c)){d.push(c[e]);}} return d;};$.jstree.plugins.changed=function(options,parent){var last=[];this.trigger=function(ev,data){var i,j;if(!data){data={};} if(ev.replace('.jstree','')==='changed'){data.changed={selected:[],deselected:[]};var tmp={};for(i=0,j=last.length;i-1){sel[temp[i]]=true;} else{delete sel[temp[i]];}}} if(s.indexOf('up')!==-1){while(par&&par.id!==$.jstree.root){c=0;for(i=0,j=par.children.length;i-1;});} if(s.indexOf('up')!==-1&&cur.indexOf(obj.id)===-1){for(i=0,j=obj.parents.length;i0&&c===j){p.state[t?'selected':'checked']=true;this._data[t?'core':'checkbox'].selected.push(p.id);tmp=this.get_node(p,true);if(tmp&&tmp.length){tmp.attr('aria-selected',true).children('.jstree-anchor').addClass(t?'jstree-clicked':'jstree-checked');}} else{break;} p=this.get_node(p.parent);}},this)).on('move_node.jstree',$.proxy(function(e,data){var is_multi=data.is_multi,old_par=data.old_parent,new_par=this.get_node(data.parent),m=this._model.data,p,c,i,j,tmp,t=this.settings.checkbox.tie_selection;if(!is_multi){p=this.get_node(old_par);while(p&&p.id!==$.jstree.root&&!p.state[t?'selected':'checked']){c=0;for(i=0,j=p.children.length;i0&&c===j){p.state[t?'selected':'checked']=true;this._data[t?'core':'checkbox'].selected.push(p.id);tmp=this.get_node(p,true);if(tmp&&tmp.length){tmp.attr('aria-selected',true).children('.jstree-anchor').addClass(t?'jstree-clicked':'jstree-checked');}} else{break;} p=this.get_node(p.parent);}} p=new_par;while(p&&p.id!==$.jstree.root){c=0;for(i=0,j=p.children.length;i-1){selectedChildrenIds.push(childId);}}} var dom=self.get_node(node,true);var undetermined=selectedChildrenIds.length>0&&selectedChildrenIds.length250)){$.vakata.context.hide();} last_ts=0;},this)).on("touchstart.jstree",".jstree-anchor",function(e){if(!e.originalEvent||!e.originalEvent.changedTouches||!e.originalEvent.changedTouches[0]){return;} ex=e.originalEvent.changedTouches[0].clientX;ey=e.originalEvent.changedTouches[0].clientY;cto=setTimeout(function(){$(e.currentTarget).trigger('contextmenu',true);},750);}).on('touchmove.vakata.jstree',function(e){if(cto&&e.originalEvent&&e.originalEvent.changedTouches&&e.originalEvent.changedTouches[0]&&(Math.abs(ex-e.originalEvent.changedTouches[0].clientX)>10||Math.abs(ey-e.originalEvent.changedTouches[0].clientY)>10)){clearTimeout(cto);$.vakata.context.hide();}}).on('touchend.vakata.jstree',function(e){if(cto){clearTimeout(cto);}});$(document).on("context_hide.vakata.jstree",$.proxy(function(e,data){this._data.contextmenu.visible=false;$(data.reference).removeClass('jstree-context');},this));};this.teardown=function(){if(this._data.contextmenu.visible){$.vakata.context.hide();} parent.teardown.call(this);};this.show_contextmenu=function(obj,x,y,e){obj=this.get_node(obj);if(!obj||obj.id===$.jstree.root){return false;} var s=this.settings.contextmenu,d=this.get_node(obj,true),a=d.children(".jstree-anchor"),o=false,i=false;if(s.show_at_node||x===undefined||y===undefined){o=a.offset();x=o.left;y=o.top+this._data.core.li_height;} if(this.settings.contextmenu.select_node&&!this.is_selected(obj)){this.activate_node(obj,e);} i=s.items;if($.isFunction(i)){i=i.call(this,obj,$.proxy(function(i){this._show_contextmenu(obj,x,y,i);},this));} if($.isPlainObject(i)){this._show_contextmenu(obj,x,y,i);}};this._show_contextmenu=function(obj,x,y,i){var d=this.get_node(obj,true),a=d.children(".jstree-anchor");$(document).one("context_show.vakata.jstree",$.proxy(function(e,data){var cls='jstree-contextmenu jstree-'+this.get_theme()+'-contextmenu';$(data.element).addClass(cls);a.addClass('jstree-context');},this));this._data.contextmenu.visible=true;$.vakata.context.show(a,{'x':x,'y':y},i);this.trigger('show_contextmenu',{"node":obj,"x":x,"y":y});};};(function($){var right_to_left=false,vakata_context={element:false,reference:false,position_x:0,position_y:0,items:[],html:"",is_visible:false};$.vakata.context={settings:{hide_onmouseleave:0,icons:true},_trigger:function(event_name){$(document).triggerHandler("context_"+event_name+".vakata",{"reference":vakata_context.reference,"element":vakata_context.element,"position":{"x":vakata_context.position_x,"y":vakata_context.position_y}});},_execute:function(i){i=vakata_context.items[i];return i&&(!i._disabled||($.isFunction(i._disabled)&&!i._disabled({"item":i,"reference":vakata_context.reference,"element":vakata_context.element})))&&i.action?i.action.call(null,{"item":i,"reference":vakata_context.reference,"element":vakata_context.element,"position":{"x":vakata_context.position_x,"y":vakata_context.position_y}}):false;},_parse:function(o,is_callback){if(!o){return false;} if(!is_callback){vakata_context.html="";vakata_context.items=[];} var str="",sep=false,tmp;if(is_callback){str+="<"+"ul>";} $.each(o,function(i,val){if(!val){return true;} vakata_context.items.push(val);if(!sep&&val.separator_before){str+="<"+"li class='vakata-context-separator'><"+"a href='#' "+($.vakata.context.settings.icons?'':'style="margin-left:0px;"')+"> <"+"/a><"+"/li>";} sep=false;str+="<"+"li class='"+(val._class||"")+(val._disabled===true||($.isFunction(val._disabled)&&val._disabled({"item":val,"reference":vakata_context.reference,"element":vakata_context.element}))?" vakata-contextmenu-disabled ":"")+"' "+(val.shortcut?" data-shortcut='"+val.shortcut+"' ":'')+">";str+="<"+"a href='#' rel='"+(vakata_context.items.length-1)+"' "+(val.title?"title='"+val.title+"'":"")+">";if($.vakata.context.settings.icons){str+="<"+"i ";if(val.icon){if(val.icon.indexOf("/")!==-1||val.icon.indexOf(".")!==-1){str+=" style='background:url(\""+val.icon+"\") center center no-repeat' ";} else{str+=" class='"+val.icon+"' ";}} str+="><"+"/i><"+"span class='vakata-contextmenu-sep'> <"+"/span>";} str+=($.isFunction(val.label)?val.label({"item":i,"reference":vakata_context.reference,"element":vakata_context.element}):val.label)+(val.shortcut?' '+(val.shortcut_label||'')+'':'')+"<"+"/a>";if(val.submenu){tmp=$.vakata.context._parse(val.submenu,true);if(tmp){str+=tmp;}} str+="<"+"/li>";if(val.separator_after){str+="<"+"li class='vakata-context-separator'><"+"a href='#' "+($.vakata.context.settings.icons?'':'style="margin-left:0px;"')+"> <"+"/a><"+"/li>";sep=true;}});str=str.replace(/
  • <\/li\>$/,"");if(is_callback){str+="";} if(!is_callback){vakata_context.html=str;$.vakata.context._trigger("parse");} return str.length>10?str:false;},_show_submenu:function(o){o=$(o);if(!o.length||!o.children("ul").length){return;} var e=o.children("ul"),xl=o.offset().left,x=xl+o.outerWidth(),y=o.offset().top,w=e.width(),h=e.height(),dw=$(window).width()+$(window).scrollLeft(),dh=$(window).height()+$(window).scrollTop();if(right_to_left){o[x-(w+10+o.outerWidth())<0?"addClass":"removeClass"]("vakata-context-left");} else{o[x+w>dw&&xl>dw-x?"addClass":"removeClass"]("vakata-context-right");} if(y+h+10>dh){e.css("bottom","-1px");} if(o.hasClass('vakata-context-right')){if(xldw){x=dw-(w+20);} if(y+h+20>dh){y=dh-(h+20);} vakata_context.element.css({"left":x,"top":y}).show().find('a').first().focus().parent().addClass("vakata-context-hover");vakata_context.is_visible=true;$.vakata.context._trigger("show");}},hide:function(){if(vakata_context.is_visible){vakata_context.element.hide().find("ul").hide().end().find(':focus').blur().end().detach();vakata_context.is_visible=false;$.vakata.context._trigger("hide");}}};$(function(){right_to_left=$(document.body).css("direction")==="rtl";var to=false;vakata_context.element=$("
      ");vakata_context.element.on("mouseenter","li",function(e){e.stopImmediatePropagation();if($.contains(this,e.relatedTarget)){return;} if(to){clearTimeout(to);} vakata_context.element.find(".vakata-context-hover").removeClass("vakata-context-hover").end();$(this).siblings().find("ul").hide().end().end().parentsUntil(".vakata-context","li").addBack().addClass("vakata-context-hover");$.vakata.context._show_submenu(this);}).on("mouseleave","li",function(e){if($.contains(this,e.relatedTarget)){return;} $(this).find(".vakata-context-hover").addBack().removeClass("vakata-context-hover");}).on("mouseleave",function(e){$(this).find(".vakata-context-hover").removeClass("vakata-context-hover");if($.vakata.context.settings.hide_onmouseleave){to=setTimeout((function(t){return function(){$.vakata.context.hide();};}(this)),$.vakata.context.settings.hide_onmouseleave);}}).on("click","a",function(e){e.preventDefault();if(!$(this).blur().parent().hasClass("vakata-context-disabled")&&$.vakata.context._execute($(this).attr("rel"))!==false){$.vakata.context.hide();}}).on('keydown','a',function(e){var o=null;switch(e.which){case 13:case 32:e.type="click";e.preventDefault();$(e.currentTarget).trigger(e);break;case 37:if(vakata_context.is_visible){vakata_context.element.find(".vakata-context-hover").last().closest("li").first().find("ul").hide().find(".vakata-context-hover").removeClass("vakata-context-hover").end().end().children('a').focus();e.stopImmediatePropagation();e.preventDefault();} break;case 38:if(vakata_context.is_visible){o=vakata_context.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").prevAll("li:not(.vakata-context-separator)").first();if(!o.length){o=vakata_context.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").last();} o.addClass("vakata-context-hover").children('a').focus();e.stopImmediatePropagation();e.preventDefault();} break;case 39:if(vakata_context.is_visible){vakata_context.element.find(".vakata-context-hover").last().children("ul").show().children("li:not(.vakata-context-separator)").removeClass("vakata-context-hover").first().addClass("vakata-context-hover").children('a').focus();e.stopImmediatePropagation();e.preventDefault();} break;case 40:if(vakata_context.is_visible){o=vakata_context.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").nextAll("li:not(.vakata-context-separator)").first();if(!o.length){o=vakata_context.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").first();} o.addClass("vakata-context-hover").children('a').focus();e.stopImmediatePropagation();e.preventDefault();} break;case 27:$.vakata.context.hide();e.preventDefault();break;default:break;}}).on('keydown',function(e){e.preventDefault();var a=vakata_context.element.find('.vakata-contextmenu-shortcut-'+e.which).parent();if(a.parent().not('.vakata-context-disabled')){a.click();}});$(document).on("mousedown.vakata.jstree",function(e){if(vakata_context.is_visible&&vakata_context.element[0]!==e.target&&!$.contains(vakata_context.element[0],e.target)){$.vakata.context.hide();}}).on("context_show.vakata.jstree",function(e,data){vakata_context.element.find("li:has(ul)").children("a").addClass("vakata-context-parent");if(right_to_left){vakata_context.element.addClass("vakata-context-rtl").css("direction","rtl");} vakata_context.element.find("ul").hide().end();});});}($));$.jstree.defaults.dnd={copy:true,open_timeout:500,is_draggable:true,check_while_dragging:true,always_copy:false,inside_pos:0,drag_selection:true,touch:true,large_drop_target:false,large_drag_target:false,use_html5:false};var drg,elm;$.jstree.plugins.dnd=function(options,parent){this.init=function(el,options){parent.init.call(this,el,options);this.settings.dnd.use_html5=this.settings.dnd.use_html5&&('draggable'in document.createElement('span'));};this.bind=function(){parent.bind.call(this);this.element.on(this.settings.dnd.use_html5?'dragstart.jstree':'mousedown.jstree touchstart.jstree',this.settings.dnd.large_drag_target?'.jstree-node':'.jstree-anchor',$.proxy(function(e){if(this.settings.dnd.large_drag_target&&$(e.target).closest('.jstree-node')[0]!==e.currentTarget){return true;} if(e.type==="touchstart"&&(!this.settings.dnd.touch||(this.settings.dnd.touch==='selected'&&!$(e.currentTarget).closest('.jstree-node').children('.jstree-anchor').hasClass('jstree-clicked')))){return true;} var obj=this.get_node(e.target),mlt=this.is_selected(obj)&&this.settings.dnd.drag_selection?this.get_top_selected().length:1,txt=(mlt>1?mlt+' '+this.get_string('nodes'):this.get_text(e.currentTarget));if(this.settings.core.force_text){txt=$.vakata.html.escape(txt);} if(obj&&obj.id&&obj.id!==$.jstree.root&&(e.which===1||e.type==="touchstart"||e.type==="dragstart")&&(this.settings.dnd.is_draggable===true||($.isFunction(this.settings.dnd.is_draggable)&&this.settings.dnd.is_draggable.call(this,(mlt>1?this.get_top_selected(true):[obj]),e)))){drg={'jstree':true,'origin':this,'obj':this.get_node(obj,true),'nodes':mlt>1?this.get_top_selected():[obj.id]};elm=e.currentTarget;if(this.settings.dnd.use_html5){$.vakata.dnd._trigger('start',e,{'helper':$(),'element':elm,'data':drg});}else{this.element.trigger('mousedown.jstree');return $.vakata.dnd.start(e,drg,'
      '+txt+'
      ');}}},this));if(this.settings.dnd.use_html5){this.element.on('dragover.jstree',function(e){e.preventDefault();$.vakata.dnd._trigger('move',e,{'helper':$(),'element':elm,'data':drg});return false;}).on('drop.jstree',$.proxy(function(e){e.preventDefault();$.vakata.dnd._trigger('stop',e,{'helper':$(),'element':elm,'data':drg});return false;},this));}};this.redraw_node=function(obj,deep,callback,force_render){obj=parent.redraw_node.apply(this,arguments);if(obj&&this.settings.dnd.use_html5){if(this.settings.dnd.large_drag_target){obj.setAttribute('draggable',true);}else{var i,j,tmp=null;for(i=0,j=obj.childNodes.length;i ').hide();$(document).on('dragover.vakata.jstree',function(e){if(elm){$.vakata.dnd._trigger('move',e,{'helper':$(),'element':elm,'data':drg});}}).on('drop.vakata.jstree',function(e){if(elm){$.vakata.dnd._trigger('stop',e,{'helper':$(),'element':elm,'data':drg});elm=null;drg=null;}}).on('dnd_start.vakata.jstree',function(e,data){lastmv=false;lastev=false;if(!data||!data.data||!data.data.jstree){return;} marker.appendTo(document.body);}).on('dnd_move.vakata.jstree',function(e,data){var isDifferentNode=data.event.target!==lastev.target;if(opento){if(!data.event||data.event.type!=='dragover'||isDifferentNode){clearTimeout(opento);}} if(!data||!data.data||!data.data.jstree){return;} if(data.event.target.id&&data.event.target.id==='jstree-marker'){return;} lastev=data.event;var ins=$.jstree.reference(data.event.target),ref=false,off=false,rel=false,tmp,l,t,h,p,i,o,ok,t1,t2,op,ps,pr,ip,tm,is_copy,pn,c;if(ins&&ins._data&&ins._data.dnd){marker.attr('class','jstree-'+ins.get_theme()+(ins.settings.core.themes.responsive?' jstree-dnd-responsive':''));is_copy=data.data.origin&&(data.data.origin.settings.dnd.always_copy||(data.data.origin.settings.dnd.copy&&(data.event.metaKey||data.event.ctrlKey)));data.helper.children().attr('class','jstree-'+ins.get_theme()+' jstree-'+ins.get_theme()+'-'+ins.get_theme_variant()+' '+(ins.settings.core.themes.responsive?' jstree-dnd-responsive':'')).find('.jstree-copy').first()[is_copy?'show':'hide']();if((data.event.target===ins.element[0]||data.event.target===ins.get_container_ul()[0])&&ins.get_container_ul().children().length===0){ok=true;for(t1=0,t2=data.data.nodes.length;t1h-h/3){o=['a','i','b'];} else{o=rel>h/2?['i','a','b']:['i','b','a'];} $.each(o,function(j,v){switch(v){case'b':l=off.left-6;t=off.top;p=ins.get_parent(ref);i=ref.parent().index();c='jstree-below';break;case'i':ip=ins.settings.dnd.inside_pos;tm=ins.get_node(ref.parent());l=off.left-2;t=off.top+h/2+1;p=tm.id;i=ip==='first'?0:(ip==='last'?tm.children.length:Math.min(ip,tm.children.length));c='jstree-inside';break;case'a':l=off.left-6;t=off.top+h;p=ins.get_parent(ref);i=ref.parent().index()+1;c='jstree-above';break;} ok=true;for(t1=0,t2=data.data.nodes.length;t1$.inArray(data.data.nodes[t1],pr.children)){ps-=1;}} ok=ok&&((ins&&ins.settings&&ins.settings.dnd&&ins.settings.dnd.check_while_dragging===false)||ins.check(op,(data.data.origin&&data.data.origin!==ins?data.data.origin.get_node(data.data.nodes[t1]):data.data.nodes[t1]),p,ps,{'dnd':true,'ref':ins.get_node(ref.parent()),'pos':v,'origin':data.data.origin,'is_multi':(data.data.origin&&data.data.origin!==ins),'is_foreign':(!data.data.origin)}));if(!ok){if(ins&&ins.last_error){laster=ins.last_error();} break;}} if(v==='i'&&ref.parent().is('.jstree-closed')&&ins.settings.dnd.open_timeout){if(!data.event||data.event.type!=='dragover'||isDifferentNode){if(opento){clearTimeout(opento);} opento=setTimeout((function(x,z){return function(){x.open_node(z);};}(ins,ref)),ins.settings.dnd.open_timeout);}} if(ok){pn=ins.get_node(p,true);if(!pn.hasClass('.jstree-dnd-parent')){$('.jstree-dnd-parent').removeClass('jstree-dnd-parent');pn.addClass('jstree-dnd-parent');} lastmv={'ins':ins,'par':p,'pos':v==='i'&&ip==='last'&&i===0&&!ins.is_loaded(tm)?'last':i};marker.css({'left':l+'px','top':t+'px'}).show();marker.removeClass('jstree-above jstree-inside jstree-below').addClass(c);data.helper.find('.jstree-icon').first().removeClass('jstree-er').addClass('jstree-ok');if(data.event.originalEvent&&data.event.originalEvent.dataTransfer){data.event.originalEvent.dataTransfer.dropEffect=is_copy?'copy':'move';} laster={};o=true;return false;}});if(o===true){return;}}}} $('.jstree-dnd-parent').removeClass('jstree-dnd-parent');lastmv=false;data.helper.find('.jstree-icon').removeClass('jstree-ok').addClass('jstree-er');if(data.event.originalEvent&&data.event.originalEvent.dataTransfer){} marker.hide();}).on('dnd_scroll.vakata.jstree',function(e,data){if(!data||!data.data||!data.data.jstree){return;} marker.hide();lastmv=false;lastev=false;data.helper.find('.jstree-icon').first().removeClass('jstree-ok').addClass('jstree-er');}).on('dnd_stop.vakata.jstree',function(e,data){$('.jstree-dnd-parent').removeClass('jstree-dnd-parent');if(opento){clearTimeout(opento);} if(!data||!data.data||!data.data.jstree){return;} marker.hide().detach();var i,j,nodes=[];if(lastmv){for(i=0,j=data.data.nodes.length;i'),escape:function(str){return $.vakata.html.div.text(str).html();},strip:function(str){return $.vakata.html.div.empty().append($.parseHTML(str)).text();}};var vakata_dnd={element:false,target:false,is_down:false,is_drag:false,helper:false,helper_w:0,data:false,init_x:0,init_y:0,scroll_l:0,scroll_t:0,scroll_e:false,scroll_i:false,is_touch:false};$.vakata.dnd={settings:{scroll_speed:10,scroll_proximity:20,helper_left:5,helper_top:10,threshold:5,threshold_touch:10},_trigger:function(event_name,e,data){if(data===undefined){data=$.vakata.dnd._get();} data.event=e;$(document).triggerHandler("dnd_"+event_name+".vakata",data);},_get:function(){return{"data":vakata_dnd.data,"element":vakata_dnd.element,"helper":vakata_dnd.helper};},_clean:function(){if(vakata_dnd.helper){vakata_dnd.helper.remove();} if(vakata_dnd.scroll_i){clearInterval(vakata_dnd.scroll_i);vakata_dnd.scroll_i=false;} vakata_dnd={element:false,target:false,is_down:false,is_drag:false,helper:false,helper_w:0,data:false,init_x:0,init_y:0,scroll_l:0,scroll_t:0,scroll_e:false,scroll_i:false,is_touch:false};elm=null;$(document).off("mousemove.vakata.jstree touchmove.vakata.jstree",$.vakata.dnd.drag);$(document).off("mouseup.vakata.jstree touchend.vakata.jstree",$.vakata.dnd.stop);},_scroll:function(init_only){if(!vakata_dnd.scroll_e||(!vakata_dnd.scroll_l&&!vakata_dnd.scroll_t)){if(vakata_dnd.scroll_i){clearInterval(vakata_dnd.scroll_i);vakata_dnd.scroll_i=false;} return false;} if(!vakata_dnd.scroll_i){vakata_dnd.scroll_i=setInterval($.vakata.dnd._scroll,100);return false;} if(init_only===true){return false;} var i=vakata_dnd.scroll_e.scrollTop(),j=vakata_dnd.scroll_e.scrollLeft();vakata_dnd.scroll_e.scrollTop(i+vakata_dnd.scroll_t*$.vakata.dnd.settings.scroll_speed);vakata_dnd.scroll_e.scrollLeft(j+vakata_dnd.scroll_l*$.vakata.dnd.settings.scroll_speed);if(i!==vakata_dnd.scroll_e.scrollTop()||j!==vakata_dnd.scroll_e.scrollLeft()){$.vakata.dnd._trigger("scroll",vakata_dnd.scroll_e);}},start:function(e,data,html){if(e.type==="touchstart"&&e.originalEvent&&e.originalEvent.changedTouches&&e.originalEvent.changedTouches[0]){e.pageX=e.originalEvent.changedTouches[0].pageX;e.pageY=e.originalEvent.changedTouches[0].pageY;e.target=document.elementFromPoint(e.originalEvent.changedTouches[0].pageX-window.pageXOffset,e.originalEvent.changedTouches[0].pageY-window.pageYOffset);} if(vakata_dnd.is_drag){$.vakata.dnd.stop({});} try{e.currentTarget.unselectable="on";e.currentTarget.onselectstart=function(){return false;};if(e.currentTarget.style){e.currentTarget.style.touchAction="none";e.currentTarget.style.msTouchAction="none";e.currentTarget.style.MozUserSelect="none";}}catch(ignore){} vakata_dnd.init_x=e.pageX;vakata_dnd.init_y=e.pageY;vakata_dnd.data=data;vakata_dnd.is_down=true;vakata_dnd.element=e.currentTarget;vakata_dnd.target=e.target;vakata_dnd.is_touch=e.type==="touchstart";if(html!==false){vakata_dnd.helper=$("
      ").html(html).css({"display":"block","margin":"0","padding":"0","position":"absolute","top":"-2000px","lineHeight":"16px","zIndex":"10000"});} $(document).on("mousemove.vakata.jstree touchmove.vakata.jstree",$.vakata.dnd.drag);$(document).on("mouseup.vakata.jstree touchend.vakata.jstree",$.vakata.dnd.stop);return false;},drag:function(e){if(e.type==="touchmove"&&e.originalEvent&&e.originalEvent.changedTouches&&e.originalEvent.changedTouches[0]){e.pageX=e.originalEvent.changedTouches[0].pageX;e.pageY=e.originalEvent.changedTouches[0].pageY;e.target=document.elementFromPoint(e.originalEvent.changedTouches[0].pageX-window.pageXOffset,e.originalEvent.changedTouches[0].pageY-window.pageYOffset);} if(!vakata_dnd.is_down){return;} if(!vakata_dnd.is_drag){if(Math.abs(e.pageX-vakata_dnd.init_x)>(vakata_dnd.is_touch?$.vakata.dnd.settings.threshold_touch:$.vakata.dnd.settings.threshold)||Math.abs(e.pageY-vakata_dnd.init_y)>(vakata_dnd.is_touch?$.vakata.dnd.settings.threshold_touch:$.vakata.dnd.settings.threshold)){if(vakata_dnd.helper){vakata_dnd.helper.appendTo(document.body);vakata_dnd.helper_w=vakata_dnd.helper.outerWidth();} vakata_dnd.is_drag=true;$(vakata_dnd.target).one('click.vakata',false);$.vakata.dnd._trigger("start",e);} else{return;}} var d=false,w=false,dh=false,wh=false,dw=false,ww=false,dt=false,dl=false,ht=false,hl=false;vakata_dnd.scroll_t=0;vakata_dnd.scroll_l=0;vakata_dnd.scroll_e=false;$($(e.target).parentsUntil("body").addBack().get().reverse()).filter(function(){return(/^auto|scroll$/).test($(this).css("overflow"))&&(this.scrollHeight>this.offsetHeight||this.scrollWidth>this.offsetWidth);}).each(function(){var t=$(this),o=t.offset();if(this.scrollHeight>this.offsetHeight){if(o.top+t.height()-e.pageY<$.vakata.dnd.settings.scroll_proximity){vakata_dnd.scroll_t=1;} if(e.pageY-o.top<$.vakata.dnd.settings.scroll_proximity){vakata_dnd.scroll_t=-1;}} if(this.scrollWidth>this.offsetWidth){if(o.left+t.width()-e.pageX<$.vakata.dnd.settings.scroll_proximity){vakata_dnd.scroll_l=1;} if(e.pageX-o.left<$.vakata.dnd.settings.scroll_proximity){vakata_dnd.scroll_l=-1;}} if(vakata_dnd.scroll_t||vakata_dnd.scroll_l){vakata_dnd.scroll_e=$(this);return false;}});if(!vakata_dnd.scroll_e){d=$(document);w=$(window);dh=d.height();wh=w.height();dw=d.width();ww=w.width();dt=d.scrollTop();dl=d.scrollLeft();if(dh>wh&&e.pageY-dt<$.vakata.dnd.settings.scroll_proximity){vakata_dnd.scroll_t=-1;} if(dh>wh&&wh-(e.pageY-dt)<$.vakata.dnd.settings.scroll_proximity){vakata_dnd.scroll_t=1;} if(dw>ww&&e.pageX-dl<$.vakata.dnd.settings.scroll_proximity){vakata_dnd.scroll_l=-1;} if(dw>ww&&ww-(e.pageX-dl)<$.vakata.dnd.settings.scroll_proximity){vakata_dnd.scroll_l=1;} if(vakata_dnd.scroll_t||vakata_dnd.scroll_l){vakata_dnd.scroll_e=d;}} if(vakata_dnd.scroll_e){$.vakata.dnd._scroll(true);} if(vakata_dnd.helper){ht=parseInt(e.pageY+$.vakata.dnd.settings.helper_top,10);hl=parseInt(e.pageX+$.vakata.dnd.settings.helper_left,10);if(dh&&ht+25>dh){ht=dh-50;} if(dw&&hl+vakata_dnd.helper_w>dw){hl=dw-(vakata_dnd.helper_w+2);} vakata_dnd.helper.css({left:hl+"px",top:ht+"px"});} $.vakata.dnd._trigger("move",e);return false;},stop:function(e){if(e.type==="touchend"&&e.originalEvent&&e.originalEvent.changedTouches&&e.originalEvent.changedTouches[0]){e.pageX=e.originalEvent.changedTouches[0].pageX;e.pageY=e.originalEvent.changedTouches[0].pageY;e.target=document.elementFromPoint(e.originalEvent.changedTouches[0].pageX-window.pageXOffset,e.originalEvent.changedTouches[0].pageY-window.pageYOffset);} if(vakata_dnd.is_drag){if(e.target!==vakata_dnd.target){$(vakata_dnd.target).off('click.vakata');} $.vakata.dnd._trigger("stop",e);} else{if(e.type==="touchend"&&e.target===vakata_dnd.target){var to=setTimeout(function(){$(e.target).click();},100);$(e.target).one('click',function(){if(to){clearTimeout(to);}});}} $.vakata.dnd._clean();return false;}};}($));$.jstree.defaults.massload=null;$.jstree.plugins.massload=function(options,parent){this.init=function(el,options){this._data.massload={};parent.init.call(this,el,options);};this._load_nodes=function(nodes,callback,is_callback,force_reload){var s=this.settings.massload,toLoad=[],m=this._model.data,i,j,dom;if(!is_callback){for(i=0,j=nodes.length;i32){options.fuzzy=false;} if(options.fuzzy){matchmask=1<<(patternLen-1);pattern_alphabet=(function(){var mask={},i=0;for(i=0;i=start;j--){charMatch=pattern_alphabet[text.charAt(j-1)];if(i===0){rd[j]=((rd[j+1]<<1)|1)&charMatch;}else{rd[j]=((rd[j+1]<<1)|1)&charMatch|(((lastRd[j+1]|lastRd[j])<<1)|1)|lastRd[j+1];} if(rd[j]&matchmask){score=match_bitapScore(i,j-1);if(score<=scoreThreshold){scoreThreshold=score;bestLoc=j-1;locations.push(bestLoc);if(bestLoc>MATCH_LOCATION){start=Math.max(1,2*MATCH_LOCATION-bestLoc);}else{break;}}}} if(match_bitapScore(i+1,MATCH_LOCATION)>scoreThreshold){break;} lastRd=rd;} return{isMatch:bestLoc>=0,score:score};};return txt===true?{'search':search}:search(txt);};$.vakata.search.defaults={location:0,distance:100,threshold:0.6,fuzzy:false,caseSensitive:false};}($));$.jstree.defaults.sort=function(a,b){return this.get_text(a)>this.get_text(b)?1:-1;};$.jstree.plugins.sort=function(options,parent){this.bind=function(){parent.bind.call(this);this.element.on("model.jstree",$.proxy(function(e,data){this.sort(data.parent,true);},this)).on("rename_node.jstree create_node.jstree",$.proxy(function(e,data){this.sort(data.parent||data.node.parent,false);this.redraw_node(data.parent||data.node.parent,true);},this)).on("move_node.jstree copy_node.jstree",$.proxy(function(e,data){this.sort(data.parent,false);this.redraw_node(data.parent,true);},this));};this.sort=function(obj,deep){var i,j;obj=this.get_node(obj);if(obj&&obj.children&&obj.children.length){obj.children.sort($.proxy(this.settings.sort,this));if(deep){for(i=0,j=obj.children_d.length;ik.ttl){return false;} if(!!k&&k.state){k=k.state;} if(!!k&&$.isFunction(this.settings.state.filter)){k=this.settings.state.filter.call(this,k);} if(!!k){if(!this.settings.state.preserve_loaded){delete k.core.loaded;} this.element.one("set_state.jstree",function(e,data){data.instance.trigger('restore_state',{'state':$.extend(true,{},k)});});this.set_state(k);return true;} return false;};this.clear_state=function(){return $.vakata.storage.del(this.settings.state.key);};};(function($,undefined){$.vakata.storage={set:function(key,val){return window.localStorage.setItem(key,val);},get:function(key){return window.localStorage.getItem(key);},del:function(key){return window.localStorage.removeItem(key);}};}($));$.jstree.defaults.types={'default':{}};$.jstree.defaults.types[$.jstree.root]={};$.jstree.plugins.types=function(options,parent){this.init=function(el,options){var i,j;if(options&&options.types&&options.types['default']){for(i in options.types){if(i!=="default"&&i!==$.jstree.root&&options.types.hasOwnProperty(i)){for(j in options.types['default']){if(options.types['default'].hasOwnProperty(j)&&options.types[i][j]===undefined){options.types[i][j]=options.types['default'][j];}}}}} parent.init.call(this,el,options);this._model.data[$.jstree.root].type=$.jstree.root;};this.refresh=function(skip_loading,forget_state){parent.refresh.call(this,skip_loading,forget_state);this._model.data[$.jstree.root].type=$.jstree.root;};this.bind=function(){this.element.on('model.jstree',$.proxy(function(e,data){var m=this._model.data,dpc=data.nodes,t=this.settings.types,i,j,c='default',k;for(i=0,j=dpc.length;i .jstree-ocl",$.proxy(function(e){e.stopImmediatePropagation();var tmp=$.Event('click',{metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey});$(e.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(tmp).focus();},this)).on("mouseover.jstree",".jstree-wholerow, .jstree-icon",$.proxy(function(e){e.stopImmediatePropagation();if(!this.is_disabled(e.currentTarget)){this.hover_node(e.currentTarget);} return false;},this)).on("mouseleave.jstree",".jstree-node",$.proxy(function(e){this.dehover_node(e.currentTarget);},this));};this.teardown=function(){if(this.settings.wholerow){this.element.find(".jstree-wholerow").remove();} parent.teardown.call(this);};this.redraw_node=function(obj,deep,callback,force_render){obj=parent.redraw_node.apply(this,arguments);if(obj){var tmp=div.cloneNode(true);if($.inArray(obj.id,this._data.core.selected)!==-1){tmp.className+=' jstree-wholerow-clicked';} if(this._data.core.focused&&this._data.core.focused===obj.id){tmp.className+=' jstree-wholerow-hovered';} obj.insertBefore(tmp,obj.childNodes[0]);} return obj;};};if(window.customElements&&Object&&Object.create){var proto=Object.create(HTMLElement.prototype);proto.createdCallback=function(){var c={core:{},plugins:[]},i;for(i in $.jstree.plugins){if($.jstree.plugins.hasOwnProperty(i)&&this.attributes[i]){c.plugins.push(i);if(this.getAttribute(i)&&JSON.parse(this.getAttribute(i))){c[i]=JSON.parse(this.getAttribute(i));}}} for(i in $.jstree.defaults.core){if($.jstree.defaults.core.hasOwnProperty(i)&&this.attributes[i]){c.core[i]=JSON.parse(this.getAttribute(i))||this.getAttribute(i);}} $(this).jstree(c);};try{window.customElements.define("vakata-jstree",function(){},{prototype:proto});}catch(ignore){}}}));;Ext.onReady(function(){window.gsuiteHelper=function(){var _cacheName='g_suites_config_info';var $exportModal=$('#GDrive_ReportExport');var $exportFormat=$('#GDrive_ReportExport_Format');var _cacheData;var _reportFrame;function initReports(frame){_reportFrame=frame;$exportFormat.selectpicker();checkConfig(function(configData){if(configData!=null&&configData!='null'){_reportFrame.contentWindow.postMessage(JSON.stringify({action:'addItemToExport'}),'*');$('#GDrive_ReportExport_btnSave').on('click',function(){var data=window.jsTreeHelper.getSelectedNode();var dataForExport={action:'exportToGDrive',menuItemText:$exportFormat.val()};if(data==null){checkConfig(function(data){if(data!='null'){data=JSON.parse(data);if(data.GD_DefaultDirID_Reporting==null||data.GD_DefaultDirID_Reporting==undefined){Dear_Notification_Error('Please select a location to save the files.');return;} dataForExport.GDriveDirId=data.GD_DefaultDirID_Reporting;_reportFrame.contentWindow.postMessage(JSON.stringify(dataForExport),'*');$exportModal.modal('hide');}});}else{dataForExport.GDriveDirId=data.id;_reportFrame.contentWindow.postMessage(JSON.stringify(dataForExport),'*');$exportModal.modal('hide');}});}});} function initReportsWithoutFrame(){$exportFormat.selectpicker();checkConfig(function(configData){if(configData!=null&&configData!='null'){var menu=Ext.getCmp('menuExportID');if(menu){var item=new Ext.menu.Item({text:'Save to Google Drive',plain:true,baseCls:'dearMenuItemNoMargin',itemId:'gdriveItem',handler:function handler(){var menu=Ext.getCmp('menuExportID');var menuItems=[];if(menu){for(var i=0;i"));_item2.handler();$('#hidGDriveDirId').remove();break;}}} $exportModal.modal('hide');};if(data==null){checkConfig(function(data){if(data!='null'){data=JSON.parse(data);if(data.GD_DefaultDirID_Reporting==null||data.GD_DefaultDirID_Reporting==undefined){Dear_Notification_Error('Please select a location to save the files.');return;} menuItemHandler(data.GD_DefaultDirID_Reporting);}});}else{menuItemHandler(data.id);}});}});} function init(page,configId,fileAttachedCallback){if(configId!=null&&configId!='null'){window.jsTreeHelper.setConfig(page,fileAttachedCallback);if(window.IsReadOnly===false){$('.GDrive_divAttachFrom').showContent();}} $(document).on('click','.gsuites-set-popover',function(){if($(this).hasClass('opened')){$(this).popover('hide');$(this).removeClass('opened');}else{$(this).popover('show');$(this).addClass('opened');} var currId=$(this).data('id');$(".gsuites-set-popover[data-id!=\"".concat(currId,"\"]")).each(function(){$(this).next().remove();$(this).removeClass('opened');});});setTimeout(function(){$('.dr-body').on('scroll',function(){$('.set-popover').popover('hide');$('.gsuites-set-popover').popover('hide');});},1000);} function setData(data){_cacheData=data;} function clearCache(){_cacheData=null;} function checkConfig(successCallback){if(_cacheData!=null){successCallback(_cacheData);}else{_getConfig(function(data){_cacheData=data;if(typeof successCallback==='function'){successCallback(data);}});}} function renderAttachment(record){if(record.get('ExternalDownloadLink')||record.get('ExternalViewLink')){var downloadLink='';if(record.get('ExternalDownloadLink')!=null&&record.get('ExternalDownloadLink')!=''){downloadLink="Download");} var content="");return" \n ").concat(record.get('FileName'),"\n ");} return null;} function renderAttachmentMult(tooltip,title,record){if(record.get('ExternalDownloadLink')||record.get('ExternalViewLink')){return" \n ").concat(record.get('FileName'),"\n ");} return null;} function setEventsAttachmentMult(){var getPlacement=function getPlacement(){if($(window).width()>1200){return'right';} return'left';};$('.gsuites-mult-set-popover').on('mouseenter',function(){$(this).popover('destroy');var content_html=$(this).data('content_html');var title=$(this).data('title');$(this).popover({html:true,content:content_html,trigger:'manual',title:title,placement:getPlacement()});var _this=this;setTimeout(function(){$(_this).popover('show');$('.popover').on('mouseleave',function(){$(_this).popover('hide');});},100);}).on('click',function(){$(this).popover('destroy');var external_download_link=$(this).data('external_download_link');var external_view_link=$(this).data('external_view_link');var downloadLink='';if(external_download_link!=null&&external_download_link!=''){downloadLink="Download");} var content="");$(this).popover({html:true,content:content,trigger:'manual',title:null,placement:getPlacement()});var _this=this;setTimeout(function(){$(_this).popover('show');$('.popover').on('mouseleave',function(){$(_this).popover('hide');});},100);}).on('mouseleave',function(){var _this=this;setTimeout(function(){if(!$('.popover:hover').length){$(_this).popover('hide');}},100);});} function reportExportShow(data){$exportFormat.html('');for(var i=0;i").concat(data.menuItems[i],""));} $exportFormat.selectpicker('refresh');$exportModal.modal('show');var config=_cacheData;if(config!=null&&config!='null'){config=JSON.parse(config);$('#GDrive_ReportExport #gdLocationNameReporting').text(config.GD_DefaultDirPath_Reporting);$('#divScheduleReport #gdLocationNameReporting').text(config.GD_DefaultDirPath_Reporting);} window.jsTreeHelper.refresh();} function _getConfig(successCallback){Ext.Ajax.request({url:'/api/GSuites_Index_Config',method:'GET',success:function success(response){var data=null;if(response.responseText){data=JSON.parse(response.responseText);if(data.root.length==0){data=null;}else{data=JSON.stringify(data.root[0]);}} if(typeof successCallback==='function'){successCallback(data);}}});} return{init:init,initReports:initReports,initReportsWithoutFrame:initReportsWithoutFrame,setData:setData,checkConfig:checkConfig,renderAttachment:renderAttachment,clearCache:clearCache,reportExportShow:reportExportShow,renderAttachmentMult:renderAttachmentMult,setEventsAttachmentMult:setEventsAttachmentMult};}();if($('#hidJsonPageNames').length>0){window.gsuiteHelper.pages=JSON.parse($('#hidJsonPageNames').val());}});;$(document).ready(function(){window.jsTreeHelper=function(){var _url='/api/GSuites_Index_Directory';var _urlFiles='/api/GSuites_Index_Files';var _selectedNode;var $modal=$('#GDrive_ExplorerModal');var $modalHeader=$('#GDrive_ExplorerModal_Header',$modal);var $jsTreeContainer;var $jsTreeFilesContainer=$('#divGSuites_DirectoryTree_Files');var _filesInCurrDirectory=[];var _currPage;var _fileAttachedCallback;var _isWithFiles=false;function initTree(withFiles,dirFor){if($jsTreeContainer){$jsTreeContainer.jstree('close_all');}else{$jsTreeContainer=$('#divGSuites_DirectoryTree');$jsTreeContainer.on('ready.jstree',function(e,data){_selectedNode=null;});$jsTreeContainer.on('select_node.jstree',function(e,data){_selectedNode=data.node;if(withFiles===true){_getFiles(_selectedNode.id).then(function(d){var html=null;if(d.files.length<=0||d.files==undefined||d.files==null){html='Folder is empty';}else{html=_getFilesHtml(d.files);} $jsTreeFilesContainer.html(html);_filesInCurrDirectory=d.files;})["catch"](function(err){Dear_Notification_Error(err);});}});$jsTreeContainer.jstree({'core':{'data':function data(node,cb){jsTreeHelper.getNode(node).then(function(d){var data=_getNodeModel(d.files);cb(data);})["catch"](function(err){cb(null);});},'animation':100,'themes':{'variant':'large'},'multiple':false,'check_callback':true},'plugins':['wholerow','search'],'search':{'case_sensitive':false,'show_only_matches':false}});if(withFiles===true){$(document).on('click','ul.gdrive-explorer-files>li',function(){$(this).parent().children('li').removeClass('active');$(this).addClass('active');});$('#GDrive_ExplorerModal_btnSave').on('click',window.jsTreeHelper.saveFile);$jsTreeFilesContainer.showContent();}else{}} if(withFiles===false){$('#GDrive_ExplorerModal_btnSave').off();$('#GDrive_ExplorerModal_btnSave').on('click',function(){window.jsTreeHelper.setDirectory(dirFor);});}} function setConfig(page,fileAttachedCallback){_currPage=page;_fileAttachedCallback=fileAttachedCallback;} function showPopup(withFiles,dirFor){initTree(withFiles,dirFor);if(withFiles===false){$modal.removeClass('modal-md');$modal.addClass('modal-sm');$modalHeader.text('Choose a folder');}else{$modalHeader.text('Choose a file');} $modal.modal('show');} function closePopup(){$modal.modal('hide');} function refresh(){_selectedNode=null;if($jsTreeContainer){$jsTreeContainer.jstree().deselect_all(true);}} function saveFile(){var fileId=$('.gdrive-explorer-files>li.active').data('fileid');var fileInfo={};for(var i=0;i<_filesInCurrDirectory.length;i++){if(_filesInCurrDirectory[i].id==fileId){fileInfo=_filesInCurrDirectory[i];}} fileInfo.UploadToID=_getTaskID();_attachFile(fileInfo).then(function(){window.jsTreeHelper.closePopup();if(typeof _fileAttachedCallback==='function'){_fileAttachedCallback();}})["catch"](function(err){Dear_Notification_Error(err);});} function setDirectory(dirFor){var data=getSelectedNode();var record=null;var record2=null;if(typeof window.vGSuiteConfigStore!='undefined'){record=window.vGSuiteConfigStore.getAt(0);}else if(typeof window.vScheduledReportSettingsUpdatedStore!='undefined'){record2=window.vScheduledReportSettingsUpdatedStore.getAt(0);} if(dirFor=='reporting'){$('#GDrive_ReportExport #gdLocationNameReporting').text(data.path);$('#setupForm #gdLocationNameReporting').text(data.path);$('#divScheduleReport #gdLocationNameReporting').text(data.path);$('#divScheduledReportEdit #gdLocationNameReporting').text(data.path);if(record){record.set('GD_DefaultDirID_Reporting',data.id);record.set('GD_DefaultDirPath_Reporting',data.path);}else if(record2){record2.set('GD_DirID',data.id);record2.set('GD_DirPath',data.path);}}else if(dirFor=='printing'){$('#gdLocationNamePrinting').text(data.path);if(record){record.set('GD_DefaultDirID_Printing',data.id);record.set('GD_DefaultDirPath_Printing',data.path);}} window.jsTreeHelper.closePopup();} function getNode(node){return _getDirectories(node.id);} function getSelectedNode(){var getNodeText=function getNodeText(id){var node=$jsTreeContainer.jstree(true).get_node(id);if(node){return node.text;} return'';};if(_selectedNode!=null){var count=_selectedNode.parents.length;var path='';for(var i=count-1;i>=0;i--){if(_selectedNode.parents[i]=='#'){continue;} path+="".concat(getNodeText(_selectedNode.parents[i]),"/");} path+="".concat(getNodeText(_selectedNode.id),"/");return{id:_selectedNode.id,path:path};}} function _getNodeModel(data){var models=[];for(var i=0;i").concat(item.name,"
    • ");result+=li;} result+='';return result;} function _getTaskID(){if(location.hash){var sepIndex=location.hash.indexOf('~');if(sepIndex>-1){return location.hash.substring(1,sepIndex);} return location.hash.substring(1);}else if(document.getElementById('IDToUpload')!=null){return document.getElementById('IDToUpload').value;} return null;} function _getDirectories(id){return new Promise(function(resolve,reject){var url=id=='#'?_url:"".concat(_url,"?parentId=").concat(id);Ext.Ajax.request({url:url,method:'GET',success:function success(response){var data=null;if(response.responseText){data=JSON.parse(response.responseText);} resolve(data);},failure:function failure(response){Dear_Notification_Error(response.responseText);reject(err);}});});} function _getFiles(id){return new Promise(function(resolve,reject){dearHelper.blockUI.show();Ext.Ajax.request({url:"".concat(_urlFiles,"?parentId=").concat(id),method:'GET',success:function success(response){var data=null;if(response.responseText){data=JSON.parse(response.responseText);} dearHelper.blockUI.hide();resolve(data);},failure:function failure(err){dearHelper.blockUI.hide();reject(err);}});});} function _attachFile(fileData){return new Promise(function(resolve,reject){dearHelper.blockUI.show();Ext.Ajax.request({url:"".concat(_urlFiles,"?pageName=").concat(_currPage),method:'POST',params:fileData,success:function success(response){dearHelper.blockUI.hide();var data=null;if(response.responseText){data=JSON.parse(response.responseText);if(data.ErrorMessage){reject(data.ErrorMessage);}} resolve();},failure:function failure(err){dearHelper.blockUI.hide();reject(err);}});});} return{setConfig:setConfig,showPopup:showPopup,closePopup:closePopup,saveFile:saveFile,setDirectory:setDirectory,getNode:getNode,getSelectedNode:getSelectedNode,refresh:refresh};}();});;