fnp
/
fnpeditor.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
07d6b62
)
editor: actions returns via callback
author
Aleksander Łukasz
<aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 22 Apr 2014 10:35:16 +0000
(12:35 +0200)
committer
Aleksander Łukasz
<aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 23 Apr 2014 11:05:05 +0000
(13:05 +0200)
src/editor/modules/documentToolbar/actionView.js
patch
|
blob
|
history
src/editor/plugins/core/core.js
patch
|
blob
|
history
src/editor/plugins/core/lists.js
patch
|
blob
|
history
src/editor/plugins/core/switch.js
patch
|
blob
|
history
src/editor/plugins/core/templates.js
patch
|
blob
|
history
diff --git
a/src/editor/modules/documentToolbar/actionView.js
b/src/editor/modules/documentToolbar/actionView.js
index
114eb32
..
74db332
100644
(file)
--- a/
src/editor/modules/documentToolbar/actionView.js
+++ b/
src/editor/modules/documentToolbar/actionView.js
@@
-108,8
+108,9
@@
var ActionView = Backbone.View.extend({
this.trigger('mousedown');
},
onExecute: function() {
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),
},
onSelectionChange: function(e) {
var select = $(e.target),
diff --git
a/src/editor/plugins/core/core.js
b/src/editor/plugins/core/core.js
index
3465046
..
4c2f4c0
100644
(file)
--- a/
src/editor/plugins/core/core.js
+++ b/
src/editor/plugins/core/core.js
@@
-54,8
+54,9
@@
var undoRedoAction = function(dir) {
label: dir === 'undo' ? '<-' : '->',
icon: 'share-alt',
iconStyle: dir === 'undo' ? '-webkit-transform: scale(-1,1); transform: scale(-1, 1)' : '',
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]();
params.document[dir]();
+ callback();
},
},
getState: function(params) {
},
},
getState: function(params) {
@@
-90,7
+91,7
@@
var commentAction = {
},
stateDefaults: {
icon: 'comment',
},
stateDefaults: {
icon: 'comment',
- execute: function(params, editor) {
+ execute: function(
callback,
params, editor) {
/* globals Node */
var node = params.fragment.node,
action = this;
/* globals Node */
var node = params.fragment.node,
action = this;
@@
-124,7
+125,8
@@
var commentAction = {
}, {
metadata: {
description: action.getState().description
}, {
metadata: {
description: action.getState().description
- }
+ },
+ success: callback
});
},
},
});
},
},
@@
-168,7
+170,7
@@
var createWrapTextAction = function(createParams) {
return _.extend(state, {
allowed: true,
description: createParams.description,
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({
params.fragment.document.transaction(function() {
var parent = params.fragment.startNode.parent();
return parent.wrapText({
@@
-180,7
+182,8
@@
var createWrapTextAction = function(createParams) {
}, {
metadata: {
description: createParams.description
}, {
metadata: {
description: createParams.description
- }
+ },
+ success: callback
});
}
});
});
}
});
@@
-189,7
+192,7
@@
var createWrapTextAction = function(createParams) {
};
};
-var createLinkFromSelection = function(params) {
+var createLinkFromSelection = function(
callback,
params) {
var doc = params.fragment.document,
dialog = Dialog.create({
title: gettext('Create link'),
var doc = params.fragment.document,
dialog = Dialog.create({
title: gettext('Create link'),
@@
-215,13
+218,14
@@
var createLinkFromSelection = function(params) {
}, {
metadata: {
description: action.getState().description
}, {
metadata: {
description: action.getState().description
- }
+ },
+ success: callback
});
});
dialog.show();
};
});
});
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({
var doc = params.fragment.document,
link = params.fragment.node.getParent('link'),
dialog = Dialog.create({
@@
-241,7
+245,8
@@
var editLink = function(params) {
}, {
metadata: {
description: action.getState().description
}, {
metadata: {
description: action.getState().description
- }
+ },
+ success: callback
});
});
dialog.show();
});
});
dialog.show();
diff --git
a/src/editor/plugins/core/lists.js
b/src/editor/plugins/core/lists.js
index
a8dc802
..
911a1f2
100644
(file)
--- a/
src/editor/plugins/core/lists.js
+++ b/
src/editor/plugins/core/lists.js
@@
-32,7
+32,7
@@
var countItems = function(boundries) {
var toggleListAction = function(type) {
var execute = {
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;
var boundries = getBoundriesForAList(params.fragment),
listParams = {klass: type === 'Bullet' ? 'list' : 'list.enum'},
action = this;
@@
-45,13
+45,14
@@
var toggleListAction = function(type) {
}, {
metadata: {
description: action.getState().description
}, {
metadata: {
description: action.getState().description
- }
+ },
+ success: callback
});
} else {
throw new Error('Invalid boundries');
}
},
});
} else {
throw new Error('Invalid boundries');
}
},
- remove: function(params) {
+ remove: function(
callback,
params) {
/* globals Node */
var current = params.fragment.node,
action = this;
/* globals Node */
var current = params.fragment.node,
action = this;
@@
-65,14
+66,15
@@
var toggleListAction = function(type) {
}, {
metadata: {
description: action.getState().description
}, {
metadata: {
description: action.getState().description
- }
+ },
+ success: callback
});
return true; // break
}
}.bind(this));
},
});
return true; // break
}
}.bind(this));
},
- changeType: function(params) {
+ changeType: function(
callback,
params) {
var node = params.fragment.node,
action = this;
node.document.transaction(function() {
var node = params.fragment.node,
action = this;
node.document.transaction(function() {
@@
-80,7
+82,8
@@
var toggleListAction = function(type) {
}, {
metadata: {
description: action.getState().description
}, {
metadata: {
description: action.getState().description
- }
+ },
+ success: callback
});
}
};
});
}
};
diff --git
a/src/editor/plugins/core/switch.js
b/src/editor/plugins/core/switch.js
index
2730761
..
57b28b9
100644
(file)
--- a/
src/editor/plugins/core/switch.js
+++ b/
src/editor/plugins/core/switch.js
@@
-43,7
+43,7
@@
var createSwitchAction = function(createParams) {
allowed: !!toSwitch,
toggled: alreadyInTarget,
description: description,
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);
f.document.transaction(function() {
if(createParams.to.tagName) {
toSwitch = toSwitch.setTag(createParams.to.tagName);
@@
-54,7
+54,8
@@
var createSwitchAction = function(createParams) {
}, {
metadata: {
description: description
}, {
metadata: {
description: description
- }
+ },
+ success: callback
});
}
});
});
}
});
diff --git
a/src/editor/plugins/core/templates.js
b/src/editor/plugins/core/templates.js
index
69e30f9
..
7d6d74f
100644
(file)
--- a/
src/editor/plugins/core/templates.js
+++ b/
src/editor/plugins/core/templates.js
@@
-38,7
+38,7
@@
var insertTemplateAction = {
return {
allowed: true,
description: description,
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);
var node = params.fragment.node.getNearestElementNode();
node.document.transaction(function() {
var toAdd = node.document.createDocumentNode(params.template.content);
@@
-46,7
+46,8
@@
var insertTemplateAction = {
}, {
metadata: {
description: description
}, {
metadata: {
description: description
- }
+ },
+ success: callback
});
}
};
});
}
};