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

Commit

Permalink
some fixes to CTA button
Browse files Browse the repository at this point in the history
  • Loading branch information
Gordon Koo committed Apr 11, 2013
1 parent 226fc18 commit 3f63619
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 38 deletions.
22 changes: 13 additions & 9 deletions js/hopscotch-0.0.5.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,9 @@
_createButton: function(id, text) {
var btnEl = document.createElement('button');
btnEl.id = id;
btnEl.innerHTML = text;
if (text) {
btnEl.innerHTML = text;
}
utils.addClass(btnEl, 'hopscotch-nav-button');

if (id.indexOf('prev') >= 0) {
Expand Down Expand Up @@ -632,7 +634,7 @@
this.prevBtnEl = this._createButton('hopscotch-prev', HopscotchI18N.prevBtn);
this.nextBtnEl = this._createButton('hopscotch-next', HopscotchI18N.nextBtn);
this.doneBtnEl = this._createButton('hopscotch-done', HopscotchI18N.doneBtn);
this.ctaBtnEl = this._createButton('hopscotch-cta', HopscotchI18N.ctaBtn);
this.ctaBtnEl = this._createButton('hopscotch-cta');
utils.addClass(this.doneBtnEl, 'hide');

buttonsEl.appendChild(this.prevBtnEl);
Expand Down Expand Up @@ -796,15 +798,17 @@

// Show/hide CTA button
this._showButton(this.ctaBtnEl, !!step.showCTAButton);
this.ctaBtnEl.innerHTML = step.ctaLabel;
if (step.showCTAButton) {
this.ctaBtnEl.innerHTML = step.ctaLabel;

if (step.onCTA) {
if (this.onCTA) {
utils.removeClickListener(this.ctaBtnEl, this.onCTA);
}
if (step.onCTA) {
if (this.onCTA) {
utils.removeClickListener(this.ctaBtnEl, this.onCTA);
}

utils.addClickListener(this.ctaBtnEl, step.onCTA);
this.onCTA = step.onCTA; // cache for removing later
utils.addClickListener(this.ctaBtnEl, step.onCTA);
this.onCTA = step.onCTA; // cache for removing later
}
}
else if (this.onCTA) {
// Remove previous CTA callback.
Expand Down
Loading

0 comments on commit 3f63619

Please # to comment.