summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js/website.backend.iframe.js
diff options
context:
space:
mode:
authorChristophe Matthieu <chm@odoo.com>2015-02-09 13:40:49 +0100
committerJulien De Coster <jdc@odoo.com>2015-02-12 11:58:12 +0100
commit28ed28f9451edcb32f70daf7082d2ae91148b79c (patch)
tree9ad5ae4a272340247a81332895bd230952dbb5bd /addons/website/static/src/js/website.backend.iframe.js
parenta46a060f0fda429109fa1c34784c9267d57e2660 (diff)
[IMP] website: create a new web editor in the backend to edit html field with the website builder
Diffstat (limited to 'addons/website/static/src/js/website.backend.iframe.js')
-rw-r--r--addons/website/static/src/js/website.backend.iframe.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/addons/website/static/src/js/website.backend.iframe.js b/addons/website/static/src/js/website.backend.iframe.js
new file mode 100644
index 00000000000..86e472708ef
--- /dev/null
+++ b/addons/website/static/src/js/website.backend.iframe.js
@@ -0,0 +1,55 @@
+(function () {
+ 'use strict';
+
+ window.top.openerp[callback+"_set_value"] = function (value, fields_values) {
+ var $editable = $("#wrapwrap .o_editable:first");
+ if (value !== $editable.html()) {
+ openerp.website.editor_bar.rte.historyRecordUndo($editable);
+ openerp.website.editor_bar.snippets.make_active(false);
+ $editable.html(value);
+ }
+ };
+
+ openerp.website.EditorBar.include({
+ start: function () {
+ var res = this._super.apply(this, arguments);
+ if (location.search.indexOf("enable_editor") !== -1) {
+ this.on('rte:ready', this, function () {
+ $("#website-top-edit").hide();
+ if (window.top.openerp[callback+"_editor"]) {
+ window.top.openerp[callback+"_editor"](this);
+ }
+
+ var $editable = $("#wrapwrap .o_editable:first");
+ setTimeout(function () {
+ $($editable.find("*").filter(function () {return !this.children.length;}).first()[0] || $editable)
+ .focusIn().trigger("mousedown").trigger("keyup");
+ },0);
+
+ this.rte.on('change', this, function () {
+ window.top.openerp[callback+"_downup"]($editable.prop('innerHTML'));
+ });
+ });
+
+ var style = document.createElement("style");
+ style.textContent = "#wrapwrap > main > * { margin-top: 50px; }";
+ $("head").append(style);
+
+ this.on("snippets:ready", this, function () {
+ $(window.top).trigger("resize");
+ });
+
+ } else if (window.top.openerp[callback+"_editor"]) {
+ window.top.openerp[callback+"_editor"](this);
+ }
+ return res;
+ }
+ });
+
+ openerp.website.snippet.BuildingBlock.include({
+ _get_snippet_url: function () {
+ return snippets_url;
+ }
+ });
+
+})(); \ No newline at end of file