From c27b57a8460685c6d181fe7e3effbe06009a8795 Mon Sep 17 00:00:00 2001 From: Tim Perry Date: Wed, 2 Dec 2015 18:25:59 +0100 Subject: [PATCH] Add very basic minimal hopscotch API --- hopscotch/hopscotch-tests.ts | 55 ++++++++++++++++++++++++++++++++++++ hopscotch/hopscotch.d.ts | 45 +++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 hopscotch/hopscotch-tests.ts create mode 100644 hopscotch/hopscotch.d.ts diff --git a/hopscotch/hopscotch-tests.ts b/hopscotch/hopscotch-tests.ts new file mode 100644 index 000000000..52d021395 --- /dev/null +++ b/hopscotch/hopscotch-tests.ts @@ -0,0 +1,55 @@ +/// + +var tourDefinition = { + id: 'intro-tour', + steps: [ + { + target: '.popupTarget', + placement: 'bottom', + title: 'A tour step', + content: 'A tour message' + }, + { + target: [".aSelector"], + placement: 'bottom', + + yOffset: 10, + width: 400, + xOffset: -420, + arrowOffset: 380 + }, + { + target: '.domainPatterns form', + placement: 'right', + title: 'A question?', + content: "Hello!", + onShow: function () { } + }, + { + target: '.home-button', + placement: 'left', + title: "Let's get started", + content: "Content", + + multipage: true, + nextOnTargetClick: true, + showNextButton: false + }, + { + target: '.buttons', + placement: 'top', + + title: 'Another title', + content: "A message", + + showNextButton: false, + nextOnTargetClick: true, + onShow: function () { } + } + ], + skipIfNoElement: false, + onClose: function () { }, + onEnd: function () { } +}; + +hopscotch.startTour(tourDefinition); diff --git a/hopscotch/hopscotch.d.ts b/hopscotch/hopscotch.d.ts new file mode 100644 index 000000000..e7f7be6e9 --- /dev/null +++ b/hopscotch/hopscotch.d.ts @@ -0,0 +1,45 @@ +// Type definitions for Hopscotch v0.2.5 +// Project: http://linkedin.github.io/hopscotch/ +// Definitions by: Tim Perry +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface TourDefinition { + id: string; + steps: StepDefinition[]; + + skipIfNoElement: boolean; + + onEnd: () => void; + onClose: () => void; +} + +interface StepDefinition { + placement: string; + target: string | HTMLElement | Array + + title?: string; + content?: string; + + xOffset?: number; + yOffset?: number; + arrowOffset?: number; + + height?: number; + width?: number; + + multipage?: boolean; + showNextButton?: boolean; + nextOnTargetClick?: boolean; + + onShow?: () => void; +} + +interface HopscotchStatic { + startTour(tour: TourDefinition, stepNum?: number): void; +} + +declare var hopscotch: HopscotchStatic; + +declare module "hopscotch" { + export = hopscotch; +}