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