Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-10323] Fixed issues with the WebViewBridge not being installed properly. #5424

Merged
merged 1 commit into from
Mar 4, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions mobileweb/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ var require = {
"native-localstorage": function (g) {
return "localStorage" in g && "setItem" in localStorage;
},
"function-bind": function () {
return !!Function.prototype.bind;
},
"js-btoa": function (g) {
return "btoa" in g;
},
Expand Down
31 changes: 0 additions & 31 deletions mobileweb/titanium/Ti.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,37 +72,6 @@ define(
}),
loadAppjs = Ti.deferStart();

if (!has("function-bind")) {
function Empty(){}

Function.prototype.bind = function bind(that) {
var target = this,
slice = Array.prototype.slice,
args = slice.call(arguments, 1),
bound = function () {
var a = args.concat(slice.call(arguments)),
result;
if (this instanceof bound) {
result = target.apply(this, a);
if (Object(result) === result) {
return result;
}
return this;
} else {
return target.apply(that, a);
}
};

if (target.prototype) {
Empty.prototype = target.prototype;
bound.prototype = new Empty();
Empty.prototype = null;
}

return bound;
};
}

if (!has("js-btoa")) {
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
fromCharCode = String.fromCharCode;
Expand Down
8 changes: 4 additions & 4 deletions mobileweb/titanium/Ti/UI/WebView.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*global define, window*/
define(['Ti/_/declare', 'Ti/_/UI/Widget', 'Ti/_/dom', 'Ti/_/event', 'Ti/_/lang', 'Ti/_/text!Ti/_/UI/WebViewBridge.js', 'Ti/App', 'Ti/API', 'Ti/UI', 'Ti/_/style'],
function(declare, Widget, dom, event, lang, bridge, App, API, UI, style) {
define(['Ti/_/declare', 'Ti/UI/View', 'Ti/_/dom', 'Ti/_/event', 'Ti/_/lang', 'Ti/_/text!Ti/_/UI/WebViewBridge.js', 'Ti/App', 'Ti/API', 'Ti/UI', 'Ti/_/style'],
function(declare, View, dom, event, lang, bridge, App, API, UI, style) {

var on = require.on;

return declare('Ti.UI.WebView', Widget, {
return declare('Ti.UI.WebView', View, {

constructor: function() {
App.addEventListener(this.widgetId + ':unload', lang.hitch(this, function() {
Expand Down Expand Up @@ -99,7 +99,7 @@ define(['Ti/_/declare', 'Ti/_/UI/Widget', 'Ti/_/dom', 'Ti/_/event', 'Ti/_/lang',
},

_setParent: function() {
Widget.prototype._setParent.apply(this, arguments);
View.prototype._setParent.apply(this, arguments);

// we are being added to a parent, need to manually fire
(this.url || this.html) && this._createIFrame();
Expand Down
3 changes: 2 additions & 1 deletion mobileweb/titanium/Ti/_/Evented.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ define(function() {
modifiers = this._modifiers && this._modifiers[name],
listeners = this.listeners && this.listeners[name],
l = modifiers && modifiers.length;

data = data || {};
mix(data, {
source: data.source || this,
Expand Down Expand Up @@ -64,7 +65,7 @@ define(function() {

_addEventModifier: function(name, handler) {
this._modifiers || (this._modifiers = {});
(require.is(name, 'Array') ? name : [name]).forEach(function(n) {
(Array.isArray(name) ? name : [name]).forEach(function(n) {
(this._modifiers[n] = this._modifiers[n] || []).push(handler);
}, this);
},
Expand Down
53 changes: 27 additions & 26 deletions mobileweb/titanium/Ti/_/UI/WebViewBridge.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
var a, b,
w = window,
p = w.parent,
u = w.onunload;
(function (w) {
var a, b,
p = w.parent,
u = w.onunload;

if (!Ti && !Titanium && p && p.Ti) {
a = p.Ti.API;
b = p.Ti.App;
Ti = Titanium = {
API: {
log: a.log,
debug: a.debug,
error: a.error,
info: a.info,
warn: a.warn
},
App: {
addEventListener: b.addEventListener,
removeEventListener: b.removeEventListener,
fireEvent: b.fireEvent
}
};
}
if (p && typeof Ti == 'undefined' && typeof p.Ti == 'object') {
a = p.Ti.API;
b = p.Ti.App;
w.Ti = w.Titanium = {
API: {
log: a.log,
debug: a.debug,
error: a.error,
info: a.info,
warn: a.warn
},
App: {
addEventListener: b.addEventListener.bind(b),
removeEventListener: b.removeEventListener.bind(b),
fireEvent: b.fireEvent.bind(b)
}
};
}

w.onunload = function() {
Ti.App.fireEvent("WEBVIEW_ID");
u && u();
};
w.onunload = function () {
Ti.App.fireEvent("WEBVIEW_ID");
u && u();
};
}(window));