From b5376ef4590735df8cfaee2f51e40c8cc0eadd7e Mon Sep 17 00:00:00 2001 From: Steve Mayes Date: Sat, 27 Feb 2016 15:31:51 -0500 Subject: [PATCH 1/6] Updated intro.js definition to reflect v2.0 (1) Updates for v2.0, primarily hint-related items (2) Updates for the IntroJs Factory interface / constructor --- intro.js/intro.js.d.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/intro.js/intro.js.d.ts b/intro.js/intro.js.d.ts index 6763124ba9..a3cb5a8e42 100644 --- a/intro.js/intro.js.d.ts +++ b/intro.js/intro.js.d.ts @@ -1,4 +1,4 @@ -// Type definitions for intro.js 1.1.1 +// Type definitions for intro.js 2.0 // Project: https://github.com/usablica/intro.js // Definitions by: Maxime Fabre // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -29,12 +29,15 @@ declare module IntroJs { overlayOpacity?: number; positionPrecedence?: string[]; disableInteraction?: boolean; + hintPosition: string; + hintButtonLabel: string; steps: Step[]; } interface IntroJs { start(): IntroJs; exit(): IntroJs; + clone(): IntroJs; goToStep(step: number): IntroJs; nextStep(): IntroJs; @@ -48,12 +51,20 @@ declare module IntroJs { onexit(callback: Function): IntroJs; onbeforechange(callback: (element: HTMLElement) => any): IntroJs; onafterchange(callback: (element: HTMLElement) => any): IntroJs; - onchange(callback: Function): IntroJs; + onchange(callback: (element: HTMLElement) => any): IntroJs; oncomplete(callback: Function): IntroJs; + + addHints(): IntroJs; + + onhintsadded(callback: Function): IntroJs; + onhintclick(callback: (hintElement: HTMLElement, item: Step, stepId: number) => any): IntroJs; + onhintclose(callback: (stepId: number) => any): IntroJs; } interface Factory { - (element?: string): IntroJs; + (): IntroJs; + (element: HTMLElement): IntroJs; + (querySelector: string): IntroJs; } } From 09fb173b0b90748278010c084c85f2866c4edd91 Mon Sep 17 00:00:00 2001 From: Steve Mayes Date: Sat, 27 Feb 2016 15:37:20 -0500 Subject: [PATCH 2/6] Updated intro.js tests per definition updates Added and updated tests per the latest intro.js definition updates --- intro.js/intro.js-tests.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/intro.js/intro.js-tests.ts b/intro.js/intro.js-tests.ts index 0ec5938f5c..2f342996e7 100644 --- a/intro.js/intro.js-tests.ts +++ b/intro.js/intro.js-tests.ts @@ -1,6 +1,8 @@ /// var intro = introJs(); +var introWithElement = introJs(document.body); +var introWithQuerySelector = introJs('body'); intro.setOption('doneLabel', 'Next page'); intro.setOption('overlayOpacity', 50); @@ -53,4 +55,18 @@ intro.start() }) .oncomplete(function () { alert('Done'); - }); + }) + .onexit(function () { + alert('Exiting'); + }) + .onhintsadded(function () { + alert('Hints added'); + }) + .onhintclick(function (hintElement, item, stepId) { + element.getAttribute('class'); + }) + .onhintclose(function (stepId) { + alert('Hint close for Step ID ' + stepId); + }) + .addHints() + .clone(); From fe9c877b9309fbd092256a02b2b05340d45f16aa Mon Sep 17 00:00:00 2001 From: Steve Mayes Date: Sat, 27 Feb 2016 15:40:23 -0500 Subject: [PATCH 3/6] Updated the onchange test's parameter Updated the onchange test's parameter so it matches the latest definition. --- intro.js/intro.js-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/intro.js/intro.js-tests.ts b/intro.js/intro.js-tests.ts index 2f342996e7..7dc2afd2a9 100644 --- a/intro.js/intro.js-tests.ts +++ b/intro.js/intro.js-tests.ts @@ -50,8 +50,8 @@ intro.start() .onafterchange(function (element) { element.getAttribute('class'); }) - .onchange(function () { - alert('Changed'); + .onchange(function (element) { + element.getAttribute('class'); }) .oncomplete(function () { alert('Done'); From 1640c7008cef30acb9f5a4f86bb279188f014ced Mon Sep 17 00:00:00 2001 From: Steve Mayes Date: Sat, 27 Feb 2016 20:17:37 -0500 Subject: [PATCH 4/6] Added additional tests for alternate constructors For those objects built with the alternate constructors / IntroJs.Factory functions, test a subset of the IntroJs object's functions to ensure the IntroJs objects are the correct type. --- intro.js/intro.js-tests.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/intro.js/intro.js-tests.ts b/intro.js/intro.js-tests.ts index 7dc2afd2a9..46efe88442 100644 --- a/intro.js/intro.js-tests.ts +++ b/intro.js/intro.js-tests.ts @@ -70,3 +70,11 @@ intro.start() }) .addHints() .clone(); + +introWithElement.start() + .exit() + .clone(); + +introWithQuerySelector.start() + .exit() + .clone(); From e5c72c986c540fe0e9366d9615806c1d0f5cf6a4 Mon Sep 17 00:00:00 2001 From: Steve Mayes Date: Sat, 27 Feb 2016 20:20:27 -0500 Subject: [PATCH 5/6] Fix for the onhintclick test case --- intro.js/intro.js-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intro.js/intro.js-tests.ts b/intro.js/intro.js-tests.ts index 46efe88442..a3e5c0e4dd 100644 --- a/intro.js/intro.js-tests.ts +++ b/intro.js/intro.js-tests.ts @@ -63,7 +63,7 @@ intro.start() alert('Hints added'); }) .onhintclick(function (hintElement, item, stepId) { - element.getAttribute('class'); + hintElement.getAttribute('class'); }) .onhintclose(function (stepId) { alert('Hint close for Step ID ' + stepId); From 4315d16fd511566b3c8603d8c9b352fc75ff1e84 Mon Sep 17 00:00:00 2001 From: Steve Mayes Date: Sat, 27 Feb 2016 20:22:58 -0500 Subject: [PATCH 6/6] Fixes to the Option interface (1) Fixed hintPosition and hintButtonLabel to make them optional. (2) Made steps optional since it is not required by the intro.js library. --- intro.js/intro.js.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/intro.js/intro.js.d.ts b/intro.js/intro.js.d.ts index a3cb5a8e42..b476d5793d 100644 --- a/intro.js/intro.js.d.ts +++ b/intro.js/intro.js.d.ts @@ -29,9 +29,9 @@ declare module IntroJs { overlayOpacity?: number; positionPrecedence?: string[]; disableInteraction?: boolean; - hintPosition: string; - hintButtonLabel: string; - steps: Step[]; + hintPosition?: string; + hintButtonLabel?: string; + steps?: Step[]; } interface IntroJs {