Skip to content

Commit 40bec1e

Browse files
committed
added license and readme files
1 parent fafcf2f commit 40bec1e

File tree

4 files changed

+221
-164
lines changed

4 files changed

+221
-164
lines changed

LICENSE

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
PhoneGap is available under *either* the terms of the modified BSD license *or* the
2+
MIT License (2008). As a recipient of PhonegGap, you may choose which
3+
license to receive this code under (except as noted in per-module LICENSE
4+
files). Some modules may not be the copyright of Nitobi. These
5+
modules contain explicit declarations of copyright in both the LICENSE files in
6+
the directories in which they reside and in the code itself. No external
7+
contributions are allowed under licenses which are fundamentally incompatible
8+
with the MIT or BSD licenses that PhoneGap is distributed under.
9+
10+
The text of the MIT and BSD licenses is reproduced below.
11+
12+
-------------------------------------------------------------------------------
13+
The "New" BSD License:
14+
**********************
15+
16+
Copyright (c) 2005-2011, Nitobi Software Inc.
17+
All rights reserved.
18+
19+
Redistribution and use in source and binary forms, with or without
20+
modification, are permitted provided that the following conditions are met:
21+
22+
* Redistributions of source code must retain the above copyright notice, this
23+
list of conditions and the following disclaimer.
24+
* Redistributions in binary form must reproduce the above copyright notice,
25+
this list of conditions and the following disclaimer in the documentation
26+
and/or other materials provided with the distribution.
27+
* Neither the name of Phonegap/Nitobi nor the names of its contributors
28+
may be used to endorse or promote products derived from this software
29+
without specific prior written permission.
30+
31+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
32+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
33+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
34+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
35+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
37+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
38+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
39+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41+
42+
-------------------------------------------------------------------------------
43+
The MIT License
44+
*****************
45+
46+
Copyright (c) <2011> <Nitobi Software Inc., et. al., >
47+
48+
Permission is hereby granted, free of charge, to any person obtaining a copy
49+
of this software and associated documentation files (the "Software"), to deal
50+
in the Software without restriction, including without limitation the rights
51+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
52+
copies of the Software, and to permit persons to whom the Software is
53+
furnished to do so, subject to the following conditions:
54+
55+
The above copyright notice and this permission notice shall be included in
56+
all copies or substantial portions of the Software.
57+
58+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
59+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
60+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
61+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
62+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
63+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
64+
THE SOFTWARE.

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# PhoneGap.js Module Prototype
2+
3+
Just a scratchpad to prototype what having a common javascript
4+
layer for PhoneGap would look like if we used a module based
5+
pattern.
6+
7+
Everything here Is kinda a hack at the moment so please take it
8+
will a grain of salt. Currently:
9+
10+
# building
11+
12+
Just make sure you have node, npm and jake installed and run:
13+
14+
jake
15+
16+
it will build into the pkg folder. You can load up test/smoke.htm
17+
as it includes the build copy.
18+
19+
all you can do right now is require in some modules:
20+
21+
var PhoneGap = require("phonegap");
22+
23+
and .... thats about it.
24+
25+
#todo
26+
27+
- figure out the bootstrap
28+
- add in a platform builder to build up navigator
29+
- think more about what it means to run in node

lib/bootstrap.js

