🎨 更改主题设置代码结构

pull/37/head
ruibaby 2018-10-11 22:36:53 +08:00
parent bc1a0918a8
commit b394677a50
2 changed files with 66 additions and 28 deletions

View File

@ -75,31 +75,6 @@ function initMenu() {
});
}
/**
*
* @param text
* @param icon
* @param hideAfter
*/
function showMsg(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'
});
}
/**
*
*
@ -185,6 +160,36 @@ $.halo.prototype.showMsgAndRedirect = function (text, icon, hideAfter, url) {
});
};
/**
*
* @param text text
* @param icon icon
* @param hideAfter hideAfter
* @param url 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;
}
});
};
/**
*
*

View File

@ -31,6 +31,12 @@
<script src="/static/js/halo.js"></script>
<#nested />
<script>
var halo = new $.halo();
var heading = "<@spring.message code='common.text.tips' />";
/**
* 保存设置选项
* @param option option
*/
function saveThemeOptions(option) {
var param = $('#'+option).serialize();
$.ajax({
@ -39,17 +45,22 @@
data: param,
success: function (data) {
if(data.code==1){
showMsg(data.msg,"success",1000);
halo.showMsg(data.msg, "success", 1000);
}else{
showMsg(data.msg,"error",1000);
halo.showMsg(data.msg, "error", 1000);
}
}
});
}
/**
* 所有附件
* @param id id
*/
function openAttach(id) {
layer.open({
type: 2,
title: '所有附件',
title: '<@spring.message code="common.js.all-attachment" />',
shadeClose: true,
shade: 0.5,
area: ['90%', '90%'],
@ -57,6 +68,28 @@
scrollbar: false
});
}
/**
* 更新主题
*/
function updateTheme(theme, e) {
$(e).button('loading');
$.ajax({
type: 'get',
url: '/admin/themes/pull',
data: {
'themeName': theme
},
success: function (data) {
if (data.code == 1) {
halo.showMsgAndParentRedirect(data.msg, 'success', 1000, '/admin/themes');
} else {
halo.showMsg(data.msg, 'error', 2000);
$(e).button('reset');
}
}
});
}
</script>
</html>
</#macro>