Sea Hunt Dealer Display (2024)

'); $teakAlerts.appendTo('.product-options-wrapper'); var $teakVariations = $('#dvTeakVariations').css('display', 'none'); $teakVariations .append('

Please specify your size measurements below in inches.

');if ((pricingJson.InfoHTML != undefined) && (pricingJson.InfoHTML != '')) {$teakVariations.append('

'); $teakAttentions .append('

') .append('

') .append('

') .append('

'); // move attn msgs after attention block $teakAttentions.appendTo('.product-add-form'); // METHODS // --------------------------------- function checkThenCalculate() { if (checkFields()) { calculateAndBuildUrl(); if ((pricingType == 'Door') || (pricingType == '3DMaterial')) { CutoutDimensions(); } } } function checkFields() { var txtLengthIn = $('#txtLengthIn').val(); if ((txtLengthIn != undefined) && (txtLengthIn.trim() != '') && (/[^0-9\s]/.test(txtLengthIn))) { alert('Decimals are not permitted. Use the accompanying dropdown for fractional values.'); return false; } var txtWidthIn = $('#txtWidthIn').val(); if ((txtWidthIn != undefined) && (txtWidthIn.trim() != '') && (/[^0-9\s]/.test(txtWidthIn))) { alert('Decimals are not permitted. Use the accompanying dropdown for fractional values.'); return false; } var txtDepthIn = $('#txtDepthIn').val(); if ((txtDepthIn != undefined) && (txtDepthIn.trim() != '') && (/[^0-9\s]/.test(txtDepthIn))) { alert('Decimals are not permitted. Use the accompanying dropdown for fractional values.'); return false; } var txtCutoutLengthIn = $('#txtCutoutLengthIn').val(); if ((txtCutoutLengthIn != undefined) && (txtCutoutLengthIn.trim() != '') && (/[^0-9\s]/.test(txtCutoutLengthIn))) { alert('Decimals are not permitted. Use the accompanying dropdown for fractional values.'); return false; } var chkLength = (txtLengthIn != ''); var chkWidth = (txtWidthIn != '');var chkDepth = (txtDepthIn != ''); return (toValidate && chkLength && chkWidth && chkDepth); } function ShowPrice(price, oldprice) { if (price > 0) { $calcPrice.children(":first").text('$' + price); $calcPrice.show(); if ((oldprice > 0) && (price < oldprice)) { $calcPrice.find('.price-value').text('$' + oldprice); $calcPrice.find('.orig-price-box').show(); } else $calcPrice.find('.orig-price-box').hide(); } else $calcPrice.hide(); } function castToNum(val) { if (isNaN(val) || (val == '')) { return 0; } else { return parseFloat(val); } } // Display dimensioan help databox function CutoutDimensions() { var MeasurementType = $.trim($('#ddMeasurementType').val()); var LengthIn = parseInt(castToNum($('#txtLengthIn').val()).toString()); var LengthInFraction = $('#ddLengthIn').val(); var WidthIn = parseInt(castToNum($('#txtWidthIn').val()).toString()); var WidthInFraction = $('#ddWidthIn').val(); var CutoutLengthIn = parseInt(castToNum($('#txtCutoutLengthIn').val()).toString()); var CutoutLengthInFraction = $('#ddCutoutLengthIn').val(); var convert = eval(LengthInFraction); convert = convert-0; var TotalLength = (LengthIn + convert); convert = eval(WidthInFraction); convert = convert-0; var TotalWidth = (WidthIn + convert); convert = eval(CutoutLengthInFraction); convert = convert-0; var TotalCutoutLength = (CutoutLengthIn + convert); var cutoutDimWidth = 0.0; var cutoutDimLength = 0.0; if (pricingJson.CutoutDim.indexOf(',') == -1) { cutoutDimWidth = castToNum(pricingJson.CutoutDim); cutoutDimLength = castToNum(pricingJson.CutoutDim); } else { var pair = pricingJson.CutoutDim.split(","); cutoutDimWidth = castToNum(pair[0]); cutoutDimLength = castToNum(pair[1]); } var outsideDim = castToNum(pricingJson.OutsideDim); // Populate INFO box $('#dvCutoutArea').html(''); $('#dvCutoutArea').hide();// Minimum of length and width required for all calculators if (isNaN(LengthIn) || isNaN(WidthIn) || (LengthIn <= 0) || (WidthIn <= 0)) { return false; }if (MeasurementType == '') { $('#dvMsgAlert').html(' Measurement Type is required.').show('highlight', 800); return; } $('#dvCutoutArea').append('Important Dimensions: Please Review
'); if (MeasurementType == 'Outside') { $('#dvCutoutArea').append('

Outside Dimensions: ' + (TotalLength - castToNum(pricingJson.OutsideDim)) + '" x ' + (TotalWidth - castToNum(pricingJson.OutsideDim)) + '"

'); $('#dvCutoutArea').append('

Cutout Dimensions: ' + (TotalLength - cutoutDimLength) + '" x ' + (TotalWidth - cutoutDimWidth) + '"

'); $('#dvCutoutArea').append('

Pass-through Dimensions: ' + (TotalLength - castToNum(pricingJson.PassDim)) + '" x ' + (TotalWidth - castToNum(pricingJson.PassDim)) + '"

'); if (pricingJson.MountingDim != undefined) $('#dvCutoutArea').append('

Mounting Surface: ' + (TotalLength - castToNum(pricingJson.PassDim) - castToNum(pricingJson.MountingDim)) + '" x ' + (TotalWidth - castToNum(pricingJson.PassDim) - castToNum(pricingJson.MountingDim)) + '"

'); } else { $('#dvCutoutArea').append('

Outside Dimensions: ' + (TotalLength + cutoutDimLength) + '" x ' + (TotalWidth + cutoutDimWidth) + '"

'); $('#dvCutoutArea').append('

Cutout Dimensions: ' + (TotalLength + castToNum(pricingJson.OutsideDim)) + '" x ' + (TotalWidth + castToNum(pricingJson.OutsideDim)) + '"

'); $('#dvCutoutArea').append('

Pass-through Dimensions: ' + (TotalLength - castToNum(pricingJson.PassDim) + cutoutDimLength) + '" x ' + (TotalWidth - castToNum(pricingJson.PassDim) + cutoutDimWidth) + '"

'); if (pricingJson.MountingDim != undefined) $('#dvCutoutArea').append('

Mounting Surface: ' + (TotalLength - castToNum(pricingJson.PassDim) - castToNum(pricingJson.MountingDim) + cutoutDimLength) + '" x ' + (TotalWidth - castToNum(pricingJson.PassDim) - castToNum(pricingJson.MountingDim) + cutoutDimWidth) + '"

