KodExplorer/static/js/app/src/edit/main.js

2 lines
34 KiB
JavaScript

var animate_time=160;define("app/src/edit/main",["lib/jquery-lib","lib/util","lib/contextMenu/jquery-contextMenu","lib/artDialog/jquery-artDialog","./taskTap","./toolbar","./edit","./mode","../../common/core","../../tpl/search","../../tpl/upload"],function(e){e("lib/jquery-lib"),e("lib/util"),e("lib/contextMenu/jquery-contextMenu"),e("lib/artDialog/jquery-artDialog"),Tap=e("./taskTap"),Toolbar=e("./toolbar"),Editor=e("./edit"),core=e("../../common/core"),rightMenu=Tap.rightMenu,preview=Toolbar.preview,Global={topbar_height:40,isIE:!-[1]},$(document).ready(function(){Tap.init(),Toolbar.init(),""!=G.frist_file&&Editor.add(G.frist_file),window.onbeforeunload=function(){return Editor.hasFileSave()?LNG.if_save_file:void 0}})}),define("app/src/edit/taskTap",[],function(){var e=function(){$(".edit_tab .tab").live("mouseenter",function(){$(this).hasClass("this")||$(this).addClass("hover"),$(this).unbind("mousedown").mousedown(function(e){$(this).hasClass("this")||$.nodeName(e.target,"A")||($(this).removeClass("hover").addClass("this"),Editor.select($(this).attr("uuid")))})}).die("mouseleave").live("mouseleave",function(){$(this).removeClass("hover")}).die("dblclick").live("dblclick",function(e){Editor.remove($(this).attr("uuid")),stopPP(e)}),$(".edit_tab").die("dblclick").live("dblclick",function(e){Editor.add(),stopPP(e)}),$(".edit_tab .tab .close").live("click",function(){var e=$(this).parent().attr("uuid");Editor.remove(e)})},t=function(){$(".context-menu-list").filter(":visible").trigger("contextmenu:hide")},a=function(){$("body").click(t).contextmenu(t),$.contextMenu({zIndex:9999,selector:".edit_tab_menu",items:{close:{name:LNG.close,icon:"remove",accesskey:"d"},close_right:{name:LNG.close_right,icon:"remove-sign",accesskey:"r"},close_others:{name:LNG.close_others,icon:"remove-circle",accesskey:"o"},sep1:"--------",create:{name:LNG.newfile,icon:"plus",accesskey:"n"},preview:{name:LNG.preview,icon:"globe",accesskey:"p"}},callback:function(e,t){var a=t.$trigger,i=a.attr("uuid");switch(e){case"close":Editor.remove();break;case"close_right":var s=$(".edit_tab .tabs .tab").index(a);$(".edit_tab .tabs .tab:gt("+s+")").each(function(){Editor.remove($(this).attr("uuid"))});break;case"close_others":$(".edit_tab .tabs .tab").each(function(){var e=$(this).attr("uuid");e!=i&&Editor.remove(e)});break;case"create":Editor.add();break;case"preview":Toolbar.doAction("preview");break;default:}}}),$(".context-menu-root").addClass("fadein")},i=function(){var e,t,a,i,s=!1,o=!1,n=0,r=0,l=0,c=0,d=0,p=0;$(".edit_tab .tab").die("mousedown").live("mousedown",function(t){$.nodeName(t.target,"A")||(e=$.nodeName(t.target,"SPAN")?$(t.target).parent():$(this),s=!0,this.setCapture&&this.setCapture(),$(document).mousemove(function(e){f(e)}),$(document).one("mouseup",function(e){return m(e),this.releaseCapture&&this.releaseCapture(),stopPP(e),!1}))});var u=function(i){o=!0,n=i.pageX,$tab_parent=$(".edit_tab"),t=$(".edit_tab .tab"),$(".draggable-dragging").remove(),a=e.clone().addClass("draggable-dragging").prependTo("body"),c=parseInt(t.css("margin-right")),d=$tab_parent.width(),p=$tab_parent.get(0).getBoundingClientRect().left,p+=$(window).scrollLeft(),r=e.get(0).getBoundingClientRect().left,l=parseInt(t.css("width"));var s=e.get(0).getBoundingClientRect().top-parseInt(e.css("margin-top")),u=i.clientX-n+r;$("body").prepend("<div class='dragMaskView'></div>"),a.css({width:l+"px",top:s,left:u}),e.css("opacity",0)},f=function(i){if(s){0==o&&u(i);var f=i.clientX-n+r;p>f||f>p+d-l||(a.css("left",f),t.each(function(){var t=$(this).get(0).getBoundingClientRect().left;if(f>t&&t+l/2+c>f){if(e.attr("uuid")==$(this).attr("uuid"))return;h($(this).attr("uuid"),"left")}if(f>t-l/2+c&&t>f){if(e.attr("uuid")==$(this).attr("uuid"))return;h($(this).attr("uuid"),"right")}}))}},h=function(a,s){if(!e.is(":animated")||i!=a){i=a,e.stop(!0,!0),$(".insertTemp").remove(),t=$(".edit_tab .tab");var o=e.width(),n=$(".edit_tab .tab_"+a),r=e.clone(!0).insertAfter(e).css({"margin-right":"0px",border:"none"}).addClass("insertTemp");"left"==s?e.after(n).css("width","0px"):(e.before(n).css("width","0px"),n.before(r)),e.animate({width:o+"px"},animate_time),r.animate({width:"0px"},animate_time,function(){$(this).remove(),t=$(".edit_tab .tab")})}},m=function(){s=!1,o=!1,startTime=0,$(".dragMaskView").remove(),void 0!=a&&(r=e.get(0).getBoundingClientRect().left,a.animate({left:r+"px"},animate_time,function(){e.css("opacity",1),$(this).remove()}))}},s=function(e,t,a){var i=1.5*animate_time,s=122,o=s,n=$(".edit_tab .tab"),r=$(".edit_tab .tabs").width()-4,l=parseInt(n.css("margin-right"))+parseInt(n.css("border-right")),c=parseInt($(".edit_tab .add").outerWidth())+2*l,d=n.length,p=Math.floor((r-c)/(s+l));switch(d>p&&(o=Math.floor((r-c)/d)-l),e){case"add":$(".edit_tab .tabs .this").css({"margin-top":"30px",width:o}).animate({"margin-top":"0px"},i),n.animate({width:o+"px"},i);break;case"remove":void 0!=a&&Editor.select(a),t.animate({width:"0","margin-top":"+=30"},i,function(){t.remove()}),n.animate({width:o+"px"},i);break;case"resize":n.css("width",o+"px");break;default:}};return{rightMenu:{hidden:t},resetWidth:s,init:function(){$("body").live("resize",function(){s("resize")}),e(),i(),a(),Mousetrap.bind(["ctrl+s","command+s"],function(e){e.preventDefault(),e.returnvalue=!1,Editor.save()})}}}),define("app/src/edit/toolbar",[],function(){var e=function(){$(window).bind("resize",function(){i.resize()}),$("#fontsize li").mouseenter(function(){$(this).addClass("lihover"),$(this).unbind("click").click(function(){var e=$(this).text();$("a.font span").text(e),Editor.config("fontsize",e),$(".dropbox").css("display","none"),$("#fontsize li.this").removeClass("this"),$(this).addClass("this"),Editor.current()&&Editor.current().focus()})}).mouseleave(function(){$(this).toggleClass("lihover")}),$(".tools a[action=wordbreak],.tools a[action=display],.tools a[action=auto_complete]").bind("click",function(){$(this).toggleClass("select")}),$(".tools a").bind("click",function(){var e=$(this).attr("action");t(e),Editor.current()&&Editor.current().focus()}),$("#codetheme li").mouseenter(function(){$(this).addClass("lihover"),$(this).unbind("click").click(function(){var e=$(this).attr("theme");Editor.config("theme",e),$("a[action=codetheme] span").text($(this).html()),$(".dropbox").css("display","none"),$("#codetheme li.this").removeClass("this"),$(this).addClass("this")})}).mouseleave(function(){$(this).toggleClass("lihover")}),$(".tools .left a").tooltip({placement:"bottom"})},t=function(e){switch(e){case"max":FrameCall.father("core.editorFull","''");break;default:}if(Editor.current())switch(e){case"save":Editor.save();break;case"saveall":Editor.saveall();break;case"pre":Editor.current().undo();break;case"next":Editor.current().redo();break;case"find":Editor.current().execCommand("find");break;case"gotoline":Editor.current().commands.exec("gotoline",Editor.current());break;case"font":"block"==$("#fontsize").css("display")?$("#fontsize").fadeOut(100):$("#fontsize").fadeIn(100);break;case"codetheme":"block"==$("#codetheme").css("display")?$("#codetheme").fadeOut(100):$("#codetheme").fadeIn(100);break;case"wordbreak":Editor.config("wrap");break;case"display":Editor.config("display");break;case"setting":Editor.config("setting");break;case"auto_complete":Editor.config("auto_complete");break;case"preview":var t=urlDecode(urlDecode(Editor.current().kod.filename));t=core.path2url(t),i.open(t);break;case"close":Editor.remove();break;default:}},a=function(){$(".frame_right input").keyEnter(i.refresh);var e=!1,t=0,a=0;$drag=$(".frame_right .resize"),$box_left=$(".frame_left"),$box=$drag.parent(),$drag.die("mousedown").live("mousedown",function(e){return 1!=e.which?!0:(s(e),this.setCapture&&this.setCapture(),$(document).mousemove(function(e){o(e)}),$(document).one("mouseup",function(e){return n(e),this.releaseCapture&&this.releaseCapture(),!1}),void 0)});var s=function(i){e=!0,t=i.pageX,a=$box.width(),$drag.addClass("resize_active"),$("body").css("cursor","col-resize"),$box.append('<div class="preview_frame mask_view"></div>')},o=function(i){if(!e)return!0;var s=i.pageX-t,o=a-s,n=$(window).width();o>=n-50&&(o=n-50),100>=o&&(o=100),$box_left.css("width",n-o).find(".edit_body").css("width",n-o),$box.width(o),Tap.resetWidth("resize"),Editor.config("resize")},n=function(){return e?(e=!1,$drag.removeClass("resize_active"),$("body").css("cursor","default"),$box.find(".mask_view").remove(),void 0):!1}},i=function(){var e=$(".frame_right"),t=$(".frame_left"),a=e.find("input"),s=400;return{open:function(t){if("block"!=e.css("display")){e.css("display","block").css("width",s);var o=$(window).width()-s;$(".frame_left").css("width",o).find(".edit_body").css("width",o)}a.val(t),e.find(".open_ie").attr("href",t),e.find("iframe").attr("src",t),i.resize()},resize:function(){if("block"==e.css("display")){var a=e.width(),i=$(window).width();a>=i-50&&(a=i-50),100>=a&&(a=100),e.width(a),t.css("width",i-a).find(".edit_body").css("width",i-a)}Tap.resetWidth("resize"),Editor.config("resize")},close:function(){e.css("display","none"),a.val(""),e.find("iframe").attr("src",""),$(".frame_left").css("width","100%").find(".edit_body").css("width","100%"),Tap.resetWidth("resize"),Editor.config("resize")},refresh:function(){var t=a.attr("value");e.find(".open_ie").attr("href",t),e.find("iframe").attr("src",t)}}}();return{preview:i,doAction:t,init:function(){e(),a()}}}),define("app/src/edit/edit",["./mode"],function(e){var t={theme:G.codetheme,auto_complete:!0,fontsize:14,wrap:!0,display:!1},a={},i=void 0,s=e("./mode");ace.require("ace/ext/language_tools");var o=function(e,t){if(void 0==t||void 0==e||1>a.length)return"";for(var i in a)if(a[i].kod[e]==t)return a[i].kod.uuid;return""},n=function(e){var t,i="id_"+UUID();if(void 0==e)return t={uuid:i,name:"newfile.txt",charset:"utf-8",filename:"",mode:s.get("txt")},r(t),l(t),$(".edit_body .this").removeClass("this"),$(".edit_body pre#"+i).addClass("this"),void 0;t={charset:"utf-8",uuid:i,name:core.pathThis(urlDecode(urlDecode(e))),filename:e,mode:s.get(core.pathExt(urlDecode(e)))},r(t,!0);var o=art.dialog({title:!1,content:LNG.getting,icon:"warning"});$.ajax({dataType:"json",url:"./index.php?editor/fileGet&filename="+e,error:function(e,a,i){o.close(),v(t.uuid),core.ajaxError(e,a,i)},success:function(e){if(o.close(),!e.code)return Tips.tips(e),v(t.uuid),void 0;var s=e.data;a[i]=void 0,$("pre#"+i).text(s.content),l(t),$(".edit_body .this").removeClass("this"),$(".edit_body pre#"+i).addClass("this");var n=a[i];n.kod.charset=s.charset,n.navigateTo(0),n.moveCursorTo(0,0)}})},r=function(e,t){var a='<div class="edit_tab_menu tab tab_'+e.uuid+'" uuid="'+e.uuid+'" title="'+urlDecode(urlDecode(e.filename))+'">'+' <div class="name">'+e.name+"</div>"+' <a href="javascript:void(0);" class="close icon-remove-sign"></a>'+' <div style="clear:both;"></div>'+"</div>";$(a).insertBefore(".edit_tab .add");var i='<pre id="'+e.uuid+'" class="edit_content"></pre>';if($(".edit_body .tabs").append(i),c(e.uuid),t){var s=animate_time;animate_time=1,Tap.resetWidth("add"),animate_time=s}else Tap.resetWidth("add")},l=function(e){var s=ace.edit(e.uuid);s.setTheme("ace/theme/"+t.theme),void 0!=e.mode&&s.getSession().setMode("ace/mode/"+e.mode),s.getSession().setTabSize(4),s.getSession().setUseSoftTabs(!0),s.getSession().setUseWrapMode(t.wrap),s.setShowPrintMargin(!1),s.setDragDelay(100),s.setShowInvisibles(t.display),s.setFontSize(t.fontsize),s.setOptions({enableBasicAutocompletion:!0,enableSnippets:!0,enableLiveAutocompletion:t.auto_complete}),s.on("change",function(){u(s,!0)}),s.commands.addCommand({name:"editSave",bindKey:{win:"Ctrl-S",mac:"Command-S",sender:"editor|cli"},exec:function(e){f(e.kod.uuid)}}),s.commands.addCommand({name:"preview",bindKey:{win:"Ctrl-Shift-S",mac:"Command-Shift-S"},exec:function(){preview.open(),Toolbar.doAction("preview")}}),s.kod={uuid:e.uuid,name:e.name,charset:"ansii",filename:e.filename},a[e.uuid]=s,i=e.uuid,a[i].focus()},c=function(e,t){$(".edit_tab .this").removeClass("this"),$(".edit_tab .tab_"+e).addClass("this"),i=e,void 0!=a[e]&&a[e].focus(),1==t&&$(".edit_tab .this").stop(!0,!0).animate({opacity:.3},100).animate({opacity:.8},100).animate({opacity:.5},40).animate({opacity:1},40,function(){a[e].focus()})},d=function(e,t){void 0!=e&&""!=e&&(c(e,t),$(".edit_body .this").removeClass("this"),$(".edit_body pre#"+e).addClass("this"))},p=function(e,i,s){var o=a;void 0!=s&&(o={},o[s]=a[s]);for(var n in o){var r=o[n];switch(e){case"resize":r.resize();break;case"theme":t[e]=i,r.setTheme("ace/theme/"+i);break;case"fontsize":t[e]=i,r.setFontSize(i);break;case"wrap":t[e]=!r.getSession().getUseWrapMode(),r.getSession().setUseWrapMode(t[e]);break;case"display":t[e]=!r.getShowInvisibles(),r.setShowInvisibles(t[e]);break;case"setting":r.commands.exec("showSettingsMenu",r);break;case"auto_complete":t[e]=!r.$enableBasicAutocompletion,r.setOptions({enableLiveAutocompletion:t[e]}),r.$enableBasicAutocompletion=t[e];break;default:}}"theme"==e&&$.ajax({url:"./index.php?setting/set&k=codetheme&v="+i,dataType:"json",success:function(e){tips(e)}})},u=function(e,t){t!=e.hasChanged&&(e.hasChanged=t,$(".edit_tab .tabs .tab_"+e.kod.uuid).toggleClass("edit_changed"))},f=function(e,t){if(void 0!=i){void 0==e&&(e=i),void 0==t&&(t=!1);var s=a[e];if(s.hasChanged){if(void 0==s||""==s)return tips(LNG.data_error,"warning"),void 0;b().focus();var o=urlEncode2(s.getValue()),n=s.kod.filename;$.ajax({type:"POST",async:!1,dataType:"json",url:"./index.php?editor/fileSave",data:"path="+n+"&charset="+s.kod.charset+"&filestr="+o,beforeSend:function(){Tips.loading(LNG.sending)},error:core.ajaxError,success:function(a){Tips.close(a),a.code&&(u(s,!1),t&&v(e))}})}}},h=function(){for(var e in a)f(e)},m=function(e){if(void 0==e&&(e=i),void 0!=a[e]){var t=a[e];t.hasChanged?$.dialog({title:LNG.warning,resize:!1,background:"#fff",opacity:.4,lock:!0,icon:"question",content:t.kod.name+"<br/>"+LNG.if_save_file,padding:30,button:[{name:LNG.button_save,focus:!0,callback:function(){f(e,!0)}},{name:LNG.button_not_save,callback:function(){v(e)}},{name:LNG.button_cancle,callback:function(){b().focus()}}]}):v(e)}},v=function(e){delete a[e];var t="",i=$(".edit_tab .tab"),s=$(".edit_tab .tab_"+e),o=$(".edit_body pre#"+e);s.hasClass("this")?(i.length>1&&($(i[0]).attr("uuid")==e?t=$(i[1]).attr("uuid"):i.each(function(){var a=$(this).attr("uuid");return a==e?!1:(t=a,void 0)})),""!=t&&$(".edit_body pre#"+t).addClass("this"),o.remove(),Tap.resetWidth("remove",s,t)):(o.remove(),Tap.resetWidth("remove",s))},g=function(){for(var e in a)if(a[e].hasChanged)return!0;return!1},_=function(e){core.setSkin(e,"app_code_edit.css")},b=function(){return i&&a[i]?a[i]:!1};return{current:b,hasFileSave:g,config:p,setTheme:_,select:d,remove:m,save:f,saveall:h,add:function(e){var t=o("filename",e);""!=t?d(t,!0):n(e)}}}),define("app/src/edit/mode",[],function(){function e(){for(var e in i)for(var t=0;i[e].length>t;t++)a[i[e][t]]=e}function t(e){return a[e]}var a={},i={abap:["abap"],actionscript:["as"],ada:["ada","adb"],apache_conf:["htaccess","htgroups","htpasswd","conf","htaccess","htgroups","htpasswd"],asciidoc:["asciidoc"],assembly_x86:["asm"],autohotkey:["ahk"],batchfile:["bat","cmd"],c9search:["c9search_results"],c_cpp:["cpp","c","cc","cxx","h","hh","hpp"],clojure:["clj"],cobol:["cbl","cob"],coffee:["coffee","cf","cson","cakefile"],coldfusion:["cfm"],csharp:["cs"],css:["css"],curly:["curly"],d:["d","di"],dart:["dart"],diff:["diff","patch"],dot:["dot"],erlang:["erl","hrl"],ejs:["ejs"],forth:["frt","fs","ldr"],ftl:["ftl"],glsl:["glsl","frag","vert"],golang:["go"],groovy:["groovy"],haml:["haml"],handlebars:["hbs","handlebars","tpl","mustache"],haskell:["hs"],haxe:["hx"],html:["html","htm","xhtml","cshtml"],html_ruby:["erb","rhtml"],ini:["ini","conf","cfg","prefs"],jack:["jack"],jade:["jade"],java:["java"],javascript:["js","jsm"],json:["json","oexe"],jsoniq:["jq"],jsp:["jsp"],jsx:["jsx"],julia:["jl"],latex:["tex","latex","ltx","bib"],less:["less"],liquid:["liquid"],lisp:["lisp"],livescript:["ls"],logiql:["logic","lql"],lsl:["lsl"],lua:["lua"],luapage:["lp"],lucene:["lucene"],makefile:["makefile","gnumakefile","makefile","ocamlmakefile","make"],matlab:["matlab"],markdown:["md","markdown"],mel:["mel"],mysql:["mysql"],mushcode:["mc","mush"],nix:["nix"],objectivec:["m","mm"],ocaml:["ml","mli"],pascal:["pas","p"],perl:["pl","pm"],pgsql:["pgsql"],php:["php","phtml"],powershell:["ps1"],prolog:["plg","prolog"],properties:["properties"],protobuf:["proto"],python:["py"],r:["r"],rdoc:["rd"],rhtml:["rhtml"],ruby:["rb","ru","gemspec","rake","guardfile","rakefile","gemfile"],rust:["rs"],sass:["sass"],scad:["scad"],scala:["scala"],scheme:["scm","rkt"],scss:["scss"],sh:["sh","bash",".bashrc"],sjs:["sjs"],space:["space"],snippets:["snippets"],soy_template:["soy"],sql:["sql"],stylus:["styl","stylus"],svg:["svg"],tcl:["tcl"],tex:["tex"],text:["txt","ini","log"],textile:["textile"],toml:["toml"],twig:["twig"],typescript:["ts","typescript","str"],vbscript:["vbs"],velocity:["vm"],verilog:["v","vh","sv","svh"],xml:["xml","rdf","rss","wsdl","xslt","atom","mathml","mml","xul","xbl"],xquery:["xq"],yaml:["yaml","yml"]};return e(),{get:t,modes:a}}),define("app/common/core",["../tpl/search","../tpl/upload"],function(require,exports){return{filetype:{music:["mp3","wma","wav","mid","aac","ogg","oga","midi","ram","ac3","aif","aiff","m3a","m4a","m4b","mka","mp1","mx3","mp2"],movie:["avi","flv","f4v","wmv","3gp","rmvb","mp4","rm","rmvb","flv","mkv","wmv","asf","avi","aiff","mp4","divx","dv","m4v","mov","mpeg","vob","mpg","mpv","ogm","ogv","qt"],image:["jpg","jpeg","png","bmp","gif","ico","tif","tiff","dib","rle"],code:["html","htm","js","css","less","scss","sass","py","php","rb","erl","lua","pl","c","cpp","m","h","java","jsp","cs","asp","sql","as","go","lsp","yml","json","tpl","xml","cmd","reg","bat","vbs","sh"],doc:["doc","docx","docm","xls","xlsx","xlsb","xlsm","ppt","pptx","pptm"],text:["txt","ini","inc","inf","conf","oexe","md","htaccess","csv","log","asc","tsv"],bindary:["pdf","bin","zip","swf","gzip","rar","arj","tar","gz","cab","tbz","tbz2","lzh","uue","bz2","ace","exe","so","dll","chm","rtf","odp","odt","pages","class","psd","ttf"]},ico:function(e){var t=G.static_path+"images/file_16/",a=["folder","file","edit","search","up","setting","appStore","error","info","mp3","flv","pdf","doc","xls","ppt","html","swf"],i=$.inArray(e,a);return-1==i?t+"file.png":t+e+".png"},contextmenu:function(e){rightMenu.hidden();var t=e||window.event;return t&&($.nodeName(t.target,"TEXTAREA")||$.nodeName(t.target,"INPUT"))?!0:void 0},pathThis:function(e){e=e.replace(/\\/g,"/");var t=e.split("/"),a=t[t.length-1];return""==a&&(a=t[t.length-2]),a},pathFather:function(e){e=e.replace(/\\/g,"/");var t=e.lastIndexOf("/");return e.substr(0,t+1)},pathExt:function(e){e=e.replace(/\\/g,"/"),e=e.replace(/\/+/g,"/");var t=e.lastIndexOf(".");return e=e.substr(t+1),e.toLowerCase()},path2url:function(e){if("http"==e.substr(0,4))return e;if(e=e.replace(/\\/g,"/"),e=e.replace(/\/+/g,"/"),e=e.replace(/\/\.*\//g,"/"),e.substring(0,G.public_path.length)==G.public_path)return G.app_host+"data/public/"+e.replace(G.public_path,"");if(G.is_root){if(e.substring(0,G.web_root.length)==G.web_root)return G.web_host+e.replace(G.web_root,"");var t=G.basic_path.replace(G.web_root,"")+"/";return t=G.web_host+t,t+"index.php?explorer/fileProxy&path="+urlEncode(e)}return G.web_host+G.web_root+e},ajaxError:function(e){core.tips.close(LNG.system_error,!1);var t=e.responseText,a='<div class="ajaxError">'+t+"</div>",i=$.dialog.list.ajaxErrorDialog;return"<!--user login-->"==t.substr(0,17)?(FrameCall.goRefresh(),void 0):(i?i.content(a):$.dialog({id:"ajaxErrorDialog",padding:0,fixed:!0,resize:!0,ico:core.ico("error"),title:"ajax error",content:a}),void 0)},setting:function(e){void 0==e&&(e=""),void 0==window.top.frames.Opensetting_mode?$.dialog.open("./index.php?setting#"+e,{id:"setting_mode",fixed:!0,ico:core.ico("setting"),resize:!0,title:LNG.setting,width:960,height:580}):($.dialog.list.setting_mode.display(!0),FrameCall.top("Opensetting_mode","Setting.setGoto",'"'+e+'"'))},appStore:function(){$.dialog.open("./index.php?app",{id:"app_store",fixed:!0,ico:core.ico("appStore"),resize:!0,title:LNG.app_store,width:800,height:500})},openApp:function(app){if("url"==app.type){var icon=app.icon;-1==app.icon.search(G.static_path)&&"http"!=app.icon.substring(0,4)&&(icon=G.static_path+"images/app/"+app.icon),"number"!=typeof app.width&&-1==app.width.search("%")&&(app.width=parseInt(app.width)),"number"!=typeof app.height&&-1==app.height.search("%")&&(app.height=parseInt(app.height)),$.dialog.open(app.content,{title:app.name,fixed:!0,ico:icon,resize:app.resize,simple:app.simple,title:app.name.replace(".oexe",""),width:app.width,height:app.height})}else{var exec=app.content;eval("{"+exec+"}")}},update:function(e){var t=base64_decode("aHR0cDovL3N0YXRpYy5rYWxjYWRkbGUuY29tL3VwZGF0ZS9tYWluLmpz");require.async(t,function(t){try{t.todo(e)}catch(a){}})},explorer:function(e){void 0==e&&(e=""),$.dialog.open("?/explorer&type=iframe&path="+e,{resize:!0,fixed:!0,ico:core.ico("folder"),title:LNG.ui_filemanage,width:880,height:550})},setSkin:function(e,t){var a="./../../../style/skin/"+e+t,i=G.static_path+"style/skin/"+e+t;require.async(a,function(){$("#link_css_list").attr("href",i),$("link[rel=stylesheet]").each(function(){var e=$(this).attr("href");e.substring(e.length-t.length)==t&&"link_css_list"!=$(this).attr("id")&&$(this).remove()})})},editorFull:function(){var e=$("iframe[name=OpenopenEditor]");e.toggleClass("frame_fullscreen")},language:function(e){Cookie.set("kod_user_language",e,8760),window.location.reload()},tips:{loading:function(e){Tips.loading(e,"info",Global.topbar_height)},close:function(e,t){"object"==typeof e?Tips.close(e.data,e.code,Global.topbar_height):Tips.close(e,t,Global.topbar_height)},tips:function(e,t){"object"==typeof e?Tips.tips(e.data,e.code,Global.topbar_height):Tips.tips(e,t,Global.topbar_height)}},createFlash:function(e,t,a){var i='<object type="application/x-shockwave-flash" id="'+a+'" data="'+e+'" width="100%" height="100%">'+'<param name="movie" value="'+e+'"/>'+'<param name="allowfullscreen" value="true" />'+'<param name="allowscriptaccess" value="always" />'+'<param name="flashvars" value="'+t+'" />'+'<param name="wmode" value="transparent" />'+"</object>";return i},search:function(e,t){var a,i,s=require("../tpl/search"),o=function(){var o=template.compile(s.html);0==$(".dialog_do_search").length?(r(),i={search:e,path:t,is_content:void 0,is_case:void 0,ext:"",LNG:LNG},a=$.dialog({id:"dialog_do_search",padding:0,fixed:!0,ico:core.ico("search"),resize:!0,title:LNG.search,width:450,content:o(i)}),c(i),$("#search_ext").tooltip({placement:"bottom",html:!0}),$("#search_path").tooltip({placement:"bottom",html:!0,title:function(){return $("#search_path").val()}})):($("#search_value").val(e),$("#search_path").val(t),n(),$.dialog.list.dialog_do_search.display(!0))},n=function(){i={search:$("#search_value").val(),path:$("#search_path").val(),is_content:$("#search_is_content").attr("checked"),is_case:$("#search_is_case").attr("checked"),ext:$("#search_ext").val()},c(i)},r=function(){l(),$("#search_value,#search_ext,#search_path").keyEnter(n),$(".search_header a.button").die("click").live("click",n),$(".search_result .list .name").die("click").live("click",function(){var e=$(this).find("a").html(),t=$(this).parent().find(".path a").html()+e;$(this).parent().hasClass("file")?ui.pathOpen.open(t):"explorer"==Config.pageApp?ui.path.list(t+"/","tips"):core.explorer(t+"/")}),$(".search_result .list .path a").die("click").live("click",function(){var e=$(this).html();"explorer"==Config.pageApp?ui.path.list(e,"tips"):core.explorer(e)})},l=function(){$("#search_value").die("keyup").live("keyup",function(){ui.path.setSearchByStr($(this).val())})},c=function(e){var t=150;$("#search_value").focus(),$(".search_result .list").remove();var a=$(".search_result .message td");return e.search&&e.path?1>=e.search.length?(a.hide().html("too short!").fadeIn(t),void 0):($.ajax({url:"index.php?explorer/search",dataType:"json",type:"POST",data:e,beforeSend:function(){a.hide().html(LNG.searching+'<img src="'+G.static_path+'images/loading.gif">').fadeIn(t)},error:core.ajaxError,success:function(e){if(!e.code)return a.hide().html(e.data).fadeIn(t),void 0;if(0==e.data.filelist.length&&0==e.data.folderlist.length)return a.hide().html(LNG.search_null).fadeIn(t),void 0;a.hide();var i=template.compile(s.list);e.data.LNG=LNG,$(i(e.data)).insertAfter(".search_result .message").fadeIn(t)}}),void 0):(a.hide().html(LNG.search_info).fadeIn(t),void 0)};o()},upload:function(){G.upload_path=G.this_path;var e=urlDecode(G.upload_path);uploader.option("server","index.php?explorer/fileUpload&path="+G.upload_path);var t=30>=e.length?e:"..."+e.substr(e.length-30);if(0!=$(".dialog_file_upload").length)return $(".file_upload .upload_path b").html(t),$.dialog.list.dialog_file_upload.display(!0),void 0;var a=require("../tpl/upload"),i=template.compile(a.html),s=WebUploader.Base.formatSize(G.upload_max);$.dialog({padding:5,height:430,resize:!0,ico:core.ico("up"),id:"dialog_file_upload",fixed:!0,title:LNG.upload_muti,content:i({LNG:LNG,maxsize:s}),close:function(){$.each(uploader.getFiles(),function(e,t){uploader.skipFile(t),uploader.removeFile(t)})}}),$(".file_upload .tips").tooltip({placement:"bottom"}),$(".file_upload .upload_path").tooltip({placement:"bottom",title:function(){return G.upload_path}}),$(".file_upload .upload_path b").html(t),$(".file_upload .top_nav a.menu").unbind("click").bind("click",function(){$(this).hasClass("tab_upload")?($(".file_upload .tab_upload").addClass("this"),$(".file_upload .tab_download").removeClass("this"),$(".file_upload .upload_box").removeClass("hidden"),$(".file_upload .download_box").addClass("hidden")):($(".file_upload .tab_upload").removeClass("this"),$(".file_upload .tab_download").addClass("this"),$(".file_upload .upload_box").addClass("hidden"),$(".file_upload .download_box").removeClass("hidden"))}),$(".file_upload .download_box button").unbind("click").bind("click",function(){core.server_dwonload(G.upload_path)}),uploader.addButton({id:"#picker"})},server_dwonload:function(e){var t=$(".download_box"),a=t.find("#download_list"),i=t.find("input").val();if(t.find("input").val(""),!i||"http"!=i.substr(0,4))return core.tips.tips("url false!",!1),void 0;var s=UUID(),o='<div id="'+s+'" class="item">'+'<div class="info"><span class="title" title="'+i+'">'+i+'</span><span class="state">'+LNG.upload_ready+'</span><div style="clear:both"></div></div></div>';a.find(".item").length>0?$(o).insertBefore(a.find(".item:eq(0)")):a.append(o);var n,r,l,c=0,d=$("#"+s+" .state").text(LNG.download_ready),p=$('<div class="progress progress-striped active"><div class="progress-bar" role="progressbar" style="width: 0%;text-align:right;"></div></div>').appendTo("#"+s).find(".progress-bar");$.ajax({url:"./index.php?explorer/serverDownload&type=download&save_path="+e+"&url="+urlEncode2(i)+"&uuid="+s,dataType:"json",error:function(e,t,a){core.ajaxError(e,t,a),clearInterval(n),n=!1,clearTimeout(r),n=!1,p.parent().remove(),d.addClass("error").text(LNG.download_error)},success:function(e){clearInterval(n),n=!1,clearTimeout(r),n=!1,e.code?(FrameCall.father("ui.f5_callback","function(){ui.path.setSelectByFilename('"+e.info+"');}"),d.text(LNG.download_success),$("#"+s+" .info .title").html(e.info)):d.addClass("error").text(LNG.error),p.parent().remove()}});var u=function(){$.ajax({url:"./index.php?explorer/serverDownload&type=percent&uuid="+s,dataType:"json",success:function(e){if(n){if(!e.code)return d.text(LNG.loading),void 0;var t="",a=e.data;if(a){if(a.size=parseFloat(a.size),a.time=parseFloat(a.time),l){var i=(a.size-l.size)/(a.time-l.time);if(c>.2*i){var s=c;c=i,i=s}else c=i;t=core.file_size(i)+"/s"}if(0==a.length)p.css("width","100%").text(LNG.loading);else{var o=round(100*(a.size/a.length),1);p.css("width",o+"%").text(o+"%")}d.text(t+"("+core.file_size(a.length)+")"),l=a}}}})};r=setTimeout(function(){u(),n=setInterval(function(){u()},1e3)},100)},file_size:function(e){if(0==e)return"0B";e=parseFloat(e);var t={GB:1073741824,MB:1048576,KB:1024,"B ":0};for(var a in t)if(e>=t[a])return(e/t[a]).toFixed(1)+a;return"0B"},upload_init:function(){var e="#thelist",t="span.state";uploader=WebUploader.create({swf:G.static_path+"js/lib/webuploader/Uploader.swf",dnd:"body",threads:3,fileSizeLimit:G.upload_max,resize:!1});var a=[];uploader.on("uploadBeforeSend",function(e,t){var a=urlEncode(e.file.fullPath);(void 0==a||"undefined"==a)&&(a=""),t.fullPath=a}).on("fileQueued",function(t){var a,i=$(e),a=t.fullPath;(void 0==a||"undefined"==a)&&(a=t.name),$(e).find(".item").length>0&&(i=$(e).find(".item:eq(0)"));var s='<div id="'+t.id+'" class="item">'+'<div class="info"><span class="title" tytle="'+a+'">'+a+'</span><span class="state">'+LNG.upload_ready+'</span><div style="clear:both"></div></div></div>';$(e).find(".item").length>0?$(s).insertBefore($(e).find(".item:eq(0)")):$(e).append(s),uploader.upload()}).on("uploadProgress",function(e,t){var a=$("#"+e.id),i=a.find(".progress .progress-bar");i.length||(i=$('<div class="progress progress-striped active"><div class="progress-bar" role="progressbar" style="width: 0%"></div></div>').appendTo(a).find(".progress-bar")),a.find(".state").text((100*t).toFixed(2)+"%"),i.css("width",100*t+"%")}).on("uploadAccept",function(e,t){e.file.serverData=t;try{a.push(core.pathThis(t.info))}catch(i){}}).on("uploadSuccess",function(e){var i=e.serverData;i.code?$("#"+e.id).find(t).text(i.data):$("#"+e.id).find(t).addClass("error").text(i.data),uploader.removeFile(e),$("#"+e.id).find(".progress").fadeOut();var s=a;ui.f5_callback(function(){ui.path.setSelectByFilename(s)})}).on("uploadError",function(e){$("#"+e.id).find(t).addClass("error").text(LNG.upload_error)}).on("uploadFinished",function(){$(e).find(".item").delay(2e3).each(function(e){$(this).delay(300*e).slideUp(600)}),a=[],"explorer"==Config.pageApp&&ui.tree.checkIfChange(G.this_path)}).on("error",function(e){core.tips.tips(e,!1)});var i;inState=!1,dragOver=function(){0==inState&&(inState=!0,MaskView.tips(LNG.upload_drag_tips)),i&&window.clearTimeout(i)},dragLeave=function(e){stopPP(e),i&&window.clearTimeout(i),i=window.setTimeout(function(){inState=!1,MaskView.close()},100)},dragDrop=function(e){e=e.originalEvent||e;var t=e.dataTransfer.getData("text/plain");t&&"http"==t.substring(0,4)?ui.path.pathOperate.appAddURL(t):core.upload(),stopPP(e),inState&&(inState=!1,MaskView.close())}}}}),define("app/tpl/search",[],function(){var e="<div class='do_search'> <div class='search_header'> <div class='s_br'> <input type='text' id='search_value' value='{{search}}'/><a class='right button icon-search'></a> <div style='float:right'>{{LNG.path}}:<input type='text' id='search_path' value='{{path}}'/></div> </div> <div class='s_br'> <input type='checkbox' id='search_is_case' {{if is_case}}checked='true'{{/if}}/> <label for='search_is_case'>{{LNG.search_uplow}}</label> <input type='checkbox' id='search_is_content' {{if is_content}}checked='true'{{/if}}/> <label for='search_is_content'>{{LNG.search_content}}</label> <div style='float:right'>{{LNG.file_type}}:<input type='text' id='search_ext' value='{{ext}}' title='{{LNG.search_ext_tips}}'/></div> </div> </div> <div class='search_result'> <table border='0' cellspacing='0' cellpadding='0'> <tr class='search_title'> <td class='name'>{{LNG.name}}</td> <td class='type'>{{LNG.type}}</td> <td class='size'>{{LNG.size}}</td> <td class='path'>{{LNG.path}}</td> </tr> <tr class='message'><td colspan='4'></td></tr> </table> </div> </div>",t="{{each folderlist as v i}} <tr class='list folder' data-path='{{v.path}}{{v.name}}' data-type='folder' data-size='0'> <td class='name'><a href='javascript:void(0);' title='{{LNG.open}}{{v.name}}'>{{v.name}}</a></td> <td class='type'>{{LNG.folder}}</td> <td class='size'>0</td> <td class='path'><a href='javascript:void(0);' title='{{LNG.goto}}{{v.path}}'>{{v.path}}</a></td> </tr> {{/each}} {{each filelist as v i}} <tr class='list file' data-path='{{v.path}}{{v.name}}' data-type='{{v.ext}}' data-size='{{v.size}}'> <td class='name'><a href='javascript:void(0);' title='{{LNG.open}}{{v.name}}'>{{v.name}}</a></td> <td class='type'>{{v.ext}}</td> <td class='size'>{{v.size_friendly}}</td> <td class='path'><a href='javascript:void(0);' title='{{LNG.goto}}{{v.path}}'>{{v.path}}</a></td> </tr> {{/each}}";
return{html:e,list:t}}),define("app/tpl/upload",[],function(){return{html:"<div class='file_upload'> <div class='top_nav'> <a href='javascript:void(0);' class='menu this tab_upload'>{{LNG.upload_local}}</a> <a href='javascript:void(0);' class='menu tab_download''>{{LNG.download_from_server}}</a> <a class='button' style='margin:-1px 0 0 10px;cursor: pointer;' href='javascript:core.upload()'>{{LNG.upload_path_current}}</a> <div style='clear:both'></div> </div> <div class='upload_path'>{{LNG.save_path}}:<b></b></div> <div class='upload_box'> <div class='btns'><div id='picker'>{{LNG.upload_select}}</div> <div tips class='tips' title='{{LNG.upload_size_info}}'>{{LNG.upload_max_size}}:{{maxsize}}</div> <div style='clear:both'></div></div> <div id='uploader' class='wu-example'> <div id='thelist' class='uploader-list'></div> </div> </div> <div class='download_box hidden'> <div class='list'>{{LNG.download_address}}<input type='text' name='url'/> <button class='btn btn-default btn-sm' type='button'>{{LNG.download}}</button> </div> <div style='clear:both'></div> <div id='downloader'> <div id='download_list' class='uploader-list'></div> </div> </div> </div>"}});