[FIX] Event tour was broken by change
[odoo/odoo.git] / addons / website_event / static / src / js / website.tour.event.js
1 (function () {
2     'use strict';
3
4     var website = openerp.website;
5
6     website.EditorBar.include({
7         start: function () {
8             this.registerTour(new website.EventTour(this));
9             return this._super();
10         },
11     });
12
13     website.EventTour = website.Tour.extend({
14         id: 'event-tutorial',
15         name: "Create an event",
16         init: function (editor) {
17             var self = this;
18             self.steps = [
19                 {
20                     stepId: 'welcome-event',
21                     orphan: true,
22                     backdrop: true,
23                     title: "Create an Event",
24                     content: "Let's go through the firsts step to publish a new event.",
25                     template: self.popover({ next: "Start Tutorial", end: "Skip It" }),
26                 },
27                 {
28                     stepId: 'content-menu',
29                     element: '#content-menu-button',
30                     placement: 'left',
31                     reflex: true,
32                     title: "Add Content",
33                     content: "The <em>Content</em> menu allows to create new pages, events, menus, etc.",
34                 },
35                 {
36                     stepId: 'new-post-entry',
37                     element: 'a[data-action=new_event]',
38                     placement: 'left',
39                     title: "New Event",
40                     content: "Click here to create a new event.",
41                     modal: {
42                         stopOnClose: true,
43                         afterSubmit: 'event-page',
44                     },
45                 },
46                 {
47                     stepId: 'choose-name',
48                     element: '.modal input',
49                     placement: 'right',
50                     title: "Choose an Event Name",
51                     content: "Choose a name for your new event and click <em>'Continue'</em>. e.g: Technical Training",
52                 },
53                 {
54                     stepId: 'event-page',
55                     orphan: true,
56                     title: "New Event Created",
57                     content: "This is your new event page. We will edit the event presentation page.",
58                     template: self.popover({ next: "OK" }),
59                 },
60                 {
61                     stepId: 'event-price',
62                     element: '[data-oe-field=price]',
63                     placement: 'top',
64                     title: "Ticket price",
65                     content: "Edit your ticket price.",
66                     template: self.popover({ next: "OK" }),
67                 },
68                 {
69                     stepId: 'add-banner',
70                     element: 'button[data-action=snippet]',
71                     placement: 'bottom',
72                     title: "Layout your event",
73                     content: "Insert blocks like 'Banner' to layout the body of your event.",
74                     triggers: function () {
75                         $('button[data-action=snippet]').one('click', function () {
76                             self.moveToNextStep();
77                         });
78                     },
79                 },
80                 {
81                     stepId: 'drag-banner',
82                     element: '#website-top-navbar [data-snippet-id=carousel].ui-draggable',
83                     placement: 'bottom',
84                     title: "Drag & Drop a block",
85                     content: "Drag the 'Banner' block and drop it in your page.",
86                     triggers: function () {
87                         self.onSnippetDraggedAdvance('carousel');
88                     },
89                 },
90                 {
91                     stepId: 'add-text-block',
92                     element: 'button[data-action=snippet]',
93                     placement: 'bottom',
94                     title: "Layout your event",
95                     content: "Insert another block to your event.",
96                     triggers: function () {
97                         $('button[data-action=snippet]').one('click', function () {
98                             self.moveToNextStep();
99                         });
100                     },
101                 },
102                 {
103                     stepId: 'drag-text-block',
104                     element: '#website-top-navbar [data-snippet-id=text-block].ui-draggable',
105                     placement: 'bottom',
106                     title: "Drag & Drop a block",
107                     content: "Drag the 'Text Block' block below the banner.",
108                     triggers: function () {
109                         self.onSnippetDraggedAdvance('text-block');
110                     },
111                     onHide: function () {
112                         window.scrollTo(0, 0);
113                     },
114                 },
115                 {
116                     stepId: 'add-three-columns',
117                     element: 'button[data-action=snippet]',
118                     placement: 'bottom',
119                     title: "Layout your event",
120                     content: "Insert a last block to your event.",
121                     triggers: function () {
122                         $('button[data-action=snippet]').one('click', function () {
123                             self.moveToNextStep();
124                         });
125                     },
126                 },
127                 {
128                     stepId: 'drag-three-columns',
129                     element: '#website-top-navbar [data-snippet-id=three-columns].ui-draggable',
130                     placement: 'bottom',
131                     title: "Drag & Drop a block",
132                     content: "Drag the 'Three Columns' block at the bottom.",
133                     triggers: function () {
134                         self.onSnippetDraggedAdvance('three-columns');
135                     },
136                     onHide: function () {
137                         window.scrollTo(0, 0);
138                     },
139                 },
140                 {
141                     stepId: 'save-changes',
142                     element: 'button[data-action=save]',
143                     placement: 'right',
144                     title: "Save your modifications",
145                     content: "Once you click on save, your event is updated.",
146                     triggers: function () {
147                         var $publish = $('button.js_publish_btn');
148                         if ($publish.length > 0 && $publish.is(":visible")) {
149                             self.moveToNextStep();
150                         }
151                     },
152                 },
153                 {
154                     stepId: 'publish-event',
155                     element: 'button.js_publish_btn',
156                     placement: 'top',
157                     reflex: true,
158                     title: "Publish your event",
159                     content: "Click to publish your event.",
160                 },
161                 {
162                     stepId: 'customize-event',
163                     element: '.js_publish_management button:last',
164                     placement: 'left',
165                     reflex: true,
166                     title: "Customize your event",
167                     content: "Click here to customize your event further.",
168                 },
169                 {
170                     stepId: 'edit-event-backend',
171                     element: '.js_publish_management ul>li>a',
172                     placement: 'left',
173                     reflex: true,
174                     title: "Customize your event",
175                     content: "Click here to edit your event in the backend.",
176                 },
177             ];
178             return this._super();
179         },
180         resume: function () {
181             return (this.isCurrentStep('event-page') || this.isCurrentStep('save-changes')) && this._super();
182         },
183         trigger: function () {
184             return (this.resume() && this.testUrl(/^\/event\/[0-9]+\/register/)) || this._super();
185         },
186     });
187
188 }());