'); } $('#dvCutoutArea').show(); return true; } function calculateAndBuildUrl() { var SKU = 0; var Price = 0; var Weight = 0; var Thickness = 0; var sThickness = ''; var customOptions = {}; var AddQuantity = $('#qty').val(); var fracParts = []; var priceModifier = 0; var pricePercentageDiscount = 0; // Get Calculator Meta if (pricingJson.Base.length == 1) { // Only one SKU (thickness N/A) SKU = pricingJson.Base[0].SKU; Price = parseFloat(pricingJson.Base[0].Price); Weight = parseFloat(pricingJson.Base[0].Weight); sThickness = pricingJson.Base[0].Thickness; } else { // Get the SKU (thickness) selected by the user var userSelectedThickness = $('#ddThickness').val(); // Get the meta for the user selected SKU for (var i = 0; i < pricingJson.Base.length; i++) { if (userSelectedThickness == pricingJson.Base[i].SKU) { SKU = pricingJson.Base[i].SKU; Price = parseFloat(pricingJson.Base[i].Price); Weight = parseFloat(pricingJson.Base[i].Weight); sThickness = pricingJson.Base[i].Thickness; // String break; } } } Thickness = eval(sThickness); // ----------------------- // Get Dims // ----------------------- var TotalHeight = 2; // Default if ((pricingType != 'Door') && (pricingType != '3DMaterial')) {// Adjust for qty of sheets + pkg paddingTotalHeight = Math.ceil(1+(Thickness*AddQuantity)); } var WidthInFraction = $('#ddWidthIn').val(); var WidthIn = parseInt(castToNum($('#txtWidthIn').val()).toString()); // Some calculators use the fractional control to house both the integer and frac portions (eg. 1 3/4") fracParts = WidthInFraction.split(' '); if (fracParts.length > 1) { WidthIn = parseInt(fracParts[0]); WidthInFraction = fracParts[1]; } frac = eval(WidthInFraction); frac = frac-0; var TotalWidth = (WidthIn + frac); var LengthInFraction = $('#ddLengthIn').val(); var LengthIn = parseInt(castToNum($('#txtLengthIn').val()).toString()); var frac = eval(LengthInFraction); frac = frac-0; var TotalLength = (LengthIn + frac);var DepthInFraction = $('#ddDepthIn').val(); var DepthIn = parseInt(castToNum($('#txtDepthIn').val()).toString());frac = eval(DepthInFraction); frac = frac-0; var TotalDepth = (DepthIn + frac);// Circles have the same width/length values if ((pricingType == 'Circle') || (pricingType == 'Donut')) { TotalWidth = TotalLength; } var MeasurementType = $.trim($('#ddMeasurementType').val()); // Cutout Size var CutoutLengthIn = parseInt(castToNum($('#txtCutoutLengthIn').val()).toString()); var CutoutLengthInFraction = $('#ddCutoutLengthIn').val(); if (MeasurementType == "Disc") { // Discs don't have a cutout hold CutoutLengthIn = 0; CutoutLengthInFraction = "0/16"; } frac = eval(CutoutLengthInFraction); frac = frac-0; var TotalCutoutLength = (CutoutLengthIn + frac); var CutoutWidthIn = parseInt(castToNum($('#txtCutoutWidthIn').val()).toString()); var CutoutWidthInFraction = $('#ddCutoutWidthIn').val(); frac = eval(CutoutWidthInFraction); frac = frac-0; var TotalCutoutWidth = (CutoutWidthIn + frac); if ((pricingType == 'Door') && (MeasurementType != 'Outside')) { if (MeasurementType == '') { $('#dvMsgAlert').html(' Please select a measurement type.').show('highlight', 800); return false; } // They are using inside sizes so adjust the calculated size to the outside dims TotalLength += castToNum(pricingJson.CutoutDim); TotalWidth += castToNum(pricingJson.CutoutDim); } // Perform validation checks $('#dvMsgAlert').hide(); if (isNaN(TotalLength) || isNaN(TotalWidth)) { $('#dvMsgAlert').html(' Please enter values for all dimensions.').show('highlight', 800); return false; }// Only applies when the user provides cutout dims (aka a hole in a disc) if (((TotalCutoutLength+1) > TotalLength) || ((TotalCutoutWidth+1) > TotalWidth)) { $('#dvMsgAlert').html(' The cutout is too large relative to the outside dimension. We require at least 1/2" width of material for the outside edge. Otherwise, call for special orders.').show('highlight', 800); return false; } if ((pricingType == 'Circle') || (pricingType == 'Donut')) { var notAvail = false; var color = findProductOption('Color').find('option:selected').text(); if (color != undefined) { if ((color == 'Dolphin Gray') && ((Thickness == 0.25) || (Thickness == 1))) notAvail = true; if ((color == 'Glacier Gray') && ((Thickness == 1))) notAvail = true; if ((color == 'Fish White') && ((Thickness == 0.25))) notAvail = true; if (notAvail) { $('#dvMsgAlert').html(' Sorry. That color and thickness combination is unavailable at this time.').show('highlight', 800); return false; } } if (($('#txtCutoutLengthIn').val() != '') && (castToNum(pricingJson.MinCutoutLength) > 0)) { // Length dim only if (TotalCutoutLength < castToNum(pricingJson.MinCutoutLength)) { $('#dvMsgAlert').html(' Minimum dimension for the cutout is ' + castToNum(pricingJson.MinCutoutLength) + '". To discuss other options, please give us a call.').show('highlight', 800); return false; } } } if (($('#txtCutoutLengthIn').val() != '') && ($('#txtCutoutWidthIn').val() != '')) { if ((castToNum(pricingJson.MinCutoutLength) > 0) && (castToNum(pricingJson.MinCutoutWidth) > 0)) { if ((TotalCutoutLength < castToNum(pricingJson.MinCutoutLength)) || (TotalCutoutWidth < castToNum(pricingJson.MinCutoutWidth))) { $('#dvMsgAlert').html(' Minimum dimensions for the cutout is ' + castToNum(pricingJson.MinCutoutLength) + '" x ' + castToNum(pricingJson.MinCutoutWidth) + '". To discuss other options, please give us a call.').show('highlight', 800); return false; } } } // The material length needs to always be the longest dim, flip the values if so if (((pricingType == 'Calculator') || (pricingJson.LengthMustBeLongest && (pricingJson.LengthMustBeLongest == true))) && (TotalLength < TotalWidth) ) { // Swap var intWidth = TotalWidth; TotalWidth = TotalLength; TotalLength = intWidth; var lenIn = LengthIn; var lenInFrac = LengthInFraction; LengthIn = WidthIn; LengthInFraction = WidthInFraction; WidthIn = lenIn; WidthInFraction = lenInFrac; // Update the display $('#txtLengthIn').val(LengthIn); $('#ddLengthIn').val(LengthInFraction); $('#txtWidthIn').val(WidthIn); $('#ddWidthIn').val(WidthInFraction); } // Check against minimums if ((TotalLength < castToNum(pricingJson.MinLength)) || ((TotalWidth < castToNum(pricingJson.MinWidth)) && (castToNum(pricingJson.MinWidth) > 0)) || ((TotalDepth < castToNum(pricingJson.MinDepth)) && (castToNum(pricingJson.MinDepth) > 0))) { if ((castToNum(pricingJson.MinLength) > 0) && (castToNum(pricingJson.MinWidth) > 0) && (castToNum(pricingJson.MinDepth) > 0)) { $('#dvMsgAlert').html(' Minimum dimensions for this product are ' + castToNum(pricingJson.MinLength) + '" x ' + castToNum(pricingJson.MinWidth) + '" x ' + castToNum(pricingJson.MinDepth) + '". To discuss other options, please give us a call.').show('highlight', 800); } else if ((castToNum(pricingJson.MinLength) > 0) && (castToNum(pricingJson.MinWidth) > 0)) { $('#dvMsgAlert').html(' Minimum dimensions for this product are ' + castToNum(pricingJson.MinLength) + '" x ' + castToNum(pricingJson.MinWidth) + '". To discuss other options, please give us a call.').show('highlight', 800); } else if ((castToNum(pricingJson.MinLength) > 0)) { $('#dvMsgAlert').html(' Minimum dimension for this product is ' + pricingJson.MinLength + '". To discuss other options, please give us a call.').show('highlight', 800); } else if ((castToNum(pricingJson.MinWidth) > 0)) { $('#dvMsgAlert').html(' Minimum dimension for this product is ' + pricingJson.MinWidth + '". To discuss other options, please give us a call.').show('highlight', 800); } return false; } // Check against maximums if ((TotalLength > castToNum(pricingJson.MaxLength)) || ((TotalWidth > castToNum(pricingJson.MaxWidth)) && (castToNum(pricingJson.MaxWidth) > 0)) || ((TotalDepth > castToNum(pricingJson.MaxDepth)) && (castToNum(pricingJson.MaxDepth) > 0))) { if (pricingType == 'Door') { $('#dvMsgAlert').html(' This size presents additional engineering considerations. We prefer to discuss the application with you to ensure we provide you with the best possible product.\n\nPlease give us a call at (866)-633-7961.').show('highlight', 800); } else if ((castToNum(pricingJson.MaxLength) > 0) && (castToNum(pricingJson.MaxWidth) > 0) && (castToNum(pricingJson.MaxDepth) > 0)) { $('#dvMsgAlert').html(' Maximum dimensions for this product are ' + pricingJson.MaxLength + '" x ' + pricingJson.MaxWidth + '" x ' + pricingJson.MaxDepth + '".').show('highlight', 800); } else if ((castToNum(pricingJson.MaxLength) > 0) && (castToNum(pricingJson.MaxWidth) > 0)) { $('#dvMsgAlert').html(' Maximum dimensions for this product are ' + pricingJson.MaxLength + '" x ' + pricingJson.MaxWidth + '".').show('highlight', 800); } else if ((castToNum(pricingJson.MaxLength) > 0)) { $('#dvMsgAlert').html(' Maximum dimension for this product is ' + pricingJson.MaxLength + '".').show('highlight', 800); } else if ((castToNum(pricingJson.MaxDepth) > 0)) { $('#dvMsgAlert').html(' Maximum dimension for this product is ' + pricingJson.MaxDepth + '".').show('highlight', 800); } return false; } if (pricingType == 'Door') { var $latchQtyFld = findProductOption('Latch Qty'); if ((castToNum(pricingJson.SingleLatchMaxLength) > 0) && ((TotalLength > castToNum(pricingJson.SingleLatchMaxLength)) || (TotalWidth > castToNum(pricingJson.SingleLatchMaxLength)))) { $('#dvMsgAlert').html(' The size you\'ve specified requires a second latch to properly support good door closure. The price has been adjusted to include this second matching latch. Questions? Please call us to discuss at (866)-633-7961.').show('highlight', 800); // Set latch qty = 2 attrTest = false; attrTest = $latchQtyFld.attr('name'); if ((typeof attrTest !== typeof undefined) && (attrTest !== false)) { $latchQtyFld.val($latchQtyFld.find('option:eq(2)').val()); //hideProductOption('Latch Qty'); } } else { // Set latch qty = 1 attrTest = false; attrTest = $latchQtyFld.attr('name'); if ((typeof attrTest !== typeof undefined) && (attrTest !== false)) { $latchQtyFld.val($latchQtyFld.find('option:eq(1)').val()); //hideProductOption('Latch Qty'); } } } var selectedRadius, radiusSize, maxCornerSize, smallestDim; var selectedEdge, selectedEdgeType, selectedEdgeTypePos; var selectedCutoutRadius; var optionX, optionA, optionB, optionC, optionD, optionE, optionF, optionG, optionH; if (pricingType == 'Material') { // Make sure radius is within limits selectedRadius = $('#ddRadiusCorners').val(); if (selectedRadius != undefined) { if (selectedRadius == '') selectedRadius = '0/16'; radiusSize = 0; fracParts = selectedRadius.split(' '); if (fracParts.length > 1) { radiusSize = parseFloat(fracParts[0]) + eval(fracParts[1]); } else radiusSize = eval(selectedRadius); radiusSize = radiusSize-0; smallestDim = (TotalWidth > TotalLength ? TotalLength : TotalWidth); if (radiusSize > (smallestDim/2)) { $('#dvMsgAlert').html(' The size previously selected for the radius was too large for the dimensions and has been reset. Questions? Please call us to discuss at (866)-633-7961.').show('highlight', 800); selectedRadius = "0/16"; } // Fill control maxCornerSize = (smallestDim/2); if (maxCornerSize > 6.5) maxCornerSize = 6.5; var minRadiusCorners = 0.125; // Mininum non-zero starting point if (castToNum(isNaN(pricingJson.MinRadiusCorners) ? 0 : pricingJson.MinRadiusCorners) > 0) { minRadiusCorners = castToNum(pricingJson.MinRadiusCorners); } var zeroRadiusCornersLabel = '

'; if ((pricingJson.ZeroRadiusCornersLabel != undefined) && (pricingJson.ZeroRadiusCornersLabel != '')) { zeroRadiusCornersLabel = '

'; } addFracs($('#ddRadiusCorners'), zeroRadiusCornersLabel, minRadiusCorners, 1, 0.125, true); addFracs($('#ddRadiusCorners'), '', 1.25, (maxCornerSize-0.0625), 0.25, false); $('#ddRadiusCorners').val(selectedRadius); // Reselect previous value $('#ddRadiusCorners').parent().parent().show(); } else selectedRadius = '0/16'; // Make sure the routed edge is within limits selectedEdge = $('#ddRoutedEdge').val(); if (selectedEdge != undefined) { if (selectedEdge == '') selectedEdge = '0/16'; selectedEdgeType = ''; selectedEdgeTypePos = selectedEdge.indexOf(" ("); if (selectedEdgeTypePos > 0) { selectedEdgeType = selectedEdge.substr(selectedEdgeTypePos); selectedEdge = selectedEdge.substr(0, selectedEdgeTypePos); } fracParts = selectedEdge.split(' '); if (fracParts.length > 1) { edgeSize = parseInt(fracParts[0]) + eval(fracParts[1]); } else edgeSize = eval(selectedEdge); edgeSize = edgeSize-0; if (((Thickness/2)+0.125) <= edgeSize) { $('#dvMsgAlert').html(' The size you previously selected for the routed edge was too large for the thickness and has been reset. Question? Please call us to discuss at (866)-633-7961.').show('highlight', 800); selectedEdge = "0/16"; } // Fill control optionX = '

'; optionA = '

'; optionB = '

'; optionC = '

'; optionD = '

'; optionE = '

'; optionF = '

'; optionG = '

'; optionH = '

'; $('#ddRoutedEdge').find('option').remove().end(); switch (Thickness) { case 0.125 : $('#ddRoutedEdge').append(optionX + optionA + optionB); break; case 0.25 : $('#ddRoutedEdge').append(optionX + optionA + optionB + optionC + optionE); break; case 0.375 : $('#ddRoutedEdge').append(optionX + optionA + optionB + optionC + optionD + optionE + optionG); break; case 0.5 : $('#ddRoutedEdge').append(optionX + optionA + optionB + optionC + optionD + optionE + optionF + optionG); break; default : $('#ddRoutedEdge').append(optionX + optionA + optionB + optionC + optionD + optionE + optionF + optionG + optionH); } $('#ddRoutedEdge').val(selectedEdge + selectedEdgeType); // Reselect previous value $('#ddRoutedEdge').parent().parent().show(); } else selectedEdge = '0/16'; // Cutout Radius var minCutoutRadius = 0.125; // Mininum non-zero starting point if (castToNum(isNaN(pricingJson.MinCutoutRadius) ? 0 : pricingJson.MinCutoutRadius) > 0) { minCutoutRadius = castToNum(pricingJson.MinCutoutRadius); } var zeroCutoutRadiusLabel = ''; if ((pricingJson.ZeroCutoutRadiusLabel != undefined) && (pricingJson.ZeroCutoutRadiusLabel != '')) { zeroCutoutRadiusLabel = pricingJson.ZeroCutoutRadiusLabel; zeroCutoutRadiusOption = '

'; } selectedCutoutRadius = $('#ddCutoutRadiusCorners').val(); if (selectedCutoutRadius != undefined) { if ((MeasurementType == 'InsideAndOutside') || (MeasurementType == 'InsideOrOutside')) { // Make sure cutout radius is within limits if ((TotalCutoutWidth > 0) && (TotalCutoutLength > 0)) { radiusSize = 0; fracParts = selectedCutoutRadius.split(' '); if (fracParts.length > 1) { radiusSize = parseFloat(fracParts[0]) + eval(fracParts[1]); } else radiusSize = eval((selectedCutoutRadius == zeroCutoutRadiusLabel.replace(/\s/g,'')) ? 0 : selectedCutoutRadius); radiusSize = radiusSize-0; smallestDim = (TotalCutoutWidth > TotalCutoutLength ? TotalCutoutLength : TotalCutoutWidth); if (radiusSize > (smallestDim/2)) { $('#dvMsgAlert').html(' The size previously selected for the cutout radius was too large for the cutout dimensions and has been reset.').show('highlight', 800); selectedCutoutRadius = makeFrac(minCutoutRadius); } // Fill control maxCornerSize = (smallestDim/2); if (maxCornerSize > 6.5) maxCornerSize = 6.5; addFracs($('#ddCutoutRadiusCorners'), zeroCutoutRadiusOption, minCutoutRadius, 1, 0.125, true); addFracs($('#ddCutoutRadiusCorners'), '', 1.25, (maxCornerSize-0.0625), 0.25, false); if ((selectedCutoutRadius == '') || (selectedCutoutRadius == '0/16')) selectedCutoutRadius = makeFrac(minCutoutRadius); $('#ddCutoutRadiusCorners').val(selectedCutoutRadius).trigger('change'); $('#ddCutoutRadiusCorners').parent().parent().show(); } } } else { selectedCutoutRadius = makeFrac(minCutoutRadius); } // Update the custom options if (selectedCutoutRadius != zeroCutoutRadiusLabel.replace(/\s/g,'')) customOptions['Cutout Radius'] = selectedCutoutRadius + '"'; else customOptions['Cutout Radius'] = selectedCutoutRadius; if (selectedEdge == '0/16') customOptions['roundover edges'] = "None (Raw Cut)"; else customOptions['roundover edges'] = selectedEdge + '"' + selectedEdgeType; if (selectedRadius == '0/16') customOptions['radius corners'] = "None (Square)"; else customOptions['radius corners'] = selectedRadius + '"'; if (castToNum(isNaN(pricingJson.RoutedEdge) ? 0 : pricingJson.RoutedEdge) > 0) { if (selectedEdge != '0/16') { priceModifier += castToNum(pricingJson.RoutedEdge); } } if (castToNum(isNaN(pricingJson.RadiusCorners) ? 0 : pricingJson.RadiusCorners) > 0) { if (selectedRadius != '0/16') { priceModifier += castToNum(pricingJson.RadiusCorners); } } if (castToNum(isNaN(pricingJson.CutoutRadiusCorners) ? 0 : pricingJson.CutoutRadiusCorners) > 0) { if ((selectedCutoutRadius != '0/16') && (selectedCutoutRadius != zeroCutoutRadiusLabel.replace(/\s/g,''))) { priceModifier += castToNum(pricingJson.CutoutRadiusCorners); } } } if (pricingType == 'MaterialOpening') { var sCutoutStyle = $('#ddCutoutStyle').val(); if (sCutoutStyle != 'None') { // Make sure cutout is within limits var cutoutLengthMinTopMargin = castToNum(isNaN(pricingJson.CutoutLengthMinTopMargin) ? 0 : pricingJson.CutoutLengthMinTopMargin); var cutoutWidthMinSideMargin = castToNum(isNaN(pricingJson.CutoutWidthMinSideMargin) ? 0 : pricingJson.CutoutWidthMinSideMargin); var cutoutMinLength = castToNum(isNaN(pricingJson.CutoutMinLength) ? 0 : pricingJson.CutoutMinLength); var cutoutMinWidth = castToNum(isNaN(pricingJson.CutoutMinWidth) ? 0 : pricingJson.CutoutMinWidth); if ((TotalCutoutWidth > 0) && (TotalCutoutLength > 0)) { if ((cutoutMinLength > 0) && (cutoutMinWidth > 0)) { if ((TotalCutoutLength < cutoutMinLength) || (TotalCutoutWidth < cutoutMinWidth)) { $('#dvMsgAlert').html(' Minimum dimensions for the opening are ' + cutoutMinLength + '" x ' + cutoutMinWidth + '". To discuss other options, please give us a call.').show('highlight', 800); return false; } } if (cutoutLengthMinTopMargin > 0) { if ((TotalCutoutLength) > TotalLength-cutoutLengthMinTopMargin) { $('#dvMsgAlert').html(' The opening is too tall relative to the outside dimension. We require at least ' + cutoutLengthMinTopMargin + '" of material above the opening edge. Otherwise, call for special orders.').show('highlight', 800); return false; } } if (cutoutWidthMinSideMargin > 0) { if ((TotalCutoutWidth) > TotalWidth-(cutoutWidthMinSideMargin*2)) { $('#dvMsgAlert').html(' The opening is too wide relative to the outside dimension. We require at least ' + cutoutWidthMinSideMargin + '" of material on both sides of the opening for structural stability (the opening width must be at least ' + cutoutWidthMinSideMargin*2 + '" smaller than the outside width). Otherwise, call for special orders.').show('highlight', 800); return false; } } } } } if (pricingType == 'Calculator') { // Make sure radius is within limits selectedRadius = $('#ddRadiusCorners').val(); if (selectedRadius != undefined) { if (selectedRadius == '') selectedRadius = '0/16'; radiusSize = 0; fracParts = selectedRadius.split(' '); if (fracParts.length > 1) { radiusSize = parseFloat(fracParts[0]) + eval(fracParts[1]); } else radiusSize = eval(selectedRadius); radiusSize = radiusSize-0; smallestDim = (TotalWidth > TotalLength ? TotalLength : TotalWidth); if (radiusSize > (smallestDim/2)) { $('#dvMsgAlert').html(' The size previously selected for the radius was too large for the dimensions and has been reset. Questions? Please call us to discuss at (866)-633-7961.').show('highlight', 800); selectedRadius = "0/16"; } // Fill control maxCornerSize = (smallestDim/2); if (maxCornerSize > 6.5) maxCornerSize = 6.5; addFracs($('#ddRadiusCorners'), '

', 0.125, 1, 0.125, true); addFracs($('#ddRadiusCorners'), '', 1.25, (maxCornerSize-0.0625), 0.25, false); $('#ddRadiusCorners').val(selectedRadius); // Reselect previous value $('#ddRadiusCorners').parent().parent().show(); } // Make sure the routed edge is within limits selectedEdge = $('#ddRoutedEdge').val(); if (selectedEdge != undefined) { if (selectedEdge == '') selectedEdge = '0/16'; selectedEdgeType = ''; selectedEdgeTypePos = selectedEdge.indexOf(" ("); if (selectedEdgeTypePos > 0) { selectedEdgeType = selectedEdge.substr(selectedEdgeTypePos); selectedEdge = selectedEdge.substr(0, selectedEdgeTypePos); } fracParts = selectedEdge.split(' '); if (fracParts.length > 1) { edgeSize = parseInt(fracParts[0]) + eval(fracParts[1]); } else edgeSize = eval(selectedEdge); edgeSize = edgeSize-0; if (((Thickness/2)+0.125) <= edgeSize) { $('#dvMsgAlert').html(' The size you previously selected for the routed edge was too large for the thickness and has been reset. Question? Please call us to discuss at (866)-633-7961.').show('highlight', 800); selectedEdge = "0/16"; } // Fill control optionX = '

'; optionA = '

'; optionB = '

'; optionC = '

'; optionD = '

'; optionE = '

'; optionF = '

'; optionG = '

'; optionH = '

'; $('#ddRoutedEdge').find('option').remove().end(); switch (Thickness) { case 0.125 : $('#ddRoutedEdge').append(optionX + optionA + optionB); break; case 0.25 : $('#ddRoutedEdge').append(optionX + optionA + optionB + optionC + optionE); break; case 0.375 : $('#ddRoutedEdge').append(optionX + optionA + optionB + optionC + optionD + optionE + optionG); break; case 0.5 : $('#ddRoutedEdge').append(optionX + optionA + optionB + optionC + optionD + optionE + optionF + optionG); break; default : $('#ddRoutedEdge').append(optionX + optionA + optionB + optionC + optionD + optionE + optionF + optionG + optionH); } $('#ddRoutedEdge').val(selectedEdge + selectedEdgeType); // Reselect previous value $('#ddRoutedEdge').parent().parent().show(); } // Update the custom options if (selectedEdge == '0/16') customOptions['roundover edges'] = "None (Raw Cut)"; else customOptions['roundover edges'] = selectedEdge + '"' + selectedEdgeType; if (selectedRadius == '0/16') customOptions['radius corners'] = "None (Square)"; else customOptions['radius corners'] = selectedRadius + '"'; if (castToNum(isNaN(pricingJson.RoutedEdge) ? 0 : pricingJson.RoutedEdge) > 0) { if (selectedEdge != '0/16') { priceModifier += castToNum(pricingJson.RoutedEdge); } } if (castToNum(isNaN(pricingJson.RadiusCorners) ? 0 : pricingJson.RadiusCorners) > 0) { if (selectedRadius != '0/16') { priceModifier += castToNum(pricingJson.RadiusCorners); } } } // Color Warning var showBlackWarning = false; var color = findProductOption('Color').find('option:selected').text(); if ((color != undefined) && (color == 'Black')) showBlackWarning = true; else if ((pricingJson.Color != undefined) && (pricingJson.Color == 'Black')) showBlackWarning = true; if (showBlackWarning) { $('#dvAdditionalInfo').html('Sea Hunt Dealer Display (1) Attention
Black is more susceptible to scratches and scuffs than white. Typically these are small, superficial and only visible at certain angles/lighting. While we make every effort to minimize this during the manufacturing process, please be aware that some marks may be visible.

