1'use strict'; 2( function ( $, novacity ) { 3 4 $( document ).ready(function() { 5 6 // Add external icon on external links only if got direct child text 7 $( '[target="_blank"]' ).each( function ( index, element ) { 8 if ( typeof element.childNodes[0] != 'undefined' && element.childNodes[0].nodeValue != null && element.childNodes[0].nodeValue.trim() != '' ) { 9 $( element ).addClass( 'external-link' ).append([ novacity.icons.external_link, '<span class="visually-hidden">(ouverture dans un nouvel onglet)</span>' ]); 10 } 11 } ); 12 13 // Get real height as css variables 14 const appHeight = () => { 15 const vh = window.innerHeight * 0.01; 16 document.documentElement.style.setProperty( '--vh', `${vh}px` ); 17 } 18 window.addEventListener('resize', appHeight) 19 appHeight(); 20 21 22 $( window ).on( 'load', function () { 23 // Scroll to 24 $( '[data-toggle="scroll-to"]' ).on( 'click', function ( event ) { 25 event.preventDefault(); 26 var $this = $( this ), to; 27 if ( $this.attr( 'href' ) != undefined ) { 28 to = $this.attr( 'href' ); 29 } else if ( $this.data( 'target' ) != undefined ) { 30 if ( $this.data( 'target' ) == 'next' ) { 31 to = $this.closest( 'section' ).next(); 32 } else { 33 to = $this.data( 'target' ); 34 } 35 } else { 36 return false; 37 } 38 var navHeight = $( '#navigation' ).outerHeight(), 39 top = $( to ).offset().top - navHeight - 30; 40 $( 'html, body' ).stop().animate({ 41 scrollTop: top 42 }, 1 ); 43 } ); 44 } ); 45 46 // Chained select 47 $( '[data-chained-select]' ).each( function ( index, el ) { 48 var $parent = $(el), 49 $child = $( $parent.data( 'chained-select' ) ), 50 $selected, 51 $child_options = $child.clone(), 52 $child_default = $child_options.find( 'option' ).eq( 0 ).clone() 53 54 $selected = $parent.find( 'option:selected' ) 55 56 if ( $parent.val() != '' && $child_options.find( '[data-parent-id="' + $selected.data( 'id' ) + '"]' ).length ) { 57 58 $child 59 .removeAttr( 'disabled' ) 60 .html( $child_default.clone() ) 61 .show() 62 .append( $child_options.clone().find( '[data-parent-id="' + $selected.data( 'id' ) + '"]' ) ) 63 .closest( '.form-group' ) 64 .show() 65 } else { 66 $child 67 .html( $child_default.clone() ) 68 .attr( 'disabled', 'disabled' ) 69 .hide() 70 .closest( '.form-group' ) 71 .hide() 72 } 73 74 $parent.on( 'change', function ( event ) { 75 $selected = $parent.find( 'option:selected' ) 76 77 if ( $parent.val() != '' && $child_options.find( '[data-parent-id="' + $selected.data( 'id' ) + '"]' ).length ) { 78 79 $child 80 .removeAttr( 'disabled' ) 81 .html( $child_default.clone() ) 82 .show() 83 .append( $child_options.clone().find( '[data-parent-id="' + $selected.data( 'id' ) + '"]' ) ) 84 .closest( '.form-group' ) 85 .show() 86 87 } else { 88 $child 89 .html( $child_default.clone() ) 90 .attr( 'disabled', 'disabled' ) 91 .hide() 92 .closest( '.form-group' ) 93 .hide() 94 } 95 } ); 96 } ); 97 98 // here for each comment reply link of WordPress 99 $( '.comment-reply-link' ).addClass( 'btn btn-primary' ); 100 101 // here for the submit button of the comment reply form 102 $( '#commentsubmit' ).addClass( 'btn btn-primary' ); 103 104 // Set the sharer 105 $( '[data-sharer]' ).on( 'click', function ( event ) { 106 event.preventDefault(); 107 108 var $this = $( this ), 109 leftPosition = ( window.screen.width / 2 ) - ( ( width / 2 ) + 10 ), 110 topPosition = ( window.screen.height / 2 ) - ( ( height / 2 ) + 50 ), 111 width = 526, 112 height = 350, 113 windowFeatures = 'status=no,height=' + height + ',width=' + width + ',resizable=yes,left=' + leftPosition + ',top=' + topPosition + ',screenX=' + leftPosition + ',screenY=' + topPosition + ',toolbar=no,menubar=no,scrollbars=no,location=no,directories=no', 114 t = document.title; 115 116 window.open( $this.attr( 'href' ), 'sharer', windowFeatures ); 117 118 return false; 119 120 } ); 121 122 /* 123 * Detect active language if Google Translate is actived 124 * 125 * @since 1.6.0 126 */ 127 function setActiveLanguage( lang ) { 128 var list = $( '#nova-translate' ); 129 list.find( 'a' ).removeClass( 'active' ) 130 if ( lang ) { 131 list.find( '[onclick^="doGTranslate(\'fr|' + lang + '"]' ).addClass( 'active' ) 132 } else { 133 list.find( '[onclick^="doGTranslate(\'fr|fr"]' ).addClass( 'active' ) 134 } 135 } 136 if ( $( '#nova-translate' ).length ) { 137 $( '#google_translate_element2' ).on( 'change', function ( event ) {
138 setActiveLanguage( GTranslateGetCurrentLang() ) 139 } ).change() 140 } 141 142 // Hide Popover on click outside 143 // $( document ).on( 'click', function (e) { 144 // $( '[data-bs-toggle="popover"],[data-bs-original-title]' ).each(function () { 145 // //the 'is' for buttons that trigger popups 146 // //the 'has' for icons within a button that triggers a popup 147 // if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $( '.popover' ).has(e.target).length === 0) { 148 // (( $(this).popover( 'hide' ).removeClass( 'active' ).data( 'bs.popover' )||{}).inState||{}).click = false // fix for BS 3.3.6 149 // } 150 // }); 151 // }); 152 153 // Periode 154 if ( $( '.page-template-event' ).length ) { 155 $( '#field_date' ).on( 'change', function ( event ) { 156 event.preventDefault(); 157 if ( $( this ).val() == 'periode' ) { 158 $( '#periode' ).addClass( 'show' ).removeClass( 'visually-hidden' ).find( 'input' ).removeAttr( 'disabled' ) 159 } else { 160 $( '#periode' ).removeClass( 'show' ).addClass( 'visually-hidden' ).find( 'input' ).attr( 'disabled', 'disabled' ) 161 } 162 } ).change(); 163 } 164 165 // Tooltip 166 if ( $( '.map-tooltip' ).length) { 167 let tooltip = document.getElementById( 'map-tooltip' ); 168 function showTooltip( evt, text ) { 169 if ( tooltip.innerHTML !== text ) { 170 tooltip.innerHTML = text; 171 } 172 if ( tooltip.style.display !== 'block' ) { 173 tooltip.style.display = 'block'; 174 } 175 tooltip.style.left = evt.pageX + 0 + 'px'; 176 tooltip.style.top = evt.pageY - 0 + 'px'; 177 } 178 function hideTooltip() { 179 tooltip.style.display = 'none'; 180 } 181 $( '.map-tooltip' ).appendTo( $( 'body' ) ); 182 $( '.js-map-svg' ).find( 'a' ) 183 .on( 'mousemove', throttle( function ( event ) { 184 showTooltip(event, $( this ).attr( 'data-title' ) ); 185 $( '.js-map-list a[data-path="' + $( this ).attr( 'id' ) + '"]' ).addClass( 'active' ); 186 }, 1 ) ) 187 .on( 'mouseout', function () { 188 hideTooltip(); 189 $( '.js-map-list a[data-path="' + $( this ).attr( 'id' ) + '"]' ).removeClass( 'active' ); 190 } ); 191 $( '.js-map-list' ).on( 'mouseenter', 'a', function ( event ) { 192 event.preventDefault(); 193 $( '#' + $( this ).data( 'path' ) ).addClass( 'active' ); 194 } ).on( 'mouseleave', 'a', function ( event ) { 195 event.preventDefault(); 196 $( '#' + $( this ).data( 'path' ) ).removeClass( 'active' ); 197 } ); 198 } 199 200 // Headroom 201 var headroomElement = document.querySelector( '.headroom' ); 202 if ( headroomElement !== null ) { 203 var layoutNavigationOffset = $( '.layout-navigation' ).offset(); 204 var layoutNavigationOffsetTop = layoutNavigationOffset.top + 100; 205 var headroomOptions = { 206 offset: { 207 up: 0, 208 down: layoutNavigationOffsetTop 209 }, 210 tolerance : 5, 211 } 212 var headroom = new Headroom( headroomElement, headroomOptions ); 213 headroom.init(); 214 } 215 216 217 218 function daysIntoYear(date){ 219 return (Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()) - Date.UTC(date.getFullYear(), 0, 0)) / 24 / 60 / 60 / 1000; 220 } 221 222 if ( $( '.tourinsoft-availability' ).length ) { 223 224 var plannings = $( '.tourinsoft-availability' ).data( 'plannings' ) 225 226 227 228 $.each( plannings, function(index, val) { 229 plannings[ index ] = val.split( '' ) 230 }); 231 232 var defaultOptions = { 233 buttonClass: 'btn', 234 language: 'fr', 235 'beforeShowDay': function (date) { 236 237 if ( typeof plannings[ date.getFullYear() ] != 'undefined' ) { 238 239 var dayOfYear = daysIntoYear( date ); 240 241 if ( typeof plannings[ date.getFullYear() ][ dayOfYear ] != 'undefined' ) { 242 243 var available = plannings[ date.getFullYear() ][ dayOfYear - 1 ]; 244 245 return { 246 classes: 'available-' + available 247 }; 248 } 249 250 } 251 } 252 }; 253 254 // Init 255 var datepicker = new Datepicker( $( '.tourinsoft-availability' )[0], defaultOptions ); 256 257 258 } 259 260 }); 261 262 263 $( '.simplefavorite-button' ).each( function ( index, el ) { 264 265 if ( $( el ).hasClass('active') ) { 266 267 new bootstrap.Tooltip( el, { 268 placement: 'top', 269 title: 'Retirer de mon carnet de voyage', 270 container: 'body', 271 }) 272 273 } else { 274 new bootstrap.Tooltip( el, { 275 placement: 'top', 276 title: 'Ajouter à mon carnet de voyage', 277 container: 'body', 278 }) 279 } 280 281 }); 282 283 284 285 286 var $favorites_count = $('.nav-link-favorites').find('.count'); 287 /** 288 * favorites-updated-single 289 * Fires after a favorite button has been submitted successfully 290 * @param favorites - Array of post objects the user has favorited 291 * @param post_id - The post ID that was updated 292 * @param site_id - The site ID for the post that was updated (for multisite) 293 * @param status - Whether the button was active or inactive 294 */ 295 $( document ).on('favorites-updated-single', function(event, favorites, post_id, site_id, status){ 296 297 var count = $favorites_count.eq(0).text() * 1; 298 $favorites_count.removeClass( 'count-' + count ) 299 300 if ( status == 'active' ) { 301 count++; 302 $favorites_count.parent().addClass( 'is-favorited' ) 303 $favorites_count.addClass( 'count-' + count ).text( count ) 304 } else {
305 count--; 306 $favorites_count.parent().removeClass( 'is-favorited' ) 307 $favorites_count.addClass( 'count-' + count ).text( count ) 308 } 309 310 $( '.simplefavorite-button' ).each( function ( index, el ) { 311 312 const tooltip = bootstrap.Tooltip.getInstance( el ) 313 if ( tooltip != null ) { 314 if ( $( el ).hasClass('active') ) { 315 tooltip.setContent({ '.tooltip-inner': 'Retirer de mon carnet de voyage' }) 316 } else { 317 tooltip.setContent({ '.tooltip-inner': 'Ajouter à mon carnet de voyage' }) 318 } 319 } 320 321 }); 322 }); 323 324 /** 325 * favorites-cleared 326 * Fires after all favorites have been cleared 327 * @param button - The active clear button 328 */ 329 $( document ).on('favorites-cleared', function(event, button){ 330 331 var count = $favorites_count.text() * 1; 332 $favorites_count.removeClass( 'count-' + count ) 333 334 $favorites_count.addClass( 'count-0' ).text( 0 ) 335 336 }); 337 338} )( jQuery, novacity );
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.