@advertol/service-google-dfp
Advanced tools
Comparing version 1.0.1-alpha.0 to 1.0.2-alpha.0
@@ -32,2 +32,3 @@ 'use strict'; | ||
_this = _Service.call(this) || this; | ||
_this.slots = {}; | ||
_this.filledZoneCallbacks = {}; | ||
@@ -40,4 +41,4 @@ _this.emptyZoneCallbacks = {}; | ||
var _options = options, | ||
_options$slots = _options.slots, | ||
slots = _options$slots === void 0 ? {} : _options$slots, | ||
_options$zones = _options.zones, | ||
zones = _options$zones === void 0 ? [] : _options$zones, | ||
_options$onSetup = _options.onSetup, | ||
@@ -48,3 +49,11 @@ onSetup = _options$onSetup === void 0 ? function () {} : _options$onSetup, | ||
_this.refreshZones = refreshZones.bind(_assertThisInitialized(_this)); | ||
_this.slots = slots; | ||
zones.forEach(function (_ref) { | ||
var id = _ref.id, | ||
slot = _ref.slot; | ||
_this.addZone({ | ||
id: id, | ||
slot: slot | ||
}); | ||
}); | ||
/* istanbul ignore next */ | ||
@@ -63,3 +72,4 @@ | ||
/** | ||
* @param {Function} callback [description] | ||
* @param {string} id | ||
* @param {Function} callback | ||
*/ | ||
@@ -70,2 +80,17 @@ | ||
_proto.addZone = function addZone(_ref2) { | ||
var id = _ref2.id, | ||
slot = _ref2.slot; | ||
if (id in this.slots) { | ||
return; | ||
} | ||
this.slots[id] = slot; | ||
} | ||
/** | ||
* @param {Function} callback [description] | ||
*/ | ||
; | ||
_proto.cmd | ||
@@ -124,5 +149,5 @@ /* istanbul ignore next */ | ||
/* istanbul ignore next */ | ||
= function displayZone(_ref) { | ||
var element = _ref.element, | ||
id = _ref.id; | ||
= function displayZone(_ref3) { | ||
var element = _ref3.element, | ||
id = _ref3.id; | ||
@@ -162,7 +187,7 @@ if (typeof window.googletag === 'undefined') { | ||
zones.filter(function (_ref2) { | ||
var id = _ref2.id; | ||
zones.filter(function (_ref4) { | ||
var id = _ref4.id; | ||
return _this3.slotResolvedZones.indexOf(id) === -1 && id in _this3.slots === true; | ||
}).forEach(function (_ref3) { | ||
var id = _ref3.id; | ||
}).forEach(function (_ref5) { | ||
var id = _ref5.id; | ||
@@ -188,7 +213,7 @@ _this3.slotResolvedZones.push(id); | ||
var slots = zones.filter(function (_ref4) { | ||
var id = _ref4.id; | ||
var slots = zones.filter(function (_ref6) { | ||
var id = _ref6.id; | ||
return _this4.refreshedZones.indexOf(id) === -1 && id in _this4.slots === true; | ||
}).map(function (_ref5) { | ||
var id = _ref5.id; | ||
}).map(function (_ref7) { | ||
var id = _ref7.id; | ||
@@ -215,7 +240,7 @@ _this4.refreshedZones.push(id); | ||
_proto.writeZone = function writeZone(_ref6) { | ||
_proto.writeZone = function writeZone(_ref8) { | ||
var _this5 = this; | ||
var element = _ref6.element, | ||
id = _ref6.id; | ||
var element = _ref8.element, | ||
id = _ref8.id; | ||
return new Promise(function (resolve) { | ||
@@ -222,0 +247,0 @@ _this5.filledZoneCallbacks[id] = function () { |
@@ -30,2 +30,3 @@ import { Service } from '@advertol/core'; | ||
_this = _Service.call(this) || this; | ||
_this.slots = {}; | ||
_this.filledZoneCallbacks = {}; | ||
@@ -38,4 +39,4 @@ _this.emptyZoneCallbacks = {}; | ||
var _options = options, | ||
_options$slots = _options.slots, | ||
slots = _options$slots === void 0 ? {} : _options$slots, | ||
_options$zones = _options.zones, | ||
zones = _options$zones === void 0 ? [] : _options$zones, | ||
_options$onSetup = _options.onSetup, | ||
@@ -46,3 +47,11 @@ onSetup = _options$onSetup === void 0 ? function () {} : _options$onSetup, | ||
_this.refreshZones = refreshZones.bind(_assertThisInitialized(_this)); | ||
_this.slots = slots; | ||
zones.forEach(function (_ref) { | ||
var id = _ref.id, | ||
slot = _ref.slot; | ||
_this.addZone({ | ||
id: id, | ||
slot: slot | ||
}); | ||
}); | ||
/* istanbul ignore next */ | ||
@@ -61,3 +70,4 @@ | ||
/** | ||
* @param {Function} callback [description] | ||
* @param {string} id | ||
* @param {Function} callback | ||
*/ | ||
@@ -68,2 +78,17 @@ | ||
_proto.addZone = function addZone(_ref2) { | ||
var id = _ref2.id, | ||
slot = _ref2.slot; | ||
if (id in this.slots) { | ||
return; | ||
} | ||
this.slots[id] = slot; | ||
} | ||
/** | ||
* @param {Function} callback [description] | ||
*/ | ||
; | ||
_proto.cmd | ||
@@ -122,5 +147,5 @@ /* istanbul ignore next */ | ||
/* istanbul ignore next */ | ||
= function displayZone(_ref) { | ||
var element = _ref.element, | ||
id = _ref.id; | ||
= function displayZone(_ref3) { | ||
var element = _ref3.element, | ||
id = _ref3.id; | ||
@@ -160,7 +185,7 @@ if (typeof window.googletag === 'undefined') { | ||
zones.filter(function (_ref2) { | ||
var id = _ref2.id; | ||
zones.filter(function (_ref4) { | ||
var id = _ref4.id; | ||
return _this3.slotResolvedZones.indexOf(id) === -1 && id in _this3.slots === true; | ||
}).forEach(function (_ref3) { | ||
var id = _ref3.id; | ||
}).forEach(function (_ref5) { | ||
var id = _ref5.id; | ||
@@ -186,7 +211,7 @@ _this3.slotResolvedZones.push(id); | ||
var slots = zones.filter(function (_ref4) { | ||
var id = _ref4.id; | ||
var slots = zones.filter(function (_ref6) { | ||
var id = _ref6.id; | ||
return _this4.refreshedZones.indexOf(id) === -1 && id in _this4.slots === true; | ||
}).map(function (_ref5) { | ||
var id = _ref5.id; | ||
}).map(function (_ref7) { | ||
var id = _ref7.id; | ||
@@ -213,7 +238,7 @@ _this4.refreshedZones.push(id); | ||
_proto.writeZone = function writeZone(_ref6) { | ||
_proto.writeZone = function writeZone(_ref8) { | ||
var _this5 = this; | ||
var element = _ref6.element, | ||
id = _ref6.id; | ||
var element = _ref8.element, | ||
id = _ref8.id; | ||
return new Promise(function (resolve) { | ||
@@ -220,0 +245,0 @@ _this5.filledZoneCallbacks[id] = function () { |
{ | ||
"name": "@advertol/service-google-dfp", | ||
"version": "1.0.1-alpha.0", | ||
"version": "1.0.2-alpha.0", | ||
"description": "Google DFP/Ad Manager service.", | ||
@@ -29,3 +29,3 @@ "main": "index.cjs.js", | ||
"dependencies": { | ||
"@advertol/core": "^1.0.0-alpha.0" | ||
"@advertol/core": "^1.0.1-alpha.0" | ||
}, | ||
@@ -90,3 +90,3 @@ "devDependencies": { | ||
"homepage": "https://github.com/niksy/advertol#readme", | ||
"gitHead": "d66945458ff04dd8651af9cc3c600891795adf57" | ||
"gitHead": "37c1884afb062b799450a8a7e808910ebd8e88c0" | ||
} |
@@ -39,5 +39,6 @@ # @advertol/service-google-dfp | ||
new GoogleDfpService({ | ||
slots: { | ||
'becky': () => window.googletag.defineSlot('/0/becky', ['fluid'], 'zone-becky').addService(window.googletag.pubads()) | ||
} | ||
zones: [{ | ||
id: 'becky', | ||
slot: () => window.googletag.defineSlot('/0/becky', ['fluid'], 'zone-becky').addService(window.googletag.pubads()) | ||
}] | ||
}) | ||
@@ -54,13 +55,13 @@ ] | ||
#### slots | ||
#### zones | ||
Type: `Object` | ||
Type: `Object[]` | ||
Service slots. | ||
List of zones with their slot callback. | ||
Each object property has: | ||
| Property | Type | Description | | ||
| --- | --- | --- | | ||
| `slot` | `Function` | Function which returns [`googletag.defineSlot`][googletag-define-slot] or [`googletag.defineOutOfPageSlot`][googletag-define-outofpage-slot] instance. | | ||
| `id` | `string` | Zone ID. | | ||
* Key, which is zone ID | ||
* Value, which is function which returns [`googletag.defineSlot`][googletag-define-slot] or [`googletag.defineOutOfPageSlot`][googletag-define-outofpage-slot] instance | ||
#### onSetup | ||
@@ -86,2 +87,11 @@ | ||
### instance.addZone({ slot, id }) | ||
Add new zone with slot callback. | ||
| Property | Type | Description | | ||
| --- | --- | --- | | ||
| `slot` | `Function` | Function which returns [`googletag.defineSlot`][googletag-define-slot] or [`googletag.defineOutOfPageSlot`][googletag-define-outofpage-slot] instance. | | ||
| `id` | `string` | Zone ID. | | ||
## Browser support | ||
@@ -88,0 +98,0 @@ |
18791
439
113