').show('highlight', 800); } else $('#dvAdditionalInfo').hide(); // Base lines var sqFt = parseFloat((TotalLength * TotalWidth) / 144); $('#FreeShippingPopup').hide(); $('#GirthPopup').hide(); $('#LargePackagePopup').hide(); $('#AdditionalHandlingPopup').hide(); var longLength = [TotalLength, TotalWidth, TotalHeight]; longLength.sort(sortNumReversed); // Weight Weight = Weight * sqFt; // Check dimensional weight (we use dim weight if its greater) var DimensionalWeight = (((longLength[0]+4)*(longLength[1]+2)*2)/200); // Adding 1" for outside padding/packages if (DimensionalWeight > Weight) { Weight = DimensionalWeight; } var Girth = ((longLength[0]+4) + (2 * (longLength[1]+2)) + (2 * longLength[2])); var $content = ''; // Shipping Rule: Check for max shippable girth var shippingGroup = ''; if (Girth > castToNum(pricingJson.MaxGirth)) { Weight += 100; // Add weight of pallette $content = $('#GirthPopup'); $content.show(); shippingGroup = '1156,'; // 'Freight Only'; } // Shipping Rule: Check for large package surcharge (weight must be at least 90 for large pkgs) else if ((Girth > 130) || ((longLength[0]+4) > 95)) { if (Weight < 90) Weight = 90; $content = $('#LargePackagePopup'); $content.show(); shippingGroup = '1166,'; // 'Large Package Surcharge'; } // Shipping Rule: If the longest dimension is > 47 OR second longest is > 29 else if ((longLength[0]+4 > 47) || (longLength[1]+2 > 29)) { $content = $('#AdditionalHandlingPopup'); $content.show(); shippingGroup = '1167,'; // 'Additional Handling'; } else $('#FreeShippingPopup').show(); // Append product base shipping group if present if ((pricingJson.ShippingGroup != undefined) && (pricingJson.ShippingGroup != '')) { shippingGroup = shippingGroup + pricingJson.ShippingGroup + ','; } // Trim trailing comma if (shippingGroup != '') shippingGroup = shippingGroup.substring(0, shippingGroup.length - 1); customOptions['shipperhq_shipping_group'] = shippingGroup; // Personalization string var sPersonalization = ''; var sLength, sHeight, sWidth, sDepth; if ((pricingType == 'Circle') || (pricingType == 'Donut')) { /* Store product has Personalizations configured as: Diameter|HoleDiameter|Thickness */ var sDiameter = isNaN(LengthIn) ? 0 : LengthIn; if (LengthInFraction != '0/16') { sDiameter += ' ' + LengthInFraction; } var sHoleDiameter = isNaN(CutoutLengthIn) ? 0 : CutoutLengthIn; if (CutoutLengthInFraction != '0/16') { sHoleDiameter += ' ' + CutoutLengthInFraction; } sDiameter += '"'; sHoleDiameter += '"'; sThickness += '"'; customOptions['diameter'] = sDiameter; customOptions['hole diameter'] = sHoleDiameter; customOptions['thickness'] = sThickness; sPersonalization = sDiameter + '|' + sHoleDiameter + '|' + sThickness; } else if (pricingType == 'Door') { /* Store product has Personalizations configured as: Height|Width|MeasurementType */ sHeight = isNaN(LengthIn) ? 0 : LengthIn; if (LengthInFraction != '0/16') { sHeight += ' ' + LengthInFraction; } sWidth = isNaN(WidthIn) ? 0 : WidthIn; if (WidthInFraction != '0/16') { sWidth += ' ' + WidthInFraction; } sHeight += '"'; sWidth += '"'; customOptions['height'] = sHeight; customOptions['width'] = sWidth; customOptions['measurement type'] = MeasurementType; sPersonalization = sHeight + '|' + sWidth + '|' + MeasurementType; } else if (pricingType == 'LengthOnly') { /* Store product has Personalizations configured as: Length */ sLength = isNaN(LengthIn) ? 0 : LengthIn; if (LengthInFraction != '0/16') { sLength += ' ' + LengthInFraction; } sLength += '"'; customOptions['length'] = sLength; sPersonalization = sLength; } else if (pricingType == 'Strip') { /* Store product has Personalizations configured as: Length */ sLength = isNaN(LengthIn) ? 0 : LengthIn; if (LengthInFraction != '0/16') { sLength += ' ' + LengthInFraction; } sLength += '"'; customOptions['length'] = sLength; sPersonalization = sLength; } else if (pricingType == 'KeeperStrip') { /* Store product has Personalizations configured as: Length|Width */ sLength = isNaN(LengthIn) ? 0 : LengthIn; if (LengthInFraction != '0/16') { sLength += ' ' + LengthInFraction; } sHeight = isNaN(WidthIn) ? 0 : WidthIn; if (WidthInFraction != '0') { sHeight += ' ' + WidthInFraction; } sLength += '"'; sHeight += '"'; customOptions['length'] = sLength; customOptions['height'] = sHeight; sPersonalization = sLength + '|' + sHeight; } else if (pricingType == 'HeightWidthMaterial') { /* Store product has Personalizations configured as: Length|Width|SKU|Thickness */ sLength = isNaN(LengthIn) ? 0 : LengthIn; if (LengthInFraction != '0/16') { sLength += ' ' + LengthInFraction; } sWidth = isNaN(WidthIn) ? 0 : WidthIn; if (WidthInFraction != '0/16') { sWidth += ' ' + WidthInFraction; } sLength += '"'; sWidth += '"'; sThickness += '"'; customOptions['height'] = sLength; customOptions['width'] = sWidth; customOptions['thickness'] = sThickness; customOptions['sku'] = SKU; sPersonalization = sLength + '|' + sWidth + '|' + SKU + '|' + sThickness; } else if (pricingType == 'Material') { /* Store product has Personalizations configured as: Length|Width|SKU|Thickness */ sLength = isNaN(LengthIn) ? 0 : LengthIn; if (LengthInFraction != '0/16') { sLength += ' ' + LengthInFraction; } sWidth = isNaN(WidthIn) ? 0 : WidthIn; if (WidthInFraction != '0/16') { sWidth += ' ' + WidthInFraction; } var sCutoutLength = isNaN(CutoutLengthIn) ? 0 : CutoutLengthIn; if (CutoutLengthInFraction != '0/16') { sCutoutLength += ' ' + CutoutLengthInFraction; } var sCutoutWidth = isNaN(CutoutWidthIn) ? 0 : CutoutWidthIn; if (CutoutWidthInFraction != '0/16') { sCutoutWidth += ' ' + CutoutWidthInFraction; } sLength += '"'; sWidth += '"'; sThickness += '"'; sCutoutLength += '"'; sCutoutWidth += '"'; customOptions[lengthLabel] = sLength; customOptions[widthLabel] = sWidth; customOptions['thickness'] = sThickness; customOptions['sku'] = SKU; customOptions[cutoutLengthLabel] = sCutoutLength; customOptions[cutoutWidthLabel] = sCutoutWidth; // customOptions['cutout radius'] = sCutoutRadius; (we dont need to pass this in because its navite value format is fine) sPersonalization = sLength + '|' + sWidth + '|' + SKU + '|' + sThickness; } else if (pricingType == 'MaterialOpening') { /* Store product has Personalizations configured as: Length|Width|SKU|Thickness */ sLength = isNaN(LengthIn) ? 0 : LengthIn; if (LengthInFraction != '0/16') { sLength += ' ' + LengthInFraction; } sWidth = isNaN(WidthIn) ? 0 : WidthIn; if (WidthInFraction != '0/16') { sWidth += ' ' + WidthInFraction; } var sCutoutStyle = $('#ddCutoutStyle').val(); if (sCutoutStyle == 'None') { CutoutLengthIn = 0; CutoutLengthInFraction = '0/16'; CutoutWidthIn = 0; CutoutWidthInFraction = '0/16'; } var sCutoutLength = isNaN(CutoutLengthIn) ? 0 : CutoutLengthIn; if (CutoutLengthInFraction != '0/16') { sCutoutLength += ' ' + CutoutLengthInFraction; } var sCutoutWidth = isNaN(CutoutWidthIn) ? 0 : CutoutWidthIn; if (CutoutWidthInFraction != '0/16') { sCutoutWidth += ' ' + CutoutWidthInFraction; } sLength += '"'; sWidth += '"'; sThickness += '"'; sCutoutLength += '"'; sCutoutWidth += '"'; customOptions['height'] = sLength; customOptions['width'] = sWidth; customOptions['thickness'] = sThickness; customOptions['sku'] = SKU; customOptions['OpeningStyle'] = sCutoutStyle; customOptions['OpeningHeight'] = sCutoutLength; customOptions['OpeningWidth'] = sCutoutWidth; sPersonalization = sLength + '|' + sWidth + '|' + SKU + '|' + sThickness; }else if (pricingType == '3DMaterial') { /* Store product has Personalizations configured as: Height|Width|Depth|Dividers|Measurement Type */ sLength = isNaN(LengthIn) ? 0 : LengthIn; if (LengthInFraction != '0/16') { sLength += ' ' + LengthInFraction; } sWidth = isNaN(WidthIn) ? 0 : WidthIn; if (WidthInFraction != '0/16') { sWidth += ' ' + WidthInFraction; }sDepth = isNaN(DepthIn) ? 0 : DepthIn; if (DepthInFraction != '0/16') { sDepth += ' ' + DepthInFraction; } sLength += '"'; sWidth += '"';sDepth += '"'; customOptions['height'] = sLength; customOptions['width'] = sWidth; customOptions['depth'] = sDepth;if (pricingJson.IncludeDividers != 'No') {var includeDividers = $('#ddIncludeDividers').val();customOptions['dividers'] = includeDividers;} customOptions['measurement type'] = MeasurementType; sPersonalization = sLength + '|' + sWidth + '|' + sDepth + '|' + MeasurementType; } else { /* Store product has Personalizations configured as: Length|Width|SKU|Thickness */ sLength = isNaN(LengthIn) ? 0 : LengthIn; if (LengthInFraction != '0/16') { sLength += ' ' + LengthInFraction; } sWidth = isNaN(WidthIn) ? 0 : WidthIn; if (WidthInFraction != '0/16') { sWidth += ' ' + WidthInFraction; } sLength += '"'; sWidth += '"'; sThickness += '"'; customOptions['length'] = sLength; customOptions['width'] = sWidth; customOptions['thickness'] = sThickness; customOptions['sku'] = SKU; sPersonalization = sLength + '|' + sWidth + '|' + SKU + '|' + sThickness; } // Pricing var CalcPrice = sqFt * Price; var OldPrice = 0;// --------------------------------- // Pricing (exceptions)// --------------------------------- if (pricingType == 'LengthOnly') { // Priced by length CalcPrice = parseFloat(TotalLength) * Price; } else if (pricingType == 'Strip') { // Strips have a min width needed for production var minCalcWidth = castToNum(pricingJson.MinCalcWidth); if (TotalWidth < minCalcWidth) { CalcPrice = (parseFloat((TotalLength * minCalcWidth) / 144)) * Price; } } else if (pricingType == 'KeeperStrip') { // KeeperStrips have a min 5" width needed for production if (TotalWidth < 5) { CalcPrice = (parseFloat((TotalLength * 5) / 144)) * Price; } }else if (pricingType == '3DMaterial') {CalcPrice = parseFloat((TotalLength*TotalWidth*TotalDepth) * Price);if ($('#ddIncludeDividers').val() != 'No') {if ((pricingJson.DividersPrice != undefined) && (pricingJson.DividersPrice != '')) {var dividersPrice = castToNum(pricingJson.DividersPrice);CalcPrice += parseFloat((TotalLength*TotalWidth*TotalDepth) * dividersPrice);}}} else {// You might be allowed to make a 2x2 part but we might// have a min billable production proce of a 5x5 part (min/max Calc values)// not to be confused with (min/max values) for dimension limits. var minCalcWidth = castToNum(pricingJson.MinCalcWidth); var minCalcLength = castToNum(pricingJson.MinCalcLength); var calcWidth = TotalWidth; var calcLength = TotalLength; var recalc = false; if (TotalWidth < minCalcWidth) { calcWidth = minCalcWidth; recalc = true; } if (TotalLength < minCalcLength) { calcLength = minCalcLength; recalc = true; } if (recalc) CalcPrice = (parseFloat((calcWidth * calcLength) / 144)) * Price; } CalcPrice += castToNum(eval(pricingJson.CalculationBasePrice)) + priceModifier; // Process Variants / Adjust Price var sVariants = ''; var txtMarkup = ''; /* handle standard variants */ $('#product-options-wrapper').find('select.product-custom-option').each(function(index) { var txtSelected = $(this).find("option:selected").text().trim(); /* get the markup */ if (txtSelected.indexOf('+$') > -1 || txtSelected.indexOf('+ $') > -1 || txtSelected.indexOf('add $') > -1) { /* dollar markup */ txtMarkup = txtSelected.split('$')[1]; CalcPrice += parseFloat(eval(txtMarkup)); } else if (txtSelected.indexOf('add') > -1 && txtSelected.indexOf("%") > -1) { /* percentage markup */ txtMarkup = txtSelected.split('add ')[1]; txtMarkup = txtMarkup.split('%')[0]; CalcPrice += parseFloat(CalcPrice * (eval(txtMarkup) / 100)); } /* record the selected text ShortDesc */ if (txtSelected.indexOf(' / ') == -1) { sVariants += txtSelected + "|"; } else { var sVar = $.trim(txtSelected.split(' / ')[0]); sVariants += sVar + "|"; } }); if (castToNum(pricingJson.CutChargeThreshold) > 0) { if (sqFt < castToNum(pricingJson.CutChargeThreshold)) { CalcPrice += castToNum(pricingJson.CutCharge); } } var customer_group = readCookie('customer_group') if (customer_group != null) { customer_group = customer_group.replace(/\+/g, ' '); console.log("Customer Group: " + customer_group); } if (customer_group == pricingJson.PricePercentageDiscountGroup) { pricePercentageDiscount = castToNum(pricingJson.PricePercentageDiscount); } // Add scrap factor for sheets if ((castToNum(pricingJson.SheetWidth) > 0) && (castToNum(pricingJson.ScrapBillRate) > 0)) { // longLength[0] = longest ... sorted [3] var lengthLong = longLength[0]; var lengthShort = longLength[1]; var sheetWidth = castToNum(pricingJson.SheetWidth); var scrapBillRate = castToNum(pricingJson.ScrapBillRate); var scrapFactorAmt = 0; if (lengthLong < sheetWidth) scrapFactorAmt = (((((sheetWidth-lengthLong)*(lengthShort))/144)*Price)*scrapBillRate); else if (lengthLong > sheetWidth) scrapFactorAmt = (((((sheetWidth-lengthShort)*(lengthLong))/144)*Price)*scrapBillRate); // Adjust price CalcPrice += scrapFactorAmt; } // Adjust for discount if (pricePercentageDiscount > 0) { OldPrice = CalcPrice; CalcPrice = CalcPrice - (CalcPrice * pricePercentageDiscount); } // Check min price (hardcoded for now -- make Json property later if (CalcPrice < 10) { CalcPrice = 10.00; OldPrice = CalcPrice; } CalcPrice = CalcPrice.toFixed(2); OldPrice = OldPrice.toFixed(2); ShowPrice(CalcPrice, OldPrice); customOptions['item_id'] = pricingJson.ItemID; customOptions['price'] = CalcPrice; customOptions['variants'] = sVariants; customOptions['quantity'] = AddQuantity; customOptions['personalization'] = sPersonalization; customOptions['weight'] = Weight; for (var prop in customOptions) { var propValue = customOptions[prop]; setCustomField("calc_" + prop, propValue); setProductOption(prop, propValue); } return true; } function sortNumReversed(a, b) { return b - a; } function setCustomField(name, value) { var $field = $form.find("#" + name); if ($field.length < 1) { $field = createCustomField(name); } $field.val(value); } function createCustomField(input_name) { return $("", { type: "hidden", id: input_name, name: input_name }).appendTo($form); } function createHiddenField(id, value) { return $("", { type: "hidden", id: id, name: id, value: value }).appendTo($form); } function setProductOption(name, value) {console.log('Setting product option: ' + name); findProductOption(name).val(value); } function showProductOption(name) {console.log('Showing product option: ' + name); findProductOption(name).closest('.field').show(); } function hideProductOption(name) {console.log('Hiding product option: ' + name); findProductOption(name).closest('.field').hide(); } function findProductOption(name) {console.log('Looking for product option: ' + name); // initialize as empty element so that we don't get null pointers if trying to // access a field that wasn't found in our check below var $field = $(''); $('#product-options-wrapper .field').each(function() { if ($(this).is('.configurable')) { return true; // continue; } var $label = $(this).find('.label'); if ($label.text().trim().toLowerCase() === name.trim().toLowerCase()) { $field = $('#' + $label.attr('for')); return false; // break; } }); return $field; } function clearFields() { $('input', $teakVariations).val('').trigger('change'); $('select', $teakVariations).each(function() { $('option', this).first().prop('selected', true); $(this).trigger('change'); }); findProductOption('thickness').val(''); findProductOption('height').val(''); findProductOption('length').val(''); findProductOption('width').val(''); findProductOption('depth').val(''); setCustomField("calc_price", ""); } function prefill(pricingType) { var $lengthInput = $('#txtLengthIn'); var $lengthSelect = $('#ddLengthIn'); var $widthInput = $('#txtWidthIn'); var $widthSelect = $('#ddWidthIn'); var $depthInput = $('#txtDepthIn'); var $depthSelect = $('#ddDepthIn'); var $cutoutLengthInput = $('#txtCutoutLengthIn'); var $cutoutLengthSelect = $('#ddCutoutLengthIn'); var $cutoutWidthInput = $('#txtCutoutWidthIn'); var $cutoutWidthSelect = $('#ddCutoutWidthIn'); var cHeight, cHoleDiameter, cMeasurementType, cutoutLength; switch (pricingType) { case 'Circle': prefillUnitFields('diameter', $lengthInput, 0, $lengthSelect, 1); prefillUnitFields('hole diameter', $cutoutLengthInput, 0, $cutoutLengthSelect, 1); prefillThickness(); cHoleDiameter = findProductOption('hole diameter').val(); cHoleDiameter = stripUnits(cHoleDiameter); if (cHoleDiameter.length === 0 || cHoleDiameter == 0) { $('#ddMeasurementType').val('Disc').trigger('change'); } else { $('#ddMeasurementType').val('Donut').trigger('change'); } break; case 'Donut': prefillUnitFields('diameter', $lengthInput, 0, $lengthSelect, 1); prefillUnitFields('hole diameter', $cutoutLengthInput, 0, $cutoutLengthSelect, 1); prefillThickness(); $('#ddMeasurementType').val('Donut').trigger('change'); break; case 'LengthOnly': prefillUnitFields('length', $lengthInput, 0, $lengthSelect, 1); break; case 'KeeperStrip': case 'Strip': prefillUnitFields('length', $lengthInput, 0, $lengthSelect, 1); cHeight = findProductOption('height').val(); if (cHeight.length > 0) { cHeight = stripUnits(cHeight); if (cHeight.indexOf(" ") == -1) { if (cHeight.indexOf("/") != -1) { cHeight = "0 " + cHeight; } else { cHeight = cHeight + " 0"; } } $('#ddWidthIn').val(cHeight).trigger('change'); } break; case 'Door': prefillUnitFields('height', $lengthInput, 0, $lengthSelect, 1); prefillUnitFields('width', $widthInput, 0, $widthSelect, 1); cMeasurementType = findProductOption('measurement type').val(); if (cMeasurementType.length > 0) { $('#ddMeasurementType').val(cMeasurementType).trigger('change'); } break; case 'HeightWidthMaterial': prefillUnitFields('height', $lengthInput, 0, $lengthSelect, 1); prefillUnitFields('width', $widthInput, 0, $widthSelect, 1); prefillThickness(); break; case 'Material': prefillUnitFields(lengthLabel, $lengthInput, 0, $lengthSelect, 1); prefillUnitFields(widthLabel, $widthInput, 0, $widthSelect, 1); prefillThickness(); prefillUnitFields(cutoutLengthLabel, $cutoutLengthInput, 0, $cutoutLengthSelect, 1); prefillUnitFields(cutoutWidthLabel, $cutoutWidthInput, 0, $cutoutWidthSelect, 1); cMeasurementType = findProductOption('measurement type').val(); if (cMeasurementType.length > 0) { cutoutLength = findProductOption('cutout length').val(); cutoutLength = stripUnits(cutoutLength); if (cutoutLength.length === 0 || cutoutLength == 0) { $('#ddMeasurementType').val('Outside').trigger('change'); } else { $('#ddMeasurementType').val(cMeasurementType).trigger('change'); } } break;case '3DMaterial': prefillUnitFields(lengthLabel, $lengthInput, 0, $lengthSelect, 1); prefillUnitFields(widthLabel, $widthInput, 0, $widthSelect, 1); prefillUnitFields(depthLabel, $depthInput, 0, $depthSelect, 1); //prefillUnitFields(cutoutLengthLabel, $cutoutLengthInput, 0, $cutoutLengthSelect, 1); //prefillUnitFields(cutoutWidthLabel, $cutoutWidthInput, 0, $cutoutWidthSelect, 1); cMeasurementType = findProductOption('measurement type').val(); if (cMeasurementType.length > 0) { cutoutLength = findProductOption('cutout length').val(); cutoutLength = stripUnits(cutoutLength); if (cutoutLength.length === 0 || cutoutLength == 0) { $('#ddMeasurementType').val('Outside').trigger('change'); } else { $('#ddMeasurementType').val(cMeasurementType).trigger('change'); } } break; case 'MaterialOpening': prefillUnitFields('height', $lengthInput, 0, $lengthSelect, 1); prefillUnitFields('width', $widthInput, 0, $widthSelect, 1); prefillThickness(); // Default hidden selection $('#ddCutoutStyle').val('None').trigger('change'); prefillUnitFields('OpeningHeight', $cutoutLengthInput, 0, $cutoutLengthSelect, 1); prefillUnitFields('OpeningWidth', $cutoutWidthInput, 0, $cutoutWidthSelect, 1); break; case 'Calculator': prefillUnitFields('length', $lengthInput, 0, $lengthSelect, 1); prefillUnitFields('width', $widthInput, 0, $widthSelect, 1); prefillThickness(); break; default: break; } } function prefillUnitFields(property, $field1, idx1, $field2, idx2) {console.log('Prefilling: ' + property); var value = findProductOption(property).val(); if (typeof value !== 'undefined' && value.length > 0) { value = stripUnits(value); var valueArray = value.split(' '); if (typeof idx1 !== 'undefined' && $field1.length > 0) { var value1 = valueArray[idx1]; if (typeof value1 !== 'undefined') { $field1.val(value1).trigger('change'); } } if (typeof idx2 !== 'undefined' && $field2.length > 0) { var value2 = valueArray[idx2]; if (typeof value2 !== 'undefined') { $field2.val(value2).trigger('change'); } } } } function prefillThickness() { var cThickness = findProductOption('thickness').val(); if (typeof cThickness !== 'undefined') { cThickness = stripUnits(cThickness); for (var i = 0; i < pricingJson.Base.length; i++) { if (pricingJson.Base[i]['Thickness'] == cThickness) { $('#ddThickness').val(pricingJson.Base[i]['SKU']).trigger('change'); return; } } } } function stripUnits(value) { if (typeof value !== 'undefined' && value.length > 0) { return value.substring(0, value.length - 1); } return value; } function addFracs(el, firstItem, startVal, endVal, increment, clear) { if (clear) $(el).find('option').remove().end(); var options = firstItem; var frac = ''; for(var i = startVal; i<=endVal; i+=increment) { frac = makeFrac(i); options += '

