[REF] theme_common: remove (deprecated) $target uses in public widgets
See community commit for details. closes odoo/design-themes#618 Related: odoo/enterprise#34343 Related: odoo/odoo#106437 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
@@ -9,7 +9,7 @@ odoo.define('theme_common.s_css_slider_frontend', function (require) {
|
|||||||
|
|
||||||
start: function () {
|
start: function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
var $container = self.$target;
|
var $container = self.$el;
|
||||||
$container.find(".s_css_slider_pagination").remove();
|
$container.find(".s_css_slider_pagination").remove();
|
||||||
// create slider pagination
|
// create slider pagination
|
||||||
var sliderPagination = self.createSliderPagination($container);
|
var sliderPagination = self.createSliderPagination($container);
|
||||||
|
|||||||
@@ -17,34 +17,34 @@ odoo.define("theme_common.s_showcase_slider_frontend", function (require) {
|
|||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
_.defer(this.unbindEvents.bind(this)); // FIXME delayed to counter a web_editor bug which off all click event
|
_.defer(this.unbindEvents.bind(this)); // FIXME delayed to counter a web_editor bug which off all click event
|
||||||
this.destroyPagination();
|
this.destroyPagination();
|
||||||
this.$target.removeClass("active");
|
this.$el.removeClass("active");
|
||||||
},
|
},
|
||||||
|
|
||||||
bindEvents: function () {
|
bindEvents: function () {
|
||||||
// Enlarge image on click if not already enlarged
|
// Enlarge image on click if not already enlarged
|
||||||
this.$target.on("click.s_showcase_slider", ".s_ss_slider", (function (e) {
|
this.$el.on("click.s_showcase_slider", ".s_ss_slider", (function (e) {
|
||||||
if (this.$target.hasClass("active")) return;
|
if (this.$el.hasClass("active")) return;
|
||||||
|
|
||||||
this.$target
|
this.$el
|
||||||
.addClass("active")
|
.addClass("active")
|
||||||
.one("webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend", (function () {
|
.one("webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend", (function () {
|
||||||
dom.scrollTo(this.$target[0], {
|
dom.scrollTo(this.el, {
|
||||||
duration: 200,
|
duration: 200,
|
||||||
extraOffset: 70,
|
extraOffset: 70,
|
||||||
});
|
});
|
||||||
this.$target.trigger("transitionIsFinished");
|
this.$el.trigger("transitionIsFinished");
|
||||||
}).bind(this));
|
}).bind(this));
|
||||||
}).bind(this));
|
}).bind(this));
|
||||||
|
|
||||||
// Close the enlarged image on close icon click
|
// Close the enlarged image on close icon click
|
||||||
this.$target.on("click.s_showcase_slider", ".s_ss_close", (function (e) {
|
this.$el.on("click.s_showcase_slider", ".s_ss_close", (function (e) {
|
||||||
this.$target.removeClass("active");
|
this.$el.removeClass("active");
|
||||||
}).bind(this));
|
}).bind(this));
|
||||||
|
|
||||||
// Handle click navigation
|
// Handle click navigation
|
||||||
this.$target.on("click.s_showcase_slider", ".s_ss_prev", this.prevSlide.bind(this));
|
this.$el.on("click.s_showcase_slider", ".s_ss_prev", this.prevSlide.bind(this));
|
||||||
this.$target.on("click.s_showcase_slider", ".s_ss_next", this.nextSlide.bind(this));
|
this.$el.on("click.s_showcase_slider", ".s_ss_next", this.nextSlide.bind(this));
|
||||||
this.$target.on("click.s_showcase_slider", ".s_ss_slider_pagination > li > a", (function (e) {
|
this.$el.on("click.s_showcase_slider", ".s_ss_slider_pagination > li > a", (function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var $selectedDot = $(e.currentTarget).parent();
|
var $selectedDot = $(e.currentTarget).parent();
|
||||||
if ($selectedDot.hasClass("selected")) return;
|
if ($selectedDot.hasClass("selected")) return;
|
||||||
@@ -53,7 +53,7 @@ odoo.define("theme_common.s_showcase_slider_frontend", function (require) {
|
|||||||
|
|
||||||
// Keyboard slider navigation
|
// Keyboard slider navigation
|
||||||
$(document).on("keyup.s_showcase_slider", (function (e) {
|
$(document).on("keyup.s_showcase_slider", (function (e) {
|
||||||
if (!this.$target.hasClass("active")) return;
|
if (!this.$el.hasClass("active")) return;
|
||||||
|
|
||||||
switch (e.which) {
|
switch (e.which) {
|
||||||
case $.ui.keyCode.LEFT:
|
case $.ui.keyCode.LEFT:
|
||||||
@@ -63,24 +63,24 @@ odoo.define("theme_common.s_showcase_slider_frontend", function (require) {
|
|||||||
this.nextSlide();
|
this.nextSlide();
|
||||||
break;
|
break;
|
||||||
case $.ui.keyCode.ESCAPE:
|
case $.ui.keyCode.ESCAPE:
|
||||||
this.$target.removeClass("active");
|
this.$el.removeClass("active");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}).bind(this));
|
}).bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
unbindEvents: function () {
|
unbindEvents: function () {
|
||||||
this.$target.off(".s_showcase_slider");
|
this.$el.off(".s_showcase_slider");
|
||||||
$(document).off(".s_showcase_slider");
|
$(document).off(".s_showcase_slider");
|
||||||
},
|
},
|
||||||
|
|
||||||
createPagination: function () { // FIXME pagination should be saved with editor but keep this for compatibility
|
createPagination: function () { // FIXME pagination should be saved with editor but keep this for compatibility
|
||||||
this.$target.find(".s_ss_slider_pagination").remove(); // Remove saved-with-editor pagination
|
this.$el.find(".s_ss_slider_pagination").remove(); // Remove saved-with-editor pagination
|
||||||
|
|
||||||
this.$pagination = $("<ul/>", {class: "s_ss_slider_pagination"});
|
this.$pagination = $("<ul/>", {class: "s_ss_slider_pagination"});
|
||||||
this.$pagination.insertAfter(this.$target.find(".s_ss_slider_navigation"));
|
this.$pagination.insertAfter(this.$el.find(".s_ss_slider_navigation"));
|
||||||
|
|
||||||
var nbSlides = this.$target.find(".s_ss_slider").children().length;
|
var nbSlides = this.$el.find(".s_ss_slider").children().length;
|
||||||
for (var i = 0 ; i < nbSlides ; i++) {
|
for (var i = 0 ; i < nbSlides ; i++) {
|
||||||
this.$pagination.append("<li><a href=\"#\"></a></li>");
|
this.$pagination.append("<li><a href=\"#\"></a></li>");
|
||||||
}
|
}
|
||||||
@@ -96,24 +96,24 @@ odoo.define("theme_common.s_showcase_slider_frontend", function (require) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
prevSlide: function () {
|
prevSlide: function () {
|
||||||
var nbSlides = this.$target.find(".s_ss_slider").children().length;
|
var nbSlides = this.$el.find(".s_ss_slider").children().length;
|
||||||
var currentIndex = this.getCurrentIndex();
|
var currentIndex = this.getCurrentIndex();
|
||||||
this.changeSlide(currentIndex > 0 ? (currentIndex - 1) : (nbSlides - 1));
|
this.changeSlide(currentIndex > 0 ? (currentIndex - 1) : (nbSlides - 1));
|
||||||
},
|
},
|
||||||
|
|
||||||
nextSlide: function () {
|
nextSlide: function () {
|
||||||
var nbSlides = this.$target.find(".s_ss_slider").children().length;
|
var nbSlides = this.$el.find(".s_ss_slider").children().length;
|
||||||
var currentIndex = this.getCurrentIndex();
|
var currentIndex = this.getCurrentIndex();
|
||||||
this.changeSlide((currentIndex + 1) % nbSlides);
|
this.changeSlide((currentIndex + 1) % nbSlides);
|
||||||
},
|
},
|
||||||
|
|
||||||
getCurrentIndex: function () {
|
getCurrentIndex: function () {
|
||||||
return this.$target.find(".s_ss_slider > .selected").index();
|
return this.$el.find(".s_ss_slider > .selected").index();
|
||||||
},
|
},
|
||||||
|
|
||||||
changeSlide: function (n) {
|
changeSlide: function (n) {
|
||||||
var $slides = this.$target.find(".s_ss_slider > li").removeClass("selected");
|
var $slides = this.$el.find(".s_ss_slider > li").removeClass("selected");
|
||||||
this.$target.find(".s_ss_slider_pagination > li").removeClass("selected");
|
this.$el.find(".s_ss_slider_pagination > li").removeClass("selected");
|
||||||
|
|
||||||
var $slide = $slides.eq(n).addClass("selected");
|
var $slide = $slides.eq(n).addClass("selected");
|
||||||
$slides.removeClass("move-left");
|
$slides.removeClass("move-left");
|
||||||
@@ -124,9 +124,9 @@ odoo.define("theme_common.s_showcase_slider_frontend", function (require) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
updateNavigation: function () {
|
updateNavigation: function () {
|
||||||
var $active = this.$target.find(".s_ss_slider > .selected");
|
var $active = this.$el.find(".s_ss_slider > .selected");
|
||||||
this.$target.find(".s_ss_prev").toggleClass("inactive", $active.is(":first-child"));
|
this.$el.find(".s_ss_prev").toggleClass("inactive", $active.is(":first-child"));
|
||||||
this.$target.find(".s_ss_next").toggleClass("inactive", $active.is(":last-child"));
|
this.$el.find(".s_ss_next").toggleClass("inactive", $active.is(":last-child"));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user