-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.mk_toggle 2.js
78 lines (54 loc) · 1.71 KB
/
jquery.mk_toggle 2.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
;/* $.fn.mk_toggle.js
****************************************************************************
/////////////////////////////////////////////////////////////////////////
@varsion : 0
@author : http://www.makinokobo.com - [email protected]
@last update : 2011.06.03 - [email protected]
@Copyright : Copyright (c) 2010 Skill Partners Inc. All Rights Reserved.
/////////////////////////////////////////////////////////////////////////
usage:
****************************************************************************/
(function($){
$(function(){
$('#footerMenu').mk_toggle({
button: '#footerMenu-head > p.menuSwitch a',
area: '#footerMenu-body'
});
});
$.fn.mk_toggle = function(options){
if(!this.size()) return this;
//default options
var defaults = {
button: '.ui-mk_toggle-btn',
area: '.ui-mk_toggle-area',
textOpen: 'open',
textClose: 'close',
classOpen: 'ui-open',
classClose: 'ui-close',
speed: 600
};
var o = $.extend(defaults, options);
this.each(function(){
var $this = $(this);
var $btn = $this.find(o.button);
var $area = $this.find(o.area);
//init
$area.hide();
$btn.text(o.textOpen).removeClass(o.classOpen).addClass(o.classClose);
//button click action
$btn.toggle(
function(e){
$area.stop(false,true).slideDown(o.speed);
$btn.text(o.textClose).removeClass(o.classClose).addClass(o.classOpen);
e.preventDefault();
},
function(e){
$area.stop(false,true).slideUp(o.speed/2);
$btn.text(o.textOpen).removeClass(o.classOpen).addClass(o.classClose);
e.preventDefault();
}
);
});
return this;
};
})(jQuery);