重构代码:更新Settings网页代码

This commit is contained in:
Argo-MacBookPro 2018-06-07 12:49:59 +08:00
parent 72c0e47e6f
commit 80e8055d67
2 changed files with 48 additions and 72 deletions

View File

@ -6,6 +6,7 @@
@section Javascript {
<script src="~/js/longbow.dataentity.js"></script>
<script src="~/js/jquery.validate.js"></script>
<script src="~/js/longbow.validate.js"></script>
<script src="~/js/messages_zh.js"></script>
<script src="~/js/Settings.js"></script>
}
@ -14,28 +15,24 @@
}
<div class="panel panel-default">
<div class="panel-heading">系统名称设置</div>
<div class="panel-body">
<form id="headerDataForm" name="headerDataForm">
<div class="input-group form-group col-xs-12">
<input type="text" class="form-control" id="sysName" name="sysName" placeholder="请输入网站标题50字以内" value="@Model.Title" maxlength="50" />
<span class="input-group-btn">
<button class="btn btn-default" type="button" id="sysSave">保存</button>
</span>
</div>
</form>
<div class="panel-body" data-toggle="LgbValidate" data-valid-button="#sysSave">
<div class="input-group form-group col-xs-12">
<input type="text" class="form-control" id="sysName" placeholder="请输入网站标题50字以内" value="@Model.Title" maxlength="50" data-valid="true" />
<span class="input-group-btn">
<button class="btn btn-default" type="button" data-method="title">保存</button>
</span>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">页脚设置</div>
<div class="panel-body">
<form id="footerDataForm" name="footerDataForm">
<div class="input-group form-group col-xs-12">
<input type="text" class="form-control" id="sysFoot" name="sysFoot" placeholder="请输入网站页脚50字以内" value="@Model.Footer" maxlength="50" />
<span class="input-group-btn">
<button class="btn btn-default" type="button" id="footSave">保存</button>
</span>
</div>
</form>
<div class="panel-body" data-toggle="LgbValidate" data-valid-button="#footSave">
<div class="input-group form-group col-xs-12">
<input type="text" class="form-control" id="sysFoot" placeholder="请输入网站页脚50字以内" value="@Model.Footer" maxlength="50" data-valid="true" />
<span class="input-group-btn">
<button class="btn btn-default" type="button" data-method="footer">保存</button>
</span>
</div>
</div>
</div>
<div class="panel panel-default">
@ -54,7 +51,7 @@
<li><a href="#" data-val="">默认样式</a></li>
</ul>
</div>
<button class="btn btn-default pull-right" type="button" id="cssSave">保存</button>
<button class="btn btn-default pull-right" type="button" data-method="css">保存</button>
</div>
</div>
</form>

View File

@ -1,21 +1,5 @@
$(function () {
$('a[data-admin="False"]').hide();
$('#headerDataForm').autoValidate({
sysName: {
required: true,
maxlength: 50
}
}, {
button: ['sysSave']
});
$('#footerDataForm').autoValidate({
sysFoot: {
required: true,
maxlength: 50
}
}, {
button: ['footSave']
});
var bsa = new BootstrapAdmin({
url: Settings.url,
@ -27,46 +11,41 @@
Title: "sysName",
Footer: "sysFoot"
}
}),
click: {
assign: [{
id: 'sysSave',
click: function (row, data) {
if ($(this).attr('data-valid') == "true") {
$.bc({
url: Settings.url, data: { name: '网站标题', code: data.Title, category: Settings.title }, title: Settings.title,
callback: function (result) {
if (result) $('#websiteTitle').text(data.Title);
}
});
})
});
$('button[data-method]').on('click', function (e) {
var $this = $(this);
switch ($this.attr('data-method')) {
case 'footer':
var data = bsa.dataEntity.get();
$.bc({
url: Settings.url, data: { name: '网站页脚', code: data.Footer, category: Settings.title }, title: Settings.title,
callback: function (result) {
if (result) $('#websiteFooter').text(data.Footer);
}
}
}, {
id: 'footSave',
click: function (row, data) {
if ($(this).attr('data-valid') == "true") {
$.bc({
url: Settings.url, data: { name: '网站页脚', code: data.Footer, category: Settings.title }, title: Settings.title,
callback: function (result) {
if (result) $('#websiteFooter').text(data.Footer);
}
});
});
break;
case 'title':
var data = bsa.dataEntity.get();
$.bc({
url: Settings.url, data: { name: '网站标题', code: data.Title, category: Settings.title }, title: Settings.title,
callback: function (result) {
if (result) $('#websiteTitle').text(data.Title);
}
}
}, {
id: 'cssSave',
click: function (row, data) {
var cssDefine = $('#dictCssDefine').val();
$.bc({
url: Settings.url, data: { name: '使用样式', code: cssDefine, category: '当前样式' }, title: '网站样式',
callback: function (result) {
if (result) {
window.setTimeout(function () { window.location.reload(true); }, 1000);
}
});
break;
case 'css':
var cssDefine = $('#dictCssDefine').val();
$.bc({
url: Settings.url, data: { name: '使用样式', code: cssDefine, category: '当前样式' }, title: '网站样式',
callback: function (result) {
if (result) {
window.setTimeout(function () { window.location.reload(true); }, 1000);
}
});
}
}]
}
});
break;
}
});