jq-dynamic-titles 1.0.1 → 1.1.0
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/CHANGELOG.md +7 -0
- package/README.md +19 -4
- package/package.json +2 -2
- package/scripts/jq-dynamic-titles.js +15 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.1.0
|
|
4
|
+
|
|
5
|
+
- Accept case-insensitive values for effect type, named speed, and scrolling direction. Message capitalisation and option names remain unchanged.
|
|
6
|
+
- Accept `forward` and `backward` as aliases for `fwd` and `bwd`, including mixed-case variants.
|
|
7
|
+
- Preserve supplied options and defaults by normalising only the per-call settings. Existing validation still rejects invalid values.
|
|
8
|
+
- Update the README introduction and document case-insensitive values and direction aliases.
|
|
9
|
+
|
|
3
10
|
## 1.0.1
|
|
4
11
|
|
|
5
12
|
- Validate message and focus options, plus scrolling direction and reverse options, before changing a running effect. Invalid values throw `TypeError`.
|
package/README.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# jQuery Dynamic Titles
|
|
2
|
+
## Dynamically change your browser tab's title using `$.dynTitles`
|
|
3
|
+
jQuery Dynamic Titles changes the page title to blink, scroll, or display a constant message. A fourth action stops the effect and restores the original title.
|
|
4
|
+
|
|
5
|
+
Use it to draw attention to an update, such as a new message or a completed task. By default, effects are displayed only when the window is unfocused and stop when the user returns. Set `onlyOnNonFocus: false` to display an effect regardless of focus.
|
|
2
6
|
|
|
3
|
-
Blink, scroll, or replace a browser tab's title using `$.dynTitles`.
|
|
4
7
|
This utility changes `document.title` for the page, so no element selection is needed.
|
|
5
8
|
|
|
6
9
|
## Installation
|
|
@@ -88,7 +91,7 @@ Each valid call cancels the previous animation timer. The original title remains
|
|
|
88
91
|
| `type` | `'blink'` | `'blink'`, `'scroll'`, `'const'`, or `'restore'` |
|
|
89
92
|
| `message` | `'New Message'` | String to display; unused for restore |
|
|
90
93
|
| `speed` | `'medium'` | `'fast'`, `'medium'`, `'slow'`, or a positive finite number of milliseconds, up to 2147483647 |
|
|
91
|
-
| `direction` | `'fwd'` | Starting scroll direction: `'fwd'` or `'bwd'` |
|
|
94
|
+
| `direction` | `'fwd'` | Starting scroll direction: `'fwd'` / `'forward'` or `'bwd'` / `'backward'` |
|
|
92
95
|
| `reverse` | `true` | Alternate scroll directions; use `false` to repeat the starting direction |
|
|
93
96
|
| `onlyOnNonFocus` | `true` | Apply the effect only when the window does not have focus; restore and stop when focus returns |
|
|
94
97
|
|
|
@@ -108,10 +111,22 @@ Invalid options throw `TypeError` before changing state or cancelling an existin
|
|
|
108
111
|
|
|
109
112
|
- `type` must be one of the four actions listed above.
|
|
110
113
|
- For blink, scroll, and constant titles, `message` must be a string (an empty string is allowed), `speed` must meet the requirements above, and `onlyOnNonFocus` must be a boolean.
|
|
111
|
-
- For scrolling, `direction` must be `'fwd'` or `'
|
|
114
|
+
- For scrolling, `direction` must be `'fwd'`, `'forward'`, `'bwd'`, or `'backward'`, and `reverse` must be a boolean. Other actions ignore those two options.
|
|
112
115
|
- Restore ignores all effect-specific options.
|
|
113
116
|
|
|
114
|
-
|
|
117
|
+
The string values of `type`, named `speed`, and `direction` are case-insensitive. For example, `'SCROLL'`, `'Fast'`, and `'Forward'` are accepted. Full direction names are aliases: `'forward'` means `'fwd'`, and `'backward'` means `'bwd'`. Message text retains its original capitalisation. Option names remain case-sensitive, including `onlyOnNonFocus`.
|
|
118
|
+
|
|
119
|
+
```js
|
|
120
|
+
$.dynTitles({
|
|
121
|
+
type: 'SCROLL',
|
|
122
|
+
speed: 'Fast',
|
|
123
|
+
direction: 'Forward',
|
|
124
|
+
message: 'Keep My Capitalisation',
|
|
125
|
+
onlyOnNonFocus: false
|
|
126
|
+
});
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Use actual booleans (`true` and `false`), rather than strings such as `'false'` or numbers such as `0` and `1`. Numeric speeds must be numbers, not numeric strings. Normalisation affects only the per-call settings; supplied options and public defaults are not modified.
|
|
115
130
|
|
|
116
131
|
The implementation also accepts an optional `position` value for scrolling, but normal usage should omit it to use the starting position for the chosen direction.
|
|
117
132
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jq-dynamic-titles",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A jQuery utility for blinking, scrolling and restoring the document title",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"document-title",
|
|
22
22
|
"notification"
|
|
23
23
|
],
|
|
24
|
-
"author": "Paul Albinson",
|
|
24
|
+
"author": "Dr Paul Albinson",
|
|
25
25
|
"license": "AGPL-3.0-only",
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"jquery": "^3.7.1 || ^4.0.0"
|
|
@@ -36,6 +36,20 @@
|
|
|
36
36
|
|
|
37
37
|
let settings = $.extend({}, $.dynTitles.defaults, options);
|
|
38
38
|
|
|
39
|
+
// Normalise recognised string options without changing the message.
|
|
40
|
+
['type', 'speed', 'direction'].forEach(function (key) {
|
|
41
|
+
if (typeof settings[key] === 'string') {
|
|
42
|
+
settings[key] = settings[key].toLowerCase();
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Accept full direction names alongside the existing shorthand.
|
|
47
|
+
if (settings.direction === 'forward') {
|
|
48
|
+
settings.direction = 'fwd';
|
|
49
|
+
} else if (settings.direction === 'backward') {
|
|
50
|
+
settings.direction = 'bwd';
|
|
51
|
+
}
|
|
52
|
+
|
|
39
53
|
let namedSpeed = settings.speed === 'fast' ||
|
|
40
54
|
settings.speed === 'medium' ||
|
|
41
55
|
settings.speed === 'slow';
|
|
@@ -62,7 +76,7 @@
|
|
|
62
76
|
}
|
|
63
77
|
|
|
64
78
|
if (settings.type === 'scroll' && settings.direction !== 'fwd' && settings.direction !== 'bwd') {
|
|
65
|
-
throw new TypeError('Direction must be fwd or bwd.');
|
|
79
|
+
throw new TypeError('Direction must be forward or backward, or the shorthand fwd or bwd.');
|
|
66
80
|
}
|
|
67
81
|
|
|
68
82
|
if (settings.type === 'scroll' && typeof settings.reverse !== 'boolean') {
|