
//主导航
(function () {
    var $nav = $('#left_panel nav');
    var $a = $nav.find('a');
    $a.each(function () {
        var $btn = $(this);
        var $parent_li = $btn.parent();
        var $ul = $btn.next('ul');
        var $i = $btn.find('b i');
        if ($ul.length >= 1) {
            $btn.on('click', function () {
                var ul_orgH = $ul.innerHeight();
                if (!$parent_li.hasClass('open')) {
                    $parent_li.addClass('open');
                    //$ul.css({'height': 0}).css('display', 'block');
                    $i.removeClass('fa-plus-square-o').addClass('fa-minus-square-o');
                } else {
                    $parent_li.removeClass('open');
                    $i.removeClass('fa-minus-square-o').addClass('fa-plus-square-o');
                }

                $others_li = $btn.parent().siblings('.open');
                $others_li.each(function () {
                    var $parent_li = $(this);
                    var $btn = $parent_li.find('a:first');
                    var $ul = $btn.next('ul');
                    var $i = $btn.find('b i');
                    $parent_li.removeClass('open');
                    $i.removeClass('fa-minus-square-o').addClass('fa-plus-square-o');
                });
            });
        }
    });

    var $minifyBtn = $('#left_panel .minifyBtn');
    var $body = $('body');
    $minifyBtn.on('click', function () {
        $('#left_panel nav li.open').each(function () {
            var $parent_li = $(this);
            var $btn = $parent_li.find('a:first');
            var $ul = $btn.next('ul');
            var $i = $btn.find('b i');
            $parent_li.removeClass('open');
            $i.removeClass('fa-minus-square-o').addClass('fa-plus-square-o');
            $ul.css({'height': "auto"});
        });
        if (!$body.hasClass('minified')) {
            $body.addClass('minified');
            $(this).find('i').addClass('fa-flip-horizontal');
        } else {
            $body.removeClass('minified');
            $(this).find('i').removeClass('fa-flip-horizontal');
        }
    });
})();


//树形菜单表格
(function () {
    $(document).on('click', '.J_tree_table .J_pull_btn', function () {
        var $btn = $(this);
        if ($btn.hasClass('pull_down')) {
            $btn.removeClass('pull_down').addClass('pull_up');
            var $tr = $btn.parent();
            while ($tr[0].nodeName.toLowerCase() !== 'tr') {
                $tr = $tr.parent();
            }
            $tr.siblings().css('display', 'none');
        } else if ($btn.hasClass('pull_up')) {
            $btn.removeClass('pull_up').addClass('pull_down');
            var $tr2 = $btn.parent();
            while ($tr2[0].nodeName.toLowerCase() !== 'tr') {
                $tr2 = $tr2.parent();
            }
            $tr2.siblings().css('display', 'table-row');
        }
    });
    $(document).on('click', '.J_tree_table_all_open', function () {
        var $btn = $(this);
        var $targetTable = $($btn.attr('data-target'));
        if ($targetTable.length >= 1) {
            var $all_J_pull_btn = $targetTable.find('.J_pull_btn');
            $all_J_pull_btn.removeClass('pull_up').addClass('pull_down');
            var $all_tr = $targetTable.find('tr');
            $all_tr.css('display', 'table-row');
        }
    });
    $(document).on('click', '.J_tree_table_all_close', function () {
        var $btn = $(this);
        var $targetTable = $($btn.attr('data-target'));
        if ($targetTable.length >= 1) {
            var $all_J_pull_btn = $targetTable.find('.J_pull_btn');
            $all_J_pull_btn.each(function () {
                var $btn = $(this);
                $btn.removeClass('pull_down').addClass('pull_up');
                var $tr = $btn.parent();
                while ($tr[0].nodeName.toLowerCase() !== 'tr') {
                    $tr = $tr.parent();
                }
                $tr.siblings().css('display', 'none');
            });
        }
    });
})();
(function () {
	$('.btn-delete').click(function(){
		layer.confirm('确定删除么？',function(){
			layer.close(index);	
		})	
	})	
	/*$('.btn-edit',document.getElementById('iFrame1').contentWindow.document).click(function(){
		layer.open({
		  type: 2,
		  title: '内容修改',
		  maxmin: true,
		  shadeClose: true, //点击遮罩关闭层
		  area : ['100%' , '100%'],
		  content: '../app/edit_detail.html'
		});
	})*/	
	$('#mapView').click(function(){
		layer.open({
		  type: 2,
		  title: '地图监控',
		  maxmin: false,
		  shadeClose: true, //点击遮罩关闭层
		  area : ['100%' , '100%'],
		  content: '../map/index.html'
		});
	})	
    $('#bxfx').click(function(){
        layer.open({
          type: 2,
          title: '波形分析',
          maxmin: false,
          shadeClose: true, //点击遮罩关闭层
          area : ['100%' , '100%'],
          content: 'vdwaveform',
	  scrollbar: false
        });
    }) 
    $('.form_datetime').datetimepicker({
        minView: "month", //选择日期后，不会再跳转去选择时分秒 
        language:  'zh-CN',
        format: 'yyyy-mm-dd',
        todayBtn: false,//今日按钮
        autoclose: 1,
    });
    $('#fwfx').click(function(){
        layer.open({
          type: 2,
          title: '暂降范围分析',
          maxmin: false,
          shadeClose: true, //点击遮罩关闭层
          area : ['100%' , '100%'],
          content: 'map'
        });
    })  
    $('#bxck').click(function(){
        layer.open({
          type: 2,
          title: '波形分析',
          maxmin: false,
          shadeClose: true, //点击遮罩关闭层
          area : ['100%' , '100%'],
          content: 'waveform',
          scrollbar: false
        });
    })  
    $('#sbtj').click(function(){
        layer.open({
          type: 2,
          title: '统计',
          maxmin: false,
          shadeClose: true, //点击遮罩关闭层
          area : ['100%' , '100%'],
          content: 'statistics',
          scrollbar: false
        });
    })  
    $('#dzgl').click(function(){
        layer.open({
          type: 2,
          title: '定值管理',
          maxmin: false,
          shadeClose: true, //点击遮罩关闭层
          area : ['100%' , '100%'],
          content: 'valuemanage',
          scrollbar: false
        });
    })  
    
    $('#txcs').click(function(){
        layer.open({
          type: 2,
          title: '通讯测试',
          maxmin: false,	
          shadeClose: true, //点击遮罩关闭层
          area : ['100%' , '100%'],
          content: 'communicate',
          scrollbar: false 
        });
    })  
	 $('#example tbody').on( 'click', 'tr', function () {
                $(this).toggleClass('selected');
            } );
})();

  $(".njcn").mouseover(function(){
	  $(this).attr("class","njcn btn");
  });
  $(".njcn").mouseout(function(){
	  $(this).attr("class","njcn btn btn-primary");
  });

/***
 * 柱状图间隔(超过多少个）
 */
var barspaclength = 20;

function getRole(url) {
    var da = 0;

    $.ajax({
        type: 'POST',
        dataType: "json",
        url: '/pqs9200/overview/getRole',
        async: false,
        data: {
            url: url
        },
        success: function (data) {
            if (data == 1) {
                da = 1
            }
        }
    });
    return da;
}

var url = /^([/]([A-Za-z0-9]|\/)*[^/])|#$/; //菜单的url校验
var passwordz = /^(?=.*[a-zA-Z])(?=.*\d)(?=.*[@#_!$%^&*()?<>/|~,\\\-+\.]).{8,16}$/;//密码格式,需要包含特殊字符字母数字，长度为8-16

  
  

	