Commit 4de6a804 by fengshuonan

修复bug

parent 4775a338
/** EasyWeb iframe v3.1.0 data:2019-01-17 */
layui.define(["jquery"], function (exports) {
var $ = layui.jquery;
var contextMenu = {
// 绑定元素
bind: function (elem, items) {
$(elem).bind('contextmenu', function (e) {
contextMenu.show(items, e.clientX, e.clientY);
return false;
});
},
// 构建无限级
getHtml: function (items, pid) {
var htmlStr = '';
for (var i = 0; i < items.length; i++) {
var item = items[i];
item.itemId = 'ctxMenu-' + pid + i;
if (item.subs && item.subs.length > 0) {
htmlStr += '<div class="ctxMenu-item haveMore" lay-id="' + item.itemId + '">';
htmlStr += '<a>';
if (item.icon) {
htmlStr += '<i class="' + item.icon + ' ctx-icon"></i>';
}
htmlStr += item.name;
htmlStr += '<i class="layui-icon layui-icon-right icon-more"></i>';
htmlStr += '</a>';
htmlStr += '<div class="ctxMenu-sub" style="display: none;">';
htmlStr += contextMenu.getHtml(item.subs, pid + i);
htmlStr += '</div>';
} else {
htmlStr += '<div class="ctxMenu-item" lay-id="' + item.itemId + '">';
htmlStr += '<a>';
if (item.icon) {
htmlStr += '<i class="' + item.icon + ' ctx-icon"></i>';
}
htmlStr += item.name;
htmlStr += '</a>';
}
htmlStr += '</div>';
if (item.hr == true) {
htmlStr += '<hr/>';
}
}
return htmlStr;
},
// 设置事件监听
setEvents: function (items) {
for (var i = 0; i < items.length; i++) {
var item = items[i];
if (item.click) {
$('.ctxMenu').on('click', '[lay-id="' + item.itemId + '"]', item.click);
}
if (item.subs && item.subs.length > 0) {
contextMenu.setEvents(item.subs);
}
}
},
// 移除所有
remove: function () {
var ifs = top.window.frames;
for (var i = 0; i < ifs.length; i++) {
var tif = ifs[i];
try {
tif.layui.jquery('.ctxMenu').remove();
} catch (e) {
}
}
try {
top.layui.jquery('.ctxMenu').remove();
} catch (e) {
}
},
// 获取浏览器高度
getPageHeight: function () {
return document.documentElement.clientHeight || document.body.clientHeight;
},
// 获取浏览器宽度
getPageWidth: function () {
return document.documentElement.clientWidth || document.body.clientWidth;
},
// 在指定坐标显示菜单
show: function (items, x, y) {
var xy = 'left: ' + x + 'px; top: ' + y + 'px;';
var htmlStr = '<div class="ctxMenu" style="' + xy + '">';
htmlStr += contextMenu.getHtml(items, '');
htmlStr += '</div>';
contextMenu.remove();
$('body').append(htmlStr);
// 调整溢出位置
var $ctxMenu = $('.ctxMenu');
if (x + $ctxMenu.outerWidth() > contextMenu.getPageWidth()) {
x -= $ctxMenu.outerWidth();
}
if (y + $ctxMenu.outerHeight() > contextMenu.getPageHeight()) {
y = y - $ctxMenu.outerHeight();
if (y < 0) {
y = 0;
}
}
$ctxMenu.css({'top': y, 'left': x});
// 添加item点击事件
contextMenu.setEvents(items);
// 显示子菜单事件
$('.ctxMenu-item.haveMore').on('mouseenter', function () {
var $item = $(this).find('>a');
var $sub = $(this).find('>.ctxMenu-sub');
var top = $item.offset().top;
var left = $item.offset().left + $item.outerWidth();
if (left + $sub.outerWidth() > contextMenu.getPageWidth()) {
left = $item.offset().left - $sub.outerWidth();
}
if (top + $sub.outerHeight() > contextMenu.getPageHeight()) {
top = top - $sub.outerHeight() + $item.outerHeight();
if (top < 0) {
top = 0;
}
}
$(this).find('>.ctxMenu-sub').css({
'top': top,
'left': left,
'display': 'block'
});
}).on('mouseleave', function () {
$(this).find('>.ctxMenu-sub').css('display', 'none');
});
}
};
// 点击任意位置关闭菜单
$(document).off('click.ctxMenu').on('click.ctxMenu', function () {
contextMenu.remove();
});
// 点击有子菜单的节点不关闭菜单
$('body').off('click.ctxMenuMore').on('click.ctxMenuMore', '.ctxMenu-item', function (e) {
if ($(this).hasClass('haveMore')) {
if (e !== void 0) {
e.preventDefault();
e.stopPropagation();
}
} else {
contextMenu.remove();
}
});
exports("contextMenu", contextMenu);
});
\ No newline at end of file
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('l.14(["z"],3(h){4 g=l.z,e={Z:3(c,b){g(c).Z("1c",3(a){e.L(b,a.1b,a.18);x!1})},E:3(c,b){D(4 a="",d=0;d<c.m;d++){4 f=c[d];f.t="2-"+b+d;f.k&&0<f.k.m?(a+=\'<6 7="2-u B" I-K="\'+f.t+\'">\',a+="<a>",f.5&&(a+=\'<i 7="\'+f.5+\' M-5"></i>\'),a+=f.N,a+=\'<i 7="l-5 l-5-17 5-16"></i>\',a+="</a>",a+=\'<6 7="2-w" P="C: W;">\',a+=e.E(f.k,b+d),a+="</6>"):(a+=\'<6 7="2-u" I-K="\'+f.t+\'">\',a+="<a>",f.5&&(a+=\'<i 7="\'+f.5+\' M-5"></i>\'),a+=f.N,a+="</a>");a+="</6>";1==f.X&&(a+="<X/>")}x a},F:3(c){D(4 b=0;b<c.m;b++){4 a=c[b];13(a.8)g(".2").o("8",\'[I-K="\'+a.t+\'"]\',a.8);a.k&&0<a.k.m&&e.F(a.k)}},9:3(){D(4 c=j.12.11,b=0;b<c.m;b++){4 a=c[b];R{a.l.z(".2").9()}S(d){}}R{j.l.z(".2").9()}S(d){}},G:3(){x n.U.V||n.v.V},J:3(){x n.U.Y||n.v.Y},L:3(c,b,a){4 d=\'<6 7="2" P="\'+("s: "+b+"Q; j: "+a+"Q;")+\'">\'+e.E(c,"");d+="</6>";e.9();g("v").19(d);d=g(".2");b+d.r()>e.J()&&(b-=d.r());a+d.p()>e.G()&&(a-=d.p(),0>a&&(a=0));d.A({j:a,s:b});e.F(c);g(".2-u.B").o("15",3(){4 a=g(q).y(">a"),c=g(q).y(">.2-w"),b=a.H().j,d=a.H().s+a.r();d+c.r()>e.J()&&(d=a.H().s-c.r());b+c.p()>e.G()&&(b=b-c.p()+a.p(),0>b&&(b=0));g(q).y(">.2-w").A({j:b,s:d,C:"10"})}).o("1a",3(){g(q).y(">.2-w").A("C","W")})}};g(n).O("8.2").o("8.2",3(){e.9()});g("v").O("8.T").o("8.T",".2-u",3(c){g(q).1d("B")?1e 0!==c&&(c.1f(),c.1g()):e.9()});h("1h",e)});',62,80,'||ctxMenu|function|var|icon|div|class|click|remove||||||||||top|subs|layui|length|document|on|outerHeight|this|outerWidth|left|itemId|item|body|sub|return|find|jquery|css|haveMore|display|for|getHtml|setEvents|getPageHeight|offset|lay|getPageWidth|id|show|ctx|name|off|style|px|try|catch|ctxMenuMore|documentElement|clientHeight|none|hr|clientWidth|bind|block|frames|window|if|define|mouseenter|more|right|clientY|append|mouseleave|clientX|contextmenu|hasClass|void|preventDefault|stopPropagation|contextMenu'.split('|'),0,{}))
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment