diff --git a/build/compile-handlebars-templates.sh b/build/compile-handlebars-templates.sh index 8dc0e0397aa7fd31a0dad4680155d3c85dd91356..96080d12ec16467084c953482f4ae92ecef86138 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 19f361d2dfeed06deb5207a7e3b02abf7429b52f..161e4766f3ff737a68cac5130c7aa93adb3ff48b 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 846ba967ed5b92a794bb06600d46f15c116a5d5c..641858ee2ed092b42e07ea4852766eb8dc031b0c 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 ba72d4862047002a197a38ef44a794dc2484397b..82fd659c72e3d95d57b151377e6c64b774f752b2 100644 --- a/core/js/systemtags/systemtagsinputfield.js +++ b/core/js/systemtags/systemtagsinputfield.js @@ -11,39 +11,6 @@ /* global Handlebars */ (function(OC) { - var TEMPLATE = - '<input class="systemTagsInputField" type="hidden" name="tags" value=""/>'; - - var RESULT_TEMPLATE = - '<span class="systemtags-item{{#if isNew}} new-item{{/if}}" data-id="{{id}}">' + - ' <span class="checkmark icon icon-checkmark"></span>' + - '{{#if isAdmin}}' + - ' <span class="label">{{{tagMarkup}}}</span>' + - '{{else}}' + - ' <span class="label">{{name}}</span>' + - '{{/if}}' + - '{{#allowActions}}' + - ' <span class="systemtags-actions">' + - ' <a href="#" class="rename icon icon-rename" title="{{renameTooltip}}"></a>' + - ' </span>' + - '{{/allowActions}}' + - '</span>'; - - var SELECTION_TEMPLATE = - '{{#if isAdmin}}' + - ' <span class="label">{{{tagMarkup}}}</span>' + - '{{else}}' + - ' <span class="label">{{name}}</span>' + - '{{/if}}'; - - var RENAME_FORM_TEMPLATE = - '<form class="systemtags-rename-form">' + - ' <label class="hidden-visually" for="{{cid}}-rename-input">{{renameLabel}}</label>' + - ' <input id="{{cid}}-rename-input" type="text" value="{{name}}">' + - ' {{#if isAdmin}}' + - ' <a href="#" class="delete icon icon-delete" title="{{deleteTooltip}}"></a>' + - ' {{/if}}' + - '</form>'; /** * @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 '<input class="systemTagsInputField" type="hidden" name="tags" value=""/>'; }, /** @@ -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 0000000000000000000000000000000000000000..0894d646829169c068c0ddc7b1065424c291990c --- /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 " <span class=\"label\">" + + ((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 : "") + + "</span>\n"; +},"5":function(container,depth0,helpers,partials,data) { + var helper; + + return " <span class=\"label\">" + + 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))) + + "</span>\n"; +},"7":function(container,depth0,helpers,partials,data) { + var helper; + + return " <span class=\"systemtags-actions\">\n <a href=\"#\" class=\"rename icon icon-rename\" title=\"" + + container.escapeExpression(((helper = (helper = helpers.renameTooltip || (depth0 != null ? depth0.renameTooltip : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"renameTooltip","hash":{},"data":data}) : helper))) + + "\"></a>\n </span>\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 = + "<span class=\"systemtags-item" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isNew : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "\" data-id=\"" + + container.escapeExpression(((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<span class=\"checkmark icon icon-checkmark\"></span>\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 + "</span>';\n"; +},"useData":true}); +templates['result_form'] = template({"1":function(container,depth0,helpers,partials,data) { + var helper; + + return " <a href=\"#\" class=\"delete icon icon-delete\" title=\"" + + container.escapeExpression(((helper = (helper = helpers.deleteTooltip || (depth0 != null ? depth0.deleteTooltip : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"deleteTooltip","hash":{},"data":data}) : helper))) + + "\"></a>\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 "<form class=\"systemtags-rename-form\">\n <label class=\"hidden-visually\" for=\"" + + alias4(((helper = (helper = helpers.cid || (depth0 != null ? depth0.cid : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"cid","hash":{},"data":data}) : helper))) + + "-rename-input\">" + + alias4(((helper = (helper = helpers.renameLabel || (depth0 != null ? depth0.renameLabel : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"renameLabel","hash":{},"data":data}) : helper))) + + "</label>\n <input id=\"" + + alias4(((helper = (helper = helpers.cid || (depth0 != null ? depth0.cid : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"cid","hash":{},"data":data}) : helper))) + + "-rename-input\" type=\"text\" value=\"" + + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper))) + + "\">\n" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isAdmin : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "</form>\n"; +},"useData":true}); +templates['selection'] = template({"1":function(container,depth0,helpers,partials,data) { + var stack1, helper; + + return " <span class=\"label\">" + + ((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 : "") + + "</span>\n"; +},"3":function(container,depth0,helpers,partials,data) { + var helper; + + return " <span class=\"label\">" + + 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))) + + "</span>\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 0000000000000000000000000000000000000000..ce69c8a21ff188d971e619007b26439316a93be8 --- /dev/null +++ b/core/js/systemtags/templates/result.handlebars @@ -0,0 +1,13 @@ +<span class="systemtags-item{{#if isNew}} new-item{{/if}}" data-id="{{id}}"> +<span class="checkmark icon icon-checkmark"></span> + {{#if isAdmin}} + <span class="label">{{{tagMarkup}}}</span> + {{else}} + <span class="label">{{name}}</span> + {{/if}} + {{#allowActions}} + <span class="systemtags-actions"> + <a href="#" class="rename icon icon-rename" title="{{renameTooltip}}"></a> + </span> + {{/allowActions}} +</span>'; diff --git a/core/js/systemtags/templates/result_form.handlebars b/core/js/systemtags/templates/result_form.handlebars new file mode 100644 index 0000000000000000000000000000000000000000..28fe8c56fe242523c9e697d9b1e44ee4d97ce09c --- /dev/null +++ b/core/js/systemtags/templates/result_form.handlebars @@ -0,0 +1,7 @@ +<form class="systemtags-rename-form"> + <label class="hidden-visually" for="{{cid}}-rename-input">{{renameLabel}}</label> + <input id="{{cid}}-rename-input" type="text" value="{{name}}"> + {{#if isAdmin}} + <a href="#" class="delete icon icon-delete" title="{{deleteTooltip}}"></a> + {{/if}} +</form> diff --git a/core/js/systemtags/templates/selection.handlebars b/core/js/systemtags/templates/selection.handlebars new file mode 100644 index 0000000000000000000000000000000000000000..b006b1297483f93ee041f64099861b5df62b687b --- /dev/null +++ b/core/js/systemtags/templates/selection.handlebars @@ -0,0 +1,5 @@ +{{#if isAdmin}} + <span class="label">{{{tagMarkup}}}</span> +{{else}} + <span class="label">{{name}}</span> +{{/if}}