From 7a97c50d03bb3441fa72c96049d4085e752131e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E5=AE=AA?= Date: Mon, 25 May 2015 18:26:24 +0800 Subject: [PATCH] =?UTF-8?q?head=E4=B8=8A=E7=9A=84=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E5=92=8C=E5=AF=BC=E8=88=AA=E5=8A=A8=E7=94=BB=E3=80=82=E3=80=82?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/script.js | 86 +++++++++++++++++++++++++++++++++++++ static/style.css | 9 ++-- theme/templates/layout.html | 13 +++--- 3 files changed, 99 insertions(+), 9 deletions(-) diff --git a/static/script.js b/static/script.js index 2065c1b5bd..2cce9e2f91 100644 --- a/static/script.js +++ b/static/script.js @@ -15,4 +15,90 @@ $(function() { function slideToggleCode(item) { $(item).find('.highlight').slideToggle(150); } + var navFunc={ + navStrArr: [], + init:function (){ + var self=this; + self.navBox = $(".nav"); + self.navBar = self.navBox.find(".bar"); + self.navList = self.navBox.find("ul li"); + for(var i=0;i=urlArr.length-1){ + links+=urlArr[i] + }else{ + links+=urlArr[i]+"/" + } + } + for (var i = 0; i < self.navStrArr.length; i++) { + if(links=="/"){ + self.navNum=0; + break; + } + if ((self.navStrArr[i].indexOf(links)>=0||links.indexOf(self.navStrArr[i])>=0)&&i!==0) { + self.navNum = i; + break; + } + } + }, + search: function (c) { + var self = this; + self.searchBox = c; + self.searchInput = self.searchBox.find("input[type='text']"); + self.searchBtn = self.searchBox.find("button"); + self.searchInput.focus(function (e) { + $(this).addClass("focus"); + self.searchBtn.css("left", self.searchBox.width() + 13); + }); + self.searchInput.blur(function (e) { + if (!self.searchInput.val()) { + self.searchBtn.attr("style", ""); + $(this).removeClass("focus"); + } + }); + self.searchBtn.click(function (e) { + self.searchBox.find("form").submit(); + }) + }, + navBarAnim: function () { + var self = this,delay; + function startBarAnim(num) { + self.navBar.css("left", self.navList.width() * num); + self.navList.eq(num).find("a").addClass("hover"); + } + self.navList.bind("mouseenter", function (e) { + clearTimeout(delay); + var m = e.currentTarget; + self.navList.find("a").removeClass("hover"); + self.navBar.addClass("barAnim").css("left", $(m).width() * $(m).index()) + }); + self.navList.bind("mouseleave", function (e) { + delay = setTimeout(function () { + startBarAnim(self.navNum) + }, 500); + }); + } + }; + navFunc.init() }); diff --git a/static/style.css b/static/style.css index 86f9bdef95..2f6bee366e 100644 --- a/static/style.css +++ b/static/style.css @@ -91,9 +91,9 @@ header { .search input:-ms-input-placeholder { color: #CADCE3; } -.search input:focus { +.search form .focus { padding: 0 20px 0 0; - width: 150px; + /*width: 150px;*/ } .search button { position: absolute; @@ -172,7 +172,10 @@ header { top: 0; left: 0; background: #6EB4E0; - transition: left .3s cubic-bezier(0.075, 0.82, 0.165, 1); + +} +.barAnim{ + transition: left .3s cubic-bezier(0.075, 0.82, 0.165, 1); } .nav-phone-icon { display: none; diff --git a/theme/templates/layout.html b/theme/templates/layout.html index 970aa53f81..0cfaa7d1f8 100644 --- a/theme/templates/layout.html +++ b/theme/templates/layout.html @@ -31,23 +31,24 @@