From 0914887b4f050fbc58b3531779aaea244134a52a Mon Sep 17 00:00:00 2001 From: JC Brand Date: Sat, 11 May 2013 16:58:08 +0200 Subject: [PATCH] More work towards letting users configure chatrooms Add a configure button on chatrooms when the user is the chatroom owner. --- converse.css | 19 ++++++++++++++----- converse.js | 34 +++++++++++++++++----------------- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/converse.css b/converse.css index df5d76e47..ed63dca48 100644 --- a/converse.css +++ b/converse.css @@ -324,18 +324,19 @@ form.search-xmpp-contact input { padding: 3px 0 0 0; } -.close-chatbox-button { - cursor: pointer; - float: right; +a.configure-chatroom-button, +a.close-chatbox-button { margin-top: 0.2em; margin-right: 0.5em; + cursor: pointer; + float: right; + width: 12px; -moz-box-shadow:inset 0 1px 0 0 #ffffff; -webkit-box-shadow:inset 0 1px 0 0 #ffffff; box-shadow:inset 0 1px 0 0 #ffffff; background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #ffffff), color-stop(1, #f6f6f6) ); background:-moz-linear-gradient( center top, #ffffff 5%, #f6f6f6 100% ); filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#f6f6f6'); - background-color:#ffffff; -moz-border-radius:6px; -webkit-border-radius:6px; border-radius:6px; @@ -345,11 +346,19 @@ form.search-xmpp-contact input { font-family:arial; font-size:12px; font-weight:bold; - padding:0 4px; text-decoration:none; text-shadow:1px 1px 0 #ffffff; } +a.configure-chatroom-button { + padding:0 4px; + background: #ffffff url('images/preferences-system.png') no-repeat center center; +} + +.close-chatbox-button { + padding: 0 2px 0 6px; +} + .close-chatbox-button:hover { background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #f6f6f6), color-stop(1, #ffffff) ); background:-moz-linear-gradient( center top, #f6f6f6 5%, #ffffff 100% ); diff --git a/converse.js b/converse.js index e95536e8b..cfc3992ab 100644 --- a/converse.js +++ b/converse.js @@ -992,6 +992,7 @@ className: 'chatroom', events: { 'click a.close-chatbox-button': 'closeChat', + 'click a.configure-chatroom-button': 'configureChatRoom', 'keypress textarea.chat-textarea': 'keyPressed' }, info_template: _.template('
{{message}}
'), @@ -1039,6 +1040,7 @@ template: _.template( '
' + 'X' + + '' + '
{{ name }}
' + '

' + '

' + @@ -1097,35 +1099,33 @@ } }, + configureChatRoom: function (ev) { + ev.preventDefault(); + converse.connection.muc.configure( + this.model.get('jid'), + $.proxy(this.showRoomConfigOptions, this) + ); + }, + onChatRoomPresence: function (presence, room) { var nick = room.nick, $presence = $(presence), - from = $presence.attr('from'), item; + from = $presence.attr('from'), $item; if ($presence.attr('type') !== 'error') { if ($presence.find("status[code='201']").length) { // This is a new chatroom. We create an instant // chatroom, and let the user manually set any // configuration setting. (2nd part is TODO) converse.connection.muc.createInstantRoom(room.name); - /* TODO: Find a place for this code (it configures a - * newly created chatroom). - * ------------------------------------------------- - $item = $presence.find('item'); - if ($item.length) { - if ($item.attr('affiliation') == 'owner') { - if (false) { - } else { - converse.connection.muc.configure( - room.name, - $.proxy(this.showRoomConfigOptions, this) - ); - } - } - } - */ } // check for status 110 to see if it's our own presence if ($presence.find("status[code='110']").length) { + $item = $presence.find('item'); + if ($item.length) { + if ($item.attr('affiliation') == 'owner') { + this.$el.find('a.configure-chatroom-button').show(); + } + } if ($presence.find("status[code='210']").length) { // check if server changed our nick this.model.set({'nick': Strophe.getResourceFromJid(from)});