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

Commit

Permalink
added some comments for _setupCTAButton()
Browse files Browse the repository at this point in the history
  • Loading branch information
Gordon Koo committed May 15, 2013
1 parent 5d6384f commit aa1d028
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions js/hopscotch-0.1.js
Expand Up @@ -768,23 +768,34 @@
return this;
},

/**
* Set up the CTA button, using the `showCTAButton`, `ctaLabel`, and
* `onCTA` properties.
*
* @private
*/
_setupCTAButton: function(step) {
var callback,
self = this;

this._showButton(this.ctaBtnEl, !!step.showCTAButton);
if (step.showCTAButton && step.ctaLabel) {
this.ctaBtnEl.innerHTML = step.ctaLabel;

// Create callback to remove the callout. If a onCTA callback is
// provided, call it from within this one.
callback = function() {
utils.removeEvtListener(self.ctaBtnEl, 'click', callback);
if (!self.opt.isTourBubble) {
// This is a callout. Close the callout when CTA is clicked.
winHopscotch.getCalloutManager().removeCallout(step.id);
}
// Call onCTA callback if one is provided
if (step.onCTA && typeof step.onCTA === 'function') {
step.onCTA();
}
};

utils.addEvtListener(this.ctaBtnEl, 'click', callback);
}
},
Expand Down

0 comments on commit aa1d028

Please sign in to comment.