diff --git a/route/static/app/public.js b/route/static/app/public.js index dd153ff0f..2d08b25f3 100755 --- a/route/static/app/public.js +++ b/route/static/app/public.js @@ -520,24 +520,16 @@ function onlineEditFile(k, f) { var l = $("#PathPlace input").val(); var h = encodeURIComponent($("#textBody").val()); var a = $("select[name=encoding]").val(); - var loadT = layer.msg(lan.bt.save_file, { - icon: 16, - time: 0 - }); + var loadT = layer.msg('正在保存,请稍候...', {icon: 16,time: 0}); $.post("/files/save_body", "data=" + h + "&path=" + encodeURIComponent(f) + "&encoding=" + a, function(m) { if(k == 1) { layer.close(loadT); } - layer.msg(m.msg, { - icon: m.status ? 1 : 2 - }); + layer.msg(m.msg, {icon: m.status ? 1 : 2}); },'json'); return } - var e = layer.msg(lan.bt.read_file, { - icon: 16, - time: 0 - }); + var e = layer.msg('正在读取文件,请稍候...', {icon: 16,time: 0}); var g = f.split("."); var b = g[g.length - 1]; var d; @@ -595,15 +587,12 @@ function onlineEditFile(k, f) { default: var j = { name: "htmlmixed", - scriptTypes: [{ - matches: /\/x-handlebars-template|\/x-mustache/i, - mode: null - }, { - matches: /(text|application)\/(x-)?vb(a|script)/i, - mode: "vbscript" - }] + scriptTypes: [ + {matches: /\/x-handlebars-template|\/x-mustache/i,mode: null}, + {matches: /(text|application)\/(x-)?vb(a|script)/i,mode: "vbscript"} + ] }; - d = j + d = j; } $.post("/files/get_body", "path=" + encodeURIComponent(f), function(s) { if(s.status === false){ @@ -619,55 +608,57 @@ function onlineEditFile(k, f) { m = s.data.encoding == u[p] ? "selected" : ""; n += '"; } + var code_mirror = null; var r = layer.open({ type: 1, shift: 5, closeBtn: 1, area: ["90%", "90%"], - title: lan.bt.edit_title+"[" + f + "]", - content: '
' - }); - $("#textBody").text(s.data.data); - var q = $(window).height() * 0.9; - $("#textBody").height(q - 160); - var t = CodeMirror.fromTextArea(document.getElementById("textBody"), { - extraKeys: { - "Ctrl-F": "findPersistent", - "Ctrl-H": "replaceAll", - "Ctrl-S": function() { - $("#textBody").text(t.getValue()); - onlineEditFile(2, f) - }, - "Cmd-S":function() { - $("#textBody").text(t.getValue()); - onlineEditFile(2, f) - }, + ', + success:function(){ + $("#textBody").text(s.data.data); + var q = $(window).height() * 0.9; + $("#textBody").height(q - 160); + code_mirror = CodeMirror.fromTextArea(document.getElementById("textBody"), { + extraKeys: { + "Ctrl-F": "findPersistent", + "Ctrl-H": "replaceAll", + "Ctrl-S": function() { + $("#textBody").text(code_mirror.getValue()); + onlineEditFile(2, f) + }, + "Cmd-S":function() { + $("#textBody").text(code_mirror.getValue()); + onlineEditFile(2, f) + }, + }, + mode: d, + lineNumbers: true, + matchBrackets: true, + matchtags: true, + autoMatchParens: true + }); + code_mirror.focus(); + code_mirror.setSize("auto", q - 150); + + $(window).resize(function(){ + var q = $(window).height() * 0.9; + code_mirror.setSize("auto", q - 150); + }); }, - mode: d, - lineNumbers: true, - matchBrackets: true, - matchtags: true, - autoMatchParens: true - }); - t.focus(); - t.setSize("auto", q - 150); - $("#OnlineEditFileBtn").click(function() { - $("#textBody").text(t.getValue()); - onlineEditFile(1, f); - }); - $(".btn-editor-close").click(function() { - layer.close(r); + yes:function(){ + $("#textBody").text(code_mirror.getValue()); + onlineEditFile(1, f); + } }); },'json'); } @@ -1137,18 +1128,21 @@ function bindPanel(a,type,ip,btid,url,user,pw){