Move more comments to compiled handlebars

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2018-10-15 19:52:22 +02:00
parent 6f835aff31
commit e7443ee892
No known key found for this signature in database
GPG Key ID: F941078878347C0C
5 changed files with 56 additions and 27 deletions

View File

@ -10,20 +10,6 @@
/* global Handlebars */
(function() {
var TEMPLATE_MENU =
'<ul>' +
'{{#each items}}' +
'<li>' +
'<a href="#" class="menuitem action {{name}} permanent" data-action="{{name}}">' +
'{{#if iconClass}}' +
'<span class="icon {{iconClass}}"></span>' +
'{{else}}' +
'<span class="no-icon"></span>' +
'{{/if}}' +
'<span>{{displayName}}</span>' +
'</li>' +
'{{/each}}' +
'</ul>';
/**
* Construct a new CommentsModifyMenuinstance
@ -52,8 +38,6 @@
'click a.action': '_onClickAction'
},
template: Handlebars.compile(TEMPLATE_MENU),
/**
* Event handler whenever an action has been clicked within the menu
*
@ -74,7 +58,7 @@
* Renders the menu with the currently set items
*/
render: function() {
this.$el.html(this.template({
this.$el.html(OCA.Comments.Templates['commentsmodifymenu']({
items: this._scopes
}));
},
@ -121,4 +105,4 @@
OCA.Comments = OCA.Comments || {};
OCA.Comments.CommentsModifyMenu = CommentsModifyMenu;
})(OC, OCA);
})(OC, OCA);

View File

@ -16,11 +16,6 @@
PROPERTY_COMMENTS_UNREAD: '{' + OC.Files.Client.NS_OWNCLOUD + '}comments-unread'
});
var TEMPLATE_COMMENTS_UNREAD =
'<a class="action action-comment permanent" title="{{countMessage}}" href="#">' +
'<img class="svg" src="{{iconUrl}}"/>' +
'</a>';
OCA.Comments = _.extend({}, OCA.Comments);
if (!OCA.Comments) {
/**
@ -39,10 +34,7 @@
],
_formatCommentCount: function(count) {
if (!this._commentsUnreadTemplate) {
this._commentsUnreadTemplate = Handlebars.compile(TEMPLATE_COMMENTS_UNREAD);
}
return this._commentsUnreadTemplate({
return OCA.Comments.Templates['filesplugin']({
count: count,
countMessage: n('comments', '%n unread comment', '%n unread comments', count),
iconUrl: OC.imagePath('core', 'actions/comment')

View File

@ -46,6 +46,33 @@ templates['comment'] = template({"1":function(container,depth0,helpers,partials,
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isLong : depth0),{"name":"if","hash":{},"fn":container.program(11, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "</li>\n";
},"useData":true});
templates['commentsmodifymenu'] = template({"1":function(container,depth0,helpers,partials,data) {
var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return " <li>\n <a href=\"#\" class=\"menuitem action "
+ alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
+ " permanent\" data-action=\""
+ alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
+ "\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.iconClass : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.program(4, data, 0),"data":data})) != null ? stack1 : "")
+ " <span>"
+ alias4(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data}) : helper)))
+ "</span>\n </a>\n </li>\n";
},"2":function(container,depth0,helpers,partials,data) {
var helper;
return " <span class=\"icon "
+ container.escapeExpression(((helper = (helper = helpers.iconClass || (depth0 != null ? depth0.iconClass : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"iconClass","hash":{},"data":data}) : helper)))
+ "\"></span>\n";
},"4":function(container,depth0,helpers,partials,data) {
return " <span class=\"no-icon\"></span>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1;
return "<ul>\n"
+ ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.items : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "</ul>\n";
},"useData":true});
templates['edit_comment'] = template({"1":function(container,depth0,helpers,partials,data) {
var helper;
@ -75,6 +102,15 @@ templates['edit_comment'] = template({"1":function(container,depth0,helpers,part
+ alias4(((helper = (helper = helpers.tag || (depth0 != null ? depth0.tag : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"tag","hash":{},"data":data}) : helper)))
+ ">\n";
},"useData":true});
templates['filesplugin'] = template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return "<a class=\"action action-comment permanent\" title=\""
+ alias4(((helper = (helper = helpers.countMessage || (depth0 != null ? depth0.countMessage : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"countMessage","hash":{},"data":data}) : helper)))
+ "\" href=\"#\">\n <img class=\"svg\" src=\""
+ alias4(((helper = (helper = helpers.iconUrl || (depth0 != null ? depth0.iconUrl : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"iconUrl","hash":{},"data":data}) : helper)))
+ "\"/>\n</a>\n";
},"useData":true});
templates['view'] = template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

View File

@ -0,0 +1,14 @@
<ul>
{{#each items}}
<li>
<a href="#" class="menuitem action {{name}} permanent" data-action="{{name}}">
{{#if iconClass}}
<span class="icon {{iconClass}}"></span>
{{else}}
<span class="no-icon"></span>
{{/if}}
<span>{{displayName}}</span>
</a>
</li>
{{/each}}
</ul>

View File

@ -0,0 +1,3 @@
<a class="action action-comment permanent" title="{{countMessage}}" href="#">
<img class="svg" src="{{iconUrl}}"/>
</a>