stori.js

Create decision trees, gamebooks, pathfinders, presentations, photo slide shows, and other multiple path tools easily using stori and jQuery.

Get Started
Unsplashed background img 1

star

Features
  • check Unlimited pages, paths, and choices: Create as many pages as you want.
  • check Minimal markup: Don't add bloat to your HTML.
  • check No loading spinners: All content is available at page load.
  • check "Back", "Forward", and "Restart" buttons: Auto-adds buttons to go back one step, or restart from the beginning.
  • check Linear mode: For presentations, slide shows, other linear content. With automatic drop-down navigation.
  • check User history: User's position & history can be saved per session or forever, so they can close and resume later.
  • check Small footprint: Minified JavaScript file ~= 8k

file_download

Download

v0.8.0

Download stori.zipfile_download

The stori.zip file above includes the following files:

Or get stori via Github.com/dhewer/stori.

Follow the installation & setup instructions in the docs to get going.

stori logo

"Oh, yeah, that's cool I guess."

– Some guy

Unsplashed background img 2
DEMO #1: Customer patherfinder demo

Which package of SoftTechWareInc's amazing App is right for you?

Use the decision helper tool below to find the best package for you!

The number of employees at my company is:

1: Just me (self-employed)

2-100: Two to one hundred employees

100+: Over one hundred employees

Where do you most often use our App?

Choose the location you most frequently use the app:

PC/Mac desktop computer

Mobile device; phone or tablet

check Thank you!

Based on your responses, the best package for you is:

$39.99 APP ENTRY LEVEL

shopping_cart Buy now Back to the beginning

check Thank you!

Based on your responses, the best package for you is:

$59.99 APP DESKTOP+MOBILE PACKAGE

shopping_cart Buy now Back to the beginning

Is your company a registered non-profit?

Non-profit entities are eligible for a discount:

Yes, we are a non-profit

No, we are not a non-profit

check Thank you!

Based on your responses, the best package for you is:

$29.99 ENTERPRISE NON-PROFIT PACKAGE

shopping_cart Buy now Back to the beginning

check Thank you!

Based on your responses, the best package for you is:

$199.99 ENTERPRISE PACKAGE

shopping_cart Buy now Back to the beginning

check Thank you!

Please call us by phone or contact us at the email address below and we will discuss your company's needs and provide you with our best price! Thank you!

1-888-BUY-APPS

info@softtechwareinc.net

Back to the beginning

  • code View code

DEMO #2: Choose-your-own-adventure demo

This one remembers your history ("forever" via localStorage) if you reload the page.

You're a treasure hunter who has heard that there may be treasure hidden on the Mountain of Plentiful Treasure. As you climb the mountain, you notice the path forks off in two directions. There is a path which winds further up the mountain. A second path heads downwards into a cave. You also notice an animal digging in the dirt nearby.

MAKE YOUR CHOICE:

Go up the path - Climb further up the mountain

Go down towards the cave - Climb down and enter the cave

Go towards the animal - See what the animal is doing

You continue to climb further up the mountain. Suddenly, you hear a mighty rumble from above! It could be that an avalanche is headed your way!

MAKE YOUR CHOICE:

Go back down - Head back where you came from

Keep going - It's probably nothing ...

Not heeding the obvious imminent danger, you continue forward, only to be crushed by a multitude of rocks.

☹ You are dead.

Restart - Go back to the beginning

As you enter the cave, you are confronted by a large, less-than-happy looking bear.

MAKE YOUR CHOICE:

Fight the bear - With your pocket knife

Play dead - Maybe it'll lose interest ...

Your attack with the pocket knife seems ill-advised, but it's surprisingly effective, and the bear retreats further into the cave. Nearby you find a treasure chest, and inside is a ruby the size of a chihuahua's head.

☺ You win!

Restart - Go back to the beginning

The enraged bear is not fooled by your ruse. You are quickly mauled and eaten.

☹ You are dead. Like, not just playing dead. Actually dead. Dead-dead.

Restart - Go back to the beginning

The animal appears to be a large rodent of some sort. It seems to be trying to bury a large object in the ground.

MAKE YOUR CHOICE:

Grab the object - It might be valuable

Bargain with the rodent - Perhaps it's open to negotiation

The rodent doesn't take too kindly to your meddling; it goes for the throat, and is super effective!

☹ You are dead.

Restart - Go back to the beginning

Your superior intellect and negotiation skills overpower the rodent, and it eventually yields its prize to you: A shiny gold nugget!

☺ You win!

Restart - Go back to the beginning

  • code View code

DEMO #3: Linear slideshow / presentation example

This one is 'linear' type which makes all pages available via forward / back from the beginning and proceeds linearly. There is no need for you to create additional navigation or to put ID's on all the pages.

Slide 1: A photo
Slide 2: No need for ID's for linear type
Slide 3: Back and forward can be used for nav
  • code View code

stori logo

Your creation is limited only by your creativity

(And technical constraints ... and time ... and skills ...)

See below for instructions on how to get started

Unsplashed background img 3

Documentation

Installation & Setup

1) Download and include the necessary js and css files.
Include the css file inside the <head> tags:
<link href="stori.css" rel="stylesheet" media="screen,projection">
And the js files at the bottom of your body (or wherever, just include jQuery first):
<script src="jquery-2.1.1.min.js"></script>
<script src="stori.min.js"></script>

2) Set up your stori element and pages.

