Added type definitions for smartwizard (#37895)

* Added type definitions for smartwizard

* Correct package name in the header
This commit is contained in:
Stan Kurek 2019-08-26 18:49:10 +02:00 committed by Sheetal Nandi
parent 296094758a
commit 8590aaecf8
4 changed files with 143 additions and 0 deletions

61
types/smartwizard/index.d.ts vendored Normal file
View File

@ -0,0 +1,61 @@
// Type definitions for smartwizard 4.3
// Project: https://github.com/techlab/SmartWizard
// Definitions by: Stan Kurek <https://github.com/stankurek>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="jquery"/>
declare namespace JQuerySmartwizard {
type TransitionEffect = 'none' | 'slide' | 'fade';
type ToolbarPosition = 'none' | 'top' | 'bottom' | 'both';
type ToolbarButtonPosition = 'left' | 'right';
interface ToolbarSettings {
toolbarPosition?: ToolbarPosition;
toolbarButtonPosition?: ToolbarButtonPosition;
showNextButton?: boolean;
showPreviousButton?: boolean;
toolbarExtraButtons?: JQuery[];
}
interface AnchorSettings {
anchorClickable?: boolean;
enableAllAnchors?: boolean;
markDoneStep?: boolean;
markAllPreviousStepsAsDone?: boolean;
removeDoneStepOnNavigateBack?: boolean;
enableAnchorOnDoneStep?: boolean;
}
interface Lang {
next?: string;
previous?: string;
}
interface SmartWizardOptions {
selected?: number;
keyNavigation?: boolean;
autoAdjustHeight?: boolean;
cycleSteps?: boolean;
backButtonSupport?: boolean;
useURLhash?: boolean;
showStepURLhash?: boolean;
contentURL?: null | string;
contentCache?: boolean;
ajaxSettings?: JQueryAjaxSettings;
disabledSteps?: number[];
errorSteps?: number[];
hiddenSteps?: number[];
theme?: string;
transitionEffect?: TransitionEffect;
transitionSpeed?: string | number;
toolbarSettings?: ToolbarSettings;
anchorSettings?: AnchorSettings;
lang?: Lang;
}
}
interface JQuery {
smartWizard(options?: JQuerySmartwizard.SmartWizardOptions): JQuery;
}

View File

@ -0,0 +1,57 @@
import 'jquery';
import 'smartwizard';
$('#smartwizard').smartWizard({
selected: 0,
keyNavigation: true,
autoAdjustHeight: true,
cycleSteps: false,
backButtonSupport: true,
useURLhash: true,
showStepURLhash: true,
contentURL: null,
contentCache: true,
ajaxSettings: {
async: true,
cache: true,
timeout: 60000,
},
disabledSteps: [2],
errorSteps: [3, 4],
hiddenSteps: [1],
theme: 'dots',
transitionEffect: 'fade',
transitionSpeed: '400',
toolbarSettings: {
toolbarPosition: 'bottom',
toolbarButtonPosition: 'right',
showNextButton: true,
showPreviousButton: true,
toolbarExtraButtons: [
$('<button></button>')
.text('Finish')
.addClass('btn btn-info')
.on('click', () => {
alert('Finsih button click');
}),
$('<button></button>')
.text('Cancel')
.addClass('btn btn-danger')
.on('click', () => {
alert('Cancel button click');
}),
],
},
anchorSettings: {
anchorClickable: true,
enableAllAnchors: false,
markDoneStep: true,
markAllPreviousStepsAsDone: true,
removeDoneStepOnNavigateBack: false,
enableAnchorOnDoneStep: true,
},
lang: {
next: 'Next',
previous: 'Previous',
},
});

View File

@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"smartwizard-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }