Show More
@@ -1,139 +1,160 | |||||
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: ' |
|
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: "Message 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'>\ | |||
|
103 | <div class='arrow'></div>\ | |||
|
104 | <h3 class='popover-title'> | |||
|
105 | <button class='btn btn-default' data-role='end'>End tour</button>\</h3>\ | |||
|
106 | <div class='popover-content'></div>\ | |||
|
107 | <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-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 | ||||
|
112 | </div>\ | |||
|
113 | </div>" | |||
|
114 | ||||
|
115 | var toggle_pause_play = function () { $('#tour-pause').toggleClass('icon-pause icon-play'); } | |||
|
116 | ||||
102 | IPython = (function (IPython) { |
|
117 | IPython = (function (IPython) { | |
103 | "use strict"; |
|
118 | "use strict"; | |
104 |
|
119 | |||
105 |
|
120 | |||
106 | var NotebookTour = function () { |
|
121 | var NotebookTour = function () { | |
107 | this.step_duration = 5000; |
|
122 | this.step_duration = 5000; | |
108 | this.tour_steps = tour_steps ; |
|
123 | this.tour_steps = tour_steps ; | |
109 | 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"; | |
110 | this.tour = new Tour({ |
|
125 | this.tour = new Tour({ | |
111 | //orphan: true, |
|
126 | //orphan: true, | |
112 | storage: false, // start tour from beginning every time |
|
127 | storage: false, // start tour from beginning every time | |
113 | //element: $("#ipython_notebook"), |
|
128 | //element: $("#ipython_notebook"), | |
114 | debug: true, |
|
129 | debug: true, | |
115 | reflex: true, // click on element to continue tour |
|
130 | reflex: true, // click on element to continue tour | |
116 | //backdrop: true, // show dark behind popover |
|
131 | //backdrop: true, // show dark behind popover | |
117 | animation: false, |
|
132 | animation: false, | |
118 | duration: this.step_duration, |
|
133 | duration: this.step_duration, | |
119 | 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 | |||
|
136 | // merged upstream to make this work via data-resume-class and | |||
|
137 | // data-resume-text attributes. | |||
|
138 | onPause: toggle_pause_play, | |||
|
139 | onResume: toggle_pause_play, | |||
120 | steps: this.tour_steps, |
|
140 | steps: this.tour_steps, | |
|
141 | template: tour_style | |||
121 | }); |
|
142 | }); | |
122 | this.tour.init(); |
|
143 | this.tour.init(); | |
123 | }; |
|
144 | }; | |
124 |
|
145 | |||
125 | NotebookTour.prototype.start = function () { |
|
146 | NotebookTour.prototype.start = function () { | |
126 | console.log("let's start the tour"); |
|
147 | console.log("let's start the tour"); | |
127 | this.tour.start(); |
|
148 | this.tour.start(); | |
128 | if (this.tour.ended()) |
|
149 | if (this.tour.ended()) | |
129 | { |
|
150 | { | |
130 | this.tour.restart(); |
|
151 | this.tour.restart(); | |
131 | } |
|
152 | } | |
132 | }; |
|
153 | }; | |
133 |
|
154 | |||
134 | // Set module variables |
|
155 | // Set module variables | |
135 | IPython.NotebookTour = NotebookTour; |
|
156 | IPython.NotebookTour = NotebookTour; | |
136 |
|
157 | |||
137 | return IPython; |
|
158 | return IPython; | |
138 |
|
159 | |||
139 | }(IPython)); |
|
160 | }(IPython)); |
General Comments 0
You need to be logged in to leave comments.
Login now