• Stars
    star
    4,994
  • Rank 8,327 (Top 0.2 %)
  • Language
    JavaScript
  • License
    Other
  • Created over 11 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple overlay instructions for your apps.

Chardin.js

Simple overlay instructions for your apps.

Check out a demo.

Or demo sequential stepping.

Chardin.js is a jQuery plugin that creates a simple overlay to display instructions on existent elements. It is inspired by the recent Gmail new composer tour which I loved.

chardin
Jean-Baptiste-Simรฉon Chardin

Installing

Simple! Fork this repo or download chardinjs.css and chardinjs.min.js and add the following assets to your HTML:

<link href="chardinjs.css" rel="stylesheet">
<script src="chardinjs.min.js"></script>

There's a chardinjs-rails gem.

Adding data for the instructions

Add the instructions to your elements:

data-intro: Text to show with the instructions/tooltip. data-position: (left, top, right, bottom), where to place the text with respect to the element. In addition you can alter the relative position of the tooltip text by placing a colon and a percentage value (-100 to 100) after the position text, eg "top:-50". This will slide the tooltip along the length or height of the element away from the centre. If you want to increae the distance of the tooltip from the element, you can do it by placing a comma and a percentage value (100, 200, 300, 400 or 500) after the tooltip offset, eg "top:0,200". This will shift the tooltip to be twice farther away from the element than by default.

<img src="img/chardin.png" data-intro="An awesome 18th-century painter, who found beauty in everyday, common things." data-position="right" />

You can also run Chardin in sequenced mode, where one element will be displayed at a time, moving on to the next with a mouse click (or automatically after a set delay). Add data-chardin-sequenced="true" entry to the body tag. Also add data-chardin-auto="true" and data-chardin-delay="100" for automatic movement through the elements. Delay is in milliseconds. The default sequence is as loaded by the DOM, but this can be overridden using the tag data-sequence with a number. If no auto-traversal is set, clicking will move sequentially through the elements, clicking with the shift key down will move backwards through them.

<body data-chardin-sequenced="true" data-chardin-auto="false" data-chardin-delay="800" >

Running

Once you have your elements ready, initialise the library and assign it to a button that the user will click to show the overlay. The library will store an initialised object to the containing element's data set so you can start and stop it with whatever options you set.

$('body').chardinJs();
$('body').on('click', 'button[data-toggle="chardinjs"]', function (e) {
    e.preventDefault();
    return ($('body').data('chardinJs')).toggle();
});

You can run it explicitly like so:

$('body').chardinJs('start')

If you would rather run ChardinJs confined to a particular container (instead of using the whole document) you can change body to some other selector.

$('.container').chardinJs('start')

You may also refresh instructions overlay any time to reflect whatever changes happened to the underlying page elements since the instructions overlay has been displayed.

var chardinOverlay = $('body').chardinJs('start');
...
chardinOverlay.refresh();

Options

The chardinJS constructor can take several options, eg:

$('body').chardinJs({ url: "/help/HelpOverlay.json" });

Options are:

  • url: specifies a url that returns a json object containing text to show. This is useful to dynamically change the overlay, or to hold all your overlay text in one external file. The json file should contain a set of name-value pairs, the name will match the data-intro attribute if it begins with a '#'. The value contains the required text and an optional position. For conflicts between the data attributes and the json entries, the attribute takes precedence.

Example:

{
    "#summary-btns": {
        "text": "buttons to interact with the displayed summary",
        "position": "left"
    },
    "#search-btn": { 
        "text": "expand this to filter the list of profiles" 
    }
}

This text will be shown against an element that has data-intro='#summary-btns'. If the data-intro does not start with a #, then the value will be used as the text to display. If no entry is present for a given element's data reference, then nothing will be displayed.

  • attribute: changes the data attribute from data-intro to data-. Example:
$('body').chardinJs({ attribute: 'data-intro' });

Methods

.chardinJs('start')

Start ChardinJs in the selector.

.chardinJs('toggle')

