[FIX] Fixes to shop tour

bzr revid: ddm@openerp.com-20131119151059-8xl169vodupwy8xw
This commit is contained in:
ddm
2013-11-19 16:10:59 +01:00
parent 64c70ddf33
commit 47295c4e0e
3 changed files with 33 additions and 25 deletions
+1 -1
View File
@@ -115,7 +115,7 @@ class Website(openerp.addons.web.controllers.main.Home):
return request.website.render('website.snippets')
@website.route('/page/<page:page>', type='http', auth="public", multilang=True)
def page(self, page):
def page(self, page, **opt):
values = {
'path': page,
}
+12 -22
View File
@@ -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();
}
});
@@ -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({