From 5a8887832c269b10aa36c43ef51768b3d2d91643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Fri, 24 Feb 2017 11:11:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=87=E4=BB=B6=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/static/admin/app.js | 22 +++++++++++++++++++-- public/static/admin/listen.js | 36 +++++++++++++++++++++++++++++------ public/static/admin/plugs.js | 24 ++++++++++++++++------- 3 files changed, 67 insertions(+), 15 deletions(-) diff --git a/public/static/admin/app.js b/public/static/admin/app.js index 109a78620..bb52eedac 100644 --- a/public/static/admin/app.js +++ b/public/static/admin/app.js @@ -1,6 +1,22 @@ -/* global require, layer, layui */ -var a = document.scripts, c = a[a.length - 1].src, baseUrl = c.substring(0, c.lastIndexOf("/") + 1); +// +---------------------------------------------------------------------- +// | Think.Admin +// +---------------------------------------------------------------------- +// | 版权所有 2016~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ] +// +---------------------------------------------------------------------- +// | 官方网站: http://think.ctolog.com +// +---------------------------------------------------------------------- +// | 开源协议 ( https://mit-license.org ) +// +---------------------------------------------------------------------- +// | github开源项目:https://github.com/zoujingli/Think.Admin +// +---------------------------------------------------------------------- +// 当前资源URL目录 +var baseUrl = (function () { + var scripts = document.scripts, src = scripts[scripts.length - 1].src; + return src.substring(0, src.lastIndexOf("/") + 1); +})(); + +// RequireJs 配置参数 require.config({ baseUrl: baseUrl, waitSeconds: 0, @@ -40,6 +56,7 @@ require.config({ 'admin.listen': {deps: ['jquery', 'jquery.cookies', 'admin.plugs']}, }, deps: ['css!//cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css'], + // 开启debug模式,不缓存资源 urlArgs: "t=" + (new Date()).getTime() }); @@ -47,6 +64,7 @@ window.WEB_SOCKET_SWF_LOCATION = "//cdn.bootcss.com/web-socket-js/1.0.0/WebSocke window.UEDITOR_HOME_URL = (window.ROOT_URL ? window.ROOT_URL + '/static/' : baseUrl) + '../plugs/ueditor/'; window.LAYDATE_PATH = baseUrl + '../plugs/layui/laydate/'; +// UI框架初始化 require(['pace', 'jquery', 'layui', 'laydate', 'bootstrap', 'template', 'ueditor', 'jquery.cookies'], function () { layui.config({dir: baseUrl + '../plugs/layui/'}); layui.use(['layer', 'form', 'element'], function () { diff --git a/public/static/admin/listen.js b/public/static/admin/listen.js index 8d74260a0..bf565cbd6 100644 --- a/public/static/admin/listen.js +++ b/public/static/admin/listen.js @@ -1,3 +1,15 @@ +// +---------------------------------------------------------------------- +// | Think.Admin +// +---------------------------------------------------------------------- +// | 版权所有 2016~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ] +// +---------------------------------------------------------------------- +// | 官方网站: http://think.ctolog.com +// +---------------------------------------------------------------------- +// | 开源协议 ( https://mit-license.org ) +// +---------------------------------------------------------------------- +// | github开源项目:https://github.com/zoujingli/Think.Admin +// +---------------------------------------------------------------------- + define(['jquery', 'admin.plugs'], function () { /*! 定义当前body对象 */ @@ -7,9 +19,11 @@ define(['jquery', 'admin.plugs'], function () { this.$body.on('click', '[data-load]', function () { var url = $(this).attr('data-load'); var tips = $(this).attr('data-tips'); + function _goLoad() { $.form.load(url, {}, 'GET', null, true, tips); } + if ($(this).attr('data-confirm')) { return $.msg.confirm($(this).attr('data-confirm'), _goLoad); } @@ -43,11 +57,11 @@ define(['jquery', 'admin.plugs'], function () { /*! 注册 data-update 事件行为 */ this.$body.on('click', '[data-update]', function () { var id = $(this).attr('data-update') || (function () { - var data = []; - return $($(this).attr('data-list-target') || 'input.list-check-box').map(function () { - (this.checked) && data.push(this.value); - }), data.join(','); - }).call(this); + var data = []; + return $($(this).attr('data-list-target') || 'input.list-check-box').map(function () { + (this.checked) && data.push(this.value); + }), data.join(','); + }).call(this); if (id.length < 1) { return $.msg.tips('请选择需要操作的数据!'); } @@ -125,7 +139,16 @@ define(['jquery', 'admin.plugs'], function () { $container.find('img').on('click', function () { $iframe.attr('src', src); }); - var index = layer.open({type: 1, scrollbar: false, area: ['320px', '600px'], title: false, closeBtn: 1, skin: 'layui-layer-nobg', shadeClose: true, content: $container.removeClass('hide'), end: function () { + var index = layer.open({ + type: 1, + scrollbar: false, + area: ['320px', '600px'], + title: false, + closeBtn: 1, + skin: 'layui-layer-nobg', + shadeClose: true, + content: $container.removeClass('hide'), + end: function () { $container.remove(); } }); @@ -160,6 +183,7 @@ define(['jquery', 'admin.plugs'], function () { $("[data-menu-box]").not($leftmenu).addClass('hide'); $openNode ? $openNode.trigger('click') : $leftmenu.find('[data-open]:first').trigger('click'); } + var $menutarget = $('[data-menu-target]').on('click', function () { $menutarget.not($(this).addClass('active')).removeClass('active'); showLeftMenu($(this).attr('data-menu-target')); diff --git a/public/static/admin/plugs.js b/public/static/admin/plugs.js index ae80aafb2..f543b8e28 100644 --- a/public/static/admin/plugs.js +++ b/public/static/admin/plugs.js @@ -1,4 +1,14 @@ -/* global layer, Pace */ +// +---------------------------------------------------------------------- +// | Think.Admin +// +---------------------------------------------------------------------- +// | 版权所有 2016~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ] +// +---------------------------------------------------------------------- +// | 官方网站: http://think.ctolog.com +// +---------------------------------------------------------------------- +// | 开源协议 ( https://mit-license.org ) +// +---------------------------------------------------------------------- +// | github开源项目:https://github.com/zoujingli/Think.Admin +// +---------------------------------------------------------------------- define(['zeroclipboard', 'jquery'], function (ZeroClipboard) { @@ -150,8 +160,8 @@ define(['zeroclipboard', 'jquery'], function (ZeroClipboard) { msg.prototype.loading = function (msg, callback) { this.close(); return this.index = msg - ? layer.msg(msg, {icon: 16, scrollbar: false, shade: this.shade, time: 0, end: callback}) - : layer.load(2, {time: 0, scrollbar: false, shade: this.shade, end: callback}); + ? layer.msg(msg, {icon: 16, scrollbar: false, shade: this.shade, time: 0, end: callback}) + : layer.load(2, {time: 0, scrollbar: false, shade: this.shade, end: callback}); }; /** @@ -720,10 +730,10 @@ define(['zeroclipboard', 'jquery'], function (ZeroClipboard) { var callback = $(this).attr('data-callback'); $(this).attr('data-listen', "true").validate(function (data) { $.form.load(this.getAttribute('action') || window.location.href, data, - this.getAttribute('method') || 'POST', - window[callback || '_default_callback'] || undefined, true, - this.getAttribute('data-tips') || undefined, - this.getAttribute('data-time') || undefined); + this.getAttribute('method') || 'POST', + window[callback || '_default_callback'] || undefined, true, + this.getAttribute('data-tips') || undefined, + this.getAttribute('data-time') || undefined); }); }); };