Brion VIBBER has submitted this change and it was merged.
Change subject: Fix for link taps which weren't working.
......................................................................
Fix for link taps which weren't working.
Change-Id: I7dc0cda3e247a37a2e8d1063409f4b90361505fe
---
M Wikipedia-iOS/View Controllers/ViewController.m
M Wikipedia-iOS/mw-bridge/bridge-index.html
2 files changed, 22 insertions(+), 0 deletions(-)
Approvals:
Brion VIBBER: Verified; Looks good to me, approved
diff --git a/Wikipedia-iOS/View Controllers/ViewController.m
b/Wikipedia-iOS/View Controllers/ViewController.m
index 10276b9..ae0fd6e 100644
--- a/Wikipedia-iOS/View Controllers/ViewController.m
+++ b/Wikipedia-iOS/View Controllers/ViewController.m
@@ -76,6 +76,21 @@
[bridge_ addListener:@"DOMLoaded" withBlock:^(NSString *messageType,
NSDictionary *payload) {
//NSLog(@"QQQ HEY DOMLoaded!");
}];
+
+ __weak ViewController *weakSelf = self;
+ [bridge_ addListener:@"linkClicked" withBlock:^(NSString *messageType,
NSDictionary *payload) {
+ NSString *href = payload[@"href"];
+ if ([href hasPrefix:@"/wiki/"]) {
+ NSString *title = [href substringWithRange:NSMakeRange(6,
href.length - 6)];
+ [weakSelf navigateToPage:title];
+ }else if ([href hasPrefix:@"//"]) {
+ href = [@"http:" stringByAppendingString:href];
+
+NSString *msg = [NSString stringWithFormat:@"To do: add code for navigating to
external link: %@", href];
+[weakSelf.webView stringByEvaluatingJavaScriptFromString:[NSString
stringWithFormat:@"alert('%@')", msg]];
+
+ }
+ }];
[self setupQMonitorDebuggingLabel];
diff --git a/Wikipedia-iOS/mw-bridge/bridge-index.html
b/Wikipedia-iOS/mw-bridge/bridge-index.html
index ad7b2ec..cf3cd7a 100644
--- a/Wikipedia-iOS/mw-bridge/bridge-index.html
+++ b/Wikipedia-iOS/mw-bridge/bridge-index.html
@@ -56,6 +56,13 @@
bridge.sendMessage( "pong", payload );
});
+ document.onclick = function() {
+ if ( event.target.tagName === "A" ) {
+ bridge.sendMessage( 'linkClicked', { href:
event.target.getAttribute( "href" ) });
+ event.preventDefault();
+ }
+ }
+
} )();
</script>
</head>
--
To view, visit https://gerrit.wikimedia.org/r/96571
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7dc0cda3e247a37a2e8d1063409f4b90361505fe
Gerrit-PatchSet: 3
Gerrit-Project: apps/ios/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Mhurd <[email protected]>
Gerrit-Reviewer: Brion VIBBER <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits