[IMP] Improve tour registration

bzr revid: ddm@openerp.com-20131119094353-kg04ijualwtsz1lo
This commit is contained in:
ddm
2013-11-19 10:43:53 +01:00
parent 6185c3270e
commit 4ba5cad0e3
5 changed files with 57 additions and 48 deletions
@@ -8,6 +8,7 @@
website.EditorBannerTour = website.EditorTour.extend({
id: 'add_banner_tour',
name: "Insert a banner",
urlTrigger: '?banner-tutorial=true',
init: function (editor) {
var self = this;
var $body = $(document.body);
@@ -132,28 +133,23 @@
var showTutorialsIndex = this.indexOfStep('show-tutorials');
return (currentStepIndex === secondPartIndex || currentStepIndex === showTutorialsIndex) && !this.tour.ended();
},
continueTour: function () {
return this.startOfPart2();
},
canResume: function () {
return this.startOfPart2() || this._super();
},
redirect: function (url) {
url = url || new website.UrlParser(window.location.href);
if (url.pathname !== '/' && url.pathname !== '/page/website.homepage') {
window.location.replace('/page/website.homepage?banner-tutorial=true');
}
},
});
website.EditorBar.include({
start: function () {
var menu = $('#help-menu');
var bannerTour = new website.EditorBannerTour(this);
var $menuItem = $($.parseHTML('<li><a href="#">'+bannerTour.name+'</a></li>'));
$menuItem.click(function () {
if (url.pathname !== '/' && url.pathname !== '/page/website.homepage') {
window.location.replace('/page/website.homepage?banner-tutorial=true');
}
bannerTour.reset();
bannerTour.start();
});
menu.append($menuItem);
var url = new website.UrlParser(window.location.href);
if (url.search.indexOf('?banner-tutorial=true') === 0 || bannerTour.startOfPart2()) {
bannerTour.start();
}
this.registerTour(new website.EditorBannerTour(this));
return this._super();
},
});
@@ -49,14 +49,7 @@
website.EditorBar.include({
start: function () {
var menu = $('#help-menu');
var installAppTour = new website.InstallAppTour(this);
var $menuItem = $($.parseHTML('<li><a href="#">'+installAppTour.name+'</a></li>'));
$menuItem.click(function () {
installAppTour.reset();
installAppTour.start();
});
menu.append($menuItem);
this.registerTour(new website.InstallAppTour(this));
return this._super();
},
});
@@ -82,6 +82,13 @@
stop: function () {
this.tour.end();
},
continueTour: function () {
// Override if necessary
return true;
},
redirect: function () {
// Override if necessary
},
});
website.UrlParser = openerp.Class.extend({
@@ -100,13 +107,31 @@
});
website.EditorBar.include({
tours: [],
start: function () {
$('.tour-backdrop').click(function (e) {
e.stopImmediatePropagation();
e.preventDefault();
});
var url = new website.UrlParser(window.location.href);
var menu = $('#help-menu');
_.each(this.tours, function (tour) {
var $menuItem = $($.parseHTML('<li><a href="#">'+tour.name+'</a></li>'));
$menuItem.click(function () {
tour.redirect(url);
tour.reset();
tour.start();
});
menu.append($menuItem);
if (tour.urlTrigger && (url.search.indexOf(tour.urlTrigger) === 0 || tour.continueTour())) {
tour.start();
}
});
return this._super();
},
registerTour: function (tour) {
this.tours.push(tour);
},
});
}());
@@ -100,14 +100,7 @@
website.EditorBar.include({
start: function () {
var menu = $('#help-menu');
var builderTour = new website.EditorBuilderTour(this);
var $menuItem = $($.parseHTML('<li><a href="#">'+builderTour.name+'</a></li>'));
$menuItem.click(function () {
builderTour.reset();
builderTour.start();
});
menu.append($menuItem);
this.registerTour(new website.EditorBuilderTour(this));
return this._super();
},
});
@@ -8,6 +8,7 @@
website.EditorShopTour = website.EditorTour.extend({
id: 'shop_tour',
name: "Create a product",
urlTrigger: '?shop-tutorial=true',
init: function (editor) {
var self = this;
var $body = $(document.body);
@@ -16,32 +17,33 @@
stepId: 'welcome-shop',
orphan: true,
backdrop: true,
title: "e-commerce",
content: "Welcome to the e-commerce. This tutorial will help you to create a product.",
title: "Welcome to your shop",
content: "You successfully installed the e-commerce. This guide will help you to create your product and promote your sales.",
template: render('website.tour_popover', { next: "Start Tutorial", end: "Skip It" }),
},
{
stepId: 'content-menu',
element: '#content-menu-button',
placement: 'left',
reflex: true,
title: "Create your first product",
content: "Click here to add a new product.",
template: render('website.tour_popover'),
},
];
return this._super();
},
redirect: function (url) {
url = url || new website.UrlParser(window.location.href);
if (url.pathname !== '/shop') {
window.location.replace('/shop?shop-tutorial=true');
}
},
});
website.EditorBar.include({
start: function () {
var menu = $('#help-menu');
var shopTour = new website.EditorShopTour(this);
var $menuItem = $($.parseHTML('<li><a href="#">'+shopTour.name+'</a></li>'));
var url = new website.UrlParser(window.location.href);
$menuItem.click(function () {
shopTour.reset();
shopTour.start();
if (url.pathname !== '/shop') {
window.location.replace('/shop?shop-tutorial=true');
}
});
if (url.search.indexOf('?shop-tutorial=true') === 0) {
shopTour.start();
}
menu.append($menuItem);
this.registerTour(new website.EditorShopTour(this));
return this._super();
},
});