diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-10-15 19:52:22 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-10-15 19:52:22 +0200 |
commit | e7443ee892f2ef49fed327cef6770ce11cd1fc0b (patch) | |
tree | 3e5276506ae57b3ca72e96e195024607586c31de | |
parent | 6f835aff31549a30d63e8bdcad4854f13120dbe5 (diff) | |
download | nextcloud-server-e7443ee892f2ef49fed327cef6770ce11cd1fc0b.tar.gz nextcloud-server-e7443ee892f2ef49fed327cef6770ce11cd1fc0b.zip |
Move more comments to compiled handlebars
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
-rw-r--r-- | apps/comments/js/commentsmodifymenu.js | 20 | ||||
-rw-r--r-- | apps/comments/js/filesplugin.js | 10 | ||||
-rw-r--r-- | apps/comments/js/templates.js | 36 | ||||
-rw-r--r-- | apps/comments/js/templates/commentsmodifymenu.handlebars | 14 | ||||
-rw-r--r-- | apps/comments/js/templates/filesplugin.handlebars | 3 |
5 files changed, 56 insertions, 27 deletions
diff --git a/apps/comments/js/commentsmodifymenu.js b/apps/comments/js/commentsmodifymenu.js index 4b17cbbfbf0..fd1e3d80bd0 100644 --- a/apps/comments/js/commentsmodifymenu.js +++ b/apps/comments/js/commentsmodifymenu.js @@ -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);
\ No newline at end of file +})(OC, OCA); diff --git a/apps/comments/js/filesplugin.js b/apps/comments/js/filesplugin.js index 8c5762065a1..939edc8c695 100644 --- a/apps/comments/js/filesplugin.js +++ b/apps/comments/js/filesplugin.js @@ -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') diff --git a/apps/comments/js/templates.js b/apps/comments/js/templates.js index a5706baa27e..26ca658c772 100644 --- a/apps/comments/js/templates.js +++ b/apps/comments/js/templates.js @@ -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; diff --git a/apps/comments/js/templates/commentsmodifymenu.handlebars b/apps/comments/js/templates/commentsmodifymenu.handlebars new file mode 100644 index 00000000000..28f6ffcdde6 --- /dev/null +++ b/apps/comments/js/templates/commentsmodifymenu.handlebars @@ -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> diff --git a/apps/comments/js/templates/filesplugin.handlebars b/apps/comments/js/templates/filesplugin.handlebars new file mode 100644 index 00000000000..8f3699380be --- /dev/null +++ b/apps/comments/js/templates/filesplugin.handlebars @@ -0,0 +1,3 @@ +<a class="action action-comment permanent" title="{{countMessage}}" href="#"> + <img class="svg" src="{{iconUrl}}"/> +</a> |