this.trigger('mousedown');
},
onExecute: function() {
- var ret = this.action.execute();
- this.trigger('actionExecuted', this.action, ret);
+ this.action.execute(function(ret) {
+ this.trigger('actionExecuted', this.action, ret);
+ }.bind(this));
},
onSelectionChange: function(e) {
var select = $(e.target),
label: dir === 'undo' ? '<-' : '->',
icon: 'share-alt',
iconStyle: dir === 'undo' ? '-webkit-transform: scale(-1,1); transform: scale(-1, 1)' : '',
- execute: function(params) {
+ execute: function(callback, params) {
params.document[dir]();
+ callback();
},
},
getState: function(params) {
},
stateDefaults: {
icon: 'comment',
- execute: function(params, editor) {
+ execute: function(callback, params, editor) {
/* globals Node */
var node = params.fragment.node,
action = this;
}, {
metadata: {
description: action.getState().description
- }
+ },
+ success: callback
});
},
},
return _.extend(state, {
allowed: true,
description: createParams.description,
- execute: function(params) {
+ execute: function(callback, params) {
params.fragment.document.transaction(function() {
var parent = params.fragment.startNode.parent();
return parent.wrapText({
}, {
metadata: {
description: createParams.description
- }
+ },
+ success: callback
});
}
});
};
-var createLinkFromSelection = function(params) {
+var createLinkFromSelection = function(callback, params) {
var doc = params.fragment.document,
dialog = Dialog.create({
title: gettext('Create link'),
}, {
metadata: {
description: action.getState().description
- }
+ },
+ success: callback
});
});
dialog.show();
};
-var editLink = function(params) {
+var editLink = function(callback, params) {
var doc = params.fragment.document,
link = params.fragment.node.getParent('link'),
dialog = Dialog.create({
}, {
metadata: {
description: action.getState().description
- }
+ },
+ success: callback
});
});
dialog.show();
var toggleListAction = function(type) {
var execute = {
- add: function(params) {
+ add: function(callback, params) {
var boundries = getBoundriesForAList(params.fragment),
listParams = {klass: type === 'Bullet' ? 'list' : 'list.enum'},
action = this;
}, {
metadata: {
description: action.getState().description
- }
+ },
+ success: callback
});
} else {
throw new Error('Invalid boundries');
}
},
- remove: function(params) {
+ remove: function(callback, params) {
/* globals Node */
var current = params.fragment.node,
action = this;
}, {
metadata: {
description: action.getState().description
- }
+ },
+ success: callback
});
return true; // break
}
}.bind(this));
},
- changeType: function(params) {
+ changeType: function(callback, params) {
var node = params.fragment.node,
action = this;
node.document.transaction(function() {
}, {
metadata: {
description: action.getState().description
- }
+ },
+ success: callback
});
}
};
allowed: !!toSwitch,
toggled: alreadyInTarget,
description: description,
- execute: alreadyInTarget ? function() {} : function() {
+ execute: alreadyInTarget ? function() {} : function(callback) {
f.document.transaction(function() {
if(createParams.to.tagName) {
toSwitch = toSwitch.setTag(createParams.to.tagName);
}, {
metadata: {
description: description
- }
+ },
+ success: callback
});
}
});
return {
allowed: true,
description: description,
- execute: function(params) {
+ execute: function(callback, params) {
var node = params.fragment.node.getNearestElementNode();
node.document.transaction(function() {
var toAdd = node.document.createDocumentNode(params.template.content);
}, {
metadata: {
description: description
- }
+ },
+ success: callback
});
}
};