UNPKG

fd-gulp-convert-encoding

Version:

convert file to assigned charset

281 lines (234 loc) 8.37 kB
/** * ����Ƶ������ͷ�� * @author terence.wangt * date:2012.03.12 */ /*!!cmd:compress=true*/ /*!!cmd:jsCompressOpt=["--disable-optimizations"]*/ !(function($){ var Sandbox, iPageConfig, SU = Searchweb.Utility, configs = { searchFormId: '#s_search_form', end:0 }, self; function Header(sb) { Sandbox = sb; return Header; } $.extend(Header,{ init:function(cfg){ self = this; self.config = $.extend(true, {}, configs, cfg); iPageConfig = this.config.global ? this.config.global : window.iPageConfig; this.categoryChangeInit(); this.searchTabChangeSubmit(); this.searchTraceOnsubmit(); this.addPlaceholder(); }, /** * ��Ʒ��Ŀѡ�� * @param {Object} config ҳ������ò��� */ categoryChangeInit: function() { if ($('#searchbar-category').length == 0) return; var root = $('#searchbar-category'), a = root.find('a'), focus = $(a[0]), other = $(a[1]), map = {}, //�����е�ֵ,����category��keyword tr, tipsicon = $('#searchbar-category-newicon'), tipsmsg = $('#searchbar-category-tips'); root.find('.searchbar-category-list').bind('mouseenter', function(){ clearTimeout(tr); root.addClass('hover'); }); root.find('.searchbar-category-list').bind('mouseleave', function(){ tr = setTimeout(function() { root.removeClass('hover'); }, 0); }); $(self.config.searchFormId + ' input').each(function(index, input) { map[input.name] = input; }); other.bind('click',function(e) { e.preventDefault(); root.removeClass('hover'); var temp = focus.html(), tempClick = focus.attr('onmousedown'); focus.html(other.html()); other.html(temp); focus.attr('onmousedown', other.attr('onmousedown')); other.attr('onmousedown', tempClick); if (temp != '������Ŀ') { if (map.categoryId) map.categoryId.value = ''; if (map.categoryStyle) map.categoryStyle.value = ''; } else { if (map.categoryId) map.categoryId.value = root.attr('categoryid'); if (map.categoryStyle) map.categoryStyle.value = 'false'; } }); //ɶ��������ʾtipsmsg,Ϊ��ֹ�û����cookie����ˢ��ҳ��,�����ж�cookie�IJ��������¼������� $('#q').bind('focus',function() { if (map.categoryId.value) { var alicnweb = unescape(SU.getCookie('alicnweb')); if (!alicnweb || !/[\|^]categorytips=closed[\|$]/.test(alicnweb)) { //�����ڴ�cookie���߲�����categorytips=closed tipsmsg.show(); } } }); $('#searchbar-category-closetips').bind('click', function() { tipsmsg.hide(); var alicnweb = unescape(SU.getCookie('alicnweb')); if (!alicnweb || !/(\|^)categorytips=closed(\|$)/.test(alicnweb)) { SU.addCookie('alicnweb', alicnweb + 'categorytips=closed|', '.alibaba.com'); }; }); }, /** *Tab�л�ʱ���������ύ */ searchTabChangeSubmit: function() { if ($('#s_searchtabList').length == 0) return; var self = this; var tabs =$('li a', '#s_searchtabList'); tabs.bind('click', function(e) { if(iPageConfig.keywords==''){ return ; } e.preventDefault(); //�ڲ�ƷƵ������Ŀ������Ҫ���⴦�� if ($('#searchbar-category')) { var categoryId = $('input[name=categoryId]', self.config.searchFormId); categoryId.val(''); } var form = $(self.config.searchFormId); var tabAction = $(this).attr('action'); form.attr('action', tabAction); var searchType = $(this).parents("li:first").attr('data-type'); self.checkNullInput(searchType); form.submit(); }); tabs.bind('focus',function(e) { this.blur(); }); }, /** *�ύʱ��� */ searchTraceOnsubmit: function() { var self = this; var form = $(this.config.searchFormId); form.bind('submit', function(e) { self.checkNullInput(); self.checkInputScaleBuying(e); self.disableInput(); if (iPageConfig.searchType == 'news') { var options = $('input', '#select-option'); if (options[0].checked == true) { SU.aliclick(this, '?searchtrace=info_top_allinfo'); } else if (options[1].checked == true) { SU.aliclick(this, '?searchtrace=info_top_picinfo'); } } }); }, disableInput:function(){ var self = this; $('input[type=hidden]', self.config.searchFormId).each(function(index, input) { if($(input).val() === ""){ $(input).attr('disabled', 'disabled'); } }); }, checkInputScaleBuying:function(e){ var element = $('#q'),placeholder = element.attr("placeholder"),inputValue=element.val(); if (!placeholder) return; if($.trim(inputValue) == ''|| inputValue==placeholder){ e.preventDefault(); var aElem=document.createElement('a'); aElem.target='_blank'; aElem.href=element.attr("linkurl"); if(element.attr("point")){ SU.aliclick(this, '?searchtrace='+element.attr("point")); } document.body.appendChild(aElem); aElem.click(); document.body.removeChild(aElem); } }, /* 4�²ɹ��� ������placeholder �������� */ addPlaceholder: function() { var element = $('#q'),placeholder = element.attr("placeholder"); //�������Ԫ�ص�html��ǩ���Ƿ���placeholder����,���û�У��˺�����ִ�� if (!placeholder) return; this.addExposureClick(element); //�������Ԫ���Ƿ�֧��HTML5��placeholder����,�����֧�֣����������³���ģ��placeholder���� if (element.length >0 && !("placeholder" in document.createElement("input"))) { //��ǰ�ı��ؼ��Ƿ���id, û���򴴽� var idLabel = element.attr('id'); if (!idLabel) { idLabel = "placeholder_" + new Date().getTime(); element.attr('id', idLabel); } //����labelԪ�� var eleLabel = document.createElement("label"); eleLabel.htmlFor = idLabel; eleLabel.className='label-placeholder'; eleLabel.style.left=element.position().left+'px'; //���봴����labelԪ�ؽڵ� element.before(eleLabel); //�¼�ע�� element.bind('focus',function() { eleLabel.innerHTML = ""; }); element.bind('blur',function() { if (element.val() == "") { eleLabel.innerHTML = placeholder; } }); //placeholder������ʽ��ʼ�� if (element.val() == "") { eleLabel.innerHTML = placeholder; } } }, addExposureClick:function(element){ if(element.val()=='' && element.attr("foodtag")=="true"){ SU.exposureClick('bitchina_searchbar'); } element.bind('blur',function() { if (this.value === "" && element.attr("foodtag")=="true") { SU.exposureClick('bitchina_searchbar'); } }); }, checkNullInput: function(searchType) { var categoryId = $('input[name=categoryId]', this.config.searchFormId), cValue = ''; if (categoryId) { cValue = categoryId.val(); } if ($.trim($('#q').val()) == '' && cValue == '') { //�ؼ���Ϊ��,��ĿΪ�� if (!searchType) searchType = iPageConfig.searchType; var actionUrl = ''; if (searchType == 'saleoffer') actionUrl = 'http://page.1688.com/buy/index.html'; else if (searchType == 'company') actionUrl = 'http://page.1688.com/cp/cp1.html'; else if (searchType == 'buyoffer') actionUrl = 'http://page.1688.com/cp/cp8.html'; else if (searchType == 'news') actionUrl = 'http://info.1688.com/'; else if (searchType == 'wiki') actionUrl = 'http://baike.1688.com/'; else if (searchType == 'forum') actionUrl = 'http://club.1688.com/'; else if (searchType == 'blog') actionUrl = 'http://blog.1688.com/'; $(this.config.searchFormId).attr('action', actionUrl); } }, end:0 }); Searchweb.Business.Header = Header; AppCore.register("sw_mod_header", Searchweb.Business.Header); })(jQuery);