Browse Source

Update RTE components

pull/36/head
Artur Arseniev 10 years ago
parent
commit
b414d4c8ed
  1. 5
      src/commands/view/SelectComponent.js
  2. 18
      src/rich_text_editor/main.js
  3. 11
      src/rich_text_editor/view/CommandButtonsView.js
  4. 4
      src/rich_text_editor/view/TextEditorView.js

5
src/commands/view/SelectComponent.js

@ -117,7 +117,10 @@ define(function() {
* @private
*/
onClick: function(e) {
var s = $(e.target).data('model').get('stylable');
var m = $(e.target).data('model');
if(!m)
return;
var s = m.get('stylable');
if(!(s instanceof Array) && !s)
return;
this.onSelect(e, e.target);

18
src/rich_text_editor/main.js

@ -36,7 +36,7 @@ define(function(require) {
toolS.top = (dims.top - toolbar.$el.outerHeight()) + u;
toolS.left = dims.left + u;
}
this.bindToolbar(view).show();
this.show();
//Avoid closing edit mode clicking on toolbar
toolbar.$el.on('mousedown', this.disableProp);
},
@ -52,22 +52,6 @@ define(function(require) {
toolbar.$el.off('mousedown', this.disableProp);
},
/**
* Bind toolbar to element
* @param {Object} view
* @return {this}
* */
bindToolbar: function(view){
var id = tlbPfx + view.model.cid,
dId = tlbPfx + 'inited';
if(!view.$el.data(dId)){
view.$el.data(dId, 1);
view.$el.attr('id',id);
}
toolbar.updateTarget('#' + id);
return this;
},
/**
* Show toolbar
*

11
src/rich_text_editor/view/CommandButtonsView.js

@ -15,17 +15,6 @@ define(['backbone','./CommandButtonView'],
this.$el.data('helper',1);
},
/**
* Update RTE target pointer
* @param {String} target
*
* @return this
* */
updateTarget: function(target){
this.$el.attr('data-target', target);
return this;
},
render: function() {
var fragment = document.createDocumentFragment();
this.$el.empty();

4
src/rich_text_editor/view/TextEditorView.js

@ -102,10 +102,10 @@ define(['jquery'],
input.data(options.selectionMarker, color);
},
bindToolbar = function (toolbar, options) {
toolbar.find(toolbarBtnSelector).click(function () {
toolbar.find(toolbarBtnSelector).unbind().click(function () {
restoreSelection();
editor.focus();
execCommand($(this).data(options.commandRole));
editor.get(0).ownerDocument.execCommand($(this).data(options.commandRole));
saveSelection();
});
toolbar.find('[data-toggle=dropdown]').click(restoreSelection);

Loading…
Cancel
Save