More examples and docs
Browse files- demo/scripts/demo.js +105 -2
- index.html +151 -4
demo/scripts/demo.js
CHANGED
@@ -4,10 +4,18 @@ const tourSholo = new Sholo({
|
|
4 |
animate: true,
|
5 |
opacity: 0.8,
|
6 |
padding: 5,
|
|
|
7 |
});
|
8 |
|
9 |
tourSholo.defineSteps([
|
10 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
element: '.section__header',
|
12 |
popover: {
|
13 |
title: 'Adding Introductions',
|
@@ -128,7 +136,7 @@ document.querySelector('#run-single-element-with-popover-position')
|
|
128 |
// Highlighting single element with popover position
|
129 |
/////////////////////////////////////////////////////
|
130 |
const positionBtnsSholo = new Sholo({
|
131 |
-
padding: 0
|
132 |
});
|
133 |
|
134 |
document.querySelector('#position-btn-left')
|
@@ -185,4 +193,99 @@ document.querySelector('#position-btn-top')
|
|
185 |
position: 'top'
|
186 |
}
|
187 |
});
|
188 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
animate: true,
|
5 |
opacity: 0.8,
|
6 |
padding: 5,
|
7 |
+
showButtons: false,
|
8 |
});
|
9 |
|
10 |
tourSholo.defineSteps([
|
11 |
{
|
12 |
+
element: '.emoji',
|
13 |
+
popover: {
|
14 |
+
title: 'Adding Introductions',
|
15 |
+
description: 'You can use it to add popovers on top of the website',
|
16 |
+
position: 'bottom',
|
17 |
+
},
|
18 |
+
}, {
|
19 |
element: '.section__header',
|
20 |
popover: {
|
21 |
title: 'Adding Introductions',
|
|
|
136 |
// Highlighting single element with popover position
|
137 |
/////////////////////////////////////////////////////
|
138 |
const positionBtnsSholo = new Sholo({
|
139 |
+
padding: 0,
|
140 |
});
|
141 |
|
142 |
document.querySelector('#position-btn-left')
|
|
|
193 |
position: 'top'
|
194 |
}
|
195 |
});
|
196 |
+
});
|
197 |
+
|
198 |
+
/////////////////////////////////////////////////////
|
199 |
+
// Highlighting single element with popover position
|
200 |
+
/////////////////////////////////////////////////////
|
201 |
+
const htmlSholo = new Sholo();
|
202 |
+
|
203 |
+
document.querySelector('#run-single-element-with-popover-html')
|
204 |
+
.addEventListener('click', (e) => {
|
205 |
+
e.preventDefault();
|
206 |
+
|
207 |
+
htmlSholo.highlight({
|
208 |
+
element: '#single-element-with-popover-html',
|
209 |
+
popover: {
|
210 |
+
title: '<em>Tags</em> in title or <u>body</u>',
|
211 |
+
description: 'Body can also have <strong>html tags</strong>!',
|
212 |
+
position: 'top'
|
213 |
+
}
|
214 |
+
});
|
215 |
+
});
|
216 |
+
|
217 |
+
/////////////////////////////////////////////////////
|
218 |
+
// Without Overlay Example
|
219 |
+
/////////////////////////////////////////////////////
|
220 |
+
const withoutOverlay = new Sholo({
|
221 |
+
opacity: 0,
|
222 |
+
padding: 0
|
223 |
+
});
|
224 |
+
|
225 |
+
document.querySelector('#run-element-without-popover')
|
226 |
+
.addEventListener('click', (e) => {
|
227 |
+
e.preventDefault();
|
228 |
+
|
229 |
+
withoutOverlay.highlight({
|
230 |
+
element: '#run-element-without-popover',
|
231 |
+
popover: {
|
232 |
+
title: 'Title for the Popover',
|
233 |
+
description: 'Description for it',
|
234 |
+
position: 'left', // can be `top`, `left`, `right`, `bottom`
|
235 |
+
}
|
236 |
+
} );
|
237 |
+
});
|
238 |
+
|
239 |
+
/////////////////////////////////////////////////////
|
240 |
+
// Highlighting single element with popover position
|
241 |
+
/////////////////////////////////////////////////////
|
242 |
+
const featureIntroductionSholo = new Sholo();
|
243 |
+
featureIntroductionSholo.defineSteps([
|
244 |
+
{
|
245 |
+
element: '#first-element-introduction',
|
246 |
+
popover: {
|
247 |
+
title: 'Title on Popover',
|
248 |
+
description: 'Body of the popover',
|
249 |
+
position: 'bottom'
|
250 |
+
}
|
251 |
+
},
|
252 |
+
{
|
253 |
+
element: '#second-para-feature-introductions',
|
254 |
+
popover: {
|
255 |
+
title: 'Title on Popover',
|
256 |
+
description: 'Body of the popover',
|
257 |
+
position: 'left'
|
258 |
+
}
|
259 |
+
},
|
260 |
+
{
|
261 |
+
element: '#third-para-feature-introductions',
|
262 |
+
popover: {
|
263 |
+
title: 'Title on Popover',
|
264 |
+
description: 'Body of the popover',
|
265 |
+
position: 'right'
|
266 |
+
}
|
267 |
+
},
|
268 |
+
{
|
269 |
+
element: '#run-multi-element-popovers',
|
270 |
+
popover: {
|
271 |
+
title: 'Title on Popover',
|
272 |
+
description: 'Body of the popover',
|
273 |
+
position: 'top'
|
274 |
+
}
|
275 |
+
},
|
276 |
+
{
|
277 |
+
element: '#third-element-introduction',
|
278 |
+
popover: {
|
279 |
+
title: 'Title on Popover',
|
280 |
+
description: 'Body of the popover',
|
281 |
+
position: 'top'
|
282 |
+
}
|
283 |
+
},
|
284 |
+
]);
|
285 |
+
|
286 |
+
document.querySelector('#run-multi-element-popovers')
|
287 |
+
.addEventListener('click', (e) => {
|
288 |
+
e.preventDefault();
|
289 |
+
featureIntroductionSholo.start();
|
290 |
+
});
|
291 |
+
|
index.html
CHANGED
@@ -29,7 +29,7 @@
|
|
29 |
<p>Driver is compatible with all the major browsers and can be used for any of your overlay needs. Feature
|
30 |
introductions, focus shifters, call-to-action are just a few examples.</p>
|
31 |
<ul>
|
32 |
-
<li>π <strong>Highlight</strong> any item on page</li>
|
33 |
<li>β <strong>Block user interactions</strong></li>
|
34 |
<li>π£ Create <strong>feature introductions</strong></li>
|
35 |
<li>π Add <strong>focus shifters</strong> for users</li>
|
@@ -56,7 +56,7 @@
|
|
56 |
<h4>Highlighting a Single Element β Without Popover</h4>
|
57 |
<p class="zero-bottom">If all you want is just highlight a single element, you can do that simply by passing the
|
58 |
selector</p>
|
59 |
-
<a href="#" class="btn__run-demo" id="run-single-element-no-popover">
|
60 |
<pre><code class="javascript">const driver = new Driver();
|
61 |
driver.highlight('#create-post');
|
62 |
</code></pre>
|
@@ -92,7 +92,7 @@ document.getElementById('creation-input')
|
|
92 |
<h4>Highlighting a Single Element β With Popover</h4>
|
93 |
<p>If you would like to show some details alongside the highlighted element, you can do that easily by specifying
|
94 |
title and description</p>
|
95 |
-
<a href="#" class="btn__run-demo" id="run-single-element-with-popover">
|
96 |
<pre><code class="javascript">const driver = new Driver();
|
97 |
driver.highlight({
|
98 |
element: '#some-element',
|
@@ -112,7 +112,7 @@ driver.highlight({
|
|
112 |
<h4>Popover Positioning</h4>
|
113 |
<p>You can also, change the position of the popover to be either <code>left</code>, <code>top</code>,
|
114 |
<code>right</code> or <code>bottom</code>.</p>
|
115 |
-
<a href="#" class="btn__run-demo" id="run-single-element-with-popover-position">
|
116 |
<pre><code class="javascript">const driver = new Driver();
|
117 |
driver.highlight({
|
118 |
element: '#some-element',
|
@@ -123,6 +123,8 @@ driver.highlight({
|
|
123 |
}
|
124 |
});
|
125 |
</code></pre>
|
|
|
|
|
126 |
<div class="top-20 position-btns">
|
127 |
<a href="#" id="position-btn-left">On my Left</a>
|
128 |
<a href="#" id="position-btn-top">On my Top</a>
|
@@ -132,6 +134,151 @@ driver.highlight({
|
|
132 |
<p class="top-20">If you don't specify the position or specify it to be <code>auto</code>, it will automatically
|
133 |
find the suitable position for the popover and show it</p>
|
134 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
</section>
|
136 |
</div>
|
137 |
|
|
|
29 |
<p>Driver is compatible with all the major browsers and can be used for any of your overlay needs. Feature
|
30 |
introductions, focus shifters, call-to-action are just a few examples.</p>
|
31 |
<ul>
|
32 |
+
<li>π <strong>Highlight</strong> any (literally any) item on page</li>
|
33 |
<li>β <strong>Block user interactions</strong></li>
|
34 |
<li>π£ Create <strong>feature introductions</strong></li>
|
35 |
<li>π Add <strong>focus shifters</strong> for users</li>
|
|
|
56 |
<h4>Highlighting a Single Element β Without Popover</h4>
|
57 |
<p class="zero-bottom">If all you want is just highlight a single element, you can do that simply by passing the
|
58 |
selector</p>
|
59 |
+
<a href="#" class="btn__run-demo" id="run-single-element-no-popover">Show Demo</a>
|
60 |
<pre><code class="javascript">const driver = new Driver();
|
61 |
driver.highlight('#create-post');
|
62 |
</code></pre>
|
|
|
92 |
<h4>Highlighting a Single Element β With Popover</h4>
|
93 |
<p>If you would like to show some details alongside the highlighted element, you can do that easily by specifying
|
94 |
title and description</p>
|
95 |
+
<a href="#" class="btn__run-demo" id="run-single-element-with-popover">Show Demo</a>
|
96 |
<pre><code class="javascript">const driver = new Driver();
|
97 |
driver.highlight({
|
98 |
element: '#some-element',
|
|
|
112 |
<h4>Popover Positioning</h4>
|
113 |
<p>You can also, change the position of the popover to be either <code>left</code>, <code>top</code>,
|
114 |
<code>right</code> or <code>bottom</code>.</p>
|
115 |
+
<a href="#" class="btn__run-demo" id="run-single-element-with-popover-position">Show Demo</a>
|
116 |
<pre><code class="javascript">const driver = new Driver();
|
117 |
driver.highlight({
|
118 |
element: '#some-element',
|
|
|
123 |
}
|
124 |
});
|
125 |
</code></pre>
|
126 |
+
</div>
|
127 |
+
<div class="section__example">
|
128 |
<div class="top-20 position-btns">
|
129 |
<a href="#" id="position-btn-left">On my Left</a>
|
130 |
<a href="#" id="position-btn-top">On my Top</a>
|
|
|
134 |
<p class="top-20">If you don't specify the position or specify it to be <code>auto</code>, it will automatically
|
135 |
find the suitable position for the popover and show it</p>
|
136 |
</div>
|
137 |
+
<hr class="hr__fancy">
|
138 |
+
<div id="single-element-with-popover-html" class="section__example">
|
139 |
+
<h4>HTML in Popovers</h4>
|
140 |
+
<p>You can also specify HTML in the body or the title of the popovers. Here is an example:</p>
|
141 |
+
<a href="#" class="btn__run-demo" id="run-single-element-with-popover-html">Show Demo</a>
|
142 |
+
<pre><code class="javascript">const driver = new Driver();
|
143 |
+
driver.highlight({
|
144 |
+
element: '#some-element',
|
145 |
+
popover: {
|
146 |
+
title: '<em>An italicized title</em>',
|
147 |
+
description: 'Description may also contain <strong>HTML</strong>'
|
148 |
+
}
|
149 |
+
});
|
150 |
+
</code></pre>
|
151 |
+
</div>
|
152 |
+
|
153 |
+
<p class="top-20">And of-course it can be any valid HTML.</p>
|
154 |
+
|
155 |
+
<hr class="hr__fancy">
|
156 |
+
|
157 |
+
<div id="third-element-introduction" class="section__example">
|
158 |
+
<h4 id="first-element-introduction">Creating Feature Introductions</h4>
|
159 |
+
<p id="second-para-feature-introductions">You can also make powerful feature introductions to guide the users
|
160 |
+
about the features. Just provide an array of steps where each step specifies an element to highlight.</p>
|
161 |
+
<p id="third-para-feature-introductions">Below is just a quick example showing you how to combine the steps in
|
162 |
+
introduction.</p>
|
163 |
+
<a href="#" class="btn__run-demo" id="run-multi-element-popovers">Show Demo</a>
|
164 |
+
</div>
|
165 |
+
<pre><code class="javascript">const driver = new Driver();
|
166 |
+
// Define the steps for introduction
|
167 |
+
driver.defineSteps([
|
168 |
+
{
|
169 |
+
element: '#first-element-introduction',
|
170 |
+
popover: {
|
171 |
+
title: 'Title on Popover',
|
172 |
+
description: 'Body of the popover',
|
173 |
+
position: 'left'
|
174 |
+
}
|
175 |
+
},
|
176 |
+
{
|
177 |
+
element: '#second-element-introduction',
|
178 |
+
popover: {
|
179 |
+
title: 'Title on Popover',
|
180 |
+
description: 'Body of the popover',
|
181 |
+
position: 'top'
|
182 |
+
}
|
183 |
+
},
|
184 |
+
{
|
185 |
+
element: '#third-element-introduction',
|
186 |
+
popover: {
|
187 |
+
title: 'Title on Popover',
|
188 |
+
description: 'Body of the popover',
|
189 |
+
position: 'right'
|
190 |
+
}
|
191 |
+
},
|
192 |
+
]);
|
193 |
+
// Start the introduction
|
194 |
+
driver.start();
|
195 |
+
</code></pre>
|
196 |
+
<p class="top-20">This is just a quick example for the feature introduction. For a richer one, please have a look at
|
197 |
+
the
|
198 |
+
<a href="#" class="btn__example">"Quick Tour"</a></p>
|
199 |
+
|
200 |
+
<p>You may also turn off the footer buttons in popover, in which case user can control the popover using the arrows
|
201 |
+
keys on keyboard. Or you may control it using the methods provided by Driver.</p>
|
202 |
+
|
203 |
+
<hr class="hr__fancy">
|
204 |
+
|
205 |
+
<div id="element-without-popover" class="section__example">
|
206 |
+
<h4>Without Overlay</h4>
|
207 |
+
<p>You can create feature introductions and do everything listed above without overlays also. All you have to do is just set the opacity to `0`.</p>
|
208 |
+
<a href="#" class="btn__run-demo" id="run-element-without-popover">Show Demo</a>
|
209 |
+
<pre><code class="javascript">const driver = new Driver({
|
210 |
+
opacity: 0,
|
211 |
+
});
|
212 |
+
|
213 |
+
driver.highlight({
|
214 |
+
element: '#run-element-without-popover',
|
215 |
+
popover: {
|
216 |
+
title: 'Title for the Popover',
|
217 |
+
description: 'Description for it',
|
218 |
+
position: 'top', // can be `top`, `left`, `right`, `bottom`
|
219 |
+
}
|
220 |
+
});
|
221 |
+
</code></pre>
|
222 |
+
<p class="top-20">..and you can do the same for the feature introductions</p>
|
223 |
+
</div>
|
224 |
+
|
225 |
+
<hr class="hr__fancy">
|
226 |
+
|
227 |
+
<div class="section__example">
|
228 |
+
<h3>..and much much more</h3>
|
229 |
+
<p>Driver comes with many options that you can manipulate to make driver behave as you may like</p>
|
230 |
+
<h4>Driver Definition</h4>
|
231 |
+
<p>Here are the options that Driver understands</p>
|
232 |
+
<pre><code class="javascript">const driver = new Driver({
|
233 |
+
animate: true, // Animate while changing highlighted element
|
234 |
+
opacity: 0.75, // Background opacity (0 means only popovers and without overlay)
|
235 |
+
padding: 10, // Distance of element from around the edges
|
236 |
+
onHighlightStarted: (Element) {}, // Called when element is about to be highlighted
|
237 |
+
onHighlighted: (Element) {}, // Called when element is fully highlighted
|
238 |
+
onDeselected: (Element) {}, // Called when element has been deselected
|
239 |
+
});
|
240 |
+
</code></pre>
|
241 |
+
</div>
|
242 |
+
<div class="section__example">
|
243 |
+
<h4>Step Definition</h4>
|
244 |
+
<p>Here are the set of options that you can pass in each step i.e. an item in array of steps or the object that you pass to <code>highlight</code> method</p>
|
245 |
+
<pre><code class="javascript">const stepDefinition = {
|
246 |
+
element: '#some-item', // Query selector for the item to be highlighted
|
247 |
+
popover: { // There will be no popover if empty or not given
|
248 |
+
title: 'Title', // Title on the popover
|
249 |
+
description: 'Description', // Body of the popover
|
250 |
+
showButtons: false, // Do not show control buttons in footer
|
251 |
+
doneBtnText: 'Done', // Text on the last button
|
252 |
+
closeBtnText: 'Close', // Text on the close button
|
253 |
+
nextBtnText: 'Next', // Next button text
|
254 |
+
prevBtnText: 'Previous', // Previous button text
|
255 |
+
}
|
256 |
+
};
|
257 |
+
</code></pre>
|
258 |
+
</div>
|
259 |
+
<div class="section__example">
|
260 |
+
<h4>API Methods</h4>
|
261 |
+
<p>Below are the set of methods that are available to you</p>
|
262 |
+
<pre><code class="javascript">const driver = new Driver(driverOptions);
|
263 |
+
|
264 |
+
const isActivated = driver.isActivated; // Checks if the driver is active or not
|
265 |
+
driver.moveNext(); // Moves to next step in the steps list
|
266 |
+
driver.movePrevious(); // Moves to previous step in the steps list
|
267 |
+
driver.start(stepNumber = 0); // Starts driving through the defined steps
|
268 |
+
driver.highlight(string|stepDefinition); // highlights the element using query selector or the step definition
|
269 |
+
driver.reset(); // Resets the overlay and clears the screen
|
270 |
+
driver.hasHighlightedElement(); // Checks if there is any highlighted element
|
271 |
+
driver.hasNextStep(); // Checks if there is next step to move to
|
272 |
+
driver.hasPreviousStep(); // Checks if there is previous step to move to
|
273 |
+
|
274 |
+
// Gets the currently highlighted element on screen
|
275 |
+
const activeElement = driver.getHighlightedElement();
|
276 |
+
const lastActiveElement = driver.getLastHighlightedElement();
|
277 |
+
activeElement.getScreenCoordinates(); // Gets screen co-ordinates of the active element
|
278 |
+
activeElement.hidePopover(); // Hide the popover
|
279 |
+
activeElement.showPopover(); // Show the popover
|
280 |
+
</code></pre>
|
281 |
+
</div>
|
282 |
</section>
|
283 |
</div>
|
284 |
|