update order form
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 15 Jul 2014 20:30:29 +0000 (16:30 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 15 Jul 2014 20:30:29 +0000 (16:30 -0400)
Bring in the script for pre selecting the golfers
From old site.

libjs/golfersSelect.js [new file with mode: 0644]
priceQuoteForm.inc

diff --git a/libjs/golfersSelect.js b/libjs/golfersSelect.js
new file mode 100644 (file)
index 0000000..c1d7e7f
--- /dev/null
@@ -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 <jamie.kahgee@gmail.com>
+/*     =========================       */
+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);
index 8244853..13590e2 100644 (file)
@@ -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');