Files
sentcms/public/static/admin/js/main.js

139 lines
5.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
// 当前资源URL目录
var baseRoot = (function () {
var scripts = document.scripts, src = scripts[0].src;
return src.substring(0, src.lastIndexOf("/") - 9) + '/';
})();
// 配置参数
require.config({
waitSeconds: 60,
packages: [{
name: 'moment',
location: 'plugins/moment',
main: 'moment'
}
],
baseUrl: baseRoot,
map: {'*': {css: baseRoot + 'plugins/require/require.css.js'}},
paths: {
'sent': ['common/js/sent'],
'form': ['common/js/require-form'],
'upload': 'common/js/require-upload',
'validator': 'common/js/require-validator',
'message': ['plugins/messager/messager'],
'sortable': 'plugins/Sortable/Sortable.min',
'template': ['plugins/art-template/template'],
'webupload': ['plugins/webuploader/webuploader.min'],
'pcasunzips': ['plugins/jquery/pcasunzips'],
// openSource
'layer': ['plugins/layer/layer'],
'base64': ['plugins/jquery/base64.min'],
'angular': ['plugins/angular/angular.min'],
'cxselect': ['plugins/cxselect/jquery.cxselect.min'],
'websocket': ['plugins/socket/websocket'],
// jQuery
'jquery': ['plugins/jquery/jquery.min'],
'json': ['plugins/jquery/json2.min'],
'jquery.ztree': ['plugins/ztree/jquery.ztree.all.min'],
'jquery.masonry': ['plugins/jquery/masonry.min'],
'jquery.cookies': ['plugins/jquery/jquery.cookie'],
// bootstrap
'bootstrap': ['plugins/bootstrap/js/bootstrap.min'],
'bootstrap.typeahead': ['plugins/bootstrap/js/bootstrap3-typeahead.min'],
'bootstrap.multiselect': ['plugins/bootstrap-multiselect/bootstrap-multiselect'],
'bootstrap-select': 'plugins/bootstrap-select/js/bootstrap-select.min',
'bootstrap-select-lang': 'plugins/bootstrap-select/js/i18n/defaults-zh_CN',
'bootstrap-editable': 'plugins/bootstrap-editable/js/bootstrap-editable.min',
'bootstrap-datetimepicker': 'plugins/eonasdan-bootstrap-datetimepicker/js/bootstrap-datetimepicker.min',
'bootstrap-daterangepicker': 'plugins/bootstrap-daterangepicker/daterangepicker',
// distpicker
'distpicker': ['plugins/distpicker/distpicker'],
'validator-core': 'plugins/nice-validator/jquery.validator',
'validator-lang': 'plugins/nice-validator/local/zh-CN',
'NKeditor': 'plugins/NKeditor/NKeditor-all-min',
//adminlte
'adminlte': ['plugins/adminlte/js/adminlte.min'],
// nanoscroller
'slimscroll': 'plugins/jquery-slimscroll/jquery.slimscroll',
},
shim: {
'message': {deps: ['css!'+'plugins/messager/css/style.css']},
'board': {deps: ['css!'+'plugins/board/board.min.css']},
// open-source
'websocket': {deps: [baseRoot + 'plugins/socket/swfobject.min.js']},
// jquery
'jquery.ztree': {deps: ['css!' + baseRoot + 'plugins/ztree/zTreeStyle/zTreeStyle.css']},
// bootstrap
'bootstrap':{deps: ['jquery']},
'bootstrap.typeahead': {deps: ['bootstrap']},
'bootstrap.multiselect': {deps: ['bootstrap', 'css!' + baseRoot + 'plugins/bootstrap-multiselect/bootstrap-multiselect.css']},
'bootstrap-select-lang': ['bootstrap-select'],
'bootstrap-editable': {deps:['bootstrap', 'css!'+baseRoot+'plugins/bootstrap-editable/css/bootstrap-editable.css'], exports:'$.fn.editable'},
'distpicker': {deps: [baseRoot + 'plugins/distpicker/distpicker.data.js']},
'bootstrap-daterangepicker': [
'moment/locale/zh-cn'
],
'bootstrap-datetimepicker': [
'moment/locale/zh-cn',
'css!'+baseRoot+'plugins/eonasdan-bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css',
],
'validator-lang': ['validator-core'],
'slimscroll': {deps: ['jquery'],exports: '$.fn.extend'},
'adminlte': {deps: ['bootstrap', 'slimscroll'],exports: '$.AdminLTE'},
'webupload': {deps: ['jquery', 'css!'+baseRoot+'plugins/webuploader/theme/webuploader.css', 'css!'+baseRoot+'/plugins/webuploader/theme/app.css']},
'layer': {deps: ['jquery', 'css!'+baseRoot+'plugins/layer/theme/default/layer.css']},
'layui':{exports: "layui"}
},
deps: ['json'],
// 开启debug模式不缓存资源
urlArgs: "ver=" + (new Date()).getTime()
});
// 注册jquery到require模块
require(['jquery', 'bootstrap', 'message', 'adminlte'], function ($) {
//初始配置
var Config = requirejs.s.contexts._.config.config;
//将Config渲染到全局
window.Config = Config;
// 配置语言包的路径
var paths = {}; // 避免目录冲突
paths['backend/'] = 'backend/';
require.config({paths: paths});
$(function(){
require(['sent'], function(sent){
require(['admin/js/backend'], function(backend){
//加载相应模块
if (Config.jsname) {
require([Config.jsname], function (Controller) {
if (Controller.hasOwnProperty(Config.actionname)) {
Controller[Config.actionname]();
} else {
if (Controller.hasOwnProperty("_empty")) {
Controller._empty();
}
}
}, function (e) {
console.error(e);
// 这里可捕获模块加载的错误
});
}
})
})
})
});