1
1
if ( ! window . getComputedStyle ) {
2
- window . getComputedStyle = function ( e , t ) {
3
- return this . el = e , this . getPropertyValue = function ( t ) {
4
- var n = / ( \- ( [ a - z ] ) { 1 } ) / g;
5
- return t == "float" && ( t = "styleFloat" ) , n . test ( t ) && ( t = t . replace ( n , function ( ) {
6
- return arguments [ 2 ] . toUpperCase ( ) ;
7
- } ) ) , e . currentStyle [ t ] ? e . currentStyle [ t ] : null ;
8
- } , this ;
9
- } ;
2
+ window . getComputedStyle = function ( e , t ) {
3
+ return (
4
+ ( this . el = e ) ,
5
+ ( this . getPropertyValue = function ( t ) {
6
+ var n = / ( \- ( [ a - z ] ) { 1 } ) / g;
7
+ return (
8
+ t == 'float' && ( t = 'styleFloat' ) ,
9
+ n . test ( t ) &&
10
+ ( t = t . replace ( n , function ( ) {
11
+ return arguments [ 2 ] . toUpperCase ( ) ;
12
+ } ) ) ,
13
+ e . currentStyle [ t ] ? e . currentStyle [ t ] : null
14
+ ) ;
15
+ } ) ,
16
+ this
17
+ ) ;
18
+ } ;
10
19
}
11
20
12
21
if ( ! Array . isArray ) {
13
- Array . isArray = function ( arg ) {
14
- return Object . prototype . toString . call ( arg ) === '[object Array]' ;
15
- } ;
22
+ Array . isArray = function ( arg ) {
23
+ return Object . prototype . toString . call ( arg ) === '[object Array]' ;
24
+ } ;
16
25
}
17
26
18
27
if ( ! Array . prototype . lastIndexOf ) {
19
- Array . prototype . lastIndexOf = function ( searchElement /*, fromIndex*/ ) {
20
- 'use strict' ;
21
-
22
- if ( this === void 0 || this === null ) {
23
- throw new TypeError ( ) ;
24
- }
25
-
26
- var n , k ,
27
- t = Object ( this ) ,
28
- len = t . length >>> 0 ;
29
- if ( len === 0 ) {
30
- return - 1 ;
31
- }
32
-
33
- n = len - 1 ;
34
- if ( arguments . length > 1 ) {
35
- n = Number ( arguments [ 1 ] ) ;
36
- if ( n != n ) {
37
- n = 0 ;
38
- }
39
- else if ( n != 0 && n != ( 1 / 0 ) && n != - ( 1 / 0 ) ) {
40
- n = ( n > 0 || - 1 ) * Math . floor ( Math . abs ( n ) ) ;
41
- }
42
- }
43
-
44
- for ( k = n >= 0 ? Math . min ( n , len - 1 ) : len - Math . abs ( n ) ; k >= 0 ; k -- ) {
45
- if ( k in t && t [ k ] === searchElement ) {
46
- return k ;
47
- }
48
- }
49
- return - 1 ;
50
- } ;
51
- }
52
-
28
+ Array . prototype . lastIndexOf = function ( searchElement /*, fromIndex*/ ) {
29
+ 'use strict' ;
30
+
31
+ if ( this === void 0 || this === null ) {
32
+ throw new TypeError ( ) ;
33
+ }
34
+
35
+ var n ,
36
+ k ,
37
+ t = Object ( this ) ,
38
+ len = t . length >>> 0 ;
39
+ if ( len === 0 ) {
40
+ return - 1 ;
41
+ }
42
+
43
+ n = len - 1 ;
44
+ if ( arguments . length > 1 ) {
45
+ n = Number ( arguments [ 1 ] ) ;
46
+ if ( n != n ) {
47
+ n = 0 ;
48
+ } else if ( n != 0 && n != 1 / 0 && n != - ( 1 / 0 ) ) {
49
+ n = ( n > 0 || - 1 ) * Math . floor ( Math . abs ( n ) ) ;
50
+ }
51
+ }
52
+
53
+ for ( k = n >= 0 ? Math . min ( n , len - 1 ) : len - Math . abs ( n ) ; k >= 0 ; k -- ) {
54
+ if ( k in t && t [ k ] === searchElement ) {
55
+ return k ;
56
+ }
57
+ }
58
+ return - 1 ;
59
+ } ;
60
+ }
53
61
54
62
if ( ! Array . prototype . reduce ) {
55
- Array . prototype . reduce = function ( callback , initial ) {
56
- var accumulator = initial ;
57
- for ( var i = 0 ; i < this . length ; i ++ ) {
58
- if ( accumulator !== undefined ) {
59
- accumulator = callback . call ( undefined , accumulator , this [ i ] , i , this ) ;
60
- continue ;
61
- }
62
- accumulator = this [ i ] ;
63
- }
64
- return accumulator ;
65
- }
63
+ Array . prototype . reduce = function ( callback , initial ) {
64
+ var accumulator = initial ;
65
+ for ( var i = 0 ; i < this . length ; i ++ ) {
66
+ if ( accumulator !== undefined ) {
67
+ accumulator = callback . call ( undefined , accumulator , this [ i ] , i , this ) ;
68
+ continue ;
69
+ }
70
+ accumulator = this [ i ] ;
71
+ }
72
+ return accumulator ;
73
+ } ;
66
74
}
67
75
68
- ( function ( win , doc ) {
69
- if ( win . addEventListener ) return ;
76
+ ( function ( win , doc ) {
77
+ if ( win . addEventListener ) return ;
70
78
71
- function docHijack ( p ) { var old = doc [ p ] ; doc [ p ] = function ( v ) { return addListen ( old ( v ) ) } }
72
- function addEvent ( on , fn , self ) {
73
- return ( self = this ) . attachEvent ( 'on' + on , function ( e ) {
79
+ function docHijack ( p ) {
80
+ var old = doc [ p ] ;
81
+ doc [ p ] = function ( v ) {
82
+ return addListen ( old ( v ) ) ;
83
+ } ;
84
+ }
85
+ function addEvent ( on , fn , self ) {
86
+ return ( self = this ) . attachEvent ( 'on' + on , function ( e ) {
74
87
var e = e || win . event ;
75
- e . preventDefault = e . preventDefault || function ( ) { e . returnValue = false }
76
- e . stopPropagation = e . stopPropagation || function ( ) { e . cancelBubble = true }
88
+ e . preventDefault =
89
+ e . preventDefault ||
90
+ function ( ) {
91
+ e . returnValue = false ;
92
+ } ;
93
+ e . stopPropagation =
94
+ e . stopPropagation ||
95
+ function ( ) {
96
+ e . cancelBubble = true ;
97
+ } ;
77
98
fn . call ( self , e ) ;
78
99
} ) ;
79
100
}
80
- function addListen ( obj , i ) {
81
- if ( i = obj . length ) while ( i -- ) obj [ i ] . addEventListener = addEvent ;
101
+ function addListen ( obj , i ) {
102
+ if ( ( i = obj . length ) ) while ( i -- ) obj [ i ] . addEventListener = addEvent ;
82
103
else obj . addEventListener = addEvent ;
83
104
return obj ;
84
105
}
85
106
86
107
addListen ( [ doc , win ] ) ;
87
- if ( 'Element' in win ) {
88
- win . Element . prototype . addEventListener = addEvent ;
89
- return ;
90
- }
91
-
92
- doc . attachEvent ( 'onreadystatechange' , function ( ) { addListen ( doc . all ) } ) ;
93
- docHijack ( 'getElementsByTagName' ) ;
94
- docHijack ( 'getElementById' ) ;
95
- docHijack ( 'createElement' ) ;
96
- addListen ( doc . all ) ;
108
+ if ( 'Element' in win ) {
109
+ win . Element . prototype . addEventListener = addEvent ;
110
+ return ;
111
+ }
112
+
113
+ doc . attachEvent ( 'onreadystatechange' , function ( ) {
114
+ addListen ( doc . all ) ;
115
+ } ) ;
116
+ docHijack ( 'getElementsByTagName' ) ;
117
+ docHijack ( 'getElementById' ) ;
118
+ docHijack ( 'createElement' ) ;
119
+ addListen ( doc . all ) ;
97
120
} ) ( window , document ) ;
98
121
99
- window . matchMedia || ( window . matchMedia = function ( ) {
100
- 'use strict' ;
122
+ window . matchMedia ||
123
+ ( window . matchMedia = ( function ( ) {
124
+ 'use strict' ;
101
125
102
- var styleMedia = ( window . styleMedia || window . media ) ;
126
+ var styleMedia = window . styleMedia || window . media ;
103
127
104
- if ( ! styleMedia ) {
105
- var style = document . createElement ( 'style' ) ,
106
- script = document . getElementsByTagName ( 'script' ) [ 0 ] ,
107
- info = null ;
128
+ if ( ! styleMedia ) {
129
+ var style = document . createElement ( 'style' ) ,
130
+ script = document . getElementsByTagName ( 'script' ) [ 0 ] ,
131
+ info = null ;
108
132
109
- style . type = 'text/css' ;
110
- style . id = 'matchmediajs-test' ;
133
+ style . type = 'text/css' ;
134
+ style . id = 'matchmediajs-test' ;
111
135
112
- if ( ! script ) {
113
- document . head . appendChild ( style ) ;
114
- } else {
115
- script . parentNode . insertBefore ( style , script ) ;
116
- }
136
+ if ( ! script ) {
137
+ document . head . appendChild ( style ) ;
138
+ } else {
139
+ script . parentNode . insertBefore ( style , script ) ;
140
+ }
117
141
118
- info = ( 'getComputedStyle' in window ) && window . getComputedStyle ( style , null ) || style . currentStyle ;
142
+ info = ( 'getComputedStyle' in window && window . getComputedStyle ( style , null ) ) || style . currentStyle ;
119
143
120
- styleMedia = {
121
- matchMedium : function ( media ) {
122
- var text = '@media ' + media + '{ #matchmediajs-test { width: 1px; } }' ;
144
+ styleMedia = {
145
+ matchMedium : function ( media ) {
146
+ var text = '@media ' + media + '{ #matchmediajs-test { width: 1px; } }' ;
123
147
124
- if ( style . styleSheet ) {
125
- style . styleSheet . cssText = text ;
126
- } else {
127
- style . textContent = text ;
128
- }
148
+ if ( style . styleSheet ) {
149
+ style . styleSheet . cssText = text ;
150
+ } else {
151
+ style . textContent = text ;
152
+ }
129
153
130
- return info . width === '1px' ;
131
- }
132
- } ;
133
- }
154
+ return info . width === '1px' ;
155
+ } ,
156
+ } ;
157
+ }
134
158
135
- return function ( media ) {
136
- return {
137
- matches : styleMedia . matchMedium ( media || 'all' ) ,
138
- media : media || 'all'
139
- } ;
140
- } ;
141
- } ( ) ) ;
159
+ return function ( media ) {
160
+ return {
161
+ matches : styleMedia . matchMedium ( media || 'all' ) ,
162
+ media : media || 'all' ,
163
+ } ;
164
+ } ;
165
+ } ) ( ) ) ;
142
166
143
167
if ( ! document . querySelectorAll ) {
144
- document . querySelectorAll = function ( selectors ) {
145
- var style = document . createElement ( 'style' ) , elements = [ ] , element ;
146
- document . documentElement . firstChild . appendChild ( style ) ;
147
- document . _qsa = [ ] ;
148
-
149
- style . styleSheet . cssText = selectors + '{x-qsa:expression(document._qsa && document._qsa.push(this))}' ;
150
- window . scrollBy ( 0 , 0 ) ;
151
- style . parentNode . removeChild ( style ) ;
152
-
153
- while ( document . _qsa . length ) {
154
- element = document . _qsa . shift ( ) ;
155
- element . style . removeAttribute ( 'x-qsa' ) ;
156
- elements . push ( element ) ;
157
- }
158
- document . _qsa = null ;
159
- return elements ;
160
- } ;
168
+ document . querySelectorAll = function ( selectors ) {
169
+ var style = document . createElement ( 'style' ) ,
170
+ elements = [ ] ,
171
+ element ;
172
+ document . documentElement . firstChild . appendChild ( style ) ;
173
+ document . _qsa = [ ] ;
174
+
175
+ style . styleSheet . cssText = selectors + '{x-qsa:expression(document._qsa && document._qsa.push(this))}' ;
176
+ window . scrollBy ( 0 , 0 ) ;
177
+ style . parentNode . removeChild ( style ) ;
178
+
179
+ while ( document . _qsa . length ) {
180
+ element = document . _qsa . shift ( ) ;
181
+ element . style . removeAttribute ( 'x-qsa' ) ;
182
+ elements . push ( element ) ;
183
+ }
184
+ document . _qsa = null ;
185
+ return elements ;
186
+ } ;
161
187
}
162
188
163
189
if ( ! document . querySelector ) {
164
- document . querySelector = function ( selectors ) {
165
- var elements = document . querySelectorAll ( selectors ) ;
166
- return ( elements . length ) ? elements [ 0 ] : null ;
167
- } ;
190
+ document . querySelector = function ( selectors ) {
191
+ var elements = document . querySelectorAll ( selectors ) ;
192
+ return elements . length ? elements [ 0 ] : null ;
193
+ } ;
168
194
}
169
195
170
196
if ( ! String . prototype . trim ) {
171
- ( function ( ) {
172
- var rtrim = / ^ [ \s \uFEFF \xA0 ] + | [ \s \uFEFF \xA0 ] + $ / g;
173
- String . prototype . trim = function ( ) {
174
- return this . replace ( rtrim , '' ) ;
175
- } ;
176
- } ) ( ) ;
177
- }
197
+ ( function ( ) {
198
+ var rtrim = / ^ [ \s \uFEFF \xA0 ] + | [ \s \uFEFF \xA0 ] + $ / g;
199
+ String . prototype . trim = function ( ) {
200
+ return this . replace ( rtrim , '' ) ;
201
+ } ;
202
+ } ) ( ) ;
203
+ }
0 commit comments