1/* 2 * This file is part of EC-CUBE 3 * 4 * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved. 5 * 6 * http://www.ec-cube.co.jp/ 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10*/ 11 12$(function() { 13 14 $('.pagetop').hide(); 15 16 $(window).on('scroll', function() { 17 // ãã¼ã¸ããããã§ã¼ãã¤ã³ 18 if ($(this).scrollTop() > 300) { 19 $('.pagetop').fadeIn(); 20 } else { 21 $('.pagetop').fadeOut(); 22 } 23 24 // PCè¡¨ç¤ºã®æã®ã¿ã«é©ç¨ 25 if (window.innerWidth > 767) { 26 27 if ($('#shopping-form').length) { 28 29 var side = $(".ec-orderRole__summary"), 30 wrap = $("#shopping-form"), 31 min_move = wrap.offset().top, 32 max_move = wrap.height(), 33 margin_bottom = max_move - min_move; 34 35 var scrollTop = $(window).scrollTop(); 36 if (scrollTop > min_move && scrollTop < max_move) { 37 var margin_top = scrollTop - min_move; 38 side.css({"margin-top": margin_top}); 39 } else if (scrollTop < min_move) { 40 side.css({"margin-top": 0}); 41 } else if (scrollTop > max_move) { 42 side.css({"margin-top": margin_bottom}); 43 } 44 45 } 46 } 47 return false; 48 }); 49 50 51 $('.ec-headerNavSP').on('click', function() { 52 $('.ec-layoutRole').toggleClass('is_active'); 53 $('.ec-drawerRole').toggleClass('is_active'); 54 $('.ec-drawerRoleClose').toggleClass('is_active'); 55 $('body').toggleClass('have_curtain'); 56 }); 57 58 $('.ec-overlayRole').on('click', function() { 59 $('body').removeClass('have_curtain'); 60 $('.ec-layoutRole').removeClass('is_active'); 61 $('.ec-drawerRole').removeClass('is_active'); 62 $('.ec-drawerRoleClose').removeClass('is_active'); 63 }); 64 65 $('.ec-drawerRoleClose').on('click', function() { 66 $('body').removeClass('have_curtain'); 67 $('.ec-layoutRole').removeClass('is_active'); 68 $('.ec-drawerRole').removeClass('is_active'); 69 $('.ec-drawerRoleClose').removeClass('is_active'); 70 }); 71 72 // TODO: ã«ã¼ãå±éæã®ã¢ã¤ã³ã³å¤æ´å¦ç 73 $('.ec-headerRole__cart').on('click', '.ec-cartNavi', function() { 74 // $('.ec-cartNavi').toggleClass('is-active'); 75 $('.ec-cartNaviIsset').toggleClass('is-active'); 76 $('.ec-cartNaviNull').toggleClass('is-active') 77 }); 78 79 $('.ec-headerRole__cart').on('click', '.ec-cartNavi--cancel', function() { 80 // $('.ec-cartNavi').toggleClass('is-active'); 81 $('.ec-cartNaviIsset').toggleClass('is-active'); 82 $('.ec-cartNaviNull').toggleClass('is-active') 83 }); 84 85 $('.ec-orderMail__link').on('click', function() { 86 $(this).siblings('.ec-orderMail__body').slideToggle(); 87 }); 88 89 $('.ec-orderMail__close').on('click', function() { 90 $(this).parent().slideToggle(); 91 }); 92 93 $('.is_inDrawer').each(function() { 94 var html = $(this).html(); 95 $(html).appendTo('.ec-drawerRole'); 96 }); 97 98 $('.ec-blockTopBtn').on('click', function() { 99 $('html,body').animate({'scrollTop': 0}, 500); 100 }); 101 102 // ã¹ããã®ããã¯ã¼ã¡ãã¥ã¼å ã®ä¸å±¤ã«ãã´ãªè¡¨ç¤º 103 // TODO FIXME ã¹ããã®ã«ãã´ãªè¡¨ç¤ºæ¹æ³ 104 $('.ec-itemNav ul a').click(function() { 105 var child = $(this).siblings(); 106 if (child.length > 0) { 107 if (child.is(':visible')) { 108 return true; 109 } else { 110 child.slideToggle(); 111 return false; 112 } 113 } 114 }); 115 116 // ã¤ãã³ãå®è¡æã®ãªã¼ãã¼ã¬ã¤å¦ç 117 // classã«ãload-overlayããè¨è¿°ããã¦ããã¨ç»é¢ããªã¼ãã¼ã¬ã¤ããã 118 $('.load-overlay').on({ 119 click: function() { 120 loadingOverlay(); 121 }, 122 change: function() { 123 loadingOverlay(); 124 } 125 }); 126 127 // submitå¦çã«ã¤ãã¦ã¯ãªã¼ãã¼ã¬ã¤å¦çãè¡ã 128 $(document).on('click', 'input[type="submit"], button[type="submit"]', function() { 129 130 // html5 validate対å¿
131 var valid = true; 132 var form = getAncestorOfTagType(this, 'FORM'); 133 134 if (typeof form !== 'undefined' && !form.hasAttribute('novalidate')) { 135 // form validation 136 if (typeof form.checkValidity === 'function') { 137 valid = form.checkValidity(); 138 } 139 } 140 141 if (valid) { 142 loadingOverlay(); 143 } 144 }); 145}); 146 147$(window).on('pageshow', function() { 148 loadingOverlay('hide'); 149}); 150 151/** 152 * ãªã¼ãã¼ã¬ã¤å¦çãè¡ã颿° 153 */ 154function loadingOverlay(action) { 155 156 if (action == 'hide') { 157 $('.bg-load-overlay').remove(); 158 } else { 159 $overlay = $('<div class="bg-load-overlay">'); 160 $('body').append($overlay); 161 } 162} 163 164/** 165 * è¦ç´ FORMãã§ã㯠166 */ 167function getAncestorOfTagType(elem, type) { 168 169 while (elem.parentNode && elem.tagName !== type) { 170 elem = elem.parentNode; 171 } 172 173 return (type === elem.tagName) ? elem : undefined; 174} 175 176// anchorãã¯ãªãã¯ããæã«formãè£ã§ä½ã£ã¦æå®ã®ã¡ã½ããã§ãªã¯ã¨ã¹ããé£ã°ã 177// Twigã«ã¯ä»¥ä¸ã®ããã«åãè¾¼ã 178// <a href="PATH" {{ csrf_token_for_anchor() }} data-method="(put/delete/postã®ãã¡ãããã)" data-confirm="xxxx" data-message="xxxx"> 179// 180// ãªãã·ã§ã³è¦ç´ 181// data-confirm : falseãå®ç¾©ããã¨ç¢ºèªãã¤ã¢ãã°ãåºããªããããã©ã«ãã¯ãã¤ã¢ãã°ãåºã 182// data-message : 確èªãã¤ã¢ãã°ãåºãéã®ã¡ãã»ã¼ã¸ãããã©ã«ããã夿´ãã 183// 184$(function() { 185 var createForm = function(action, data) { 186 var $form = $('<form action="' + action + '" method="post"></form>'); 187 for (input in data) { 188 if (data.hasOwnProperty(input)) { 189 $form.append('<input name="' + input + '" value="' + data[input] + '">'); 190 } 191 } 192 return $form; 193 }; 194 195 $('a[token-for-anchor]').click(function(e) { 196 e.preventDefault(); 197 var $this = $(this); 198 var data = $this.data(); 199 if (data.confirm != false) { 200 if (!confirm(data.message ? data.message : eccube_lang['common.delete_confirm'] )) { 201 return false; 202 } 203 } 204 205 // å餿ã¯ãªã¼ãã¼ã¬ã¤å¦çãå ¥ãã 206 loadingOverlay(); 207 208 var $form = createForm($this.attr('href'), { 209 _token: $this.attr('token-for-anchor'), 210 _method: data.method 211 }).hide(); 212 213 $('body').append($form); // Firefox requires form to be on the page to allow submission 214 $form.submit(); 215 }); 216});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.