-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpluginTemplate.js
48 lines (48 loc) · 1.93 KB
/
pluginTemplate.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
/*!
* Web Experience Toolkit (WET) / Boîte à outils de l'expérience Web (BOEW)
* www.tbs.gc.ca/ws-nw/wet-boew/terms / www.sct.gc.ca/ws-nw/wet-boew/conditions
*/
/*
* Template for WET-BOEW v3.x plugins
*/
/*global jQuery: false, pe: false*/
(function ($) {
var _pe = window.pe || {
fn: {}
};
/* local reference */
_pe.fn.pluginName = {
type: 'plugin',
// This is an example from tabbed interface, to show how to call required libraries
depends: ['easytabs', 'equalheights'],
// Don't include a mobile function if your plugin shouldn't run in mobile mode.
mobile: function (elm) {
// If applicaple, convert html elements and attributes into the format that jQuery mobile expects.
return elm;
},
_exec: function (elm) {
// Don't include this if statement if your plugin shouldn't run in mobile mode.
if (pe.mobile) {
return _pe.fn.pluginName.mobile(elm);
}
var opts,
aVariable,
anotherVariable;
opts = {
// This is an example from tabbedinterface, to show how to pass configuration parameters from the html element to the plugin.
// There are some simple examples here, along with some more complicated ones.
defaultElm: ((elm.find(".default").length) ? ".default" : "li:first-child"),
autoHeight: (elm.hasClass("auto-height-none") ? false : true),
cycle: (elm.hasClass("cycle-slow") ? 8000 : (elm.hasClass("cycle-fast") ? 2000 : (elm.hasClass("cycle") ? 6000 : false))),
carousel: (/style-carousel/i.test(elm.attr('class'))) ? true : false,
autoPlay: (elm.hasClass("auto-play") ? true : false),
animate: (elm.hasClass("animate") || elm.hasClass("animate-slow") || elm.hasClass("animate-fast") ? true : false),
animationSpeed: (elm.hasClass("animate-slow") ? "slow" : (elm.hasClass("animate-fast") ? "fast" : "normal"))
};
// Do plugin stuff here...
return elm;
} // end of exec
};
window.pe = _pe;
return _pe;
}(jQuery));