40 lines
994 B
JavaScript
40 lines
994 B
JavaScript
|
(function( $ ){
|
||
|
|
||
|
$.fn.sidemenu = function(options) {
|
||
|
|
||
|
var defualts = {
|
||
|
//控制按钮
|
||
|
'ctrlBtn':'#sidemenu_ctrl',
|
||
|
'status':'show'
|
||
|
};
|
||
|
var opts = $.extend({}, defualts, options);
|
||
|
var menu = $(this);
|
||
|
//this.each(function() {
|
||
|
if(opts.ctrlBtn=='' || opts.status=='')
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
var hidenText = "<<<隐藏菜单";
|
||
|
var showText = "展开菜单>>>";
|
||
|
|
||
|
$(opts.ctrlBtn).bind('click', function() {
|
||
|
|
||
|
if(opts.status == "show"){
|
||
|
menu.show();
|
||
|
$(opts.ctrlBtn).html(hidenText);
|
||
|
$(opts.ctrlBtn).attr('onclick',"$('#"+menu.attr('id')+"').sidemenu({'ctrlBtn':'"+opts.ctrlBtn+"','status':'hide'})");
|
||
|
}
|
||
|
|
||
|
if(opts.status == "hide")
|
||
|
{
|
||
|
menu.hide();
|
||
|
$(opts.ctrlBtn).html(showText);
|
||
|
$(opts.ctrlBtn).attr('onclick',"$('#"+menu.attr('id')+"').sidemenu({'ctrlBtn':'"+opts.ctrlBtn+"','status':'show'})");
|
||
|
}
|
||
|
|
||
|
});
|
||
|
|
||
|
//});
|
||
|
};
|
||
|
})( jQuery );
|