repo: janusweb
action: commit
revision: 
path_from: 
revision_from: 10c51877bf2cc0b25bdd5c2062ef9b00d7ff39e4:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit 10c51877bf2cc0b25bdd5c2062ef9b00d7ff39e4
Author: James Baicoianu 
Date:   Sun Jan 22 00:32:46 2017 -0800

    Hide chat by default

diff --git a/scripts/chat.js b/scripts/chat.js
index c73b5b907fbe6eb12e339c6136fa958a587bc9ba..
index ..19979b9d19741b26b5ab6f94d5cf4eb5abe2cf99 100644
--- a/scripts/chat.js
+++ b/scripts/chat.js
@@ -8,11 +8,16 @@ elation.require(['ui.window', 'ui.list', 'ui.input', 'elation.collection'], func
       this.args.bottom = true;
       this.args.resizable = false;
       this.args.controls = true;
-      this.player = this.args.player;
       this.client = this.args.client;
+      this.player = this.args.player || this.client.player;
+      this.network = this.args.network;

       elation.janusweb.chat.extendclass.init.call(this);

+      this.chatbutton = elation.ui.button({classname: 'janusweb_chat', label: 'Chat'});
+      elation.events.add(this.chatbutton, 'ui_button_click', elation.bind(this, this.toggleChat));
+      this.client.buttons.add('chat', this.chatbutton);
+
       this.messagecollection = elation.collection.indexed({index: 'timestamp'});
       var panel = elation.ui.panel_vertical({classname: 'janusweb_chat_panel'});
       this.messagelist = elation.ui.list({append: panel, classname: 'janusweb_chat_messages', itemcollection: this.messagecollection, attrs: {itemtemplate: 'janusweb.chat.message'}});
@@ -28,6 +33,7 @@ elation.require(['ui.window', 'ui.list', 'ui.input', 'elation.collection'], func
       });

       this.setcontent(panel);
+      this.hide();
     }
     this.addmessage = function(msg) {
       if (!msg.timestamp) msg.timestamp = window.performance.now();
@@ -42,7 +48,7 @@ elation.require(['ui.window', 'ui.list', 'ui.input', 'elation.collection'], func
       this.refresh();
     }
     this.sendmessage = function() {
-      this.client.send({'method': 'chat', data: this.input.value});
+      this.network.send({'method': 'chat', data: this.input.value});
       var msg = {userId: 'me', message: this.input.value, self: true};
       this.addmessage(msg);
       elation.events.fire({element: this, type: 'janusweb_chat_send', data: msg});
@@ -61,5 +67,14 @@ elation.require(['ui.window', 'ui.list', 'ui.input', 'elation.collection'], func
         this.player.enable();
       }
     }
+    this.toggleChat = function() {
+      if (this.hidden) {
+        this.show();
+        this.refresh();
+      } else {
+        this.hide();
+        this.refresh();
+      }
+    }
   }, elation.ui.window);
 });

-----END OF PAGE-----