From 0af0b461449c6dbb5804135ded3fcffcd88d481c Mon Sep 17 00:00:00 2001 From: Alvaro T Date: Fri, 20 Oct 2017 20:33:25 +0200 Subject: [PATCH] Fixed the interface which error does allow to compile with angular CLI 1.4.9 and Typescript 2.5.3 --- ng-intro/ng-introjs.service.ts | 328 ++++++++++++++++----------------- 1 file changed, 164 insertions(+), 164 deletions(-) diff --git a/ng-intro/ng-introjs.service.ts b/ng-intro/ng-introjs.service.ts index a7ffe1b..2d62156 100644 --- a/ng-intro/ng-introjs.service.ts +++ b/ng-intro/ng-introjs.service.ts @@ -1,182 +1,182 @@ import { Injectable } from '@angular/core'; import { IntroJs } from 'intro.js'; -export enum introStatus{ +export enum introStatus { open, closed } -export interface IIntrojsService{ - intro: IntroJs.IntroJs, - addListener(name: introStatus, callback :Function) :void - removeListener(name: introStatus): void - setOptions: IntroJs.Options, - start(stepId?: number): IntroJs.IntroJs, - exit(): IntroJs.IntroJs, - clear(callback: Function): IntroJs.IntroJs, - - addHints(): IntroJs.IntroJs, - showHint(hintIdx: number): IntroJs.IntroJs, - showHints(): IntroJs.IntroJs, - hideHint(hintIdx:number): IntroJs.IntroJs, - hideHints(): IntroJs.IntroJs - - previous(): IntroJs.IntroJs, - next(): IntroJs.IntroJs, - - refresh(): IntroJs.IntroJs, - - onComplete(callback: Function) : void - onExit(callback: Function) : void - onBeforeChange(callback: Function) : void - onAfterChange(callback: Function) : void - onChange(callback: Function) : void - onHintClick(callback: Function) : void - onHintClose(callback: Function) : void - onHintsAdded(callback: Function) : void +export interface IIntrojsService { + intro: IntroJs.IntroJs, + addListener(name: introStatus, callback: Function): void + removeListener(name: introStatus): void + setOptions(options: IntroJs.Options): IntroJs, + start(stepId?: number): IntroJs.IntroJs, + exit(): IntroJs.IntroJs, + clear(callback: Function): IntroJs.IntroJs, + + addHints(): IntroJs.IntroJs, + showHint(hintIdx: number): IntroJs.IntroJs, + showHints(): IntroJs.IntroJs, + hideHint(hintIdx: number): IntroJs.IntroJs, + hideHints(): IntroJs.IntroJs + + previous(): IntroJs.IntroJs, + next(): IntroJs.IntroJs, + + refresh(): IntroJs.IntroJs, + + onComplete(callback: Function): void + onExit(callback: Function): void + onBeforeChange(callback: Function): void + onAfterChange(callback: Function): void + onChange(callback: Function): void + onHintClick(callback: Function): void + onHintClose(callback: Function): void + onHintsAdded(callback: Function): void } @Injectable() -export class IntrojsService implements IIntrojsService{ +export class IntrojsService implements IIntrojsService { private notifyList = []; - public intro : IntroJs.IntroJs; + public intro: IntroJs.IntroJs; - private isFunction(func){ + private isFunction(func) { return typeof func === "function" } constructor() { - this.intro = introJs(); - } - + this.intro = introJs(); + } + ///adds into notifyList, if there's a valid callback. - addListener(name:introStatus, cb: Function){ - - if(this.isFunction(cb)) - this.notifyList[name] = cb; - } - //remove from this.notifyList. - removeListener(name:introStatus){ - delete this.notifyList[name]; - } - - ///iterate through this.notifyList and call each callback. - private notifyListeners(status : introStatus){ - for(var key in this.notifyList){ - if(this.notifyList.hasOwnProperty(key)){ - if(this.isFunction(this.notifyList[key])) - this.notifyList[key](status); - } - } - } - - setOptions(options: IntroJs.Options){ - return this.intro.setOptions(options); - } - - start(step?:number){ - if (typeof (step) === 'number') { - this.intro.start().goToStep(step); - } else { - this.intro.start(); - } - this.notifyListeners(introStatus.open); - - return this.intro; - } - - exit(){ - this.notifyListeners(introStatus.closed); - return this.intro.exit(); - } - - clear(cb:Function){ - if(typeof(this.intro) !=='undefined') - this.intro.exit(); - - this.intro = introJs(); - - this.notifyListeners(introStatus.closed); - - if(this.isFunction(cb)) cb(); - - return this.intro; - } - - addHints(){ - return this.intro.addHints(); - } - showHint(hintIndex: number){ - return this.intro.showHint(hintIndex); - } - showHints(){ - return this.intro.showHints(); - } - - hideHint(hintIndex: number){ - return this.intro.hideHint(hintIndex); - } - - hideHints(){ - return this.intro.hideHints(); - } - - previous(){ - this.notifyListeners(introStatus.open); - return this.intro.previousStep(); - } - next(){ - this.notifyListeners(introStatus.open); - return this.intro.nextStep(); - - } - - refresh(){ - return this.intro.refresh(); - } - - onComplete(cb:Function){ - return this.intro.oncomplete(()=> { - if(this.isFunction(cb)) cb(); - this.notifyListeners(introStatus.closed); - }); - } - onExit(cb: Function){ - return this.intro.onexit(()=> { - this.notifyListeners(introStatus.closed); - if(this.isFunction(cb)) cb(); - }); - } - onBeforeChange(cb:Function){ - return this.intro.onbeforechange(()=>{ - if(this.isFunction(cb)) cb(); - }); - } - onChange(cb:Function){ - return this.intro.onchange(()=> { - if(this.isFunction(cb)) cb(); - }); - } - onAfterChange(cb:Function){ - return this.intro.onafterchange(()=> { - if(this.isFunction(cb)) cb(); - }); - } - - onHintClick(cb:Function){ - return this.intro.onhintclick(()=> { - if(this.isFunction(cb)) cb(); - }); - } - - onHintClose(cb:Function){ - return this.intro.onhintclose( ()=> { - if(this.isFunction(cb)) cb(); - }); - } - onHintsAdded(cb:Function){ - return this.intro.onhintclose(()=> { - if(this.isFunction(cb)) cb(); - }); - } + addListener(name: introStatus, cb: Function) { + + if (this.isFunction(cb)) + this.notifyList[name] = cb; + } + //remove from this.notifyList. + removeListener(name: introStatus) { + delete this.notifyList[name]; + } + + ///iterate through this.notifyList and call each callback. + private notifyListeners(status: introStatus) { + for (var key in this.notifyList) { + if (this.notifyList.hasOwnProperty(key)) { + if (this.isFunction(this.notifyList[key])) + this.notifyList[key](status); + } + } + } + + setOptions(options: IntroJs.Options) { + return this.intro.setOptions(options); + } + + start(step?: number) { + if (typeof (step) === 'number') { + this.intro.start().goToStep(step); + } else { + this.intro.start(); + } + this.notifyListeners(introStatus.open); + + return this.intro; + } + + exit() { + this.notifyListeners(introStatus.closed); + return this.intro.exit(); + } + + clear(cb: Function) { + if (typeof (this.intro) !== 'undefined') + this.intro.exit(); + + this.intro = introJs(); + + this.notifyListeners(introStatus.closed); + + if (this.isFunction(cb)) cb(); + + return this.intro; + } + + addHints() { + return this.intro.addHints(); + } + showHint(hintIndex: number) { + return this.intro.showHint(hintIndex); + } + showHints() { + return this.intro.showHints(); + } + + hideHint(hintIndex: number) { + return this.intro.hideHint(hintIndex); + } + + hideHints() { + return this.intro.hideHints(); + } + + previous() { + this.notifyListeners(introStatus.open); + return this.intro.previousStep(); + } + next() { + this.notifyListeners(introStatus.open); + return this.intro.nextStep(); + + } + + refresh() { + return this.intro.refresh(); + } + + onComplete(cb: Function) { + return this.intro.oncomplete(() => { + if (this.isFunction(cb)) cb(); + this.notifyListeners(introStatus.closed); + }); + } + onExit(cb: Function) { + return this.intro.onexit(() => { + this.notifyListeners(introStatus.closed); + if (this.isFunction(cb)) cb(); + }); + } + onBeforeChange(cb: Function) { + return this.intro.onbeforechange(() => { + if (this.isFunction(cb)) cb(); + }); + } + onChange(cb: Function) { + return this.intro.onchange(() => { + if (this.isFunction(cb)) cb(); + }); + } + onAfterChange(cb: Function) { + return this.intro.onafterchange(() => { + if (this.isFunction(cb)) cb(); + }); + } + + onHintClick(cb: Function) { + return this.intro.onhintclick(() => { + if (this.isFunction(cb)) cb(); + }); + } + + onHintClose(cb: Function) { + return this.intro.onhintclose(() => { + if (this.isFunction(cb)) cb(); + }); + } + onHintsAdded(cb: Function) { + return this.intro.onhintclose(() => { + if (this.isFunction(cb)) cb(); + }); + } }