Skip to content

Commit c534fc8

Browse files
author
sentsin
committed
layer mobile 1.7
1 parent 4d60116 commit c534fc8

File tree

7 files changed

+49
-47
lines changed

7 files changed

+49
-47
lines changed

GruntFile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
options: {
2828
banner: '/*! layer mobile-v<%= pkg.mobile %> <%= pkg.description %>移动版 License LGPL <%= pkg.homepage %>mobile By <%= pkg.author %> */\n;'
2929
},
30-
src: './src/mobile/layer.m.js',
31-
dest: './mobile/layer.m.js'
30+
src: './src/mobile/layer.js',
31+
dest: './mobile/layer.js'
3232
}
3333
},
3434

mobile/layer.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mobile/layer.m.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

mobile/need/layer.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "layer",
33
"version": "2.1",
4-
"mobile": "1.6",
4+
"mobile": "1.7",
55
"description": "弹层组件",
66
"main": "",
77
"scripts": {

src/mobile/layer.m.js renamed to src/mobile/layer.js

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*!
22
3-
@Name:layer mobile v1.6 弹层组件移动版
3+
@Name:layer mobile v1.7 弹层组件移动版
44
@Author:贤心
5-
@Date:2015-11-06
5+
@Date:2015-11-25
66
@Copyright:Sentsin Xu(贤心)
77
@官网:http://layer.layui.com/mobile/
88
@License:MIT
@@ -12,23 +12,10 @@
1212
;!function(win){
1313
"use strict";
1414

15-
var path = ''; //所在路径,如果非模块加载不用配置
16-
path = path ? path : document.scripts[document.scripts.length-1].src.match(/[\s\S]*\//)[0];
17-
1815
var doc = document, query = 'querySelectorAll', claname = 'getElementsByClassName', S = function(s){
1916
return doc[query](s);
2017
};
2118

22-
//插入css
23-
document.head.appendChild((function(){
24-
var link = doc.createElement('link');
25-
link.href = path + 'need/layer.css';
26-
link.type = 'text/css';
27-
link.rel = 'styleSheet'
28-
link.id = 'layermcss';
29-
return link;
30-
}()));
31-
3219
//默认配置
3320
var config = {
3421
type: 0,
@@ -38,26 +25,24 @@ var config = {
3825
anim: true
3926
};
4027

41-
win.ready = {
28+
var ready = {
4229
extend: function(obj){
4330
var newobj = JSON.parse(JSON.stringify(config));
4431
for(var i in obj){
4532
newobj[i] = obj[i];
4633
}
4734
return newobj;
4835
},
49-
timer: {},
50-
end: {}
36+
timer: {}, end: {}
5137
};
5238

5339
//点触事件
5440
ready.touch = function(elem, fn){
5541
var move;
5642
if(!/Android|iPhone|SymbianOS|Windows Phone|iPad|iPod/.test(navigator.userAgent)){
57-
elem.addEventListener('click', function(e){
43+
return elem.addEventListener('click', function(e){
5844
fn.call(this, e);
5945
}, false);
60-
return;
6146
}
6247
elem.addEventListener('touchmove', function(){
6348
move = true;
@@ -108,7 +93,7 @@ Layer.prototype.view = function(){
10893
}
10994

11095
if(config.type === 2){
111-
config.content = '<i></i><i class="laymloadtwo"></i><i></i><div>' + (config.content||'') + '</div>';
96+
config.content = '<i></i><i class="laymloadtwo"></i><i></i>';
11297
}
11398

11499
layerbox.innerHTML = (config.shade ? '<div '+ (typeof config.shade === 'string' ? 'style="'+ config.shade +'"' : '') +' class="laymshade"></div>' : '')
@@ -184,8 +169,8 @@ Layer.prototype.action = function(config, elem){
184169
config.end && (ready.end[that.index] = config.end);
185170
};
186171

187-
var layer = {
188-
v: '1.6',
172+
win.layer = {
173+
v: '1.7',
189174
index: index,
190175

191176
//核心方法
@@ -214,8 +199,25 @@ var layer = {
214199
}
215200
};
216201

217-
'function' === typeof define ? define(function() {
202+
'function' == typeof define ? define(function() {
218203
return layer;
219-
}) : win.layer = layer;
204+
}) : function(){
205+
206+
var js = document.scripts, script = js[js.length - 1], jsPath = script.src;
207+
var path = jsPath.substring(0, jsPath.lastIndexOf("/") + 1);
208+
209+
//如果合并方式,则需要单独引入layer.css
210+
if(script.getAttribute('merge')) return;
211+
212+
document.head.appendChild(function(){
213+
var link = doc.createElement('link');
214+
link.href = path + 'need/layer.css';
215+
link.type = 'text/css';
216+
link.rel = 'styleSheet'
217+
link.id = 'layermcss';
218+
return link;
219+
}());
220+
221+
}();
220222

221223
}(window);

0 commit comments

Comments
 (0)