typed.js 2.0.12 → 2.0.132
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +1 -1
- package/README.md +31 -21
- package/dist/typed.cjs +2 -0
- package/dist/typed.cjs.map +1 -0
- package/dist/typed.module.js +2 -0
- package/dist/typed.module.js.map +1 -0
- package/dist/typed.umd.js +3 -0
- package/dist/typed.umd.js.map +1 -0
- package/index.d.ts +131 -134
- package/package.json +21 -28
- package/.codeclimate.yml +0 -31
- package/.csslintrc +0 -2
- package/.esdoc.json +0 -4
- package/.eslintignore +0 -3
- package/.eslintrc.yml +0 -25
- package/.github/CONTRIBUTING.md +0 -44
- package/.github/ISSUE_TEMPLATE.md +0 -27
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -38
- package/.prettierrc +0 -4
- package/.travis.yml +0 -16
- package/.vscode/launch.json +0 -14
- package/.vscode/settings.json +0 -11
- package/CODE_OF_CONDUCT.md +0 -46
- package/app.js +0 -12
- package/assets/demos.css +0 -61
- package/assets/demos.js +0 -133
- package/bower.json +0 -11
- package/docs/API.md +0 -231
- package/docs/assets/anchor.js +0 -197
- package/docs/assets/bass-addons.css +0 -12
- package/docs/assets/bass.css +0 -543
- package/docs/assets/fonts/EOT/SourceCodePro-Bold.eot +0 -0
- package/docs/assets/fonts/EOT/SourceCodePro-Regular.eot +0 -0
- package/docs/assets/fonts/LICENSE.txt +0 -93
- package/docs/assets/fonts/OTF/SourceCodePro-Bold.otf +0 -0
- package/docs/assets/fonts/OTF/SourceCodePro-Regular.otf +0 -0
- package/docs/assets/fonts/TTF/SourceCodePro-Bold.ttf +0 -0
- package/docs/assets/fonts/TTF/SourceCodePro-Regular.ttf +0 -0
- package/docs/assets/fonts/WOFF/OTF/SourceCodePro-Bold.otf.woff +0 -0
- package/docs/assets/fonts/WOFF/OTF/SourceCodePro-Regular.otf.woff +0 -0
- package/docs/assets/fonts/WOFF/TTF/SourceCodePro-Bold.ttf.woff +0 -0
- package/docs/assets/fonts/WOFF/TTF/SourceCodePro-Regular.ttf.woff +0 -0
- package/docs/assets/fonts/WOFF2/OTF/SourceCodePro-Bold.otf.woff2 +0 -0
- package/docs/assets/fonts/WOFF2/OTF/SourceCodePro-Regular.otf.woff2 +0 -0
- package/docs/assets/fonts/WOFF2/TTF/SourceCodePro-Bold.ttf.woff2 +0 -0
- package/docs/assets/fonts/WOFF2/TTF/SourceCodePro-Regular.ttf.woff2 +0 -0
- package/docs/assets/fonts/source-code-pro.css +0 -23
- package/docs/assets/github.css +0 -123
- package/docs/assets/site.js +0 -108
- package/docs/assets/style.css +0 -136
- package/docs/index.html +0 -2187
- package/gulpfile.js +0 -95
- package/index.html +0 -184
- package/lib/typed.js +0 -1052
- package/lib/typed.min.js +0 -11
- package/lib/typed.min.js.map +0 -1
- package/logo-cropped.png +0 -0
- package/logo.png +0 -0
- package/src/defaults.js +0 -164
- package/src/html-parser.js +0 -67
- package/src/initializer.js +0 -207
- package/src/typed.js +0 -433
- package/webpack.config.js +0 -45
package/assets/demos.css
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
@import url(https://fonts.googleapis.com/css?family=Ubuntu:400,500);
|
|
2
|
-
|
|
3
|
-
*{
|
|
4
|
-
padding:0;
|
|
5
|
-
margin:0;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
body{
|
|
9
|
-
font-family: "Ubuntu", sans-serif;
|
|
10
|
-
font-size: 100%;
|
|
11
|
-
background:#f8f8f8;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
a{
|
|
15
|
-
text-decoration: none;
|
|
16
|
-
color:#666;
|
|
17
|
-
}
|
|
18
|
-
a:hover{
|
|
19
|
-
color:#999;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
button {
|
|
23
|
-
padding: 10px;
|
|
24
|
-
border-radius: 3px;
|
|
25
|
-
background: #E0E0E0;
|
|
26
|
-
border: #CCC 1px solid;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
p{
|
|
30
|
-
line-height: 2em;
|
|
31
|
-
margin:0 0 20px;
|
|
32
|
-
text-align: center;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
hr{
|
|
36
|
-
border: 0;
|
|
37
|
-
border-bottom: #CCC 2px solid;
|
|
38
|
-
margin: 30px auto;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.title{
|
|
42
|
-
font-size: 4em;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.wrap{
|
|
46
|
-
max-width: 600px;
|
|
47
|
-
margin:50px auto;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.type-wrap{
|
|
51
|
-
margin:10px auto;
|
|
52
|
-
padding:20px;
|
|
53
|
-
background:#f0f0f0;
|
|
54
|
-
border-radius:5px;
|
|
55
|
-
border:#CCC 1px solid;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.links{
|
|
59
|
-
margin:20px 0;
|
|
60
|
-
font-size: 0.75em;
|
|
61
|
-
}
|
package/assets/demos.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
document.addEventListener('DOMContentLoaded', function() {
|
|
2
|
-
var typed = new Typed('#typed', {
|
|
3
|
-
stringsElement: '#typed-strings',
|
|
4
|
-
typeSpeed: 20,
|
|
5
|
-
backSpeed: 20,
|
|
6
|
-
startDelay: 1000,
|
|
7
|
-
loop: false,
|
|
8
|
-
loopCount: Infinity,
|
|
9
|
-
onBegin: function(self) {
|
|
10
|
-
prettyLog('onBegin ' + self);
|
|
11
|
-
},
|
|
12
|
-
onComplete: function(self) {
|
|
13
|
-
prettyLog('onComplete ' + self);
|
|
14
|
-
},
|
|
15
|
-
preStringTyped: function(pos, self) {
|
|
16
|
-
prettyLog('preStringTyped ' + pos + ' ' + self);
|
|
17
|
-
},
|
|
18
|
-
onStringTyped: function(pos, self) {
|
|
19
|
-
prettyLog('onStringTyped ' + pos + ' ' + self);
|
|
20
|
-
},
|
|
21
|
-
onLastStringBackspaced: function(self) {
|
|
22
|
-
prettyLog('onLastStringBackspaced ' + self);
|
|
23
|
-
},
|
|
24
|
-
onTypingPaused: function(pos, self) {
|
|
25
|
-
prettyLog('onTypingPaused ' + pos + ' ' + self);
|
|
26
|
-
},
|
|
27
|
-
onTypingResumed: function(pos, self) {
|
|
28
|
-
prettyLog('onTypingResumed ' + pos + ' ' + self);
|
|
29
|
-
},
|
|
30
|
-
onReset: function(self) {
|
|
31
|
-
prettyLog('onReset ' + self);
|
|
32
|
-
},
|
|
33
|
-
onStop: function(pos, self) {
|
|
34
|
-
prettyLog('onStop ' + pos + ' ' + self);
|
|
35
|
-
},
|
|
36
|
-
onStart: function(pos, self) {
|
|
37
|
-
prettyLog('onStart ' + pos + ' ' + self);
|
|
38
|
-
},
|
|
39
|
-
onDestroy: function(self) {
|
|
40
|
-
prettyLog('onDestroy ' + self);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
document.querySelector('.toggle').addEventListener('click', function() {
|
|
45
|
-
typed.toggle();
|
|
46
|
-
});
|
|
47
|
-
document.querySelector('.stop').addEventListener('click', function() {
|
|
48
|
-
typed.stop();
|
|
49
|
-
});
|
|
50
|
-
document.querySelector('.start').addEventListener('click', function() {
|
|
51
|
-
typed.start();
|
|
52
|
-
});
|
|
53
|
-
document.querySelector('.reset').addEventListener('click', function() {
|
|
54
|
-
typed.reset();
|
|
55
|
-
});
|
|
56
|
-
document.querySelector('.destroy').addEventListener('click', function() {
|
|
57
|
-
typed.destroy();
|
|
58
|
-
});
|
|
59
|
-
document.querySelector('.loop').addEventListener('click', function() {
|
|
60
|
-
toggleLoop(typed);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
var typed2 = new Typed('#typed2', {
|
|
64
|
-
strings: [
|
|
65
|
-
'Some <i>strings</i> with',
|
|
66
|
-
'Some <strong>HTML</strong>',
|
|
67
|
-
'Chars × ©'
|
|
68
|
-
],
|
|
69
|
-
typeSpeed: 0,
|
|
70
|
-
backSpeed: 0,
|
|
71
|
-
fadeOut: true,
|
|
72
|
-
loop: true
|
|
73
|
-
});
|
|
74
|
-
document.querySelector('.loop2').addEventListener('click', function() {
|
|
75
|
-
toggleLoop(typed2);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
new Typed('#typed3', {
|
|
79
|
-
strings: [
|
|
80
|
-
'My strings are: <i>strings</i> with',
|
|
81
|
-
'My strings are: <strong>HTML</strong>',
|
|
82
|
-
'My strings are: Chars × ©'
|
|
83
|
-
],
|
|
84
|
-
typeSpeed: 0,
|
|
85
|
-
backSpeed: 0,
|
|
86
|
-
smartBackspace: true,
|
|
87
|
-
loop: true
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
new Typed('#typed4', {
|
|
91
|
-
strings: ['Some strings without', 'Some HTML', 'Chars'],
|
|
92
|
-
typeSpeed: 0,
|
|
93
|
-
backSpeed: 0,
|
|
94
|
-
attr: 'placeholder',
|
|
95
|
-
bindInputFocusEvents: true,
|
|
96
|
-
loop: true
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
new Typed('#typed5', {
|
|
100
|
-
strings: [
|
|
101
|
-
'1 Some <i>strings</i> with',
|
|
102
|
-
'2 Some <strong>HTML</strong>',
|
|
103
|
-
'3 Chars × ©'
|
|
104
|
-
],
|
|
105
|
-
typeSpeed: 0,
|
|
106
|
-
backSpeed: 0,
|
|
107
|
-
shuffle: true,
|
|
108
|
-
cursorChar: '_',
|
|
109
|
-
smartBackspace: false,
|
|
110
|
-
loop: true
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
new Typed('#typed6', {
|
|
114
|
-
strings: [
|
|
115
|
-
'npm install^1000\n`installing components...` ^1000\n`Fetching from source...`'
|
|
116
|
-
],
|
|
117
|
-
typeSpeed: 40,
|
|
118
|
-
backSpeed: 0,
|
|
119
|
-
loop: true
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
function prettyLog(str) {
|
|
124
|
-
console.log('%c ' + str, 'color: green; font-weight: bold;');
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function toggleLoop(typed) {
|
|
128
|
-
if (typed.loop) {
|
|
129
|
-
typed.loop = false;
|
|
130
|
-
} else {
|
|
131
|
-
typed.loop = true;
|
|
132
|
-
}
|
|
133
|
-
}
|
package/bower.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "typed.js",
|
|
3
|
-
"version": "2.0.12",
|
|
4
|
-
"homepage": "https://github.com/mattboldt/typed.js",
|
|
5
|
-
"authors": ["Matt Boldt <me@mattboldt.com>"],
|
|
6
|
-
"description": "A JavaScript Typing Animation Library",
|
|
7
|
-
"main": "lib/typed.js",
|
|
8
|
-
"keywords": ["typed", "animation"],
|
|
9
|
-
"ignore": [],
|
|
10
|
-
"license": "MIT"
|
|
11
|
-
}
|
package/docs/API.md
DELETED
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
|
2
|
-
|
|
3
|
-
## defaults
|
|
4
|
-
|
|
5
|
-
Defaults & options
|
|
6
|
-
|
|
7
|
-
Returns **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Typed defaults & options
|
|
8
|
-
|
|
9
|
-
### strings
|
|
10
|
-
|
|
11
|
-
**Properties**
|
|
12
|
-
|
|
13
|
-
- `strings` **[array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** strings to be typed
|
|
14
|
-
- `stringsElement` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** ID of element containing string children
|
|
15
|
-
|
|
16
|
-
### typeSpeed
|
|
17
|
-
|
|
18
|
-
**Properties**
|
|
19
|
-
|
|
20
|
-
- `typeSpeed` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** type speed in milliseconds
|
|
21
|
-
|
|
22
|
-
### startDelay
|
|
23
|
-
|
|
24
|
-
**Properties**
|
|
25
|
-
|
|
26
|
-
- `startDelay` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** time before typing starts in milliseconds
|
|
27
|
-
|
|
28
|
-
### backSpeed
|
|
29
|
-
|
|
30
|
-
**Properties**
|
|
31
|
-
|
|
32
|
-
- `backSpeed` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** backspacing speed in milliseconds
|
|
33
|
-
|
|
34
|
-
### smartBackspace
|
|
35
|
-
|
|
36
|
-
**Properties**
|
|
37
|
-
|
|
38
|
-
- `smartBackspace` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** only backspace what doesn't match the previous string
|
|
39
|
-
|
|
40
|
-
### shuffle
|
|
41
|
-
|
|
42
|
-
**Properties**
|
|
43
|
-
|
|
44
|
-
- `shuffle` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** shuffle the strings
|
|
45
|
-
|
|
46
|
-
### backDelay
|
|
47
|
-
|
|
48
|
-
**Properties**
|
|
49
|
-
|
|
50
|
-
- `backDelay` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** time before backspacing in milliseconds
|
|
51
|
-
|
|
52
|
-
### fadeOut
|
|
53
|
-
|
|
54
|
-
**Properties**
|
|
55
|
-
|
|
56
|
-
- `fadeOut` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Fade out instead of backspace
|
|
57
|
-
- `fadeOutClass` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** css class for fade animation
|
|
58
|
-
- `fadeOutDelay` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Fade out delay in milliseconds
|
|
59
|
-
|
|
60
|
-
### loop
|
|
61
|
-
|
|
62
|
-
**Properties**
|
|
63
|
-
|
|
64
|
-
- `loop` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** loop strings
|
|
65
|
-
- `loopCount` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** amount of loops
|
|
66
|
-
|
|
67
|
-
### showCursor
|
|
68
|
-
|
|
69
|
-
**Properties**
|
|
70
|
-
|
|
71
|
-
- `showCursor` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** show cursor
|
|
72
|
-
- `cursorChar` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** character for cursor
|
|
73
|
-
- `autoInsertCss` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** insert CSS for cursor and fadeOut into HTML <head>
|
|
74
|
-
|
|
75
|
-
### attr
|
|
76
|
-
|
|
77
|
-
**Properties**
|
|
78
|
-
|
|
79
|
-
- `attr` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** attribute for typing
|
|
80
|
-
Ex: input placeholder, value, or just HTML text
|
|
81
|
-
|
|
82
|
-
### bindInputFocusEvents
|
|
83
|
-
|
|
84
|
-
**Properties**
|
|
85
|
-
|
|
86
|
-
- `bindInputFocusEvents` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** bind to focus and blur if el is text input
|
|
87
|
-
|
|
88
|
-
### contentType
|
|
89
|
-
|
|
90
|
-
**Properties**
|
|
91
|
-
|
|
92
|
-
- `contentType` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** 'html' or 'null' for plaintext
|
|
93
|
-
|
|
94
|
-
### onBegin
|
|
95
|
-
|
|
96
|
-
Before it begins typing
|
|
97
|
-
|
|
98
|
-
**Parameters**
|
|
99
|
-
|
|
100
|
-
- `self` **[Typed](#typed)**
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
### onComplete
|
|
104
|
-
|
|
105
|
-
All typing is complete
|
|
106
|
-
|
|
107
|
-
**Parameters**
|
|
108
|
-
|
|
109
|
-
- `self` **[Typed](#typed)**
|
|
110
|
-
|
|
111
|
-
### preStringTyped
|
|
112
|
-
|
|
113
|
-
Before each string is typed
|
|
114
|
-
|
|
115
|
-
**Parameters**
|
|
116
|
-
|
|
117
|
-
- `arrayPos` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)**
|
|
118
|
-
- `self` **[Typed](#typed)**
|
|
119
|
-
|
|
120
|
-
### onStringTyped
|
|
121
|
-
|
|
122
|
-
After each string is typed
|
|
123
|
-
|
|
124
|
-
**Parameters**
|
|
125
|
-
|
|
126
|
-
- `arrayPos` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)**
|
|
127
|
-
- `self` **[Typed](#typed)**
|
|
128
|
-
|
|
129
|
-
### onLastStringBackspaced
|
|
130
|
-
|
|
131
|
-
During looping, after last string is typed
|
|
132
|
-
|
|
133
|
-
**Parameters**
|
|
134
|
-
|
|
135
|
-
- `self` **[Typed](#typed)**
|
|
136
|
-
|
|
137
|
-
### onTypingPaused
|
|
138
|
-
|
|
139
|
-
Typing has been stopped
|
|
140
|
-
|
|
141
|
-
**Parameters**
|
|
142
|
-
|
|
143
|
-
- `arrayPos` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)**
|
|
144
|
-
- `self` **[Typed](#typed)**
|
|
145
|
-
|
|
146
|
-
### onTypingResumed
|
|
147
|
-
|
|
148
|
-
Typing has been started after being stopped
|
|
149
|
-
|
|
150
|
-
**Parameters**
|
|
151
|
-
|
|
152
|
-
- `arrayPos` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)**
|
|
153
|
-
- `self` **[Typed](#typed)**
|
|
154
|
-
|
|
155
|
-
### onReset
|
|
156
|
-
|
|
157
|
-
After reset
|
|
158
|
-
|
|
159
|
-
**Parameters**
|
|
160
|
-
|
|
161
|
-
- `self` **[Typed](#typed)**
|
|
162
|
-
|
|
163
|
-
### onStop
|
|
164
|
-
|
|
165
|
-
After stop
|
|
166
|
-
|
|
167
|
-
**Parameters**
|
|
168
|
-
|
|
169
|
-
- `arrayPos` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)**
|
|
170
|
-
- `self` **[Typed](#typed)**
|
|
171
|
-
|
|
172
|
-
### onStart
|
|
173
|
-
|
|
174
|
-
After start
|
|
175
|
-
|
|
176
|
-
**Parameters**
|
|
177
|
-
|
|
178
|
-
- `arrayPos` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)**
|
|
179
|
-
- `self` **[Typed](#typed)**
|
|
180
|
-
|
|
181
|
-
### onDestroy
|
|
182
|
-
|
|
183
|
-
After destroy
|
|
184
|
-
|
|
185
|
-
**Parameters**
|
|
186
|
-
|
|
187
|
-
- `self` **[Typed](#typed)**
|
|
188
|
-
|
|
189
|
-
## HTMLParser
|
|
190
|
-
|
|
191
|
-
TODO: These methods can probably be combined somehow
|
|
192
|
-
Parse HTML tags & HTML Characters
|
|
193
|
-
|
|
194
|
-
## Initializer
|
|
195
|
-
|
|
196
|
-
Initialize the Typed object
|
|
197
|
-
|
|
198
|
-
## Typed
|
|
199
|
-
|
|
200
|
-
Welcome to Typed.js!
|
|
201
|
-
|
|
202
|
-
**Parameters**
|
|
203
|
-
|
|
204
|
-
- `elementId` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** HTML element ID _OR_ HTML element
|
|
205
|
-
- `options` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** options object
|
|
206
|
-
|
|
207
|
-
Returns **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** a new Typed object
|
|
208
|
-
|
|
209
|
-
### toggle
|
|
210
|
-
|
|
211
|
-
Toggle start() and stop() of the Typed instance
|
|
212
|
-
|
|
213
|
-
### stop
|
|
214
|
-
|
|
215
|
-
Stop typing / backspacing and enable cursor blinking
|
|
216
|
-
|
|
217
|
-
### start
|
|
218
|
-
|
|
219
|
-
Start typing / backspacing after being stopped
|
|
220
|
-
|
|
221
|
-
### destroy
|
|
222
|
-
|
|
223
|
-
Destroy this instance of Typed
|
|
224
|
-
|
|
225
|
-
### reset
|
|
226
|
-
|
|
227
|
-
Reset Typed and optionally restarts
|
|
228
|
-
|
|
229
|
-
**Parameters**
|
|
230
|
-
|
|
231
|
-
- `restart` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?= nser**
|
package/docs/assets/anchor.js
DELETED
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* AnchorJS - v1.2.1 - 2015-07-02
|
|
3
|
-
* https://github.com/bryanbraun/anchorjs
|
|
4
|
-
* Copyright (c) 2015 Bryan Braun; Licensed MIT
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
function AnchorJS(options) {
|
|
8
|
-
'use strict';
|
|
9
|
-
|
|
10
|
-
this.options = options || {};
|
|
11
|
-
|
|
12
|
-
this._applyRemainingDefaultOptions = function(opts) {
|
|
13
|
-
this.options.icon = this.options.hasOwnProperty('icon') ? opts.icon : '\ue9cb'; // Accepts characters (and also URLs?), like '#', '¶', '❡', or '§'.
|
|
14
|
-
this.options.visible = this.options.hasOwnProperty('visible') ? opts.visible : 'hover'; // Also accepts 'always'
|
|
15
|
-
this.options.placement = this.options.hasOwnProperty('placement') ? opts.placement : 'right'; // Also accepts 'left'
|
|
16
|
-
this.options.class = this.options.hasOwnProperty('class') ? opts.class : ''; // Accepts any class name.
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
this._applyRemainingDefaultOptions(options);
|
|
20
|
-
|
|
21
|
-
this.add = function(selector) {
|
|
22
|
-
var elements,
|
|
23
|
-
elsWithIds,
|
|
24
|
-
idList,
|
|
25
|
-
elementID,
|
|
26
|
-
i,
|
|
27
|
-
roughText,
|
|
28
|
-
tidyText,
|
|
29
|
-
index,
|
|
30
|
-
count,
|
|
31
|
-
newTidyText,
|
|
32
|
-
readableID,
|
|
33
|
-
anchor;
|
|
34
|
-
|
|
35
|
-
this._applyRemainingDefaultOptions(this.options);
|
|
36
|
-
|
|
37
|
-
// Provide a sensible default selector, if none is given.
|
|
38
|
-
if (!selector) {
|
|
39
|
-
selector = 'h1, h2, h3, h4, h5, h6';
|
|
40
|
-
} else if (typeof selector !== 'string') {
|
|
41
|
-
throw new Error('The selector provided to AnchorJS was invalid.');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
elements = document.querySelectorAll(selector);
|
|
45
|
-
if (elements.length === 0) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
this._addBaselineStyles();
|
|
50
|
-
|
|
51
|
-
// We produce a list of existing IDs so we don't generate a duplicate.
|
|
52
|
-
elsWithIds = document.querySelectorAll('[id]');
|
|
53
|
-
idList = [].map.call(elsWithIds, function assign(el) {
|
|
54
|
-
return el.id;
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
for (i = 0; i < elements.length; i++) {
|
|
58
|
-
|
|
59
|
-
if (elements[i].hasAttribute('id')) {
|
|
60
|
-
elementID = elements[i].getAttribute('id');
|
|
61
|
-
} else {
|
|
62
|
-
roughText = elements[i].textContent;
|
|
63
|
-
|
|
64
|
-
// Refine it so it makes a good ID. Strip out non-safe characters, replace
|
|
65
|
-
// spaces with hyphens, truncate to 32 characters, and make toLowerCase.
|
|
66
|
-
//
|
|
67
|
-
// Example string: // '⚡⚡⚡ Unicode icons are cool--but they definitely don't belong in a URL fragment.'
|
|
68
|
-
tidyText = roughText.replace(/[^\w\s-]/gi, '') // ' Unicode icons are cool--but they definitely dont belong in a URL fragment'
|
|
69
|
-
.replace(/\s+/g, '-') // '-Unicode-icons-are-cool--but-they-definitely-dont-belong-in-a-URL-fragment'
|
|
70
|
-
.replace(/-{2,}/g, '-') // '-Unicode-icons-are-cool-but-they-definitely-dont-belong-in-a-URL-fragment'
|
|
71
|
-
.substring(0, 64) // '-Unicode-icons-are-cool-but-they-definitely-dont-belong-in-a-URL'
|
|
72
|
-
.replace(/^-+|-+$/gm, '') // 'Unicode-icons-are-cool-but-they-definitely-dont-belong-in-a-URL'
|
|
73
|
-
.toLowerCase(); // 'unicode-icons-are-cool-but-they-definitely-dont-belong-in-a-url'
|
|
74
|
-
|
|
75
|
-
// Compare our generated ID to existing IDs (and increment it if needed)
|
|
76
|
-
// before we add it to the page.
|
|
77
|
-
newTidyText = tidyText;
|
|
78
|
-
count = 0;
|
|
79
|
-
do {
|
|
80
|
-
if (index !== undefined) {
|
|
81
|
-
newTidyText = tidyText + '-' + count;
|
|
82
|
-
}
|
|
83
|
-
// .indexOf is supported in IE9+.
|
|
84
|
-
index = idList.indexOf(newTidyText);
|
|
85
|
-
count += 1;
|
|
86
|
-
} while (index !== -1);
|
|
87
|
-
index = undefined;
|
|
88
|
-
idList.push(newTidyText);
|
|
89
|
-
|
|
90
|
-
// Assign it to our element.
|
|
91
|
-
// Currently the setAttribute element is only supported in IE9 and above.
|
|
92
|
-
elements[i].setAttribute('id', newTidyText);
|
|
93
|
-
|
|
94
|
-
elementID = newTidyText;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
readableID = elementID.replace(/-/g, ' ');
|
|
98
|
-
|
|
99
|
-
// The following code builds the following DOM structure in a more effiecient (albeit opaque) way.
|
|
100
|
-
// '<a class="anchorjs-link ' + this.options.class + '" href="#' + elementID + '" aria-label="Anchor link for: ' + readableID + '" data-anchorjs-icon="' + this.options.icon + '"></a>';
|
|
101
|
-
anchor = document.createElement('a');
|
|
102
|
-
anchor.className = 'anchorjs-link ' + this.options.class;
|
|
103
|
-
anchor.href = '#' + elementID;
|
|
104
|
-
anchor.setAttribute('aria-label', 'Anchor link for: ' + readableID);
|
|
105
|
-
anchor.setAttribute('data-anchorjs-icon', this.options.icon);
|
|
106
|
-
|
|
107
|
-
if (this.options.visible === 'always') {
|
|
108
|
-
anchor.style.opacity = '1';
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (this.options.icon === '\ue9cb') {
|
|
112
|
-
anchor.style.fontFamily = 'anchorjs-icons';
|
|
113
|
-
anchor.style.fontStyle = 'normal';
|
|
114
|
-
anchor.style.fontVariant = 'normal';
|
|
115
|
-
anchor.style.fontWeight = 'normal';
|
|
116
|
-
anchor.style.lineHeight = 1;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (this.options.placement === 'left') {
|
|
120
|
-
anchor.style.position = 'absolute';
|
|
121
|
-
anchor.style.marginLeft = '-1em';
|
|
122
|
-
anchor.style.paddingRight = '0.5em';
|
|
123
|
-
elements[i].insertBefore(anchor, elements[i].firstChild);
|
|
124
|
-
} else { // if the option provided is `right` (or anything else).
|
|
125
|
-
anchor.style.paddingLeft = '0.375em';
|
|
126
|
-
elements[i].appendChild(anchor);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return this;
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
this.remove = function(selector) {
|
|
134
|
-
var domAnchor,
|
|
135
|
-
elements = document.querySelectorAll(selector);
|
|
136
|
-
for (var i = 0; i < elements.length; i++) {
|
|
137
|
-
domAnchor = elements[i].querySelector('.anchorjs-link');
|
|
138
|
-
if (domAnchor) {
|
|
139
|
-
elements[i].removeChild(domAnchor);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return this;
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
this._addBaselineStyles = function() {
|
|
146
|
-
// We don't want to add global baseline styles if they've been added before.
|
|
147
|
-
if (document.head.querySelector('style.anchorjs') !== null) {
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
var style = document.createElement('style'),
|
|
152
|
-
linkRule =
|
|
153
|
-
' .anchorjs-link {' +
|
|
154
|
-
' opacity: 0;' +
|
|
155
|
-
' text-decoration: none;' +
|
|
156
|
-
' -webkit-font-smoothing: antialiased;' +
|
|
157
|
-
' -moz-osx-font-smoothing: grayscale;' +
|
|
158
|
-
' }',
|
|
159
|
-
hoverRule =
|
|
160
|
-
' *:hover > .anchorjs-link,' +
|
|
161
|
-
' .anchorjs-link:focus {' +
|
|
162
|
-
' opacity: 1;' +
|
|
163
|
-
' }',
|
|
164
|
-
anchorjsLinkFontFace =
|
|
165
|
-
' @font-face {' +
|
|
166
|
-
' font-family: "anchorjs-icons";' +
|
|
167
|
-
' font-style: normal;' +
|
|
168
|
-
' font-weight: normal;' + // Icon from icomoon; 10px wide & 10px tall; 2 empty below & 4 above
|
|
169
|
-
' src: url(data:application/x-font-ttf;charset=utf-8;base64,AAEAAAALAIAAAwAwT1MvMg8SBTUAAAC8AAAAYGNtYXAWi9QdAAABHAAAAFRnYXNwAAAAEAAAAXAAAAAIZ2x5Zgq29TcAAAF4AAABNGhlYWQEZM3pAAACrAAAADZoaGVhBhUDxgAAAuQAAAAkaG10eASAADEAAAMIAAAAFGxvY2EAKACuAAADHAAAAAxtYXhwAAgAVwAAAygAAAAgbmFtZQ5yJ3cAAANIAAAB2nBvc3QAAwAAAAAFJAAAACAAAwJAAZAABQAAApkCzAAAAI8CmQLMAAAB6wAzAQkAAAAAAAAAAAAAAAAAAAABEAAAAAAAAAAAAAAAAAAAAABAAADpywPA/8AAQAPAAEAAAAABAAAAAAAAAAAAAAAgAAAAAAADAAAAAwAAABwAAQADAAAAHAADAAEAAAAcAAQAOAAAAAoACAACAAIAAQAg6cv//f//AAAAAAAg6cv//f//AAH/4xY5AAMAAQAAAAAAAAAAAAAAAQAB//8ADwABAAAAAAAAAAAAAgAANzkBAAAAAAEAAAAAAAAAAAACAAA3OQEAAAAAAQAAAAAAAAAAAAIAADc5AQAAAAACADEARAJTAsAAKwBUAAABIiYnJjQ/AT4BMzIWFxYUDwEGIicmND8BNjQnLgEjIgYPAQYUFxYUBw4BIwciJicmND8BNjIXFhQPAQYUFx4BMzI2PwE2NCcmNDc2MhcWFA8BDgEjARQGDAUtLXoWOR8fORYtLTgKGwoKCjgaGg0gEhIgDXoaGgkJBQwHdR85Fi0tOAobCgoKOBoaDSASEiANehoaCQkKGwotLXoWOR8BMwUFLYEuehYXFxYugC44CQkKGwo4GkoaDQ0NDXoaShoKGwoFBe8XFi6ALjgJCQobCjgaShoNDQ0NehpKGgobCgoKLYEuehYXAAEAAAABAACiToc1Xw889QALBAAAAAAA0XnFFgAAAADRecUWAAAAAAJTAsAAAAAIAAIAAAAAAAAAAQAAA8D/wAAABAAAAAAAAlMAAQAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAACAAAAAoAAMQAAAAAACgAUAB4AmgABAAAABQBVAAIAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAADgCuAAEAAAAAAAEADgAAAAEAAAAAAAIABwCfAAEAAAAAAAMADgBLAAEAAAAAAAQADgC0AAEAAAAAAAUACwAqAAEAAAAAAAYADgB1AAEAAAAAAAoAGgDeAAMAAQQJAAEAHAAOAAMAAQQJAAIADgCmAAMAAQQJAAMAHABZAAMAAQQJAAQAHADCAAMAAQQJAAUAFgA1AAMAAQQJAAYAHACDAAMAAQQJAAoANAD4YW5jaG9yanMtaWNvbnMAYQBuAGMAaABvAHIAagBzAC0AaQBjAG8AbgBzVmVyc2lvbiAxLjAAVgBlAHIAcwBpAG8AbgAgADEALgAwYW5jaG9yanMtaWNvbnMAYQBuAGMAaABvAHIAagBzAC0AaQBjAG8AbgBzYW5jaG9yanMtaWNvbnMAYQBuAGMAaABvAHIAagBzAC0AaQBjAG8AbgBzUmVndWxhcgBSAGUAZwB1AGwAYQByYW5jaG9yanMtaWNvbnMAYQBuAGMAaABvAHIAagBzAC0AaQBjAG8AbgBzRm9udCBnZW5lcmF0ZWQgYnkgSWNvTW9vbi4ARgBvAG4AdAAgAGcAZQBuAGUAcgBhAHQAZQBkACAAYgB5ACAASQBjAG8ATQBvAG8AbgAuAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==) format("truetype");' +
|
|
170
|
-
' }',
|
|
171
|
-
pseudoElContent =
|
|
172
|
-
' [data-anchorjs-icon]::after {' +
|
|
173
|
-
' content: attr(data-anchorjs-icon);' +
|
|
174
|
-
' }',
|
|
175
|
-
firstStyleEl;
|
|
176
|
-
|
|
177
|
-
style.className = 'anchorjs';
|
|
178
|
-
style.appendChild(document.createTextNode('')); // Necessary for Webkit.
|
|
179
|
-
|
|
180
|
-
// We place it in the head with the other style tags, if possible, so as to
|
|
181
|
-
// not look out of place. We insert before the others so these styles can be
|
|
182
|
-
// overridden if necessary.
|
|
183
|
-
firstStyleEl = document.head.querySelector('[rel="stylesheet"], style');
|
|
184
|
-
if (firstStyleEl === undefined) {
|
|
185
|
-
document.head.appendChild(style);
|
|
186
|
-
} else {
|
|
187
|
-
document.head.insertBefore(style, firstStyleEl);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
style.sheet.insertRule(linkRule, style.sheet.cssRules.length);
|
|
191
|
-
style.sheet.insertRule(hoverRule, style.sheet.cssRules.length);
|
|
192
|
-
style.sheet.insertRule(pseudoElContent, style.sheet.cssRules.length);
|
|
193
|
-
style.sheet.insertRule(anchorjsLinkFontFace, style.sheet.cssRules.length);
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
var anchors = new AnchorJS();
|