/********************************************* * cd.js *********************************************/ /* ------------------------------------------- * @constructor ------------------------------------------- */ var u = new EPOS_CARD.Util(); // u インスタンスを作成 /* 201612:リニューアルに伴うレスポンシブ対応 ------------------------------------------- */ $(function(){ var spFreewordAction = "/atm/search/word.html"; if(u.isSmartphone()){ $("#atmSearch").attr("action",spFreewordAction); $("#atmSearch_url").val(spFreewordAction); } $.cdFloatingControl(); $.customScroll(); }); /* 201612:リニューアル前踏襲 ------------------------------------------- */ if(navigator.platform.indexOf("Win")==-1) v = 0; else v = 1; function print_out() { if (v) self.print(); else alert("お使いのブラウザではこの機能は利用できません。"); } function MM_openBrWindow(theURL,winName,features,urlVal) { //v2.0 if(winName == "MAP"){ window.open(theURL,winName,features); }else{ var mapwin = window.open('',winName,features); mapwin.location.href=urlVal } } //20151019 宛先URL変更につき調整 function isEmpty(val) { if (val && val.length > 0) { if (!/^[  \r\n\t]+$/.test(val)) { return false; } else { return true; } } else { return true; } } function inputCheck($inputText,message,urltext){ var encodeFn = typeof encodeURIComponent ? encodeURIComponent : encodeURI, url = urltext.val(), params = { //'search-target' : $('#atmSearch_search-target').val(), 'word' : $inputText.val() }, tmp = ""; if (isEmpty(url)) return; if(isEmpty(params['word'])){ alert(message); $inputText.focus(); return false; } else { for ( var key in params ) { tmp += key + '=' + encodeFn(params[key]) + '&'; } url = url + '?' + tmp.slice(0, -1); if(u.isSmartphone()){ window.open(url,"_blank"); } else { MM_openBrWindow(url,'MAP','status=yes,scrollbars=yes,resizable=yes,width=1000,height=950',url); } return false; }; } function run(url) { navigator.geolocation.getCurrentPosition(function(e){ callback(e, url); }, errorCallback); } function callback(position, url) { lat = position.coords.latitude lng = position.coords.longitude; url = url + '?coord=' + lat + ',' + lng; location.href = url; } /***** 位置情報が取得できない場合 *****/ function errorCallback(error) { var err_msg = ""; switch(error.code) { case 1: err_msg = "現在地が判定できません\n位置情報サービスがオンになっているか\nご確認ください"; break; case 2: err_msg = "現在地が判定できません\n位置情報サービスがオンになっているか\nご確認ください"; break; case 3: err_msg = "通信に失敗しました"; break; } window.alert(err_msg); //デバッグ → document.getElementById("show_result").innerHTML = error.message; } //現在位置から探す $(function(){ $('#mapAtmSearch').click(function(e){ e.stopPropagation(); e.preventDefault(); var $this = $(this), url = $this.attr('href') ? $this.attr('href') : ""; if (!isEmpty(url)) { run(url); } }); $('#mapAtmSearch2').click(function(e){ e.stopPropagation(); e.preventDefault(); var $this = $(this), url = $this.attr('href') ? $this.attr('href') : ""; if (!isEmpty(url)) { run(url); } }); }); //-- Navitime用のJS Start //上記ではjQueryが呼ばれていないため分離 $(function(){ var $urlEl = $('#atmSearch_url'), $wordEl = $('#atmSearch_word'), alertTxt = '文字が入力されていません。'; //フリーワードで探す $('#atmSearch').submit(function(e){ e.stopPropagation(); e.preventDefault(); return inputCheck($wordEl, alertTxt, $urlEl); }); }); //-- Navitime用のJS End (function($){ /* * cdFloatingControl * - フローティング */ $.cdFloatingControl = function(){ // element var $elm = $("#floatingAtmSearch"); if($elm.length === 0){ return false; } // setting var slideInSpeed = 500, completeNm = "slide-in-completed", negative = $elm.innerHeight() + 20; $elm.css("bottom", "-" + negative + "px"); // init u.$win.on("scroll",function(){ if($elm.hasClass(completeNm)){ return; } $elm.show(); $elm.addClass(completeNm).animate({ "bottom": 0 },slideInSpeed); }); }; /* * 既存踏襲 * $.customScroll * カスタムスクロールバー */ $.customScroll = function(){ if($("#news_area").length === 0){ return false; } $(window).load(function(){ $("#news_area").mCustomScrollbar({ scrollButtons:{enable:true}, theme:"my-theme" }); }); }; })(jQuery);