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
|
||||
@ -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) {
|
||||
if (message) {
|
||||
utils.defineGetter(obj, key, function() {
|
||||
window.console && console.log(message);
|
||||
console.log(message);
|
||||
return value;
|
||||
});
|
||||
} 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.
|
||||
target.prototype[prop] = src[prop];
|
||||
} else {
|
||||
target[prop] = typeof src[prop] === 'object' ? recursiveMerge(
|
||||
target[prop], src[prop]) : src[prop];
|
||||
if (typeof src[prop] === 'object') {
|
||||
target[prop] = recursiveMerge(target[prop], src[prop]);
|
||||
} else {
|
||||
clobber(target, prop, src[prop]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -404,19 +417,15 @@ function recursiveMerge(target, src) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
build: function (objects) {
|
||||
return {
|
||||
intoButDoNotClobber: function (target) {
|
||||
buildIntoButDoNotClobber: function(objects, target) {
|
||||
include(target, objects, false, false);
|
||||
},
|
||||
intoAndClobber: function(target) {
|
||||
buildIntoAndClobber: function(objects, target) {
|
||||
include(target, objects, true, false);
|
||||
},
|
||||
intoAndMerge: function(target) {
|
||||
buildIntoAndMerge: function(objects, target) {
|
||||
include(target, objects, true, true);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
@ -701,7 +710,7 @@ module.exports = {
|
||||
define("cordova/common", function(require, exports, module) {
|
||||
|
||||
module.exports = {
|
||||
objects: {
|
||||
defaults: {
|
||||
cordova: {
|
||||
path: 'cordova',
|
||||
children: {
|
||||
@ -720,6 +729,9 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
},
|
||||
open : {
|
||||
path: 'cordova/plugin/InAppBrowser'
|
||||
},
|
||||
navigator: {
|
||||
children: {
|
||||
notification: {
|
||||
@ -737,9 +749,6 @@ module.exports = {
|
||||
compass:{
|
||||
path: 'cordova/plugin/compass'
|
||||
},
|
||||
connection: {
|
||||
path: 'cordova/plugin/network'
|
||||
},
|
||||
contacts: {
|
||||
path: 'cordova/plugin/contacts'
|
||||
},
|
||||
@ -907,6 +916,15 @@ module.exports = {
|
||||
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) {
|
||||
// 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) {
|
||||
androidExec.setJsToNativeBridgeMode(jsToNativeModes.JS_OBJECT);
|
||||
}
|
||||
@ -1199,7 +1218,7 @@ module.exports = {
|
||||
exec(null, null, "App", "show", []);
|
||||
}, [channel.onCordovaReady]);
|
||||
},
|
||||
objects: {
|
||||
clobbers: {
|
||||
navigator: {
|
||||
children: {
|
||||
app:{
|
||||
@ -1218,6 +1237,9 @@ module.exports = {
|
||||
},
|
||||
MediaError: { // exists natively on Android WebView on Android 4.x
|
||||
path: "cordova/plugin/MediaError"
|
||||
},
|
||||
open : {
|
||||
path: 'cordova/plugin/InAppBrowser'
|
||||
}
|
||||
},
|
||||
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
|
||||
define("cordova/plugin/LocalFileSystem", function(require, exports, module) {
|
||||
|
||||
@ -4954,6 +4995,7 @@ function Device() {
|
||||
this.name = null;
|
||||
this.uuid = null;
|
||||
this.cordova = null;
|
||||
this.model = null;
|
||||
|
||||
var me = this;
|
||||
|
||||
@ -4965,6 +5007,7 @@ function Device() {
|
||||
me.name = info.name;
|
||||
me.uuid = info.uuid;
|
||||
me.cordova = info.cordova;
|
||||
me.model = info.model;
|
||||
channel.onCordovaInfoReady.fire();
|
||||
},function(e) {
|
||||
me.available = false;
|
||||
@ -6004,49 +6047,9 @@ if (typeof navigator != 'undefined') {
|
||||
});
|
||||
}
|
||||
|
||||
var NetworkConnection = function () {
|
||||
this.type = null;
|
||||
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);
|
||||
});
|
||||
});
|
||||
};
|
||||
function NetworkConnection() {
|
||||
this.type = 'unknown';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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} errorCallback The function to call when there is an error getting the Connection data. (OPTIONAL)
|
||||
*/
|
||||
NetworkConnection.prototype.getInfo = function (successCallback, errorCallback) {
|
||||
// Get info
|
||||
NetworkConnection.prototype.getInfo = function(successCallback, errorCallback) {
|
||||
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.
|
||||
*
|
||||
* @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) {
|
||||
exec(null, null, "Notification", "vibrate", [mills]);
|
||||
vibrate: function(time) {
|
||||
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
|
||||
*/
|
||||
@ -6454,10 +6527,10 @@ window.cordova = require('cordova');
|
||||
(function (context) {
|
||||
// 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.
|
||||
if (typeof navigator != 'undefined') {
|
||||
var CordovaNavigator = function () {};
|
||||
CordovaNavigator.prototype = navigator;
|
||||
navigator = new CordovaNavigator();
|
||||
if (context.navigator) {
|
||||
function CordovaNavigator() {}
|
||||
CordovaNavigator.prototype = context.navigator;
|
||||
context.navigator = new CordovaNavigator();
|
||||
}
|
||||
|
||||
var channel = require("cordova/channel"),
|
||||
@ -6472,17 +6545,13 @@ window.cordova = require('cordova');
|
||||
platform = require('cordova/platform');
|
||||
|
||||
// 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
|
||||
// and clobber any existing object.
|
||||
builder.build(platform.objects).intoAndClobber(window);
|
||||
|
||||
// Merge the platform-specific overrides/enhancements into
|
||||
// the window object.
|
||||
if (typeof platform.merges !== 'undefined') {
|
||||
builder.build(platform.merges).intoAndMerge(window);
|
||||
}
|
||||
builder.buildIntoButDoNotClobber(platform.defaults, context);
|
||||
builder.buildIntoAndMerge(platform.merges, context);
|
||||
builder.buildIntoAndClobber(platform.clobbers, context);
|
||||
|
||||
// Call the platform-specific initialization
|
||||
platform.initialize();
|
||||
|
Loading…
Reference in New Issue
Block a user