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) {
21 if(!(params.template && params.template.id)) {
24 description: gettext('No template selected')
27 !params.fragment || !params.fragment.isValid() ||
28 !(params.fragment instanceof params.fragment.NodeFragment) ||
29 params.fragment.node.getNearestElementNode().isRoot()
33 description: gettext('Wrong node selected')
37 description = interpolate(gettext('Insert template %s after %s'), [params.template.name, params.fragment.node.getNearestElementNode().getTagName()]);
40 description: description,
41 execute: function(params) {
42 var node = params.fragment.node.getNearestElementNode();
43 node.document.transaction(function() {
44 var toAdd = node.document.createDocumentNode(params.template.content);
48 description: description
58 actions: [insertTemplateAction]