整理代码
parent
157ad9da3f
commit
f6e62d9671
|
|
@ -46,17 +46,13 @@ layui.define(['table', 'jquery', 'element'], function(exports) {
|
||||||
createMenu(option);
|
createMenu(option);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
element.init();
|
element.init();
|
||||||
|
|
||||||
downShow(option);
|
downShow(option);
|
||||||
|
|
||||||
option.done();
|
option.done();
|
||||||
return new pearMenu(option);
|
return new pearMenu(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
pearMenu.prototype.click = function(clickEvent) {
|
pearMenu.prototype.click = function(clickEvent) {
|
||||||
|
|
||||||
var _this = this;
|
var _this = this;
|
||||||
$("#" + _this.option.elem + " .site-demo-active").parent().click(function() {
|
$("#" + _this.option.elem + " .site-demo-active").parent().click(function() {
|
||||||
var dom = $(this).children(".site-demo-active");
|
var dom = $(this).children(".site-demo-active");
|
||||||
|
|
@ -67,9 +63,7 @@ layui.define(['table', 'jquery', 'element'], function(exports) {
|
||||||
menuIcon: dom.attr("menu-icon"),
|
menuIcon: dom.attr("menu-icon"),
|
||||||
menuUrl: dom.attr("menu-url")
|
menuUrl: dom.attr("menu-url")
|
||||||
};
|
};
|
||||||
|
|
||||||
var doms = hash(dom);
|
var doms = hash(dom);
|
||||||
|
|
||||||
if (doms.text() != '') {
|
if (doms.text() != '') {
|
||||||
data['menuPath'] = doms.find("span").text() + " / " + data['menuPath'];
|
data['menuPath'] = doms.find("span").text() + " / " + data['menuPath'];
|
||||||
}
|
}
|
||||||
|
|
@ -89,7 +83,6 @@ layui.define(['table', 'jquery', 'element'], function(exports) {
|
||||||
return dom.parent().parent().prev();
|
return dom.parent().parent().prev();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pearMenu.prototype.skin = function(skin) {
|
pearMenu.prototype.skin = function(skin) {
|
||||||
var menu = $(".pear-nav-tree[lay-filter='" + this.option.elem + "']").parent();
|
var menu = $(".pear-nav-tree[lay-filter='" + this.option.elem + "']").parent();
|
||||||
menu.removeClass("dark-theme");
|
menu.removeClass("dark-theme");
|
||||||
|
|
@ -97,7 +90,6 @@ layui.define(['table', 'jquery', 'element'], function(exports) {
|
||||||
menu.addClass(skin);
|
menu.addClass(skin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pearMenu.prototype.selectItem = function(pearId) {
|
pearMenu.prototype.selectItem = function(pearId) {
|
||||||
|
|
||||||
if (this.option.control != false) {
|
if (this.option.control != false) {
|
||||||
|
|
@ -114,15 +106,12 @@ layui.define(['table', 'jquery', 'element'], function(exports) {
|
||||||
$("#" + this.option.control).find(".layui-this").removeClass("layui-this");
|
$("#" + this.option.control).find(".layui-this").removeClass("layui-this");
|
||||||
$("#" + this.option.control).find("[pear-id='" + controlId + "']").addClass("layui-this");
|
$("#" + this.option.control).find("[pear-id='" + controlId + "']").addClass("layui-this");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.option.accordion == true) {
|
if (this.option.accordion == true) {
|
||||||
$("#" + this.option.elem + " a[menu-id='" + pearId + "']").parents(".pear-nav-tree").find(".layui-nav-itemed").removeClass(
|
$("#" + this.option.elem + " a[menu-id='" + pearId + "']").parents(".pear-nav-tree").find(".layui-nav-itemed").removeClass(
|
||||||
"layui-nav-itemed");
|
"layui-nav-itemed");
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#" + this.option.elem + " a[menu-id='" + pearId + "']").parents(".pear-nav-tree").find(".layui-this").removeClass(
|
$("#" + this.option.elem + " a[menu-id='" + pearId + "']").parents(".pear-nav-tree").find(".layui-this").removeClass(
|
||||||
"layui-this");
|
"layui-this");
|
||||||
|
|
||||||
if (!$("#" + this.option.elem).is(".pear-nav-mini")) {
|
if (!$("#" + this.option.elem).is(".pear-nav-mini")) {
|
||||||
$("#" + this.option.elem + " a[menu-id='" + pearId + "']").parents(".layui-nav-item").addClass("layui-nav-itemed");
|
$("#" + this.option.elem + " a[menu-id='" + pearId + "']").parents(".layui-nav-item").addClass("layui-nav-itemed");
|
||||||
$("#" + this.option.elem + " a[menu-id='" + pearId + "']").parents("dd").addClass("layui-nav-itemed");
|
$("#" + this.option.elem + " a[menu-id='" + pearId + "']").parents("dd").addClass("layui-nav-itemed");
|
||||||
|
|
@ -131,14 +120,10 @@ layui.define(['table', 'jquery', 'element'], function(exports) {
|
||||||
$("#" + this.option.elem + " a[menu-id='" + pearId + "']").parent().addClass("layui-this");
|
$("#" + this.option.elem + " a[menu-id='" + pearId + "']").parent().addClass("layui-this");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var activeMenus;
|
var activeMenus;
|
||||||
|
|
||||||
pearMenu.prototype.collaspe = function(time) {
|
pearMenu.prototype.collaspe = function(time) {
|
||||||
|
|
||||||
var elem = this.option.elem;
|
var elem = this.option.elem;
|
||||||
var config = this.option;
|
var config = this.option;
|
||||||
|
|
||||||
if ($("#" + this.option.elem).is(".pear-nav-mini")) {
|
if ($("#" + this.option.elem).is(".pear-nav-mini")) {
|
||||||
$.each(activeMenus, function(i, item) {
|
$.each(activeMenus, function(i, item) {
|
||||||
$("#" + elem + " a[menu-id='" + $(this).attr("menu-id") + "']").parent().addClass("layui-nav-itemed");
|
$("#" + elem + " a[menu-id='" + $(this).attr("menu-id") + "']").parent().addClass("layui-nav-itemed");
|
||||||
|
|
@ -212,9 +197,7 @@ layui.define(['table', 'jquery', 'element'], function(exports) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function createMenuAndControl(option) {
|
function createMenuAndControl(option) {
|
||||||
|
|
||||||
var control = '<ul class="layui-nav pear-nav-control pc layui-hide-xs">';
|
var control = '<ul class="layui-nav pear-nav-control pc layui-hide-xs">';
|
||||||
|
|
||||||
var controlPe = '<ul class="layui-nav pear-nav-control layui-hide-sm">';
|
var controlPe = '<ul class="layui-nav pear-nav-control layui-hide-sm">';
|
||||||
// 声 明 头 部
|
// 声 明 头 部
|
||||||
var menu = '<div class="layui-side-scroll ' + option.theme + '">'
|
var menu = '<div class="layui-side-scroll ' + option.theme + '">'
|
||||||
|
|
@ -231,9 +214,7 @@ layui.define(['table', 'jquery', 'element'], function(exports) {
|
||||||
'" class="layui-nav arrow layui-nav-tree pear-nav-tree">';
|
'" class="layui-nav arrow layui-nav-tree pear-nav-tree">';
|
||||||
// 兼容移动端
|
// 兼容移动端
|
||||||
controlPe += '<li class="layui-nav-item"><a class="pe-title" href="javascript:;" >'+ item.title +'</a>';
|
controlPe += '<li class="layui-nav-item"><a class="pe-title" href="javascript:;" >'+ item.title +'</a>';
|
||||||
|
|
||||||
controlItemPe += '<dd pear-href="' + item.href + '" pear-title="' + item.title + '" pear-id="' + item.id +'"><a href="javascript:void(0);">'+ item.title +'</a></dd>';
|
controlItemPe += '<dd pear-href="' + item.href + '" pear-title="' + item.title + '" pear-id="' + item.id +'"><a href="javascript:void(0);">'+ item.title +'</a></dd>';
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
controlItem = '<li pear-href="' + item.href + '" pear-title="' + item.title + '" pear-id="' + item.id +
|
controlItem = '<li pear-href="' + item.href + '" pear-title="' + item.title + '" pear-id="' + item.id +
|
||||||
'" class="layui-nav-item"><a href="#">' + item.title + '</a></li>';
|
'" class="layui-nav-item"><a href="#">' + item.title + '</a></li>';
|
||||||
|
|
@ -379,39 +360,27 @@ layui.define(['table', 'jquery', 'element'], function(exports) {
|
||||||
function isHoverMenu(b, option) {
|
function isHoverMenu(b, option) {
|
||||||
if (b) {
|
if (b) {
|
||||||
$("#" + option.elem + ".pear-nav-mini .layui-nav-item,#" + option.elem + ".pear-nav-mini dd").hover(function() {
|
$("#" + option.elem + ".pear-nav-mini .layui-nav-item,#" + option.elem + ".pear-nav-mini dd").hover(function() {
|
||||||
|
|
||||||
$(this).children(".layui-nav-child").addClass("layui-nav-hover");
|
$(this).children(".layui-nav-child").addClass("layui-nav-hover");
|
||||||
|
|
||||||
var top = $(this).offset().top + 5;
|
var top = $(this).offset().top + 5;
|
||||||
|
|
||||||
if (!$(this).is(".layui-nav-item")) {
|
if (!$(this).is(".layui-nav-item")) {
|
||||||
|
|
||||||
var left = $(this).offset().left + 132;
|
var left = $(this).offset().left + 132;
|
||||||
|
|
||||||
$(this).children(".layui-nav-child").offset({
|
$(this).children(".layui-nav-child").offset({
|
||||||
left: left
|
left: left
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
var left = $(this).offset().left + 62;
|
var left = $(this).offset().left + 62;
|
||||||
|
|
||||||
$(this).children(".layui-nav-child").offset({
|
$(this).children(".layui-nav-child").offset({
|
||||||
left: left
|
left: left
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
$(this).children(".layui-nav-child").offset({
|
$(this).children(".layui-nav-child").offset({
|
||||||
top: top
|
top: top
|
||||||
});
|
});
|
||||||
|
|
||||||
}, function() {
|
}, function() {
|
||||||
|
|
||||||
$(this).children(".layui-nav-child").removeClass("layui-nav-hover");
|
$(this).children(".layui-nav-child").removeClass("layui-nav-hover");
|
||||||
|
|
||||||
$(this).children(".layui-nav-child").css({
|
$(this).children(".layui-nav-child").css({
|
||||||
left: '0px'
|
left: '0px'
|
||||||
});
|
});
|
||||||
|
|
||||||
$(this).children(".layui-nav-child").css({
|
$(this).children(".layui-nav-child").css({
|
||||||
top: '0px'
|
top: '0px'
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue