$(document).ready(function () { SetdropdownLeft(); $('.gn-list >li').hover( function () { $(this).addClass("active"); var current_li = $(this); if (!$(current_li).children('.dropdown').is(':visible') && $('.dropdown').find('a').length > 0) { $(current_li).find('.dropdown').slideDown(200); } } , function () { $(this).find('.dropdown').slideUp(100); $(this).removeClass("active"); }); if (li_id) { $("#" + li_id + " >a").addClass("active1"); }; bodyW = $('body').width(); $('.projects-listing').each(function() { var $this = $(this), offset = parseInt($this.find('.listing-item').css('padding-left')), w = parseInt($this.parents('[class*="col-"]').width()) + offset, h = 0, $elems = $this.find('.listing-item'); $this.css({ 'margin-left' : -offset, 'width' : w }); if ($this.hasClass('projects-listing-3-cols')) { if (bodyW < 768) { $elems.width($this.width()-30); } else { $elems.width($this.width()/3 - 30); } } if ($this.hasClass('projects-listing-4-cols')) { if (bodyW < 768) { $elems.width($this.width()-30); } else { $elems.width($this.width()/4 - 30); } } if ($this.hasClass('projects-listing-5-cols')) { if (bodyW < 768) { $elems.width($this.width()-30); } else { $elems.width($this.width()/5 - 30); } } }); $(window).resize(function () { SetdropdownLeft(); bodyW = $('body').width(); $('.projects-listing').each(function () { var $this = $(this) , offset = parseInt($this.find('.listing-item').css('padding-left')) , w = parseInt($this.parents('[class*="col-"]').width()) + offset , h = 0 , $elems = $this.find('.listing-item'); $this.css({ 'margin-left': -offset , 'width': w }); if ($this.hasClass('projects-listing-3-cols')) { if (bodyW < 768) { $elems.width($this.width()-30); } else { $elems.width($this.width() / 3 - 30); } } if ($this.hasClass('projects-listing-4-cols')) { if (bodyW < 768) { $elems.width($this.width()-30); } else { $elems.width($this.width() / 4 - 30); } } if ($this.hasClass('projects-listing-5-cols')) { if (bodyW < 768) { $elems.width($this.width()-30); } else { $elems.width($this.width() / 5 - 30); } } }); }); }) function SetdropdownLeft(){ if($(window).width()>767){ $(".gn-list >li").each(function(i,o){ $(o).find(".dropdown").attr("w",$(o).find(".dropdown").width()); $(o).attr("w",$(o).width()); $(o).find(".dropdown").css("margin-left",($(o).width()-$(o).find(".dropdown").width()-20)/2); }); }else{ $(".gn-list .dropdown").removeAttr("style"); } } function popupDiv(div_id) { //根据自己需求注意宽度和高度的调整 var iWidth = document.documentElement.clientWidth; var iHeight = document.documentElement.clientHeight; //遮罩层 var bgObj = document.createElement("div"); bgObj.setAttribute("id", "bgObj"); //设置ID bgObj.setAttribute("onclick", "hideDiv('" + div_id + "')"); bgObj.style.cssText = "position:absolute;left:0px;top:0px;width:" + Math.max(document.body.scrollWidth, iWidth) + "px;height:" + Math.max(document.body.scrollHeight, iHeight) + "px;filter:Alpha(Opacity=30);opacity:0.1;background-color:#000000;z-index:20000;"; document.body.appendChild(bgObj); var div_obj = $("#" + div_id); var windowWidth = document.documentElement.clientWidth; var windowHeight = document.documentElement.clientHeight; var popupHeight = div_obj.height(); var popupWidth = div_obj.width(); //添加并显示遮罩层 //$("
").addClass("overlap") //.width(windowWidth * 0.99) //.height(windowHeight * 0.99) //.click(function() {hideDiv(div_id); }) //.appendTo("body") //.fadeIn(200); div_obj.fadeIn(500); div_obj.css({ "position": "fixed", "z-index": "30000", "left": windowWidth / 2 - popupWidth / 2, "top": windowHeight / 2 - popupHeight / 2 }).animate({ opacity: "show" }, "slow"); } function hideDiv(div_id) { $("#bgObj").remove(); //$("#mask").remove(); $("#" + div_id).fadeOut(500); }