You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2012/05/02 00:05:10 UTC
webworks commit: Updated BB to 1.7.0
Updated Branches:
refs/heads/master def15ead0 -> f9e845848
Updated BB to 1.7.0
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/commit/f9e84584
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/tree/f9e84584
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/diff/f9e84584
Branch: refs/heads/master
Commit: f9e845848536d05c037664dec801f31a10d0d22a
Parents: def15ea
Author: shazron <sh...@gmail.com>
Authored: Tue May 1 15:05:00 2012 -0700
Committer: shazron <sh...@gmail.com>
Committed: Tue May 1 15:05:00 2012 -0700
----------------------------------------------------------------------
VERSION | 2 +-
.../ext/src/org/apache/cordova/device/Device.java | 2 +-
javascript/cordova.blackberry.js | 302 +++++++++------
javascript/cordova.playbook.js | 271 ++++++++------
4 files changed, 335 insertions(+), 242 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/f9e84584/VERSION
----------------------------------------------------------------------
diff --git a/VERSION b/VERSION
index d88d8e7..bd8bf88 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.7.0rc1
+1.7.0
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/f9e84584/framework/ext/src/org/apache/cordova/device/Device.java
----------------------------------------------------------------------
diff --git a/framework/ext/src/org/apache/cordova/device/Device.java b/framework/ext/src/org/apache/cordova/device/Device.java
index e718941..e0226f5 100644
--- a/framework/ext/src/org/apache/cordova/device/Device.java
+++ b/framework/ext/src/org/apache/cordova/device/Device.java
@@ -53,7 +53,7 @@ public final class Device extends Plugin {
JSONObject device = new JSONObject();
device.put( FIELD_PLATFORM, new String(DeviceInfo.getPlatformVersion() ) );
device.put( FIELD_UUID, new Integer( DeviceInfo.getDeviceId()) );
- device.put( FIELD_CORDOVA, "1.7.0rc1" );
+ device.put( FIELD_CORDOVA, "1.7.0" );
device.put( FIELD_NAME, new String(DeviceInfo.getDeviceName()) );
device.put( FIELD_VERSION, new String(DeviceInfo.getSoftwareVersion()) );
result = new PluginResult(PluginResult.Status.OK, device);
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/f9e84584/javascript/cordova.blackberry.js
----------------------------------------------------------------------
diff --git a/javascript/cordova.blackberry.js b/javascript/cordova.blackberry.js
index d4680da..8b543e0 100644
--- a/javascript/cordova.blackberry.js
+++ b/javascript/cordova.blackberry.js
@@ -1,6 +1,6 @@
-// commit a42f0ae6245e7609c9bad1eb582777a696201aad
+// commit 9cfdc134f83b5d51f655e52ec7d4ddab167437c7
-// File generated at :: Tue Apr 24 2012 15:08:45 GMT-0700 (PDT)
+// File generated at :: Tue May 01 2012 14:06:43 GMT-0700 (PDT)
/*
Licensed to the Apache Software Foundation (ASF) under one
@@ -101,27 +101,27 @@ document.addEventListener = function(evt, handler, capture) {
if (e == 'deviceready') {
channel.onDeviceReady.subscribeOnce(handler);
} else if (e == 'resume') {
- channel.onResume.subscribe(handler);
- // if subscribing listener after event has already fired, invoke the handler
- if (channel.onResume.fired && handler instanceof Function) {
- handler();
- }
+ channel.onResume.subscribe(handler);
+ // if subscribing listener after event has already fired, invoke the handler
+ if (channel.onResume.fired && typeof handler == 'function') {
+ handler();
+ }
} else if (e == 'pause') {
- channel.onPause.subscribe(handler);
+ channel.onPause.subscribe(handler);
} else if (typeof documentEventHandlers[e] != 'undefined') {
- documentEventHandlers[e].subscribe(handler);
+ documentEventHandlers[e].subscribe(handler);
} else {
- m_document_addEventListener.call(document, evt, handler, capture);
+ m_document_addEventListener.call(document, evt, handler, capture);
}
};
window.addEventListener = function(evt, handler, capture) {
- var e = evt.toLowerCase();
- if (typeof windowEventHandlers[e] != 'undefined') {
- windowEventHandlers[e].subscribe(handler);
- } else {
- m_window_addEventListener.call(window, evt, handler, capture);
- }
+ var e = evt.toLowerCase();
+ if (typeof windowEventHandlers[e] != 'undefined') {
+ windowEventHandlers[e].subscribe(handler);
+ } else {
+ m_window_addEventListener.call(window, evt, handler, capture);
+ }
};
document.removeEventListener = function(evt, handler, capture) {
@@ -140,30 +140,29 @@ document.removeEventListener = function(evt, handler, capture) {
};
window.removeEventListener = function(evt, handler, capture) {
- var e = evt.toLowerCase();
- // If unsubcribing from an event that is handled by a plugin
- if (typeof windowEventHandlers[e] != "undefined") {
- windowEventHandlers[e].unsubscribe(handler);
- } else {
- m_window_removeEventListener.call(window, evt, handler, capture);
- }
+ var e = evt.toLowerCase();
+ // If unsubcribing from an event that is handled by a plugin
+ if (typeof windowEventHandlers[e] != "undefined") {
+ windowEventHandlers[e].unsubscribe(handler);
+ } else {
+ m_window_removeEventListener.call(window, evt, handler, capture);
+ }
};
function createEvent(type, data) {
- var event = document.createEvent('Events');
- event.initEvent(type, false, false);
- if (data) {
- for (var i in data) {
- if (data.hasOwnProperty(i)) {
- event[i] = data[i];
- }
+ var event = document.createEvent('Events');
+ event.initEvent(type, false, false);
+ if (data) {
+ for (var i in data) {
+ if (data.hasOwnProperty(i)) {
+ event[i] = data[i];
+ }
+ }
}
- }
- return event;
+ return event;
}
-if(typeof window.console === "undefined")
-{
+if(typeof window.console === "undefined") {
window.console = {
log:function(){}
};
@@ -176,16 +175,16 @@ var cordova = {
* Methods to add/remove your own addEventListener hijacking on document + window.
*/
addWindowEventHandler:function(event, opts) {
- return (windowEventHandlers[event] = channel.create(event, opts));
+ return (windowEventHandlers[event] = channel.create(event, opts));
},
addDocumentEventHandler:function(event, opts) {
- return (documentEventHandlers[event] = channel.create(event, opts));
+ return (documentEventHandlers[event] = channel.create(event, opts));
},
removeWindowEventHandler:function(event) {
- delete windowEventHandlers[event];
+ delete windowEventHandlers[event];
},
removeDocumentEventHandler:function(event) {
- delete documentEventHandlers[event];
+ delete documentEventHandlers[event];
},
/**
* Retreive original event handlers that were replaced by Cordova
@@ -200,20 +199,20 @@ var cordova = {
* Method to fire event from native code
*/
fireDocumentEvent: function(type, data) {
- var evt = createEvent(type, data);
- if (typeof documentEventHandlers[type] != 'undefined') {
- documentEventHandlers[type].fire(evt);
- } else {
- document.dispatchEvent(evt);
- }
+ var evt = createEvent(type, data);
+ if (typeof documentEventHandlers[type] != 'undefined') {
+ documentEventHandlers[type].fire(evt);
+ } else {
+ document.dispatchEvent(evt);
+ }
},
fireWindowEvent: function(type, data) {
- var evt = createEvent(type,data);
- if (typeof windowEventHandlers[type] != 'undefined') {
- windowEventHandlers[type].fire(evt);
- } else {
- window.dispatchEvent(evt);
- }
+ var evt = createEvent(type,data);
+ if (typeof windowEventHandlers[type] != 'undefined') {
+ windowEventHandlers[type].fire(evt);
+ } else {
+ window.dispatchEvent(evt);
+ }
},
// TODO: this is Android only; think about how to do this better
shuttingDown:false,
@@ -319,15 +318,41 @@ var cordova = {
}
};
+// Adds deprecation warnings to functions of an object (but only logs a message once)
+function deprecateFunctions(obj, objLabel) {
+ var newObj = {};
+ var logHash = {};
+ for (var i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ if (typeof obj[i] == 'function') {
+ newObj[i] = (function(prop){
+ var oldFunk = obj[prop];
+ var funkId = objLabel + '_' + prop;
+ return function() {
+ if (!logHash[funkId]) {
+ console.log('[DEPRECATION NOTICE] The "' + objLabel + '" global will be removed in version 2.0, please use lowercase "cordova".');
+ logHash[funkId] = true;
+ }
+ oldFunk.apply(obj, arguments);
+ };
+ })(i);
+ } else {
+ newObj[i] = (function(prop) { return obj[prop]; })(i);
+ }
+ }
+ }
+ return newObj;
+}
+
/**
* Legacy variable for plugin support
* TODO: remove in 2.0.
*/
if (!window.PhoneGap) {
- window.PhoneGap = cordova;
+ window.PhoneGap = deprecateFunctions(cordova, 'PhoneGap');
}
if (!window.Cordova) {
- window.Cordova = cordova;
+ window.Cordova = deprecateFunctions(cordova, 'Cordova');
}
/**
@@ -437,6 +462,8 @@ module.exports = {
// file: lib/common/channel.js
define("cordova/channel", function(require, exports, module) {
+var utils = require('cordova/utils');
+
/**
* Custom pub-sub "channel" that can have functions subscribed to it
* This object is used to define and control firing of events for
@@ -484,21 +511,21 @@ define("cordova/channel", function(require, exports, module) {
* context to the Channel.
*/
var Channel = function(type, opts) {
- this.type = type;
- this.handlers = {};
- this.numHandlers = 0;
- this.guid = 0;
- this.fired = false;
- this.enabled = true;
- this.events = {
- onSubscribe:null,
- onUnsubscribe:null
- };
- if (opts) {
- if (opts.onSubscribe) this.events.onSubscribe = opts.onSubscribe;
- if (opts.onUnsubscribe) this.events.onUnsubscribe = opts.onUnsubscribe;
- }
- },
+ this.type = type;
+ this.handlers = {};
+ this.numHandlers = 0;
+ this.guid = 0;
+ this.fired = false;
+ this.enabled = true;
+ this.events = {
+ onSubscribe:null,
+ onUnsubscribe:null
+ };
+ if (opts) {
+ if (opts.onSubscribe) this.events.onSubscribe = opts.onSubscribe;
+ if (opts.onUnsubscribe) this.events.onUnsubscribe = opts.onUnsubscribe;
+ }
+},
channel = {
/**
* Calls the provided function only after all of the channels specified
@@ -558,8 +585,11 @@ var Channel = function(type, opts) {
c.fire();
}
}
- },
- utils = require('cordova/utils');
+ };
+
+function forceFunction(f) {
+ if (f === null || f === undefined || typeof f != 'function') throw "Function required as first argument!";
+}
/**
* Subscribes the given function to the channel. Any time that
@@ -570,10 +600,10 @@ var Channel = function(type, opts) {
*/
Channel.prototype.subscribe = function(f, c, g) {
// need a function to call
- if (f === null || f === undefined) { return; }
+ forceFunction(f);
var func = f;
- if (typeof c == "object" && f instanceof Function) { func = utils.close(c, f); }
+ if (typeof c == "object") { func = utils.close(c, f); }
g = g || func.observer_guid || f.observer_guid || this.guid++;
func.observer_guid = g;
@@ -590,7 +620,7 @@ Channel.prototype.subscribe = function(f, c, g) {
*/
Channel.prototype.subscribeOnce = function(f, c) {
// need a function to call
- if (f === null || f === undefined) { return; }
+ forceFunction(f);
var g = null;
var _this = this;
@@ -599,7 +629,7 @@ Channel.prototype.subscribeOnce = function(f, c) {
_this.unsubscribe(g);
};
if (this.fired) {
- if (typeof c == "object" && f instanceof Function) { f = utils.close(c, f); }
+ if (typeof c == "object") { f = utils.close(c, f); }
f.apply(this, this.fireArgs);
} else {
g = this.subscribe(m);
@@ -612,9 +642,9 @@ Channel.prototype.subscribeOnce = function(f, c) {
*/
Channel.prototype.unsubscribe = function(g) {
// need a function to unsubscribe
- if (g === null || g === undefined) { return; }
+ if (g === null || g === undefined) { throw "You must pass _something_ into Channel.unsubscribe"; }
- if (g instanceof Function) { g = g.observer_guid; }
+ if (typeof g == 'function') { g = g.observer_guid; }
this.handlers[g] = null;
delete this.handlers[g];
this.numHandlers--;
@@ -630,7 +660,7 @@ Channel.prototype.fire = function(e) {
this.fired = true;
for (var item in this.handlers) {
var handler = this.handlers[item];
- if (handler instanceof Function) {
+ if (typeof handler == 'function') {
var rv = (handler.apply(this, arguments)===false);
fail = fail || rv;
}
@@ -676,6 +706,7 @@ channel.waitForInitialization('onCordovaInfoReady');
channel.waitForInitialization('onCordovaConnectionReady');
module.exports = channel;
+
});
// file: lib/common/common.js
@@ -690,6 +721,20 @@ module.exports = {
}
}
},
+ Cordova: {
+ children: {
+ exec: {
+ path: 'cordova/exec'
+ }
+ }
+ },
+ PhoneGap:{
+ children: {
+ exec: {
+ path: 'cordova/exec'
+ }
+ }
+ },
navigator: {
children: {
notification: {
@@ -860,6 +905,7 @@ module.exports = {
}
}
};
+
});
// file: lib/blackberry/exec.js
@@ -1416,14 +1462,14 @@ function convertOut(contact) {
var value = contact.birthday;
if (value !== null) {
// try to make it a Date object if it is not already
- if (!value instanceof Date){
+ if (!utils.isDate(value)){
try {
value = new Date(value);
} catch(exception){
value = null;
}
}
- if (value instanceof Date){
+ if (utils.isDate(value)){
value = value.valueOf(); // convert to milliseconds
}
contact.birthday = value;
@@ -1566,6 +1612,7 @@ Contact.prototype.save = function(successCB, errorCB) {
module.exports = Contact;
+
});
// file: lib/common/plugin/ContactAddress.js
@@ -1634,8 +1681,8 @@ define("cordova/plugin/ContactField", function(require, exports, module) {
*/
var ContactField = function(type, value, pref) {
this.id = null;
- this.type = type || null;
- this.value = value || null;
+ this.type = (type && type.toString()) || null;
+ this.value = (value && value.toString()) || null;
this.pref = (typeof pref != 'undefined' ? pref : false);
};
@@ -2520,7 +2567,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
fileKey = options.fileKey;
fileName = options.fileName;
mimeType = options.mimeType;
- if (options.chunkedMode !== null || typeof options.chunkedMode !== "undefined") {
+ if (options.chunkedMode !== null || typeof options.chunkedMode != "undefined") {
chunkedMode = options.chunkedMode;
}
if (options.params) {
@@ -3136,7 +3183,7 @@ var utils = require('cordova/utils'),
* size {Number} size of the file in bytes
*/
var MediaFile = function(name, fullPath, type, lastModifiedDate, size){
- MediaFile.__super__.constructor.apply(this, arguments);
+ MediaFile.__super__.constructor.apply(this, arguments);
};
utils.extend(MediaFile, File);
@@ -3151,10 +3198,11 @@ MediaFile.prototype.getFormatData = function(successCallback, errorCallback) {
if (typeof this.fullPath === "undefined" || this.fullPath === null) {
errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
} else {
- exec(successCallback, errorCallback, "Capture", "getFormatData", [this.fullPath, this.type]);
+ exec(successCallback, errorCallback, "Capture", "getFormatData", [this.fullPath, this.type]);
}
};
+// TODO: can we axe this?
/**
* Casts a PluginResult message property (array of objects) to an array of MediaFile objects
* (used in Objective-C and Android)
@@ -3162,22 +3210,22 @@ MediaFile.prototype.getFormatData = function(successCallback, errorCallback) {
* @param {PluginResult} pluginResult
*/
MediaFile.cast = function(pluginResult) {
- var mediaFiles = [];
- var i;
- for (i=0; i<pluginResult.message.length; i++) {
- var mediaFile = new MediaFile();
- mediaFile.name = pluginResult.message[i].name;
- mediaFile.fullPath = pluginResult.message[i].fullPath;
- mediaFile.type = pluginResult.message[i].type;
- mediaFile.lastModifiedDate = pluginResult.message[i].lastModifiedDate;
- mediaFile.size = pluginResult.message[i].size;
- mediaFiles.push(mediaFile);
- }
- pluginResult.message = mediaFiles;
- return pluginResult;
+ var mediaFiles = [];
+ for (var i=0; i<pluginResult.message.length; i++) {
+ var mediaFile = new MediaFile();
+ mediaFile.name = pluginResult.message[i].name;
+ mediaFile.fullPath = pluginResult.message[i].fullPath;
+ mediaFile.type = pluginResult.message[i].type;
+ mediaFile.lastModifiedDate = pluginResult.message[i].lastModifiedDate;
+ mediaFile.size = pluginResult.message[i].size;
+ mediaFiles.push(mediaFile);
+ }
+ pluginResult.message = mediaFiles;
+ return pluginResult;
};
module.exports = MediaFile;
+
});
// file: lib/common/plugin/MediaFileData.js
@@ -3493,6 +3541,7 @@ module.exports = battery;
define("cordova/plugin/blackberry/Contact", function(require, exports, module) {
var ContactError = require('cordova/plugin/ContactError'),
ContactUtils = require('cordova/plugin/blackberry/ContactUtils'),
+ utils = require('cordova/utils'),
ContactAddress = require('cordova/plugin/ContactAddress'),
exec = require('cordova/exec');
@@ -3512,8 +3561,7 @@ var findByUniqueId = function(uid) {
if (!uid) {
return null;
}
- var bbContacts = blackberry.pim.Contact
- .find(new blackberry.find.FilterExpression("uid", "==", uid));
+ var bbContacts = blackberry.pim.Contact.find(new blackberry.find.FilterExpression("uid", "==", uid));
return bbContacts[0] || null;
};
@@ -3594,7 +3642,7 @@ var saveToDevice = function(contact) {
// NOTE: BlackBerry's Date.parse() does not work well, so use new Date()
//
if (contact.birthday !== null) {
- if (contact.birthday instanceof Date) {
+ if (utils.isDate(contact.birthday)) {
bbContact.birthday = contact.birthday;
} else {
var bday = contact.birthday.toString();
@@ -3603,7 +3651,7 @@ var saveToDevice = function(contact) {
}
// BlackBerry supports three email addresses
- if (contact.emails && contact.emails instanceof Array) {
+ if (contact.emails && utils.isArray(contact.emails)) {
// if this is an update, re-initialize email addresses
if (update) {
@@ -3631,7 +3679,7 @@ var saveToDevice = function(contact) {
// BlackBerry supports a finite number of phone numbers
// copy into appropriate fields based on type
- if (contact.phoneNumbers && contact.phoneNumbers instanceof Array) {
+ if (contact.phoneNumbers && utils.isArray(contact.phoneNumbers)) {
// if this is an update, re-initialize phone numbers
if (update) {
@@ -3679,7 +3727,7 @@ var saveToDevice = function(contact) {
// BlackBerry supports two addresses: home and work
// copy the first two addresses found from Contact
- if (contact.addresses && contact.addresses instanceof Array) {
+ if (contact.addresses && utils.isArray(contact.addresses)) {
// if this is an update, re-initialize addresses
if (update) {
@@ -3692,7 +3740,7 @@ var saveToDevice = function(contact) {
var bbWorkAddress = null;
for ( var k = 0; k < contact.addresses.length; k += 1) {
address = contact.addresses[k];
- if (!address || address instanceof ContactAddress === false) {
+ if (!address || address.id === undefined || address.pref === undefined || address.type === undefined || address.formatted === undefined) {
continue;
}
@@ -3707,7 +3755,7 @@ var saveToDevice = function(contact) {
}
// copy first url found to BlackBerry 'webpage' field
- if (contact.urls && contact.urls instanceof Array) {
+ if (contact.urls && utils.isArray(contact.urls)) {
// if this is an update, re-initialize web page
if (update) {
@@ -3729,7 +3777,7 @@ var saveToDevice = function(contact) {
// copy fields from first organization to the
// BlackBerry 'company' and 'jobTitle' fields
- if (contact.organizations && contact.organizations instanceof Array) {
+ if (contact.organizations && utils.isArray(contact.organizations)) {
// if this is an update, re-initialize org attributes
if (update) {
@@ -3751,7 +3799,7 @@ var saveToDevice = function(contact) {
}
// categories
- if (contact.categories && contact.categories instanceof Array) {
+ if (contact.categories && utils.isArray(contact.categories)) {
bbContact.categories = [];
var category = null;
for ( var o = 0; o < contact.categories.length; o += 1) {
@@ -3767,7 +3815,7 @@ var saveToDevice = function(contact) {
// invoke native side to save photo
// fail gracefully if photo URL is no good, but log the error
- if (contact.photos && contact.photos instanceof Array) {
+ if (contact.photos && utils.isArray(contact.photos)) {
var photo = null;
for ( var p = 0; p < contact.photos.length; p += 1) {
photo = contact.photos[p];
@@ -3885,6 +3933,7 @@ var ContactAddress = require('cordova/plugin/ContactAddress'),
ContactName = require('cordova/plugin/ContactName'),
ContactField = require('cordova/plugin/ContactField'),
ContactOrganization = require('cordova/plugin/ContactOrganization'),
+ utils = require('cordova/utils'),
Contact = require('cordova/plugin/Contact');
/**
@@ -4036,7 +4085,7 @@ module.exports = {
// build a filter expression using all Contact fields provided
var filterExpression = null;
- if (fields && fields instanceof Array) {
+ if (fields && utils.isArray(fields)) {
var fe = null;
for ( var f in fields) {
if (!fields[f]) {
@@ -4096,7 +4145,7 @@ module.exports = {
var contact = new Contact(bbContact.uid, bbContact.user1);
// nothing to do
- if (!fields || !(fields instanceof Array) || fields.length === 0) {
+ if (!fields || !(utils.isArray(fields)) || fields.length === 0) {
return contact;
} else if (fields.length == 1 && fields[0] === "*") {
// Cordova enhancement to allow fields value of ["*"] to indicate
@@ -4633,6 +4682,7 @@ module.exports = {
// file: lib/blackberry/plugin/blackberry/contacts.js
define("cordova/plugin/blackberry/contacts", function(require, exports, module) {
var ContactError = require('cordova/plugin/ContactError'),
+ utils = require('cordova/utils'),
ContactUtils = require('cordova/plugin/blackberry/ContactUtils');
module.exports = {
@@ -4649,8 +4699,8 @@ module.exports = {
}
// Search qualifier is required and cannot be empty.
- if (!fields || !(fields instanceof Array) || fields.length === 0) {
- if (typeof fail === 'function') {
+ if (!fields || !(utils.isArray(fields)) || fields.length === 0) {
+ if (typeof fail == 'function') {
fail(new ContactError(ContactError.INVALID_ARGUMENT_ERROR));
}
return;
@@ -4694,6 +4744,7 @@ module.exports = {
}
};
+
});
// file: lib/blackberry/plugin/blackberry/device.js
@@ -5057,6 +5108,7 @@ module.exports = compass;
define("cordova/plugin/contacts", function(require, exports, module) {
var exec = require('cordova/exec'),
ContactError = require('cordova/plugin/ContactError'),
+ utils = require('cordova/utils'),
Contact = require('cordova/plugin/Contact');
/**
@@ -5076,7 +5128,7 @@ var contacts = {
if (!successCB) {
throw new TypeError("You must specify a success callback for the find command.");
}
- if (!fields || (fields instanceof Array && fields.length === 0)) {
+ if (!fields || (utils.isArray(fields) && fields.length === 0)) {
if (typeof errorCB === "function") {
errorCB(new ContactError(ContactError.INVALID_ARGUMENT_ERROR));
}
@@ -5112,6 +5164,7 @@ var contacts = {
};
module.exports = contacts;
+
});
// file: lib/common/plugin/geolocation.js
@@ -5460,17 +5513,23 @@ function UUIDcreatePart(length) {
}
var _self = {
+ isArray:function(a) {
+ return Object.prototype.toString.call(a) == '[object Array]';
+ },
+ isDate:function(d) {
+ return Object.prototype.toString.call(d) == '[object Date]';
+ },
/**
* Does a deep clone of the object.
*/
clone: function(obj) {
- if(!obj) {
+ if(!obj || typeof obj == 'function' || _self.isDate(obj) || typeof obj != 'object') {
return obj;
}
var retVal, i;
- if(obj instanceof Array){
+ if(_self.isArray(obj)){
retVal = [];
for(i = 0; i < obj.length; ++i){
retVal.push(_self.clone(obj[i]));
@@ -5478,18 +5537,6 @@ var _self = {
return retVal;
}
- if (obj instanceof Function) {
- return obj;
- }
-
- if(!(obj instanceof Object)){
- return obj;
- }
-
- if(obj instanceof Date){
- return obj;
- }
-
retVal = {};
for(i in obj){
if(!(i in retVal) || retVal[i] != obj[i]) {
@@ -5500,7 +5547,7 @@ var _self = {
},
close: function(context, func, params) {
- if (typeof params === 'undefined') {
+ if (typeof params == 'undefined') {
return function() {
return func.apply(context, arguments);
};
@@ -5551,6 +5598,7 @@ var _self = {
};
module.exports = _self;
+
});
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/f9e84584/javascript/cordova.playbook.js
----------------------------------------------------------------------
diff --git a/javascript/cordova.playbook.js b/javascript/cordova.playbook.js
index 0a180bb..a7cbc87 100644
--- a/javascript/cordova.playbook.js
+++ b/javascript/cordova.playbook.js
@@ -1,6 +1,6 @@
-// commit a42f0ae6245e7609c9bad1eb582777a696201aad
+// commit 9cfdc134f83b5d51f655e52ec7d4ddab167437c7
-// File generated at :: Tue Apr 24 2012 15:08:45 GMT-0700 (PDT)
+// File generated at :: Tue May 01 2012 14:06:43 GMT-0700 (PDT)
/*
Licensed to the Apache Software Foundation (ASF) under one
@@ -101,27 +101,27 @@ document.addEventListener = function(evt, handler, capture) {
if (e == 'deviceready') {
channel.onDeviceReady.subscribeOnce(handler);
} else if (e == 'resume') {
- channel.onResume.subscribe(handler);
- // if subscribing listener after event has already fired, invoke the handler
- if (channel.onResume.fired && handler instanceof Function) {
- handler();
- }
+ channel.onResume.subscribe(handler);
+ // if subscribing listener after event has already fired, invoke the handler
+ if (channel.onResume.fired && typeof handler == 'function') {
+ handler();
+ }
} else if (e == 'pause') {
- channel.onPause.subscribe(handler);
+ channel.onPause.subscribe(handler);
} else if (typeof documentEventHandlers[e] != 'undefined') {
- documentEventHandlers[e].subscribe(handler);
+ documentEventHandlers[e].subscribe(handler);
} else {
- m_document_addEventListener.call(document, evt, handler, capture);
+ m_document_addEventListener.call(document, evt, handler, capture);
}
};
window.addEventListener = function(evt, handler, capture) {
- var e = evt.toLowerCase();
- if (typeof windowEventHandlers[e] != 'undefined') {
- windowEventHandlers[e].subscribe(handler);
- } else {
- m_window_addEventListener.call(window, evt, handler, capture);
- }
+ var e = evt.toLowerCase();
+ if (typeof windowEventHandlers[e] != 'undefined') {
+ windowEventHandlers[e].subscribe(handler);
+ } else {
+ m_window_addEventListener.call(window, evt, handler, capture);
+ }
};
document.removeEventListener = function(evt, handler, capture) {
@@ -140,30 +140,29 @@ document.removeEventListener = function(evt, handler, capture) {
};
window.removeEventListener = function(evt, handler, capture) {
- var e = evt.toLowerCase();
- // If unsubcribing from an event that is handled by a plugin
- if (typeof windowEventHandlers[e] != "undefined") {
- windowEventHandlers[e].unsubscribe(handler);
- } else {
- m_window_removeEventListener.call(window, evt, handler, capture);
- }
+ var e = evt.toLowerCase();
+ // If unsubcribing from an event that is handled by a plugin
+ if (typeof windowEventHandlers[e] != "undefined") {
+ windowEventHandlers[e].unsubscribe(handler);
+ } else {
+ m_window_removeEventListener.call(window, evt, handler, capture);
+ }
};
function createEvent(type, data) {
- var event = document.createEvent('Events');
- event.initEvent(type, false, false);
- if (data) {
- for (var i in data) {
- if (data.hasOwnProperty(i)) {
- event[i] = data[i];
- }
+ var event = document.createEvent('Events');
+ event.initEvent(type, false, false);
+ if (data) {
+ for (var i in data) {
+ if (data.hasOwnProperty(i)) {
+ event[i] = data[i];
+ }
+ }
}
- }
- return event;
+ return event;
}
-if(typeof window.console === "undefined")
-{
+if(typeof window.console === "undefined") {
window.console = {
log:function(){}
};
@@ -176,16 +175,16 @@ var cordova = {
* Methods to add/remove your own addEventListener hijacking on document + window.
*/
addWindowEventHandler:function(event, opts) {
- return (windowEventHandlers[event] = channel.create(event, opts));
+ return (windowEventHandlers[event] = channel.create(event, opts));
},
addDocumentEventHandler:function(event, opts) {
- return (documentEventHandlers[event] = channel.create(event, opts));
+ return (documentEventHandlers[event] = channel.create(event, opts));
},
removeWindowEventHandler:function(event) {
- delete windowEventHandlers[event];
+ delete windowEventHandlers[event];
},
removeDocumentEventHandler:function(event) {
- delete documentEventHandlers[event];
+ delete documentEventHandlers[event];
},
/**
* Retreive original event handlers that were replaced by Cordova
@@ -200,20 +199,20 @@ var cordova = {
* Method to fire event from native code
*/
fireDocumentEvent: function(type, data) {
- var evt = createEvent(type, data);
- if (typeof documentEventHandlers[type] != 'undefined') {
- documentEventHandlers[type].fire(evt);
- } else {
- document.dispatchEvent(evt);
- }
+ var evt = createEvent(type, data);
+ if (typeof documentEventHandlers[type] != 'undefined') {
+ documentEventHandlers[type].fire(evt);
+ } else {
+ document.dispatchEvent(evt);
+ }
},
fireWindowEvent: function(type, data) {
- var evt = createEvent(type,data);
- if (typeof windowEventHandlers[type] != 'undefined') {
- windowEventHandlers[type].fire(evt);
- } else {
- window.dispatchEvent(evt);
- }
+ var evt = createEvent(type,data);
+ if (typeof windowEventHandlers[type] != 'undefined') {
+ windowEventHandlers[type].fire(evt);
+ } else {
+ window.dispatchEvent(evt);
+ }
},
// TODO: this is Android only; think about how to do this better
shuttingDown:false,
@@ -319,15 +318,41 @@ var cordova = {
}
};
+// Adds deprecation warnings to functions of an object (but only logs a message once)
+function deprecateFunctions(obj, objLabel) {
+ var newObj = {};
+ var logHash = {};
+ for (var i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ if (typeof obj[i] == 'function') {
+ newObj[i] = (function(prop){
+ var oldFunk = obj[prop];
+ var funkId = objLabel + '_' + prop;
+ return function() {
+ if (!logHash[funkId]) {
+ console.log('[DEPRECATION NOTICE] The "' + objLabel + '" global will be removed in version 2.0, please use lowercase "cordova".');
+ logHash[funkId] = true;
+ }
+ oldFunk.apply(obj, arguments);
+ };
+ })(i);
+ } else {
+ newObj[i] = (function(prop) { return obj[prop]; })(i);
+ }
+ }
+ }
+ return newObj;
+}
+
/**
* Legacy variable for plugin support
* TODO: remove in 2.0.
*/
if (!window.PhoneGap) {
- window.PhoneGap = cordova;
+ window.PhoneGap = deprecateFunctions(cordova, 'PhoneGap');
}
if (!window.Cordova) {
- window.Cordova = cordova;
+ window.Cordova = deprecateFunctions(cordova, 'Cordova');
}
/**
@@ -437,6 +462,8 @@ module.exports = {
// file: lib/common/channel.js
define("cordova/channel", function(require, exports, module) {
+var utils = require('cordova/utils');
+
/**
* Custom pub-sub "channel" that can have functions subscribed to it
* This object is used to define and control firing of events for
@@ -484,21 +511,21 @@ define("cordova/channel", function(require, exports, module) {
* context to the Channel.
*/
var Channel = function(type, opts) {
- this.type = type;
- this.handlers = {};
- this.numHandlers = 0;
- this.guid = 0;
- this.fired = false;
- this.enabled = true;
- this.events = {
- onSubscribe:null,
- onUnsubscribe:null
- };
- if (opts) {
- if (opts.onSubscribe) this.events.onSubscribe = opts.onSubscribe;
- if (opts.onUnsubscribe) this.events.onUnsubscribe = opts.onUnsubscribe;
- }
- },
+ this.type = type;
+ this.handlers = {};
+ this.numHandlers = 0;
+ this.guid = 0;
+ this.fired = false;
+ this.enabled = true;
+ this.events = {
+ onSubscribe:null,
+ onUnsubscribe:null
+ };
+ if (opts) {
+ if (opts.onSubscribe) this.events.onSubscribe = opts.onSubscribe;
+ if (opts.onUnsubscribe) this.events.onUnsubscribe = opts.onUnsubscribe;
+ }
+},
channel = {
/**
* Calls the provided function only after all of the channels specified
@@ -558,8 +585,11 @@ var Channel = function(type, opts) {
c.fire();
}
}
- },
- utils = require('cordova/utils');
+ };
+
+function forceFunction(f) {
+ if (f === null || f === undefined || typeof f != 'function') throw "Function required as first argument!";
+}
/**
* Subscribes the given function to the channel. Any time that
@@ -570,10 +600,10 @@ var Channel = function(type, opts) {
*/
Channel.prototype.subscribe = function(f, c, g) {
// need a function to call
- if (f === null || f === undefined) { return; }
+ forceFunction(f);
var func = f;
- if (typeof c == "object" && f instanceof Function) { func = utils.close(c, f); }
+ if (typeof c == "object") { func = utils.close(c, f); }
g = g || func.observer_guid || f.observer_guid || this.guid++;
func.observer_guid = g;
@@ -590,7 +620,7 @@ Channel.prototype.subscribe = function(f, c, g) {
*/
Channel.prototype.subscribeOnce = function(f, c) {
// need a function to call
- if (f === null || f === undefined) { return; }
+ forceFunction(f);
var g = null;
var _this = this;
@@ -599,7 +629,7 @@ Channel.prototype.subscribeOnce = function(f, c) {
_this.unsubscribe(g);
};
if (this.fired) {
- if (typeof c == "object" && f instanceof Function) { f = utils.close(c, f); }
+ if (typeof c == "object") { f = utils.close(c, f); }
f.apply(this, this.fireArgs);
} else {
g = this.subscribe(m);
@@ -612,9 +642,9 @@ Channel.prototype.subscribeOnce = function(f, c) {
*/
Channel.prototype.unsubscribe = function(g) {
// need a function to unsubscribe
- if (g === null || g === undefined) { return; }
+ if (g === null || g === undefined) { throw "You must pass _something_ into Channel.unsubscribe"; }
- if (g instanceof Function) { g = g.observer_guid; }
+ if (typeof g == 'function') { g = g.observer_guid; }
this.handlers[g] = null;
delete this.handlers[g];
this.numHandlers--;
@@ -630,7 +660,7 @@ Channel.prototype.fire = function(e) {
this.fired = true;
for (var item in this.handlers) {
var handler = this.handlers[item];
- if (handler instanceof Function) {
+ if (typeof handler == 'function') {
var rv = (handler.apply(this, arguments)===false);
fail = fail || rv;
}
@@ -676,6 +706,7 @@ channel.waitForInitialization('onCordovaInfoReady');
channel.waitForInitialization('onCordovaConnectionReady');
module.exports = channel;
+
});
// file: lib/common/common.js
@@ -690,6 +721,20 @@ module.exports = {
}
}
},
+ Cordova: {
+ children: {
+ exec: {
+ path: 'cordova/exec'
+ }
+ }
+ },
+ PhoneGap:{
+ children: {
+ exec: {
+ path: 'cordova/exec'
+ }
+ }
+ },
navigator: {
children: {
notification: {
@@ -860,6 +905,7 @@ module.exports = {
}
}
};
+
});
// file: lib/playbook/exec.js
@@ -1256,14 +1302,14 @@ function convertOut(contact) {
var value = contact.birthday;
if (value !== null) {
// try to make it a Date object if it is not already
- if (!value instanceof Date){
+ if (!utils.isDate(value)){
try {
value = new Date(value);
} catch(exception){
value = null;
}
}
- if (value instanceof Date){
+ if (utils.isDate(value)){
value = value.valueOf(); // convert to milliseconds
}
contact.birthday = value;
@@ -1406,6 +1452,7 @@ Contact.prototype.save = function(successCB, errorCB) {
module.exports = Contact;
+
});
// file: lib/common/plugin/ContactAddress.js
@@ -1474,8 +1521,8 @@ define("cordova/plugin/ContactField", function(require, exports, module) {
*/
var ContactField = function(type, value, pref) {
this.id = null;
- this.type = type || null;
- this.value = value || null;
+ this.type = (type && type.toString()) || null;
+ this.value = (value && value.toString()) || null;
this.pref = (typeof pref != 'undefined' ? pref : false);
};
@@ -2360,7 +2407,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
fileKey = options.fileKey;
fileName = options.fileName;
mimeType = options.mimeType;
- if (options.chunkedMode !== null || typeof options.chunkedMode !== "undefined") {
+ if (options.chunkedMode !== null || typeof options.chunkedMode != "undefined") {
chunkedMode = options.chunkedMode;
}
if (options.params) {
@@ -2976,7 +3023,7 @@ var utils = require('cordova/utils'),
* size {Number} size of the file in bytes
*/
var MediaFile = function(name, fullPath, type, lastModifiedDate, size){
- MediaFile.__super__.constructor.apply(this, arguments);
+ MediaFile.__super__.constructor.apply(this, arguments);
};
utils.extend(MediaFile, File);
@@ -2991,10 +3038,11 @@ MediaFile.prototype.getFormatData = function(successCallback, errorCallback) {
if (typeof this.fullPath === "undefined" || this.fullPath === null) {
errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
} else {
- exec(successCallback, errorCallback, "Capture", "getFormatData", [this.fullPath, this.type]);
+ exec(successCallback, errorCallback, "Capture", "getFormatData", [this.fullPath, this.type]);
}
};
+// TODO: can we axe this?
/**
* Casts a PluginResult message property (array of objects) to an array of MediaFile objects
* (used in Objective-C and Android)
@@ -3002,22 +3050,22 @@ MediaFile.prototype.getFormatData = function(successCallback, errorCallback) {
* @param {PluginResult} pluginResult
*/
MediaFile.cast = function(pluginResult) {
- var mediaFiles = [];
- var i;
- for (i=0; i<pluginResult.message.length; i++) {
- var mediaFile = new MediaFile();
- mediaFile.name = pluginResult.message[i].name;
- mediaFile.fullPath = pluginResult.message[i].fullPath;
- mediaFile.type = pluginResult.message[i].type;
- mediaFile.lastModifiedDate = pluginResult.message[i].lastModifiedDate;
- mediaFile.size = pluginResult.message[i].size;
- mediaFiles.push(mediaFile);
- }
- pluginResult.message = mediaFiles;
- return pluginResult;
+ var mediaFiles = [];
+ for (var i=0; i<pluginResult.message.length; i++) {
+ var mediaFile = new MediaFile();
+ mediaFile.name = pluginResult.message[i].name;
+ mediaFile.fullPath = pluginResult.message[i].fullPath;
+ mediaFile.type = pluginResult.message[i].type;
+ mediaFile.lastModifiedDate = pluginResult.message[i].lastModifiedDate;
+ mediaFile.size = pluginResult.message[i].size;
+ mediaFiles.push(mediaFile);
+ }
+ pluginResult.message = mediaFiles;
+ return pluginResult;
};
module.exports = MediaFile;
+
});
// file: lib/common/plugin/MediaFileData.js
@@ -3515,6 +3563,7 @@ module.exports = compass;
define("cordova/plugin/contacts", function(require, exports, module) {
var exec = require('cordova/exec'),
ContactError = require('cordova/plugin/ContactError'),
+ utils = require('cordova/utils'),
Contact = require('cordova/plugin/Contact');
/**
@@ -3534,7 +3583,7 @@ var contacts = {
if (!successCB) {
throw new TypeError("You must specify a success callback for the find command.");
}
- if (!fields || (fields instanceof Array && fields.length === 0)) {
+ if (!fields || (utils.isArray(fields) && fields.length === 0)) {
if (typeof errorCB === "function") {
errorCB(new ContactError(ContactError.INVALID_ARGUMENT_ERROR));
}
@@ -3570,6 +3619,7 @@ var contacts = {
};
module.exports = contacts;
+
});
// file: lib/common/plugin/geolocation.js
@@ -3891,7 +3941,7 @@ var webworks = require('cordova/plugin/webworks/manager'),
"name" : blackberry.system.model,
"uuid" : blackberry.identity.PIN,
"platform" : "PlayBook",
- "cordova" : "1.7.0rc1"
+ "cordova" : "1.7.0"
}
};
}
@@ -4274,17 +4324,23 @@ function UUIDcreatePart(length) {
}
var _self = {
+ isArray:function(a) {
+ return Object.prototype.toString.call(a) == '[object Array]';
+ },
+ isDate:function(d) {
+ return Object.prototype.toString.call(d) == '[object Date]';
+ },
/**
* Does a deep clone of the object.
*/
clone: function(obj) {
- if(!obj) {
+ if(!obj || typeof obj == 'function' || _self.isDate(obj) || typeof obj != 'object') {
return obj;
}
var retVal, i;
- if(obj instanceof Array){
+ if(_self.isArray(obj)){
retVal = [];
for(i = 0; i < obj.length; ++i){
retVal.push(_self.clone(obj[i]));
@@ -4292,18 +4348,6 @@ var _self = {
return retVal;
}
- if (obj instanceof Function) {
- return obj;
- }
-
- if(!(obj instanceof Object)){
- return obj;
- }
-
- if(obj instanceof Date){
- return obj;
- }
-
retVal = {};
for(i in obj){
if(!(i in retVal) || retVal[i] != obj[i]) {
@@ -4314,7 +4358,7 @@ var _self = {
},
close: function(context, func, params) {
- if (typeof params === 'undefined') {
+ if (typeof params == 'undefined') {
return function() {
return func.apply(context, arguments);
};
@@ -4365,6 +4409,7 @@ var _self = {
};
module.exports = _self;
+
});