improve rename and new poupus
This commit is contained in:
1 parent
01c4a28dcc
commit
9f8ffce08b
5 files changed
+159
-100
No files matched your search
Vendored
+1
-1
@@ -1 +1 @@
|
||||
img,legend{border:0}legend,td,th{padding:0}.fa-ul>li,sub,sup{position:relative}.fa-fw,.fa-li{text-align:center}a:active,a:hover,input{outline:0}.browse a,a,body>nav ul li a{text-decoration:none}html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}.fa,.fa-stack{display:inline-block}abbr[title]{border-bottom:1px dotted}b,optgroup,strong{font-weight:700}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{max-width:100%}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{box-sizing:content-box;height:0}pre,textarea{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}.fa.fa-pull-left,.fa.pull-left{margin-right:.3em}button{overflow:visible}button,select{text-transform:none}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{height:auto}input[type=search]{-webkit-appearance:textfield;box-sizing:content-box}.block,.noty_icon,.noty_text,body>nav,fieldset{box-sizing:border-box}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}table{border-collapse:collapse;border-spacing:0}@font-face{font-family:FontAwesome;src:url(../fonts/fontawesome-webfont.eot?v=4.5.0);src:url(../fonts/fontawesome-webfont.eot?#iefix&v=4.5.0) format('embedded-opentype'),url(../fonts/fontawesome-webfont.woff2?v=4.5.0) format('woff2'),url(../fonts/fontawesome-webfont.woff?v=4.5.0) format('woff'),url(../fonts/fontawesome-webfont.ttf?v=4.5.0) format('truetype'),url(../fonts/fontawesome-webfont.svg?v=4.5.0#fontawesomeregular) format('svg');font-weight:400;font-style:normal}.fa{font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.fa-lg{font-size:1.33333333em;line-height:.75em;vertical-align:-15%}.browse .actions .fa,.fa-stack,body>nav ul li{vertical-align:middle}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.28571429em}.fa-ul{padding-left:0;margin-left:2.14285714em;list-style-type:none}.fa.fa-pull-right,.fa.pull-right{margin-left:.3em}.fa-li{position:absolute;left:-2.14285714em;width:2.14285714em;top:.14285714em}.fa-li.fa-lg{left:-1.85714286em}.fa-border{padding:.2em .25em .15em;border:.08em solid #eee;border-radius:.1em}.fa-pull-left{float:left}.fa-pull-right,.pull-right{float:right}.pull-left{float:left}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=1);-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2);-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1);-webkit-transform:scale(-1,1);-ms-transform:scale(-1,1);transform:scale(-1,1)}.fa-flip-vertical{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1);-webkit-transform:scale(1,-1);-ms-transform:scale(1,-1);transform:scale(1,-1)}:root .fa-flip-horizontal,:root .fa-flip-vertical,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-rotate-90{filter:none}.fa-stack{position:relative;width:2em;height:2em;line-height:2em}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:"\f000"}.fa-music:before{content:"\f001"}.fa-search:before{content:"\f002"}.fa-envelopeLine truncated
|
||||
img,legend{border:0}legend,td,th{padding:0}.fa-ul>li,sub,sup{position:relative}.fa-fw,.fa-li{text-align:center}a:active,a:hover,input{outline:0}.browse a,a,body>nav ul li a{text-decoration:none}html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}.fa,.fa-stack{display:inline-block}abbr[title]{border-bottom:1px dotted}b,optgroup,strong{font-weight:700}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{max-width:100%}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{box-sizing:content-box;height:0}pre,textarea{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}.fa.fa-pull-left,.fa.pull-left{margin-right:.3em}button{overflow:visible}button,select{text-transform:none}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{height:auto}input[type=search]{-webkit-appearance:textfield;box-sizing:content-box}*,.block,.noty_icon,.noty_text,body>nav,fieldset{box-sizing:border-box}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}table{border-collapse:collapse;border-spacing:0}@font-face{font-family:FontAwesome;src:url(../fonts/fontawesome-webfont.eot?v=4.5.0);src:url(../fonts/fontawesome-webfont.eot?#iefix&v=4.5.0) format('embedded-opentype'),url(../fonts/fontawesome-webfont.woff2?v=4.5.0) format('woff2'),url(../fonts/fontawesome-webfont.woff?v=4.5.0) format('woff'),url(../fonts/fontawesome-webfont.ttf?v=4.5.0) format('truetype'),url(../fonts/fontawesome-webfont.svg?v=4.5.0#fontawesomeregular) format('svg');font-weight:400;font-style:normal}.fa{font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.fa-lg{font-size:1.33333333em;line-height:.75em;vertical-align:-15%}.browse .actions .fa,.fa-stack,body>nav ul li{vertical-align:middle}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.28571429em}.fa-ul{padding-left:0;margin-left:2.14285714em;list-style-type:none}.fa.fa-pull-right,.fa.pull-right{margin-left:.3em}.fa-li{position:absolute;left:-2.14285714em;width:2.14285714em;top:.14285714em}.fa-li.fa-lg{left:-1.85714286em}.fa-border{padding:.2em .25em .15em;border:.08em solid #eee;border-radius:.1em}.fa-pull-left{float:left}.fa-pull-right,.pull-right{float:right}.pull-left{float:left}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=1);-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2);-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1);-webkit-transform:scale(-1,1);-ms-transform:scale(-1,1);transform:scale(-1,1)}.fa-flip-vertical{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1);-webkit-transform:scale(1,-1);-ms-transform:scale(1,-1);transform:scale(1,-1)}:root .fa-flip-horizontal,:root .fa-flip-vertical,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-rotate-90{filter:none}.fa-stack{position:relative;width:2em;height:2em;line-height:2em}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:"\f000"}.fa-music:before{content:"\f001"}.fa-search:before{content:"\f002"}.fa-enveloLine truncated
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
$(document).ready(function(){$("#logout").click(function(a){return a.preventDefault(),$.ajax({type:"GET",url:"/admin",async:!1,username:"username",password:"password",headers:{Authorization:"Basic xxx"}}).fail(function(){window.location="/"}),!1}),$(document).pjax("a[data-pjax]","#content")}),$(document).on("ready pjax:success",function(){function a(){this.style.height="5px",this.style.height=this.scrollHeight+"px"}return document.title=document.getElementById("site-title").innerHTML,$("textarea").each(a),$("textarea").keyup(a),$(window).resize(function(){$("textarea").each(a)}),$("main").hasClass("browse")&&$(document).trigger("page:browse"),$(".editor")[0]&&$(document).trigger("page:editor"),!1}),$(document).on("page:browse",function(){$("body").off("click",".rename").on("click",".rename",function(a){a.preventDefault(),button=$(this);var b=prompt("New file name:");if(""==b)return!1;"/"!=b.substring(0,1)&&(b=window.location.pathname.replace("/admin/browse/","")+"/"+b);var c='{"filename": "'+b+'"}';return $.ajax({type:"PUT",url:button.data("file"),data:c,dataType:"json",encode:!0}).done(function(a){$.pjax({url:window.location.pathname,container:"#content"}),notification({text:button.data("message"),type:"success",timeout:5e3})}).fail(function(a){notification({text:"Something went wrong.",type:"error"}),console.log(a)}),!1}),$("body").off("click",".delete").on("click",".delete",function(a){return a.preventDefault(),button=$(this),$.ajax({type:"DELETE",url:button.data("file")}).done(function(a){button.parent().parent().fadeOut(),notification({text:button.data("message"),type:"success",timeout:5e3})}).fail(function(a){notification({text:"Something went wrong.",type:"error"}),console.log(a)}),!1}),$(".new").off("click").click(function(a){return a.preventDefault(),$(this).data("opened")?($(".foreground").fadeOut(200),$("#new-file-form").fadeOut(200),$(this).data("opened",!1)):($(".foreground").fadeIn(200),$("#new-file-form").fadeIn(200),$(this).data("opened",!0)),!1}),$(".foreground").off("click").click(function(){$(".input").fadeOut(200),$(".foreground").fadeOut(200),$(".new").data("opened",!1)}),$("#new-file-name").off("keypress").keypress(function(a){return 13==a.keyCode?(a.preventDefault(),$("#new-file-form").submit(),!1):void 0}),$("#new-file-form").submit(function(a){a.preventDefault();var b=$("#new-file-name").val(),c=b.split(":"),d="",e="";if(""==b)return notification({text:"You have to write something. If you want to close the box, click the button again.",type:"warning",timeout:5e3}),!1;if(1==c.length)d=b;else{if(2!=c.length)return notification({text:"Hmm... I don't understand you. Try writing something like 'name[:archetype]'.",type:"error"}),!1;d=c[0],e=c[1]}var f='{"filename": "'+d+'", "archetype": "'+e+'"}';return $.ajax({type:"POST",url:window.location.pathname,data:f,dataType:"json",encode:!0}).done(function(a){notification({text:"File created successfully.",type:"success",timeout:5e3}),$.pjax({url:window.location.pathname.replace("browse","edit")+d,container:"#content"})}).fail(function(a){notification({text:"Something went wrong.",type:"error"}),console.log(a)}),!1}),$("#upload").click(function(a){return a.preventDefault(),$('.actions input[type="file"]').click(),!1}),$('input[type="file"]').on("change",function(a){a.preventDefault(),files=a.target.files;var b=new FormData;return $.each(files,function(a,c){b.append(a,c)}),$.ajax({url:window.location.pathname,type:"POST",data:b,cache:!1,dataType:"json",headers:{"X-Upload":"true"},processData:!1,contentType:!1}).done(function(a){notification({text:"File(s) uploaded successfully.",type:"success",timeout:5e3}),$.pjax({url:window.location.pathname,container:"#content"})}).fail(function(a){notification({text:"Something went wrong.",type:"error"}),console.log(a)}),!1})}),$(document).on("page:editor",function(){var a=$(".editor"),b=$("#editor-preview"),c=$("#editor-source");if(a.hasClass("complete")&&$("#site-title").keyup(function(){$(".frontmatter #title").val($(this).val())}),!a.hasClass("frontmatter-only")){var d=$("#editor-source").data("mode"),e=$('textarea[name="content"]').hide(),f=ace.edit("editor-source");f.getSession().setMode("ace/mode/"+d),f.getSession().setValue(e.val()),f.getSession().on("change",function(){e.val(f.getSession().getValue())}),f.setOptions({wrap:!0,maxLines:1/0,theme:"ace/theme/github",showPrintMargin:!1,fontSize:"1em"}),$("#see-source").off("click").click(function(a){a.preventDefault(),b.hide(),c.fadeIn(),$("#see-preview").data("previewing","false")}),$("#see-preview").off("click").click(function(a){if(a.preventDefault(),"true"==$(this).data("previewing"))b.hide(),c.fadeIn(),$(this).data("previewing","false");else{var d=new showdown.Converter,e=f.getValue(),g=d.makeHtml(e);c.hide(),b.html(g).fadeIn(),$(this).data("previewing","true")}return!1})}$("body").off("keypress","input").on("keypress","input",function(a){return 13==a.keyCode?(a.preventDefault(),$('input[value="Save"]').focus().click(),!1):void 0}),$("form").submitLine truncated
|
||||
$(document).ready(function(){$("#logout").click(function(a){return a.preventDefault(),$.ajax({type:"GET",url:"/admin",async:!1,username:"username",password:"password",headers:{Authorization:"Basic xxx"}}).fail(function(){window.location="/"}),!1}),$(document).pjax("a[data-pjax]","#content")}),$(document).on("ready pjax:success",function(){function a(){this.style.height="5px",this.style.height=this.scrollHeight+"px"}return document.title=document.getElementById("site-title").innerHTML,$("textarea").each(a),$("textarea").keyup(a),$(window).resize(function(){$("textarea").each(a)}),$("main").hasClass("browse")&&$(document).trigger("page:browse"),$(".editor")[0]&&$(document).trigger("page:editor"),!1}),$(document).on("page:browse",function(){var a=$(".foreground");$('input[type="file"]').on("change",function(a){a.preventDefault(),files=a.target.files;var b=new FormData;return $.each(files,function(a,c){b.append(a,c)}),$.ajax({url:window.location.pathname,type:"POST",data:b,cache:!1,dataType:"json",headers:{"X-Upload":"true"},processData:!1,contentType:!1}).done(function(a){notification({text:"File(s) uploaded successfully.",type:"success",timeout:5e3}),$.pjax({url:window.location.pathname,container:"#content"})}).fail(function(a){notification({text:"Something went wrong.",type:"error"}),console.log(a)}),!1}),$("#upload").click(function(a){return a.preventDefault(),$('.actions input[type="file"]').click(),!1});var b=new Object;b.form=$("form#new"),b.button="",b.url="",$(".new").off("click").click(function(c){return c.preventDefault(),b.button=$(this),$(this).data("opened")?(a.fadeOut(200),b.form.fadeOut(200),b.button.data("opened",!1)):(a.fadeIn(200),b.form.fadeIn(200),b.button.data("opened",!0)),!1}),b.form.find('input[type="text"]').off("keypress").keypress(function(a){return 13==a.keyCode?(a.preventDefault(),$(b.form).submit(),!1):void 0}),b.form.submit(function(a){a.preventDefault();var c=b.form.find('input[type="text"]').val(),d=c.split(":"),e="",f="";if(""==c)return notification({text:"You have to write something. If you want to close the box, click the button again.",type:"warning",timeout:5e3}),!1;if(1==d.length)e=c;else{if(2!=d.length)return notification({text:"Hmm... I don't understand you. Try writing something like 'name[:archetype]'.",type:"error"}),!1;e=d[0],f=d[1]}var g='{"filename": "'+e+'", "archetype": "'+f+'"}';return $.ajax({type:"POST",url:window.location.pathname,data:g,dataType:"json",encode:!0}).done(function(a){notification({text:"File created successfully.",type:"success",timeout:5e3}),$.pjax({url:window.location.pathname.replace("browse","edit")+e,container:"#content"})}).fail(function(a){notification({text:"Something went wrong.",type:"error"}),console.log(a)}),!1});var c=new Object;c.form=$("form#rename"),c.button="",c.url="",$(".rename").off("click").click(function(b){return b.preventDefault(),c.button=$(this),$(this).data("opened")?(a.fadeOut(200),c.form.fadeOut(200),c.button.data("opened",!1)):(a.fadeIn(200),c.url=$(this).parent().parent().find(".filename").text(),c.form.fadeIn(200),c.form.find("span").text(c.url),c.form.find('input[type="text"]').val(c.url),c.button.data("opened",!0)),!1}),c.form.find('input[type="text"]').off("keypress").keypress(function(a){return 13==a.keyCode?(a.preventDefault(),$(c.form).submit(),!1):void 0}),c.form.off("submit").submit(function(a){a.preventDefault();var b=c.form.find('input[type="text"]').val();if(""===b)return!1;"/"!=b.substring(0,1)&&(b=window.location.pathname.replace("/admin/browse/","")+"/"+b);var d='{"filename": "'+b+'"}';return $.ajax({type:"PUT",url:c.url,data:d,dataType:"json",encode:!0}).done(function(a){$.pjax({url:window.location.pathname,container:"#content"}),notification({text:c.button.data("message"),type:"success",timeout:5e3})}).fail(function(a){notification({text:"Something went wrong.",type:"error"}),console.log(a)}),!1}),$("body").off("click",".delete").on("click",".delete",function(a){return a.preventDefault(),button=$(this),$.ajax({type:"DELETE",url:button.data("file")}).done(function(a){button.parent().parent().fadeOut(),notification({text:button.data("message"),type:"success",timeout:5e3})}).fail(function(a){notification({text:"Something went wrong.",type:"error"}),console.log(a)}),!1}),a.off("click").click(function(){a.fadeOut(200),b.form.fadeOut(200),c.form.fadeOut(200),b.button.data("opened",!1),c.button.data("opened",!1)})}),$(document).on("page:editor",function(){var a=$(".editor"),b=$("#editor-preview"),c=$("#editor-source");if(a.hasClass("complete")&&$("#site-title").keyup(function(){$(".frontmatter #title").val($(this).val())}),!a.hasClass("frontmatter-only")){var d=$("#editor-source").data("mode"),e=$('textarea[name="content"]').hide(),f=ace.edit("editor-source");f.getSession().setMode("ace/mode/"+d),f.getSession().setValue(e.val()),f.getSession().on("change",function(){e.val(f.getSession().getValue())}),f.setOptions({wrap:!0,maxLines:1/0,theme:"ace/theme/github",showPrintMargin:!1,fontSize:"1em"}),$("#seeLine truncated
|
||||
@@ -7,6 +7,10 @@ body {
|
||||
padding-top: 3em;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: #1976D2;
|
||||
@@ -466,6 +470,8 @@ fieldset input {
|
||||
width: 182%;
|
||||
}
|
||||
|
||||
/* POPUS */
|
||||
|
||||
.foreground {
|
||||
z-index: 99999;
|
||||
position: fixed;
|
||||
@@ -476,7 +482,7 @@ fieldset input {
|
||||
background-color: rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.input {
|
||||
.popup {
|
||||
z-index: 999999;
|
||||
position: fixed;
|
||||
margin: 0 auto;
|
||||
@@ -492,7 +498,7 @@ fieldset input {
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,.12),0 1px 2px rgba(0,0,0,.24);
|
||||
}
|
||||
|
||||
.input input[type="text"] {
|
||||
.popup input[type="text"] {
|
||||
border-bottom: .15em solid white;
|
||||
}
|
||||
|
||||
|
||||
+137
-88
@@ -1,36 +1,40 @@
|
||||
$(document).on('page:browse', function() {
|
||||
$('body').off('click', '.rename').on('click', '.rename', function(event) {
|
||||
var foreground = $('.foreground');
|
||||
|
||||
/* FILE UPLOAD */
|
||||
|
||||
$('input[type="file"]').on('change', function(event) {
|
||||
event.preventDefault();
|
||||
button = $(this);
|
||||
files = event.target.files;
|
||||
|
||||
var filename = prompt("New file name:");
|
||||
|
||||
if (filename == "") {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (filename.substring(0, 1) != "/") {
|
||||
filename = window.location.pathname.replace("/admin/browse/", "") + '/' + filename;
|
||||
}
|
||||
|
||||
var content = '{"filename": "' + filename + '"}';
|
||||
// Create a formdata object and add the files
|
||||
var data = new FormData();
|
||||
$.each(files, function(key, value) {
|
||||
data.append(key, value);
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
type: 'PUT',
|
||||
url: button.data("file"),
|
||||
data: content,
|
||||
url: window.location.pathname,
|
||||
type: 'POST',
|
||||
data: data,
|
||||
cache: false,
|
||||
dataType: 'json',
|
||||
encode: true
|
||||
headers: {
|
||||
'X-Upload': 'true',
|
||||
},
|
||||
processData: false,
|
||||
contentType: false,
|
||||
}).done(function(data) {
|
||||
notification({
|
||||
text: "File(s) uploaded successfully.",
|
||||
type: 'success',
|
||||
timeout: 5000
|
||||
});
|
||||
|
||||
$.pjax({
|
||||
url: window.location.pathname,
|
||||
container: '#content'
|
||||
});
|
||||
notification({
|
||||
text: button.data("message"),
|
||||
type: 'success',
|
||||
timeout: 5000
|
||||
});
|
||||
})
|
||||
}).fail(function(data) {
|
||||
notification({
|
||||
text: 'Something went wrong.',
|
||||
@@ -38,68 +42,51 @@ $(document).on('page:browse', function() {
|
||||
});
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$('body').off('click', '.delete').on('click', '.delete', function(event) {
|
||||
$("#upload").click(function(event) {
|
||||
event.preventDefault();
|
||||
button = $(this);
|
||||
|
||||
$.ajax({
|
||||
type: 'DELETE',
|
||||
url: button.data("file")
|
||||
}).done(function(data) {
|
||||
button.parent().parent().fadeOut();
|
||||
notification({
|
||||
text: button.data("message"),
|
||||
type: 'success',
|
||||
timeout: 5000
|
||||
});
|
||||
}).fail(function(data) {
|
||||
notification({
|
||||
text: 'Something went wrong.',
|
||||
type: 'error'
|
||||
});
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
$('.actions input[type="file"]').click();
|
||||
return false;
|
||||
});
|
||||
|
||||
/* NEW FILE */
|
||||
|
||||
var create = new Object();
|
||||
create.form = $('form#new');
|
||||
create.button = '';
|
||||
create.url = '';
|
||||
|
||||
$('.new').off('click').click(function(event) {
|
||||
event.preventDefault();
|
||||
create.button = $(this);
|
||||
|
||||
if ($(this).data("opened")) {
|
||||
$('.foreground').fadeOut(200);
|
||||
$('#new-file-form').fadeOut(200);
|
||||
$(this).data("opened", false);
|
||||
foreground.fadeOut(200);
|
||||
create.form.fadeOut(200);
|
||||
create.button.data("opened", false);
|
||||
} else {
|
||||
$('.foreground').fadeIn(200);
|
||||
$('#new-file-form').fadeIn(200);
|
||||
$(this).data("opened", true);
|
||||
foreground.fadeIn(200);
|
||||
create.form.fadeIn(200);
|
||||
create.button.data("opened", true);
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.foreground').off('click').click(function() {
|
||||
$('.input').fadeOut(200);
|
||||
$('.foreground').fadeOut(200);
|
||||
$('.new').data("opened", false);
|
||||
});
|
||||
|
||||
$('#new-file-name').off('keypress').keypress(function(event) {
|
||||
create.form.find('input[type="text"]').off('keypress').keypress(function(event) {
|
||||
if (event.keyCode == 13) {
|
||||
event.preventDefault();
|
||||
$('#new-file-form').submit();
|
||||
$(create.form).submit();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('#new-file-form').submit(function(event) {
|
||||
create.form.submit(function(event) {
|
||||
event.preventDefault();
|
||||
var value = $('#new-file-name').val(),
|
||||
|
||||
var value = create.form.find('input[type="text"]').val(),
|
||||
splited = value.split(":"),
|
||||
filename = "",
|
||||
archetype = "";
|
||||
@@ -146,7 +133,6 @@ $(document).on('page:browse', function() {
|
||||
container: '#content'
|
||||
})
|
||||
}).fail(function(data) {
|
||||
// error types
|
||||
notification({
|
||||
text: 'Something went wrong.',
|
||||
type: 'error'
|
||||
@@ -157,44 +143,71 @@ $(document).on('page:browse', function() {
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#upload").click(function(event) {
|
||||
/* RENAME FILE */
|
||||
|
||||
var rename = new Object();
|
||||
rename.form = $('form#rename');
|
||||
rename.button = '';
|
||||
rename.url = '';
|
||||
|
||||
$('.rename').off('click').click(function(event) {
|
||||
event.preventDefault();
|
||||
$('.actions input[type="file"]').click();
|
||||
rename.button = $(this);
|
||||
|
||||
if ($(this).data("opened")) {
|
||||
foreground.fadeOut(200);
|
||||
rename.form.fadeOut(200);
|
||||
rename.button.data("opened", false);
|
||||
} else {
|
||||
foreground.fadeIn(200);
|
||||
rename.url = $(this).parent().parent().find('.filename').text();
|
||||
rename.form.fadeIn(200);
|
||||
rename.form.find('span').text(rename.url);
|
||||
rename.form.find('input[type="text"]').val(rename.url);
|
||||
rename.button.data("opened", true);
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$('input[type="file"]').on('change', function(event) {
|
||||
event.preventDefault();
|
||||
files = event.target.files;
|
||||
rename.form.find('input[type="text"]').off('keypress').keypress(function(event) {
|
||||
if (event.keyCode == 13) {
|
||||
event.preventDefault();
|
||||
$(rename.form).submit();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// Create a formdata object and add the files
|
||||
var data = new FormData();
|
||||
$.each(files, function(key, value) {
|
||||
data.append(key, value);
|
||||
});
|
||||
rename.form.off('submit').submit(function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
var filename = rename.form.find('input[type="text"]').val();
|
||||
if (filename === "") {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (filename.substring(0, 1) != "/") {
|
||||
filename = window.location.pathname.replace("/admin/browse/", "") + '/' + filename;
|
||||
}
|
||||
|
||||
var content = '{"filename": "' + filename + '"}';
|
||||
|
||||
$.ajax({
|
||||
url: window.location.pathname,
|
||||
type: 'POST',
|
||||
data: data,
|
||||
cache: false,
|
||||
type: 'PUT',
|
||||
url: rename.url,
|
||||
data: content,
|
||||
dataType: 'json',
|
||||
headers: {
|
||||
'X-Upload': 'true',
|
||||
},
|
||||
processData: false,
|
||||
contentType: false,
|
||||
encode: true
|
||||
}).done(function(data) {
|
||||
notification({
|
||||
text: "File(s) uploaded successfully.",
|
||||
type: 'success',
|
||||
timeout: 5000
|
||||
});
|
||||
|
||||
$.pjax({
|
||||
url: window.location.pathname,
|
||||
container: '#content'
|
||||
})
|
||||
});
|
||||
notification({
|
||||
text: rename.button.data("message"),
|
||||
type: 'success',
|
||||
timeout: 5000
|
||||
});
|
||||
}).fail(function(data) {
|
||||
notification({
|
||||
text: 'Something went wrong.',
|
||||
@@ -202,6 +215,42 @@ $(document).on('page:browse', function() {
|
||||
});
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$('body').off('click', '.delete').on('click', '.delete', function(event) {
|
||||
event.preventDefault();
|
||||
button = $(this);
|
||||
|
||||
$.ajax({
|
||||
type: 'DELETE',
|
||||
url: button.data("file")
|
||||
}).done(function(data) {
|
||||
button.parent().parent().fadeOut();
|
||||
notification({
|
||||
text: button.data("message"),
|
||||
type: 'success',
|
||||
timeout: 5000
|
||||
});
|
||||
}).fail(function(data) {
|
||||
notification({
|
||||
text: 'Something went wrong.',
|
||||
type: 'error'
|
||||
});
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
/* FOREGROUND */
|
||||
|
||||
foreground.off('click').click(function() {
|
||||
foreground.fadeOut(200);
|
||||
create.form.fadeOut(200);
|
||||
rename.form.fadeOut(200);
|
||||
create.button.data("opened", false);
|
||||
rename.button.data("opened", false);
|
||||
});
|
||||
});
|
||||
+12
-8
@@ -40,9 +40,9 @@
|
||||
<tr>
|
||||
<td>
|
||||
{{if .IsDir}}
|
||||
<i class="fa fa-folder"></i> <a data-pjax href="{{.URL}}">{{.Name}}</a> {{else}} {{ if CanBeEdited .URL }}
|
||||
<i class="fa fa-file"></i> <a data-pjax class="file" href="/admin/edit{{ $path }}{{.URL}}">{{.Name}}</a> {{ else }}
|
||||
<i class="fa fa-file"></i> {{.Name}} {{ end }} {{ end }}
|
||||
<i class="fa fa-folder"></i> <a data-pjax class="filename" href="{{.URL}}">{{.Name}}</a> {{else}} {{ if CanBeEdited .URL }}
|
||||
<i class="fa fa-file"></i> <a data-pjax class="file filename" href="/admin/edit{{ $path }}{{.URL}}">{{.Name}}</a> {{ else }}
|
||||
<i class="fa fa-file"></i> <span class="filename">{{.Name}}</span> {{ end }} {{ end }}
|
||||
</td>
|
||||
<td class="right hideable">{{.HumanSize}}</td>
|
||||
<td class="right hideable">{{.HumanModTime "01/02/2006 3:04:05 PM"}}</td>
|
||||
@@ -55,17 +55,21 @@
|
||||
|
||||
<div class="foreground hidden"></div>
|
||||
|
||||
<form id="new-file-form" class="input hidden">
|
||||
<form class="popup hidden" id="new">
|
||||
<h3>New file</h3>
|
||||
<p>Write the name of the new file. If you want to use an archetype, add <code>:archetype</code> in the end, replacing 'archetype' by its name.</p>
|
||||
<input id="new-file-name" type="text" placeholder="Write here...">
|
||||
<input type="text" placeholder="Write here...">
|
||||
<p class="right">
|
||||
<input type="submit" value="Create">
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<div class="input hidden" id="rename-form">
|
||||
<form class="popup hidden" id="rename">
|
||||
<h3>Rename file</h3>
|
||||
<input id="new-file-name" type="text" placeholder="New name...">
|
||||
</div>
|
||||
<p>Write down the new name of "<span></span>".</p>
|
||||
<input type="text" placeholder="New name...">
|
||||
<p class="right">
|
||||
<input type="submit" value="Rename">
|
||||
</p>
|
||||
</form>
|
||||
{{ end }}
|
||||
Reference in new issue
Block a user