]> git.parisson.com Git - teleforma.git/commitdiff
dev
authorYoan Le Clanche <yoan@ellington.pilotsystems.net>
Wed, 19 Sep 2018 13:04:04 +0000 (15:04 +0200)
committerYoan Le Clanche <yoan@ellington.pilotsystems.net>
Wed, 19 Sep 2018 13:04:04 +0000 (15:04 +0200)
teleforma/templates/teleforma/appointments.html

index 309247c33d9027c3f7e44c3fb2f93df14efb94dc..811ece1313f9c5aa6f07608da1a1b1f8f1d14b99 100644 (file)
         var currentForm;
 
         function updateDisplayedDays() {
+            // show appointment table according to selected day
             $('section.booking_day').hide();
             $('section.booking_day .day').hide();
             var selectedDay = $('[name="day-to-show"]').val();
             $('section.booking_day[data-day="' + selectedDay + '"]').show();
+            updateNextPreviousButtons();
+        }
+
+        function updateNextPreviousButtons(){
+            // show or hide next and previous buttons according to selected day
+            $('[name="day-to-show"]').each(function(){
+                var selected = $(this).val();
+                var $selectedOption = $(this).find('option[value="' + selected + '"]');
+
+                // show next/previous buttons
+                $(this).next().show();
+                $(this).prev().show();
+
+                if(!$selectedOption.prev().size())
+                    $(this).prev().hide();
+                if(!$selectedOption.next().size())
+                    $(this).next().hide();
+            })
         }
 
         $(document).ready(function () {
@@ -77,6 +96,7 @@
             $('[name="day-to-show"]').bind('change', updateDisplayedDays);
             updateDisplayedDays();
 
+            // next / previous button
             $('.previous_day').click(function () {
                 var $select = $(this).parent().find('select');
                 if ($select.find('option:selected').prev().size()) {