Quellcode durchsuchen

Streamline contributing a bit

Thomas Dy vor 11 Jahren
Ursprung
Commit
1df1f97979
2 geänderte Dateien mit 13 neuen und 7 gelöschten Zeilen
  1. 6 0
      public/javascripts/main.js
  2. 7 7
      public/partials/contribute.html

+ 6 - 0
public/javascripts/main.js

@@ -45,6 +45,8 @@ function GameCtrl($scope, Taboo) {
 }
 
 function ContributeCtrl($scope, $http) {
+  $scope.submitting = false;
+
   function init() {
     $scope.card = {
       word: '',
@@ -53,10 +55,14 @@ function ContributeCtrl($scope, $http) {
   }
 
   $scope.submit = function() {
+    if($scope.submitting) return;
+    $scope.submitting = true;
     $http.post(jsRoutes.controllers.Cards.add().url, $scope.card)
       .then(function() {
+        $scope.submitting = false;
         alert("Thank you for your contribution!");
         init();
+        $('#inputWord').focus();
       });
   }
 

+ 7 - 7
public/partials/contribute.html

@@ -6,19 +6,19 @@
     <div class="span12" id="main">
       <p>Help make the game! Contribute words and make the game better.</p>
       <form ng-submit="submit()">
-        <input type="text" ng-model="card.word" id="inputWord" placeholder="Word">
+        <input type="text" ng-model="card.word" id="inputWord" placeholder="Word" required>
         <br>
-        <input type="text" ng-model="card.taboos[0]" placeholder="Taboo Word">
+        <input type="text" ng-model="card.taboos[0]" placeholder="Taboo Word" required>
         <br>
-        <input type="text" ng-model="card.taboos[1]" placeholder="Taboo Word">
+        <input type="text" ng-model="card.taboos[1]" placeholder="Taboo Word" required>
         <br>
-        <input type="text" ng-model="card.taboos[2]" placeholder="Taboo Word">
+        <input type="text" ng-model="card.taboos[2]" placeholder="Taboo Word" required>
         <br>
-        <input type="text" ng-model="card.taboos[3]" placeholder="Taboo Word">
+        <input type="text" ng-model="card.taboos[3]" placeholder="Taboo Word" required>
         <br>
-        <input type="text" ng-model="card.taboos[4]" placeholder="Taboo Word">
+        <input type="text" ng-model="card.taboos[4]" placeholder="Taboo Word" required>
         <hr>
-        <input class="btn btn-primary" type="submit" value="Submit">
+        <input ng-disabled="submitting" class="btn btn-primary" type="submit" value="{{submitting ? 'Submitting...' : 'Submit'}}">
       </form>
     </div>
   </div>