Changeset:
        e39eb47cf7a4
        
https://sourceforge.net/p/mrbs/hg-code/ci/e39eb47cf7a408c04fb277ed40884e660244f759
Author:
        Campbell Morrison <[email protected]>
Date:
        Tue Apr 11 18:45:50 2017 +0100
Log message:

Made sure there's always at least one period.

diffstat:

 web/js/edit_area_room.js.php |  25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)

diffs (55 lines):

diff -r c32bad59e4ba -r e39eb47cf7a4 web/js/edit_area_room.js.php
--- a/web/js/edit_area_room.js.php      Tue Apr 11 18:26:40 2017 +0100
+++ b/web/js/edit_area_room.js.php      Tue Apr 11 18:45:50 2017 +0100
@@ -217,6 +217,22 @@
                  .css('visibility', 'visible');
 }
 
+
+<?php
+// Check to see if there's only one period name left and, if so,
+// disable the delete button, to make sure there's always at least one
+// period.  (We could in theory have no period names, but it doesn't
+// have a practical use.  Besides, always having at least one makes the
+// code a little simpler because there will always be something to clone.
+?>
+function checkForLastPeriodName()
+{
+  if ($('.period_name').length === 1)
+  {
+    $('.delete_period').hide();
+  }
+}
+
 <?php
 
 
@@ -241,10 +257,12 @@
       toggleMode('fast');
     });
   toggleMode(0);
+  checkForLastPeriodName();
 
   <?php
   // When the Add Period button is clicked, duplicate the last period
-  // name input field, clearing its contents.
+  // name input field, clearing its contents.  Re-enable all the delete
+  // icons because there must be more than one having added one.
   ?>
   $('#add_period').click(function() {
       var lastPeriodName = $('#period_settings .period_name').last(),
@@ -252,10 +270,13 @@
           
       clone.find('input').val('');
       clone.insertAfter(lastPeriodName);
+      $('.delete_period').show();
     });
-    
+  
+  <?php // Delete a period name input field ?>  
   $('.delete_period').click(function() {
       $(this).parent().remove();
+      checkForLastPeriodName();
     });
     
   <?php

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to