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