'; } $(el).append(options); } // IE < 12 compatibility Math.trunc = Math.trunc || function(x) { if (isNaN(x)) { return NaN; } if (x > 0) { return Math.floor(x); } return Math.ceil(x); }; function makeFrac(inches) { var asFrac = ''; var unitsPart = ''; var fracPart = ''; var leftPart = Math.trunc(inches); if (leftPart > 0) unitsPart = leftPart.toString(); var rightPart = inches - leftPart; switch (rightPart.toFixed("5").toString()) { case "0.01560": fracPart = "1/64"; break; case "0.03130": fracPart = "1/32"; break; case "0.03125": fracPart = "1/32"; break; // Because some of our data rounded case "0.04690": fracPart = "3/64"; break; case "0.06250": fracPart = "1/16"; break; case "0.07810": fracPart = "5/64"; break; case "0.09380": fracPart = "3/32"; break; case "0.10940": fracPart = "7/64"; break; case "0.12500": fracPart = "1/8"; break; case "0.14060": fracPart = "9/64"; break; case "0.15630": fracPart = "5/32"; break; case "0.17190": fracPart = "11/64"; break; case "0.18700": fracPart = "3/16"; break; // Because some of our data rounded case "0.18750": fracPart = "3/16"; break; case "0.20310": fracPart = "13/64"; break; case "0.21880": fracPart = "7/32"; break; case "0.23440": fracPart = "15/64"; break; case "0.25000": fracPart = "1/4"; break; case "0.26560": fracPart = "17/64"; break; case "0.28130": fracPart = "9/32"; break; case "0.29690": fracPart = "19/64"; break; case "0.31250": fracPart = "5/16"; break; case "0.32810": fracPart = "21/64"; break; case "0.34380": fracPart = "11/32"; break; case "0.35940": fracPart = "23/64"; break; case "0.37500": fracPart = "3/8"; break; case "0.39060": fracPart = "25/64"; break; case "0.40630": fracPart = "13/32"; break; case "0.42190": fracPart = "27/64"; break; case "0.43750": fracPart = "7/16"; break; case "0.45310": fracPart = "29/64"; break; case "0.46880": fracPart = "15/32"; break; case "0.48440": fracPart = "31/64"; break; case "0.50000": fracPart = "1/2"; break; case "0.51560": fracPart = "33/64"; break; case "0.53130": fracPart = "17/32"; break; case "0.54690": fracPart = "35/64"; break; case "0.56250": fracPart = "9/16"; break; case "0.57810": fracPart = "37/64"; break; case "0.59380": fracPart = "19/32"; break; case "0.60940": fracPart = "39/64"; break; case "0.62500": fracPart = "5/8"; break; case "0.64060": fracPart = "41/64"; break; case "0.65630": fracPart = "21/32"; break; case "0.67190": fracPart = "43/64"; break; case "0.68750": fracPart = "11/16"; break; case "0.70310": fracPart = "45/64"; break; case "0.71880": fracPart = "23/32"; break; case "0.73440": fracPart = "47/64"; break; case "0.75000": fracPart = "3/4"; break; case "0.76560": fracPart = "49/64"; break; case "0.78130": fracPart = "25/32"; break; case "0.79690": fracPart = "51/64"; break; case "0.81250": fracPart = "13/16"; break; case "0.82810": fracPart = "53/64"; break; case "0.84380": fracPart = "27/32"; break; case "0.85940": fracPart = "55/64"; break; case "0.87500": fracPart = "7/8"; break; case "0.89060": fracPart = "57/64"; break; case "0.90630": fracPart = "29/32"; break; case "0.92190": fracPart = "59/64"; break; case "0.93750": fracPart = "15/16"; break; case "0.95310": fracPart = "61/64"; break; case "0.96880": fracPart = "31/32"; break; case "0.98440": fracPart = "63/64"; break; } if (leftPart > 0) { asFrac = unitsPart; if ((fracPart != '') && (fracPart != '0/16')) asFrac += ' '; } if (rightPart > 0) asFrac += fracPart; return asFrac; } // CALCULATOR CONTROLS // --------------------------------- var lengthLabel, widthLabel, thicknessLabel, cutoutLengthLabel, cutoutWidthLabel, radiusLabel, cutoutRadiusLabel; if (pricingType == 'Circle') { lengthLabel = pricingJson.LengthLabel ? pricingJson.LengthLabel : "Diameter"; widthLabel = pricingJson.WidthLabel ? pricingJson.WidthLabel : "Diameter"; thicknessLabel = pricingJson.ThicknessLabel ? pricingJson.ThicknessLabel : "Thickness"; $teakVariations.append('

