[TIMOB-9080] iOS: send navigationType when beforeload event is fired in iOS webview
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-05-11T10:38:50.000+0000 |
Affected Version/s | Release 2.1.0 |
Fix Version/s | Release 2.1.0, Sprint 2012-10 API |
Components | iOS |
Labels | community, core, module_webview, qe-testadded |
Reporter | Tommy Leung |
Assignee | Max Stepanov |
Created | 2012-05-03T10:39:37.000+0000 |
Updated | 2013-11-25T08:51:46.000+0000 |
Description
Implement UIWebViewNavigationType such that the beforeload event will include this in its parameters
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWebView_Class/Reference/Reference.html
Test case:
var win1 = Titanium.UI.createWindow({
navBarHidden:false
});
var webview1 = Ti.UI.createWebView({
url: 'http://www.gmail.com'
});
webview1.addEventListener('beforeload', function(e){
var navigationType = e.navigationType;
if(Ti.UI.iOS.WEBVIEW_NAVIGATIONTYPE_LINK_CLICKED == navigationType){
Ti.API.info("WEBVIEW_NAVIGATIONTYPE_LINK_CLICKED");
} else if (Ti.UI.iOS.WEBVIEW_NAVIGATIONTYPE_FORM_SUBMITTED == navigationType){
Ti.API.info("WEBVIEW_NAVIGATIONTYPE_FORM_SUBMITTED");
} else if (Ti.UI.iOS.WEBVIEW_NAVIGATIONTYPE_BACK_FORWARD == navigationType){
Ti.API.info("WEBVIEW_NAVIGATIONTYPE_BACK_FORWARD");
} else if (Ti.UI.iOS.WEBVIEW_NAVIGATIONTYPE_RELOAD == navigationType){
Ti.API.info("WEBVIEW_NAVIGATIONTYPE_RELOAD");
} else if (Ti.UI.iOS.WEBVIEW_NAVIGATIONTYPE_FORM_RESUBMITTED == navigationType){
Ti.API.info("WEBVIEW_NAVIGATIONTYPE_FORM_RESUBMITTED");
} else if (Ti.UI.iOS.WEBVIEW_NAVIGATIONTYPE_OTHER == navigationType){
Ti.API.info("WEBVIEW_NAVIGATIONTYPE_OTHER");
}
});
var bb2 = Titanium.UI.createButtonBar({
labels:['Back', 'Reload', 'Forward'],
bottom: 0
});
var flexSpace = Titanium.UI.createButton({
systemButton:Titanium.UI.iPhone.SystemButton.FLEXIBLE_SPACE
});
bb2.addEventListener('click',function(ce){
if (ce.index == 0) { webview1.goBack(); }
else if (ce.index == 1) { webview1.reload(); }
else { webview1.goForward(); }
});
win1.add(webview1);
win1.add(bb2);
win1.open();
Pull request https://github.com/appcelerator/titanium_mobile/pull/1902
PR merged https://github.com/appcelerator/titanium_mobile/pull/1902
Closing issue Tested with Ti Studio build 2.1.0.201206111802 Ti Mobile SDK 2.1.0.v20120612102301 hash refeef019 OSX Lion 10.7.3 iPhone 4S OS 5.1 Verified that the navigation type is sent to the before load event
Anvil test case added. PR link: https://github.com/appcelerator/titanium_mobile/pull/5020