8 var createAction = function(actionConfig) {
11 name: actionConfig.name,
13 fragment: {type: 'context', name: 'fragment'}
16 icon: actionConfig.icon || null,
17 execute: function(callback, params) {
21 var node = params.fragment.node;
22 if(node.nodeType === Node.TEXT_NODE) {
26 node.document.transaction(function() {
27 var exerciseNode = node.after(node.document.edumedCreateExerciseNode(actionConfig.exercise));
30 if(actionConfig.exercise === 'order') {
31 exerciseNode.object.addItem('first item');
32 exerciseNode.contents('.p')[0].append({text: 'Write here...'});
38 getState: function(params) {
40 allowed: params.fragment && params.fragment.isValid() && params.fragment instanceof params.fragment.NodeFragment && !params.fragment.node.isInside('exercise'),
41 description: gettext('Insert exercise: ' + actionConfig.exerciseTitle)
49 createAction({name: 'insertOrderExercise', icon: 'random', exercise: 'order', exerciseTitle: gettext('Order') })