commit/galaxy-central: guerler: Ui: Add packed script, fix attributes
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/05d002ec72e1/ Changeset: 05d002ec72e1 User: guerler Date: 2014-09-16 08:42:09 Summary: Ui: Add packed script, fix attributes Affected #: 2 files diff -r 673228acc8abfeb724c3e5306ff5b2da24d70858 -r 05d002ec72e1c99317d32d976b4aae6450227de4 static/scripts/mvc/ui/ui-options.js --- a/static/scripts/mvc/ui/ui-options.js +++ b/static/scripts/mvc/ui/ui-options.js @@ -3,22 +3,17 @@ /** base class for options based ui elements **/ var OptionsBase = Backbone.View.extend({ - // settings - settings : { - multiple : false - }, - - // options - optionsDefault: { - value : [], - visible : true, - data : [], - id : Utils.uuid(), - empty : 'No data available' - }, - // initialize initialize: function(options) { + // options + this.optionsDefault = { + value : [], + visible : true, + data : [], + id : Utils.uuid(), + empty : 'No data available' + }; + // configure options this.options = Utils.merge(options, this.optionsDefault); @@ -123,7 +118,7 @@ } // return multiple or single value - if (this.settings.multiple) { + if (this.options.multiple) { var values = []; selected.each(function() { values.push($(this).val()); @@ -145,7 +140,7 @@ Checkbox.View = OptionsBase.extend({ // initialize initialize: function(options) { - this.settings.multiple = true; + options.multiple = true; OptionsBase.prototype.initialize.call(this, options); }, @@ -196,8 +191,9 @@ value: function (new_val) { // set new value if (new_val !== undefined) { + this.$el.find('input').prop('checked', false); this.$el.find('label').removeClass('active'); - this.$el.find('[value="' + new_val + '"]').closest('label').addClass('active'); + this.$el.find('[value="' + new_val + '"]').prop('checked', true).closest('label').addClass('active'); } // get and return value @@ -206,7 +202,7 @@ // template for options _templateOption: function(pair) { - return '<label class="btn btn-default">' + + return '<label class="ui-option btn btn-default">' + '<input type="radio" name="' + this.options.id + '" value="' + pair.value + '">' + pair.label + '</label>'; }, diff -r 673228acc8abfeb724c3e5306ff5b2da24d70858 -r 05d002ec72e1c99317d32d976b4aae6450227de4 static/scripts/packed/mvc/ui/ui-options.js --- /dev/null +++ b/static/scripts/packed/mvc/ui/ui-options.js @@ -0,0 +1,1 @@ +define(["utils/utils"],function(b){var a=Backbone.View.extend({initialize:function(f){this.optionsDefault={value:[],visible:true,data:[],id:b.uuid(),empty:"No data available"};this.options=b.merge(f,this.optionsDefault);this.setElement(this._template(this.options));if(!this.options.visible){this.$el.hide()}this.update(this.options.data);if(this.options.value){this.value(this.options.value)}var e=this;this.on("change",function(){e._change()})},update:function(f){var h=this._getValue();this.$el.find(".ui-option").remove();for(var g in f){this.$el.append(this._templateOption(f[g]))}var e=this;this.$el.find("input").on("change",function(){e.value(e._getValue());e._change()});this._refresh();this.value(h)},exists:function(f){if(typeof f==="string"){f=[f]}for(var e in f){if(this.$el.find('input[value="'+f[e]+'"]').length>0){return true}}return false},first:function(){var e=this.$el.find("input");if(e.length>0){return e.val()}else{return undefined}},_change:function(){if(this.options.onchange){this.options.onchange(this._getValue())}},_refresh:function(){this.$el.find(".ui-error").remove();var e=this.$el.find("input").length;if(e==0){this.$el.append(this._templateEmpty())}},_getValue:function(){var f=this.$el.find(":checked");if(f.length==0){return null}if(this.options.multiple){var e=[];f.each(function(){e.push($(this).val())});return e}else{return f.val()}},_templateEmpty:function(){return'<div class="ui-error">'+this.options.empty+"</div>"}});var c={};c.View=a.extend({initialize:function(e){e.multiple=true;a.prototype.initialize.call(this,e)},value:function(e){if(typeof e==="string"){e=[e]}if(e!==undefined){this.$el.find("input").prop("checked",false);for(var f in e){this.$el.find("input[value="+e[f]+"]").prop("checked",true)}}return this._getValue()},_templateOption:function(e){return'<div class="ui-option"><input type="checkbox" name="'+this.options.id+'" value="'+e.value+'"/>'+e.label+"<br></div>"},_template:function(){return'<div class="ui-checkbox"/>'}});var d={};d.View=a.extend({initialize:function(e){a.prototype.initialize.call(this,e)},value:function(e){if(e!==undefined){this.$el.find("input").prop("checked",false);this.$el.find("label").removeClass("active");this.$el.find('[value="'+e+'"]').prop("checked",true).closest("label").addClass("active")}return this._getValue()},_templateOption:function(e){return'<label class="ui-option btn btn-default"><input type="radio" name="'+this.options.id+'" value="'+e.value+'">'+e.label+"</label>"},_template:function(){return'<div class="btn-group ui-radiobutton" data-toggle="buttons"/>'}});return{Checkbox:c,RadioButton:d}}); \ No newline at end of file Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org