var def_shareurl = location.href; var def_sharetitle = document.title; /*-----------------------------------------------* *fb share *-----------------------------------------------*/ function social_share(type, shareurl, sharetitle) { if(typeof(shareurl) == "undefined") var shareurl = def_shareurl; if(typeof(sharetitle) == "undefined") var sharetitle = def_sharetitle; var share_url = ""; var is_open = true; switch (type) { case "fb": var share_url = 'http://www.facebook.com/sharer.php?u='+encodeURIComponent(shareurl)+'&t='+encodeURIComponent(sharetitle); break; case "twitter": var share_url = 'http://twitter.com/intent/tweet?source='+encodeURIComponent(shareurl)+'&text='+encodeURIComponent(sharetitle)+':%20'+encodeURIComponent(shareurl); break; case "google": var share_url = 'https://plus.google.com/share?url='+encodeURIComponent(shareurl); break; case "pinterest": var share_url = 'http://pinterest.com/pin/create/button/?url='+encodeURIComponent(shareurl)+'&description='+encodeURIComponent(sharetitle); break; case "linkedin": var share_url = 'http://www.linkedin.com/shareArticle?mini=true&url='+encodeURIComponent(shareurl)+'&title='+encodeURIComponent(sharetitle)+'&source='+encodeURIComponent(shareurl); break; case "email": var share_url = 'mailto:?subject='+encodeURIComponent(sharetitle)+'&body='+encodeURIComponent(sharetitle)+':%20'+encodeURIComponent(shareurl); break; } if(is_open && share_url) { window.open(share_url, 'sharer', 'toolbar=0,status=0,width=626,height=436'); return true; } return false; } // FB function fb_share(shareurl,sharetitle) { if(typeof(shareurl) == "undefined") var shareurl = def_shareurl; if(typeof(sharetitle) == "undefined") var sharetitle = def_sharetitle; window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(shareurl)+'&t='+encodeURIComponent(sharetitle), 'sharer', 'toolbar=0,status=0,width=626,height=436'); return false; } //Twitter function twitter_share(shareurl,sharetitle) { if(typeof(shareurl) == "undefined") var shareurl = def_shareurl; if(typeof(sharetitle) == "undefined") var sharetitle = def_sharetitle; window.open('http://twitter.com/intent/tweet?source='+encodeURIComponent(shareurl)+'&text='+encodeURIComponent(sharetitle)+':%20'+encodeURIComponent(shareurl)); return false; } //Google+ function google_share(shareurl,sharetitle) { if(typeof(shareurl) == "undefined") var shareurl = def_shareurl; if(typeof(sharetitle) == "undefined") var sharetitle = def_sharetitle; window.open('https://plus.google.com/share?url='+encodeURIComponent(shareurl)); return false; } //pinterest function pinterest_share(shareurl,sharetitle) { if(typeof(shareurl) == "undefined") var shareurl = def_shareurl; if(typeof(sharetitle) == "undefined") var sharetitle = def_sharetitle; window.open('http://pinterest.com/pin/create/button/?url='+encodeURIComponent(shareurl)+'&description='+encodeURIComponent(sharetitle)); return false; } //linkedin function linkedin_share(shareurl,sharetitle) { if(typeof(shareurl) == "undefined") var shareurl = def_shareurl; if(typeof(sharetitle) == "undefined") var sharetitle = def_sharetitle; window.open('http://www.linkedin.com/shareArticle?mini=true&url='+encodeURIComponent(shareurl)+'&title='+encodeURIComponent(sharetitle)+'&source='+encodeURIComponent(shareurl)); return false; } // Email function email_share(shareurl,sharetitle) { if(typeof(shareurl) == "undefined") var shareurl = def_shareurl; if(typeof(sharetitle) == "undefined") var sharetitle = def_sharetitle; window.open('mailto:?subject='+encodeURIComponent(sharetitle)+'&body='+encodeURIComponent(sharetitle)+':%20'+encodeURIComponent(shareurl)); return false; } function plurk_share(shareurl,sharetitle) { if(typeof(shareurl) == "undefined") var shareurl = def_shareurl; if(typeof(sharetitle) == "undefined") var sharetitle = def_sharetitle; window.open('http://www.plurk.com/?qualifier=shares&status='+encodeURIComponent(shareurl+' ('+sharetitle+')'), 'sharer', 'toolbar=0,status=0,width=626,height=436'); return false; } function show_thumb() { $('.sort > a').unbind("click"); $('.sort > a').click(function(){ if($(this).attr("class") == "iconGrid") { $(this).siblings().removeClass(); $(this).siblings().addClass("iconList"); $(this).removeClass(); $(this).addClass("iconGridOn"); $("#prod_layout").removeClass("productList"); $("#prod_layout").addClass("productGrid"); $.cookie("swap", "grid", { expires: 3 }); }else if($(this).attr("class") == "iconList") { $(this).siblings().removeClass(); $(this).siblings().addClass("iconGrid"); $(this).removeClass(); $(this).addClass("iconListOn"); $("#prod_layout").removeClass("productGrid"); $("#prod_layout").addClass("productList"); $.cookie("swap", "list", { expires: 3 }); } }); } function show_pthumb() { $('.psort > a').unbind("click"); $('.psort > a').click(function(){ if($(this).attr("class") == "iconGrid") { $(this).siblings().removeClass(); $(this).siblings().addClass("iconList"); $(this).removeClass(); $(this).addClass("iconGridOn"); $("#prod_layout").removeClass("productList"); $("#prod_layout").addClass("productGrid"); $.cookie("pswap", "grid", { expires: 3 }); }else if($(this).attr("class") == "iconList") { $(this).siblings().removeClass(); $(this).siblings().addClass("iconGrid"); $(this).removeClass(); $(this).addClass("iconListOn"); $("#prod_layout").removeClass("productGrid"); $("#prod_layout").addClass("productList"); $.cookie("pswap", "list", { expires: 3 }); } }); } function show_tree() { $('.colSide > .sideCate > li > span > .tree').unbind("click"); $(".colSide > .sideCate > li > span > .tree").on( "click", function() { if($(this).hasClass('active')) { $("ul.on").removeClass("on").slideUp("slow"); $(this).removeClass("active"); $(this).parent().parent().removeClass("active"); $(this).parent().parent().siblings().removeClass("active"); }else{ $("ul.on").removeClass("on").slideUp("slow"); $(this).parent().next("ul").addClass("on").slideDown("slow"); $(".colSide > .sideCate > li > span > .tree").removeClass("active"); $(this).addClass("active"); $(this).parent().parent().addClass("active"); $(this).parent().parent().siblings(".active").removeClass("active"); } }); } function show_tree2() { $('.colSide > .sideCate span .tree').unbind("click"); $(".colSide > .sideCate span .tree").on("click", function() { if($(this).hasClass('active')) { $(this).parent().next("ul").removeClass("on").slideUp("slow"); $(this).parent().parent().removeClass("active"); $(this).removeClass("active"); /* $("ul.on").removeClass("on").slideUp("slow"); $(this).removeClass("active"); $(this).parent().parent().removeClass("active"); $(this).parent().parent().siblings().removeClass("active"); */ }else{ $(this).parent().next("ul").addClass("on").slideDown("slow"); $(this).addClass("active"); $(this).parent().parent().addClass("active"); //$(this).parents("span a.tree").addClass("active"); /* $("ul.on").removeClass("on").slideUp("slow"); $(this).parent().next("ul").addClass("on").slideDown("slow"); $(".colSide > .sideCate span a.tree").removeClass("active"); $(this).addClass("active"); $(this).parent().parent().addClass("active"); $(this).parent().parent().siblings(".active").removeClass("active"); */ } }); } function tree_click(id) { $("#c-"+id+" > span > a.tree").click(); if($("#c-"+id+" > a.mm-subopen").length>0) { $("#c-"+id+" > a.mm-subopen").click(); } } /** 主選單的下拉子選單 **/ function show_flag() { $('.lag>span').hover(function(){ // 先找到 span 中的子選單 var _this = $(this), _subnav = _this.children('ul'); // 變更目前母選項的背景顏色 // 同時顯示子選單(如果有的話) _this.css('backgroundColor', '#025'); _subnav.css('display', 'block'); } , function(){ // 變更目前母選項的背景顏色 // 同時隱藏子選單(如果有的話) // 也可以把整句拆成上面的寫法 $(this).css('backgroundColor', '').children('ul').css('display', 'none'); }); // 取消超連結的虛線框 $('a').focus(function(){ this.blur(); }); } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i0 && n<=5 ? n : 2; s = parseFloat((s+"").replace(/[^\d\.-]/g,"")).toFixed(n)+""; var l = s.split(".")[0].split("").reverse(), r = s.split(".")[1]; t = ""; for (i = 0;i100) $("#gotop").fadeIn(1000);//以1秒的間隔漸顯id=gotop的元素 else $("#gotop").fadeOut(1000);//以1秒的間隔漸隱id=gotop的元素 }); }; function init_top() { //點擊回到頂部的元素 $("#gotop").click(function(e) { //以1秒的間隔返回頂部 //$('body,html').animate({scrollTop:0},1000); var $body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body'); $body.animate({ scrollTop: $("body").offset().top //.container }, 1000); }); $("#gotop").mouseover(function(e) { $(this).css("background","url(/assets/images/backtop.png) no-repeat 0px 0px"); }); $("#gotop").mouseout(function(e) { $(this).css("background","url(/assets/images/backtop.png) no-repeat -70px 0px"); }); goTop();//實現回到頂部元素的漸顯與漸隱 } function show_cart_num() { if ($(".cart_cnt").length > 0) { var url = "/index.php?s=shop&c=cart&a=cartcnt&isajax=t"; $.get(url, function(res){ //console.log(res); $('.cart_cnt').text(res); }); } } //add by hank 2016.6.1 for get media width function get_media_width(){ var e = window, a = 'inner'; if (!('innerWidth' in window )) { a = 'client'; e = document.documentElement || document.body; } //return { width : e[ a+'Width' ] , height : e[ a+'Height' ] }; //var mediaW = e[ a+'Width' ] ; return e[ a+'Width' ] ; } function get_media_height(){ var e = window, a = 'inner'; if (!('innerHeight' in window )) { a = 'client'; e = document.documentElement || document.body; } //return { width : e[ a+'Width' ] , height : e[ a+'Height' ] }; //var mediaW = e[ a+'Width' ] ; console.log(e[ a+'Height' ]); return e[ a+'Height' ] ; } /*----------------------------------------------- * init *-----------------------------------------------*/ $(function(){ //show_flag(); show_cart_num(); if ($("#a_iframe").length > 0) { $("#a_iframe").fancybox({ 'width' : '80%', 'height' : '80%', 'autoScale' : false, 'transitionIn' : 'none', 'transitionOut' : 'none', 'type' : 'iframe' }); } if ($("a[rel^='prettyPhoto']").length > 0) { $("a[rel^='prettyPhoto']").prettyPhoto({ iframe_markup: '
', social_tools: '' }); } if($('.lightbox a').length > 0 ) { $('.lightbox a').fancybox({ prevEffect : 'none', nextEffect : 'none' }); } if($("a[rel=img_group]").length > 0) { $("a[rel=img_group]").fancybox({ 'transitionIn' : 'none', 'transitionOut' : 'none', 'titlePosition' : 'over', 'titleFormat' : function(title, currentArray, currentIndex, currentOpts) { return 'Image ' + (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title + ''; } }); } if($('.various').length > 0 ) { $('.various').fancybox({ prevEffect : 'none', nextEffect : 'none' }); } if($('.l_iframe').length > 0 ) { $(".l_iframe").fancybox({ 'width' : '30%', 'height' : '30%', //Add by ben 2016.12.28 for 國揚軸承line帳號語法 'minWidth' : '260', 'autoScale' : false, 'transitionIn' : 'none', 'transitionOut' : 'none', 'type' : 'iframe' }); } /* if($('.video').length > 0 ) { $(".video").click(function() { $.fancybox({ 'padding' : 0, 'autoScale' : false, 'transitionIn' : 'none', 'transitionOut' : 'none', 'width' : 640, 'height' : 385, 'href' : href.replace(new RegExp("watch\\?v=", "i"), 'v/'), 'type' : 'swf', 'swf' : { 'wmode' : 'transparent', 'allowfullscreen' : 'true' } }); return false; }); } */ //-- 判斷連結的內容,並依內容在連結前加上相對應的圖片 -- //$('').appendTo($('#tabs a[href$=".pdf"]')); //$('a[href$=".pdf"]').before(' '); /* $('.tabs a[href$=".mp3"]').before(' '); $('.tabs a[href$=".pdf"]').before(' '); $('.tabs a[href$=".doc"]').before(' '); $('.tabs a[href$=".zip"]').before(' '); */ });