commit/galaxy-central: carlfeberhard: QuotaMeter: remove handlebars templates, render within view, update for bootstrap 3.0; pack scripts
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/ff9603c007c7/ Changeset: ff9603c007c7 User: carlfeberhard Date: 2013-10-23 20:22:20 Summary: QuotaMeter: remove handlebars templates, render within view, update for bootstrap 3.0; pack scripts Affected #: 9 files diff -r bd89b1ef5a95cd9ca8de04a829043788e9dde0ad -r ff9603c007c78c5c256171592bbd0aed5e20cab1 static/scripts/mvc/user/user-quotameter.js --- a/static/scripts/mvc/user/user-quotameter.js +++ b/static/scripts/mvc/user/user-quotameter.js @@ -57,31 +57,33 @@ var modelJson = this.model.toJSON(), //prevPercent = this.model.previous( 'quota_percent' ), percent = modelJson.quota_percent, - meter = $( UserQuotaMeter.templates.quota( modelJson ) ); + //meter = $( UserQuotaMeter.templates.quota( modelJson ) ); + $meter = $( this._templateQuotaMeter( modelJson ) ), + $bar = $meter.find( '.progress-bar' ); //this.log( this + '.rendering quota, percent:', percent, 'meter:', meter ); // OVER QUOTA: color the quota bar and show the quota error message if( this.isOverQuota() ){ //this.log( '\t over quota' ); - meter.addClass( 'progress-danger' ); - meter.find( '#quota-meter-text' ).css( 'color', 'white' ); + $bar.attr( 'class', 'progress-bar progress-bar-danger' ); + $meter.find( '.quota-meter-text' ).css( 'color', 'white' ); //TODO: only trigger event if state has changed this.trigger( 'quota:over', modelJson ); // APPROACHING QUOTA: color the quota bar } else if( percent >= this.options.warnAtPercent ){ //this.log( '\t approaching quota' ); - meter.addClass( 'progress-warning' ); + $bar.attr( 'class', 'progress-bar progress-bar-warning' ); //TODO: only trigger event if state has changed this.trigger( 'quota:under quota:under:approaching', modelJson ); // otherwise, hide/don't use the msg box } else { - meter.addClass( 'progress-success' ); + $bar.attr( 'class', 'progress-bar progress-bar-success' ); //TODO: only trigger event if state has changed this.trigger( 'quota:under quota:under:ok', modelJson ); } - return meter; + return $meter; }, /** Render the meter when the user has NO applicable quota. Will render as text @@ -89,7 +91,8 @@ * @returns {jQuery} the rendered text */ _render_usage : function(){ - var usage = $( UserQuotaMeter.templates.usage( this.model.toJSON() ) ); + //var usage = $( UserQuotaMeter.templates.usage( this.model.toJSON() ) ); + var usage = $( this._templateUsage( this.model.toJSON() ) ); this.log( this + '.rendering usage:', usage ); return usage; }, @@ -120,14 +123,29 @@ return this; }, + _templateQuotaMeter : function( data ){ + return [ + '<div id="quota-meter" class="quota-meter progress">', + '<div class="progress-bar" style="width: ', data.quota_percent, '%"></div>', + '<div class="quota-meter-text" style="top: 6px"', + (( data.nice_total_disk_usage )?( ' title="Using ' + data.nice_total_disk_usage + '">' ):( '>' )), + _l( 'Using' ), ' ', data.quota_percent, '%', + '</div>', + '</div>' + ].join( '' ); + }, + + _templateUsage : function( data ){ + return [ + '<div id="quota-meter" class="quota-meter" style="background-color: transparent">', + '<div class="quota-meter-text" style="top: 6px; color: white">', + (( data.nice_total_disk_usage )?( _l( 'Using ' ) + data.nice_total_disk_usage ):( '' )), + '</div>', + '</div>' + ].join( '' ); + }, + toString : function(){ return 'UserQuotaMeter(' + this.model + ')'; } }); - - -//------------------------------------------------------------------------------ TEMPLATES -UserQuotaMeter.templates = { - quota : Handlebars.templates[ 'template-user-quotaMeter-quota' ], - usage : Handlebars.templates[ 'template-user-quotaMeter-usage' ] -}; diff -r bd89b1ef5a95cd9ca8de04a829043788e9dde0ad -r ff9603c007c78c5c256171592bbd0aed5e20cab1 static/scripts/packed/mvc/user/user-quotameter.js --- a/static/scripts/packed/mvc/user/user-quotameter.js +++ b/static/scripts/packed/mvc/user/user-quotameter.js @@ -1,1 +1,1 @@ -var UserQuotaMeter=Backbone.View.extend(LoggableMixin).extend({options:{warnAtPercent:85,errorAtPercent:100},initialize:function(a){this.log(this+".initialize:",a);_.extend(this.options,a);this.model.bind("change:quota_percent change:total_disk_usage",this.render,this)},update:function(a){this.log(this+" updating user data...",a);this.model.loadFromApi(this.model.get("id"),a);return this},isOverQuota:function(){return(this.model.get("quota_percent")!==null&&this.model.get("quota_percent")>=this.options.errorAtPercent)},_render_quota:function(){var a=this.model.toJSON(),b=a.quota_percent,c=$(UserQuotaMeter.templates.quota(a));if(this.isOverQuota()){c.addClass("progress-danger");c.find("#quota-meter-text").css("color","white");this.trigger("quota:over",a)}else{if(b>=this.options.warnAtPercent){c.addClass("progress-warning");this.trigger("quota:under quota:under:approaching",a)}else{c.addClass("progress-success");this.trigger("quota:under quota:under:ok",a)}}return c},_render_usage:function(){var a=$(UserQuotaMeter.templates.usage(this.model.toJSON()));this.log(this+".rendering usage:",a);return a},render:function(){var a=null;this.log(this+".model.quota_percent:",this.model.get("quota_percent"));if((this.model.get("quota_percent")===null)||(this.model.get("quota_percent")===undefined)){a=this._render_usage()}else{a=this._render_quota()}this.$el.html(a);this.$el.find(".quota-meter-text").tooltip();return this},toString:function(){return"UserQuotaMeter("+this.model+")"}});UserQuotaMeter.templates={quota:Handlebars.templates["template-user-quotaMeter-quota"],usage:Handlebars.templates["template-user-quotaMeter-usage"]}; \ No newline at end of file +var UserQuotaMeter=Backbone.View.extend(LoggableMixin).extend({options:{warnAtPercent:85,errorAtPercent:100},initialize:function(a){this.log(this+".initialize:",a);_.extend(this.options,a);this.model.bind("change:quota_percent change:total_disk_usage",this.render,this)},update:function(a){this.log(this+" updating user data...",a);this.model.loadFromApi(this.model.get("id"),a);return this},isOverQuota:function(){return(this.model.get("quota_percent")!==null&&this.model.get("quota_percent")>=this.options.errorAtPercent)},_render_quota:function(){var a=this.model.toJSON(),c=a.quota_percent,b=$(this._templateQuotaMeter(a)),d=b.find(".progress-bar");if(this.isOverQuota()){d.attr("class","progress-bar progress-bar-danger");b.find(".quota-meter-text").css("color","white");this.trigger("quota:over",a)}else{if(c>=this.options.warnAtPercent){d.attr("class","progress-bar progress-bar-warning");this.trigger("quota:under quota:under:approaching",a)}else{d.attr("class","progress-bar progress-bar-success");this.trigger("quota:under quota:under:ok",a)}}return b},_render_usage:function(){var a=$(this._templateUsage(this.model.toJSON()));this.log(this+".rendering usage:",a);return a},render:function(){var a=null;this.log(this+".model.quota_percent:",this.model.get("quota_percent"));if((this.model.get("quota_percent")===null)||(this.model.get("quota_percent")===undefined)){a=this._render_usage()}else{a=this._render_quota()}this.$el.html(a);this.$el.find(".quota-meter-text").tooltip();return this},_templateQuotaMeter:function(a){return['<div id="quota-meter" class="quota-meter progress">','<div class="progress-bar" style="width: ',a.quota_percent,'%"></div>','<div class="quota-meter-text" style="top: 6px"',((a.nice_total_disk_usage)?(' title="Using '+a.nice_total_disk_usage+'">'):(">")),_l("Using")," ",a.quota_percent,"%","</div>","</div>"].join("")},_templateUsage:function(a){return['<div id="quota-meter" class="quota-meter" style="background-color: transparent">','<div class="quota-meter-text" style="top: 6px; color: white">',((a.nice_total_disk_usage)?(_l("Using ")+a.nice_total_disk_usage):("")),"</div>","</div>"].join("")},toString:function(){return"UserQuotaMeter("+this.model+")"}}); \ No newline at end of file diff -r bd89b1ef5a95cd9ca8de04a829043788e9dde0ad -r ff9603c007c78c5c256171592bbd0aed5e20cab1 static/scripts/packed/templates/compiled/template-user-quotaMeter-quota.js --- a/static/scripts/packed/templates/compiled/template-user-quotaMeter-quota.js +++ /dev/null @@ -1,1 +0,0 @@ -(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a["template-user-quotaMeter-quota"]=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,p,h="function",j=this.escapeExpression,o=this,n=f.blockHelperMissing;function e(t,s){var q="",r;q+=' title="Using ';if(r=f.nice_total_disk_usage){r=r.call(t,{hash:{},data:s})}else{r=t.nice_total_disk_usage;r=typeof r===h?r.apply(t):r}q+=j(r)+'"';return q}function c(r,q){return"Using"}i+='<div id="quota-meter" class="quota-meter progress">\n <div id="quota-meter-bar" class="quota-meter-bar bar" style="width: ';if(d=f.quota_percent){d=d.call(m,{hash:{},data:k})}else{d=m.quota_percent;d=typeof d===h?d.apply(m):d}i+=j(d)+'%"></div>\n \n <div id="quota-meter-text" class="quota-meter-text"\n style="top: 6px"';d=f["if"].call(m,m.nice_total_disk_usage,{hash:{},inverse:o.noop,fn:o.program(1,e,k),data:k});if(d||d===0){i+=d}i+=">\n ";p={hash:{},inverse:o.noop,fn:o.program(3,c,k),data:k};if(d=f.local){d=d.call(m,p)}else{d=m.local;d=typeof d===h?d.apply(m):d}if(!f.local){d=n.call(m,d,p)}if(d||d===0){i+=d}i+=" ";if(d=f.quota_percent){d=d.call(m,{hash:{},data:k})}else{d=m.quota_percent;d=typeof d===h?d.apply(m):d}i+=j(d)+"%\n </div>\n</div>";return i})})(); \ No newline at end of file diff -r bd89b1ef5a95cd9ca8de04a829043788e9dde0ad -r ff9603c007c78c5c256171592bbd0aed5e20cab1 static/scripts/packed/templates/compiled/template-user-quotaMeter-usage.js --- a/static/scripts/packed/templates/compiled/template-user-quotaMeter-usage.js +++ /dev/null @@ -1,1 +0,0 @@ -(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a["template-user-quotaMeter-usage"]=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",c,o=this,h="function",n=f.blockHelperMissing,j=this.escapeExpression;function e(t,s){var p="",r,q;q={hash:{},inverse:o.noop,fn:o.program(2,d,s),data:s};if(r=f.local){r=r.call(t,q)}else{r=t.local;r=typeof r===h?r.apply(t):r}if(!f.local){r=n.call(t,r,q)}if(r||r===0){p+=r}p+=" ";if(r=f.nice_total_disk_usage){r=r.call(t,{hash:{},data:s})}else{r=t.nice_total_disk_usage;r=typeof r===h?r.apply(t):r}p+=j(r);return p}function d(q,p){return"Using"}i+='<div id="quota-meter" class="quota-meter" style="background-color: transparent">\n <div id="quota-meter-text" class="quota-meter-text" style="top: 6px; color: white">\n ';c=f["if"].call(m,m.nice_total_disk_usage,{hash:{},inverse:o.noop,fn:o.program(1,e,k),data:k});if(c||c===0){i+=c}i+="\n </div>\n</div>";return i})})(); \ No newline at end of file diff -r bd89b1ef5a95cd9ca8de04a829043788e9dde0ad -r ff9603c007c78c5c256171592bbd0aed5e20cab1 static/scripts/templates/compiled/template-user-quotaMeter-quota.js --- a/static/scripts/templates/compiled/template-user-quotaMeter-quota.js +++ /dev/null @@ -1,46 +0,0 @@ -(function() { - var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; -templates['template-user-quotaMeter-quota'] = template(function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, options, functionType="function", escapeExpression=this.escapeExpression, self=this, blockHelperMissing=helpers.blockHelperMissing; - -function program1(depth0,data) { - - var buffer = "", stack1; - buffer += " title=\"Using "; - if (stack1 = helpers.nice_total_disk_usage) { stack1 = stack1.call(depth0, {hash:{},data:data}); } - else { stack1 = depth0.nice_total_disk_usage; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } - buffer += escapeExpression(stack1) - + "\""; - return buffer; - } - -function program3(depth0,data) { - - - return "Using"; - } - - buffer += "<div id=\"quota-meter\" class=\"quota-meter progress\">\n <div id=\"quota-meter-bar\" class=\"quota-meter-bar bar\" style=\"width: "; - if (stack1 = helpers.quota_percent) { stack1 = stack1.call(depth0, {hash:{},data:data}); } - else { stack1 = depth0.quota_percent; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } - buffer += escapeExpression(stack1) - + "%\"></div>\n " - + "\n <div id=\"quota-meter-text\" class=\"quota-meter-text\"\n style=\"top: 6px\""; - stack1 = helpers['if'].call(depth0, depth0.nice_total_disk_usage, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data}); - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += ">\n "; - options = {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data}; - if (stack1 = helpers.local) { stack1 = stack1.call(depth0, options); } - else { stack1 = depth0.local; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } - if (!helpers.local) { stack1 = blockHelperMissing.call(depth0, stack1, options); } - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += " "; - if (stack1 = helpers.quota_percent) { stack1 = stack1.call(depth0, {hash:{},data:data}); } - else { stack1 = depth0.quota_percent; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } - buffer += escapeExpression(stack1) - + "%\n </div>\n</div>"; - return buffer; - }); -})(); \ No newline at end of file diff -r bd89b1ef5a95cd9ca8de04a829043788e9dde0ad -r ff9603c007c78c5c256171592bbd0aed5e20cab1 static/scripts/templates/compiled/template-user-quotaMeter-usage.js --- a/static/scripts/templates/compiled/template-user-quotaMeter-usage.js +++ /dev/null @@ -1,34 +0,0 @@ -(function() { - var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; -templates['template-user-quotaMeter-usage'] = template(function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; - var buffer = "", stack1, self=this, functionType="function", blockHelperMissing=helpers.blockHelperMissing, escapeExpression=this.escapeExpression; - -function program1(depth0,data) { - - var buffer = "", stack1, options; - options = {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data}; - if (stack1 = helpers.local) { stack1 = stack1.call(depth0, options); } - else { stack1 = depth0.local; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } - if (!helpers.local) { stack1 = blockHelperMissing.call(depth0, stack1, options); } - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += " "; - if (stack1 = helpers.nice_total_disk_usage) { stack1 = stack1.call(depth0, {hash:{},data:data}); } - else { stack1 = depth0.nice_total_disk_usage; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } - buffer += escapeExpression(stack1); - return buffer; - } -function program2(depth0,data) { - - - return "Using"; - } - - buffer += "<div id=\"quota-meter\" class=\"quota-meter\" style=\"background-color: transparent\">\n <div id=\"quota-meter-text\" class=\"quota-meter-text\" style=\"top: 6px; color: white\">\n "; - stack1 = helpers['if'].call(depth0, depth0.nice_total_disk_usage, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data}); - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n </div>\n</div>"; - return buffer; - }); -})(); \ No newline at end of file diff -r bd89b1ef5a95cd9ca8de04a829043788e9dde0ad -r ff9603c007c78c5c256171592bbd0aed5e20cab1 static/scripts/templates/ui-templates.html --- a/static/scripts/templates/ui-templates.html +++ /dev/null @@ -1,19 +0,0 @@ -<script type="text/template" class="template-user" id="template-user-quotaMeter-quota"> -<div id="quota-meter" class="quota-meter progress"> - <div id="quota-meter-bar" class="quota-meter-bar bar" style="width: {{quota_percent}}%"></div> - {{! TODO: remove the hardcoded style }} - <div id="quota-meter-text" class="quota-meter-text" - style="top: 6px"{{#if nice_total_disk_usage}} title="Using {{nice_total_disk_usage}}"{{/if}}> - {{#local}}Using{{/local}} {{ quota_percent }}% - </div> -</div> -</script> - -<!-- TODO: remove the hardcoded styles --> -<script type="text/template" class="template-user" id="template-user-quotaMeter-usage"> -<div id="quota-meter" class="quota-meter" style="background-color: transparent"> - <div id="quota-meter-text" class="quota-meter-text" style="top: 6px; color: white"> - {{#if nice_total_disk_usage }}{{#local}}Using{{/local}} {{ nice_total_disk_usage }}{{/if}} - </div> -</div> -</script> diff -r bd89b1ef5a95cd9ca8de04a829043788e9dde0ad -r ff9603c007c78c5c256171592bbd0aed5e20cab1 templates/webapps/galaxy/base_panels.mako --- a/templates/webapps/galaxy/base_panels.mako +++ b/templates/webapps/galaxy/base_panels.mako @@ -7,7 +7,7 @@ ${parent.javascripts()} <!-- quota meter --> -${h.templates( "helpers-common-templates", "template-user-quotaMeter-quota", "template-user-quotaMeter-usage" )} +${h.templates( "helpers-common-templates" )} ${h.js( "mvc/base-mvc", "utils/localization", "mvc/user/user-model", "mvc/user/user-quotameter" )} </%def> diff -r bd89b1ef5a95cd9ca8de04a829043788e9dde0ad -r ff9603c007c78c5c256171592bbd0aed5e20cab1 templates/webapps/galaxy/galaxy.masthead.mako --- a/templates/webapps/galaxy/galaxy.masthead.mako +++ b/templates/webapps/galaxy/galaxy.masthead.mako @@ -232,7 +232,7 @@ <div class="quota-meter-container"></div><!-- quota meter --> - ${h.templates( "helpers-common-templates", "template-user-quotaMeter-quota", "template-user-quotaMeter-usage" )} + ${h.templates( "helpers-common-templates" )} ${h.js( "mvc/base-mvc", "utils/localization", "mvc/user/user-model", "mvc/user/user-quotameter" )} <script type="text/javascript"> 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