From 660e8798abdd73eb56f1b571654edb39707c24c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Mon, 19 Aug 2013 11:25:07 +0200 Subject: [PATCH 01/24] [WIP] website: Cleaning up the snippet editor bzr revid: fva@openerp.com-20130819092507-s3d9wl1ph6z43thh --- addons/website/static/src/css/editor.css | 28 ++++- addons/website/static/src/css/editor.sass | 26 +++++ addons/website/static/src/js/website.js | 92 +++++++++++------ addons/website/static/src/xml/website.xml | 7 ++ addons/website/views/views.xml | 119 +++------------------- 5 files changed, 135 insertions(+), 137 deletions(-) diff --git a/addons/website/static/src/css/editor.css b/addons/website/static/src/css/editor.css index 246d62b62be..94552c801c2 100644 --- a/addons/website/static/src/css/editor.css +++ b/addons/website/static/src/css/editor.css @@ -1,4 +1,7 @@ -@charset "utf-8"; +.oe_hidden { + display: none !important; +} + .oe_website_editorbar { position: fixed; top: 0; @@ -54,3 +57,26 @@ z-index: 1; display: none; } + +.oe_snippets { + position: fixed; + left: 0px; + right: 0px; + bottom: 0px; + height: 120px; + background: black; +} +.oe_snippets .oe_snippet { + display: inline; +} +.oe_snippets .oe_snippet .oe_snippet_thumbnail { + display: inline-block; + background: red; + width: 100px; + height: 100px; + border-radius: 3px; + margin: 10px; +} +.oe_snippets .oe_snippet .oe_snippet_body { + display: none; +} diff --git a/addons/website/static/src/css/editor.sass b/addons/website/static/src/css/editor.sass index 24a549f1d05..565e7571dca 100644 --- a/addons/website/static/src/css/editor.sass +++ b/addons/website/static/src/css/editor.sass @@ -1,5 +1,8 @@ @charset "utf-8" +.oe_hidden + display: none !important + .oe_website_editorbar position: fixed top: 0 @@ -47,3 +50,26 @@ white-space: nowrap z-index: 1 display: none + +.oe_snippets + position: fixed + left: 0px + right: 0px + bottom: 0px + height: 120px + background: black + + .oe_snippet + display: inline + .oe_snippet_thumbnail + display: inline-block + background: red + width: 100px + height: 100px + border-radius: 3px + margin: 10px + + .oe_snippet_body + display: none + + diff --git a/addons/website/static/src/js/website.js b/addons/website/static/src/js/website.js index c83cc5cc1be..8eaf0c42e0c 100644 --- a/addons/website/static/src/js/website.js +++ b/addons/website/static/src/js/website.js @@ -71,11 +71,12 @@ instance.website.EditorBar = instance.web.Widget.extend({ snippet: this.$('button[data-action=snippet]'), }; - self.snippet_start(); - this.rte = new instance.website.RTE(this); this.rte.on('change', this, this.proxy('rte_changed')); + this.snippets = new instance.website.Snippets(); + this.snippets.appendTo($("body")); + return $.when( this._super.apply(this, arguments), this.rte.insertBefore(this.$buttons.snippet.parent()) @@ -161,36 +162,8 @@ instance.website.EditorBar = instance.web.Widget.extend({ cancel: function () { window.location.reload(); }, - setup_droppable: function () { - var self = this; - $('.oe_snippet_drop').remove(); - var droppable = '
'; - var $zone = $(':not(.oe_snippet) > .container'); - $zone.after(droppable);//.after(droppable); - - $(".oe_snippet_drop").droppable({ - hoverClass: 'oe_accepting', - drop: function( event, ui ) { - console.log(event, ui, "DROP"); - - $(event.target).replaceWith($(ui.draggable).html()); - $('.oe_selected').remove(); - $('.oe_snippet_drop').remove(); - } - }); - }, - snippet_start: function () { - var self = this; - $('.oe_snippet').draggable().click(function(ev) { - self.setup_droppable(); - $(".oe_snippet_drop").show(); - $('.oe_selected').removeClass('oe_selected'); - $(ev.currentTarget).addClass('oe_selected'); - }); - - }, snippet: function (ev) { - $('.oe_snippet_editor').toggle(); + this.snippets.toggle(); }, }); @@ -297,6 +270,63 @@ instance.website.RTE = instance.web.Widget.extend({ } }); +instance.website.Snippets = instance.web.Widget.extend({ + template: 'website.snippets', + init: function () { + this._super.apply(this, arguments); + }, + start: function() { + var self = this; + + $.ajax({ + type: "GET", + url: "/page/website.snippets", + dataType: "text", + success: function(text){ + self.$el.html(text); + }, + }); + + // load snippets + // /page/website.snippets + }, + setup_droppable: function () { + var self = this; + $('.oe_snippet_drop').remove(); + var droppable = '
'; + var $zone = $(':not(.oe_snippet) > .container'); + $zone.after(droppable);//.after(droppable); + + $(".oe_snippet_drop").droppable({ + hoverClass: 'oe_accepting', + drop: function( event, ui ) { + console.log(event, ui, "DROP"); + + $(event.target).replaceWith($(ui.draggable).html()); + $('.oe_selected').remove(); + $('.oe_snippet_drop').remove(); + } + }); + }, + toggle: function(){ + if(this.$el.hasClass('oe_hidden')){ + this.$el.removeClass('oe_hidden'); + }else{ + this.$el.addClass('oe_hidden'); + } + }, + snippet_start: function () { + var self = this; + $('.oe_snippet').draggable().click(function(ev) { + self.setup_droppable(); + $(".oe_snippet_drop").show(); + $('.oe_selected').removeClass('oe_selected'); + $(ev.currentTarget).addClass('oe_selected'); + }); + + }, +}); + $(function(){ function make_static(){ diff --git a/addons/website/static/src/xml/website.xml b/addons/website/static/src/xml/website.xml index 9f11ff40bca..3e2e5db538b 100644 --- a/addons/website/static/src/xml/website.xml +++ b/addons/website/static/src/xml/website.xml @@ -57,4 +57,11 @@ + + +
+ sadfasdfsadf +
+
+ diff --git a/addons/website/views/views.xml b/addons/website/views/views.xml index e081585b682..db0cd25eec6 100644 --- a/addons/website/views/views.xml +++ b/addons/website/views/views.xml @@ -6,12 +6,12 @@ -