Lines changed: 128 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,141 +1,141 @@
1-
var Channel = require("./Channel"),
2-
/**
3-
* onDOMContentLoaded channel is fired when the DOM content
4-
* of the page has been parsed.
5-
*/
6-
onDOMContentLoaded = new Channel('onDOMContentLoaded'),
7-
/**
8-
* onNativeReady channel is fired when the PhoneGap native code
9-
* has been initialized.
10-
*/
11-
onNativeReady = new Channel('onNativeReady'),
12-
/**
13-
* onPhoneGapInit channel is fired when the web page is fully loaded and
14-
* PhoneGap native code has been initialized.
15-
*/
16-
onPhoneGapInit = new Channel('onPhoneGapInit'),
17-
/**
18-
* onPhoneGapReady channel is fired when the JS PhoneGap objects have been created.
19-
*/
20-
onPhoneGapReady = new Channel('onPhoneGapReady'),
21-
/**
22-
* onPhoneGapInfoReady channel is fired when the PhoneGap device properties
23-
* has been set.
24-
*/
25-
onPhoneGapInfoReady = new Channel('onPhoneGapInfoReady'),
26-
/**
27-
* onPhoneGapConnectionReady channel is fired when the PhoneGap connection properties
28-
* has been set.
29-
*/
30-
onPhoneGapConnectionReady = new Channel('onPhoneGapConnectionReady'),
31-
/**
32-
* onResume channel is fired when the PhoneGap native code
33-
* resumes.
34-
*/
35-
onResume = new Channel('onResume'),
36-
/**
37-
* onPause channel is fired when the PhoneGap native code
38-
* pauses.
39-
*/
40-
onPause = new Channel('onPause'),
41-
/**
42-
* onDeviceReady is fired only after all PhoneGap objects are created and
43-
* the device properties are set.
44-
*/
45-
onDeviceReady = new Channel('onDeviceReady'),
46-
/**
47-
* PhoneGap Channels that must fire before "deviceready" is fired.
48-
*/
49-
deviceReadyChannelsArray = [onPhoneGapReady, onPhoneGapInfoReady, onPhoneGapConnectionReady],
50-
deviceReadyChannelsMap = {},
51-
_self = {
1+
(function (context) {
2+
var Channel = require("./Channel"),
3+
/**
4+
* onDOMContentLoaded channel is fired when the DOM content
5+
* of the page has been parsed.
6+
*/
7+
onDOMContentLoaded = new Channel('onDOMContentLoaded'),
8+
/**
9+
* onNativeReady channel is fired when the PhoneGap native code
10+
* has been initialized.
11+
*/
12+
onNativeReady = new Channel('onNativeReady'),
13+
/**
14+
* onPhoneGapInit channel is fired when the web page is fully loaded and
15+
* PhoneGap native code has been initialized.
16+
*/
17+
onPhoneGapInit = new Channel('onPhoneGapInit'),
18+
/**
19+
* onPhoneGapReady channel is fired when the JS PhoneGap objects have been created.
20+
*/
21+
onPhoneGapReady = new Channel('onPhoneGapReady'),
22+
/**
23+
* onPhoneGapInfoReady channel is fired when the PhoneGap device properties
24+
* has been set.
25+
*/
26+
onPhoneGapInfoReady = new Channel('onPhoneGapInfoReady'),
27+
/**
28+
* onPhoneGapConnectionReady channel is fired when the PhoneGap connection properties
29+
* has been set.
30+
*/
31+
onPhoneGapConnectionReady = new Channel('onPhoneGapConnectionReady'),
32+
/**
33+
* onResume channel is fired when the PhoneGap native code
34+
* resumes.
35+
*/
36+
onResume = new Channel('onResume'),
37+
/**
38+
* onPause channel is fired when the PhoneGap native code
39+
* pauses.
40+
*/
41+
onPause = new Channel('onPause'),
42+
/**
43+
* onDeviceReady is fired only after all PhoneGap objects are created and
44+
* the device properties are set.
45+
*/
46+
onDeviceReady = new Channel('onDeviceReady'),
47+
/**
48+
* PhoneGap Channels that must fire before "deviceready" is fired.
49+
*/
50+
deviceReadyChannelsArray = [onPhoneGapReady, onPhoneGapInfoReady, onPhoneGapConnectionReady],
51+
deviceReadyChannelsMap = {},
52+
_self = {
5253

53-
boot: function () {
54-
//---------------
55-
// Event handling
56-
//---------------
54+
boot: function () {
55+
//---------------
56+
// Event handling
57+
//---------------
5758

58-
/**
59-
* Listen for DOMContentLoaded and notify our channel subscribers.
60-
*/
61-
document.addEventListener('DOMContentLoaded', function() {
62-
PhoneGap.onDOMContentLoaded.fire();
63-
}, false);
59+
/**
60+
* Listen for DOMContentLoaded and notify our channel subscribers.
61+
*/
62+
document.addEventListener('DOMContentLoaded', function() {
63+
PhoneGap.onDOMContentLoaded.fire();
64+
}, false);
6465

65-
/**
66-
* Intercept calls to document.addEventListener and handle deviceready,
67-
* resume, and pause events.
68-
*/
69-
PhoneGap.m_document_addEventListener = document.addEventListener;
66+
/**
67+
* Intercept calls to document.addEventListener and handle deviceready,
68+
* resume, and pause events.
69+
*/
70+
PhoneGap.m_document_addEventListener = document.addEventListener;
7071

71-
document.addEventListener = function(evt, handler, capture) {
72-
var e = evt.toLowerCase();
73-
if (e == 'deviceready') {
74-
PhoneGap.onDeviceReady.subscribeOnce(handler);
75-
} else if (e == 'resume') {
76-
PhoneGap.onResume.subscribe(handler);
77-
// if subscribing listener after event has already fired, invoke the handler
78-
if (PhoneGap.onResume.fired && handler instanceof Function) {
79-
handler();
72+
document.addEventListener = function(evt, handler, capture) {
73+
var e = evt.toLowerCase();
74+
if (e == 'deviceready') {
75+
PhoneGap.onDeviceReady.subscribeOnce(handler);
76+
} else if (e == 'resume') {
77+
PhoneGap.onResume.subscribe(handler);
78+
// if subscribing listener after event has already fired, invoke the handler
79+
if (PhoneGap.onResume.fired && handler instanceof Function) {
80+
handler();
81+
}
82+
} else if (e == 'pause') {
83+
PhoneGap.onPause.subscribe(handler);
84+
} else {
85+
PhoneGap.m_document_addEventListener.call(document, evt, handler, capture);
8086
}
81-
} else if (e == 'pause') {
82-
PhoneGap.onPause.subscribe(handler);
83-
} else {
84-
PhoneGap.m_document_addEventListener.call(document, evt, handler, capture);
85-
}
86-
};
87+
};
8788

88-
/**
89-
* Create all PhoneGap objects once page has fully loaded and native side is ready.
90-
*/
91-
Channel.join(function() {
89+
/**
90+
* Create all PhoneGap objects once page has fully loaded and native side is ready.
91+
*/
92+
Channel.join(function() {
9293

93-
// Run PhoneGap constructors
94-
onPhoneGapInit.fire();
94+
// Run PhoneGap constructors
95+
onPhoneGapInit.fire();
9596

96-
// Fire event to notify that all objects are created
97-
onPhoneGapReady.fire();
97+
// Fire event to notify that all objects are created
98+
onPhoneGapReady.fire();
9899

99-
// Fire onDeviceReady event once all constructors have run and
100-
// PhoneGap info has been received from native side.
101-
Channel.join(function() {
102-
onDeviceReady.fire();
100+
// Fire onDeviceReady event once all constructors have run and
101+
// PhoneGap info has been received from native side.
102+
Channel.join(function() {
103+
onDeviceReady.fire();
104+
105+
// Fire the onresume event, since first one happens before JavaScript is loaded
106+
onResume.fire();
107+
}, deviceReadyChannelsArray);
103108

104-
// Fire the onresume event, since first one happens before JavaScript is loaded
105-
onResume.fire();
106-
}, deviceReadyChannelsArray);
107-
108-
}, [ onDOMContentLoaded, onNativeReady ]);
109-
},
109+
}, [ onDOMContentLoaded, onNativeReady ]);
110+
},
110111

111-
/**
112-
* User-defined channels that must also fire before "deviceready" is fired.
113-
*/
114-
waitForInitialization: function(feature) {
115-
var channel;
116-
if (feature) {
117-
channel = new Channel(feature);
118-
deviceReadyChannelsMap[feature] = channel;
119-
deviceReadyChannelsArray.push(channel);
120-
}
121-
},
122-
/**
123-
* Indicate that initialization code has completed and the feature is ready to
124-
* be used.
125-
*
126-
* @param feature {String} The unique feature name
127-
*/
128-
initializationComplete: function(feature) {
129-
var channel = deviceReadyChannelsMap[feature];
130-
if (channel) {
131-
channel.fire();
132-
}
112+
/**
113+
* User-defined channels that must also fire before "deviceready" is fired.
114+
*/
115+
waitForInitialization: function(feature) {
116+
var channel;
117+
if (feature) {
118+
channel = new Channel(feature);
119+
deviceReadyChannelsMap[feature] = channel;
120+
deviceReadyChannelsArray.push(channel);
121+
}
122+
},
123+
/**
124+
* Indicate that initialization code has completed and the feature is ready to
125+
* be used.
126+
*
127+
* @param feature {String} The unique feature name
128+
*/
129+
initializationComplete: function(feature) {
130+
var channel = deviceReadyChannelsMap[feature];
131+
if (channel) {
132+
channel.fire();
133+
}
134+
};
133135
};
134-
};
135-
136-
module.exports = _self;
137136

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

0 commit comments

Comments
 (0)