1var ric = jQuery.noConflict(); 2 ric(document).ready(function() { 3 var roomsMax = 2; 4 5 var regex = /^mySelect_(.*)$/; 6 var cloneIndex = 0; 7 8 9 10 // Remove an apartment: 11 ric("#remove_room").click(function(){ removeRoom();}); 12 var removeRoom = function() { 13 if (cloneIndex>1){ 14 cloneIndex--; 15 ric("#camere_persone_"+ cloneIndex).remove(); 16 ric("#nrcamere").attr("value", (cloneIndex)); 17 } 18 // Hide remove button: 19 if (cloneIndex <= 1) 20 ric("#remove_room").hide(); 21 if (cloneIndex < roomsMax) 22 ric("#add_room").show(); 23 24 // Hide .formError: 25 ric(".formError").remove(); 26 } 27 28 29 // Populate hidden input for countryname in full (used for email) 30 ric('#land').change(function() { 31 var countrynameoption = ric(this).find(":selected"); 32 var countrynamefull = ric(countrynameoption).text(); 33 ric('#countrynamefull').val(countrynamefull); 34 35 // empty input if not selection on #land 36 if (ric(countrynameoption).val() == ""){ 37 ric('#countrynamefull').val(""); 38 } 39 }); 40 41 // Add apartment: 42 ric("#add_room").click(function(){ 43 44 if (cloneIndex == roomsMax) 45 return; 46 47 // Clone #camere_persone, change id and put it after last .camerePersone: 48 ric("#camere_persone").clone().attr("id", "camere_persone_" + cloneIndex).insertAfter('.camerePersone:last').show(); 49 50 // Add cloneIndex to id/name of each element: 51 ric("#camere_persone_"+ cloneIndex).find("*").each(function() { 52 var id = this.id || ""; 53 if (id.length>0){ 54 this.id = this.id + "_" +(cloneIndex); 55 } 56 var name = this.name || ""; 57 if (name.length>0){ 58 this.name = this.name + "_" +(cloneIndex); 59 } 60 }); 61 62 ric("#nradulti_" + cloneIndex).addClass( "validate[required]" ); 63 //ric("#nrstanze_" + cloneIndex).addClass( "validate[required,custom[SelectNotEmpty]]" ); 64 65 // checl category only if present! 66 if ( ric("#categoria_" + cloneIndex) ){ 67 ric("#categoria_" + cloneIndex).addClass( "validate[required]" ); 68 } 69 70 71 // add/remove classes to annibamb selects 72 // select nrbamb is always showed 73 ric('#mySelect_'+cloneIndex).change(function() { 74 var id = this.id; 75 var match = id.match(regex) || []; 76 if (match.length > 0) { 77 //remove class to selects to reset 78 ric("#formContainer_"+match[1] + " div:not('.alwaysShow') select").removeClass("validate[required]"); 79 //delete error cause it remains even if the annibamb select is hidden 80 ric(".formError").remove(); 81 ric("#formContainer_"+match[1] + " div:not('.alwaysShow') select").change(); 82 ric("#formContainer_"+match[1] + " div:not('.alwaysShow')").hide(); 83 ric("#formContainer_"+match[1] + " .show" + ric(this).val()).show(); 84 ric("#formContainer_"+match[1] + " .show" + ric(this).val()+ " select").addClass( "validate[required]" ); 85 } 86 }); 87 ric('#mySelect_'+cloneIndex).change(); // simulate a change event to trigger the above 88 89 ric("#mySelect_" + cloneIndex).addClass( "validate[required]" ); 90 91 // Title: 92 ric("#camere_persone_"+ cloneIndex + " .camere_persone_title").append('Request '+(cloneIndex+1)); 93 94 // Counter: 95 ric("#nrcamere").attr("value", (cloneIndex+1)); 96 97 cloneIndex++; 98 99 // Show/hide buttons: 100 if (cloneIndex>1) 101 ric("#remove_room").show(); 102 if (cloneIndex==roomsMax) 103 ric("#add_room").hide(); 104 105 // Hide .formError: 106 ric(".formError").remove(); 107 }); 108 109 110 111 // Remove all apartments: 112 ric("button#cancel").click(function(){ 113 while(cloneIndex>1){ 114 removeRoom(); 115 } 116 ric(".show1, .show2, .show3, .show4, .show5, .show6").hide(); 117 }); 118 119 // Fix validation bug for datepicker and jquery validation 120 ric(document).on('change','#datepicker',function(){ 121 ric('.datepickerformError').hide(); 122 }) 123 ric(document).on('change','#datepicker2',function(){ 124 ric('.datepicker2formError').hide(); 125 }) 126
127 // Add first apartment: 128 ric("#add_room").click(); 129 130 131 132 });
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.