[FIX] website tour: flickering; banner auto run; work with different language
bzr revid: chm@openerp.com-20140203112816-c350lxr5pgo9x2li
This commit is contained in:
parent
a9ea8c2275
commit
d23f8425ad
|
@ -59,7 +59,7 @@
|
|||
</record>
|
||||
<record id="action_website_tutorial" model="ir.actions.act_url">
|
||||
<field name="name">Website With Tutorial</field>
|
||||
<field name="url">/?tutorial.banner=true</field>
|
||||
<field name="url">/#tutorial.banner=true</field>
|
||||
<field name="target">self</field>
|
||||
</record>
|
||||
<record id="action_website_homepage" model="ir.actions.act_url">
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
website.BannerTour = website.Tour.extend({
|
||||
id: 'banner',
|
||||
name: "Insert a banner",
|
||||
path: '/page/website.homepage',
|
||||
path: '/',
|
||||
init: function (editor) {
|
||||
var self = this;
|
||||
self.steps = [
|
||||
|
@ -52,9 +52,9 @@
|
|||
placement: 'top',
|
||||
title: "Customize banner's text",
|
||||
content: "Click in the text and start editing it. Click continue once it's done.",
|
||||
template: self.popover({ next: "Continue" }),
|
||||
},
|
||||
{
|
||||
waitNot: '#wrap [data-snippet-id=carousel]:first .carousel-caption:contains("Your Banner Title")',
|
||||
element: '.oe_overlay_options .oe_options',
|
||||
placement: 'left',
|
||||
title: "Customize the banner",
|
||||
|
|
|
@ -7,10 +7,6 @@ website.add_template_file('/website/static/src/xml/website.tour.xml');
|
|||
website.EditorBar.include({
|
||||
tours: [],
|
||||
start: function () {
|
||||
// $('.tour-backdrop').click(function (e) {
|
||||
// e.stopImmediatePropagation();
|
||||
// e.preventDefault();
|
||||
// });
|
||||
var self = this;
|
||||
var menu = $('#help-menu');
|
||||
_.each(this.tours, function (tour) {
|
||||
|
@ -113,11 +109,13 @@ website.Tour = openerp.Class.extend({
|
|||
this.localStorage.setItem("tour-"+this.id+"-test-automatic", true);
|
||||
}
|
||||
|
||||
// redirect to begin of the tour
|
||||
if (this.path) {
|
||||
var path = this.path.split('?');
|
||||
window.location.href = path[0] + "?tutorial."+this.id+"=true" + path.slice(1, path.length).join("?");
|
||||
return;
|
||||
// redirect to begin of the tour in function of the language
|
||||
if (!this.testUrl(this.path+"(#.*)?$")) {
|
||||
var path = this.path.split('#');
|
||||
window.location.href = "/"+this.getLang()+path[0] + "#tutorial."+this.id+"=true&" + path.slice(1, path.length).join("#");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var self = this;
|
||||
|
@ -125,12 +123,12 @@ website.Tour = openerp.Class.extend({
|
|||
website.Tour.waitReady.call(this, function () {self._running();});
|
||||
},
|
||||
running: function () {
|
||||
if (+this.localStorage.getItem("tour-"+this.id+"-test") >= this.steps.length) {
|
||||
if (+this.localStorage.getItem("tour-"+this.id+"-test") >= this.steps.length-1) {
|
||||
this.endTour();
|
||||
return;
|
||||
}
|
||||
|
||||
if (website.Tour.is_busy() || !this.testUrl()) return;
|
||||
if (website.Tour.is_busy() || !this.testPathUrl()) return;
|
||||
|
||||
// launch tour with url
|
||||
this.checkRunningUrl();
|
||||
|
@ -143,7 +141,6 @@ website.Tour = openerp.Class.extend({
|
|||
var self = this;
|
||||
website.Tour.waitReady.call(this, function () {self._running();});
|
||||
},
|
||||
|
||||
_running: function () {
|
||||
var stepId = this.localStorage.getItem("tour-"+this.id+"-test");
|
||||
var automatic = !!this.localStorage.getItem("tour-"+this.id+"-test-automatic");
|
||||
|
@ -174,13 +171,19 @@ website.Tour = openerp.Class.extend({
|
|||
$('.popover.tour').remove();
|
||||
},
|
||||
|
||||
testUrl: function () {
|
||||
return !this.testPath || this.testPath.test(window.location.href);
|
||||
getLang: function () {
|
||||
return $("html").attr("lang").replace(/-/, '_');
|
||||
},
|
||||
testUrl: function (url) {
|
||||
return new RegExp("(/"+this.getLang()+")?"+url, "i").test(window.location.href);
|
||||
},
|
||||
testPathUrl: function () {
|
||||
if (!this.testPath || this.testUrl(this.testPath)) return true;
|
||||
},
|
||||
checkRunningUrl: function () {
|
||||
if (window.location.search.indexOf("tutorial."+this.id+"=true") > -1) {
|
||||
if (window.location.hash.indexOf("tutorial."+this.id+"=true") > -1) {
|
||||
this.localStorage.setItem("tour-"+this.id+"-test", 0);
|
||||
window.location.href = window.location.href.replace(/tutorial.+=true&?/, '');
|
||||
window.location.hash = window.location.hash.replace(/tutorial.+=true&?/, '');
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -315,7 +318,11 @@ website.Tour = openerp.Class.extend({
|
|||
}
|
||||
},
|
||||
endTour: function () {
|
||||
console.log('{ "event": "success" }');
|
||||
if (parseInt(this.localStorage.getItem("tour-"+this.id+"-test"),10) >= this.steps.length-1) {
|
||||
console.log('{ "event": "success" }');
|
||||
} else {
|
||||
console.log('{ "event": "canceled" }');
|
||||
}
|
||||
this.reset();
|
||||
},
|
||||
autoNextStep: function () {
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<record id="action_open_website" model="ir.actions.act_url">
|
||||
<field name="name">Website Blogs</field>
|
||||
<field name="target">self</field>
|
||||
<field name="url" eval="'/blog/'+str(ref('website_blog.blog_blog_1'))+'/?tutorial.blog=true'"/>
|
||||
<field name="url" eval="'/blog/'+str(ref('website_blog.blog_blog_1'))+'/#tutorial.blog=true'"/>
|
||||
</record>
|
||||
<record id="base.open_menu" model="ir.actions.todo">
|
||||
<field name="action_id" ref="action_open_website"/>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
website.BlogTour = website.Tour.extend({
|
||||
id: 'blog',
|
||||
name: "Create a blog post",
|
||||
testPath: /\/(blog|blogpost)\/[0-9]+\//,
|
||||
testPath: '/(blog|blogpost)',
|
||||
init: function (editor) {
|
||||
var self = this;
|
||||
self.steps = [
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
website.EventTour = website.Tour.extend({
|
||||
id: 'event',
|
||||
name: "Create an event",
|
||||
testPath: /\/event\/[0-9]+\/register/,
|
||||
testPath: '/event(/[0-9]+/register)?',
|
||||
init: function (editor) {
|
||||
var self = this;
|
||||
self.steps = [
|
||||
|
|
|
@ -11,7 +11,7 @@ testRunner.run(function eventTest (page, timeout) {
|
|||
});
|
||||
}, function executeTest () {
|
||||
page.evaluate(function () {
|
||||
window.openerp.website.Tour.run_test('event');
|
||||
window.openerp.website.Tour.get('event').run(true);
|
||||
});
|
||||
}, timeout);
|
||||
});
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<record id="action_open_website" model="ir.actions.act_url">
|
||||
<field name="name">Website Shop</field>
|
||||
<field name="target">self</field>
|
||||
<field name="url">/shop?tutorial.shop=true</field>
|
||||
<field name="url">/shop#tutorial.shop=true</field>
|
||||
</record>
|
||||
<record id="base.open_menu" model="ir.actions.todo">
|
||||
<field name="action_id" ref="action_open_website"/>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
website.EditorShopTour = website.Tour.extend({
|
||||
id: 'shop',
|
||||
name: "Create a product",
|
||||
testPath: /\/shop\/.*/,
|
||||
testPath: '/shop',
|
||||
init: function (editor) {
|
||||
var self = this;
|
||||
self.steps = [
|
||||
|
@ -145,7 +145,7 @@
|
|||
id: 'shop_buy_product',
|
||||
name: "Try to buy products",
|
||||
path: '/shop',
|
||||
testPath: /\/shop/,
|
||||
testPath: '/shop',
|
||||
init: function (editor) {
|
||||
var self = this;
|
||||
self.steps = [
|
||||
|
@ -217,10 +217,10 @@
|
|||
},
|
||||
{
|
||||
title: "select acquirer",
|
||||
element: 'input[name="acquirer"]',
|
||||
element: 'input[name="acquirer"]:first',
|
||||
},
|
||||
{
|
||||
title: "confirm",
|
||||
title: "Pay Now",
|
||||
element: 'button:contains("Pay Now")',
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue