-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathtorturial.jquery.txt
63 lines (60 loc) · 5.73 KB
/
torturial.jquery.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
┏━━━━━━━━━━━━━━━┓
┃ TORTURIAL ┃
┗━━━━━━━━━━━━━━━┛
VERSION ==> #0.1.0
JQ.torturial(OBJ_ARR, OBJ2) #Registers a tutorial (but doesn't open it) :
# - divided in "view", which can switched with UI or keyboard arrows
# - each "view" can change from "step" to the other (through delay or event)
# - tutorial can be escaped by Esc, finishing it or clicking the close button.
#JQ is an empty DIV, which will contain the tutorial objects (popups, overlay,
#etc.)
#Link to the CSS file too.
#Réinitialise à chaque fois.
#OBJ are a "view", with members :
# - title STR, a displayed title for the "view" (déf: undefined)
# - steps OBJ3_ARR, each "step", with members :
# - popovers OBJ4_ARR, a popup, with members :
# - id STR: DOM id of the element (déf: undefined)
# - text STR : HTML content
# - attachTo JQ : element to which popup is attached
# - attachPos STR, among "left", "right" (déf), "top", "bottom"
# - position [ UINT, UINT2 ] : display:absolute position (left and top)
# (can't use attachTo in the same time)
# - delay NUM : before changing "step" or (if final "step"), "view" (in ms)
# (déf: null). Can't be on final "step" and final "view"
# - changeOn [ STR, STR2[, OBJ][, FUNC] ] : event changing the "step".
# - STR is the event
# - STR2 the selector of the object
# - OBJ is data passed to JQEVENT
# - FUNC is event handler (return false to cancel step changing)
# - foreground JQ : highlighted element
#OBJ2 are (can be empty) :
# - startingView : index of the first "view" (déf: 0)
# - startingStep : index of the first "step" (déf: 0)
#CSS :
# - .torturial : the container (JQ)
# - #torturial-background : the overlay
# - #torturial-close : the close button
# - #torturial-title : the title
# - .torturial-popover : popups, each with id according to "id"
# - .torturial-popover-arrow-left|right|top|bottom : part of the popup
# - .torturial-popover-text : content of the popup
# - .torturial-attach : elements to which attachTo.
# - .torturial-foreground : elements to which foreground.
# - .torturial-right|left|top|bottom-arrow : arrow to switch "views"
# - .torturial-selector : selector on bottom to switch "views"
# - .selector-element : little circles
# - .selected-element : active little circle
# Those two can fuck up the layout because of css rule
# "position: relative !important", which can be hacked without "!important"
# in the CSS file to solve the problem.
JQ2.torturial("show|hide") #JQ2 is the JQ returned by the JQ.torturial(...) initialization
#function. (not the first JQ, even though it looks the same)
JQ2.torturial("destroy") #Triggers a "hide" first. Same thing for
JQ.on("torturial:EVENT") #Event possibles :
# - initialized : when ready (never seem to fire)
# - show|viewopened|stepopened : when starting the tutorial, a "view", or a
# "step"
# - hide : when finishing all
# - destroy : same as hide, but also when invoking torturial("destroy")
# - timedout : with "delay" has passed