Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 040CEF614 for ; Fri, 19 Apr 2013 22:11:54 +0000 (UTC) Received: (qmail 21609 invoked by uid 500); 19 Apr 2013 22:11:53 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 21582 invoked by uid 500); 19 Apr 2013 22:11:53 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 21575 invoked by uid 99); 19 Apr 2013 22:11:53 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Apr 2013 22:11:53 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 96B8081B1D7; Fri, 19 Apr 2013 22:11:53 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: timkim@apache.org To: commits@cordova.apache.org Date: Fri, 19 Apr 2013 22:11:53 -0000 Message-Id: <548a44aa5948432492db80c538e5d4fd@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] webworks commit: [CB-3078] - updated javascript Updated Branches: refs/heads/master cdb5ad136 -> 493deb905 [CB-3078] - updated javascript Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/1c63bd5e Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/1c63bd5e Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/1c63bd5e Branch: refs/heads/master Commit: 1c63bd5e901b7d340d3271918ec465496ad46c01 Parents: cdb5ad1 Author: Tim Kim Authored: Fri Apr 19 15:05:14 2013 -0700 Committer: Tim Kim Committed: Fri Apr 19 15:05:14 2013 -0700 ---------------------------------------------------------------------- javascript/cordova.blackberry.js | 327 +++++++++++++++++++-------------- 1 files changed, 190 insertions(+), 137 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/1c63bd5e/javascript/cordova.blackberry.js ---------------------------------------------------------------------- diff --git a/javascript/cordova.blackberry.js b/javascript/cordova.blackberry.js index 6df67ea..cd5878b 100644 --- a/javascript/cordova.blackberry.js +++ b/javascript/cordova.blackberry.js @@ -1,8 +1,8 @@ // Platform: blackberry -// commit 104709b2130a29e7ad8596d1a6cee1ed48138803 +// commit 4808bdada2a73c3fb2ec69857b8e970414c31d57 -// File generated at :: Wed Mar 27 2013 13:50:52 GMT-0700 (PDT) +// File generated at :: Fri Apr 19 2013 14:51:35 GMT-0700 (PDT) /* Licensed to the Apache Software Foundation (ASF) under one @@ -219,6 +219,10 @@ var cordova = { } else { setTimeout(function() { + // Fire deviceready on listeners that were registered before cordova.js was loaded. + if (type == 'deviceready') { + document.dispatchEvent(evt); + } documentEventHandlers[type].fire(evt); }, 0); } @@ -742,6 +746,7 @@ channel.createSticky('onDestroy'); // Channels that must fire before "deviceready" is fired. channel.waitForInitialization('onCordovaReady'); channel.waitForInitialization('onCordovaConnectionReady'); +channel.waitForInitialization('onDOMContentLoaded'); module.exports = channel; @@ -2222,7 +2227,7 @@ function initRead(reader, file) { if (typeof file == 'string') { // Deprecated in Cordova 2.4. - console.warning('Using a string argument with FileReader.readAs functions is deprecated.'); + console.warn('Using a string argument with FileReader.readAs functions is deprecated.'); reader._fileName = file; } else if (typeof file.fullPath == 'string') { reader._fileName = file.fullPath; @@ -2580,7 +2585,7 @@ function getBasicAuthHeader(urlString) { var origin = protocol + url.host; // check whether there are the username:password credentials in the url - if (url.href.indexOf(origin) != 0) { // credentials found + if (url.href.indexOf(origin) !== 0) { // credentials found var atIndex = url.href.indexOf("@"); credentials = url.href.substring(protocol.length, atIndex); } @@ -2629,15 +2634,11 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro var params = null; var chunkedMode = true; var headers = null; - + var httpMethod = null; var basicAuthHeader = getBasicAuthHeader(server); if (basicAuthHeader) { - if (!options) { - options = new FileUploadOptions(); - } - if (!options.headers) { - options.headers = {}; - } + options = options || {}; + options.headers = options.headers || {}; options.headers[basicAuthHeader.name] = basicAuthHeader.value; } @@ -2646,6 +2647,12 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro fileName = options.fileName; mimeType = options.mimeType; headers = options.headers; + httpMethod = options.httpMethod || "POST"; + if (httpMethod.toUpperCase() == "PUT"){ + httpMethod = "PUT"; + } else { + httpMethod = "POST"; + } if (options.chunkedMode !== null || typeof options.chunkedMode != "undefined") { chunkedMode = options.chunkedMode; } @@ -2672,7 +2679,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro successCallback && successCallback(result); } }; - exec(win, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers, this._id]); + exec(win, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers, this._id, httpMethod]); }; /** @@ -2690,12 +2697,8 @@ FileTransfer.prototype.download = function(source, target, successCallback, erro var basicAuthHeader = getBasicAuthHeader(source); if (basicAuthHeader) { - if (!options) { - options = {}; - } - if (!options.headers) { - options.headers = {}; - } + options = options || {}; + options.headers = options.headers || {}; options.headers[basicAuthHeader.name] = basicAuthHeader.value; } @@ -2734,12 +2737,11 @@ FileTransfer.prototype.download = function(source, target, successCallback, erro }; /** - * Aborts the ongoing file transfer on this object - * @param successCallback {Function} Callback to be invoked upon success - * @param errorCallback {Function} Callback to be invoked upon error + * Aborts the ongoing file transfer on this object. The original error + * callback for the file transfer will be called if necessary. */ -FileTransfer.prototype.abort = function(successCallback, errorCallback) { - exec(successCallback, errorCallback, 'FileTransfer', 'abort', [this._id]); +FileTransfer.prototype.abort = function() { + exec(null, null, 'FileTransfer', 'abort', [this._id]); }; module.exports = FileTransfer; @@ -2783,12 +2785,13 @@ define("cordova/plugin/FileUploadOptions", function(require, exports, module) { * @param headers {Object} Keys are header names, values are header values. Multiple * headers of the same name are not supported. */ -var FileUploadOptions = function(fileKey, fileName, mimeType, params, headers) { +var FileUploadOptions = function(fileKey, fileName, mimeType, params, headers, httpMethod) { this.fileKey = fileKey || null; this.fileName = fileName || null; this.mimeType = mimeType || null; this.params = params || null; this.headers = headers || null; + this.httpMethod = httpMethod || null; }; module.exports = FileUploadOptions; @@ -3123,6 +3126,7 @@ define("cordova/plugin/InAppBrowser", function(require, exports, module) { var exec = require('cordova/exec'); var channel = require('cordova/channel'); +var modulemapper = require('cordova/modulemapper'); function InAppBrowser() { this.channels = { @@ -3151,6 +3155,26 @@ InAppBrowser.prototype = { if (eventname in this.channels) { this.channels[eventname].unsubscribe(f); } + }, + + executeScript: function(injectDetails, cb) { + if (injectDetails.code) { + exec(cb, null, "InAppBrowser", "injectScriptCode", [injectDetails.code, !!cb]); + } else if (injectDetails.file) { + exec(cb, null, "InAppBrowser", "injectScriptFile", [injectDetails.file, !!cb]); + } else { + throw new Error('executeScript requires exactly one of code or file to be specified'); + } + }, + + insertCSS: function(injectDetails, cb) { + if (injectDetails.code) { + exec(cb, null, "InAppBrowser", "injectStyleCode", [injectDetails.code, !!cb]); + } else if (injectDetails.file) { + exec(cb, null, "InAppBrowser", "injectStyleFile", [injectDetails.file, !!cb]); + } else { + throw new Error('insertCSS requires exactly one of code or file to be specified'); + } } }; @@ -3159,6 +3183,13 @@ module.exports = function(strUrl, strWindowName, strWindowFeatures) { var cb = function(eventname) { iab._eventHandler(eventname); }; + + // Don't catch calls that write to existing frames (e.g. named iframes). + if (window.frames && window.frames[strWindowName]) { + var origOpenFunc = modulemapper.getOriginalSymbol(window, 'open'); + return origOpenFunc.apply(window, arguments); + } + exec(cb, cb, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]); return iab; }; @@ -5361,7 +5392,7 @@ module.exports = { model: "PlayBook", name: "PlayBook", // deprecated: please use device.model uuid: info.uuid, - cordova: "2.6.0rc1" + cordova: "2.7.0rc1" }); }), request = new blackberry.transport.RemoteFunctionCall("org/apache/cordova/getDeviceInfo"); @@ -6018,7 +6049,7 @@ console.debug = function() { console.assert = function(expression) { if (expression) return; - var message = utils.vformat(arguments[1], [].slice.call(arguments, 2)); + var message = logger.format.apply(logger.format, [].slice.call(arguments, 1)); console.log("ASSERT: " + message); }; @@ -8669,10 +8700,10 @@ function logWithArgs(level, args) { * Parameters passed after message are used applied to * the message with utils.format() */ -logger.logLevel = function(level, message /* , ... */) { +logger.logLevel = function(level /* , ... */) { // format the message with the parameters - var formatArgs = [].slice.call(arguments, 2); - message = utils.vformat(message, formatArgs); + var formatArgs = [].slice.call(arguments, 1); + var message = logger.format.apply(logger.format, formatArgs); if (LevelsMap[level] === null) { throw new Error("invalid logging level: " + level); @@ -8707,6 +8738,92 @@ logger.logLevel = function(level, message /* , ... */) { } }; + +/** + * Formats a string and arguments following it ala console.log() + * + * Any remaining arguments will be appended to the formatted string. + * + * for rationale, see FireBug's Console API: + * http://getfirebug.com/wiki/index.php/Console_API + */ +logger.format = function(formatString, args) { + return __format(arguments[0], [].slice.call(arguments,1)).join(' '); +}; + + +//------------------------------------------------------------------------------ +/** + * Formats a string and arguments following it ala vsprintf() + * + * format chars: + * %j - format arg as JSON + * %o - format arg as JSON + * %c - format arg as '' + * %% - replace with '%' + * any other char following % will format it's + * arg via toString(). + * + * Returns an array containing the formatted string and any remaining + * arguments. + */ +function __format(formatString, args) { + if (formatString === null || formatString === undefined) return [""]; + if (arguments.length == 1) return [formatString.toString()]; + + if (typeof formatString != "string") + formatString = formatString.toString(); + + var pattern = /(.*?)%(.)(.*)/; + var rest = formatString; + var result = []; + + while (args.length) { + var match = pattern.exec(rest); + if (!match) break; + + var arg = args.shift(); + rest = match[3]; + result.push(match[1]); + + if (match[2] == '%') { + result.push('%'); + args.unshift(arg); + continue; + } + + result.push(__formatted(arg, match[2])); + } + + result.push(rest); + + var remainingArgs = [].slice.call(args); + remainingArgs.unshift(result.join('')); + return remainingArgs; +} + +function __formatted(object, formatChar) { + + try { + switch(formatChar) { + case 'j': + case 'o': return JSON.stringify(object); + case 'c': return ''; + } + } + catch (e) { + return "error JSON.stringify()ing argument: " + e; + } + + if ((object === null) || (object === undefined)) { + return Object.prototype.toString.call(object); + } + + return object.toString(); +} + + +//------------------------------------------------------------------------------ // when deviceready fires, log queued messages logger.__onDeviceReady = function() { if (DeviceReady) return; @@ -8875,13 +8992,13 @@ module.exports = { console.log("Notification.confirm(string, function, string, string) is deprecated. Use Notification.confirm(string, function, string, array)."); } - // Android and iOS take an array of button label names. + // Some platforms take an array of button label names. // Other platforms take a comma separated list. // For compatibility, we convert to the desired type based on the platform. - if (platform.id == "android" || platform.id == "ios") { + if (platform.id == "android" || platform.id == "ios" || platform.id == "windowsphone") { if (typeof _buttonLabels === 'string') { var buttonLabelString = _buttonLabels; - _buttonLabels = buttonLabelString.split(","); + _buttonLabels = _buttonLabels.split(","); // not crazy about changing the var type here } } else { if (Array.isArray(_buttonLabels)) { @@ -9290,7 +9407,7 @@ module.exports = { model: "Dev Alpha", name: "Dev Alpha", // deprecated: please use device.model uuid: blackberry.identity.uuid, - cordova: "2.6.0rc1" + cordova: "2.7.0rc1" }); return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "Device info returned" }; @@ -9303,6 +9420,7 @@ module.exports = { define("cordova/plugin/qnx/file", function(require, exports, module) { /*global WebKitBlobBuilder:false */ +/*global Blob:false */ var cordova = require('cordova'), FileError = require('cordova/plugin/FileError'), DirectoryEntry = require('cordova/plugin/DirectoryEntry'), @@ -9710,6 +9828,7 @@ module.exports = { // file: lib/blackberry/plugin/qnx/fileTransfer.js define("cordova/plugin/qnx/fileTransfer", function(require, exports, module) { +/*global Blob:false */ var cordova = require('cordova'), FileEntry = require('cordova/plugin/FileEntry'), FileTransferError = require('cordova/plugin/FileTransferError'), @@ -10566,62 +10685,6 @@ utils.alert = function(msg) { } }; -/** - * Formats a string and arguments following it ala sprintf() - * - * see utils.vformat() for more information - */ -utils.format = function(formatString /* ,... */) { - var args = [].slice.call(arguments, 1); - return utils.vformat(formatString, args); -}; - -/** - * Formats a string and arguments following it ala vsprintf() - * - * format chars: - * %j - format arg as JSON - * %o - format arg as JSON - * %c - format arg as '' - * %% - replace with '%' - * any other char following % will format it's - * arg via toString(). - * - * for rationale, see FireBug's Console API: - * http://getfirebug.com/wiki/index.php/Console_API - */ -utils.vformat = function(formatString, args) { - if (formatString === null || formatString === undefined) return ""; - if (arguments.length == 1) return formatString.toString(); - if (typeof formatString != "string") return formatString.toString(); - - var pattern = /(.*?)%(.)(.*)/; - var rest = formatString; - var result = []; - - while (args.length) { - var arg = args.shift(); - var match = pattern.exec(rest); - - if (!match) break; - - rest = match[3]; - - result.push(match[1]); - - if (match[2] == '%') { - result.push('%'); - args.unshift(arg); - continue; - } - - result.push(formatted(arg, match[2])); - } - - result.push(rest); - - return result.join(''); -}; //------------------------------------------------------------------------------ function UUIDcreatePart(length) { @@ -10636,26 +10699,6 @@ function UUIDcreatePart(length) { return uuidpart; } -//------------------------------------------------------------------------------ -function formatted(object, formatChar) { - - try { - switch(formatChar) { - case 'j': - case 'o': return JSON.stringify(object); - case 'c': return ''; - } - } - catch (e) { - return "error JSON.stringify()ing argument: " + e; - } - - if ((object === null) || (object === undefined)) { - return Object.prototype.toString.call(object); - } - - return object.toString(); -} }); @@ -10665,6 +10708,25 @@ window.cordova = require('cordova'); // file: lib/scripts/bootstrap.js (function (context) { + var channel = require('cordova/channel'); + var platformInitChannelsArray = [channel.onNativeReady, channel.onPluginsReady]; + + function logUnfiredChannels(arr) { + for (var i = 0; i < arr.length; ++i) { + if (arr[i].state != 2) { + console.log('Channel not fired: ' + arr[i].type); + } + } + } + + window.setTimeout(function() { + if (channel.onDeviceReady.state != 2) { + console.log('deviceready has not fired after 5 seconds.'); + logUnfiredChannels(platformInitChannelsArray); + logUnfiredChannels(channel.deviceReadyChannelsArray); + } + }, 5000); + // Replace navigator before any modules are required(), to ensure it happens as soon as possible. // We replace it so that properties that can't be clobbered can instead be overridden. function replaceNavigator(origNavigator) { @@ -10686,8 +10748,6 @@ window.cordova = require('cordova'); context.navigator = replaceNavigator(context.navigator); } - var channel = require("cordova/channel"); - // _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 cordova JS is ready. @@ -10696,29 +10756,26 @@ window.cordova = require('cordova'); } /** - * Create all cordova objects once page has fully loaded and native side is ready. + * Create all cordova objects once native side is ready. */ channel.join(function() { - var builder = require('cordova/builder'), - platform = require('cordova/platform'); - - builder.buildIntoButDoNotClobber(platform.defaults, context); - builder.buildIntoAndClobber(platform.clobbers, context); - builder.buildIntoAndMerge(platform.merges, context); - // Call the platform-specific initialization - platform.initialize(); + require('cordova/platform').initialize(); // Fire event to notify that all objects are created channel.onCordovaReady.fire(); - // Fire onDeviceReady event once all constructors have run and - // cordova info has been received from native side. + // Fire onDeviceReady event once page has fully loaded, all + // constructors have run and cordova info has been received from native + // side. + // This join call is deliberately made after platform.initialize() in + // order that plugins may manipulate channel.deviceReadyChannelsArray + // if necessary. channel.join(function() { require('cordova').fireDocumentEvent('deviceready'); }, channel.deviceReadyChannelsArray); - }, [ channel.onDOMContentLoaded, channel.onNativeReady, channel.onPluginsReady ]); + }, platformInitChannelsArray); }(window)); @@ -10823,31 +10880,27 @@ document.addEventListener("DOMContentLoaded", function () { } } + // Try to XHR the cordova_plugins.json file asynchronously. - try { // we commented we were going to try, so let us actually try and catch + try { // we commented we were going to try, so let us actually try and catch var xhr = new context.XMLHttpRequest(); - xhr.onreadystatechange = function() { - if (this.readyState != 4) { // not DONE - return; - } - + xhr.onload = function() { // If the response is a JSON string which composes an array, call handlePluginsObject. // If the request fails, or the response is not a JSON array, just call finishPluginLoading. - if (this.status == 200) { - var obj = JSON.parse(this.responseText); - if (obj && obj instanceof Array && obj.length > 0) { - handlePluginsObject(obj); - } else { - finishPluginLoading(); - } + var obj = JSON.parse(this.responseText); + if (obj && obj instanceof Array && obj.length > 0) { + handlePluginsObject(obj); } else { finishPluginLoading(); } }; + xhr.onerror = function() { + finishPluginLoading(); + }; xhr.open('GET', 'cordova_plugins.json', true); // Async xhr.send(); } - catch(err) { + catch(err){ finishPluginLoading(); } }(window));