A library for creating in-situ guided tours, help interfaces and onboarding flows for your web app. No dependencies needed.
Orient is a Javascript library for creating in-situ guided tours, help interfaces and onboarding flows for your web app. No dependencies needed.
Orient has been tested in Chrome 75, Firefox 67, Internet Explorer 11, Edge 44, and Chrome Android 75.
Orient can easily be integrated into a page:
/dist
into your project. The JS file is the main Orient script, and the CSS file is the theming.</body>
tag referencing the orient file, wherever it has been placed, e.g. <script src="/js/orient.min.js"></script>
.<head>
of the page <link rel="stylesheet" type="text/css" href="/css/default.css">
.FlowFile: A FlowFile is a JSON file with a particular syntax, which defines a Flow and its constituent slides. See FlowFiles below to read more.
Flow: A flow is an ordered series of slides. The user can move either to the next or previous slide in a flow when they are interacting with Orient.
Slide: An individual element which helps describe something on your website or application. A slide is made up of a title, text and even media (images or video). A slide also has a style - which specifies how the slide is displayed on the page.
As described above, a Flow is a series of slides, and a FlowFile is a JSON file that defines a Flow and its constituent slides.
FlowFiles are a key component of Orient and, at their core are a simple JSON file with an array of objects. Each object in the array represents a slide, and the index of each array item represents the order of the slides. From here, it’s probably best to just show an example of a FlowFile:
[
{
"title": "Welcome to Orient",
"media": {
"type": "image",
"url": "media/slide1.jpg"
},
"body": "Orient is a JS library for easily creating in-situ guided tours, help systems and onboarding flows. You're currently seeing the first slide of an Orient Flow!",
"style": "modal",
"onShow": "console.log('Runs when the slide is shown')"
},
{
"title": "Easy to Create Flows",
"media": {
"type": "video",
"url": "media/slide2.mp4"
},
"body": "Define flows in simple external JSON files or even an API endpoint. Flows are made up of multiple slides, just like this one.",
"style": "float",
"target": "#main-title"
},
...
]
This is actually the start of the FlowFile used in the /examples
directory, so if you view the demo, you can see exactly how it works. The full FlowFile is located at /examples/flows/demo.json
.
As a minimum, each slide requires a title
, body
and style
property. If the style
is “float”, then the target
property is also required. See the FlowFile Syntax Reference below for a full list of properties and their potential values.
If you’ve come here from the Quick Start and have created a FlowFile, the next step is starting a flow.
The FlowFile should be in JSON format and accessible by the client from the website via an AJAX request. The FlowFile should contain an array as the outermost element, and should contain objects immediately inside that array. You can always view the demo FlowFile which is located at /examples/flows/demo.json
.
Each object represents a slide and can contain a variety of properties, which are detailed below.
#some_id
or .this-class-right-here
. If the string does not start with a #
or a .
then it is assumed that the user is attempting to target an element by its data-orient-target
attribute.<script>
tag inside the slide HTML on the page and is run automatically when the slide is shown. WARNING: this allows HTML to be injected directly into the page.new Function
call inside its own anonymous self-executing function when a slide is removed from the page.Once Orient is correctly included the page and a FlowFile has been created, you can initialise Orient and start a flow.
Initialising Orient is simple. Just make sure that you call it after the Orient script tag, and after the page has loaded. Instantiation looks something like this:
var orient = new Orient({
flowURL: '/examples/flows/demo.json',
keyEvents: true,
clickOverlayClosesTour: true
});
The Orient constructor accepts a number of options which are documented in src/orient.js
.
Starting a flow looks like this (assuming you’ve used the variable name orient
):
orient.loadFlow(function () {
orient.startFlow();
});
orient.loadFlow()
makes the request to get the FlowFile, and accepts a callback function as an argument. Most commonly you will want to start the flow here with orient.startFlow()
.
That’s it! If you want to load and start the flow at another point, for example when a button is clicked, just move it into the event handler.
var button = document.querySelector('#example-button');
button.addEventListener('click', function() {
orient.loadFlow(function () {
orient.startFlow();
});
});
There are three ways to customise the styling of Orient. The first two are global style changes and will allow you to change the style of all of the common elements of Orient. If desired, you can also style individual slides - see the third option for this.
/src/default.css
into /src
and modify it. Run gulp to build and minify it. Link to this CSS file in your page instead of default.css
.cssPrefix
property to the Orient constructor. The wrapping <div>
will contain this custom class which you can now target with new CSS rules in any stylesheet. See the /examples/index.html
and /examples/styles.css
files for an example.classList
property to the slide in the FlowFile. The classList should be an array of strings, see the FlowFile Syntax Reference for details or the last slide in the demo FlowFile /examples/flows/demo.json
for an example.The main source files are in /src
, modify these files and then run gulp watch
to watch, minify and copy them into the /dist
directory. To run gulp, you will need to run npm install
from within the project folder.
Note: the minification/uglification step in the gulp build and watch tasks also remove any console.logs and other console.* functions. The non-minified versions of the files will retain these console.* function calls.
If you want to use multiple flows on a page, you can either create a new Orient instance, as detailed in Starting a Flow or you can re-use the same instance and simply change the flowURL. Ensure that any flows currently being run from that instance have been stopped - as running loadFlow
will stop and reset that instance of Orient.
orient.setFlowURL('/flows/new_flow_file.json');
orient.loadFlow(function () {
orient.startFlow();
});
MIT