浏览代码

Disallow sending empty messages

Thomas Dy 10 年之前
父节点
当前提交
df856fbc60
共有 3 个文件被更改,包括 3 次插入4 次删除
  1. 1 1
      public/javascripts/main.js
  2. 1 1
      public/partials/chatRoom.html
  3. 1 2
      public/stylesheets/main.css

+ 1 - 1
public/javascripts/main.js

@@ -41,7 +41,7 @@ function ChatCtrl($scope, Chat, Connection) {
   $scope.chat = Chat;
 
   $scope.onType = function(event) {
-    if(event.keyCode == 13) {
+    if($scope.text != '' && event.keyCode == 13) {
       Chat.send($scope.text);
       $scope.text = '';
       event.originalEvent.preventDefault();

+ 1 - 1
public/partials/chatRoom.html

@@ -21,7 +21,7 @@
           <p>{{message.message}}</p>
         </div>
       </div>
-      <textarea ng-model="text" id="talk" ng-keypress="onType($event)"></textarea>
+      <input type="text" ng-model="text" id="talk" ng-keypress="onType($event)">
     </div>
     <div class="span4" ng-controller="GameCtrl">
       <button class="btn" ng-show="game.pendingRound" ng-click="game.startRound()">Start</button>

+ 1 - 2
public/stylesheets/main.css

@@ -68,7 +68,7 @@ body {
 
 #messages {
     position: absolute;
-    bottom: 60px;
+    bottom: 40px;
 }
 
 #talk {
@@ -77,7 +77,6 @@ body {
     left: 0;
     right: 0;
     width: auto;
-    height: 40px
 }
 
 .message {