MCPcopy
hub / github.com/ampproject/amphtml / attach

Method attach

third_party/subscriptions-project/swg.js:8786–8807  ·  view source on GitHub ↗

* Attaches the Classic 'Subscribe With Google' button. * @param {!Element} button * @param {../api/subscriptions.ButtonOptions|function()} optionsOrCallback * @param {function()=} callback * @return {!Element}

(button, optionsOrCallback, callback)

Source from the content-addressed store, hash-verified

8784 * @return {!Element}
8785 */
8786 attach(button, optionsOrCallback, callback) {
8787 const options = this.setupButtonAndGetParams_(
8788 button,
8789 AnalyticsEvent.ACTION_SWG_BUTTON_CLICK,
8790 optionsOrCallback,
8791 callback
8792 ).options;
8793
8794 const theme = options['theme'];
8795 button.classList.add(`swg-button-${theme}`);
8796 button.setAttribute('role', 'button');
8797 if (options['lang']) {
8798 button.setAttribute('lang', options['lang']);
8799 }
8800 button.setAttribute(
8801 'title',
8802 msg(SWG_I18N_STRINGS.SUBSCRIPTION_TITLE_LANG_MAP, button) || ''
8803 );
8804 this.logSwgEvent_(AnalyticsEvent.IMPRESSION_SWG_BUTTON);
8805
8806 return button;
8807 }
8808
8809 /**
8810 * Attaches the new subscribe button, for subscription product types.

Callers 4

createMethod · 0.95
openMethod · 0.45
popupOpenedMethod · 0.45
attachButtonMethod · 0.45

Calls 5

logSwgEvent_Method · 0.95
msgFunction · 0.70
addMethod · 0.45
setAttributeMethod · 0.45

Tested by

no test coverage detected