🎨 精简js代码

pull/37/head
ruibaby 2018-10-07 13:00:48 +08:00
parent 1d2fdfbbec
commit 65cd25eeb4
14 changed files with 116 additions and 250 deletions

View File

@ -1,7 +1,7 @@
.native-list-one-head a, .native-list-one-content a{
/* color: #424242; */
color: #7575d0;
opacity: 1;!important;
opacity: 1!important;
-webkit-transition: all .15s linear;
-moz-transition: all .15s linear;
-o-transition: all .15s linear;

View File

@ -96,6 +96,7 @@
.skin-yellow-light .nav-tabs-custom > .nav-tabs > li.active {
border-top-color: #fff;
}
.layout-boxed {
background: url('../images/boxed-bg.jpg') repeat fixed;
}
@ -105,9 +106,11 @@
height: 2px;
background-color: #eee;
}
::-webkit-scrollbar-thumb {
background-color: #d0afaf;
}
::-webkit-scrollbar-track {
background-color: #eee;
}
@ -130,15 +133,18 @@
}
.btn-header:hover {
background:#3c8dbc;color:#fff
background: #3c8dbc;
color: #fff
}
.table-responsive {
border: none !important;
}
.table-bordered {
border: none !important;
}
.box {
border-top: none !important;
}

View File

@ -185,6 +185,38 @@ $.halo.prototype.showMsgAndRedirect = function (text, icon, hideAfter, url) {
});
};
/**
*
*
* @param a a
* @returns {*} a
*/
$.halo.prototype.formatContent = function (a) {
a = a.replace(/\r\n/g, '<br/>');
a = a.replace(/\n/g, '<br/>');
a = a.replace(/\s/g, ' ');
return a;
};
/**
* layer
*
* @param url
* @param title
*/
$.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
});
};
/**
*
*/

View File

