jquery.function.js

/* --------------------------- 要素を変数化 -------------------------- */ var body = $('body'); var img = $('img'); /* --------------------------- singleページのaタグ処理 -------------------------- */ $("body.single .post a[href$='.pdf']").attr({target:"_blank"}); // PDFの場合はtarget追加 $("body.single .post img").parents("a[href$='.gif'], a[href$='.jpg'], a[href$='.jpeg'], a[href$='.png']").attr({rel:"ph_g1"}); // imgの場合はカラーボックス用のrel追加 $("body.single .post img").parents("a[href$='.gif'], a[href$='.jpg'], a[href$='.jpeg'], a[href$='.png']").addClass("ph_g1"); // imgの場合はカラーボックス用のcss追加 $("body.single .post a").attr("title",(( $(".cbox img").attr("title"))) ); // imgのtitleを取得してaに追加 /* --------------------------- フェードイン -------------------------- */ // $(document).ready(function() { // setTimeout(function(){ // wrap.transitionAnimate({"opacity":"1"},"1000ms","ease-out"); // },800); // }); /* --------------------------- Retina-Srcset.js --------------------------- */ $(function(){ var retinaCheck = window.devicePixelRatio; if(retinaCheck >= 2) { // Retinaディスプレイのときを分岐させている $('img.retina').each( function() { var retinaimg = $(this).attr('src').replace(/\.(?=(?:png|jpg|jpeg)$)/i, '@2x.'); $(this).attr('srcset', retinaimg + " 2x"); }); } }); /* --------------------------- スマートフォンのみtelリンク有効 --------------------------- */ /* HTML -- テキスト <p>TEL<span class="tel-link">06-6372-1168</span></p> */ $(function(){ var ua = navigator.userAgent; if(ua.indexOf('iPhone') > 0 && ua.indexOf('iPod') == -1 || ua.indexOf('Android') > 0 && ua.indexOf('Mobile') > 0 && ua.indexOf('SC-01C') == -1 && ua.indexOf('A1_07') == -1 ){ $('.tel-link').each(function(){ var str = $(this).text(); $(this).html($('<a>').attr('href', 'tel:' + str.replace(/-/g, '')).append(str + '</a>')); }); } }); /* HTML -- 画像 お問い合わせ:<span class="tel-link"><img src="[表示する画像のパス]" alt="00-0000-0000"></span> */ $(function(){ var ua = navigator.userAgent; if(ua.indexOf('iPhone') > 0 && ua.indexOf('iPod') == -1 || ua.indexOf('Android') > 0 && ua.indexOf('Mobile') > 0 && ua.indexOf('SC-01C') == -1 && ua.indexOf('A1_07') == -1 ){ $('.tel-link img').each(function(){ var alt = $(this).attr('alt'); $(this).wrap($('<a>').attr('href', 'tel:' + alt.replace(/-/g, ''))); }); } }); /* --------------------------- OS判定+ブラウザ判定してhtmlにクラスをつける --------------------------- */ $(function() { //ここから判定してクラス付与スクリプト var ua, verArr, version, ieVer, ie, chrome, firefox, opera, safari; ua = navigator.userAgent; // IEかそれ以外かどうかを判定 if (ua.match(/msie/i) || ua.match(/trident/i)) { // IEの場合はバージョンを判定 verArr = /(msie|rv:?)\s?([\d\.]+)/i.exec(ua); version = (verArr) ? verArr[2] : ''; version = version.replace('.', '_'); ieVer = "ie" + version; // "ie11_0"等を付与 $("html").addClass(ieVer); } else { if (ua.match(/chrome/i)) { // chrome $("html").addClass('chrome'); } else if (ua.match(/firefox/i)) { // firefox $("html").addClass('firefox'); } else if (ua.match(/opera/i)) { // opera $("html").addClass('opera'); } else if (ua.match(/safari/i)) { // safari $("html").addClass('safari'); } } //ここからOS判定 if (navigator.userAgent.indexOf('Win') > 0) { $('html').addClass('win'); } else if (navigator.userAgent.indexOf('Mac') > 0) { $('html').addClass('mac'); } else if (navigator.userAgent.indexOf('iPhone') > 0) { $('html').addClass('iphone'); } else if (navigator.userAgent.indexOf('iPad') > 0) { $('html').addClass('ipad'); } else if (navigator.userAgent.indexOf('iPod') > 0) { $('html').addClass('ipod'); } else if (navigator.userAgent.indexOf('Android') > 0) { $('html').addClass('android'); } })

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.