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 () { // 姒х姵鐖i幐鍥ф倻, 闁剧偓甯存妯瑰瘨 links_1.hover(function () { control(this, false) }, none); links_2.hover(function () { control(this, true) }, none); // 姒х姵鐖g粋璇茬磻鐎佃壈鍩呴弽锟? 閹垹顦茶ぐ鎾冲妞ょ敻娼版妯瑰瘨 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 娣囶喗鏁奸幖婊呭偍, 濞h濮炵拠顓♀枅 var subitem_search = subitem.filter('.search'), subitem_langs = subitem.filter('.langs'); 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.hover(none, function() { timeout = settimeout(function() { prev_item.removeclass('on'); }, 300); }); }()); // 閹兼粎鍌ㄩ幐澶愭尦 (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 () { // 閹懎鍠?閿涘苯顩ч弸婊勭セ鐟欏牆娅掗弨顖涘瘮 placeholder閿涘苯鍨导妯哄帥娴h法鏁ゆ妯款吇閵嗭拷 var input = document.createelement("input"); input.type = "text"; if ("placeholder" in input) return; // 閹懎鍠?閿涘苯顩ч弸婊勭梾閺堝鎹㈡担鏇熺垼缁涘彞濞囬悽锟?placeholder閿涘苯鍨稉宥呬粵娴犺缍嶆径鍕倞閵嗭拷 var inputs = $("*[placeholder]"), val = ""; if (!inputs.length) return; // 閹懎鍠?閿涘苯顕禍搴濈瑝閺€顖涘瘮 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; // }); }()); // 鐠嬪啯鏆f妯哄 (function() { var copyright = $('#copyright'), hei = $('html').height()-$('body').height(); if (hei<=0) return; copyright.find('.g-wrap div').height(37+hei); }()); });