Merge pull request #11849 from nextcloud/csp/fileactionsmenu
Move fileactionsmenu to compiled handlebars
This commit is contained in:
commit
353fddfbb9
|
@ -10,24 +10,6 @@
|
|||
|
||||
(function() {
|
||||
|
||||
var TEMPLATE_MENU =
|
||||
'<ul>' +
|
||||
'{{#each items}}' +
|
||||
'<li>' +
|
||||
'<a href="#" class="menuitem action action-{{nameLowerCase}} permanent" data-action="{{name}}">' +
|
||||
'{{#if icon}}<img class="icon" src="{{icon}}"/>' +
|
||||
'{{else}}'+
|
||||
'{{#if iconClass}}' +
|
||||
'<span class="icon {{iconClass}}"></span>' +
|
||||
'{{else}}' +
|
||||
'<span class="no-icon"></span>' +
|
||||
'{{/if}}' +
|
||||
'{{/if}}' +
|
||||
'<span>{{displayName}}</span></a>' +
|
||||
'</li>' +
|
||||
'{{/each}}' +
|
||||
'</ul>';
|
||||
|
||||
/**
|
||||
* Construct a new FileActionsMenu instance
|
||||
* @constructs FileActionsMenu
|
||||
|
@ -49,10 +31,7 @@
|
|||
},
|
||||
|
||||
template: function(data) {
|
||||
if (!OCA.Files.FileActionsMenu._TEMPLATE) {
|
||||
OCA.Files.FileActionsMenu._TEMPLATE = Handlebars.compile(TEMPLATE_MENU);
|
||||
}
|
||||
return OCA.Files.FileActionsMenu._TEMPLATE(data);
|
||||
return OCA.Files.Templates['fileactionsmenu'](data);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -81,6 +81,43 @@ templates['file_action_trigger'] = template({"1":function(container,depth0,helpe
|
|||
+ ((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['fileactionsmenu'] = 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 " <li>\n <a href=\"#\" class=\"menuitem 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)))
|
||||
+ " permanent\" 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(2, data, 0),"inverse":container.program(4, data, 0),"data":data})) != null ? stack1 : "")
|
||||
+ " <span>"
|
||||
+ 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)))
|
||||
+ "</span>\n </a>\n </li>\n";
|
||||
},"2":function(container,depth0,helpers,partials,data) {
|
||||
var helper;
|
||||
|
||||
return "<img class=\"icon\" src=\""
|
||||
+ container.escapeExpression(((helper = (helper = helpers.icon || (depth0 != null ? depth0.icon : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"icon","hash":{},"data":data}) : helper)))
|
||||
+ "\"/>\n";
|
||||
},"4":function(container,depth0,helpers,partials,data) {
|
||||
var stack1;
|
||||
|
||||
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.iconClass : depth0),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.program(7, data, 0),"data":data})) != null ? stack1 : "");
|
||||
},"5":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)))
|
||||
+ "\"></span>\n";
|
||||
},"7":function(container,depth0,helpers,partials,data) {
|
||||
return " <span class=\"no-icon\"></span>\n";
|
||||
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
|
||||
var stack1;
|
||||
|
||||
return "<ul>\n"
|
||||
+ ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.items : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
|
||||
+ "</ul>\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;
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<ul>
|
||||
{{#each items}}
|
||||
<li>
|
||||
<a href="#" class="menuitem action action-{{nameLowerCase}} permanent" data-action="{{name}}">
|
||||
{{#if icon}}<img class="icon" src="{{icon}}"/>
|
||||
{{else}}
|
||||
{{#if iconClass}}
|
||||
<span class="icon {{iconClass}}"></span>
|
||||
{{else}}
|
||||
<span class="no-icon"></span>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
<span>{{displayName}}</span>
|
||||
</a>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
|
@ -203,7 +203,7 @@ describe('OCA.Files.FileActionsMenu tests', function() {
|
|||
|
||||
expect(displayNameStub.calledOnce).toEqual(true);
|
||||
expect(displayNameStub.calledWith(menuContext)).toEqual(true);
|
||||
expect(menu.$el.find('a[data-action=Something]').text()).toEqual('Test');
|
||||
expect(menu.$el.find('a[data-action=Something] span:not(.icon)').text()).toEqual('Test');
|
||||
});
|
||||
it('uses plain iconClass', function() {
|
||||
fileActions.registerAction({
|
||||
|
|
Loading…
Reference in New Issue