Changeset 6282c5 in indico
- Timestamp:
- 06/24/11 14:31:49 (2 years ago)
- Branches:
- master, hello-world-walkthrough, ipv6, v0.98-series, v0.98.2, v0.98.3, v0.98b2, v0.99, b8c30da8ebdbdcbd675a873997cc3e95f567de49, 4287315ec967a3da168d83963c14001db8487d53
- Children:
- 75bea1
- Parents:
- cc169e
- git-author:
- Adrian Moennich <jerome.ernst.monnich@…> (06/14/11 15:19:20)
- git-committer:
- Pedro Ferreira <jose.pedro.ferreira@…> (06/24/11 14:31:49)
- Location:
- indico
- Files:
-
- 5 edited
-
MaKaC/webinterface/tpls/RoomBookingBookingForm.tpl (modified) (6 diffs)
-
MaKaC/webinterface/tpls/RoomBookingPeriodForm.tpl (modified) (1 diff)
-
MaKaC/webinterface/tpls/RoomBookingSearch4Bookings.tpl (modified) (10 diffs)
-
MaKaC/webinterface/tpls/RoomBookingSearch4Rooms.tpl (modified) (8 diffs)
-
htdocs/js/indico/Legacy/Widgets.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
indico/MaKaC/webinterface/tpls/RoomBookingBookingForm.tpl
r076d0a r6282c5 1 1 <script type="text/javascript"> 2 3 // Function for checking and submitting the form when the user presses Enter.4 // The JavaScript doesn't behave as expected in this case, since the checking is5 // skipped.6 function submit_on_enter(ev) {7 8 var kc, e;9 if (window.event) {10 e = window.event;11 kc = window.event.keyCode;12 }13 else if (ev) {14 e = ev;15 kc = ev.which;16 }17 else {18 return true;19 }20 21 if (kc == 13) {22 // If Enter was pressed in the "Reason" textarea, we don't want23 // to submit the form24 if (e.target == $('reason')) {25 return true;26 }27 if (forms_are_valid( true )) {28 submit_booking();29 }30 else {31 alert( ${ _("'There are errors in the form. Please correct fields with red background.'")} );32 }33 return false;34 }35 else {36 return true;37 }38 }39 40 2 // Reds out the invalid textboxes and returns false if something is invalid. 41 3 // Returns true if form may be submited. 42 function forms_are_valid( onSubmit ) 43 { 44 if ( onSubmit != true ) 4 function forms_are_valid(onSubmit) { 5 if (onSubmit != true) { 45 6 onSubmit = false; 7 } 46 8 47 9 // Init, clean up (make all textboxes white again) 48 var f1 = $('bookingForm') 49 period_clean_redouts( f1 ) 50 f1.bookedForName.className = f1.contactEmail.className = f1.contactPhone.className = f1.reason.className = '' 51 52 var isValid = true 53 isValid = validate_period( f1, true, ${ allowPast } ) && isValid 54 isValid = required_fields( ['bookedForName', 'contactEmail', 'reason'] ) && isValid 55 56 if ( !Util.Validation.isEmailList( $F( 'contactEmail' ) ) ) 57 { 58 isValid = false 59 $('contactEmail').className = 'invalid' 10 var bookingForm = $j('#bookingForm'); 11 $j(':input', bookingForm).removeClass('invalid'); 12 13 var isValid = true; 14 isValid = validate_period(bookingForm[0], true, ${allowPast}) && isValid; 15 isValid = required_fields(['bookedForName', 'contactEmail', 'reason']) && isValid; 16 17 if (!Util.Validation.isEmailList($F('contactEmail'))) { 18 isValid = false; 19 $j('#contactEmail').addClass('invalid'); 60 20 } 61 21 62 22 // Holidays warning 63 if ( isValid && !onSubmit ) 64 { 65 var holidaysWarning = indicoSource('roomBooking.getDateWarning', $(f1).serialize(true)); 66 67 holidaysWarning.state.observe(function(state) { 68 if (state == SourceState.Loaded) { 69 $E('holidays-warning').set(holidaysWarning.get()); 23 if (isValid && !onSubmit) { 24 var lastDateInfo = bookingForm.data('lastDateInfo'); 25 var dateInfo = $j('#sDay, #sMonth, #sYear, #eDay, #eMonth, #eYear').serialize(); 26 if (dateInfo != lastDateInfo) { 27 bookingForm.data('lastDateInfo', dateInfo); 28 var holidaysWarning = indicoSource('roomBooking.getDateWarning', bookingForm.serializeObject()); 29 30 holidaysWarning.state.observe(function(state) { 31 if (state == SourceState.Loaded) { 32 $E('holidays-warning').set(holidaysWarning.get()); 33 } 34 }); 35 } 36 } 37 38 % if candResv.room.needsAVCSetup: 39 var vcIsValid = true; 40 if ($j('#usesAVC').is(':checked')) { 41 vcIsValid = $j('input.videoConferenceOption').is(':checked'); 42 } 43 $j('#vcSystemList').toggleClass('invalid', !vcIsValid); 44 isValid = isValid && vcIsValid; 45 % endif 46 47 return isValid; 48 } 49 50 51 $j(window).load(function() { 52 % if candResv.room.needsAVCSetup: 53 $j('.videoConferenceOption, #needsAVCSupport').change(function() { 54 if(this.checked) { 55 $j('#usesAVC').prop('checked', true); 70 56 } 71 57 }); 72 } 73 74 % if candResv.room.needsAVCSetup: 75 76 $('vcSystemList').className='' 77 78 if ($('usesAVC').checked) { 79 80 var oneChecked = false; 81 82 $$('input.videoConferenceOption').each(function(elem){ 83 if (elem.checked) 84 { 85 oneChecked = true; 86 } 87 }); 88 89 if (!oneChecked) { 90 $( 'vcSystemList' ).className = 'invalid'; 91 isValid = false; 92 } 93 94 } 95 % endif 96 97 98 return isValid; 99 } 100 101 function submit_booking() 102 { 103 $('bookingForm').action = "${ saveBookingUH.getURL( conf ) }" 104 $('bookingForm').submit() 105 } 106 107 108 109 58 $j('#usesAVC').change(function() { 59 if(!this.checked) { 60 $j('.videoConferenceOption, #needsAVCSupport').prop('checked', false); 61 } 62 }); 63 % endif 64 65 if (forms_are_valid()) { 66 set_repeatition_comment(); 67 } 68 69 $j('#bookingForm').delegate(':input', 'keyup change', function() { 70 forms_are_valid(); 71 }).submit(function(e) { 72 if (!forms_are_valid(true)) { 73 e.preventDefault(); 74 alert(${_("'There are errors in the form. Please correct the fields with red background.'")}); 75 }; 76 }).keydown(function(e) { 77 if(e.which == 13 && !$j(e.target).is('textarea, :submit')) { 78 e.preventDefault(); 79 $j('#saveBooking').click(); 80 } 81 }); 82 83 $j('#saveBooking').click(function(e) { 84 $j('#bookingForm').attr('action', '${saveBookingUH.getURL(conf)}'); 85 }); 86 $j('#checkBooking').click(function(e) { 87 $j('#bookingForm').attr('action', '${bookingFormURL}#conflicts'); 88 if (!validate_period($j('#bookingForm')[0], true, ${ allowPast })) { 89 alert(${_("'There are errors in the form. Please correct fields with red background.'")}); 90 e.preventDefault(); 91 } 92 }); 93 94 % if candResv.room.needsAVCSetup: 95 alert("The conference room you have chosen is equipped\nfor video-conferencing and video-projection.\nIf you need this equipment, DO NOT FORGET to select it.\nIf you don't need any of this equipment please choose\nanother room, if a suitable one is free on a suitable\nlocation for your meeting.\n\n\n Thank you for your understanding.") 96 % endif 97 }); 110 98 </script> 111 99 … … 129 117 <!-- END OF CONTEXT HELP DIVS --> 130 118 131 <form id="bookingForm" action="${bookingFormURL}#conflicts" method="post" onkeypress="return submit_on_enter(event);">119 <form id="bookingForm" action="${bookingFormURL}#conflicts" method="post"> 132 120 <input type="hidden" id="afterCalPreview" name="afterCalPreview" value="True" /> 133 121 <table cellpadding="0" cellspacing="0" border="0" width="80%"> … … 221 209 <% checked = """checked="checked" """ %> 222 210 % endif 223 <% htmlCheckbox = """<br>\n<input id="vc_%s" name="vc_%s" class="videoConferenceOption" type="checkbox" onclick="if(this.checked){$(usesAVC).checked=true;}"%s /> %s""" %>211 <% htmlCheckbox = """<br>\n<input id="vc_%s" name="vc_%s" class="videoConferenceOption" type="checkbox" %s /> %s""" %> 224 212 ${ htmlCheckbox % (vc[:3], vc[:3], checked, vc) } 225 213 % endfor … … 230 218 <td align="right" class="subFieldWidth" valign="top"><small><span style="color: Red;"> ${ _("I need assistance")}</span> </small></td> 231 219 <td align="left" class="blacktext"> 232 <input id="needsAVCSupport" name="needsAVCSupport" type="checkbox" ${' checked="checked" ' if candResv.needsAVCSupport else ""} onclick="if ( this.checked ) { $( 'usesAVC' ).checked = true; }"/>220 <input id="needsAVCSupport" name="needsAVCSupport" type="checkbox" ${' checked="checked" ' if candResv.needsAVCSupport else ""} /> 233 221 ${contextHelp('iNeedAVCSupport' )} 234 222 </td> … … 245 233 <input type="hidden" name="conf" value="${ conf.getId() if conf else ""}" /> 246 234 <input type="hidden" name="standalone" value="${ standalone }" /> 247 <input type="submit" class="btn" value="${ _("Re-check for conflicts")}" onclick="if (!validate_period(document.forms[0], true, ${ allowPast })) { alert( ${ _("'There are errors in the form. Please correct fields with red background.'")} ); return false; }"/>248 <input type="submit" class="btn" ${' value="Save" ' if formMode==FormMode.MODIF else ""} value="${ bookingMessage }" onclick="if (forms_are_valid( true )) { submit_booking(); } else { alert( ${ _("'There are errors in the form. Please correct fields with red background.'")} ); }; return false;" />235 <input type="submit" id="checkBooking" class="btn" value="${ _("Re-check for conflicts")}" /> 236 <input type="submit" id="saveBooking" class="btn" ${' value="Save" ' if formMode==FormMode.MODIF else ""} value="${ bookingMessage }" /> 249 237 ( 250 238 <input type="checkbox" name="skipConflicting" id="skipConflicting" ${' checked="checked" ' if skipConflicting else ""} /> … … 270 258 </form> 271 259 <br /> 272 <!-- Just to initialize -->273 <script type="text/javascript">274 Event.observe( window, 'load',275 function ()276 {277 if ( forms_are_valid() )278 set_repeatition_comment();279 new Form.Observer( 'bookingForm', 0.4, forms_are_valid );280 }281 );282 % if candResv.room.needsAVCSetup:283 alert("The conference room you have chosen is equiped\nfor video-conferencing and video-projection.\nIf you need this equipment, DO NOT FORGET to select it.\nIf you don't need any of this equipment please choose\nanother room, if a suitable one is free on a suitable\nlocation for your meeting.\n\n\n Thank you for your understanding.")284 % endif285 286 </script> -
indico/MaKaC/webinterface/tpls/RoomBookingPeriodForm.tpl
r988cfe r6282c5 2 2 <script type="text/javascript"> 3 3 4 // Removes red background from form fields.5 // Often calleed in the beginning of validation.6 function period_clean_redouts( f1 )7 {8 f1.sDay.className = f1.sMonth.className = f1.sYear.className = f1.sdate.className = '';9 f1.eDay.className = f1.eMonth.className = f1.eYear.className = f1.edate.className = '';10 f1.sTime.className = f1.eTime.className = '';11 f1.repeatability.className = '';12 }13 14 4 // Comments the repeatition for user, to make it clear 15 function set_repeatition_comment() 16 { 17 var repTypeSel = $('repeatability') 18 var repCom = $('repComment') 19 var s = '' 20 var repType = parseInt( repTypeSel.value, 10 ) 21 if ( repType > 0 ) 22 { 23 date = new Date( parseInt( $F('sYear'), 10 ), parseInt( $F('sMonth')-1, 10 ), parseInt( $F('sDay'), 10 ) ) 24 weekDays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] 25 s = 'on ' + weekDays[date.getDay()] 26 if ( repType == 4 ) 27 { 28 weekNr = Math.floor( date.getDate() / 7 ) + 1 29 postfix = ['st', 'nd', 'rd', 'th', 'th'] 30 weekNrStr = 'the ' + weekNr + postfix[weekNr-1] + ' ' 31 s = 'on ' + weekNrStr + weekDays[date.getDay()] + ' of a month' 5 function set_repeatition_comment() { 6 var s = ''; 7 var repType = parseInt($j('#repeatability').val(), 10); 8 if(repType > 0) { 9 date = new Date(parseInt($F('sYear'), 10), parseInt($F('sMonth')-1, 10), parseInt($F('sDay'), 10)); 10 weekDays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; 11 s = 'on ' + weekDays[date.getDay()]; 12 if(repType == 4) { 13 weekNr = Math.floor( date.getDate() / 7 ) + 1; 14 postfix = ['st', 'nd', 'rd', 'th', 'th']; 15 weekNrStr = 'the ' + weekNr + postfix[weekNr-1] + ' '; 16 s = 'on ' + weekNrStr + weekDays[date.getDay()] + ' of a month'; 32 17 } 33 18 } 34 repCom.innerHTML = s 35 36 /* 37 skipConflicts = $( '' ); 38 if ( skipConflicts ) 39 { 40 if ( repType == 0 ) skipConflicts.hide(); 41 else skipConflicts.show(); 42 } 43 */ 19 $j('#repComment').html(s); 44 20 } 45 21 -
indico/MaKaC/webinterface/tpls/RoomBookingSearch4Bookings.tpl
rc0de5a r6282c5 4 4 5 5 // Displays div with dates and hours 6 function period_clean_redouts( f1 ) 7 { 8 f1.sDay.className = f1.sMonth.className = f1.sYear.className = f1.sdate.className = '' 9 f1.eDay.className = f1.eMonth.className = f1.eYear.className = f1.edate.className = '' 10 f1.sTime.className = f1.eTime.className = '' 6 function all_date_fields_are_blank() { 7 return ($F('sDay')=='' && $F('sMonth')=='' && $F('sYear')=='' && $F('sdate')=='' && 8 $F('eDay')=='' && $F('eMonth')=='' && $F('eYear')=='' && $F('edate')==''); 11 9 } 12 function all_date_fields_are_blank() 13 { 14 return $F('sDay')=='' && $F('sMonth')=='' && $F('sYear')=='' && $F('sdate')=='' && $F('eDay')=='' && $F('eMonth')=='' && $F('eYear')=='' && $F('edate')=='' 15 } 16 function all_time_fields_are_blank() 17 { 18 return $F( 'sTime' ) == '' && $F( 'eTime' ) == '' 10 function all_time_fields_are_blank() { 11 return $F('sTime') == '' && $F('eTime') == ''; 19 12 } 20 13 21 14 // Reds out the invalid textboxes and returns false if something is invalid. 22 15 // Returns true if form may be submited. 23 function forms_are_valid( onSubmit ) 24 { 25 if ( onSubmit != true ) 16 function forms_are_valid(onSubmit) { 17 if (onSubmit != true) { 26 18 onSubmit = false; 19 } 27 20 28 21 // Clean up - make all textboxes white again 29 var f1 = $('searchForm')30 period_clean_redouts( f1 )22 var searchForm = $j('#searchForm'); 23 $j(':input', searchForm).removeClass('invalid'); 31 24 32 25 // Init 33 isValid = true26 var isValid = true; 34 27 35 28 // Simple search 36 if ( !all_date_fields_are_blank() ) 37 isValid = validate_period( f1, false, true, 1 ) // 1: validate only dates 38 if ( !all_time_fields_are_blank() ) 39 isValid = isValid && validate_period( f1, false, true, 2 ) // 2: validate only times 29 if (!all_date_fields_are_blank()) { 30 isValid = validate_period(searchForm[0], false, true, 1) // 1: validate only dates 31 } 32 if (!all_time_fields_are_blank()) { 33 isValid = isValid && validate_period(searchForm[0], false, true, 2) // 2: validate only times 34 } 40 35 41 36 // Holidays warning 42 if ( isValid && !onSubmit ) 43 { 44 var holidaysWarning = indicoSource('roomBooking.getDateWarning', $(f1).serialize(true)); 45 46 holidaysWarning.state.observe(function(state) { 47 if (state == SourceState.Loaded) { 48 $E('holidays-warning').set(holidaysWarning.get()); 49 } 50 }); 51 } 52 53 return isValid 37 if (isValid && !onSubmit) { 38 var lastDateInfo = searchForm.data('lastDateInfo'); 39 var dateInfo = $j('#sDay, #sMonth, #sYear, #eDay, #eMonth, #eYear').serialize(); 40 if (dateInfo != lastDateInfo) { 41 searchForm.data('lastDateInfo', dateInfo); 42 var holidaysWarning = indicoSource('roomBooking.getDateWarning', searchForm.serializeObject()); 43 44 holidaysWarning.state.observe(function(state) { 45 if (state == SourceState.Loaded) { 46 $E('holidays-warning').set(holidaysWarning.get()); 47 } 48 }); 49 } 50 } 51 52 return isValid; 54 53 } 55 54 56 function confirm_search() 57 { 58 if ( $F('onlyMy') ) 55 function confirm_search() { 56 if ($F('onlyMy')) { 59 57 return true; 60 if ( $F('roomGUID')[0] != undefined && $F('roomGUID')[0].length > 0 ) 58 } 59 if ($F('roomGUID')[0] !== undefined && $F('roomGUID')[0].length > 0) { 61 60 return true; 62 try { if ( $F('ofMyRooms') ) return true; } catch (err) {} 63 /*c = confirm( 'It is recommended to click "Cancel" and choose a room. Your query is very generic and it may take long time to process. Are you sure you want to continue?' ) 64 if ( c ) 65 { 66 $( 'submitBtn1' ).disabled = true; 67 $( 'submitBtn2' ).disabled = true; 68 }*/ 69 alert( 'Please select a room (or several rooms).' ) 61 } 62 try { if ($F('ofMyRooms')) { return true; } } catch (err) {} 63 alert('Please select a room (or several rooms).'); 70 64 return false; 71 65 } 72 66 73 IndicoUI.executeOnLoad(function() 74 { 75 76 var startDate = IndicoUI.Widgets.Generic.dateField_sdate(false,null,['sDay', 'sMonth', 'sYear']); 67 $j(window).load(function() { 68 var startDate = IndicoUI.Widgets.Generic.dateField_sdate(false, null, ['sDay', 'sMonth', 'sYear']); 77 69 $E('sDatePlace').set(startDate); 78 70 79 var endDate = IndicoUI.Widgets.Generic.dateField_edate(false, null,['eDay', 'eMonth', 'eYear']);71 var endDate = IndicoUI.Widgets.Generic.dateField_edate(false, null, ['eDay', 'eMonth', 'eYear']); 80 72 $E('eDatePlace').set(endDate); 81 73 … … 84 76 and if it's so we need to change it */ 85 77 startDate.observe(function(value) { 86 if ( IndicoUtil.parseDate(startDate.get()) > IndicoUtil.parseDate(endDate.get())) {78 if (IndicoUtil.parseDate(startDate.get()) > IndicoUtil.parseDate(endDate.get())) { 87 79 endDate.set(startDate.get()); 88 endDate.dom. onchange();80 endDate.dom.trigger('change'); 89 81 } 90 82 }); 91 83 92 84 endDate.observe(function(value) { 93 if ( IndicoUtil.parseDate(startDate.get()) > IndicoUtil.parseDate(endDate.get())) {85 if (IndicoUtil.parseDate(startDate.get()) > IndicoUtil.parseDate(endDate.get())) { 94 86 startDate.set(endDate.get()); 95 startDate.dom. onchange();96 } 97 }); 98 99 % if today.day != '':87 startDate.dom.trigger('change'); 88 } 89 }); 90 91 % if today.day != '': 100 92 startDate.set('${ today.day }/${ today.month }/${ today.year }'); 101 93 % endif … … 105 97 % endif 106 98 107 }); 99 $j('#onlyBookings').change(function() { 100 if(this.checked) { 101 $j('#onlyPrebookings').prop('checked', false); 102 } 103 }); 104 105 $j('#onlyPrebookings').change(function() { 106 if(this.checked) { 107 $j('#onlyBookings').prop('checked', false); 108 } 109 }); 110 111 $j('#searchForm').delegate(':input', 'keyup change', function() { 112 forms_are_valid(); 113 }).submit(function(e) { 114 if (!forms_are_valid(true)) { 115 alert(${_("'There are errors in the form. Please correct fields with red background.'")}); 116 e.preventDefault(); 117 } 118 else if(!confirm_search()) { 119 e.preventDefault(); 120 } 121 }); 122 }); 108 123 </script> 109 124 <!-- CONTEXT HELP DIVS --> … … 152 167 ${inlineContextHelp(_("You can select multiple rooms the same way you select multiple files in Windows - press (and hold) left mouse button and move the cursor. Alternatively you can use keyboard - hold SHIFT and press up/down arrows.") )} 153 168 <input type="hidden" name="search" value="on" /> 154 <!-- HACK to make form submitable with ENTER. This is just submit button copied and hidden. -->155 <input style="width: 0px; position:absolute; left: -50px;" type="submit" class="btn" onclick="if (!forms_are_valid( true )) { alert( ${ _("'There are errors in the form. Please correct fields with red background.'")} ); return false; }; return confirm_search();" value="${ _('Search') }" />156 169 </td> 157 170 </tr> … … 168 181 <td class="blacktext"> 169 182 <span id="sDatePlace"></span> 170 <input type="hidden" value="${ today.day }" name="sDay" id="sDay" onchange="this.form.eDay.value=this.value;"/>171 <input type="hidden" value="${ today.month }" name="sMonth" id="sMonth" onchange="this.form.eMonth.value=this.value;"/>172 <input type="hidden" value="${ today.year }" name="sYear" id="sYear" onchange="this.form.eYear.value=this.value;"/>183 <input type="hidden" value="${ today.day }" name="sDay" id="sDay" /> 184 <input type="hidden" value="${ today.month }" name="sMonth" id="sMonth" /> 185 <input type="hidden" value="${ today.year }" name="sYear" id="sYear" /> 173 186 </td> 174 187 </tr> … … 221 234 </tr> 222 235 </table> 223 <input id="submitBtn1" type="submit" class="btn" onclick="if (!forms_are_valid( true )) { alert( ${ _("'There are errors in the form. Please correct fields with red background.'")} ); return false; }; return confirm_search();" value="${ _('Search')}" />236 <input id="submitBtn1" type="submit" class="btn" value="${ _('Search')}" /> 224 237 </td> 225 238 </tr> … … 237 250 <td width="165px" align="right" valign="top"><small>Only Bookings </small></td> 238 251 <td align="left" class="blacktext" > 239 <input id="onlyBookings" name="onlyBookings" type="checkbox" onchange="javascript: if (this.checked) { $('onlyPrebookings').checked = false; }"/>252 <input id="onlyBookings" name="onlyBookings" type="checkbox" /> 240 253 ${inlineContextHelp(_("[v] Show only <b>Bookings</b>. If not checked, both pre-bookings and confirmed bookings will be shown.") )} 241 254 <br /> … … 245 258 <td width="165px" align="right" valign="top"><small>Only Pre-bookings </small></td> 246 259 <td align="left" class="blacktext" > 247 <input id="onlyPrebookings" name="onlyPrebookings" type="checkbox" onchange="javascript: if (this.checked) { $('onlyBookings').checked = false; }"/>260 <input id="onlyPrebookings" name="onlyPrebookings" type="checkbox" /> 248 261 ${inlineContextHelp(_("[v] Show only <b>PRE-bookings</b>. If not checked, both pre-bookings and confirmed bookings will be shown.") )} 249 262 <br /> … … 311 324 </tr> 312 325 </table> 313 <input id="submitBtn2" type="submit" class="btn" onclick="if (!forms_are_valid( true )) { alert( ${ _("'There are errors in the form. Please correct fields with red background.'")} ); return false; }; return confirm_search();" value="${ _("Search")}" />326 <input id="submitBtn2" type="submit" class="btn" value="${ _('Search')}" /> 314 327 </td> 315 328 </tr> … … 326 339 </tr> 327 340 </table> 328 <!-- Just to initialize -->329 <script type="text/javascript">330 Event.observe( window, 'load',331 function() { new Form.Observer( 'searchForm', 0.4, forms_are_valid ); }332 );333 </script> -
indico/MaKaC/webinterface/tpls/RoomBookingSearch4Rooms.tpl
rfb6f28 r6282c5 3 3 4 4 // Displays div with dates and hours 5 function display_availability( bool) 6 { 7 trs = $( 'sdatesTR', 'edatesTR', 'hoursTR', 'repTypeTR', 'includePrebookingsTR', 'includePendingBlockingsTR' ) 8 for ( i = 0; i < trs.length; i++ ) 9 { 10 if ( bool ) trs[i].style.display = '' // Show 11 if ( !bool ) trs[i].style.display = 'none' // Hide 12 } 5 function display_availability(bool) { 6 $j('#sdatesTR, #edatesTR, #hoursTR, #repTypeTR, #includePrebookingsTR, #includePendingBlockingsTR').toggle(bool); 13 7 } 14 8 // Reds out the invalid textboxes and returns false if something is invalid. 15 9 // Returns true if form may be submited. 16 function forms_are_valid( onSubmit ) 17 { 18 if ( onSubmit != true ) 10 function forms_are_valid(onSubmit) { 11 if (onSubmit != true) { 19 12 onSubmit = false; 13 } 20 14 21 15 // Clean up - make all textboxes white again 22 f1 = $('searchForm') 23 period_clean_redouts( f1 ) 24 f1.capacity.className = '' 25 16 var searchForm = $j('#searchForm'); 17 $j(':input', searchForm).removeClass('invalid'); 26 18 // Init 27 isValid = true19 var isValid = true; 28 20 29 21 // Simple search ------------------------------------- 30 22 // Availability 31 if ( !$('searchForm').availability[2].checked ) // only if NOT "Don't care" 32 { 33 isValid = validate_period( f1 ) 23 if (!$j('input[name="availability"]', searchForm).is(':checked')) { // only if NOT "Don't care" 24 isValid = validate_period(searchForm[0]); 34 25 } 35 26 // capacity 36 if ( $F( 'capacity' ).length > 0 && parseInt( $F( 'capacity' ), 10 ).toString() == 'NaN' ) 37 { 38 f1.capacity.className = 'invalid' 39 isValid = false 27 if ($F('capacity').length > 0 && parseInt($F('capacity'), 10).toString() == 'NaN') { 28 $j('#capacity').addClass('invalid'); 29 isValid = false; 40 30 } 41 31 42 32 // Holidays warning 43 if ( isValid && !onSubmit ) 44 { 45 var holidaysWarning = indicoSource('roomBooking.getDateWarning', $(f1).serialize(true)); 46 47 holidaysWarning.state.observe(function(state) { 48 if (state == SourceState.Loaded) { 49 $E('holidays-warning').set(holidaysWarning.get()); 50 } 51 }); 52 } 53 54 if (f1.sdate.value == '' ){ 55 f1.sdate.className = 'invalid' 56 isValid = false; 57 } 58 59 if (f1.edate.value == ''){ 60 f1.edate.className = 'invalid' 61 isValid = false; 62 } 63 64 return isValid 33 if (isValid && !onSubmit) { 34 var lastDateInfo = searchForm.data('lastDateInfo'); 35 var dateInfo = $j('#sDay, #sMonth, #sYear, #eDay, #eMonth, #eYear').serialize(); 36 if (dateInfo != lastDateInfo) { 37 searchForm.data('lastDateInfo', dateInfo); 38 var holidaysWarning = indicoSource('roomBooking.getDateWarning', searchForm.serializeObject()); 39 40 holidaysWarning.state.observe(function(state) { 41 if (state == SourceState.Loaded) { 42 $E('holidays-warning').set(holidaysWarning.get()); 43 } 44 }); 45 } 46 } 47 48 if (!$j('#sdate').val()) { 49 $j('#sdate').addClass('invalid'); 50 isValid = false; 51 } 52 53 if (!$j('#edate').val()) { 54 $j('#edate').addClass('invalid'); 55 isValid = false; 56 } 57 58 return isValid; 65 59 } 66 60 // Check whether a room can be booked (or pre-booked) by the user 67 61 // If not, pop up a dialog 68 function isBookable() 69 { 62 function isBookable() { 70 63 // Get the selected option in the SELECT 71 64 var selectedURL = $F('roomName'); … … 102 95 }); 103 96 } 97 98 $j(window).load(function() { 99 $j('#searchForm').delegate(':input', 'keyup change', function() { 100 forms_are_valid(); 101 }).submit(function(e) { 102 if (!forms_are_valid(true)) { 103 e.preventDefault(); 104 alert(${_("'There are errors in the form. Please correct the fields with red background.'")}); 105 }; 106 }); 107 108 if (forms_are_valid()) { 109 set_repeatition_comment(); 110 } 111 if ($j('#searchForm input[name="availability"]').is(':checked')) { // if "Don't care" about availability 112 display_availability(false); 113 } 114 $j('#searchForm input[name="availability"]').change(function() { 115 display_availability($j(this).data('showAvailability')); 116 }); 117 $j('#freeSearch').focus(); 118 }); 119 104 120 105 121 </script> … … 209 225 210 226 % if forNewBooking: 211 <span id="bookButtonWrapper"><input id="bookButton" class="btn" type="button" value="${ _("Book")}" onclick="isBookable();" /></span>227 <span id="bookButtonWrapper"><input id="bookButton" class="btn" type="button" value="${_("Book")}" onclick="isBookable();" /></span> 212 228 % endif 213 229 % if not forNewBooking: 214 <input class="btn" type="button" value="${ _("Room details")}" onclick="document.location = $F( 'roomName'); return false;" />230 <input class="btn" type="button" value="${ _("Room details")}" onclick="document.location = $F('roomName'); return false;" /> 215 231 % endif 216 232 … … 243 259 % endfor 244 260 </select> 245 <!-- HACK to make form submitable with ENTER. This is just submit button copied and hidden. -->246 <input style="width: 0px; position:absolute; left: -50px;" type="submit" class="btn" onclick="if (!forms_are_valid( true )) { alert( ${ _("'There are errors in the form. Please correct fields with red background.'")} ); return false; };" value="" />247 261 </td> 248 262 </tr> … … 273 287 <td class="subFieldWidth" align="right" ><small> ${ _("Must be")} </small></td> 274 288 <td align="left" class="blacktext"> 275 <input name="availability" type="radio" value="Available" onclick="display_availability( true );" ${'checked="checked"' if forNewBooking else ""} /> ${ _("Available")}276 <input name="availability" type="radio" value="Booked" onclick="display_availability( true ); "/> ${ _("Booked")}277 <input name="availability" type="radio" value="Don't care" onclick="display_availability( false )" ${'checked="checked"' if not forNewBooking else ""}/> ${ _("Don't care")}289 <input name="availability" type="radio" value="Available" data-show-availability="true" ${'checked="checked"' if forNewBooking else ""} /> ${ _("Available")} 290 <input name="availability" type="radio" value="Booked" data-show-availability="true" /> ${ _("Booked")} 291 <input name="availability" type="radio" value="Don't care" data-show-availability="false" ${'checked="checked"' if not forNewBooking else ""}/> ${ _("Don't care")} 278 292 ${contextHelp('availabilityHelp' )} 279 293 </td> … … 331 345 </tr> 332 346 <tr> 333 <td nowrap class="titleCellTD" style="width: 125px;"><span class="titleCellFormat"> ${ _("Special attributes")}</td> <td align="right"> 347 <td nowrap class="titleCellTD" style="width: 125px;"><span class="titleCellFormat"> ${ _("Special attributes")}</td> 348 <td align="right"> 334 349 <table width="100%" cellspacing="4px"> 335 350 <tr> … … 372 387 </td> 373 388 </tr> 374 <tr><td colspan="2" style="padding-left:20px"><input type="submit" class="btn" onclick="if (!forms_are_valid( true )) {alert( ${ _("'There are errors in the form. Please correct fields with red background.'")} ); return false; };"value="${ _('Search') }" /></td></tr>389 <tr><td colspan="2" style="padding-left:20px"><input type="submit" class="btn" value="${ _('Search') }" /></td></tr> 375 390 </table> 376 391 </form> … … 385 400 </tr> 386 401 </table> 387 <!-- Just to initialize -->388 <script type="text/javascript">389 Event.observe( window, 'load',390 function () {391 if ( forms_are_valid() )392 set_repeatition_comment();393 if ( $('searchForm').availability[2].checked ) // if "Don't care" about availability394 display_availability( false );395 $( 'freeSearch' ).focus();396 new Form.Observer( 'searchForm', 0.4, forms_are_valid );397 }398 );399 </script> -
indico/htdocs/js/indico/Legacy/Widgets.js
r4bbdbe r6282c5 931 931 if (update && p.inputField) { 932 932 p.inputField.value = cal.date.print(p.ifFormat); 933 if (typeof p.inputField.onchange == "function") 934 p.inputField.onchange(); 933 $j(p.inputField).trigger('change'); 935 934 } 936 935 if (update && p.displayArea)
Note: See TracChangeset
for help on using the changeset viewer.
