1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/10b4f2107e90/ Changeset: 10b4f2107e90 User: guerler Date: 2014-10-10 04:03:59+00:00 Summary: ToolForm: Fix optional label, add file Affected #: 3 files diff -r 34e643839cdace531f6ebf1a7d08e5d735be51a6 -r 10b4f2107e90f3821f94be4286f320628c518034 client/galaxy/scripts/mvc/tools/tools-input.js --- /dev/null +++ b/client/galaxy/scripts/mvc/tools/tools-input.js @@ -0,0 +1,108 @@ +/** + This class creates a tool form input element wrapper +*/ +define([], function() { + + // input field element wrapper + return Backbone.View.extend({ + // initialize input wrapper + initialize: function(options) { + // link field + this.field = options.field; + + // set element + this.setElement(this._template(options)); + + // link elements + this.$field = this.$el.find('.ui-table-form-field'); + this.$title_optional = this.$el.find('.ui-table-form-title-optional'); + this.$error_text = this.$el.find('.ui-table-form-error-text'); + this.$error = this.$el.find('.ui-table-form-error'); + + // add field element + this.$field.prepend(this.field.$el); + + // hide optional field on initialization + if (options.optional) { + this.field.skip = true; + } else { + this.field.skip = false; + } + + // refresh view + this._refresh(); + + // add optional hide/show + var self = this; + this.$title_optional.on('click', function() { + // flip flag + self.field.skip = !self.field.skip; + + // refresh view + self._refresh(); + }); + }, + + /** Set error text + */ + error: function(text) { + this.$error_text.html(text); + this.$error.fadeIn(); + this.$el.addClass('ui-error'); + }, + + /** Reset this view + */ + reset: function() { + this.$error.hide(); + this.$el.removeClass('ui-error'); + }, + + /** Refresh element + */ + _refresh: function() { + // show/hide field element + if (!this.field.skip) { + this.$field.fadeIn('fast'); + this.$title_optional.html('Disable'); + } else { + this.$field.hide(); + this.$title_optional.html('Enable'); + } + }, + + /** Main Template + */ + _template: function(options) { + // create table element + var tmp = '<div class="ui-table-form-element">' + + '<div class="ui-table-form-error ui-error">' + + '<span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"/>' + + '</div>' + + '<div class="ui-table-form-title-strong">'; + + // is optional + if (options.optional) { + tmp += 'Optional: ' + options.label + + '<span> [<span class="ui-table-form-title-optional"/>]</span>'; + } else { + tmp += options.label; + } + + // finalize title + tmp += '</div>' + + '<div class="ui-table-form-field">'; + // add help + if (options.help) { + tmp += '<div class="ui-table-form-info">' + options.help + '</div>'; + } + + // finalize + tmp += '</div>' + + '</div>'; + + // return input element + return tmp; + } + }); +}); diff -r 34e643839cdace531f6ebf1a7d08e5d735be51a6 -r 10b4f2107e90f3821f94be4286f320628c518034 static/scripts/mvc/tools/tools-input.js --- a/static/scripts/mvc/tools/tools-input.js +++ b/static/scripts/mvc/tools/tools-input.js @@ -83,7 +83,7 @@ // is optional if (options.optional) { - tmp += '*Optional: ' + options.label + + tmp += 'Optional: ' + options.label + '<span> [<span class="ui-table-form-title-optional"/>]</span>'; } else { tmp += options.label; diff -r 34e643839cdace531f6ebf1a7d08e5d735be51a6 -r 10b4f2107e90f3821f94be4286f320628c518034 static/scripts/packed/mvc/tools/tools-input.js --- a/static/scripts/packed/mvc/tools/tools-input.js +++ b/static/scripts/packed/mvc/tools/tools-input.js @@ -1,1 +1,1 @@ -define([],function(){return Backbone.View.extend({initialize:function(b){this.field=b.field;this.setElement(this._template(b));this.$field=this.$el.find(".ui-table-form-field");this.$title_optional=this.$el.find(".ui-table-form-title-optional");this.$error_text=this.$el.find(".ui-table-form-error-text");this.$error=this.$el.find(".ui-table-form-error");this.$field.prepend(this.field.$el);if(b.optional){this.field.skip=true}else{this.field.skip=false}this._refresh();var a=this;this.$title_optional.on("click",function(){a.field.skip=!a.field.skip;a._refresh()})},error:function(a){this.$error_text.html(a);this.$error.fadeIn();this.$el.addClass("ui-error")},reset:function(){this.$error.hide();this.$el.removeClass("ui-error")},_refresh:function(){if(!this.field.skip){this.$field.fadeIn("fast");this.$title_optional.html("Disable")}else{this.$field.hide();this.$title_optional.html("Enable")}},_template:function(a){var b='<div class="ui-table-form-element"><div class="ui-table-form-error ui-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"/></div><div class="ui-table-form-title-strong">';if(a.optional){b+="*Optional: "+a.label+'<span> [<span class="ui-table-form-title-optional"/>]</span>'}else{b+=a.label}b+='</div><div class="ui-table-form-field">';if(a.help){b+='<div class="ui-table-form-info">'+a.help+"</div>"}b+="</div></div>";return b}})}); \ No newline at end of file +define([],function(){return Backbone.View.extend({initialize:function(b){this.field=b.field;this.setElement(this._template(b));this.$field=this.$el.find(".ui-table-form-field");this.$title_optional=this.$el.find(".ui-table-form-title-optional");this.$error_text=this.$el.find(".ui-table-form-error-text");this.$error=this.$el.find(".ui-table-form-error");this.$field.prepend(this.field.$el);if(b.optional){this.field.skip=true}else{this.field.skip=false}this._refresh();var a=this;this.$title_optional.on("click",function(){a.field.skip=!a.field.skip;a._refresh()})},error:function(a){this.$error_text.html(a);this.$error.fadeIn();this.$el.addClass("ui-error")},reset:function(){this.$error.hide();this.$el.removeClass("ui-error")},_refresh:function(){if(!this.field.skip){this.$field.fadeIn("fast");this.$title_optional.html("Disable")}else{this.$field.hide();this.$title_optional.html("Enable")}},_template:function(a){var b='<div class="ui-table-form-element"><div class="ui-table-form-error ui-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"/></div><div class="ui-table-form-title-strong">';if(a.optional){b+="Optional: "+a.label+'<span> [<span class="ui-table-form-title-optional"/>]</span>'}else{b+=a.label}b+='</div><div class="ui-table-form-field">';if(a.help){b+='<div class="ui-table-form-info">'+a.help+"</div>"}b+="</div></div>";return b}})}); \ 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.