@ -95,6 +95,7 @@ function loadAvatar() {
* @returns {string}
*/
var parser = new UAParser();
function show_ua(string) {
parser.setUA(string);
var uua = parser.getResult();

View File

@ -2,6 +2,7 @@ var halo = new $.halo();
$(document).ready(function () {
$("#login-name").val(localStorage.getItem("loginName"));
});
function btn_login() {
$('#btn-login').button('loading');
var name = $("#login-name").val();
@ -46,6 +47,7 @@ function btn_login() {
});
}
}
$(document).keydown(function (event) {
if (event.keyCode == 13) {
btn_login();

View File

@ -33,7 +33,7 @@
</div>
<div class="row">
<#list attachments.content as attachment>
<div class="col-lg-2 col-md-3 col-sm-6 col-xs-6 div-thumbnail" onclick="openDetail(${attachment.attachId?c})">
<div class="col-lg-2 col-md-3 col-sm-6 col-xs-6 div-thumbnail" onclick="halo.layerModal('/admin/attachments/attachment?attachId=${attachment.attachId?c}','<@spring.message code="admin.attachments.js.modal.detail-title" />')">
<a href="#" class="thumbnail">
<img src="${attachment.attachSmallPath?if_exists}" class="img-responsive">
</a>
@ -53,18 +53,6 @@
</div>
</section>
<script type="application/javascript">
function openDetail(id) {
layer.open({
type: 2,
title: '<@spring.message code="admin.attachments.js.modal.detail-title" />',
shadeClose: true,
shade: 0.5,
maxmin: true,
area: ['90%', '90%'],
content: '/admin/attachments/attachment?attachId='+id,
scrollbar: false
});
}
function loadFileInput() {
$('#uploadImg').fileinput({
language: 'zh',

View File

@ -185,7 +185,7 @@
'commentId': $("#commentId").val(),
'userAgent': $("#userAgent").val(),
'postId': $("#postId").val(),
'commentContent': formatContent($("#commentContent").val())
'commentContent': halo.formatContent($("#commentContent").val())
},
success: function (data) {
if(data.code==1){
@ -194,18 +194,6 @@
}
});
}
/**
* 格式化字符串
* @param a a
* @returns {*}
*/
function formatContent(a) {
a = a.replace(/\r\n/g, '<br/>');
a = a.replace(/\n/g, '<br/>');
a = a.replace(/\s/g, ' ');
return a;
}
</script>
</div>
<#include "module/_footer.ftl">

View File

@ -337,7 +337,7 @@
<button type="button" class="btn btn-box-tool dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<i class="fa fa-bars"></i></button>
<ul class="dropdown-menu pull-right" role="menu">
<li><a href="#" onclick="openAllLogs()"><@spring.message code='common.btn.view-all' /></a></li>
<li><a href="#" onclick="halo.layerModal('/admin/logs','<@spring.message code="admin.index.widgets.text.all-logs" />')"><@spring.message code='common.btn.view-all' /></a></li>
<li><a href="/admin/logs/clear"><@spring.message code='admin.index.widgets.btn.clear-logs' /></a></li>
</ul>
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse">
@ -409,18 +409,6 @@
$('#blogStart').html(days+1);
$('#blogStartDay').html(days+1);
});
function openAllLogs() {
layer.open({
type: 2,
title: '<@spring.message code="admin.index.widgets.text.all-logs" />',
shadeClose: true,
shade: 0.5,
maxmin: true,
area: ['90%', '90%'],
content: '/admin/logs',
scrollbar: false
});
}
$('#btnWidgetsOption').click(function () {
$('#widgetOptionsPanel').slideToggle(400);
});

View File

@ -94,7 +94,7 @@
<div class="input-group">
<input type="text" class="form-control selectData" id="blogLogo" name="blog_logo" value="${options.blog_logo?if_exists}">
<span class="input-group-btn">
<button class="btn btn-default " type="button" onclick="openAttach('blogLogo')"><@spring.message code='common.btn.choose' /></button>
<button class="btn btn-default " type="button" onclick="halo.layerModal('/admin/attachments/select?id=blogLogo','<@spring.message code="common.js.all-attachment" />')"><@spring.message code='common.btn.choose' /></button>
</span>
</div>
</div>
@ -105,7 +105,7 @@
<div class="input-group">
<input type="text" class="form-control selectData" id="blogFavicon" name="blog_favicon" value="${options.blog_favicon?if_exists}">
<span class="input-group-btn">
<button class="btn btn-default " type="button" onclick="openAttach('blogFavicon')"><@spring.message code='common.btn.choose' /></button>
<button class="btn btn-default " type="button" onclick="halo.layerModal('/admin/attachments/select?id=blogFavicon','<@spring.message code="common.js.all-attachment" />')"><@spring.message code='common.btn.choose' /></button>
</span>
</div>
</div>
@ -663,22 +663,6 @@
checkAttachOption();
});
/**
* 打开附件
*/
function openAttach(id) {
layer.open({
type: 2,
title: '<@spring.message code="common.js.all-attachment" />',
shadeClose: true,
shade: 0.5,
maxmin: true,
area: ['90%', '90%'],
content: '/admin/attachments/select?id='+id,
scrollbar: false
});
}
/**
* 更新所有文章的摘要
*/

View File

@ -66,7 +66,7 @@
<div class="input-group">
<input type="text" class="form-control" id="galleryUrl" name="galleryUrl">
<span class="input-group-btn">
<button class="btn btn-default " type="button" onclick="openAttach('galleryUrl')"><@spring.message code='common.btn.choose' /></button>
<button class="btn btn-default " type="button" onclick="halo.layerModal('/admin/attachments/select?id=galleryUrl','<@spring.message code="common.js.all-attachment" />')"><@spring.message code='common.btn.choose' /></button>
</span>
</div>
</div>
@ -87,7 +87,7 @@
</div>
<div class="row">
<#list galleries.content as gallery>
<div class="col-lg-2 col-md-3 col-sm-6 col-xs-6 div-thumbnail" onclick="openDetail(${gallery.galleryId?c})">
<div class="col-lg-2 col-md-3 col-sm-6 col-xs-6 div-thumbnail" onclick="halo.layerModal('/admin/page/gallery?galleryId=${gallery.galleryId?c}','<@spring.message code="admin.pages.galleries.modal.title" />')">
<a href="#" class="thumbnail">
<img src="${gallery.galleryThumbnailUrl?if_exists}" class="img-responsive">
</a>
@ -110,28 +110,6 @@
$('#btnNewPicture').click(function () {
$('#newPicturePanel').slideToggle(400);
});
function openAttach(id) {
layer.open({
type: 2,
title: '<@spring.message code="common.js.all-attachment" />',
shadeClose: true,
shade: 0.5,
area: ['90%', '90%'],
content: '/admin/attachments/select?id='+id,
scrollbar: false
});
}
function openDetail(id) {
layer.open({
type: 2,
title: '<@spring.message code="admin.pages.galleries.modal.title" />',
shadeClose: true,
shade: 0.5,
area: ['90%', '90%'],
content: '/admin/page/gallery?galleryId='+id,
scrollbar: false
});
}
</script>
</div>
<#include "module/_footer.ftl">

