[FIX] website: manage css margin for resizing

In some case margin could be applied via CSS and not via mb* classes
(e.g several themes with different aspects but a shared snippet). This
commit allow this if custom CSS margin matches a CSS mb* class value
(currently 0, 4, 8, 16, 32, 48, 92 and 128).
This commit is contained in:
Nicolas Lempereur
2015-08-21 15:58:52 +02:00
committed by Christophe Matthieu
parent 681195a53e
commit 0ddb68be81
@@ -1411,9 +1411,13 @@
} 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;
@@ -1509,12 +1513,12 @@
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";