From: Aleksander Ɓukasz Date: Fri, 18 Jul 2014 09:44:56 +0000 (+0200) Subject: Merge in change to the Actions api X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/b673187ef27821aef4972223e465b6e09a495e77?hp=83edceffb18f5802bb6a9b20746437a3a46f2450 Merge in change to the Actions api --- diff --git a/src/editor/modules/documentToolbar/actionView.js b/src/editor/modules/documentToolbar/actionView.js index 74db332..5439045 100644 --- a/src/editor/modules/documentToolbar/actionView.js +++ b/src/editor/modules/documentToolbar/actionView.js @@ -108,9 +108,7 @@ var ActionView = Backbone.View.extend({ this.trigger('mousedown'); }, onExecute: function() { - this.action.execute(function(ret) { - this.trigger('actionExecuted', this.action, ret); - }.bind(this)); + this.action.execute(); }, onSelectionChange: function(e) { var select = $(e.target), diff --git a/src/editor/modules/documentToolbar/documentToolbar.js b/src/editor/modules/documentToolbar/documentToolbar.js index 9ae5c94..6e3d630 100644 --- a/src/editor/modules/documentToolbar/documentToolbar.js +++ b/src/editor/modules/documentToolbar/documentToolbar.js @@ -27,7 +27,7 @@ return function(sandbox) { }); group.append(view.dom); - view.on('actionExecuted', function(action, ret) { + action.on('actionExecuted', function(ret) { sandbox.publish('actionExecuted', action, ret); }); diff --git a/src/fnpjs/actions.js b/src/fnpjs/actions.js index f380ed6..b8aa033 100644 --- a/src/fnpjs/actions.js +++ b/src/fnpjs/actions.js @@ -72,9 +72,13 @@ _.extend(Action.prototype, Backbone.Events, { } return this._cache; }, - execute: function(callback) { + execute: function() { var state = this.getState(); - callback = callback || function() {}; + + var callback = function(ret) { + this.trigger('actionExecuted', ret); + }.bind(this); + if(state.allowed) { return state.execute.call(this, callback, this.params, this.appObject); }