Browse Source

Add run and stop event to commands

pull/36/head
Artur Arseniev 10 years ago
parent
commit
2721980ea2
  1. 2
      bower.json
  2. 28
      dist/grapes.min.js
  3. 2
      package.json
  4. 8
      src/editor/main.js
  5. 12
      src/panels/view/ButtonView.js

2
bower.json

@ -1,7 +1,7 @@
{ {
"name": "grapesjs", "name": "grapesjs",
"description": "Open source Web Template Editor", "description": "Open source Web Template Editor",
"version": "0.3.4", "version": "0.3.5",
"author": "Artur Arseniev", "author": "Artur Arseniev",
"homepage": "http://grapesjs.com", "homepage": "http://grapesjs.com",
"main": [ "main": [

28
dist/grapes.min.js

File diff suppressed because one or more lines are too long

2
package.json

@ -1,7 +1,7 @@
{ {
"name": "grapesjs", "name": "grapesjs",
"description": "Open source Web Template Editor", "description": "Open source Web Template Editor",
"version": "0.3.4", "version": "0.3.5",
"author": "Artur Arseniev", "author": "Artur Arseniev",
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"homepage": "http://grapesjs.com", "homepage": "http://grapesjs.com",

8
src/editor/main.js

@ -283,8 +283,10 @@ define(function (require){
runCommand: function(id, options) { runCommand: function(id, options) {
var command = em.get('Commands').get(id); var command = em.get('Commands').get(id);
if(command) if(command){
command.run(this, this, options); command.run(this, this, options);
this.trigger('run:' + id);
}
}, },
/** /**
@ -297,8 +299,10 @@ define(function (require){
stopCommand: function(id, options) { stopCommand: function(id, options) {
var command = em.get('Commands').get(id); var command = em.get('Commands').get(id);
if(command) if(command){
command.stop(this, this, options); command.stop(this, this, options);
this.trigger('stop:' + id);
}
}, },
/** /**

12
src/panels/view/ButtonView.js

@ -208,9 +208,9 @@ function(Backbone, require) {
updateActive: function(){ updateActive: function(){
var command = null; var command = null;
var editor = this.em && this.em.get ? this.em.get('Editor') : null; var editor = this.em && this.em.get ? this.em.get('Editor') : null;
var commandName = this.model.get('command');
if(this.commands) if(this.commands)
command = this.commands.get(this.model.get('command')); command = this.commands.get(commandName);
if(this.model.get('active')){ if(this.model.get('active')){
@ -220,8 +220,10 @@ function(Backbone, require) {
if(this.parentM) if(this.parentM)
this.parentM.set('active', true, { silent: true }).trigger('checkActive'); this.parentM.set('active', true, { silent: true }).trigger('checkActive');
if(command) if(command){
command.run(editor, this.model, this.model.get('options')); command.run(editor, this.model, this.model.get('options'));
editor.trigger('run:' + commandName);
}
}else{ }else{
this.$el.removeClass(this.activeCls); this.$el.removeClass(this.activeCls);
@ -230,8 +232,10 @@ function(Backbone, require) {
if(this.parentM) if(this.parentM)
this.parentM.set('active', false, { silent: true }).trigger('checkActive'); this.parentM.set('active', false, { silent: true }).trigger('checkActive');
if(command) if(command){
command.stop(editor, this.model, this.model.get('options')); command.stop(editor, this.model, this.model.get('options'));
editor.trigger('stop:' + commandName);
}
} }
}, },

Loading…
Cancel
Save