From 5f0a90d00e1298d265fcea05d17010d60c30e581 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Sun, 12 May 2013 15:17:58 +0200 Subject: [PATCH] Make sure that checkboxes are ticked in chat config --- converse.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/converse.js b/converse.js index 8b031c52a..9b5444f66 100644 --- a/converse.js +++ b/converse.js @@ -1085,8 +1085,9 @@ form_input_template: _.template(''), select_option_template: _.template(''), form_select_template: _.template(''), + form_checkbox_template: _.template(''), - showRoomConfigOptions: function (stanza) { + showRoomConfiguration: function (stanza) { var $form= this.$el.find('form.configure-chatroom'), $stanza = $(stanza), $fields = $stanza.find('field'), @@ -1120,6 +1121,13 @@ label: $field.attr('label'), options: options.join('') })); + } else if ($field.attr('type') == 'boolean') { + $form.append(this.form_checkbox_template({ + name: $field.attr('var'), + type: input_types[$field.attr('type')], + label: $field.attr('label') || '', + checked: $field.find('value').text() && 'checked="1"' || '' + })); } else { $form.append(this.form_input_template({ name: $field.attr('var'), @@ -1166,6 +1174,7 @@ }); this.$el.find('div.configure-chatroom-container').hide( function () { + $(this).remove(); that.$el.find('.chat-area').show(); that.$el.find('.participants').show(); }); @@ -1184,6 +1193,7 @@ var that = this; this.$el.find('div.configure-chatroom-container').hide( function () { + $(this).remove(); that.$el.find('.chat-area').show(); that.$el.find('.participants').show(); }); @@ -1191,6 +1201,9 @@ configureChatRoom: function (ev) { ev.preventDefault(); + if (this.$el.find('div.configure-chatroom-container').length) { + return; + } this.$el.find('.chat-area').hide(); this.$el.find('.participants').hide(); this.$el.find('.chat-body').append( @@ -1200,7 +1213,7 @@ '')); converse.connection.muc.configure( this.model.get('jid'), - $.proxy(this.showRoomConfigOptions, this) + $.proxy(this.showRoomConfiguration, this) ); },