diff --git a/addons/portal/static/src/js/portal.js b/addons/portal/static/src/js/portal.js index 6a96ac5c967..08e37bb2681 100644 --- a/addons/portal/static/src/js/portal.js +++ b/addons/portal/static/src/js/portal.js @@ -5,7 +5,7 @@ var publicWidget = require('web.public.widget'); publicWidget.registry.portalDetails = publicWidget.Widget.extend({ selector: '.o_portal_details', - read_events: { + events: { 'change select[name="country_id"]': '_onCountryChange', }, @@ -14,9 +14,6 @@ publicWidget.registry.portalDetails = publicWidget.Widget.extend({ */ start: function () { var def = this._super.apply(this, arguments); - if (this.editableMode) { - return; - } this.$state = this.$('select[name="state_id"]'); this.$stateOptions = this.$state.filter(':enabled').find('option:not(:first)'); @@ -55,7 +52,7 @@ publicWidget.registry.portalDetails = publicWidget.Widget.extend({ publicWidget.registry.portalSearchPanel = publicWidget.Widget.extend({ selector: '.o_portal_search_panel', - read_events: { + events: { 'click .search-submit': '_onSearchSubmitClick', 'click .dropdown-item': '_onDropdownItemClick', 'keyup input[name="search"]': '_onSearchInputKeyup', @@ -66,12 +63,7 @@ publicWidget.registry.portalSearchPanel = publicWidget.Widget.extend({ */ start: function () { var def = this._super.apply(this, arguments); - if (this.editableMode) { - return; - } - this._adaptSearchLabel(this.$('.dropdown-item.active')); - return def; }, diff --git a/addons/sale/static/src/js/product_configurator_renderer.js b/addons/sale/static/src/js/product_configurator_renderer.js index 899656c8065..8d16f2a329a 100644 --- a/addons/sale/static/src/js/product_configurator_renderer.js +++ b/addons/sale/static/src/js/product_configurator_renderer.js @@ -4,7 +4,7 @@ odoo.define('sale.ProductConfiguratorFormRenderer', function (require) { var FormRenderer = require('web.FormRenderer'); var ProductConfiguratorMixin = require('sale.ProductConfiguratorMixin'); -var ProductConfiguratorFormRenderer = FormRenderer.extend(ProductConfiguratorMixin ,{ +var ProductConfiguratorFormRenderer = FormRenderer.extend(ProductConfiguratorMixin, { /** * @override */ diff --git a/addons/web/static/src/js/public/public_root.js b/addons/web/static/src/js/public/public_root.js index eedc6cf5377..ebf9bb0937d 100644 --- a/addons/web/static/src/js/public/public_root.js +++ b/addons/web/static/src/js/public/public_root.js @@ -135,6 +135,14 @@ var PublicRoot = publicWidget.RootWidget.extend(ServiceProviderMixin, { _getExtraContext: function (context) { return this._getContext(context); }, + /** + * @private + * @param {Object} [options] + * @returns {Object} + */ + _getPublicWidgetsRegistry: function (options) { + return publicWidget.registry; + }, /** * As the root instance is designed to be unique, the associated * registry has been instantiated outside of the class and is simply @@ -176,7 +184,7 @@ var PublicRoot = publicWidget.RootWidget.extend(ServiceProviderMixin, { this._stopAnimations($from); - var defs = _.map(publicWidget.registry, function (WebsiteWidget) { + var defs = _.map(this._getPublicWidgetsRegistry(options), function (WebsiteWidget) { var selector = WebsiteWidget.prototype.selector || ''; var $target = $from.find(selector).addBack(selector); diff --git a/addons/web/static/src/js/public/public_widget.js b/addons/web/static/src/js/public/public_widget.js index 2f720c019f1..ed99c5da457 100644 --- a/addons/web/static/src/js/public/public_widget.js +++ b/addons/web/static/src/js/public/public_widget.js @@ -207,41 +207,15 @@ var PublicWidget = Widget.extend({ * @type {Object} */ events: {}, - /** - * Acts as @see Widget.events except that the events are only binded if the - * Animation instance is instanciated in edit mode. - */ - edit_events: {}, - /** - * Acts as @see Widget.events except that the events are only binded if the - * Animation instance is instanciated in readonly mode. - */ - read_events: {}, /** - * Initializes the events that will need to be binded according to the - * given mode. - * * @constructor * @param {Object} parent - * @param {Object} options - * @param {boolean} options.editableMode - true if the page is in edition mode + * @param {Object} [options] */ init: function (parent, options) { this._super.apply(this, arguments); - - // Note that the notion of editable mode is kept here for now even - // though nothing can be edited here. This allows to have a readable - // code for frontend widgets and mainly to prevent having loading - // problems an "include" could have caused. this.options = options || {}; - this.editableMode = this.options.editableMode || false; - - if (this.editableMode) { - this.events = _.extend({}, this.events || {}, this.edit_events || {}); - } else { - this.events = _.extend({}, this.events || {}, this.read_events || {}); - } }, /** * Destroys the animation and basically restores the target to the state it diff --git a/addons/website/static/src/js/content/menu.js b/addons/website/static/src/js/content/menu.js index 7e06140f657..b8ea9f61564 100644 --- a/addons/website/static/src/js/content/menu.js +++ b/addons/website/static/src/js/content/menu.js @@ -13,9 +13,6 @@ sAnimation.registry.affixMenu = sAnimation.Class.extend({ */ start: function () { var def = this._super.apply(this, arguments); - if (this.editableMode) { - return def; - } var self = this; this.$headerClone = this.$target.clone().addClass('o_header_affix affix').removeClass('o_affix_enabled'); diff --git a/addons/website/static/src/js/content/snippets.animation.js b/addons/website/static/src/js/content/snippets.animation.js index d2ef26a1bf6..ae4df825c50 100644 --- a/addons/website/static/src/js/content/snippets.animation.js +++ b/addons/website/static/src/js/content/snippets.animation.js @@ -33,6 +33,54 @@ if (!window.performance || !window.performance.now) { }; } +/** + * Add the notion of edit mode to public widgets. + */ +publicWidget.Widget.include({ + /** + * Indicates if the widget should not be instantiated in edit. The default + * is true, indeed most (all?) defined widgets only want to initialize + * events and states which should not be active in edit mode (this is + * especially true for non-website widgets). + * + * @type {boolean} + */ + disabledInEditableMode: true, + /** + * Acts as @see Widget.events except that the events are only binded if the + * Animation instance is instanciated in edit mode. The property is not + * considered if @see disabledInEditableMode is false. + */ + edit_events: null, + /** + * Acts as @see Widget.events except that the events are only binded if the + * Animation instance is instanciated in readonly mode. The property only + * makes sense if @see disabledInEditableMode is false, you should simply + * use @see Widget.events otherwise. + */ + read_events: null, + + /** + * Initializes the events that will need to be binded according to the + * given mode. + * + * @constructor + * @param {Object} parent + * @param {Object} [options] + * @param {boolean} [options.editableMode=false] + * true if the page is in edition mode + */ + init: function (parent, options) { + this._super.apply(this, arguments); + + this.editableMode = this.options.editableMode || false; + var extraEvents = this.editableMode ? this.edit_events : this.read_events; + if (extraEvents) { + this.events = _.extend(this.events || {}, extraEvents); + } + }, +}); + /** * In charge of handling one animation loop using the requestAnimationFrame * feature. This is used by the `Animation` class below and should not be called @@ -379,6 +427,7 @@ var registry = publicWidget.registry; registry.slider = publicWidget.Widget.extend({ selector: '.carousel', + disabledInEditableMode: false, edit_events: { 'slid.bs.carousel': '_onEditionSlide', }, @@ -669,7 +718,7 @@ registry.ul = publicWidget.Widget.extend({ registry.gallery = publicWidget.Widget.extend({ selector: '.o_gallery:not(.o_slideshow)', xmlDependencies: ['/website/static/src/xml/website.gallery.xml'], - read_events: { + events: { 'click img': '_onClickImg', }, @@ -741,6 +790,7 @@ registry.gallery = publicWidget.Widget.extend({ registry.gallerySlider = publicWidget.Widget.extend({ selector: '.o_slideshow', xmlDependencies: ['/website/static/src/xml/website.gallery.xml'], + disabledInEditableMode: false, /** * @override @@ -820,7 +870,7 @@ registry.gallerySlider = publicWidget.Widget.extend({ registry.socialShare = publicWidget.Widget.extend({ selector: '.oe_social_share', xmlDependencies: ['/website/static/src/xml/website.share.xml'], - read_events: { + events: { 'mouseenter': '_onMouseEnter', }, @@ -947,7 +997,7 @@ registry.facebookPage = publicWidget.Widget.extend({ registry.anchorSlide = publicWidget.Widget.extend({ selector: 'a[href^="/"][href*="#"], a[href^="#"]', - read_events: { + events: { 'click': '_onAnimateClick', }, diff --git a/addons/website/static/src/js/content/website_root.js b/addons/website/static/src/js/content/website_root.js index ce4ebfec435..fee9488583e 100644 --- a/addons/website/static/src/js/content/website_root.js +++ b/addons/website/static/src/js/content/website_root.js @@ -70,6 +70,18 @@ var WebsiteRoot = publicRootData.PublicRoot.extend({ 'edit_translations': !!html.dataset.edit_translations, }, this._super.apply(this, arguments)); }, + /** + * @override + */ + _getPublicWidgetsRegistry: function (options) { + var registry = this._super.apply(this, arguments); + if (options.editableMode) { + return _.pick(registry, function (PublicWidget) { + return !PublicWidget.prototype.disabledInEditableMode; + }); + } + return registry; + }, //-------------------------------------------------------------------------- // Handlers diff --git a/addons/website/static/src/js/editor/snippets.options.js b/addons/website/static/src/js/editor/snippets.options.js index f51dda964db..c6423fa359d 100644 --- a/addons/website/static/src/js/editor/snippets.options.js +++ b/addons/website/static/src/js/editor/snippets.options.js @@ -246,10 +246,7 @@ options.registry.carousel = options.Class.extend({ } }); _.defer(function () { - self.trigger_up('animation_start_demand', { - editableMode: true, - $target: self.$target, - }); + self._refreshAnimations(); self.$target.carousel(index > 0 ? --index : cycle); }); } diff --git a/addons/website_blog/static/src/js/s_latest_posts_frontend.js b/addons/website_blog/static/src/js/s_latest_posts_frontend.js index f1b8ea4f23d..fcc0ea087cf 100644 --- a/addons/website_blog/static/src/js/s_latest_posts_frontend.js +++ b/addons/website_blog/static/src/js/s_latest_posts_frontend.js @@ -8,6 +8,7 @@ var _t = core._t; sAnimation.registry.js_get_posts = sAnimation.Class.extend({ selector : '.js_get_posts', + disabledInEditableMode: false, /** * @override diff --git a/addons/website_blog/static/src/js/website_blog.js b/addons/website_blog/static/src/js/website_blog.js index 9d2af1a3bbc..ee0d9313600 100644 --- a/addons/website_blog/static/src/js/website_blog.js +++ b/addons/website_blog/static/src/js/website_blog.js @@ -5,7 +5,7 @@ var sAnimations = require('website.content.snippets.animation'); sAnimations.registry.websiteBlog = sAnimations.Class.extend({ selector: '.website_blog', - read_events: { + events: { 'click .cover_footer': '_onNextBlogClick', 'click a[href^="#blog_content"]': '_onContentAnchorClick', 'click .o_twitter, .o_facebook, .o_linkedin, .o_google, .o_twitter_complete, .o_facebook_complete, .o_linkedin_complete, .o_google_complete': '_onShareArticle', diff --git a/addons/website_crm_partner_assign/static/src/js/crm_partner_assign.js b/addons/website_crm_partner_assign/static/src/js/crm_partner_assign.js index 78b427eb296..8c185aa72c6 100644 --- a/addons/website_crm_partner_assign/static/src/js/crm_partner_assign.js +++ b/addons/website_crm_partner_assign/static/src/js/crm_partner_assign.js @@ -5,7 +5,7 @@ var sAnimations = require('website.content.snippets.animation'); sAnimations.registry.crmPartnerAssign = sAnimations.Class.extend({ selector: '#wrapwrap:has(.interested_partner_assign_form, .desinterested_partner_assign_form, .opp-stage-button, .new_opp_form)', - read_events: { + events: { 'click .interested_partner_assign_confirm': '_onInterestedPartnerAssignConfirm', 'click .desinterested_partner_assign_confirm': '_onDesinterestedPartnerAssignConfirm', 'click .opp-stage-button': '_onOppStageButtonClick', diff --git a/addons/website_event_track/static/src/js/website_event_track.js b/addons/website_event_track/static/src/js/website_event_track.js index 77c54c10501..152792bb9e5 100644 --- a/addons/website_event_track/static/src/js/website_event_track.js +++ b/addons/website_event_track/static/src/js/website_event_track.js @@ -5,7 +5,7 @@ var sAnimations = require('website.content.snippets.animation'); sAnimations.registry.websiteEventTrack = sAnimations.Class.extend({ selector: '.o_website_event', - read_events: { + events: { 'input #event_track_search': '_onEventTrackSearchInput', }, diff --git a/addons/website_forum/static/src/js/website_forum.js b/addons/website_forum/static/src/js/website_forum.js index 613163a045a..d1ce5b18f5c 100644 --- a/addons/website_forum/static/src/js/website_forum.js +++ b/addons/website_forum/static/src/js/website_forum.js @@ -12,7 +12,7 @@ var _t = core._t; sAnimations.registry.websiteForum = sAnimations.Class.extend({ selector: '.website_forum', xmlDependencies: ['/website_forum/static/src/xml/website_forum_share_templates.xml'], - read_events: { + events: { 'click .karma_required': '_onKarmaRequiredClick', 'mouseenter .o_js_forum_tag_follow': '_onTagFollowBoxMouseEnter', 'mouseleave .o_js_forum_tag_follow': '_onTagFollowBoxMouseLeave', @@ -506,7 +506,7 @@ sAnimations.registry.websiteForum = sAnimations.Class.extend({ sAnimations.registry.websiteForumSpam = sAnimations.Class.extend({ selector: '.o_wforum_moderation_queue', xmlDependencies: ['/website_forum/static/src/xml/website_forum_share_templates.xml'], - read_events: { + events: { 'click .o_wforum_select_all_spam': '_onSelectallSpamClick', 'click .o_wforum_mark_spam': 'async _onMarkSpamClick', 'input #spamSearch': '_onSpamSearchInput', diff --git a/addons/website_forum/static/src/js/website_forum.share.js b/addons/website_forum/static/src/js/website_forum.share.js index c1d0d8a1b4a..0fea6e4ef9c 100644 --- a/addons/website_forum/static/src/js/website_forum.share.js +++ b/addons/website_forum/static/src/js/website_forum.share.js @@ -11,15 +11,15 @@ var ForumShare = sAnimations.registry.socialShare.extend({ selector: '', xmlDependencies: sAnimations.registry.socialShare.prototype.xmlDependencies .concat(['/website_forum/static/src/xml/website_forum_share_templates.xml']), - read_events: {}, + events: {}, /** * @override * @param {Object} parent - * @param {boolean} editableMode + * @param {Object} options * @param {string} targetType */ - init: function (parent, editableMode, targetType) { + init: function (parent, options, targetType) { this._super.apply(this, arguments); this.targetType = targetType; }, @@ -71,7 +71,7 @@ var ForumShare = sAnimations.registry.socialShare.extend({ sAnimations.registry.websiteForumShare = sAnimations.Class.extend({ selector: '.website_forum', - read_events: { + events: { 'click :not(.karma_required).oe_social_share_call': '_onShareCallClick', }, diff --git a/addons/website_links/static/src/js/website_links.js b/addons/website_links/static/src/js/website_links.js index afe64642f47..ec77790bc00 100644 --- a/addons/website_links/static/src/js/website_links.js +++ b/addons/website_links/static/src/js/website_links.js @@ -339,7 +339,7 @@ var RecentLinks = Widget.extend({ sAnimations.registry.websiteLinks = sAnimations.Class.extend({ selector: '.o_website_links_create_tracked_url', - read_events: { + events: { 'click #filter-newest-links': '_onFilterNewestLinksClick', 'click #filter-most-clicked-links': '_onFilterMostClickedLinksClick', 'click #filter-recently-used-links': '_onFilterRecentlyUsedLinksClick', diff --git a/addons/website_links/static/src/js/website_links_charts.js b/addons/website_links/static/src/js/website_links_charts.js index 08ea40f1bed..5fcc343cede 100644 --- a/addons/website_links/static/src/js/website_links_charts.js +++ b/addons/website_links/static/src/js/website_links_charts.js @@ -150,7 +150,7 @@ var PieChart = Widget.extend({ sAnimations.registry.websiteLinksCharts = sAnimations.Class.extend({ selector: '.o_website_links_chart', - read_events: { + events: { 'click .graph-tabs li a': '_onGraphTabClick', 'click .copy-to-clipboard': '_onCopyToClipboardClick', }, diff --git a/addons/website_links/static/src/js/website_links_code_editor.js b/addons/website_links/static/src/js/website_links_code_editor.js index 3d550983e7a..d8d2f86a1a6 100644 --- a/addons/website_links/static/src/js/website_links_code_editor.js +++ b/addons/website_links/static/src/js/website_links_code_editor.js @@ -8,7 +8,7 @@ var _t = core._t; sAnimations.registry.websiteLinksCodeEditor = sAnimations.Class.extend({ selector: '#wrapwrap:has(.o_website_links_edit_code)', - read_events: { + events: { 'click .o_website_links_edit_code': '_onEditCodeClick', 'click .o_website_links_cancel_edit': '_onCancelEditClick', 'submit #edit-code-form': '_onEditCodeFormSubmit', diff --git a/addons/website_mail/static/src/js/follow.js b/addons/website_mail/static/src/js/follow.js index 0893c998ff1..7e72e5e5a4e 100644 --- a/addons/website_mail/static/src/js/follow.js +++ b/addons/website_mail/static/src/js/follow.js @@ -5,6 +5,7 @@ var sAnimation = require('website.content.snippets.animation'); sAnimation.registry.follow = sAnimation.Class.extend({ selector: '.js_follow', + disabledInEditableMode: false, start: function () { var self = this; diff --git a/addons/website_mail_channel/static/src/js/website_mail_channel.js b/addons/website_mail_channel/static/src/js/website_mail_channel.js index 84571336dfb..b30f9c583e3 100644 --- a/addons/website_mail_channel/static/src/js/website_mail_channel.js +++ b/addons/website_mail_channel/static/src/js/website_mail_channel.js @@ -5,7 +5,7 @@ var sAnimations = require('website.content.snippets.animation'); sAnimations.registry.websiteMailChannel = sAnimations.Class.extend({ selector: '#wrapwrap', - read_events: { + events: { 'click .o_mg_link_hide': '_onHideLinkClick', 'click .o_mg_link_show': '_onShowLinkClick', 'click button.o_mg_read_more': '_onReadMoreClick', diff --git a/addons/website_mail_channel/static/src/js/website_mail_channel.snippet.js b/addons/website_mail_channel/static/src/js/website_mail_channel.snippet.js index b8fd3761fc9..7ac4319a88b 100644 --- a/addons/website_mail_channel/static/src/js/website_mail_channel.snippet.js +++ b/addons/website_mail_channel/static/src/js/website_mail_channel.snippet.js @@ -5,6 +5,7 @@ var sAnimation = require('website.content.snippets.animation'); sAnimation.registry.follow_alias = sAnimation.Class.extend({ selector: ".js_follow_alias", + disabledInEditableMode: false, start: function () { var self = this; this.is_user = false; diff --git a/addons/website_mass_mailing/static/src/js/website_mass_mailing.js b/addons/website_mass_mailing/static/src/js/website_mass_mailing.js index e30f824693d..66a260264eb 100644 --- a/addons/website_mass_mailing/static/src/js/website_mass_mailing.js +++ b/addons/website_mass_mailing/static/src/js/website_mass_mailing.js @@ -6,6 +6,8 @@ var sAnimation = require('website.content.snippets.animation'); sAnimation.registry.subscribe = sAnimation.Class.extend({ selector: ".js_subscribe", + disabledInEditableMode: false, + start: function () { var self = this; @@ -65,6 +67,8 @@ sAnimation.registry.subscribe = sAnimation.Class.extend({ sAnimation.registry.newsletter_popup = sAnimation.Class.extend({ selector: ".o_newsletter_popup", + disabledInEditableMode: false, + start: function () { var self = this; diff --git a/addons/website_sale/static/src/js/website_sale.js b/addons/website_sale/static/src/js/website_sale.js index 94e9c54a312..9ac6a8f4237 100644 --- a/addons/website_sale/static/src/js/website_sale.js +++ b/addons/website_sale/static/src/js/website_sale.js @@ -9,7 +9,7 @@ var timeout; sAnimations.registry.websiteSaleCartLink = sAnimations.Class.extend({ selector: '#top_menu a[href$="/shop/cart"]', - read_events: { + events: { 'mouseenter': '_onMouseEnter', 'mouseleave': '_onMouseLeave', }, @@ -18,11 +18,6 @@ sAnimations.registry.websiteSaleCartLink = sAnimations.Class.extend({ * @override */ start: function () { - var def = this._super.apply(this, arguments); - if (this.editableMode) { - return def; - } - this.$el.popover({ trigger: 'manual', animation: true, @@ -34,7 +29,7 @@ sAnimations.registry.websiteSaleCartLink = sAnimations.Class.extend({ placement: 'auto', template: '' }); - return def; + return this._super.apply(this, arguments); }, //-------------------------------------------------------------------------- @@ -89,7 +84,7 @@ var sAnimations = require('website.content.snippets.animation'); sAnimations.registry.websiteSaleCategory = sAnimations.Class.extend({ selector: '#o_shop_collapse_category', - read_events: { + events: { 'click .fa-chevron-right': '_onOpenClick', 'click .fa-chevron-down': '_onCloseClick', }, @@ -123,18 +118,15 @@ sAnimations.registry.websiteSaleCategory = sAnimations.Class.extend({ odoo.define('website_sale.website_sale', function (require) { 'use strict'; -var utils = require('web.utils'); var ProductConfiguratorMixin = require('sale.ProductConfiguratorMixin'); var core = require('web.core'); var config = require('web.config'); var sAnimations = require('website.content.snippets.animation'); require("website.content.zoomodoo"); -var _t = core._t; - sAnimations.registry.WebsiteSale = sAnimations.Class.extend(ProductConfiguratorMixin, { selector: '.oe_website_sale', - read_events: { + events: _.extend({}, ProductConfiguratorMixin.events || {}, { 'change form .js_product:first input[name="add_qty"]': '_onChangeAddQuantity', 'mouseup .js_publish': '_onMouseupPublish', 'touchend .js_publish': '_onMouseupPublish', @@ -152,7 +144,7 @@ sAnimations.registry.WebsiteSale = sAnimations.Class.extend(ProductConfiguratorM 'change #shipping_use_same': '_onChangeShippingUseSame', 'click .toggle_summary': '_onToggleSummary', 'click input.js_product_change': 'onChangeVariant', - }, + }), /** * @constructor @@ -170,9 +162,6 @@ sAnimations.registry.WebsiteSale = sAnimations.Class.extend(ProductConfiguratorM */ start: function () { var def = this._super.apply(this, arguments); - if (this.editableMode) { - return def; - } _.each(this.$('div.js_product'), function (product) { $('input.js_product_change', product).first().trigger('change'); @@ -610,7 +599,7 @@ sAnimations.registry.WebsiteSale = sAnimations.Class.extend(ProductConfiguratorM sAnimations.registry.websiteSaleCart = sAnimations.Class.extend({ selector: '.oe_website_sale .oe_cart', - read_events: { + events: { 'click .js_change_shipping': '_onClickChangeShipping', 'click .js_edit_address': '_onClickEditAddress', 'click .js_delete_product': '_onClickDeleteProduct', diff --git a/addons/website_sale/static/src/js/website_sale_options.js b/addons/website_sale/static/src/js/website_sale_options.js index 92f325c18be..c80265c7131 100644 --- a/addons/website_sale/static/src/js/website_sale_options.js +++ b/addons/website_sale/static/src/js/website_sale_options.js @@ -10,9 +10,9 @@ require('website_sale.website_sale'); sAnimations.registry.WebsiteSaleOptions = sAnimations.Class.extend(ProductConfiguratorMixin, { selector: '.oe_website_sale', - read_events: { + events: _.extend({}, ProductConfiguratorMixin.events || {}, { 'click #add_to_cart, #products_grid .product_price .a-submit': 'async _onClickAdd', - }, + }), /** * @constructor diff --git a/addons/website_sale/static/src/js/website_sale_tracking.js b/addons/website_sale/static/src/js/website_sale_tracking.js index b2d51c1dc67..684b461bb35 100644 --- a/addons/website_sale/static/src/js/website_sale_tracking.js +++ b/addons/website_sale/static/src/js/website_sale_tracking.js @@ -4,7 +4,7 @@ var sAnimations = require('website.content.snippets.animation'); sAnimations.registry.websiteSaleTracking = sAnimations.Class.extend({ selector: '.oe_website_sale', - read_events: { + events: { 'click form[action="/shop/cart/update"] a.a-submit': '_onAddProductIntoCart', 'click a[href="/shop/checkout"]': '_onCheckoutStart', 'click div.oe_cart a[href^="/web?redirect"][href$="/shop/checkout"]': '_onCustomerSignin', @@ -17,10 +17,6 @@ sAnimations.registry.websiteSaleTracking = sAnimations.Class.extend({ */ start: function () { var self = this; - var def = this._super.apply(this, arguments); - if (this.editableMode) { - return def; - } // Watching a product if (this.$el.is('#product_detail')) { @@ -50,7 +46,7 @@ sAnimations.registry.websiteSaleTracking = sAnimations.Class.extend({ }); } - return def; + return this._super.apply(this, arguments); }, //-------------------------------------------------------------------------- @@ -61,7 +57,7 @@ sAnimations.registry.websiteSaleTracking = sAnimations.Class.extend({ * @private */ _trackGA: function () { - websiteGA = window.ga || function () {}; + var websiteGA = window.ga || function () {}; websiteGA.apply(this, arguments); }, /** diff --git a/addons/website_sale/static/src/js/website_sale_validate.js b/addons/website_sale/static/src/js/website_sale_validate.js index 4bf71ce35b0..5c590f8e88b 100644 --- a/addons/website_sale/static/src/js/website_sale_validate.js +++ b/addons/website_sale/static/src/js/website_sale_validate.js @@ -11,13 +11,8 @@ sAnimations.registry.websiteSaleValidate = sAnimations.Class.extend({ */ start: function () { var def = this._super.apply(this, arguments); - if (this.editableMode) { - return def; - } - this._poll_nbr = 0; this._paymentTransationPollStatus(); - return def; }, diff --git a/addons/website_sale_comparison/static/src/js/website_sale_comparison.js b/addons/website_sale_comparison/static/src/js/website_sale_comparison.js index a52d548cb77..c88ee50efa9 100644 --- a/addons/website_sale_comparison/static/src/js/website_sale_comparison.js +++ b/addons/website_sale_comparison/static/src/js/website_sale_comparison.js @@ -237,7 +237,7 @@ var ProductComparison = Widget.extend(ProductConfiguratorMixin, { sAnimations.registry.ProductComparison = sAnimations.Class.extend({ selector: '.oe_website_sale', - read_events: { + events: { 'click .o_add_compare, .o_add_compare_dyn': '_onClickAddCompare', 'click #o_comparelist_table tr': '_onClickComparelistTr', }, @@ -247,10 +247,6 @@ sAnimations.registry.ProductComparison = sAnimations.Class.extend({ */ start: function () { var def = this._super.apply(this, arguments); - if (this.editableMode) { - return def; - } - this.productComparison = new ProductComparison(this); return $.when(def, this.productComparison.appendTo(this.$el)); }, diff --git a/addons/website_sale_delivery/static/src/js/website_sale_delivery.js b/addons/website_sale_delivery/static/src/js/website_sale_delivery.js index 88c240222d9..8cf7c8f08cb 100644 --- a/addons/website_sale_delivery/static/src/js/website_sale_delivery.js +++ b/addons/website_sale_delivery/static/src/js/website_sale_delivery.js @@ -10,7 +10,7 @@ var dp = new concurrency.DropPrevious(); sAnimations.registry.websiteSaleDelivery = sAnimations.Class.extend({ selector: '.oe_website_sale', - read_events: { + events: { 'change select[name="shipping_id"]': '_onSetAddress', 'click #delivery_carrier .o_delivery_carrier_select': '_onCarrierClick', }, diff --git a/addons/website_sale_wishlist/static/src/js/website_sale_wishlist.js b/addons/website_sale_wishlist/static/src/js/website_sale_wishlist.js index 947500a7106..1b237499ab2 100644 --- a/addons/website_sale_wishlist/static/src/js/website_sale_wishlist.js +++ b/addons/website_sale_wishlist/static/src/js/website_sale_wishlist.js @@ -10,7 +10,7 @@ var ProductConfiguratorMixin = require('sale.ProductConfiguratorMixin'); // in website_sale.js sAnimations.registry.ProductWishlist = sAnimations.Class.extend(ProductConfiguratorMixin, { selector: '.oe_website_sale', - read_events: { + events: { 'click #my_wish': '_onClickMyWish', 'click .o_add_wishlist, .o_add_wishlist_dyn': '_onClickAddWish', 'change input.product_id': '_onChangeVariant', @@ -18,7 +18,6 @@ sAnimations.registry.ProductWishlist = sAnimations.Class.extend(ProductConfigura 'click .wishlist-section .o_wish_rm': '_onClickWishRemove', 'click .wishlist-section .o_wish_add': '_onClickWishAdd', }, - events: sAnimations.Class.events, /** * @constructor @@ -36,9 +35,6 @@ sAnimations.registry.ProductWishlist = sAnimations.Class.extend(ProductConfigura willStart: function () { var self = this; var def = this._super.apply(this, arguments); - if (this.editableMode) { - return def; - } var wishDef = $.get('/shop/wishlist', { count: 1, @@ -56,9 +52,6 @@ sAnimations.registry.ProductWishlist = sAnimations.Class.extend(ProductConfigura */ start: function () { var def = this._super.apply(this, arguments); - if (this.editableMode) { - return def; - } this._updateWishlistView(); // trigger change on only one input diff --git a/addons/website_slides/static/src/js/slides.js b/addons/website_slides/static/src/js/slides.js index bda80f1e689..1f4c5ff4d49 100644 --- a/addons/website_slides/static/src/js/slides.js +++ b/addons/website_slides/static/src/js/slides.js @@ -6,8 +6,6 @@ var sAnimations = require('website.content.snippets.animation'); sAnimations.registry.websiteSlides = sAnimations.Class.extend({ selector: '#wrapwrap', - read_events: { - }, /** * @override diff --git a/addons/website_slides/static/src/js/slides_category.js b/addons/website_slides/static/src/js/slides_category.js index d1d7efb7747..9ae79b6b980 100644 --- a/addons/website_slides/static/src/js/slides_category.js +++ b/addons/website_slides/static/src/js/slides_category.js @@ -109,7 +109,7 @@ odoo.define('website_slides.add.section', function (require) { sAnimations.registry.websiteSlidesSection = sAnimations.Class.extend({ selector: '.oe_slide_js_add_section', xmlDependencies: ['/website_slides/static/src/xml/website_slides_upload.xml'], - read_events: { + events: { 'click': '_onAddSectionClick', }, diff --git a/addons/website_slides/static/src/js/slides_delete_slide.js b/addons/website_slides/static/src/js/slides_delete_slide.js index e3eef38502d..94273413614 100644 --- a/addons/website_slides/static/src/js/slides_delete_slide.js +++ b/addons/website_slides/static/src/js/slides_delete_slide.js @@ -59,7 +59,7 @@ odoo.define('website_slides.delete.slide', function (require) { sAnimations.registry.websiteSlidesDeleteSlide = sAnimations.Class.extend({ selector: '.oe_slide_js_delete_slide', xmlDependencies: ['/website_slides/static/src/xml/website_slides_upload.xml'], - read_events: { + events: { 'click': '_onDeleteSlideClick', }, diff --git a/addons/website_slides/static/src/js/slides_share.js b/addons/website_slides/static/src/js/slides_share.js index 1dfaa3aee41..3fd2a875bea 100644 --- a/addons/website_slides/static/src/js/slides_share.js +++ b/addons/website_slides/static/src/js/slides_share.js @@ -41,7 +41,7 @@ var ShareMail = Widget.extend({ sAnimations.registry.websiteSlidesShare = sAnimations.Class.extend({ selector: '#wrapwrap', - read_events: { + events: { 'click a.o_slides_social_share': '_onSlidesSocialShare', }, diff --git a/addons/website_slides/static/src/js/slides_upload.js b/addons/website_slides/static/src/js/slides_upload.js index 7b0a2964bf8..0b63cc4fdd5 100644 --- a/addons/website_slides/static/src/js/slides_upload.js +++ b/addons/website_slides/static/src/js/slides_upload.js @@ -563,7 +563,7 @@ var SlideUploadDialog = Dialog.extend({ sAnimations.registry.websiteSlidesUpload = sAnimations.Class.extend({ selector: '.oe_slide_js_upload', xmlDependencies: ['/website_slides/static/src/xml/website_slides_upload.xml'], - read_events: { + events: { 'click': '_onUploadClick', }, @@ -584,9 +584,7 @@ sAnimations.registry.websiteSlidesUpload = sAnimations.Class.extend({ _openDialog: function ($element) { var data = $element.data(); - var dialog = new SlideUploadDialog(this, data) - dialog.appendTo(document.body); - return dialog.open(); + return new SlideUploadDialog(this, data).open(); }, //--------------------------------------------------------------------------