Skip to content
This repository was archived by the owner on Feb 17, 2021. It is now read-only.

Commit 3f63619

Browse files
author
Gordon Koo
committed
some fixes to CTA button
1 parent 226fc18 commit 3f63619

File tree

2 files changed

+42
-38
lines changed

2 files changed

+42
-38
lines changed

js/hopscotch-0.0.5.js

+13-9
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,9 @@
527527
_createButton: function(id, text) {
528528
var btnEl = document.createElement('button');
529529
btnEl.id = id;
530-
btnEl.innerHTML = text;
530+
if (text) {
531+
btnEl.innerHTML = text;
532+
}
531533
utils.addClass(btnEl, 'hopscotch-nav-button');
532534

533535
if (id.indexOf('prev') >= 0) {
@@ -632,7 +634,7 @@
632634
this.prevBtnEl = this._createButton('hopscotch-prev', HopscotchI18N.prevBtn);
633635
this.nextBtnEl = this._createButton('hopscotch-next', HopscotchI18N.nextBtn);
634636
this.doneBtnEl = this._createButton('hopscotch-done', HopscotchI18N.doneBtn);
635-
this.ctaBtnEl = this._createButton('hopscotch-cta', HopscotchI18N.ctaBtn);
637+
this.ctaBtnEl = this._createButton('hopscotch-cta');
636638
utils.addClass(this.doneBtnEl, 'hide');
637639

638640
buttonsEl.appendChild(this.prevBtnEl);
@@ -796,15 +798,17 @@
796798

797799
// Show/hide CTA button
798800
this._showButton(this.ctaBtnEl, !!step.showCTAButton);
799-
this.ctaBtnEl.innerHTML = step.ctaLabel;
801+
if (step.showCTAButton) {
802+
this.ctaBtnEl.innerHTML = step.ctaLabel;
800803

801-
if (step.onCTA) {
802-
if (this.onCTA) {
803-
utils.removeClickListener(this.ctaBtnEl, this.onCTA);
804-
}
804+
if (step.onCTA) {
805+
if (this.onCTA) {
806+
utils.removeClickListener(this.ctaBtnEl, this.onCTA);
807+
}
805808

806-
utils.addClickListener(this.ctaBtnEl, step.onCTA);
807-
this.onCTA = step.onCTA; // cache for removing later
809+
utils.addClickListener(this.ctaBtnEl, step.onCTA);
810+
this.onCTA = step.onCTA; // cache for removing later
811+
}
808812
}
809813
else if (this.onCTA) {
810814
// Remove previous CTA callback.

0 commit comments

Comments
 (0)