[MediaWiki-commits] [Gerrit] Don't crash when a reference is clicked - change (apps...wikipedia)
Yuvipanda has uploaded a new change for review. https://gerrit.wikimedia.org/r/115958 Change subject: Don't crash when a reference is clicked .. Don't crash when a reference is clicked Change-Id: I9f28f8b0be702503579d4a97ce22cff30d21f7cd --- M wikipedia/assets/bundle.js M wikipedia/assets/preview.js M www/js/actions.js M www/preview.js 4 files changed, 28 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia refs/changes/58/115958/1 diff --git a/wikipedia/assets/bundle.js b/wikipedia/assets/bundle.js index 98ac29b..84e36b6 100644 --- a/wikipedia/assets/bundle.js +++ b/wikipedia/assets/bundle.js @@ -23,7 +23,13 @@ handlers[i]( event.target, event ); } } else { -bridge.sendMessage( 'linkClicked', { href: event.target.getAttribute( "href" ) }); +var href = event.target.getAttribute( "href" ); +if ( href[0] === "#" ) { +// If it is a link to an anchor in the current page, just scroll to it +document.getElementById( href.substring( 1 ) ).scrollIntoView(); +} else { +bridge.sendMessage( 'linkClicked', { "href": href } ); +} event.preventDefault(); } } diff --git a/wikipedia/assets/preview.js b/wikipedia/assets/preview.js index 1e8c969..e6f488c 100644 --- a/wikipedia/assets/preview.js +++ b/wikipedia/assets/preview.js @@ -23,7 +23,13 @@ handlers[i]( event.target, event ); } } else { -bridge.sendMessage( 'linkClicked', { href: event.target.getAttribute( "href" ) }); +var href = event.target.getAttribute( "href" ); +if ( href[0] === "#" ) { +// If it is a link to an anchor in the current page, just scroll to it +document.getElementById( href.substring( 1 ) ).scrollIntoView(); +} else { +bridge.sendMessage( 'linkClicked', { "href": href } ); +} event.preventDefault(); } } diff --git a/www/js/actions.js b/www/js/actions.js index f255072..fdfe383 100644 --- a/www/js/actions.js +++ b/www/js/actions.js @@ -22,7 +22,13 @@ handlers[i]( event.target, event ); } } else { -bridge.sendMessage( 'linkClicked', { href: event.target.getAttribute( "href" ) }); +var href = event.target.getAttribute( "href" ); +if ( href[0] === "#" ) { +// If it is a link to an anchor in the current page, just scroll to it +document.getElementById( href.substring( 1 ) ).scrollIntoView(); +} else { +bridge.sendMessage( 'linkClicked', { "href": href } ); +} event.preventDefault(); } } diff --git a/www/preview.js b/www/preview.js index 1e8c969..e6f488c 100644 --- a/www/preview.js +++ b/www/preview.js @@ -23,7 +23,13 @@ handlers[i]( event.target, event ); } } else { -bridge.sendMessage( 'linkClicked', { href: event.target.getAttribute( "href" ) }); +var href = event.target.getAttribute( "href" ); +if ( href[0] === "#" ) { +// If it is a link to an anchor in the current page, just scroll to it +document.getElementById( href.substring( 1 ) ).scrollIntoView(); +} else { +bridge.sendMessage( 'linkClicked', { "href": href } ); +} event.preventDefault(); } } -- To view, visit https://gerrit.wikimedia.org/r/115958 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9f28f8b0be702503579d4a97ce22cff30d21f7cd Gerrit-PatchSet: 1 Gerrit-Project: apps/android/wikipedia Gerrit-Branch: master Gerrit-Owner: Yuvipanda ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Don't crash when a reference is clicked - change (apps...wikipedia)
Brion VIBBER has submitted this change and it was merged. Change subject: Don't crash when a reference is clicked .. Don't crash when a reference is clicked Change-Id: I9f28f8b0be702503579d4a97ce22cff30d21f7cd --- M wikipedia/assets/bundle.js M wikipedia/assets/preview.js M www/js/actions.js M www/preview.js 4 files changed, 28 insertions(+), 4 deletions(-) Approvals: Brion VIBBER: Verified; Looks good to me, approved diff --git a/wikipedia/assets/bundle.js b/wikipedia/assets/bundle.js index 98ac29b..84e36b6 100644 --- a/wikipedia/assets/bundle.js +++ b/wikipedia/assets/bundle.js @@ -23,7 +23,13 @@ handlers[i]( event.target, event ); } } else { -bridge.sendMessage( 'linkClicked', { href: event.target.getAttribute( "href" ) }); +var href = event.target.getAttribute( "href" ); +if ( href[0] === "#" ) { +// If it is a link to an anchor in the current page, just scroll to it +document.getElementById( href.substring( 1 ) ).scrollIntoView(); +} else { +bridge.sendMessage( 'linkClicked', { "href": href } ); +} event.preventDefault(); } } diff --git a/wikipedia/assets/preview.js b/wikipedia/assets/preview.js index 1e8c969..e6f488c 100644 --- a/wikipedia/assets/preview.js +++ b/wikipedia/assets/preview.js @@ -23,7 +23,13 @@ handlers[i]( event.target, event ); } } else { -bridge.sendMessage( 'linkClicked', { href: event.target.getAttribute( "href" ) }); +var href = event.target.getAttribute( "href" ); +if ( href[0] === "#" ) { +// If it is a link to an anchor in the current page, just scroll to it +document.getElementById( href.substring( 1 ) ).scrollIntoView(); +} else { +bridge.sendMessage( 'linkClicked', { "href": href } ); +} event.preventDefault(); } } diff --git a/www/js/actions.js b/www/js/actions.js index f255072..fdfe383 100644 --- a/www/js/actions.js +++ b/www/js/actions.js @@ -22,7 +22,13 @@ handlers[i]( event.target, event ); } } else { -bridge.sendMessage( 'linkClicked', { href: event.target.getAttribute( "href" ) }); +var href = event.target.getAttribute( "href" ); +if ( href[0] === "#" ) { +// If it is a link to an anchor in the current page, just scroll to it +document.getElementById( href.substring( 1 ) ).scrollIntoView(); +} else { +bridge.sendMessage( 'linkClicked', { "href": href } ); +} event.preventDefault(); } } diff --git a/www/preview.js b/www/preview.js index 1e8c969..e6f488c 100644 --- a/www/preview.js +++ b/www/preview.js @@ -23,7 +23,13 @@ handlers[i]( event.target, event ); } } else { -bridge.sendMessage( 'linkClicked', { href: event.target.getAttribute( "href" ) }); +var href = event.target.getAttribute( "href" ); +if ( href[0] === "#" ) { +// If it is a link to an anchor in the current page, just scroll to it +document.getElementById( href.substring( 1 ) ).scrollIntoView(); +} else { +bridge.sendMessage( 'linkClicked', { "href": href } ); +} event.preventDefault(); } } -- To view, visit https://gerrit.wikimedia.org/r/115958 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I9f28f8b0be702503579d4a97ce22cff30d21f7cd Gerrit-PatchSet: 1 Gerrit-Project: apps/android/wikipedia Gerrit-Branch: master Gerrit-Owner: Yuvipanda Gerrit-Reviewer: Brion VIBBER ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits