rink.js 1.0.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/LICENSE.txt +21 -0
- package/README.md +112 -0
- package/dist/rink.d.mts +2 -0
- package/dist/rink.d.ts +2 -0
- package/dist/rink.esm.js +225 -0
- package/dist/rink.esm.js.map +1 -0
- package/dist/rink.js +227 -0
- package/dist/rink.js.map +1 -0
- package/dist/rink.min.js +1 -0
- package/docs/images/icon.png +0 -0
- package/eslint.config.mjs +43 -0
- package/package.json +50 -0
- package/src/rink.ts +262 -0
- package/src/ts/api.ts +60 -0
- package/src/ts/constant.ts +21 -0
- package/src/ts/data/default.ts +29 -0
- package/src/ts/data/enum.ts +29 -0
- package/src/ts/data/is.ts +33 -0
- package/src/ts/dom/document-element.ts +22 -0
- package/src/ts/options/config.ts +27 -0
- package/src/ts/type.ts +22 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 William Troup
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
<h1 align="center">
|
|
2
|
+
Rink.js
|
|
3
|
+
|
|
4
|
+
[](https://twitter.com/intent/tweet?text=Rink.js%2C%20a%20free%20JavaScript%json%20converter&url=https://github.com/williamtroup/Rink.js&hashtags=javascript,json,html,converter)
|
|
5
|
+
[](https://www.npmjs.com/package/rink.js)
|
|
6
|
+
[](https://www.nuget.org/packages/Rink.js/)
|
|
7
|
+
[](https://github.com/williamtroup/Rink.js/blob/main/LICENSE.txt)
|
|
8
|
+
[](https://github.com/williamtroup/Rink.js/discussions)
|
|
9
|
+
[](https://william-troup.com/)
|
|
10
|
+
</h1>
|
|
11
|
+
|
|
12
|
+
> <p align="center">🔗 A JavaScript library for generating responsive HTML link targets.</p>
|
|
13
|
+
> <p align="center">v1.0.0</p>
|
|
14
|
+
<br />
|
|
15
|
+
<br />
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
<h1>What features does Rink.js have?</h1>
|
|
19
|
+
|
|
20
|
+
- 😏 Zero-dependencies and extremely lightweight!
|
|
21
|
+
- 🦾 Written in TypeScript, allowing greater support for React, Angular, and other libraries!
|
|
22
|
+
- 💻 Full API available via public functions.
|
|
23
|
+
<br />
|
|
24
|
+
<br />
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
<h1>What browsers are supported?</h1>
|
|
28
|
+
|
|
29
|
+
All modern browsers (such as Google Chrome, FireFox, and Opera) are fully supported.
|
|
30
|
+
<br>
|
|
31
|
+
<br>
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
<h1>How do I install Rink.js?</h1>
|
|
35
|
+
|
|
36
|
+
You can install the library with npm into your local modules directory using the following command:
|
|
37
|
+
|
|
38
|
+
```markdown
|
|
39
|
+
npm install rink.js
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Or, you can also use the following CDN links:
|
|
43
|
+
|
|
44
|
+
```markdown
|
|
45
|
+
https://cdn.jsdelivr.net/gh/williamtroup/Rink.js@1.0.0/dist/rink.min.js
|
|
46
|
+
```
|
|
47
|
+
<br>
|
|
48
|
+
<br>
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
<h1>How do I get started?</h1>
|
|
52
|
+
|
|
53
|
+
To get started using Rink.js, do the following steps:
|
|
54
|
+
<br>
|
|
55
|
+
<br>
|
|
56
|
+
|
|
57
|
+
### 1. Prerequisites:
|
|
58
|
+
|
|
59
|
+
Make sure you include the "DOCTYPE html" tag at the top of your HTML, as follows:
|
|
60
|
+
|
|
61
|
+
```markdown
|
|
62
|
+
<!DOCTYPE html>
|
|
63
|
+
```
|
|
64
|
+
<br>
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
### 2. Include Files:
|
|
68
|
+
|
|
69
|
+
```markdown
|
|
70
|
+
<script src="dist/rink.js"></script>
|
|
71
|
+
```
|
|
72
|
+
<br>
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
### 3. Getting/Rendering JSON:
|
|
76
|
+
|
|
77
|
+
```markdown
|
|
78
|
+
<a href="https://www.william-troup.com/" data-rink-js-sm="_blank" target="_self">Test Link SM</a>
|
|
79
|
+
<a href="https://www.william-troup.com/" data-rink-js-md="_blank" target="_self">Test Link MD</a>
|
|
80
|
+
<a href="https://www.william-troup.com/" data-rink-js-lg="_blank" target="_self">Test Link LG</a>
|
|
81
|
+
<a href="https://www.william-troup.com/" data-rink-js-xl="_blank" target="_self">Test Link XL</a>
|
|
82
|
+
<a href="https://www.william-troup.com/" data-rink-js-xxl="_blank" target="_self">Test Link XXL</a>
|
|
83
|
+
<a href="https://www.william-troup.com/" data-rink-js-800="_blank" target="_self">Test Link (800)</a>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
<br>
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
### 4. Finishing Up:
|
|
90
|
+
|
|
91
|
+
That's it! Nice and simple. Please refer to the code if you need more help (fully documented).
|
|
92
|
+
<br>
|
|
93
|
+
<br>
|
|
94
|
+
|
|
95
|
+
<h1>How do I go about customizing Rink.js?</h1>
|
|
96
|
+
|
|
97
|
+
To customize, and get more out of Rink.js, please read through the following documentation.
|
|
98
|
+
<br>
|
|
99
|
+
<br>
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
### 5. Configuration:
|
|
103
|
+
|
|
104
|
+
Configuration options allow you to customize how Rink.js will function. You can set them as follows:
|
|
105
|
+
|
|
106
|
+
```markdown
|
|
107
|
+
<script>
|
|
108
|
+
$rink.setConfiguration( {
|
|
109
|
+
safeMode: false
|
|
110
|
+
} );
|
|
111
|
+
</script>
|
|
112
|
+
```
|
package/dist/rink.d.mts
ADDED
package/dist/rink.d.ts
ADDED
package/dist/rink.esm.js
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
var t;
|
|
2
|
+
|
|
3
|
+
(t => {
|
|
4
|
+
function e(t) {
|
|
5
|
+
return t !== null && t !== void 0 && t.toString() !== "";
|
|
6
|
+
}
|
|
7
|
+
t.defined = e;
|
|
8
|
+
function n(t) {
|
|
9
|
+
return e(t) && typeof t === "object";
|
|
10
|
+
}
|
|
11
|
+
t.definedObject = n;
|
|
12
|
+
function r(t) {
|
|
13
|
+
return e(t) && typeof t === "string";
|
|
14
|
+
}
|
|
15
|
+
t.definedString = r;
|
|
16
|
+
function i(t) {
|
|
17
|
+
return e(t) && typeof t === "number";
|
|
18
|
+
}
|
|
19
|
+
t.definedNumber = i;
|
|
20
|
+
})(t || (t = {}));
|
|
21
|
+
|
|
22
|
+
var e;
|
|
23
|
+
|
|
24
|
+
(e => {
|
|
25
|
+
function n(e, n) {
|
|
26
|
+
return t.definedString(e) ? e : n;
|
|
27
|
+
}
|
|
28
|
+
e.getString = n;
|
|
29
|
+
function r(e, n) {
|
|
30
|
+
return t.definedNumber(e) ? e : n;
|
|
31
|
+
}
|
|
32
|
+
e.getNumber = r;
|
|
33
|
+
function i(e, n) {
|
|
34
|
+
return t.definedObject(e) ? e : n;
|
|
35
|
+
}
|
|
36
|
+
e.getObject = i;
|
|
37
|
+
})(e || (e = {}));
|
|
38
|
+
|
|
39
|
+
var n;
|
|
40
|
+
|
|
41
|
+
(t => {
|
|
42
|
+
let n;
|
|
43
|
+
(t => {
|
|
44
|
+
function n(t = null) {
|
|
45
|
+
const n = e.getObject(t, {});
|
|
46
|
+
n.responsiveDelay = e.getNumber(n.responsiveDelay, 250);
|
|
47
|
+
return n;
|
|
48
|
+
}
|
|
49
|
+
t.get = n;
|
|
50
|
+
})(n = t.Options || (t.Options = {}));
|
|
51
|
+
})(n || (n = {}));
|
|
52
|
+
|
|
53
|
+
var r;
|
|
54
|
+
|
|
55
|
+
(t => {
|
|
56
|
+
function e(t) {
|
|
57
|
+
if (document.readyState === "loading") {
|
|
58
|
+
document.addEventListener("DOMContentLoaded", () => t());
|
|
59
|
+
} else {
|
|
60
|
+
t();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
t.onContentLoaded = e;
|
|
64
|
+
})(r || (r = {}));
|
|
65
|
+
|
|
66
|
+
var i;
|
|
67
|
+
|
|
68
|
+
(t => {
|
|
69
|
+
t.RINK_JS_ATTRIBUTE_NAME_SM = "data-rink-js-sm";
|
|
70
|
+
t.RINK_JS_ATTRIBUTE_NAME_MD = "data-rink-js-md";
|
|
71
|
+
t.RINK_JS_ATTRIBUTE_NAME_LG = "data-rink-js-lg";
|
|
72
|
+
t.RINK_JS_ATTRIBUTE_NAME_XL = "data-rink-js-xl";
|
|
73
|
+
t.RINK_JS_ATTRIBUTE_NAME_XXL = "data-rink-js-xxl";
|
|
74
|
+
t.RINK_JS_ATTRIBUTE_NAME_CUSTOM = "data-rink-js";
|
|
75
|
+
})(i || (i = {}));
|
|
76
|
+
|
|
77
|
+
(() => {
|
|
78
|
+
let e = {};
|
|
79
|
+
const o = {};
|
|
80
|
+
let s = 0;
|
|
81
|
+
function c() {
|
|
82
|
+
const t = [ "a" ];
|
|
83
|
+
const e = t.length;
|
|
84
|
+
let n = false;
|
|
85
|
+
for (let r = 0; r < e; r++) {
|
|
86
|
+
const e = document.getElementsByTagName(t[r]);
|
|
87
|
+
const i = [].slice.call(e);
|
|
88
|
+
const o = i.length;
|
|
89
|
+
for (let t = 0; t < o; t++) {
|
|
90
|
+
if (a(i[t])) {
|
|
91
|
+
n = true;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (n) {
|
|
96
|
+
window.addEventListener("resize", d);
|
|
97
|
+
g();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function a(e) {
|
|
101
|
+
let n = false;
|
|
102
|
+
const r = e.getAttribute(i.RINK_JS_ATTRIBUTE_NAME_SM);
|
|
103
|
+
const o = e.getAttribute(i.RINK_JS_ATTRIBUTE_NAME_MD);
|
|
104
|
+
const s = e.getAttribute(i.RINK_JS_ATTRIBUTE_NAME_LG);
|
|
105
|
+
const c = e.getAttribute(i.RINK_JS_ATTRIBUTE_NAME_XL);
|
|
106
|
+
const a = e.getAttribute(i.RINK_JS_ATTRIBUTE_NAME_XXL);
|
|
107
|
+
if (t.definedString(r)) {
|
|
108
|
+
u(576, e, r);
|
|
109
|
+
n = true;
|
|
110
|
+
}
|
|
111
|
+
if (t.definedString(o)) {
|
|
112
|
+
u(768, e, o);
|
|
113
|
+
n = true;
|
|
114
|
+
}
|
|
115
|
+
if (t.definedString(s)) {
|
|
116
|
+
u(992, e, s);
|
|
117
|
+
n = true;
|
|
118
|
+
}
|
|
119
|
+
if (t.definedString(c)) {
|
|
120
|
+
u(1200, e, c);
|
|
121
|
+
n = true;
|
|
122
|
+
}
|
|
123
|
+
if (t.definedString(a)) {
|
|
124
|
+
u(1400, e, a);
|
|
125
|
+
n = true;
|
|
126
|
+
}
|
|
127
|
+
if (!n) {
|
|
128
|
+
f(e);
|
|
129
|
+
}
|
|
130
|
+
return n;
|
|
131
|
+
}
|
|
132
|
+
function f(e) {
|
|
133
|
+
const n = e.attributes;
|
|
134
|
+
const r = n.length;
|
|
135
|
+
for (let o = 0; o < r; o++) {
|
|
136
|
+
const r = n[o];
|
|
137
|
+
if (r.name.startsWith(i.RINK_JS_ATTRIBUTE_NAME_CUSTOM)) {
|
|
138
|
+
const n = r.name.split("-");
|
|
139
|
+
const i = n[n.length - 1];
|
|
140
|
+
const o = r.value;
|
|
141
|
+
if (t.definedString(o)) {
|
|
142
|
+
u(parseInt(i), e, o);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function u(t, e, n) {
|
|
148
|
+
if (!Object.prototype.hasOwnProperty.call(o, t.toString())) {
|
|
149
|
+
o[t.toString()] = [];
|
|
150
|
+
}
|
|
151
|
+
o[t.toString()].push({
|
|
152
|
+
anchorTag: e,
|
|
153
|
+
newTarget: n,
|
|
154
|
+
originalTarget: e.getAttribute("target")
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
function d() {
|
|
158
|
+
if (s !== 0) {
|
|
159
|
+
clearTimeout(s);
|
|
160
|
+
}
|
|
161
|
+
s = setTimeout(() => g(), e.responsiveDelay);
|
|
162
|
+
}
|
|
163
|
+
function g() {
|
|
164
|
+
T(l());
|
|
165
|
+
}
|
|
166
|
+
function l() {
|
|
167
|
+
const t = [];
|
|
168
|
+
for (const e in o) {
|
|
169
|
+
if (Object.prototype.hasOwnProperty.call(o, e)) {
|
|
170
|
+
const n = window.innerWidth;
|
|
171
|
+
const r = parseInt(e);
|
|
172
|
+
if (n >= r) {
|
|
173
|
+
const n = o[e];
|
|
174
|
+
const r = n.length;
|
|
175
|
+
t.push(e);
|
|
176
|
+
for (let t = 0; t < r; t++) {
|
|
177
|
+
const e = n[t];
|
|
178
|
+
e.anchorTag.setAttribute("target", e.newTarget);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return t;
|
|
184
|
+
}
|
|
185
|
+
function T(t) {
|
|
186
|
+
for (const e in o) {
|
|
187
|
+
if (Object.prototype.hasOwnProperty.call(o, e)) {
|
|
188
|
+
if (t.indexOf(e) === -1) {
|
|
189
|
+
const t = o[e];
|
|
190
|
+
const n = t.length;
|
|
191
|
+
for (let e = 0; e < n; e++) {
|
|
192
|
+
const n = t[e];
|
|
193
|
+
n.anchorTag.setAttribute("target", n.originalTarget);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
const _ = {
|
|
200
|
+
setConfiguration: r => {
|
|
201
|
+
if (t.definedObject(r)) {
|
|
202
|
+
const t = e;
|
|
203
|
+
let i = false;
|
|
204
|
+
for (const e in r) {
|
|
205
|
+
if (Object.prototype.hasOwnProperty.call(r, e) && Object.prototype.hasOwnProperty.call(t, e) && t[e] !== r[e]) {
|
|
206
|
+
t[e] = r[e];
|
|
207
|
+
i = true;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (i) {
|
|
211
|
+
e = n.Options.get(t);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return _;
|
|
215
|
+
},
|
|
216
|
+
getVersion: () => "1.0.0"
|
|
217
|
+
};
|
|
218
|
+
(() => {
|
|
219
|
+
e = n.Options.get();
|
|
220
|
+
r.onContentLoaded(() => c());
|
|
221
|
+
if (!t.defined(window.$rink)) {
|
|
222
|
+
window.$rink = _;
|
|
223
|
+
}
|
|
224
|
+
})();
|
|
225
|
+
})();//# sourceMappingURL=rink.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/williamtroup/Documents/GitHub%20Repos/Rink.js/dist/rink.esm.js"],"names":["Is","Is2","defined","value","toString","definedObject","object","definedString","definedNumber","Default","Default2","getString","defaultValue","getNumber","getObject","Configuration","Configuration2","Options","Options2","get","newConfigurationOptions","configurationOptions","responsiveDelay","DocumentElement","DocumentElement2","onContentLoaded","onLoadFunc","document","readyState","addEventListener","Constant","Constant2","RINK_JS_ATTRIBUTE_NAME_SM","RINK_JS_ATTRIBUTE_NAME_MD","RINK_JS_ATTRIBUTE_NAME_LG","RINK_JS_ATTRIBUTE_NAME_XL","RINK_JS_ATTRIBUTE_NAME_XXL","RINK_JS_ATTRIBUTE_NAME_CUSTOM","_configurationOptions","_screenWidthAnchors","_screenWidthChangeTimer","render","tagTypes","tagTypesLength","length","anchorTagsFound","tagTypeIndex","domElements","getElementsByTagName","elements","slice","call","elementsLength","elementIndex","renderElement","window","onWindowResize","updateAnchorTags","anchorElement","added","attributeSmData","getAttribute","attributeMdData","attributeLgData","attributeXlData","attributeXxlData","addAnchorToScreenWidthAnchors","findCustomSizeAnchor","anchorTagAttributes","attributes","anchorTagAttributesLength","anchorTagAttributeIndex","anchorTagAttribute","name","startsWith","attributeNameParts","split","attributeWidth","anchorTarget","parseInt","screenSize","newTarget","Object","prototype","hasOwnProperty","push","anchorTag","originalTarget","clearTimeout","setTimeout","updateAnchorTagsNotProcessed","updateAnchorTagTargets","screenWidthsProcessed","screenWidth","windowWidth","innerWidth","windowCheckWidth","anchorTags","anchorTagsLength","anchorTagIndex","setAttribute","indexOf","_public","setConfiguration","existingConfigurationOptions","configurationOptionsHaveChanged","propertyName","getVersion","$rink"],"mappings":"AACA,IAAIA;;AACJ,CAAEC;IACA,SAASC,EAAQC;QACf,OAAOA,MAAU,QAAQA,WAAe,KAAKA,EAAMC,eAAe;AACpE;IACAH,EAAIC,UAAUA;IACd,SAASG,EAAcC;QACrB,OAAOJ,EAAQI,aAAkBA,MAAW;AAC9C;IACAL,EAAII,gBAAgBA;IACpB,SAASE,EAAcD;QACrB,OAAOJ,EAAQI,aAAkBA,MAAW;AAC9C;IACAL,EAAIM,gBAAgBA;IACpB,SA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strict";
|
|
2
|
+
|
|
3
|
+
var t;
|
|
4
|
+
|
|
5
|
+
(t => {
|
|
6
|
+
function e(t) {
|
|
7
|
+
return t !== null && t !== void 0 && t.toString() !== "";
|
|
8
|
+
}
|
|
9
|
+
t.defined = e;
|
|
10
|
+
function n(t) {
|
|
11
|
+
return e(t) && typeof t === "object";
|
|
12
|
+
}
|
|
13
|
+
t.definedObject = n;
|
|
14
|
+
function r(t) {
|
|
15
|
+
return e(t) && typeof t === "string";
|
|
16
|
+
}
|
|
17
|
+
t.definedString = r;
|
|
18
|
+
function i(t) {
|
|
19
|
+
return e(t) && typeof t === "number";
|
|
20
|
+
}
|
|
21
|
+
t.definedNumber = i;
|
|
22
|
+
})(t || (t = {}));
|
|
23
|
+
|
|
24
|
+
var e;
|
|
25
|
+
|
|
26
|
+
(e => {
|
|
27
|
+
function n(e, n) {
|
|
28
|
+
return t.definedString(e) ? e : n;
|
|
29
|
+
}
|
|
30
|
+
e.getString = n;
|
|
31
|
+
function r(e, n) {
|
|
32
|
+
return t.definedNumber(e) ? e : n;
|
|
33
|
+
}
|
|
34
|
+
e.getNumber = r;
|
|
35
|
+
function i(e, n) {
|
|
36
|
+
return t.definedObject(e) ? e : n;
|
|
37
|
+
}
|
|
38
|
+
e.getObject = i;
|
|
39
|
+
})(e || (e = {}));
|
|
40
|
+
|
|
41
|
+
var n;
|
|
42
|
+
|
|
43
|
+
(t => {
|
|
44
|
+
let n;
|
|
45
|
+
(t => {
|
|
46
|
+
function n(t = null) {
|
|
47
|
+
const n = e.getObject(t, {});
|
|
48
|
+
n.responsiveDelay = e.getNumber(n.responsiveDelay, 250);
|
|
49
|
+
return n;
|
|
50
|
+
}
|
|
51
|
+
t.get = n;
|
|
52
|
+
})(n = t.Options || (t.Options = {}));
|
|
53
|
+
})(n || (n = {}));
|
|
54
|
+
|
|
55
|
+
var r;
|
|
56
|
+
|
|
57
|
+
(t => {
|
|
58
|
+
function e(t) {
|
|
59
|
+
if (document.readyState === "loading") {
|
|
60
|
+
document.addEventListener("DOMContentLoaded", () => t());
|
|
61
|
+
} else {
|
|
62
|
+
t();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
t.onContentLoaded = e;
|
|
66
|
+
})(r || (r = {}));
|
|
67
|
+
|
|
68
|
+
var i;
|
|
69
|
+
|
|
70
|
+
(t => {
|
|
71
|
+
t.RINK_JS_ATTRIBUTE_NAME_SM = "data-rink-js-sm";
|
|
72
|
+
t.RINK_JS_ATTRIBUTE_NAME_MD = "data-rink-js-md";
|
|
73
|
+
t.RINK_JS_ATTRIBUTE_NAME_LG = "data-rink-js-lg";
|
|
74
|
+
t.RINK_JS_ATTRIBUTE_NAME_XL = "data-rink-js-xl";
|
|
75
|
+
t.RINK_JS_ATTRIBUTE_NAME_XXL = "data-rink-js-xxl";
|
|
76
|
+
t.RINK_JS_ATTRIBUTE_NAME_CUSTOM = "data-rink-js";
|
|
77
|
+
})(i || (i = {}));
|
|
78
|
+
|
|
79
|
+
(() => {
|
|
80
|
+
let e = {};
|
|
81
|
+
const o = {};
|
|
82
|
+
let s = 0;
|
|
83
|
+
function c() {
|
|
84
|
+
const t = [ "a" ];
|
|
85
|
+
const e = t.length;
|
|
86
|
+
let n = false;
|
|
87
|
+
for (let r = 0; r < e; r++) {
|
|
88
|
+
const e = document.getElementsByTagName(t[r]);
|
|
89
|
+
const i = [].slice.call(e);
|
|
90
|
+
const o = i.length;
|
|
91
|
+
for (let t = 0; t < o; t++) {
|
|
92
|
+
if (a(i[t])) {
|
|
93
|
+
n = true;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (n) {
|
|
98
|
+
window.addEventListener("resize", d);
|
|
99
|
+
g();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function a(e) {
|
|
103
|
+
let n = false;
|
|
104
|
+
const r = e.getAttribute(i.RINK_JS_ATTRIBUTE_NAME_SM);
|
|
105
|
+
const o = e.getAttribute(i.RINK_JS_ATTRIBUTE_NAME_MD);
|
|
106
|
+
const s = e.getAttribute(i.RINK_JS_ATTRIBUTE_NAME_LG);
|
|
107
|
+
const c = e.getAttribute(i.RINK_JS_ATTRIBUTE_NAME_XL);
|
|
108
|
+
const a = e.getAttribute(i.RINK_JS_ATTRIBUTE_NAME_XXL);
|
|
109
|
+
if (t.definedString(r)) {
|
|
110
|
+
u(576, e, r);
|
|
111
|
+
n = true;
|
|
112
|
+
}
|
|
113
|
+
if (t.definedString(o)) {
|
|
114
|
+
u(768, e, o);
|
|
115
|
+
n = true;
|
|
116
|
+
}
|
|
117
|
+
if (t.definedString(s)) {
|
|
118
|
+
u(992, e, s);
|
|
119
|
+
n = true;
|
|
120
|
+
}
|
|
121
|
+
if (t.definedString(c)) {
|
|
122
|
+
u(1200, e, c);
|
|
123
|
+
n = true;
|
|
124
|
+
}
|
|
125
|
+
if (t.definedString(a)) {
|
|
126
|
+
u(1400, e, a);
|
|
127
|
+
n = true;
|
|
128
|
+
}
|
|
129
|
+
if (!n) {
|
|
130
|
+
f(e);
|
|
131
|
+
}
|
|
132
|
+
return n;
|
|
133
|
+
}
|
|
134
|
+
function f(e) {
|
|
135
|
+
const n = e.attributes;
|
|
136
|
+
const r = n.length;
|
|
137
|
+
for (let o = 0; o < r; o++) {
|
|
138
|
+
const r = n[o];
|
|
139
|
+
if (r.name.startsWith(i.RINK_JS_ATTRIBUTE_NAME_CUSTOM)) {
|
|
140
|
+
const n = r.name.split("-");
|
|
141
|
+
const i = n[n.length - 1];
|
|
142
|
+
const o = r.value;
|
|
143
|
+
if (t.definedString(o)) {
|
|
144
|
+
u(parseInt(i), e, o);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function u(t, e, n) {
|
|
150
|
+
if (!Object.prototype.hasOwnProperty.call(o, t.toString())) {
|
|
151
|
+
o[t.toString()] = [];
|
|
152
|
+
}
|
|
153
|
+
o[t.toString()].push({
|
|
154
|
+
anchorTag: e,
|
|
155
|
+
newTarget: n,
|
|
156
|
+
originalTarget: e.getAttribute("target")
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
function d() {
|
|
160
|
+
if (s !== 0) {
|
|
161
|
+
clearTimeout(s);
|
|
162
|
+
}
|
|
163
|
+
s = setTimeout(() => g(), e.responsiveDelay);
|
|
164
|
+
}
|
|
165
|
+
function g() {
|
|
166
|
+
T(l());
|
|
167
|
+
}
|
|
168
|
+
function l() {
|
|
169
|
+
const t = [];
|
|
170
|
+
for (const e in o) {
|
|
171
|
+
if (Object.prototype.hasOwnProperty.call(o, e)) {
|
|
172
|
+
const n = window.innerWidth;
|
|
173
|
+
const r = parseInt(e);
|
|
174
|
+
if (n >= r) {
|
|
175
|
+
const n = o[e];
|
|
176
|
+
const r = n.length;
|
|
177
|
+
t.push(e);
|
|
178
|
+
for (let t = 0; t < r; t++) {
|
|
179
|
+
const e = n[t];
|
|
180
|
+
e.anchorTag.setAttribute("target", e.newTarget);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return t;
|
|
186
|
+
}
|
|
187
|
+
function T(t) {
|
|
188
|
+
for (const e in o) {
|
|
189
|
+
if (Object.prototype.hasOwnProperty.call(o, e)) {
|
|
190
|
+
if (t.indexOf(e) === -1) {
|
|
191
|
+
const t = o[e];
|
|
192
|
+
const n = t.length;
|
|
193
|
+
for (let e = 0; e < n; e++) {
|
|
194
|
+
const n = t[e];
|
|
195
|
+
n.anchorTag.setAttribute("target", n.originalTarget);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const _ = {
|
|
202
|
+
setConfiguration: r => {
|
|
203
|
+
if (t.definedObject(r)) {
|
|
204
|
+
const t = e;
|
|
205
|
+
let i = false;
|
|
206
|
+
for (const e in r) {
|
|
207
|
+
if (Object.prototype.hasOwnProperty.call(r, e) && Object.prototype.hasOwnProperty.call(t, e) && t[e] !== r[e]) {
|
|
208
|
+
t[e] = r[e];
|
|
209
|
+
i = true;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if (i) {
|
|
213
|
+
e = n.Options.get(t);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return _;
|
|
217
|
+
},
|
|
218
|
+
getVersion: () => "1.0.0"
|
|
219
|
+
};
|
|
220
|
+
(() => {
|
|
221
|
+
e = n.Options.get();
|
|
222
|
+
r.onContentLoaded(() => c());
|
|
223
|
+
if (!t.defined(window.$rink)) {
|
|
224
|
+
window.$rink = _;
|
|
225
|
+
}
|
|
226
|
+
})();
|
|
227
|
+
})();//# sourceMappingURL=rink.js.map
|
package/dist/rink.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/williamtroup/Documents/GitHub%20Repos/Rink.js/dist/rink.js"],"names":["Is","Is2","defined","value","toString","definedObject","object","definedString","definedNumber","Default","Default2","getString","defaultValue","getNumber","getObject","Configuration","Configuration2","Options","Options2","get","newConfigurationOptions","configurationOptions","responsiveDelay","DocumentElement","DocumentElement2","onContentLoaded","onLoadFunc","document","readyState","addEventListener","Constant","Constant2","RINK_JS_ATTRIBUTE_NAME_SM","RINK_JS_ATTRIBUTE_NAME_MD","RINK_JS_ATTRIBUTE_NAME_LG","RINK_JS_ATTRIBUTE_NAME_XL","RINK_JS_ATTRIBUTE_NAME_XXL","RINK_JS_ATTRIBUTE_NAME_CUSTOM","_configurationOptions","_screenWidthAnchors","_screenWidthChangeTimer","render","tagTypes","tagTypesLength","length","anchorTagsFound","tagTypeIndex","domElements","getElementsByTagName","elements","slice","call","elementsLength","elementIndex","renderElement","window","onWindowResize","updateAnchorTags","anchorElement","added","attributeSmData","getAttribute","attributeMdData","attributeLgData","attributeXlData","attributeXxlData","addAnchorToScreenWidthAnchors","findCustomSizeAnchor","anchorTagAttributes","attributes","anchorTagAttributesLength","anchorTagAttributeIndex","anchorTagAttribute","name","startsWith","attributeNameParts","split","attributeWidth","anchorTarget","parseInt","screenSize","newTarget","Object","prototype","hasOwnProperty","push","anchorTag","originalTarget","clearTimeout","setTimeout","updateAnchorTagsNotProcessed","updateAnchorTagTargets","screenWidthsProcessed","screenWidth","windowWidth","innerWidth","windowCheckWidth","anchorTags","anchorTagsLength","anchorTagIndex","setAttribute","indexOf","_public","setConfiguration","existingConfigurationOptions","configurationOptionsHaveChanged","propertyName","getVersion","$rink"],"mappings":"AAAA;;AAGA,IAAIA;;AACJ,CAAEC;IACA,SAASC,EAAQC;QACf,OAAOA,MAAU,QAAQA,WAAe,KAAKA,EAAMC,eAAe;AACpE;IACAH,EAAIC,UAAUA;IACd,SAASG,EAAcC;QACrB,OAAOJ,EAAQI,aAAkBA,MAAW;AAC9C;IACAL,EAAII,gBAAgBA;IACpB,SAASE,EAAcD;QACrB,OAAOJ,EAAQI,aAAkBA,MAAW;AAC9C;IACAL,EAAIM,gBAAgBA;IACpB,SAASC,EAAcF;QACrB,OAAOJ,EAAQI,aAAkBA,MAAW;AAC9C;IACAL,EAAIO,gBAAgBA;AACrB,EAjBD,CAiBGR,MAAOA,IAAK,CAAC;;AAGhB,IAAIS;;AACJ,CAAEC;IACA,SAASC,EAAUR,GAAOS;QACxB,OAAOZ,EAAGO,cAAcJ,KAASA,IAAQS;AAC3C;IACAF,EAASC,YAAYA;IACrB,SAASE,EAAUV,GAAOS;QACxB,OAAOZ,EAAGQ,cAAcL,KAASA,IAAQS;AAC3C;IACAF,EAASG,YAAYA;IACrB,SAASC,EAAUX,GAAOS;QACxB,OAAOZ,EAAGK,cAAcF,KAASA,IAAQS;AAC3C;IACAF,EAASI,YAAYA;AACtB,EAbD,CAaGL,MAAYA,IAAU,CAAC;;AAG1B,IAAIM;;AACJ,CAAEC;IACA,IAAIC;IACJ,CAAEC;QACA,SAASC,EAAIC,IAA0B;YACrC,MAAMC,IAAuBZ,EAAQK,UAAUM,GAAyB,CAAC;YACzEC,EAAqBC,kBAAkBb,EAAQI,UAAUQ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,KAAK,MAAMC,KAAgBrF,GAAsB;oBAC/C,IAAI6D,OAAOC,UAAUC,eAAejC,KAAK9B,GAAsBqF,MAAiBxB,OAAOC,UAAUC,eAAejC,KAAKqD,GAA8BE,MAAiBF,EAA6BE,OAAkBrF,EAAqBqF,IAAe;wBACrPF,EAA6BE,KAAgBrF,EAAqBqF;wBAClED,IAAkC;AACpC;AACF;gBACA,IAAIA,GAAiC;oBACnCnE,IAAwBvB,EAAcE,QAAQE,IAAIqF;AACpD;AACF;YACA,OAAOF;;QAOTK,YAAY,MACH;;IAGX;QACErE,IAAwBvB,EAAcE,QAAQE;QAC9CI,EAAgBE,gBAAgB,MAAMgB;QACtC,KAAKzC,EAAGE,QAAQqD,OAAOqD,QAAQ;YAC7BrD,OAAOqD,QAAQN;AACjB;AACD,MAND;AAOD,EAhKD","sourcesContent":[null]}
|
package/dist/rink.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var t,e,n,r,i,o,a;(t=>{function e(t){return null!=t&&""!==t.toString()}t.defined=e,t.definedObject=function(t){return e(t)&&"object"==typeof t},t.definedString=function(t){return e(t)&&"string"==typeof t},t.definedNumber=function(t){return e(t)&&"number"==typeof t}})(t||(t={})),(n=e||(e={})).getString=function(e,n){return t.definedString(e)?e:n},n.getNumber=function(e,n){return t.definedNumber(e)?e:n},n.getObject=function(e,n){return t.definedObject(e)?e:n},(t=>{let n;(n=t.Options||(t.Options={})).get=function(t=null){const n=e.getObject(t,{});return n.responsiveDelay=e.getNumber(n.responsiveDelay,250),n}})(r||(r={})),(i||(i={})).onContentLoaded=function(t){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>t()):t()},(a=o||(o={})).RINK_JS_ATTRIBUTE_NAME_SM="data-rink-js-sm",a.RINK_JS_ATTRIBUTE_NAME_MD="data-rink-js-md",a.RINK_JS_ATTRIBUTE_NAME_LG="data-rink-js-lg",a.RINK_JS_ATTRIBUTE_NAME_XL="data-rink-js-xl",a.RINK_JS_ATTRIBUTE_NAME_XXL="data-rink-js-xxl",a.RINK_JS_ATTRIBUTE_NAME_CUSTOM="data-rink-js",(()=>{let e={};const n={};let a=0;function c(e){let n=!1;const r=e.getAttribute(o.RINK_JS_ATTRIBUTE_NAME_SM),i=e.getAttribute(o.RINK_JS_ATTRIBUTE_NAME_MD),a=e.getAttribute(o.RINK_JS_ATTRIBUTE_NAME_LG),c=e.getAttribute(o.RINK_JS_ATTRIBUTE_NAME_XL),d=e.getAttribute(o.RINK_JS_ATTRIBUTE_NAME_XXL);return t.definedString(r)&&(s(576,e,r),n=!0),t.definedString(i)&&(s(768,e,i),n=!0),t.definedString(a)&&(s(992,e,a),n=!0),t.definedString(c)&&(s(1200,e,c),n=!0),t.definedString(d)&&(s(1400,e,d),n=!0),n||function(e){const n=e.attributes,r=n.length;for(let i=0;i<r;i++){const r=n[i];if(r.name.startsWith(o.RINK_JS_ATTRIBUTE_NAME_CUSTOM)){const n=r.name.split("-"),i=n[n.length-1],o=r.value;t.definedString(o)&&s(parseInt(i),e,o)}}}(e),n}function s(t,e,r){Object.prototype.hasOwnProperty.call(n,t.toString())||(n[t.toString()]=[]),n[t.toString()].push({anchorTag:e,newTarget:r,originalTarget:e.getAttribute("target")})}function d(){0!==a&&clearTimeout(a),a=setTimeout(()=>u(),e.responsiveDelay)}function u(){!function(t){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e)&&-1===t.indexOf(e)){const t=n[e],r=t.length;for(let e=0;e<r;e++){const n=t[e];n.anchorTag.setAttribute("target",n.originalTarget)}}}(function(){const t=[];for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e)){if(window.innerWidth>=parseInt(e)){const r=n[e],i=r.length;t.push(e);for(let t=0;t<i;t++){const e=r[t];e.anchorTag.setAttribute("target",e.newTarget)}}}return t}())}const g={setConfiguration:n=>{if(t.definedObject(n)){const t=e;let i=!1;for(const e in n)Object.prototype.hasOwnProperty.call(n,e)&&Object.prototype.hasOwnProperty.call(t,e)&&t[e]!==n[e]&&(t[e]=n[e],i=!0);i&&(e=r.Options.get(t))}return g},getVersion:()=>"1.0.0"};e=r.Options.get(),i.onContentLoaded(()=>function(){const t=["a"],e=t.length;let n=!1;for(let r=0;r<e;r++){const e=document.getElementsByTagName(t[r]),i=[].slice.call(e),o=i.length;for(let t=0;t<o;t++)c(i[t])&&(n=!0)}n&&(window.addEventListener("resize",d),u())}()),t.defined(window.$rink)||(window.$rink=g)})();
|
|
Binary file
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { defineConfig } from "eslint/config";
|
|
2
|
+
import typescriptEslint from "@typescript-eslint/eslint-plugin";
|
|
3
|
+
import tsParser from "@typescript-eslint/parser";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import js from "@eslint/js";
|
|
7
|
+
import { FlatCompat } from "@eslint/eslintrc";
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
const __filename = fileURLToPath( import.meta.url );
|
|
11
|
+
const __dirname = path.dirname( __filename );
|
|
12
|
+
const compat = new FlatCompat( {
|
|
13
|
+
baseDirectory: __dirname,
|
|
14
|
+
recommendedConfig: js.configs.recommended,
|
|
15
|
+
allConfig: js.configs.all
|
|
16
|
+
} );
|
|
17
|
+
|
|
18
|
+
export default defineConfig( [ {
|
|
19
|
+
extends: compat.extends( "eslint:recommended", "plugin:@typescript-eslint/recommended" ),
|
|
20
|
+
|
|
21
|
+
ignores: [ "dist/**", "node_modules/**", "build/**", "**/*.js" ],
|
|
22
|
+
|
|
23
|
+
plugins: {
|
|
24
|
+
"@typescript-eslint": typescriptEslint,
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
languageOptions: {
|
|
28
|
+
parser: tsParser,
|
|
29
|
+
parserOptions: {
|
|
30
|
+
ecmaVersion: "2022",
|
|
31
|
+
sourceType: "module",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
rules: {
|
|
36
|
+
"@typescript-eslint/no-unused-vars": [ "error" ],
|
|
37
|
+
"@typescript-eslint/no-namespace": "off",
|
|
38
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
39
|
+
"@typescript-eslint/no-unsafe-function-type": "off",
|
|
40
|
+
"no-debugger": "off",
|
|
41
|
+
"prefer-spread": "off",
|
|
42
|
+
},
|
|
43
|
+
} ] );
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rink.js",
|
|
3
|
+
"title": "Rink.js",
|
|
4
|
+
"description": "A JavaScript library for generating responsive HTML link targets.",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"homepage": "https://github.com/williamtroup/Rink.js",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "Bunoon"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/williamtroup/Rink.js"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"typescript",
|
|
17
|
+
"javascript",
|
|
18
|
+
"html5",
|
|
19
|
+
"rink.js",
|
|
20
|
+
"anchor",
|
|
21
|
+
"html",
|
|
22
|
+
"responsive",
|
|
23
|
+
"link",
|
|
24
|
+
"target",
|
|
25
|
+
"render"
|
|
26
|
+
],
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/williamtroup/Rink.js/issues"
|
|
29
|
+
},
|
|
30
|
+
"main": "dist/rink.js",
|
|
31
|
+
"types": "dist/rink.d.ts",
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build-all-verify": "npx eslint '**/*.ts' && npm run build-all",
|
|
34
|
+
"build-all": "npm run build && npm run build-minimized",
|
|
35
|
+
"build": "tsup --config tsup.build.config.ts && tsup --config tsup.build.esm.config.ts",
|
|
36
|
+
"build-minimized": "tsup --config tsup.build.min.config.ts",
|
|
37
|
+
"build-typescript": "tsup --config tsup.build.config.ts",
|
|
38
|
+
"build-typescript-esm": "tsup --config tsup.build.esm.config.ts",
|
|
39
|
+
"build-typescript-minimized": "tsup --config tsup.build.min.config.ts"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@swc/core": "^1.15.10",
|
|
43
|
+
"sass": "^1.97.3",
|
|
44
|
+
"terser": "^5.46.0",
|
|
45
|
+
"tsup": "^8.5.1",
|
|
46
|
+
"typescript": "^5.9.3",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^8.53.1",
|
|
48
|
+
"@typescript-eslint/parser": "^8.53.1"
|
|
49
|
+
}
|
|
50
|
+
}
|
package/src/rink.ts
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rink.js
|
|
3
|
+
*
|
|
4
|
+
* A JavaScript library for generating responsive HTML link targets.
|
|
5
|
+
*
|
|
6
|
+
* @file rink.ts
|
|
7
|
+
* @version v1.0.0
|
|
8
|
+
* @author Bunoon
|
|
9
|
+
* @license MIT License
|
|
10
|
+
* @copyright Bunoon 2026
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
type AnchorOptions,
|
|
16
|
+
type ConfigurationOptions } from "./ts/type";
|
|
17
|
+
|
|
18
|
+
import { type PublicApi } from "./ts/api";
|
|
19
|
+
|
|
20
|
+
import { Is } from "./ts/data/is";
|
|
21
|
+
import { Configuration } from "./ts/options/config";
|
|
22
|
+
import { DocumentElement } from "./ts/dom/document-element";
|
|
23
|
+
import { Constant } from "./ts/constant";
|
|
24
|
+
import { Char, ScreenSize, Value } from "./ts/data/enum";
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
( () : void => {
|
|
28
|
+
// Variables: Configuration
|
|
29
|
+
let _configurationOptions: ConfigurationOptions = {} as ConfigurationOptions;
|
|
30
|
+
|
|
31
|
+
// Variables: Anchors
|
|
32
|
+
const _screenWidthAnchors: Record<string, AnchorOptions[]> = {};
|
|
33
|
+
let _screenWidthChangeTimer: number = 0;
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
38
|
+
* Rendering
|
|
39
|
+
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
function render() : void {
|
|
43
|
+
const tagTypes: string[] = [ "a" ];
|
|
44
|
+
const tagTypesLength: number = tagTypes.length;
|
|
45
|
+
let anchorTagsFound: boolean = false;
|
|
46
|
+
|
|
47
|
+
for ( let tagTypeIndex: number = 0; tagTypeIndex < tagTypesLength; tagTypeIndex++ ) {
|
|
48
|
+
const domElements: HTMLCollectionOf<Element> = document.getElementsByTagName( tagTypes[ tagTypeIndex ] );
|
|
49
|
+
const elements: HTMLElement[] = [].slice.call( domElements );
|
|
50
|
+
const elementsLength: number = elements.length;
|
|
51
|
+
|
|
52
|
+
for ( let elementIndex: number = 0; elementIndex < elementsLength; elementIndex++ ) {
|
|
53
|
+
if ( renderElement( elements[ elementIndex ] as HTMLAnchorElement ) ) {
|
|
54
|
+
anchorTagsFound = true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if ( anchorTagsFound ) {
|
|
60
|
+
window.addEventListener( "resize", onWindowResize );
|
|
61
|
+
|
|
62
|
+
updateAnchorTags();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function renderElement( anchorElement: HTMLAnchorElement ) : boolean {
|
|
67
|
+
let added: boolean = false;
|
|
68
|
+
|
|
69
|
+
const attributeSmData: string = anchorElement.getAttribute( Constant.RINK_JS_ATTRIBUTE_NAME_SM )!;
|
|
70
|
+
const attributeMdData: string = anchorElement.getAttribute( Constant.RINK_JS_ATTRIBUTE_NAME_MD )!;
|
|
71
|
+
const attributeLgData: string = anchorElement.getAttribute( Constant.RINK_JS_ATTRIBUTE_NAME_LG )!;
|
|
72
|
+
const attributeXlData: string = anchorElement.getAttribute( Constant.RINK_JS_ATTRIBUTE_NAME_XL )!;
|
|
73
|
+
const attributeXxlData: string = anchorElement.getAttribute( Constant.RINK_JS_ATTRIBUTE_NAME_XXL )!;
|
|
74
|
+
|
|
75
|
+
if ( Is.definedString( attributeSmData ) ) {
|
|
76
|
+
addAnchorToScreenWidthAnchors( ScreenSize.sm, anchorElement, attributeSmData );
|
|
77
|
+
added = true;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if ( Is.definedString( attributeMdData ) ) {
|
|
81
|
+
addAnchorToScreenWidthAnchors( ScreenSize.md, anchorElement, attributeMdData );
|
|
82
|
+
added = true;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if ( Is.definedString( attributeLgData ) ) {
|
|
86
|
+
addAnchorToScreenWidthAnchors( ScreenSize.lg, anchorElement, attributeLgData );
|
|
87
|
+
added = true;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if ( Is.definedString( attributeXlData ) ) {
|
|
91
|
+
addAnchorToScreenWidthAnchors( ScreenSize.xl, anchorElement, attributeXlData );
|
|
92
|
+
added = true;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if ( Is.definedString( attributeXxlData ) ) {
|
|
96
|
+
addAnchorToScreenWidthAnchors( ScreenSize.xxl, anchorElement, attributeXxlData );
|
|
97
|
+
added = true;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if ( !added ) {
|
|
101
|
+
findCustomSizeAnchor( anchorElement );
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return added;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function findCustomSizeAnchor( anchorElement: HTMLAnchorElement ) : void {
|
|
108
|
+
const anchorTagAttributes: NamedNodeMap = anchorElement.attributes;
|
|
109
|
+
const anchorTagAttributesLength: number = anchorTagAttributes.length;
|
|
110
|
+
|
|
111
|
+
for ( let anchorTagAttributeIndex = 0; anchorTagAttributeIndex < anchorTagAttributesLength; anchorTagAttributeIndex++ ) {
|
|
112
|
+
const anchorTagAttribute: Attr = anchorTagAttributes[ anchorTagAttributeIndex ];
|
|
113
|
+
|
|
114
|
+
if ( anchorTagAttribute.name.startsWith( Constant.RINK_JS_ATTRIBUTE_NAME_CUSTOM ) ) {
|
|
115
|
+
const attributeNameParts: string[] = anchorTagAttribute.name.split( Char.dash );
|
|
116
|
+
const attributeWidth: string = attributeNameParts[ attributeNameParts.length - 1 ];
|
|
117
|
+
const anchorTarget: string = anchorTagAttribute.value;
|
|
118
|
+
|
|
119
|
+
if ( Is.definedString( anchorTarget ) ) {
|
|
120
|
+
addAnchorToScreenWidthAnchors( parseInt( attributeWidth ), anchorElement, anchorTarget );
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function addAnchorToScreenWidthAnchors( screenSize: number, anchorElement: HTMLAnchorElement, newTarget: string ) : void {
|
|
127
|
+
if ( !Object.prototype.hasOwnProperty.call( _screenWidthAnchors, screenSize.toString() ) ) {
|
|
128
|
+
_screenWidthAnchors[ screenSize.toString() ] = [];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
_screenWidthAnchors[ screenSize.toString() ].push( {
|
|
132
|
+
anchorTag: anchorElement,
|
|
133
|
+
newTarget: newTarget,
|
|
134
|
+
originalTarget: anchorElement.getAttribute( "target" )!
|
|
135
|
+
} as AnchorOptions );
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
/*
|
|
140
|
+
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
141
|
+
* Window Resizing
|
|
142
|
+
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
143
|
+
*/
|
|
144
|
+
|
|
145
|
+
function onWindowResize() : void {
|
|
146
|
+
if (_screenWidthChangeTimer !== 0) {
|
|
147
|
+
clearTimeout(_screenWidthChangeTimer);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
_screenWidthChangeTimer = setTimeout( () => updateAnchorTags() , _configurationOptions.responsiveDelay! );
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function updateAnchorTags() {
|
|
154
|
+
updateAnchorTagsNotProcessed(updateAnchorTagTargets())
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function updateAnchorTagTargets() : string[] {
|
|
158
|
+
const screenWidthsProcessed: string[] = [];
|
|
159
|
+
|
|
160
|
+
for ( const screenWidth in _screenWidthAnchors ) {
|
|
161
|
+
if ( Object.prototype.hasOwnProperty.call( _screenWidthAnchors, screenWidth ) ) {
|
|
162
|
+
const windowWidth: number = window.innerWidth;
|
|
163
|
+
const windowCheckWidth: number = parseInt(screenWidth);
|
|
164
|
+
|
|
165
|
+
if ( windowWidth >= windowCheckWidth ) {
|
|
166
|
+
const anchorTags: AnchorOptions[] = _screenWidthAnchors[ screenWidth ];
|
|
167
|
+
const anchorTagsLength: number = anchorTags.length;
|
|
168
|
+
|
|
169
|
+
screenWidthsProcessed.push( screenWidth );
|
|
170
|
+
|
|
171
|
+
for ( let anchorTagIndex = 0; anchorTagIndex < anchorTagsLength; anchorTagIndex++ ) {
|
|
172
|
+
const anchorTag: AnchorOptions = anchorTags[ anchorTagIndex ];
|
|
173
|
+
|
|
174
|
+
anchorTag.anchorTag.setAttribute( "target", anchorTag.newTarget! );
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return screenWidthsProcessed;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function updateAnchorTagsNotProcessed( screenWidthsProcessed: string[] ) : void {
|
|
184
|
+
for ( const screenWidth in _screenWidthAnchors ) {
|
|
185
|
+
if ( Object.prototype.hasOwnProperty.call( _screenWidthAnchors, screenWidth ) ) {
|
|
186
|
+
if ( screenWidthsProcessed.indexOf( screenWidth ) === Value.notFound ) {
|
|
187
|
+
const anchorTags: AnchorOptions[] = _screenWidthAnchors[ screenWidth ];
|
|
188
|
+
const anchorTagsLength: number = anchorTags.length;
|
|
189
|
+
|
|
190
|
+
for ( let anchorTagIndex = 0; anchorTagIndex < anchorTagsLength; anchorTagIndex++ ) {
|
|
191
|
+
const anchorTag: AnchorOptions = anchorTags[ anchorTagIndex ];
|
|
192
|
+
|
|
193
|
+
anchorTag.anchorTag.setAttribute( "target", anchorTag.originalTarget! );
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
/*
|
|
202
|
+
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
203
|
+
* Public API Functions:
|
|
204
|
+
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
205
|
+
*/
|
|
206
|
+
|
|
207
|
+
const _public: PublicApi = {
|
|
208
|
+
/*
|
|
209
|
+
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
210
|
+
* Public API Functions: Configuration
|
|
211
|
+
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
212
|
+
*/
|
|
213
|
+
|
|
214
|
+
setConfiguration: ( configurationOptions: ConfigurationOptions ) : PublicApi => {
|
|
215
|
+
if ( Is.definedObject( configurationOptions ) ) {
|
|
216
|
+
const existingConfigurationOptions: ConfigurationOptions = _configurationOptions;
|
|
217
|
+
let configurationOptionsHaveChanged: boolean = false;
|
|
218
|
+
|
|
219
|
+
for ( const propertyName in configurationOptions ) {
|
|
220
|
+
if ( Object.prototype.hasOwnProperty.call( configurationOptions, propertyName ) && Object.prototype.hasOwnProperty.call( existingConfigurationOptions, propertyName ) && existingConfigurationOptions[ propertyName ] !== configurationOptions[ propertyName ] ) {
|
|
221
|
+
existingConfigurationOptions[ propertyName ] = configurationOptions[ propertyName ];
|
|
222
|
+
configurationOptionsHaveChanged = true;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if ( configurationOptionsHaveChanged ) {
|
|
227
|
+
_configurationOptions = Configuration.Options.get( existingConfigurationOptions );
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return _public;
|
|
232
|
+
},
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
/*
|
|
236
|
+
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
237
|
+
* Public API Functions: Additional Data
|
|
238
|
+
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
239
|
+
*/
|
|
240
|
+
|
|
241
|
+
getVersion: () : string => {
|
|
242
|
+
return "1.0.0";
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
/*
|
|
248
|
+
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
249
|
+
* Initialize Rink.js
|
|
250
|
+
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
251
|
+
*/
|
|
252
|
+
|
|
253
|
+
( () : void => {
|
|
254
|
+
_configurationOptions = Configuration.Options.get();
|
|
255
|
+
|
|
256
|
+
DocumentElement.onContentLoaded( () : void => render() );
|
|
257
|
+
|
|
258
|
+
if ( !Is.defined( window.$rink ) ) {
|
|
259
|
+
window.$rink = _public;
|
|
260
|
+
}
|
|
261
|
+
} )();
|
|
262
|
+
} )();
|
package/src/ts/api.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rink.js
|
|
3
|
+
*
|
|
4
|
+
* A JavaScript library for generating responsive HTML link targets.
|
|
5
|
+
*
|
|
6
|
+
* @file api.ts
|
|
7
|
+
* @version v1.0.0
|
|
8
|
+
* @author Bunoon
|
|
9
|
+
* @license MIT License
|
|
10
|
+
* @copyright Bunoon 2026
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
import { type ConfigurationOptions } from "./type";
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export type PublicApi = {
|
|
18
|
+
/*
|
|
19
|
+
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
20
|
+
* Public API Functions: Configuration
|
|
21
|
+
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* setConfiguration().
|
|
26
|
+
*
|
|
27
|
+
* Sets the specific configuration options that should be used.
|
|
28
|
+
*
|
|
29
|
+
* @public
|
|
30
|
+
*
|
|
31
|
+
* @param {Object} configurationOptions All the configuration options that should be set (refer to "Configuration Options" documentation for properties).
|
|
32
|
+
*
|
|
33
|
+
* @returns {Object} The Rink.js class instance.
|
|
34
|
+
*/
|
|
35
|
+
setConfiguration: ( configurationOptions: ConfigurationOptions ) => PublicApi;
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
/*
|
|
39
|
+
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
40
|
+
* Public API Functions: Additional Data
|
|
41
|
+
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* getVersion().
|
|
46
|
+
*
|
|
47
|
+
* Returns the version of Rink.js.
|
|
48
|
+
*
|
|
49
|
+
* @public
|
|
50
|
+
*
|
|
51
|
+
* @returns {string} The version number.
|
|
52
|
+
*/
|
|
53
|
+
getVersion: () => string;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
declare global {
|
|
57
|
+
interface Window {
|
|
58
|
+
$rink: PublicApi;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rink.js
|
|
3
|
+
*
|
|
4
|
+
* A JavaScript library for generating responsive HTML link targets.
|
|
5
|
+
*
|
|
6
|
+
* @file constant.ts
|
|
7
|
+
* @version v1.0.0
|
|
8
|
+
* @author Bunoon
|
|
9
|
+
* @license MIT License
|
|
10
|
+
* @copyright Bunoon 2026
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export namespace Constant {
|
|
15
|
+
export const RINK_JS_ATTRIBUTE_NAME_SM: string = "data-rink-js-sm";
|
|
16
|
+
export const RINK_JS_ATTRIBUTE_NAME_MD: string = "data-rink-js-md";
|
|
17
|
+
export const RINK_JS_ATTRIBUTE_NAME_LG: string = "data-rink-js-lg";
|
|
18
|
+
export const RINK_JS_ATTRIBUTE_NAME_XL: string = "data-rink-js-xl";
|
|
19
|
+
export const RINK_JS_ATTRIBUTE_NAME_XXL: string = "data-rink-js-xxl";
|
|
20
|
+
export const RINK_JS_ATTRIBUTE_NAME_CUSTOM: string = "data-rink-js";
|
|
21
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rink.js
|
|
3
|
+
*
|
|
4
|
+
* A JavaScript library for generating responsive HTML link targets.
|
|
5
|
+
*
|
|
6
|
+
* @file default.ts
|
|
7
|
+
* @version v1.0.0
|
|
8
|
+
* @author Bunoon
|
|
9
|
+
* @license MIT License
|
|
10
|
+
* @copyright Bunoon 2026
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
import { Is } from "./is";
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export namespace Default {
|
|
18
|
+
export function getString( value: any, defaultValue: string ) : string {
|
|
19
|
+
return Is.definedString( value ) ? value : defaultValue;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function getNumber( value: any, defaultValue: number ) : number {
|
|
23
|
+
return Is.definedNumber( value ) ? value : defaultValue;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function getObject( value: any, defaultValue: object ) : any {
|
|
27
|
+
return Is.definedObject( value ) ? value : defaultValue;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rink.js
|
|
3
|
+
*
|
|
4
|
+
* A JavaScript library for generating responsive HTML link targets.
|
|
5
|
+
*
|
|
6
|
+
* @file enum.ts
|
|
7
|
+
* @version v1.0.0
|
|
8
|
+
* @author Bunoon
|
|
9
|
+
* @license MIT License
|
|
10
|
+
* @copyright Bunoon 2026
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export enum Char {
|
|
15
|
+
empty = "",
|
|
16
|
+
dash = "-",
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export enum Value {
|
|
20
|
+
notFound = -1,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export enum ScreenSize {
|
|
24
|
+
sm = 576,
|
|
25
|
+
md = 768,
|
|
26
|
+
lg = 992,
|
|
27
|
+
xl = 1200,
|
|
28
|
+
xxl = 1400,
|
|
29
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rink.js
|
|
3
|
+
*
|
|
4
|
+
* A JavaScript library for generating responsive HTML link targets.
|
|
5
|
+
*
|
|
6
|
+
* @file is.ts
|
|
7
|
+
* @version v1.0.0
|
|
8
|
+
* @author Bunoon
|
|
9
|
+
* @license MIT License
|
|
10
|
+
* @copyright Bunoon 2026
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
import { Char } from "./enum";
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export namespace Is {
|
|
18
|
+
export function defined( value: any ) : boolean {
|
|
19
|
+
return value !== null && value !== undefined && value.toString() !== Char.empty;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function definedObject( object: any ) : boolean {
|
|
23
|
+
return defined( object ) && typeof object === "object";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function definedString( object: any ) : boolean {
|
|
27
|
+
return defined( object ) && typeof object === "string";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function definedNumber( object: any ) : boolean {
|
|
31
|
+
return defined( object ) && typeof object === "number";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rink.js
|
|
3
|
+
*
|
|
4
|
+
* A JavaScript library for generating responsive HTML link targets.
|
|
5
|
+
*
|
|
6
|
+
* @file document-element.ts
|
|
7
|
+
* @version v1.0.0
|
|
8
|
+
* @author Bunoon
|
|
9
|
+
* @license MIT License
|
|
10
|
+
* @copyright Bunoon 2026
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export namespace DocumentElement {
|
|
15
|
+
export function onContentLoaded( onLoadFunc: Function ) : void {
|
|
16
|
+
if ( document.readyState === "loading" ) {
|
|
17
|
+
document.addEventListener( "DOMContentLoaded", () : void => onLoadFunc() );
|
|
18
|
+
} else {
|
|
19
|
+
onLoadFunc();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rink.js
|
|
3
|
+
*
|
|
4
|
+
* A JavaScript library for generating responsive HTML link targets.
|
|
5
|
+
*
|
|
6
|
+
* @file config.ts
|
|
7
|
+
* @version v1.0.0
|
|
8
|
+
* @author Bunoon
|
|
9
|
+
* @license MIT License
|
|
10
|
+
* @copyright Bunoon 2026
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
import { type ConfigurationOptions } from "../type";
|
|
15
|
+
import { Default } from "../data/default";
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
export namespace Configuration {
|
|
19
|
+
export namespace Options {
|
|
20
|
+
export function get( newConfigurationOptions: unknown = null ) : ConfigurationOptions {
|
|
21
|
+
const configurationOptions: ConfigurationOptions = Default.getObject( newConfigurationOptions, {} as ConfigurationOptions );
|
|
22
|
+
configurationOptions.responsiveDelay = Default.getNumber( configurationOptions.responsiveDelay, 250 );
|
|
23
|
+
|
|
24
|
+
return configurationOptions;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
package/src/ts/type.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rink.js
|
|
3
|
+
*
|
|
4
|
+
* A JavaScript library for generating responsive HTML link targets.
|
|
5
|
+
*
|
|
6
|
+
* @file type.ts
|
|
7
|
+
* @version v1.0.0
|
|
8
|
+
* @author Bunoon
|
|
9
|
+
* @license MIT License
|
|
10
|
+
* @copyright Bunoon 2026
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export type ConfigurationOptions = {
|
|
15
|
+
responsiveDelay?: number;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type AnchorOptions = {
|
|
19
|
+
anchorTag: HTMLAnchorElement;
|
|
20
|
+
newTarget?: string;
|
|
21
|
+
originalTarget?: string;
|
|
22
|
+
};
|