This repository has been archived by the owner on Jun 1, 2021. It is now read-only.
/
bespoke-indexfinger.js
63 lines (48 loc) · 2 KB
/
bespoke-indexfinger.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*!
* bespoke-indexfinger v0.1.1
* https://github.com/joelpurra/bespoke-indexfinger
*
* Copyright 2013, Joel Purra
* This content is released under the MIT license
*/
(function(bespoke, convenient, ns, pluginName, undefined) {
"use strict";
var cv = convenient.builder(pluginName),
plugin = function(deck) {
var off = {},
activeSlide = null,
activeSlideIndex = -1,
unboundActiveSlideDeckMethods = {
// Plugin functions expect to be executed in a deck context
enableActiveSlideListener: function() {
off.saveActiveSlide = this.on("activate", unboundActiveSlideDeckMethods.saveActiveSlide.bind(this));
},
saveActiveSlide: function(e) {
activeSlide = e.slide;
activeSlideIndex = e.index;
},
getActiveSlide: function() {
return activeSlide;
},
getActiveSlideIndex: function() {
return activeSlideIndex;
}
},
registerDeckExtensions = function() {
deck.getActiveSlide = unboundActiveSlideDeckMethods.getActiveSlide.bind(deck);
deck.getActiveSlideIndex = unboundActiveSlideDeckMethods.getActiveSlideIndex.bind(deck);
},
enable = function() {
unboundActiveSlideDeckMethods.enableActiveSlideListener.call(deck);
},
init = function() {
registerDeckExtensions();
enable();
};
init();
};
if (ns[pluginName] !== undefined) {
throw cv.generateErrorObject("The " + pluginName + " plugin has already been loaded.");
}
ns[pluginName] = plugin;
}(bespoke, bespoke.plugins.convenient, bespoke.plugins, "indexfinger"));