From 47295c4e0e02f4186a9f979ebc3f9d7c3b2a2291 Mon Sep 17 00:00:00 2001 From: ddm Date: Tue, 19 Nov 2013 16:10:59 +0100 Subject: [PATCH] [FIX] Fixes to shop tour bzr revid: ddm@openerp.com-20131119151059-8xl169vodupwy8xw --- addons/website/controllers/main.py | 2 +- addons/website/static/src/js/website.tour.js | 34 +++++++------------ .../static/src/js/website.tour.shop.js | 22 ++++++++++-- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index 64fe1009f2a..ba3a1154e54 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -115,7 +115,7 @@ class Website(openerp.addons.web.controllers.main.Home): return request.website.render('website.snippets') @website.route('/page/', type='http', auth="public", multilang=True) - def page(self, page): + def page(self, page, **opt): values = { 'path': page, } diff --git a/addons/website/static/src/js/website.tour.js b/addons/website/static/src/js/website.tour.js index b7cd46dff59..d70405e3601 100644 --- a/addons/website/static/src/js/website.tour.js +++ b/addons/website/static/src/js/website.tour.js @@ -24,22 +24,6 @@ step.title = website.tour.render('website.tour_popover_title', { title: step.title }); return step; })); - // TODO: Disabled until properly implemented - // this.monkeyPatchTour(); - }, - monkeyPatchTour: function () { - var self = this; - // showStep should wait for 'element' to appear instead of moving to the next step - self.tour.showStep = function (i) { - var step = self.tour.getStep(i); - return (function proceed () { - if (step.orphan || $(step.element).length > 0) { - return Tour.prototype.showStep.call(self.tour, i); - } else { - setTimeout(proceed, 50); - } - }()); - }; }, reset: function () { this.tourStorage.removeItem(this.id+'_current_step'); @@ -82,10 +66,6 @@ stop: function () { this.tour.end(); }, - continueTour: function () { - // Override if necessary - return this.currentStepIndex() === 0; - }, redirect: function (url) { url = url || new website.UrlParser(window.location.href); if (this.startPath && url.pathname !== this.startPath) { @@ -93,6 +73,16 @@ window.location.replace(newUrl); } }, + continueTour: function () { + // Override if necessary + return this.currentStepIndex() === 0; + }, + isTriggerUrl: function (url) { + // Override if necessary + url = url || new website.UrlParser(window.location.href); + var urlTrigger = this.id + "=true"; + return url.search.indexOf(urlTrigger) >= 0; + }, }); website.UrlParser = openerp.Class.extend({ @@ -107,6 +97,7 @@ this.pathname = a.pathname; this.origin = a.origin; this.search = a.search; + this.hash = a.hash; }, }); @@ -127,8 +118,7 @@ tour.start(); }); menu.append($menuItem); - var urlTrigger = tour.id + "=true"; - if (url.search.indexOf(urlTrigger) >= 0) { + if (tour.isTriggerUrl()) { tour.start(); } }); diff --git a/addons/website_sale/static/src/js/website.tour.shop.js b/addons/website_sale/static/src/js/website.tour.shop.js index 637c9ef5fc5..acbc4efc642 100644 --- a/addons/website_sale/static/src/js/website.tour.shop.js +++ b/addons/website_sale/static/src/js/website.tour.shop.js @@ -38,11 +38,23 @@ content: "Select 'New Product' to create it and manage its properties to boost your sales.", template: render('website.tour_popover'), onShow: function () { - editor.on('tour:menu_editor_dialog_ready', editor, function () { - self.movetoStep('add-menu-entry'); + $(document).one('shown.bs.modal', function () { + $('.modal button.btn-primary').click(function () { + self.movetoStep('product-page'); + }); + self.movetoStep('enter-name'); }); }, }, + { + stepId: 'enter-name', + element: '.modal input[type=text]', + placement: 'right', + title: "Choose name", + content: "Enter a name for your new product.", + template: render('website.tour_popover'), + + }, { stepId: 'product-page', orphan: true, @@ -63,6 +75,7 @@ stepId: 'add-block', element: 'button[data-action=snippet]', placement: 'bottom', + reflex: true, title: "Describe the product for your audience", content: "Insert blocks like text-image, or gallery to fully describe the product and make your visitors want to buy this product.", template: render('website.tour_popover'), @@ -78,6 +91,11 @@ continueTour: function () { return this.productPage(); }, + isTriggerUrl: function (url) { + url = url || new website.UrlParser(window.location.href); + var addProductPattern = /^\/shop\/product\/[0-9]+\/\?enable_editor=1/; + return addProductPattern.test(url.pathname+url.search) || this._super(); + }, }); website.EditorBar.include({