summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src
diff options
context:
space:
mode:
authorChristophe Matthieu <chm@odoo.com>2015-11-04 10:29:36 +0100
committerChristophe Matthieu <chm@odoo.com>2015-11-04 16:10:44 +0100
commit554bfa7d1075bff3598d7dec1bd084f3c4a70243 (patch)
treeef1b8781dca7bf2ad4929ed3c42bad3ddf02e1ab /addons/web_editor/static/src
parentbdb787a18dec45809b67c0f22e0705d2404eed83 (diff)
[FIX] web_editor: use history to enable or disable save button
Diffstat (limited to 'addons/web_editor/static/src')
-rw-r--r--addons/web_editor/static/src/js/editor.js3
-rw-r--r--addons/web_editor/static/src/js/rte.js10
2 files changed, 4 insertions, 9 deletions
diff --git a/addons/web_editor/static/src/js/editor.js b/addons/web_editor/static/src/js/editor.js
index f74df98b42a..88d86bc825b 100644
--- a/addons/web_editor/static/src/js/editor.js
+++ b/addons/web_editor/static/src/js/editor.js
@@ -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 () {
diff --git a/addons/web_editor/static/src/js/rte.js b/addons/web_editor/static/src/js/rte.js
index a87f9fcf1e8..d1f94ed46f5 100644
--- a/addons/web_editor/static/src/js/rte.js
+++ b/addons/web_editor/static/src/js/rte.js
@@ -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 () {