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 = - '{{{tagMarkup}}}' + - '{{else}}' + - ' {{name}}' + - '{{/if}}'; - - var RENAME_FORM_TEMPLATE = - '
'; /** * @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 " '; - - var SELECTION_TEMPLATE = - '{{#if isAdmin}}' + - ' " + + ((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"; +},"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"; +},"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"; +},"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 @@ + '; 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 @@ + 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}}