View File

@ -21,7 +21,7 @@
<h1 style="display: inline-block;">
<@spring.message code='admin.pages.edit.title' />
</h1>
<a class="btn-header" id="btnOpenAttach" href="#" onclick="openAttachCopy()">
<a class="btn-header" id="btnOpenAttach" href="#" onclick="halo.layerModal('/admin/attachments/select?type=post','<@spring.message code="common.js.all-attachment" />')">
<@spring.message code='admin.editor.btn.attachs' />
</a>
<ol class="breadcrumb">
@ -104,9 +104,9 @@
<div class="box-body">
<div>
<#if post??>
<img src="${post.postThumbnail?default("/static/images/thumbnail/thumbnail.png")}" class="img-responsive img-thumbnail" id="selectImg" onclick="openAttach('selectImg')" style="cursor: pointer;">
<img src="${post.postThumbnail?default("/static/images/thumbnail/thumbnail.png")}" class="img-responsive img-thumbnail" id="selectImg" onclick="halo.layerModal('/admin/attachments/select?id=selectImg','<@spring.message code="common.js.all-attachment" />')" style="cursor: pointer;">
<#else >
<img src="/static/images/thumbnail/thumbnail.png" class="img-responsive img-thumbnail" id="selectImg" onclick="openAttach('selectImg')" style="cursor: pointer;">
<img src="/static/images/thumbnail/thumbnail.png" class="img-responsive img-thumbnail" id="selectImg" onclick="halo.layerModal('/admin/attachments/select?id=selectImg','<@spring.message code="common.js.all-attachment" />')" style="cursor: pointer;">
</#if>
</div>
</div>
@ -147,33 +147,6 @@
});
})
/**
* 打开附件
*/
function openAttach(e) {
layer.open({
type: 2,
title: '<@spring.message code="common.js.all-attachment" />',
shadeClose: true,
shade: 0.5,
maxmin: true,
area: ['90%', '90%'],
content: '/admin/attachments/select?id='+e,
scrollbar: false
});
}
function openAttachCopy() {
layer.open({
type: 2,
title: '<@spring.message code="common.js.all-attachment" />',
shadeClose: true,
shade: 0.5,
maxmin: true,
area: ['90%', '90%'],
content: '/admin/attachments/select?type=post',
scrollbar: false
});
}
/**
* 检测是否已经存在该链接
* @constructor

View File

@ -20,7 +20,7 @@
</style>
<section class="content-header">
<h1 style="display: inline-block;"><@spring.message code='admin.posts.edit.title' /></h1>
<a class="btn-header" id="btnOpenAttach" href="#" onclick="openAttachCopy()">
<a class="btn-header" id="btnOpenAttach" href="#" onclick="halo.layerModal('/admin/attachments/select?type=post','<@spring.message code="common.js.all-attachment" />')">
<@spring.message code='admin.editor.btn.attachs' />
</a>
<ol class="breadcrumb">
@ -169,9 +169,9 @@
<div class="box-body">
<div>
<#if post??>
<img src="${post.postThumbnail?default("/static/images/thumbnail/thumbnail.png")}" class="img-responsive img-thumbnail" id="selectImg" onclick="openAttach('selectImg')" style="cursor: pointer;">
<img src="${post.postThumbnail?default("/static/images/thumbnail/thumbnail.png")}" class="img-responsive img-thumbnail" id="selectImg" onclick="halo.layerModal('/admin/attachments/select?id=selectImg','<@spring.message code="common.js.all-attachment" />')" style="cursor: pointer;">
<#else >
<img src="/static/images/thumbnail/thumbnail.png" class="img-responsive img-thumbnail" id="selectImg" onclick="openAttach('selectImg')" style="cursor: pointer;">
<img src="/static/images/thumbnail/thumbnail.png" class="img-responsive img-thumbnail" id="selectImg" onclick="halo.layerModal('/admin/attachments/select?id=selectImg','<@spring.message code="common.js.all-attachment" />')" style="cursor: pointer;">
</#if>
</div>
</div>
@ -240,35 +240,6 @@
$('#tagList').tagEditor('addTag',$(this).val());
});
/**
* 打开附件
*/
function openAttach(e) {
layer.open({
type: 2,
title: '<@spring.message code="common.js.all-attachment" />',
shadeClose: true,
shade: 0.5,
maxmin: true,
area: ['90%', '90%'],
content: '/admin/attachments/select?id='+e,
scrollbar: false
});
}
function openAttachCopy() {
layer.open({
type: 2,
title: '<@spring.message code="common.js.all-attachment" />',
shadeClose: true,
shade: 0.5,
maxmin: true,
area: ['90%', '90%'],
content: '/admin/attachments/select?type=post',
scrollbar: false
});
}
/**
* 自动填充路径,并且将汉字转化成拼音以-隔开
*/

