|
18 | 18 | */
|
19 | 19 | function IntroJs(obj) {
|
20 | 20 | this._targetElement = obj;
|
| 21 | + |
| 22 | + this._options = { |
| 23 | + nextLabel: 'Next →', |
| 24 | + prevLabel: '← Back', |
| 25 | + skipLabel: 'Skip' |
| 26 | + } |
21 | 27 | }
|
22 | 28 |
|
23 | 29 | /**
|
|
261 | 267 |
|
262 | 268 | nextTooltipButton.className = "introjs-button introjs-nextbutton";
|
263 | 269 | nextTooltipButton.href = "javascript:void(0);";
|
264 |
| - nextTooltipButton.innerHTML = "Next →"; |
| 270 | + nextTooltipButton.innerHTML = this._options.nextLabel; |
265 | 271 |
|
266 | 272 | //previous button
|
267 | 273 | var prevTooltipButton = document.createElement("a");
|
|
272 | 278 |
|
273 | 279 | prevTooltipButton.className = "introjs-button introjs-prevbutton";
|
274 | 280 | prevTooltipButton.href = "javascript:void(0);";
|
275 |
| - prevTooltipButton.innerHTML = "← Back"; |
| 281 | + prevTooltipButton.innerHTML = this._options.prevLabel; |
276 | 282 |
|
277 | 283 | //skip button
|
278 | 284 | var skipTooltipButton = document.createElement("a");
|
279 | 285 | skipTooltipButton.className = "introjs-button introjs-skipbutton";
|
280 | 286 | skipTooltipButton.href = "javascript:void(0);";
|
281 |
| - skipTooltipButton.innerHTML = "Skip"; |
| 287 | + skipTooltipButton.innerHTML = this._options.skipLabel; |
282 | 288 |
|
283 | 289 | skipTooltipButton.onclick = function() {
|
284 | 290 | _exitIntro.call(self, self._targetElement);
|
|
421 | 427 | return elementPosition;
|
422 | 428 | }
|
423 | 429 |
|
| 430 | + /** |
| 431 | + * Overwrites obj1's values with obj2's and adds obj2's if non existent in obj1 |
| 432 | + * via: http://stackoverflow.com/questions/171251/how-can-i-merge-properties-of-two-javascript-objects-dynamically |
| 433 | + * @param obj1 |
| 434 | + * @param obj2 |
| 435 | + * @returns obj3 a new object based on obj1 and obj2 |
| 436 | + */ |
| 437 | + function _mergeOptions(obj1,obj2){ |
| 438 | + var obj3 = {}; |
| 439 | + for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; } |
| 440 | + for (var attrname in obj2) { obj3[attrname] = obj2[attrname]; } |
| 441 | + return obj3; |
| 442 | + } |
| 443 | + |
424 | 444 | var introJs = function (targetElm) {
|
425 | 445 | if (typeof (targetElm) === "object") {
|
426 | 446 | //Ok, create a new instance
|
|
453 | 473 | clone: function () {
|
454 | 474 | return new IntroJs(this);
|
455 | 475 | },
|
| 476 | + setoption: function(option, value){ |
| 477 | + this._options[option] = value; |
| 478 | + return this; |
| 479 | + }, |
| 480 | + setoptions: function(options){ |
| 481 | + this._options = _mergeOptions(this._options, options); |
| 482 | + return this; |
| 483 | + }, |
456 | 484 | start: function () {
|
457 | 485 | _introForElement.call(this, this._targetElement);
|
458 | 486 | return this;
|
|
0 commit comments