Your base/root element must contain a unique id. Each of your pages should be a direct child of the parent (root) element. Each page also requires a unique id, except if you are using the "linear" mode (see below).

Normal (branching) storis: (See demos #1 and #2 above.)

                            
<div id="mything">
<div id="coverpage"> ... </div>
<div id="page1"> ... </div>
<div id="page2"> ... </div>
<div id="lastpage"> ... </div>
</div>

Linear (sequential) storis: These proceed from first to last, all pages are available from the beginning, and the user can jump to any page via the dropbox box. (See demo #3 above.) Make sure to set the "linear" option when initializing (see options section below).

                            
<div id="mything">
<div> ... </div>
<div> ... </div>
<div> ... </div>
<div> ... </div>
</div>

Use normal links like <a href="#page1">Go to page 1</a> to link between pages.

You can also use the data-page attribute on any element, and when clicked, stori will go to that page, ex: <div data-page="page1">Go to page 1</div>

See the code for the examples above for more information.


3) Initialize stori on your base element, ex:
<script> var s1 = $('#thing').stori().data('stori'); </script>
Adding .data('stori') to the end enables you to easily use stori's methods (see below).
Include the "linear" option to use the linear / sequential behavior. You can also include numerous other options to customize sorti's behavior. (See below)


Options

Include these options when intitializing your stori, like this:

                            <script> var s1 = $('#thing').stori({
                            
transition: 'none',
buttonForward: false
}).data('stori'); </script>

Option Default Valid values Description
buttonBack true true / false Displays or hides the back button in the controls. (true = show, false = hide)
buttonBackHtml <button class="stori-button stori-back" title="Back"></button> String containing HTML Replaces the default back button in the controls with HTML of your choice.
buttonForward true true / false Displays or hides the forward button in the controls. (true = show, false = hide)
buttonForwardHtml <button class="stori-button stori-forward" title="Forward"></button> String containing HTML Replaces the default forward button in the controls with HTML of your choice.
buttonRestart true true / false Displays or hides the restart button in the controls. (true = show, false = hide)
buttonRestartHtml <button class="stori-button stori-restart" title="Restart"></button> String containing HTML Replaces the default restart button in the controls with HTML of your choice.
controls 'top' 'top'
'bottom'
'both'
'none'
Positions the controls on top, bottom, both, or none (hidden).
controlsHtml false String containing HTML Replaces the default controls with HTML of your choice. Note that this will override any custom button options (see above).
debug true true / false Logs warnings and errors to the console. Set to false to disable console warnings / errors.
focus true true / false On page change, sets focus to first "focusable" element on the page. Set to false to disable automatic focus setting. (Note that it will not set focus on first load of the page; otherwise the view would be dragged down to the stori element whenever the page first loads. If necessary you can use the HTML attribute 'autofocus' to manually set the focus upon first loading.)
Option Default Valid values Description
history 'clear' 'keep'
'session'
'clear'
Determines whether the user's position is remembered after they leave the page:
'clear' - User's history is cleared when they leave the page.
'keep' - User's history is retained via localStorage (ie, "forever") in the browser.
'session' - User's history is retained via sessionStorage (ie, until they close the browser window)
linear false true / false Changes stori behavior to linear / sequential style. If set to true, all pages will be available from the outset, and the user can step through the pages in order using the back/forward buttons. This style is appropraite for things like a presentation, photo slideshow, book that is read front to back, etc.
Note: Do not put id's on pages when setting linear to true; stori will automatically replace them with its own ids.
linearDropdown true true / false Adds a select box to allow the user to select which page to view. This is displayed in the controls. This setting only has effect if both linear and controls options are on. Add page titles to pages by adding the title attribute to the page, ex:
<div title="Sales forecast for 2018">...</div>
start false Page id Initial starting page. By default, the first page (element) in your root element will be the starting page. To specify a different start page, specify its id here.
transition 'fade' 'fade'
'slide'
'none'
Specifies the type of transition when changing pages. This uses jQuery fade/slide transitions, or changes pages immediately if 'none' is specified. ('fade' or 'none' are recommended; 'slide' seems buggy under some circumstances.)
transitionSpeed 250 Integer (milliseconds) The number of milliseconds that page transitions take. (Ignored if transition is set to 'none'.)
warn false true / false Confirm the user wants to leave the page and lose their progress. (If set to true, only pops if 'history' is set to 'clear' or 'session' since 'keep' would not be cleared.)


Built-in classes

Include these classes on elements to control / trigger stori's behavior:

Class Name Description
.stori-ignore Causes stori to ignore the element. It will ignore any anchor link and/or data-page attribute, and if this class is added to one of the children of your root, that element will be ignored when processing pages. So for example you can add your own elements to the bottom or top of your stori and then add .stori-ignore to them so that they won't be processed like the other pages.
.stori-back Clicks on the element will trigger page back action.
.stori-forward Clicks on the element will trigger page forward action.
.stori-restart Clicks on the element will trigger page restart action.


Methods

All of stori's own methods are available after initialization. Call them like this (this would move the user one page back in their history):

                            <script>
var s1 = $('#thing').stori().data('stori');
s1.pageBack();
</script>

For example, if you wanted to add swipe touch controls using another library like hammer.js or jQuery Mobile or something else, you could call s1.pageBack() when the swipe left is detected on the root stori element.

Refer to the JSDoc for the functions in the unminified stori.js file for information on the available methods.

License

stori by Darren Hewer is licensed under the
MIT License

If you use stori, please include an attribution somewhere. Thanks!

Unsplashed background img 1