diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-10-01 21:53:35 +0300 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-10-04 10:53:45 +0300 |
commit | b574d1c81474b0dbc94a32ae18ec3d68a81db51a (patch) | |
tree | 4d261a6e119bcdc9835a739cb860a637c0bc854e /apps | |
parent | b0fd31496b5edb95264c0ea3139692b5969f40e0 (diff) |
Move files_versions to compiled handlebars templates
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_versions/js/merged.json | 1 | ||||
-rw-r--r-- | apps/files_versions/js/templates.js | 54 | ||||
-rw-r--r-- | apps/files_versions/js/templates/item.handlebars | 22 | ||||
-rw-r--r-- | apps/files_versions/js/templates/template.handlebars | 10 | ||||
-rw-r--r-- | apps/files_versions/js/versionstabview.js | 48 |
5 files changed, 89 insertions, 46 deletions
diff --git a/apps/files_versions/js/merged.json b/apps/files_versions/js/merged.json index 1a7fbad298b..67ee60b3851 100644 --- a/apps/files_versions/js/merged.json +++ b/apps/files_versions/js/merged.json @@ -1,5 +1,6 @@ [ "versionmodel.js", + "templates.js", "versioncollection.js", "versionstabview.js", "filesplugin.js" diff --git a/apps/files_versions/js/templates.js b/apps/files_versions/js/templates.js new file mode 100644 index 00000000000..17293d763df --- /dev/null +++ b/apps/files_versions/js/templates.js @@ -0,0 +1,54 @@ +(function() { + var template = Handlebars.template, templates = OCA.Versions.Templates = OCA.Versions.Templates || {}; +templates['item'] = template({"1":function(container,depth0,helpers,partials,data) { + var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return " <div class=\"version-details\">\n <span class=\"size has-tooltip\" title=\"" + + alias4(((helper = (helper = helpers.altSize || (depth0 != null ? depth0.altSize : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"altSize","hash":{},"data":data}) : helper))) + + "\">" + + alias4(((helper = (helper = helpers.humanReadableSize || (depth0 != null ? depth0.humanReadableSize : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"humanReadableSize","hash":{},"data":data}) : helper))) + + "</span>\n </div>\n"; +},"3":function(container,depth0,helpers,partials,data) { + var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return " <a href=\"#\" class=\"revertVersion\" title=\"" + + alias4(((helper = (helper = helpers.revertLabel || (depth0 != null ? depth0.revertLabel : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"revertLabel","hash":{},"data":data}) : helper))) + + "\"><img src=\"" + + alias4(((helper = (helper = helpers.revertIconUrl || (depth0 != null ? depth0.revertIconUrl : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"revertIconUrl","hash":{},"data":data}) : helper))) + + "\" /></a>\n"; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, helper, options, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression, alias5=helpers.blockHelperMissing, buffer = + "<li data-revision=\"" + + alias4(((helper = (helper = helpers.timestamp || (depth0 != null ? depth0.timestamp : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"timestamp","hash":{},"data":data}) : helper))) + + "\">\n <div>\n <div class=\"preview-container\">\n <img class=\"preview\" src=\"" + + alias4(((helper = (helper = helpers.previewUrl || (depth0 != null ? depth0.previewUrl : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"previewUrl","hash":{},"data":data}) : helper))) + + "\" width=\"44\" height=\"44\"/>\n </div>\n <div class=\"version-container\">\n <div>\n <a href=\"" + + alias4(((helper = (helper = helpers.downloadUrl || (depth0 != null ? depth0.downloadUrl : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"downloadUrl","hash":{},"data":data}) : helper))) + + "\" class=\"downloadVersion\"><img src=\"" + + alias4(((helper = (helper = helpers.downloadIconUrl || (depth0 != null ? depth0.downloadIconUrl : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"downloadIconUrl","hash":{},"data":data}) : helper))) + + "\" />\n <span class=\"versiondate has-tooltip live-relative-timestamp\" data-timestamp=\"" + + alias4(((helper = (helper = helpers.millisecondsTimestamp || (depth0 != null ? depth0.millisecondsTimestamp : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"millisecondsTimestamp","hash":{},"data":data}) : helper))) + + "\" title=\"" + + alias4(((helper = (helper = helpers.formattedTimestamp || (depth0 != null ? depth0.formattedTimestamp : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"formattedTimestamp","hash":{},"data":data}) : helper))) + + "\">" + + alias4(((helper = (helper = helpers.relativeTimestamp || (depth0 != null ? depth0.relativeTimestamp : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"relativeTimestamp","hash":{},"data":data}) : helper))) + + "</span>\n </a>\n </div>\n"; + stack1 = ((helper = (helper = helpers.hasDetails || (depth0 != null ? depth0.hasDetails : depth0)) != null ? helper : alias2),(options={"name":"hasDetails","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data}),(typeof helper === alias3 ? helper.call(alias1,options) : helper)); + if (!helpers.hasDetails) { stack1 = alias5.call(depth0,stack1,options)} + if (stack1 != null) { buffer += stack1; } + buffer += " </div>\n"; + stack1 = ((helper = (helper = helpers.canRevert || (depth0 != null ? depth0.canRevert : depth0)) != null ? helper : alias2),(options={"name":"canRevert","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data}),(typeof helper === alias3 ? helper.call(alias1,options) : helper)); + if (!helpers.canRevert) { stack1 = alias5.call(depth0,stack1,options)} + if (stack1 != null) { buffer += stack1; } + return buffer + " </div>\n</li>\n"; +},"useData":true}); +templates['template'] = 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 "<ul class=\"versions\"></ul>\n<div class=\"clear-float\"></div>\n<div class=\"empty hidden\">\n <div class=\"emptycontent\">\n <div class=\"icon-history\"></div>\n <p>" + + alias4(((helper = (helper = helpers.emptyResultLabel || (depth0 != null ? depth0.emptyResultLabel : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"emptyResultLabel","hash":{},"data":data}) : helper))) + + "</p>\n </div>\n</div>\n<input type=\"button\" class=\"showMoreVersions hidden\" value=\"" + + alias4(((helper = (helper = helpers.moreVersionsLabel || (depth0 != null ? depth0.moreVersionsLabel : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"moreVersionsLabel","hash":{},"data":data}) : helper))) + + "\" name=\"show-more-versions\" id=\"show-more-versions\" />\n<div class=\"loading hidden\" style=\"height: 50px\"></div>\n"; +},"useData":true}); +})();
\ No newline at end of file diff --git a/apps/files_versions/js/templates/item.handlebars b/apps/files_versions/js/templates/item.handlebars new file mode 100644 index 00000000000..6d11b9c0888 --- /dev/null +++ b/apps/files_versions/js/templates/item.handlebars @@ -0,0 +1,22 @@ +<li data-revision="{{timestamp}}"> + <div> + <div class="preview-container"> + <img class="preview" src="{{previewUrl}}" width="44" height="44"/> + </div> + <div class="version-container"> + <div> + <a href="{{downloadUrl}}" class="downloadVersion"><img src="{{downloadIconUrl}}" /> + <span class="versiondate has-tooltip live-relative-timestamp" data-timestamp="{{millisecondsTimestamp}}" title="{{formattedTimestamp}}">{{relativeTimestamp}}</span> + </a> + </div> + {{#hasDetails}} + <div class="version-details"> + <span class="size has-tooltip" title="{{altSize}}">{{humanReadableSize}}</span> + </div> + {{/hasDetails}} + </div> + {{#canRevert}} + <a href="#" class="revertVersion" title="{{revertLabel}}"><img src="{{revertIconUrl}}" /></a> + {{/canRevert}} + </div> +</li> diff --git a/apps/files_versions/js/templates/template.handlebars b/apps/files_versions/js/templates/template.handlebars new file mode 100644 index 00000000000..f01a6f41626 --- /dev/null +++ b/apps/files_versions/js/templates/template.handlebars @@ -0,0 +1,10 @@ +<ul class="versions"></ul> +<div class="clear-float"></div> +<div class="empty hidden"> + <div class="emptycontent"> + <div class="icon-history"></div> + <p>{{emptyResultLabel}}</p> + </div> +</div> +<input type="button" class="showMoreVersions hidden" value="{{moreVersionsLabel}}" name="show-more-versions" id="show-more-versions" /> +<div class="loading hidden" style="height: 50px"></div> diff --git a/apps/files_versions/js/versionstabview.js b/apps/files_versions/js/versionstabview.js index 3a9026901ea..dacd567fdc9 100644 --- a/apps/files_versions/js/versionstabview.js +++ b/apps/files_versions/js/versionstabview.js @@ -11,42 +11,6 @@ /* @global Handlebars */ (function() { - var TEMPLATE_ITEM = - '<li data-revision="{{timestamp}}">' + - '<div>' + - '<div class="preview-container">' + - '<img class="preview" src="{{previewUrl}}" width="44" height="44"/>' + - '</div>' + - '<div class="version-container">' + - '<div>' + - '<a href="{{downloadUrl}}" class="downloadVersion"><img src="{{downloadIconUrl}}" />' + - '<span class="versiondate has-tooltip live-relative-timestamp" data-timestamp="{{millisecondsTimestamp}}" title="{{formattedTimestamp}}">{{relativeTimestamp}}</span>' + - '</a>' + - '</div>' + - '{{#hasDetails}}' + - '<div class="version-details">' + - '<span class="size has-tooltip" title="{{altSize}}">{{humanReadableSize}}</span>' + - '</div>' + - '{{/hasDetails}}' + - '</div>' + - '{{#canRevert}}' + - '<a href="#" class="revertVersion" title="{{revertLabel}}"><img src="{{revertIconUrl}}" /></a>' + - '{{/canRevert}}' + - '</div>' + - '</li>'; - - var TEMPLATE = - '<ul class="versions"></ul>' + - '<div class="clear-float"></div>' + - '<div class="empty hidden">' + - '<div class="emptycontent">' + - '<div class="icon-history"></div>' + - '<p>{{emptyResultLabel}}</p>' + - '</div></div>' + - '<input type="button" class="showMoreVersions hidden" value="{{moreVersionsLabel}}"' + - ' name="show-more-versions" id="show-more-versions" />' + - '<div class="loading hidden" style="height: 50px"></div>'; - /** * @memberof OCA.Versions */ @@ -182,19 +146,11 @@ }, template: function(data) { - if (!this._template) { - this._template = Handlebars.compile(TEMPLATE); - } - - return this._template(data); + return OCA.Versions.Templates['template'](data); }, itemTemplate: function(data) { - if (!this._itemTemplate) { - this._itemTemplate = Handlebars.compile(TEMPLATE_ITEM); - } - - return this._itemTemplate(data); + return OCA.Versions.Templates['item'](data); }, setFileInfo: function(fileInfo) { |