From 294ae693b1f1227cee22c3042a664e5047d32992 Mon Sep 17 00:00:00 2001 From: ruibaby Date: Tue, 13 Nov 2018 11:26:19 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E5=90=8E=E5=8F=B0=E7=AE=A1=E7=90=86UI?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/static/js/halo.js | 32 +++++++++++++++++++ src/main/resources/static/js/halo.min.js | 2 +- .../templates/admin/admin_attachment.ftl | 4 +-- .../templates/admin/admin_backup.ftl | 4 +-- .../templates/admin/admin_category.ftl | 4 +-- .../templates/admin/admin_comment.ftl | 4 +-- .../resources/templates/admin/admin_halo.ftl | 4 +-- .../resources/templates/admin/admin_index.ftl | 4 +-- .../resources/templates/admin/admin_menu.ftl | 4 +-- .../templates/admin/admin_option.ftl | 4 +-- .../resources/templates/admin/admin_page.ftl | 4 +-- .../templates/admin/admin_page_gallery.ftl | 4 +-- .../templates/admin/admin_page_link.ftl | 4 +-- .../templates/admin/admin_page_md_editor.ftl | 4 +-- .../resources/templates/admin/admin_post.ftl | 4 +-- .../templates/admin/admin_post_md_editor.ftl | 4 +-- .../templates/admin/admin_profile.ftl | 4 +-- .../resources/templates/admin/admin_tag.ftl | 4 +-- .../templates/admin/admin_theme-editor.ftl | 4 +-- .../resources/templates/admin/admin_theme.ftl | 4 +-- 20 files changed, 69 insertions(+), 37 deletions(-) diff --git a/src/main/resources/static/js/halo.js b/src/main/resources/static/js/halo.js index c854c22bd..168a1ba25 100755 --- a/src/main/resources/static/js/halo.js +++ b/src/main/resources/static/js/halo.js @@ -6,6 +6,33 @@ $.extend({ } }); +$.fn.extend({ + animateCss: function(animationName, callback) { + var animationEnd = (function(el) { + var animations = { + animation: 'animationend', + OAnimation: 'oAnimationEnd', + MozAnimation: 'mozAnimationEnd', + WebkitAnimation: 'webkitAnimationEnd' + }; + + for (var t in animations) { + if (el.style[t] !== undefined) { + return animations[t]; + } + } + })(document.createElement('div')); + + this.addClass('animated ' + animationName).one(animationEnd, function() { + $(this).removeClass('animated ' + animationName); + + if (typeof callback === 'function') callback(); + }); + + return this; + } +}); + /** * 适配移动端并初始化菜单 */ @@ -19,6 +46,7 @@ $(document).ready(function () { } } initMenu(); + $("#animated-header,#animated-content").animateCss("fadeIn"); }); /** @@ -28,6 +56,10 @@ $(document).on('pjax:clicked', function() { initMenu(); }); +$(document).on('pjax:complete',function () { + $("#animated-header,#animated-content").animateCss("fadeIn"); +}); + /** * https://github.com/JpressProjects/jpress/blob/master/jpress-web/src/main/resources/static/admin/js/jpressadmin.js */ diff --git a/src/main/resources/static/js/halo.min.js b/src/main/resources/static/js/halo.min.js index e3590227f..d49fbc565 100644 --- a/src/main/resources/static/js/halo.min.js +++ b/src/main/resources/static/js/halo.min.js @@ -1 +1 @@ -$.extend({halo:function(){}});$(document).ready(function(){if($(window).width()<1024){if($("body").hasClass("layout-boxed")){$("body").removeClass("layout-boxed");}if($("body").hasClass("sidebar-collapse")){$("body").removeClass("sidebar-collapse");}}initMenu();});$(document).on("pjax:clicked",function(){initMenu();});function initMenu(){var pathName=location.pathname;if(pathName=="/admin/posts/edit"){pathName="/admin/posts/new";}if(pathName=="/admin/category/edit"){pathName="/admin/category";}if(pathName=="/admin/tag/edit"){pathName="/admin/tag";}if(pathName=="/admin/page/edit"){pathName="/admin/page/new";}if(pathName=="/admin/page/links"){pathName="/admin/page";}if(pathName=="/admin/page/galleries"){pathName="/admin/page";}if(pathName=="/admin/menus/edit"){pathName="/admin/menus";}$(".sidebar-menu").children().each(function(){var li=$(this);li.find("a").each(function(){var href=$(this).attr("href");if(pathName==href){li.addClass("active");$(this).parent().addClass("active");}else{$(this).parent().removeClass("active");}});});}$.halo.prototype.showMsg=function(text,icon,hideAfter){if(heading==undefined){var heading="提示";}$.toast({text:text,heading:heading,icon:icon,showHideTransition:"fade",allowToastClose:true,hideAfter:hideAfter,stack:1,position:"top-center",textAlign:"left",loader:true,loaderBg:"#ffffff"});};$.halo.prototype.showMsgAndReload=function(text,icon,hideAfter){if(heading==undefined){var heading="提示";}$.toast({text:text,heading:heading,icon:icon,showHideTransition:"fade",allowToastClose:true,hideAfter:hideAfter,stack:1,position:"top-center",textAlign:"left",loader:true,loaderBg:"#ffffff",afterHidden:function(){window.location.reload();}});};$.halo.prototype.showMsgAndRedirect=function(text,icon,hideAfter,url){if(heading==undefined){var heading="提示";}$.toast({text:text,heading:heading,icon:icon,showHideTransition:"fade",allowToastClose:true,hideAfter:hideAfter,stack:1,position:"top-center",textAlign:"left",loader:true,loaderBg:"#ffffff",afterHidden:function(){window.location.href=url;}});};$.halo.prototype.showMsgAndParentRedirect=function(text,icon,hideAfter,url){if(heading==undefined){var heading="提示";}$.toast({text:text,heading:heading,icon:icon,showHideTransition:"fade",allowToastClose:true,hideAfter:hideAfter,stack:1,position:"top-center",textAlign:"left",loader:true,loaderBg:"#ffffff",afterHidden:function(){parent.location.href=url;}});};$.halo.prototype.formatContent=function(a){a=a.replace(/\r\n/g,"
");a=a.replace(/\n/g,"
");a=a.replace(/\s/g," ");return a;};$.halo.prototype.layerModal=function(url,title){layer.open({type:2,title:title,shadeClose:true,shade:0.5,maxmin:true,area:["90%","90%"],content:url,scrollbar:false});};function saveOptions(option){var param=$("#"+option).serialize();$.ajax({type:"post",url:"/admin/option/save",data:param,success:function(data){if(data.code==1){halo.showMsg(data.msg,"success",1000);}else{halo.showMsg(data.msg,"error",2000);}}});} \ No newline at end of file +$.extend({halo:function(){}});$.fn.extend({animateCss:function(animationName,callback){var animationEnd=(function(el){var animations={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"mozAnimationEnd",WebkitAnimation:"webkitAnimationEnd"};for(var t in animations){if(el.style[t]!==undefined){return animations[t];}}})(document.createElement("div"));this.addClass("animated "+animationName).one(animationEnd,function(){$(this).removeClass("animated "+animationName);if(typeof callback==="function"){callback();}});return this;}});$(document).ready(function(){if($(window).width()<1024){if($("body").hasClass("layout-boxed")){$("body").removeClass("layout-boxed");}if($("body").hasClass("sidebar-collapse")){$("body").removeClass("sidebar-collapse");}}initMenu();$("#animated-header,#animated-content").animateCss("fadeIn");});$(document).on("pjax:clicked",function(){initMenu();});$(document).on("pjax:complete",function(){$("#animated-header,#animated-content").animateCss("fadeIn");});function initMenu(){var pathName=location.pathname;if(pathName=="/admin/posts/edit"){pathName="/admin/posts/new";}if(pathName=="/admin/category/edit"){pathName="/admin/category";}if(pathName=="/admin/tag/edit"){pathName="/admin/tag";}if(pathName=="/admin/page/edit"){pathName="/admin/page/new";}if(pathName=="/admin/page/links"){pathName="/admin/page";}if(pathName=="/admin/page/galleries"){pathName="/admin/page";}if(pathName=="/admin/menus/edit"){pathName="/admin/menus";}$(".sidebar-menu").children().each(function(){var li=$(this);li.find("a").each(function(){var href=$(this).attr("href");if(pathName==href){li.addClass("active");$(this).parent().addClass("active");}else{$(this).parent().removeClass("active");}});});}$.halo.prototype.showMsg=function(text,icon,hideAfter){if(heading==undefined){var heading="提示";}$.toast({text:text,heading:heading,icon:icon,showHideTransition:"fade",allowToastClose:true,hideAfter:hideAfter,stack:1,position:"top-center",textAlign:"left",loader:true,loaderBg:"#ffffff"});};$.halo.prototype.showMsgAndReload=function(text,icon,hideAfter){if(heading==undefined){var heading="提示";}$.toast({text:text,heading:heading,icon:icon,showHideTransition:"fade",allowToastClose:true,hideAfter:hideAfter,stack:1,position:"top-center",textAlign:"left",loader:true,loaderBg:"#ffffff",afterHidden:function(){window.location.reload();}});};$.halo.prototype.showMsgAndRedirect=function(text,icon,hideAfter,url){if(heading==undefined){var heading="提示";}$.toast({text:text,heading:heading,icon:icon,showHideTransition:"fade",allowToastClose:true,hideAfter:hideAfter,stack:1,position:"top-center",textAlign:"left",loader:true,loaderBg:"#ffffff",afterHidden:function(){window.location.href=url;}});};$.halo.prototype.showMsgAndParentRedirect=function(text,icon,hideAfter,url){if(heading==undefined){var heading="提示";}$.toast({text:text,heading:heading,icon:icon,showHideTransition:"fade",allowToastClose:true,hideAfter:hideAfter,stack:1,position:"top-center",textAlign:"left",loader:true,loaderBg:"#ffffff",afterHidden:function(){parent.location.href=url;}});};$.halo.prototype.formatContent=function(a){a=a.replace(/\r\n/g,"
");a=a.replace(/\n/g,"
");a=a.replace(/\s/g," ");return a;};$.halo.prototype.layerModal=function(url,title){layer.open({type:2,title:title,shadeClose:true,shade:0.5,maxmin:true,area:["90%","90%"],content:url,scrollbar:false});};function saveOptions(option){var param=$("#"+option).serialize();$.ajax({type:"post",url:"/admin/option/save",data:param,success:function(data){if(data.code==1){halo.showMsg(data.msg,"success",1000);}else{halo.showMsg(data.msg,"error",2000);}}});} \ No newline at end of file diff --git a/src/main/resources/templates/admin/admin_attachment.ftl b/src/main/resources/templates/admin/admin_attachment.ftl index 1eca8bf57..47e4c07d3 100755 --- a/src/main/resources/templates/admin/admin_attachment.ftl +++ b/src/main/resources/templates/admin/admin_attachment.ftl @@ -6,7 +6,7 @@ .div-thumbnail{transition:all .5s ease-in-out;padding:10px} .thumbnail{margin-bottom:0} -
+

<@spring.message code='admin.attachments.title' />

<@spring.message code='admin.attachments.btn.upload' /> @@ -16,7 +16,7 @@
  • <@spring.message code='admin.attachments.title' />
  • -
    +