' + thicknessLabel + ':

'); for (var i = 0; i < pricingJson.Base.length; i++) { $('#ddThickness').append('

'); } $teakVariations.append('

Diameter:

'); $('#ddLengthIn').append('

'); createHiddenField("txtWidthIn", "0"); createHiddenField("ddWidthIn", "0"); $teakVariations.append('

'); $('#CircleCutoutOption').append('

Center Hole Cut-Out Option

If desired, we can cut out a center hole for you. Do you want to provide dimensions for a center hole cutout?

'); $('#ddMeasurementType').on('change', function() { if ($(this).val() == 'Donut') { $('#CircleCutoutDimensions').show(); } else { $('#CircleCutoutDimensions').hide(); } }); $('#CircleCutoutOption').append('

'); $('#ddCutoutLengthIn').append('

'); hideProductOption('thickness'); hideProductOption('diameter'); hideProductOption('hole diameter'); $teakVariations.show(); } else if (pricingType == 'Donut') { lengthLabel = pricingJson.LengthLabel ? pricingJson.LengthLabel : "Diameter"; widthLabel = pricingJson.WidthLabel ? pricingJson.WidthLabel : "Diameter"; thicknessLabel = pricingJson.ThicknessLabel ? pricingJson.ThicknessLabel : "Thickness"; $teakVariations.append('

' + thicknessLabel + ':

'); for (var i = 0; i < pricingJson.Base.length; i++) { $('#ddThickness').append('

'); } $teakVariations.append('

Outside Diameter:

'); $('#ddLengthIn').append('

'); createHiddenField("txtWidthIn", "0"); createHiddenField("ddWidthIn", "0"); createHiddenField("ddMeasurementType", "Donut"); $teakVariations.append('

Hole Diameter:

'); $('#ddCutoutLengthIn').append('

'); hideProductOption('thickness'); hideProductOption('diameter'); hideProductOption('hole diameter'); $teakVariations.show(); } else if (pricingType == 'MaterialOpening') { lengthLabel = pricingJson.LengthLabel ? pricingJson.LengthLabel : "Length"; widthLabel = pricingJson.WidthLabel ? pricingJson.WidthLabel : "Width"; thicknessLabel = pricingJson.ThicknessLabel ? pricingJson.ThicknessLabel : "Thickness"; cutoutLengthLabel = pricingJson.CutoutLengthLabel ? pricingJson.CutoutLengthLabel : "Opening Length"; cutoutWidthLabel = pricingJson.CutoutWidthLabel ? pricingJson.CutoutWidthLabel : "Opening Width"; cutoutStyleLabel = pricingJson.CutoutStyleLabel ? pricingJson.CutoutStyleLabel : "Opening Style"; if (pricingJson.Base.length == 1) { createHiddenField("ddThickness", pricingJson.Base[0].SKU); } else { $teakVariations.append('

' + thicknessLabel + ':

'); for (var i = 0; i < pricingJson.Base.length; i++) { $('#ddThickness').append('

'); } } $teakVariations.append('

' + lengthLabel + ':

'); $('#ddLengthIn').append('

'); $teakVariations.append('

' + widthLabel + ':

'); $('#ddWidthIn').append('

'); $teakVariations.append('

'); $('#CutoutStyleOption').append('

' + cutoutStyleLabel + ':

'); $('#ddCutoutStyle').on('change', function() { var sCutoutStyle = $(this).val(); // Assing the selection to the actual hidden field // var $cutoutStyleFld = findProductOption('OpeningStyle'); // var val = $cutoutStyleFld.children('option').filter(function () { return $(this).html() == sCutoutStyle; }).val(); // $cutoutStyleFld.val(val).trigger('change'); if (sCutoutStyle == 'None') { $('#CutoutDimensionsW').hide(); $('#CutoutDimensionsL').hide(); $('#CutoutDimensionsPic').hide(); } else { $('#CutoutDimensionsW').show(); $('#CutoutDimensionsL').show(); // Show style // $('#CutoutDimensionsPic .stylepics').hide(); // if (sCutoutStyle == 'Rectangular') $('#CutoutDimensionsPic .stylepics.style1').show(); // if (sCutoutStyle == 'Partial Arch') $('#CutoutDimensionsPic .stylepics.style2').show(); // if (sCutoutStyle == 'Full Radius') $('#CutoutDimensionsPic .stylepics.style3').show(); // $('#CutoutDimensionsPic').show(); } }); $('#CutoutStyleOption').append('

'); $('#CutoutStyleOption').append('

'); $('#ddCutoutLengthIn').append('

'); $('#CutoutStyleOption').append('

'); $('#ddCutoutWidthIn').append('

'); // Default hidden selection // $('#ddCutoutStyle').trigger('change'); // var $cutoutStyleFld = findProductOption('OpeningStyle'); hideProductOption('Thickness'); hideProductOption('Height'); hideProductOption('Width'); hideProductOption('OpeningHeight'); hideProductOption('OpeningWidth'); hideProductOption('OpeningStyle'); $teakVariations.show(); } else if (pricingType == 'LengthOnly') { lengthLabel = pricingJson.LengthLabel ? pricingJson.LengthLabel : "Length"; widthLabel = pricingJson.WidthLabel ? pricingJson.WidthLabel : "Height"; thicknessLabel = pricingJson.ThicknessLabel ? pricingJson.ThicknessLabel : "Thickness"; $teakVariations.append('

' + lengthLabel + ':

'); $('#ddLengthIn').append('

'); createHiddenField("txtWidthIn", "0"); createHiddenField("ddWidthIn", "0"); hideProductOption('length'); $teakVariations.show(); } else if (pricingType == 'Strip') { lengthLabel = pricingJson.LengthLabel ? pricingJson.LengthLabel : "Length"; widthLabel = pricingJson.WidthLabel ? pricingJson.WidthLabel : "Height"; thicknessLabel = pricingJson.ThicknessLabel ? pricingJson.ThicknessLabel : "Thickness"; $teakVariations.append('

' + lengthLabel + ':

'); $('#ddLengthIn').append('

'); createHiddenField("txtWidthIn", "0"); if (castToNum(pricingJson.MaxWidth) > 0) { $teakVariations.append('

' + widthLabel + ':

'); } else { createHiddenField("ddWidthIn", "0"); } hideProductOption('length'); $teakVariations.show(); } else if (pricingType == 'KeeperStrip') { lengthLabel = pricingJson.LengthLabel ? pricingJson.LengthLabel : "Length"; widthLabel = pricingJson.WidthLabel ? pricingJson.WidthLabel : "Height"; thicknessLabel = pricingJson.ThicknessLabel ? pricingJson.ThicknessLabel : "Thickness"; $teakVariations.append('

