UNPKG

1.55 kBJavaScriptView Raw
1/**
2 * @namespace Splat.ads
3 */
4
5var platform = require("./platform");
6
7if (platform.isEjecta()) {
8 var adBanner = new window.Ejecta.AdBanner();
9
10 var isLandscape = window.innerWidth > window.innerHeight;
11
12 var sizes = {
13 "iPhone": {
14 "portrait": {
15 "width": 320,
16 "height": 50
17 },
18 "landscape": {
19 "width": 480,
20 "height": 32
21 }
22 },
23 "iPad": {
24 "portrait": {
25 "width": 768,
26 "height": 66
27 },
28 "landscape": {
29 "width": 1024,
30 "height": 66
31 }
32 }
33 };
34
35 var device = window.navigator.userAgent.indexOf("iPad") >= 0 ? "iPad" : "iPhone";
36 var size = sizes[device][isLandscape ? "landscape" : "portrait"];
37
38 module.exports = {
39 /**
40 * Show an advertisement.
41 * @alias Splat.ads.show
42 * @param {boolean} isAtBottom true if the ad should be shown at the bottom of the screen. false if it should be shown at the top.
43 */
44 "show": function(isAtBottom) {
45 adBanner.isAtBottom = isAtBottom;
46 adBanner.show();
47 },
48 /**
49 * Hide the current advertisement.
50 * @alias Splat.ads.hide
51 */
52 "hide": function() {
53 adBanner.hide();
54 },
55 /**
56 * The width of the ad that will show.
57 * @alias Splat.ads#width
58 */
59 "width": size.width,
60 /**
61 * The height of the ad that will show.
62 * @alias Splat.ads#height
63 */
64 "height": size.height
65 };
66} else {
67 module.exports = {
68 "show": function() {},
69 "hide": function() {},
70 "width": 0,
71 "height": 0
72 };
73}