dot-store-iframe
Advanced tools
Comparing version 2.2.4 to 2.2.5
111
dist/dfp.js
@@ -6,4 +6,12 @@ "use strict"; | ||
}); | ||
exports.createDfpSlot = undefined; | ||
exports.destroyDfpSlot = exports.createDfpSlot = undefined; | ||
var _regenerator = require("babel-runtime/regenerator"); | ||
var _regenerator2 = _interopRequireDefault(_regenerator); | ||
var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator"); | ||
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2); | ||
var _slicedToArray2 = require("babel-runtime/helpers/slicedToArray"); | ||
@@ -17,13 +25,5 @@ | ||
var _regenerator = require("babel-runtime/regenerator"); | ||
var _regenerator2 = _interopRequireDefault(_regenerator); | ||
var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator"); | ||
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2); | ||
var createDfpSlot = exports.createDfpSlot = function () { | ||
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(options) { | ||
var iframeId, prev, props, state, dfp, iframes, iframe, divId, _iframe$dfp, oop, path, unitId, unit, slot, sizeMap; | ||
var iframeId, prev, props, state, dfp, iframes, iframe, divId, _iframe$dfp, oop, path, targets, unitId, unit, slot, sizeMap, key; | ||
@@ -55,3 +55,3 @@ return _regenerator2.default.wrap(function _callee$(_context) { | ||
divId = iframe.divId; | ||
_iframe$dfp = iframe.dfp, oop = _iframe$dfp.oop, path = _iframe$dfp.path, unitId = _iframe$dfp.unitId; | ||
_iframe$dfp = iframe.dfp, oop = _iframe$dfp.oop, path = _iframe$dfp.path, targets = _iframe$dfp.targets, unitId = _iframe$dfp.unitId; | ||
unit = dfp.units[unitId]; | ||
@@ -72,2 +72,8 @@ slot = void 0; | ||
} | ||
if (slot && targets) { | ||
for (key in targets) { | ||
slot.setTargeting(key, targets[key]); | ||
} | ||
} | ||
} | ||
@@ -94,5 +100,38 @@ | ||
exports.activateDfpSlot = activateDfpSlot; | ||
var destroyDfpSlot = exports.destroyDfpSlot = function () { | ||
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(_ref4) { | ||
var iframeId = _ref4.iframeId; | ||
return _regenerator2.default.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
if (hasGpt) { | ||
_context2.next = 2; | ||
break; | ||
} | ||
return _context2.abrupt("return"); | ||
case 2: | ||
window.googletag.destroySlots([slots[iframeId]]); | ||
slots[iframeId] = undefined; | ||
case 4: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
} | ||
}, _callee2, this); | ||
})); | ||
return function destroyDfpSlot(_x2) { | ||
return _ref3.apply(this, arguments); | ||
}; | ||
}(); | ||
exports.attachDfp = attachDfp; | ||
exports.buildSizeMap = buildSizeMap; | ||
exports.refreshDfpSlot = refreshDfpSlot; | ||
exports.updateDfpTargets = updateDfpTargets; | ||
@@ -110,16 +149,2 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
// Dfp | ||
function activateDfpSlot(_ref) { | ||
var iframeId = _ref.iframeId, | ||
state = _ref.state; | ||
var iframes = state.iframes; | ||
var divId = iframes[iframeId].divId; | ||
if (!hasGpt || !slots[divId]) { | ||
return; | ||
} | ||
window.googletag.pubads().refresh([slots[divId]], { changeCorrelator: false }); | ||
} | ||
function attachDfp(store) { | ||
@@ -145,5 +170,5 @@ if (!hasGpt) { | ||
function buildSizeMap(_ref3) { | ||
var dfp = _ref3.dfp, | ||
unit = _ref3.unit; | ||
function buildSizeMap(_ref) { | ||
var dfp = _ref.dfp, | ||
unit = _ref.unit; | ||
@@ -185,2 +210,30 @@ if (sizeMaps[unit.id]) { | ||
} | ||
function refreshDfpSlot(_ref5) { | ||
var iframeId = _ref5.iframeId, | ||
state = _ref5.state; | ||
var iframes = state.iframes; | ||
var divId = iframes[iframeId].divId; | ||
if (!hasGpt || !slots[divId]) { | ||
return; | ||
} | ||
window.googletag.pubads().refresh([slots[divId]], { changeCorrelator: false }); | ||
} | ||
function updateDfpTargets(_ref6) { | ||
var store = _ref6.store; | ||
if (!hasGpt) { | ||
return; | ||
} | ||
var targets = store.getSync("dfp.targets") || {}; | ||
for (var key in targets) { | ||
window.googletag.pubads().setTargeting(key, targets[key] || ""); | ||
} | ||
} | ||
//# sourceMappingURL=dfp.js.map |
@@ -8,6 +8,8 @@ "use strict"; | ||
exports.default = function (store) { | ||
store.on("dfp.targets", _dfp.updateDfpTargets); | ||
store.on("iframes.{iframeId}", _dfp.createDfpSlot); | ||
store.on("iframes.{iframeId}", _iframes.createIframe); | ||
store.on("iframes.{iframeId}.active", _dfp.activateDfpSlot); | ||
store.on("afterDelete", "iframes.{iframeId}", _dfp.destroyDfpSlot); | ||
@@ -17,2 +19,4 @@ store.on("iframes.{iframeId}.height", _iframes.iframeSize); | ||
store.on("iframes.{iframeId}.refresh", _dfp.refreshDfpSlot); | ||
(0, _dfp.attachDfp)(store); | ||
@@ -19,0 +23,0 @@ |
{ | ||
"name": "dot-store-iframe", | ||
"version": "2.2.4", | ||
"version": "2.2.5", | ||
"description": "Iframe controller integration for dot-store", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
23521
260