From 128f1e1281a640d21cb4ef7b587f66fdffc4ce7f Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 17 Dec 2013 16:37:51 +0100 Subject: [PATCH 1/3] [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(-) 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', From 90a9e522f3190a314fca289066943f312cd637f3 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 18 Dec 2013 12:49:01 +0100 Subject: [PATCH 2/3] [ADD] placeholder support on t-field A placeholder is looked up: 1. in the field's options ("placeholder") 2. on the t-field node itself (@placeholder) 3. on the field's column (.placeholder) The first one found is used as the @placeholder of the resulting node (in-HTML), and displayed when the field is empty and unfocused. If no placeholder is found, an empty field just gets a small padding in order to be easier to see & focus. bzr revid: xmo@openerp.com-20131218114901-xi3ye11x5pysq2a2 --- addons/website/models/ir_qweb.py | 11 ++++++++++- addons/website/static/src/css/editor.css | 8 +++++++- addons/website/static/src/css/editor.sass | 15 ++++++++++++--- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/addons/website/models/ir_qweb.py b/addons/website/models/ir_qweb.py index ea982bbe563..64a374119fa 100644 --- a/addons/website/models/ir_qweb.py +++ b/addons/website/models/ir_qweb.py @@ -73,12 +73,21 @@ class Field(orm.AbstractModel): def attributes(self, cr, uid, field_name, record, options, source_element, g_att, t_att, qweb_context, context=None): + if options is None: options = {} column = record._model._all_columns[field_name].column + attrs = [('data-oe-translate', 1 if column.translate else 0)] + + placeholder = options.get('placeholder') \ + or source_element.getAttribute('placeholder') \ + or getattr(column, 'placeholder', None) + if placeholder: + attrs.append(('placeholder', placeholder)) + return itertools.chain( super(Field, self).attributes(cr, uid, field_name, record, options, source_element, g_att, t_att, qweb_context, context=context), - [('data-oe-translate', 1 if column.translate else 0)] + attrs ) def value_from_string(self, value): diff --git a/addons/website/static/src/css/editor.css b/addons/website/static/src/css/editor.css index e40d6996850..e21bfc1fbe8 100644 --- a/addons/website/static/src/css/editor.css +++ b/addons/website/static/src/css/editor.css @@ -211,9 +211,15 @@ ul.oe_menu_editor .disclose { } .cke_widget_editable:empty:after { - content: " "; + opacity: 0.3; white-space: pre-wrap; } +.cke_widget_editable:not([placeholder]):empty::after { + content: " "; +} +.cke_widget_editable[placeholder]:not(:focus):empty::after { + content: attr(placeholder); +} .oe_carlos_danger { outline: 1px solid red !important; diff --git a/addons/website/static/src/css/editor.sass b/addons/website/static/src/css/editor.sass index 38b1d9f3436..ff62f416d8d 100644 --- a/addons/website/static/src/css/editor.sass +++ b/addons/website/static/src/css/editor.sass @@ -171,11 +171,20 @@ ul.oe_menu_editor // Breaks completely horribly crazy products listing page, so take it out. .cke_widget_wrapper position: static !important + // prevent inline widgets from entirely disappearing when their (textual) // content is removed -.cke_widget_editable:empty:after - content: " " - white-space: pre-wrap +.cke_widget_editable + // basic config + &:empty:after + opacity: 0.3 + white-space: pre-wrap + // no @placeholder -> just add some padding + &:not([placeholder]):empty::after + content: " " + // with placeholder and when not (yet) focused -> display placeholder + &[placeholder]:not(:focus):empty::after + content: attr(placeholder) .oe_carlos_danger outline: 1px solid red !important From f57869a89d84591cb2ddfe10df77a72debc30717 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 18 Dec 2013 14:05:15 +0100 Subject: [PATCH 3/3] [FIX] menu should honor the 'Open in a new window' option bzr revid: fme@openerp.com-20131218130515-7ztpt4qpfb9bq5ah --- addons/website/views/website_templates.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website/views/website_templates.xml b/addons/website/views/website_templates.xml index 4df613359e4..fa65b909c9a 100644 --- a/addons/website/views/website_templates.xml +++ b/addons/website/views/website_templates.xml @@ -13,7 +13,7 @@