[IMP] Tour: simplify modal handling
bzr revid: ddm@openerp.com-20131126141324-3aynn0r5sqpttc90
This commit is contained in:
parent
03f61a078c
commit
09a54b25de
|
@ -15,11 +15,6 @@
|
|||
keyboard: false,
|
||||
template: this.popover(),
|
||||
});
|
||||
this.tour.addSteps(_.map(this.steps, function (step) {
|
||||
step.title = openerp.qweb.render('website.tour_popover_title', { title: step.title });
|
||||
step.onShow = step.triggers;
|
||||
return step;
|
||||
}));
|
||||
},
|
||||
reset: function () {
|
||||
this.tourStorage.removeItem(this.id+'_current_step');
|
||||
|
@ -28,6 +23,31 @@
|
|||
$('.popover.tour').remove();
|
||||
},
|
||||
start: function () {
|
||||
var self = this;
|
||||
this.tour.addSteps(_.map(this.steps, function (step) {
|
||||
step.title = openerp.qweb.render('website.tour_popover_title', { title: step.title });
|
||||
if (step.modal) {
|
||||
step.onShow = function () {
|
||||
var $doc = $(document);
|
||||
function onStop () {
|
||||
if (step.modal.stopOnClose) {
|
||||
self.stop();
|
||||
}
|
||||
}
|
||||
$doc.on('hide.bs.modal', onStop);
|
||||
$doc.one('shown.bs.modal', function () {
|
||||
$('.modal button.btn-primary').one('click', function () {
|
||||
$doc.off('hide.bs.modal', onStop);
|
||||
self.moveToStep(step.modal.afterSubmit);
|
||||
});
|
||||
self.moveToNextStep();
|
||||
});
|
||||
};
|
||||
} else {
|
||||
step.onShow = step.triggers;
|
||||
}
|
||||
return step;
|
||||
}));
|
||||
if (this.resume() || ((this.currentStepIndex() === 0) && !this.tour.ended())) {
|
||||
this.tour.start();
|
||||
}
|
||||
|
|
|
@ -38,19 +38,9 @@
|
|||
placement: 'left',
|
||||
title: "New Blog Post",
|
||||
content: "Select this entry to create a new blog post.",
|
||||
triggers: function () {
|
||||
var $doc = $(document);
|
||||
function stopNewBlog () {
|
||||
self.stop();
|
||||
}
|
||||
$doc.on('hide.bs.modal', stopNewBlog);
|
||||
$doc.one('shown.bs.modal', function () {
|
||||
$('.modal button.btn-primary').one('click', function () {
|
||||
$doc.off('hide.bs.modal', stopNewBlog);
|
||||
self.moveToStep('post-page');
|
||||
});
|
||||
self.moveToNextStep();
|
||||
});
|
||||
modal: {
|
||||
stopOnClose: true,
|
||||
afterSubmit: 'post-page',
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -167,7 +157,7 @@
|
|||
{
|
||||
stepId: 'publish-post',
|
||||
element: 'button.js_publish_btn',
|
||||
placement: 'right',
|
||||
placement: 'top',
|
||||
reflex: true,
|
||||
title: "Publish Your Post",
|
||||
content: "Your blog post is not yet published. You can update this draft version and publish it once you are ready.",
|
||||
|
|
|
@ -38,19 +38,9 @@
|
|||
placement: 'left',
|
||||
title: "New Event",
|
||||
content: "Click here to create a new event.",
|
||||
triggers: function () {
|
||||
var $doc = $(document);
|
||||
function stopNewEvent () {
|
||||
self.stop();
|
||||
}
|
||||
$doc.on('hide.bs.modal', stopNewEvent);
|
||||
$doc.one('shown.bs.modal', function () {
|
||||
$('.modal button.btn-primary').one('click', function () {
|
||||
$doc.off('hide.bs.modal', stopNewEvent);
|
||||
self.moveToStep('event-page');
|
||||
});
|
||||
self.moveToNextStep();
|
||||
});
|
||||
modal: {
|
||||
stopOnClose: true,
|
||||
afterSubmit: 'event-page',
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -100,7 +90,7 @@
|
|||
{
|
||||
stepId: 'publish-post',
|
||||
element: 'button.js_publish_btn',
|
||||
placement: 'right',
|
||||
placement: 'top',
|
||||
reflex: true,
|
||||
title: "Publish your event",
|
||||
content: "Click to publish your event.",
|
||||
|
|
|
@ -38,19 +38,9 @@
|
|||
placement: 'left',
|
||||
title: "Create a new product",
|
||||
content: "Select 'New Product' to create it and manage its properties to boost your sales.",
|
||||
triggers: function () {
|
||||
var $doc = $(document);
|
||||
function stopProductTour () {
|
||||
self.stop();
|
||||
}
|
||||
$doc.on('hide.bs.modal', stopProductTour);
|
||||
$doc.one('shown.bs.modal', function () {
|
||||
$('.modal button.btn-primary').one('click', function () {
|
||||
$doc.off('hide.bs.modal', stopProductTour);
|
||||
self.moveToStep('product-page');
|
||||
});
|
||||
self.moveToNextStep();
|
||||
});
|
||||
modal: {
|
||||
stopOnClose: true,
|
||||
afterSubmit: 'product-page',
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -147,7 +137,7 @@
|
|||
{
|
||||
stepId: 'publish-product',
|
||||
element: 'button.js_publish_btn',
|
||||
placement: 'right',
|
||||
placement: 'top',
|
||||
reflex: true,
|
||||
title: "Publish your product",
|
||||
content: "Click to publish your product so your customers can see it.",
|
||||
|
@ -158,7 +148,7 @@
|
|||
resume: function () {
|
||||
return (this.isCurrentStep('product-page') || this.isCurrentStep('publish-product')) && this._super();
|
||||
},
|
||||
trigger: function (url) {
|
||||
trigger: function () {
|
||||
return (this.resume() && this.testUrl(/^\/shop\/product\/[0-9]+\//)) || this._super();
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue