Ext.onReady(function(){ Ext.namespace('com.fcac.vehicle'); com.fcac.vehicle.years = [ ['2018'],['2017'],['2016'],['2015'],['2014'],['2013'],['2012'],['2011'],['2010'],['2009'],['2008'],['2007'],['2006'],['2005'],['2004'],['2003'],['2002'],['2001'],['2000'],['1999'],['1998'],['1997'],['1996'],['1995'],['1994'],['1993'],['1992'],['1991'],['1990'],['1989'],['1988'],['1987'],['1986'],['1985'],['1984'],['1983'] ]; var yearStore = new Ext.data.SimpleStore({ fields: ['year'], data: com.fcac.vehicle.years }); var vehicleStore = new Ext.data.JsonStore({ url: '/pricing/selectVehicle.action', root: 'data', fields: ['text', 'value'] }); var makeStore = new Ext.data.JsonStore({ url: '/pricing/selectVehicle.action', root: 'data', fields: ['text', 'value'] }); var modelStore = new Ext.data.JsonStore({ url: '/pricing/selectVehicle.action', root: 'data', fields: ['text', 'value'] }); var submodelStore = new Ext.data.JsonStore({ url: '/pricing/selectVehicle.action', root: 'data', fields: ['text', 'value', 'tpms', 'acesVehicleId'] }); var vehicleCombo = BFRC.dataCombo.cloneConfig({ store: vehicleStore, cls: 'vehicleCombo select' }); var yearCombo = vehicleCombo.cloneConfig({ id: 'year', store: yearStore, displayField: 'year', valueField: 'year', mode: 'local', emptyText: 'Year', transform: 'year', listeners: {select:{fn:function(combo, value) { var make = Ext.getCmp('make'); make.setValue(''); make.disable(); var model = Ext.getCmp('model'); model.setValue(''); model.disable(); var submodel = Ext.getCmp('submodel'); submodel.setValue(''); submodel.disable(); wipeHidden(); make.store.load({ params: { year: combo.getValue() }, callback: function() { var make = Ext.getCmp('make'); make.enable(); } }); }} }, width: 60 }); var makeCombo = vehicleCombo.cloneConfig({ id: 'make', emptyText: 'Make', transform: 'make', disabled: true, lastQuery: '', store: makeStore, listeners: {select:{fn:function(combo, value) { var model = Ext.getCmp('model'); model.setValue(''); model.disable(); var submodel = Ext.getCmp('submodel'); submodel.setValue(''); submodel.disable(); wipeHidden(); model.store.load({ params: { year: Ext.getCmp('year').getValue(), make: combo.getValue() }, callback: function() { var model = Ext.getCmp('model'); model.enable(); } }); }} } }); function setMakeModelHidden() { var makeCmp = Ext.getCmp('make'); var modelCmp = Ext.getCmp('model'); Ext.getDom('makeHidden').value = BFRC.getFirstLabelForValue(makeCmp); Ext.getDom('modelHidden').value = BFRC.getFirstLabelForValue(modelCmp); } var modelCombo = vehicleCombo.cloneConfig({ id: 'model', emptyText: 'Model', transform: 'model', disabled: true, lastQuery: '', store: modelStore, listeners: {select:{fn:function(combo, value) { setMakeModelHidden(); var submodel = Ext.getCmp('submodel'); submodel.setValue(''); submodel.disable(); wipeHidden(); submodel.store.load({ params: { year: Ext.getCmp('year').getValue(), make: Ext.getCmp('make').getValue(), model: combo.getValue() }, callback: function() { var submodel = Ext.getCmp('submodel'); if(submodel.store.getCount() == 1) { submodel.setValue(submodel.store.getAt(0).get('value')); submodel.fireEvent('select'); } submodel.enable(); } }); }} } }); var submodelCombo = vehicleCombo.cloneConfig({ id: 'submodel', emptyText: 'Submodel', transform: 'submodel', width: 90, listWidth: 400, disabled: true, lastQuery: '', store: submodelStore, listeners: {select:{fn:function(combo, value) { }} } }); var popupButton = Ext.get('popupButton'); if(popupButton != null) Ext.addBehaviors({'#popupButton@click' : function() { var maintForm = document.forms['maintenanceForm']; var acesVehicleId = maintForm.acesVehicleId.value; var submodel = maintForm['vehicle.submodel'].value; if(acesVehicleId == null || acesVehicleId == '' || submodel == null || submodel == '') { alert("Please select your vehicle"); return false; } var mileage = maintForm.initMileage.value; var mileageOk = false; if(mileage != null || mileage != '') { mileage = new Number(mileage); if(mileage != NaN && mileage > 0 && 1000000 > mileage) mileageOk = true; } if(!mileageOk) { alert('Please entire a mileage in 6 digits or less'); return false; } window.location.href = '/maintenance/listServices.action?mileage=' + mileage + '&acesVehicleId=' + acesVehicleId + '&submodel=' + submodel + '&tpms=' + maintForm.tpms.value; }}); function wipeHidden() { if(!Ext.getDom('hiddenYear')) return; Ext.getDom('hiddenYear').value = ''; /* Ext.getDom('hiddenMake').value = ''; Ext.getDom('hiddenModel').value = ''; */ Ext.getDom('hiddenSubmodel').value = ''; } function setHidden() { if(!Ext.getDom('hiddenYear')) return; Ext.getDom('hiddenYear').value = Ext.getCmp('year').getValue(); /* Ext.getDom('hiddenMake').value = Ext.getCmp('make').getValue(); Ext.getDom('hiddenModel').value = Ext.getCmp('model').getValue(); */ Ext.getDom('hiddenSubmodel').value = Ext.getCmp('submodel').getValue(); } function getHidden() { if(!Ext.getDom('hiddenYear')) return; var submodel = Ext.getDom('hiddenSubmodel').value; if(submodel != null && submodel != '' && submodel != 'Submodel') { Ext.getCmp('year').setValue(Ext.getDom('hiddenYear').value); Ext.getCmp('make').setValue(Ext.getDom('makeHidden').value); Ext.getCmp('model').setValue(Ext.getDom('modelHidden').value); Ext.getCmp('submodel').setValue(submodel); } } getHidden(); }); function submitPricing(method, geoPointId) { var frm = document.forms['vehicleSelector']; var zip = frm['zip'].value; var msg = "Please select:\n"; var error = false; if(!isValidZipCode(zip)) { msg += "Valid ZIP Code\n"; error = true; } if(method == null || method == '') method = 'vehicle'; if(method == 'size') { var cross = frm['cross'].value; var aspect = frm['aspect'].value; var rim = frm['rim'].value; if(cross == '') { msg += "Cross Section\n"; error = true; } if(aspect == '') { msg += "Aspect Ratio\n"; error = true; } if(rim == '') { msg += "Rim Size\n"; error = true; } } else { var vehMsg = checkVehicle(frm); if(vehMsg != '') { error = true; msg += vehMsg; } } if(error) { alert(msg); return false; } frm['method'].value = method; frm.action = "/pricing/selectStore.action"; frm.submit(); return false; } function checkVehicle(frm) { var msg = ''; var year = frm['vehicle.year'].value; var make = frm['vehicle.make'].value; var model = frm['vehicle.model'].value; var submodel = frm['vehicle.submodel'].value; if(year == null || year == '' || year == 'Year') { msg += "Year\n"; } if(make == null || make == '' || make == 'Make') { msg += "Make\n"; } if(model == null || model == '' || model == 'Model') { msg += "Model\n"; } if(submodel == null || submodel == '' || submodel == 'Submodel') { msg += "Submodel\n"; } return msg; }