var win = $(window), nav_on = null; $(function () { // 瀵艰埅鏍忔帶鍒? (function () { var nav = $('#nav'), shop = $('#shop'), // search_box = shop.find('#searchbox'), // search_btn = shop.find('.btn-search')[0], lis = nav.children(), lis_1 = lis.filter(':not(.more)'), lis_2 = lis.filter('.more'), links = lis.children(), links_1 = lis_1.children(), links_2 = lis_2.children(), subnav = $('#subnav'), subitem = $('#subnav').find('.item'), prev_item = $(), spans = links.children(), offs = spans.filter('.off'), ons = spans.filter('.on'), sbs = spans.filter('.slideblock'), hei = links.eq(0).height(), len = lis.length, // 璁板綍褰撳墠 link_page = null, link_curr = null, timeout = -1; // 鍒濆鍖栧綋鍓嶉摼鎺? href = location.href.replace(/[_\d]{1,2}\./, '.'); // 闈欐€侀〉闈㈢敤 // href = location.href, // 绋嬪簭鐢? for (var i = 0; i < len; i++) { link_page = links.eq(i); if (href.indexof(link_page.attr('href').replace(/(?:_\d)?\..*/, '')) > 0) { // 闈欐€侀〉闈㈢敤 // if (href.indexof(link_page.attr('href').replace(/(?:_\d)?\..*/, '')) > 0) { // 绋嬪簭鐢? control(nav_on = link_curr = link_page = link_page[0], false); delete i; break; } } links_2.each(function (idx) { if (this === nav_on) return; this.setattribute('idx', idx); }); if (i === len) { if (href.indexof('/user') >= 0) { control(nav_on = link_curr = link_page = links.eq(5)[0], false); } else { control(nav_on = link_curr = link_page = links.eq(0)[0], false); } } win.on('load', function () { // 榧犳爣鎸囧悜, 閾炬帴楂樹寒 links_1.hover(function () { control(this, false) }, none); links_2.hover(function () { control(this, true) }, none); // 榧犳爣绂诲紑瀵艰埅鏍? 鎭㈠褰撳墠椤甸潰楂樹寒 nav.hover(none, function () { timeout = settimeout(function () { control(link_page, true); }, 10); }); subnav.hover(function () { cleartimeout(timeout); }, function () { control(link_page, true); }); }); function control(elem, flag, idx) { // link_curr.classname = ""; // elem.classname = "on"; link_curr = elem; prev_item.removeclass('on'); if (flag) { idx = parseint(elem.getattribute('idx')); prev_item = subitem.eq(idx).addclass('on'); // search_box.hide(); // search_btn.classname = "btn-search"; } } function none() { } // 2015.06.09 淇敼鎼滅储, 娣诲姞璇█ var subitem_search = subitem.filter('.search'), subitem_langs = subitem.filter('.langs'); subitem_nwmenu = subitem.filter('.nwmenu'); shop.find('.btn-search').hover(function () { prev_item.removeclass('on'); prev_item = subitem_search.addclass('on'); }, none); shop.find('.btn-lang').hover(function () { prev_item.removeclass('on'); prev_item = subitem_langs.addclass('on'); }, none); shop.find('.header-nwbtn').hover(function () { prev_item.removeclass('on'); prev_item = subitem_nwmenu.addclass('on'); }, none); shop.hover(none, function () { timeout = settimeout(function () { prev_item.removeclass('on'); }, 300); }); subitem_nwmenu.on('mouseleave',function(){ prev_item.removeclass('on'); }) }()); // 鎼滅储鎸夐挳 (function () { var sup = $('#header'), btn = sup.find('.btn-search'), box = sup.find('#searchbox'), timeout = -1, delay = 1000; btn.hover(open, autofade); box.on('focus', function () { cleartimeout(timeout); }).on('blur', function () { autofade(); }); function open() { cleartimeout(timeout); btn.addclass('on'); box.stop(false, true).fadein(300); } function close() { btn.removeclass('on'); box.stop(false, true).fadeout(300); } function autofade() { timeout = settimeout(function () { close(); }, delay); } }()); // placeholder 澶勭悊 (function () { // 鎯呭喌1锛屽鏋滄祻瑙堝櫒鏀寔 placeholder锛屽垯浼樺厛浣跨敤榛樿銆? var input = document.createelement("input"); input.type = "text"; if ("placeholder" in input) return; // 鎯呭喌2锛屽鏋滄病鏈変换浣曟爣绛句娇鐢?placeholder锛屽垯涓嶅仛浠讳綍澶勭悊銆? var inputs = $("*[placeholder]"), val = ""; if (!inputs.length) return; // 鎯呭喌3锛屽浜庝笉鏀寔 placeholder 灞炴€х殑鍏冪礌杩涜棰勫姞杞藉拰浜嬩欢鎸傝浇銆? inputs .each(function () { input = $(this); input.val(input.attr("placeholder")); }) .on("focus", focus) .on("blur", blur) .on("change", change); // 澶勭悊鍑芥暟 function focus() { input = $(this); val = input.val(); if (val && (val !== input.attr('placeholder'))) return; else input.val(""); } function blur() { // input.val(input.attr("placeholder")); val = input.val(); if (val && (val !== input.attr('placeholder'))) { return; } else { input.val(input.attr("placeholder")); } } function change() { if (input.val()) { input.off("focus").off("blur"); } else { input.on("focus", focus).on("blur", blur); } } })(); // 娉曞緥澹版槑 & 缃戠珯鍦板浘 鍞ゅ嚭 (function () { var copyright = $('#copyright'), btn_legal = copyright.find('.legal'), btn_map = copyright.find('.sitemap'), mask = $('#mask'), wraps = mask.find('.wrap'), legal = wraps.filter('#legal'), map = wraps.filter('#sitemap'), curr = $(), body = $(document.body), m_left = (win.width() - body.width()) / 2; win.on('resize', function () { m_left = (win.width() - body.width()) / 2; body.css('margin-left', m_left); }); btn_legal.on('click', function () { open(legal); }); btn_map.on('click', function () { open(map); }); mask.on('click', close); function open(elem) { mask.show() curr = elem.animate({ 'right': 0 }, 189); body.stop().animate({ 'margin-left': m_left - 378 }, 189); } function close() { curr.stop().animate({ 'right': -378 }, 189, function () { mask.hide(); }); body.stop().animate({ 'margin-left': m_left }, 189); } // wraps.on('click', function (e) { // if (e && e.stoppropagation) { // e.stoppropagation(); // } else window.event.cancelbubble = true; // // return false; // }); }()); // 璋冩暣楂樺害 (function () { var copyright = $('#copyright'), hei = $('html').height() - $('body').height(); if (hei <= 0) return; copyright.find('.g-wrap div').height(37 + hei); }()); });