var LinUnitSelNew = LinUnitSelNew||{}; (function() { var _LOAD_DATA_MAX_TABS = 5; var $_orientationCustomRadio = null; var $_alphaInput = null; var $_betaInput = null; var $_mountingRadioProfile = null; var $_basicCycleTabRadio = null; var $_sectionHeaderCycle = null; var $_sectionHeaderSuitable = null; var _basicCycleElements = { strokeBox: null, startPositionBox: null, endPositionBox: null, entireCycleCheck: null, cycleInfoProfileTypeSelect: null, cycleInfoInputTypeSelect: null, cycleInfoProfileTypeImg: null, cycleInfoTotalTravelTimeBox: null, cycleInfoAccTimeBox: null, cycleInfoDecTimeBox: null, cycleInfoDelayTimeBox: null, cycleInfoPeakTravelSpeedBox: null, cycleInfoTotalTravelAccBox: null, cycleInfoTotalTravelDecBox: null, cycleInfoDeltaPosBox: null, cycleInfoTimeConstBox: null, cycleInfoVMaxBox: null, cycleInfoVStartBox: null, cycleInfoVEndBox: null, cycleInfoAccPathBox: null, cycleInfoDecPathBox: null, cycleInfoConstSpeedPathBox: null, cycleInfoCycleTimeBox: null, loadDataChangeCoordSystemCheck: null, loadDataModulOrientationImg: null, loadDataTabs: null, loadDataSingleFields: null, loadDataEditFields: { massOfLoad: null, massOfLoadDir: null, distanceX: null, distanceY: null, distanceZ: null, forceX: null, forceXDir: null, forceXDistanceY: null, forceXDistanceZ: null, forceY: null, forceYDir: null, forceYDistanceX: null, forceYDistanceZ: null, forceZ: null, forceZDir: null, forceZDistanceX: null, forceZDistanceY: null, momentX: null, momentXDir: null, momentY: null, momentYDir: null, momentZ: null, momentZDir: null, distributedLoadZ: null, distributedLoadZDir: null, distributedLoadY: null, distributedLoadYDir: null, accelerationX: null, accelerationXDir: null, accelerationY: null, accelerationYDir: null, accelerationZ: null, accelerationZDir: null }, displayTableCycleInfo: { table: null, unitRow: null, totalTimeBox: null }, displayTableLoadData: { table: null, unitRow: null } }; var _$basicCycleLoadDataSelectedSingleFields = null; var _advCycleElements = { editCycleContainer: null, strokeBox: null, startPositionBox: null, stepControls : { newStep: null, copyFromStep: null, resetInputs: null, clearAll: null }, cycleInfoStepNameBox: null, cycleInfoPositionBox: null, cycleInfoProfileTypeSelect: null, cycleInfoInputTypeSelect: null, cycleInfoProfileTypeImg: null, cycleInfoTotalTravelTimeBox: null, cycleInfoAccTimeBox: null, cycleInfoDecTimeBox: null, cycleInfoDelayTimeBox: null, cycleInfoPeakTravelSpeedBox: null, cycleInfoTotalTravelAccBox: null, cycleInfoTotalTravelDecBox: null, cycleInfoDeltaPosBox: null, cycleInfoTimeConstBox: null, cycleInfoVMaxBox: null, cycleInfoVStartBox: null, cycleInfoVEndBox: null, cycleInfoAccPathBox: null, cycleInfoDecPathBox: null, cycleInfoConstSpeedPathBox: null, cycleInfoCycleTimeBox: null, loadDataChangeCoordSystemCheck: null, loadDataModulOrientationImg: null, loadDataTabs: null, loadDataAddTab: null, loadDataSingleFields: null, loadDataEditFields: { massOfLoad: null, distanceX: null, distanceY: null, distanceZ: null, forceX: null, forceXDistanceY: null, forceXDistanceZ: null, forceY: null, forceYDistanceX: null, forceYDistanceZ: null, forceZ: null, forceZDistanceX: null, forceZDistanceY: null, momentX: null, momentY: null, momentZ: null, distributedLoadZ: null, distributedLoadY: null, accelerationX: null, accelerationY: null, accelerationZ: null }, acceptStepBtn: null, displayTableCycleInfo: { table: null, unitRow: null, totalTimeBox: null }, displayTableLoadData: { table: null, unitRow: null }, cyclesStepSingleFields: null }; var _advCycleCycleDataSelectedSingleFields = { index: 0, //When set it should always be greater than 0 div: null, loadTab: null }; var _CYCLE_DATA_TABLE_INDEX = { POSITION: 0, DELTA_POS: 1, TIME_TOTAL: 2, TIME_CONST: 3, TIME_ACC: 4, TIME_DEC: 5, TIME_DELAY: 6, V_MAX: 7, V_START: 8, V_END: 9, V_CONST_V_PEAK: 10, A_ACC: 11, A_DEC: 12, S_ACC: 13, S_DEC: 14, S_CONST: 15 }; var _advCycleCycleDataTable = []; var _dutyValueElements = { cyclesPerHour: null, workingHoursPerDay: null, workingDaysPerYear: null, requiredWorkingYears: null, dutyCycle: null, requiredWorkingHours: null, requiredCycles: null, highestTemp: null, lowestTemp: null }; var _additionalOptionsElements = { distanceABox: null, numberOfCarriagesSelect: null, rigidlyConnectedCarriagesCheck: null, rigidlyConnectedCarriagesImage: null, mountingSideSelect: null, mountingSideImage: null, motorMassBox: null, distanceAxialBox: null, distanceRightBox: null, distanceZBox: null }; var _supportElements = { supportRadiosDiv: null, consoleMounting: null, supportDriveBlock: null, supportTensionBlock: null, distanceSpan: null, distance_hx: null, distance_hy: null, distance_hz: null, poiImage: null }; var _suitableProducts = { listTab: null, detailsTab: null, listDiv: null, detailsDiv: null, list: { selectedTopPanel: null, selectedNameSpan: null, selectedValidOkSpan: null, selectedValidNotOkSpan: null, selectedValidResults: null, selectedDetailsLink: null, selectedNotesDiv: null, selectedNotesResults: null, selectedImage: null, filterSelect: null, onlySuitableCheck: null, table: null, noResultsDiv: null }, details: { orderCodeDiv: null, nameSpan: null, validOkSpan: null, validNotOkSpan: null, validResults: null, notesDiv: null, notesResults: null, image: null, realPrice: null, priceWithout: null, priceRebate: null, stockYes: null, stockNo: null, saveBtn: null, cannotBeOrderedDirectlyDiv: null, fileLinksDiv: null, specTab: null, accTab: null, specDiv: null, accDiv: null }, detailsUnitIdHidden: null, summaryUnitIdHidden: null }; var _suitableProductsListSelectedUnit = null; //Id of unit var _suitableProductsDetailSelectedUnit = null; //Id of unit var _lastValues = { alfaInput: null, betaInput: null, basicCycleStartPosition: null, basicCycleEndPosition: null, supportType: null }; var _templates = { loadTab: null, loadTabSingleFields: null, cycleStepSingleFields: null }; var _isBasicCycleUsed = function() { return !!$_basicCycleTabRadio.prop('checked'); }; /** * Number of decimal places for showing in data tables (by index in calculated values) */ var _roundingIndexes = { cycleInfoTable: [2,2,3,3,3,3,3,3,3,3,3,3,3,2,2,2], cycleLoadTable: [2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3] }; var vChartSimp = null, aChartSimp = null, sChartSimp = null; var vChartAdv = null, aChartAdv = null, sChartAdv = null; /** * Returns proper stroke box, based on which cycle is used (basic, advance). */ var _getProperStrokeBox = function() { if(_isBasicCycleUsed()) { return _basicCycleElements.strokeBox; } else { return _advCycleElements.strokeBox; } }; LinUnitSelNew.init = function(opts) { if(!!opts) { if(!!opts.loadDataMaxTabs) { _LOAD_DATA_MAX_TABS = parseInt(opts.loadDataMaxTabs); } } $_orientationCustomRadio = jQuery('#OrientationRadio_user'); $_alphaInput = jQuery('#alfaInput'); $_betaInput = jQuery('#betaInput'); $_mountingRadioProfile = jQuery('#MountingRadio_profile'); $_basicCycleTabRadio = jQuery('#advancedCycleUsedRadio_0'); $_sectionHeaderCycle = jQuery('#sec_header_cycle'); $_sectionHeaderSuitable = jQuery('#sec_header_suitable'); _basicCycleElements.strokeBox = jQuery('#strokeBox'); _basicCycleElements.startPositionBox = jQuery('#startPositionBox'); _basicCycleElements.endPositionBox = jQuery('#endPositionBox'); _basicCycleElements.entireCycleCheck = jQuery('#entireStrokeUsedCheck'); _basicCycleElements.cycleInfoProfileTypeSelect = jQuery('#basicCycleProfileTypeSelect'); _basicCycleElements.cycleInfoInputTypeSelect = jQuery('#basicCycleInputTypeSelect'); _basicCycleElements.cycleInfoProfileTypeImg = jQuery('#basicCycleprofilePicImg'); _basicCycleElements.cycleInfoTotalTravelTimeBox = jQuery('#basicCycleTotalTravelTimeBox'); _basicCycleElements.cycleInfoAccTimeBox = jQuery('#basicCycleAccTimeBox'); _basicCycleElements.cycleInfoDecTimeBox = jQuery('#basicCycleDecTimeBox'); _basicCycleElements.cycleInfoDelayTimeBox = jQuery('#basicCycleDelayTimeBox'); _basicCycleElements.cycleInfoPeakTravelSpeedBox = jQuery('#basicCyclePeakTravelSpeedBox'); _basicCycleElements.cycleInfoTotalTravelAccBox = jQuery('#basicCycleAccBox'); _basicCycleElements.cycleInfoTotalTravelDecBox = jQuery('#basicCycleDecBox'); _basicCycleElements.cycleInfoDeltaPosBox = jQuery('#basicCycleDeltaPosBox'); _basicCycleElements.cycleInfoTimeConstBox = jQuery('#basicCycleTimeConstBox'); _basicCycleElements.cycleInfoVMaxBox = jQuery('#basicCycleVMaxBox'); _basicCycleElements.cycleInfoVStartBox = jQuery('#basicCycleVStartBox'); _basicCycleElements.cycleInfoVEndBox = jQuery('#basicCycleVEndBox'); _basicCycleElements.cycleInfoAccPathBox = jQuery('#basicCycleAccPathBox'); _basicCycleElements.cycleInfoDecPathBox = jQuery('#basicCycleDecPathBox'); _basicCycleElements.cycleInfoConstSpeedPathBox = jQuery('#basicCycleConstSpeedPathBox'); _basicCycleElements.cycleInfoCycleTimeBox = jQuery('#basicCycleCycleTimeBox'); _basicCycleElements.loadDataChangeCoordSystemCheck = jQuery('#basicCycleMounting_case_carriage_loadsAtDriveBlockCheck'); _basicCycleElements.loadDataModulOrientationImg = jQuery('#basicCycleModulOrientationImg'); _basicCycleElements.loadDataTabs = jQuery('#basicCycleLoadDataTabs'); _basicCycleElements.loadDataSingleFields = jQuery('#basicCycleLoadDataSingleFields'); _basicCycleElements.loadDataEditFields.massOfLoad = jQuery('#basicCycleLoadDataMassOfLoadBox'); _basicCycleElements.loadDataEditFields.massOfLoadDir = jQuery('#basicCycleLoadDataMassOfLoadDir'); _basicCycleElements.loadDataEditFields.distanceX = jQuery('#basicCycleLoadDataDistanceXBox'); _basicCycleElements.loadDataEditFields.distanceY = jQuery('#basicCycleLoadDataDistanceYBox'); _basicCycleElements.loadDataEditFields.distanceZ = jQuery('#basicCycleLoadDataDistanceZBox'); _basicCycleElements.loadDataEditFields.forceX = jQuery('#basicCycleLoadDataForceXBox'); _basicCycleElements.loadDataEditFields.forceXDir = jQuery('#basicCycleLoadDataForceXDir'); _basicCycleElements.loadDataEditFields.forceXDistanceY = jQuery('#basicCycleLoadDataForceXDistYBox'); _basicCycleElements.loadDataEditFields.forceXDistanceZ = jQuery('#basicCycleLoadDataForceXDistZBox'); _basicCycleElements.loadDataEditFields.forceY = jQuery('#basicCycleLoadDataForceYBox'); _basicCycleElements.loadDataEditFields.forceYDir = jQuery('#basicCycleLoadDataForceYDir'); _basicCycleElements.loadDataEditFields.forceYDistanceX = jQuery('#basicCycleLoadDataForceYDistXBox'); _basicCycleElements.loadDataEditFields.forceYDistanceZ = jQuery('#basicCycleLoadDataForceYDistZBox'); _basicCycleElements.loadDataEditFields.forceZ = jQuery('#basicCycleLoadDataForceZBox'); _basicCycleElements.loadDataEditFields.forceZDir = jQuery('#basicCycleLoadDataForceZDir'); _basicCycleElements.loadDataEditFields.forceZDistanceX = jQuery('#basicCycleLoadDataForceZDistXBox'); _basicCycleElements.loadDataEditFields.forceZDistanceY = jQuery('#basicCycleLoadDataForceZDistYBox'); _basicCycleElements.loadDataEditFields.momentX = jQuery('#basicCycleLoadDataMomentXBox'); _basicCycleElements.loadDataEditFields.momentXDir = jQuery('#basicCycleLoadDataMomentXDir'); _basicCycleElements.loadDataEditFields.momentY = jQuery('#basicCycleLoadDataMomentYBox'); _basicCycleElements.loadDataEditFields.momentYDir = jQuery('#basicCycleLoadDataMomentYDir'); _basicCycleElements.loadDataEditFields.momentZ = jQuery('#basicCycleLoadDataMomentZBox'); _basicCycleElements.loadDataEditFields.momentZDir = jQuery('#basicCycleLoadDataMomentZDir'); _basicCycleElements.loadDataEditFields.distributedLoadZ = jQuery('#basicCycleLoadDataDistLoadZBox'); _basicCycleElements.loadDataEditFields.distributedLoadZDir = jQuery('#basicCycleLoadDataDistLoadZDir'); _basicCycleElements.loadDataEditFields.distributedLoadY = jQuery('#basicCycleLoadDataDistLoadYBox'); _basicCycleElements.loadDataEditFields.distributedLoadYDir = jQuery('#basicCycleLoadDataDistLoadYDir'); _basicCycleElements.loadDataEditFields.accelerationX = jQuery('#basicCycleLoadDataAccXBox'); _basicCycleElements.loadDataEditFields.accelerationXDir = jQuery('#basicCycleLoadDataAccXDir'); _basicCycleElements.loadDataEditFields.accelerationY = jQuery('#basicCycleLoadDataAccYBox'); _basicCycleElements.loadDataEditFields.accelerationYDir = jQuery('#basicCycleLoadDataAccYDir'); _basicCycleElements.loadDataEditFields.accelerationZ = jQuery('#basicCycleLoadDataAccZBox'); _basicCycleElements.loadDataEditFields.accelerationZDir = jQuery('#basicCycleLoadDataAccZDir'); _basicCycleElements.displayTableCycleInfo.table = jQuery('#basicCycleDisplayCycleTableInfo'); _basicCycleElements.displayTableCycleInfo.unitRow = _basicCycleElements.displayTableCycleInfo.table.find('.unit-row:first'); _basicCycleElements.displayTableCycleInfo.totalTimeBox = jQuery('#basicCycleTableTotalTimeBox'); _basicCycleElements.displayTableLoadData.table = jQuery('#basicCycleDisplayCycleTableLoad'); _basicCycleElements.displayTableLoadData.unitRow = _basicCycleElements.displayTableLoadData.table.find('.unit-row:first'); _advCycleElements.editCycleContainer = jQuery('#advCycleStepEditContainer'); _advCycleElements.strokeBox = jQuery('#strokeAdvancedBox'); _advCycleElements.startPositionBox = jQuery('#startPositionAdvancedBox'); _advCycleElements.cycleInfoStepNameBox = jQuery('#advCycleCycleNameBox'); _advCycleElements.stepControls.newStep = jQuery('#cycleDataAdvNewStepButton'); _advCycleElements.stepControls.resetInputs = jQuery('#cycleDataAdvResetStepButton'); _advCycleElements.stepControls.copyFromStep = jQuery('#cycleDataAdvCopyFromAnotherStepSelect'); _advCycleElements.stepControls.clearAll = jQuery('#cycleDataAdvClearAllButton'); _advCycleElements.cycleInfoPositionBox = jQuery('#advCyclePositionBox'); _advCycleElements.cycleInfoProfileTypeSelect = jQuery('#advCycleProfileTypeSelect'); _advCycleElements.cycleInfoInputTypeSelect = jQuery('#advCycleInputTypeSelect'); _advCycleElements.cycleInfoProfileTypeImg = jQuery('#advCycleprofilePicImg'); _advCycleElements.cycleInfoTotalTravelTimeBox = jQuery('#advCycleTotalTravelTimeBox'); _advCycleElements.cycleInfoAccTimeBox = jQuery('#advCycleAccTimeBox'); _advCycleElements.cycleInfoDecTimeBox = jQuery('#advCycleDecTimeBox'); _advCycleElements.cycleInfoDelayTimeBox = jQuery('#advCycleDelayTimeBox'); _advCycleElements.cycleInfoPeakTravelSpeedBox = jQuery('#advCyclePeakTravelSpeedBox'); _advCycleElements.cycleInfoTotalTravelAccBox = jQuery('#advCycleAccBox'); _advCycleElements.cycleInfoTotalTravelDecBox = jQuery('#advCycleDecBox'); _advCycleElements.cycleInfoDeltaPosBox = jQuery('#advCycleDeltaPosBox'); _advCycleElements.cycleInfoTimeConstBox = jQuery('#advCycleTimeConstBox'); _advCycleElements.cycleInfoVMaxBox = jQuery('#advCycleVMaxBox'); _advCycleElements.cycleInfoVStartBox = jQuery('#advCycleVStartBox'); _advCycleElements.cycleInfoVEndBox = jQuery('#advCycleVEndBox'); _advCycleElements.cycleInfoAccPathBox = jQuery('#advCycleAccPathBox'); _advCycleElements.cycleInfoDecPathBox = jQuery('#advCycleDecPathBox'); _advCycleElements.cycleInfoConstSpeedPathBox = jQuery('#advCycleConstSpeedPathBox'); _advCycleElements.cycleInfoCycleTimeBox = jQuery('#advCycleCycleTimeBox'); _advCycleElements.loadDataChangeCoordSystemCheck = jQuery('#advCycleMounting_case_carriage_loadsAtDriveBlockCheck'); _advCycleElements.loadDataModulOrientationImg = jQuery('#advCycleModulOrientationImg'); _advCycleElements.loadDataTabs = jQuery('#advCycleLoadDataTabs'); _advCycleElements.loadDataAddTab = jQuery('#advCycleLoadDataAddLoad'); _advCycleElements.loadDataSingleFields = jQuery('#advCycleLoadDataSingleFields'); _advCycleElements.loadDataEditFields.massOfLoad = jQuery('#advCycleLoadDataMassOfLoadBox'); _advCycleElements.loadDataEditFields.distanceX = jQuery('#advCycleLoadDataDistanceXBox'); _advCycleElements.loadDataEditFields.distanceY = jQuery('#advCycleLoadDataDistanceYBox'); _advCycleElements.loadDataEditFields.distanceZ = jQuery('#advCycleLoadDataDistanceZBox'); _advCycleElements.loadDataEditFields.forceX = jQuery('#advCycleLoadDataForceXBox'); _advCycleElements.loadDataEditFields.forceXDistanceY = jQuery('#advCycleLoadDataForceXDistYBox'); _advCycleElements.loadDataEditFields.forceXDistanceZ = jQuery('#advCycleLoadDataForceXDistZBox'); _advCycleElements.loadDataEditFields.forceY = jQuery('#advCycleLoadDataForceYBox'); _advCycleElements.loadDataEditFields.forceYDistanceX = jQuery('#advCycleLoadDataForceYDistXBox'); _advCycleElements.loadDataEditFields.forceYDistanceZ = jQuery('#advCycleLoadDataForceYDistZBox'); _advCycleElements.loadDataEditFields.forceZ = jQuery('#advCycleLoadDataForceZBox'); _advCycleElements.loadDataEditFields.forceZDistanceX = jQuery('#advCycleLoadDataForceZDistXBox'); _advCycleElements.loadDataEditFields.forceZDistanceY = jQuery('#advCycleLoadDataForceZDistYBox'); _advCycleElements.loadDataEditFields.momentX = jQuery('#advCycleLoadDataMomentXBox'); _advCycleElements.loadDataEditFields.momentY = jQuery('#advCycleLoadDataMomentYBox'); _advCycleElements.loadDataEditFields.momentZ = jQuery('#advCycleLoadDataMomentZBox'); _advCycleElements.loadDataEditFields.distributedLoadZ = jQuery('#advCycleLoadDataDistLoadZBox'); _advCycleElements.loadDataEditFields.distributedLoadY = jQuery('#advCycleLoadDataDistLoadYBox'); _advCycleElements.loadDataEditFields.accelerationX = jQuery('#advCycleLoadDataAccXBox'); _advCycleElements.loadDataEditFields.accelerationY = jQuery('#advCycleLoadDataAccYBox'); _advCycleElements.loadDataEditFields.accelerationZ = jQuery('#advCycleLoadDataAccZBox'); _advCycleElements.acceptStepBtn = jQuery('#advCycleAcceptStepInputBtn'); _advCycleElements.cyclesStepSingleFields = jQuery('#advCycleStepSingleFields'); _advCycleElements.displayTableCycleInfo.table = jQuery('#advCycleDisplayCycleTableInfo'); _advCycleElements.displayTableCycleInfo.unitRow = _advCycleElements.displayTableCycleInfo.table.find('.unit-row:first'); _advCycleElements.displayTableCycleInfo.totalTimeBox = jQuery('#advCycleTableTotalTimeBox'); _advCycleElements.displayTableLoadData.table = jQuery('#advCycleDisplayCycleTableLoad'); _advCycleElements.displayTableLoadData.unitRow = _advCycleElements.displayTableLoadData.table.find('.unit-row:first'); _dutyValueElements.cyclesPerHour = jQuery('#Number_of_cycles_perHourBox'); _dutyValueElements.workingHoursPerDay = jQuery('#Working_hours_perDayBox'); _dutyValueElements.workingDaysPerYear = jQuery('#Working_days_perYearBox'); _dutyValueElements.requiredWorkingYears = jQuery('#Required_yearsBox'); _dutyValueElements.dutyCycle = jQuery('#dutyCycleBox'); _dutyValueElements.requiredWorkingHours = jQuery('#requiredWorkingHoursBox'); _dutyValueElements.requiredCycles = jQuery('#requiredCyclesBox'); _dutyValueElements.highestTemp = jQuery('#Temperature_highBox'); _dutyValueElements.lowestTemp = jQuery('#Temperature_lowBox'); _supportElements.supportRadiosDiv = jQuery('#deflectionSupportRadios'); _supportElements.consoleMounting = jQuery('#Supporting_is_console_at_drive_blockSelect'); _supportElements.supportDriveBlock = jQuery('#Supporting_shift_to_drive_blockBox'); _supportElements.supportTensionBlock = jQuery('#Supporting_shift_to_tension_blockBox'); _supportElements.distanceSpan = jQuery('#Supporting_span_distancekBox'); _supportElements.distance_hx = jQuery('#Deflection_hxBox'); _supportElements.distance_hy = jQuery('#Deflection_hyBox'); _supportElements.distance_hz = jQuery('#Deflection_hzBox'); _supportElements.poiImage = jQuery('#deflectionPoiImage'); _additionalOptionsElements.distanceABox = jQuery('#DistanceAInputBox'); _additionalOptionsElements.numberOfCarriagesSelect = jQuery('#Number_of_carriages_blocksSelect'); _additionalOptionsElements.rigidlyConnectedCarriagesCheck = jQuery('#toga_povezava_vozickovCheck'); _additionalOptionsElements.rigidlyConnectedCarriagesImage = jQuery('#specialRigidlyConnectedImage'); _additionalOptionsElements.mountingSideSelect = jQuery('#Motor_position_is_right_to_linearUnitSelect'); _additionalOptionsElements.mountingSideImage = jQuery('#specialMountingSideImage'); _additionalOptionsElements.motorMassBox = jQuery('#Motor_MassBox'); _additionalOptionsElements.distanceAxialBox = jQuery('#Motor_hAxialBox'); _additionalOptionsElements.distanceRightBox = jQuery('#Motor_hRight_to_drive_blockBox'); _additionalOptionsElements.distanceZBox = jQuery('#Motor_hzBox'); _suitableProducts.listTab = jQuery('#suitProdsTabProdsList'); _suitableProducts.listDiv = jQuery('#suitableProductsList'); _suitableProducts.detailsTab = jQuery('#suitProdsTabProdDetails'); _suitableProducts.detailsDiv = jQuery('#suitableProductDetail'); _suitableProducts.list.selectedTopPanel = jQuery('#suitProdsProdsListSelectedDetail'); _suitableProducts.list.selectedDetailsLink = jQuery('#suitProdsSelProdDetailsLink'); _suitableProducts.list.selectedImage = jQuery('#suitProdsSelProdImage'); _suitableProducts.list.selectedNameSpan = jQuery('#suitProdsSelProdName'); _suitableProducts.list.selectedValidResults = jQuery('#suitProdsSelProdValidation'); _suitableProducts.list.selectedValidOkSpan = jQuery('#suitProdsValidationOKSpan'); _suitableProducts.list.selectedValidNotOkSpan = jQuery('#suitProdsValidationNotOKSpan'); _suitableProducts.list.selectedNotesDiv = jQuery('#suitProdsSelProdNotesDiv'); _suitableProducts.list.selectedNotesResults = jQuery('#suitProdsSelProdNotesUl'); _suitableProducts.list.filterSelect = jQuery('#suitProdsFilterSelect'); _suitableProducts.list.onlySuitableCheck = jQuery('#suitProdsViewOnlySuitableCheck'); _suitableProducts.list.table = jQuery('#suitProdsProdsTable'); _suitableProducts.list.noResultsDiv = jQuery('#suitProdsNoProdsDiv'); _suitableProducts.details.orderCodeDiv = jQuery('#suitProdsProdDetailsOrderCode'); _suitableProducts.details.nameSpan = jQuery('#suitProdsProdDetailsName'); _suitableProducts.details.validOkSpan = jQuery('#suitProdsProdDetailsValidationOKSpan'); _suitableProducts.details.validNotOkSpan = jQuery('#suitProdsProdDetailsValidationNotOKSpan'); _suitableProducts.details.validResults = jQuery('#suitProdsProdDetailsValidation'); _suitableProducts.details.notesDiv = jQuery('#suitProdsProdDetailsNotesDiv'); _suitableProducts.details.notesResults = jQuery('#suitProdsProdDetailsNotesUl'); _suitableProducts.details.image = jQuery('#suitProdsProdDetailsImage'); _suitableProducts.details.realPrice = jQuery('#suitProdsProdDetailsRealPrice'); _suitableProducts.details.priceWithout = jQuery('#suitProdsProdDetailsPriceWithout'); _suitableProducts.details.priceRebate = jQuery('#suitProdsProdDetailsRebate'); _suitableProducts.details.stockYes = jQuery('#suitProdsProdDetailsStockYes'); _suitableProducts.details.stockNo = jQuery('#suitProdsProdDetailsStockNo'); _suitableProducts.details.saveBtn = jQuery('#suitProdsProdDetailsSaveBtn'); _suitableProducts.details.cannotBeOrderedDirectlyDiv = jQuery('#suitProductsCannotBeOrderedDirectly'); _suitableProducts.details.fileLinksDiv = jQuery('#suitProdsProdDetailsFileLinks'); _suitableProducts.details.specTab = jQuery('#suitProdsProdDetailsTabSpec'); _suitableProducts.details.accTab = jQuery('#suitProdsProdDetailsTabAcc'); _suitableProducts.details.specDiv = jQuery('#suitProdsProdDetailsSpecs'); _suitableProducts.details.accDiv = jQuery('#suitProdsProdDetailsAccessories'); _suitableProducts.detailsUnitIdHidden = jQuery('#detailsUnitIdInput'); _suitableProducts.summaryUnitIdHidden = jQuery('#summaryUnitIdInput'); _templates.loadTab = jQuery('#ld-tab-template'); _templates.loadTabSingleFields = jQuery('#loadDataSingleLoadTemplate'); _templates.cycleStepSingleFields = jQuery('#cycleStepSingleStepTemplate'); _bindCheckFunctions(); //Init clicks to get proper states _basicCycleElements.cycleInfoProfileTypeSelect.change(); _supportElements.consoleMounting.closest('.support-type').find('input[name=Supporting]:checked').click(); //Basic Cycle - Init loadDataDivs _basicCycleElements.loadDataSingleFields.children().each(function() { _initLoadDataSingleFieldDiv(jQuery(this), true); }); //Basic Cycle - Select tab var anyLoadTabSelected = false; var loadTabs = _basicCycleElements.loadDataTabs.children(); loadTabs.each(function() { if(jQuery(this).hasClass('selected')) { anyLoadTabSelected = true; _selectLoadTab(jQuery(this), true); return false; } }); if(!anyLoadTabSelected && loadTabs.length>0) { _selectLoadTab(loadTabs.eq(0), true); } _generateBasicCycleInfoTableHtml(); _generateBasicLoadDataTableHtml(); //Advanced cycle - Init cycleStepsFields _advCycleElements.cyclesStepSingleFields.children().each(function() { _initCycleStepSingleFieldDiv(jQuery(this)); }); _generateAdvancedCycleInfoTableAndHtml(); _generateAdvancedLoadDataTableHtml(); _supportElementsSectionValidate(); _additionalOptionsElements.numberOfCarriagesSelect.change(); _suitableProducts.list.filterSelect.change(); _lastValues.alfaInput = $_alphaInput.val(); _lastValues.betaInput = $_betaInput.val(); }; /** * Common check function for checking if string is numeric value. */ var _commonNumericCheckFn = function(val) { if(!Common.isStringNumber(val)) { return ''; } return null; }; var _bindCheckFunctions = function() { _basicCycleElements.strokeBox[0].checkFn = function(val) { if(!Common.isStringNumber(val)) { return ''; } var ival = _getFloatFromString(val); if(ival <= 0) { return 'Value must be greater than 0.'; } return null; }; _basicCycleElements.startPositionBox[0].checkFn = function(val) { if(!Common.isStringNumber(val)) { return ''; } var ival = _getFloatFromString(val); var sval = _getFloatFromInput(_basicCycleElements.strokeBox); var endval = _getFloatFromInput(_basicCycleElements.endPositionBox); if(ival < 0) { return 'Value cannot be less than 0.'; } else if(ival > sval) { return 'Value cannot exceed stroke value.'; } else if(ival > endval) { return 'Value cannot exceed end position.'; } return null; }; _basicCycleElements.endPositionBox[0].checkFn = function(val) { if(!Common.isStringNumber(val)) { return ''; } var ival = _getFloatFromString(val); var sval = _getFloatFromInput(_basicCycleElements.strokeBox); var startval = _getFloatFromInput(_basicCycleElements.startPositionBox) || 0; if(ival < 0) { return 'Value cannot be less than 0.'; } else if(ival > sval) { return 'Value cannot exceed stroke value.'; } else if(ival < startval) { return 'Value cannot be less than start position.'; } return null; }; _advCycleElements.strokeBox[0].checkFn = function(val) { if(!Common.isStringNumber(val)) { return ''; } var ival = _getFloatFromString(val); if(ival <= 0) { return 'Value must be greater than 0.'; } return null; }; _advCycleElements.startPositionBox[0].checkFn = function(val) { if(!Common.isStringNumber(val)) { return ''; } var ival = _getFloatFromString(val); var sval = _getFloatFromInput(_advCycleElements.strokeBox); if(ival < 0) { return 'Value cannot be less than 0.'; } else if(ival > sval) { return 'Value cannot exceed stroke value.'; } return null; }; _dutyValueElements.cyclesPerHour[0].checkFn = function(val) { if(!Common.isStringNumber(val)) { return ''; } var ival = _getFloatFromString(val); if(ival < 0 && ival != -112) { return 'Value cannot be less than 0.'; } return null; }; _dutyValueElements.workingHoursPerDay[0].checkFn = function(val) { if(!Common.isStringNumber(val)) { return ''; } var ival = _getFloatFromString(val); if(ival < 0) { return 'Value cannot be less than 0.'; } else if(ival > 24) { return 'Too many hours in day.'; } return null; }; _dutyValueElements.workingDaysPerYear[0].checkFn = function(val) { if(!Common.isStringNumber(val)) { return ''; } var ival = _getFloatFromString(val); if(ival < 0) { return 'Value cannot be less than 0.'; } else if(ival > 366) { return 'Too many days in year.'; } return null; }; _dutyValueElements.requiredWorkingYears[0].checkFn = function(val) { if(!Common.isStringNumber(val)) { return ''; } var ival = _getFloatFromString(val); if(ival < 0) { return 'Value cannot be less than 0.'; } return null; }; _supportElements.supportDriveBlock[0].checkFn = function(val) { if(!Common.isStringNumber(val)) { return ''; } var ival = _getFloatFromString(val); var sval = _getFloatFromInput(_getProperStrokeBox()); if(ival < 0) { return 'Value cannot be less than 0.'; } else if(!sval || ival > sval) { return 'Value cannot exceed stroke value.'; } return null; }; _supportElements.supportTensionBlock[0].checkFn = function(val) { if(!Common.isStringNumber(val)) { return ''; } var ival = _getFloatFromString(val); var sval = _getFloatFromInput(_getProperStrokeBox()); if(ival < 0) { return 'Value cannot be less than 0.'; } else if(!sval || ival > sval) { return 'Value cannot exceed stroke value.'; } return null; }; _supportElements.distanceSpan[0].checkFn = function(val) { if(!Common.isStringNumber(val)) { return ''; } var ival = _getFloatFromString(val); var sval = _getFloatFromInput(_getProperStrokeBox()); if(ival < 0) { return 'Value cannot be less than 0.'; } else if(!sval || ival > sval) { return 'Value cannot exceed stroke value.'; } return null; }; _additionalOptionsElements.distanceABox[0].checkFn = function(val) { if(!Common.isStringNumber(val)) { return ''; } var ival = _getFloatFromString(val); if(ival < 0) { return 'Value cannot be less than 0.'; } return null; }; $_alphaInput.on('keyup change', function() { _checkFieldValue($_alphaInput, _commonNumericCheckFn); }); $_betaInput.on('keyup change', function() { _checkFieldValue($_betaInput, _commonNumericCheckFn); }); _basicCycleElements.strokeBox.on('change', function() { _advCycleElements.strokeBox.val(_basicCycleElements.strokeBox.val()); _advCycleElements.strokeBox.keyup(); }); _basicCycleElements.strokeBox.on('keyup', function() { var success = _checkFieldValue(_basicCycleElements.strokeBox); if(!!_basicCycleElements.entireCycleCheck[0].checked) { _basicCycleElements.endPositionBox.val(_getFloatFromInput(_basicCycleElements.strokeBox) || 0); } if(!!success) { _checkFieldValue(_basicCycleElements.startPositionBox); _checkFieldValue(_basicCycleElements.endPositionBox); _basicCycleElements.cycleInfoInputTypeSelect.change(); _supportElementsSectionValidate(); } _setSectionErrorMsgVisibility(this, 'cycle'); }); _basicCycleElements.startPositionBox.on('change', function() { _advCycleElements.startPositionBox.val(_basicCycleElements.startPositionBox.val()); _advCycleElements.startPositionBox.keyup(); }); _basicCycleElements.startPositionBox.on('keyup', function() { var success = _checkFieldValue(_basicCycleElements.startPositionBox); if(!!success) { _basicCycleElements.cycleInfoInputTypeSelect.change(); } _setSectionErrorMsgVisibility(this, 'cycle'); }); _basicCycleElements.endPositionBox.on('change keyup', function() { var success = _checkFieldValue(_basicCycleElements.endPositionBox); if(!!success) { _basicCycleElements.cycleInfoInputTypeSelect.change(); } _setSectionErrorMsgVisibility(this, 'cycle'); }); _basicCycleElements.cycleInfoProfileTypeSelect.change(function() { _changeProfileTypeInputImage(this, true); _generateBasicCycleInfoTableHtml(true); _setSectionErrorMsgVisibility(this, 'cycle'); }); _basicCycleElements.cycleInfoInputTypeSelect.change(function() { _generateBasicCycleInfoTableHtml(true); _setSectionErrorMsgVisibility(this, 'cycle'); }); _basicCycleElements.cycleInfoTotalTravelTimeBox.on('change keyup', function() { var success = _checkFieldValue(_basicCycleElements.cycleInfoTotalTravelTimeBox, _commonNumericCheckFn); if(!!success) { _generateBasicCycleInfoTableHtml(true); } _setSectionErrorMsgVisibility(this, 'cycle'); }); _basicCycleElements.cycleInfoAccTimeBox.on('change keyup', function() { var success = _checkFieldValue(_basicCycleElements.cycleInfoAccTimeBox, _commonNumericCheckFn); if(!!success) { _generateBasicCycleInfoTableHtml(true); } _setSectionErrorMsgVisibility(this, 'cycle'); }); _basicCycleElements.cycleInfoDecTimeBox.on('change keyup', function() { var success = _checkFieldValue(_basicCycleElements.cycleInfoDecTimeBox, _commonNumericCheckFn); if(!!success) { _generateBasicCycleInfoTableHtml(true); } _setSectionErrorMsgVisibility(this, 'cycle'); }); _basicCycleElements.cycleInfoDelayTimeBox.on('change keyup', function() { var success = _checkFieldValue(_basicCycleElements.cycleInfoDelayTimeBox, _commonNumericCheckFn); if(!!success) { _generateBasicCycleInfoTableHtml(true); } _setSectionErrorMsgVisibility(this, 'cycle'); }); _basicCycleElements.cycleInfoPeakTravelSpeedBox.on('change keyup', function() { var success = _checkFieldValue(_basicCycleElements.cycleInfoPeakTravelSpeedBox, _commonNumericCheckFn); if(!!success) { _generateBasicCycleInfoTableHtml(true); } _setSectionErrorMsgVisibility(this, 'cycle'); }); _basicCycleElements.cycleInfoTotalTravelAccBox.on('change keyup', function() { var success = _checkFieldValue(_basicCycleElements.cycleInfoTotalTravelAccBox, _commonNumericCheckFn); if(!!success) { _generateBasicCycleInfoTableHtml(true); } _setSectionErrorMsgVisibility(this, 'cycle'); }); _basicCycleElements.cycleInfoTotalTravelDecBox.on('change keyup', function() { var success = _checkFieldValue(_basicCycleElements.cycleInfoTotalTravelDecBox, _commonNumericCheckFn); if(!!success) { _generateBasicCycleInfoTableHtml(true); } _setSectionErrorMsgVisibility(this, 'cycle'); }); //Change events on load data boxes for(var key in _basicCycleElements.loadDataEditFields) { _basicCycleElements.loadDataEditFields[key].on('change keyup', function() { _loadDataSetSelectedLoadFieldsFromEdit(true, true); if(this.id.endsWith('Box')) { //Check for numeric values if(!_checkFieldValue(jQuery(this), _commonNumericCheckFn) || jQuery(this).closest('.load-data-inputs').find('.field-div.error:first').length>0) { _setSectionErrorMsgVisibility(this, 'cycle'); _basicCycleElements.loadDataTabs.find('.selected').addClass('error'); return; //Error in data } _basicCycleElements.loadDataTabs.find('.selected').removeClass('error'); //All is OK } if(this.id == 'basicCycleLoadDataForceXBox' || this.id == 'basicCycleLoadDataForceYBox' || this.id == 'basicCycleLoadDataForceZBox') { _loadDataForceBoxChange(this); } else if(this.id == 'basicCycleLoadDataAccXBox' || this.id == 'basicCycleLoadDataAccYBox' || this.id == 'basicCycleLoadDataAccZBox' || this.id == 'basicCycleLoadDataAccXDir' || this.id == 'basicCycleLoadDataAccYDir' || this.id == 'basicCycleLoadDataAccZDir') { //Set all other load data from first one var $children = _basicCycleElements.loadDataSingleFields.children(); if($children.length > 0) { var _firstFlds = $children[0]._flds; for(var chi=1; chi<$children.length; chi++) { var _newFlds = $children[chi]._flds; _newFlds.accelerationX.val(_firstFlds.accelerationX.val()); _newFlds.accelerationY.val(_firstFlds.accelerationY.val()); _newFlds.accelerationZ.val(_firstFlds.accelerationZ.val()); _newFlds.accelerationXDir.val(_firstFlds.accelerationXDir.val()); _newFlds.accelerationYDir.val(_firstFlds.accelerationYDir.val()); _newFlds.accelerationZDir.val(_firstFlds.accelerationZDir.val()); } } } _setSectionErrorMsgVisibility(this, 'cycle'); _generateBasicLoadDataTableHtml(); }); }; _advCycleElements.strokeBox.on('change', function() { _basicCycleElements.strokeBox.val(_advCycleElements.strokeBox.val()); _basicCycleElements.strokeBox.change(); _basicCycleElements.strokeBox.keyup(); }); _advCycleElements.strokeBox.on('keyup', function() { _checkFieldValue(_advCycleElements.strokeBox); _checkFieldValue(_advCycleElements.startPositionBox); if(!!_advCycleCycleDataSelectedSingleFields.index) { //Something is selected _advCycleElements.cycleInfoInputTypeSelect.change(); } else { _advCycleSetSaveStepEnabled(this); } _setSectionErrorMsgVisibility(this, 'cycle'); _supportElementsSectionValidate(); }); _advCycleElements.startPositionBox.on('change', function() { if(!_basicCycleElements.entireCycleCheck[0].checked) { _basicCycleElements.startPositionBox.val(_advCycleElements.startPositionBox.val()); _basicCycleElements.startPositionBox.change(); _basicCycleElements.startPositionBox.keyup(); } else { _lastValues.basicCycleStartPosition = _advCycleElements.startPositionBox.val(); } }); _advCycleElements.startPositionBox.on('keyup', function() { _checkFieldValue(_advCycleElements.startPositionBox); if(!!_advCycleCycleDataSelectedSingleFields.index) { //Something is selected _advCycleElements.cycleInfoInputTypeSelect.change(); } else { _advCycleSetSaveStepEnabled(this); } _setSectionErrorMsgVisibility(this, 'cycle'); _generateAdvancedCycleInfoTableAndHtml(); }); _advCycleElements.stepControls.copyFromStep.change(function() { var val = jQuery(this).val(); //Get div var $sourceDiv = _advCycleElements.cyclesStepSingleFields.find('#cycleStepSingleFields_'+val); if($sourceDiv.length > 0) { _cycleDataSetEditCycleFieldsFromSelected($sourceDiv); jQuery(this).val(''); _advCycleElements.cycleInfoInputTypeSelect.change(); } }); _advCycleElements.cycleInfoProfileTypeSelect.change(function() { _changeProfileTypeInputImage(this, false); var val = jQuery(this).val(); //Hide/Show v/a if(val == 'constant') { if(_advCycleElements.cycleInfoInputTypeSelect.val() == 'v/a') { _advCycleElements.cycleInfoInputTypeSelect.val('t'); } _advCycleElements.cycleInfoInputTypeSelect.find('[value!=t]').hide(); } else { _advCycleElements.cycleInfoInputTypeSelect.find('[value!=t]').show(); } if(!!_advCycleCycleDataSelectedSingleFields.div) { _calculateCycleInfoRow(false, null, _advCycleCycleDataTable[_advCycleCycleDataSelectedSingleFields.index-1]); _advCycleSetSaveStepEnabled(this); } }); _advCycleElements.cycleInfoInputTypeSelect.change(function() { if(!!_advCycleCycleDataSelectedSingleFields.div) { _calculateCycleInfoRow(false, null, _advCycleCycleDataTable[_advCycleCycleDataSelectedSingleFields.index-1]); _advCycleSetSaveStepEnabled(this); } }); _advCycleElements.cycleInfoPositionBox.on('change keyup', function() { if(!!_advCycleCycleDataSelectedSingleFields.div) { var success = _checkFieldValue(_advCycleElements.cycleInfoPositionBox, _commonNumericCheckFn); if(!!success) { _calculateCycleInfoRow(false, null, _advCycleCycleDataTable[_advCycleCycleDataSelectedSingleFields.index-1]); } _advCycleSetSaveStepEnabled(this); } }); _advCycleElements.cycleInfoTotalTravelTimeBox.on('change keyup', function() { if(!!_advCycleCycleDataSelectedSingleFields.div) { var success = _checkFieldValue(_advCycleElements.cycleInfoTotalTravelTimeBox, _commonNumericCheckFn); if(!!success) { _calculateCycleInfoRow(false, null, _advCycleCycleDataTable[_advCycleCycleDataSelectedSingleFields.index-1]); } _advCycleSetSaveStepEnabled(this); } }); _advCycleElements.cycleInfoAccTimeBox.on('change keyup', function() { if(!!_advCycleCycleDataSelectedSingleFields.div) { var success = _checkFieldValue(_advCycleElements.cycleInfoAccTimeBox, _commonNumericCheckFn); if(!!success) { _calculateCycleInfoRow(false, null, _advCycleCycleDataTable[_advCycleCycleDataSelectedSingleFields.index-1]); } _advCycleSetSaveStepEnabled(this); } }); _advCycleElements.cycleInfoDecTimeBox.on('change keyup', function() { if(!!_advCycleCycleDataSelectedSingleFields.div) { var success = _checkFieldValue(_advCycleElements.cycleInfoDecTimeBox, _commonNumericCheckFn); if(!!success && jQuery(this).closest('.inputs').find('.field-div.error:first').length==0) { _calculateCycleInfoRow(false, null, _advCycleCycleDataTable[_advCycleCycleDataSelectedSingleFields.index-1]); } _advCycleSetSaveStepEnabled(this); } }); _advCycleElements.cycleInfoDelayTimeBox.on('change keyup', function() { if(!!_advCycleCycleDataSelectedSingleFields.div) { var success = _checkFieldValue(_advCycleElements.cycleInfoDelayTimeBox, _commonNumericCheckFn); if(!!success) { _calculateCycleInfoRow(false, null, _advCycleCycleDataTable[_advCycleCycleDataSelectedSingleFields.index-1]); } _advCycleSetSaveStepEnabled(this); } }); _advCycleElements.cycleInfoPeakTravelSpeedBox.on('change keyup', function() { if(!!_advCycleCycleDataSelectedSingleFields.div) { var success = _checkFieldValue(_advCycleElements.cycleInfoPeakTravelSpeedBox, _commonNumericCheckFn); if(!!success) { _calculateCycleInfoRow(false, null, _advCycleCycleDataTable[_advCycleCycleDataSelectedSingleFields.index-1]); } _advCycleSetSaveStepEnabled(this); } }); _advCycleElements.cycleInfoTotalTravelAccBox.on('change keyup', function() { if(!!_advCycleCycleDataSelectedSingleFields.div) { var success = _checkFieldValue(_advCycleElements.cycleInfoTotalTravelAccBox, _commonNumericCheckFn); if(!!success) { _calculateCycleInfoRow(false, null, _advCycleCycleDataTable[_advCycleCycleDataSelectedSingleFields.index-1]); } _advCycleSetSaveStepEnabled(this); } }); _advCycleElements.cycleInfoTotalTravelDecBox.on('change keyup', function() { if(!!_advCycleCycleDataSelectedSingleFields.div) { var success = _checkFieldValue(_advCycleElements.cycleInfoTotalTravelDecBox, _commonNumericCheckFn); if(!!success) { _calculateCycleInfoRow(false, null, _advCycleCycleDataTable[_advCycleCycleDataSelectedSingleFields.index-1]); } _advCycleSetSaveStepEnabled(this); } }); //Change events on load data boxes for(var key in _advCycleElements.loadDataEditFields) { _advCycleElements.loadDataEditFields[key].on('change keyup', function() { _loadDataSetSelectedLoadFieldsFromEdit(false, true); if(this.id.endsWith('Box')) { //Check for numeric values if(!_checkFieldValue(jQuery(this), _commonNumericCheckFn) || jQuery(this).closest('.load-data-inputs').find('.field-div.error:first').length>0) { _advCycleElements.loadDataTabs.find('.selected').addClass('error'); _advCycleSetSaveStepEnabled(this); return; //Error in data } _advCycleElements.loadDataTabs.find('.selected').removeClass('error'); _advCycleSetSaveStepEnabled(this); } if(this.id == 'advCycleLoadDataForceXBox' || this.id == 'advCycleLoadDataForceYBox' || this.id == 'advCycleLoadDataForceZBox') { _loadDataForceBoxChange(this); } else if(this.id == 'advCycleLoadDataAccXBox' || this.id == 'advCycleLoadDataAccYBox' || this.id == 'advCycleLoadDataAccZBox') { //Set all other load data from first one var $children = _advCycleElements.loadDataSingleFields.children(); if($children.length > 0) { var _firstFlds = $children[0]._flds; for(var chi=1; chi<$children.length; chi++) { var _newFlds = $children[chi]._flds; _newFlds.accelerationX.val(_firstFlds.accelerationX.val()); _newFlds.accelerationY.val(_firstFlds.accelerationY.val()); _newFlds.accelerationZ.val(_firstFlds.accelerationZ.val()); } } } _generateAdvancedLoadDataTableHtml(); }); } _dutyValueElements.cyclesPerHour.on('change keyup', function() { _checkFieldValue(_dutyValueElements.cyclesPerHour); _recalculateDutyCycles(); _setSectionErrorMsgVisibility(this, 'duty'); }); _dutyValueElements.workingHoursPerDay.on('change keyup', function() { _checkFieldValue(_dutyValueElements.workingHoursPerDay); _recalculateDutyCycles(); _setSectionErrorMsgVisibility(this, 'duty'); }); _dutyValueElements.workingDaysPerYear.on('change keyup', function() { _checkFieldValue(_dutyValueElements.workingDaysPerYear); _recalculateDutyCycles(); _setSectionErrorMsgVisibility(this, 'duty'); }); _dutyValueElements.requiredWorkingYears.on('change keyup', function() { _checkFieldValue(_dutyValueElements.requiredWorkingYears); _recalculateDutyCycles(); _setSectionErrorMsgVisibility(this, 'duty'); }); _dutyValueElements.highestTemp.on('change keyup', function() { _checkFieldValue(_dutyValueElements.highestTemp, _commonNumericCheckFn); _setSectionErrorMsgVisibility(this, 'duty'); }); _dutyValueElements.lowestTemp.on('change keyup', function() { _checkFieldValue(_dutyValueElements.lowestTemp, _commonNumericCheckFn); _setSectionErrorMsgVisibility(this, 'duty'); }); _supportElements.supportDriveBlock.on('change keyup', function() { _checkFieldValue(_supportElements.supportDriveBlock); _setSectionErrorMsgVisibility(this, 'deflection'); }); _supportElements.supportTensionBlock.on('change keyup', function() { _checkFieldValue(_supportElements.supportTensionBlock); _setSectionErrorMsgVisibility(this, 'deflection'); }); _supportElements.distanceSpan.on('change keyup', function() { _checkFieldValue(_supportElements.distanceSpan); _setSectionErrorMsgVisibility(this, 'deflection'); }); _supportElements.consoleMounting.change(function() { var val = jQuery(this).val(); if(val == '1') { _disableInput(_supportElements.supportTensionBlock, true); _disableInput(_supportElements.supportDriveBlock, false); _checkFieldValue(_supportElements.supportDriveBlock); } else { _disableInput(_supportElements.supportTensionBlock, false); _disableInput(_supportElements.supportDriveBlock, true); _checkFieldValue(_supportElements.supportTensionBlock); } _setSectionErrorMsgVisibility(this, 'deflection'); }); _supportElements.distance_hx.on('change keyup', function() { _checkFieldValue(_supportElements.distance_hx, _commonNumericCheckFn); _setSectionErrorMsgVisibility(this, 'deflection'); }); _supportElements.distance_hy.on('change keyup', function() { _checkFieldValue(_supportElements.distance_hy, _commonNumericCheckFn); _setSectionErrorMsgVisibility(this, 'deflection'); }); _supportElements.distance_hz.on('change keyup', function() { _checkFieldValue(_supportElements.distance_hz, _commonNumericCheckFn); _setSectionErrorMsgVisibility(this, 'deflection'); }); _additionalOptionsElements.distanceABox.on('change keyup', function() { _checkFieldValue(_additionalOptionsElements.distanceABox); _setSectionErrorMsgVisibility(this, 'special'); }); _additionalOptionsElements.numberOfCarriagesSelect.change(function() { var enable = jQuery(this).val() != '1'; _disableInput(_additionalOptionsElements.distanceABox, !enable); _disableInput(_additionalOptionsElements.rigidlyConnectedCarriagesCheck, !enable); }); _additionalOptionsElements.rigidlyConnectedCarriagesCheck.on('click', function() { if(!!this.checked) { _additionalOptionsElements.rigidlyConnectedCarriagesImage.prop('src', '/images/lus_new/num_carriage_rigid.jpg'); } else { _additionalOptionsElements.rigidlyConnectedCarriagesImage.prop('src', '/images/lus_new/num_carriage.jpg'); } }); _additionalOptionsElements.motorMassBox.on('change keyup', function() { _checkFieldValue(_additionalOptionsElements.motorMassBox, _commonNumericCheckFn); _setSectionErrorMsgVisibility(this, 'special'); }); _additionalOptionsElements.distanceAxialBox.on('change keyup', function() { _checkFieldValue(_additionalOptionsElements.distanceAxialBox, _commonNumericCheckFn); _setSectionErrorMsgVisibility(this, 'special'); }); _additionalOptionsElements.distanceRightBox.on('change keyup', function() { _checkFieldValue(_additionalOptionsElements.distanceRightBox, _commonNumericCheckFn); _setSectionErrorMsgVisibility(this, 'special'); }); _additionalOptionsElements.distanceZBox.on('change keyup', function() { _checkFieldValue(_additionalOptionsElements.distanceZBox, _commonNumericCheckFn); _setSectionErrorMsgVisibility(this, 'special'); }); _additionalOptionsElements.mountingSideSelect.change(function() { var val = jQuery(this).val(); if(val == '1') { _additionalOptionsElements.mountingSideImage.prop('src', '/images/lus_new/masa_motorja1.jpg'); } else { _additionalOptionsElements.mountingSideImage.prop('src', '/images/lus_new/masa_motorja2.jpg'); } }); _suitableProducts.list.filterSelect.change(function() { _suitableProductsFilterRows(); }); //Admin tab jQuery('#sec_header_admin').next().find('input[type=text]').on('change keyup', function() { _checkFieldValue(jQuery(this), _commonNumericCheckFn); _setSectionErrorMsgVisibility(this, 'admin'); }); }; var _changeProfileTypeInputImage = function(sender, forBasic) { var pval = jQuery(sender).val(); var imgsrc = 'Profil_type_1.jpg'; if('triangle' == pval) { imgsrc = 'Profil_type_2.jpg'; } else if('trapez13' == pval) { imgsrc = 'Profil_type_3.jpg'; } else if('triangle12' == pval) { imgsrc = 'Profil_type_4.jpg'; } else if('acc' == pval) { imgsrc = 'Profil_type_5.jpg'; } else if('dec' == pval) { imgsrc = 'Profil_type_6.jpg'; } else if('constant' == pval) { imgsrc = 'Profil_type_7.jpg'; } if(!!forBasic) { _basicCycleElements.cycleInfoProfileTypeImg.prop('src', '/images/lus_new/'+imgsrc); } else { _advCycleElements.cycleInfoProfileTypeImg.prop('src', '/images/lus_new/'+imgsrc); } }; var _loadDataForceBoxChange = function(sender) { var val = _getFloatFromInput(jQuery(sender)); if(!!val) { //Show next 2 fields jQuery(sender).closest('.field-div').nextAll('.field-div').slice(0,2).show(); } else { jQuery(sender).closest('.field-div').nextAll('.field-div').slice(0,2).hide(); } }; LinUnitSelNew.onAgreeClick = function(sender) { jQuery(sender).closest('.calculation_agree').find('.formerror').remove(); jQuery.ajax({ url: '/'+REQUEST_LOCALE+'/ajax/lusnew_ajax', data: ({m: 'agree'}), _snd: sender, success: function(json) { if(json == null || !JSON.isResponseOK(json)) { this._error(json == null?null:JSON.getErrorMessageFromResponse(json)); return; } jQuery.fancybox.close(); }, error: function() { this._error(); }, _error: function(msg) { jQuery(this._snd).before('
'+(!msg?'Sorry, an error has occured.':msg)+'
'); setTimeout(function() {jQuery.fancybox.close();}, 2000); }, dataType: 'json' }); }; LinUnitSelNew.onOpenCloseSectionClick = function(sender) { var $secHeader = jQuery(sender); var $sectionData = $secHeader.next(); if($sectionData.is(':visible')) { $sectionData.slideUp(function() { $secHeader.removeClass('opened'); if(sender.id != 'sec_header_suitable') { $secHeader.find('a').text('OPEN'); } }); $secHeader.find('input[name^=secOpened_]').val('0'); } else { $sectionData.slideDown(function() { $secHeader.addClass('opened'); if(sender.id != 'sec_header_suitable') { $secHeader.find('a').text('CLOSE'); } }); $secHeader.find('input[name^=secOpened_]').val('1'); } }; /** * Sets visibiilty of section error message. * Returns true, if there is now error, false otherwise. */ var _setSectionErrorMsgVisibility = function(sender, section) { var $secData = jQuery(sender).closest('.sec-data'); if($secData[0]._sectionErrorMsg == null) { $secData[0]._sectionErrorMsg = $secData.find('.section-error-msg:last'); } $secData[0]._sectionErrorMsg.hide(); if(section == 'cycle') { var $contDiv = null; if(_isBasicCycleUsed()) { $contDiv = jQuery(sender).closest('.sec-data').find('#adv-cycle-tab_0'); } else { $contDiv = jQuery(sender).closest('.sec-data').find('#adv-cycle-tab_1').find('.stroke-div:first'); } if($contDiv.find('.field-div.error:first,.ld-tab.error:first').length > 0) { $secData[0]._sectionErrorMsg.show(); return false; } return true; } else { if($secData.find('.field-div.error:first').length > 0) { $secData[0]._sectionErrorMsg.show(); return false; } return true; } }; LinUnitSelNew.onContinueSectionButtonClick = function(sender, event, section, submitParam, submitValue) { if(_setSectionErrorMsgVisibility(sender, section) || Common.isCtrlOrShiftPressed(event)) { jQuery(sender).closest('.lus_new').find('input').prop('disabled', ''); commonSubmitClosestForm(sender, submitParam, submitValue); } }; LinUnitSelNew.onAxisInclinationChange = function(sender) { _lastValues.alfaInput = $_alphaInput.val(); _lastValues.betaInput = $_betaInput.val(); //Remember values if($_orientationCustomRadio.prop('checked') != true) { $_orientationCustomRadio.click(); } }; LinUnitSelNew.onOrientationRadioClick = function(sender) { if(sender.value == 'bottom') { $_alphaInput.val('0'); $_betaInput.val('0'); } else if(sender.value == 'wall_hor') { $_alphaInput.val('0'); $_betaInput.val('-90'); } else if(sender.value == 'wall_ver') { $_alphaInput.val('90'); $_betaInput.val('0'); } else if(sender.value == 'top') { $_alphaInput.val('0'); $_betaInput.val('180'); } else if(sender.value == 'user') { $_alphaInput.val(_lastValues.alfaInput); $_betaInput.val(_lastValues.betaInput); } }; LinUnitSelNew.onTabClick = function(sender) { jQuery(sender).closest('.lus-nav-tab').addClass('selected').siblings().removeClass('selected'); //Show/hide tabs var clickedVal = sender.value; jQuery(sender).closest('.lus-nav-tabs').nextAll('.lus-tabs:first').children().each(function() { if(this.id.endsWith('_'+clickedVal)) { jQuery(this).show(); } else { jQuery(this).hide(); } }); //Trigger duty cycle recalculation _recalculateDutyCycles(); //Trigger support elements check _supportElementsSectionValidate(); //Trigger images check _setModulOrientationImage(_isBasicCycleUsed()); //Trigger check on cycle tab if(_isBasicCycleUsed()) { _setSectionErrorMsgVisibility(_basicCycleElements.strokeBox, 'cycle'); } else { _setSectionErrorMsgVisibility(_advCycleElements.strokeBox, 'cycle'); } }; var _supportElementsSectionValidate = function() { _supportElements.distanceSpan.closest('.support-type').find('input[type=radio]:checked:first').click(); }; LinUnitSelNew.onViewAllSectionsClick = function(sender) { jQuery(sender).closest('.lus_new').find('.sec-header').each(function() { var $secHeader = jQuery(this).closest('.sec-header'); var $sectionData = $secHeader.next(); if(!$sectionData.is(':visible')) { $sectionData.show(function() { $secHeader.addClass('opened'); $secHeader.find('a').text('CLOSE'); }); } }); }; var _disableInput = function($inp, disable) { if(!!disable) { $inp.closest('.field-div').addClass('disabled'); } else { $inp.closest('.field-div').removeClass('disabled'); } $inp.prop('disabled', !!disable?'disabled':''); }; var _clearAllErrors = function($container) { $container.find('.error').removeClass('error'); }; var _clearErrorField = function($inp) { $inp.prop('title', ''); $inp.closest('.error').removeClass('error'); }; var _setFieldError = function($inp, errorMsg) { $inp.prop('title', errorMsg); $inp.closest('.field-div').addClass('error'); }; /** * Check function takes 1 argument (input value) and should return null if everything is OK and error otherwise.
* If check function is not defined, it checks if input has its own check function.
* Returns true if there is no error, returns false if there is any error. */ var _checkFieldValue = function($inp, checkFunction) { var _err = null; if(!!checkFunction) { _err = checkFunction($inp.val()); } else if(!!$inp[0].checkFn) { _err = $inp[0].checkFn($inp.val()); } if(_err != null) { _setFieldError($inp, _err); return false; } else { _clearErrorField($inp); return true; } }; var _round = function(num, roundBase) { if(!roundBase) { roundBase = 1000000; } if(!_isFloatNanOrZero(num)) { num = Math.round(num*roundBase)/roundBase; } return num; }; LinUnitSelNew.onBasicCycleEntireStrokeUsedCheckClick = function(sender) { if(!!sender.checked) { //Remember last values _lastValues.basicCycleStartPosition = _basicCycleElements.startPositionBox.val(); _lastValues.basicCycleEndPosition = _basicCycleElements.endPositionBox.val(); if(Common.isEmptyString(_basicCycleElements.strokeBox.val())) { _basicCycleElements.startPositionBox.val('0'); _basicCycleElements.endPositionBox.val(''); } else { _basicCycleElements.startPositionBox.val('0'); _basicCycleElements.endPositionBox.val(_basicCycleElements.strokeBox.val()); } _clearErrorField(_basicCycleElements.startPositionBox); _clearErrorField(_basicCycleElements.endPositionBox); } else { //Remember last values if empty if(!_lastValues.basicCycleStartPosition) { _lastValues.basicCycleStartPosition = _basicCycleElements.startPositionBox.val(); } if(!_lastValues.basicCycleEndPosition) { _lastValues.basicCycleEndPosition = _basicCycleElements.endPositionBox.val(); } _basicCycleElements.startPositionBox.val(_lastValues.basicCycleStartPosition); _basicCycleElements.endPositionBox.val(_lastValues.basicCycleEndPosition); _checkFieldValue(_basicCycleElements.startPositionBox); _checkFieldValue(_basicCycleElements.endPositionBox); } _disableInput(_basicCycleElements.startPositionBox, !!sender.checked); _disableInput(_basicCycleElements.endPositionBox, !!sender.checked); _basicCycleElements.cycleInfoInputTypeSelect.change(); }; var _cycleTimes = { basic: 0, advanced: 0 }; _isFloatNanOrZero = function(fl) { return isNaN(fl) || fl == 0; }; /** * Returns float from input.. * @param inpJq * @returns */ _getFloatFromInput = function(inpJq, nullOnEmpty) { return _getFloatFromString(inpJq.val(), nullOnEmpty); }; /** * Returns float given from string. * @param str * @param nullOnEmpty If string is empty and true, null is returned, 0 otherwise. * @returns */ _getFloatFromString = function(str, nullOnEmpty) { if(isEmptyString(str)) { return !!nullOnEmpty?null:0; } return parseFloat(str.replace(",",".")); }; var _recalculateDutyCycles = function() { var cyclesPerHour = _getFloatFromInput(_dutyValueElements.cyclesPerHour); var workingHoursPerDay = _getFloatFromInput(_dutyValueElements.workingHoursPerDay); var workingDaysPerYear = _getFloatFromInput(_dutyValueElements.workingDaysPerYear); var requiredWorkingYears = _getFloatFromInput(_dutyValueElements.requiredWorkingYears); var cycTime = _isBasicCycleUsed()?_cycleTimes.basic:_cycleTimes.advanced; var dutyCycle = cyclesPerHour * cycTime/3600 * 100; var requiredWorkingHours = workingHoursPerDay*workingDaysPerYear*requiredWorkingYears; var requiredCycles = requiredWorkingHours*3600/cycTime; //round dutyCycle = _round(dutyCycle); requiredWorkingHours = _round(requiredWorkingHours); requiredCycles = _round(requiredCycles, 2); _dutyValueElements.dutyCycle.text(dutyCycle); _dutyValueElements.requiredWorkingHours.text(requiredWorkingHours); _dutyValueElements.requiredCycles.text(requiredCycles); }; LinUnitSelNew.onSupportingRadioClick = function(sender) { if(!!sender.checked && sender.value=='fully') { _disableInput(_supportElements.supportDriveBlock, true); _disableInput(_supportElements.supportTensionBlock, true); _disableInput(_supportElements.distanceSpan, true); _clearErrorField(_supportElements.supportDriveBlock); _clearErrorField(_supportElements.supportTensionBlock); _clearErrorField(_supportElements.distanceSpan); _supportElements.consoleMounting.closest('.field-div').hide(); } else if(!!sender.checked && sender.value=='end') { _disableInput(_supportElements.supportDriveBlock, false); _disableInput(_supportElements.supportTensionBlock, false); _disableInput(_supportElements.distanceSpan, true); _checkFieldValue(_supportElements.supportDriveBlock); _checkFieldValue(_supportElements.supportTensionBlock); _clearErrorField(_supportElements.distanceSpan); _supportElements.consoleMounting.closest('.field-div').hide(); } else if(!!sender.checked && sender.value=='distributed') { _disableInput(_supportElements.supportDriveBlock, true); _disableInput(_supportElements.supportTensionBlock, true); _disableInput(_supportElements.distanceSpan, false); _clearErrorField(_supportElements.supportDriveBlock); _clearErrorField(_supportElements.supportTensionBlock); _checkFieldValue(_supportElements.distanceSpan); _supportElements.consoleMounting.closest('.field-div').hide(); } else if(!!sender.checked && sender.value=='console') { _disableInput(_supportElements.supportDriveBlock, false); _disableInput(_supportElements.supportTensionBlock, false); _disableInput(_supportElements.distanceSpan, false); _supportElements.consoleMounting.closest('.field-div').show(); _supportElements.consoleMounting.change(); _checkFieldValue(_supportElements.supportDriveBlock); _checkFieldValue(_supportElements.supportTensionBlock); _checkFieldValue(_supportElements.distanceSpan); } else { } _setSectionErrorMsgVisibility(sender, 'deflection'); }; LinUnitSelNew.onCycleShowCycleInfoClick = function(sender) { if(!!sender.checked) { jQuery(sender).closest('.field-div').next().show(); } else { jQuery(sender).closest('.field-div').next().hide(); } }; LinUnitSelNew.onMountingCasePicClick = function(sender) { if(!!sender.checked && sender.value=='profile') { _basicCycleElements.loadDataChangeCoordSystemCheck.closest('.field-div').css('visibility', 'hidden'); _advCycleElements.loadDataChangeCoordSystemCheck.closest('.field-div').css('visibility', 'hidden'); _supportElements.supportRadiosDiv.find('input').prop('disabled', false); _supportElements.supportRadiosDiv.find('#SupportingRadio_fully').closest('.pic').find('img').prop('src', '/images/lus_new/support_fully.jpg') if(!!_lastValues.supportType) { var lvRadio = _supportElements.supportRadiosDiv.find('[value='+_lastValues.supportType+']')[0]; lvRadio.checked = true; LinUnitSelNew.onSupportingRadioClick(lvRadio); _lastValues.supportType = null; } } else { _basicCycleElements.loadDataChangeCoordSystemCheck.closest('.field-div').css('visibility', 'visible'); _advCycleElements.loadDataChangeCoordSystemCheck.closest('.field-div').css('visibility', 'visible'); _lastValues.supportType = _supportElements.supportRadiosDiv.find('input:checked').val(); var fullyRadio = _supportElements.supportRadiosDiv.find('[value=fully]')[0]; fullyRadio.checked = true; LinUnitSelNew.onSupportingRadioClick(fullyRadio); _supportElements.supportRadiosDiv.find('[value!=fully]').prop('disabled', true); _supportElements.supportRadiosDiv.find('#SupportingRadio_fully').closest('.pic').find('img').prop('src', '/images/lus_new/support_fully_carriage.jpg') } _setModulOrientationImage(true); _setModulOrientationImage(false); }; var _setModulOrientationImage = function(forBasic) { var profileChecked = !!$_mountingRadioProfile[0].checked; var changeOrientChecked = forBasic?!!_basicCycleElements.loadDataChangeCoordSystemCheck[0].checked:!!_advCycleElements.loadDataChangeCoordSystemCheck[0].checked; var modOrientSrc = 'orientacija_modul1.jpg'; var poiSrc = 'POI_1.jpg'; if(!profileChecked) { if(changeOrientChecked) { modOrientSrc = 'orientacija_modul3.jpg'; poiSrc = 'POI_3.jpg'; } else { modOrientSrc = 'orientacija_modul2.jpg'; poiSrc = 'POI_2.jpg'; } } if(forBasic) { _basicCycleElements.loadDataModulOrientationImg.prop('src', '/images/lus_new/'+modOrientSrc); } else { _advCycleElements.loadDataModulOrientationImg.prop('src', '/images/lus_new/'+modOrientSrc); } _supportElements.poiImage.prop('src', '/images/lus_new/'+poiSrc); }; LinUnitSelNew.onModuleOrientationChangeCheckClick = function(sender, forBasic) { _setModulOrientationImage(forBasic); }; LinUnitSelNew.onLoadDataExpandImgClick = function(sender) { var $subDiv = jQuery(sender).parent().next(); if($subDiv.is(':visible')) { $subDiv.hide(); jQuery(sender).parent().find('img').prop('src', '/images/plus-ecs.png'); } else { $subDiv.show(); jQuery(sender).parent().find('img').prop('src', '/images/minus-ecs.png'); } }; LinUnitSelNew.onLoadDataTabAddClick = function(sender, basicCycle) { if(!!basicCycle) { var $tab = jQuery(sender); var $newTab = _templates.loadTab.clone(); var nextId = new PPRandom().nextId('loadDataSingleLoad_'); $newTab.setAfterId(nextId); $newTab.prop('id', 'ld-tab_'+nextId).hide(); var $dataSingle = _templates.loadTabSingleFields.clone(); $dataSingle.setAfterId(nextId, 'loadDataSingleTabId'); $dataSingle.prop('id', 'loadDataSingleLoad_'+nextId); //Set props for faster updating _initLoadDataSingleFieldDiv($dataSingle, basicCycle); //Set acc properties from first load data var $firstChild = _basicCycleElements.loadDataSingleFields.children(':first'); if($firstChild.length > 0) { var _newFlds = $dataSingle[0]._flds; var _firstFlds = $firstChild[0]._flds; _newFlds.accelerationX.val(_firstFlds.accelerationX.val()); _newFlds.accelerationY.val(_firstFlds.accelerationY.val()); _newFlds.accelerationZ.val(_firstFlds.accelerationZ.val()); _newFlds.accelerationXDir.val(_firstFlds.accelerationXDir.val()); _newFlds.accelerationYDir.val(_firstFlds.accelerationYDir.val()); _newFlds.accelerationZDir.val(_firstFlds.accelerationZDir.val()); } $tab.before($newTab); if($tab.parent().children('[id^=ld-tab_]').length >= _LOAD_DATA_MAX_TABS) { $tab.parent().find('.add').hide(); //Hide add link } _basicCycleElements.loadDataSingleFields.append($dataSingle); _selectLoadTab($newTab, true); $newTab.fadeIn(); _reindexLoadTabs(_basicCycleElements.loadDataTabs); _generateBasicLoadDataTableHtml(); } else { _addAdvCycleStepLoadDataTab(sender, true, null) } }; var _addAdvCycleStepLoadDataTab = function(sender, recalculate, $sourceDataDiv) { var $tab = null; if(!!sender) { $tab = jQuery(sender); } else { $tab = _advCycleElements.loadDataAddTab; } //Always add to selected step var $newTab = _templates.loadTab.clone(); var stepId = _advCycleCycleDataSelectedSingleFields.div.getAfterId(); //Step is always selected one var nextLoadId = new PPRandom().nextId('loadDataSingleLoad_'+stepId+'_'); var nextLoadIdTotal = stepId+'_'+nextLoadId; $newTab.prop('id', 'ld-tab_'+nextLoadIdTotal).hide(); $newTab.addClass('adv'); var $dataSingle = _templates.loadTabSingleFields.clone(); $dataSingle.setAfterId(nextLoadIdTotal); $dataSingle.prop('id', 'loadDataSingleLoad_'+nextLoadIdTotal); //Set props for faster updating _initLoadDataSingleFieldDiv($dataSingle, false); if(!!$sourceDataDiv) { //Set values for(var key in $sourceDataDiv[0]._flds) { $dataSingle[0]._flds[key].val($sourceDataDiv[0]._flds[key].val()); } } $tab.before($newTab); if($tab.parent().children('[id^=ld-tab_]').length >= _LOAD_DATA_MAX_TABS) { $tab.parent().find('.add').hide(); //Hide add link } if(!!recalculate) { //Set acc properties from first load data var $firstChild = _advCycleElements.loadDataSingleFields.children(':first'); if($firstChild.length > 0) { var _newFlds = $dataSingle[0]._flds; var _firstFlds = $firstChild[0]._flds; _newFlds.accelerationX.val(_firstFlds.accelerationX.val()); _newFlds.accelerationY.val(_firstFlds.accelerationY.val()); _newFlds.accelerationZ.val(_firstFlds.accelerationZ.val()); } } _advCycleElements.loadDataSingleFields.append($dataSingle) $newTab.fadeIn(); if(!!recalculate) { _reindexLoadTabs(_advCycleElements.loadDataTabs); _selectLoadTab($newTab, false); } }; var _loadDataSetSelectedLoadFieldsFromEdit = function(forBasic, delayHtmlCreation) { if(!!forBasic) { if(!!_$basicCycleLoadDataSelectedSingleFields) { for(var key in _$basicCycleLoadDataSelectedSingleFields._flds) { _$basicCycleLoadDataSelectedSingleFields._flds[key].val(_basicCycleElements.loadDataEditFields[key].val()); } if(!delayHtmlCreation) { _generateBasicLoadDataTableHtml(); } } } else { if(!!_advCycleCycleDataSelectedSingleFields.loadTab) { for(var key in _advCycleCycleDataSelectedSingleFields.loadTab._flds) { _advCycleCycleDataSelectedSingleFields.loadTab._flds[key].val(_advCycleElements.loadDataEditFields[key].val()); } if(!delayHtmlCreation) { _generateAdvancedLoadDataTableHtml(); } } } }; var _loadDataSetEditLoadFieldsFromSelected = function(forBasic) { var accEnable = false; if(!!forBasic) { if(!!_$basicCycleLoadDataSelectedSingleFields) { for(var key in _$basicCycleLoadDataSelectedSingleFields._flds) { _basicCycleElements.loadDataEditFields[key].val(_$basicCycleLoadDataSelectedSingleFields._flds[key].val()); if(!key.endsWith('Dir')) { //Trigger error validation _checkFieldValue(_basicCycleElements.loadDataEditFields[key], _commonNumericCheckFn); } } //Enable only if first and selected accEnable = _$basicCycleLoadDataSelectedSingleFields.previousSibling==null; } _loadDataForceBoxChange(_basicCycleElements.loadDataEditFields.forceX[0]); _loadDataForceBoxChange(_basicCycleElements.loadDataEditFields.forceY[0]); _loadDataForceBoxChange(_basicCycleElements.loadDataEditFields.forceZ[0]); } else { if(!!_advCycleCycleDataSelectedSingleFields.loadTab) { for(var key in _advCycleCycleDataSelectedSingleFields.loadTab._flds) { _advCycleElements.loadDataEditFields[key].val(_advCycleCycleDataSelectedSingleFields.loadTab._flds[key].val()); if(!key.endsWith('Dir')) { //Trigger error validation _checkFieldValue(_advCycleElements.loadDataEditFields[key], _commonNumericCheckFn); } } //Enable only if first is selected accEnable = _advCycleCycleDataSelectedSingleFields.loadTab.previousSibling==null; } _loadDataForceBoxChange(_advCycleElements.loadDataEditFields.forceX[0]); _loadDataForceBoxChange(_advCycleElements.loadDataEditFields.forceY[0]); _loadDataForceBoxChange(_advCycleElements.loadDataEditFields.forceZ[0]); } //Enable/disable acceleration fields _loadDataEnableAccelerationFields(!forBasic, accEnable); }; var _loadDataEnableAccelerationFields = function(advanced, enable) { var accXBox = !!advanced?_advCycleElements.loadDataEditFields.accelerationX:_basicCycleElements.loadDataEditFields.accelerationX; var accYBox = !!advanced?_advCycleElements.loadDataEditFields.accelerationY:_basicCycleElements.loadDataEditFields.accelerationY; var accZBox = !!advanced?_advCycleElements.loadDataEditFields.accelerationZ:_basicCycleElements.loadDataEditFields.accelerationZ; _disableInput(accXBox, !enable); _disableInput(accYBox, !enable); _disableInput(accZBox, !enable); if(!advanced) { //This fields are not present on advance cycle _disableInput(_basicCycleElements.loadDataEditFields.accelerationXDir, !enable); _disableInput(_basicCycleElements.loadDataEditFields.accelerationYDir, !enable); _disableInput(_basicCycleElements.loadDataEditFields.accelerationZDir, !enable); } }; var _initLoadDataSingleFieldDiv = function($fdiv, forBasic) { var ds = $fdiv[0]; var nextId = !!forBasic?$fdiv.getAfterId():$fdiv.getAfterIdTotal(); ds._flds = {}; ds._flds.massOfLoad = $fdiv.find('input[name=massOfLoad_'+nextId+']'); ds._flds.distanceX = $fdiv.find('input[name=distanceX_'+nextId+']'); ds._flds.distanceY = $fdiv.find('input[name=distanceY_'+nextId+']'); ds._flds.distanceZ = $fdiv.find('input[name=distanceZ_'+nextId+']'); ds._flds.forceX = $fdiv.find('input[name=forceX_'+nextId+']'); ds._flds.forceXDistanceY = $fdiv.find('input[name=forceXDistanceY_'+nextId+']'); ds._flds.forceXDistanceZ = $fdiv.find('input[name=forceXDistanceZ_'+nextId+']'); ds._flds.forceY = $fdiv.find('input[name=forceY_'+nextId+']'); ds._flds.forceYDistanceX = $fdiv.find('input[name=forceYDistanceX_'+nextId+']'); ds._flds.forceYDistanceZ = $fdiv.find('input[name=forceYDistanceZ_'+nextId+']'); ds._flds.forceZ = $fdiv.find('input[name=forceZ_'+nextId+']'); ds._flds.forceZDistanceX = $fdiv.find('input[name=forceZDistanceX_'+nextId+']'); ds._flds.forceZDistanceY = $fdiv.find('input[name=forceZDistanceY_'+nextId+']'); ds._flds.momentX = $fdiv.find('input[name=momentX_'+nextId+']'); ds._flds.momentY = $fdiv.find('input[name=momentY_'+nextId+']'); ds._flds.momentZ = $fdiv.find('input[name=momentZ_'+nextId+']'); ds._flds.distributedLoadZ = $fdiv.find('input[name=distributedLoadZ_'+nextId+']'); ds._flds.distributedLoadY = $fdiv.find('input[name=distributedLoadY_'+nextId+']'); ds._flds.accelerationX = $fdiv.find('input[name=accelerationX_'+nextId+']'); ds._flds.accelerationY = $fdiv.find('input[name=accelerationY_'+nextId+']'); ds._flds.accelerationZ = $fdiv.find('input[name=accelerationZ_'+nextId+']'); if(!!forBasic) { ds._flds.massOfLoadDir = $fdiv.find('input[name=massOfLoadDir_'+nextId+']'); ds._flds.forceXDir = $fdiv.find('input[name=forceXDir_'+nextId+']'); ds._flds.forceYDir = $fdiv.find('input[name=forceYDir_'+nextId+']'); ds._flds.forceZDir = $fdiv.find('input[name=forceZDir_'+nextId+']'); ds._flds.momentXDir = $fdiv.find('input[name=momentXDir_'+nextId+']'); ds._flds.momentYDir = $fdiv.find('input[name=momentYDir_'+nextId+']'); ds._flds.momentZDir = $fdiv.find('input[name=momentZDir_'+nextId+']'); ds._flds.distributedLoadZDir = $fdiv.find('input[name=distributedLoadZDir_'+nextId+']'); ds._flds.distributedLoadYDir = $fdiv.find('input[name=distributedLoadYDir_'+nextId+']'); ds._flds.accelerationXDir = $fdiv.find('input[name=accelerationXDir_'+nextId+']'); ds._flds.accelerationYDir = $fdiv.find('input[name=accelerationYDir_'+nextId+']'); ds._flds.accelerationZDir = $fdiv.find('input[name=accelerationZDir_'+nextId+']'); } }; var _selectLoadTab = function($tab, forBasic) { $tab.siblings().removeClass('selected'); $tab.addClass('selected'); if(forBasic) { _$basicCycleLoadDataSelectedSingleFields = _basicCycleElements.loadDataSingleFields.find('#loadDataSingleLoad_'+$tab.getAfterId())[0]; } else { _advCycleCycleDataSelectedSingleFields.loadTab = _advCycleElements.loadDataSingleFields.find('#loadDataSingleLoad_'+$tab.getAfterIdTotal())[0]; } _loadDataSetEditLoadFieldsFromSelected(forBasic); }; var _reindexLoadTabs = function($tabParent) { var advanced = $tabParent.prop('id') == _advCycleElements.loadDataTabs.prop('id'); var isFirstSelected = false; var ind = 1; $tabParent.children().each(function() { var $t = jQuery(this); if($t.hasClass('add')) { return false; } var $lbl = $t.find('label'); if($lbl.text().match(/\s\d+$/)) { $lbl.text($lbl.text().replace(/^(.*) (\d+)/, '$1 '+ind)); } else { $lbl.text($lbl.text()+' '+ind); } if(ind == 1 && $t.hasClass('selected')) { isFirstSelected = true; } ind++; }); }; LinUnitSelNew.onLoadDataTabRemoveClick = function(sender) { var $tab = jQuery(sender).closest('.ld-tab'); var basicCycle = !$tab.hasClass('adv'); if(!!basicCycle) { var afterId = $tab.getAfterId(); _basicCycleElements.loadDataSingleFields.find('#loadDataSingleLoad_'+afterId).remove(); } else { var afterId = $tab.getAfterIdTotal(); _advCycleElements.loadDataSingleFields.find('#loadDataSingleLoad_'+afterId).remove(); } $tab.fadeOut('fast', function() { var loadDataFieldsSet = false; if($tab.hasClass('selected')) { if($tab.prev().length==0) { if($tab.nextAll('[id^=ld-tab_]:first').length > 0) { _selectLoadTab($tab.nextAll('[id^=ld-tab_]:first'), basicCycle); loadDataFieldsSet = true; } else { //Empty load data visible fields if(!!basicCycle) { for(var key in _basicCycleElements.loadDataEditFields) { _basicCycleElements.loadDataEditFields[key].val(''); } } else { for(var key in _basicCycleElements.loadDataEditFields) { _advCycleElements.loadDataEditFields[key].val(''); } } } } else { _selectLoadTab($tab.prev(), basicCycle); loadDataFieldsSet = true; } } $tab.parent().find('.add').show(); //Show add link $tab.remove(); if(!!basicCycle) { _reindexLoadTabs(_basicCycleElements.loadDataTabs); } else { _reindexLoadTabs(_advCycleElements.loadDataTabs); } if(!loadDataFieldsSet) { //Enable acc fields if first load tab is selected var enable = !!basicCycle?_basicCycleElements.loadDataTabs.find('.ld-tab:first').hasClass('selected'):_advCycleElements.loadDataTabs.find('.ld-tab:first').hasClass('selected'); _loadDataEnableAccelerationFields(!basicCycle, enable); } }); _generateBasicLoadDataTableHtml(); }; LinUnitSelNew.onLoadDataTabClick = function(sender) { var $tab = jQuery(sender).closest('.ld-tab'); _selectLoadTab($tab, !$tab.hasClass('adv')); }; var _cycleDataSetSelectedCycleFieldsFromEdit = function() { if(!!_advCycleCycleDataSelectedSingleFields.index) { for(var key in _advCycleCycleDataSelectedSingleFields.div[0]._flds) { if(key == 'loadData') { var stepId = _advCycleCycleDataSelectedSingleFields.div.getAfterId(); //Check which load data were deleted/added/modified var $oldLoadData = _advCycleCycleDataSelectedSingleFields.div[0]._flds.loadData; var $newLoadData = _advCycleElements.loadDataSingleFields.children(); var $newLoadToAppend = []; for(var i=0; i<$newLoadData.length; i++) { var $loadDataFields = null; for(var j=0; j<$oldLoadData.length; j++) { if($newLoadData.eq(i).getAfterId() == $oldLoadData[j].getAfterId()) { $loadDataFields = $oldLoadData[j]; break; } } if($loadDataFields == null) { $loadDataFields = _templates.loadTabSingleFields.clone(); $loadDataFields.setAfterId($newLoadData.eq(i).getAfterIdTotal()); $loadDataFields.prop('id', 'loadDataSingleLoad_'+$newLoadData.eq(i).getAfterIdTotal()); $loadDataFields.find('[name=loadDataSingleTabId]').prop('name', 'loadDataSingleTabId_'+stepId).val($newLoadData.eq(i).getAfterId()); _initLoadDataSingleFieldDiv($loadDataFields, false); } $newLoadToAppend.push($loadDataFields); //Set values for(var key in $loadDataFields[0]._flds) { $loadDataFields[0]._flds[key].val($newLoadData.eq(i)[0]._flds[key].val()); } } var $stepsDiv = _advCycleCycleDataSelectedSingleFields.div.find('#stepLoadData_'+stepId); $stepsDiv.empty(); for(var i=0; i<$newLoadToAppend.length; i++) { $stepsDiv.append($newLoadToAppend[i]); } //Init load data fields _advCycleCycleDataSelectedSingleFields.div[0]._flds.loadData = $newLoadToAppend; } else if(key == 'loadDataChangeCoordSystemCheck') { _advCycleCycleDataSelectedSingleFields.div[0]._flds[key].val(!!_advCycleElements[key][0].checked?'1':'0'); } else { _advCycleCycleDataSelectedSingleFields.div[0]._flds[key].val(_advCycleElements[key].val()); } } _advCycleCycleDataSelectedSingleFields.div.find('input[name^=notAccepted_]').remove(); //Mark that step has been saved } }; /** * If $sourceDiv is null, selected cycle is used. */ var _cycleDataSetEditCycleFieldsFromSelected = function($sourceDiv) { if(!!_advCycleCycleDataSelectedSingleFields.index || !!$sourceDiv) { var $sdiv = !!$sourceDiv?$sourceDiv:_advCycleCycleDataSelectedSingleFields.div; for(var key in $sdiv[0]._flds) { if(key == 'loadData') { _advCycleElements.loadDataTabs.children('[id^=ld-tab_]').remove(); _advCycleElements.loadDataSingleFields.empty(); var $cycleStepLoadDataSingleFields = $sdiv[0]._flds.loadData; for(var i=0; i<$cycleStepLoadDataSingleFields.length; i++) { //Create load data tab _addAdvCycleStepLoadDataTab(null, i==$cycleStepLoadDataSingleFields.length-1, $cycleStepLoadDataSingleFields[i]); } } else if(key == 'loadDataChangeCoordSystemCheck') { if(_advCycleCycleDataSelectedSingleFields.index>1) { _advCycleElements[key].closest('.field-div').addClass('disabled'); } else { _advCycleElements[key].closest('.field-div').removeClass('disabled'); } if(_advCycleElements.cyclesStepSingleFields.children().length > 0) { //Always same as first step _advCycleElements[key][0].checked = _advCycleElements.cyclesStepSingleFields.children()[0]._flds[key].val()=='1'; } } else { _advCycleElements[key].val($sdiv[0]._flds[key].val()); } } _advCycleElements.cycleInfoProfileTypeSelect.change(); } }; var _initCycleStepSingleFieldDiv = function($fdiv) { var ds = $fdiv[0]; var nextId = $fdiv.getAfterId(); ds._flds = {}; ds._flds.cycleInfoStepNameBox = $fdiv.find('input[name=stepName_'+nextId+']'); ds._flds.cycleInfoPositionBox = $fdiv.find('input[name=position_'+nextId+']'); ds._flds.cycleInfoProfileTypeSelect = $fdiv.find('input[name=profileType_'+nextId+']'); ds._flds.cycleInfoInputTypeSelect = $fdiv.find('input[name=inputType_'+nextId+']'); ds._flds.cycleInfoTotalTravelTimeBox = $fdiv.find('input[name=totalTravelTime_'+nextId+']'); ds._flds.cycleInfoAccTimeBox = $fdiv.find('input[name=accTime_'+nextId+']'); ds._flds.cycleInfoDecTimeBox = $fdiv.find('input[name=decTime_'+nextId+']'); ds._flds.cycleInfoDelayTimeBox = $fdiv.find('input[name=delayTime_'+nextId+']'); ds._flds.cycleInfoPeakTravelSpeedBox = $fdiv.find('input[name=peakTravelSpeed_'+nextId+']'); ds._flds.cycleInfoTotalTravelAccBox = $fdiv.find('input[name=acc_'+nextId+']'); ds._flds.cycleInfoTotalTravelDecBox = $fdiv.find('input[name=dec_'+nextId+']'); ds._flds.loadDataChangeCoordSystemCheck = $fdiv.find('input[name=Mounting_case_carriage_loadsAtDriveBlock_'+nextId+']'); var $loadDataSingleFields = $fdiv.find('#stepLoadData_'+nextId).children(); ds._flds.loadData = []; for(var i=0; i<$loadDataSingleFields.length; i++) { _initLoadDataSingleFieldDiv($loadDataSingleFields.eq(i), false); ds._flds.loadData.push($loadDataSingleFields.eq(i)); } }; var _selectAdvCycleRow = function($row) { $row.siblings().removeClass('selected'); $row.addClass('selected'); var cycleId = $row.getAfterId(); _advCycleElements.stepControls.copyFromStep.children().slice(1).remove(); //Select cycle with this after id (and remember index) var stepFieldDivs = _advCycleElements.cyclesStepSingleFields.children(); var anyToCopy = false; for(var i=0; i'+stepFieldDivs.eq(i)[0]._flds.cycleInfoStepNameBox.val()+''); anyToCopy = true; } } //Set controls if(anyToCopy) { _advCycleElements.stepControls.copyFromStep.prop('disabled', false); } else { _advCycleElements.stepControls.copyFromStep.prop('disabled', true); } _advCycleElements.stepControls.newStep.addClass('disabled'); _advCycleElements.stepControls.resetInputs.removeClass('disabled'); _advCycleElements.stepControls.clearAll.hide(); _cycleDataSetEditCycleFieldsFromSelected(); _advCycleElements.cycleInfoPositionBox.change(); _advCycleShowHideEditContainer(true); }; var _advCycleShowHideEditContainer = function(show) { if(!!show) { //Scroll to top of cycle tab _advCycleElements.editCycleContainer.show(); } else { //Scroll to tables _advCycleElements.editCycleContainer.hide(); } jQuery('html, body').animate({ scrollTop: $_sectionHeaderCycle.offset().top }, 300); }; LinUnitSelNew.onCycleResetStepClick = function(sender) { if(jQuery(sender).hasClass('disabled')) { return; } //Reset values //Cycle info _advCycleElements.cycleInfoStepNameBox.val(''); _advCycleElements.cycleInfoPositionBox.val(''); _advCycleElements.cycleInfoProfileTypeImg.val(''); _advCycleElements.cycleInfoTotalTravelTimeBox.val(''); _advCycleElements.cycleInfoAccTimeBox.val(''); _advCycleElements.cycleInfoDecTimeBox.val(''); _advCycleElements.cycleInfoDelayTimeBox.val(''); _advCycleElements.cycleInfoPeakTravelSpeedBox.val(''); _advCycleElements.cycleInfoTotalTravelAccBox.val(''); _advCycleElements.cycleInfoTotalTravelDecBox.val(''); _advCycleElements.cycleInfoDeltaPosBox.text(''); _advCycleElements.cycleInfoTimeConstBox.text(''); _advCycleElements.cycleInfoVMaxBox.text(''); _advCycleElements.cycleInfoVStartBox.text(''); _advCycleElements.cycleInfoVEndBox.text(''); _advCycleElements.cycleInfoAccPathBox.text(''); _advCycleElements.cycleInfoDecPathBox.text(''); _advCycleElements.cycleInfoConstSpeedPathBox.text(''); _advCycleElements.cycleInfoCycleTimeBox.text(''); //Load data _advCycleElements.loadDataEditFields.massOfLoad.val(''); _advCycleElements.loadDataEditFields.distanceX.val(''); _advCycleElements.loadDataEditFields.distanceY.val(''); _advCycleElements.loadDataEditFields.distanceZ.val(''); _advCycleElements.loadDataEditFields.forceX.val(''); _advCycleElements.loadDataEditFields.forceXDistanceY.val(''); _advCycleElements.loadDataEditFields.forceXDistanceZ.val(''); _advCycleElements.loadDataEditFields.forceY.val(''); _advCycleElements.loadDataEditFields.forceYDistanceX.val(''); _advCycleElements.loadDataEditFields.forceYDistanceZ.val(''); _advCycleElements.loadDataEditFields.forceZ.val(''); _advCycleElements.loadDataEditFields.forceZDistanceX.val(''); _advCycleElements.loadDataEditFields.forceZDistanceY.val(''); _advCycleElements.loadDataEditFields.momentX.val(''); _advCycleElements.loadDataEditFields.momentY.val(''); _advCycleElements.loadDataEditFields.momentZ.val(''); _advCycleElements.loadDataEditFields.distributedLoadZ.val(''); _advCycleElements.loadDataEditFields.distributedLoadY.val(''); _advCycleElements.loadDataEditFields.accelerationX.val(''); _advCycleElements.loadDataEditFields.accelerationY.val(''); _advCycleElements.loadDataEditFields.accelerationZ.val(''); //Remove all load data _advCycleElements.loadDataSingleFields.empty(); _advCycleElements.loadDataTabs.children('[id^=ld-tab_]').remove(); //And add new, empty one _addAdvCycleStepLoadDataTab(null, true, null); }; LinUnitSelNew.onAdvCycleClearAllClick = function(sender) { if(jQuery(sender).hasClass('disabled')) { return; } _advCycleElements.cyclesStepSingleFields.empty(); _generateAdvancedCycleInfoTableAndHtml(); }; var _setTextToElements = function($els, vals1, vals2) { var vals = vals1.concat(vals2); for(var i=0; i<$els.length && i0) { for(var ldi=0; ldi