odoo.define('sale.SalePortalSidebar', function (require) { 'use strict'; var publicWidget = require('web.public.widget'); var PortalSidebar = require('portal.PortalSidebar'); publicWidget.registry.SalePortalSidebar = PortalSidebar.extend({ selector: '.o_portal_sale_sidebar', /** * @constructor */ init: function (parent, options) { this._super.apply(this, arguments); this.authorizedTextTag = ['em', 'b', 'i', 'u']; this.spyWatched = $('body[data-target=".navspy"]'); }, /** * @override */ start: function () { var def = this._super.apply(this, arguments); var $spyWatcheElement = this.$el.find('[data-id="portal_sidebar"]'); this._setElementId($spyWatcheElement); // Nav Menu ScrollSpy this._generateMenu(); // After singature, automatically open the popup for payment if ($.bbq.getState('allow_payment') === 'yes' && this.$('#o_sale_portal_paynow').length) { this.$('#o_sale_portal_paynow').trigger('click'); $.bbq.removeState('allow_payment'); } return def; }, //-------------------------------------------------------------------------- // Private //--------------------------------------------------------------------------- /** * create an unique id and added as a attribute of spyWatched element * * @private * @param {string} prefix * @param {Object} $el * */ _setElementId: function (prefix, $el) { var id = _.uniqueId(prefix); this.spyWatched.find($el).attr('id', id); return id; }, /** * generate the new spy menu * * @private * */ _generateMenu: function () { var self = this, lastLI = false, lastUL = null, $bsSidenav = this.$el.find('.bs-sidenav'); $("#quote_content [id^=quote_header_], #quote_content [id^=quote_]", this.spyWatched).attr("id", ""); _.each(this.spyWatched.find("#quote_content h2, #quote_content h3"), function (el) { var id, text; switch (el.tagName.toLowerCase()) { case "h2": id = self._setElementId('quote_header_', el); text = self._extractText($(el)); if (!text) { break; } lastLI = $("