From ec4372ac23b2c1e9cb3c578bc575dfe2efbf3f81 Mon Sep 17 00:00:00 2001 From: ddm Date: Thu, 21 Nov 2013 12:11:02 +0100 Subject: [PATCH] [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();