From 3c42f58f7955f1d9cf5a37d96e3b1ef760810114 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Tue, 15 Jul 2014 16:30:29 -0400 Subject: [PATCH] update order form Bring in the script for pre selecting the golfers From old site. --- libjs/golfersSelect.js | 83 ++++++++++++++++++++++++++++++++++++++++++ priceQuoteForm.inc | 4 ++ 2 files changed, 87 insertions(+) create mode 100644 libjs/golfersSelect.js diff --git a/libjs/golfersSelect.js b/libjs/golfersSelect.js new file mode 100644 index 0000000..c1d7e7f --- /dev/null +++ b/libjs/golfersSelect.js @@ -0,0 +1,83 @@ +/* ========================= */ +// This script is for the No. Golfers select bug on +// the 3rd page of the price quote form. +// basically pear isn't setting defaults to the elements +// in the element grid if its within a controller page (multipage form controller) +// What this script does is check if all the select boxes have the same index +// ie. (they're all the same) If they are, then it sets their default state to +// the highest # of golfers available. If they are not all the same +// then that means the user has submitted this form once and changed the # +// of golfers on one day and has since returned to this form to correct something +// or is passing through to get to a previous or later form page. + +// Gaslight Media (c) 2008 +// 04/21/2008 +// Author: Jamie Kahgee +/* ========================= */ +var golfersSelect = +{ + selects: null, + length: null, + target: null, + + init: function() + { + if ($('#viewCourses')) + { + golfersSelect.selects = $('table.elementGrid select'); + golfersSelect.length = golfersSelect.selects.length; + golfersSelect.target = golfersSelect.selects[0].options.length - 1; + + // Only make the elements all the same if the user + // hasn't passed through here before. + if (golfersSelect.allTheSame()) + { + golfersSelect.makeTheSame(); + } + } + }, + + allTheSame: function() + { + var initIndex = golfersSelect.selects[0].selectedIndex; + var allTheSame = true; + for (var i = 0, j = 0; i < golfersSelect.length; ++i, ++j) + { + if (j == 3) + { + j = 0; + } + + if (j == 0) + { + if (golfersSelect.selects[i].selectedIndex != initIndex) + { + allTheSame = false; + } + } + } + + return allTheSame; + }, + + makeTheSame: function() + { + for (var i = 0, j = 0; i < golfersSelect.length; ++i, ++j) + { + if (j == 3) + { + j = 0; + } + + if (j == 0) + { + golfersSelect.selects[i].selectedIndex = golfersSelect.target; + } + } + } +}; + +$(function(){ + golfersSelect.init(); +}); +//Event.observe(window, 'load', golfersSelect.init); diff --git a/priceQuoteForm.inc b/priceQuoteForm.inc index 8244853..13590e2 100644 --- a/priceQuoteForm.inc +++ b/priceQuoteForm.inc @@ -223,6 +223,10 @@ class PageThird extends PageBase { function buildForm() { +// $GLOBALS['bottomScripts'][] +// = MEDIA_BASE_URL . 'libjs/prototype.js'; + $GLOBALS['bottomScripts'][] + = MEDIA_BASE_URL . 'libjs/golfersSelect.js'; $this->_formBuilt = true; $arrival = $this->controller->exportValue('page1', 'arrival'); -- 2.17.1