##// END OF EJS Templates
Fix bootstrap tour
Jonathan Frederic -
Show More
@@ -1,175 +1,175 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 title: "Welcome to the Notebook Tour",
14 title: "Welcome to the Notebook Tour",
15 placement: 'bottom',
15 placement: 'bottom',
16 orphan: true,
16 orphan: true,
17 content: "This tour will take 2 minutes.",
17 content: "This tour will take 2 minutes.",
18 }, {
18 }, {
19 element: "#notebook_name",
19 element: "#notebook_name",
20 title: "Filename",
20 title: "Filename",
21 placement: 'bottom',
21 placement: 'bottom',
22 content: "Click here to change the filename for this notebook."
22 content: "Click here to change the filename for this notebook."
23 }, /*{
23 }, /*{
24 element: "#checkpoint_status",
24 element: "#checkpoint_status",
25 title: "Checkpoint Status",
25 title: "Checkpoint Status",
26 placement: 'bottom',
26 placement: 'bottom',
27 content: "Information about the last time this notebook was saved."
27 content: "Information about the last time this notebook was saved."
28 },*/ {
28 },*/ {
29 element: $("#menus").parent(),
29 element: $("#menus").parent(),
30 placement: 'bottom',
30 placement: 'bottom',
31 backdrop: true,
31 backdrop: true,
32 title: "Notebook Menubar",
32 title: "Notebook Menubar",
33 content: "The menubar has menus for actions on the notebook, its cells, and the kernel it communicates with."
33 content: "The menubar has menus for actions on the notebook, its cells, and the kernel it communicates with."
34 }, {
34 }, {
35 element: "#maintoolbar",
35 element: "#maintoolbar",
36 placement: 'bottom',
36 placement: 'bottom',
37 backdrop: true,
37 backdrop: true,
38 title: "Notebook Toolbar",
38 title: "Notebook Toolbar",
39 content: "The toolbar has buttons for the most common actions. Hover your mouse over each button for more information."
39 content: "The toolbar has buttons for the most common actions. Hover your mouse over each button for more information."
40 }, {
40 }, {
41 element: "#modal_indicator",
41 element: "#modal_indicator",
42 title: "Mode Indicator",
42 title: "Mode Indicator",
43 placement: 'bottom',
43 placement: 'bottom',
44 content: "The Notebook has two modes: Edit Mode and Command Mode. In this area, an indicator can appear to tell you which mode you are in.",
44 content: "The Notebook has two modes: Edit Mode and Command Mode. In this area, an indicator can appear to tell you which mode you are in.",
45 onShow: function(tour) { command_icon_hack(); }
45 onShow: function(tour) { command_icon_hack(); }
46 }, {
46 }, {
47 element: "#modal_indicator",
47 element: "#modal_indicator",
48 title: "Command Mode",
48 title: "Command Mode",
49 placement: 'bottom',
49 placement: 'bottom',
50 onShow: function(tour) { IPython.notebook.command_mode(); command_icon_hack(); },
50 onShow: function(tour) { IPython.notebook.command_mode(); command_icon_hack(); },
51 onNext: function(tour) { edit_mode(); },
51 onNext: function(tour) { edit_mode(); },
52 content: "Right now you are in Command Mode, and many keyboard shortcuts are available. In this mode, no icon is displayed in the indicator area."
52 content: "Right now you are in Command Mode, and many keyboard shortcuts are available. In this mode, no icon is displayed in the indicator area."
53 }, {
53 }, {
54 element: "#modal_indicator",
54 element: "#modal_indicator",
55 title: "Edit Mode",
55 title: "Edit Mode",
56 placement: 'bottom',
56 placement: 'bottom',
57 onShow: function(tour) { edit_mode(); },
57 onShow: function(tour) { edit_mode(); },
58 content: "Pressing <code>Enter</code> or clicking in the input text area of the cell switches to Edit Mode."
58 content: "Pressing <code>Enter</code> or clicking in the input text area of the cell switches to Edit Mode."
59 }, {
59 }, {
60 element: '.selected',
60 element: '.selected',
61 title: "Edit Mode",
61 title: "Edit Mode",
62 placement: 'bottom',
62 placement: 'bottom',
63 onShow: function(tour) { edit_mode(); },
63 onShow: function(tour) { edit_mode(); },
64 content: "Notice that the border around the currently active cell changed color. Typing will insert text into the currently active cell."
64 content: "Notice that the border around the currently active cell changed color. Typing will insert text into the currently active cell."
65 }, {
65 }, {
66 element: '.selected',
66 element: '.selected',
67 title: "Back to Command Mode",
67 title: "Back to Command Mode",
68 placement: 'bottom',
68 placement: 'bottom',
69 onShow: function(tour) { IPython.notebook.command_mode(); },
69 onShow: function(tour) { IPython.notebook.command_mode(); },
70 onHide: function(tour) { $('#help_menu').parent().children('a').click(); },
70 content: "Pressing <code>Esc</code> or clicking outside of the input text area takes you back to Command Mode."
71 content: "Pressing <code>Esc</code> or clicking outside of the input text area takes you back to Command Mode."
71 }, {
72 }, {
72 element: '#keyboard_shortcuts',
73 element: '#keyboard_shortcuts',
73 title: "Keyboard Shortcuts",
74 title: "Keyboard Shortcuts",
74 placement: 'bottom',
75 placement: 'bottom',
75 onShow: function(tour) { $('#help_menu').parent().addClass('open'); },
76 onHide: function(tour) { $('#help_menu').parent().children('a').click(); },
76 onHide: function(tour) { $('#help_menu').parent().removeClass('open'); },
77 content: "You can click here to get a list of all of the keyboard shortcuts."
77 content: "You can click here to get a list of all of the keyboard shortcuts."
78 }, {
78 }, {
79 element: "#kernel_indicator",
79 element: "#kernel_indicator",
80 title: "Kernel Indicator",
80 title: "Kernel Indicator",
81 placement: 'bottom',
81 placement: 'bottom',
82 onShow: function(tour) { $([IPython.events]).trigger('status_idle.Kernel');},
82 onShow: function(tour) { $([IPython.events]).trigger('status_idle.Kernel');},
83 content: "This is the Kernel indicator. It looks like this when the Kernel is idle.",
83 content: "This is the Kernel indicator. It looks like this when the Kernel is idle.",
84 }, {
84 }, {
85 element: "#kernel_indicator",
85 element: "#kernel_indicator",
86 title: "Kernel Indicator",
86 title: "Kernel Indicator",
87 placement: 'bottom',
87 placement: 'bottom',
88 onShow: function(tour) { $([IPython.events]).trigger('status_busy.Kernel'); },
88 onShow: function(tour) { $([IPython.events]).trigger('status_busy.Kernel'); },
89 content: "The Kernel indicator looks like this when the Kernel is busy.",
89 content: "The Kernel indicator looks like this when the Kernel is busy.",
90 }, {
90 }, {
91 element: ".icon-stop",
91 element: ".icon-stop",
92 placement: 'bottom',
92 placement: 'bottom',
93 title: "Interrupting the Kernel",
93 title: "Interrupting the Kernel",
94 onHide: function(tour) { $([IPython.events]).trigger('status_idle.Kernel'); },
94 onHide: function(tour) { $([IPython.events]).trigger('status_idle.Kernel'); },
95 content: "To cancel a computation in progress, you can click here."
95 content: "To cancel a computation in progress, you can click here."
96 }, {
96 }, {
97 element: "#notification_kernel",
97 element: "#notification_kernel",
98 placement: 'bottom',
98 placement: 'bottom',
99 onShow: function(tour) { $('.icon-stop').click(); },
99 onShow: function(tour) { $('.icon-stop').click(); },
100 title: "Notification Area",
100 title: "Notification Area",
101 content: "Messages in response to user actions (Save, Interrupt, etc) appear here."
101 content: "Messages in response to user actions (Save, Interrupt, etc) appear here."
102 }, {
102 }, {
103 title: "Fin.",
103 title: "Fin.",
104 placement: 'bottom',
104 placement: 'bottom',
105 orphan: true,
105 orphan: true,
106 content: "This concludes the IPython Notebook User Interface Tour. Happy hacking!",
106 content: "This concludes the IPython Notebook User Interface Tour. Happy hacking!",
107 }
107 }
108 ];
108 ];
109
109
110 var tour_style = "<div class='popover tour'>\
110 var tour_style = "<div class='popover tour'>\
111 <div class='arrow'></div>\
111 <div class='arrow'></div>\
112 <div style='position:absolute; top:7px; right:7px'>\
112 <div style='position:absolute; top:7px; right:7px'>\
113 <button class='btn btn-default btn-sm icon-remove' data-role='end'></button></div>\
113 <button class='btn btn-default btn-sm icon-remove' data-role='end'></button></div>\
114 <h3 class='popover-title'></h3>\
114 <h3 class='popover-title'></h3>\
115 <div class='popover-content'></div>\
115 <div class='popover-content'></div>\
116 <div class='popover-navigation'>\
116 <div class='popover-navigation'>\
117 <button class='btn btn-default icon-step-backward' data-role='prev'></button>\
117 <button class='btn btn-default icon-step-backward' data-role='prev'></button>\
118 <button class='btn btn-default icon-step-forward pull-right' data-role='next'></button>\
118 <button class='btn btn-default icon-step-forward pull-right' data-role='next'></button>\
119 <button id='tour-pause' class='btn btn-sm btn-default icon-pause' data-resume-text='' data-pause-text='' data-role='pause-resume'></button>\
119 <button id='tour-pause' class='btn btn-sm btn-default icon-pause' data-resume-text='' data-pause-text='' data-role='pause-resume'></button>\
120 </div>\
120 </div>\
121 </div>";
121 </div>";
122
122
123 var command_icon_hack = function() {$('#modal_indicator').css('min-height', 20);}
123 var command_icon_hack = function() {$('#modal_indicator').css('min-height', 20);}
124 var toggle_pause_play = function () { $('#tour-pause').toggleClass('icon-pause icon-play'); };
124 var toggle_pause_play = function () { $('#tour-pause').toggleClass('icon-pause icon-play'); };
125 var edit_mode = function() {
125 var edit_mode = function() {
126 IPython.notebook.focus_cell();
126 IPython.notebook.focus_cell();
127 IPython.notebook.edit_mode();
127 IPython.notebook.edit_mode();
128 ;}
128 ;}
129
129
130 IPython = (function (IPython) {
130 IPython = (function (IPython) {
131 "use strict";
131 "use strict";
132
132
133
133
134 var NotebookTour = function () {
134 var NotebookTour = function () {
135 this.step_duration = 0;
135 this.step_duration = 0;
136 this.tour_steps = tour_steps ;
136 this.tour_steps = tour_steps ;
137 this.tour_steps[0].content = "You can use the left and right arrow keys to go backwards and forwards.";
137 this.tour_steps[0].content = "You can use the left and right arrow keys to go backwards and forwards.";
138 this.tour = new Tour({
138 this.tour = new Tour({
139 //orphan: true,
139 //orphan: true,
140 storage: false, // start tour from beginning every time
140 storage: false, // start tour from beginning every time
141 //element: $("#ipython_notebook"),
141 //element: $("#ipython_notebook"),
142 debug: true,
142 debug: true,
143 reflex: true, // click on element to continue tour
143 reflex: true, // click on element to continue tour
144 //backdrop: true, // show dark behind popover
144 //backdrop: true, // show dark behind popover
145 animation: false,
145 animation: false,
146 duration: this.step_duration,
146 duration: this.step_duration,
147 onStart: function() { console.log('tour started'); },
147 onStart: function() { console.log('tour started'); },
148 // TODO: remove the onPause/onResume logic once pi's patch has been
148 // TODO: remove the onPause/onResume logic once pi's patch has been
149 // merged upstream to make this work via data-resume-class and
149 // merged upstream to make this work via data-resume-class and
150 // data-resume-text attributes.
150 // data-resume-text attributes.
151 onPause: toggle_pause_play,
151 onPause: toggle_pause_play,
152 onResume: toggle_pause_play,
152 onResume: toggle_pause_play,
153 steps: this.tour_steps,
153 steps: this.tour_steps,
154 template: tour_style,
154 template: tour_style,
155 orphan: true
155 orphan: true
156 });
156 });
157
157
158 };
158 };
159
159
160 NotebookTour.prototype.start = function () {
160 NotebookTour.prototype.start = function () {
161 console.log("let's start the tour");
161 console.log("let's start the tour");
162 this.tour.init();
162 this.tour.init();
163 this.tour.start();
163 this.tour.start();
164 if (this.tour.ended())
164 if (this.tour.ended())
165 {
165 {
166 this.tour.restart();
166 this.tour.restart();
167 }
167 }
168 };
168 };
169
169
170 // Set module variables
170 // Set module variables
171 IPython.NotebookTour = NotebookTour;
171 IPython.NotebookTour = NotebookTour;
172
172
173 return IPython;
173 return IPython;
174
174
175 }(IPython));
175 }(IPython));
General Comments 0
You need to be logged in to leave comments. Login now