Skip to content

Commit 06d2efe

Browse files
committed
backward compatibility API
1 parent 7b9ec39 commit 06d2efe

File tree

1 file changed

+51
-14
lines changed

1 file changed

+51
-14
lines changed

src/index.ts

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,65 @@ import { version } from "../package.json";
22
import { Hint } from "./packages/hint";
33
import { Tour } from "./packages/tour";
44

5-
/**
6-
* Intro.js module
7-
*/
8-
const introJs = {
5+
class LegacyIntroJs extends Tour {
96
/**
10-
* Create a new Intro.js Tour instance
11-
* @param elementOrSelector Optional target element to start the Tour on
7+
* @deprecated introJs().addHints() is deprecated, please use introJs.hint().addHints() instead
8+
* @param args
129
*/
13-
tour: (elementOrSelector?: string | HTMLElement) =>
14-
new Tour(elementOrSelector),
10+
addHints(..._: any[]) {
11+
console.error(
12+
"introJs().addHints() is deprecated, please use introJs.hint.addHints() instead."
13+
);
14+
}
1515

1616
/**
17-
* Create a new Intro.js Hint instance
18-
* @param elementOrSelector Optional target element to start the Hint on
17+
* @deprecated introJs().addHint() is deprecated, please use introJs.hint.addHint() instead
18+
* @param args
1919
*/
20-
hint: (elementOrSelector?: string | HTMLElement) =>
21-
new Hint(elementOrSelector),
20+
addHint(..._: any[]) {
21+
console.error(
22+
"introJs().addHint() is deprecated, please use introJs.hint.addHint() instead."
23+
);
24+
}
2225

2326
/**
24-
* Current Intro.js version
27+
* @deprecated introJs().removeHints() is deprecated, please use introJs.hint.hideHints() instead
28+
* @param args
2529
*/
26-
version: version,
30+
removeHints(..._: any[]) {
31+
console.error(
32+
"introJs().removeHints() is deprecated, please use introJs.hint.removeHints() instead."
33+
);
34+
}
35+
}
36+
37+
/**
38+
* Intro.js module
39+
*/
40+
const introJs = (elementOrSelector?: string | HTMLElement) => {
41+
console.warn(
42+
"introJs() is deprecated. Please use introJs.tour() or introJs.hint() instead."
43+
);
44+
return new LegacyIntroJs(elementOrSelector);
2745
};
2846

47+
/**
48+
* Create a new Intro.js Tour instance
49+
* @param elementOrSelector Optional target element to start the Tour on
50+
*/
51+
introJs.tour = (elementOrSelector?: string | HTMLElement) =>
52+
new Tour(elementOrSelector);
53+
54+
/**
55+
* Create a new Intro.js Hint instance
56+
* @param elementOrSelector Optional target element to start the Hint on
57+
*/
58+
introJs.hint = (elementOrSelector?: string | HTMLElement) =>
59+
new Hint(elementOrSelector);
60+
61+
/**
62+
* Current Intro.js version
63+
*/
64+
introJs.version = version;
65+
2966
export default introJs;

0 commit comments

Comments
 (0)