Make sure that checkboxes are ticked in chat config

This commit is contained in:
JC Brand 2013-05-12 15:17:58 +02:00
parent 0e1386cb60
commit 5f0a90d00e

View File

@ -1085,8 +1085,9 @@
form_input_template: _.template('<label>{{label}}<input name="{{name}}" type="{{type}}" value="{{value}}"></label>'), form_input_template: _.template('<label>{{label}}<input name="{{name}}" type="{{type}}" value="{{value}}"></label>'),
select_option_template: _.template('<option value="{{value}}">{{label}}</option>'), select_option_template: _.template('<option value="{{value}}">{{label}}</option>'),
form_select_template: _.template('<label>{{label}}<select name="{{name}}">{{options}}</select></label>'), form_select_template: _.template('<label>{{label}}<select name="{{name}}">{{options}}</select></label>'),
form_checkbox_template: _.template('<label>{{label}}<input name="{{name}}" type="{{type}}" {{checked}}"></label>'),
showRoomConfigOptions: function (stanza) { showRoomConfiguration: function (stanza) {
var $form= this.$el.find('form.configure-chatroom'), var $form= this.$el.find('form.configure-chatroom'),
$stanza = $(stanza), $stanza = $(stanza),
$fields = $stanza.find('field'), $fields = $stanza.find('field'),
@ -1120,6 +1121,13 @@
label: $field.attr('label'), label: $field.attr('label'),
options: options.join('') 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 { } else {
$form.append(this.form_input_template({ $form.append(this.form_input_template({
name: $field.attr('var'), name: $field.attr('var'),
@ -1166,6 +1174,7 @@
}); });
this.$el.find('div.configure-chatroom-container').hide( this.$el.find('div.configure-chatroom-container').hide(
function () { function () {
$(this).remove();
that.$el.find('.chat-area').show(); that.$el.find('.chat-area').show();
that.$el.find('.participants').show(); that.$el.find('.participants').show();
}); });
@ -1184,6 +1193,7 @@
var that = this; var that = this;
this.$el.find('div.configure-chatroom-container').hide( this.$el.find('div.configure-chatroom-container').hide(
function () { function () {
$(this).remove();
that.$el.find('.chat-area').show(); that.$el.find('.chat-area').show();
that.$el.find('.participants').show(); that.$el.find('.participants').show();
}); });
@ -1191,6 +1201,9 @@
configureChatRoom: function (ev) { configureChatRoom: function (ev) {
ev.preventDefault(); ev.preventDefault();
if (this.$el.find('div.configure-chatroom-container').length) {
return;
}
this.$el.find('.chat-area').hide(); this.$el.find('.chat-area').hide();
this.$el.find('.participants').hide(); this.$el.find('.participants').hide();
this.$el.find('.chat-body').append( this.$el.find('.chat-body').append(
@ -1200,7 +1213,7 @@
'</div>')); '</div>'));
converse.connection.muc.configure( converse.connection.muc.configure(
this.model.get('jid'), this.model.get('jid'),
$.proxy(this.showRoomConfigOptions, this) $.proxy(this.showRoomConfiguration, this)
); );
}, },