summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2015-07-22 16:17:54 +0200
committerChristophe Simonis <chs@odoo.com>2015-07-22 16:17:54 +0200
commit2cf91d16a5f844a2a3d5d22c025c180a6615bab8 (patch)
treea7bc3974a9c349ae1575fd3b10bbb25d9b74b9ab /addons/web_editor/static/src
parentd74e0c3e9d9cd80bf532ba90f7c634ff55881b51 (diff)
parent63e92cbc9621813a276e340b7d961cbd8f8b97c4 (diff)
[MERGE] forward port of branch saas-6 up to 63e92cb
Diffstat (limited to 'addons/web_editor/static/src')
-rw-r--r--addons/web_editor/static/src/js/rte.summernote.js2
-rw-r--r--addons/web_editor/static/src/js/snippets.options.js7
-rw-r--r--addons/web_editor/static/src/js/summernote.js9
-rw-r--r--addons/web_editor/static/src/js/widgets.js65
-rw-r--r--addons/web_editor/static/src/xml/editor.xml8
5 files changed, 58 insertions, 33 deletions
diff --git a/addons/web_editor/static/src/js/rte.summernote.js b/addons/web_editor/static/src/js/rte.summernote.js
index c5e5dd6dd51..1067576ad15 100644
--- a/addons/web_editor/static/src/js/rte.summernote.js
+++ b/addons/web_editor/static/src/js/rte.summernote.js
@@ -408,7 +408,7 @@ dom.isImgFont = function (node) {
if (node && (nodeName === "SPAN" || nodeName === "I") && className.length) {
var classNames = className.split(/\s+/);
for (var k=0; k<widgets.fontIcons.length; k++) {
- if (_.intersection(widgets.fontIcons[k].icons, classNames).length) {
+ if (_.intersection(widgets.fontIcons[k].alias, classNames).length) {
return true;
}
}
diff --git a/addons/web_editor/static/src/js/snippets.options.js b/addons/web_editor/static/src/js/snippets.options.js
index a46c00baa25..4dce2e358ed 100644
--- a/addons/web_editor/static/src/js/snippets.options.js
+++ b/addons/web_editor/static/src/js/snippets.options.js
@@ -312,6 +312,7 @@ var colorpicker = Option.extend({
.click(function () {
$td.removeClass("selected");
$(this).parent().addClass("selected");
+ self.$target.closest(".o_editable").trigger("content_changed");
});
}
});
@@ -327,13 +328,17 @@ var background = Option.extend({
},
background: function(type, value, $li) {
if (value && value.length) {
- this.$bg.attr("style", 'background-image: url(' + value + ')' + (this.$bg.attr("style") || '').replace(/background-image:[^;]+/, '') );
+ this.$bg.attr("style", 'background-image: url(' + value + '); ' + (this.$bg.attr("style") || '').replace(/background-image:[^;]+/, '') );
this.$bg.addClass("oe_img_bg");
} else {
this.$bg.css("background-image", "");
this.$bg.removeClass("oe_img_bg").removeClass("oe_custom_bg");
}
},
+ select_class : function(type, value, $li) {
+ this.background(type, '', $li);
+ this._super(type, value, $li);
+ },
choose_image: function(type, value, $li) {
if(type !== "click") return;
diff --git a/addons/web_editor/static/src/js/summernote.js b/addons/web_editor/static/src/js/summernote.js
index b144ae4eacc..46b21aeec88 100644
--- a/addons/web_editor/static/src/js/summernote.js
+++ b/addons/web_editor/static/src/js/summernote.js
@@ -1776,7 +1776,7 @@ $.summernote.pluginEvents.applyFont = function (event, editor, layoutInfo, color
var startPoint = rng.getStartPoint();
var endPoint = rng.getEndPoint();
- if (rng.isCollapsed()) {
+ if (rng.isCollapsed() && !dom.isFont(rng.sc)) {
return {
sc: startPoint.node,
so: startPoint.offset,
@@ -1824,6 +1824,11 @@ $.summernote.pluginEvents.applyFont = function (event, editor, layoutInfo, color
});
nodes = list.unique(nodes);
+ // If ico fa
+ if (rng.isCollapsed()) {
+ nodes.push(startPoint.node);
+ }
+
// apply font: foreColor, backColor, size (the color can be use a class text-... or bg-...)
var node, font, $font, fonts = [], className;
if (color || bgcolor || size) {
@@ -1847,7 +1852,7 @@ $.summernote.pluginEvents.applyFont = function (event, editor, layoutInfo, color
if (color) {
for (var k=0; k<className.length; k++) {
- if (!className[k].length && className[k].slice(0,5) === "text-") {
+ if (className[k].length && className[k].slice(0,5) === "text-") {
className.splice(k,1);
k--;
}
diff --git a/addons/web_editor/static/src/js/widgets.js b/addons/web_editor/static/src/js/widgets.js
index 6fab80ad802..c4be26d313a 100644
--- a/addons/web_editor/static/src/js/widgets.js
+++ b/addons/web_editor/static/src/js/widgets.js
@@ -501,9 +501,21 @@ var getCssSelectors = function(filter) {
for(var r = 0; r < rules.length; r++) {
var selectorText = rules[r].selectorText;
if (selectorText) {
- var match = selectorText.match(filter);
- if (match) {
- css.push([match[1], rules[r].cssText.replace(/(^.*\{\s*)|(\s*\}\s*$)/g, '')]);
+ selectorText = selectorText.split(/\s*,\s*/);
+ var data = null;
+ for(var s = 0; s < selectorText.length; s++) {
+ var match = selectorText[s].match(filter);
+ if (match) {
+ var clean = match[1].slice(1).replace(/::?before$/, '');
+ if (!data) {
+ data = [match[1], rules[r].cssText.replace(/(^.*\{\s*)|(\s*\}\s*$)/g, ''), clean, [clean]];
+ } else {
+ data[3].push(clean);
+ }
+ }
+ }
+ if (data) {
+ css.push(data);
}
}
}
@@ -513,8 +525,11 @@ var getCssSelectors = function(filter) {
};
function computeFonts() {
_.each(fontIcons, function (data) {
- data.icons = _.map(getCssSelectors(data.parser), function (css) {
- return css[0].slice(1, css[0].length).replace(/::?before$/, '');
+ data.cssData = website.editor.getCssSelectors(data.parser);
+ data.alias = [];
+ data.icons = _.map(data.cssData, function (css) {
+ data.alias.push.apply(data.alias, css[3]);
+ return css[2];
});
});
}
@@ -575,22 +590,20 @@ var fontIconsDialog = Widget.extend({
search: function (needle) {
var iconsParser = this.iconsParser;
if (needle) {
- var parser = [];
- var fontIcon;
-
- for (var k=0; k<fontIcons.length; k++) {
- fontIcon = fontIcons[k];
- var icons = _(fontIcon.icons).filter(function (icon) {
- return icon.indexOf(needle) !== -1;
+ var iconsParser = [];
+ _.filter(this.iconsParser, function (data) {
+ var cssData = _.filter(data.cssData, function (cssData) {
+ return _.find(cssData[3], function (alias) {
+ return alias.indexOf(needle) !== -1;
+ });
});
- if (icons.length) {
- parser.push({
- base: fontIcon.base,
- icons: icons
+ if (cssData.length) {
+ iconsParser.push({
+ base: data.base,
+ cssData: cssData
});
}
- }
- iconsParser = parser;
+ });
}
this.$('div.font-icons-icons').html(
QWeb.render('web_editor.dialog.font-icons.icons', {'iconsParser': iconsParser}));
@@ -624,17 +637,17 @@ var fontIconsDialog = Widget.extend({
if (!(classNames instanceof Array)) {
classNames = (classNames||"").split(/\s+/);
}
- var fontIcon, className;
- for (var i=0; i<classNames.length; i++) {
- className = classNames[i];
- for (var k=0; k<fontIcons.length; k++) {
- fontIcon = fontIcons[k];
- if (className === fontIcon.base || fontIcon.icons.indexOf(className) !== -1) {
+ var fontIcon, cssData;
+ for (var k=0; k<this.iconsParser.length; k++) {
+ fontIcon = this.iconsParser[k];
+ for (var s=0; s<fontIcon.cssData.length; s++) {
+ cssData = fontIcon.cssData[s];
+ if (_.intersection(classNames, cssData[3]).length) {
return {
'base': fontIcon.base,
'parser': fontIcon.parser,
'icons': fontIcon.icons,
- 'font': className
+ 'font': cssData[2]
};
}
}
@@ -670,7 +683,7 @@ var fontIconsDialog = Widget.extend({
continue;
case '': continue;
default:
- $(".font-icons-icon").removeClass("font-icons-selected").filter("."+cls).addClass("font-icons-selected");
+ $(".font-icons-icon").removeClass("font-icons-selected").filter("[data-alias*=',"+cls+",']").addClass("font-icons-selected");
for (var k=0; k<this.icons.length; k++) {
if (this.icons.indexOf(cls) !== -1) {
this.$('#fa-icon').val(cls);
diff --git a/addons/web_editor/static/src/xml/editor.xml b/addons/web_editor/static/src/xml/editor.xml
index 7b73f9e3e16..111e91343b1 100644
--- a/addons/web_editor/static/src/xml/editor.xml
+++ b/addons/web_editor/static/src/xml/editor.xml
@@ -217,9 +217,11 @@
</t>
<t t-name="web_editor.dialog.font-icons.icons">
<t t-foreach="iconsParser" t-as="data">
- <span t-foreach="data.icons" t-as="icon"
- t-attf-class="#{data.base} font-icons-icon #{icon}"
- t-att-data-id="icon"/>
+ <span t-foreach="data.cssData" t-as="cssData"
+ t-attf-class="#{data.base} font-icons-icon #{cssData[2]}"
+ t-attf-data-alias=",#{cssData[3]},"
+ t-att-title="cssData[3].join(', ')"
+ t-att-data-id="cssData[2]"/>
</t>
</t>