123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- var config = {}
- layui.use(['element'], function(){
- $ = layui.jquery;
- element = layui.element();
-
- //导航的hover效果、二级菜单等功能,需要依赖element模块
- // 侧边栏点击隐藏兄弟元素
- $('.layui-nav-item').click(function(event) {
- $(this).siblings().removeClass('layui-nav-itemed');
- });
- $('.layui-tab-title li').eq(0).find('i').remove();
- height = $('.layui-layout-admin .site-demo').height();
- $('.layui-layout-admin .site-demo').height(height-100);
- if($(window).width()<750){
- trun = 0;
- $('.x-slide_left').css('background-position','0px -61px');
- }else{
- trun = 1;
- }
- $('.x-slide_left').click(function(event) {
- if(trun){
- $('.x-side').animate({left: '-200px'},200).siblings('.x-main').animate({left: '0px'},200);
- $(this).css('background-position','0px -61px');
- trun=0;
- }else{
- $('.x-side').animate({left: '0px'},200).siblings('.x-main').animate({left: '200px'},200);
- $(this).css('background-position','0px 0px');
- trun=1;
- }
-
- });
- //监听导航点击
- element.on('nav(side)', function(elem){
- var title = elem.find('cite').text();
- var url = elem.find('a').attr('_href');
- // alert(url);
- var parent = elem.parent().parent().find('cite').eq(0).text()
- config.cur = url
- config.parentTitle = parent
- config.subTitle = title
- $("#content").attr('src',url);
- return;
- for (var i = 0; i <$('.x-iframe').length; i++) {
- if($('.x-iframe').eq(i).attr('src')==url){
- element.tabChange('x-tab', i);
- return;
- }
- };
- res = element.tabAdd('x-tab', {
- title: title
- ,content: '<iframe frameborder="0" src="'+url+'" class="x-iframe"></iframe>'
- });
- element.tabChange('x-tab', $('.layui-tab-title li').length-1);
- $('.layui-tab-title li').eq(0).find('i').remove();
- });
- });
|