(function($, window, document, undefined) {
var pluginName = "jqueryAccordionMenu";
var defaults = {
speed: 300,
showDelay: 0,
hideDelay: 0,
singleOpen: true,
clickEffect: true
};
function Plugin(element, options) {
this.element = element;
this.settings = $.extend({},
defaults, options);
this._defaults = defaults;
this._name = pluginName;
this.init()
};
$.extend(Plugin.prototype, {
init: function() {
this.openSubmenu();
this.submenuIndicators();
if (defaults.clickEffect) {
this.addClickEffect()
}
},
openSubmenu: function() {
$(this.element).children("ul").find("li").bind("click touchstart",
function(e) {
e.stopPropagation();
e.preventDefault();
if ($(this).children(".submenu").length > 0) {
if ($(this).children(".submenu").css("display") == "none") {
$(this).children(".submenu").delay(defaults.showDelay).slideDown(defaults.speed);
$(this).children(".submenu").siblings("a").addClass("submenu-indicator-minus");
if (defaults.singleOpen) {
$(this).siblings().children(".submenu").slideUp(defaults.speed);
$(this).siblings().children(".submenu").siblings("a").removeClass("submenu-indicator-minus")
}
return false
} else {
$(this).children(".submenu").delay(defaults.hideDelay).slideUp(defaults.speed)
}
if ($(this).children(".submenu").siblings("a").hasClass("submenu-indicator-minus")) {
$(this).children(".submenu").siblings("a").removeClass("submenu-indicator-minus")
}
}
window.location.href = $(this).children("a").attr("href")
})
},
submenuIndicators: function() {
if ($(this.element).find(".submenu").length > 0) {
$(this.element).find(".submenu").siblings("a").append("
")}
},
addClickEffect: function() {
var ink, d, x, y;
$(this.element).find("a").bind("click touchstart",
function(e) {
$(".ink").remove();
if ($(this).children(".ink").length === 0) {
$(this).prepend("")
}
ink = $(this).find(".ink");
ink.removeClass("animate-ink");
if (!ink.height() && !ink.width()) {
d = Math.max($(this).outerWidth(), $(this).outerHeight());
ink.css({
height: d,
width: d
})
}
x = e.pageX - $(this).offset().left - ink.width() / 2;
y = e.pageY - $(this).offset().top - ink.height() / 2;
ink.css({
top: y + 'px',
left: x + 'px'
}).addClass("animate-ink")
})
}
});
$.fn[pluginName] = function(options) {
this.each(function() {
if (!$.data(this, "plugin_" + pluginName)) {
$.data(this, "plugin_" + pluginName, new Plugin(this, options))
}
});
return this
}
})(jQ大享上。是发了概开程态间些告人屏果会区。uery, window, document)微和二第说,班。都年很过过事发工开宗定据发指互数个遍前互就;
修改效果是点击某子菜单后,此菜单保留点击时样式,而不是随鼠标移走而恢复A:link样式。
如需要查看css文件,可问我