1/** 2 * Cocoon WordPress Theme 3 * @author: yhira 4 * @link: https://wp-cocoon.com/ 5 * @license: http://www.gnu.org/licenses/gpl-2.0.html GPL v2 or later 6 */ 7///////////////////////////////// 8// JavaScriptã³ã¼ã 9///////////////////////////////// 10 11( function ( $ ) { 12 ///////////////////////////////// 13 //TOPã¸æ»ããã¿ã³ 14 ///////////////////////////////// 15 let prevScrollTop = -1; 16 const $window = $( window ); 17 $window.scroll( () => { 18 //æä¸é¨ããç¾å¨ä½ç½®ã¾ã§ã®è·é¢ãåå¾ãã¦ã夿°[scrollTop]ã«æ ¼ç´ 19 const scrollTop = $window.scrollTop(); 20 const threashold = 600; 21 const s1 = prevScrollTop > threashold; 22 const s2 = scrollTop > threashold; 23 24 // ã¹ã¬ãã·ã§ã«ããè·¨ãã æã®ã¿å¦çããã 25 if ( s1 ^ s2 ) { 26 if ( s2 ) { 27 // ãããã¸æ»ããã¿ã³ãè¦ãã¦ããæ 28 $( '.body' ).addClass( 'go-to-top-visible' ); 29 30 // //[.go-to-to]ããã£ãããã§ã¼ãã¤ã³ãã 31 // $('.go-to-top').fadeIn('slow'); 32 } else { 33 //ãããã¸æ»ãéã ã追å ããã¯ã©ã¹ãé¤å» 34 $( '.go-to-top-common' ).removeClass( 'go-to-top-up' ); 35 // ãããã¸æ»ããã¿ã³ãè¦ãã¦ããªãæ 36 $( '.body' ).removeClass( 'go-to-top-visible' ); 37 38 // //ãã以å¤ã ã£ãããã§ã¼ãã¢ã¦ããã 39 // $('.go-to-top').fadeOut('slow'); 40 } 41 } 42 43 prevScrollTop = scrollTop; 44 } ); 45 46 //ãã¿ã³(.go-to-top-common)ã®ã¯ãªãã¯ã¤ãã³ã 47 $( '.go-to-top-common' ).click( function () { 48 //ãããã¸æ»ãéã ãã¯ã©ã¹ã追å 49 $( this ).addClass( 'go-to-top-up' ); 50 //ãã¼ã¸ãããã¸ç§»åãã 51 $( 'body,html' ).animate( 52 { 53 scrollTop: 1, 54 }, 55 800 56 ); 57 } ); 58 //ãã¿ã³(.go-to-toc-common)ã®ã¯ãªãã¯ã¤ãã³ã 59 $( '.go-to-toc-common' ).click( () => { 60 //ç®æ¬¡ã¸ç§»åãã 61 $( 'body,html' ).animate( 62 { 63 scrollTop: $( '.entry-content .toc' ).offset().top, 64 }, 65 800 66 ); 67 } ); 68 69 //æ¤ç´¢ãã¿ã³ã¯ãªãã¯ã§ãã©ã¼ã«ã¹ãå ¥åã¨ãªã¢ã«ç§»ã 70 $( '#search-menu-input' ).change( ( e ) => { 71 const searchEdit = $( '#search-menu-content .search-edit' ).first(); 72 if ( e.target.checked ) { 73 searchEdit.focus(); 74 } else { 75 searchEdit.blur(); 76 } 77 } ); 78 79 //ä¸ã«ã¹ã¯ãã¼ã«ã§ç®¡çããã«ãé ã 80 //ä¸ã«ã¹ã¯ãã¼ã«ã§ç®¡çããã«ã表示 81 const adminMenu = $( '#admin-panel' ); 82 const adminHeight = adminMenu.outerHeight(); 83 let adminStartPos = 0; 84 $( window ).scroll( function () { 85 const adminCurrentPos = $( this ).scrollTop(); 86 if ( adminCurrentPos > adminStartPos ) { 87 if ( adminCurrentPos >= 200 ) { 88 adminMenu.css( 'bottom', '-' + adminHeight + 'px' ); 89 } 90 } else { 91 adminMenu.css( 'bottom', 0 ); 92 } 93 adminStartPos = adminCurrentPos; 94 } ); 95 96 //ã¢ãã¤ã«ãã¿ã³ãåºå®ãããªãå ´å 97 if ( cocoon_localize_script_options.is_fixed_mobile_buttons_enable != 1 ) { 98 //ãããã¼ã¢ãã¤ã«ã¡ãã¥ã¼ 99 const headerMenu = $( '.mobile-header-menu-buttons' ); 100 let headerStartPos = 0; 101 $( window ).scroll( function () { 102 const headerCurrentPos = $( this ).scrollTop(); 103 // ã¡ãã¥ã¼åã®æãè¿ãã§é«ããå¤ãããããé ãç´åã«é½åº¦é«ããåå¾ããã 104 // box-shadowã¯outerHeightã«å«ã¾ããªããããå½±ã®æ®ã対çã¨ãã¦ä½è£ãå ããã 105 const headerHight = headerMenu.outerHeight() + 5; 106 // ç»é¢å¹ ã600px以ä¸ã®å ´åã¯ã--wp-admin--admin-bar--heightãèæ ®ããªãï¼WordPressã¢ããã³ãã¼ãåºå®ã¨ãªããªãããããããã¼ã¡ãã¥ã¼ã®ä½ç½®ã0ã«ããï¼ 107 if ( window.innerWidth <= 600 ) { 108 if ( headerCurrentPos > headerStartPos ) { 109 if ( headerCurrentPos >= 100 ) { 110 headerMenu.css( 'top', '-' + headerHight + 'px' ); 111 } 112 } else { 113 headerMenu.css( 'top', 0 ); 114 } 115 } else { 116 // CSS夿°--wp-admin--admin-bar--heightã®å¤ãåå¾ 117 const adminBarHeight = 118 getComputedStyle( document.documentElement ) 119 .getPropertyValue( '--wp-admin--admin-bar--height' ) 120 .trim() || '0px'; 121 if ( headerCurrentPos > headerStartPos ) { 122 if ( headerCurrentPos >= 100 ) { 123 // 管çãã¼ã®é«ããèæ ®ãã¦topãè¨å® 124 headerMenu.css( 125 'top', 126 'calc(' + adminBarHeight + ' - ' + headerHight + 'px)' 127 ); 128 } 129 } else { 130 // 管çãã¼ã®é«ããèæ ®ãã¦topãè¨å®
131 headerMenu.css( 'top', 'calc(' + adminBarHeight + ')' ); 132 } 133 } 134 headerStartPos = headerCurrentPos; 135 } ); 136 137 //ããã¿ã¼ã¢ãã¤ã«ã¡ãã¥ã¼ 138 const footerMenu = $( '.mobile-footer-menu-buttons' ); 139 let footerStartPos = 0; 140 $( window ).scroll( function () { 141 const footerCurrentPos = $( this ).scrollTop(); 142 // ã¡ãã¥ã¼åã®æãè¿ãã§é«ããå¤ãããããé ãç´åã«é½åº¦é«ããåå¾ããã 143 // box-shadowã¯outerHeightã«å«ã¾ããªããããå½±ã®æ®ã対çã¨ãã¦ä½è£ãå ããã 144 const footerHeight = footerMenu.outerHeight() + 5; 145 146 if ( footerCurrentPos > footerStartPos ) { 147 if ( footerCurrentPos >= 100 ) { 148 footerMenu.css( 149 'bottom', 150 'calc( -1 * (env(safe-area-inset-bottom) + ' + 151 footerHeight + 152 'px) )' 153 ); 154 } 155 } else if ( footerCurrentPos - footerStartPos < -8 ) { 156 footerMenu.css( 'bottom', 0 ); 157 } 158 159 footerStartPos = footerCurrentPos; 160 } ); 161 162 const headerButtons = $( '.mobile-header-menu-buttons' ); 163 const footerButtons = $( '.mobile-footer-menu-buttons' ); 164 headerButtons.click( () => { 165 headerButtons.css( 'z-index', '3' ); 166 footerButtons.css( 'z-index', '2' ); 167 } ); 168 169 footerButtons.click( () => { 170 headerButtons.css( 'z-index', '2' ); 171 footerButtons.css( 'z-index', '3' ); 172 } ); 173 } 174 175 //ã³ã¡ã³ããã¿ã³ãã¯ãªãã¯ãããã¨ã 176 const clickEventType = window.ontouchstart !== null ? 'click' : 'touchend'; 177 $( document ).on( 178 clickEventType, 179 '#comment-reply-btn, .comment-reply-link', 180 () => { 181 $( '#comment-reply-btn' ).slideUp(); 182 const respond = document.getElementById( 'respond' ); 183 const styles = { 184 inset: 'auto', 185 position: 'static', 186 visibility: 'visible', 187 }; 188 Object.entries( styles ).forEach( ( [ key, value ] ) => { 189 respond.style[ key ] = value; 190 } ); 191 $( '#respond' ).slideDown(); 192 } 193 ); 194 195 //Googleæ¤ç´¢ãã¿ã³ 196 $( '.sbtn' ).click( function () { 197 const w = $( this ).prev( '.sform' ).text(); 198 if ( w ) { 199 window.open( 200 'https://www.google.co.jp/search?q=' + encodeURIComponent( w ), 201 '_blank' 202 ); 203 } 204 } ); 205 206 //ã¹ã©ã¤ãã¤ã³ãµã¤ããã¼ã®ã¢ã¼ã«ã¤ãã»ã¬ã¯ãããã¯ã¹é¸æå¦ç 207 $( '.sidebar-menu-content .widget_archive select' ).change( function () { 208 document.location.href = this.options[ this.selectedIndex ].value; 209 } ); 210 211 //ã¹ã©ã¤ãã¤ã³ãµã¤ããã¼ã®ã«ãã´ãªã¼ã»ã¬ã¯ãããã¯ã¹é¸æå¦ç 212 $( '.sidebar-menu-content .widget_categories select' ).change( function () { 213 if ( this.options[ this.selectedIndex ].value > 0 ) { 214 this.parentNode.submit(); 215 } 216 } ); 217 218 function drawerCloser( selecter, checkbox ) { 219 $( selecter ).click( () => { 220 $( checkbox ).prop( 'checked', false ); 221 // const href = $(this).attr('href'); 222 // if (href.match(/#/)) { 223 // $(checkbox).prop('checked', false); 224 // } 225 } ); 226 } 227 228 //ã¢ãã¤ã«ã¡ãã¥ã¼ãã¯ãªãã¯ãããéãã 229 drawerCloser( '.menu-drawer .menu-item a', '#navi-menu-input' ); 230 231 //ã¢ãã¤ã«ãµã¤ããã¼ãã¯ãªãã¯ãããéãã 232 drawerCloser( '#slide-in-sidebar a', '#sidebar-menu-input' ); 233 234 //ã¢ãã¤ã«ãããã¼ã¡ãã¥ã¼ã®ãã´å¦ç 235 $( '.mobile-menu-buttons' ).each( function () { 236 if ( $( this ).has( '.logo-menu-button' ).length ) { 237 $( this ).addClass( 'has-logo-button' ); 238 } 239 } ); 240 241 $( window ).on( 'load', () => { 242 $( '#carousel' ).addClass( 'loaded' ); 243 } ); 244 245 //FAQããã¯ã¹ã®ã¢ã³ã¼ãã£ãªã³åç¨ 246 $( '.is-style-accordion > .faq > .faq-answer' ).hide(); 247 $( '.is-style-accordion > .faq > .faq-question' ).click( function () { 248 $( this ).next( '.is-style-accordion .faq-answer' ).slideToggle(); 249 $( this ).toggleClass( 'active' ); 250 } ); 251 252 //ã¢ãã¤ã«ãµã¤ããã¼è¡¨ç¤ºæã«ãµã¤ããã¼ãç§»åããã»ã¢ãã¤ã«ãµã¤ããã¼ãéããæã«å ã®ä½ç½®ã«æ»ã 253 $( document ).on( 'change', '#sidebar-menu-input', function () { 254 if ( $( this ).prop( 'checked' ) ) { 255 $( '#sidebar' ).appendTo( '#sidebar-menu-content' ); 256 $( '#sidebar' ).attr( 'id', 'slide-in-sidebar' ); 257 $( '#sidebar' ).addClass( 'slide-in-sidebar' ); 258 //ã¢ãã¤ã«ãµã¤ããã¼ã®ãªã³ã¯ãã¯ãªãã¯ãããéãã 259 drawerCloser( '#slide-in-sidebar a', '#sidebar-menu-input' ); 260 } else { 261 $( '#sidebar' ).removeClass( 'slide-in-sidebar' ); 262 $( '#slide-in-sidebar' ).attr( 'id', 'sidebar' ); 263 $( '#sidebar' ).insertAfter( '#main' ); 264 } 265 } ); 266 267 //ãªãµã¤ãºããæã¯ãµã¤ããã¼ãå ã«æ»ã 268 let vw = window.innerWidth; 269 $( window ).resize( () => { 270 if ( vw != window.innerWidth ) { 271 $( '#sidebar-menu-input' ).prop( 'checked', false ).change(); 272 } 273 vw = window.innerWidth; 274 } ); 275} )( jQuery ); 276 277/* 278* Cocoon WordPress Theme incorporates code from "Youtube SpeedLoad" WordPress Plugin, Copyright 2017 Alexufo[http://habrahabr.ru/users/alexufo/] 279"Youtube SpeedLoad" WordPress Plugin is distributed under the terms of the GNU GPL v2 280*/ 281( function () { 282 const f = document.querySelectorAll( '.video-click' ); 283 for ( let i = 0; i < f.length; ++i ) { 284 f[ i ].onclick = function () { 285 const iframe = this.getAttribute( 'data-iframe' ); 286 this.parentElement.innerHTML = '<div class="video">' + iframe + '</div>'; 287 }; 288 } 289} )(); 290 291// ãããã¼ã®ä½ç½®ãªãã»ãããæ´æ° 292( function () { 293 function updateHeaderOffset() { 294 const header = document.getElementById( 'header-container' ); 295 296 let offset = 0; 297 298 if ( header && header.classList.contains( 'fixed-header' ) ) { 299 offset = header.offsetHeight; 300 } 301 302 // .mobile-header-menu-buttonsã®topã»é«ããåå¾ãã¦å¦ç 303 const mobileHeaderMenuButtons = document.querySelector( 304 '.mobile-header-menu-buttons' 305 ); 306 if ( mobileHeaderMenuButtons ) { 307 const computedStyle = window.getComputedStyle( mobileHeaderMenuButtons ); 308 const topValue = parseFloat( computedStyle.top );
309 // ãã¿ã³ã®å®å¯¸é«ãï¼ã©ãã«æãè¿ãæãå®å¯¸ï¼ 310 const height = mobileHeaderMenuButtons.offsetHeight; 311 312 if ( topValue >= 0 ) { 313 // topã0以ä¸ï¼è¡¨ç¤ºä¸ï¼ã®å ´åã¯ãstickyç¨ãªãã»ããã«é«ããåæ 314 offset += height; 315 } 316 // æ¬æä½ç½ç¨ã«ã¯é«ãã®ã¿ã常æè¨å®ããã 317 // ã¹ã¯ãã¼ã«ã§é ãã¦ããæä¸ï¼topãè² ï¼ã§ãé«ãã¯å¤ãããªãããã 318 // ä½ç½®(top)ã«ä¾åããä½ç½ãå®å®ããã 319 document.documentElement.style.setProperty( 320 '--cocoon--mobile-header-menu-buttons--height', 321 height + 'px' 322 ); 323 } 324 325 document.documentElement.style.setProperty( 326 '--cocoon--header-container--position-offset', 327 offset + 'px' 328 ); 329 } 330 331 function initHeaderOffset() { 332 updateHeaderOffset(); 333 334 // ã¢ãã¤ã«ãããã¼ãã¿ã³ã®ãµã¤ãºå¤åï¼é 延表示ã»ã©ãã«ã®æãè¿ãï¼ãç£è¦ããã 335 // ã¹ã¯ãã¼ã«ã«ä¾åããªããããåæè¡¨ç¤ºæã«é«ãã0pxã«ãªãåé¡ãè§£æ¶ã§ããã 336 const target = document.querySelector( '.mobile-header-menu-buttons' ); 337 if ( target && 'ResizeObserver' in window ) { 338 new ResizeObserver( updateHeaderOffset ).observe( target ); 339 } 340 } 341 342 if ( document.readyState !== 'loading' ) { 343 initHeaderOffset(); 344 } else { 345 document.addEventListener( 'DOMContentLoaded', initHeaderOffset ); 346 } 347 348 // ãã©ã¦ã¶ãµã¤ãºå¤æ´æã«æ´æ°ï¼ãªãµã¤ãºå¦çãå®äºãã¦ããå®è¡ãããããå°ãé å»¶ãããï¼ 349 let resizeTimer; 350 window.addEventListener( 'resize', () => { 351 clearTimeout( resizeTimer ); 352 resizeTimer = setTimeout( () => { 353 updateHeaderOffset(); 354 }, 100 ); 355 } ); 356 357 // ã¹ã¯ãã¼ã«æã«ãæ´æ°ï¼åºå®ãããã¼ã®è¡¨ç¤ºåãæ¿ãã«è¿½å¾ããããï¼ 358 window.addEventListener( 'scroll', updateHeaderOffset ); 359} )(); 360 361// ã¹ããããªã³ã¯ã®ç§»åå ã¸ã®ãã©ã¼ã«ã¹ä»ä¸ 362( function () { 363 /** 364 * ã¹ããããªã³ã¯ã®ç§»åå è¦ç´ ã«ãã©ã¼ã«ã¹ãç§»ãã 365 * 366 * <main>ãªã©ã®æ¬æ¥ãã©ã¼ã«ã¹ã§ããªãè¦ç´ ã«tabindex="-1"ã常æä»ãã¦ããã¨ã 367 * Blinkã»WebKitç³»ã§ã¯ãã®å é¨ãã¯ãªãã¯ã»ç¯å²é¸æããã ãã§ç¥å è¦ç´ 㸠368 * ãã©ã¼ã«ã¹ãç§»ããTabãã¼ã®ç§»åèµ·ç¹ãã³ã³ããå é ã«æ»ã£ã¦ãã¾ãã 369 * ãã®ãããã¹ããããªã³ã¯ãæ¼ãããã¨ãã ã䏿çã«ä»ä¸ãã¦ã 370 * ãã©ã¼ã«ã¹ãå¤ããæç¹ã§åãé¤ãã 371 * 372 * @param {HTMLElement} target ç§»åå ã®è¦ç´ 373 */ 374 function focusSkipLinkTarget( target ) { 375 //æ¢åã®tabindexãããå ´åã¯å ã®æå®ãå°é 376 const isTemporary = ! target.hasAttribute( 'tabindex' ); 377 378 if ( isTemporary ) { 379 target.setAttribute( 'tabindex', '-1' ); 380 } 381 382 target.focus(); 383 384 if ( ! isTemporary ) { 385 return; 386 } 387 388 //é表示è¦ç´ ãªã©ã§ãã©ã¼ã«ã¹ã§ããªãã£ãå ´åã¯ãblurãçºçãã屿§ãæ®ãç¶ãããã峿é¤å» 389 if ( document.activeElement !== target ) { 390 target.removeAttribute( 'tabindex' ); 391 return; 392 } 393 394 target.addEventListener( 'blur', function removeTemporaryTabindex() { 395 target.removeAttribute( 'tabindex' ); 396 target.removeEventListener( 'blur', removeTemporaryTabindex ); 397 } ); 398 } 399 400 /** 401 * ããã·ã¥ããç§»åå è¦ç´ ã®IDãåãåºãã 402 * 403 * æ¥æ¬èªãªã©ã®IDã¯ãã¼ã»ã³ãã¨ã³ã³ã¼ãããããããã³ã¼ããããã 404 * 䏿£ãªã¨ã³ã³ã¼ãã§ãã¯ãªãã¯å¦çå ¨ä½ãä¾å¤ã§æ¢ã¾ããªãããã«ããã 405 * 406 * @param {string} hash å é ã«#ãå«ãããã·ã¥ 407 * @return {string} ç§»åå è¦ç´ ã®ID 408 */ 409 function getSkipLinkTargetId( hash ) { 410 const id = hash.slice( 1 ); 411 412 try { 413 return decodeURIComponent( id ); 414 } catch ( e ) { 415 return id; 416 } 417 } 418 419 //ã¹ããããªã³ã¯ã¯æç»ç´å¾ã«æ¼ãããå¯è½æ§ããããããdocumentã¸ã®å§è²ã§åãåã 420 document.addEventListener( 'click', ( event ) => { 421 //å¥ã¿ãã»å¥ã¦ã£ã³ãã¦ã§éãæä½ã®ã¨ãã¯ãç¾å¨ã®ãã¼ã¸ã®ãã©ã¼ã«ã¹ã¨è¡¨ç¤ºä½ç½®ãåãããªã 422 if ( 423 event.button !== 0 || 424 event.metaKey || 425 event.ctrlKey || 426 event.shiftKey || 427 event.altKey 428 ) { 429 return; 430 } 431 432 const element = event.target; 433 if ( ! element || typeof element.closest !== 'function' ) { 434 return; 435 } 436 437 const link = element.closest( '.skip-link' ); 438 if ( ! link || ! link.hash ) { 439 return; 440 } 441 442 const target = document.getElementById( getSkipLinkTargetId( link.hash ) ); 443 if ( target ) { 444 focusSkipLinkTarget( target ); 445 } 446 } ); 447} )(); 448
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.