UNPKG

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