-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtool.js
More file actions
62 lines (55 loc) · 1.48 KB
/
Copy pathtool.js
File metadata and controls
62 lines (55 loc) · 1.48 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
function getInner(){
if (typeof window.innerWidth != 'undefined'){
return{
width:window.innerWidth,
height:window.innerHeight
}
}else{
return{
width:document.documentElement.clientWidth,
height:document.documentElement.clientHeight
}
}
}
function getStyle(element,attr) {
if (typeof window.getComputedStyle != 'undefined') {//W3C
return window.getComputedStyle(element,null)[attr];
}else if (typeof element.currentStyle != 'undefined'){//IE
return this.elements[i].currentStyle[attr];
}
}
function hasClass(element,className) {
return element.className.match(new RegExp('(\\s|^)'+className+'(\\s|^)'))
}
function insertRule(sheet,selectorText,cssText,position){
if (typeof sheet.insertRule != 'undefined') {//W3C
sheet.insertRule(selectorText + "{" + cssText + "}",position);
}else if (typeof sheet.addRule != 'undefined'){//IE
sheet.addRule(selectorText,cssText,position);
}
}
function removeRule(sheet,index){
if (typeof sheet.deleteRule != 'undefined') {//W3C
sheet.deleteRule(index);
}else if (typeof sheet.removeRule != 'undefined'){//IE
sheet.removeRule(index);
}
}
function getEvent(event){
return event || window.event;
}
function preDef(event){
var e = getEvent(event);
if (typeof e.preventDefault != 'undefined'){ //W3C
e.preventDefault();
}else{//IE
e.returnValue = false;
}
}
function trim(str){
return str.replace('/(^\s*)|(\s*$)/g',"");
}
function scrollTop(){
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
};