[FIX] web_editor: use history to enable or disable save button

This commit is contained in:
Christophe Matthieu
2015-11-04 16:10:44 +01:00
parent bdb787a18d
commit 554bfa7d10
2 changed files with 4 additions and 9 deletions
+1 -2
View File
@@ -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 () {
+3 -7
View File
@@ -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 () {