diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index a263f6e8003..c5f069ce07a 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -156,7 +156,7 @@ class Website(openerp.addons.web.controllers.main.Home): 'name': v.name, 'id': v.id, 'header': False, - 'active': v.inherit_id.id == v.inherit_option_id.id + 'active': (v.inherit_id.id == v.inherit_option_id.id) or (not optional and v.inherit_id.id) }) return result diff --git a/addons/website/static/src/css/editor.css b/addons/website/static/src/css/editor.css index 402293bc84f..3b6c7055e13 100644 --- a/addons/website/static/src/css/editor.css +++ b/addons/website/static/src/css/editor.css @@ -116,23 +116,12 @@ table.editorbar-panel td.selected { user-select: auto; } -.modal .existing-attachments a.thumbnail { - position: relative; +.modal-dialog.select-image { + width: 80%; } -.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; + +.modal .existing-attachments .pager { + margin: 0; } .modal .image-preview { @@ -242,6 +231,10 @@ table.editorbar-panel td.selected { } /* ---- SNIPPETS DROP ZONES ---- */ +.col-md-12 { + float: left; +} + .oe_drop_zone.oe_insert { display: block; height: 48px; @@ -252,7 +245,7 @@ table.editorbar-panel td.selected { position: absolute; z-index: 1000; } -.oe_drop_zone.oe_insert:before { +.oe_drop_zone.oe_insert:not(.oe_vertical):before { content: ""; display: block; border-top: dashed 2px rgba(209, 178, 255, 0.72); @@ -263,25 +256,31 @@ table.editorbar-panel td.selected { border-top: dashed 2px rgba(116, 255, 161, 0.72); } .oe_drop_zone.oe_insert.oe_vertical { - width: 16px; - display: inline-block; - position: absolute; - margin: 0px !important; + width: 48px; + float: left; + position: relative; + margin: 0px -24px !important; } .oe_drop_zone.oe_insert.oe_overlay { background: rgba(153, 0, 255, 0.17); border-radius: 3px; } -.oe_drop_zone { +.oe_drop_zone, .oe_drop_zone_style { background: rgba(153, 0, 255, 0.17); border-radius: 3px; } -.oe_drop_zone.oe_hover { +.oe_drop_zone.oe_hover, .oe_drop_zone_style.oe_hover { background: rgba(0, 255, 133, 0.22); z-index: 1001; } +.oe_drop_zone_style { + color: white; + height: 48px; + margin-bottom: 32px; +} + /* ---- SNIPPET MANIPULATOR ---- */ .oe_overlay { display: block; @@ -360,12 +359,20 @@ table.editorbar-panel td.selected { display: none; z-index: 1002; } -.oe_overlay .oe_overlay_options > div { +.oe_overlay .oe_overlay_options > * { + margin: 0 -2px 0 -3px; display: inline-block; } -.oe_overlay .oe_overlay_options .btn { +.oe_overlay .oe_overlay_options * { + border-radius: 0; +} +.oe_overlay .oe_overlay_options .btn, .oe_overlay .oe_overlay_options a { pointer-events: auto; - display: inline-block; + cursor: pointer; +} +.oe_overlay .oe_overlay_options .dropdown-menu { + text-align: left; + min-width: 180px; } .oe_overlay .oe_overlay_options .oe_label { position: absolute; @@ -499,8 +506,19 @@ table.editorbar-panel td.selected { .oe_seo_configuration .oe_remove { color: #e00101; } -.oe_seo_configuration .oe_seo_suggestion { +.oe_seo_configuration .oe_seo_keyword { cursor: pointer; + padding: 0.2em 0.4em 0.2em 0.5em; + border-radius: 0.4em; +} +.oe_seo_configuration .keyword-in-title { + background-color: #5cb85c; +} +.oe_seo_configuration .keyword-in-description { + background-color: #428bca; +} +.oe_seo_configuration .keyword-in-body { + background-color: #5bc0de; } /* ---- ACE EDITOR ---- */ diff --git a/addons/website/static/src/css/editor.sass b/addons/website/static/src/css/editor.sass index d71be46c1ac..4db40a8f9c2 100644 --- a/addons/website/static/src/css/editor.sass +++ b/addons/website/static/src/css/editor.sass @@ -104,32 +104,18 @@ table.editorbar-panel -o-user-select: auto user-select: auto -.modal .existing-attachments a.thumbnail - position: relative +.modal-dialog.select-image + width: 80% - &.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 +.modal .existing-attachments + .pager + margin: 0 .modal .image-preview margin-bottom: 0.5em /* ---- SNIPPET EDITOR ---- */ - #oe_snippets position: fixed left: 0px @@ -220,6 +206,8 @@ table.editorbar-panel /* ---- SNIPPETS DROP ZONES ---- */ +.col-md-12 + float: left .oe_drop_zone.oe_insert display: block height: 48px @@ -229,7 +217,7 @@ table.editorbar-panel width: 100% position: absolute z-index: 1000 - &:before + &:not(.oe_vertical):before content: "" display: block border-top: dashed 2px rgba(209, 178, 255, 0.72) @@ -238,21 +226,26 @@ table.editorbar-panel &.oe_hover:before border-top: dashed 2px rgba(116, 255, 161, 0.72) &.oe_vertical - width: 16px - display: inline-block - position: absolute - margin: 0px !important + width: 48px + float: left + position: relative + margin: 0px -24px !important &.oe_overlay background: rgba(153, 0, 255, 0.17) border-radius: 3px -.oe_drop_zone +.oe_drop_zone, .oe_drop_zone_style background: rgba(153, 0, 255, 0.17) border-radius: 3px &.oe_hover background: rgba(0, 255, 133, 0.22) z-index: 1001 +.oe_drop_zone_style + color: white + height: 48px + margin-bottom: 32px + /* ---- SNIPPET MANIPULATOR ---- */ .oe_overlay @@ -319,11 +312,17 @@ table.editorbar-panel top: -11px display: none z-index: 1002 - > div + > * + margin: 0 -2px 0 -3px display: inline-block - .btn + * + border-radius: 0 + .btn, a pointer-events: auto - display: inline-block + cursor: pointer + .dropdown-menu + text-align: left + min-width: 180px .oe_label position: absolute top: 3px @@ -430,13 +429,24 @@ $icon_close: #E00101 /* ---- SEO TOOLS ---- */ $remove_color: $icon_close +$in_title_color: #5cb85c +$in_description_color: #428bca +$in_body_color: #5bc0de .oe_seo_configuration .modal-dialog width: 80% .oe_remove color: $remove_color - .oe_seo_suggestion + .oe_seo_keyword cursor: pointer + padding: .2em .4em .2em .5em + border-radius: .4em + .keyword-in-title + background-color: $in_title_color + .keyword-in-description + background-color: $in_description_color + .keyword-in-body + background-color: $in_body_color /* ---- ACE EDITOR ---- */ diff --git a/addons/website/static/src/css/fonts/glyphicons-halflings-regular.eot b/addons/website/static/src/css/fonts/glyphicons-halflings-regular.eot new file mode 100644 index 00000000000..87eaa434234 Binary files /dev/null and b/addons/website/static/src/css/fonts/glyphicons-halflings-regular.eot differ diff --git a/addons/website/static/src/css/fonts/glyphicons-halflings-regular.svg b/addons/website/static/src/css/fonts/glyphicons-halflings-regular.svg new file mode 100644 index 00000000000..5fee0685496 --- /dev/null +++ b/addons/website/static/src/css/fonts/glyphicons-halflings-regular.svg @@ -0,0 +1,228 @@ + + + \ No newline at end of file diff --git a/addons/website/static/src/css/fonts/glyphicons-halflings-regular.ttf b/addons/website/static/src/css/fonts/glyphicons-halflings-regular.ttf new file mode 100644 index 00000000000..be784dc1d5b Binary files /dev/null and b/addons/website/static/src/css/fonts/glyphicons-halflings-regular.ttf differ diff --git a/addons/website/static/src/css/fonts/glyphicons-halflings-regular.woff b/addons/website/static/src/css/fonts/glyphicons-halflings-regular.woff new file mode 100644 index 00000000000..2cc3e4852a5 Binary files /dev/null and b/addons/website/static/src/css/fonts/glyphicons-halflings-regular.woff differ diff --git a/addons/website/static/src/css/website.css b/addons/website/static/src/css/website.css index c5b0b6474d4..261d89b40e8 100644 --- a/addons/website/static/src/css/website.css +++ b/addons/website/static/src/css/website.css @@ -186,9 +186,8 @@ h1.text-muted, h2.text-muted, h3.text-muted { } /* ----- BOOTSTRAP HACK FOR HEADER NAV BAR ----- */ -div#wrap > .carousel:first-child, div#wrap > .jumbotron:first-child { - top: -20px; - position: relative; +.navbar.navbar-default.navbar-static-top { + margin-bottom: 0; } /* ----- BOOTSTRAP HACK FOR STICKY FOOTER ----- */ diff --git a/addons/website/static/src/css/website.sass b/addons/website/static/src/css/website.sass index 8519292bf0a..a289436d63a 100644 --- a/addons/website/static/src/css/website.sass +++ b/addons/website/static/src/css/website.sass @@ -118,10 +118,8 @@ h1.text-muted, h2.text-muted, h3.text-muted /* ----- BOOTSTRAP HACK FOR HEADER NAV BAR ----- */ -div#wrap - > .carousel:first-child, > .jumbotron:first-child - top: -20px - position: relative +.navbar.navbar-default.navbar-static-top + margin-bottom: 0 /* ----- BOOTSTRAP HACK FOR STICKY FOOTER ----- */ diff --git a/addons/website/static/src/img/library/baby.jpg b/addons/website/static/src/img/library/baby.jpg new file mode 100644 index 00000000000..2e1b0cb877a Binary files /dev/null and b/addons/website/static/src/img/library/baby.jpg differ diff --git a/addons/website/static/src/img/library/business_conference.jpg b/addons/website/static/src/img/library/business_conference.jpg new file mode 100644 index 00000000000..407137d159a Binary files /dev/null and b/addons/website/static/src/img/library/business_conference.jpg differ diff --git a/addons/website/static/src/img/library/business_hands.jpg b/addons/website/static/src/img/library/business_hands.jpg new file mode 100644 index 00000000000..cb012519301 Binary files /dev/null and b/addons/website/static/src/img/library/business_hands.jpg differ diff --git a/addons/website/static/src/img/library/business_stats.jpg b/addons/website/static/src/img/library/business_stats.jpg new file mode 100644 index 00000000000..1123100c675 Binary files /dev/null and b/addons/website/static/src/img/library/business_stats.jpg differ diff --git a/addons/website/static/src/img/library/engineer.jpg b/addons/website/static/src/img/library/engineer.jpg new file mode 100644 index 00000000000..bd0fa56c38f Binary files /dev/null and b/addons/website/static/src/img/library/engineer.jpg differ diff --git a/addons/website/static/src/img/library/flight.jpg b/addons/website/static/src/img/library/flight.jpg new file mode 100644 index 00000000000..0071979a015 Binary files /dev/null and b/addons/website/static/src/img/library/flight.jpg differ diff --git a/addons/website/static/src/img/library/gears.jpg b/addons/website/static/src/img/library/gears.jpg new file mode 100644 index 00000000000..868c2532c41 Binary files /dev/null and b/addons/website/static/src/img/library/gears.jpg differ diff --git a/addons/website/static/src/img/library/helpdesk.jpg b/addons/website/static/src/img/library/helpdesk.jpg new file mode 100644 index 00000000000..9591abe164e Binary files /dev/null and b/addons/website/static/src/img/library/helpdesk.jpg differ diff --git a/addons/website/static/src/img/library/landscape_tree.jpg b/addons/website/static/src/img/library/landscape_tree.jpg new file mode 100644 index 00000000000..fd5c9446c7b Binary files /dev/null and b/addons/website/static/src/img/library/landscape_tree.jpg differ diff --git a/addons/website/static/src/img/library/lazagne.jpg b/addons/website/static/src/img/library/lazagne.jpg new file mode 100644 index 00000000000..21f10a01ca7 Binary files /dev/null and b/addons/website/static/src/img/library/lazagne.jpg differ diff --git a/addons/website/static/src/img/library/manufacturing.jpg b/addons/website/static/src/img/library/manufacturing.jpg new file mode 100644 index 00000000000..dc7266e46a8 Binary files /dev/null and b/addons/website/static/src/img/library/manufacturing.jpg differ diff --git a/addons/website/static/src/img/library/personal_laptop.jpg b/addons/website/static/src/img/library/personal_laptop.jpg new file mode 100644 index 00000000000..069487766dd Binary files /dev/null and b/addons/website/static/src/img/library/personal_laptop.jpg differ diff --git a/addons/website/static/src/img/library/school_kids.jpg b/addons/website/static/src/img/library/school_kids.jpg new file mode 100644 index 00000000000..107b56bba97 Binary files /dev/null and b/addons/website/static/src/img/library/school_kids.jpg differ diff --git a/addons/website/static/src/img/library/ship_sea.jpg b/addons/website/static/src/img/library/ship_sea.jpg new file mode 100644 index 00000000000..cd0057dbdd6 Binary files /dev/null and b/addons/website/static/src/img/library/ship_sea.jpg differ diff --git a/addons/website/static/src/img/library/vegetables.jpg b/addons/website/static/src/img/library/vegetables.jpg new file mode 100644 index 00000000000..61a2518bbc4 Binary files /dev/null and b/addons/website/static/src/img/library/vegetables.jpg differ diff --git a/addons/website/static/src/img/library/world.jpg b/addons/website/static/src/img/library/world.jpg new file mode 100644 index 00000000000..b7b36d65360 Binary files /dev/null and b/addons/website/static/src/img/library/world.jpg differ diff --git a/addons/website/static/src/js/website.ace.js b/addons/website/static/src/js/website.ace.js index a39aa747e1c..206813f237b 100644 --- a/addons/website/static/src/js/website.ace.js +++ b/addons/website/static/src/js/website.ace.js @@ -25,9 +25,9 @@ website.EditorBar.include({ events: _.extend({}, website.EditorBar.prototype.events, { - 'click a[data-action=ace]': 'launch', + 'click a[data-action=ace]': 'launchAce', }), - launch: function (e) { + launchAce: function (e) { e.preventDefault(); launch(); }, diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index df7245a024f..c2495e30d9c 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -692,12 +692,12 @@ }, }); - var IMAGES_PER_ROW = 3; - var IMAGES_ROWS = 3; + var IMAGES_PER_ROW = 6; + var IMAGES_ROWS = 4; 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', + 'click .existing-attachments img': 'select_existing', 'click .pager > li': function (e) { e.preventDefault(); var $target = $(e.currentTarget); @@ -727,7 +727,7 @@ method: 'search_read', args: [], kwargs: { - fields: ['name'], + fields: ['name', 'website_url'], domain: [['res_model', '=', 'ir.ui.view']], order: 'name', context: website.get_context(), @@ -760,17 +760,11 @@ }, select_existing: function (e) { - e.preventDefault(); - this.$('a.thumbnail.selected').removeClass('selected'); - - $(e.currentTarget).addClass('selected'); - }, - save: function () { - var link = this.$('a.thumbnail.selected').attr('href'); + var link = $(e.currentTarget).attr('src'); if (link) { this.parent.set_image(link); } - this._super(); + this.close() }, }); diff --git a/addons/website/static/src/js/website.seo.js b/addons/website/static/src/js/website.seo.js index c2c2ce16d9a..357cbce308e 100644 --- a/addons/website/static/src/js/website.seo.js +++ b/addons/website/static/src/js/website.seo.js @@ -6,9 +6,9 @@ website.EditorBar.include({ events: _.extend({}, website.EditorBar.prototype.events, { - 'click a[data-action=promote-current-page]': 'promotePage', + 'click a[data-action=promote-current-page]': 'launchSeo', }), - promotePage: function () { + launchSeo: function () { (new website.seo.Configurator()).appendTo($(document.body)); }, }); @@ -20,31 +20,21 @@ events: { 'click .js_seo_suggestion': 'select', }, - init: function (parent, keyword, htmlPage) { - this.keyword = keyword; - this.htmlPage = htmlPage; - this.type = this.computeType(); + init: function (parent, options) { + this.root = options.root; + this.keyword = options.keyword; + this.htmlPage = options.page; this._super(parent); }, start: function () { - var self = this; - function update () { - self.updateType(); - } - self.htmlPage.on('title-changed', self, update); - self.htmlPage.on('description-changed', self, update); + this.htmlPage.on('title-changed', this, this.renderElement); + this.htmlPage.on('description-changed', this, this.renderElement); }, - computeType: function () { - // cf. http://getbootstrap.com/components/#labels - // default, primary, success, info, warning, danger - return this.htmlPage.isInTitle(this.keyword) ? 'success' - : this.htmlPage.isInDescription(this.keyword) ? 'primary' - : this.htmlPage.isInBody(this.keyword) ? 'info' - : 'default'; - }, - updateType: function () { - this.type = this.computeType(); - this.renderElement(); + highlight: function () { + return this.htmlPage.isInTitle(this.keyword) ? 'keyword-in-title' + : this.htmlPage.isInDescription(this.keyword) ? 'keyword-in-description' + : this.htmlPage.isInBody(this.keyword) ? 'keyword-in-body' + : ""; }, select: function () { this.trigger('selected', this.keyword); @@ -53,9 +43,9 @@ website.seo.SuggestionList = openerp.Widget.extend({ template: 'website.seo_list', - init: function (parent, word, htmlPage) { - this.word = word; - this.htmlPage = htmlPage; + init: function (parent, options) { + this.root = options.root; + this.htmlPage = options.page; this._super(parent); }, start: function () { @@ -67,14 +57,18 @@ function addSuggestions (list) { self.$el.empty(); // TODO Improve algorithm + Ajust based on custom user keywords - var nameRegex = new RegExp(self.companyName, "gi"); - var cleanList = _.map(list, function removeCompanyName (word) { - return word.replace(nameRegex, "").trim(); + var regex = new RegExp(self.root, "gi"); + var cleanList = _.map(list, function (word) { + return word.replace(regex, "").trim(); }); // TODO Order properly ? _.each(_.uniq(cleanList), function (keyword) { if (keyword) { - var suggestion = new website.seo.Suggestion(self, keyword, self.htmlPage); + var suggestion = new website.seo.Suggestion(self, { + root: self.root, + keyword: keyword, + page: self.htmlPage, + }); suggestion.on('selected', self, function (word) { self.trigger('selected', word); }); @@ -82,7 +76,7 @@ } }); } - $.getJSON("http://seo.eu01.aws.af.cm/suggest/"+encodeURIComponent(this.word + " "), addSuggestions); + $.getJSON("http://seo.eu01.aws.af.cm/suggest/"+encodeURIComponent(this.root + " "), addSuggestions); }, }); @@ -92,36 +86,32 @@ 'click a[data-action=remove-keyword]': 'destroy', }, maxWordsPerKeyword: 4, // TODO Check - init: function (parent, keyword, htmlPage) { - this.keyword = keyword; - this.htmlPage = htmlPage; - this.type = this.computeType(); + init: function (parent, options) { + this.keyword = options.word; + this.htmlPage = options.page; this._super(parent); }, start: function () { - var self = this; - function update () { - self.updateType(); - } - self.htmlPage.on('title-changed', self, update); - self.htmlPage.on('description-changed', self, update); - self.suggestionList = new website.seo.SuggestionList(self, this.keyword, this.htmlPage); - self.suggestionList.on('selected', self, function (word) { - self.trigger('selected', word); + this.htmlPage.on('title-changed', this, this.updateLabel); + this.htmlPage.on('description-changed', this, this.updateLabel); + this.suggestionList = new website.seo.SuggestionList(this, { + root: this.keyword, + page: this.htmlPage, + }); + this.suggestionList.on('selected', this, function (word) { + this.trigger('selected', word); }); this.suggestionList.appendTo(this.$('.js_seo_keyword_suggestion')); }, - computeType: function () { - // cf. http://getbootstrap.com/components/#labels - // default, primary, success, info, warning, danger - return this.htmlPage.isInTitle(this.keyword) ? 'success' - : this.htmlPage.isInDescription(this.keyword) ? 'primary' - : this.htmlPage.isInBody(this.keyword) ? 'warning' - : 'default'; + highlight: function () { + return this.htmlPage.isInTitle(this.keyword) ? 'keyword-in-title' + : this.htmlPage.isInDescription(this.keyword) ? 'keyword-in-description' + : this.htmlPage.isInBody(this.keyword) ? 'keyword-in-body' + : ""; }, - updateType: function () { - this.type = this.computeType(); - this.$('span.js_seo_keyword').attr('class', "label label-"+this.type+" js_seo_keyword"); + updateLabel: function () { + var cssClass = "oe_seo_keyword js_seo_keyword " + this.highlight(); + this.$(".js_seo_keyword").attr('class', cssClass); }, destroy: function () { this.trigger('removed'); @@ -132,29 +122,44 @@ website.seo.KeywordList = openerp.Widget.extend({ template: 'website.seo_list', maxKeywords: 10, - init: function (parent, htmlPage) { - this.htmlPage = htmlPage; + init: function (parent, options) { + this.htmlPage = options.page; this._super(parent); }, + start: function () { + var self = this; + var existingKeywords = self.htmlPage.keywords(); + if (existingKeywords.length > 0) { + _.each(existingKeywords, function (word) { + self.add.call(self, word); + }); + } else { + var companyName = self.htmlPage.company().toLowerCase(); + self.add(companyName); + } + }, keywords: function () { var result = []; - this.$('span.js_seo_keyword').each(function () { + this.$('.js_seo_keyword').each(function () { result.push($(this).data('keyword')); }); return result; }, - isKeywordListFull: function () { + isFull: function () { return this.keywords().length >= this.maxKeywords; }, - isExistingKeyword: function (word) { + exists: function (word) { return _.contains(this.keywords(), word); }, add: function (candidate) { var self = this; // TODO Refine - var word = candidate ? candidate.replace(/[,;.:<>]+/g, " ").replace(/ +/g, " ").trim() : ""; - if (word && !self.isKeywordListFull() && !self.isExistingKeyword(word)) { - var keyword = new website.seo.Keyword(self, word, this.htmlPage); + var word = candidate ? candidate.replace(/[,;.:<>]+/g, " ").replace(/ +/g, " ").trim().toLowerCase() : ""; + if (word && !self.isFull() && !self.exists(word)) { + var keyword = new website.seo.Keyword(self, { + word: word, + page: this.htmlPage, + }); keyword.on('removed', self, function () { self.trigger('list-not-full'); self.trigger('removed', word); @@ -164,7 +169,7 @@ }); keyword.appendTo(self.$el); } - if (self.isKeywordListFull()) { + if (self.isFull()) { self.trigger('list-full'); } }, @@ -181,8 +186,8 @@ website.seo.ImageList = openerp.Widget.extend({ - init: function (parent, htmlPage) { - this.htmlPage = htmlPage; + init: function (parent, options) { + this.htmlPage = options.page; this._super(parent); }, start: function () { @@ -228,10 +233,11 @@ this.trigger('description-changed', description); }, keywords: function () { - return $('meta[name=keywords]').attr('value').split(","); + var parsed = $('meta[name=keywords]').attr('value').split(","); + return parsed[0] ? parsed: []; }, changeKeywords: function (keywords) { - $('meta[name=keywords]').attr('value', keyword.join(",")); + $('meta[name=keywords]').attr('value', keywords.join(",")); this.trigger('keywords-changed', keywords); }, headers: function (tag) { @@ -299,9 +305,9 @@ $modal.find('input[name=seo_page_title]').val(htmlPage.title()); $modal.find('textarea[name=seo_page_description]').val(htmlPage.description()); self.suggestImprovements(); - self.imageList = new website.seo.ImageList(self, htmlPage); + self.imageList = new website.seo.ImageList(self, { page: htmlPage }); self.imageList.appendTo($modal.find('.js_seo_image_list')); - self.keywordList = new website.seo.KeywordList(self, htmlPage); + self.keywordList = new website.seo.KeywordList(self, { page: htmlPage }); self.keywordList.on('list-full', self, function () { $modal.find('input[name=seo_page_keywords]') .attr('readonly', "readonly") @@ -319,8 +325,6 @@ self.keywordList.add(word); }); self.keywordList.appendTo($modal.find('.js_seo_keywords_list')); - var companyName = htmlPage.company().toLowerCase(); - self.addKeyword(companyName); $modal.modal(); }, suggestImprovements: function () { @@ -389,5 +393,9 @@ self.htmlPage.changeDescription(description); }, 1); }, + destroy: function () { + this.htmlPage.changeKeywords(this.keywordList.keywords()); + this._super(); + }, }); })(); diff --git a/addons/website/static/src/js/website.snippets.js b/addons/website/static/src/js/website.snippets.js index cd11dd4b8c7..db2545ada29 100644 --- a/addons/website/static/src/js/website.snippets.js +++ b/addons/website/static/src/js/website.snippets.js @@ -110,23 +110,21 @@ .click(function () {self.$el.toggleClass("hidden");}) .prependTo($ul); - var $stylesblock = $(openerp.qweb.render('website.snippets_style')).insertAfter($button); - $stylesblock.find('#oe_snippets_style').on('click', 'li a', _.bind(this.change_style, this)); - this.fetch_snippet_templates(); - this.change_style_options(); - this.bind_selected_manipulator(); this.bind_snippet_click_editor(); this.activate_overlay_zones(); this.scrollspy(); this.$el.addClass("hidden"); + + this.$modal = $(openerp.qweb.render('website.snippets_modal')); + this.$modal.appendTo("body"); }, fetch_snippet_templates: function () { var self = this; - var $styles = self.parent.$('#oe_snippets_style'); + this.style_templates = {}; _.each(openerp.qweb.compiled_templates, function (val, key) { if (key.indexOf('website.snippets.') === 0) { @@ -135,15 +133,15 @@ if (snipped_id) { if ($snippet.data('category') === 'style') { - var $li = $("
") - .data("selector", $snippet.data('selector')) - .data("class", $snippet.find(".oe_snippet_class").text()) - .data("snipped-id", snipped_id); - var $a = $('').text($snippet.find(".oe_snippet_label").text()); - $li.append($a); - $styles.append($li); - - } else if ($snippet.find(".oe_snippet_thumbnail").length) { + self.style_templates[snipped_id] = { + 'snipped-id' : snipped_id, + 'selector': $snippet.data('selector'), + 'class': $snippet.find(".oe_snippet_class").text(), + 'label': $snippet.find(".oe_snippet_label").text(), + '$el': $snippet + }; + } + if ($snippet.find(".oe_snippet_thumbnail").length) { self.$el.find('#snippet_' + $snippet.data('category')).append($snippet); self.make_snippet_draggable($snippet); } @@ -151,47 +149,6 @@ } }); }, - change_style_options: function () { - var self = this; - var $styles = self.parent.$('#oe_snippets_style'); - var visible = false; - $styles.find("li").each(function () { - var $li = $(this); - if (!$li.data("snipped-id")) - return; - - if (self.$active_snipped_id && (!$li.data("selector") || self.dom_filter($li.data("selector")).is(self.$active_snipped_id))) { - $li.show(); - if (self.$active_snipped_id.hasClass( "oe_snippet_" + $li.data("snipped-id") )) { - $li.addClass("active"); - } else { - $li.removeClass("active"); - } - visible = true; - } - else { - $li.hide(); - } - }); - $styles.parents("li:first").toggle(visible); - }, - change_style: function (event) { - var $li = $(event.currentTarget).parent(); - var snipped_id = $li.data("snipped-id"); - var active = $li.hasClass("active"); - - if (website.snippet.editorRegistry[snipped_id]) { - var snippet = new website.snippet.editorRegistry[snipped_id](this, this.$active_snipped_id); - snippet.build_snippet(this.$active_snipped_id); - } - var _class = "oe_snippet_" + snipped_id + " " + ($opt.data("class") || ""); - if (active) { - this.$active_snipped_id.addClass(_class); - } else { - this.$active_snipped_id.removeClass(_class); - } - $li.toggleClass("active"); - }, scrollspy: function (){ var self = this; var $ul = this.$("ul"); @@ -243,17 +200,12 @@ if (snipped_event_flag) { return; } - var $target = $(event.currentTarget); - if (self.$active_snipped_id) { - if (self.$active_snipped_id[0] === $target[0] || $.contains(self.$active_snipped_id, $target[0])) { - var $parent = self.$active_snipped_id.parents("[data-snippet-id]:first"); - if ($parent.length) { - $target = $parent; - } - } - } snipped_event_flag = true; setTimeout(function () {snipped_event_flag = false;}, 0); + var $target = $(event.currentTarget); + if (self.$active_snipped_id && self.$active_snipped_id.is($target)) { + return; + } self.make_active($target); }); $("body > :not(:has(#website-top-view)):not(#oe_manipulators)").on('click', function (ev) { @@ -296,7 +248,6 @@ } else { self.$active_snipped_id = false; } - this.change_style_options(); }, create_overlay: function ($snipped_id) { if (typeof $snipped_id.data("snippet-editor") === 'undefined') { @@ -342,8 +293,10 @@ var self = this; var $toInsert = false; var $tumb = $snippet.find(".oe_snippet_thumbnail"); + var dropped = false; $snippet.draggable({ + greedy: true, helper: 'clone', zIndex: '1000', appendTo: 'body', @@ -355,7 +308,7 @@ }, start: function(){ self.hide(); - + dropped = false; var snipped_id = $snippet.data('snippet-id'); var action = $snippet.find('.oe_snippet_body').size() ? 'insert' : 'mutate'; if( action === 'insert'){ @@ -391,26 +344,18 @@ $('.oe_drop_zone').droppable({ over: function(){ if( action === 'insert'){ + dropped = true; $(this).first().after($toInsert); - } else { - // FIXME: stupid hack to prevent multiple droppable to activate at once ... - // it's not even working properly but it's better than nothing. - $(".oe_drop_zone.oe_hover").removeClass("oe_hover"); - $(this).addClass("oe_hover"); } }, out: function(){ if( action === 'insert'){ + dropped = false; $toInsert.detach(); - } else { - $(this).removeClass("oe_hover"); } }, drop: function(){ - - if (!$(".oe_drop_zone.oe_hover").length) { - return false; - } + dropped = true; var $target = false; if(action === 'insert'){ @@ -424,7 +369,7 @@ $target.data("snippet-editor").build_snippet($target); } else { - $target = $(".oe_drop_zone.oe_hover").first().data('target'); + $target = $(this).data('target'); self.create_overlay($target); if (website.snippet.editorRegistry[snipped_id]) { @@ -441,6 +386,9 @@ }, stop: function(){ $('.oe_drop_zone').droppable('destroy').remove(); + if (!dropped) { + self.$modal.modal('toggle'); + } }, }); }, @@ -476,9 +424,31 @@ if(vertical_child_selector){ self.dom_filter(vertical_child_selector).each(function (){ var $zone = $(this); - var $template = $(zone_template).addClass("oe_vertical").css('height', $zone.outerHeight()+'px'); - $zone.find('> *:not(.oe_drop_zone):visible').after($template); - $zone.prepend($template.clone()); + var $template = $(zone_template).addClass("oe_vertical"); + var nb = 0; + var $lastinsert = false; + var left = 0; + var temp_left = 0; + $zone.find('> *:not(.oe_drop_zone):visible').each(function () { + var $col = $(this); + $template.css('height', ($col.outerHeight() + parseInt($col.css("margin-top")) + parseInt($col.css("margin-bottom")))+'px'); + $lastinsert = $template.clone(); + $(this).after($lastinsert); + + temp_left = $col.position().left; + if (left === temp_left) { + $col.prev(".oe_drop_zone.oe_vertical").remove(); + $col.before($template.clone().css("clear", "left")); + } + else if (!nb) { + $col.before($template.clone()); + } + left = temp_left; + nb ++; + }); + if (!nb) { + $zone.prepend($template.css('height', $zone.outerHeight()+'px')); + } }); } @@ -497,11 +467,11 @@ var count; do { count = 0; - var $zones = $('.oe_drop_zone + .oe_drop_zone'); // no two consecutive zones - count += $zones.length; - $zones.remove(); + // var $zones = $('.oe_drop_zone + .oe_drop_zone'); // no two consecutive zones + // count += $zones.length; + // $zones.remove(); - $zones = $('.oe_drop_zone > .oe_drop_zone').remove(); // no recusrive zones + $zones = $('.oe_drop_zone > .oe_drop_zone:not(.oe_vertical)').remove(); // no recusrive zones count += $zones.length; $zones.remove(); } while (count > 0); @@ -617,6 +587,8 @@ this.$overlay = this.$target.data('overlay'); this.snippet_id = this.$target.data("snippet-id"); this._readXMLData(); + this.load_style_options(); + this.get_parent_block(); this.start(); }, @@ -645,7 +617,9 @@ var $options = this.$overlay.find(".oe_overlay_options"); this.$editor.prependTo($options.find(".oe_options ul")); - $options.find(".oe_label").text(this.$el.find('.oe_snippet_label').text()); + if ($options.find(".oe_options ul li").length) { + $options.find(".oe_options").removeClass("hidden"); + } }, @@ -664,17 +638,17 @@ top: 14 }, helper: function() { - var $clone = $(this).clone().css({width: "24px", height: "50px", border: 0}); + var $clone = $(this).clone().css({width: "24px", height: "24px", border: 0}); $clone.find(".oe_overlay_options >:not(.oe_snippet_move), .oe_handle").remove(); $clone.find(":not(.glyphicon)").css({position: 'absolute', top: 0, left: 0}); - return $clone.appendTo("body").show(); + return $clone.appendTo("body").removeClass("hidden"); }, start: function(){ self.parent.hide(); self.parent.editor_busy = true; self.$target.after(""); self.$target.detach(); - self.$overlay.hide(); + self.$overlay.addClass("hidden"); self.parent.activate_insertion_zones({ siblings: self.$el ? self.$el.data('selector-siblings') : false, children: self.$el ? self.$el.data('selector-children') : false, @@ -698,11 +672,12 @@ if (!dropped) { $(".oe_drop_clone").after(self.$target); } - self.$overlay.show(); + self.$overlay.removeClass("hidden"); $("body").removeClass('move-important'); $('.oe_drop_zone').droppable('destroy').remove(); $(".oe_drop_clone").remove(); self.parent.editor_busy = false; + self.get_parent_block(); setTimeout(function () {self.parent.create_overlay(self.$target);},0); }, }); @@ -720,6 +695,59 @@ }); }, + load_style_options: function () { + var self = this; + var $styles = this.$overlay.find('.oe_options'); + var $ul = $styles.find('ul'); + _.each(this.parent.style_templates, function (val, key) { + if (!self.parent.dom_filter(val.selector).is(self.$target)) { + return; + } + var $li = $("").data(val); + $li.append($('').text(val.label)); + $ul.append($li); + if (self.$target.hasClass( "oe_snippet_" + $li.data("snipped-id") )) { + $li.addClass("active"); + } + $styles.removeClass("hidden"); + }); + $styles.on('click', 'li.oe_style a', _.bind(this.change_style, this)); + }, + change_style: function (event) { + var $li = $(event.currentTarget).parent(); + var snipped_id = $li.data("snipped-id"); + var active = $li.hasClass("active"); + + if (website.snippet.editorRegistry[snipped_id]) { + var snippet = new website.snippet.editorRegistry[snipped_id](this, this.$target); + snippet.build_snippet(this.$target); + } + var _class = "oe_snippet_" + snipped_id + " " + ($li.data("class") || ""); + if (active) { + this.$target.removeClass(_class); + } else { + this.$target.addClass(_class); + } + $li.toggleClass("active"); + }, + + get_parent_block: function () { + var self = this; + var $button = this.$overlay.find('.oe_snippet_parent'); + var $parent = this.$target.parents("[data-snippet-id]:first"); + if ($parent.length) { + $button.removeClass("hidden"); + $button.off("click").on('click', function (event) { + event.preventDefault(); + setTimeout(function () { + self.parent.make_active($parent); + }, 0); + }); + } else { + $button.addClass("hidden"); + } + }, + /* * start * This method is called after init and _readXMLData @@ -829,7 +857,7 @@ var xy = event['page'+XY]; var begin = current; var beginClass = self.$target.attr("class"); - var regClass = new RegExp("\\s*" + resize[0][begin].replace(/[-]*[0-9]+/, '[0-9-]+'), 'g'); + var regClass = new RegExp("\\s*" + resize[0][begin].replace(/[-]*[0-9]+/, '[-]*[0-9]+'), 'g'); var cursor = $handle.css("cursor")+'-important'; $("body").addClass(cursor); diff --git a/addons/website/static/src/xml/website.editor.xml b/addons/website/static/src/xml/website.editor.xml index dec159b96dd..cbc34068118 100644 --- a/addons/website/static/src/xml/website.editor.xml +++ b/addons/website/static/src/xml/website.editor.xml @@ -99,10 +99,10 @@ -— or —
+— or —
@@ -174,7 +206,7 @@
OpenERP provides essential platform for our project management. @@ -185,7 +217,7 @@
Image-Text