mirror of https://github.com/artf/grapesjs.git
9 changed files with 159 additions and 19 deletions
@ -0,0 +1,6 @@ |
|||
define(['backbone','./ToolbarButton'], |
|||
function (Backbone, ToolbarButton) { |
|||
|
|||
return Backbone.Collection.extend({model: ToolbarButton}); |
|||
|
|||
}); |
|||
@ -0,0 +1,13 @@ |
|||
define(['backbone'], |
|||
function(Backbone) { |
|||
|
|||
return Backbone.Model.extend({ |
|||
|
|||
defaults: { |
|||
command: '', |
|||
attributes: {}, |
|||
}, |
|||
|
|||
|
|||
}); |
|||
}); |
|||
@ -0,0 +1,37 @@ |
|||
define(['backbone'], |
|||
function (Backbone) { |
|||
|
|||
return Backbone.View.extend({ |
|||
|
|||
events: { |
|||
'mousedown': 'handleClick', |
|||
}, |
|||
|
|||
attributes: function () { |
|||
return this.model.get('attributes'); |
|||
}, |
|||
|
|||
initialize: function(opts) { |
|||
this.editor = opts.config.editor; |
|||
}, |
|||
|
|||
handleClick: function() { |
|||
var command = this.model.get('command'); |
|||
|
|||
if (typeof command === 'function') { |
|||
command(this.editor); |
|||
} |
|||
|
|||
if (typeof command === 'string') { |
|||
this.editor.runCommand(command); |
|||
} |
|||
}, |
|||
|
|||
render: function () { |
|||
var config = this.editor.getConfig(); |
|||
this.el.className += ' ' + config.stylePrefix + 'toolbar-item'; |
|||
return this; |
|||
}, |
|||
|
|||
}); |
|||
}); |
|||
@ -0,0 +1,15 @@ |
|||
define(['backbone', 'Abstract/view/DomainViews', './ToolbarButtonView'], |
|||
function (Backbone, DomainViews, ToolbarButtonView) { |
|||
|
|||
return DomainViews.extend({ |
|||
|
|||
itemView: ToolbarButtonView, |
|||
|
|||
initialize: function(opts) { |
|||
this.config = {editor: opts.editor || ''}; |
|||
this.listenTo(this.collection, 'reset', this.render); |
|||
}, |
|||
|
|||
}); |
|||
|
|||
}); |
|||
Loading…
Reference in new issue