jquery.mmenu.toggles.js
1.59 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
* jQuery mmenu toggles addon
* mmenu.frebsite.nl
*
* Copyright (c) Fred Heusschen
* www.frebsite.nl
*/
(function( $ ) {
var _PLUGIN_ = 'mmenu',
_ADDON_ = 'toggles';
var _c, _d, _e, glbl,
addon_initiated = false;
$[ _PLUGIN_ ].prototype[ '_addon_' + _ADDON_ ] = function()
{
if ( !addon_initiated )
{
_initAddon();
}
this.opts[ _ADDON_ ] = extendOptions( this.opts[ _ADDON_ ] );
this.conf[ _ADDON_ ] = extendConfiguration( this.conf[ _ADDON_ ] );
var that = this,
opts = this.opts[ _ADDON_ ],
conf = this.conf[ _ADDON_ ];
// Refactor toggle class
this.__refactorClass( $('input', this.$menu), this.conf.classNames[ _ADDON_ ].toggle, 'toggle' );
// Add markup
$('.' + _c.toggle, this.$menu)
.each(
function()
{
var $t = $(this),
$p = $t.parent(),
id = $t.attr( 'id' ) || that.__getUniqueId();
$t.attr( 'id', id );
$p.prepend( $t );
$('<label for="' + id + '" class="' + _c.toggle + '"><div></div></label>')
.insertBefore( $p.children().last() );
}
);
};
// Add to plugin
$[ _PLUGIN_ ].addons = $[ _PLUGIN_ ].addons || [];
$[ _PLUGIN_ ].addons.push( _ADDON_ );
// Defaults
$[ _PLUGIN_ ].defaults[ _ADDON_ ] = {};
$[ _PLUGIN_ ].configuration.classNames[ _ADDON_ ] = {
toggle : 'Toggle'
};
function extendOptions( o )
{
return o;
}
function extendConfiguration( c )
{
return c;
}
function _initAddon()
{
addon_initiated = true;
_c = $[ _PLUGIN_ ]._c;
_d = $[ _PLUGIN_ ]._d;
_e = $[ _PLUGIN_ ]._e;
_c.add( 'toggle' );
glbl = $[ _PLUGIN_ ].glbl;
}
})( jQuery );