Move fileactions to compiled handlebars

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2018-10-01 20:04:13 +02:00
parent 8dfc397a5e
commit 6f940a9b02
No known key found for this signature in database
GPG Key ID: F941078878347C0C
3 changed files with 58 additions and 16 deletions

View File

@ -10,17 +10,6 @@
(function() {
var TEMPLATE_FILE_ACTION_TRIGGER =
'<a class="action action-{{nameLowerCase}}" href="#" data-action="{{name}}">' +
'{{#if icon}}' +
'<img class="svg" alt="{{altText}}" src="{{icon}}" />' +
'{{else}}' +
'{{#if iconClass}}<span class="icon {{iconClass}}" />{{/if}}' +
'{{#unless hasDisplayName}}<span class="hidden-visually">{{altText}}</span>{{/unless}}' +
'{{/if}}' +
'{{#if displayName}}<span> {{displayName}}</span>{{/if}}' +
'</a>';
/**
* 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));
},
/**

View File

@ -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)))
+ "</span>\n</div>\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 " <img class=\"svg\" alt=\""
+ 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)))
+ "\" src=\""
+ alias4(((helper = (helper = helpers.icon || (depth0 != null ? depth0.icon : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"icon","hash":{},"data":data}) : helper)))
+ "\" />\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 " <span class=\"icon "
+ container.escapeExpression(((helper = (helper = helpers.iconClass || (depth0 != null ? depth0.iconClass : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"iconClass","hash":{},"data":data}) : helper)))
+ "\" />\n";
},"6":function(container,depth0,helpers,partials,data) {
var helper;
return " <span class=\"hidden-visually\">"
+ 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)))
+ "</span>\n";
},"8":function(container,depth0,helpers,partials,data) {
var helper;
return "<span> "
+ 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)))
+ "</span>";
},"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 "<a class=\"action action-"
+ alias4(((helper = (helper = helpers.nameLowerCase || (depth0 != null ? depth0.nameLowerCase : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"nameLowerCase","hash":{},"data":data}) : helper)))
+ "\" href=\"#\" data-action=\""
+ alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
+ "\">\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.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</a>\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;

View File

@ -0,0 +1,13 @@
<a class="action action-{{nameLowerCase}}" href="#" data-action="{{name}}">
{{#if icon}}
<img class="svg" alt="{{altText}}" src="{{icon}}" />
{{else}}
{{#if iconClass}}
<span class="icon {{iconClass}}" />
{{/if}}
{{#unless hasDisplayName}}
<span class="hidden-visually">{{altText}}</span>
{{/unless}}
{{/if}}
{{#if displayName}}<span> {{displayName}}</span>{{/if}}
</a>