[FIX] web_editor: use history to enable or disable save button
This commit is contained in:
@@ -120,8 +120,7 @@ editor.Class = Widget.extend({
|
||||
});
|
||||
},
|
||||
rte_changed: function () {
|
||||
// todo: use !rte.history.getEditableHasUndo().length (but phantomjs unknow error)
|
||||
this.$('button[data-action=save]').prop('disabled', !$('.o_dirty').length);
|
||||
this.$('button[data-action=save]').prop('disabled', !rte.history.getEditableHasUndo().length);
|
||||
},
|
||||
save: function () {
|
||||
return this.rte.save().then(function () {
|
||||
|
||||
@@ -51,10 +51,6 @@ var History = function History ($editable) {
|
||||
|
||||
$editable.trigger("content_changed");
|
||||
|
||||
if (!oSnap.bookmark || oSnap.event === "blur") {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
var r = oSnap.editable.innerHTML === "" ? range.create(oSnap.editable, 0) : range.createFromBookmark(oSnap.editable, oSnap.bookmark);
|
||||
r.select();
|
||||
@@ -105,7 +101,7 @@ var History = function History ($editable) {
|
||||
pos--;
|
||||
}
|
||||
this.applySnap(aUndo[Math.max(--pos,0)]);
|
||||
while (pos && (aUndo[pos].event === "blur" || aUndo[pos].event === "activate")) {
|
||||
while (pos && (aUndo[pos].event === "blur" || (aUndo[pos+1].editable === aUndo[pos].editable && aUndo[pos+1].contents === aUndo[pos].contents))) {
|
||||
this.applySnap(aUndo[--pos]);
|
||||
}
|
||||
};
|
||||
@@ -132,8 +128,8 @@ var History = function History ($editable) {
|
||||
this.redo = function () {
|
||||
if (!aUndo[pos+1]) { return; }
|
||||
this.applySnap(aUndo[++pos]);
|
||||
while (aUndo[pos+1] && (aUndo[pos].event === "blur" || aUndo[pos].event === "activate" || aUndo[pos].event === "undo")) {
|
||||
this.applySnap(aUndo[Math.max(++pos,aUndo.length-1)]);
|
||||
while (aUndo[pos+1] && aUndo[pos].event === "active") {
|
||||
this.applySnap(aUndo[pos++]);
|
||||
}
|
||||
};
|
||||
this.hasRedo = function () {
|
||||
|
||||
Reference in New Issue
Block a user