/** * Author: Up and Running Software, Inc. * * Short Description: Displays the dialog box for entering an address. It handles several dialog boxes on the site interface. * * Library: jQuery */ function selectAddressDialog(backuri) { $('#address-dialog').innerHTML = $('#address-dialog-loading').innerHTML; $("#address-dialog").show("slow"); $("#address-dialog").dialog({ modal: true, overlay: { opacity: 0.5, background: "black" }, width: 500, height: 450 }); $("#address-dialog").load(base_url+"order/selectaddress/?ajax=1&back="+backuri); } /** * Save the selected address to the database */ function saveAddressDialog(){ form = $('#selectAddressForm'); form.ajaxSubmit({ url: base_url + '/order/setdeliveryaddress/?ajax=1', success: function(data){ $('#address-dialog').innerHTML = data; } }); } /** * Close the address dialog box */ function hideAddressDialog() { $("#address-dialog").dialog("close"); $("#address-dialog").hide("slow"); } /** * Close the select target time dialog box */ function hideTargetTimeDialog() { $("#targettime-dialog").dialog("close"); $("#targettime-dialog").hide("slow"); } /** * Show the select target time dialog box */ function showTargetTimeDialog(back_uri) { $("#targettime-dialog").show("slow"); $("#targettime-dialog").dialog({ modal: true, overlay: { opacity: 0.5, background: "black" }, width: 500, height: 450 }); $("#targettime-dialog").load(base_url+"order/targettime/?ajax=1&back="+back_uri); } /** * Update the interface depending on whether the ASAP box was checked on the target time form */ function checkAsapBox(){ if($('#asapbox').selectedIndex == 0){ $('#targetTimeSelector').style.display = 'none'; }else{ $('#targetTimeSelector').style.display = 'block'; } } /** * Validate the target time form */ function checkTimeInterval(){ var lower = parseInt($('#lower_window').options[$('#lower_window').selectedIndex].value); var upper = parseInt($('#upper_window').options[$('#upper_window').selectedIndex].value); var date = parseInt($('#window_date').options[$('#window_date').selectedIndex].value); var now = parseInt(new Date().getTime()/1000); if(lower > 0 && now > date+lower){ alert('The start of the window cannot be in the past.'); }else if(now > date+upper){ alert('The end of the window cannot be in the past.'); }else if(lower < 0 && $('#window_date').selectedIndex != 0){ alert('The ASAP option is only available when placing the order for today.'); }else if(lower < upper){ $('#targetTimeForm').submit(); }else{ alert('The start of the time window must be before the end of the time window.'); } } /** * Hide the radius select form */ function hideRadiusDialog() { $("#radius-dialog").dialog("close"); $("#radius-dialog").hide("slow"); } /** * Show the radius select dialog box */ function showRadiusDialog(back_uri) { $("#radius-dialog").show("slow"); $("#radius-dialog").dialog({ modal: true, overlay: { opacity: 0.5, background: "black" }, width: 500, height: 450 }); $("#radius-dialog").load(base_url+"restaurant/radius/?ajax=1&back="+back_uri); } /** * Show the restaurant map pane */ function showRTab(pane,id){ hideRTab(pane == 1 ? 2 : 1,id); $('#rtab_'+pane+'_'+id).className = 'gmaps_restaurant_tabbar_tab gmaps_restaurant_tabbar_tab_active'; $('#rtab_contents_'+pane+'_'+id).style.display = 'block'; } /** * Hide the restaurant map pane */ function hideRTab(pane,id){ $('#rtab_'+pane+'_'+id).className = 'gmaps_restaurant_tabbar_tab'; $('#rtab_contents_'+pane+'_'+id).style.display = 'none'; }