MCPcopy Create free account
hub / github.com/ampproject/amphtml / constructor

Method constructor

extensions/amp-pinterest/0.1/save-button.js:32–64  ·  view source on GitHub ↗

@param {!Element} rootElement

(rootElement)

Source from the content-addressed store, hash-verified

30export class SaveButton {
31 /** @param {!Element} rootElement */
32 constructor(rootElement) {
33 userAssert(
34 rootElement.getAttribute('data-url'),
35 'The data-url attribute is required for Save buttons'
36 );
37 userAssert(
38 rootElement.getAttribute('data-media'),
39 'The data-media attribute is required for Save buttons'
40 );
41 userAssert(
42 rootElement.getAttribute('data-description'),
43 'The data-description attribute is required for Save buttons'
44 );
45 this.element = rootElement;
46 this.xhr = Services.xhrFor(getWin(rootElement));
47 this.color = rootElement.getAttribute('data-color');
48 this.count = rootElement.getAttribute('data-count');
49 this.lang = rootElement.getAttribute('data-lang');
50 const hasOneToOneDimensions =
51 rootElement.hasAttribute('height') &&
52 rootElement.hasAttribute('width') &&
53 rootElement.getAttribute('height') === rootElement.getAttribute('width');
54 this.round =
55 rootElement.getAttribute('data-round') || hasOneToOneDimensions;
56 this.tall = rootElement.getAttribute('data-tall');
57 this.description = rootElement.getAttribute('data-description');
58 /** @type {?string} */
59 this.media = null;
60 /** @type {?string} */
61 this.url = null;
62 /** @type {?string} */
63 this.href = null;
64 }
65
66 /**
67 * Override the default href click handling to log and open popup

Callers

nothing calls this directly

Calls 3

userAssertFunction · 0.90
getWinFunction · 0.90
getAttributeMethod · 0.80

Tested by

no test coverage detected