publish
This commit is contained in:
@@ -47,12 +47,12 @@ a cite{font-style: normal; *cursor:pointer;}
|
||||
/** 图标字体 **/
|
||||
@font-face {
|
||||
font-family: 'layui-icon';
|
||||
src: url('../font/iconfont.eot?v=250');
|
||||
src: url('../font/iconfont.eot?v=250#iefix') format('embedded-opentype'),
|
||||
url('../font/iconfont.woff2?v=250') format('woff2'),
|
||||
url('../font/iconfont.woff?v=250') format('woff'),
|
||||
url('../font/iconfont.ttf?v=250') format('truetype'),
|
||||
url('../font/iconfont.svg?v=250#layui-icon') format('svg');
|
||||
src: url('../font/iconfont.eot?v=256');
|
||||
src: url('../font/iconfont.eot?v=256#iefix') format('embedded-opentype'),
|
||||
url('../font/iconfont.woff2?v=256') format('woff2'),
|
||||
url('../font/iconfont.woff?v=256') format('woff'),
|
||||
url('../font/iconfont.ttf?v=256') format('truetype'),
|
||||
url('../font/iconfont.svg?v=256#layui-icon') format('svg');
|
||||
}
|
||||
|
||||
.layui-icon{
|
||||
@@ -90,6 +90,7 @@ a cite{font-style: normal; *cursor:pointer;}
|
||||
.layui-icon-face-smile:before{content:"\e6af"}
|
||||
.layui-icon-survey:before{content:"\e6b2"}
|
||||
.layui-icon-tree:before{content:"\e62e"}
|
||||
.layui-icon-ie:before{content:"\e7bb"}
|
||||
.layui-icon-upload-circle:before{content:"\e62f"}
|
||||
.layui-icon-add-circle:before{content:"\e61f"}
|
||||
.layui-icon-download-circle:before{content:"\e601"}
|
||||
@@ -109,6 +110,7 @@ a cite{font-style: normal; *cursor:pointer;}
|
||||
.layui-icon-carousel:before{content:"\e634"}
|
||||
.layui-icon-help:before{content:"\e607"}
|
||||
.layui-icon-code-circle:before{content:"\e635"}
|
||||
.layui-icon-windows:before{content:"\e67f"}
|
||||
.layui-icon-water:before{content:"\e636"}
|
||||
.layui-icon-username:before{content:"\e66f"}
|
||||
.layui-icon-find-fill:before{content:"\e670"}
|
||||
@@ -121,6 +123,7 @@ a cite{font-style: normal; *cursor:pointer;}
|
||||
.layui-icon-delete:before{content:"\e640"}
|
||||
.layui-icon-play:before{content:"\e652"}
|
||||
.layui-icon-top:before{content:"\e604"}
|
||||
.layui-icon-firefox:before{content:"\e686"}
|
||||
.layui-icon-friends:before{content:"\e612"}
|
||||
.layui-icon-refresh-3:before{content:"\e9aa"}
|
||||
.layui-icon-ok:before{content:"\e605"}
|
||||
@@ -133,6 +136,7 @@ a cite{font-style: normal; *cursor:pointer;}
|
||||
.layui-icon-link:before{content:"\e64c"}
|
||||
.layui-icon-diamond:before{content:"\e735"}
|
||||
.layui-icon-log:before{content:"\e60e"}
|
||||
.layui-icon-key:before{content:"\e683"}
|
||||
.layui-icon-rate-solid:before{content:"\e67a"}
|
||||
.layui-icon-fonts-del:before{content:"\e64f"}
|
||||
.layui-icon-unlink:before{content:"\e64d"}
|
||||
@@ -154,11 +158,15 @@ a cite{font-style: normal; *cursor:pointer;}
|
||||
.layui-icon-add-1:before{content:"\e654"}
|
||||
.layui-icon-face-smile-b:before{content:"\e650"}
|
||||
.layui-icon-fonts-html:before{content:"\e64b"}
|
||||
.layui-icon-screen-full:before{content:"\e622"}
|
||||
.layui-icon-form:before{content:"\e63c"}
|
||||
.layui-icon-cart:before{content:"\e657"}
|
||||
.layui-icon-camera-fill:before{content:"\e65d"}
|
||||
.layui-icon-tabs:before{content:"\e62a"}
|
||||
.layui-icon-heart-fill:before{content:"\e68f"}
|
||||
.layui-icon-fonts-code:before{content:"\e64e"}
|
||||
.layui-icon-ios:before{content:"\e680"}
|
||||
.layui-icon-at:before{content:"\e687"}
|
||||
.layui-icon-fire:before{content:"\e756"}
|
||||
.layui-icon-set:before{content:"\e716"}
|
||||
.layui-icon-fonts-u:before{content:"\e646"}
|
||||
@@ -166,21 +174,29 @@ a cite{font-style: normal; *cursor:pointer;}
|
||||
.layui-icon-tips:before{content:"\e702"}
|
||||
.layui-icon-picture:before{content:"\e64a"}
|
||||
.layui-icon-more-vertical:before{content:"\e671"}
|
||||
.layui-icon-bluetooth:before{content:"\e689"}
|
||||
.layui-icon-flag:before{content:"\e66c"}
|
||||
.layui-icon-loading:before{content:"\e63d"}
|
||||
.layui-icon-fonts-i:before{content:"\e644"}
|
||||
.layui-icon-refresh-1:before{content:"\e666"}
|
||||
.layui-icon-rmb:before{content:"\e65e"}
|
||||
.layui-icon-addition:before{content:"\e624"}
|
||||
.layui-icon-home:before{content:"\e68e"}
|
||||
.layui-icon-time:before{content:"\e68d"}
|
||||
.layui-icon-user:before{content:"\e770"}
|
||||
.layui-icon-notice:before{content:"\e667"}
|
||||
.layui-icon-chrome:before{content:"\e68a"}
|
||||
.layui-icon-edge:before{content:"\e68b"}
|
||||
.layui-icon-login-weibo:before{content:"\e675"}
|
||||
.layui-icon-voice:before{content:"\e688"}
|
||||
.layui-icon-upload-drag:before{content:"\e681"}
|
||||
.layui-icon-login-qq:before{content:"\e676"}
|
||||
.layui-icon-snowflake:before{content:"\e6b1"}
|
||||
.layui-icon-heart:before{content:"\e68c"}
|
||||
.layui-icon-logout:before{content:"\e682"}
|
||||
.layui-icon-file-b:before{content:"\e655"}
|
||||
.layui-icon-template:before{content:"\e663"}
|
||||
.layui-icon-transfer:before{content:"\e691"}
|
||||
.layui-icon-auz:before{content:"\e672"}
|
||||
.layui-icon-console:before{content:"\e665"}
|
||||
.layui-icon-app:before{content:"\e653"}
|
||||
@@ -188,6 +204,7 @@ a cite{font-style: normal; *cursor:pointer;}
|
||||
.layui-icon-website:before{content:"\e7ae"}
|
||||
.layui-icon-next:before{content:"\e65b"}
|
||||
.layui-icon-component:before{content:"\e857"}
|
||||
.layui-icon-android:before{content:"\e684"}
|
||||
.layui-icon-more:before{content:"\e65f"}
|
||||
.layui-icon-login-wechat:before{content:"\e677"}
|
||||
.layui-icon-shrink-right:before{content:"\e668"}
|
||||
@@ -197,6 +214,7 @@ a cite{font-style: normal; *cursor:pointer;}
|
||||
.layui-icon-refresh:before{content:"\e669"}
|
||||
.layui-icon-female:before{content:"\e661"}
|
||||
.layui-icon-male:before{content:"\e662"}
|
||||
.layui-icon-screen-restore:before{content:"\e758"}
|
||||
.layui-icon-password:before{content:"\e673"}
|
||||
.layui-icon-senior:before{content:"\e674"}
|
||||
.layui-icon-theme:before{content:"\e66a"}
|
||||
@@ -206,18 +224,22 @@ a cite{font-style: normal; *cursor:pointer;}
|
||||
.layui-icon-rate:before{content:"\e67b"}
|
||||
.layui-icon-template-1:before{content:"\e656"}
|
||||
.layui-icon-vercode:before{content:"\e679"}
|
||||
.layui-icon-service:before{content:"\e626"}
|
||||
.layui-icon-cellphone:before{content:"\e678"}
|
||||
|
||||
.layui-icon-screen-full:before{content:"\e622";}
|
||||
.layui-icon-screen-restore:before{content:"\e758";}
|
||||
.layui-icon-cols:before{content:"\e610";}
|
||||
.layui-icon-export:before{content:"\e67d";}
|
||||
.layui-icon-print:before{content:"\e66d";}
|
||||
.layui-icon-slider:before{content: "\e714";}
|
||||
.layui-icon-addition:before{content: "\e624";}
|
||||
.layui-icon-subtraction:before{content: "\e67e";}
|
||||
.layui-icon-service:before{content: "\e626";}
|
||||
.layui-icon-transfer:before{content: "\e691";}
|
||||
.layui-icon-print:before{content:"\e66d"}
|
||||
.layui-icon-cols:before{content:"\e610"}
|
||||
.layui-icon-wifi:before{content:"\e7e0"}
|
||||
.layui-icon-export:before{content:"\e67d"}
|
||||
.layui-icon-rss:before{content:"\e808"}
|
||||
.layui-icon-slider:before{content:"\e714"}
|
||||
.layui-icon-email:before{content:"\e618"}
|
||||
.layui-icon-subtraction:before{content:"\e67e"}
|
||||
.layui-icon-mike:before{content:"\e6dc"}
|
||||
.layui-icon-light:before{content:"\e748"}
|
||||
.layui-icon-gift:before{content:"\e627"}
|
||||
.layui-icon-mute:before{content:"\e685"}
|
||||
.layui-icon-reduce-circle:before{content:"\e616"}
|
||||
.layui-icon-music:before{content:"\e690"}
|
||||
|
||||
/* 基本布局 */
|
||||
.layui-main{position: relative; width: 1140px; margin: 0 auto;}
|
||||
@@ -390,28 +412,43 @@ a cite{font-style: normal; *cursor:pointer;}
|
||||
.layui-col-lg-offset12{margin-left: 100%;}
|
||||
}
|
||||
|
||||
/* 列间隔 */.layui-col-space1{margin: -0.5px;}
|
||||
/* 列间隔 */
|
||||
.layui-col-space1{margin: -0.5px;}
|
||||
.layui-col-space1>*{padding: 0.5px;}
|
||||
.layui-col-space3{margin: -1.5px;}
|
||||
.layui-col-space3>*{padding: 1.5px;}
|
||||
.layui-col-space2{margin: -1px;}
|
||||
.layui-col-space2>*{padding: 1px;}
|
||||
.layui-col-space4{margin: -2px;}
|
||||
.layui-col-space4>*{padding: 2px;}
|
||||
.layui-col-space5{margin: -2.5px;}
|
||||
.layui-col-space5>*{padding: 2.5px;}
|
||||
.layui-col-space8{margin: -3.5px;}
|
||||
.layui-col-space8>*{padding: 3.5px;}
|
||||
.layui-col-space6{margin: -3px;}
|
||||
.layui-col-space6>*{padding: 3px;}
|
||||
.layui-col-space8{margin: -4px;}
|
||||
.layui-col-space8>*{padding: 4px;}
|
||||
.layui-col-space10{margin: -5px;}
|
||||
.layui-col-space10>*{padding: 5px;}
|
||||
.layui-col-space12{margin: -6px;}
|
||||
.layui-col-space12>*{padding: 6px;}
|
||||
.layui-col-space14{margin: -7px;}
|
||||
.layui-col-space14>*{padding: 7px;}
|
||||
.layui-col-space15{margin: -7.5px;}
|
||||
.layui-col-space15>*{padding: 7.5px;}
|
||||
.layui-col-space16{margin: -8px;}
|
||||
.layui-col-space16>*{padding: 8px;}
|
||||
.layui-col-space18{margin: -9px;}
|
||||
.layui-col-space18>*{padding: 9px;}
|
||||
.layui-col-space20{margin: -10px;}
|
||||
.layui-col-space20>*{padding: 10px;}
|
||||
.layui-col-space22{margin: -11px;}
|
||||
.layui-col-space22>*{padding: 11px;}
|
||||
.layui-col-space24{margin: -12px;}
|
||||
.layui-col-space24>*{padding: 12px;}
|
||||
.layui-col-space25{margin: -12.5px;}
|
||||
.layui-col-space25>*{padding: 12.5px;}
|
||||
.layui-col-space26{margin: -13px;}
|
||||
.layui-col-space26>*{padding: 13px;}
|
||||
.layui-col-space28{margin: -14px;}
|
||||
.layui-col-space28>*{padding: 14px;}
|
||||
.layui-col-space30{margin: -15px;}
|
||||
.layui-col-space30>*{padding: 15px;}
|
||||
|
||||
|
||||
Binary file not shown.
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 277 KiB After Width: | Height: | Size: 299 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -77,7 +77,7 @@ layui.define('jquery', function(exports){
|
||||
var othis = $(this), top = othis.scrollTop();
|
||||
|
||||
if(timer) clearTimeout(timer);
|
||||
if(isOver) return;
|
||||
if(isOver || !elem.width()) return; //如果已经结束,或者元素处于隐藏状态,则不执行滚动加载
|
||||
|
||||
timer = setTimeout(function(){
|
||||
//计算滚动所在容器的可视高度
|
||||
@@ -94,6 +94,7 @@ layui.define('jquery', function(exports){
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
|
||||
return that;
|
||||
};
|
||||
|
||||
|
||||
@@ -443,7 +443,7 @@ layui.define('layer', function(exports){
|
||||
,'<div class="'+ TITLE +'">'
|
||||
,('<input type="text" placeholder="'+ placeholder +'" '
|
||||
+('value="'+ (value ? selected.html() : '') +'"') //默认值
|
||||
+(isSearch ? '' : ' readonly') //是否开启搜索
|
||||
+((!disabled && isSearch) ? '' : ' readonly') //是否开启搜索
|
||||
+' class="layui-input'
|
||||
+(isSearch ? '' : ' layui-unselect')
|
||||
+ (disabled ? (' ' + DISABLED) : '') +'">') //禁用状态
|
||||
|
||||
@@ -262,10 +262,11 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
|
||||
//响应数据的自定义格式
|
||||
options.response = $.extend({
|
||||
statusName: 'code'
|
||||
,statusCode: 0
|
||||
,msgName: 'msg'
|
||||
,dataName: 'data'
|
||||
statusName: 'code' //规定数据状态的字段名称
|
||||
,statusCode: 0 //规定成功的状态码
|
||||
,msgName: 'msg' //规定状态信息的字段名称
|
||||
,dataName: 'data' //规定数据总数的字段名称
|
||||
,totalRowName: 'totalRow' //规定数据统计的字段名称
|
||||
,countName: 'count'
|
||||
}, options.response);
|
||||
|
||||
@@ -737,6 +738,11 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
|
||||
res[response.dataName] = options.data.concat().splice(startLimit, options.limit);
|
||||
res[response.countName] = options.data.length;
|
||||
|
||||
//记录合计行数据
|
||||
if(typeof options.totalRow === 'object'){
|
||||
res[response.totalRowName] = $.extend({}, options.totalRow);
|
||||
}
|
||||
|
||||
that.renderData(res, curr, res[response.countName]), sort();
|
||||
that.setColsWidth();
|
||||
@@ -755,7 +761,8 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
Class.prototype.renderData = function(res, curr, count, sort){
|
||||
var that = this
|
||||
,options = that.config
|
||||
,data = res[options.response.dataName] || []
|
||||
,data = res[options.response.dataName] || [] //列表数据
|
||||
,totalRowData = res[options.response.totalRowName] //合计行数据
|
||||
,trs = []
|
||||
,trs_fixed = []
|
||||
,trs_fixed_r = []
|
||||
@@ -893,7 +900,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
}
|
||||
|
||||
render(); //渲染数据
|
||||
that.renderTotal(data); //数据合计
|
||||
that.renderTotal(data, totalRowData); //数据合计
|
||||
|
||||
//同步分页状态
|
||||
if(options.page){
|
||||
@@ -923,7 +930,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
};
|
||||
|
||||
//数据合计行
|
||||
Class.prototype.renderTotal = function(data){
|
||||
Class.prototype.renderTotal = function(data, totalRowData){
|
||||
var that = this
|
||||
,options = that.config
|
||||
,totalNums = {};
|
||||
@@ -944,7 +951,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
});
|
||||
|
||||
that.dataTotal = {};
|
||||
|
||||
|
||||
var tds = [];
|
||||
that.eachCols(function(i3, item3){
|
||||
var field = item3.field || i3;
|
||||
@@ -958,7 +965,12 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
||||
tplData[field] = thisTotalNum;
|
||||
thisTotalNum = parseTempData(item3, thisTotalNum, tplData);
|
||||
|
||||
return item3.totalRow ? (thisTotalNum || text) : text;
|
||||
//如果直接传入了合计行数据,则不输出自动计算的结果
|
||||
if(totalRowData){
|
||||
return totalRowData[item3.field] || text;
|
||||
} else {
|
||||
return item3.totalRow ? (thisTotalNum || text) : text;
|
||||
}
|
||||
}()
|
||||
,td = ['<td data-field="'+ field +'" data-key="'+ options.index + '-'+ item3.key +'" '+ function(){
|
||||
var attr = [];
|
||||
|
||||
@@ -205,9 +205,9 @@ layui.define('layer' , function(exports){
|
||||
});
|
||||
|
||||
//提交文件
|
||||
$.ajax({
|
||||
var opts = {
|
||||
url: options.url
|
||||
,type: 'post'
|
||||
,type: 'post' //统一采用 post 上传
|
||||
,data: formData
|
||||
,contentType: false
|
||||
,processData: false
|
||||
@@ -226,19 +226,22 @@ layui.define('layer' , function(exports){
|
||||
error(index);
|
||||
allDone();
|
||||
}
|
||||
,xhr: function(){
|
||||
var xhr = new XMLHttpRequest();
|
||||
};
|
||||
//监听进度条
|
||||
if(typeof options.progress === 'function'){
|
||||
opts.xhr = function(){
|
||||
var xhr = $.ajaxSettings.xhr();
|
||||
//监听上传进度
|
||||
xhr.upload.addEventListener("progress", function (e) {
|
||||
if(e.lengthComputable) {
|
||||
var percent = Math.floor((e.loaded/e.total)* 100); //百分比
|
||||
typeof options.progress === 'function' && options.progress(percent, e);
|
||||
options.progress(percent, options.item[0], e);
|
||||
}
|
||||
});
|
||||
return xhr;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
$.ajax(opts);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ layui.define('jquery', function(exports){
|
||||
,stamp = new Date().getTime() - new Date(time).getTime();
|
||||
|
||||
//返回具体日期
|
||||
if(stamp > 1000*60*60*24*8){
|
||||
if(stamp > 1000*60*60*24*31){
|
||||
stamp = new Date(time);
|
||||
arr[0][0] = that.digit(stamp.getFullYear(), 4);
|
||||
arr[0][1] = that.digit(stamp.getMonth() + 1);
|
||||
@@ -120,7 +120,7 @@ layui.define('jquery', function(exports){
|
||||
return ((stamp/1000/60/60/24)|0) + '天前';
|
||||
} else if(stamp >= 1000*60*60){
|
||||
return ((stamp/1000/60/60)|0) + '小时前';
|
||||
} else if(stamp >= 1000*60*2){ //2分钟以内为:刚刚
|
||||
} else if(stamp >= 1000*60*3){ //3分钟以内为:刚刚
|
||||
return ((stamp/1000/60)|0) + '分钟前';
|
||||
} else if(stamp < 0){
|
||||
return '未来';
|
||||
@@ -174,12 +174,27 @@ layui.define('jquery', function(exports){
|
||||
|
||||
//批量事件
|
||||
,event: function(attr, obj, eventType){
|
||||
var _body = $('body');
|
||||
eventType = eventType || 'click';
|
||||
|
||||
//记录事件回调集合
|
||||
obj = util.event[attr] = $.extend(true, util.event[attr], obj) || {};
|
||||
$('body').on(eventType || 'click', '*['+ attr +']', function(){
|
||||
|
||||
//清除委托事件
|
||||
util.event.UTIL_EVENT_CALLBACK = util.event.UTIL_EVENT_CALLBACK || {};
|
||||
_body.off(eventType, '*['+ attr +']', util.event.UTIL_EVENT_CALLBACK[attr])
|
||||
|
||||
//绑定委托事件
|
||||
util.event.UTIL_EVENT_CALLBACK[attr] = function(){
|
||||
var othis = $(this)
|
||||
,key = othis.attr(attr);
|
||||
obj[key] && obj[key].call(this, othis);
|
||||
});
|
||||
(typeof obj[key] === 'function') && obj[key].call(this, othis);
|
||||
};
|
||||
|
||||
//清除旧事件,绑定新事件
|
||||
_body.on(eventType, '*['+ attr +']', util.event.UTIL_EVENT_CALLBACK[attr]);
|
||||
|
||||
return obj;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
96
src/layui.js
96
src/layui.js
@@ -1,8 +1,8 @@
|
||||
/*!
|
||||
|
||||
@Title: layui
|
||||
@Name: layui
|
||||
@Description:经典模块化前端 UI 框架
|
||||
@Site: www.layui.com
|
||||
@Homepage: www.layui.com
|
||||
@Author: 贤心
|
||||
@License:MIT
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
}
|
||||
|
||||
,Layui = function(){
|
||||
this.v = '2.5.5'; //版本号
|
||||
this.v = '2.5.6'; //版本号
|
||||
}
|
||||
|
||||
//获取layui所在目录
|
||||
@@ -115,7 +115,7 @@
|
||||
|
||||
apps = typeof apps === 'string' ? [apps] : apps;
|
||||
|
||||
//如果页面已经存在jQuery1.7+库且所定义的模块依赖jQuery,则不加载内部jquery模块
|
||||
//如果页面已经存在 jQuery 1.7+ 库且所定义的模块依赖 jQuery,则不加载内部 jquery 模块
|
||||
if(window.jQuery && jQuery.fn.on){
|
||||
that.each(apps, function(index, item){
|
||||
if(item === 'jquery'){
|
||||
@@ -162,20 +162,26 @@
|
||||
){
|
||||
return onCallback(), that;
|
||||
}
|
||||
|
||||
//获取加载的模块 URL
|
||||
//如果是内置模块,则按照 dir 参数拼接模块路径
|
||||
//如果是扩展模块,则判断模块路径值是否为 {/} 开头,
|
||||
//如果路径值是 {/} 开头,则模块路径即为后面紧跟的字符。
|
||||
//否则,则按照 base 参数拼接模块路径
|
||||
var url = ( modules[item] ? (dir + 'lay/')
|
||||
: (/^\{\/\}/.test(that.modules[item]) ? '' : (config.base || ''))
|
||||
) + (that.modules[item] || item) + '.js';
|
||||
|
||||
url = url.replace(/^\{\/\}/, '');
|
||||
|
||||
//如果扩展模块(即:非内置模块)对象已经存在,则不必再加载
|
||||
if(!config.modules[item] && layui[item]){
|
||||
config.modules[item] = url; //并记录起该扩展模块的 url
|
||||
}
|
||||
|
||||
//首次加载模块
|
||||
if(!config.modules[item]){
|
||||
var node = doc.createElement('script')
|
||||
|
||||
//如果是内置模块,则按照 dir 参数拼接模块路径
|
||||
//如果是扩展模块,则判断模块路径值是否为 {/} 开头,
|
||||
//如果路径值是 {/} 开头,则模块路径即为后面紧跟的字符。
|
||||
//否则,则按照 base 参数拼接模块路径
|
||||
,url = ( modules[item] ? (dir + 'lay/')
|
||||
: (/^\{\/\}/.test(that.modules[item]) ? '' : (config.base || ''))
|
||||
) + (that.modules[item] || item) + '.js';
|
||||
|
||||
url = url.replace(/^\{\/\}/, '');
|
||||
var node = doc.createElement('script');
|
||||
|
||||
node.async = true;
|
||||
node.charset = 'utf-8';
|
||||
@@ -323,7 +329,7 @@
|
||||
return that;
|
||||
};
|
||||
|
||||
//路由解析
|
||||
// location.hash 路由解析
|
||||
Layui.prototype.router = function(hash){
|
||||
var that = this
|
||||
,hash = hash || location.hash
|
||||
@@ -338,7 +344,7 @@
|
||||
data.href = '/' + hash;
|
||||
hash = hash.replace(/([^#])(#.*$)/, '$1').split('/') || [];
|
||||
|
||||
//提取Hash结构
|
||||
//提取 Hash 结构
|
||||
that.each(hash, function(index, item){
|
||||
/^\w+=/.test(item) ? function(){
|
||||
item = item.split('=');
|
||||
@@ -348,6 +354,61 @@
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
//URL 解析
|
||||
Layui.prototype.url = function(href){
|
||||
var that = this
|
||||
,data = {
|
||||
//提取 url 路径
|
||||
pathname: function(){
|
||||
var pathname = href
|
||||
? function(){
|
||||
var pathUrl = (href.match(/\.[^.]+?\/.+/) || [])[0] || '';
|
||||
return pathUrl.replace(/^[^\/]+/, '').replace(/\?.+/, '');
|
||||
}()
|
||||
: location.pathname;
|
||||
return pathname.replace(/^\//, '').split('/');
|
||||
}()
|
||||
|
||||
//提取 url 参数
|
||||
,search: function(){
|
||||
var obj = {}
|
||||
,search = (href
|
||||
? ((href.match(/\?.+/) || [])[0] || '')
|
||||
: location.search
|
||||
).replace(/^\?+/, '').split('&'); //去除 ?,按 & 分割参数
|
||||
|
||||
//遍历分割后的参数
|
||||
that.each(search, function(index, item){
|
||||
var _index = item.indexOf('=')
|
||||
,key = function(){ //提取 key
|
||||
if(_index < 0){
|
||||
return item.substr(0, item.length);
|
||||
} else if(_index === 0){
|
||||
return false;
|
||||
} else {
|
||||
return item.substr(0, _index);
|
||||
}
|
||||
}();
|
||||
//提取 value
|
||||
if(key){
|
||||
obj[key] = _index > 0 ? item.substr(_index + 1) : null;
|
||||
}
|
||||
});
|
||||
|
||||
return obj;
|
||||
}()
|
||||
|
||||
//提取 Hash
|
||||
,hash: that.router(function(){
|
||||
return href
|
||||
? ((href.match(/#.+/) || [])[0] || '')
|
||||
: location.hash;
|
||||
}())
|
||||
};
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
//本地持久性存储
|
||||
Layui.prototype.data = function(table, settings, storage){
|
||||
@@ -423,6 +484,7 @@
|
||||
//移动设备
|
||||
result.android = /android/.test(agent);
|
||||
result.ios = result.os === 'ios';
|
||||
result.mobile = (result.android || result.ios) ? true : false;
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user