From ba8364c71708b599ee80e8307581a19578d7fade Mon Sep 17 00:00:00 2001 From: ddm Date: Wed, 20 Nov 2013 15:26:31 +0100 Subject: [PATCH 1/9] [IMP] Better file naming bzr revid: ddm@openerp.com-20131120142631-e4fsdx2vw7q3u3pp --- .../{website.tour.install-app.js => website.tour.app.js} | 8 ++++---- addons/website/static/src/js/website.tour.banner.js | 4 ++-- .../{website.tour.menu-editor.js => website.tour.page.js} | 8 ++++---- addons/website/views/website_templates.xml | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) rename addons/website/static/src/js/{website.tour.install-app.js => website.tour.app.js} (91%) rename addons/website/static/src/js/{website.tour.menu-editor.js => website.tour.page.js} (95%) diff --git a/addons/website/static/src/js/website.tour.install-app.js b/addons/website/static/src/js/website.tour.app.js similarity index 91% rename from addons/website/static/src/js/website.tour.install-app.js rename to addons/website/static/src/js/website.tour.app.js index d7d98fb5430..52c4c892aad 100644 --- a/addons/website/static/src/js/website.tour.install-app.js +++ b/addons/website/static/src/js/website.tour.app.js @@ -7,14 +7,14 @@ website.EditorBar.include({ start: function () { - this.registerTour(new website.InstallAppTour(this)); + this.registerTour(new website.AppTour(this)); return this._super(); }, }); - website.InstallAppTour = website.Tour.extend({ - id: 'install-app', - name: "Install a new App", + website.AppTour = website.Tour.extend({ + id: 'app-tutorial', + name: "Install a new application", init: function (editor) { var self = this; self.steps = [ diff --git a/addons/website/static/src/js/website.tour.banner.js b/addons/website/static/src/js/website.tour.banner.js index bb4b576ba24..e01fbd6e662 100644 --- a/addons/website/static/src/js/website.tour.banner.js +++ b/addons/website/static/src/js/website.tour.banner.js @@ -7,12 +7,12 @@ website.EditorBar.include({ start: function () { - this.registerTour(new website.AddBannerTour(this)); + this.registerTour(new website.BannerTour(this)); return this._super(); }, }); - website.AddBannerTour = website.Tour.extend({ + website.BannerTour = website.Tour.extend({ id: 'banner-tutorial', name: "Insert a banner", startPath: '/page/website.homepage', diff --git a/addons/website/static/src/js/website.tour.menu-editor.js b/addons/website/static/src/js/website.tour.page.js similarity index 95% rename from addons/website/static/src/js/website.tour.menu-editor.js rename to addons/website/static/src/js/website.tour.page.js index b37d3c3813e..d461d7cd22f 100644 --- a/addons/website/static/src/js/website.tour.menu-editor.js +++ b/addons/website/static/src/js/website.tour.page.js @@ -7,13 +7,13 @@ website.EditorBar.include({ start: function () { - this.registerTour(new website.EditorBuilderTour(this)); + this.registerTour(new website.PageTour(this)); return this._super(); }, }); - website.EditorBuilderTour = website.Tour.extend({ - id: 'menu-editor', + website.PageTour = website.Tour.extend({ + id: 'page-tutorial', name: "Add a new page", init: function (editor) { var self = this; @@ -71,7 +71,7 @@ }, { stepId: 'enter-page-name', - element: '#link-new', + element: '.modal .select2-container', placement: 'left', title: "Link your menu to a 'gallery' page", content: "This page does not exist. Create it by filling the name here. For instance, 'gallery'.", diff --git a/addons/website/views/website_templates.xml b/addons/website/views/website_templates.xml index dfd9b47756a..efb9176db12 100644 --- a/addons/website/views/website_templates.xml +++ b/addons/website/views/website_templates.xml @@ -102,8 +102,8 @@ - - + + From eb23569c9ee3d43b1ae17768d7553d88407be974 Mon Sep 17 00:00:00 2001 From: ddm Date: Wed, 20 Nov 2013 16:40:42 +0100 Subject: [PATCH 2/9] [IMP] Blog tour add first section bzr revid: ddm@openerp.com-20131120154042-8byh7l4eifchcfe8 --- .../static/src/js/website.tour.blog.js | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/addons/website_blog/static/src/js/website.tour.blog.js b/addons/website_blog/static/src/js/website.tour.blog.js index 02c69530ce5..0cf1996ec58 100644 --- a/addons/website_blog/static/src/js/website.tour.blog.js +++ b/addons/website_blog/static/src/js/website.tour.blog.js @@ -68,14 +68,48 @@ content: "You just created a new blog post. We are now going to edit it.", template: render('website.tour_popover', { next: "OK" }), }, + { + stepId: 'post-title', + element: 'h1[data-oe-expression="blog_post.name"]', + placement: 'top', + title: "Pick a title", + content: "Choose a catchy title for your blog post.", + template: render('website.tour_popover', { next: "OK" }), + }, { stepId: 'add-block', element: 'button[data-action=snippet]', placement: 'bottom', - reflex: true, title: "Layout your blog post", content: "Insert blocks like text-image to layout the body of your blog post.", template: render('website.tour_popover'), + onShow: function () { + $('button[data-action=snippet]').click(function () { + self.movetoStep('drag-image-text'); + }); + } + }, + { + stepId: 'drag-image-text', + element: '#website-top-navbar [data-snippet-id=image-text].ui-draggable', + placement: 'bottom', + title: "Drag & Drop a block", + content: "Drag the 'Image Text' block and drop it in your page.", + template: render('website.tour_popover'), + onShow: function () { + var $body = $(document.body); + function beginDrag () { + $('.popover.tour').remove(); + function goToNextStep () { + $('#oe_snippets').hide(); + self.stop(); + $body.off('mouseup', goToNextStep); + } + $body.off('mousedown', beginDrag); + $body.on('mouseup', goToNextStep); + } + $body.on('mousedown', beginDrag); + }, }, ]; return this._super(); From 2f0f411b438821ce14445a6b1ccef625931119a0 Mon Sep 17 00:00:00 2001 From: ddm Date: Wed, 20 Nov 2013 16:54:44 +0100 Subject: [PATCH 3/9] [FIX] Tour bug with snippet editor bzr revid: ddm@openerp.com-20131120155444-yn5fovlq0q3dkpau --- addons/website/static/src/js/website.tour.banner.js | 2 +- addons/website_blog/static/src/js/website.tour.blog.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/website/static/src/js/website.tour.banner.js b/addons/website/static/src/js/website.tour.banner.js index e01fbd6e662..6bf3c955852 100644 --- a/addons/website/static/src/js/website.tour.banner.js +++ b/addons/website/static/src/js/website.tour.banner.js @@ -65,7 +65,7 @@ function beginDrag () { $('.popover.tour').remove(); function goToNextStep () { - $('#oe_snippets').hide(); + $('#snippets').toggle(); self.movetoStep('edit-title'); $body.off('mouseup', goToNextStep); } diff --git a/addons/website_blog/static/src/js/website.tour.blog.js b/addons/website_blog/static/src/js/website.tour.blog.js index 0cf1996ec58..89e1eabc568 100644 --- a/addons/website_blog/static/src/js/website.tour.blog.js +++ b/addons/website_blog/static/src/js/website.tour.blog.js @@ -101,7 +101,7 @@ function beginDrag () { $('.popover.tour').remove(); function goToNextStep () { - $('#oe_snippets').hide(); + $('#snippets').toggle(); self.stop(); $body.off('mouseup', goToNextStep); } From 7d43b226ab8288e5f916e3b4074f38ed16a8be7c Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 20 Nov 2013 21:28:42 +0100 Subject: [PATCH 4/9] [IMP] Use LazyResponse for website.render() bzr revid: fme@openerp.com-20131120202842-zethge8jykzlzjjy --- addons/website/controllers/main.py | 14 ++++++-------- addons/website/models/website.py | 14 ++++++++++---- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index ba3a1154e54..03f83f412ca 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -261,8 +261,9 @@ class Website(openerp.addons.web.controllers.main.Home): @website.route(['/robots.txt'], type='http', auth="public") def robots(self): - body = request.website.render('website.robots', {'url_root': request.httprequest.url_root}) - return request.make_response(body, headers=[('Content-Type', 'text/plain')]) + response = request.website.render('website.robots', {'url_root': request.httprequest.url_root}) + response.mimetype = 'text/plain' + return response @website.route('/sitemap', type='http', auth='public', multilang=True) def sitemap(self): @@ -270,14 +271,11 @@ class Website(openerp.addons.web.controllers.main.Home): @website.route('/sitemap.xml', type='http', auth="public") def sitemap_xml(self): - body = request.website.render('website.sitemap_xml', { + response = request.website.render('website.sitemap_xml', { 'pages': request.website.enumerate_pages() }) - - return request.make_response(body, [ - ('Content-Type', 'application/xml;charset=utf-8') - ]) - + response.headers['Content-Type'] = 'application/xml;charset=utf-8' + return response class Images(http.Controller): def placeholder(self, response): diff --git a/addons/website/models/website.py b/addons/website/models/website.py index 60e680aaefc..478b6a97ec9 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -20,8 +20,7 @@ from openerp.osv import orm, osv, fields from openerp.tools.safe_eval import safe_eval from openerp.addons.web import http -from openerp.addons.web.http import request - +from openerp.addons.web.http import request, LazyResponse logger = logging.getLogger(__name__) @@ -157,7 +156,7 @@ class website(osv.osv): 'translatable': not is_public_user and not is_master_lang and request.multilang, }) - def render(self, cr, uid, ids, template, values=None, context=None): + def _render(self, cr, uid, ids, template, values=None, context=None): view = self.pool.get("ir.ui.view") IMD = self.pool.get("ir.model.data") user = self.pool.get("res.users") @@ -221,6 +220,13 @@ class website(osv.osv): return self.error(cr, uid, 500 if qweb_context['editable'] else 404, qweb_context, context=context) + def render(self, cr, uid, ids, template, values=None, context=None): + def callback(template, values, context): + return self._render(cr, uid, ids, template, values, context) + if values is None: + values = {} + return LazyResponse(callback, template=template, values=values, context=context) + def error(self, cr, uid, code, qweb_context, context=None): View = request.registry['ir.ui.view'] return werkzeug.wrappers.Response( @@ -478,7 +484,7 @@ class website(osv.osv): object_ids = model_obj.search(cr, uid, domain, limit=step, offset=offset, order=orderby) object_ids = model_obj.browse(cr, uid, object_ids) for object_id in object_ids: - html += request.website.render(template, {'object_id': object_id}) + html += request.website._render(template, {'object_id': object_id}) return html def get_menu(self, cr, uid, ids, context=None): From 298568136660938b9465ae93880a34d2b0eb3d8f Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 21 Nov 2013 10:59:59 +0100 Subject: [PATCH 5/9] [FIX] fixup snippets json controller for lazyresponse changes bzr revid: xmo@openerp.com-20131121095959-lwi6mnge684pxi1q --- addons/website/controllers/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index 03f83f412ca..6b11c065552 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -112,7 +112,7 @@ class Website(openerp.addons.web.controllers.main.Home): @website.route(['/website/snippets'], type='json', auth="public") def snippets(self): - return request.website.render('website.snippets') + return request.website._render('website.snippets') @website.route('/page/', type='http', auth="public", multilang=True) def page(self, page, **opt): From ec4372ac23b2c1e9cb3c578bc575dfe2efbf3f81 Mon Sep 17 00:00:00 2001 From: ddm Date: Thu, 21 Nov 2013 12:11:02 +0100 Subject: [PATCH 6/9] [IMP] Tour: better defaults bzr revid: ddm@openerp.com-20131121111102-l66jzdysdkqm7fje --- addons/website/static/src/js/website.tour.app.js | 6 +----- .../website/static/src/js/website.tour.banner.js | 16 +++++----------- addons/website/static/src/js/website.tour.js | 12 +++++------- .../website/static/src/js/website.tour.page.js | 13 +++---------- .../static/src/js/website.tour.blog.js | 13 +++---------- .../static/src/js/website.tour.event.js | 10 ++-------- .../static/src/js/website.tour.shop.js | 12 +++--------- 7 files changed, 22 insertions(+), 60 deletions(-) diff --git a/addons/website/static/src/js/website.tour.app.js b/addons/website/static/src/js/website.tour.app.js index 52c4c892aad..b4fab2db620 100644 --- a/addons/website/static/src/js/website.tour.app.js +++ b/addons/website/static/src/js/website.tour.app.js @@ -3,8 +3,6 @@ var website = openerp.website; - var render = website.tour.render; - website.EditorBar.include({ start: function () { this.registerTour(new website.AppTour(this)); @@ -24,7 +22,7 @@ backdrop: true, title: "Install an App", content: "You can intall some apps to manage your website content.", - template: render('website.tour_popover', { next: "Start Tutorial", end: "Skip It" }), + template: self.popover({ next: "Start Tutorial", end: "Skip It" }), }, { stepId: 'customize', @@ -32,7 +30,6 @@ placement: 'left', title: "Install an app", content: "Add new apps by customizing your website.", - template: render('website.tour_popover'), onShow: function () { editor.on('rte:customize_menu_ready', editor, function () { self.movetoStep('install-app'); @@ -46,7 +43,6 @@ orphan: true, title: "Install an app", content: "Click 'Install Apps' to select and install the application you would like to manage from your website.", - template: render('website.tour_popover'), }, ]; return this._super(); diff --git a/addons/website/static/src/js/website.tour.banner.js b/addons/website/static/src/js/website.tour.banner.js index 6bf3c955852..881e0cc08f0 100644 --- a/addons/website/static/src/js/website.tour.banner.js +++ b/addons/website/static/src/js/website.tour.banner.js @@ -3,8 +3,6 @@ var website = openerp.website; - var render = website.tour.render; - website.EditorBar.include({ start: function () { this.registerTour(new website.BannerTour(this)); @@ -25,7 +23,7 @@ backdrop: true, title: "Welcome to your website!", content: "This tutorial will guide you to build your home page. We will start by adding a banner.", - template: render('website.tour_popover', { next: "Start Tutorial", end: "Skip It" }), + template: self.popover({ next: "Start Tutorial", end: "Skip It" }), }, { stepId: 'edit-page', @@ -33,7 +31,6 @@ placement: 'bottom', title: "Edit this page", content: "Every page of your website can be modified through the Edit button.", - template: render('website.tour_popover'), onShow: function () { editor.on('tour:editor_bar_loaded', editor, function () { self.movetoStep('add-block'); @@ -46,7 +43,6 @@ placement: 'bottom', title: "Insert building blocks", content: "To add content in a page, you can insert building blocks.", - template: render('website.tour_popover'), onShow: function () { $('button[data-action=snippet]').click(function () { self.movetoStep('drag-banner'); @@ -59,7 +55,6 @@ placement: 'bottom', title: "Drag & Drop a Banner", content: "Drag the Banner block and drop it in your page.", - template: render('website.tour_popover'), onShow: function () { var $body = $(document.body); function beginDrag () { @@ -81,7 +76,7 @@ placement: 'top', title: "Customize banner's text", content: "Click in the text and start editing it. Click continue once it's done.", - template: render('website.tour_popover', { next: "Continue" }), + template: self.popover({ next: "Continue" }), onHide: function () { var $banner = $("#wrap [data-snippet-id=carousel]:first"); if ($banner.length) { @@ -95,7 +90,7 @@ placement: 'left', title: "Customize the banner", content: "You can customize characteristic of any blocks through the Customize menu. For instance, change the background of the banner.", - template: render('website.tour_popover', { next: "Continue" }), + template: self.popover({ next: "Continue" }), onShow: function () { $('.dropdown-menu [name=carousel-background]').click(function () { self.movetoStep('save-changes'); @@ -109,7 +104,6 @@ reflex: true, title: "Save your modifications", content: "Once you click on save, your website page is updated.", - template: render('website.tour_popover'), onHide: function () { self.saveStep('part-2'); }, @@ -119,7 +113,7 @@ orphan: true, title: "Congratulation!", content: "Your homepage have been updated. Now, we suggest you insert another snippet to overview possible customization.", - template: render('website.tour_popover', { next: "Continue" }), + template: self.popover({ next: "Continue" }), }, { stepId: 'show-tutorials', @@ -128,7 +122,7 @@ reflex: true, title: "Help is always available", content: "You can always click here if you want more helps or continue to build and get more tips about your website contents like page menu, ...", - template: render('website.tour_popover', { end: "Close" }), + template: self.popover({ end: "Close" }), } ]; return this._super(); diff --git a/addons/website/static/src/js/website.tour.js b/addons/website/static/src/js/website.tour.js index 25317f06aac..9e41f9d0745 100644 --- a/addons/website/static/src/js/website.tour.js +++ b/addons/website/static/src/js/website.tour.js @@ -4,12 +4,6 @@ var website = openerp.website; website.add_template_file('/website/static/src/xml/website.tour.xml'); - website.tour = { - render: function render (template, dict) { - return openerp.qweb.render(template, dict); - } - }; - website.Tour = openerp.Class.extend({ tour: undefined, steps: [], @@ -19,9 +13,10 @@ name: this.id, storage: this.tourStorage, keyboard: false, + template: this.popover(), }); this.tour.addSteps(_.map(this.steps, function (step) { - step.title = website.tour.render('website.tour_popover_title', { title: step.title }); + step.title = openerp.qweb.render('website.tour_popover_title', { title: step.title }); return step; })); }, @@ -87,6 +82,9 @@ var url = new website.UrlParser(window.location.href); return pattern.test(url.pathname+url.search); }, + popover: function (options) { + return openerp.qweb.render('website.tour_popover', options); + }, }); website.UrlParser = openerp.Class.extend({ diff --git a/addons/website/static/src/js/website.tour.page.js b/addons/website/static/src/js/website.tour.page.js index d461d7cd22f..adaee912110 100644 --- a/addons/website/static/src/js/website.tour.page.js +++ b/addons/website/static/src/js/website.tour.page.js @@ -3,8 +3,6 @@ var website = openerp.website; - var render = website.tour.render; - website.EditorBar.include({ start: function () { this.registerTour(new website.PageTour(this)); @@ -24,7 +22,7 @@ backdrop: true, title: "Menu editor", content: "We will show how to edit your website's menu.", - template: render('website.tour_popover', { next: "Start Tutorial", end: "Skip It" }), + template: self.popover({ next: "Start Tutorial", end: "Skip It" }), }, { stepId: 'content-menu', @@ -33,7 +31,6 @@ reflex: true, title: "Edit the content", content: "Click here to edit the menu.", - template: render('website.tour_popover'), }, { stepId: 'edit-entry', @@ -41,7 +38,6 @@ placement: 'left', title: "Edit menu", content: "Click here to create a new menu entry and manage options.", - template: render('website.tour_popover'), onShow: function () { editor.on('tour:menu_editor_dialog_ready', editor, function () { self.movetoStep('add-menu-entry'); @@ -54,7 +50,6 @@ placement: 'left', title: "Add menu entry", content: "Click here to create a new menu entry.", - template: render('website.tour_popover'), onShow: function () { editor.on('tour:new_menu_entry_dialog_ready', editor, function () { self.movetoStep('enter-entry-name'); @@ -67,7 +62,7 @@ placement: 'left', title: "Choose a label", content: "This label will appear in the top menu and will be visible by all your audience.\nGive a meaningful name to help your visitors. For instance, 'Photos Gallery'.", - template: render('website.tour_popover', { next: "Continue" }), + template: self.popover({ next: "Continue" }), }, { stepId: 'enter-page-name', @@ -75,7 +70,7 @@ placement: 'left', title: "Link your menu to a 'gallery' page", content: "This page does not exist. Create it by filling the name here. For instance, 'gallery'.", - template: render('website.tour_popover', { next: "Continue" }), + template: self.popover({ next: "Continue" }), }, { stepId: 'save-page', @@ -83,7 +78,6 @@ placement: 'right', title: "Save the page", content: "Save your new page.", - template: render('website.tour_popover'), onShow: function () { editor.on('tour:new_menu_entry_dialog_closed', editor, function () { self.movetoStep('save-menu'); @@ -97,7 +91,6 @@ reflex: true, title: "Save the menu", content: "Save the menu to edit the Gallery content directly from the interface.", - template: render('website.tour_popover'), }, ]; return this._super(); diff --git a/addons/website_blog/static/src/js/website.tour.blog.js b/addons/website_blog/static/src/js/website.tour.blog.js index 89e1eabc568..19a56aa351f 100644 --- a/addons/website_blog/static/src/js/website.tour.blog.js +++ b/addons/website_blog/static/src/js/website.tour.blog.js @@ -3,8 +3,6 @@ var website = openerp.website; - var render = website.tour.render; - website.EditorBar.include({ start: function () { this.registerTour(new website.BlogTour(this)); @@ -25,7 +23,7 @@ backdrop: true, title: "Blog", content: "We will show how to create a new blog post.", - template: render('website.tour_popover', { next: "Start Tutorial", end: "Skip It" }), + template: self.popover({ next: "Start Tutorial", end: "Skip It" }), }, { stepId: 'content-menu', @@ -34,7 +32,6 @@ reflex: true, title: "Edit the content", content: "Click here to add content to your site.", - template: render('website.tour_popover'), }, { stepId: 'new-post-entry', @@ -42,7 +39,6 @@ placement: 'left', title: "New blog post", content: "Click here to create a blog post.", - template: render('website.tour_popover'), onShow: function () { $(document).one('shown.bs.modal', function () { $('.modal button.btn-primary').click(function () { @@ -58,7 +54,6 @@ placement: 'right', title: "Choose the post category", content: "Select the 'News' category and click 'Continue'.", - template: render('website.tour_popover'), }, { stepId: 'post-page', @@ -66,7 +61,7 @@ backdrop: true, title: "New blog post created", content: "You just created a new blog post. We are now going to edit it.", - template: render('website.tour_popover', { next: "OK" }), + template: self.popover({ next: "OK" }), }, { stepId: 'post-title', @@ -74,7 +69,7 @@ placement: 'top', title: "Pick a title", content: "Choose a catchy title for your blog post.", - template: render('website.tour_popover', { next: "OK" }), + template: self.popover({ next: "OK" }), }, { stepId: 'add-block', @@ -82,7 +77,6 @@ placement: 'bottom', title: "Layout your blog post", content: "Insert blocks like text-image to layout the body of your blog post.", - template: render('website.tour_popover'), onShow: function () { $('button[data-action=snippet]').click(function () { self.movetoStep('drag-image-text'); @@ -95,7 +89,6 @@ placement: 'bottom', title: "Drag & Drop a block", content: "Drag the 'Image Text' block and drop it in your page.", - template: render('website.tour_popover'), onShow: function () { var $body = $(document.body); function beginDrag () { diff --git a/addons/website_event/static/src/js/website.tour.event.js b/addons/website_event/static/src/js/website.tour.event.js index 8bbd470d1e6..2f81eb43733 100644 --- a/addons/website_event/static/src/js/website.tour.event.js +++ b/addons/website_event/static/src/js/website.tour.event.js @@ -3,8 +3,6 @@ var website = openerp.website; - var render = website.tour.render; - website.EditorBar.include({ start: function () { this.registerTour(new website.EventTour(this)); @@ -25,7 +23,7 @@ backdrop: true, title: "Event", content: "We will show how to create a new event.", - template: render('website.tour_popover', { next: "Start Tutorial", end: "Skip It" }), + template: self.popover({ next: "Start Tutorial", end: "Skip It" }), }, { stepId: 'content-menu', @@ -34,7 +32,6 @@ reflex: true, title: "Edit the content", content: "Click here to add content to your site.", - template: render('website.tour_popover'), }, { stepId: 'new-post-entry', @@ -42,7 +39,6 @@ placement: 'left', title: "New event", content: "Click here to create an event.", - template: render('website.tour_popover'), onShow: function () { $(document).one('shown.bs.modal', function () { $('.modal button.btn-primary').click(function () { @@ -58,7 +54,6 @@ placement: 'right', title: "Choose the event name", content: "Choose a name for the new event and click 'Continue'.", - template: render('website.tour_popover'), }, { stepId: 'event-page', @@ -66,7 +61,7 @@ backdrop: true, title: "New event created", content: "You just created a new event. We are now going to edit it.", - template: render('website.tour_popover', { next: "OK" }), + template: self.popover({ next: "OK" }), }, { stepId: 'add-block', @@ -75,7 +70,6 @@ reflex: true, title: "Layout your event", content: "Insert blocks like text-image to layout the body of your event.", - template: render('website.tour_popover'), }, ]; return this._super(); 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 6b67836ac84..841e8a87a5c 100644 --- a/addons/website_sale/static/src/js/website.tour.shop.js +++ b/addons/website_sale/static/src/js/website.tour.shop.js @@ -3,8 +3,6 @@ var website = openerp.website; - var render = website.tour.render; - website.EditorBar.include({ start: function () { this.registerTour(new website.EditorShopTour(this)); @@ -25,7 +23,7 @@ backdrop: true, 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" }), + template: self.popover({ next: "Start Tutorial", end: "Skip It" }), }, { stepId: 'content-menu', @@ -34,7 +32,6 @@ reflex: true, title: "Create your first product", content: "Click here to add a new product.", - template: render('website.tour_popover'), }, { stepId: 'edit-entry', @@ -42,7 +39,6 @@ placement: 'left', title: "Create a new product", content: "Select 'New Product' to create it and manage its properties to boost your sales.", - template: render('website.tour_popover'), onShow: function () { $(document).one('shown.bs.modal', function () { $('.modal button.btn-primary').click(function () { @@ -58,7 +54,6 @@ placement: 'right', title: "Choose name", content: "Enter a name for your new product.", - template: render('website.tour_popover'), }, { @@ -67,7 +62,7 @@ backdrop: true, title: "New product created", content: "This page contains all the information related to the new product.", - template: render('website.tour_popover', { next: "OK" }), + template: self.popover({ next: "OK" }), }, { stepId: 'edit-price', @@ -75,7 +70,7 @@ placement: 'left', title: "Change the public price", content: "Edit the sale price of this product by clicking on the amount. The price is the sale price used in all sale order when selling this product.", - template: render('website.tour_popover', { next: "OK" }), + template: self.popover({ next: "OK" }), }, { stepId: 'add-block', @@ -84,7 +79,6 @@ 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'), }, ]; return this._super(); From 77c60a94beb4dce16513099a8348fe72f1b91007 Mon Sep 17 00:00:00 2001 From: ddm Date: Thu, 21 Nov 2013 12:23:12 +0100 Subject: [PATCH 7/9] [IMP] Tour: method names bzr revid: ddm@openerp.com-20131121112312-2n8kd2tja6upji3i --- addons/website/static/src/js/website.tour.banner.js | 2 +- addons/website/static/src/js/website.tour.js | 8 ++++---- addons/website_blog/static/src/js/website.tour.blog.js | 6 +++--- addons/website_event/static/src/js/website.tour.event.js | 6 +++--- addons/website_sale/static/src/js/website.tour.shop.js | 6 +++--- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/addons/website/static/src/js/website.tour.banner.js b/addons/website/static/src/js/website.tour.banner.js index 881e0cc08f0..f9b1fe1cac4 100644 --- a/addons/website/static/src/js/website.tour.banner.js +++ b/addons/website/static/src/js/website.tour.banner.js @@ -127,7 +127,7 @@ ]; return this._super(); }, - continueTour: function () { + continue: function () { return (this.isCurrentStep('part-2') || this.isCurrentStep('show-tutorials')) && !this.tour.ended(); }, }); diff --git a/addons/website/static/src/js/website.tour.js b/addons/website/static/src/js/website.tour.js index 9e41f9d0745..64f973428c5 100644 --- a/addons/website/static/src/js/website.tour.js +++ b/addons/website/static/src/js/website.tour.js @@ -27,7 +27,7 @@ $('.popover.tour').remove(); }, start: function () { - if (this.continueTour() || ((this.currentStepIndex() === 0) && !this.tour.ended())) { + if (this.continue() || ((this.currentStepIndex() === 0) && !this.tour.ended())) { this.tour.start(); } }, @@ -68,11 +68,11 @@ window.location.replace(newUrl); } }, - continueTour: function () { + continue: function () { // Override if necessary return this.currentStepIndex() === 0; }, - isTriggerUrl: function (url) { + trigger: function (url) { // Override if necessary url = url || new website.UrlParser(window.location.href); var urlTrigger = this.id + "=true"; @@ -120,7 +120,7 @@ tour.start(); }); menu.append($menuItem); - if (tour.isTriggerUrl()) { + if (tour.trigger()) { tour.start(); } }); diff --git a/addons/website_blog/static/src/js/website.tour.blog.js b/addons/website_blog/static/src/js/website.tour.blog.js index 19a56aa351f..8ce3fb03025 100644 --- a/addons/website_blog/static/src/js/website.tour.blog.js +++ b/addons/website_blog/static/src/js/website.tour.blog.js @@ -107,11 +107,11 @@ ]; return this._super(); }, - continueTour: function () { + continue: function () { return this.isCurrentStep('post-page') && !this.tour.ended(); }, - isTriggerUrl: function () { - return (this.continueTour() && this.testUrl(/^\/blog\/[0-9]+\/\?enable_editor=1/)) || this._super(); + trigger: function () { + return (this.continue() && this.testUrl(/^\/blog\/[0-9]+\/\?enable_editor=1/)) || this._super(); }, }); diff --git a/addons/website_event/static/src/js/website.tour.event.js b/addons/website_event/static/src/js/website.tour.event.js index 2f81eb43733..941a8c6c5f6 100644 --- a/addons/website_event/static/src/js/website.tour.event.js +++ b/addons/website_event/static/src/js/website.tour.event.js @@ -74,11 +74,11 @@ ]; return this._super(); }, - continueTour: function () { + continue: function () { return this.isCurrentStep('event-page') && !this.tour.ended(); }, - isTriggerUrl: function () { - return (this.continueTour() && this.testUrl(/^\/event\/[0-9]+\/\?enable_editor=1/)) || this._super(); + trigger: function () { + return (this.continue() && this.testUrl(/^\/event\/[0-9]+\/\?enable_editor=1/)) || this._super(); }, }); 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 841e8a87a5c..42f0645a015 100644 --- a/addons/website_sale/static/src/js/website.tour.shop.js +++ b/addons/website_sale/static/src/js/website.tour.shop.js @@ -83,11 +83,11 @@ ]; return this._super(); }, - continueTour: function () { + continue: function () { return this.isCurrentStep('product-page') && !this.tour.ended(); }, - isTriggerUrl: function (url) { - return (this.continueTour() && this.testUrl(/^\/shop\/product\/[0-9]+\/\?enable_editor=1/)) || this._super(); + trigger: function (url) { + return (this.continue() && this.testUrl(/^\/shop\/product\/[0-9]+\/\?enable_editor=1/)) || this._super(); }, }); From 135345bf2a7fa737546ceb70dca736860e019769 Mon Sep 17 00:00:00 2001 From: ddm Date: Thu, 21 Nov 2013 12:35:07 +0100 Subject: [PATCH 8/9] [IMP] Tour: better modal handling bzr revid: ddm@openerp.com-20131121113507-qmz5inlge2ixkib8 --- addons/website/static/src/js/website.menu.js | 6 ------ addons/website/static/src/js/website.tour.page.js | 6 +++--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/addons/website/static/src/js/website.menu.js b/addons/website/static/src/js/website.menu.js index 40551b2dd75..b3554b9e7c5 100644 --- a/addons/website/static/src/js/website.menu.js +++ b/addons/website/static/src/js/website.menu.js @@ -5,15 +5,12 @@ website.menu = {}; website.add_template_file('/website/static/src/xml/website.menu.xml'); - var globalEditor; - website.EditorBar.include({ events: _.extend({}, website.EditorBar.prototype.events, { 'click a[data-action="edit-structure"]': 'editStructure', }), editStructure: function () { var self = this; - globalEditor = self; var context = website.get_context(); openerp.jsonRpc('/web/dataset/call_kw', 'call', { model: 'website.menu', @@ -24,7 +21,6 @@ }, }).then(function (menu) { var result = new website.menu.EditMenuDialog(menu).appendTo(document.body); - self.trigger('tour:menu_editor_dialog_ready'); return result; }); }, @@ -171,7 +167,6 @@ $link_text.focus(); }); }); - globalEditor.trigger('tour:new_menu_entry_dialog_ready'); return result; }, save: function () { @@ -192,7 +187,6 @@ } }, destroy: function () { - globalEditor.trigger('tour:new_menu_entry_dialog_closed'); this._super.apply(this, arguments); }, }); diff --git a/addons/website/static/src/js/website.tour.page.js b/addons/website/static/src/js/website.tour.page.js index adaee912110..b52c11efa28 100644 --- a/addons/website/static/src/js/website.tour.page.js +++ b/addons/website/static/src/js/website.tour.page.js @@ -39,7 +39,7 @@ title: "Edit menu", content: "Click here to create a new menu entry and manage options.", onShow: function () { - editor.on('tour:menu_editor_dialog_ready', editor, function () { + $(document).one('shown.bs.modal', function () { self.movetoStep('add-menu-entry'); }); }, @@ -51,7 +51,7 @@ title: "Add menu entry", content: "Click here to create a new menu entry.", onShow: function () { - editor.on('tour:new_menu_entry_dialog_ready', editor, function () { + $(document).one('shown.bs.modal', function () { self.movetoStep('enter-entry-name'); }); }, @@ -79,7 +79,7 @@ title: "Save the page", content: "Save your new page.", onShow: function () { - editor.on('tour:new_menu_entry_dialog_closed', editor, function () { + $(document).one('hidden.bs.modal', function () { self.movetoStep('save-menu'); }); }, From 56e19c374f7a64197b183dc81d80194ceb3e0f90 Mon Sep 17 00:00:00 2001 From: ddm Date: Thu, 21 Nov 2013 12:49:22 +0100 Subject: [PATCH 9/9] [FIX] Avoid reserved keywords as method names bzr revid: ddm@openerp.com-20131121114922-w731pvjnnvqzxu42 --- addons/website/static/src/js/website.tour.banner.js | 2 +- addons/website/static/src/js/website.tour.js | 4 ++-- addons/website_blog/static/src/js/website.tour.blog.js | 4 ++-- addons/website_event/static/src/js/website.tour.event.js | 4 ++-- addons/website_sale/static/src/js/website.tour.shop.js | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/addons/website/static/src/js/website.tour.banner.js b/addons/website/static/src/js/website.tour.banner.js index f9b1fe1cac4..5e826116fe3 100644 --- a/addons/website/static/src/js/website.tour.banner.js +++ b/addons/website/static/src/js/website.tour.banner.js @@ -127,7 +127,7 @@ ]; return this._super(); }, - continue: function () { + resume: function () { return (this.isCurrentStep('part-2') || this.isCurrentStep('show-tutorials')) && !this.tour.ended(); }, }); diff --git a/addons/website/static/src/js/website.tour.js b/addons/website/static/src/js/website.tour.js index 64f973428c5..8cefecba466 100644 --- a/addons/website/static/src/js/website.tour.js +++ b/addons/website/static/src/js/website.tour.js @@ -27,7 +27,7 @@ $('.popover.tour').remove(); }, start: function () { - if (this.continue() || ((this.currentStepIndex() === 0) && !this.tour.ended())) { + if (this.resume() || ((this.currentStepIndex() === 0) && !this.tour.ended())) { this.tour.start(); } }, @@ -68,7 +68,7 @@ window.location.replace(newUrl); } }, - continue: function () { + resume: function () { // Override if necessary return this.currentStepIndex() === 0; }, diff --git a/addons/website_blog/static/src/js/website.tour.blog.js b/addons/website_blog/static/src/js/website.tour.blog.js index 8ce3fb03025..e524758819f 100644 --- a/addons/website_blog/static/src/js/website.tour.blog.js +++ b/addons/website_blog/static/src/js/website.tour.blog.js @@ -107,11 +107,11 @@ ]; return this._super(); }, - continue: function () { + resume: function () { return this.isCurrentStep('post-page') && !this.tour.ended(); }, trigger: function () { - return (this.continue() && this.testUrl(/^\/blog\/[0-9]+\/\?enable_editor=1/)) || this._super(); + return (this.resume() && this.testUrl(/^\/blog\/[0-9]+\/\?enable_editor=1/)) || this._super(); }, }); diff --git a/addons/website_event/static/src/js/website.tour.event.js b/addons/website_event/static/src/js/website.tour.event.js index 941a8c6c5f6..5d97c320b23 100644 --- a/addons/website_event/static/src/js/website.tour.event.js +++ b/addons/website_event/static/src/js/website.tour.event.js @@ -74,11 +74,11 @@ ]; return this._super(); }, - continue: function () { + resume: function () { return this.isCurrentStep('event-page') && !this.tour.ended(); }, trigger: function () { - return (this.continue() && this.testUrl(/^\/event\/[0-9]+\/\?enable_editor=1/)) || this._super(); + return (this.resume() && this.testUrl(/^\/event\/[0-9]+\/\?enable_editor=1/)) || this._super(); }, }); 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 42f0645a015..835ccd9d44a 100644 --- a/addons/website_sale/static/src/js/website.tour.shop.js +++ b/addons/website_sale/static/src/js/website.tour.shop.js @@ -83,11 +83,11 @@ ]; return this._super(); }, - continue: function () { + resume: function () { return this.isCurrentStep('product-page') && !this.tour.ended(); }, trigger: function (url) { - return (this.continue() && this.testUrl(/^\/shop\/product\/[0-9]+\/\?enable_editor=1/)) || this._super(); + return (this.resume() && this.testUrl(/^\/shop\/product\/[0-9]+\/\?enable_editor=1/)) || this._super(); }, });