Skip to content

Fixed the interface which error does allow to compile with angular CL… #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
328 changes: 164 additions & 164 deletions ng-intro/ng-introjs.service.ts
Original file line number Diff line number Diff line change
@@ -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(() => {
Copy link

@ChrisMBarr ChrisMBarr Apr 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've copied your code into my project, but notice this typo that's not your fault, but easily overlooked. This should use this.intro.onhintsadded here since the above method also calls this.intro.onhintclosed

if (this.isFunction(cb)) cb();
});
}

}