|
1 |
| -<template> |
2 |
| - <div class="carbon-ads-widget"></div> |
3 |
| -</template> |
4 | 1 |
|
5 | 2 | <script>
|
6 | 3 | export default {
|
7 | 4 | name: 'AdManager',
|
| 5 | + abstract: true, |
8 | 6 | data: () => ({
|
9 |
| - carbonEl: null |
| 7 | + carbonEl: null, |
| 8 | + codeSponsorEl: null |
10 | 9 | }),
|
| 10 | + render () { |
| 11 | + return null |
| 12 | + }, |
11 | 13 | methods: {
|
12 | 14 | saveAdsElements () {
|
13 | 15 | this.carbonEl = document.getElementById('carbonads')
|
14 |
| -
|
15 |
| - if (!this.carbonEl) { |
| 16 | + this.codeSponsorEl = document.querySelector('.code-sponsor-widget') |
| 17 | + if (!this.carbonEl || !this.codeSponsorEl) { |
16 | 18 | this.$destroy()
|
17 | 19 | }
|
18 | 20 | },
|
|
22 | 24 | const container = document.querySelector('.container')
|
23 | 25 | const mainContainer = document.querySelector('.main-container')
|
24 | 26 | const splashContainer = document.querySelector('.splash-container')
|
25 |
| - const adsContainer = document.querySelector('.carbon-ads-widget') |
26 |
| -
|
| 27 | + const carbonAdsContainer = document.querySelector('.code-sponsor-widget') |
27 | 28 | if (carbonAds && container) {
|
28 | 29 | if (splashContainer) {
|
29 |
| - adsContainer.appendChild(carbonAds) |
| 30 | + carbonAdsContainer.appendChild(carbonAds) |
30 | 31 | } else if (mainContainer) {
|
31 | 32 | mainContainer.insertBefore(carbonAds, mainContainer.firstChild)
|
32 | 33 | } else {
|
33 | 34 | container.insertBefore(carbonAds, container.firstChild)
|
34 | 35 | }
|
35 |
| -
|
| 36 | + window.clearInterval(interval) |
| 37 | + } |
| 38 | + }, 50) |
| 39 | + }, |
| 40 | + appendCodeSponsor() { |
| 41 | + const interval = window.setInterval(() => { |
| 42 | + const carbonAds = document.querySelector('.code-sponsor-widget') |
| 43 | + const container = document.querySelector('.container') |
| 44 | + const mainContainer = document.querySelector('.main-container') |
| 45 | + if (carbonAds && mainContainer) { |
| 46 | + if (mainContainer) { |
| 47 | + mainContainer.appendChild(carbonAds) |
| 48 | + } else { |
| 49 | + container.appendChild(carbonAds) |
| 50 | + } |
36 | 51 | window.clearInterval(interval)
|
37 | 52 | }
|
38 | 53 | }, 50)
|
|
41 | 56 | if (this.carbonEl) {
|
42 | 57 | document.body.appendChild(this.carbonEl)
|
43 | 58 | }
|
| 59 | + }, |
| 60 | + moveCodeSponsorToBody() { |
| 61 | + if (this.codeSponsorEl) { |
| 62 | + document.body.appendChild(this.codeSponsorEl) |
| 63 | + } |
44 | 64 | }
|
45 | 65 | },
|
46 | 66 | mounted () {
|
47 | 67 | this.saveAdsElements()
|
48 | 68 | this.appendCarbonAds()
|
| 69 | + this.appendCodeSponsor() |
49 | 70 | },
|
50 | 71 | beforeDestroy() {
|
51 | 72 | this.moveCarbonAdsToBody()
|
| 73 | + this.moveCodeSponsorToBody() |
52 | 74 | }
|
53 | 75 | }
|
54 | 76 | </script>
|
55 | 77 |
|
56 | 78 | <style lang="scss">
|
57 | 79 | @import "~vue-material/theme/engine";
|
58 |
| -
|
59 | 80 | $ad-responsive-big: 1670px;
|
60 | 81 | $ad-responsive-small: 600px;
|
61 |
| -
|
62 | 82 | @mixin ad-theme ($hue, $color) {
|
63 |
| - #carbonads { |
| 83 | + #carbonads, |
| 84 | + .code-sponsor-widget { |
64 | 85 | background: md-get-palette-color(grey, $hue);
|
65 | 86 | }
|
66 |
| -
|
67 | 87 | .carbon-wrap a {
|
68 | 88 | color: rgba($color, .7);
|
69 |
| -
|
70 | 89 | &:hover {
|
71 | 90 | color: $color;
|
72 | 91 | }
|
73 | 92 | }
|
74 |
| -
|
75 | 93 | #carbonads .carbon-poweredby {
|
76 | 94 | color: rgba($color, .54);
|
77 |
| -
|
78 | 95 | &:hover {
|
79 | 96 | color: rgba($color, .87);
|
80 | 97 | }
|
81 | 98 | }
|
82 | 99 | }
|
83 |
| -
|
84 | 100 | .main-container {
|
85 | 101 | @include ad-theme(200, #000);
|
86 | 102 | }
|
87 |
| -
|
88 | 103 | .splash-container {
|
89 | 104 | @media (min-width: $ad-responsive-big) {
|
90 | 105 | @include ad-theme(800, #fff);
|
91 | 106 | }
|
92 | 107 | }
|
93 |
| -
|
94 | 108 | #carbonads {
|
95 | 109 | max-width: 162px;
|
96 | 110 | margin: 1em 0 24px 16px;
|
97 | 111 | padding: 16px;
|
98 | 112 | float: right;
|
99 | 113 | position: relative;
|
100 | 114 | z-index: 10;
|
101 |
| -
|
102 | 115 | .splash-container & {
|
103 | 116 | @media (max-width: $ad-responsive-big) {
|
104 | 117 | background: #fff;
|
105 | 118 | }
|
106 | 119 | }
|
107 |
| -
|
108 | 120 | @media (min-width: $ad-responsive-big) {
|
109 | 121 | margin: 0;
|
110 | 122 | position: fixed;
|
111 | 123 | right: 16px;
|
112 | 124 | bottom: 16px;
|
113 | 125 | }
|
114 |
| -
|
115 | 126 | @media (max-width: $ad-responsive-small) {
|
116 | 127 | max-width: none;
|
117 | 128 | min-height: 100px;
|
118 | 129 | margin-left: 0;
|
119 | 130 | padding: 0;
|
120 | 131 | float: none;
|
121 | 132 | }
|
122 |
| -
|
123 | 133 | .splash-container & {
|
124 | 134 | @media (max-width: $ad-responsive-big) {
|
125 | 135 | max-width: none;
|
|
129 | 139 | float: none;
|
130 | 140 | }
|
131 | 141 | }
|
132 |
| -
|
133 | 142 | .carbon-wrap {
|
134 | 143 | display: flex;
|
135 | 144 | flex-direction: column;
|
136 | 145 | font-size: 12px;
|
137 |
| -
|
138 | 146 | @media (max-width: $ad-responsive-small) {
|
139 | 147 | display: block;
|
140 | 148 | }
|
141 |
| -
|
142 | 149 | .splash-container & {
|
143 | 150 | @media (max-width: $ad-responsive-big) {
|
144 | 151 | display: block;
|
145 | 152 | }
|
146 | 153 | }
|
147 |
| -
|
148 | 154 | .carbon-img {
|
149 | 155 | @media (max-width: $ad-responsive-small) {
|
150 | 156 | margin-right: 16px;
|
151 | 157 | float: left;
|
152 | 158 | }
|
153 |
| -
|
154 | 159 | .splash-container & {
|
155 | 160 | @media (max-width: $ad-responsive-big) {
|
156 | 161 | margin-right: 16px;
|
157 | 162 | float: left;
|
158 | 163 | }
|
159 | 164 | }
|
160 | 165 | }
|
161 |
| -
|
162 | 166 | .carbon-text {
|
163 | 167 | line-height: 1.5em;
|
164 |
| -
|
165 | 168 | @media (max-width: $ad-responsive-big) {
|
166 | 169 | padding-top: 1em;
|
167 | 170 | padding-right: 16px;
|
168 | 171 | display: block;
|
169 | 172 | }
|
170 |
| -
|
171 | 173 | @media (min-width: $ad-responsive-big) {
|
172 | 174 | margin: 12px 0 8px;
|
173 | 175 | }
|
174 | 176 | }
|
175 |
| -
|
176 | 177 | a {
|
177 | 178 | &:hover {
|
178 | 179 | text-decoration: none;
|
179 | 180 | }
|
180 | 181 | }
|
181 | 182 | }
|
182 |
| -
|
183 | 183 | .carbon-poweredby {
|
184 | 184 | font-size: 11px;
|
185 | 185 | }
|
186 | 186 | }
|
187 |
| -
|
188 |
| - .carbon-ads-widget { |
| 187 | + .code-sponsor-widget { |
| 188 | + margin-top: 64px; |
| 189 | + padding: 10px; |
| 190 | + display: flex; |
| 191 | + justify-content: center; |
| 192 | + @media (max-width: $ad-responsive-small) { |
| 193 | + align-items: center; |
| 194 | + flex-direction: column; |
| 195 | + } |
| 196 | + .splash-container & { |
| 197 | + width: calc(100% + 32px); |
| 198 | + margin: 0 -16px -16px; |
| 199 | + background: #fff; |
| 200 | + } |
189 | 201 | #carbonads {
|
| 202 | + margin-left: 16px; |
190 | 203 | @media (max-width: $ad-responsive-small) {
|
191 | 204 | margin-top: 16px;
|
192 | 205 | margin-left: 0;
|
|
0 commit comments