View File

@ -77,7 +77,7 @@
<div class="input-group">
<input type="text" class="form-control" id="userAvatar" name="userAvatar" value="${user.userAvatar?if_exists}">
<span class="input-group-btn">
<button class="btn btn-default " type="button" onclick="openAttach('userAvatar')"><@spring.message code='common.btn.choose' /></button>
<button class="btn btn-default " type="button" onclick="halo.layerModal('/admin/attachments/select?id=userAvatar','<@spring.message code="common.js.all-attachment" />')"><@spring.message code='common.btn.choose' /></button>
</span>
</div>
</div>
@ -136,18 +136,6 @@
$(function () {
$('[data-toggle="tooltip"]').tooltip()
});
function openAttach(id) {
layer.open({
type: 2,
title: '<@spring.message code="common.js.all-attachment" />',
shadeClose: true,
shade: 0.5,
maxmin: true,
area: ['90%', '90%'],
content: '/admin/attachments/select?id='+id,
scrollbar: false
});
}
function saveUser(option) {
var param = $('#'+option).serialize();
$.ajax({

View File

@ -40,7 +40,7 @@
</style>
<section class="content-header">
<h1 style="display: inline-block;"><@spring.message code='admin.themes.title' /></h1>
<a class="btn-header" id="showForm" href="#" onclick="openThemeInstall()">
<a class="btn-header" id="showForm" href="#" onclick="halo.layerModal('/admin/themes/install','<@spring.message code="admin.themes.js.install-theme" />')">
<i class="fa fa-cloud-upload" aria-hidden="true"></i><@spring.message code='admin.themes.btn.install' />
</a>
<ol class="breadcrumb">
@ -61,7 +61,7 @@
<div class="box-footer">
<span class="theme-title">${theme.themeName?if_exists?cap_first}</span>
<#if theme.hasOptions>
<button class="btn btn-primary btn-sm pull-right btn-theme-setting" onclick="openSetting('${theme.themeName?if_exists}','<#if theme.hasUpdate>true<#else>false</#if>')" style="display: none"><@spring.message code='admin.themes.btn.setting' /></button>
<button class="btn btn-primary btn-sm pull-right btn-theme-setting" onclick="halo.layerModal('/admin/themes/options?theme=${theme.themeName?if_exists}&hasUpdate=<#if theme.hasUpdate>true<#else>false</#if>','${theme.themeName?if_exists} <@spring.message code="admin.themes.js.theme-setting" />')" style="display: none"><@spring.message code='admin.themes.btn.setting' /></button>
</#if>
<#if activeTheme != "${theme.themeName}">
<button class="btn btn-default btn-sm pull-right btn-theme-enable" onclick="setTheme('${theme.themeName?if_exists}')" style="display: none;margin-right: 3px"><@spring.message code='admin.themes.btn.enable' /></button>
@ -104,21 +104,6 @@
</div>
</div>
<script type="application/javascript">
/**
* 打开安装主题的窗口
*/
function openThemeInstall() {
layer.open({
type: 2,
title: '<@spring.message code="admin.themes.js.install-theme" />',
shadeClose: true,
shade: 0.5,
maxmin: true,
area: ['90%', '90%'],
content: '/admin/themes/install',
scrollbar: false
});
}
/**
* 设置主题
@ -140,24 +125,6 @@
}
});
}
/**
* 打开主题设置
*
* @param theme 主题名
*/
function openSetting(theme,hasUpdate) {
layer.open({
type: 2,
title: theme+' <@spring.message code="admin.themes.js.theme-setting" />',
shadeClose: true,
shade: 0.5,
maxmin: true,
area: ['90%', '90%'],
content: '/admin/themes/options?theme='+theme+'&hasUpdate='+hasUpdate,
scrollbar: false
});
}
$('.theme-thumbnail').mouseover(function () {
$(this).children('.btn-delete').show();
});