Browse Source

Fix 360° checkbox behaviour

Now, this checkbox is checked if and only if all orientation checkboxes
are checked.  Note that this is purely cosmetic.
Baptiste Jonglez 10 years ago
parent
commit
7ee03c12ae
2 changed files with 9 additions and 1 deletions
  1. 8 0
      assets/form.js
  2. 1 1
      views/wifi-form.tpl

+ 8 - 0
assets/form.js

@@ -93,5 +93,13 @@ $( document ).ready(function() {
     $('#orientation-all').change(function(e){
         $('input[name="orientation"]').prop('checked', $(e.target).is(':checked') );
     });
+    $('.orientation').change(function(e){
+        if (! $(e.target).is(':checked')) {
+            $('input[name="orientation-all"]').prop('checked', false);
+        }
+        if ($('.orientation').filter(':not(:checked)').length == 0) {
+            $('input[name="orientation-all"]').prop('checked', true);
+        }
+    });
 
 });

+ 1 - 1
views/wifi-form.tpl

@@ -155,7 +155,7 @@ pourraient-être intéressantes.
     <br>
 %for val, label in orientations:
     <label class="checkbox-inline">
-      <input type="checkbox" name="orientation" value="{{val}}"
+      <input type="checkbox" class="orientation" name="orientation" value="{{val}}"
              {{'checked' if val in data.getall('orientation') else ''}}/>
       {{label}}
     </label>