forked from ampproject/amphtml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ✨ add ads: baidu * fix lint errors * delete preconnect delete preconnect, as it has the same domain with prefetch url * Update validator test: ads.out The new `ads.out` is regenerated by running `gulp validator --update-tests`. * Implelmentation of renderStart and noContentAvaliable API Following the guidance of this documentation, [ads README.md](https://github.com/ampproject/amphtml/blob/master/ads/README.md) * fix lint errors. * Adjust the timing of invoking renderStart * Add JS comment Add JS comment to explain why there is no good way to do `noContentAvailable` call. * Rearrage the code in alphabetical order 1. rearrage the code 2. regenerate ads.out * Modify a missing alphabetical order problem * Modify a missing alphabetical order problem
- Loading branch information
Showing
8 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* Copyright 2015 The AMP HTML Authors. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS-IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { | ||
loadScript, | ||
validateData, | ||
} from '../3p/3p'; | ||
|
||
/** | ||
* @param {!Window} global | ||
* @param {!Object} data | ||
*/ | ||
export function baidu(global, data) { | ||
validateData(data, ['cproid']); | ||
|
||
const id = '_' + Math.random().toString(36).slice(2); | ||
const container = global.document.createElement('div'); | ||
container.id = id; | ||
global.document.getElementById('c').appendChild(container); | ||
|
||
global.slotbydup = global.slotbydup || []; | ||
global.slotbydup.push({ | ||
id: data['cproid'], | ||
container: id, | ||
display: 'inlay-fix', | ||
async: true, | ||
}); | ||
|
||
global.addEventListener('message', () => { | ||
global.context.renderStart(); | ||
}); | ||
|
||
loadScript( | ||
global, | ||
'https://dup.baidustatic.com/js/dm.js', | ||
() => {}, | ||
() => { | ||
// noContentAvailable should be called, | ||
// if parent iframe receives no message. | ||
// setTimeout can work, but it's not that reliable. | ||
// So, only the faliure of JS loading is dealed with for now. | ||
global.context.noContentAvailable(); | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!--- | ||
Copyright 2016 The AMP HTML Authors. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS-IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
# Baidu | ||
|
||
## Example | ||
|
||
```html | ||
<amp-ad width="300" height="250" | ||
type="baidu" | ||
data-cproid="{cproid}"> | ||
</amp-ad> | ||
``` | ||
|
||
## Configuration | ||
|
||
For additional detials and support, see [baidu ad union website](http://union.baidu.com/product/prod-cpro.html). | ||
|
||
### Required Parameters | ||
|
||
* `data-cproid` - baidu union ad id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters