diff options
| author | Christophe Simonis <chs@odoo.com> | 2014-07-15 11:23:47 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2014-07-15 11:23:47 +0200 |
| commit | b7ba49825a85d2db483c7e31f2ab5fa10fc01390 (patch) | |
| tree | 0ae2a6b8f576bd070e2a64fe3b1792c34288377c /addons/website/static/src | |
| parent | bcfa4c8e7ca4f8fb3b577e32eca9f3c0e8f99190 (diff) | |
| parent | a5419ca800877d686b0d8eecf88b0643cc98fd2d (diff) | |
[MERGE] forward port of branch 8.0 up to a5419ca
Diffstat (limited to 'addons/website/static/src')
| -rw-r--r-- | addons/website/static/src/css/editor.css | 17 | ||||
| -rw-r--r-- | addons/website/static/src/css/editor.sass | 13 | ||||
| -rw-r--r-- | addons/website/static/src/css/snippets.css | 4 | ||||
| -rw-r--r-- | addons/website/static/src/css/snippets.sass | 1 | ||||
| -rw-r--r-- | addons/website/static/src/js/website.editor.js | 276 | ||||
| -rw-r--r-- | addons/website/static/src/js/website.seo.js | 2 | ||||
| -rw-r--r-- | addons/website/static/src/js/website.snippets.editor.js | 6 | ||||
| -rw-r--r-- | addons/website/static/src/xml/website.editor.xml | 82 |
8 files changed, 187 insertions, 214 deletions
diff --git a/addons/website/static/src/css/editor.css b/addons/website/static/src/css/editor.css index ac7ddbbccb5..49adbc3ff99 100644 --- a/addons/website/static/src/css/editor.css +++ b/addons/website/static/src/css/editor.css @@ -163,6 +163,23 @@ table.editorbar-panel td.selected { background-color: #b1c9d9; } +.link-style .dropdown > .btn { + min-width: 160px; +} +.link-style .link-style { + display: none; +} +.link-style li { + text-align: center; +} +.link-style li label { + width: 100px; + margin: 0 5px; +} +.link-style .col-sm-2 > * { + line-height: 2em; +} + /* ---- TRANSLATIONS ---- {{{ */ .oe_translate_or { color: white; diff --git a/addons/website/static/src/css/editor.sass b/addons/website/static/src/css/editor.sass index 802b6299545..89a60f5b919 100644 --- a/addons/website/static/src/css/editor.sass +++ b/addons/website/static/src/css/editor.sass @@ -134,6 +134,19 @@ table.editorbar-panel td.selected background-color: #b1c9d9 +.link-style + .dropdown > .btn + min-width: 160px + .link-style + display: none + li + text-align: center + label + width: 100px + margin: 0 5px + .col-sm-2 > * + line-height: 2em + // }}} /* ---- TRANSLATIONS ---- {{{ */ diff --git a/addons/website/static/src/css/snippets.css b/addons/website/static/src/css/snippets.css index 2bcbf0878ef..778c67e185a 100644 --- a/addons/website/static/src/css/snippets.css +++ b/addons/website/static/src/css/snippets.css @@ -104,10 +104,6 @@ } .oe_snippet .oe_snippet_thumbnail .oe_snippet_thumbnail_img { height: 74px; - -webkit-transition: all 150ms linear; - -moz-transition: all 150ms linear; - -o-transition: all 150ms linear; - transition: all 150ms linear; -webkit-box-shadow: inset 0px 0px 0px 3px #333333; -moz-box-shadow: inset 0px 0px 0px 3px #333333; box-shadow: inset 0px 0px 0px 3px #333333; diff --git a/addons/website/static/src/css/snippets.sass b/addons/website/static/src/css/snippets.sass index f065468c0db..868292ba558 100644 --- a/addons/website/static/src/css/snippets.sass +++ b/addons/website/static/src/css/snippets.sass @@ -81,7 +81,6 @@ +text-shadow(0 0 2px rgb(0,0,0)) .oe_snippet_thumbnail_img height: 74px - @include transition(all 150ms linear) +box-shadow(inset 0px 0px 0px 3px #333333) @include transform( scale(1,1)) span, div diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 2ff6fca89e2..f15278ee49f 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -209,155 +209,6 @@ } }); - 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, - context: 'a', - panel: { - css: '/web/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 = ['<div style="padding: 5px">']; - html.push('<div style="white-space: nowrap">'); - _(this.types).each(function (label, key) { - html.push(_.str.sprintf( - '<button type="button" class="btn %s" ' + - 'data-type="types" data-set-class="%s">%s</button>', - key, key, label)); - }); - html.push('</div>'); - html.push('<div style="white-space: nowrap; margin: 5px 0; text-align: center">'); - _(this.sizes).each(function (label, key) { - html.push(_.str.sprintf( - '<button type="button" class="btn btn-default %s" ' + - 'data-type="sizes" data-set-class="%s">%s</button>', - key, key, label)); - }); - html.push('</div>'); - html.push('<button type="button" class="btn btn-link btn-block" ' + - 'data-type="reset">Reset</button>'); - html.push('</div>'); - - 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', @@ -1011,7 +862,7 @@ fillEmptyBlocks: false, filebrowserImageUploadUrl: "/website/attach", // Support for sharedSpaces in 4.x - extraPlugins: 'sharedspace,customdialogs,tablebutton,oeref,linkstyle', + extraPlugins: 'sharedspace,customdialogs,tablebutton,oeref', // Place toolbar in controlled location sharedSpaces: { top: 'oe_rte_toolbar' }, toolbar: [{ @@ -1020,7 +871,7 @@ "Superscript", "TextColor", "BGColor", "RemoveFormat" ]},{ name: 'span', items: [ - "Link", "LinkStyle", "Blockquote", "BulletedList", + "Link", "Blockquote", "BulletedList", "NumberedList", "Indent", "Outdent" ]},{ name: 'justify', items: [ @@ -1081,19 +932,23 @@ website.editor.LinkDialog = website.editor.Dialog.extend({ template: 'website.editor.dialog.link', events: _.extend({}, website.editor.Dialog.prototype.events, { - 'change :input.url-source': function (e) { this.changed($(e.target)); }, + 'change :input.url-source': 'changed', + 'keyup :input.url': 'onkeyup', + 'keyup :input': 'preview', 'mousedown': function (e) { - var $target = $(e.target).closest('.list-group-item'); + var $target = $(e.target).closest('.list-group-item:has(.url-source)'); if (!$target.length || $target.hasClass('active')) { // clicked outside groups, or clicked in active groups return; } - - this.changed($target.find('.url-source').filter(':input')); + $target.find("input.url-source").change(); }, 'click button.remove': 'remove_link', 'change input#link-text': function (e) { - this.text = $(e.target).val() + this.text = $(e.target).val(); + }, + 'change .link-style': function (e) { + this.preview(); }, }), init: function (editor) { @@ -1117,7 +972,7 @@ self.fetch_pages(q.term) ).then(function (exists, results) { var rs = _.map(results, function (r) { - return { id: r.url, text: r.name, }; + return { id: r.loc, text: r.loc, }; }); if (!exists) { rs.push({ @@ -1137,67 +992,90 @@ }); 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').filter(':input'); - var val = $e.val(); - if (!val || !$e[0].checkValidity()) { + get_data: function (test) { + var self = this, + def = new $.Deferred(), + $e = this.$('.active input.url-source').filter(':input'), + val = $e.val(), + label = this.$('#link-text').val() || val; + + if (test !== false && (!val || !$e[0].checkValidity())) { // FIXME: error message $e.closest('.form-group').addClass('has-error'); $e.focus(); - return; + def.reject(); } - var done = $.when(); - if ($e.hasClass('email-address')) { - this.make_link('mailto:' + val, false, val); - } else if ($e.hasClass('page')) { + var style = this.$("input[name='link-style-type']:checked").val(); + var size = this.$("input[name='link-style-size']:checked").val(); + var classes = (style && style.length ? "btn " : "") + style + " " + size; + + if ($e.hasClass('email-address') && $e.val().indexOf("@") !== -1) { + def.resolve('mailto:' + val, false, label); + } else if ($e.val() && $e.val().length && $e.hasClass('page')) { var data = $e.select2('data'); if (!data.create) { - self.make_link(data.id, false, data.text); + def.resolve(data.id, false, data.text); } else { // Create the page, get the URL back - done = $.get(_.str.sprintf( + $.get(_.str.sprintf( '/website/add/%s?noredirect=1', encodeURI(data.id))) .then(function (response) { - self.make_link(response, false, data.id); + def.resolve(response, false, data.id); }); } } else { - this.make_link(val, this.$('input.window-new').prop('checked')); + def.resolve(val, this.$('input.window-new').prop('checked'), label, classes); } - done.then(_super); + return def; + }, + save: function () { + var self = this; + var _super = this._super.bind(this); + return this.get_data() + .then(function (url, new_window, label, classes) { + self.make_link(url, new_window, label, classes); + }).then(_super); }, - make_link: function (url, new_window, label) { + make_link: function (url, new_window, label, classes) { }, - bind_data: function (text, href, new_window) { - href = href || this.element && (this.element.data( 'cke-saved-href') + bind_data: function () { + var href = this.element && (this.element.data( 'cke-saved-href') || this.element.getAttribute('href')); - - if (new_window === undefined) { - new_window = this.element + var new_window = this.element ? this.element.getAttribute('target') === '_blank' : false; - } - if (text === undefined) { - text = this.element ? this.element.getText() : ''; + var text = this.element ? this.element.getText() : ''; + if (!text.length) { + var selection = this.editor.getSelection(); + text = selection.getSelectedText(); } this.$('input#link-text').val(text); this.$('input.window-new').prop('checked', new_window); - if (!href) { return; } + var classes = this.element && this.element.$.className; + if (classes) { + this.$('input[value!=""]').each(function () { + var $option = $(this); + if (classes.indexOf($option.val()) !== -1) { + $option.attr("checked", "checked"); + } + }); + } + var match, $control; - if ((match = /mailto:(.+)/.exec(href))) { - $control = this.$('input.email-address').val(match[1]); + if (href && (match = /mailto:(.+)/.exec(href))) { + this.$('input.email-address').val(match[1]).change(); } - if (!$control) { - $control = this.$('input.url').val(href); + if (href && !$control) { + this.$('input.url').val(href).change(); + this.$('input.window-new').closest("div").show(); } - - this.changed($control); + this.preview(); }, - changed: function ($e) { + changed: function (e) { + var $e = $(e.target); this.$('.url-source').filter(':input').not($e).val('') .filter(function () { return !!$(this).data('select2'); }) .select2('data', null); @@ -1205,6 +1083,7 @@ .addClass('active') .siblings().removeClass('active') .addBack().removeClass('has-error'); + this.preview(); }, call: function (method, args, kwargs) { var self = this; @@ -1232,6 +1111,20 @@ context: website.get_context(), }); }, + onkeyup: function (e) { + var $e = $(e.target); + var is_link = ($e.val()||'').length && $e.val().indexOf("@") === -1; + this.$('input.window-new').closest("div").toggle(is_link); + this.preview(); + }, + preview: function () { + var $preview = this.$("#link-preview"); + this.get_data(false).then(function (url, new_window, label, classes) { + $preview.attr("target", new_window ? '_blank' : "") + .text((label && label.length ? label : url)) + .attr("class", classes); + }); + } }); website.editor.RTELinkDialog = website.editor.LinkDialog.extend({ start: function () { @@ -1271,7 +1164,7 @@ * @param {Boolean} [new_window=false] * @param {String} [label=null] */ - make_link: function (url, new_window, label) { + make_link: function (url, new_window, label, classes) { var attributes = {href: url, 'data-cke-saved-href': url}; var to_remove = []; if (new_window) { @@ -1279,6 +1172,9 @@ } else { to_remove.push('target'); } + if (classes && classes.length) { + attributes['class'] = classes; + } if (this.element) { this.element.setAttributes(attributes); diff --git a/addons/website/static/src/js/website.seo.js b/addons/website/static/src/js/website.seo.js index 7ba78a22748..8d28237f924 100644 --- a/addons/website/static/src/js/website.seo.js +++ b/addons/website/static/src/js/website.seo.js @@ -441,7 +441,7 @@ }, getMainObject: function () { var repr = $('html').data('main-object'); - var m = repr.match(/.+\((.+), (\d+)\)/); + var m = repr.match(/(.+)\((\d+),(.*)\)/); if (!m) { return null; } else { diff --git a/addons/website/static/src/js/website.snippets.editor.js b/addons/website/static/src/js/website.snippets.editor.js index 61a60b2b0c5..16304f95d01 100644 --- a/addons/website/static/src/js/website.snippets.editor.js +++ b/addons/website/static/src/js/website.snippets.editor.js @@ -975,12 +975,10 @@ }, clean_for_save: function () { this._super(); - $(".carousel").find(".item").removeClass("next prev left right active"); + this.$target.find(".item").removeClass("next prev left right active"); + this.$target.find(".item:first").addClass("active"); this.$indicators.find('li').removeClass('active'); this.$indicators.find('li:first').addClass('active'); - if(!this.$target.find(".item.active").length) { - this.$target.find(".item:first").addClass("active"); - } }, start : function () { var self = this; diff --git a/addons/website/static/src/xml/website.editor.xml b/addons/website/static/src/xml/website.editor.xml index d61b6ed2664..0e3873b1de6 100644 --- a/addons/website/static/src/xml/website.editor.xml +++ b/addons/website/static/src/xml/website.editor.xml @@ -51,7 +51,7 @@ id="link-page" type="hidden"/> </li> <li class="list-group-item form-group clearfix"> - <div class="pull-right"> + <div class="pull-right" style="display: none;"> <label> <input type="checkbox" class="window-new"/> Open in new window @@ -59,21 +59,12 @@ </div> <h4 class="list-group-item-heading"> <label for="link-external" class="control-label"> - URL + URL or Email Address </label> </h4> - <input type="text" class="form-control url url-source" + <input type="text" class="form-control url email-address url-source" id="link-external" placeholder="http://openerp.com"/> </li> - <li class="list-group-item form-group"> - <h4 class="list-group-item-heading"> - <label for="link-email" class="control-label"> - Email Address - </label> - </h4> - <input type="email" class="form-control email-address url-source" - id="link-email" placeholder="you@yourwebsite.com"/> - </li> </ul> <div class="form-horizontal"> <div class="form-group"> @@ -81,8 +72,71 @@ Link text </label> <div class="col-sm-10"> - <input type="text" class="form-control" - id="link-text"/> + <input type="text" class="form-control" id="link-text"/> + </div> + </div> + </div> + <div class="form-horizontal link-style"> + <div class="form-group"> + <label class="col-sm-2 control-label"> + Style + </label> + <div class="col-sm-4"> + <div class="dropdown" style="line-height: 2em;"> + <a data-toggle="dropdown" class="btn btn-default" href="#">Color Style <span class="caret"></span></a> + <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel"> + <li> + <label class="btn btn-link">Link<input value="" class="link-style" type="radio" name="link-style-type" checked="checked"/></label> + </li> + <li> + <label class="btn btn-default">Basic<input value="btn-default" class="link-style" type="radio" name="link-style-type"/></label> + </li> + <li> + <label class="btn btn-success">Success<input value="btn-success" class="link-style" type="radio" name="link-style-type"/></label> + </li> + <li> + <label class="btn btn-primary">Primary<input value="btn-primary" class="link-style" type="radio" name="link-style-type"/></label> + </li> + <li> + <label class="btn btn-info">Info<input value="btn-info" class="link-style" type="radio" name="link-style-type"/></label> + </li> + <li> + <label class="btn btn-warning">Warning<input value="btn-warning" class="link-style" type="radio" name="link-style-type"/></label> + </li> + <li> + <label class="btn btn-danger">Danger<input value="btn-danger" class="link-style" type="radio" name="link-style-type"/></label> + </li> + </ul> + </div> + </div> + <div class="col-sm-4"> + <div class="dropdown" style="line-height: 2em;"> + <a data-toggle="dropdown" class="btn btn-default" href="#">Size <span class="caret"></span></a> + <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel"> + <li> + <label class="btn btn-default btn-xs">Extra Small<input value="btn-xs" class="link-style" type="radio" name="link-style-size"/></label> + </li> + <li> + <label class="btn btn-default btn-sm">Small<input value="btn-sm" class="link-style" type="radio" name="link-style-size"/></label> + </li> + <li> + <label class="btn btn-default">Default<input value="" class="link-style" type="radio" name="link-style-size" checked="checked"/></label> + </li> + <li> + <label class="btn btn-default btn-lg">Large<input value="btn-lg" class="link-style" type="radio" name="link-style-size"/></label> + </li> + </ul> + </div> + </div> + </div> + </div> + <div class="form-horizontal link-style"> + <div class="form-group"> + <label class="col-sm-2 control-label"> + Preview + </label> + <div class="col-sm-10" style="line-height: 2em;"> + <a id="link-preview" href="#"></a> </div> </div> </div> |
