Skip to content
Permalink
Browse files
added license and readme files
  • Loading branch information
gtanner committed Nov 15, 2011
1 parent fafcf2f commit 40bec1e3361d1bca86bc3a81659d5b104fc31450
Show file tree
Hide file tree
Showing 4 changed files with 221 additions and 164 deletions.
64 LICENSE
@@ -0,0 +1,64 @@
PhoneGap is available under *either* the terms of the modified BSD license *or* the
MIT License (2008). As a recipient of PhonegGap, you may choose which
license to receive this code under (except as noted in per-module LICENSE
files). Some modules may not be the copyright of Nitobi. These
modules contain explicit declarations of copyright in both the LICENSE files in
the directories in which they reside and in the code itself. No external
contributions are allowed under licenses which are fundamentally incompatible
with the MIT or BSD licenses that PhoneGap is distributed under.

The text of the MIT and BSD licenses is reproduced below.

-------------------------------------------------------------------------------
The "New" BSD License:
**********************

Copyright (c) 2005-2011, Nitobi Software Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Phonegap/Nitobi nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-------------------------------------------------------------------------------
The MIT License
*****************

Copyright (c) <2011> <Nitobi Software Inc., et. al., >

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
@@ -0,0 +1,29 @@
# PhoneGap.js Module Prototype

Just a scratchpad to prototype what having a common javascript
layer for PhoneGap would look like if we used a module based
pattern.

Everything here Is kinda a hack at the moment so please take it
will a grain of salt. Currently:

# building

Just make sure you have node, npm and jake installed and run:

jake

it will build into the pkg folder. You can load up test/smoke.htm
as it includes the build copy.

all you can do right now is require in some modules:

var PhoneGap = require("phonegap");

and .... thats about it.

#todo

