forked from malsup/cycle2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.cycle2.caption.js
42 lines (38 loc) · 1.19 KB
/
jquery.cycle2.caption.js
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
/*! caption plugin for Cycle2; version: 20130306 */
(function($) {
"use strict";
$.extend($.fn.cycle.defaults, {
caption: '> .cycle-caption',
captionTemplate: '{{slideNum}} / {{slideCount}}',
overlay: '> .cycle-overlay',
overlayTemplate: '<div>{{title}}</div><div>{{desc}}</div>',
captionModule: 'caption'
});
$(document).on( 'cycle-update-view', function( e, opts, slideOpts, currSlide ) {
if ( opts.captionModule !== 'caption' )
return;
var el;
$.each(['caption','overlay'], function() {
var name = this;
var template = slideOpts[name+'Template'];
var el = opts.API.getComponent( name );
if( el.length && template ) {
el.html( opts.API.tmpl( template, slideOpts, opts, currSlide ) );
el.show();
}
else {
el.hide();
}
});
});
$(document).on( 'cycle-destroyed', function( e, opts ) {
var el;
$.each(['caption','overlay'], function() {
var name = this, template = opts[name+'Template'];
if ( opts[name] && template ) {
el = opts.API.getComponent( 'caption' );
el.empty();
}
});
});
})(jQuery);