From 48d1fe01169f9437bfe762852023e666641f029f Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 1 Oct 2018 18:50:09 +0200 Subject: [PATCH 01/12] Move filelist to compiled handlebars Signed-off-by: Roeland Jago Douma --- apps/files/js/filelist.js | 10 +--------- apps/files/js/templates.js | 9 +++++++++ apps/files/js/templates/template_addbutton.handlebars | 4 ++++ 3 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 apps/files/js/templates/template_addbutton.handlebars diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index c6e603e0c9..ab3607e3db 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -10,11 +10,6 @@ (function() { - var TEMPLATE_ADDBUTTON = '' + - '' + - '{{addText}}' + - ''; - /** * @class OCA.Files.FileList * @classdesc @@ -3295,10 +3290,7 @@ if (!$actionsContainer.length || this.$el.find('.button.upload').length) { return; } - if (!this._addButtonTemplate) { - this._addButtonTemplate = Handlebars.compile(TEMPLATE_ADDBUTTON); - } - var $newButton = $(this._addButtonTemplate({ + var $newButton = $(OCA.Files.Templates['template_addbutton']({ addText: t('files', 'New'), iconClass: 'icon-add' })); diff --git a/apps/files/js/templates.js b/apps/files/js/templates.js index 8ada62b6d6..9e93d5b5ac 100644 --- a/apps/files/js/templates.js +++ b/apps/files/js/templates.js @@ -36,4 +36,13 @@ templates['filesummary'] = template({"compiler":[7,">= 4.0.0"],"main":function(c + container.escapeExpression(((helper = (helper = helpers.connectorLabel || (depth0 != null ? depth0.connectorLabel : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"connectorLabel","hash":{},"data":data}) : helper))) + "\n \n \n \n\n"; },"useData":true}); +templates['template_addbutton'] = 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 "\n \n " + + alias4(((helper = (helper = helpers.addText || (depth0 != null ? depth0.addText : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"addText","hash":{},"data":data}) : helper))) + + "\n\n"; +},"useData":true}); })(); \ No newline at end of file diff --git a/apps/files/js/templates/template_addbutton.handlebars b/apps/files/js/templates/template_addbutton.handlebars new file mode 100644 index 0000000000..62a022715a --- /dev/null +++ b/apps/files/js/templates/template_addbutton.handlebars @@ -0,0 +1,4 @@ + + + {{addText}} + From a0368608f0fd3d3d1b6107d6826cf78bc5fbabee Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 1 Oct 2018 18:55:08 +0200 Subject: [PATCH 02/12] Move systemtagsinfoviewtoggleview away from handlebars Signed-off-by: Roeland Jago Douma --- apps/systemtags/js/systemtagsinfoviewtoggleview.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/apps/systemtags/js/systemtagsinfoviewtoggleview.js b/apps/systemtags/js/systemtagsinfoviewtoggleview.js index 13a48e49cf..a3261e7994 100644 --- a/apps/systemtags/js/systemtagsinfoviewtoggleview.js +++ b/apps/systemtags/js/systemtagsinfoviewtoggleview.js @@ -21,9 +21,6 @@ (function(OCA) { - var TEMPLATE = - '' + t('systemtags', 'Tags'); - /** * @class OCA.SystemTags.SystemTagsInfoViewToggleView * @classdesc @@ -49,10 +46,7 @@ _systemTagsInfoView: null, template: function(data) { - if (!this._template) { - this._template = Handlebars.compile(TEMPLATE); - } - return this._template(data); + return '' + t('systemtags', 'Tags'); }, /** From 187953153a76e67d4ffa7b3f5af4169665b5d653 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 1 Oct 2018 18:58:12 +0200 Subject: [PATCH 03/12] Move detailsview to compiled handlebars Signed-off-by: Roeland Jago Douma --- apps/files/js/detailsview.js | 23 +------------------ apps/files/js/templates.js | 23 +++++++++++++++++++ .../files/js/templates/detailsview.handlebars | 12 ++++++++++ 3 files changed, 36 insertions(+), 22 deletions(-) create mode 100644 apps/files/js/templates/detailsview.handlebars diff --git a/apps/files/js/detailsview.js b/apps/files/js/detailsview.js index aed1736693..2a5d589a73 100644 --- a/apps/files/js/detailsview.js +++ b/apps/files/js/detailsview.js @@ -9,22 +9,6 @@ */ (function() { - var TEMPLATE = - '
' + - '
' + - ' {{#if tabHeaders}}' + - '
    ' + - ' {{#each tabHeaders}}' + - '
  • ' + - ' {{label}}' + - '
  • ' + - ' {{/each}}' + - '
' + - ' {{/if}}' + - '
' + - '
' + - ' {{closeLabel}}'; - /** * @class OCA.Files.DetailsView * @classdesc @@ -37,8 +21,6 @@ tabName: 'div', className: 'detailsView scroll-container', - _template: null, - /** * List of detail tab views * @@ -107,10 +89,7 @@ }, template: function(vars) { - if (!this._template) { - this._template = Handlebars.compile(TEMPLATE); - } - return this._template(vars); + return OCA.Files.Templates['detailsview'](vars); }, /** diff --git a/apps/files/js/templates.js b/apps/files/js/templates.js index 9e93d5b5ac..4b78ffc8c9 100644 --- a/apps/files/js/templates.js +++ b/apps/files/js/templates.js @@ -1,5 +1,28 @@ (function() { var template = Handlebars.template, templates = OCA.Files.Templates = OCA.Files.Templates || {}; +templates['detailsview'] = template({"1":function(container,depth0,helpers,partials,data) { + var stack1; + + return "
    \n" + + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.tabHeaders : depth0),{"name":"each","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "
\n"; +},"2":function(container,depth0,helpers,partials,data) { + var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return "
  • \n " + + alias4(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"label","hash":{},"data":data}) : helper))) + + "\n
  • \n"; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}); + + return "
    \n" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.tabHeaders : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "
    \n" + + container.escapeExpression(((helper = (helper = helpers.closeLabel || (depth0 != null ? depth0.closeLabel : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(alias1,{"name":"closeLabel","hash":{},"data":data}) : helper))) + + "\n"; +},"useData":true}); templates['filemultiselectmenu'] = 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; diff --git a/apps/files/js/templates/detailsview.handlebars b/apps/files/js/templates/detailsview.handlebars new file mode 100644 index 0000000000..841a8fe25f --- /dev/null +++ b/apps/files/js/templates/detailsview.handlebars @@ -0,0 +1,12 @@ +
    +{{#if tabHeaders}} +
      + {{#each tabHeaders}} +
    • + {{label}} +
    • + {{/each}} +
    +{{/if}} +
    +{{closeLabel}} From d281f2625d0896f9231d0987f7a752c01e73e6b6 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 1 Oct 2018 19:11:22 +0200 Subject: [PATCH 04/12] Move Comments to compiled handlebars Signed-off-by: Roeland Jago Douma --- apps/comments/js/commentstabview.js | 59 +------------ apps/comments/js/merged.json | 1 + apps/comments/js/templates.js | 87 +++++++++++++++++++ apps/comments/js/templates/comment.handlebars | 15 ++++ .../js/templates/edit_comment.handlebars | 16 ++++ apps/comments/js/templates/view.handlebars | 6 ++ build/compile-handlebars-templates.sh | 4 + tests/karma.config.js | 1 + 8 files changed, 133 insertions(+), 56 deletions(-) create mode 100644 apps/comments/js/templates.js create mode 100644 apps/comments/js/templates/comment.handlebars create mode 100644 apps/comments/js/templates/edit_comment.handlebars create mode 100644 apps/comments/js/templates/view.handlebars diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js index 28382c8b67..35e73d3f4a 100644 --- a/apps/comments/js/commentstabview.js +++ b/apps/comments/js/commentstabview.js @@ -11,49 +11,6 @@ /* global Handlebars, escapeHTML */ (function(OC, OCA) { - var TEMPLATE = - '
      ' + - '
    ' + - '' + - '' + - ''; - - var EDIT_COMMENT_TEMPLATE = - '<{{tag}} class="newCommentRow comment" data-id="{{id}}">' + - '
    ' + - '
    ' + - '
    {{actorDisplayName}}
    ' + - '{{#if isEditMode}}' + - '
    ' + - ' ' + - '
    ' + - '{{/if}}' + - '
    ' + - '
    ' + - '
    {{message}}
    ' + - ' ' + - ' '+ - '
    ' + - ''; - - var COMMENT_TEMPLATE = - '
  • ' + - '
    ' + - '
    ' + - '
    {{actorDisplayName}}
    ' + - '{{#if isUserAuthor}}' + - ' ' + - ' ' + - '{{/if}}' + - '
    {{date}}
    ' + - '
    ' + - '
    {{{formattedMessage}}}
    ' + - '{{#if isLong}}' + - '
    ' + - '{{/if}}' + - '
  • '; /** * @memberof OCA.Comments @@ -93,22 +50,16 @@ }, template: function(params) { - if (!this._template) { - this._template = Handlebars.compile(TEMPLATE); - } var currentUser = OC.getCurrentUser(); - return this._template(_.extend({ + return OCA.Comments.Templates['view'](_.extend({ actorId: currentUser.uid, actorDisplayName: currentUser.displayName }, params)); }, editCommentTemplate: function(params) { - if (!this._editCommentTemplate) { - this._editCommentTemplate = Handlebars.compile(EDIT_COMMENT_TEMPLATE); - } var currentUser = OC.getCurrentUser(); - return this._editCommentTemplate(_.extend({ + return OCA.Comments.Templates['edit_comment'](_.extend({ actorId: currentUser.uid, actorDisplayName: currentUser.displayName, newMessagePlaceholder: t('comments', 'New comment …'), @@ -119,10 +70,6 @@ }, commentTemplate: function(params) { - if (!this._commentTemplate) { - this._commentTemplate = Handlebars.compile(COMMENT_TEMPLATE); - } - params = _.extend({ editTooltip: t('comments', 'Edit comment'), isUserAuthor: OC.getCurrentUser().uid === params.actorId, @@ -135,7 +82,7 @@ params.actorDisplayName = t('comments', '[Deleted user]'); } - return this._commentTemplate(params); + return OCA.Comments.Templates['comment'](params); }, getLabel: function() { diff --git a/apps/comments/js/merged.json b/apps/comments/js/merged.json index d5b2b88233..8f40b5621a 100644 --- a/apps/comments/js/merged.json +++ b/apps/comments/js/merged.json @@ -1,5 +1,6 @@ [ "app.js", + "templates.js", "commentmodel.js", "commentcollection.js", "commentsummarymodel.js", diff --git a/apps/comments/js/templates.js b/apps/comments/js/templates.js new file mode 100644 index 0000000000..90ded7fe4e --- /dev/null +++ b/apps/comments/js/templates.js @@ -0,0 +1,87 @@ +(function() { + var template = Handlebars.template, templates = OCA.Comments.Templates = OCA.Comments.Templates || {}; +templates['comment'] = template({"1":function(container,depth0,helpers,partials,data) { + return " unread"; +},"3":function(container,depth0,helpers,partials,data) { + return " collapsed"; +},"5":function(container,depth0,helpers,partials,data) { + return " currentUser"; +},"7":function(container,depth0,helpers,partials,data) { + var helper; + + return "data-username=\"" + + container.escapeExpression(((helper = (helper = helpers.actorId || (depth0 != null ? depth0.actorId : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"actorId","hash":{},"data":data}) : helper))) + + "\""; +},"9":function(container,depth0,helpers,partials,data) { + return " \n
    \n"; +},"11":function(container,depth0,helpers,partials,data) { + return "
    \n"; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return "
  • \n
    \n
    \n
    " + + alias4(((helper = (helper = helpers.actorDisplayName || (depth0 != null ? depth0.actorDisplayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"actorDisplayName","hash":{},"data":data}) : helper))) + + "
    \n" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isUserAuthor : depth0),{"name":"if","hash":{},"fn":container.program(9, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "
    " + + alias4(((helper = (helper = helpers.date || (depth0 != null ? depth0.date : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"date","hash":{},"data":data}) : helper))) + + "
    \n
    \n
    " + + ((stack1 = ((helper = (helper = helpers.formattedMessage || (depth0 != null ? depth0.formattedMessage : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"formattedMessage","hash":{},"data":data}) : helper))) != null ? stack1 : "") + + "
    \n" + + ((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 : "") + + "
  • \n"; +},"useData":true}); +templates['edit_comment'] = template({"1":function(container,depth0,helpers,partials,data) { + var helper; + + return "
    \n \n
    \n"; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return "<" + + 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))) + + " class=\"newCommentRow comment\" data-id=\"" + + alias4(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"id","hash":{},"data":data}) : helper))) + + "\">\n
    \n
    \n
    " + + alias4(((helper = (helper = helpers.actorDisplayName || (depth0 != null ? depth0.actorDisplayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"actorDisplayName","hash":{},"data":data}) : helper))) + + "
    \n" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isEditMode : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "
    \n
    \n
    " + + alias4(((helper = (helper = helpers.message || (depth0 != null ? depth0.message : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"message","hash":{},"data":data}) : helper))) + + "
    \n \n
    '+\n
    \n'\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; + + return "
      \n
    \n
    \n

    " + + 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))) + + "

    \n\n
    '\n"; +},"useData":true}); +})(); \ No newline at end of file diff --git a/apps/comments/js/templates/comment.handlebars b/apps/comments/js/templates/comment.handlebars new file mode 100644 index 0000000000..c1a1091a4e --- /dev/null +++ b/apps/comments/js/templates/comment.handlebars @@ -0,0 +1,15 @@ +
  • +
    +
    +
    {{actorDisplayName}}
    + {{#if isUserAuthor}} + + + {{/if}} +
    {{date}}
    +
    +
    {{{formattedMessage}}}
    + {{#if isLong}} +
    + {{/if}} +
  • diff --git a/apps/comments/js/templates/edit_comment.handlebars b/apps/comments/js/templates/edit_comment.handlebars new file mode 100644 index 0000000000..05f89ec598 --- /dev/null +++ b/apps/comments/js/templates/edit_comment.handlebars @@ -0,0 +1,16 @@ +<{{tag}} class="newCommentRow comment" data-id="{{id}}"> +
    +
    +
    {{actorDisplayName}}
    + {{#if isEditMode}} +
    + +
    + {{/if}} +
    +
    +
    {{message}}
    + + '+ +
    +' diff --git a/apps/comments/js/templates/view.handlebars b/apps/comments/js/templates/view.handlebars new file mode 100644 index 0000000000..5f52a42861 --- /dev/null +++ b/apps/comments/js/templates/view.handlebars @@ -0,0 +1,6 @@ +
      +
    + + +' diff --git a/build/compile-handlebars-templates.sh b/build/compile-handlebars-templates.sh index 585406c4e8..8dc0e0397a 100755 --- a/build/compile-handlebars-templates.sh +++ b/build/compile-handlebars-templates.sh @@ -13,6 +13,10 @@ handlebars -n OC.ContactsMenu.Templates core/js/contactsmenu -f core/js/contacts # Files app handlebars -n OCA.Files.Templates apps/files/js/templates -f apps/files/js/templates.js +# Comments app +handlebars -n OCA.Comments.Templates apps/comments/js/templates -f apps/comments/js/templates.js + + if [[ $(git diff --name-only) ]]; then echo "Please submit your compiled handlebars templates" echo diff --git a/tests/karma.config.js b/tests/karma.config.js index 0fd9b7b801..93b7b4113f 100644 --- a/tests/karma.config.js +++ b/tests/karma.config.js @@ -87,6 +87,7 @@ module.exports = function(config) { srcFiles: [ // need to enforce loading order... 'apps/comments/js/app.js', + 'apps/comments/js/templates.js', 'apps/comments/js/vendor/Caret.js/dist/jquery.caret.min.js', 'apps/comments/js/vendor/At.js/dist/js/jquery.atwho.min.js', 'apps/comments/js/commentmodel.js', From cd7c17482ee9c166daedad14e6bac304de61c9b5 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 1 Oct 2018 19:20:32 +0200 Subject: [PATCH 05/12] Move systemtags to compiled handlebars Signed-off-by: Roeland Jago Douma --- build/compile-handlebars-templates.sh | 3 + core/js/core.json | 1 + core/js/systemtags/merged.json | 1 + core/js/systemtags/systemtagsinputfield.js | 53 +------------ core/js/systemtags/templates.js | 74 +++++++++++++++++++ .../js/systemtags/templates/result.handlebars | 13 ++++ .../templates/result_form.handlebars | 7 ++ .../systemtags/templates/selection.handlebars | 5 ++ 8 files changed, 108 insertions(+), 49 deletions(-) create mode 100644 core/js/systemtags/templates.js create mode 100644 core/js/systemtags/templates/result.handlebars create mode 100644 core/js/systemtags/templates/result_form.handlebars create mode 100644 core/js/systemtags/templates/selection.handlebars diff --git a/build/compile-handlebars-templates.sh b/build/compile-handlebars-templates.sh index 8dc0e0397a..96080d12ec 100755 --- a/build/compile-handlebars-templates.sh +++ b/build/compile-handlebars-templates.sh @@ -10,6 +10,9 @@ handlebars -n OC.Settings.Templates settings/js/authtoken.handlebars -f setting # Contactsmenu handlebars -n OC.ContactsMenu.Templates core/js/contactsmenu -f core/js/contactsmenu_templates.js +# Systemtags +handlebars -n OC.SystemTags.Templates core/js/systemtags/templates -f core/js/systemtags/templates.js + # Files app handlebars -n OCA.Files.Templates apps/files/js/templates -f apps/files/js/templates.js diff --git a/core/js/core.json b/core/js/core.json index 19f361d2df..161e4766f3 100644 --- a/core/js/core.json +++ b/core/js/core.json @@ -58,6 +58,7 @@ "files/fileinfo.js", "files/client.js", "systemtags/systemtags.js", + "systemtags/templates.js", "systemtags/systemtagmodel.js", "systemtags/systemtagscollection.js", "systemtags/systemtagsmappingcollection.js", diff --git a/core/js/systemtags/merged.json b/core/js/systemtags/merged.json index 846ba967ed..641858ee2e 100644 --- a/core/js/systemtags/merged.json +++ b/core/js/systemtags/merged.json @@ -1,5 +1,6 @@ [ "systemtags.js", + "templates.js", "systemtagmodel.js", "systemtagsmappingcollection.js", "systemtagscollection.js", diff --git a/core/js/systemtags/systemtagsinputfield.js b/core/js/systemtags/systemtagsinputfield.js index ba72d48620..82fd659c72 100644 --- a/core/js/systemtags/systemtagsinputfield.js +++ b/core/js/systemtags/systemtagsinputfield.js @@ -11,39 +11,6 @@ /* global Handlebars */ (function(OC) { - var TEMPLATE = - ''; - - var RESULT_TEMPLATE = - '' + - ' ' + - '{{#if isAdmin}}' + - ' {{{tagMarkup}}}' + - '{{else}}' + - ' {{name}}' + - '{{/if}}' + - '{{#allowActions}}' + - ' ' + - ' ' + - ' ' + - '{{/allowActions}}' + - ''; - - var SELECTION_TEMPLATE = - '{{#if isAdmin}}' + - ' {{{tagMarkup}}}' + - '{{else}}' + - ' {{name}}' + - '{{/if}}'; - - var RENAME_FORM_TEMPLATE = - '
    ' + - ' ' + - ' ' + - ' {{#if isAdmin}}' + - ' ' + - ' {{/if}}' + - '
    '; /** * @class OC.SystemTags.SystemTagsInputField @@ -64,10 +31,7 @@ className: 'systemTagsInputFieldContainer', template: function(data) { - if (!this._template) { - this._template = Handlebars.compile(TEMPLATE); - } - return this._template(data); + return ''; }, /** @@ -141,12 +105,9 @@ var $item = $(ev.target).closest('.systemtags-item'); var tagId = $item.attr('data-id'); var tagModel = this.collection.get(tagId); - if (!this._renameFormTemplate) { - this._renameFormTemplate = Handlebars.compile(RENAME_FORM_TEMPLATE); - } var oldName = tagModel.get('name'); - var $renameForm = $(this._renameFormTemplate({ + var $renameForm = $(OC.SystemTags.Templates['result_form']({ cid: this.cid, name: oldName, deleteTooltip: t('core', 'Delete'), @@ -310,10 +271,7 @@ * @return {string} HTML markup */ _formatDropDownResult: function(data) { - if (!this._resultTemplate) { - this._resultTemplate = Handlebars.compile(RESULT_TEMPLATE); - } - return this._resultTemplate(_.extend({ + return OC.SystemTags.Templates['result'](_.extend({ renameTooltip: t('core', 'Rename'), allowActions: this._allowActions, tagMarkup: this._isAdmin ? OC.SystemTags.getDescriptiveTag(data)[0].innerHTML : null, @@ -328,10 +286,7 @@ * @return {string} HTML markup */ _formatSelection: function(data) { - if (!this._selectionTemplate) { - this._selectionTemplate = Handlebars.compile(SELECTION_TEMPLATE); - } - return this._selectionTemplate(_.extend({ + return OC.SystemTags.Templates['selection'](_.extend({ tagMarkup: this._isAdmin ? OC.SystemTags.getDescriptiveTag(data)[0].innerHTML : null, isAdmin: this._isAdmin }, data)); diff --git a/core/js/systemtags/templates.js b/core/js/systemtags/templates.js new file mode 100644 index 0000000000..0894d64682 --- /dev/null +++ b/core/js/systemtags/templates.js @@ -0,0 +1,74 @@ +(function() { + var template = Handlebars.template, templates = OC.SystemTags.Templates = OC.SystemTags.Templates || {}; +templates['result'] = template({"1":function(container,depth0,helpers,partials,data) { + return " new-item"; +},"3":function(container,depth0,helpers,partials,data) { + var stack1, helper; + + return " " + + ((stack1 = ((helper = (helper = helpers.tagMarkup || (depth0 != null ? depth0.tagMarkup : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"tagMarkup","hash":{},"data":data}) : helper))) != null ? stack1 : "") + + "\n"; +},"5":function(container,depth0,helpers,partials,data) { + var helper; + + return " " + + container.escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"name","hash":{},"data":data}) : helper))) + + "\n"; +},"7":function(container,depth0,helpers,partials,data) { + var helper; + + return " \n \n \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", buffer = + "\n\n" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isAdmin : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.program(5, data, 0),"data":data})) != null ? stack1 : ""); + stack1 = ((helper = (helper = helpers.allowActions || (depth0 != null ? depth0.allowActions : depth0)) != null ? helper : alias2),(options={"name":"allowActions","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data}),(typeof helper === alias3 ? helper.call(alias1,options) : helper)); + if (!helpers.allowActions) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)} + if (stack1 != null) { buffer += stack1; } + return buffer + "';\n"; +},"useData":true}); +templates['result_form'] = template({"1":function(container,depth0,helpers,partials,data) { + var helper; + + return " \n"; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return "
    \n \n \n" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isAdmin : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "
    \n"; +},"useData":true}); +templates['selection'] = template({"1":function(container,depth0,helpers,partials,data) { + var stack1, helper; + + return " " + + ((stack1 = ((helper = (helper = helpers.tagMarkup || (depth0 != null ? depth0.tagMarkup : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"tagMarkup","hash":{},"data":data}) : helper))) != null ? stack1 : "") + + "\n"; +},"3":function(container,depth0,helpers,partials,data) { + var helper; + + return " " + + container.escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"name","hash":{},"data":data}) : helper))) + + "\n"; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1; + + return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.isAdmin : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.program(3, data, 0),"data":data})) != null ? stack1 : ""); +},"useData":true}); +})(); \ No newline at end of file diff --git a/core/js/systemtags/templates/result.handlebars b/core/js/systemtags/templates/result.handlebars new file mode 100644 index 0000000000..ce69c8a21f --- /dev/null +++ b/core/js/systemtags/templates/result.handlebars @@ -0,0 +1,13 @@ + + + {{#if isAdmin}} + {{{tagMarkup}}} + {{else}} + {{name}} + {{/if}} + {{#allowActions}} + + + + {{/allowActions}} +'; diff --git a/core/js/systemtags/templates/result_form.handlebars b/core/js/systemtags/templates/result_form.handlebars new file mode 100644 index 0000000000..28fe8c56fe --- /dev/null +++ b/core/js/systemtags/templates/result_form.handlebars @@ -0,0 +1,7 @@ +
    + + + {{#if isAdmin}} + + {{/if}} +
    diff --git a/core/js/systemtags/templates/selection.handlebars b/core/js/systemtags/templates/selection.handlebars new file mode 100644 index 0000000000..b006b12974 --- /dev/null +++ b/core/js/systemtags/templates/selection.handlebars @@ -0,0 +1,5 @@ +{{#if isAdmin}} + {{{tagMarkup}}} +{{else}} + {{name}} +{{/if}} From 8dfc397a5ed839b9f2665c8cd19ded20b44a22f4 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 1 Oct 2018 19:23:40 +0200 Subject: [PATCH 06/12] Move tagsplugin to compiled handlebars Signed-off-by: Roeland Jago Douma --- apps/files/js/tagsplugin.js | 12 +----------- apps/files/js/templates.js | 14 ++++++++++++++ apps/files/js/templates/favorite_mark.handlebars | 4 ++++ 3 files changed, 19 insertions(+), 11 deletions(-) create mode 100644 apps/files/js/templates/favorite_mark.handlebars diff --git a/apps/files/js/tagsplugin.js b/apps/files/js/tagsplugin.js index 4ce6604384..b8e17115b4 100644 --- a/apps/files/js/tagsplugin.js +++ b/apps/files/js/tagsplugin.js @@ -17,13 +17,6 @@ PROPERTY_FAVORITE: '{' + OC.Files.Client.NS_OWNCLOUD + '}favorite' }); - var TEMPLATE_FAVORITE_MARK = - '
    ' + - '' + - '{{altText}}' + - '
    '; - /** * Returns the icon class for the matching state * @@ -41,10 +34,7 @@ * @return {Object} jQuery object */ function renderStar (state) { - if (!this._template) { - this._template = Handlebars.compile(TEMPLATE_FAVORITE_MARK); - } - return this._template({ + return OCA.Files.Templates['favorite_mark']({ isFavorite: state, altText: state ? t('files', 'Favorited') : t('files', 'Not favorited'), iconClass: getStarIconClass(state) diff --git a/apps/files/js/templates.js b/apps/files/js/templates.js index 4b78ffc8c9..4cbd326bac 100644 --- a/apps/files/js/templates.js +++ b/apps/files/js/templates.js @@ -23,6 +23,20 @@ templates['detailsview'] = template({"1":function(container,depth0,helpers,parti + container.escapeExpression(((helper = (helper = helpers.closeLabel || (depth0 != null ? depth0.closeLabel : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(alias1,{"name":"closeLabel","hash":{},"data":data}) : helper))) + "
    \n"; },"useData":true}); +templates['favorite_mark'] = template({"1":function(container,depth0,helpers,partials,data) { + return "permanent"; +},"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, buffer = + "
    \n \n " + + alias4(((helper = (helper = helpers.altText || (depth0 != null ? depth0.altText : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"altText","hash":{},"data":data}) : helper))) + + "\n
    \n"; +},"useData":true}); templates['filemultiselectmenu'] = 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; diff --git a/apps/files/js/templates/favorite_mark.handlebars b/apps/files/js/templates/favorite_mark.handlebars new file mode 100644 index 0000000000..7e0cb4385a --- /dev/null +++ b/apps/files/js/templates/favorite_mark.handlebars @@ -0,0 +1,4 @@ +
    + + {{altText}} +
    From 6f940a9b02bca9e388640c45b928ebedb6eca153 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 1 Oct 2018 20:04:13 +0200 Subject: [PATCH 07/12] Move fileactions to compiled handlebars Signed-off-by: Roeland Jago Douma --- apps/files/js/fileactions.js | 17 +------ apps/files/js/templates.js | 44 +++++++++++++++++++ .../templates/file_action_trigger.handlebars | 13 ++++++ 3 files changed, 58 insertions(+), 16 deletions(-) create mode 100644 apps/files/js/templates/file_action_trigger.handlebars diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js index 4fcb290ca8..5af558d77b 100644 --- a/apps/files/js/fileactions.js +++ b/apps/files/js/fileactions.js @@ -10,17 +10,6 @@ (function() { - var TEMPLATE_FILE_ACTION_TRIGGER = - '' + - '{{#if icon}}' + - '{{altText}}' + - '{{else}}' + - '{{#if iconClass}}{{/if}}' + - '{{#unless hasDisplayName}}{{altText}}{{/unless}}' + - '{{/if}}' + - '{{#if displayName}} {{displayName}}{{/if}}' + - ''; - /** * Construct a new FileActions instance * @constructs FileActions @@ -335,11 +324,7 @@ * @param {Object} params action params */ _makeActionLink: function(params) { - if (!this._fileActionTriggerTemplate) { - this._fileActionTriggerTemplate = Handlebars.compile(TEMPLATE_FILE_ACTION_TRIGGER); - } - - return $(this._fileActionTriggerTemplate(params)); + return $(OCA.Files.Templates['file_action_trigger'](params)); }, /** diff --git a/apps/files/js/templates.js b/apps/files/js/templates.js index 4cbd326bac..ac36f0098a 100644 --- a/apps/files/js/templates.js +++ b/apps/files/js/templates.js @@ -37,6 +37,50 @@ templates['favorite_mark'] = template({"1":function(container,depth0,helpers,par + alias4(((helper = (helper = helpers.altText || (depth0 != null ? depth0.altText : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"altText","hash":{},"data":data}) : helper))) + "
    \n\n"; },"useData":true}); +templates['file_action_trigger'] = 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 " \""\n"; +},"3":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {}); + + return ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.iconClass : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers.unless.call(alias1,(depth0 != null ? depth0.hasDisplayName : depth0),{"name":"unless","hash":{},"fn":container.program(6, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : ""); +},"4":function(container,depth0,helpers,partials,data) { + var helper; + + return " \n"; +},"6":function(container,depth0,helpers,partials,data) { + var helper; + + return " " + + container.escapeExpression(((helper = (helper = helpers.altText || (depth0 != null ? depth0.altText : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"altText","hash":{},"data":data}) : helper))) + + "\n"; +},"8":function(container,depth0,helpers,partials,data) { + var helper; + + return " " + + container.escapeExpression(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"displayName","hash":{},"data":data}) : helper))) + + ""; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return "\n" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.icon : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.program(3, data, 0),"data":data})) != null ? stack1 : "") + + " " + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.displayName : depth0),{"name":"if","hash":{},"fn":container.program(8, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "\n\n"; +},"useData":true}); templates['filemultiselectmenu'] = 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; diff --git a/apps/files/js/templates/file_action_trigger.handlebars b/apps/files/js/templates/file_action_trigger.handlebars new file mode 100644 index 0000000000..d7112ee2b2 --- /dev/null +++ b/apps/files/js/templates/file_action_trigger.handlebars @@ -0,0 +1,13 @@ + + {{#if icon}} + {{altText}} + {{else}} + {{#if iconClass}} + + {{/if}} + {{#unless hasDisplayName}} + {{altText}} + {{/unless}} + {{/if}} + {{#if displayName}} {{displayName}}{{/if}} + From fca9987a6ad890d3b3e7854fae157f51fac54ed8 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 1 Oct 2018 20:07:09 +0200 Subject: [PATCH 08/12] Move mainfileinfodetailsview to commpiled handlebars Signed-off-by: Roeland Jago Douma --- apps/files/js/mainfileinfodetailview.js | 28 +---------- apps/files/js/templates.js | 47 +++++++++++++++++++ .../mainfileinfodetailsview.handlebars | 21 +++++++++ 3 files changed, 69 insertions(+), 27 deletions(-) create mode 100644 apps/files/js/templates/mainfileinfodetailsview.handlebars diff --git a/apps/files/js/mainfileinfodetailview.js b/apps/files/js/mainfileinfodetailview.js index 626ab86ded..82860780d3 100644 --- a/apps/files/js/mainfileinfodetailview.js +++ b/apps/files/js/mainfileinfodetailview.js @@ -9,29 +9,6 @@ */ (function() { - var TEMPLATE = - '
    ' + - '
    ' + - '
    ' + - '

    {{name}}

    ' + - '' + - '
    ' + - '
    ' + - ' {{#if hasFavoriteAction}}' + - ' ' + - ' ' + - ' ' + - ' {{/if}}' + - ' {{#if hasSize}}{{size}}, {{/if}}{{date}}' + - '
    ' + - '
    ' + - ''; - /** * @class OCA.Files.MainFileInfoDetailView * @classdesc @@ -71,10 +48,7 @@ }, template: function(data) { - if (!this._template) { - this._template = Handlebars.compile(TEMPLATE); - } - return this._template(data); + return OCA.Files.Templates['mainfileinfodetailsview'](data); }, initialize: function(options) { diff --git a/apps/files/js/templates.js b/apps/files/js/templates.js index ac36f0098a..c5522d8407 100644 --- a/apps/files/js/templates.js +++ b/apps/files/js/templates.js @@ -117,6 +117,53 @@ templates['filesummary'] = template({"compiler":[7,">= 4.0.0"],"main":function(c + container.escapeExpression(((helper = (helper = helpers.connectorLabel || (depth0 != null ? depth0.connectorLabel : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"connectorLabel","hash":{},"data":data}) : helper))) + "\n \n \n \n\n"; },"useData":true}); +templates['mainfileinfodetailsview'] = 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 " \n \n \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 "" + + alias4(((helper = (helper = helpers.size || (depth0 != null ? depth0.size : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"size","hash":{},"data":data}) : helper))) + + ", "; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return "
    \n
    \n
    \n

    " + + 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 \n \n " + + alias4(((helper = (helper = helpers.permalinkTitle || (depth0 != null ? depth0.permalinkTitle : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"permalinkTitle","hash":{},"data":data}) : helper))) + + "\n \n
    \n
    \n" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.hasFavoriteAction : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + " " + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.hasSize : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "" + + alias4(((helper = (helper = helpers.date || (depth0 != null ? depth0.date : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"date","hash":{},"data":data}) : helper))) + + "\n
    \n
    \n
    \n \n
    \n"; +},"useData":true}); templates['template_addbutton'] = 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/files/js/templates/mainfileinfodetailsview.handlebars b/apps/files/js/templates/mainfileinfodetailsview.handlebars new file mode 100644 index 0000000000..02a4cdb641 --- /dev/null +++ b/apps/files/js/templates/mainfileinfodetailsview.handlebars @@ -0,0 +1,21 @@ +
    +
    + +
    + {{#if hasFavoriteAction}} + + + + {{/if}} + {{#if hasSize}}{{size}}, {{/if}}{{date}} +
    +
    + From b10cddebe583dff888d844c550f607d52b496d49 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 1 Oct 2018 20:08:49 +0200 Subject: [PATCH 09/12] Move sharetabview to compiled handlebars Signed-off-by: Roeland Jago Douma --- apps/files_sharing/js/sharetabview.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/apps/files_sharing/js/sharetabview.js b/apps/files_sharing/js/sharetabview.js index 7bb1f1229d..fc7f2c5f04 100644 --- a/apps/files_sharing/js/sharetabview.js +++ b/apps/files_sharing/js/sharetabview.js @@ -25,10 +25,7 @@ className: 'tab shareTabView', template: function(params) { - if (!this._template) { - this._template = Handlebars.compile(TEMPLATE); - } - return this._template(params); + return TEMPLATE; }, getLabel: function() { From b0fd31496b5edb95264c0ea3139692b5969f40e0 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 1 Oct 2018 20:46:29 +0200 Subject: [PATCH 10/12] Move OC.Share to compiled handlebars Signed-off-by: Roeland Jago Douma --- build/compile-handlebars-templates.sh | 3 + core/js/core.json | 1 + core/js/merged-share-backend.json | 1 + .../share/sharedialoglinkshareview.handlebars | 25 + ...ialoglinkshareview_popover_menu.handlebars | 96 +++ ...kshareview_popover_menu_pending.handlebars | 14 + .../sharedialogresharerinfoview.handlebars | 5 + .../sharedialogshareelistview.handlebars | 28 + ...alogshareelistview_popover_menu.handlebars | 106 +++ core/js/share/sharedialogview.handlebars | 12 + core/js/sharedialoglinkshareview.js | 156 +---- core/js/sharedialogresharerinfoview.js | 13 +- core/js/sharedialogshareelistview.js | 156 +---- core/js/sharedialogview.js | 30 +- core/js/sharetemplates.js | 629 ++++++++++++++++++ 15 files changed, 927 insertions(+), 348 deletions(-) create mode 100644 core/js/share/sharedialoglinkshareview.handlebars create mode 100644 core/js/share/sharedialoglinkshareview_popover_menu.handlebars create mode 100644 core/js/share/sharedialoglinkshareview_popover_menu_pending.handlebars create mode 100644 core/js/share/sharedialogresharerinfoview.handlebars create mode 100644 core/js/share/sharedialogshareelistview.handlebars create mode 100644 core/js/share/sharedialogshareelistview_popover_menu.handlebars create mode 100644 core/js/share/sharedialogview.handlebars create mode 100644 core/js/sharetemplates.js diff --git a/build/compile-handlebars-templates.sh b/build/compile-handlebars-templates.sh index 96080d12ec..a3463a04ea 100755 --- a/build/compile-handlebars-templates.sh +++ b/build/compile-handlebars-templates.sh @@ -13,6 +13,9 @@ handlebars -n OC.ContactsMenu.Templates core/js/contactsmenu -f core/js/contacts # Systemtags handlebars -n OC.SystemTags.Templates core/js/systemtags/templates -f core/js/systemtags/templates.js +# Share +handlebars -n OC.Share.Templates core/js/share -f core/js/sharetemplates.js + # Files app handlebars -n OCA.Files.Templates apps/files/js/templates -f apps/files/js/templates.js diff --git a/core/js/core.json b/core/js/core.json index 161e4766f3..12249d4dba 100644 --- a/core/js/core.json +++ b/core/js/core.json @@ -33,6 +33,7 @@ "l10n.js", "apps.js", "share.js", + "sharetemplates.js", "sharesocialmanager.js", "shareconfigmodel.js", "shareitemmodel.js", diff --git a/core/js/merged-share-backend.json b/core/js/merged-share-backend.json index 63c3575a66..8d67d9309c 100644 --- a/core/js/merged-share-backend.json +++ b/core/js/merged-share-backend.json @@ -1,5 +1,6 @@ [ "shareconfigmodel.js", + "sharetemplates.js", "shareitemmodel.js", "sharesocialmanager.js", "sharedialogresharerinfoview.js", diff --git a/core/js/share/sharedialoglinkshareview.handlebars b/core/js/share/sharedialoglinkshareview.handlebars new file mode 100644 index 0000000000..e0787cc7d3 --- /dev/null +++ b/core/js/share/sharedialoglinkshareview.handlebars @@ -0,0 +1,25 @@ +{{#if shareAllowed}} + +{{else}} +{{#if noSharingPlaceholder}}{{/if}} +{{/if}}' diff --git a/core/js/share/sharedialoglinkshareview_popover_menu.handlebars b/core/js/share/sharedialoglinkshareview_popover_menu.handlebars new file mode 100644 index 0000000000..412ed8efca --- /dev/null +++ b/core/js/share/sharedialoglinkshareview_popover_menu.handlebars @@ -0,0 +1,96 @@ + diff --git a/core/js/share/sharedialoglinkshareview_popover_menu_pending.handlebars b/core/js/share/sharedialoglinkshareview_popover_menu_pending.handlebars new file mode 100644 index 0000000000..e39c082315 --- /dev/null +++ b/core/js/share/sharedialoglinkshareview_popover_menu_pending.handlebars @@ -0,0 +1,14 @@ + diff --git a/core/js/share/sharedialogresharerinfoview.handlebars b/core/js/share/sharedialogresharerinfoview.handlebars new file mode 100644 index 0000000000..e2cfa13da9 --- /dev/null +++ b/core/js/share/sharedialogresharerinfoview.handlebars @@ -0,0 +1,5 @@ + +
    + {{sharedByText}} +
    ' + +{{#if hasShareNote}}{{/if}} diff --git a/core/js/share/sharedialogshareelistview.handlebars b/core/js/share/sharedialogshareelistview.handlebars new file mode 100644 index 0000000000..ba9aa6e510 --- /dev/null +++ b/core/js/share/sharedialogshareelistview.handlebars @@ -0,0 +1,28 @@ +
      + {{#each sharees}} +
    • +
      + {{shareWithDisplayName}} + + {{#if editPermissionPossible}} + + + + + {{/if}} + + +
    • + {{/each}} + {{#each linkReshares}} +
    • +
      + t('core', '{{shareInitiatorDisplayName}} shared via link') + ' + + {{unshareLabel}} + +
    • + {{/each}} +
    diff --git a/core/js/share/sharedialogshareelistview_popover_menu.handlebars b/core/js/share/sharedialogshareelistview_popover_menu.handlebars new file mode 100644 index 0000000000..c135d31b08 --- /dev/null +++ b/core/js/share/sharedialogshareelistview_popover_menu.handlebars @@ -0,0 +1,106 @@ + diff --git a/core/js/share/sharedialogview.handlebars b/core/js/share/sharedialogview.handlebars new file mode 100644 index 0000000000..d364be901a --- /dev/null +++ b/core/js/share/sharedialogview.handlebars @@ -0,0 +1,12 @@ +
    +{{#if isSharingAllowed}} + +
    + + '+ + +
    +{{/if}} +
    +
    +'; diff --git a/core/js/sharedialoglinkshareview.js b/core/js/sharedialoglinkshareview.js index 9cd48aaf9a..995ff480aa 100644 --- a/core/js/sharedialoglinkshareview.js +++ b/core/js/sharedialoglinkshareview.js @@ -19,138 +19,6 @@ var PASSWORD_PLACEHOLDER_MESSAGE = t('core', 'Choose a password for the public link'); var PASSWORD_PLACEHOLDER_MESSAGE_OPTIONAL = t('core', 'Choose a password for the public link or press the "Enter" key'); - var TEMPLATE = - '{{#if shareAllowed}}' + - '' + - '{{else}}' + - // FIXME: this doesn't belong in this view - '{{#if noSharingPlaceholder}}{{/if}}' + - '{{/if}}' - ; - var TEMPLATE_POPOVER_MENU = - ''; - - // popovermenu waiting for password or expiration date before saving the share - var TEMPLATE_POPOVER_MENU_PENDING = - ''; - /** * @class OCA.Share.ShareDialogLinkShareView * @member {OC.Share.ShareItemModel} model @@ -168,15 +36,6 @@ /** @type {OC.Share.ShareConfigModel} **/ configModel: undefined, - /** @type {Function} **/ - _template: undefined, - - /** @type {Function} **/ - _popoverMenuTemplate: undefined, - - /** @type {Function} **/ - _pendingPopoverMenuTemplate: undefined, - /** @type {boolean} **/ showLink: true, @@ -684,10 +543,7 @@ * @private */ template: function () { - if (!this._template) { - this._template = Handlebars.compile(TEMPLATE); - } - return this._template; + return OC.Share.Templates['sharedialoglinkshareview']; }, /** @@ -697,10 +553,7 @@ * @returns {string} */ popoverMenuTemplate: function(data) { - if(!this._popoverMenuTemplate) { - this._popoverMenuTemplate = Handlebars.compile(TEMPLATE_POPOVER_MENU); - } - return this._popoverMenuTemplate(data); + return OC.Share.Templates['sharedialoglinkshareview_popover_menu'](data); }, /** @@ -710,10 +563,7 @@ * @returns {string} */ pendingPopoverMenuTemplate: function(data) { - if(!this._pendingPopoverMenuTemplate) { - this._pendingPopoverMenuTemplate = Handlebars.compile(TEMPLATE_POPOVER_MENU_PENDING); - } - return this._pendingPopoverMenuTemplate(data); + return OC.Share.Templates['sharedialoglinkshareview_popover_menu_pending'](data); }, onPopUpClick: function(event) { diff --git a/core/js/sharedialogresharerinfoview.js b/core/js/sharedialogresharerinfoview.js index b2d5a09399..f55f2bcc52 100644 --- a/core/js/sharedialogresharerinfoview.js +++ b/core/js/sharedialogresharerinfoview.js @@ -15,14 +15,6 @@ OC.Share = {}; } - var TEMPLATE = - '' + - '
    ' + - ' {{sharedByText}}' + - '
    ' + - '{{#if hasShareNote}}{{/if}}' - ; - /** * @class OCA.Share.ShareDialogView * @member {OC.Share.ShareItemModel} model @@ -159,10 +151,7 @@ * @private */ template: function () { - if (!this._template) { - this._template = Handlebars.compile(TEMPLATE); - } - return this._template; + return OC.Share.Templates['sharedialogresharerinfoview']; } }); diff --git a/core/js/sharedialogshareelistview.js b/core/js/sharedialogshareelistview.js index 2627d5fa66..39e79f19eb 100644 --- a/core/js/sharedialogshareelistview.js +++ b/core/js/sharedialogshareelistview.js @@ -21,146 +21,6 @@ OC.Share = {}; } - var TEMPLATE = - '
      ' + - '{{#each sharees}}' + - '
    • ' + - '
      ' + - '{{shareWithDisplayName}}' + - '' + - '{{#if editPermissionPossible}}' + - '' + - '' + - '' + - '' + - '{{/if}}' + - '' + - '' + - '
    • ' + - '{{/each}}' + - '{{#each linkReshares}}' + - '
    • ' + - '
      ' + - '' + t('core', '{{shareInitiatorDisplayName}} shared via link') + '' + - - '' + - '{{unshareLabel}}' + - '' + - '
    • ' + - '{{/each}}' + - '
    ' - ; - - var TEMPLATE_POPOVER_MENU = - ''; - /** * @class OCA.Share.ShareDialogShareeListView * @member {OC.Share.ShareItemModel} model @@ -178,12 +38,6 @@ /** @type {OC.Share.ShareConfigModel} **/ configModel: undefined, - /** @type {Function} **/ - _template: undefined, - - /** @type {Function} **/ - _popoverMenuTemplate: undefined, - _menuOpen: false, /** @type {boolean|number} **/ @@ -503,16 +357,13 @@ * @private */ template: function (data) { - if (!this._template) { - this._template = Handlebars.compile(TEMPLATE); - } var sharees = data.sharees; if(_.isArray(sharees)) { for (var i = 0; i < sharees.length; i++) { data.sharees[i].popoverMenu = this.popoverMenuTemplate(sharees[i]); } } - return this._template(data); + return OC.Share.Templates['sharedialogshareelistview'](data); }, /** @@ -522,10 +373,7 @@ * @returns {string} */ popoverMenuTemplate: function(data) { - if(!this._popoverMenuTemplate) { - this._popoverMenuTemplate = Handlebars.compile(TEMPLATE_POPOVER_MENU); - } - return this._popoverMenuTemplate(data); + return OC.Share.Templates['sharedialogshareelistview_popover_menu'](data); }, showNoteForm: function(event) { diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js index f5b876c37b..9c648357e6 100644 --- a/core/js/sharedialogview.js +++ b/core/js/sharedialogview.js @@ -15,20 +15,6 @@ OC.Share = {}; } - var TEMPLATE_BASE = - '
    ' + - '{{#if isSharingAllowed}}' + - '' + - '
    ' + - ' ' + - ' '+ - ' ' + - '
    ' + - '{{/if}}' + - '
    ' + - '
    ' + - ''; - /** * @class OCA.Share.ShareDialogView * @member {OC.Share.ShareItemModel} model @@ -663,7 +649,7 @@ render: function() { var self = this; - var baseTemplate = this._getTemplate('base', TEMPLATE_BASE); + var baseTemplate = OC.Share.Templates['sharedialogview']; this.$el.html(baseTemplate({ cid: this.cid, @@ -739,20 +725,6 @@ return t('core', 'Name...'); }, - /** - * - * @param {string} key - an identifier for the template - * @param {string} template - the HTML to be compiled by Handlebars - * @returns {Function} from Handlebars - * @private - */ - _getTemplate: function (key, template) { - if (!this._templates[key]) { - this._templates[key] = Handlebars.compile(template); - } - return this._templates[key]; - }, - }); OC.Share.ShareDialogView = ShareDialogView; diff --git a/core/js/sharetemplates.js b/core/js/sharetemplates.js new file mode 100644 index 0000000000..94700e1a06 --- /dev/null +++ b/core/js/sharetemplates.js @@ -0,0 +1,629 @@ +(function() { + var template = Handlebars.template, templates = OC.Share.Templates = OC.Share.Templates || {}; +templates['sharedialoglinkshareview'] = 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 "
      \n
    • \n
      " + + alias4(((helper = (helper = helpers.linkShareLabel || (depth0 != null ? depth0.linkShareLabel : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"linkShareLabel","hash":{},"data":data}) : helper))) + + "\n \n \n \n \n \n \n" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.showMenu : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + " \n
    • \n
    \n"; +},"2":function(container,depth0,helpers,partials,data) { + return "checked=\"checked\""; +},"4":function(container,depth0,helpers,partials,data) { + var stack1; + + return "
    \n" + + ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.showPending : depth0),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.program(7, data, 0),"data":data})) != null ? stack1 : "") + + "
    \n"; +},"5":function(container,depth0,helpers,partials,data) { + var stack1, helper; + + return " " + + ((stack1 = ((helper = (helper = helpers.pendingPopoverMenu || (depth0 != null ? depth0.pendingPopoverMenu : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"pendingPopoverMenu","hash":{},"data":data}) : helper))) != null ? stack1 : "") + + "\n"; +},"7":function(container,depth0,helpers,partials,data) { + var stack1, helper; + + return " " + + ((stack1 = ((helper = (helper = helpers.popoverMenu || (depth0 != null ? depth0.popoverMenu : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"popoverMenu","hash":{},"data":data}) : helper))) != null ? stack1 : "") + + "\n"; +},"9":function(container,depth0,helpers,partials,data) { + var stack1; + + return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.noSharingPlaceholder : depth0),{"name":"if","hash":{},"fn":container.program(10, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "\n"; +},"10":function(container,depth0,helpers,partials,data) { + var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return ""; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1; + + return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.shareAllowed : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.program(9, data, 0),"data":data})) != null ? stack1 : "") + + "'\n"; +},"useData":true}); +templates['sharedialoglinkshareview_popover_menu'] = 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 "
  • \n \n \n \n \n \n
  • \n
  • \n \n \n \n \n
  • \n
  • \n \n \n \n \n \n
  • \n"; +},"3":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return "
  • \n \n \n \n \n \n
  • \n"; +},"5":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return "
  • \n \n \n \n \n
  • \n
  • \n \n \n \n \n
  • \n"; +},"6":function(container,depth0,helpers,partials,data) { + return "checked=\"checked\""; +},"8":function(container,depth0,helpers,partials,data) { + return "disabled=\"disabled\""; +},"10":function(container,depth0,helpers,partials,data) { + return "hidden"; +},"12":function(container,depth0,helpers,partials,data) { + var helper; + + return container.escapeExpression(((helper = (helper = helpers.expireDate || (depth0 != null ? depth0.expireDate : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"expireDate","hash":{},"data":data}) : helper))); +},"14":function(container,depth0,helpers,partials,data) { + var helper; + + return container.escapeExpression(((helper = (helper = helpers.defaultExpireDate || (depth0 != null ? depth0.defaultExpireDate : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"defaultExpireDate","hash":{},"data":data}) : helper))); +},"16":function(container,depth0,helpers,partials,data) { + var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return "
  • \n \n \n " + + alias4(((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"label","hash":{},"data":data}) : helper))) + + "\n \n
  • \n"; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return "
    \n \n
    \n"; +},"useData":true}); +templates['sharedialoglinkshareview_popover_menu_pending'] = 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 "
  • \n \n \n
  • \n
  • \n \n \n
  • \n"; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1; + + return "
    \n
      \n" + + ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.isPasswordEnforced : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "
    \n
    \n"; +},"useData":true}); +templates['sharedialogresharerinfoview'] = template({"1":function(container,depth0,helpers,partials,data) { + var helper; + + return "
    " + + container.escapeExpression(((helper = (helper = helpers.shareNote || (depth0 != null ? depth0.shareNote : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"shareNote","hash":{},"data":data}) : helper))) + + "
    "; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return "\n
    \n " + + alias4(((helper = (helper = helpers.sharedByText || (depth0 != null ? depth0.sharedByText : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"sharedByText","hash":{},"data":data}) : helper))) + + "\n
    ' +\n" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.hasShareNote : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "\n"; +},"useData":true}); +templates['sharedialogshareelistview'] = 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 "
  • \n
    \n " + + alias4(((helper = (helper = helpers.shareWithDisplayName || (depth0 != null ? depth0.shareWithDisplayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"shareWithDisplayName","hash":{},"data":data}) : helper))) + + "\n \n" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.editPermissionPossible : depth0),{"name":"if","hash":{},"fn":container.program(6, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "
    \n " + + ((stack1 = ((helper = (helper = helpers.popoverMenu || (depth0 != null ? depth0.popoverMenu : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"popoverMenu","hash":{},"data":data}) : helper))) != null ? stack1 : "") + + "\n
    \n
    \n
  • \n"; +},"2":function(container,depth0,helpers,partials,data) { + return "imageplaceholderseed"; +},"4":function(container,depth0,helpers,partials,data) { + var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return "data-seed=\"" + + alias4(((helper = (helper = helpers.shareWith || (depth0 != null ? depth0.shareWith : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"shareWith","hash":{},"data":data}) : helper))) + + " " + + alias4(((helper = (helper = helpers.shareType || (depth0 != null ? depth0.shareType : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"shareType","hash":{},"data":data}) : helper))) + + "\""; +},"6":function(container,depth0,helpers,partials,data) { + var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return " \n \n \n \n"; +},"8":function(container,depth0,helpers,partials,data) { + var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return "
  • \n
    \n t('core', '" + + alias4(((helper = (helper = helpers.shareInitiatorDisplayName || (depth0 != null ? depth0.shareInitiatorDisplayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"shareInitiatorDisplayName","hash":{},"data":data}) : helper))) + + " shared via link') + '\n \n " + + alias4(((helper = (helper = helpers.unshareLabel || (depth0 != null ? depth0.unshareLabel : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"unshareLabel","hash":{},"data":data}) : helper))) + + "\n \n
  • \n"; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {}); + + return "
      \n" + + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.sharees : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.linkReshares : depth0),{"name":"each","hash":{},"fn":container.program(8, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "
    \n"; +},"useData":true}); +templates['sharedialogshareelistview_popover_menu'] = template({"1":function(container,depth0,helpers,partials,data) { + var stack1; + + return " " + + ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.sharePermissionPossible : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + " "; +},"2":function(container,depth0,helpers,partials,data) { + var stack1; + + return " " + + ((stack1 = helpers.unless.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.isMailShare : depth0),{"name":"unless","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + " "; +},"3":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return "\n
  • \n \n \n \n \n
  • \n "; +},"4":function(container,depth0,helpers,partials,data) { + return "checked=\"checked\""; +},"6":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {}); + + return " " + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.createPermissionPossible : depth0),{"name":"if","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "\n " + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.updatePermissionPossible : depth0),{"name":"if","hash":{},"fn":container.program(10, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "\n " + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.deletePermissionPossible : depth0),{"name":"if","hash":{},"fn":container.program(13, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "\n"; +},"7":function(container,depth0,helpers,partials,data) { + var stack1; + + return ((stack1 = helpers.unless.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.isMailShare : depth0),{"name":"unless","hash":{},"fn":container.program(8, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : ""); +},"8":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return "\n
  • \n \n \n \n \n
  • \n "; +},"10":function(container,depth0,helpers,partials,data) { + var stack1; + + return ((stack1 = helpers.unless.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.isMailShare : depth0),{"name":"unless","hash":{},"fn":container.program(11, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : ""); +},"11":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return "\n
  • \n \n \n \n \n
  • \n "; +},"13":function(container,depth0,helpers,partials,data) { + var stack1; + + return ((stack1 = helpers.unless.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.isMailShare : depth0),{"name":"unless","hash":{},"fn":container.program(14, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : ""); +},"14":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return "\n
  • \n \n \n \n \n
  • \n "; +},"16":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.hasCreatePermission : depth0),{"name":"if","hash":{},"fn":container.program(17, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "
  • \n \n \n \n \n
  • \n
  • \n \n \n \n \n \n
  • \n" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isTalkEnabled : depth0),{"name":"if","hash":{},"fn":container.program(24, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : ""); +},"17":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return "
  • \n \n \n \n \n
  • \n"; +},"19":function(container,depth0,helpers,partials,data) { + var stack1; + + return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.isPasswordForMailSharesRequired : depth0),{"name":"if","hash":{},"fn":container.program(20, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : ""); +},"20":function(container,depth0,helpers,partials,data) { + return "disabled=\"\""; +},"22":function(container,depth0,helpers,partials,data) { + return "hidden"; +},"24":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return "
  • \n \n \n \n \n
  • \n
  • \n \n \n \n \n \n
  • \n"; +},"26":function(container,depth0,helpers,partials,data) { + var helper; + + return container.escapeExpression(((helper = (helper = helpers.expireDate || (depth0 != null ? depth0.expireDate : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"expireDate","hash":{},"data":data}) : helper))); +},"28":function(container,depth0,helpers,partials,data) { + var helper; + + return container.escapeExpression(((helper = (helper = helpers.defaultExpireDate || (depth0 != null ? depth0.defaultExpireDate : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"defaultExpireDate","hash":{},"data":data}) : helper))); +},"30":function(container,depth0,helpers,partials,data) { + var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return "
  • \n \n \n " + + alias4(((helper = (helper = helpers.addNoteLabel || (depth0 != null ? depth0.addNoteLabel : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"addNoteLabel","hash":{},"data":data}) : helper))) + + "\n \n \n
  • \n
  • \n \n \n \n \n
  • \n"; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return "\n"; +},"useData":true}); +templates['sharedialogview'] = 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 " \n
    \n \n '+\n \n
    \n"; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1; + + return "
    \n" + + ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.isSharingAllowed : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "
    \n
    \n
    ';\n"; +},"useData":true}); +})(); \ No newline at end of file From b574d1c81474b0dbc94a32ae18ec3d68a81db51a Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 1 Oct 2018 20:53:35 +0200 Subject: [PATCH 11/12] Move files_versions to compiled handlebars templates Signed-off-by: Roeland Jago Douma --- apps/files_versions/js/merged.json | 1 + apps/files_versions/js/templates.js | 54 +++++++++++++++++++ .../js/templates/item.handlebars | 22 ++++++++ .../js/templates/template.handlebars | 10 ++++ apps/files_versions/js/versionstabview.js | 48 +---------------- build/compile-handlebars-templates.sh | 3 ++ tests/karma.config.js | 1 + 7 files changed, 93 insertions(+), 46 deletions(-) create mode 100644 apps/files_versions/js/templates.js create mode 100644 apps/files_versions/js/templates/item.handlebars create mode 100644 apps/files_versions/js/templates/template.handlebars diff --git a/apps/files_versions/js/merged.json b/apps/files_versions/js/merged.json index 1a7fbad298..67ee60b385 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 0000000000..17293d763d --- /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 "
    \n " + + 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))) + + "\n
    \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 " \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 = + "
  • \n
    \n
    \n \n
    \n
    \n \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 += "
    \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 + "
    \n
  • \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 "
      \n
      \n
      \n
      \n
      \n

      " + + 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))) + + "

      \n
      \n
      \n\n
      \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 0000000000..6d11b9c088 --- /dev/null +++ b/apps/files_versions/js/templates/item.handlebars @@ -0,0 +1,22 @@ +
    • +
      +
      + +
      +
      + + {{#hasDetails}} +
      + {{humanReadableSize}} +
      + {{/hasDetails}} +
      + {{#canRevert}} + + {{/canRevert}} +
      +
    • diff --git a/apps/files_versions/js/templates/template.handlebars b/apps/files_versions/js/templates/template.handlebars new file mode 100644 index 0000000000..f01a6f4162 --- /dev/null +++ b/apps/files_versions/js/templates/template.handlebars @@ -0,0 +1,10 @@ +
        +
        + + + diff --git a/apps/files_versions/js/versionstabview.js b/apps/files_versions/js/versionstabview.js index 3a9026901e..dacd567fdc 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 = - '
      • ' + - '
        ' + - '
        ' + - '' + - '
        ' + - '
        ' + - '' + - '{{#hasDetails}}' + - '
        ' + - '{{humanReadableSize}}' + - '
        ' + - '{{/hasDetails}}' + - '
        ' + - '{{#canRevert}}' + - '' + - '{{/canRevert}}' + - '
        ' + - '
      • '; - - var TEMPLATE = - '
          ' + - '
          ' + - '' + - '' + - ''; - /** * @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) { diff --git a/build/compile-handlebars-templates.sh b/build/compile-handlebars-templates.sh index a3463a04ea..2f83dd3956 100755 --- a/build/compile-handlebars-templates.sh +++ b/build/compile-handlebars-templates.sh @@ -22,6 +22,9 @@ handlebars -n OCA.Files.Templates apps/files/js/templates -f apps/files/js/templ # Comments app handlebars -n OCA.Comments.Templates apps/comments/js/templates -f apps/comments/js/templates.js +# Versions app +handlebars -n OCA.Versions.Templates apps/files_versions/js/templates -f apps/files_versions/js/templates.js + if [[ $(git diff --name-only) ]]; then echo "Please submit your compiled handlebars templates" diff --git a/tests/karma.config.js b/tests/karma.config.js index 93b7b4113f..8339285116 100644 --- a/tests/karma.config.js +++ b/tests/karma.config.js @@ -77,6 +77,7 @@ module.exports = function(config) { srcFiles: [ // need to enforce loading order... 'apps/files_versions/js/versionmodel.js', + 'apps/files_versions/js/templates.js', 'apps/files_versions/js/versioncollection.js', 'apps/files_versions/js/versionstabview.js' ], From 1161b838d78a7a77d68b17664759766e49c9bb46 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 1 Oct 2018 22:40:26 +0200 Subject: [PATCH 12/12] Move newfilemenu to compiled handlebars Signed-off-by: Roeland Jago Douma --- apps/files/js/newfilemenu.js | 28 ++------------- apps/files/js/templates.js | 36 +++++++++++++++++++ .../files/js/templates/newfilemenu.handlebars | 10 ++++++ .../newfilemenu_filename_form.handlebars | 4 +++ 4 files changed, 52 insertions(+), 26 deletions(-) create mode 100644 apps/files/js/templates/newfilemenu.handlebars create mode 100644 apps/files/js/templates/newfilemenu_filename_form.handlebars diff --git a/apps/files/js/newfilemenu.js b/apps/files/js/newfilemenu.js index 0ad7312c98..109a2fed67 100644 --- a/apps/files/js/newfilemenu.js +++ b/apps/files/js/newfilemenu.js @@ -12,24 +12,6 @@ (function() { - var TEMPLATE_MENU = - '
            ' + - '
          • ' + - '' + - '
          • ' + - '{{#each items}}' + - '
          • ' + - '{{displayName}}' + - '
          • ' + - '{{/each}}' + - '
          '; - - var TEMPLATE_FILENAME_FORM = - '
          ' + - '' + - '' - '
          '; - /** * Construct a new NewFileMenu instance * @constructs NewFileMenu @@ -78,10 +60,7 @@ }, template: function(data) { - if (!OCA.Files.NewFileMenu._TEMPLATE) { - OCA.Files.NewFileMenu._TEMPLATE = Handlebars.compile(TEMPLATE_MENU); - } - return OCA.Files.NewFileMenu._TEMPLATE(data); + return OCA.Files.Templates['newfilemenu'](data); }, /** @@ -111,9 +90,6 @@ _promptFileName: function($target) { var self = this; - if (!OCA.Files.NewFileMenu._TEMPLATE_FORM) { - OCA.Files.NewFileMenu._TEMPLATE_FORM = Handlebars.compile(TEMPLATE_FILENAME_FORM); - } if ($target.find('form').length) { $target.find('input[type=\'text\']').focus(); @@ -128,7 +104,7 @@ var newName = $target.attr('data-templatename'); var fileType = $target.attr('data-filetype'); - var $form = $(OCA.Files.NewFileMenu._TEMPLATE_FORM({ + var $form = $(OCA.Files.Templates['newfilemenu_filename_form']({ fileName: newName, cid: this.cid, fileType: fileType diff --git a/apps/files/js/templates.js b/apps/files/js/templates.js index c5522d8407..1433b24070 100644 --- a/apps/files/js/templates.js +++ b/apps/files/js/templates.js @@ -164,6 +164,42 @@ templates['mainfileinfodetailsview'] = template({"1":function(container,depth0,h + alias4(((helper = (helper = helpers.permalinkTitle || (depth0 != null ? depth0.permalinkTitle : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"permalinkTitle","hash":{},"data":data}) : helper))) + "\" readonly=\"readonly\"/>\n
          \n"; },"useData":true}); +templates['newfilemenu'] = 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 "
        • \n " + + 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))) + + "\n
        • \n"; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return "
            \n
          • \n \n
          • \n" + + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.items : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "
          \n"; +},"useData":true}); +templates['newfilemenu_filename_form'] = 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 "
          \n \n '\n
          \n"; +},"useData":true}); templates['template_addbutton'] = 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/files/js/templates/newfilemenu.handlebars b/apps/files/js/templates/newfilemenu.handlebars new file mode 100644 index 0000000000..0d9ad9682c --- /dev/null +++ b/apps/files/js/templates/newfilemenu.handlebars @@ -0,0 +1,10 @@ +
            +
          • + +
          • + {{#each items}} +
          • + {{displayName}} +
          • + {{/each}} +
          diff --git a/apps/files/js/templates/newfilemenu_filename_form.handlebars b/apps/files/js/templates/newfilemenu_filename_form.handlebars new file mode 100644 index 0000000000..cf18b28cad --- /dev/null +++ b/apps/files/js/templates/newfilemenu_filename_form.handlebars @@ -0,0 +1,4 @@ +
          + + ' +