Authored by happyhour7

导航菜单中的二级子菜单

... ... @@ -5,11 +5,14 @@
*/
window.tmp$ = null;
var $ = require('jquery'),
Swiper = require("yoho-idangerous.swiper");
var $ = require('jquery'), Swiper = require("yoho-idangerous.swiper");
require("lazyload");
$(".lazy").lazyload();
//菜单初始化所使用变量
var menuTmpl = $("#menuItemTmpl").html(), dataKey = null, mustache = require("mustache");
$.fn.top = function() {
if (arguments.length > 0) {
$(this).css("top", arguments[0]);
... ... @@ -28,9 +31,6 @@ $.fn.left = function() {
}
};
$(".lazy").lazyload();
//扩展jquery=================================================================
... ... @@ -109,7 +109,7 @@ $(".content").click(function() {
//企业滚动效果======================================================================================================
var minMenuHasShow = false;
var minMenuHasDropDown=false;
var minMenuHasDropDown = false;
//小导航是否显示
var isTop = true;
var bigMenuHeight = 220;
... ... @@ -131,16 +131,9 @@ $(window).scroll(function() {
}).show();
minMenuHasShow = true;
$(".enterprise-header-fixed").show();
$(".search-input-box").hide();
$(".home-search-button").hide();
window.isSearching = false;
//$(".search-text").width(73);
$(".search-text").find(".search-text-content").html("Search...");
$(".search-input-box").val("").hide().trigger("blur");
$(".search-area").find(".icons").show();
$(".home-search-button").hide();
window.isSearching = false;
$(document.body).trigger("click");
} else if (scrollTop < 177 && minMenuHasShow === true) {
$(".search-input-box").trigger("blur");
$("#maxEnterprise").css({
... ... @@ -148,16 +141,10 @@ $(window).scroll(function() {
});
$(".enterprise-header-fixed").hide();
$("#minEnterprise").hide();
$(".search-input-box").hide();
$(".home-search-button").hide();
window.isSearching = false;
minMenuHasShow = false;
//搜索归位
$(".search-text").find(".search-text-content").html("Search...");
$(".search-input-box").val("").hide().trigger("blur");
$(".search-area").find(".icons").show();
$(".home-search-button").hide();
window.isSearching = false;
$(document.body).trigger("click");
}
if (scrollTop > 0 && isTop === true) {
... ... @@ -181,18 +168,20 @@ $(window).scroll(function() {
$(document).bind({
mousemove : function(event) {
var scrollTop = $(this).scrollTop();
var mouseY=event.pageY-scrollTop;
if(mouseY<=200&&minMenuHasDropDown===false&&minMenuHasShow===true){
minMenuHasDropDown=true;
$("#minEnterprise").animate({top:37},500);
var mouseY = event.pageY - scrollTop;
if (mouseY <= 200 && minMenuHasDropDown === false && minMenuHasShow === true) {
minMenuHasDropDown = true;
$("#minEnterprise").animate({
top : 37
}, 500);
} else if (minMenuHasDropDown === true && minMenuHasShow === true && mouseY > 200) {
minMenuHasDropDown = false;
$("#minEnterprise").animate({
top : 0
}, 500);
}
else if(minMenuHasDropDown===true&&minMenuHasShow===true&&mouseY>200)
{
minMenuHasDropDown=false;
$("#minEnterprise").animate({top:0},500);
}
}
});
... ... @@ -311,18 +300,6 @@ if (!isIpad && $(".share").size() > 0) {
});
}
window.scrollWindow = function() {
if (document.body.clientWidth >= 1190) {
//document.body.scrollTop=850;
window.tmp$(window).scrollTop(850);
} else if (document.body.clientWidth < 1190 && document.body.clientWidth > 768) {
window.tmp$(window).scrollTop(700);
} else if (document.body.clientWidth <= 768) {
window.tmp$(window).scrollTop(600);
}
};
//搜索按钮===========================================================================
var clientWidth = $(window).width();
$(".search-input-box").keypress(function(event) {
... ... @@ -353,7 +330,7 @@ $(document.body).click(function() {
if (clientWidth <= 768) {
target.parent().removeAttr("style");
target.css({
width : "auto"
width : "65px"
});
} else {
target.animate({
... ... @@ -368,26 +345,27 @@ $(".search-text").click(function() {
});
$(".search-text").click(function() {
var clientWidth = document.body.clientWidth, parent = null;
$(this).find(".search-text-content").hide();
parent = $(this).parent();
if (clientWidth <= 768) {
$(this).parent().width(131);
$(this).find(".home-search-button").show();
$(this).find(".search-input-box").width(80).val("").show();
$(this).find(".search-input-box").focus();
parent.width(131);
parent.find(".home-search-button").show();
parent.find(".search-input-box").width(80).val("").show();
parent.find(".search-input-box").focus();
$(this).width(120);
} else if (clientWidth >= 924 && clientWidth < 1080) {
$(this).parent().width(198);
$(this).find(".search-input-box").width(150).val("").show();
} else if (clientWidth >= 924 && clientWidth < 1190) {
parent.width(198);
parent.find(".search-input-box").width(150).val("").show();
$(this).animate({
width : 190
}, 500, function() {
$(this).find(".home-search-button").show();
$(this).find(".search-input-box").focus();
});
} else {
$(this).parent().width(218);
$(this).find(".search-input-box").width(150).val("").show();
} else if (clientWidth >= 1190) {
parent.width(218);
parent.find(".search-input-box").width(150).val("").show();
$(this).animate({
width : 190
}, 500, function() {
... ... @@ -401,7 +379,6 @@ $(".search-text").click(function() {
window.scrollWindow = function() {
if (document.body.clientWidth >= 1190) {
//document.body.scrollTop=850;
window.tmp$(window).scrollTop(850);
} else if (document.body.clientWidth < 1190 && document.body.clientWidth > 768) {
... ... @@ -411,3 +388,25 @@ window.scrollWindow = function() {
window.tmp$(window).scrollTop(600);
}
};
//初始化菜单============================================================================
$.ajax({
url : "http://newgirls.test.yoho.cn/default/default/getnewest",
dataType: "jsonp",
jsonp:"callback",
success : function(tmp) {
var data=tmp.data,
dataKey=null,
mustacheHtml=null,
_html=null;
for(dataKey in data){
mustacheHtml=mustache.render(menuTmpl,data);
_html=$(".submenu-"+dataKey).html();
$(".submenu-"+dataKey).html(mustacheHtml+_html);
}
}
});
//====================================================================================
\ No newline at end of file
... ...
... ... @@ -26,10 +26,8 @@
"yoho-tips": "0.0.1",
"mustache": "2.0.0",
"jquery.autocomplete": "~0.0.2",
"mlellipsis": "0.0.3",
"mlellipsis": "~0.0.3",
"jquery.rotate2d": "0.0.3"
},
"devDependencies": {
"expect.js": "0.3.1"
... ...
... ... @@ -103,7 +103,7 @@
float:left;
position:relative;
.link{
.menu-link{
@include blockwh(100%,100%);
cursor:pointer;
position:absolute;
... ... @@ -127,7 +127,7 @@
height:100%;
}
}
.text{
.menu-text{
@include blockwh(298px,auto);
font-size:18px;
line-height:22px;
... ... @@ -141,7 +141,7 @@
color:#000;
}
}
.detail{margin-top:10px;}
.menu-detail{margin-top:10px;}
}
}
.menu-item{
... ... @@ -1276,20 +1276,20 @@
.submenu-fashion {
left:-1px;
left:0px;
}
.submenu-sports {
left:-288px;
left:-287px;
}
.submenu-lifestyle {
left:-419px;
left:-418px;
}
.submenu-video {
left:-568px;
left:-567px;
}
.submenu-beauty {
left:-147px;
left:-146px;
}
... ...
... ... @@ -57,7 +57,7 @@
margin:0 auto;
position:relative;
.submenu{
width:668px;
width:628px;
height:395px;
background:url(../assets/images/submenubackground.png);
position:absolute;
... ... @@ -1151,16 +1151,16 @@
}
.submenu-sports {
left:--213px;
left:-177px;
}
.submenu-lifestyle {
left:--286px;
left:-254px;
}
.submenu-video {
left:-369px;
left:-329px;
}
.submenu-beauty {
left:-124px;
left:-88px;
}
... ...
... ... @@ -814,7 +814,7 @@
width:295px;
height:176px;
background:url(../assets/images/followusbackground.png) 0 -190px;
margin-top:32px;
margin:32px 0 20px 0;
.title{
@include blockwh(100%,70px);
line-height:90px;
... ...