summaryrefslogtreecommitdiff
path: root/addons/website/static/src
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2015-08-24 18:19:19 +0200
committerChristophe Simonis <chs@odoo.com>2015-08-24 18:19:19 +0200
commit88c0ce0692ccf3b1302e15c4ebe34dbf2040be40 (patch)
tree5bb1749f69f96df22a92a747052dc2965e83430e /addons/website/static/src
parent878c3c9291ad69b530d24227cb25b38dbf10229b (diff)
parente16d495d8965522d90ddf5d5da234b1650a695f9 (diff)
[MERGE] forward port of branch saas-6 up to e16d495
Diffstat (limited to 'addons/website/static/src')
-rw-r--r--addons/website/static/src/js/website.snippets.editor.js12
-rw-r--r--addons/website/static/src/js/website.snippets.gallery.js21
-rw-r--r--addons/website/static/src/js/website.theme.js54
3 files changed, 54 insertions, 33 deletions
diff --git a/addons/website/static/src/js/website.snippets.editor.js b/addons/website/static/src/js/website.snippets.editor.js
index 9cc40247b89..61a7622ecbf 100644
--- a/addons/website/static/src/js/website.snippets.editor.js
+++ b/addons/website/static/src/js/website.snippets.editor.js
@@ -81,7 +81,7 @@ options.registry.slider = options.Class.extend({
this.$indicators.append('<li data-target="#' + this.id + '" data-slide-to="' + cycle + '"></li>');
// clone the best candidate from template to use new features
- var $snippets = this.BuildingBlock.$snippets;
+ var $snippets = this.buildingBlock.$snippets;
//since saas-6, all snippets must start by s_
var selection = this.$target.closest('[class*="s_"');
if (_.isUndefined(selection)) {
@@ -174,7 +174,7 @@ options.registry.carousel = options.registry.slider.extend({
};
this.$target.on('slid.bs.carousel', function () {
if(self.editor && self.editor.styles.background) {
- self.editor.styles.background.$bg = self.$target.find(".item.active");
+ self.editor.styles.background.$target = self.$target.find(".item.active");
self.editor.styles.background.set_active();
}
self.$target.carousel("pause");
@@ -264,9 +264,13 @@ options.registry.marginAndResize = options.Class.extend({
} else {
var xy = event['page'+XY];
var current = resize[2] || 0;
+ var margin_dir = {s:'bottom', n: 'top', w: 'left', e: 'right'}[compass];
+ var real_margin = parseInt(self.$target.css('margin-'+margin_dir));
_.each(resize[0], function (val, key) {
if (self.$target.hasClass(val)) {
current = key;
+ } else if (resize[1][key] === real_margin) {
+ current = key;
}
});
var begin = current;
@@ -362,12 +366,12 @@ options.registry.marginAndResize = options.Class.extend({
if (offset === 0) overlay_class+= " block-w-left";
var mb = _class.match(/mb([0-9-]+)/i);
- mb = mb ? +mb[1] : 0;
+ mb = mb ? +mb[1] : parseInt(this.$target.css('margin-bottom'));
if (mb >= 128) overlay_class+= " block-s-bottom";
else if (!mb) overlay_class+= " block-s-top";
var mt = _class.match(/mt([0-9-]+)/i);
- mt = mt ? +mt[1] : 0;
+ mt = mt ? +mt[1] : parseInt(this.$target.css('margin-top'));
if (mt >= 128) overlay_class+= " block-n-top";
else if (!mt) overlay_class+= " block-n-bottom";
diff --git a/addons/website/static/src/js/website.snippets.gallery.js b/addons/website/static/src/js/website.snippets.gallery.js
index 4eb09a4837b..fd6005456e2 100644
--- a/addons/website/static/src/js/website.snippets.gallery.js
+++ b/addons/website/static/src/js/website.snippets.gallery.js
@@ -38,13 +38,9 @@ options.registry.gallery = options.Class.extend({
this._temp_col = this.$el.find("data-columns").data("columns");
},
drop_and_build_snippet: function() {
- var uuid = 0;
- $(".carousel").each(function () {
- var id = parseInt(($(this).attr('id') || '0').replace(/[^0-9]/, ''));
- if (id > uuid) uuid = id;
- });
- this.$target.find('.carousel').attr('id', 'slideshow_'+ (uuid+1));
- this.$target.find('[data-target]').attr('data-target', '#slideshow_'+ (uuid+1));
+ var uuid = new Date().getTime();
+ this.$target.find('.carousel').attr('id', 'slideshow_' + uuid);
+ this.$target.find('[data-target]').attr('data-target', '#slideshow_' + uuid);
},
styling : function(type, value) {
var classes = this.$el.find('li[data-styling]').map(function () {
@@ -194,18 +190,13 @@ options.registry.gallery = options.Class.extend({
var self = this,
$imgs = $(this.get_imgs()),
- urls = $imgs.map(function() { return $(this).attr("src"); } ).get(),
- uuid = 0;
- $(".carousel").each(function () {
- var id = parseInt(($(this).attr('id') || '0').replace(/[^0-9]/, ''));
- if (id > uuid) uuid = id;
- });
+ urls = $imgs.map(function() { return $(this).attr("src"); } ).get();
var params = {
srcs : urls,
- index: 1,
+ index: 0,
title: "",
interval : this.$target.data("interval") || false,
- id: "slideshow_" + (uuid+1)
+ id: "slideshow_" + new Date().getTime()
},
$slideshow = $(qweb.render('website.gallery.slideshow', params));
this.replace($slideshow);
diff --git a/addons/website/static/src/js/website.theme.js b/addons/website/static/src/js/website.theme.js
index f0d45c169ac..7b10fd7ea13 100644
--- a/addons/website/static/src/js/website.theme.js
+++ b/addons/website/static/src/js/website.theme.js
@@ -29,6 +29,12 @@ var Theme = Widget.extend({
template: 'website.theme_customize',
events: {
'change input[data-xmlid],input[data-enable],input[data-disable]': 'change_selection',
+ 'click label:has(input[data-xmlid],input[data-enable],input[data-disable])': function (event) {
+ var self = this;
+ this.time_select = _.defer(function () {
+ self.on_select($(event.target).find('input'));
+ });
+ },
'click .close': 'close',
'click': 'click',
},
@@ -39,7 +45,7 @@ var Theme = Widget.extend({
this.flag = false;
this.$el.addClass("theme_customize_modal");
this.active_select_tags();
- this.$inputs = $("input[data-xmlid],input[data-enable],input[data-disable]");
+ this.$inputs = this.$("input[data-xmlid],input[data-enable],input[data-disable]");
setTimeout(function () {self.$el.addClass('in');}, 0);
this.keydown_escape = function (event) {
if (event.keyCode === 27) {
@@ -92,10 +98,10 @@ var Theme = Widget.extend({
self.$inputs.filter('[data-xmlid=""]').prop("checked", true).change();
self.$inputs.filter('[data-xmlid]:not([data-xmlid=""])').each(function () {
if (!_.difference(self.get_xml_ids($(this)), data[1]).length) {
- $(this).prop("checked", false).change();
+ $(this).prop("checked", false).trigger("change", true);
}
if (!_.difference(self.get_xml_ids($(this)), data[0]).length) {
- $(this).prop("checked", true).change();
+ $(this).prop("checked", true).trigger("change", true);
}
});
}).fail(function (d, error) {
@@ -174,9 +180,8 @@ var Theme = Widget.extend({
return $.Deferred();
}
},
- enable_disable: function (data, enable) {
- if (!data) return;
- this.$('#'+data.split(",").join(", #")).each(function () {
+ enable_disable: function ($inputs, enable) {
+ $inputs.each(function () {
var check = $(this).prop("checked");
var $label = $(this).closest("label");
$(this).prop("checked", enable);
@@ -187,21 +192,31 @@ var Theme = Widget.extend({
}
});
},
- change_selection: function (event) {
+ change_selection: function (event, init_mode) {
var self = this;
- if (this.$el.hasClass("loading")) return;
+ clearTimeout(this.time_select);
+ if (this.$el.hasClass("loading")) return; // prevent to change selection when css is loading
+
var $option = $(event.target),
+ $options = $option,
checked = $option.prop("checked");
if (checked) {
- this.enable_disable($option.data('enable'), true);
- this.enable_disable($option.data('disable'), false);
+ if($option.data('enable')) {
+ var $inputs = this.get_inputs($option.data('enable'));
+ $options = $options.add($inputs.filter(':not(:checked)'));
+ this.enable_disable($inputs, true);
+ }
+ if($option.data('disable')) {
+ var $inputs = this.get_inputs($option.data('disable'));
+ $options = $options.add($inputs.filter(':checked'));
+ this.enable_disable($inputs, false);
+ }
$option.closest("label").addClass("checked");
} else {
$option.closest("label").removeClass("checked");
}
- $option.prop("checked", checked);
var $enable = this.$inputs.filter('[data-xmlid]:checked');
$enable.closest("label").addClass("checked");
@@ -236,14 +251,25 @@ var Theme = Widget.extend({
clearTimeout(this.timer);
if (this.flag) {
- this.timer = setTimeout(function () {
+ this.timer = _.defer(function () {
+ if (!init_mode) self.on_select($options);
self.update_style(self.get_xml_ids($enable), self.get_xml_ids($disable), self.reload);
self.reload = false;
- },0);
+ });
} else {
- this.timer = setTimeout(function () { self.reload = false; },0);
+ this.timer = _.defer(function () {
+ if (!init_mode) self.on_select($options);
+ self.reload = false;
+ });
}
},
+ /* Method call when the user change the selection or click on an input
+ * @values: all changed inputs
+ */
+ on_select: function ($inputs) {
+ clearTimeout(this.time_select);
+ console.log($inputs.get());
+ },
click: function (event) {
if (!$(event.target).closest("#theme_customize_modal > *").length) {
this.close();