Skip to content

Commit

Permalink
Merge pull request #4441 from hypothesis/remove-homepage-inline-script
Browse files Browse the repository at this point in the history
Replace inline script for homepage Via form
  • Loading branch information
robertknight authored Mar 17, 2017
2 parents 5654ce3 + 96b07d7 commit 851913a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
11 changes: 11 additions & 0 deletions h/static/scripts/legacy-site.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,14 @@ if (chromeextInstaller) {
event.preventDefault();
});
}

const viaForm = document.querySelector('.js-via-form');
if (viaForm) {
viaForm.addEventListener('submit', (event) => {
const url = event.target.elements.url.value;
if (url !== '') {
window.location.href = 'https://via.hypothes.is/' + url;
}
event.preventDefault();
});
}
10 changes: 6 additions & 4 deletions h/templates/home.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,14 @@
</span>

<em class="or hidden-xs">Or...</em>
<form class="via" onsubmit="url = document.getElementById('search').value; if (url != '') { window.location.href = 'https://via.hypothes.is/h/' + url; } return false;">
<form class="via js-via-form">
<span class="input-group"
title="Insert a URL to annotate that page.">
<input id="search" class="form-control" type="text"
name="search" placeholder="Paste a link...">
<span class="input-group-btn" data-via-button="">
<input class="form-control"
type="text"
name="url"
placeholder="Paste a link...">
<span class="input-group-btn">
<button class="btn btn-primary" type="submit">
Annotate!
</button>
Expand Down

0 comments on commit 851913a

Please sign in to comment.