Toggle ChardinJs.

.chardinJs('stop')

Make your best guess. That's right! Stops ChardinJs in the selector.

Events

'chardinJs:start'

Triggered when chardinJs is correctly started.

'chardinJs:stop'

Triggered when chardinJs is stopped.

'chardinJs:next'

Triggered when the sequential option moves to the next element

'chardinJs:previous'

Triggered when the sequential option moves to the previous element

Author

Pablo Fernandez

Contributors

Contributions

If you want to contribute, please:

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add yourself to the list of contributors in the README.md.
  • Send me a pull request on Github.

License

Copyright 2020 Pablo Fernandez

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

More Repositories

1

intro.js-rails

Integrate the awesome intro.js javascript library in your Rails asset pipeline
Ruby
106
star
2

nostr-chat-widget

Nostr-based embeddable chat widget
JavaScript
33
star
3

nostr-data-vending-machine

Nostr data vending machine example
TypeScript
25
star
4

chardin.js-rails

Rails support for Chardin.js
Ruby
23
star
5

frisky

A playful scm platform for MSR (mining software repositories)
Ruby
18
star
6

zapworthy-extension

zapworthy-extension
JavaScript
17
star
7

highlighter-archive

highlighter-archive
JavaScript
16
star
8

wiki

Svelte
13
star
9

collab

A collaborative editing experiment
Svelte
8
star
10

highlighter

Highlighter.com repo
Svelte
8
star
11

nostr-pingstr

pingstr bot
JavaScript
7
star
12

bitcoin-book

Makefile
7
star
13

vendata.io

Vendata
Svelte
6
star
14

nsecbunker-dev-docs

tailwindui-commit
JavaScript
6
star
15

nutsack

Svelte
5
star
16

highlighter-chrome-extension

Highlighter.com Chrome extension
TypeScript
5
star
17

ananostr

๐Ÿ on the blockchain
Svelte
4
star
18

dvm-references

reference implementation of a DVM (Data Vending Machine) backend
TypeScript
3
star
19

nostr-npub

Simple package to search for an npub locally
JavaScript
3
star
20

bitcoinknives

Get sats out of weak hands
Ruby
3
star
21

omniauth-lightning

OmniAuth strategy for Lightning Network
Ruby
2
star
22

class-proxy

A generic (ActiveRecord compatible) class proxy to setup proxy methods for your classes
Ruby
1
star
23

cronosII-scratch

Vintage mail user agent... from back in the day, the 0.3 version which was in a different repo
C
1
star
24

running

A repo to track my running training, goals and thoughts
1
star
25

dvdondemand

Ruby
1
star
26

happiness

Ruby
1
star
27

easy-nostr

Batteries-included Nostr client library
TypeScript
1
star
28

oh-my-zsh-bitcoin-cli

Oh my zsh plugin for bitcoin-cli
Shell
1
star
29

quoinex

Ruby
1
star
30

exit

EXIT.pub
Svelte
1
star
31

pablof7z.com

Personal website
1
star
32

cartogitphy

Cartography on Git
Ruby
1
star
33

therocktrading

Ruby
1
star
34

data-vending-machines

HTML
1
star
35

mongomapper-sublime-text2-snippets

Snippets for MongoMapper
1
star
36

psbt.io

psbt.io
Svelte
1
star
37

cronosII

Vintage mail user agent... from back in the day
C
1
star
38

sublime-text2-ruby-ddd

Miss ddd? Who wouldn't! IRB debugging through Sublime text2
1
star
39

dotfiles

Shell
1
star
40

gotnostr

gotnostr.com
Svelte
1
star
41

feeling-frisky

An insatiable frisky classifier / Skeleton classifier for frisky stream data mining
Ruby
1
star
42

david-firmware

Code for a screencast for my friend david
1
star
43

evode

See an app come to live in front of your eyes!
Ruby
1
star
44

servp-control-panel

Old server protectors repository -- Importing to keep as archive -- 3 years old ruby on rails app
Ruby
1
star