|
|
|
@ -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; |
|
|
|
|
|
|
|
|