|
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 | /**
|
|
285 | 291 |
|
286 | 292 | nextTooltipButton.className = "introjs-button introjs-nextbutton";
|
287 | 293 | nextTooltipButton.href = "javascript:void(0);";
|
288 |
| - nextTooltipButton.innerHTML = "Next →"; |
| 294 | + nextTooltipButton.innerHTML = this._options.nextLabel; |
289 | 295 |
|
290 | 296 | //previous button
|
291 | 297 | var prevTooltipButton = document.createElement("a");
|
|
296 | 302 |
|
297 | 303 | prevTooltipButton.className = "introjs-button introjs-prevbutton";
|
298 | 304 | prevTooltipButton.href = "javascript:void(0);";
|
299 |
| - prevTooltipButton.innerHTML = "← Back"; |
| 305 | + prevTooltipButton.innerHTML = this._options.prevLabel; |
300 | 306 |
|
301 | 307 | //skip button
|
302 | 308 | var skipTooltipButton = document.createElement("a");
|
303 | 309 | skipTooltipButton.className = "introjs-button introjs-skipbutton";
|
304 | 310 | skipTooltipButton.href = "javascript:void(0);";
|
305 |
| - skipTooltipButton.innerHTML = "Skip"; |
| 311 | + skipTooltipButton.innerHTML = this._options.skipLabel; |
306 | 312 |
|
307 | 313 | skipTooltipButton.onclick = function() {
|
308 | 314 | _exitIntro.call(self, self._targetElement);
|
|
462 | 468 | return elementPosition;
|
463 | 469 | }
|
464 | 470 |
|
| 471 | + /** |
| 472 | + * Overwrites obj1's values with obj2's and adds obj2's if non existent in obj1 |
| 473 | + * via: http://stackoverflow.com/questions/171251/how-can-i-merge-properties-of-two-javascript-objects-dynamically |
| 474 | + * @param obj1 |
| 475 | + * @param obj2 |
| 476 | + * @returns obj3 a new object based on obj1 and obj2 |
| 477 | + */ |
| 478 | + function _mergeOptions(obj1,obj2){ |
| 479 | + var obj3 = {}; |
| 480 | + for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; } |
| 481 | + for (var attrname in obj2) { obj3[attrname] = obj2[attrname]; } |
| 482 | + return obj3; |
| 483 | + } |
| 484 | + |
465 | 485 | var introJs = function (targetElm) {
|
466 | 486 | if (typeof (targetElm) === "object") {
|
467 | 487 | //Ok, create a new instance
|
|
494 | 514 | clone: function () {
|
495 | 515 | return new IntroJs(this);
|
496 | 516 | },
|
| 517 | + setoption: function(option, value){ |
| 518 | + this._options[option] = value; |
| 519 | + return this; |
| 520 | + }, |
| 521 | + setoptions: function(options){ |
| 522 | + this._options = _mergeOptions(this._options, options); |
| 523 | + return this; |
| 524 | + }, |
497 | 525 | start: function () {
|
498 | 526 | _introForElement.call(this, this._targetElement);
|
499 | 527 | return this;
|
|
0 commit comments