MCPcopy
hub / github.com/shipshapecode/shepherd / constructor

Method constructor

shepherd.js/src/tour.ts:119–156  ·  view source on GitHub ↗
(options: TourOptions = {})

Source from the content-addressed store, hash-verified

117 steps: Array<Step>;
118
119 constructor(options: TourOptions = {}) {
120 super();
121
122 autoBind(this);
123
124 const defaultTourOptions = {
125 exitOnEsc: true,
126 keyboardNavigation: true
127 };
128
129 this.options = Object.assign({}, defaultTourOptions, options);
130 this.classPrefix = normalizePrefix(this.options.classPrefix);
131 this.steps = [];
132 this.addSteps(this.options.steps);
133
134 // Pass these events onto the global Shepherd object
135 const events = [
136 'active',
137 'cancel',
138 'complete',
139 'inactive',
140 'show',
141 'start'
142 ];
143 events.map((event) => {
144 ((e) => {
145 this.on(e, (opts?: { [key: string]: unknown }) => {
146 opts = opts || {};
147 opts['tour'] = this;
148 Shepherd.trigger(e, opts);
149 });
150 })(event);
151 });
152
153 this._setTourID(options.id);
154
155 return this;
156 }
157
158 /**
159 * Adds a new step to the tour

Callers

nothing calls this directly

Calls 6

addStepsMethod · 0.95
_setTourIDMethod · 0.95
normalizePrefixFunction · 0.90
autoBindFunction · 0.85
onMethod · 0.80
triggerMethod · 0.80

Tested by

no test coverage detected