' + lengthLabel + ':

'); $('#ddLengthIn').append('

'); createHiddenField("txtWidthIn", "0"); $teakVariations.append('

' + widthLabel + ':

'); hideProductOption('length'); hideProductOption('height'); $teakVariations.show(); } else if (pricingType == 'Door') { lengthLabel = pricingJson.LengthLabel ? pricingJson.LengthLabel : "Height"; widthLabel = pricingJson.WidthLabel ? pricingJson.WidthLabel : "Width"; thicknessLabel = pricingJson.ThicknessLabel ? pricingJson.ThicknessLabel : "Thickness"; var cutoutDimWidth = 0.0; var cutoutDimLength = 0.0; if (pricingJson.CutoutDim.indexOf(',') == -1) { cutoutDimWidth = castToNum(pricingJson.CutoutDim); cutoutDimLength = castToNum(pricingJson.CutoutDim); } else { var pair = pricingJson.CutoutDim.split(","); cutoutDimWidth = castToNum(pair[0]); cutoutDimLength = castToNum(pair[1]); } var outsideDim = castToNum(pricingJson.OutsideDim); if ((outsideDim + cutoutDimWidth + cutoutDimLength) == 0) { $teakVariations.append('

The measurements you provide below represent the size of your:

'); } else { $teakVariations.append('

The measurements you provide below represent the size of your?

'); } $teakVariations.append('

' + lengthLabel + ':

'); $('#ddLengthIn').append('

'); $teakVariations.append('

' + widthLabel + ':

'); $('#ddWidthIn').append('

'); hideProductOption('measurement type'); hideProductOption('height'); hideProductOption('width'); // Default hidden selections (if present) attrTest = false; var $latchQtyFld = findProductOption('Latch Qty'); attrTest = $latchQtyFld.attr('name'); if ((typeof attrTest !== typeof undefined) && (attrTest !== false)) { $latchQtyFld.val($latchQtyFld.find('option:eq(1)').val()); hideProductOption('Latch Qty'); } $teakVariations.show(); $('#txtLengthIn').on('keyup', function() { CutoutDimensions(); }); $('#ddLengthIn').on('change', function() { CutoutDimensions(); }); $('#ddMeasurementType').on('change', function() { CutoutDimensions(); }); $('#txtWidthIn').on('keyup', function() { CutoutDimensions(); }); $('#ddWidthIn').on('change', function() { CutoutDimensions(); }); } else if (pricingType == 'Material') { var priceTxt = ''; var modifier = 0.0; lengthLabel = pricingJson.LengthLabel ? pricingJson.LengthLabel : "Length"; widthLabel = pricingJson.WidthLabel ? pricingJson.WidthLabel : "Width"; thicknessLabel = pricingJson.ThicknessLabel ? pricingJson.ThicknessLabel : "Thickness"; radiusLabel = pricingJson.RadiusLabel ? pricingJson.RadiusLabel : "Radius"; cutoutLengthLabel = pricingJson.CutoutLengthLabel ? pricingJson.CutoutLengthLabel : "Cutout Length"; cutoutWidthLabel = pricingJson.CutoutWidthLabel ? pricingJson.CutoutWidthLabel : "Cutout Width"; cutoutRadiusLabel = pricingJson.CutoutRadiusLabel ? pricingJson.CutoutRadiusLabel : "Cutout Radius"; if (pricingJson.Base.length == 1) { createHiddenField("ddThickness", pricingJson.Base[0].SKU); } else { $teakVariations.append('

' + thicknessLabel + ':

'); for (var i = 0; i < pricingJson.Base.length; i++) { $('#ddThickness').append('

'); } } $teakVariations.append('

' + lengthLabel + ':

'); $('#ddLengthIn').append('

'); $teakVariations.append('

' + widthLabel + ':

'); $('#ddWidthIn').append('

'); if (pricingJson.RoutedEdge != undefined) { priceTxt = ''; modifier = castToNum(isNaN(pricingJson.RoutedEdge) ? 0 : pricingJson.RoutedEdge); if (modifier > 0) { priceTxt = ' '; } $teakVariations.append('

'); } if (pricingJson.RadiusCorners != undefined) { priceTxt = ''; modifier = castToNum(isNaN(pricingJson.RadiusCorners) ? 0 : pricingJson.RadiusCorners); if (modifier > 0) { priceTxt = ' '; } $teakVariations.append('

'); } // Cutout options if ((pricingJson.MeasurementType == undefined) || (pricingJson.MeasurementType == '')) { createHiddenField("ddMeasurementType", "Outside"); } else { $teakVariations.append('

'); if (pricingJson.MeasurementType == 'InsideOrOutside') { $('#CutoutOption').append('

Center Cut-Out Option
If desired, we can cut out a center area for you. Do you want to provide dimensions for a center cutout?

'); $('#ddMeasurementType').on('change', function() { if ($(this).val() == 'InsideOrOutside') { $('#CutoutDimensions').show(); } else { $('#CutoutDimensions').hide(); } $('#CutoutOption').append('

'); }); } else { createHiddenField("ddMeasurementType", "InsideAndOutside"); $('#CutoutOption').append('

Center Cut-Out Option
Specify your desired cutout dimensions.

'); $('#CutoutOption').append('

'); } $('#CutoutDimensions').append('

' + cutoutLengthLabel + ':

'); $('#ddCutoutLengthIn').append('

'); $('#CutoutDimensions').append('

' + cutoutWidthLabel + ':

'); $('#ddCutoutWidthIn').append('

'); priceTxt = ''; modifier = castToNum(isNaN(pricingJson.CutoutRadiusCorners) ? 0 : pricingJson.CutoutRadiusCorners); if (modifier > 0) { priceTxt = ' '; } $('#CutoutDimensions').append('

' + cutoutRadiusLabel + ':

' + priceTxt + '

'); // Append the notes if ((pricingJson.ZeroCutoutRadiusNote != undefined) && (pricingJson.ZeroCutoutRadiusNote != '')) { $('#CutoutDimensions').append('

'); } if ((pricingJson.CutoutRadiusNote != undefined) && (pricingJson.CutoutRadiusNote != '')) { $('#CutoutDimensions').append('

'); } } hideProductOption('thickness'); hideProductOption(lengthLabel); hideProductOption(widthLabel); hideProductOption('Roundover Edges'); hideProductOption('Radius Corners'); hideProductOption(cutoutLengthLabel); hideProductOption(cutoutWidthLabel); hideProductOption('Cutout Radius'); var $optionFields = $('#product-options-wrapper', $form); var $configFields = $(".product-options-wrapper .field.configurable", $form); var $sizeLabel = $('.label:contains("Size")', $configFields); $sizeLabel = $sizeLabel.filter(function() { return $(this).text().trim() === 'Size'; }); if ($sizeLabel.length == 0) { $teakVariations.show(); clearFields(); // This will trigger the change event on existing controls } else { var $sizeField = $sizeLabel.parent('.field.configurable'); var $sizeSelect = $('select.super-attribute-select', $sizeField); // remove size field from config fields (size field should always be visible) $configFields = $configFields.not($sizeField); // move custom calculator fields after size field $teakVariations.insertAfter($sizeField); var $thicknessLabel = $('.label:contains("Thickness")', $configFields).first(); if ($thicknessLabel.length > 0) { var $thicknessField = $thicknessLabel.parent('.field.configurable'); var $thicknessSelect = $('select.super-attribute-select', $thicknessField); // once options are loaded, set value to N/A if custom sizing is selected $sizeSelect.on('configurableUpdated', function() { if (toValidate) { // custom sizing $('option:contains("N/A")', $thicknessSelect).prop('selected', true); $('option:contains("Custom")', $thicknessSelect).prop('selected', true); } }); } $sizeSelect.on('change', function() { var $sizeSelected = $('option:selected', this); if ($sizeSelected.text() !== 'Custom') { // standard sizing $calcPrice.hide(); $teakVariations.hide(); // Default hidden selections (if present) attrTest = false; var $routedEdgeFld = findProductOption('Roundover Edges'); attrTest = $routedEdgeFld.attr('name'); if ((typeof attrTest !== typeof undefined) && (attrTest !== false)) { $('#ddRoutedEdge').parent().parent().hide(); } var $radiusCornersFld = findProductOption('Radius Corners'); attrTest = $radiusCornersFld.attr('name'); if ((typeof attrTest !== typeof undefined) && (attrTest !== false)) { $('#ddRadiusCorners').parent().parent().hide(); } $defaultPrice.show(); $configFields.show(); toValidate = false; clearFields(); } else { // custom sizing $defaultPrice.hide(); $configFields.hide(); $calcPrice.show(); $teakVariations.show(); $('#ddRoutedEdge').parent().parent().show(); $('#ddRadiusCorners').parent().parent().show(); toValidate = true; $optionFields.find('select.product-custom-option').each(function() { $(this).trigger('change'); }); } }); // trigger change event once options are loaded $sizeSelect.one('configurableUpdated', function() { $(this).trigger('change'); }); } $('#ddRoutedEdge').on('change', function() { if ($('#ddRoutedEdge').val() != '0/16') $('#ddRoutedEdgeTip').show(); else $('#ddRoutedEdgeTip').hide(); checkThenCalculate(); }); $('#ddRadiusCorners').on('change', function() { if ($('#ddRadiusCorners').val() != '0/16') $('#ddRadiusCornersTip').show(); else $('#ddRadiusCornersTip').hide(); checkThenCalculate(); }); $('#ddCutoutRadiusCorners').on('change', function() { var selectedVal = $('#ddCutoutRadiusCorners').val(); var zeroCutoutLabel = ''; if ((pricingJson.ZeroCutoutRadiusLabel != undefined) && (pricingJson.ZeroCutoutRadiusLabel != '')) zeroCutoutLabel = pricingJson.ZeroCutoutRadiusLabel; $('.cutoutRadiusNotes').hide(); if (selectedVal == zeroCutoutLabel.replace(/\s/g,'')) $('#ZeroCutoutRadiusNote').show(); else $('#CutoutRadiusNote').show(); // Show the price note if ((zeroCutoutLabel != '') && (selectedVal != zeroCutoutLabel.replace(/\s/g,''))) $('#ddCutoutRadiusCornersTip').show(); else $('#ddCutoutRadiusCornersTip').hide(); //checkThenCalculate(); }); } else if (pricingType == 'HeightWidthMaterial') { lengthLabel = pricingJson.LengthLabel ? pricingJson.LengthLabel : "Length"; widthLabel = pricingJson.WidthLabel ? pricingJson.WidthLabel : "Width"; thicknessLabel = pricingJson.ThicknessLabel ? pricingJson.ThicknessLabel : "Thickness"; createHiddenField("ddMeasurementType", "Outside"); if (pricingJson.Base.length == 1) { createHiddenField("ddThickness", pricingJson.Base[0].SKU); } else { $teakVariations.append('

' + thicknessLabel + ':

'); for (var i = 0; i < pricingJson.Base.length; i++) { $('#ddThickness').append('

'); } } $teakVariations.append('

' + lengthLabel + ':

'); $('#ddLengthIn').append('

'); $teakVariations.append('

' + widthLabel + ':

'); $('#ddWidthIn').append('

'); hideProductOption('thickness'); hideProductOption('height'); hideProductOption('width'); var $optionFields = $('#product-options-wrapper', $form); var $configFields = $(".product-options-wrapper .field.configurable", $form); var $sizeLabel = $('.label:contains("Size")', $configFields); $sizeLabel = $sizeLabel.filter(function() { return $(this).text().trim() === 'Size'; }); if ($sizeLabel.length == 0) $teakVariations.show(); else { var $sizeField = $sizeLabel.parent('.field.configurable'); var $sizeSelect = $('select.super-attribute-select', $sizeField); // remove size field from config fields (size field should always be visible) $configFields = $configFields.not($sizeField); // move custom calculator fields after size field $teakVariations.insertAfter($sizeField); var $thicknessLabel = $('.label:contains("Thickness")', $configFields).first(); if ($thicknessLabel.length > 0) { var $thicknessField = $thicknessLabel.parent('.field.configurable'); var $thicknessSelect = $('select.super-attribute-select', $thicknessField); // once options are loaded, set value to N/A if custom sizing is selected $sizeSelect.on('configurableUpdated', function() { if (toValidate) { // custom sizing $('option:contains("N/A")', $thicknessSelect).prop('selected', true); $('option:contains("Custom")', $thicknessSelect).prop('selected', true); } }); } $sizeSelect.on('change', function() { var $sizeSelected = $('option:selected', this); if ($sizeSelected.text() !== 'Custom') { // standard sizing $calcPrice.hide(); $teakVariations.hide(); $defaultPrice.show(); $configFields.show(); toValidate = false; clearFields(); } else { // custom sizing $defaultPrice.hide(); $configFields.hide(); $calcPrice.show(); $teakVariations.show(); toValidate = true; $optionFields.find('select.product-custom-option').each(function() { $(this).trigger('change'); }); } }); // trigger change event once options are loaded $sizeSelect.one('configurableUpdated', function() { $(this).trigger('change'); }); } } else if (pricingType == 'Calculator') { createHiddenField("ddMeasurementType", "Outside"); $teakVariations.append('

Thickness:

'); for (var i = 0; i < pricingJson.Base.length; i++) { $('#ddThickness').append('

'); } $teakVariations.append('

Length:

'); $('#ddLengthIn').append('

'); $teakVariations.append('

Width:

'); $('#ddWidthIn').append('

'); var priceTxt = ''; var modifier = castToNum(isNaN(pricingJson.RoutedEdge) ? 0 : pricingJson.RoutedEdge); if (modifier > 0) { priceTxt = ' '; $teakVariations.append('

'); } priceTxt = ''; modifier = castToNum(isNaN(pricingJson.RadiusCorners) ? 0 : pricingJson.RadiusCorners); if (modifier > 0) { priceTxt = ' '; $teakVariations.append('

'); } hideProductOption('thickness'); hideProductOption('length'); hideProductOption('width'); hideProductOption('Roundover Edges'); hideProductOption('Radius Corners'); $('#ddRoutedEdge').on('change', function() { if ($('#ddRoutedEdge').val() != '0/16') $('#ddRoutedEdgeTip').show(); else $('#ddRoutedEdgeTip').hide(); }); $('#ddRadiusCorners').on('change', function() { if ($('#ddRadiusCorners').val() != '0/16') $('#ddRadiusCornersTip').show(); else $('#ddRadiusCornersTip').hide(); }); var $optionFields = $('#product-options-wrapper', $form); var $configFields = $(".product-options-wrapper .field.configurable", $form); var $sizeLabel = $('.label:contains("Size")', $configFields); $sizeLabel = $sizeLabel.filter(function() { return $(this).text().trim() === 'Size'; }); if ($sizeLabel.length == 0) { $teakVariations.show(); clearFields(); // This will trigger the change event on existing controls } else { var $sizeField = $sizeLabel.parent('.field.configurable'); var $sizeSelect = $('select.super-attribute-select', $sizeField); // remove size field from config fields (size field should always be visible) $configFields = $configFields.not($sizeField); // move custom caluclator fields after size field $teakVariations.insertAfter($sizeField); var $thicknessLabel = $('.label:contains("Thickness")', $configFields).first(); if ($thicknessLabel.length > 0) { var $thicknessField = $thicknessLabel.parent('.field.configurable'); var $thicknessSelect = $('select.super-attribute-select', $thicknessField); // once options are loaded, set value to N/A if custom sizing is selected $sizeSelect.on('configurableUpdated', function() { if (toValidate) { // custom sizing $('option:contains("N/A")', $thicknessSelect).prop('selected', true); $('option:contains("Custom")', $thicknessSelect).prop('selected', true); } }); } $sizeSelect.on('change', function() { var $sizeSelected = $('option:selected', this); if ($sizeSelected.text() !== 'Custom') { // standard sizing $calcPrice.hide(); $teakVariations.hide(); // Default hidden selections (if present) attrTest = false; var $routedEdgeFld = findProductOption('Roundover Edges'); attrTest = $routedEdgeFld.attr('name'); if ((typeof attrTest !== typeof undefined) && (attrTest !== false)) { $('#ddRoutedEdge').parent().parent().hide(); //$routedEdgeFld.val($routedEdgeFld.find('option:eq(1)').val()); //hideProductOption('Roundover Edges'); } var $radiusCornersFld = findProductOption('Radius Corners'); attrTest = $radiusCornersFld.attr('name'); if ((typeof attrTest !== typeof undefined) && (attrTest !== false)) { $('#ddRadiusCorners').parent().parent().hide(); //$radiusCornersFld.val($radiusCornersFld.find('option:eq(1)').val()); //hideProductOption('Radius Corners'); } $defaultPrice.show(); $configFields.show(); toValidate = false; clearFields(); } else { // custom sizing $defaultPrice.hide(); $configFields.hide(); $calcPrice.show(); $teakVariations.show(); $('#ddRoutedEdge').parent().parent().show(); $('#ddRadiusCorners').parent().parent().show(); //showProductOption('Roundover Edges'); //showProductOption('Radius Corners'); toValidate = true; $optionFields.find('select.product-custom-option').each(function() { $(this).trigger('change'); }); } }); // trigger change event once options are loaded $sizeSelect.one('configurableUpdated', function() { $(this).trigger('change'); }); } $('#ddRoutedEdge').on('change', function() { checkThenCalculate(); }); $('#ddRadiusCorners').on('change', function() { checkThenCalculate(); }); } else if (pricingType == '3DMaterial') { lengthLabel = pricingJson.LengthLabel ? pricingJson.LengthLabel : "Length"; widthLabel = pricingJson.WidthLabel ? pricingJson.WidthLabel : "Width"; depthLabel = pricingJson.DepthLabel ? pricingJson.DepthLabel : "Depth"; var cutoutDimWidth = 0.0; var cutoutDimLength = 0.0; if (pricingJson.CutoutDim.indexOf(',') == -1) { cutoutDimWidth = castToNum(pricingJson.CutoutDim); cutoutDimLength = castToNum(pricingJson.CutoutDim); } else { var pair = pricingJson.CutoutDim.split(","); cutoutDimWidth = castToNum(pair[0]); cutoutDimLength = castToNum(pair[1]); } var outsideDim = castToNum(pricingJson.OutsideDim); if ((outsideDim + cutoutDimWidth + cutoutDimLength) == 0) { $teakVariations.append('

The measurements you provide below represent the size of your:

'); } else { $teakVariations.append('

The measurements you provide below represent the size of your?

'); } $teakVariations.append('

' + lengthLabel + ':

'); $('#ddLengthIn').append('

'); $teakVariations.append('

' + widthLabel + ':

'); $('#ddWidthIn').append('

'); $teakVariations.append('

' + depthLabel + ':

'); $('#ddDepthIn').append('

');if (pricingJson.IncludeDividers == 'Ask') {var dividerLabel = pricingJson.DividersLabel ? pricingJson.DividersLabel : "Dividers";var note = pricingJson.DividersNote ?? '';$teakVariations.append(note + '

' + dividerLabel + ':

');}else { createHiddenField("ddIncludeDividers", pricingJson.IncludeDividers); } hideProductOption('measurement type'); hideProductOption('height'); hideProductOption('width');hideProductOption('depth');hideProductOption('dividers'); $teakVariations.show(); $('#txtLengthIn').on('keyup', function() { CutoutDimensions(); }); $('#ddLengthIn').on('change', function() { CutoutDimensions(); }); $('#ddMeasurementType').on('change', function() { CutoutDimensions(); }); $('#txtWidthIn').on('keyup', function() { CutoutDimensions(); }); $('#ddWidthIn').on('change', function() { CutoutDimensions(); });$('#txtDepthIn').on('keyup', function() { CutoutDimensions(); }); $('#ddDepthIn').on('change', function() { CutoutDimensions(); });$('#ddIncludeDividers').on('change', function() { checkThenCalculate(); }); } // START UP // --------------------------------- prefill(pricingType); //checkThenCalculate(); // BIND EVENTS // --------------------------------- $('#ddThickness').on('change', function() { checkThenCalculate(); }); if (!($('#ddMeasurementType').is('input'))) { // Only need to have this event if its a selection $('#ddMeasurementType').on('change', function() { console.log('Changing measurement type to: ' + $(this).val()); checkThenCalculate(); }); } $('#txtLengthIn').on('focusout', function() { checkThenCalculate(); }); $('#ddLengthIn').on('change', function() { checkThenCalculate(); }); $('#txtWidthIn').on('focusout', function() { checkThenCalculate(); }); $('#ddWidthIn').on('change', function() { checkThenCalculate(); }); $('#txtDepthIn').on('focusout', function() { checkThenCalculate(); }); $('#ddDepthIn').on('change', function() { checkThenCalculate(); }); $('#txtCutoutLengthIn').on('focusout', function() { checkThenCalculate(); }); $('#ddCutoutLengthIn').on('change', function() { checkThenCalculate(); }); $('#txtCutoutWidthIn').on('focusout', function() { checkThenCalculate(); }); $('#ddCutoutWidthIn').on('change', function() { checkThenCalculate(); }); $(".variantDropDown").off('change'); $(".variantSelection input").off('change'); $('#product-addtocart-button').on('click', function(e) { if (toValidate && !calculateAndBuildUrl()) { e.preventDefault(); return false; } }); $('#product-options-wrapper').find("select.product-custom-option").on('change', function(e) { checkThenCalculate(); }); } if (typeof pricingType !== "undefined" && typeof pricingJson !== "undefined") { BOProductDetailsCalculator(pricingType, pricingJson); } }); Copyright © 2010-2024 Boat Outfitters. All rights reserved.

Sea Hunt Dealer Display (2024)

References

Top Articles
Latest Posts
Article information

Author: Wyatt Volkman LLD

Last Updated:

Views: 6034

Rating: 4.6 / 5 (66 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Wyatt Volkman LLD

Birthday: 1992-02-16

Address: Suite 851 78549 Lubowitz Well, Wardside, TX 98080-8615

Phone: +67618977178100

Job: Manufacturing Director

Hobby: Running, Mountaineering, Inline skating, Writing, Baton twirling, Computer programming, Stone skipping

Introduction: My name is Wyatt Volkman LLD, I am a handsome, rich, comfortable, lively, zealous, graceful, gifted person who loves writing and wants to share my knowledge and understanding with you.