##// END OF EJS Templates
End tour via 'x' in upper right corner of window
Paul Ivanov -
Show More
@@ -1,160 +1,160 b''
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2011 The IPython Development Team
2 // Copyright (C) 2011 The IPython Development Team
3 //
3 //
4 // Distributed under the terms of the BSD License. The full license is in
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
6 //----------------------------------------------------------------------------
7
7
8 //============================================================================
8 //============================================================================
9 // Tour of IPython Notebok UI (with Bootstrap Tour)
9 // Tour of IPython Notebok UI (with Bootstrap Tour)
10 //============================================================================
10 //============================================================================
11
11
12 var tour_steps = [
12 var tour_steps = [
13 {
13 {
14 element: $("#ipython_notebook").parent(),
14 element: $("#ipython_notebook").parent(),
15 title: "Welcome to the Notebook Tour",
15 title: "Welcome to the Notebook Tour",
16 placement: 'bottom',
16 placement: 'bottom',
17 content: "This tour will take 2 minutes.",
17 content: "This tour will take 2 minutes.",
18 backdrop: true,
18 backdrop: true,
19 }, {
19 }, {
20 element: "#ipython_notebook",
20 element: "#ipython_notebook",
21 title: "Header",
21 title: "Header",
22 placement: 'bottom',
22 placement: 'bottom',
23 content: "Clicking here takes you back to the Dashboard."
23 content: "Clicking here takes you back to the Dashboard."
24 }, {
24 }, {
25 element: "#notebook_name",
25 element: "#notebook_name",
26 title: "Filename",
26 title: "Filename",
27 placement: 'bottom',
27 placement: 'bottom',
28 content: "You can click here to change the filename for this notebook."
28 content: "You can click here to change the filename for this notebook."
29 },
29 },
30 {
30 {
31 element: "#checkpoint_status",
31 element: "#checkpoint_status",
32 title: "Checkpoint status",
32 title: "Checkpoint status",
33 placement: 'bottom',
33 placement: 'bottom',
34 content: "Information about the last time this notebook was saved."
34 content: "Information about the last time this notebook was saved."
35 }, {
35 }, {
36 element: "#menus",
36 element: "#menus",
37 placement: 'left',
37 placement: 'left',
38 title: "Notebook Menubar",
38 title: "Notebook Menubar",
39 content: "The actions that you can perform with this notebook, its cells, and its kernel"
39 content: "The actions that you can perform with this notebook, its cells, and its kernel"
40 }, {
40 }, {
41 element: "#menus",
41 element: "#menus",
42 placement: 'bottom',
42 placement: 'bottom',
43 title: "Notebook Menubar",
43 title: "Notebook Menubar",
44 content: "The actions that you can perform with this notebook, its cells, and its kernel"
44 content: "The actions that you can perform with this notebook, its cells, and its kernel"
45 }, {
45 }, {
46 element: "#notification_kernel",
46 element: "#notification_kernel",
47 placement: 'bottom',
47 placement: 'bottom',
48 onShow: function(tour) { IPython.notification_area.widget_dict.kernel.set_message("sample notification"); },
48 onShow: function(tour) { IPython.notification_area.widget_dict.kernel.set_message("sample notification"); },
49 onHide: function(tour) { IPython.notification_area.widget_dict.kernel.set_message("sample notification", 100); },
49 onHide: function(tour) { IPython.notification_area.widget_dict.kernel.set_message("sample notification", 100); },
50 title: "Notification area",
50 title: "Notification area",
51 content: "Messages in response to user action (Kernel busy, Interrupt, etc)"
51 content: "Messages in response to user action (Kernel busy, Interrupt, etc)"
52 }, {
52 }, {
53 element: "#modal_indicator",
53 element: "#modal_indicator",
54 title: "Mode indicator",
54 title: "Mode indicator",
55 placement: 'bottom',
55 placement: 'bottom',
56 content: "IPython has two modes: Edit Mode and Command Mode. This indicator tells you which mode you are in."
56 content: "IPython has two modes: Edit Mode and Command Mode. This indicator tells you which mode you are in."
57 }, {
57 }, {
58 element: "#modal_indicator",
58 element: "#modal_indicator",
59 title: "Mode indicator",
59 title: "Mode indicator",
60 placement: 'bottom',
60 placement: 'bottom',
61 content: "Right now you are in Command mode, and many keyboard shortcuts are available."
61 content: "Right now you are in Command mode, and many keyboard shortcuts are available."
62 }, {
62 }, {
63 element: "#modal_indicator",
63 element: "#modal_indicator",
64 title: "Edit Mode",
64 title: "Edit Mode",
65 placement: 'bottom',
65 placement: 'bottom',
66 onShow: function(tour) { IPython.notebook.edit_mode(); },
66 onShow: function(tour) { IPython.notebook.edit_mode(); },
67 content: "And now we've switched to Edit Mode, regular typing will go into the currently active cell."
67 content: "And now we've switched to Edit Mode, regular typing will go into the currently active cell."
68 }, {
68 }, {
69 element: $('.selected'),
69 element: $('.selected'),
70 title: "Edit Mode",
70 title: "Edit Mode",
71 placement: 'bottom',
71 placement: 'bottom',
72 onHide: function(tour) { IPython.notebook.command_mode(); },
72 onHide: function(tour) { IPython.notebook.command_mode(); },
73 content: "Notice that the border around the currently active cell changed color."
73 content: "Notice that the border around the currently active cell changed color."
74 }, {
74 }, {
75 element: $('.selected'),
75 element: $('.selected'),
76 title: "back to Command Mode",
76 title: "back to Command Mode",
77 placement: 'bottom',
77 placement: 'bottom',
78 onHide: function(tour) { IPython.notebook.command_mode(); },
78 onHide: function(tour) { IPython.notebook.command_mode(); },
79 content: "Pressing Esc or clicking outside of the input text area takes you back to command mode."
79 content: "Pressing Esc or clicking outside of the input text area takes you back to command mode."
80 }, {
80 }, {
81 element: "#kernel_indicator",
81 element: "#kernel_indicator",
82 title: "Kernel indicator",
82 title: "Kernel indicator",
83 placement: 'bottom',
83 placement: 'bottom',
84 content: "This is the Kernel indicator. It looks like this when the Kernel is idle.",
84 content: "This is the Kernel indicator. It looks like this when the Kernel is idle.",
85 }, {
85 }, {
86 element: "#kernel_indicator",
86 element: "#kernel_indicator",
87 title: "Kernel Indicator",
87 title: "Kernel Indicator",
88 placement: 'bottom',
88 placement: 'bottom',
89 onShow: function(tour) { $([IPython.events]).trigger('status_busy.Kernel'); },
89 onShow: function(tour) { $([IPython.events]).trigger('status_busy.Kernel'); },
90 onHide: function(tour) { $([IPython.events]).trigger('status_idle.Kernel');},
90 onHide: function(tour) { $([IPython.events]).trigger('status_idle.Kernel');},
91 content: "The Kernel indicator looks like this when the Kernel is busy.",
91 content: "The Kernel indicator looks like this when the Kernel is busy.",
92 }, {
92 }, {
93 element: "#kernel_indicator",
93 element: "#kernel_indicator",
94 title: "Fin.",
94 title: "Fin.",
95 placement: 'bottom',
95 placement: 'bottom',
96 onShow: function(tour) { $([IPython.events]).trigger('status_busy.Kernel'); },
96 onShow: function(tour) { $([IPython.events]).trigger('status_busy.Kernel'); },
97 onHide: function(tour) { $([IPython.events]).trigger('status_idle.Kernel');},
97 onHide: function(tour) { $([IPython.events]).trigger('status_idle.Kernel');},
98 content: "This concludes the IPython Notebook User Interface Tour. Happy hacking!",
98 content: "This concludes the IPython Notebook User Interface Tour. Happy hacking!",
99 }
99 }
100 ];
100 ];
101
101
102 var tour_style = "<div class='popover tour'>\
102 var tour_style = "<div class='popover tour' style='position:relative'>\
103 <div class='arrow'></div>\
103 <div class='arrow'></div>\
104 <h3 class='popover-title'>
104 <div style='position:absolute; top:7px; right:7px'>\
105 <button class='btn btn-default' data-role='end'>End tour</button>\</h3>\
105 <button class='btn btn-sm icon-remove' data-role='end'></button></div>\
106 <h3 class='popover-title'></h3>\
106 <div class='popover-content'></div>\
107 <div class='popover-content'></div>\
107 <div class='popover-navigation'>\
108 <div class='popover-navigation'>\
108 <button class='btn btn-default icon-step-backward' data-role='prev'></button>\
109 <button class='btn btn-default icon-step-backward' data-role='prev'></button>\
109 <button class='btn btn-default icon-step-forward' data-role='next'></button>\
110 <button class='btn btn-default icon-step-forward' data-role='next'></button>\
110 <button id='tour-pause' class='btn btn-sm btn-default icon-pause' data-resume-text='' data-pause-text='' data-role='pause-resume'></button>\
111 <button id='tour-pause' class='btn btn-sm btn-default icon-pause' data-resume-text='' data-pause-text='' data-role='pause-resume'></button>\
111
112 </div>\
112 </div>\
113 </div>"
113 </div>"
114
114
115 var toggle_pause_play = function () { $('#tour-pause').toggleClass('icon-pause icon-play'); }
115 var toggle_pause_play = function () { $('#tour-pause').toggleClass('icon-pause icon-play'); }
116
116
117 IPython = (function (IPython) {
117 IPython = (function (IPython) {
118 "use strict";
118 "use strict";
119
119
120
120
121 var NotebookTour = function () {
121 var NotebookTour = function () {
122 this.step_duration = 5000;
122 this.step_duration = 5000;
123 this.tour_steps = tour_steps ;
123 this.tour_steps = tour_steps ;
124 this.tour_steps[0].content = "This tour will take " + this.step_duration * tour_steps.length / 1000 + " seconds";
124 this.tour_steps[0].content = "This tour will take " + this.step_duration * tour_steps.length / 1000 + " seconds";
125 this.tour = new Tour({
125 this.tour = new Tour({
126 //orphan: true,
126 //orphan: true,
127 storage: false, // start tour from beginning every time
127 storage: false, // start tour from beginning every time
128 //element: $("#ipython_notebook"),
128 //element: $("#ipython_notebook"),
129 debug: true,
129 debug: true,
130 reflex: true, // click on element to continue tour
130 reflex: true, // click on element to continue tour
131 //backdrop: true, // show dark behind popover
131 //backdrop: true, // show dark behind popover
132 animation: false,
132 animation: false,
133 duration: this.step_duration,
133 duration: this.step_duration,
134 onStart: function() { console.log('tour started'); },
134 onStart: function() { console.log('tour started'); },
135 // TODO: remove the onPause/onResume logic once pi's patch has been
135 // TODO: remove the onPause/onResume logic once pi's patch has been
136 // merged upstream to make this work via data-resume-class and
136 // merged upstream to make this work via data-resume-class and
137 // data-resume-text attributes.
137 // data-resume-text attributes.
138 onPause: toggle_pause_play,
138 onPause: toggle_pause_play,
139 onResume: toggle_pause_play,
139 onResume: toggle_pause_play,
140 steps: this.tour_steps,
140 steps: this.tour_steps,
141 template: tour_style
141 template: tour_style
142 });
142 });
143 this.tour.init();
143 this.tour.init();
144 };
144 };
145
145
146 NotebookTour.prototype.start = function () {
146 NotebookTour.prototype.start = function () {
147 console.log("let's start the tour");
147 console.log("let's start the tour");
148 this.tour.start();
148 this.tour.start();
149 if (this.tour.ended())
149 if (this.tour.ended())
150 {
150 {
151 this.tour.restart();
151 this.tour.restart();
152 }
152 }
153 };
153 };
154
154
155 // Set module variables
155 // Set module variables
156 IPython.NotebookTour = NotebookTour;
156 IPython.NotebookTour = NotebookTour;
157
157
158 return IPython;
158 return IPython;
159
159
160 }(IPython));
160 }(IPython));
General Comments 0
You need to be logged in to leave comments. Login now