-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.js
More file actions
69 lines (67 loc) · 1.79 KB
/
util.js
File metadata and controls
69 lines (67 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
* Created by supernever on 16/8/30.
*使用方法 var $$ = new SN();
*直接使用方法 var a1 = $$.getElements(ids)
*解决命名冲突 var $$$ = new SN().noConflict(true);
*之后$$$就为SN的直接引用
*/
(function(window,undefined){
var window = this,
undefined,
_SN = window.SN,
SN = window.SN = class{
constructor(){
this.version = '0.0.1';
}
};
Object.assign(SN.prototype,{
constructor : SN,
getElements(/*ids*/){
var elements = {};
for(var i = 0,j= arguments.length;i<j;i++){
var id = arguments[i];
var elt = document.getElementById(id);
if(elt ==null)throw new Error("没有id为"+id+"的元素");
elements[id] = elt;
}
return elements;
},
noConflict(deep){
var deep = deep?deep:'true';
if(deep)
window.SN = _SN;
return SN;
}
})
// SN.prototype = {
// constructor : SN,
// /**
// * 根据id获取相应的dom节点,可以传入多个id
// * 在低于IE8的浏览器中,getElementById()对匹配元素的ID不区分大小写,
// * 而且也返回匹配name属性的元素
// * @return {[type]} [description]
// */
// getElements : (/*ids*/)=>{
// var elements = {};
// for(var i = 0,j= arguments.length;i<j;i++){
// var id = arguments[i];
// var elt = document.getElementById(id);
// if(elt ==null)throw new Error("没有id为"+id+"的元素");
// elements[id] = elt;
// }
// return elements;
// },
// /**
// * 解决命名冲突
// * @param {[boolean]} deep [默认为true]
// * @return {[type]} [description]
// */
// noConflict : (deep)=>{
// var deep = deep?deep:'true';
// if(deep)
// window.SN = _SN;
// return SN;
// }
// };
return SN;
})(window,undefined)