if($('#pdstyle').length == 0){ function gorunchat(){ var right='10px'; var top=120; //whatsapp if(whatsapp != undefined && whatsapp != ''){ var tt=whatsapp.replace(/\D/g, ''); console.log(tt) var t1=1; if(tt.indexOf(',') != -1){ t1=tt.split(',').length; } for(var i = 0; i < t1; i++){ var wa=tt.split(',')[i]; //if(top > 1000){ topxy='bottom:'+top+'px;'; top=top+70; //}else{ //topxy='bottom:'+($( window ).height()-top)+'px;'; //} wa=wa.replace(/\(|\)| /g,''); var img; if(typeof whatsappicon != 'undefined'){ //自定義 img=whatsappicon; $('body').append(``) $('body').append(``); }else{ //default img='//imgb.mailmaihk.com/js/whatsapp.png'; $('body').append(``); } } } //instagram if(typeof instagram != 'undefined' && instagram != ''){ var tt=instagram; var t1=1; if(tt.indexOf(',') != -1){ t1=tt.split(',').length; } for(var i = 0; i < t1; i++){ var wa=tt.split(',')[i]; topxy='bottom:'+top+'px;'; top=top+70; var img; //default img='//onlineheungkung.com/image/catalog/1472111213_social-instagram-new-circle.png'; $('body').append(''); } } //fbmess if($('#fb-root').length > 0){ topxy = 'bottom:'+top+'px'; top = top+70; if(typeof fbmessbuttom != 'undefined'){ topxy = 'bottom:'+fbmessbuttom+'px'; } $('body').append(''); topxy = 'bottom:'+top+'px'; top = top+70; if(typeof fbmessbuttom != 'undefined'){ topxy = 'bottom:'+fbmessbuttom+'px'; } $('body').append(''); } } setTimeout(function(){gorunchat();},1500); //add css $('body').append('') //禁止輸入日期只可以選日期及改按鈕大小 if($('.date input[data-format="YYYY-MM-DD"]').length > 0){ $('.date input[data-format="YYYY-MM-DD"]').attr('data-date-format','YYYY-MM-DD'); } $('.date input[data-date-format="YYYY-MM-DD"]').attr("readonly","readonly"); $('.date button').outerHeight($('.date input').outerHeight()); //demo3 //右圖沒有eff if($('.cms_right_banner').length ==1){ $('body').append(''); } //fbmess $('.fb-customerchat').attr('theme_color',''); //pixe add to cart $(document).on('click','#button-cart',function(){ if ($.isFunction(window.fbq)) { fbq('track','AddToCart'); } }); //刪去購物優惠 if($(location).attr('href').indexOf('index.php?route=checkout/success') != -1){ $('#rule_based_banners-48').hide(); } //刪去比較內容 if($(location).attr('href').indexOf('index.php?route=product/compare') != -1){ $('body').append(''); } //demo9cart if($('#cart .dropdown-menu').length > 0){ if($('#cart .dropdown-menu').height()+200 > $(window).height()){ $('body').append(''); } } //cookie if(typeof cookie != 'undefined'){ if(localStorage.getItem("cookie") === null){ $('body').append('
This site uses cookies to optimize your browsing experience. By closing this banner or continuing to browse the site, you are agreeing to our use of cookies. Learn More
'); } } //訂單內容貨品加連結 if($(location).attr('href').indexOf('index.php?route=account/order/info') != -1){ $('a[href*="product_id="]').each(function(){ $(this).parents('tr').find('td:eq(0)').html(''+$(this).parents('tr').find('td:eq(0)').text()+'') }); } //取消電字報 if($('a[href*="newsletter"]').length > 0){ //註刪時取消 $('input[name="newsletter"]').parents('fieldset').hide(); if($('a[href*="newsletter"]').parent()[0].nodeName == "LI"){ $('a[href*="newsletter"]').parent().hide(); }else{ $('a[href*="newsletter"]').hide(); } } //會員註冊時取消地址 if(typeof hideaddress != 'undefined' && $(location).attr('href').indexOf('index.php?route=account/register') != -1){ $('#address input').each(function(){ $(this).val(hideaddress) $(this).parents('.form-group').hide() }); } //url改變語言 $(document).on('mousedown','#language a',function(){ var language=$(this).attr('href').replace('#',''); if($(this).attr('onclick') == undefined){ if($('#language input[name="redirect"]').val().indexOf('&language=') == -1){ $('#language input[name="redirect"]').val($('#language input[name="redirect"]').val()+'&language='+language); }else{ $('#language input[name="redirect"]').val($('#language input[name="redirect"]').val().split('&language=')[0]+'&language='+language); } } }); if($(location).attr('search').indexOf('language=') != -1 ){ var language=''; if($('#top-language span:eq(0) img').attr('alt') != undefined && $('#top-language span:eq(0) img').attr('alt') != ''){ language=$('#top-language span:eq(0) img').attr('alt'); } if($('#top-language span:eq(0)').text().trim().replace(/\s/g,'').split(':')[1] != undefined && $('#top-language span:eq(0)').text().trim().replace(/\s/g,'').split(':')[1] != ''){ language=$('#top-language span:eq(0)').text().trim().replace(/\s/g,'').split(':')[1]; } if($('#language button') != undefined && $('#language button').text().trim() != ''){ language=$('#language button').text().trim(); } if($('#language button img').attr('alt') != undefined && $('#language button img').attr('alt') != ''){ language=$('#language button img').attr('alt'); } language=$('#language a:contains('+language+')').attr('href'); var code=$(location).attr('search').split('language=')[1]; if(code.indexOf('&') != -1){ code=code.split('&')[0]; } if(language != undefined){ language=language.replace('#',''); console.log(language,code) if(language != code){ $.post('index.php?route=common/language/language',{code:code},function(data){ console.log('ok') //location.reload() }) } } } if($('.cart').length == 1){ $('.img-thumbnail').css('maxWidth','100px'); } if($(location).attr('href').indexOf('index.php?route=product/product') != -1 || $(location).attr('href').indexOf('index.php?route=product%2Fproduct') != -1){ //20210123 //把圖片轉去https $('img').each(function(){ $(this).attr('src',$(this).attr('src').replace('http://','https://')); }) $('.thumbnail').find('img').attr('src',$('.thumbnail').find('img').attr('src').replace('////','//')); $('body').append('') } //取消立即結算/description $('body').append(''); $('body').append(''); //購物車 if($(location).attr('href').indexOf('index.php?route=checkout/cart') != -1){ $('a.accordion-toggle[href="#collapse-shipping"]').parents('.panel').hide(); $('body').append(` `); } //大圖取消image.php if($('#tmzoom').length == 1){ $('#tmzoom').attr('src',$('#tmzoom').attr('src').split('image=')[1]); } //更新title if((window.location.href).indexOf('product/category&') != -1){ $('title').text($('#title-page,.page-title').text()) } //圖片尺寸 $( document ).ready(function(){ if(typeof resizeimg == 'undefined'){ //webp to gif $('img[src*=".webp"]').each(function(){ //$(this).attr('src',$(this).attr('src').replace('.webp','.gif')); }) $('a[href*=".webp"]').each(function(){ //$(this).attr('href',$(this).attr('href').replace('.webp','.gif')); }); var ih=1.1; if(typeof backgroundsize == 'undefined'){ var bs='background-size: cover;' }else{ var bs='background-size: contain;' } //把所有圖片改為背景圖及解決webp圖 function run(){ var i=0; var v=$('img[src*="image=http://"]').length; var imgd=''; imgd='a[href*="?route=product/product&"] img[src*="http"]:not([src*="1170x"]):not([src*="1140x"]),img[src*="image=http://"]'; //demo22改本地圖片 if(typeof loimgresize == 'undefined'){ }else{ imgd='a[href*="?route=product/product&"] img[src*="http"]:not([src*="1170x"]):not([src*="1140x"])'; } $(imgd).each(function(){ if($(this).parents('.imagezoom').length == 0 && $(this).attr('alt').indexOf('slider-') != 0){ if($(this).parents('.dropdown-menu').css('display') == 'none'){ v=v-1; } if($(this).width() > 0 && $(this).height() > 0 && $(this).width() < 1000 && $(this).height() < 1000){ fun($(this)); }else{ i=1; } } }); if( v > 0){ setTimeout(function(){ if(i == 1){ //console.log($(this).attr('src')) run(); } },100); } } function fun(_this){ var img = _this.attr('src'); if(_this.attr('src').indexOf('image=http:') != -1){ img = _this.attr('src').split('image=http:')[1]; } var w=_this.width(); var h=_this.height(); //上傳圖片 if(img.indexOf('-') != -1 && img.indexOf('x') != -1){ w=img.split('-')[img.split('-').length-1].split('.')[0].split('x')[0]; h=img.split('-')[img.split('-').length-1].split('.')[0].split('x')[1]; } if(_this.attr('src').indexOf('width=') != -1){ if(_this.attr('src').split('width=')[1].indexOf('&') != -1){ w=_this.attr('src').split('width=')[1].split('&')[0]; } } if(_this.attr('src').indexOf('height=') != -1){ if(_this.attr('src').split('height=')[1].indexOf('&') != -1){ h=_this.attr('src').split('height=')[1].split('&')[0]; } } //console.log('w1:'+w) var parent_w = _this.parent().width(); var parent_h = _this.parent().height(); //console.log('parent'+parent_w) if(parent_w == 0){ parent_w = _this.parent().parent().width(); parent_h = _this.parent().parent().height(); } //console.log('pw:'+parent_w) if(w > parent_w && parent_w > 200){ w = parent_w; //h = parent_h; } if(w <= 50){ w='auto'; h='auto'; } //console.log(_this.attr('src')) //console.log('w2:'+w) //console.log('h2:'+h) if($(location).attr('href').indexOf('index.php?route=product/product') == -1){ if(typeof resizeimgheight == 'undefined'){ }else{ h=w; } } if($(location).attr('href').indexOf('index.php?route=product/product') != -1 || _this.attr('src').indexOf('onlineheungkng.com') == -1 ){ _this.attr('style',` height:${h}px; width:${w}px; background-image:url("${img.replace('.webp','.gif')}"),url("${img}"); ${bs} background-position: center; background-repeat: no-repeat;`); }else{ _this.attr('style',` height:${h}px; width:'${w}px; background-image:url("//img.mailmaihk.com/imgs/${img.split('/')[img.split('/').length-1].replace('.','_thumb.')}"),url("${img.replace('.webp','.gif')}"),url("${img}"); ${bs} background-position: center; background-repeat: no-repeat;`); } _this.attr('src','data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAF0lEQVQImWP8//8/AzpgwhChUJCBgQEANlADB3ZN4FUAAAAASUVORK5CYII='); setTimeout(function(){ //用高因為好多細圖都會長方形濶不足100 if(_this.height() > 100 ){ //console.log(_this.height(),_this.width()) if(_this.height() > (_this.width()*1.4)){ _this.css('height',_this.width()*1.4); _this.css('width',_this.width()); } } if(_this.height() > _this.css('maxWidth').replace('px','')*1.4){ _this.css('maxHeight',_this.css('maxWidth')*1.4); } if(_this.height() < 10 || _this.width() < 10){ if(w > 100){ _this.css('height',h); _this.css('width',w); }else{ if(parent_w > 100){ _this.css('height',parent_w); _this.css('width',parent_w); }else{ _this.css('height','200px'); _this.css('width','200px'); } } } //圖片大出父框改尺寸 if(_this.parent().width() > 0){ if(_this.width() > _this.parent().width()){ _this.width(_this.parent().width()) _this.height(_this.parent().width()) } } if($(location).attr('href').indexOf('index.php?route=product/product') == -1){ //console.log(resizeimgheight) if(typeof resizeimgheight == 'undefined'){ }else{ _this.css('height',_this.width()*resizeimgheight); } } if((location.href).indexOf('account/wishlist') != -1){ _this.width(100); _this.height(100); } },500); /* if((_this.height() * 1.2) > _this.width()){ _this.css('height',_this.width()); _this.css('width',_this.width()); } if(_this.width() < 100){ _this.css('height',100); _this.css('width',100); } if(_this.height() > _this.parent().width()*1.2 && _this.parent().width() > 120){ _this.css('height',_this.parent().width()); _this.css('width',_this.parent().width()); } */ _this.css('margin','auto'); } if(typeof notimgresize == 'undefined'){ }else{ ih=1; bs='background-size: 100%;' } if(typeof stopimgresize == 'undefined'){ run(); } //setTimeout(function(){ //還原圖片放大 //$('.imagezoom').find('img').attr('src',$('.imagezoom').attr('href')); //},1000) } //按下方格或列表改圖大小 $(document).on('click','.fa-th-list,.fa-th',function(){ $('.image img').each(function(){ $(this).css('height',$(this).width()*1.2+'px'); }) }); $(document).on('click','#cart-tt',function(){ $('#cart').find('img').each(function(){ $(this).attr('src',$(this).attr('src').split('&image=')[1]); }) }); }); }