- figure out the bootstrap
- add in a platform builder to build up navigator
- think more about what it means to run in node
@@ -1,141 +1,141 @@
var Channel = require("./Channel"),
/**
* onDOMContentLoaded channel is fired when the DOM content
* of the page has been parsed.
*/
onDOMContentLoaded = new Channel('onDOMContentLoaded'),
/**
* onNativeReady channel is fired when the PhoneGap native code
* has been initialized.
*/
onNativeReady = new Channel('onNativeReady'),
/**
* onPhoneGapInit channel is fired when the web page is fully loaded and
* PhoneGap native code has been initialized.
*/
onPhoneGapInit = new Channel('onPhoneGapInit'),
/**
* onPhoneGapReady channel is fired when the JS PhoneGap objects have been created.
*/
onPhoneGapReady = new Channel('onPhoneGapReady'),
/**
* onPhoneGapInfoReady channel is fired when the PhoneGap device properties
* has been set.
*/
onPhoneGapInfoReady = new Channel('onPhoneGapInfoReady'),
/**
* onPhoneGapConnectionReady channel is fired when the PhoneGap connection properties
* has been set.
*/
onPhoneGapConnectionReady = new Channel('onPhoneGapConnectionReady'),
/**
* onResume channel is fired when the PhoneGap native code
* resumes.
*/
onResume = new Channel('onResume'),
/**
* onPause channel is fired when the PhoneGap native code
* pauses.
*/
onPause = new Channel('onPause'),
/**
* onDeviceReady is fired only after all PhoneGap objects are created and
* the device properties are set.
*/
onDeviceReady = new Channel('onDeviceReady'),
/**
* PhoneGap Channels that must fire before "deviceready" is fired.
*/
deviceReadyChannelsArray = [onPhoneGapReady, onPhoneGapInfoReady, onPhoneGapConnectionReady],
deviceReadyChannelsMap = {},
_self = {
(function (context) {
var Channel = require("./Channel"),
/**
* onDOMContentLoaded channel is fired when the DOM content
* of the page has been parsed.
*/
onDOMContentLoaded = new Channel('onDOMContentLoaded'),
/**
* onNativeReady channel is fired when the PhoneGap native code
* has been initialized.
*/
onNativeReady = new Channel('onNativeReady'),
/**
* onPhoneGapInit channel is fired when the web page is fully loaded and
* PhoneGap native code has been initialized.
*/
onPhoneGapInit = new Channel('onPhoneGapInit'),
/**
* onPhoneGapReady channel is fired when the JS PhoneGap objects have been created.
*/
onPhoneGapReady = new Channel('onPhoneGapReady'),
/**
* onPhoneGapInfoReady channel is fired when the PhoneGap device properties
* has been set.
*/
onPhoneGapInfoReady = new Channel('onPhoneGapInfoReady'),
/**
* onPhoneGapConnectionReady channel is fired when the PhoneGap connection properties
* has been set.
*/
onPhoneGapConnectionReady = new Channel('onPhoneGapConnectionReady'),
/**
* onResume channel is fired when the PhoneGap native code
* resumes.
*/
onResume = new Channel('onResume'),
/**
* onPause channel is fired when the PhoneGap native code
* pauses.
*/
onPause = new Channel('onPause'),
/**
* onDeviceReady is fired only after all PhoneGap objects are created and
* the device properties are set.
*/
onDeviceReady = new Channel('onDeviceReady'),
/**
* PhoneGap Channels that must fire before "deviceready" is fired.
*/
deviceReadyChannelsArray = [onPhoneGapReady, onPhoneGapInfoReady, onPhoneGapConnectionReady],
deviceReadyChannelsMap = {},
_self = {

boot: function () {
//---------------
// Event handling
//---------------
boot: function () {
//---------------
// Event handling
//---------------

/**
* Listen for DOMContentLoaded and notify our channel subscribers.
*/
document.addEventListener('DOMContentLoaded', function() {
PhoneGap.onDOMContentLoaded.fire();
}, false);
/**
* Listen for DOMContentLoaded and notify our channel subscribers.
*/
document.addEventListener('DOMContentLoaded', function() {
PhoneGap.onDOMContentLoaded.fire();
}, false);

/**
* Intercept calls to document.addEventListener and handle deviceready,
* resume, and pause events.
*/
PhoneGap.m_document_addEventListener = document.addEventListener;
/**
* Intercept calls to document.addEventListener and handle deviceready,
* resume, and pause events.
*/
PhoneGap.m_document_addEventListener = document.addEventListener;

document.addEventListener = function(evt, handler, capture) {
var e = evt.toLowerCase();
if (e == 'deviceready') {
PhoneGap.onDeviceReady.subscribeOnce(handler);
} else if (e == 'resume') {
PhoneGap.onResume.subscribe(handler);
// if subscribing listener after event has already fired, invoke the handler
if (PhoneGap.onResume.fired && handler instanceof Function) {
handler();
document.addEventListener = function(evt, handler, capture) {
var e = evt.toLowerCase();
if (e == 'deviceready') {
PhoneGap.onDeviceReady.subscribeOnce(handler);
} else if (e == 'resume') {
PhoneGap.onResume.subscribe(handler);
// if subscribing listener after event has already fired, invoke the handler
if (PhoneGap.onResume.fired && handler instanceof Function) {
handler();
}
} else if (e == 'pause') {
PhoneGap.onPause.subscribe(handler);
} else {
PhoneGap.m_document_addEventListener.call(document, evt, handler, capture);
}
} else if (e == 'pause') {
PhoneGap.onPause.subscribe(handler);
} else {
PhoneGap.m_document_addEventListener.call(document, evt, handler, capture);
}
};
};

/**
* Create all PhoneGap objects once page has fully loaded and native side is ready.
*/
Channel.join(function() {
/**
* Create all PhoneGap objects once page has fully loaded and native side is ready.
*/
Channel.join(function() {

// Run PhoneGap constructors
onPhoneGapInit.fire();
// Run PhoneGap constructors
onPhoneGapInit.fire();

// Fire event to notify that all objects are created
onPhoneGapReady.fire();
// Fire event to notify that all objects are created
onPhoneGapReady.fire();

// Fire onDeviceReady event once all constructors have run and
// PhoneGap info has been received from native side.
Channel.join(function() {
onDeviceReady.fire();
// Fire onDeviceReady event once all constructors have run and
// PhoneGap info has been received from native side.
Channel.join(function() {
onDeviceReady.fire();

// Fire the onresume event, since first one happens before JavaScript is loaded
onResume.fire();
}, deviceReadyChannelsArray);

// Fire the onresume event, since first one happens before JavaScript is loaded
onResume.fire();
}, deviceReadyChannelsArray);

}, [ onDOMContentLoaded, onNativeReady ]);
},
}, [ onDOMContentLoaded, onNativeReady ]);
},

/**
* User-defined channels that must also fire before "deviceready" is fired.
*/
waitForInitialization: function(feature) {
var channel;
if (feature) {
channel = new Channel(feature);
deviceReadyChannelsMap[feature] = channel;
deviceReadyChannelsArray.push(channel);
}
},
/**
* Indicate that initialization code has completed and the feature is ready to
* be used.
*
* @param feature {String} The unique feature name
*/
initializationComplete: function(feature) {
var channel = deviceReadyChannelsMap[feature];
if (channel) {
channel.fire();
}
/**
* User-defined channels that must also fire before "deviceready" is fired.
*/
waitForInitialization: function(feature) {
var channel;
if (feature) {
channel = new Channel(feature);
deviceReadyChannelsMap[feature] = channel;
deviceReadyChannelsArray.push(channel);
}
},
/**
* Indicate that initialization code has completed and the feature is ready to
* be used.
*
* @param feature {String} The unique feature name
*/
initializationComplete: function(feature) {
var channel = deviceReadyChannelsMap[feature];
if (channel) {
channel.fire();
}
};
};
};

module.exports = _self;

// _nativeReady is global variable that the native side can set
// to signify that the native code is ready. It is a global since
// it may be called before any PhoneGap JS is ready.
if (typeof _nativeReady !== 'undefined') { PhoneGap.onNativeReady.fire(); }
// _nativeReady is global variable that the native side can set
// to signify that the native code is ready. It is a global since
// it may be called before any PhoneGap JS is ready.
if (typeof _nativeReady !== 'undefined') { PhoneGap.onNativeReady.fire(); }
}(global || window));

0 comments on commit 40bec1e

Please sign in to comment.