1jQuery(document).ready( function($) { 2 3 4 // Detect ios 11_x_x affected 5 // NEED TO BE UPDATED if new versions are affected 6 var ua = navigator.userAgent, 7 iOS = /iPad|iPhone|iPod/.test(ua), 8 iOS11 = /OS 11_0_1|OS 11_0_2|OS 11_0_3|OS 11_1|OS 11_1_1|OS 11_1_2|OS 11_2|OS 11_2_1/.test(ua); 9 10 // ios 11 bug caret position 11 if ( iOS && iOS11 ) { 12 13 // Add CSS class to body 14 $("body").addClass("iosBugFixCaret"); 15 16 } 17 18 function trapFocus(container) { 19 const focusableSelectors = 'a, button, input, textarea, select, [tabindex]:not([tabindex="-1"])'; 20 const $focusable = container.find(focusableSelectors).filter(':visible'); 21 const first = $focusable.first()[0]; 22 const last = $focusable.last()[0]; 23 24 container.on('keydown.trapFocus', function(e) { 25 if (e.key === 'Tab') { 26 if (e.shiftKey) { 27 // Shift + Tab 28 if (document.activeElement === first) { 29 e.preventDefault(); 30 last.focus(); 31 } 32 } else { 33 // Tab 34 if (document.activeElement === last) { 35 e.preventDefault(); 36 first.focus(); 37 } 38 } 39 } 40 }); 41 42 // Sposta subito il focus sul primo elemento 43 if (first) first.focus(); 44 } 45 46 function releaseFocus(container) { 47 container.off('keydown.trapFocus'); 48 } 49 50 51 $( '.title-open-room, .title-open-date' ).click( function(e){ 52 e.preventDefault(); 53 54 $( '.modal-header .close' ).css('visibility', 'hidden'); 55 56 var form = $(this).closest('form'); 57 var clickedBtnID = $(this).attr('id'); 58 59 if( clickedBtnID == 'efb-open-date' ){ 60 61 form.find( '.open-date' ).show( 'fast', function(){ 62 $( '.title-open-date .fakeinput' ).removeClass('bg-error'); 63 //$(".modal").animate({ scrollTop: 0 }, "fast"); 64 65 e.stopPropagation(); 66 }); 67 68 }else if( clickedBtnID == 'efb-open-room' ){ 69 70 form.find( '.open-room' ).show( 'fast', function(){ 71 //$(".modal").animate({ scrollTop: 0 }, "fast"); 72 e.stopPropagation(); 73 }); 74 75 } 76 }); 77 78 $('#efb-open-room .fakeinput').on('focus', function(event) { 79 const form = $(this).closest('form'); 80 const $openRoom = form.find('.open-room'); 81 82 $openRoom.show('fast', function() { 83 trapFocus($openRoom); 84 }); 85 }); 86 87 88 $( '.closeSection' ).click( function(e){ 89 e.preventDefault(); 90 $( '.open-room' ).hide('fast'); 91 $( '.open-date' ).hide('fast'); 92 e.stopPropagation(); 93 $( '.modal-header .close' ).css('visibility', 'visible'); 94 var form_id = $(this).closest('form').attr('id'); //element not element.id 95 var clickedBtnID = $(this).attr('id'); 96 var itemParent = $( this ).closest('.efb-section-div'); 97 98 if( itemParent.hasClass('open-room')) { 99 // camere, adulti e bambini 100 var nRooms = 1; 101 var nAdults = 0; 102 var nChildren = 0; 103 104 var iRooms = $('input.efb-rooms', itemParent); 105 var iAdults = $('input.efb-adults', itemParent).not(':disabled'); 106 var iChildren = $('input.efb-children', itemParent).not(':disabled'); 107 108 var labelRooms = ( typeof( efb_config.roomsLabel ) != "undefined" ) ? efb_config.roomsLabel : 'Camere'; 109 var labelAdults = ( typeof( efb_config.adultsLabel ) != "undefined" ) ? efb_config.adultsLabel : 'Adulti'; 110 var labelChildren = ( typeof( efb_config.childrenLabel ) != "undefined" ) ? efb_config.childrenLabel : 'Bambini'; 111 112 // numero di camere 113 nRooms = ( iRooms.length > 0 ) ? iRooms.val() : 1; 114 115 // numero di adulti 116 iAdults.each( function(){ 117 var _thisInput = $(this); 118 nAdults += parseInt( _thisInput.val()); 119 }); 120 121 // numero di bambini 122 iChildren.each( function(){ 123 var _thisInput = $(this); 124 nChildren += parseInt( _thisInput.val()); 125 }); 126 127 itemParent.siblings('.fakeinput').html(" "); 128 if ( $(this).attr('id') == 'closeSection-removedata' ) { 129 $('#' + form_id).find('.open-room').find('.efb-item').each(function () { 130 131 // Hide every li item except those with class first 132 $(this).not('.first').hide(); 133 // // Disable every input under li item except those with class first 134 $(this).not('.first').find('input,select').prop('disabled', true); 135 $(this).not('.first').find('input,select').removeClass('required'); 136 137 // Reset input values 138 $(this).find('.quantity').each(function (index, element) { 139 var oldValue = element.getAttribute('value'); 140 $(element).val(oldValue); 141 });
142 143 }); 144 return; 145 } 146 147 var htmlLabel = nRooms + ' ' + labelRooms + ', ' + nAdults + ' ' + labelAdults; 148 149 // il numero di bambini li visualizzo solo se, nel form, è presente il campo relativo 150 // (nei siti business, ad esempio, non dobbiamo gestirli) 151 if( $('input.efb-children', itemParent).length > 0 ) { 152 htmlLabel += ', ' + nChildren + ' ' + labelChildren; 153 } 154 155 itemParent.siblings('.fakeinput').html( htmlLabel ); 156 157 // INIZIO / triggero un evento per eventuali personalizzazioni 158 // dell'etichetta con il numero di camere, adulti e bambini 159 const efb_event_guestlabel = new CustomEvent('efb_guest_label_change', { 160 bubbles: true, 161 detail: { 162 form: itemParent.closest('form'), 163 fieldLabel: htmlLabel, 164 fieldInput: itemParent.siblings('.fakeinput') 165 } 166 }); 167 168 document.dispatchEvent(efb_event_guestlabel); 169 // FINE TRIGGER 170 171 } else if( itemParent.hasClass('open-date')) { 172 173 var datesValues = new Array(); 174 175 // date di permanenza se ho utilizzato il campo di tipo "date-range" 176 itemParent.find('input.sectionValue').each(function(i, value){ 177 datesValues.push( $( value ).val()); 178 }); 179 180 itemParent.siblings('.fakeinput').html( datesValues.join(' / ')); 181 } 182 }); 183});
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.