Example
banner = Cocoon.Ad.createBanner(); banner.on("load", function(){ console.log("Banner loaded " + banner.width, banner.height); banner.show(); }); banner.on("fail", function(){ console.log("Banner failed to load"); }); banner.on("show", function(){ console.log("Banner shown a modal content"); }); banner.on("dismiss", function(){ console.log("Banner dismissed the modal content"); }); banner.on("click", function(){ console.log("Banner clicked"); }); banner.load();
Methods
-
<static> hide()
-
Hides the banner ad.
Example
banner = Cocoon.Ad.createBanner(settings); banner.hide();
-
<static> isReady()
-
Checks if the banner is loaded and ready
Example
var ready = banner.isReady();
-
<static> load()
-
Loads a banner ad.
Example
banner = Cocoon.Ad.createBanner(settings); banner.load();
-
<static> setLayout(layout)
-
Sets a specific layout for a banner ad.
Parameters:
Name Type Description layout
Cocoon.Ad.BannerLayout The predefined layout for a banner ad.
Example
banner = Cocoon.Ad.createBanner(settings); banner.setLayout(layout); // If CUSTOM layout
-
<static> setPosition(x, y)
-
Sets a specific position for a banner ad in CUSTOM layout.
Parameters:
Name Type Description x
number The top lef x coordinate of the banner.
y
number The top lef y coordinate of the banner.
Example
banner = Cocoon.Ad.createBanner(settings); banner.setLayout(layout); // If CUSTOM layout banner.setPosition(x, y);
-
<static> show()
-
Shows the banner ad.
Example
myBanner = Cocoon.Ad.createBanner(settings); myBanner.show();
Events
-
On click
-
Triggered when a banner is clicked.
Example
banner.on("click", function(){ console.log("Banner clicked"); });
-
On dismiss
-
Triggered when a banner is collapsed.
Example
banner.on("dismiss", function(){ console.log("Banner dismissed the modal content"); });
-
On fail
-
Triggered when the loading process of a banner has failed.
Example
banner.on("fail", function(error){ console.log("Banner failed to load: " + JSON.stringify(error)); });
-
On load
-
Triggered when a new banner is loaded.
Example
banner.on("load", function(){ console.log("Banner loaded " + banner.width, banner.height); });
-
On show
-
Triggered when a new banner is expanded to full screen.
Example
banner.on("show", function(){ console.log("Banner shown a modal content"); });