mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-26 12:03:28 +08:00
Updating JS so that InAppBrowser will work out of the box
This commit is contained in:
parent
f1e8400abf
commit
9ca2a16218
@ -1,6 +1,6 @@
|
|||||||
// commit 02b91c5313ff37d74a58f71775170afd360f4a1f
|
// commit 7203d335b59902a72a374a170b1edb04438b6a47
|
||||||
|
|
||||||
// File generated at :: Wed Oct 31 2012 10:40:25 GMT-0700 (PDT)
|
// File generated at :: Wed Nov 21 2012 16:34:19 GMT-0500 (EST)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
@ -329,14 +329,24 @@ function each(objects, func, context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clobber(obj, key, value) {
|
||||||
|
obj[key] = value;
|
||||||
|
// Getters can only be overridden by getters.
|
||||||
|
if (obj[key] !== value) {
|
||||||
|
utils.defineGetter(obj, key, function() {
|
||||||
|
return value;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function assignOrWrapInDeprecateGetter(obj, key, value, message) {
|
function assignOrWrapInDeprecateGetter(obj, key, value, message) {
|
||||||
if (message) {
|
if (message) {
|
||||||
utils.defineGetter(obj, key, function() {
|
utils.defineGetter(obj, key, function() {
|
||||||
window.console && console.log(message);
|
console.log(message);
|
||||||
return value;
|
return value;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
obj[key] = value;
|
clobber(obj, key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,8 +405,11 @@ function recursiveMerge(target, src) {
|
|||||||
// If the target object is a constructor override off prototype.
|
// If the target object is a constructor override off prototype.
|
||||||
target.prototype[prop] = src[prop];
|
target.prototype[prop] = src[prop];
|
||||||
} else {
|
} else {
|
||||||
target[prop] = typeof src[prop] === 'object' ? recursiveMerge(
|
if (typeof src[prop] === 'object') {
|
||||||
target[prop], src[prop]) : src[prop];
|
target[prop] = recursiveMerge(target[prop], src[prop]);
|
||||||
|
} else {
|
||||||
|
clobber(target, prop, src[prop]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -404,18 +417,14 @@ function recursiveMerge(target, src) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
build: function (objects) {
|
buildIntoButDoNotClobber: function(objects, target) {
|
||||||
return {
|
include(target, objects, false, false);
|
||||||
intoButDoNotClobber: function (target) {
|
},
|
||||||
include(target, objects, false, false);
|
buildIntoAndClobber: function(objects, target) {
|
||||||
},
|
include(target, objects, true, false);
|
||||||
intoAndClobber: function(target) {
|
},
|
||||||
include(target, objects, true, false);
|
buildIntoAndMerge: function(objects, target) {
|
||||||
},
|
include(target, objects, true, true);
|
||||||
intoAndMerge: function(target) {
|
|
||||||
include(target, objects, true, true);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -701,7 +710,7 @@ module.exports = {
|
|||||||
define("cordova/common", function(require, exports, module) {
|
define("cordova/common", function(require, exports, module) {
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
objects: {
|
defaults: {
|
||||||
cordova: {
|
cordova: {
|
||||||
path: 'cordova',
|
path: 'cordova',
|
||||||
children: {
|
children: {
|
||||||
@ -720,6 +729,9 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
open : {
|
||||||
|
path: 'cordova/plugin/InAppBrowser'
|
||||||
|
},
|
||||||
navigator: {
|
navigator: {
|
||||||
children: {
|
children: {
|
||||||
notification: {
|
notification: {
|
||||||
@ -737,9 +749,6 @@ module.exports = {
|
|||||||
compass:{
|
compass:{
|
||||||
path: 'cordova/plugin/compass'
|
path: 'cordova/plugin/compass'
|
||||||
},
|
},
|
||||||
connection: {
|
|
||||||
path: 'cordova/plugin/network'
|
|
||||||
},
|
|
||||||
contacts: {
|
contacts: {
|
||||||
path: 'cordova/plugin/contacts'
|
path: 'cordova/plugin/contacts'
|
||||||
},
|
},
|
||||||
@ -907,6 +916,15 @@ module.exports = {
|
|||||||
resolveLocalFileSystemURI:{
|
resolveLocalFileSystemURI:{
|
||||||
path: 'cordova/plugin/resolveLocalFileSystemURI'
|
path: 'cordova/plugin/resolveLocalFileSystemURI'
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
clobbers: {
|
||||||
|
navigator: {
|
||||||
|
children: {
|
||||||
|
connection: {
|
||||||
|
path: 'cordova/plugin/network'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -961,6 +979,7 @@ var cordova = require('cordova'),
|
|||||||
|
|
||||||
function androidExec(success, fail, service, action, args) {
|
function androidExec(success, fail, service, action, args) {
|
||||||
// Set default bridge modes if they have not already been set.
|
// Set default bridge modes if they have not already been set.
|
||||||
|
// By default, we use the failsafe, since addJavascriptInterface breaks too often
|
||||||
if (jsToNativeBridgeMode === undefined) {
|
if (jsToNativeBridgeMode === undefined) {
|
||||||
androidExec.setJsToNativeBridgeMode(jsToNativeModes.JS_OBJECT);
|
androidExec.setJsToNativeBridgeMode(jsToNativeModes.JS_OBJECT);
|
||||||
}
|
}
|
||||||
@ -1199,7 +1218,7 @@ module.exports = {
|
|||||||
exec(null, null, "App", "show", []);
|
exec(null, null, "App", "show", []);
|
||||||
}, [channel.onCordovaReady]);
|
}, [channel.onCordovaReady]);
|
||||||
},
|
},
|
||||||
objects: {
|
clobbers: {
|
||||||
navigator: {
|
navigator: {
|
||||||
children: {
|
children: {
|
||||||
app:{
|
app:{
|
||||||
@ -1218,6 +1237,9 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
MediaError: { // exists natively on Android WebView on Android 4.x
|
MediaError: { // exists natively on Android WebView on Android 4.x
|
||||||
path: "cordova/plugin/MediaError"
|
path: "cordova/plugin/MediaError"
|
||||||
|
},
|
||||||
|
open : {
|
||||||
|
path: 'cordova/plugin/InAppBrowser'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
merges: {
|
merges: {
|
||||||
@ -3237,6 +3259,25 @@ module.exports = GlobalizationError;
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// file: lib/common/plugin/InAppBrowser.js
|
||||||
|
define("cordova/plugin/InAppBrowser", function(require, exports, module) {
|
||||||
|
|
||||||
|
var exec = require('cordova/exec');
|
||||||
|
|
||||||
|
var InAppBrowser = {
|
||||||
|
open : function(strUrl, strWindowName, strWindowFeatures) {
|
||||||
|
exec(null, null, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]);
|
||||||
|
return InAppBrowser;
|
||||||
|
},
|
||||||
|
close : function() {
|
||||||
|
exec(null, null, "InAppBrowser", "close", []);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = InAppBrowser.open;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
// file: lib/common/plugin/LocalFileSystem.js
|
// file: lib/common/plugin/LocalFileSystem.js
|
||||||
define("cordova/plugin/LocalFileSystem", function(require, exports, module) {
|
define("cordova/plugin/LocalFileSystem", function(require, exports, module) {
|
||||||
|
|
||||||
@ -4954,6 +4995,7 @@ function Device() {
|
|||||||
this.name = null;
|
this.name = null;
|
||||||
this.uuid = null;
|
this.uuid = null;
|
||||||
this.cordova = null;
|
this.cordova = null;
|
||||||
|
this.model = null;
|
||||||
|
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
@ -4965,6 +5007,7 @@ function Device() {
|
|||||||
me.name = info.name;
|
me.name = info.name;
|
||||||
me.uuid = info.uuid;
|
me.uuid = info.uuid;
|
||||||
me.cordova = info.cordova;
|
me.cordova = info.cordova;
|
||||||
|
me.model = info.model;
|
||||||
channel.onCordovaInfoReady.fire();
|
channel.onCordovaInfoReady.fire();
|
||||||
},function(e) {
|
},function(e) {
|
||||||
me.available = false;
|
me.available = false;
|
||||||
@ -6004,49 +6047,9 @@ if (typeof navigator != 'undefined') {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var NetworkConnection = function () {
|
function NetworkConnection() {
|
||||||
this.type = null;
|
this.type = 'unknown';
|
||||||
this._firstRun = true;
|
}
|
||||||
this._timer = null;
|
|
||||||
this.timeout = 500;
|
|
||||||
|
|
||||||
var me = this;
|
|
||||||
|
|
||||||
channel.onCordovaReady.subscribe(function() {
|
|
||||||
me.getInfo(function (info) {
|
|
||||||
me.type = info;
|
|
||||||
if (info === "none") {
|
|
||||||
// set a timer if still offline at the end of timer send the offline event
|
|
||||||
me._timer = setTimeout(function(){
|
|
||||||
cordova.fireDocumentEvent("offline");
|
|
||||||
me._timer = null;
|
|
||||||
}, me.timeout);
|
|
||||||
} else {
|
|
||||||
// If there is a current offline event pending clear it
|
|
||||||
if (me._timer !== null) {
|
|
||||||
clearTimeout(me._timer);
|
|
||||||
me._timer = null;
|
|
||||||
}
|
|
||||||
cordova.fireDocumentEvent("online");
|
|
||||||
}
|
|
||||||
|
|
||||||
// should only fire this once
|
|
||||||
if (me._firstRun) {
|
|
||||||
me._firstRun = false;
|
|
||||||
channel.onCordovaConnectionReady.fire();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
function (e) {
|
|
||||||
// If we can't get the network info we should still tell Cordova
|
|
||||||
// to fire the deviceready event.
|
|
||||||
if (me._firstRun) {
|
|
||||||
me._firstRun = false;
|
|
||||||
channel.onCordovaConnectionReady.fire();
|
|
||||||
}
|
|
||||||
console.log("Error initializing Network Connection: " + e);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get connection info
|
* Get connection info
|
||||||
@ -6054,12 +6057,48 @@ var NetworkConnection = function () {
|
|||||||
* @param {Function} successCallback The function to call when the Connection data is available
|
* @param {Function} successCallback The function to call when the Connection data is available
|
||||||
* @param {Function} errorCallback The function to call when there is an error getting the Connection data. (OPTIONAL)
|
* @param {Function} errorCallback The function to call when there is an error getting the Connection data. (OPTIONAL)
|
||||||
*/
|
*/
|
||||||
NetworkConnection.prototype.getInfo = function (successCallback, errorCallback) {
|
NetworkConnection.prototype.getInfo = function(successCallback, errorCallback) {
|
||||||
// Get info
|
|
||||||
exec(successCallback, errorCallback, "NetworkStatus", "getConnectionInfo", []);
|
exec(successCallback, errorCallback, "NetworkStatus", "getConnectionInfo", []);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = new NetworkConnection();
|
var me = new NetworkConnection();
|
||||||
|
var timerId = null;
|
||||||
|
var timeout = 500;
|
||||||
|
|
||||||
|
channel.onCordovaReady.subscribe(function() {
|
||||||
|
me.getInfo(function(info) {
|
||||||
|
me.type = info;
|
||||||
|
if (info === "none") {
|
||||||
|
// set a timer if still offline at the end of timer send the offline event
|
||||||
|
timerId = setTimeout(function(){
|
||||||
|
cordova.fireDocumentEvent("offline");
|
||||||
|
timerId = null;
|
||||||
|
}, timeout);
|
||||||
|
} else {
|
||||||
|
// If there is a current offline event pending clear it
|
||||||
|
if (timerId !== null) {
|
||||||
|
clearTimeout(timerId);
|
||||||
|
timerId = null;
|
||||||
|
}
|
||||||
|
cordova.fireDocumentEvent("online");
|
||||||
|
}
|
||||||
|
|
||||||
|
// should only fire this once
|
||||||
|
if (channel.onCordovaConnectionReady.state !== 2) {
|
||||||
|
channel.onCordovaConnectionReady.fire();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
function (e) {
|
||||||
|
// If we can't get the network info we should still tell Cordova
|
||||||
|
// to fire the deviceready event.
|
||||||
|
if (channel.onCordovaConnectionReady.state !== 2) {
|
||||||
|
channel.onCordovaConnectionReady.fire();
|
||||||
|
}
|
||||||
|
console.log("Error initializing Network Connection: " + e);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = me;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -6106,10 +6145,20 @@ module.exports = {
|
|||||||
/**
|
/**
|
||||||
* Causes the device to vibrate.
|
* Causes the device to vibrate.
|
||||||
*
|
*
|
||||||
* @param {Integer} mills The number of milliseconds to vibrate for.
|
* @param {Integer} time The number of milliseconds to vibrate for.
|
||||||
|
* OR
|
||||||
|
* @param {Integer} pattern A vibration pattern represented by a list of time entries, in milliseconds.
|
||||||
*/
|
*/
|
||||||
vibrate: function(mills) {
|
vibrate: function(time) {
|
||||||
exec(null, null, "Notification", "vibrate", [mills]);
|
var pattern = [];
|
||||||
|
if (time) {
|
||||||
|
if (typeof time === 'number') {
|
||||||
|
pattern.push(time);
|
||||||
|
} else {
|
||||||
|
pattern = time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exec(null, null, "Notification", "vibrate", [pattern]);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -6259,6 +6308,30 @@ utils.defineGetter = function(obj, key, func) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
utils.arrayIndexOf = function(a, item) {
|
||||||
|
if (a.indexOf) {
|
||||||
|
return a.indexOf(item);
|
||||||
|
}
|
||||||
|
var len = a.length;
|
||||||
|
for (var i = 0; i < len; ++i) {
|
||||||
|
if (a[i] == item) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the item was found in the array.
|
||||||
|
*/
|
||||||
|
utils.arrayRemove = function(a, item) {
|
||||||
|
var index = utils.arrayIndexOf(a, item);
|
||||||
|
if (index != -1) {
|
||||||
|
a.splice(index, 1);
|
||||||
|
}
|
||||||
|
return index != -1;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an indication of whether the argument is an array or not
|
* Returns an indication of whether the argument is an array or not
|
||||||
*/
|
*/
|
||||||
@ -6454,10 +6527,10 @@ window.cordova = require('cordova');
|
|||||||
(function (context) {
|
(function (context) {
|
||||||
// Replace navigator before any modules are required(), to ensure it happens as soon as possible.
|
// 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.
|
// We replace it so that properties that can't be clobbered can instead be overridden.
|
||||||
if (typeof navigator != 'undefined') {
|
if (context.navigator) {
|
||||||
var CordovaNavigator = function () {};
|
function CordovaNavigator() {}
|
||||||
CordovaNavigator.prototype = navigator;
|
CordovaNavigator.prototype = context.navigator;
|
||||||
navigator = new CordovaNavigator();
|
context.navigator = new CordovaNavigator();
|
||||||
}
|
}
|
||||||
|
|
||||||
var channel = require("cordova/channel"),
|
var channel = require("cordova/channel"),
|
||||||
@ -6472,17 +6545,13 @@ window.cordova = require('cordova');
|
|||||||
platform = require('cordova/platform');
|
platform = require('cordova/platform');
|
||||||
|
|
||||||
// Drop the common globals into the window object, but be nice and don't overwrite anything.
|
// Drop the common globals into the window object, but be nice and don't overwrite anything.
|
||||||
builder.build(base.objects).intoButDoNotClobber(window);
|
builder.buildIntoButDoNotClobber(base.defaults, context);
|
||||||
|
builder.buildIntoAndMerge(base.merges, context);
|
||||||
|
builder.buildIntoAndClobber(base.clobbers, context);
|
||||||
|
|
||||||
// Drop the platform-specific globals into the window object
|
builder.buildIntoButDoNotClobber(platform.defaults, context);
|
||||||
// and clobber any existing object.
|
builder.buildIntoAndMerge(platform.merges, context);
|
||||||
builder.build(platform.objects).intoAndClobber(window);
|
builder.buildIntoAndClobber(platform.clobbers, context);
|
||||||
|
|
||||||
// Merge the platform-specific overrides/enhancements into
|
|
||||||
// the window object.
|
|
||||||
if (typeof platform.merges !== 'undefined') {
|
|
||||||
builder.build(platform.merges).intoAndMerge(window);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Call the platform-specific initialization
|
// Call the platform-specific initialization
|
||||||
platform.initialize();
|
platform.initialize();
|
||||||
|
Loading…
Reference in New Issue
Block a user