@ax2/gpt-ads-module
Advanced tools
+11
-0
@@ -6,2 +6,13 @@ # Change Log | ||
| # [0.6.0](https://github.com/ax2inc/nuxt-modules/compare/@ax2/gpt-ads-module@0.5.3...@ax2/gpt-ads-module@0.6.0) (2019-03-15) | ||
| ### Features | ||
| * Toggle class on ads slots when they become empty ([a3863f1](https://github.com/ax2inc/nuxt-modules/commit/a3863f1)) | ||
| ## [0.5.3](https://github.com/ax2inc/nuxt-modules/compare/@ax2/gpt-ads-module@0.5.2...@ax2/gpt-ads-module@0.5.3) (2018-11-01) | ||
@@ -8,0 +19,0 @@ |
+1
-0
@@ -9,2 +9,3 @@ export const DEFAULT_OPTIONS = { | ||
| collapseEmptyDivs: false, | ||
| emptyClass: 'is-empty', | ||
| }; | ||
@@ -11,0 +12,0 @@ |
@@ -9,2 +9,3 @@ export default { | ||
| ghostMode: <%= options.ghostMode %>, | ||
| isEmpty: true, | ||
| }), | ||
@@ -125,2 +126,8 @@ props: { | ||
| }, | ||
| handleSlotRenderEnded (event) { | ||
| if (event.slot.getSlotId().getDomId() !== this.divId) { | ||
| return; | ||
| } | ||
| this.isEmpty = !!event.isEmpty; | ||
| }, | ||
| /** | ||
@@ -179,7 +186,11 @@ * Window resize event listener | ||
| // Init Ad slot | ||
| googletag.cmd.push(() => { | ||
| const pubadsService = googletag.pubads() | ||
| pubadsService.addEventListener('slotRenderEnded', this.handleSlotRenderEnded); | ||
| const adSlot = googletag | ||
| .defineSlot(adUnitPath, this.formattedSize, divId) | ||
| .addService(googletag.pubads()); | ||
| .addService(pubadsService); | ||
@@ -233,3 +244,4 @@ // Collapse empty div slot-level override | ||
| render(h) { | ||
| const { divId, style } = this; | ||
| const { divId, style, isEmpty } = this; | ||
| let classAttr = isEmpty ? '<%= options.emptyClass %>' : ''; | ||
@@ -240,2 +252,3 @@ return h('div', { | ||
| id: divId, | ||
| class: classAttr, | ||
| }, | ||
@@ -242,0 +255,0 @@ domProps: { innerHTML: '' }, |
@@ -66,4 +66,3 @@ import Vue from 'vue'; | ||
| ctx.$gptAds = gptAdsOptions; | ||
| inject('gptAds', gptAdsOptions); | ||
| } |
+12
-12
| { | ||
| "name": "@ax2/gpt-ads-module", | ||
| "version": "0.5.3", | ||
| "version": "0.6.0", | ||
| "description": "Google Publisher Tag ads integration for Nuxt", | ||
@@ -22,15 +22,15 @@ "license": "MIT", | ||
| "codecov": "latest", | ||
| "eslint": "^5.6.1", | ||
| "eslint-config-airbnb-base": "^13.1.0", | ||
| "eslint-loader": "^2.1.1", | ||
| "eslint-plugin-import": "^2.14.0", | ||
| "eslint-plugin-jest": "^21.24.1", | ||
| "eslint-plugin-vue": "^4.0.0", | ||
| "jest": "^23.6.0", | ||
| "jsdom": "^12.2.0", | ||
| "nuxt": "^2.2.0", | ||
| "request-promise-native": "^1.0.5", | ||
| "eslint": "5.13.0", | ||
| "eslint-config-airbnb-base": "13.1.0", | ||
| "eslint-loader": "2.1.2", | ||
| "eslint-plugin-import": "2.16.0", | ||
| "eslint-plugin-jest": "22.3.0", | ||
| "eslint-plugin-vue": "5.2.1", | ||
| "jest": "24.1.0", | ||
| "jsdom": "14.0.0", | ||
| "nuxt": "2.4.3", | ||
| "request-promise-native": "1.0.5", | ||
| "standard-version": "latest" | ||
| }, | ||
| "gitHead": "f97174f6a2edf40ffcbbe93d0487069f55334c4c" | ||
| "gitHead": "2215412e6b1519de1305d713d090ff2ef16fb6e9" | ||
| } |
+7
-0
@@ -98,2 +98,9 @@ # gpt-ads-module | ||
| ### emptyClass | ||
| - **Type**: `String` | ||
| - **Default**: `'is-empty'` | ||
| Class to apply to empty ads slots. | ||
| ## Usage | ||
@@ -100,0 +107,0 @@ |
17411
4.6%338
3.36%202
3.59%