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