You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@steve.apache.org by ru...@apache.org on 2016/03/07 22:06:02 UTC

svn commit: r1733980 - /steve/trunk/whatif.rb

Author: rubys
Date: Mon Mar  7 21:06:02 2016
New Revision: 1733980

URL: http://svn.apache.org/viewvc?rev=1733980&view=rev
Log:
make use of input type=number

Modified:
    steve/trunk/whatif.rb

Modified: steve/trunk/whatif.rb
URL: http://svn.apache.org/viewvc/steve/trunk/whatif.rb?rev=1733980&r1=1733979&r2=1733980&view=diff
==============================================================================
--- steve/trunk/whatif.rb (original)
+++ steve/trunk/whatif.rb Mon Mar  7 21:06:02 2016
@@ -100,7 +100,7 @@ _html do
        .not-elected {background: #F00}
        .none {background: yellow}
     }
-    _script src: 'jquery.min.js'
+    _script src: 'assets/jquery.min.js'
   end
 
   _body? do
@@ -134,7 +134,8 @@ _html do
 
       _label_ for: 'seats' do
         _span 'seats:'
-        _input name: 'seats', id: 'seats', value: @seats, size: 2
+        _input name: 'seats', id: 'seats', value: @seats, size: 2,
+          type: 'number', min: 1, max: nominees.length-1
       end
 
       _input type: 'submit', value: 'submit', name: 'submit'
@@ -170,17 +171,8 @@ _html do
       // If JS is enabled, we don't need a submit button
       $('input[type=submit]').hide();
 
-      // Add up and down arrows and refresh on change
-      var seats = $('#seats');
-      seats.keyup(function() {return refresh()});
-      seats.before($('<button>&#x21D3;</button>').click(function() {
-        if (seats.val()>1) {seats.val(seats.val()-1);}
-        return refresh();
-      }));
-      seats.after($('<button>&#x21D1;</button>').click(function() {
-        if (seats.val()<1) {seats.val(seats.val()-0+1);}
-        return refresh();
-      }));
+      // Refresh on change in number of seats
+      $('#seats').on('input', function() {return refresh()});
     }
   end
 end