4 /* globals gettext, interpolate */
7 var insertTemplateAction = {
10 fragment: {type: 'context', name: 'fragment'},
11 template: {type: 'select', options: []},
12 ctrl: {type: 'key', key: 'ctrl'}
18 getState: function(params) {
19 if(!(params.template && params.template.id)) {
22 description: gettext('No template selected')
25 !params.fragment || !params.fragment.isValid() ||
26 !(params.fragment instanceof params.fragment.NodeFragment) ||
27 params.fragment.node.getNearestElementNode().isRoot()
31 description: gettext('Wrong node selected')
36 description: interpolate(gettext('Insert template %s after %s'), [params.template.name, params.fragment.node.getNearestElementNode().getTagName()]),
37 execute: function(params) {
38 var node = params.fragment.node.getNearestElementNode();
39 var toAdd = node.document.createDocumentNode(params.template.content);
48 actions: [insertTemplateAction]