From e2676729b0e5b0a58e0d19b109deaf8e1983f791 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 13 Sep 2013 12:47:39 +0200 Subject: [PATCH 01/72] [REM] listing of existing attachments in base dialog bzr revid: xmo@openerp.com-20130913104739-ma8kc0dum1ikvikd --- .../website/static/src/xml/website.editor.xml | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/addons/website/static/src/xml/website.editor.xml b/addons/website/static/src/xml/website.editor.xml index fabf2185f2a..03d0cd19849 100644 --- a/addons/website/static/src/xml/website.editor.xml +++ b/addons/website/static/src/xml/website.editor.xml @@ -95,24 +95,19 @@ enctype="multipart/form-data" target="fileframe" class="col-sm-8"> +
+ + +

— or —

+

Image URL

-
-

— or —

- - -
-

— or —

-
-

Pick an existing attachment

-
-
From dee82b1382e0439aa4104df57841d2a23d4706e3 Mon Sep 17 00:00:00 2001 From: ddm Date: Fri, 13 Sep 2013 13:40:53 +0200 Subject: [PATCH 02/72] [IMP] SEO title and description bzr revid: ddm@openerp.com-20130913114053-93vm1xn18bdc0nu2 --- addons/website/static/src/js/website.seo.js | 69 ++++++++++++++++----- addons/website/views/views.xml | 2 + 2 files changed, 55 insertions(+), 16 deletions(-) diff --git a/addons/website/static/src/js/website.seo.js b/addons/website/static/src/js/website.seo.js index e9053740eae..e7983e57af1 100644 --- a/addons/website/static/src/js/website.seo.js +++ b/addons/website/static/src/js/website.seo.js @@ -96,6 +96,10 @@ website.seo.KeywordList = openerp.Widget.extend({ template: 'website.seo_list', maxKeywords: 10, + init: function (parent, htmlPage) { + this.htmlPage = htmlPage; + this._super(parent); + }, keywords: function () { var result = []; this.$('span.js_seo_keyword').each(function () { @@ -143,7 +147,7 @@ website.seo.ImageList = openerp.Widget.extend({ start: function () { var self = this; - new website.seo.PageParser().images().each(function (index, image) { + new website.seo.HtmlPage().images().each(function (index, image) { new website.seo.Image(self, image).appendTo(self.$el); }); }, @@ -163,14 +167,29 @@ }, }); - website.seo.PageParser = openerp.Class.extend({ + website.seo.HtmlPage = openerp.Class.extend({ url: function () { var url = window.location.href; var hashIndex = url.indexOf('#'); return hashIndex >= 0 ? url.substring(0, hashIndex) : url; }, title: function () { - return $(document.title).text(); + return $('title').text(); + }, + changeTitle: function (title) { + $('title').text(title); + }, + description: function () { + return $('meta[name=description]').attr('value'); + }, + changeDescription: function (description) { + return $('meta[name=description]').attr('value', description); + }, + keywords: function () { + return $('meta[name=keywords]').attr('value').split(","); + }, + changeKeywords: function (keywords) { + return $('meta[name=keywords]').attr('value', keyword.join(",")); }, headers: function (tag) { return $('#wrap '+tag).map(function () { @@ -208,23 +227,26 @@ website.seo.Configurator = openerp.Widget.extend({ template: 'website.seo_configuration', events: { - 'keypress input[name=seo_page_keywords]': 'confirmKeyword', + 'keyup input[name=seo_page_keywords]': 'confirmKeyword', + 'keyup input[name=seo_page_title]': 'titleChanged', + 'keyup textarea[name=seo_page_description]': 'descriptionChanged', 'click button[data-action=add]': 'addKeyword', 'click button[data-action=update]': 'update', - 'hidden.bs.modal': 'destroy' + 'hidden.bs.modal': 'destroy', }, maxTitleSize: 65, maxDescriptionSize: 155, start: function () { var self = this; var $modal = self.$el; - var pageParser = new website.seo.PageParser(); - $modal.find('.js_seo_page_url').text(pageParser.url()); - $modal.find('input[name=seo_page_title]').val(pageParser.title()); - self.suggestImprovements(pageParser); + var htmlPage = this.htmlPage = new website.seo.HtmlPage(); + $modal.find('.js_seo_page_url').text(htmlPage.url()); + $modal.find('input[name=seo_page_title]').val(htmlPage.title()); + $modal.find('textarea[name=seo_page_description]').val(htmlPage.description()); + self.suggestImprovements(htmlPage); self.imageList = new website.seo.ImageList(self); self.imageList.appendTo($modal.find('.js_seo_image_list')); - self.keywordList = new website.seo.KeywordList(self); + self.keywordList = new website.seo.KeywordList(self, htmlPage); self.keywordList.on('list-full', self, function () { $modal.find('input[name=seo_page_keywords]') .attr('readonly', "readonly") @@ -242,7 +264,7 @@ self.keywordList.add(word); }); self.keywordList.appendTo($modal.find('.js_seo_keywords_list')); - var companyName = pageParser.company().toLowerCase(); + var companyName = htmlPage.company().toLowerCase(); self.addKeyword(companyName); $modal.modal(); }, @@ -255,14 +277,14 @@ type: type, }).appendTo(self.$('.js_seo_tips')); } - var pageParser = parser || new website.seo.PageParser(); - if (pageParser.headers('h1').length === 0) { + var htmlPage = parser || new website.seo.HtmlPage(); + if (htmlPage.headers('h1').length === 0) { tips.push({ type: 'warning', message: "You don't have an <h1> tag on your page.", }); } - if (pageParser.headers('h1').length > 1) { + if (htmlPage.headers('h1').length > 1) { tips.push({ type: 'warning', message: "You have more than one <h1> tag on your page.", @@ -289,13 +311,28 @@ }, update: function () { var data = { - title: this.$('input[name=seo_page_title]').val(), - description: this.$('input[name=seo_page_title]').val(), + title: this.htmlPage.title(), + description: this.htmlPage.description(), keywords: this.keywordList.keywords(), images: this.imageList.images(), }; console.log(data); // TODO Persist changes + this.$el.modal('hide'); + }, + titleChanged: function () { + var self = this; + setTimeout(function () { + var title = self.$('input[name=seo_page_title]').val(); + self.htmlPage.changeTitle(title); + }, 1); + }, + descriptionChanged: function () { + var self = this; + setTimeout(function () { + var description = self.$('textarea[name=seo_page_description]').attr('value'); + self.htmlPage.changeDescription(description); + }, 1); }, }); })(); diff --git a/addons/website/views/views.xml b/addons/website/views/views.xml index 14b020b7927..6fe3f0cee3f 100644 --- a/addons/website/views/views.xml +++ b/addons/website/views/views.xml @@ -19,6 +19,8 @@ <t t-esc="title or res_company.name"/> + + From f16b61cbe61a77cf331a54ea11520322e7730739 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 13 Sep 2013 13:41:43 +0200 Subject: [PATCH 03/72] [ADD] separate attachment dialog selector bzr revid: xmo@openerp.com-20130913114143-v799fvf08rpiox3r --- addons/website/static/src/css/editor.css | 21 ++++++++- addons/website/static/src/css/editor.sass | 21 +++++++++ .../website/static/src/js/website.editor.js | 43 ++++++++++++++++--- .../website/static/src/xml/website.editor.xml | 10 ++++- 4 files changed, 87 insertions(+), 8 deletions(-) diff --git a/addons/website/static/src/css/editor.css b/addons/website/static/src/css/editor.css index e895b1209ce..9607aef55db 100644 --- a/addons/website/static/src/css/editor.css +++ b/addons/website/static/src/css/editor.css @@ -1,4 +1,4 @@ -@charset "utf-8"; +@charset "UTF-8"; /* ---- CKEditor Minimal Reset ---- */ .navbar.navbar-inverse .cke_chrome { border: none; @@ -100,6 +100,25 @@ table.editorbar-panel td.selected { user-select: auto; } +.modal .existing-attachments a.thumbnail { + position: relative; +} +.modal .existing-attachments a.thumbnail.selected:before { + text-decoration: none; + font-size: 150%; + background-color: rgba(0, 0, 0, 0.3); + color: #21dc0f; + content: "✔"; + height: 2em; + width: 2em; + text-align: center; + padding: 5px; + border-radius: 4px 0; + position: absolute; + top: 0; + left: 0; +} + /* ---- SNIPPET EDITOR ---- */ #oe_snippets { position: fixed; diff --git a/addons/website/static/src/css/editor.sass b/addons/website/static/src/css/editor.sass index 96c77108ff6..1dd71acefdc 100644 --- a/addons/website/static/src/css/editor.sass +++ b/addons/website/static/src/css/editor.sass @@ -91,6 +91,27 @@ table.editorbar-panel -o-user-select: auto user-select: auto +.modal .existing-attachments a.thumbnail + position: relative + + &.selected:before + text-decoration: none + font-size: 150% + background-color: rgba(0, 0, 0, 0.3) + color: #21dc0f + content: "✔" + + height: 2em + width: 2em + text-align: center + padding: 5px + border-radius: 4px 0 + + position: absolute + top: 0 + left: 0 + + /* ---- SNIPPET EDITOR ---- */ #oe_snippets diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 5a8801bba38..77bed2f9215 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -589,7 +589,7 @@ }, 'change input[type=file]': 'file_selection', 'change input.url': 'preview_image', - 'click .existing-attachments a': 'select_existing', + 'click a[href=#existing]': 'browse_existing', }), start: function () { var selection = this.editor.getSelection(); @@ -600,9 +600,7 @@ this.set_image(el.getAttribute('src')); } - return $.when( - this._super(), - this.fetch_existing().then(this.proxy('fetched_existing'))); + return this._super(); }, save: function () { var url = this.$('input.url').val(); @@ -660,6 +658,29 @@ this.$('img.image-preview').attr('src', image); }, + browse_existing: function (e) { + e.preventDefault(); + new website.editor.ExistingImageDialog(this).appendTo(document.body); + }, + }); + + website.editor.ExistingImageDialog = website.editor.Dialog.extend({ + template: 'website.editor.dialog.image.existing', + events: _.extend({}, website.editor.Dialog.prototype.events, { + 'click .existing-attachments a': 'select_existing', + }), + init: function (parent) { + this.image = null; + this.parent = parent; + this._super(parent.editor); + }, + + start: function () { + return $.when( + this._super(), + this.fetch_existing().then(this.proxy('fetched_existing'))); + }, + fetch_existing: function () { // FIXME: lazy load attachments? return openerp.jsonRpc('/web/dataset/call_kw', 'call', { @@ -681,11 +702,21 @@ .values() .value(); this.$('.existing-attachments').replaceWith( - openerp.qweb.render('website.editor.dialog.image.existing', {rows: rows})); + openerp.qweb.render( + 'website.editor.dialog.image.existing.content', {rows: rows})); }, select_existing: function (e) { e.preventDefault(); - this.set_image(e.currentTarget.getAttribute('href')); + this.$('a.thumbnail.selected').removeClass('selected'); + + $(e.currentTarget).addClass('selected'); + }, + save: function () { + var link = this.$('a.thumbnail.selected').attr('href'); + if (link) { + this.parent.set_image(link); + } + this._super(); }, }); diff --git a/addons/website/static/src/xml/website.editor.xml b/addons/website/static/src/xml/website.editor.xml index 03d0cd19849..98a5af1c184 100644 --- a/addons/website/static/src/xml/website.editor.xml +++ b/addons/website/static/src/xml/website.editor.xml @@ -103,7 +103,7 @@

— or —

- + Browse your images

Image URL

@@ -120,6 +120,14 @@ + + Pick an existing attachment: +
+
+
+ + +
From 74678c7632b7506d360e8a36990136a0dad7d434 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Fri, 13 Sep 2013 13:44:56 +0200 Subject: [PATCH 04/72] [IMP] website editor snippet: image-text, text-imge, carousel bzr revid: chm@openerp.com-20130913114456-sacksn4frv2w9re1 --- addons/website/static/src/css/editor.css | 3 + addons/website/static/src/css/editor.sass | 2 + .../website/static/src/js/website.snippets.js | 28 +++++-- .../static/src/xml/website.snippets.xml | 83 ++++++++++++++----- addons/website/views/views.xml | 2 +- 5 files changed, 87 insertions(+), 31 deletions(-) diff --git a/addons/website/static/src/css/editor.css b/addons/website/static/src/css/editor.css index 0afd2be7f06..917db1b059a 100644 --- a/addons/website/static/src/css/editor.css +++ b/addons/website/static/src/css/editor.css @@ -285,6 +285,9 @@ table.editorbar-panel td.selected { .oe_overlay .oe_overlay_options .oe_move .js_box_move { margin-left: -50%; } +.oe_overlay .oe_overlay_options .dropdown-menu select, .oe_overlay .oe_overlay_options .dropdown-menu input { + display: block; +} .oe_overlay.oe_active .oe_overlay_options { display: block; } diff --git a/addons/website/static/src/css/editor.sass b/addons/website/static/src/css/editor.sass index 380564b0cec..3dc35b77a85 100644 --- a/addons/website/static/src/css/editor.sass +++ b/addons/website/static/src/css/editor.sass @@ -252,6 +252,8 @@ table.editorbar-panel left: 50% .js_box_move margin-left: -50% + .dropdown-menu select,.dropdown-menu input + display: block &.oe_active .oe_overlay_options display: block diff --git a/addons/website/static/src/js/website.snippets.js b/addons/website/static/src/js/website.snippets.js index b9086f5eaca..10d2d9f7af0 100644 --- a/addons/website/static/src/js/website.snippets.js +++ b/addons/website/static/src/js/website.snippets.js @@ -251,8 +251,8 @@ } if (website.snippet.editorRegistry[snipped_id]) { self.create_overlay($target); - var snippet = new website.snippet.editorRegistry[snipped_id](self, $target); - snippet.build_snippet($target); + $target.data("snippet-editor").build_snippet($target); + setTimeout(function () {self.make_active($target);},0); } }, @@ -276,6 +276,7 @@ var $snippet = get_snippet_from_id($instance.data('snippet-id')); $instance.draggable({ + greedy: true, helper: 'clone', zIndex: '1000', appendTo: 'body', @@ -510,6 +511,7 @@ _drag_and_drop: function(){ var self = this; this.$overlay.draggable({ + greedy: true, appendTo: 'body', cursor: "move", cursorAt: { @@ -565,8 +567,6 @@ * (after the insertion of this.$body, if this.$body exists) */ build_snippet: function ($target) { - var self = this; - setTimeout(function () {self.parent.make_active(self.$target);},0); }, /* onFocus @@ -766,14 +766,24 @@ this.$editor.find(".js_add").on('click', this.on_add); this.$editor.find(".js_remove").on('click', this.on_remove); + + //background var bg = this.$target.find('.carousel-inner .item.active').css('background-image').replace(/url\((.*)\)/g, '\$1'); - this.$editor.find('select[name="carousel-background"] option[value="'+bg+'"], select[name="carousel-background"] option[value="'+bg.replace(window.location.protocol+'//'+window.location.host, '')+'"]') - .prop('selected', true); + var selected = this.$editor.find('select[name="carousel-background"] option[value="'+bg+'"], select[name="carousel-background"] option[value="'+bg.replace(window.location.protocol+'//'+window.location.host, '')+'"]') + .prop('selected', true).length; + if (!selected) { + this.$editor.find('.carousel-background input').val(bg); + } - this.$editor.find('select[name="carousel-background"]').on('change', function () { - self.$target.find('.carousel-inner .item.active').css('background-image', 'url(' + $(this).val() + ')'); - }); + this.$editor.find('select[name="carousel-background"], input') + .on('click', function (event) {event.preventDefault(); return false;}) + .on('change', function () { + self.$target.find('.carousel-inner .item.active').css('background-image', 'url(' + $(this).val() + ')'); + $(this).next().val(""); + }); + + //style var style = false; if (this.$target.find('.carousel-inner .item.active .container .content_image.col-lg-offset-1')) style = 'image_right'; diff --git a/addons/website/static/src/xml/website.snippets.xml b/addons/website/static/src/xml/website.snippets.xml index 90a5deebd8b..be1304a9d5c 100644 --- a/addons/website/static/src/xml/website.snippets.xml +++ b/addons/website/static/src/xml/website.snippets.xml @@ -27,6 +27,7 @@ @@ -66,28 +67,27 @@
  • Remove current layer
  • -
  • - -
  • - -
  • -
  • - + + Background + + +
  • +
    carousel
    @@ -98,7 +98,7 @@