From 122ddb8e310df0a4cfd597cb49cbe8863f862d8b Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 13 Nov 2013 11:18:24 +0100 Subject: [IMP] rename list_pages to enumerate_pages, add a search method and a basic non-contiguous substring match bzr revid: xmo@openerp.com-20131113101824-uqatvqokkzhvi0ei --- addons/website/static/src/js/website.editor.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 5915ee5b359..af5763b9500 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -930,9 +930,10 @@ fetch_pages: function () { return openerp.jsonRpc('/web/dataset/call_kw', 'call', { model: 'website', - method: 'list_pages', + method: 'search_pages', args: [null], kwargs: { + limit: 10, context: website.get_context() }, }); -- cgit v1.2.3 From d15a6f426ddbd75a17cfd491e127966c7a1c03c6 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 13 Nov 2013 15:39:34 +0100 Subject: [IMP] replace selection list of existing CMS pages by FAYT via select2 bzr revid: xmo@openerp.com-20131113143934-je7dusgzj15f7li0 --- addons/website/static/src/js/website.editor.js | 83 +++++++++++++------------- 1 file changed, 43 insertions(+), 40 deletions(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index af5763b9500..994876d6c05 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -2,7 +2,7 @@ 'use strict'; var website = openerp.website; - // $.fn.data automatically parses value, '0'|'1' -> 0|1 + var _t = openerp._t; website.add_template_file('/website/static/src/xml/website.editor.xml'); website.dom_ready.done(function () { @@ -828,7 +828,7 @@ website.editor.LinkDialog = website.editor.Dialog.extend({ template: 'website.editor.dialog.link', events: _.extend({}, website.editor.Dialog.prototype.events, { - 'change .url-source': function (e) { this.changed($(e.target)); }, + 'change :input.url-source': function (e) { this.changed($(e.target)); }, 'mousedown': function (e) { var $target = $(e.target).closest('.list-group-item'); if (!$target.length || $target.hasClass('active')) { @@ -836,7 +836,7 @@ return; } - this.changed($target.find('.url-source')); + this.changed($target.find('.url-source').filter(':input')); }, 'click button.remove': 'remove_link', 'change input#link-text': function (e) { @@ -846,21 +846,36 @@ init: function (editor) { this._super(editor); // url -> name mapping for existing pages - this.pages = Object.create(null); this.text = null; }, start: function () { var self = this; - return $.when( - this.fetch_pages().done(this.proxy('fill_pages')), - this._super() - ).done(function () { - self.bind_data(); + this.$('#link-page').select2({ + minimumInputLength: 3, + placeholder: _t("New or existing page"), + query: function (q) { + // FIXME: out-of-order, abort + self.fetch_pages(q.term).then(function (results) { + var rs = _.map(results, function (r) { + return { id: r.url, text: r.name, }; + }); + rs.push({ + create: true, + id: q.term, + text: "Create " + q.term, + }); + q.callback({ + more: false, + results: rs + }); + }); + }, }); + return this._super().then(this.proxy('bind_data')); }, save: function () { var self = this, _super = this._super.bind(this); - var $e = this.$('.list-group-item.active .url-source'); + var $e = this.$('.list-group-item.active .url-source').filter(':input'); var val = $e.val(); if (!val || !$e[0].checkValidity()) { // FIXME: error message @@ -872,15 +887,18 @@ var done = $.when(); if ($e.hasClass('email-address')) { this.make_link('mailto:' + val, false, val); - } else if ($e.hasClass('existing')) { - self.make_link(val, false, this.pages[val]); - } else if ($e.hasClass('pages')) { - // Create the page, get the URL back - done = $.get(_.str.sprintf( - '/pagenew/%s?noredirect', encodeURI(val))) - .then(function (response) { - self.make_link(response, false, val); - }); + } else if ($e.hasClass('page')) { + var data = $e.select2('data'); + if (!data.create) { + self.make_link(data.id, false, data.text); + } else { + // Create the page, get the URL back + done = $.get(_.str.sprintf( + '/pagenew/%s?noredirect', encodeURI(data.id))) + .then(function (response) { + self.make_link(response, false, data.id); + }); + } } else { this.make_link(val, this.$('input.window-new').prop('checked')); } @@ -903,13 +921,6 @@ var match, $control; if ((match = /mailto:(.+)/.exec(href))) { $control = this.$('input.email-address').val(match[1]); - } else if (href in this.pages) { - $control = this.$('select.existing').val(href); - } else if ((match = /\/page\/(.+)/.exec(href))) { - var actual_href = '/page/website.' + match[1]; - if (actual_href in this.pages) { - $control = this.$('select.existing').val(actual_href); - } } if (!$control) { $control = this.$('input.url').val(href); @@ -921,33 +932,25 @@ this.$('input.window-new').prop('checked', new_window); }, changed: function ($e) { - this.$('.url-source').not($e).val(''); + this.$('.url-source').filter(':input').not($e).val('') + .filter(function () { return !!$(this).data('select2'); }) + .select2('data', null); $e.closest('.list-group-item') .addClass('active') .siblings().removeClass('active') .addBack().removeClass('has-error'); }, - fetch_pages: function () { + fetch_pages: function (term) { return openerp.jsonRpc('/web/dataset/call_kw', 'call', { model: 'website', method: 'search_pages', - args: [null], + args: [null, term], kwargs: { - limit: 10, + limit: 9, context: website.get_context() }, }); }, - fill_pages: function (results) { - var self = this; - var pages = this.$('select.existing')[0]; - _(results).each(function (result) { - self.pages[result.url] = result.name; - - pages.options[pages.options.length] = - new Option(result.name, result.url); - }); - }, }); website.editor.RTELinkDialog = website.editor.LinkDialog.extend({ start: function () { -- cgit v1.2.3 From 837aa436e5b31a06a8fab1a7bfcfdf97ab877f2b Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 13 Nov 2013 16:18:32 +0100 Subject: [IMP] abort FAYT requests when the next one comes in bzr revid: xmo@openerp.com-20131113151832-ym4hvpyhn5t7ocxs --- addons/website/static/src/js/website.editor.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 994876d6c05..245abd9960e 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -845,8 +845,9 @@ }), init: function (editor) { this._super(editor); - // url -> name mapping for existing pages this.text = null; + // Store last-performed request to be able to cancel/abort it. + this.req = null; }, start: function () { var self = this; @@ -941,7 +942,9 @@ .addBack().removeClass('has-error'); }, fetch_pages: function (term) { - return openerp.jsonRpc('/web/dataset/call_kw', 'call', { + var self = this; + if (this.req) { this.req.abort(); } + return this.req = openerp.jsonRpc('/web/dataset/call_kw', 'call', { model: 'website', method: 'search_pages', args: [null, term], @@ -949,6 +952,9 @@ limit: 9, context: website.get_context() }, + }).done(function () { + // request completed successfully -> unstore it + self.req = null; }); }, }); -- cgit v1.2.3 From ca0537ad4ae41065a43d1e8d549a63e8393c2d27 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 13 Nov 2013 16:57:04 +0100 Subject: [FIX] menu entry dialog to work correctly with select2 page picker bzr revid: xmo@openerp.com-20131113155704-7l0d87va0860h7dx --- addons/website/static/src/js/website.editor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 245abd9960e..22367e24d47 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -863,7 +863,7 @@ rs.push({ create: true, id: q.term, - text: "Create " + q.term, + text: _.str.sprintf(_t("Create page '%s'"), q.term), }); q.callback({ more: false, -- cgit v1.2.3 From 1b77b7646052bdb59e67a3f260d6c2c528b8f1e0 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 18 Nov 2013 13:49:58 +0100 Subject: [ADD] breadcrumb return_url to Website bzr revid: fme@openerp.com-20131118124958-j1t85mywopoawtk7 --- addons/website/static/src/js/website.editor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 74cf6ab81c0..27dd8c8e2f4 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -416,7 +416,7 @@ menu.append('
  • '); menu.append('
  • HTML Editor
  • '); menu.append('
  • Change Theme
  • '); - menu.append('
  • Install Apps
  • '); + menu.append('
  • Install Apps
  • '); self.trigger('rte:customize_menu_ready'); } ); -- cgit v1.2.3 From bb0badbf404102f4566e92b50be18c34489d856c Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 19 Nov 2013 12:06:12 +0100 Subject: [IMP] Simplify js_link2post event bzr revid: fme@openerp.com-20131119110612-uc4j1l6xexrt9fyt --- addons/website/static/src/js/website.editor.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 530d8470af8..1fe4149e78d 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -14,12 +14,7 @@ $(document).on('click', 'a.js_link2post', function (ev) { ev.preventDefault(); - var form = document.createElement('form'); - form.action = this.pathname; // restrict to same origin - form.method = 'POST'; - // TODO: support this.search as form input fields - $(this).append(form); - form.submit(); + website.form(this.pathname, 'POST'); }); $(document).on('hide.bs.dropdown', '.dropdown', function (ev) { -- cgit v1.2.3 From ba2ee4e2872b1cecbb9f066700339946c062e89a Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 19 Nov 2013 13:55:20 +0100 Subject: [FIX] cleanup image edition button on editor save bzr revid: xmo@openerp.com-20131119125520-qpts34qbx1oofdc1 --- addons/website/static/src/js/website.editor.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 1fe4149e78d..2281b6fd30d 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -85,7 +85,7 @@ // display button var $el = $(previousSelection = selected.$); - var $btn = $('') + var $btn = $('') .insertAfter($el) .click(function (e) { e.preventDefault(); @@ -100,6 +100,11 @@ left: $el.width() / 2 + position.left - $btn.outerWidth() / 2, }); }); + editor.on('destroy', function (evt) { + if (previousSelection) { + $('.image-edit-button').remove(); + } + }); //noinspection JSValidateTypes editor.addCommand('link', { -- cgit v1.2.3 From b6be7b87c646f83b54c69cc4b0217043cb7b6956 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 19 Nov 2013 14:11:13 +0100 Subject: [IMP] add img-responsive to images generated via dialog avoids having the image end up larger than its container bzr revid: xmo@openerp.com-20131119131113-9010p4tubk1yz10s --- addons/website/static/src/js/website.editor.js | 1 + 1 file changed, 1 insertion(+) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 2281b6fd30d..1a982fb7d30 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -1195,6 +1195,7 @@ if (!(element = this.element)) { element = editor.document.createElement('img'); element.addClass('img'); + element.addClass('img-responsive'); // focus event handler interactions between bootstrap (modal) // and ckeditor (RTE) lead to blowing the stack in Safari and // Chrome (but not FF) when this is done synchronously => -- cgit v1.2.3 From 8054696a43b968164b94575a6c97a8d69a16aa08 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Tue, 19 Nov 2013 14:57:04 +0100 Subject: [FIX] website editor for IE bzr revid: chm@openerp.com-20131119135704-rnva3skoh55h3eti --- addons/website/static/src/js/website.editor.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 1a982fb7d30..0dacbf0478e 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -694,9 +694,11 @@ self.setup_editables(root); - // disable firefox's broken table resizing thing - document.execCommand("enableObjectResizing", false, "false"); - document.execCommand("enableInlineTableEditing", false, "false"); + try { + // disable firefox's broken table resizing thing + document.execCommand("enableObjectResizing", false, "false"); + document.execCommand("enableInlineTableEditing", false, "false"); + } catch (e) {} self.trigger('rte:ready'); def.resolve(); -- cgit v1.2.3 From 5e7a8a957c449e857b0fd3718331e7b094618732 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Tue, 19 Nov 2013 15:32:59 +0100 Subject: [IMP] website editor: better rendering of the popover when failure write raise by except_osv. bzr revid: chm@openerp.com-20131119143259-vm7o3vq79358h56w --- addons/website/static/src/js/website.editor.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 0dacbf0478e..30af6fdee04 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -513,16 +513,23 @@ if (!_.isArray(failed)) { failed = [failed]; } _(failed).each(function (failure) { + var html = failure.error.exception_type === "except_osv"; + if (html) { + var msg = $("
    ").text(failure.error.message).html(); + var data = msg.substring(3,msg.length-2).split(/', u'/); + failure.error.message = '' + data[0] + '
    ' + data[1]; + } $(root).find('.' + failure.id) .removeClass(failure.id) .popover({ + html: html, trigger: 'hover', content: failure.error.message, placement: 'auto top', }) // Force-show popovers so users will notice them. .popover('show'); - }) + }); }); }); }, -- cgit v1.2.3 From fd02a389e99bca1c8b3773915e94c8a49ac84449 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 20 Nov 2013 10:11:47 +0100 Subject: [REM] apparently unnecessary icons bzr revid: xmo@openerp.com-20131120091147-4vshzojq6mwhvice --- addons/website/static/src/js/website.editor.js | 2 -- 1 file changed, 2 deletions(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 30af6fdee04..895bc8864c6 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -129,13 +129,11 @@ label: 'Link', command: 'link', toolbar: 'links,10', - icon: '/website/static/lib/ckeditor/plugins/link/icons/link.png', }); editor.ui.addButton('Image', { label: 'Image', command: 'image', toolbar: 'insert,10', - icon: '/website/static/lib/ckeditor/plugins/image/icons/image.png', }); editor.setKeystroke(CKEDITOR.CTRL + 76 /*L*/, 'link'); -- cgit v1.2.3 From 6b10be15b245e05adac2a54f0321305c6d5076d9 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Wed, 20 Nov 2013 12:52:50 +0100 Subject: [IMP] website snippet: add group for styles snippets, add custom picture with style snippet, mouseover and mouseout preview, fix dark css class in demo data bzr revid: chm@openerp.com-20131120115250-etqv5ofqguze0zsj --- addons/website/static/src/js/website.editor.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 895bc8864c6..feb8e403c54 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -834,6 +834,7 @@ events: { 'hidden.bs.modal': 'destroy', 'click button.save': 'save', + 'click button[data-dismiss="modal"]': 'cancel', }, init: function (editor) { this._super(); @@ -847,6 +848,8 @@ save: function () { this.close(); }, + cancel: function () { + }, close: function () { this.$el.modal('hide'); }, @@ -1127,6 +1130,9 @@ }); return this._super(); }, + cancel: function () { + this.trigger('cancel'); + }, /** * Sets the provided image url as the dialog's value-to-save and -- cgit v1.2.3 From fee8cb0fff1773648ea3c246a14470d92840686b Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 21 Nov 2013 12:07:48 +0100 Subject: [FIX] reimplement [Edit] button on images Button implementation turned out to be crap: * Didn't work at all in Firefox (!) * Unreliable in webkit, some types of image selection wouldn't correctly activate the button -> * changed RTEImageDialog to take an (optional) image element, used as the "source element" if provided. This allows greater reliability for events which may leave selection in debatable or variable (across browsers) state * setup and teardown button on hover, using selection triggered issues with oe_overlay thing where e.g. the first click on the button would work but the second one would not (it'd be intercepted by the overlay as far as I can tell). This also saves a click for user, they will see the [Edit] button immediately when putting the cursor over the image. bzr revid: xmo@openerp.com-20131121110748-s5e2ne3etpzwi2a6 --- addons/website/static/src/js/website.editor.js | 60 +++++++++++++++----------- 1 file changed, 34 insertions(+), 26 deletions(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index feb8e403c54..e8544221b00 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -30,8 +30,8 @@ function link_dialog(editor) { return new website.editor.RTELinkDialog(editor).appendTo(document.body); } - function image_dialog(editor) { - return new website.editor.RTEImageDialog(editor).appendTo(document.body); + function image_dialog(editor, image) { + return new website.editor.RTEImageDialog(editor, image).appendTo(document.body); } // only enable editors manually @@ -53,7 +53,7 @@ && !element.data('cke-realelement') && !element.isReadOnly() && (element.data('oe-model') !== 'ir.ui.view')) { - image_dialog(editor); + image_dialog(editor, element); return; } @@ -69,13 +69,9 @@ }, null, null, 500); var previousSelection; - editor.on('selectionChange', function (evt) { - var selected = evt.data.path.lastElement; - if (previousSelection) { - // cleanup previous selection - $(previousSelection).next().remove(); - previousSelection = null; - } + $(editor.element.$).on('mouseenter', 'img', function () { + if (previousSelection) { return; } + var selected = new CKEDITOR.dom.element(this); if (!selected.is('img') || selected.data('cke-realelement') || selected.isReadOnly() @@ -84,13 +80,13 @@ } // display button - var $el = $(previousSelection = selected.$); + var $el = $((previousSelection = selected).$); var $btn = $('') .insertAfter($el) .click(function (e) { e.preventDefault(); e.stopPropagation(); - image_dialog(editor); + image_dialog(editor, selected); }); var position = $el.position(); @@ -99,6 +95,14 @@ top: $el.height() / 2 + position.top - $btn.outerHeight() / 2, left: $el.width() / 2 + position.left - $btn.outerWidth() / 2, }); + }).on('mouseleave', 'img', function (e) { + var $button = $(previousSelection.$).next('button'); + $button.css('visibility', 'hidden'); + var el = document.elementFromPoint(e.clientX, e.clientY); + $button.css('visibility', ''); + if (el === this) { return; } + $button.remove(); + previousSelection = null; }); editor.on('destroy', function (evt) { if (previousSelection) { @@ -1182,26 +1186,30 @@ }, }); website.editor.RTEImageDialog = website.editor.ImageDialog.extend({ - init: function () { - this._super.apply(this, arguments); + init: function (editor, image) { + this._super(editor); + + this.element = image; this.on('start', this, this.proxy('started')); this.on('save', this, this.proxy('saved')); }, started: function (holder) { - var selection = this.editor.getSelection(); - var el = selection && selection.getSelectedElement(); - this.element = null; - - if (el && el.is('img')) { - this.element = el; - _(this.image_styles).each(function (style) { - if (el.hasClass(style)) { - holder.style = style; - } - }); - holder.url = el.getAttribute('src'); + if (!this.element) { + var selection = this.editor.getSelection(); + this.element = selection && selection.getSelectedElement(); } + + var el = this.element; + if (!el || !el.is('img')) { + return; + } + _(this.image_styles).each(function (style) { + if (el.hasClass(style)) { + holder.style = style; + } + }); + holder.url = el.getAttribute('src'); }, saved: function (data) { var element, editor = this.editor; -- cgit v1.2.3 From 32147fbffc3d3781fb571f3c8a6de3ced22316fb Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 21 Nov 2013 16:45:01 +0100 Subject: [REM] bootstrap link configuration combo, it has served its testing purposes bzr revid: xmo@openerp.com-20131121154501-vrs26caromm6ebgb --- addons/website/static/src/js/website.editor.js | 153 +------------------------ 1 file changed, 1 insertion(+), 152 deletions(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index e8544221b00..ae673dd811b 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -228,157 +228,6 @@ } }); - CKEDITOR.plugins.add('bootstrapcombo', { - requires: 'richcombo', - - init: function (editor) { - var config = editor.config; - - editor.ui.addRichCombo('BootstrapLinkCombo', { - // default title - label: "Links", - // hover - title: "Link styling", - toolbar: 'styles,10', - allowedContent: ['a'], - - panel: { - css: [ - '/website/static/lib/bootstrap/css/bootstrap.css', - CKEDITOR.skin.getPath( 'editor' ) - ].concat( config.contentsCss ), - multiSelect: true, - }, - - types: { - 'basic': 'btn-default', - 'primary': 'btn-primary', - 'success': 'btn-success', - 'info': 'btn-info', - 'warning': 'btn-warning', - 'danger': 'btn-danger', - }, - - sizes: { - 'large': 'btn-lg', - 'default': '', - 'small': 'btn-sm', - 'extra small': 'btn-xs', - }, - - init: function () { - this.add('', 'Reset'); - this.startGroup("Types"); - for(var type in this.types) { - if (!this.types.hasOwnProperty(type)) { continue; } - var cls = this.types[type]; - var el = _.str.sprintf( - '%s', - cls, type); - this.add(type, el); - } - this.startGroup("Sizes"); - for (var size in this.sizes) { - if (!this.sizes.hasOwnProperty(size)) { continue; } - cls = this.sizes[size]; - - el = _.str.sprintf( - '%s', - cls, size); - this.add(size, el); - } - this.commit(); - }, - onRender: function () { - var self = this; - editor.on('selectionChange', function (e) { - var path = e.data.path, el; - - if (!(el = path.contains('a'))) { - self.element = null; - self.disable(); - return; - } - - self.enable(); - // This is crap, but getting the currently selected - // element from within onOpen absolutely does not - // work, so store the "current" element in the - // widget instead - self.element = el; - }); - setTimeout(function () { - // Because I can't find any normal hook where the - // bloody button's bloody element is available - self.disable(); - }, 0); - }, - onOpen: function () { - this.showAll(); - this.unmarkAll(); - - for(var val in this.types) { - if (!this.types.hasOwnProperty(val)) { continue; } - var cls = this.types[val]; - if (!this.element.hasClass(cls)) { continue; } - - this.mark(val); - break; - } - - var found; - for(val in this.sizes) { - if (!this.sizes.hasOwnProperty(val)) { continue; } - cls = this.sizes[val]; - if (!cls || !this.element.hasClass(cls)) { continue; } - - found = true; - this.mark(val); - break; - } - if (!found && this.element.hasClass('btn')) { - this.mark('default'); - } - }, - onClick: function (value) { - editor.focus(); - editor.fire('saveShapshot'); - - // basic btn setup - var el = this.element; - if (!el.hasClass('btn')) { - el.addClass('btn'); - el.addClass('btn-default'); - } - - if (!value) { - this.setClass(this.types); - this.setClass(this.sizes); - el.removeClass('btn'); - } else if (value in this.types) { - this.setClass(this.types, value); - } else if (value in this.sizes) { - this.setClass(this.sizes, value); - } - - editor.fire('saveShapshot'); - }, - setClass: function (classMap, value) { - var element = this.element; - _(classMap).each(function (cls) { - if (!cls) { return; } - element.removeClass(cls); - }.bind(this)); - - var cls = classMap[value]; - if (cls) { - element.addClass(cls); - } - } - }); - }, - }); - var editor = new website.EditorBar(); var $body = $(document.body); editor.prependTo($body).then(function () { @@ -814,7 +663,7 @@ "Image", "TableButton" ]},{ name: 'styles', items: [ - "Styles", "BootstrapLinkCombo" + "Styles" ]} ], // styles dropdown in toolbar -- cgit v1.2.3 From 233e460b5222025ae96d3a3269ce5153392e8160 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 21 Nov 2013 17:05:16 +0100 Subject: [FIX] forgot to tell ckeditor not to load removed bootstrap combo plugin bzr revid: xmo@openerp.com-20131121160516-a29x498ode34p1ml --- addons/website/static/src/js/website.editor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index ae673dd811b..d1cb5781eba 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -641,7 +641,7 @@ fillEmptyBlocks: false, filebrowserImageUploadUrl: "/website/attach", // Support for sharedSpaces in 4.x - extraPlugins: 'sharedspace,customdialogs,tablebutton,oeref,bootstrapcombo', + extraPlugins: 'sharedspace,customdialogs,tablebutton,oeref', // Place toolbar in controlled location sharedSpaces: { top: 'oe_rte_toolbar' }, toolbar: [{ -- cgit v1.2.3 From 1f2a40e3f78277a90b357b1e26d195bd548bec28 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 22 Nov 2013 11:11:54 +0100 Subject: [FIX] horizontal centering of edition button on images centered with margin: 0 auto in webkit-based browsers bzr revid: xmo@openerp.com-20131122101154-fsae9uz33smy2ja9 --- addons/website/static/src/js/website.editor.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index d1cb5781eba..aedd5b011d9 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -90,10 +90,18 @@ }); var position = $el.position(); + // http://bugs.jquery.com/ticket/5445#comment:6 + // if the image has margin: x auto for centering, FF & IE + // will report top/left as the "correct" value and + // marginTop/marginLeft at "0px", webkit browsers will + // report top/left as 0-ish and set marginTop and + // marginLeft + var image_top = position.top + parseInt($el.css('marginTop'), 10); + var image_left = position.left + parseInt($el.css('marginLeft'), 10); $btn.css({ position: 'absolute', - top: $el.height() / 2 + position.top - $btn.outerHeight() / 2, - left: $el.width() / 2 + position.left - $btn.outerWidth() / 2, + top: $el.height() / 2 + image_top - $btn.outerHeight() / 2, + left: $el.width() / 2 + image_left - $btn.outerWidth() / 2, }); }).on('mouseleave', 'img', function (e) { var $button = $(previousSelection.$).next('button'); -- cgit v1.2.3 From 264fe7d98bb1fa28fde30cbe823e51b90d5e8eed Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 22 Nov 2013 11:23:22 +0100 Subject: [ADD] small transparency when hovering editable images, so [Edit] button stands out more bzr revid: xmo@openerp.com-20131122102322-s776o3f80bku3f4a --- addons/website/static/src/js/website.editor.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index aedd5b011d9..cce7b09644a 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -103,19 +103,23 @@ top: $el.height() / 2 + image_top - $btn.outerHeight() / 2, left: $el.width() / 2 + image_left - $btn.outerWidth() / 2, }); + $el.css('opacity', 0.75); }).on('mouseleave', 'img', function (e) { - var $button = $(previousSelection.$).next('button'); + var $previous = $(previousSelection.$); + var $button = $previous.next('button'); $button.css('visibility', 'hidden'); var el = document.elementFromPoint(e.clientX, e.clientY); $button.css('visibility', ''); if (el === this) { return; } $button.remove(); + $previous.css('opacity', ''); previousSelection = null; }); editor.on('destroy', function (evt) { - if (previousSelection) { - $('.image-edit-button').remove(); - } + if (!previousSelection) { return; } + $('.image-edit-button') + .prev().css('opacity', '').end() + .remove(); }); //noinspection JSValidateTypes -- cgit v1.2.3 From 53793703de74c9745429e213517caafc8dac6853 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 22 Nov 2013 16:11:24 +0100 Subject: [ADD] dropdown for link style bzr revid: xmo@openerp.com-20131122151124-1n7cnwldm3ej6wz7 --- addons/website/static/src/js/website.editor.js | 152 ++++++++++++++++++++++++- 1 file changed, 150 insertions(+), 2 deletions(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index cce7b09644a..cee4409240d 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -218,6 +218,154 @@ } }); + CKEDITOR.plugins.add('linkstyle', { + requires: 'panelbutton,floatpanel', + init: function (editor) { + var label = "Link Style"; + + editor.ui.add('LinkStyle', CKEDITOR.UI_PANELBUTTON, { + label: label, + title: label, + icon: '/website/static/src/img/bglink.png', + modes: { wysiwyg: true }, + editorFocus: true, + panel: { + css: '/website/static/lib/bootstrap/css/bootstrap.css', + attributes: { 'role': 'listbox', 'aria-label': label }, + }, + + types: { + 'btn-default': _t("Basic"), + 'btn-primary': _t("Primary"), + 'btn-success': _t("Success"), + 'btn-info': _t("Info"), + 'btn-warning': _t("Warning"), + 'btn-danger': _t("Danger"), + }, + sizes: { + 'btn-xs': _t("Extra Small"), + 'btn-sm': _t("Small"), + '': _t("Default"), + 'btn-lg': _t("Large") + }, + + onRender: function () { + var self = this; + editor.on('selectionChange', function (e) { + var path = e.data.path, el; + + if (!(e = path.contains('a')) || e.isReadOnly()) { + self.disable(); + return; + } + + self.enable(); + }); + // no hook where button is available, so wait + // "some time" after render. + setTimeout(function () { + self.disable(); + }, 0) + }, + enable: function () { + this.setState(CKEDITOR.TRISTATE_OFF); + }, + disable: function () { + this.setState(CKEDITOR.TRISTATE_DISABLED); + }, + + onOpen: function () { + var link = get_selected_link(editor); + var id = this._.id; + var block = this._.panel._.panel._.blocks[id]; + var $root = $(block.element.$); + $root.find('button').removeClass('active').removeProp('disabled'); + + // enable buttons matching link state + for (var type in this.types) { + if (!this.types.hasOwnProperty(type)) { continue; } + if (!link.hasClass(type)) { continue; } + + $root.find('button[data-type=types].' + type) + .addClass('active'); + } + var found; + for (var size in this.sizes) { + if (!this.sizes.hasOwnProperty(size)) { continue; } + if (!size || !link.hasClass(size)) { continue; } + found = true; + $root.find('button[data-type=sizes].' + size) + .addClass('active'); + } + if (!found && link.hasClass('btn')) { + $root.find('button[data-type="sizes"][data-set-class=""]') + .addClass('active'); + } + }, + + onBlock: function (panel, block) { + var self = this; + block.autoSize = true; + + var html = ['
    ']; + html.push('
    '); + _(this.types).each(function (label, key) { + html.push(_.str.sprintf( + '', + key, key, label)); + }); + html.push('
    '); + html.push('
    '); + _(this.sizes).each(function (label, key) { + html.push(_.str.sprintf( + '', + key, key, label)); + }); + html.push('
    '); + html.push(''); + html.push('
    '); + + block.element.setHtml(html.join(' ')); + var $panel = $(block.element.$); + $panel.on('click', 'button', function () { + self.clicked(this); + }); + }, + clicked: function (button) { + editor.focus(); + editor.fire('saveSnapshot'); + + var $button = $(button), + $link = $(get_selected_link(editor).$); + if (!$link.hasClass('btn')) { + $link.addClass('btn btn-default'); + } + switch($button.data('type')) { + case 'reset': + $link.removeClass('btn') + .removeClass(_.keys(this.types).join(' ')) + .removeClass(_.keys(this.sizes).join(' ')); + break; + case 'types': + $link.removeClass(_.keys(this.types).join(' ')) + .addClass($button.data('set-class')); + break; + case 'sizes': + $link.removeClass(_.keys(this.sizes).join(' ')) + .addClass($button.data('set-class')); + } + this._.panel.hide(); + + editor.fire('saveSnapshot'); + }, + + }); + } + }); + CKEDITOR.plugins.add('oeref', { requires: 'widget', @@ -653,7 +801,7 @@ fillEmptyBlocks: false, filebrowserImageUploadUrl: "/website/attach", // Support for sharedSpaces in 4.x - extraPlugins: 'sharedspace,customdialogs,tablebutton,oeref', + extraPlugins: 'sharedspace,customdialogs,tablebutton,oeref,linkstyle', // Place toolbar in controlled location sharedSpaces: { top: 'oe_rte_toolbar' }, toolbar: [{ @@ -665,7 +813,7 @@ "Superscript", "TextColor", "BGColor", "RemoveFormat" ]},{ name: 'span', items: [ - "Link", "Blockquote", "BulletedList", + "Link", "LinkStyle", "Blockquote", "BulletedList", "NumberedList", "Indent", "Outdent" ]},{ name: 'justify', items: [ -- cgit v1.2.3 From 52b8226a83d87fd23cf4bd6d6d720edf4975014c Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 25 Nov 2013 11:18:19 +0100 Subject: [FIX] on completion error, tell user there are no results not sure whether and how an error could/should be reported to the user. For now, it's automatically logged into the console. bzr revid: xmo@openerp.com-20131125101819-u2akhr16bd5kcsmf --- addons/website/static/src/js/website.editor.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index cee4409240d..adb60c7f362 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -912,6 +912,8 @@ more: false, results: rs }); + }, function () { + q.callback({more: false, results: []}); }); }, }); @@ -995,8 +997,8 @@ limit: 9, context: website.get_context() }, - }).done(function () { - // request completed successfully -> unstore it + }).always(function () { + // request completed -> unstore it self.req = null; }); }, -- cgit v1.2.3 From 4679bfd283d0af50233afc9e1c6ecd18e7d663cf Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 25 Nov 2013 11:22:28 +0100 Subject: [IMP] lower completion trigger threshold to 1 could be removed entirely, but not sure users would realize there are plenty more urls to look for... bzr revid: xmo@openerp.com-20131125102228-igkzfsh50y1ytwef --- addons/website/static/src/js/website.editor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index adb60c7f362..339aedcc27c 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -895,7 +895,7 @@ start: function () { var self = this; this.$('#link-page').select2({ - minimumInputLength: 3, + minimumInputLength: 1, placeholder: _t("New or existing page"), query: function (q) { // FIXME: out-of-order, abort -- cgit v1.2.3 From b05db3495c36ec5e46158f3bc3f7911280bc4fb7 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 25 Nov 2013 13:05:48 +0100 Subject: [IMP] in crawler testing, indicate at which page the failed url was found bzr revid: xmo@openerp.com-20131125120548-0s7xnhszd48e1u9v --- addons/website/static/src/js/website.editor.js | 1 - 1 file changed, 1 deletion(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 339aedcc27c..f3344c36e78 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -898,7 +898,6 @@ minimumInputLength: 1, placeholder: _t("New or existing page"), query: function (q) { - // FIXME: out-of-order, abort self.fetch_pages(q.term).then(function (results) { var rs = _.map(results, function (r) { return { id: r.url, text: r.name, }; -- cgit v1.2.3 From 854e45395882efe0968c1d50d3d1a4761627865f Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 26 Nov 2013 10:23:39 +0100 Subject: [CHG] remove opacity changes on image hover bzr revid: xmo@openerp.com-20131126092339-7wqx54t8iuvy8e9a --- addons/website/static/src/js/website.editor.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index f3344c36e78..6d6094a5d65 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -103,7 +103,6 @@ top: $el.height() / 2 + image_top - $btn.outerHeight() / 2, left: $el.width() / 2 + image_left - $btn.outerWidth() / 2, }); - $el.css('opacity', 0.75); }).on('mouseleave', 'img', function (e) { var $previous = $(previousSelection.$); var $button = $previous.next('button'); @@ -112,14 +111,11 @@ $button.css('visibility', ''); if (el === this) { return; } $button.remove(); - $previous.css('opacity', ''); previousSelection = null; }); - editor.on('destroy', function (evt) { + editor.on('destroy', function () { if (!previousSelection) { return; } - $('.image-edit-button') - .prev().css('opacity', '').end() - .remove(); + $('.image-edit-button').remove(); }); //noinspection JSValidateTypes -- cgit v1.2.3 From 3731d33852046e4b56d9d61cdf93c90f1ec10892 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 26 Nov 2013 13:47:39 +0100 Subject: [FIX] don't perform page creation when no name was provided bzr revid: xmo@openerp.com-20131126124739-djk6nbifyo087bmz --- addons/website/static/src/js/website.editor.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 6d6094a5d65..52b3f19e1ba 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -562,7 +562,9 @@ window_title: "New Page", input: "Page Title", }).then(function (val) { - document.location = '/pagenew/' + encodeURI(val); + if (val) { + document.location = '/pagenew/' + encodeURI(val); + } }); }, }); -- cgit v1.2.3 From 44af6d1e09aa3bec6967ac3eb4e67b3e9215fb08 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 26 Nov 2013 17:01:48 +0100 Subject: [IMP] significantly improve handling of trying to create a new page which already exists # Through the menu Rather than output a generic error (500 due to an IntegrityError), return a templated 409 letting the user either visit the page-which-already-exists-with-the-name-he'd-picked or open the page creation dialog again for a second round. An alternative would be to promote the website.prompt use to full-blown dialog as a result of selecting "New Page" and handle the "page already exists" case without even closing the dialog. # Through the link dialog Added an RPC call to check if a page already exists (essentially a cheaper version of opening /page/whatever and checking whether it's a 200 over JSON-RPC), if the page matching the completion term already exists, do *not* add the choice of creating the page, only provide completions from existing pages. bzr revid: xmo@openerp.com-20131126160148-wrk4zvz9istscwa0 --- addons/website/static/src/js/website.editor.js | 52 +++++++++++++++++--------- 1 file changed, 34 insertions(+), 18 deletions(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 52b3f19e1ba..c50ad392887 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -888,7 +888,8 @@ this._super(editor); this.text = null; // Store last-performed request to be able to cancel/abort it. - this.req = null; + this.page_exists_req = null; + this.search_pages_req = null; }, start: function () { var self = this; @@ -896,15 +897,20 @@ minimumInputLength: 1, placeholder: _t("New or existing page"), query: function (q) { - self.fetch_pages(q.term).then(function (results) { + $.when( + self.page_exists(q.term), + self.fetch_pages(q.term) + ).then(function (exists, results) { var rs = _.map(results, function (r) { return { id: r.url, text: r.name, }; }); - rs.push({ - create: true, - id: q.term, - text: _.str.sprintf(_t("Create page '%s'"), q.term), - }); + if (!exists) { + rs.push({ + create: true, + id: q.term, + text: _.str.sprintf(_t("Create page '%s'"), q.term), + }); + } q.callback({ more: false, results: rs @@ -983,20 +989,30 @@ .siblings().removeClass('active') .addBack().removeClass('has-error'); }, - fetch_pages: function (term) { + call: function (method, args, kwargs) { var self = this; - if (this.req) { this.req.abort(); } - return this.req = openerp.jsonRpc('/web/dataset/call_kw', 'call', { + var req = method + '_req'; + + if (this[req]) { this[req].abort(); } + + return this[req] = openerp.jsonRpc('/web/dataset/call_kw', 'call', { model: 'website', - method: 'search_pages', - args: [null, term], - kwargs: { - limit: 9, - context: website.get_context() - }, + method: method, + args: args, + kwargs: kwargs, }).always(function () { - // request completed -> unstore it - self.req = null; + self[req] = null; + }); + }, + page_exists: function (term) { + return this.call('page_exists', [null, term], { + context: website.get_context(), + }); + }, + fetch_pages: function (term) { + return this.call('search_pages', [null, term], { + limit: 9, + context: website.get_context(), }); }, }); -- cgit v1.2.3 From 9a399dfb9461acfb6ebe53779aed1012421f2846 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Fri, 29 Nov 2013 17:00:45 +0100 Subject: [FIX] website snippets: quote, quotes slider, parallax bzr revid: chm@openerp.com-20131129160045-527o2i6unyyymr6e --- addons/website/static/src/js/website.editor.js | 1 + 1 file changed, 1 insertion(+) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index c50ad392887..c1d31bcd7cc 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -104,6 +104,7 @@ left: $el.width() / 2 + image_left - $btn.outerWidth() / 2, }); }).on('mouseleave', 'img', function (e) { + if (!previousSelection) { return; } var $previous = $(previousSelection.$); var $button = $previous.next('button'); $button.css('visibility', 'hidden'); -- cgit v1.2.3 From fdfa7362ac00bbf47344643191ecbe56fdbf61e2 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 2 Dec 2013 12:33:04 +0100 Subject: [FIX] image fields getting overly dirty the addition and removal of the [edit] button on hover would be caught by the mutation observer and mark the image field as dirty, even when it had not actually been altered, leaving to spurious save events for said field. bzr revid: xmo@openerp.com-20131202113304-xpgu43se5er1ho7y --- addons/website/static/src/js/website.editor.js | 32 ++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index c1d31bcd7cc..78e452ef76c 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -1371,6 +1371,11 @@ // a/@href, ...) _(mutations).chain() .filter(function (m) { + // ignore any change related to mundane image-edit-button + if (m.target && m.target.className + && m.target.className.indexOf('image-edit-button') !== -1) { + return false; + } switch(m.type) { case 'attributes': // ignore .cke_focus being added or removed // if attribute is not a class, can't be .cke_focus change @@ -1384,8 +1389,11 @@ // ignore mutation if the *only* change is .cke_focus return change.length !== 1 || change[0] === 'cke_focus'; case 'childList': - //
    appears when focusing RTE in FF, ignore - return m.addedNodes.length !== 1 || m.addedNodes[0].nodeName !== 'BR'; + // Remove ignorable nodes from addedNodes or removedNodes, + // if either set remains non-empty it's considered to be an + // impactful change. Otherwise it's ignored. + return !!remove_mundane_nodes(m.addedNodes).length || + !!remove_mundane_nodes(m.removedNodes).length; default: return true; } @@ -1402,4 +1410,24 @@ .uniq() .each(function (node) { $(node).trigger('content_changed'); }) }); + function remove_mundane_nodes(nodes) { + if (!nodes || !nodes.length) { return []; } + + var output = []; + for(var i=0; i appears when focusing RTE in FF, ignore + continue; + } + if (node.className.indexOf('image-edit-button') !== -1) { + // [Edit] button added and removed on image hover, don't count + // as making parent node dirty + continue; + } + + output.push(node); + } + return output; + } })(); -- cgit v1.2.3 From d53a289c5b205fab11d4448ae159f7b9370551f8 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 2 Dec 2013 12:38:25 +0100 Subject: [REM] leftover thing bzr revid: xmo@openerp.com-20131202113825-c5jbqs17nihip81t --- addons/website/static/src/js/website.editor.js | 1 - 1 file changed, 1 deletion(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 78e452ef76c..b5caac71d74 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -1403,7 +1403,6 @@ while (node && !$(node).hasClass('oe_editable')) { node = node.parentNode; } - $(m.target).trigger('node_changed'); return node; }) .compact() -- cgit v1.2.3 From 9d9d3f207e7e6089d01f0b7fe26d7fd9cda0ddce Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 3 Dec 2013 12:13:23 +0100 Subject: [IMP] cancellation of RTE * rename Cancel to Discard for clarity (user test) * add intermediate dialog in case of mis-click, use 'danger' button style to clearly indicate this is a destructive operation bzr revid: xmo@openerp.com-20131203111323-9mx7aazfpsybe718 --- addons/website/static/src/js/website.editor.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index b5caac71d74..5128a3028ce 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -555,7 +555,20 @@ }); }, cancel: function () { - website.reload(); + new $.Deferred(function (d) { + var $dialog = $(openerp.qweb.render('website.editor.discard')).appendTo(document.body); + $dialog.on('click', '.btn-danger', function () { + d.resolve(); + }).on('hidden.bs.modal', function () { + d.reject(); + }); + d.always(function () { + $dialog.remove(); + }); + $dialog.modal('show'); + }).then(function () { + website.reload(); + }) }, new_page: function (ev) { ev.preventDefault(); -- cgit v1.2.3 From abf5c885109bb55e8bc3637d8428766b56f7f832 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Tue, 3 Dec 2013 16:55:36 +0100 Subject: [FIX] website: customize: apply fontawesome to icons bzr revid: chm@openerp.com-20131203155536-de2htsq0rwv6oepz --- addons/website/static/src/js/website.editor.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 5128a3028ce..64726b5625b 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -416,8 +416,8 @@ if (item.header) { menu.append(''); } else { - menu.append(_.str.sprintf('
  • %s
  • ', - item.id, item.active ? '' : '-empty', item.name)); + menu.append(_.str.sprintf('
  • %s
  • ', + item.id, item.active ? '' : '-check', item.name)); } }); // Adding Static Menus -- cgit v1.2.3 From 49f357da541296d4b7a34318386fd758c3680b27 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 3 Dec 2013 17:16:30 +0100 Subject: [FIX] rte crashes when inserting new lines We deal with text nodes in this case bzr revid: fme@openerp.com-20131203161630-f34r1nrqcb4m6jge --- addons/website/static/src/js/website.editor.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 64726b5625b..1bdc6bb9292 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -1428,14 +1428,16 @@ var output = []; for(var i=0; i appears when focusing RTE in FF, ignore - continue; - } - if (node.className.indexOf('image-edit-button') !== -1) { - // [Edit] button added and removed on image hover, don't count - // as making parent node dirty - continue; + if (node.nodeType === document.ELEMENT_NODE) { + if (node.nodeName === 'BR' && node.getAttribute('type') === '_moz') { + //
    appears when focusing RTE in FF, ignore + continue; + } + if (node.className.indexOf('image-edit-button') !== -1) { + // [Edit] button added and removed on image hover, don't count + // as making parent node dirty + continue; + } } output.push(node); -- cgit v1.2.3 From 31381c1469e4970dae7c0f00b49c7556cc6c3cf7 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 4 Dec 2013 11:42:25 +0100 Subject: [FIX] Disable form submition in editable mode bzr revid: fme@openerp.com-20131204104225-2s3jp325731mqd92 --- addons/website/static/src/js/website.editor.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 1bdc6bb9292..52e67ecd9e3 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -17,6 +17,11 @@ website.form(this.pathname, 'POST'); }); + $(document).on('submit', '.cke_editable form', function (ev) { + // Disable form submition in editable mode + ev.preventDefault(); + }); + $(document).on('hide.bs.dropdown', '.dropdown', function (ev) { // Prevent dropdown closing when a contenteditable children is focused if (ev.originalEvent -- cgit v1.2.3 From b79e56d1af9a2d9e10631df79c4325ea7d0854e1 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 4 Dec 2013 11:52:12 +0100 Subject: [IMP] clarity of links edition According to user tests, users have a hard time finding out how to edit links. Thus, add same system as image edition (a small button appearing when hovering the element). Extract and unify these two to avoid redundancies between handlings as they are broadly similar (only details such as label, positioning and size of button relative to the element being hovered really change, the lifecycle itself is the same). The main setup still isn't very clean, there might be a better way to do it. bzr revid: xmo@openerp.com-20131204105212-u0a49nbvwilgtfst --- addons/website/static/src/js/website.editor.js | 148 +++++++++++++++---------- 1 file changed, 92 insertions(+), 56 deletions(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 52e67ecd9e3..a834f5f8162 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -73,57 +73,6 @@ link_dialog(editor); }, null, null, 500); - var previousSelection; - $(editor.element.$).on('mouseenter', 'img', function () { - if (previousSelection) { return; } - var selected = new CKEDITOR.dom.element(this); - if (!selected.is('img') - || selected.data('cke-realelement') - || selected.isReadOnly() - || selected.data('oe-model') === 'ir.ui.view') { - return; - } - - // display button - var $el = $((previousSelection = selected).$); - var $btn = $('') - .insertAfter($el) - .click(function (e) { - e.preventDefault(); - e.stopPropagation(); - image_dialog(editor, selected); - }); - - var position = $el.position(); - // http://bugs.jquery.com/ticket/5445#comment:6 - // if the image has margin: x auto for centering, FF & IE - // will report top/left as the "correct" value and - // marginTop/marginLeft at "0px", webkit browsers will - // report top/left as 0-ish and set marginTop and - // marginLeft - var image_top = position.top + parseInt($el.css('marginTop'), 10); - var image_left = position.left + parseInt($el.css('marginLeft'), 10); - $btn.css({ - position: 'absolute', - top: $el.height() / 2 + image_top - $btn.outerHeight() / 2, - left: $el.width() / 2 + image_left - $btn.outerWidth() / 2, - }); - }).on('mouseleave', 'img', function (e) { - if (!previousSelection) { return; } - var $previous = $(previousSelection.$); - var $button = $previous.next('button'); - $button.css('visibility', 'hidden'); - var el = document.elementFromPoint(e.clientX, e.clientY); - $button.css('visibility', ''); - if (el === this) { return; } - $button.remove(); - previousSelection = null; - }); - editor.on('destroy', function () { - if (!previousSelection) { return; } - $('.image-edit-button').remove(); - }); - //noinspection JSValidateTypes editor.addCommand('link', { exec: function (editor) { @@ -463,6 +412,7 @@ this.rte = new website.RTE(this); this.rte.on('change', this, this.proxy('rte_changed')); this.rte.on('rte:ready', this, function () { + self.setup_hover_buttons(); self.trigger('rte:ready'); }); @@ -586,6 +536,97 @@ } }); }, + + /** + * Creates a "hover" button for image and link edition + * + * @param {String} label the button's label + * @param {Function} editfn edition function, called when clicking the button + * @param {String} [classes] additional classes to set on the button + * @returns {jQuery} + */ + make_hover_button: function (label, editfn, classes) { + return $(openerp.qweb.render('website.editor.hoverbutton', { + label: label, + classes: classes, + })).hide().appendTo(document.body).click(function (e) { + e.preventDefault(); + e.stopPropagation(); + editfn.call(this, e); + }); + }, + /** + * For UI clarity, during RTE edition when the user hovers links and + * images a small button should appear to make the capability clear, + * as not all users think of double-clicking the image or link. + */ + setup_hover_buttons: function () { + var editor = this.rte.editor; + var $link_button = this.make_hover_button(_t("Edit Link"), function () { + var sel = new CKEDITOR.dom.element(previous); + editor.getSelection().selectElement(sel); + link_dialog(editor); + $link_button.hide(); + previous = null; + }, 'btn-xs'); + var $image_button = this.make_hover_button(_t("Edit Image"), function () { + image_dialog(editor, new CKEDITOR.dom.element(previous)); + $image_button.hide(); + previous = null; + }); + + // previous is the state of the button-trigger: it's the + // currently-ish hovered element which can trigger a button showing. + // -ish, because when moving to the button itself ``previous`` is + // still set to the element having triggered showing the button. + var previous; + $(editor.element.$).on('mouseover', 'a, img', function (e) { + // Back from edit button -> ignore + if (previous && previous === this) { return; } + + var selected = new CKEDITOR.dom.element(this); + if (selected.data('oe-model') === 'ir.ui.view' + || selected.data('cke-realelement') + || selected.isReadOnly()) { + return; + } + + previous = this; + var $selected = $(this); + var position = $selected.offset(); + if ($selected.is('img')) { + var image_top = position.top + parseInt($selected.css('marginTop'), 10); + var image_left = position.left + parseInt($selected.css('marginLeft'), 10); + $link_button.hide(); + // center button on image + $image_button.show().offset({ + top: $selected.outerHeight() / 2 + + image_top + - $image_button.outerHeight() / 2, + left: $selected.outerWidth() / 2 + + image_left + - $image_button.outerWidth() / 2, + }); + } else { + $image_button.hide(); + // put button below link, horizontally centered + $link_button.show().offset({ + top: $selected.outerHeight() + + position.top, + left: $selected.outerWidth() / 2 + + position.left + - $link_button.outerWidth() / 2 + }) + } + }).on('mouseleave', 'a, img', function (e) { + var current = document.elementFromPoint(e.clientX, e.clientY); + if (current === $link_button[0] || current === $image_button[0]) { + return; + } + $image_button.add($link_button).hide(); + previous = null; + }); + } }); var blocks_selector = _.keys(CKEDITOR.dtd.$block).join(','); @@ -1438,11 +1479,6 @@ //
    appears when focusing RTE in FF, ignore continue; } - if (node.className.indexOf('image-edit-button') !== -1) { - // [Edit] button added and removed on image hover, don't count - // as making parent node dirty - continue; - } } output.push(node); -- cgit v1.2.3 From b1765e2834b0e04596b85eab29ceabc135d5b585 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Wed, 4 Dec 2013 17:17:54 +0100 Subject: [IMP] website: slip layout bzr revid: chm@openerp.com-20131204161754-5dq4bt7gghnk878c --- addons/website/static/src/js/website.editor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index a834f5f8162..aa3d7adac6c 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -371,7 +371,7 @@ menu.append(''); } else { menu.append(_.str.sprintf('
  • %s
  • ', - item.id, item.active ? '' : '-check', item.name)); + item.id, item.active ? '-check' : '', item.name)); } }); // Adding Static Menus -- cgit v1.2.3 From 04045c369931ea0c4359ddff0196c163dc5e6db5 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 4 Dec 2013 17:28:05 +0100 Subject: [IMP] use ckeditor 4.3 final feature to disable widget draghandle entirely instead of relying on CSS bzr revid: xmo@openerp.com-20131204162805-rikk5kbbx304tol6 --- addons/website/static/src/js/website.editor.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index a834f5f8162..b7bc451009b 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -323,6 +323,7 @@ init: function (editor) { editor.widgets.add('oeref', { editables: { text: '*' }, + draggable: false, upcast: function (el) { return el.attributes['data-oe-type'] @@ -331,6 +332,7 @@ }); editor.widgets.add('monetary', { editables: { text: 'span.oe_currency_value' }, + draggable: false, upcast: function (el) { return el.attributes['data-oe-type'] === 'monetary'; -- cgit v1.2.3 From a1ecb6923b8673f9f4e00f4e27e0a6a12491edd8 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 5 Dec 2013 12:39:08 +0100 Subject: [ADD] saving of oddly localized/formatted stuff bzr revid: xmo@openerp.com-20131205113908-9tr575ejn7hanhi7 --- addons/website/static/src/js/website.editor.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index b7bc451009b..6269013dd25 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -326,8 +326,18 @@ draggable: false, upcast: function (el) { - return el.attributes['data-oe-type'] - && el.attributes['data-oe-type'] !== 'monetary'; + var matches = el.attributes['data-oe-type'] && el.attributes['data-oe-type'] !== 'monetary'; + if (!matches) { return false; } + + if (el.attributes['data-oe-original']) { + while (el.children.length) { + el.children[0].remove(); + } + el.add(new CKEDITOR.htmlParser.text( + el.attributes['data-oe-original'] + )); + } + return true; }, }); editor.widgets.add('monetary', { -- cgit v1.2.3 From 083e88167e5c376a9559e6c38fd3af193266ff2f Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Wed, 11 Dec 2013 17:33:05 +0100 Subject: [IMP] website: save (button) or discard (link), on left in modal bzr revid: chm@openerp.com-20131211163305-5qwltn11k2ph179o --- addons/website/static/src/js/website.editor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index f88a876d82f..92556be0c98 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -366,7 +366,7 @@ events: { 'click button[data-action=edit]': 'edit', 'click button[data-action=save]': 'save', - 'click button[data-action=cancel]': 'cancel', + 'click a[data-action=cancel]': 'cancel', 'click a[data-action=new_page]': 'new_page', }, container: 'body', -- cgit v1.2.3 From bf876739fe1b3623f8c5c99a6fd9c1b80b317c0d Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 13 Dec 2013 10:20:25 +0100 Subject: [REM] undo RTE button by fp demand, apparently unseen & unused by users bzr revid: xmo@openerp.com-20131213092025-thlltl0xjxq0noyp --- addons/website/static/src/js/website.editor.js | 3 --- 1 file changed, 3 deletions(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 92556be0c98..40b7820e89a 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -875,9 +875,6 @@ // Place toolbar in controlled location sharedSpaces: { top: 'oe_rte_toolbar' }, toolbar: [{ - name: 'clipboard', items: [ - "Undo" - ]},{ name: 'basicstyles', items: [ "Bold", "Italic", "Underline", "Strike", "Subscript", "Superscript", "TextColor", "BGColor", "RemoveFormat" -- cgit v1.2.3 From 98c4e6b3d4023663e4fda1244d57dbf94219fd9d Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 16 Dec 2013 14:44:24 +0100 Subject: [IMP] editability criteria for links and images if a link or image is an editing host (has @contenteditable=true), its body is editable *but* its attributes should not be considered editable: if the attributes come from a t-att-*, @contenteditable will be set on the node itself. such elements should be ignored by the link & image dialog handling thing, as editing their attributes has undesirable effects. bzr revid: xmo@openerp.com-20131216134424-fdqs03i9pidbmaqt --- addons/website/static/src/js/website.editor.js | 37 ++++++++++++++++++-------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 40b7820e89a..1e3ef0da66a 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -32,6 +32,27 @@ }); }); + /** + * An editing host is an HTML element with @contenteditable=true, or the + * child of a document in designMode=on (but that one's not supported) + * + * https://dvcs.w3.org/hg/editing/raw-file/tip/editing.html#editing-host + */ + function is_editing_host(element) { + return element.getAttribute('contentEditable') === 'true'; + } + /** + * Checks that both the element's content *and the element itself* are + * editable: an editing host is considered non-editable because its content + * is editable but its attributes should not be considered editable + */ + function is_editable_node(element) { + return !(element.data('oe-model') === 'ir.ui.view' + || element.data('cke-realelement') + || is_editing_host(element) + || element.isReadOnly()); + } + function link_dialog(editor) { return new website.editor.RTELinkDialog(editor).appendTo(document.body); } @@ -54,18 +75,13 @@ init: function (editor) { editor.on('doubleclick', function (evt) { var element = evt.data.element; - if (element.is('img') - && !element.data('cke-realelement') - && !element.isReadOnly() - && (element.data('oe-model') !== 'ir.ui.view')) { + if (element.is('img') && is_editable_node(element)) { image_dialog(editor, element); return; } element = get_selected_link(editor) || evt.data.element; - if (element.isReadOnly() - || !element.is('a') - || element.data('oe-model')) { + if (!(element.is('a') && is_editable_node(element))) { return; } @@ -360,7 +376,8 @@ }); $body.css('padding-top', '50px'); // Not working properly: editor.$el.outerHeight()); }; - /* ----- TOP EDITOR BAR FOR ADMIN ---- */ + + /* ----- TOP EDITOR BAR FOR ADMIN ---- */ website.EditorBar = openerp.Widget.extend({ template: 'website.editorbar', events: { @@ -597,9 +614,7 @@ if (previous && previous === this) { return; } var selected = new CKEDITOR.dom.element(this); - if (selected.data('oe-model') === 'ir.ui.view' - || selected.data('cke-realelement') - || selected.isReadOnly()) { + if (!is_editable_node(selected)) { return; } -- cgit v1.2.3 From 128f1e1281a640d21cb4ef7b587f66fdffc4ce7f Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 17 Dec 2013 16:37:51 +0100 Subject: [FIX] odd behavior in cke widgets in "block-level" widgets (divs), when hitting [return] instead of adding a newline in the widget a new bit of widget may be added. This is caused by an incompability between widgets and the enterKey plugin. Remove enterKey, behavior on [Return] is slightly worse (always inserts br) but widgets don't get broken. See https://dev.ckeditor.com/ticket/11326 for issue in upstream. bzr revid: xmo@openerp.com-20131217153751-7fbwp34o8kac9x94 --- addons/website/static/src/js/website.editor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 1e3ef0da66a..c7c5620c9a4 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -859,7 +859,7 @@ var plugins = [ 'a11yhelp', 'basicstyles', 'blockquote', 'clipboard', 'colorbutton', 'colordialog', 'dialogadvtab', - 'elementspath', 'enterkey', 'entities', 'filebrowser', + 'elementspath', /*'enterkey',*/ 'entities', 'filebrowser', 'find', 'floatingspace','format', 'htmlwriter', 'iframe', 'indentblock', 'indentlist', 'justify', 'list', 'pastefromword', 'pastetext', 'preview', -- cgit v1.2.3 From 9abcc28884688bd251c5a9de77b3afda11dcec90 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 18 Dec 2013 18:39:15 +0100 Subject: [IMP] Set EditorBar height programmatically bzr revid: fme@openerp.com-20131218173915-ds5jeyfypbaefrqf --- addons/website/static/src/js/website.editor.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index c7c5620c9a4..661c6d80a5f 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -374,7 +374,6 @@ editor.edit(); } }); - $body.css('padding-top', '50px'); // Not working properly: editor.$el.outerHeight()); }; /* ----- TOP EDITOR BAR FOR ADMIN ---- */ @@ -423,7 +422,7 @@ }, start: function() { var self = this; - + this.height = null; this.saving_mutex = new openerp.Mutex(); this.$('#website-top-edit').hide(); @@ -443,12 +442,26 @@ this.rte.on('rte:ready', this, function () { self.setup_hover_buttons(); self.trigger('rte:ready'); + self.check_height(); }); + $(window).on('resize', _.debounce(this.check_height.bind(this), 50)); + this.check_height(); + return $.when( this._super.apply(this, arguments), this.rte.appendTo(this.$('#website-top-edit .nav.pull-right')) - ); + ).then(function () { + self.check_height(); + }); + }, + check_height: function () { + var editor_height = this.$el.outerHeight(); + if (this.height != editor_height) { + this.height = editor_height; + $(document.body).css('padding-top', this.height); + this.trigger('resize', this.height); + } }, edit: function () { this.$buttons.edit.prop('disabled', true); @@ -456,7 +469,7 @@ this.$('#website-top-edit').show(); $('.css_non_editable_mode_hidden').removeClass("css_non_editable_mode_hidden"); - this.rte.start_edition(); + this.rte.start_edition().then(this.check_height.bind(this)); }, rte_changed: function () { this.$buttons.save.prop('disabled', false); -- cgit v1.2.3 From b180d69808e7ef16e3854ef347cc8aa57eca718f Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 18 Dec 2013 21:16:19 +0100 Subject: [IMP] Better events naming for EditorBar height related stuff bzr revid: fme@openerp.com-20131218201619-vja6dv0sctokep3b --- addons/website/static/src/js/website.editor.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'addons/website/static/src/js/website.editor.js') diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 661c6d80a5f..51f14a0f6d5 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -422,7 +422,6 @@ }, start: function() { var self = this; - this.height = null; this.saving_mutex = new openerp.Mutex(); this.$('#website-top-edit').hide(); @@ -457,10 +456,9 @@ }, check_height: function () { var editor_height = this.$el.outerHeight(); - if (this.height != editor_height) { - this.height = editor_height; - $(document.body).css('padding-top', this.height); - this.trigger('resize', this.height); + if (this.get('height') != editor_height) { + $(document.body).css('padding-top', editor_height); + this.set('height', editor_height); } }, edit: function () { -- cgit v1.2.3