/* globals */ /** * Clickbus MX widget. * * Customization: * * To customize this widget you can add the following attributes to tag that * will content widget. * * @param {string} data-template-size The available size are: 120, 160, 189, * 222, 250, 300, 290x300, 311x327, 300x455, 300x600, 320, 320x285, 728, * 1059x170 * @param {string} data-template-color Color name to the widget. * The available colors are: gray, yellow. * @param {string} data-header-color Class name to the widget's header. * @param {string} data-submit-color Color name to the widget's submit button. * The available colors are: green, red, aqua-light-blue. * * Only has effect if a theme (data-theme) is not given. * * @param {string} data-campaign-param Campign name * @param {string} data-header-title ÃÆ’Æ’Æ’ÃÆ’¢â‚¬Å¡ÃÆ’Æ’‚ÃÆ’‚¿? * @param {string} data-theme The theme name. The available themes are: * yellow-mustard, purple-blue-and-orange, black-and-orange, orange-and-acqua, * orange-and-beige, full-dark-blue, red, mobilize, ht, red-wine * @param {string} data-custom-class Any class. Only has effect if a theme (data-theme) is given. * @param {string} data-link-site Link toward the page. */ /* * Widget 1.0 * Author: Wender Lima */ !function(e,l,id,s,r,d){ var c=null, v=null, jQ=null, h=e.getElementsByTagName('head')[0], w=e.getElementById(id); var getHostUrl = window.location.host, deployUrl = ''; if ( getHostUrl != 'localhost:8000' ){ deployUrl = '//static2.clickbus.com.br/widget/global/'; } if(w){ if(!e.getElementById(id+s)){ c=e.createElement(l); c.setAttribute('id',id+s); c.setAttribute('rel', 'stylesheet'); c.setAttribute('href','https://s3-sa-east-1.amazonaws.com/static2.clickbus.com.br/widget/bamcaf/vertical/widget-style.css'); c.setAttribute('type', 'text/css'); c.setAttribute('media', 'all'); h.appendChild(c); var templateSize = w.getAttribute('data-template-size') , templateColor = w.getAttribute('data-template-color') , headerColor = w.getAttribute('data-header-color') , headerType = w.getAttribute('data-header-type') , submitColor = w.getAttribute('data-submit-color') , campaignParam = w.getAttribute('data-campaign-param') , headerTitle = w.getAttribute('data-header-title') , theme = w.getAttribute('data-theme') , customClass = w.getAttribute('data-custom-class') , themeClass , imgClickbus = [] , lang = w.getAttribute('data-lang') , linkSite = w.getAttribute('data-link-site') , getCharset = document.charset; // var txtLink = w.innerHTML; if( headerColor === null ){ headerColor = "header-dark-blue"; } if( headerType === null ){ headerColor = "header-road"; } if ( templateSize === null ){ templateSize = '222'; } if ( lang === null ){ lang = 'pt'; } if ( templateColor === null ){ templateColor = 'grey'; } if ( submitColor === null ){ submitColor = 'green'; } if ( theme ){ themeClass = 'wg-clickbus-theme-'+theme; } else { themeClass = ''; } switch ( templateSize ) { case "120": imgClickbus.img_width = '100'; imgClickbus.img_height = '30'; break; case "160": imgClickbus.img_width = '79'; imgClickbus.img_height = '23'; break; case "189": imgClickbus.img_width = '79'; imgClickbus.img_height = '23'; break; case "222": imgClickbus.img_width = '49'; imgClickbus.img_height = '14'; break; case "250": imgClickbus.img_width = '49'; imgClickbus.img_height = '14'; break; case "290x300": imgClickbus.img_width = '90'; imgClickbus.img_height = '29'; break; case "300": imgClickbus.img_width = '67'; imgClickbus.img_height = '20'; break; case "311x327": imgClickbus.img_width = '71'; imgClickbus.img_height = '21'; break; case "300x455": imgClickbus.img_width = '67'; imgClickbus.img_height = '20'; break; case "300x600": imgClickbus.img_width = '76'; imgClickbus.img_height = '22'; break; case "320": imgClickbus.img_width = '67'; imgClickbus.img_height = '20'; break; case "320x285": imgClickbus.img_width = '67'; imgClickbus.img_height = '20'; break; case "728": imgClickbus.img_width = '67'; imgClickbus.img_height = '20'; break; case "960x175": imgClickbus.img_width = '40'; imgClickbus.img_height = '20'; break; case "1056x170": imgClickbus.img_width = '80'; imgClickbus.img_height = '30'; break; } //http://jsfiddle.net/w5kv2dtg/1/ Teste da parte do lang var labels = { 'pt' : { 'header' : 'Compre sua passagem de ônibus', 'lang_class' : 'wg-clickbus-lang-pt', 'originPlace' : 'Origem', 'originPlace_placeholder' : '', 'destinationPlace' : 'Destino', 'destinationPlace_placeholder' : '', 'departureDate' : 'Ida', 'departureDate_placeholder' : 'placeholder="Data de ida"', 'returnDate' : 'Volta(opcional)', 'returnDate_placeholder' : 'placeholder="Data de volta"', 'send_button' : 'Buscar', 'credito_clickbus' : 'Operado por', 'link_site' : 'https://www.clickbus.com.br', 'alt_logo' : 'Compre online suas passagens de ÃÆ’Æ’Æ’ÃÆ’†’ÃÆ’Æ’†ÃÆ’¢â‚¬â„¢ÃÆ’Æ’Æ’ÃÆ’¢â‚¬ ÃÆ’Æ’¢ÃÆ’¢â€šÂ¬ÃÆ’¢â€žÂ¢ÃÆ’Æ’Æ’ÃÆ’†’ÃÆ’Æ’¢ÃÆ’¢â€šÂ¬ÃÆ’…¡ÃÆ’Æ’Æ’ÃÆ’¢â‚¬Å¡ÃÆ’Æ’‚ÃÆ’‚´nibus com a ClickBus' }, 'es' : { 'header' : 'Compra tus boletos de autobús', 'lang_class' : 'wg-clickbus-lang-es', 'originPlace' : 'Origen', 'originPlace_placeholder' : 'placeholder="Origen*"', 'destinationPlace' : 'Destino', 'destinationPlace_placeholder' : 'placeholder="Destino*"', 'departureDate' : 'Salida', 'departureDate_placeholder' : 'placeholder="Salida*"', 'returnDate' : 'Regreso (opcional)', 'returnDate_placeholder' : 'placeholder="Regreso"', 'send_button' : 'Buscar', 'credito_clickbus' : 'Ofrecido por', 'link_site' : linkSite, 'alt_logo' : 'Compra en lÃÆ’Æ’Æ’ÃÆ’†’ÃÆ’Æ’†ÃÆ’¢â‚¬â„¢ÃÆ’Æ’Æ’ÃÆ’¢â‚¬ ÃÆ’Æ’¢ÃÆ’¢â€šÂ¬ÃÆ’¢â€žÂ¢ÃÆ’Æ’Æ’ÃÆ’†’ÃÆ’Æ’¢ÃÆ’¢â€šÂ¬ÃÆ’…¡ÃÆ’Æ’Æ’ÃÆ’¢â‚¬Å¡ÃÆ’Æ’‚ÃÆ’‚­nea tu boleto de autobÃÆ’Æ’Æ’ÃÆ’†’ÃÆ’Æ’†ÃÆ’¢â‚¬â„¢ÃÆ’Æ’Æ’ÃÆ’¢â‚¬ ÃÆ’Æ’¢ÃÆ’¢â€šÂ¬ÃÆ’¢â€žÂ¢ÃÆ’Æ’Æ’ÃÆ’†’ÃÆ’Æ’¢ÃÆ’¢â€šÂ¬ÃÆ’…¡ÃÆ’Æ’Æ’ÃÆ’¢â‚¬Å¡ÃÆ’Æ’‚ÃÆ’‚ºs por ClickBus' }, 'tr' : { 'header' : 'Otobüs Bileti Arama', 'lang_class' : 'wg-clickbus-lang-tr', 'originPlace' : 'Nereden', 'originPlace_placeholder' : '', 'destinationPlace' : 'Nereye', 'destinationPlace_placeholder' : '', 'departureDate' : 'Kalkış tarihi', 'departureDate_placeholder' : '', 'returnDate' : 'Dönüş tarihi', 'returnDate_placeholder' : '', 'send_button' : 'Bilet Ara', 'credito_clickbus' : 'Powered by', 'link_site' : 'http://www.clickbus.com.tr', 'alt_logo' : '' }, 'th' : { 'header' : 'ซื้อตั๋วรถทัวร์ง่ายๆแค่คลิ๊ก', 'lang_class' : 'wg-clickbus-lang-th', 'originPlace' : 'ต้นทาง', 'originPlace_placeholder' : ' placeholder="ต้นทาง"', 'destinationPlace' : 'ปลายทาง', 'destinationPlace_placeholder' : ' placeholder="ปลายทาง"', 'departureDate' : 'เที่ยวไป', 'departureDate_placeholder' : 'placeholder="วันที่เดินทาง"', 'returnDate' : 'เที่ยวกลับ (ถ้ามี)', 'returnDate_placeholder' : 'placeholder="หากมี"', 'send_button' : 'ค้นหา', 'credito_clickbus' : 'Powered by', 'link_site' : 'http://www.clickbus.co.th', 'alt_logo' : 'ซื้อตั๋วรถทัวร์ออนไลน์ที่ ClickBus' }, 'ph' : { 'header' : 'Buy your bus ticket', 'lang_class' : 'wg-clickbus-lang-ph', 'originPlace' : 'From', 'originPlace_placeholder' : '', 'destinationPlace' : 'To', 'destinationPlace_placeholder' : '', 'departureDate' : 'Departure', 'departureDate_placeholder' : '', 'returnDate' : 'Return (optional)', 'returnDate_placeholder' : '', 'send_button' : 'Search', 'credito_clickbus' : 'Powered by', 'link_site' : 'http://www.clickbus.com.ph', 'alt_logo' : 'ClickBus' }, }; var widgetHeader; if ( headerTitle ){ widgetHeader = headerTitle; } else { widgetHeader = labels[lang].header; } } if(!e.getElementById(id+d)){ if ( theme ) { m='

'+ widgetHeader +'

'+ labels[lang].credito_clickbus +' '+labels[lang].alt_logo+'clickbus.com.tr

'; } else { m='

'+ widgetHeader +'

'+ labels[lang].credito_clickbus +' '+labels[lang].alt_logo+'clickbus.com.tr

'; } w.outerHTML=m; } if(!e.getElementById(id+r)){ function inserejQuery(){ jQ=e.createElement('script'); jQ.setAttribute('id','jquery-lib'); jQ.setAttribute('type', 'text/javascript'); jQ.setAttribute('src','https://code.jquery.com/jquery-1.11.3.min.js'); h.appendChild(jQ); } function insertVendor( conflict ){ c=e.createElement('script'); c.setAttribute('id',id+'-vendor'); c.setAttribute('type', 'text/javascript'); if ( conflict ){ console.log('insere o noconflict'); c.setAttribute('src','https://s3-sa-east-1.amazonaws.com/static2.clickbus.com.br/widget/bamcaf/wg-clickbus-vendor.js'); } else { console.log('insere o normal'); c.setAttribute('src','https://s3-sa-east-1.amazonaws.com/static2.clickbus.com.br/widget/bamcaf/wg-clickbus-vendor.js'); } h.appendChild(c); } var noConflict = false; inserejQuery(); setTimeout( function(){ if( e.getElementById('jquery-lib') !== 'null'){ insertVendor( noConflict ); v=e.createElement('script'); v.setAttribute('id',id+s); v.setAttribute('type', 'text/javascript'); v.setAttribute('src','https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.16.0/jquery.validate.min.js'); h.appendChild(v); } var form = e.getElementById('frmBus'); form.originPlace.disabled = false; form.destinationPlace.disabled = false; form.ida.disabled = false; form.volta.disabled = false; form.btnsubmit.disabled = false; console.log('script inserted'); }, 3000); var setaFollowTr = e.querySelector('.wg-clickbus-oferecido a'); var pegaLogoFooter = e.getElementById('logo_clickbus_creditos_footer_widget'); var pegaTextoLogo = e.getElementById('texto_clickbus_widget'); if ( lang == 'tr' ) { setaFollowTr.rel="follow"; pegaLogoFooter.style.display="none"; pegaTextoLogo.style.display="inline-block"; } else { pegaTextoLogo.style.display="none"; pegaLogoFooter.style.display="inline-block"; } } } }(document,'link','widget-clickbus','-css','-script','-div');