Rev 1464 | Rev 1580 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
$(function(){var utils = {resetProductSelector: function() {$('#product').html('<option value="-1">Select Product</option>').attr('disabled', 'true');},resetForm: function() {$('#communication_category').val("-1");$('#orderComponent, #awbComponent, #productComponent, #subjectComponent, #msgComponent').hide();this.resetProductSelector();$('#submit').attr('disabled', 'disabled');$('#resetFormButton').attr('disabled', 'disabled');},activateResetButton: function() {$('#resetFormButton').removeAttr('disabled');}};$('#resetFormButton').click(function() {utils.resetForm();});$('#communication_category').change(function(){$('#orderComponent, #awbComponent, #productComponent, #subjectComponent, #msgComponent').hide();$('#frmContactUs input[name="submit"]').removeAttr('disabled');utils.resetProductSelector();switch(parseInt($(this).val())) {case 1:$('#orderComponent, #productComponent, #subjectComponent, #msgComponent').show();$('#lblSubject').html('Reason');$('#reason_to_return').attr('name', 'subject').show();$('#delivery_problem, #subject').removeAttr('name').hide();jQuery.ajax({type: "GET",url: "/contact-us/to_return",success: function(data) {$("#order_id").html(data);}});lastQueryType = 1;utils.activateResetButton();break;case 2:$('#orderComponent, #subjectComponent, #msgComponent').show();$('#lblSubject').html('Reason');$('#subject').attr('name', 'subject').show();$('#delivery_problem, #reason_to_return').removeAttr('name').hide();jQuery.ajax({type: "GET",url: "/contact-us/to_cancel",success: function(data) {$("#order_id").html(data);}});lastQueryType = 2;utils.activateResetButton();break;case 3:$('#orderComponent, #subjectComponent, #msgComponent').show();$('#lblSubject').html('Problem Type');$('#delivery_problem').attr('name', 'subject').show();$('#reason_to_return, #subject').removeAttr('name').hide();checkAndUpdateOrderSelector();lastQueryType = 3;utils.activateResetButton();break;case 4:$('#orderComponent, #msgComponent').show();checkAndUpdateOrderSelector();lastQueryType = 4;utils.activateResetButton();break;case 5:$('#orderComponent, #msgComponent').show();checkAndUpdateOrderSelector();lastQueryType = 5;utils.activateResetButton();break;case 6:$('#subjectComponent, #msgComponent').show();$('#lblSubject').html('Product Title');$('#subject').attr('name', 'subject').show();$('#delivery_problem, #reason_to_return').removeAttr('name').hide();checkAndUpdateOrderSelector();lastQueryType = 6;utils.activateResetButton();break;case 7:$('#subjectComponent, #msgComponent').show();$('#lblSubject').html('Subject');$('#subject').attr('name', 'subject').show();$('#delivery_problem, #reason_to_return').removeAttr('name').hide();checkAndUpdateOrderSelector();lastQueryType = 7;utils.activateResetButton();break;default:utils.resetForm();break;}});function checkAndUpdateOrderSelector() {if (lastQueryType == 1 || lastQueryType == 2) {jQuery.ajax({type: "GET",url: "/contact-us/all_orders",success: function(data) {$("#order_id").html(data);}});}}$('#order_id').change(function(){var orderId = parseInt($(this).val());if(isNaN(orderId)) {alert("Order Id must be an integer");} else {jQuery.ajax({type: "GET",url: "/contact-us/" + orderId + "",success: function(data) {$("#product").removeAttr('disabled').html(data);}});}});$('form[name="frmContactUs"]').validate({rules: {email: {required: true,email: true},order_id: {required: true,digits: true}}});});