diff --git a/types/smartwizard/index.d.ts b/types/smartwizard/index.d.ts new file mode 100644 index 0000000000..0494e72432 --- /dev/null +++ b/types/smartwizard/index.d.ts @@ -0,0 +1,61 @@ +// Type definitions for smartwizard 4.3 +// Project: https://github.com/techlab/SmartWizard +// Definitions by: Stan Kurek +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// + +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; +} diff --git a/types/smartwizard/smartwizard-tests.ts b/types/smartwizard/smartwizard-tests.ts new file mode 100644 index 0000000000..bcdf42e72d --- /dev/null +++ b/types/smartwizard/smartwizard-tests.ts @@ -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: [ + $('') + .text('Finish') + .addClass('btn btn-info') + .on('click', () => { + alert('Finsih button click'); + }), + $('') + .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', + }, +}); diff --git a/types/smartwizard/tsconfig.json b/types/smartwizard/tsconfig.json new file mode 100644 index 0000000000..5f0fa12ab9 --- /dev/null +++ b/types/smartwizard/tsconfig.json @@ -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" + ] +} diff --git a/types/smartwizard/tslint.json b/types/smartwizard/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/smartwizard/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }