Orchard/src/Orchard.Web/Modules/Orchard.Azure.MediaServices/Scripts/Lib/jstree.min.js

3 lines
85 KiB
JavaScript
Raw Normal View History

!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):e("object"==typeof exports?require("jquery"):jQuery)}(function(e,t){"use strict";if(!e.jstree){var i,n,r=0,s=!1,a=!1,o=!1,d=[],l=e("script:last").attr("src"),c=document,h=c.createElement("LI");h.setAttribute("role","treeitem"),i=c.createElement("I"),i.className="jstree-icon jstree-ocl",h.appendChild(i),i=c.createElement("A"),i.className="jstree-anchor",i.setAttribute("href","#"),n=c.createElement("I"),n.className="jstree-icon jstree-themeicon",i.appendChild(n),h.appendChild(i),i=n=null,e.jstree={version:"3.0.0-beta9",defaults:{plugins:[]},plugins:{},path:l&&-1!==l.indexOf("/")?l.replace(/\/[^\/]+$/,""):""},e.jstree.create=function(t,i){var n=new e.jstree.core(++r),s=i;return i=e.extend(!0,{},e.jstree.defaults,i),s&&s.plugins&&(i.plugins=s.plugins),e.each(i.plugins,function(e,t){"core"!==e&&(n=n.plugin(t,i[t]))}),n.init(t,i),n},e.jstree.core=function(e){this._id=e,this._cnt=0,this._data={core:{themes:{name:!1,dots:!1,icons:!1},selected:[],last_error:{}}}},e.jstree.reference=function(t){if(t&&!e(t).length){t.id&&(t=t.id);var i=null;return e(".jstree").each(function(){var n=e(this).data("jstree");return n&&n._model.data[t]?(i=n,!1):void 0}),i}return e(t).closest(".jstree").data("jstree")},e.fn.jstree=function(i){var n="string"==typeof i,r=Array.prototype.slice.call(arguments,1),s=null;return this.each(function(){var a=e.jstree.reference(this),o=n&&a?a[i]:null;return s=n&&o?o.apply(a,r):null,a||n||i!==t&&!e.isPlainObject(i)||e(this).data("jstree",new e.jstree.create(this,i)),a&&!n&&(s=a),null!==s&&s!==t?!1:void 0}),null!==s&&s!==t?s:this},e.expr[":"].jstree=e.expr.createPseudo(function(i){return function(i){return e(i).hasClass("jstree")&&e(i).data("jstree")!==t}}),e.jstree.defaults.core={data:!1,strings:!1,check_callback:!1,error:e.noop,animation:200,multiple:!0,themes:{name:!1,url:!1,dir:!1,dots:!0,icons:!0,stripes:!1,variant:!1,responsive:!0},expand_selected_onload:!0},e.jstree.core.prototype={plugin:function(t,i){var n=e.jstree.plugins[t];return n?(this._data[t]={},n.prototype=this,new n(i,this)):this},init:function(t,i){this._model={data:{"#":{id:"#",parent:null,parents:[],children:[],children_d:[],state:{loaded:!1}}},changed:[],force_full_redraw:!1,redraw_timeout:!1,default_state:{loaded:!0,opened:!1,selected:!1,disabled:!1}},this.element=e(t).addClass("jstree jstree-"+this._id),this.settings=i,this.element.bind("destroyed",e.proxy(this.teardown,this)),this._data.core.ready=!1,this._data.core.loaded=!1,this._data.core.rtl="rtl"===this.element.css("direction"),this.element[this._data.core.rtl?"addClass":"removeClass"]("jstree-rtl"),this.element.attr("role","tree"),this.bind(),this.trigger("init"),this._data.core.original_container_html=this.element.find(" > ul > li").clone(!0),this._data.core.original_container_html.find("li").addBack().contents().filter(function(){return 3===this.nodeType&&(!this.nodeValue||/^\s+$/.test(this.nodeValue))}).remove(),this.element.html("<ul class='jstree-container-ul'><li class='jstree-initial-node jstree-loading jstree-leaf jstree-last'><i class='jstree-icon jstree-ocl'></i><a class='jstree-anchor' href='#'><i class='jstree-icon jstree-themeicon-hidden'></i>"+this.get_string("Loading ...")+"</a></li></ul>"),this._data.core.li_height=this.get_container_ul().children("li:eq(0)").height()||18,this.trigger("loading"),this.load_node("#")},destroy:function(){this.element.unbind("destroyed",this.teardown),this.teardown()},teardown:function(){this.unbind(),this.element.removeClass("jstree").removeData("jstree").find("[class^='jstree']").addBack().attr("class",function(){return this.className.replace(/jstree[^ ]*|$/gi,"")}),this.element=null},bind:function(){this.element.on("dblclick.jstree",function(){if(document.selection&&document.selection.empty)document.selection.empty();else if(window.getSelection){var e=window.getSelection();try{e.removeAllRanges(),e.collapse()}catch(t){}}}).on("click.jstree",".jstree-ocl",e.proxy(function(e){this.toggle_node(e.target)},this)).on("click.jstree",".jstree-anchor",e.proxy(fun
var n,r,s,a;if(e.isArray(t)){for(t=t.slice(),n=0,r=t.length;r>n;n++)this.set_text(t[n],i);return!0}return t=this.get_node(t),t&&"#"!==t.id?(t.text=i,s=this.get_node(t,!0),s.length&&(s=s.children(".jstree-anchor:eq(0)"),a=s.children("I").clone(),s.html(i).prepend(a),this.trigger("set_text",{obj:t,text:i})),!0):!1},get_json:function(e,t,i){if(e=this.get_node(e||"#"),!e)return!1;t&&t.flat&&!i&&(i=[]);var n,r,s={id:e.id,text:e.text,icon:this.get_icon(e),li_attr:e.li_attr,a_attr:e.a_attr,state:{},data:t&&t.no_data?!1:e.data};if(t&&t.flat?s.parent=e.parent:s.children=[],!t||!t.no_state)for(n in e.state)e.state.hasOwnProperty(n)&&(s.state[n]=e.state[n]);if(t&&t.no_id&&(delete s.id,s.li_attr&&s.li_attr.id&&delete s.li_attr.id),t&&t.flat&&"#"!==e.id&&i.push(s),!t||!t.no_children)for(n=0,r=e.children.length;r>n;n++)t&&t.flat?this.get_json(e.children[n],t,i):s.children.push(this.get_json(e.children[n],t));return t&&t.flat?i:"#"===e.id?s.children:s},create_node:function(i,n,r,s,a){if(i=this.get_node(i),!i)return!1;if(r=r===t?"last":r,!r.toString().match(/^(before|after)$/)&&!a&&!this.is_loaded(i))return this.load_node(i,function(){this.create_node(i,n,r,s,!0)});n||(n={text:this.get_string("New node")}),n.text===t&&(n.text=this.get_string("New node"));var o,d,l,c;switch("#"===i.id&&("before"===r&&(r="first"),"after"===r&&(r="last")),r){case"before":o=this.get_node(i.parent),r=e.inArray(i.id,o.children),i=o;break;case"after":o=this.get_node(i.parent),r=e.inArray(i.id,o.children)+1,i=o;break;case"inside":case"first":r=0;break;case"last":r=i.children.length;break;default:r||(r=0)}if(r>i.children.length&&(r=i.children.length),n.id||(n.id=!0),!this.check("create_node",n,i,r))return this.settings.core.error.call(this,this._data.core.last_error),!1;if(n.id===!0&&delete n.id,n=this._parse_model_from_json(n,i.id,i.parents.concat()),!n)return!1;for(o=this.get_node(n),d=[],d.push(n),d=d.concat(o.children_d),this.trigger("model",{nodes:d,parent:i.id}),i.children_d=i.children_d.concat(d),l=0,c=i.parents.length;c>l;l++)this._model.data[i.parents[l]].children_d=this._model.data[i.parents[l]].children_d.concat(d);for(n=o,o=[],l=0,c=i.children.length;c>l;l++)o[l>=r?l+1:l]=i.children[l];return o[r]=n.id,i.children=o,this.redraw_node(i,!0),s&&s.call(this,this.get_node(n)),this.trigger("create_node",{node:this.get_node(n),parent:i.id,position:r}),n.id},rename_node:function(t,i){var n,r,s;if(e.isArray(t)){for(t=t.slice(),n=0,r=t.length;r>n;n++)this.rename_node(t[n],i);return!0}return t=this.get_node(t),t&&"#"!==t.id?(s=t.text,this.check("rename_node",t,this.get_parent(t),i)?(this.set_text(t,i),this.trigger("rename_node",{node:t,text:i,old:s}),!0):(this.settings.core.error.call(this,this._data.core.last_error),!1)):!1},delete_node:function(t){var i,n,r,s,a,o,d,l,c,h;if(e.isArray(t)){for(t=t.slice(),i=0,n=t.length;n>i;i++)this.delete_node(t[i]);return!0}if(t=this.get_node(t),!t||"#"===t.id)return!1;if(r=this.get_node(t.parent),s=e.inArray(t.id,r.children),h=!1,!this.check("delete_node",t,r,s))return this.settings.core.error.call(this,this._data.core.last_error),!1;for(-1!==s&&(r.children=e.vakata.array_remove(r.children,s)),a=t.children_d.concat([]),a.push(t.id),l=0,c=a.length;c>l;l++){for(o=0,d=t.parents.length;d>o;o++)s=e.inArray(a[l],this._model.data[t.parents[o]].children_d),-1!==s&&(this._model.data[t.parents[o]].children_d=e.vakata.array_remove(this._model.data[t.parents[o]].children_d,s));this._model.data[a[l]].state.selected&&(h=!0,s=e.inArray(a[l],this._data.core.selected),-1!==s&&(this._data.core.selected=e.vakata.array_remove(this._data.core.selected,s)))}for(this.trigger("delete_node",{node:t,parent:r.id}),h&&this.trigger("changed",{action:"delete_node",node:t,selected:this._data.core.selected,parent:r.id}),l=0,c=a.length;c>l;l++)delete this._model.data[a[l]];return this.redraw_node(r,!0),!0},check:function(t,i,n,r){i=i&&i.id?i:this.get_node(i),n=n&&n.id?n:this.get_node(n);var s=t.match(/^move_node|copy_node|create_node$/i)?n:i,a=this.settings.core.check_callback;return"move_node"!==t||i.id!==n.id&&e.inArray(i.id,n.children)!==r&&-1===e.inArra
t&&i.element.addClass("vakata-context-rtl").css("direction","rtl"),i.element.find("ul").hide().end()})})}(e),e.jstree.defaults.dnd={copy:!0,open_timeout:500,is_draggable:!0,check_while_dragging:!0},e.jstree.plugins.dnd=function(t,i){this.bind=function(){i.bind.call(this),this.element.on("mousedown touchstart",".jstree-anchor",e.proxy(function(t){var i=this.get_node(t.target),n=this.is_selected(i)?this.get_selected().length:1;return i&&i.id&&"#"!==i.id&&(1===t.which||"touchstart"===t.type)&&(this.settings.dnd.is_draggable===!0||e.isFunction(this.settings.dnd.is_draggable)&&this.settings.dnd.is_draggable.call(this,i))?(this.element.trigger("mousedown.jstree"),e.vakata.dnd.start(t,{jstree:!0,origin:this,obj:this.get_node(i,!0),nodes:n>1?this.get_selected():[i.id]},'<div id="jstree-dnd" class="jstree-'+this.get_theme()+'"><i class="jstree-icon jstree-er"></i>'+(n>1?n+" "+this.get_string("nodes"):this.get_text(t.currentTarget,!0))+'<ins class="jstree-copy" style="display:none;">+</ins></div>')):void 0},this))}},e(function(){var t=!1,i=!1,n=!1,r=e('<div id="jstree-marker">&#160;</div>').hide().appendTo("body");e(document).bind("dnd_start.vakata",function(e,i){t=!1}).bind("dnd_move.vakata",function(s,a){if(n&&clearTimeout(n),a.data.jstree&&(!a.event.target.id||"jstree-marker"!==a.event.target.id)){var o,d,l,c,h,_,u,g,f,p,m,v,y=e.jstree.reference(a.event.target),j=!1,x=!1,k=!1;if(y&&y._data&&y._data.dnd)if(r.attr("class","jstree-"+y.get_theme()),a.helper.children().attr("class","jstree-"+y.get_theme()).find(".jstree-copy:eq(0)")[a.data.origin&&a.data.origin.settings.dnd.copy&&(a.event.metaKey||a.event.ctrlKey)?"show":"hide"](),a.event.target!==y.element[0]&&a.event.target!==y.get_container_ul()[0]||0!==y.get_container_ul().children().length){if(j=e(a.event.target).closest("a"),j&&j.length&&j.parent().is(".jstree-closed, .jstree-open, .jstree-leaf")&&(x=j.offset(),k=a.event.pageY-x.top,l=j.height(),_=l/3>k?["b","i","a"]:k>l-l/3?["a","i","b"]:k>l/2?["i","a","b"]:["i","b","a"],e.each(_,function(s,k){switch(k){case"b":o=x.left-6,d=x.top-5,c=y.get_parent(j),h=j.parent().index();break;case"i":o=x.left-2,d=x.top-5+l/2+1,c=j.parent(),h=0;break;case"a":o=x.left-6,d=x.top-5+l,c=y.get_parent(j),h=j.parent().index()+1}for(u=!0,g=0,f=a.data.nodes.length;f>g;g++)if(p=a.data.origin&&a.data.origin.settings.dnd.copy&&(a.event.metaKey||a.event.ctrlKey)?"copy_node":"move_node",m=h,"move_node"===p&&"a"===k&&a.data.origin&&a.data.origin===y&&c===y.get_parent(a.data.nodes[g])&&(v=y.get_node(c),m>e.inArray(a.data.nodes[g],v.children)&&(m-=1)),u=u&&(y&&y.settings&&y.settings.dnd&&y.settings.dnd.check_while_dragging===!1||y.check(p,a.data.origin&&a.data.origin!==y?a.data.origin.get_node(a.data.nodes[g]):a.data.nodes[g],c,m)),!u){y&&y.last_error&&(i=y.last_error());break}return u?("i"===k&&j.parent().is(".jstree-closed")&&y.settings.dnd.open_timeout&&(n=setTimeout(function(e,t){return function(){e.open_node(t)}}(y,j),y.settings.dnd.open_timeout)),t={ins:y,par:c,pos:h},r.css({left:o+"px",top:d+"px"}).show(),a.helper.find(".jstree-icon:eq(0)").removeClass("jstree-er").addClass("jstree-ok"),i={},_=!0,!1):void 0}),_===!0))return}else{for(u=!0,g=0,f=a.data.nodes.length;f>g&&(u=u&&y.check(a.data.origin&&a.data.origin.settings.dnd.copy&&(a.event.metaKey||a.event.ctrlKey)?"copy_node":"move_node",a.data.origin&&a.data.origin!==y?a.data.origin.get_node(a.data.nodes[g]):a.data.nodes[g],"#","last"),u);g++);if(u)return t={ins:y,par:"#",pos:"last"},r.hide(),void a.helper.find(".jstree-icon:eq(0)").removeClass("jstree-er").addClass("jstree-ok")}t=!1,a.helper.find(".jstree-icon").removeClass("jstree-ok").addClass("jstree-er"),r.hide()}}).bind("dnd_scroll.vakata",function(e,i){i.data.jstree&&(r.hide(),t=!1,i.helper.find(".jstree-icon:eq(0)").removeClass("jstree-ok").addClass("jstree-er"))}).bind("dnd_stop.vakata",function(s,a){if(n&&clearTimeout(n),a.data.jstree){r.hide();var o,d,l=[];if(t){for(o=0,d=a.data.nodes.length;d>o;o++)l[o]=a.data.origin?a.data.origin.get_node(a.data.nodes[o]):a.data.nodes[o];t.ins[a.data.origin&&a.data.origin.settings.dnd.copy&&(a.event.metaKe