Browse Source

Disable stateless button

pull/561/head
Artur Arseniev 8 years ago
parent
commit
bea192f10b
  1. 4
      dist/grapes.min.js
  2. 2
      package-lock.json
  3. 2
      package.json
  4. 49
      src/panels/view/ButtonView.js

4
dist/grapes.min.js

File diff suppressed because one or more lines are too long

2
package-lock.json

@ -1,6 +1,6 @@
{
"name": "grapesjs",
"version": "0.12.37",
"version": "0.12.38",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

2
package.json

@ -1,7 +1,7 @@
{
"name": "grapesjs",
"description": "Free and Open Source Web Builder Framework",
"version": "0.12.37",
"version": "0.12.38",
"author": "Artur Arseniev",
"license": "BSD-3-Clause",
"homepage": "http://grapesjs.com",

49
src/panels/view/ButtonView.js

@ -1,3 +1,4 @@
import { isString, isObject, isFunction } from 'underscore';
const $ = Backbone.$;
module.exports = Backbone.View.extend({
@ -197,40 +198,40 @@ module.exports = Backbone.View.extend({
* @return void
* */
updateActive() {
const model = this.model;
const context = model.get('context');
const parent = this.parentM;
var command = null;
var editor = this.em && this.em.get ? this.em.get('Editor') : null;
var commandName = this.model.get('command');
var commandName = model.get('command');
if (this.commands && typeof commandName === 'string') {
if (this.commands && isString(commandName)) {
command = this.commands.get(commandName);
} else if (commandName !== null && typeof commandName === 'object') {
} else if (isFunction(commandName)) {
command = { run: commandName };
} else if (commandName !== null && isObject(commandName)) {
command = commandName;
} else if (typeof commandName === 'function') {
command = {run: commandName};
}
if(this.model.get('active')){
if (model.get('active')) {
model.collection.deactivateAll(context);
model.set('active', true, { silent: true }).trigger('checkActive');
parent && parent.set('active', true, { silent: true }).trigger('checkActive');
this.model.collection.deactivateAll(this.model.get('context'));
this.model.set('active', true, { silent: true }).trigger('checkActive');
if(this.parentM)
this.parentM.set('active', true, { silent: true }).trigger('checkActive');
if(command && command.run){
command.run(editor, this.model, this.model.get('options'));
if (command && command.run) {
command.run(editor, model, model.get('options'));
editor.trigger('run:' + commandName);
}
}else{
this.$el.removeClass(this.activeCls);
this.model.collection.deactivateAll(this.model.get('context'));
if(this.parentM)
this.parentM.set('active', false, { silent: true }).trigger('checkActive');
// Disable button if there is no stop method
!command.stop && model.set('active', false);
} else {
this.$el.removeClass(this.activeCls);
model.collection.deactivateAll(context);
parent && parent.set('active', false, { silent: true }).trigger('checkActive');
if(command && command.stop){
command.stop(editor, this.model, this.model.get('options'));
if (command && command.stop) {
command.stop(editor, model, model.get('options'));
editor.trigger('stop:' + commandName);
}
}
@ -242,7 +243,7 @@ module.exports = Backbone.View.extend({
} else {
this.$el.removeClass(this.disableCls);
}
},
/**
@ -266,7 +267,7 @@ module.exports = Backbone.View.extend({
clicked(e) {
if(this.model.get('bntsVis') )
return;
if(this.model.get('disable') )
return;

Loading…
Cancel
Save