$(function(){ //table隔行变色 $(".table tr:not(:first):odd").css({background:"#f7f7f7"}); $(".table tr:not(:first):even").css({background:"#fff"}); //左侧栏的效果 JPlaceHolder.init(); resetheight(); window.onresize = function(){ resetheight(); } $(".closeleft").on("click",function(){ $(".leftsidebar_box").toggle(); if($(".leftsidebar_box").is(":hidden")){ $(".right").css("margin-left","5px"); }else{ $(".right").css("margin-left","245px"); } }); $(".leftsidebar_box").on("click",' dt',function(){ $(this).parent().siblings('dl').find('ul').slideUp().siblings('dt').removeClass('sideup'); $(this).toggleClass('sideup').parent().find('ul').slideToggle(); }); $(".leftsidebar_box dl ul li").on("click",function(){ $(this).addClass("hovers").siblings('li').removeClass('hovers').end().parents('dl').siblings("dl").find('li').removeClass('hovers'); }); }); var resetheight = function(){ var wheight = $(window).height()-60-20; wheight = wheight>400 ? wheight :400; var rightboxheight = $(".rightbox").outerHeight(wheight); $(".leftsidebar_box_mask").outerHeight(wheight); $(".leftsidebar_box").outerHeight(wheight); $("#iframes").height(wheight-20); } var layer = function (name,w,z,callback){ if(!name){ name = ".layer" }else{ name = "."+name; } if(!w){ w = "500"; } if(!z){ z = 1001; } var indexs = z-1; var h = $(name).outerHeight(); $(name).show(); //top.$(".leftsidebar_box_mask").show(); if($(".dialogmaskLayer").is(":hidden")){ $(".dialogmaskLayer").show(); }else{ $(".dialogmaskLayer").css({"z-index":indexs}); } $(name).css({ "width": w+"px", "margin-left":-w/2, "margin-top":-h/2, "z-index":z }); $(name).find(".y_true").on("click",function(){ if (callback) { callback(); } $(this).closest(".layer").hide(); //top.$(".leftsidebar_box_mask").hide(); $(".dialogmaskLayer").hide(); }); $(name).find(".close_y").click(function(){ $(this).closest(".layer").hide(); //$(".dialogmaskLayer").hide(); //top.$(".leftsidebar_box_mask").hide(); indexs = indexs-2; //alert($("div.layer:hidden").length); if($("div.layer:hidden").length==$("div.layer").length){ $(".dialogmaskLayer").hide(); }else{ $(".dialogmaskLayer").css({"z-index":indexs}); } }); $(name).find(".y_cancel").on("click",function(){ $(this).closest(".layer").hide(); $(".dialogmaskLayer").hide(); top.$(".leftsidebar_box_mask").hide(); }); } //弹出加载提示框 var tipLoad = function (options, dom, opacity) { if (!dom) { dom = "body"; } if (!options) { options = '正在加载...'; } var tipDiv = $('
' + options + '
'); $(dom).css({ "position": "relative" }); tipDiv.appendTo(dom); Maskshow(opacity, dom); }; //添加遮罩层 var Maskshow = function (opacity, dom) { if (!dom) { dom = "body"; } $('
').appendTo(dom); if (!opacity) { opacity = 50; } $(".maskLayer").css({ "height": "100%", "width": "100%", "background": "#000", "filter": opacity, "opacity": opacity / 100, "top": 0, "bottom": 0, "right": 0, "left": 0, "position": "fixed", "zIndex": "1000" }); }; //删除遮罩层 var Maskremove = function () { $(".maskLayer").remove(); } //删除提示框 var tipRemove = function () { Maskremove(); $(".tipLoad").remove(); } var alertConfirm = function (content, callback) { var confirmModalObj = $('

温馨提示

' + content + '

'); confirmModalObj.appendTo("body"); confirmModalObj.find('input#confirm').on('click', function () { if (callback) { callback(); } confirmModalObj.hide(); }); confirmModalObj.find('input#cancel').on('click', function () { $(".alertm").remove(); }); }; var alertModal = function (content, callback) { var confirmModalObj = $('

温馨提示

' + content + '

'); confirmModalObj.appendTo("body"); confirmModalObj.find('input#confirm').on('click', function () { if (callback) { callback(); } confirmModalObj.hide(); }); confirmModalObj.find('input#cancel').on('click', function () { $(".alertm").remove(); }); }; var JPlaceHolder = { //检测 _check : function(){ return 'placeholder' in document.createElement('input'); }, //初始化 init : function(){ if(!this._check()){ this.fix(); } }, //修复 fix : function(){ jQuery(':input[placeholder]').each(function(index, element) { var self = $(this), txt = self.attr('placeholder'); self.wrap($('
').css({position:'relative', zoom:'1', border:'none', background:'none', padding:'none', margin:'none'})); var pos = self.position(), h = self.outerHeight(true)-2, paddingleft = self.css('padding-left'),w = self.outerWidth(true)-2;//这里减一是为了背景色不覆盖text的边框 var holder = $('').text(txt).css({position:'absolute', left:pos.left+1, top:pos.top+1, height:h,width:w, paddingLeft:paddingleft,paddingTop:'10px', color:'#aaa'}).appendTo(self.parent()); holder.css("background-color",self.css("background-color")).css("text-align","left");//设置背景色避免样式冲突 self.focusin(function(e) { holder.hide(); }).focusout(function(e) { if(!self.val()){ holder.show(); } }); holder.click(function(e) { holder.hide(); self.focus(); }); if(!self.val()){ holder.hide(); }else{ holder.show(); } }); } }; function moveEnd(obj) { obj.focus(); var len = obj.value.length; if(document.selection){ var sel = obj.createTextRange(); sel.moveStart('character', len); sel.collapse(); sel.select(); }else if(typeof obj.selectionStart == 'number' && typeof obj.selectionEnd == 'number') { obj.selectionStart = obj.selectionEnd = len; } }