layui-js/build/lay/modules/element.js

2 lines
3.2 KiB
JavaScript
Raw Normal View History

2016-10-18 08:23:17 +08:00
/** layui-v1.0.2 经典模块化前端框架 LGPL license By www.layui.com */
2016-10-20 16:07:29 +08:00
;layui.define("jquery",function(i){"use strict";var t=layui.jquery,a=(layui.hint(),layui.device()),e="element",n="layui-this",l="layui-show",o=function(){this.config={}};o.prototype.set=function(i){var a=this;return t.extend(!0,a.config,i),a},o.prototype.on=function(i,t){return layui.onevent(e,i,t)},o.prototype.init=function(i){var o={tabClick:function(i,a){var o=t(this),a=a||o.index(),s=o.parents(".layui-tab"),c=s.children(".layui-tab-content").children(".layui-tab-item"),r=s.attr("lay-filter");o.addClass(n).siblings().removeClass(n),c.eq(a).addClass(l).siblings().removeClass(l),layui.event.call(this,e,"tab("+r+")",{elem:s,index:a})},tabAuto:function(){var i="layui-tab-more",e="layui-tab-bar",l="layui-tab-close",s=this;t(".layui-tab").each(function(){var c=t(this),r=c.children(".layui-tab-title"),u=(c.children(".layui-tab-content").children(".layui-tab-item"),'lay-stope="tabmore"'),h=t('<span class="layui-unselect layui-tab-bar" '+u+"><i "+u+' class="layui-icon">&#xe61a;</i></span>');if(s===window&&8!=a.ie&&o.hideTabMore(!0),c.attr("lay-allowClose")&&!r.find("li").find("."+l)[0]){var y=t('<i class="layui-icon layui-unselect '+l+'">&#x1006;</i>');y.on("click",function(){var i=t(this).parent(),a=i.index(),e=i.parents(".layui-tab"),l=e.children(".layui-tab-content").children(".layui-tab-item");i.hasClass(n)&&(i.next()[0]?o.tabClick.call(i.next()[0],{},a+1):i.prev()[0]&&o.tabClick.call(i.prev()[0],{},a-1)),i.remove(),l.eq(a).remove()}),r.find("li").append(y)}if(r.prop("scrollWidth")>r.outerWidth()+1){if(r.find("."+e)[0])return;r.append(h),h.on("click",function(t){r[this.title?"removeClass":"addClass"](i),this.title=this.title?"":"收缩"})}else r.find("."+e).remove()})},hideTabMore:function(i){var a=t(".layui-tab-title");i!==!0&&"tabmore"===i.target.getAttribute("lay-stope")||(a.removeClass("layui-tab-more"),a.find(".layui-tab-bar").attr("title",""))}},s={tab:function(){var i=".layui-tab-title li";o.tabAuto.call({}),c.off("click",i,o.tabClick).on("click",i,o.tabClick),t(window).off("resize",o.tabAuto).on("resize",o.tabAuto),t(document).off("click",o.hideTabMore).on("click",o.hideTabMore)},nav:function(){var i,e=".layui-nav",n="layui-nav-item",l="layui-nav-bar",o="layui-nav-tree",s=200,c=function(a,e){var n=t(this);e.hasClass(o)?a.css({top:n.position().top,height:n.height(),opacity:1}):(a.css({left:n.position().left+parseFloat(n.css("marginLeft")),top:n.position().top+n.height()-5}),i=setTimeout(function(){a.css({width:n.width(),opacity:1})},s))};t(e).each(function(){var e=t(this),r=t('<span class="'+l+'"></span>');e.find("."+l)[0]||a.ie&&a.ie<10||(e.append(r),e.find("."+n).on("mouseenter",function(){c.call(this,r,e)}),e.on("mouseleave",function(){clearTimeout(i),setTimeout(function(){e.hasClass(o)?r.css({height:0,top:r.position().top+r.height()/2,opacity:0}):r.css({width:0,left:r.position().left+r.width()/2,opacity:0})},s)}))})},breadcrumb:function(){var i=".layui-breadcrumb";t(i).each(function(){var i=t(this),a=i.attr("lay-separator")||">",e=i.find("a");e.each(function(i){i!==e.length-1&&t(this).append("<span>"+a+"</span>")}),i.css("visibility","visible")})}};return layui.each(s,function(i,t){t()})};var s=new o,c=t("body");s.init(),i(e,function(i){return s.set(i)})});