@68publishers/amp-client
Advanced tools
Comparing version 1.4.0-beta.1 to 1.4.0-beta.2
{ | ||
"name": "@68publishers/amp-client", | ||
"version": "1.4.0-beta.1", | ||
"version": "1.4.0-beta.2", | ||
"description": "JS Client for 68publishers/amp", | ||
@@ -5,0 +5,0 @@ "homepage": "http://www.68publishers.io/", |
@@ -54,3 +54,3 @@ const internal = require('../utils/internal-state'); | ||
addManagedBanner(element, position, resources = {}) { | ||
addManagedBanner(element, position, resources = {}, options = {}) { | ||
const resourceArr = []; | ||
@@ -66,3 +66,3 @@ let key; | ||
const banner = new ManagedBanner(internal(this).eventBus, element, position, resourceArr); | ||
const banner = new ManagedBanner(internal(this).eventBus, element, position, resourceArr, options); | ||
@@ -69,0 +69,0 @@ internal(this).banners.push(banner); |
const State = require('./state'); | ||
const Events = require('../event/events'); | ||
const PositionData = require('./position-data'); | ||
const Options = require('./options'); | ||
const internal = require('../utils/internal-state'); | ||
class Banner { | ||
constructor(eventBus, element, position) { | ||
constructor(eventBus, element, position, options) { | ||
if (this.constructor === Banner) { | ||
@@ -18,2 +19,3 @@ throw new TypeError('Can not construct abstract class Banner.'); | ||
internal(this).positionData = PositionData.createInitial(position); | ||
internal(this).options = new Options(options); | ||
internal(this).stateCounters = {}; | ||
@@ -52,2 +54,9 @@ | ||
/** | ||
* @returns {Options} | ||
*/ | ||
get options() { | ||
return internal(this).options; | ||
} | ||
/** | ||
* @returns {Array<Fingerprint>} | ||
@@ -54,0 +63,0 @@ */ |
const Banner = require('../banner'); | ||
const Fingerprint = require('../fingerprint'); | ||
const PositionData = require('../position-data'); | ||
const AttributesParser = require('../attributes-parser'); | ||
const internal = require('../../utils/internal-state'); | ||
@@ -20,4 +21,5 @@ | ||
const positionData = new PositionData(externalData.positionData); | ||
const options = AttributesParser.parseOptions(element); | ||
super(eventBus, element, positionData.code); | ||
super(eventBus, element, positionData.code, options); | ||
@@ -24,0 +26,0 @@ const fingerprints = []; |
@@ -10,4 +10,4 @@ const Banner = require('../banner'); | ||
class ManagedBanner extends Banner { | ||
constructor(eventBus, element, position, resources = []) { | ||
super(eventBus, element, position); | ||
constructor(eventBus, element, position, resources = [], options = {}) { | ||
super(eventBus, element, position, options); | ||
@@ -14,0 +14,0 @@ internal(this).resources = resources; |
const version = require('../../package.json').version; | ||
const internal = require('../utils/internal-state'); | ||
const _config = require('../config/index'); | ||
const _config = require('./config'); | ||
const _gateway = require('../gateway/index'); | ||
@@ -8,2 +8,3 @@ const RequestFactory = require('../request/request-factory'); | ||
const ManagedBanner = require('../banner/managed/managed-banner'); | ||
const AttributesParser = require('../banner/attributes-parser'); | ||
const EventBus = require('../event/event-bus'); | ||
@@ -102,4 +103,4 @@ const Events = require('../event/events'); | ||
createBanner(element, position, resources = {}) { | ||
return internal(this).bannerManager.addManagedBanner(element, position, resources); | ||
createBanner(element, position, resources = {}, options = {}) { | ||
return internal(this).bannerManager.addManagedBanner(element, position, resources, options); | ||
} | ||
@@ -117,20 +118,14 @@ | ||
} else { | ||
const position = element.getAttribute('data-amp-banner'); | ||
const resources = {}; | ||
const position = element.dataset.ampBanner; | ||
if (!position) { | ||
continue; // the empty position, throw an error? | ||
console.warn('Unable to attach a banner to the element ', element, ' because the attribute "data-amp-banner" has an empty value.'); | ||
continue; | ||
} | ||
const attributes = [].filter.call(element.attributes, attr => { | ||
return /^data-amp-resource-[\S]+/.test(attr.name); | ||
}); | ||
const resources = AttributesParser.parseResources(element); | ||
const options = AttributesParser.parseOptions(element); | ||
for (let attr of attributes) { | ||
if (attr.value) { | ||
resources[attr.name.slice(18)] = attr.value.split(',').map(v => v.trim()); | ||
} | ||
} | ||
banner = this.createBanner(element, position, resources); | ||
banner = this.createBanner(element, position, resources, options); | ||
} | ||
@@ -137,0 +132,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
280419
44
1736