From cd34ee6dd7ebacb5569397b9d54a129dfbc44996 Mon Sep 17 00:00:00 2001 From: Ashesh Vashi Date: Thu, 17 Dec 2015 18:41:36 +0530 Subject: [PATCH] Switch Control was not honouring the user's options for bootstrap switch --- web/pgadmin/static/js/backform.pgadmin.js | 29 ++++++++++------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js index 6229ba649..23dec7e1e 100644 --- a/web/pgadmin/static/js/backform.pgadmin.js +++ b/web/pgadmin/static/js/backform.pgadmin.js @@ -203,13 +203,14 @@ var SwitchControl = Backform.SwitchControl = Backform.InputControl.extend({ defaults: { label: "", - options: {}, - extraClasses: [], - onText: 'True', - offText: 'False', - onColor: 'success', - offColor: 'default', - size: 'small' + options: { + onText: 'True', + offText: 'False', + onColor: 'success', + offColor: 'default', + size: 'small' + }, + extraClasses: [] }, template: _.template([ '', @@ -229,7 +230,7 @@ }, events: {'switchChange.bootstrapSwitch': 'onChange'}, render: function() { - var field = _.defaults(this.field.toJSON(), this.defaults), + var field = _.defaults(this.field.toJSON(), this.defaults, {options: $.fn.bootstrapSwitch.defaults}), attributes = this.model.toJSON(), attrArr = field.name.split('.'), name = attrArr.shift(), @@ -240,14 +241,10 @@ this.$input = this.$el.find("input[type=checkbox]").first(); //Check & set additional properties - this.$input.bootstrapSwitch({ - 'onText': field.onText, - 'offText': field.offText, - 'onColor': field.onColor, - 'offColor': field.offColor, - 'size': field.size, - 'state': rawValue - }); + this.$input.bootstrapSwitch( + _.extend(field.options, {'state': rawValue}) + ); + return this; } });