Moved plugin to author's repo.

This commit is contained in:
Shazron Abdullah
2012-11-04 12:21:44 -08:00
parent 599f560933
commit d2d651afb0
51 changed files with 1 additions and 6363 deletions

View File

@@ -1,75 +1 @@
# Cordova AdPlugin #
by Shazron Abdullah
## Adding the Plugin to your project ##
Using this plugin requires [Cordova](http://github.com/apache/incubator-cordova-ios) and iAd. iAd requires at least the [iOS 4 SDK](http://developer.apple.com/iphone).
1. Make sure your Cordova Xcode project has been [updated for Cordova 1.6.0](https://github.com/apache/incubator-cordova-ios/blob/master/guides/Cordova%20Plugin%20Upgrade%20Guide.md)
2. Add the "iAd" framework to your Frameworks folder, and set it to be weak linked (see "Weak Linking the iAd Framework" section below)
3. Add the .h and .m files to your Plugins folder in your project (as a Group "yellow folder" not a Reference "blue folder")
4. Add the .js files to your "www" folder on disk, and add reference(s) to the .js files as <script> tags in your html file(s)
5. In **Cordova.plist** (1.5.0 or greater) or **PhoneGap.plist** (1.4.1 or lesser), under the **Plugins** section, add an idential key and value of **"SAiOSAdPlugin"**
6. See the sample index.html
7. Make sure you check the **"RELEASE NOTES"** section below!
8. Your App must be added to [https://iad.apple.com/itcportal/](https://iad.apple.com/itcportal/) to make $
## Weak Linking the iAd Framework ##
1. In your project, under "Targets", double click on the Target item
2. Go to the "General" Tab, under "Linked Libraries"
3. For the iAd Framework, change the value from "Required" to "Weak"
## FUTURE FEATURES ##
* Landscape mode iAds
* Showing of other ad network ads in place of iAds, if no iAds are available
## RELEASE NOTES ##
### 20120409 ###
- Changed license to Apache 2.0 License
- Updated for Cordova 1.6.0 (backwards compatible to earlier versions as well)
- wrapped object in function closure (to prevent pollution of the global namespace)
### 20120308 ###
- Cordova 1.5.0 support (@RandyMcMillan)
### 20100712 ###
* Initial release
* Only supports portrait iAd banners
* Not tested on a 3.x device
* WebView initial size being oversized is a PhoneGap Core issue, and is not addressed in this plugin. When an ad is shown, it correctly sizes the WebView, and when the ad is hidden, sets the WebView back to its original size.
* Not tested with any other native UI plugins, like TabBar, and will not play nice with them (until we get a better layout management system/plugin)
### 20110627 ###
* Requires PhoneGap 0.9.6
* Fixed size issues
* Orientation change handling
* Works on iPad 4.x
* Still does not play nice with other native UI plugins like TabBar (yet)
## BUGS AND CONTRIBUTIONS ##
Patches welcome! Send a pull request. Since this is not a part of Cordova Core (which requires an Apache iCLA), this should be easier.
Post issues in the [PhoneGap Google Groups](http://groups.google.com/group/phonegap), include in the subject heading - "AdPlugin" or on [Github](http://github.com/phonegap/phoneGap-plugins/issues)
(preferred)
## LICENSE ##
Copyright 2012 Shazron Abdullah
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.
This plugin has been moved to [http://github.com/shazron/iAdPlugin](http://github.com/shazron/iAdPlugin)

View File

@@ -1,43 +0,0 @@
//
// SAiOSAdPlugin.h
// ADPlugin for PhoneGap/Cordova
//
// Created by shazron on 10-07-12.
// Copyright 2010 Shazron Abdullah. All rights reserved.
// Cordova v1.5.0 Support added 2012 @RandyMcMillan
//
#import <Foundation/Foundation.h>
#import <iAd/iAd.h>
#import "SAiOSAdPlugin.h"
//#ifdef CORDOVA_FRAMEWORK
#import <Cordova/CDVPlugin.h>
//#else
//#import "CDVPlugin.h"
//#endif
@interface SAiOSAdPlugin : CDVPlugin <ADBannerViewDelegate> {
ADBannerView* adView;
BOOL bannerIsVisible;
BOOL bannerIsInitialized;
BOOL bannerIsAtBottom;
}
@property (nonatomic, retain) ADBannerView* adView;
@property (assign) BOOL bannerIsVisible;
@property (assign) BOOL bannerIsInitialized;
@property (assign) BOOL bannerIsAtBottom;
@property (assign) BOOL isLandscape;
- (void) prepare:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
- (void) showAd:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
- (void) orientationChanged:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
@end

View File

@@ -1,77 +0,0 @@
/*
Cordova v1.5.0 Support added 2012 @RandyMcMillan
README.md for install notes
Cordova v1.6.0 Support added @shazron
*/
// /////////////////////////
(function() {
// /////////////////////////
// get local ref to global PhoneGap/Cordova/cordova object for exec function
var cordovaRef = window.PhoneGap || window.Cordova || window.cordova; // old to new fallbacks
/**
* Constructor
*/
function SAiOSAdPlugin()
{
}
/**
* show - true to show the ad, false to hide the ad
*/
SAiOSAdPlugin.prototype.orientationChanged = function()
{
cordovaRef.exec("SAiOSAdPlugin.orientationChanged", window.orientation);
}
/**
* show - true to show the ad, false to hide the ad
*/
SAiOSAdPlugin.prototype.showAd = function(show)
{
cordovaRef.exec("SAiOSAdPlugin.showAd", show);
}
/**
* atBottom - true to put the ad at the bottom, false to put the ad at the top
*/
SAiOSAdPlugin.prototype.prepare = function(atBottom)
{
if (!atBottom) {
atBottom = false;
}
cordovaRef.exec("SAiOSAdPlugin.prepare", atBottom);
}
/**
* Install function
*/
SAiOSAdPlugin.install = function()
{
if ( !window.plugins ) {
window.plugins = {};
}
if ( !window.plugins.iAdPlugin ) {
window.plugins.iAdPlugin = new SAiOSAdPlugin();
}
}
/**
* Add to Cordova constructor
*/
if (cordovaRef && cordovaRef.addConstructor) {
cordovaRef.addConstructor(SAiOSAdPlugin.install);
} else {
console.log("iAd Cordova Plugin could not be installed.");
return null;
}
// /////////////////////////
})();
// /////////////////////////

View File

@@ -1,227 +0,0 @@
//
// SAiOSAdPlugin.m
// Ad Plugin for PhoneGap
//
// Created by shazron on 10-07-12.
// Copyright 2010 Shazron Abdullah. All rights reserved.
// Cordova v1.5.0 Support added 2012 @RandyMcMillan
//
#import "SAiOSAdPlugin.h"
//#ifdef CORDOVA_FRAMEWORK
#import <Cordova/CDVDebug.h>
//#else
//#import "CDVDebug.h"
//#endif
@interface SAiOSAdPlugin(PrivateMethods)
- (void) __prepare:(BOOL)atBottom;
- (void) __showAd:(BOOL)show;
@end
@implementation SAiOSAdPlugin
@synthesize adView;
@synthesize bannerIsVisible, bannerIsInitialized, bannerIsAtBottom, isLandscape;
#pragma mark -
#pragma mark Public Methods
- (void) resizeViews
{
Class adBannerViewClass = NSClassFromString(@"ADBannerView");
if (adBannerViewClass && self.adView)
{
CGRect webViewFrame = [super webView].frame;
CGRect superViewFrame = [[super webView] superview].frame;
CGRect adViewFrame = self.adView.frame;
BOOL adIsShowing = [[[super webView] superview].subviews containsObject:self.adView];
if (adIsShowing)
{
if (self.bannerIsAtBottom) {
webViewFrame.origin.y = 0;
CGRect adViewFrame = self.adView.frame;
CGRect superViewFrame = [[super webView] superview].frame;
adViewFrame.origin.y = (self.isLandscape ? superViewFrame.size.width : superViewFrame.size.height) - adViewFrame.size.height;
self.adView.frame = adViewFrame;
} else {
webViewFrame.origin.y = adViewFrame.size.height;
}
webViewFrame.size.height = self.isLandscape? (superViewFrame.size.width - adViewFrame.size.height) : (superViewFrame.size.height - adViewFrame.size.height);
}
else
{
webViewFrame.size = self.isLandscape? CGSizeMake(superViewFrame.size.height, superViewFrame.size.width) : superViewFrame.size;
webViewFrame.origin = CGPointZero;
}
[UIView beginAnimations:@"blah" context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[super webView].frame = webViewFrame;
[UIView commitAnimations];
}
}
- (void) orientationChanged:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
{
NSInteger orientation = [[arguments objectAtIndex:0] integerValue];
switch (orientation) {
// landscape
case 90:
case -90:
self.isLandscape = YES;
break;
// portrait
case 0:
case 180:
self.isLandscape = NO;
break;
default:
break;
}
Class adBannerViewClass = NSClassFromString(@"ADBannerView");
if (adBannerViewClass && self.adView)
{
self.adView.currentContentSizeIdentifier = self.isLandscape ? ADBannerContentSizeIdentifierLandscape : ADBannerContentSizeIdentifierPortrait;
[self resizeViews];
}
}
- (void) prepare:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
{
NSUInteger argc = [arguments count];
if (argc > 1) {
return;
}
NSString* atBottomValue = [arguments objectAtIndex:0];
[self __prepare:[atBottomValue boolValue]];
}
- (void) showAd:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
{
NSUInteger argc = [arguments count];
if (argc > 1) {
return;
}
NSString* showValue = [arguments objectAtIndex:0];
[self __showAd:[showValue boolValue]];
}
#pragma mark -
#pragma mark Private Methods
- (void) __prepare:(BOOL)atBottom
{
NSLog(@"SAiOSAdPlugin Prepare Ad At Bottom: %d", atBottom);
Class adBannerViewClass = NSClassFromString(@"ADBannerView");
if (adBannerViewClass && !self.adView)
{
self.adView = [[ADBannerView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
// we are still using these constants even though they are deprecated - if it is changed, iOS 4 devices < 4.3 will crash.
// will need to do a run-time iOS version check
self.adView.requiredContentSizeIdentifiers = [NSSet setWithObjects: ADBannerContentSizeIdentifierPortrait, ADBannerContentSizeIdentifierLandscape, nil];
self.adView.delegate = self;
NSString* contentSizeId = (self.isLandscape ? ADBannerContentSizeIdentifierLandscape : ADBannerContentSizeIdentifierPortrait);
self.adView.currentContentSizeIdentifier = contentSizeId;
if (atBottom) {
self.bannerIsAtBottom = YES;
}
self.bannerIsVisible = NO;
self.bannerIsInitialized = YES;
}
}
- (void) __showAd:(BOOL)show
{
NSLog(@"SAiOSAdPlugin Show Ad: %d", show);
if (!self.bannerIsInitialized){
[self __prepare:NO];
}
if (!(NSClassFromString(@"ADBannerView") && self.adView)) { // ad classes not available
return;
}
if (show == self.bannerIsVisible) { // same state, nothing to do
return;
}
if (show)
{
[UIView beginAnimations:@"blah" context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[[[super webView] superview] addSubview:self.adView];
[[[super webView] superview] bringSubviewToFront:self.adView];
[self resizeViews];
[UIView commitAnimations];
self.bannerIsVisible = YES;
}
else
{
[UIView beginAnimations:@"blah" context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[self.adView removeFromSuperview];
[self resizeViews];
[UIView commitAnimations];
self.bannerIsVisible = NO;
}
}
#pragma mark -
#pragma ADBannerViewDelegate
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
Class adBannerViewClass = NSClassFromString(@"ADBannerView");
if (adBannerViewClass)
{
[super writeJavascript:@"Cordova.fireEvent('iAdBannerViewDidLoadAdEvent');"];
}
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError*)error
{
Class adBannerViewClass = NSClassFromString(@"ADBannerView");
if (adBannerViewClass)
{
NSString* jsString =
@"(function(){"
"var e = document.createEvent('Events');"
"e.initEvent('iAdBannerViewDidFailToReceiveAdWithErrorEvent');"
"e.error = '%@';"
"document.dispatchEvent(e);"
"})();";
[super writeJavascript:[NSString stringWithFormat:jsString, [error description]]];
}
}
@end

View File

@@ -1,156 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<!-- iPad/iPhone specific css below, add after your main css >
<link rel="stylesheet" media="only screen and (max-device-width: 1024px)" href="ipad.css" type="text/css" />
<link rel="stylesheet" media="only screen and (max-device-width: 480px)" href="iphone.css" type="text/css" />
-->
<!-- If you application is targeting iOS BEFORE 4.0 you MUST put json2.js from http://www.JSON.org/json2.js into your www directory and include it here -->
<script type="text/javascript" charset="utf-8" src="cordova-1.5.0.js"></script>
<script type="text/javascript" charset="utf-8" src="SAiOSAdPlugin.js"></script>
<script type="text/javascript" charset="utf-8">
// If you want to prevent dragging, uncomment this section
/*
function preventBehavior(e)
{
e.preventDefault();
};
document.addEventListener("touchmove", preventBehavior, false);
*/
var gLastAdLoadedDate = null;
var gTotalAdsLoaded = 0;
var gTimerId = null;
function onBodyLoad()
{
document.addEventListener("deviceready", onDeviceReady,false);
}
function onOrientationChange()
{
//alert(window.orientation);
}
/* When this function is called, PhoneGap has been initialized and is ready to roll */
function onDeviceReady()
{
// listen for orientation changes
window.addEventListener("orientationchange", window.plugins.iAdPlugin.orientationChanged, false);
// listen for the "iAdBannerViewDidLoadAdEvent" that is sent by the iAdPlugin
document.addEventListener("iAdBannerViewDidLoadAdEvent", iAdBannerViewDidLoadAdEventHandler, false);
// listen for the "iAdBannerViewDidFailToReceiveAdWithErrorEvent" that is sent by the iAdPlugin
document.addEventListener("iAdBannerViewDidFailToReceiveAdWithErrorEvent", iAdBannerViewDidFailToReceiveAdWithErrorEventHandler, false);
var adAtBottom = false;
setTimeout(function() {
window.plugins.iAdPlugin.prepare(adAtBottom); // by default, ad is at Top
}, 1000);
window.plugins.iAdPlugin.orientationChanged(true);//trigger immediately so iAd knows its orientation on first load
}
function iAdBannerViewDidFailToReceiveAdWithErrorEventHandler(evt)
{
alert(evt.error);
window.plugins.iAdPlugin.showAd(false);
var elem = document.getElementById("showAd");
elem.checked = false;
}
function iAdBannerViewDidLoadAdEventHandler(evt)
{
// if we got this event, a new ad is loaded
var elem = document.getElementById("lastAdLoaded");
gLastAdLoadedDate = new Date();
elem.innerHTML = gLastAdLoadedDate.toLocaleString();
elem = document.getElementById("showAd");
elem.disabled = false;
elem.checked = true;
window.plugins.iAdPlugin.showAd(true);
gTotalAdsLoaded++;
elem = document.getElementById("totalAdsLoaded");
elem.innerHTML = gTotalAdsLoaded.toString();
if (gTimerId) {
clearInterval(gTimerId);
}
gTimerId = setInterval(lastAdLoadedInterval, 1000);
}
function lastAdLoadedInterval()
{
var now = (new Date()).getTime();
var diff = now - gLastAdLoadedDate.getTime();
var elem = document.getElementById("lastAdLoaded");
var ms_in_a_year = 31449600000; /* 1000ms x 60s x 60m x 24hrs x 7d x 52w */
var ms_in_a_week = 604800000; /* 1000ms x 60s x 60m x 24hrs * 7d */
var ms_in_a_day = 86400000; /* 1000ms x 60s x 60m x 24hrs */
var ms_in_an_hour = 3600000; /* 1000ms x 60s x 60m */
var ms_in_a_minute = 60000; /* 1000ms x 60s */
var ms_in_a_second = 1000;
var milliseconds = Math.floor(diff);
var seconds = Math.floor(milliseconds / ms_in_a_second) % 60;
var minutes = Math.floor(milliseconds / ms_in_a_minute) % 60;
var hours = Math.floor(milliseconds / ms_in_an_hour) % 24;
var days = Math.floor(milliseconds / ms_in_a_day) % 7;
var weeks = Math.floor(milliseconds / ms_in_a_week) % 52;
var years = Math.floor(milliseconds / ms_in_a_year);
var caption = seconds + "s ago";
if (minutes > 0) {
caption = minutes + "m " + caption;
}
if (hours > 0) {
caption = hours + "h " + caption;
}
if (days > 0) {
caption = days + "d " + caption;
}
if (weeks > 0) {
caption = weeks + "w " + caption;
}
if (years > 0) {
caption = years + "yr " + caption;
}
elem.innerHTML = caption;
}
function showAdClicked(evt)
{
window.plugins.iAdPlugin.showAd(evt.checked);
}
</script>
</head>
<body style="margin:0; padding:0;border:1px solid blue;" onload="onBodyLoad()">
<span style="position:absolute; top:0;">
This is some text at the top of the webview.
</span>
<br /><br />
<form>
<input type="checkbox" id="showAd" name="showAd" disabled="disabled" onclick="showAdClicked(this);">Show iAd</input><br />
<br />
<span>New Ad Loaded: <span id="lastAdLoaded">Waiting.</span></span><br />
<span>Total Ads Loaded: <span id="totalAdsLoaded">None.</span></span>
</form>
<br />
<span style="position:absolute;bottom:0">
This is some text at the bottom of the webview.
</span>
</body>
</html>

View File

@@ -1,77 +0,0 @@
/*
Cordova v1.5.0 Support added 2012 @RandyMcMillan
README.md for install notes
Cordova v1.6.0 Support added @shazron
*/
// /////////////////////////
(function() {
// /////////////////////////
// get local ref to global PhoneGap/Cordova/cordova object for exec function
var cordovaRef = window.PhoneGap || window.Cordova || window.cordova; // old to new fallbacks
/**
* Constructor
*/
function SAiOSAdPlugin()
{
}
/**
* show - true to show the ad, false to hide the ad
*/
SAiOSAdPlugin.prototype.orientationChanged = function()
{
cordovaRef.exec("SAiOSAdPlugin.orientationChanged", window.orientation);
}
/**
* show - true to show the ad, false to hide the ad
*/
SAiOSAdPlugin.prototype.showAd = function(show)
{
cordovaRef.exec("SAiOSAdPlugin.showAd", show);
}
/**
* atBottom - true to put the ad at the bottom, false to put the ad at the top
*/
SAiOSAdPlugin.prototype.prepare = function(atBottom)
{
if (!atBottom) {
atBottom = false;
}
cordovaRef.exec("SAiOSAdPlugin.prepare", atBottom);
}
/**
* Install function
*/
SAiOSAdPlugin.install = function()
{
if ( !window.plugins ) {
window.plugins = {};
}
if ( !window.plugins.iAdPlugin ) {
window.plugins.iAdPlugin = new SAiOSAdPlugin();
}
}
/**
* Add to Cordova constructor
*/
if (cordovaRef && cordovaRef.addConstructor) {
cordovaRef.addConstructor(SAiOSAdPlugin.install);
} else {
console.log("iAd Cordova Plugin could not be installed.");
return null;
}
// /////////////////////////
})();
// /////////////////////////

View File

@@ -1,47 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "io.cordova.hello-cordova"
version = "2.0.0">
<name>Hello Cordova</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author href="http://cordova.io" email="callback-dev@incubator.apache.org">
Apache Cordova Team
</author>
<icon src="res/icon/cordova_512.png" width="512" height="512" />
<icon src="res/icon/cordova_android_96.png" width="96" height="96" gap:platform="android" />
<icon src="res/icon/cordova_bb_80.png" width="80" height="80" gap:platform="blackberry" />
<icon src="res/icon/cordova_ios_144.png" width="144" height="144" gap:platform="ios" />
<gap:splash src="res/screen/android_hdpi_landscape.png" width="800" height="480" gap:platform="android" />
<gap:splash src="res/screen/android_hdpi_portrait.png" width="480" height="800" gap:platform="android" />
<gap:splash src="res/screen/android_ldpi_landscape.png" width="320" height="200" gap:platform="android" />
<gap:splash src="res/screen/android_ldpi_portrait.png" width="200" height="320" gap:platform="android" />
<gap:splash src="res/screen/android_mdpi_landscape.png" width="480" height="320" gap:platform="android" />
<gap:splash src="res/screen/android_mdpi_portrait.png" width="320" height="480" gap:platform="android" />
<gap:splash src="res/screen/android_xhdpi_landscape.png" width="1280" height="720" gap:platform="android" />
<gap:splash src="res/screen/android_xhdpi_portrait.png" width="720" height="1280" gap:platform="android" />
<gap:splash src="res/screen/blackberry_transparent_300.png" width="300" height="300" gap:platform="blackberry" />
<gap:splash src="res/screen/blackberry_transparent_400.png" width="200" height="200" gap:platform="blackberry" />
<gap:splash src="res/screen/ipad_landscape.png" width="1024" height="748" gap:platform="ios" />
<gap:splash src="res/screen/ipad_portrait.png" width="768" height="1004" gap:platform="ios" />
<gap:splash src="res/screen/ipad_retina_landscape.png" width="2048" height="1496" gap:platform="ios" />
<gap:splash src="res/screen/ipad_retina_portrait.png" width="1536" height="2008" gap:platform="ios" />
<gap:splash src="res/screen/iphone_landscape.png" width="480" height="320" gap:platform="ios" />
<gap:splash src="res/screen/iphone_portrait.png" width="320" height="480" gap:platform="ios" />
<gap:splash src="res/screen/iphone_retina_landscape.png" width="960" height="640" gap:platform="ios" />
<gap:splash src="res/screen/iphone_retina_portrait.png" width="640" height="960" gap:platform="ios" />
<gap:splash src="res/screen/windows_phone_portrait.jpg" width="480" height="800" gap:platform="winphone" />
<feature name="http://api.phonegap.com/1.0/device" />
<preference name="phonegap-version" value="1.9.0" />
<preference name="orientation" value="default" />
<preference name="target-device" value="universal" />
<preference name="fullscreen" value="false" />
</widget>

File diff suppressed because it is too large Load Diff

View File

@@ -1,100 +0,0 @@
html,
body {
height:100%;
font-size:12px;
width:100%;
}
html {
display:table;
}
body {
background-color:#A7A7A7;
background-image:linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
background-image:-webkit-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
background-image:-ms-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
background-image:-webkit-gradient(
linear,
left top,
left bottom,
color-stop(0, #A7A7A7),
color-stop(0.51, #E4E4E4)
);
display:table-cell;
font-family:'HelveticaNeue-Light', 'HelveticaNeue', Helvetica, Arial, sans-serif;
text-transform:uppercase;
vertical-align:middle;
}
.app {
background-image:url(../img/cordova.png);
background-repeat:no-repeat;
margin:0px auto;
width:275px;
}
h1 {
font-size:2em;
font-weight:300;
margin:0px;
overflow:visible;
padding:0px;
text-align:center;
}
.status {
background-color:#333333;
border-radius:4px;
-webkit-border-radius:4px;
color:#FFFFFF;
font-size:1em;
margin:0px auto;
padding:2px 10px;
text-align:center;
width:100%;
max-width:175px;
}
.status.complete {
background-color:#4B946A;
}
.hide {
display:none;
}
@keyframes fade {
from { opacity: 1.0; }
50% { opacity: 0.4; }
to { opacity: 1.0; }
}
@-webkit-keyframes fade {
from { opacity: 1.0; }
50% { opacity: 0.4; }
to { opacity: 1.0; }
}
.blink {
animation:fade 3000ms infinite;
-webkit-animation:fade 3000ms infinite;
}
/* portrait */
/* @media screen and (max-aspect-ratio: 1/1) */
.app {
background-position:center top;
height:100px; /* adds enough room for text */
padding:180px 0px 0px 0px; /* background height - shadow offset */
}
/* lanscape (when wide enough) */
@media screen and (min-aspect-ratio: 1/1) and (min-width:445px) {
.app {
background-position:left center;
height:140px; /* height + padding = background image size */
padding-left:170px; /* background width */
padding-top:60px; /* center the text */
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

View File

@@ -1,175 +0,0 @@
<!DOCTYPE html>
<html>
<!--
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#
-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name = "format-detection" content = "telephone=no"/>
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width;" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<title>Hello Cordova</title>
</head>
<body>
<span style="position:absolute; top:0;">
This is some text at the top of the webview.
</span>
<div class="app">
<h1>Apache Cordova™</h1>
<div id="deviceready">
<p class="status pending blink">Connecting to Device</p>
<p class="status complete blink hide">Device is Ready</p>
<center>
<p><button onclick="window.plugins.iAdPlugin.showAd(true);">Click to show iAd!</button></p>
</center>
<center>
<p><button onclick="window.plugins.iAdPlugin.showAd(false);">Click to hide iAd!</button></p>
</center>
<br /><br />
<!--
<form>
<input type="checkbox" id="showAd" name="showAd" disabled="disabled" onclick="showAdClicked(this);">Show iAd</input><br />
<br />
<span>New Ad Loaded: <span id="lastAdLoaded">Waiting.</span></span><br />
<span>Total Ads Loaded: <span id="totalAdsLoaded">None.</span></span>
</form>
-->
<br />
</div>
</div>
<script type="text/javascript" src="cordova-2.0.0.js"></script>
<script type="text/javascript" charset="utf-8" src="SAiOSAdPlugin.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
app.initialize();
var gLastAdLoadedDate = null;
var gTotalAdsLoaded = 0;
var gTimerId = null;
function onOrientationChange()
{
//alert(window.orientation);
}
function iAdBannerViewDidFailToReceiveAdWithErrorEventHandler(evt)
{
alert(evt.error);
window.plugins.iAdPlugin.showAd(false);
var elem = document.getElementById("showAd");
elem.checked = false;
}
function iAdBannerViewDidLoadAdEventHandler(evt)
{
// if we got this event, a new ad is loaded
var elem = document.getElementById("lastAdLoaded");
gLastAdLoadedDate = new Date();
elem.innerHTML = gLastAdLoadedDate.toLocaleString();
elem = document.getElementById("showAd");
elem.disabled = false;
elem.checked = true;
window.plugins.iAdPlugin.showAd(true);
gTotalAdsLoaded++;
elem = document.getElementById("totalAdsLoaded");
elem.innerHTML = gTotalAdsLoaded.toString();
if (gTimerId) {
clearInterval(gTimerId);
}
gTimerId = setInterval(lastAdLoadedInterval, 1000);
}
function lastAdLoadedInterval()
{
var now = (new Date()).getTime();
var diff = now - gLastAdLoadedDate.getTime();
var elem = document.getElementById("lastAdLoaded");
var ms_in_a_year = 31449600000; /* 1000ms x 60s x 60m x 24hrs x 7d x 52w */
var ms_in_a_week = 604800000; /* 1000ms x 60s x 60m x 24hrs * 7d */
var ms_in_a_day = 86400000; /* 1000ms x 60s x 60m x 24hrs */
var ms_in_an_hour = 3600000; /* 1000ms x 60s x 60m */
var ms_in_a_minute = 60000; /* 1000ms x 60s */
var ms_in_a_second = 1000;
var milliseconds = Math.floor(diff);
var seconds = Math.floor(milliseconds / ms_in_a_second) % 60;
var minutes = Math.floor(milliseconds / ms_in_a_minute) % 60;
var hours = Math.floor(milliseconds / ms_in_an_hour) % 24;
var days = Math.floor(milliseconds / ms_in_a_day) % 7;
var weeks = Math.floor(milliseconds / ms_in_a_week) % 52;
var years = Math.floor(milliseconds / ms_in_a_year);
var caption = seconds + "s ago";
if (minutes > 0) {
caption = minutes + "m " + caption;
}
if (hours > 0) {
caption = hours + "h " + caption;
}
if (days > 0) {
caption = days + "d " + caption;
}
if (weeks > 0) {
caption = weeks + "w " + caption;
}
if (years > 0) {
caption = years + "yr " + caption;
}
elem.innerHTML = caption;
}
function showAdClicked(evt)
{
window.plugins.iAdPlugin.showAd(evt.checked);
}
</script>
<span style="position:absolute;bottom:0">
This is some text at the bottom of the webview.
</span>
</body>
</html>

View File

@@ -1,36 +0,0 @@
var app = {
initialize: function() {
this.bind();
},
bind: function() {
document.addEventListener('deviceready', this.deviceready, false);
},
deviceready: function() {
// note that this is an event handler so the scope is that of the event
// so we need to call app.report(), and not this.report()
app.report('deviceready');
// listen for orientation changes
window.addEventListener("orientationchange", window.plugins.iAdPlugin.orientationChanged, false);
// listen for the "iAdBannerViewDidLoadAdEvent" that is sent by the iAdPlugin
document.addEventListener("iAdBannerViewDidLoadAdEvent", iAdBannerViewDidLoadAdEventHandler, false);
// listen for the "iAdBannerViewDidFailToReceiveAdWithErrorEvent" that is sent by the iAdPlugin
document.addEventListener("iAdBannerViewDidFailToReceiveAdWithErrorEvent", iAdBannerViewDidFailToReceiveAdWithErrorEventHandler, false);
var adAtBottom = false;
setTimeout(function() {
window.plugins.iAdPlugin.prepare(adAtBottom); // by default, ad is at Top
}, 1000);
window.plugins.iAdPlugin.orientationChanged(true);//trigger immediately so iAd knows its orientation on first load
},
report: function(id) {
console.log("report:" + id);
// hide the .pending <p> and show the .complete <p>
document.querySelector('#' + id + ' .pending').className += ' hide';
var completeElem = document.querySelector('#' + id + ' .complete');
completeElem.className = completeElem.className.split('hide').join('');
}
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 213 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 478 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 493 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 398 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 412 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 332 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 342 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -1,50 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Jasmine Spec Runner</title>
<!-- jasmine source -->
<link rel="shortcut icon" type="image/png" href="spec/lib/jasmine-1.2.0/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="spec/lib/jasmine-1.2.0/jasmine.css">
<script type="text/javascript" src="spec/lib/jasmine-1.2.0/jasmine.js"></script>
<script type="text/javascript" src="spec/lib/jasmine-1.2.0/jasmine-html.js"></script>
<!-- include source files here... -->
<script type="text/javascript" src="js/index.js"></script>
<!-- include spec files here... -->
<script type="text/javascript" src="spec/helper.js"></script>
<script type="text/javascript" src="spec/index.js"></script>
<script type="text/javascript">
(function() {
var jasmineEnv = jasmine.getEnv();
jasmineEnv.updateInterval = 1000;
var htmlReporter = new jasmine.HtmlReporter();
jasmineEnv.addReporter(htmlReporter);
jasmineEnv.specFilter = function(spec) {
return htmlReporter.specFilter(spec);
};
var currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
execJasmine();
};
function execJasmine() {
jasmineEnv.execute();
}
})();
</script>
</head>
<body>
<div id="stage" style="display:none;"></div>
</body>
</html>

View File

@@ -1,11 +0,0 @@
afterEach(function() {
document.getElementById('stage').innerHTML = '';
});
var helper = {
trigger: function(obj, name) {
var e = document.createEvent('Event');
e.initEvent(name, true, true);
obj.dispatchEvent(e);
}
};

View File

@@ -1,49 +0,0 @@
describe('app', function() {
describe('initialize', function() {
it('should bind deviceready', function() {
runs(function() {
spyOn(app, 'deviceready');
app.initialize();
helper.trigger(window.document, 'deviceready');
});
waitsFor(function() {
return (app.deviceready.calls.length > 0);
}, 'deviceready should be called once', 500);
runs(function() {
expect(app.deviceready).toHaveBeenCalled();
});
});
});
describe('deviceready', function() {
it('should report that it fired', function() {
spyOn(app, 'report');
app.deviceready();
expect(app.report).toHaveBeenCalledWith('deviceready');
});
});
describe('report', function() {
beforeEach(function() {
var el = document.getElementById('stage');
el.innerHTML = ['<div id="deviceready">',
' <p class="status pending">Pending</p>',
' <p class="status complete hide">Complete</p>',
'</div>'].join('\n');
});
it('should show the completion state', function() {
app.report('deviceready');
var el = document.querySelector('#deviceready .complete:not(.hide)');
expect(el).toBeTruthy();
});
it('should hide the pending state', function() {
app.report('deviceready');
var el = document.querySelector('#deviceready .pending.hide');
expect(el).toBeTruthy();
});
});
});