2
2
* jQuery Cycle Lite Plugin
3
3
* http://malsup.com/jquery/cycle/lite/
4
4
* Copyright (c) 2008-2012 M. Alsup
5
- * Version: 1.6 (02-MAY-2012 )
5
+ * Version: 1.7 (20-FEB-2013 )
6
6
* Dual licensed under the MIT and GPL licenses:
7
7
* http://www.opensource.org/licenses/mit-license.php
8
8
* http://www.gnu.org/licenses/gpl.html
11
11
; ( function ( $ ) {
12
12
"use strict" ;
13
13
14
- var ver = 'Lite-1.6' ;
14
+ var ver = 'Lite-1.7' ;
15
+ var msie = / M S I E / . test ( navigator . userAgent ) ;
15
16
16
17
$ . fn . cycle = function ( options ) {
17
18
return this . each ( function ( ) {
18
19
options = options || { } ;
19
-
20
- if ( this . cycleTimeout ) clearTimeout ( this . cycleTimeout ) ;
20
+
21
+ if ( this . cycleTimeout )
22
+ clearTimeout ( this . cycleTimeout ) ;
21
23
22
24
this . cycleTimeout = 0 ;
23
25
this . cyclePause = 0 ;
24
-
26
+
25
27
var $cont = $ ( this ) ;
26
28
var $slides = options . slideExpr ? $ ( options . slideExpr , this ) : $cont . children ( ) ;
27
29
var els = $slides . get ( ) ;
@@ -36,43 +38,44 @@ $.fn.cycle = function(options) {
36
38
var meta = $ . isFunction ( $cont . data ) ? $cont . data ( opts . metaAttr ) : null ;
37
39
if ( meta )
38
40
opts = $ . extend ( opts , meta ) ;
39
-
41
+
40
42
opts . before = opts . before ? [ opts . before ] : [ ] ;
41
43
opts . after = opts . after ? [ opts . after ] : [ ] ;
42
44
opts . after . unshift ( function ( ) { opts . busy = 0 ; } ) ;
43
-
45
+
44
46
// allow shorthand overrides of width, height and timeout
45
47
var cls = this . className ;
46
48
opts . width = parseInt ( ( cls . match ( / w : ( \d + ) / ) || [ ] ) [ 1 ] , 10 ) || opts . width ;
47
49
opts . height = parseInt ( ( cls . match ( / h : ( \d + ) / ) || [ ] ) [ 1 ] , 10 ) || opts . height ;
48
50
opts . timeout = parseInt ( ( cls . match ( / t : ( \d + ) / ) || [ ] ) [ 1 ] , 10 ) || opts . timeout ;
49
51
50
- if ( $cont . css ( 'position' ) == 'static' )
52
+ if ( $cont . css ( 'position' ) == 'static' )
51
53
$cont . css ( 'position' , 'relative' ) ;
52
- if ( opts . width )
54
+ if ( opts . width )
53
55
$cont . width ( opts . width ) ;
54
- if ( opts . height && opts . height != 'auto' )
56
+ if ( opts . height && opts . height != 'auto' )
55
57
$cont . height ( opts . height ) ;
56
58
57
59
var first = 0 ;
58
60
$slides . css ( { position : 'absolute' , top :0 } ) . each ( function ( i ) {
59
61
$ ( this ) . css ( 'z-index' , els . length - i ) ;
60
62
} ) ;
61
-
63
+
62
64
$ ( els [ first ] ) . css ( 'opacity' , 1 ) . show ( ) ; // opacity bit needed to handle reinit case
63
- if ( $ . browser . msie ) els [ first ] . style . removeAttribute ( 'filter' ) ;
65
+ if ( msie )
66
+ els [ first ] . style . removeAttribute ( 'filter' ) ;
64
67
65
- if ( opts . fit && opts . width )
68
+ if ( opts . fit && opts . width )
66
69
$slides . width ( opts . width ) ;
67
- if ( opts . fit && opts . height && opts . height != 'auto' )
70
+ if ( opts . fit && opts . height && opts . height != 'auto' )
68
71
$slides . height ( opts . height ) ;
69
- if ( opts . pause )
72
+ if ( opts . pause )
70
73
$cont . hover ( function ( ) { this . cyclePause = 1 ; } , function ( ) { this . cyclePause = 0 ; } ) ;
71
74
72
75
var txFn = $ . fn . cycle . transitions [ opts . fx ] ;
73
76
if ( txFn )
74
77
txFn ( $cont , $slides , opts ) ;
75
-
78
+
76
79
$slides . each ( function ( ) {
77
80
var $el = $ ( this ) ;
78
81
this . cycleH = ( opts . fit && opts . height ) ? opts . height : $el . height ( ) ;
@@ -104,7 +107,7 @@ $.fn.cycle = function(options) {
104
107
opts . before [ 0 ] . apply ( e0 , [ e0 , e0 , opts , true ] ) ;
105
108
if ( opts . after . length > 1 )
106
109
opts . after [ 1 ] . apply ( e0 , [ e0 , e0 , opts , true ] ) ;
107
-
110
+
108
111
if ( opts . click && ! opts . next )
109
112
opts . next = opts . click ;
110
113
if ( opts . next )
@@ -120,17 +123,17 @@ $.fn.cycle = function(options) {
120
123
} ;
121
124
122
125
function go ( els , opts , manual , fwd ) {
123
- if ( opts . busy )
126
+ if ( opts . busy )
124
127
return ;
125
128
var p = els [ 0 ] . parentNode , curr = els [ opts . currSlide ] , next = els [ opts . nextSlide ] ;
126
- if ( p . cycleTimeout === 0 && ! manual )
129
+ if ( p . cycleTimeout === 0 && ! manual )
127
130
return ;
128
131
129
132
if ( manual || ! p . cyclePause ) {
130
133
if ( opts . before . length )
131
134
$ . each ( opts . before , function ( i , o ) { o . apply ( next , [ curr , next , opts , fwd ] ) ; } ) ;
132
135
var after = function ( ) {
133
- if ( $ . browser . msie )
136
+ if ( msie )
134
137
this . style . removeAttribute ( 'filter' ) ;
135
138
$ . each ( opts . after , function ( i , o ) { o . apply ( next , [ curr , next , opts , fwd ] ) ; } ) ;
136
139
queueNext ( opts ) ;
@@ -229,4 +232,4 @@ $.fn.cycle.defaults = {
229
232
timeout : 4000
230
233
} ;
231
234
232
- } ) ( jQuery ) ;
235
+ } ) ( jQuery ) ;
0 commit comments