Skip to content

Commit

Permalink
website: markup dialog box for suggested badges
Browse files Browse the repository at this point in the history
Part of #252
  • Loading branch information
espadrine committed Jan 5, 2015
1 parent 261b492 commit 0651ff0
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions try.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,6 @@
Pixel-perfect   Retina-ready   Fast   Consistent   Hackable   No tracking
</p>

<!-- FIXME: search through vendor badges (`/$suggest/v1`, see suggest.js).
It should detect URLs, call an ajax hook in the server that fetches the project
data, return a list of valid badges for the project with copy-and-paste
markdown, html, etc.
If it isn't a URL, search through available badges for keywords corresponding to
the search.
When that is implemented, change the placeholder to 'search / project URL'
-->
<form id='searchForm' action='javascript:void 0' autocomplete=off>
<input name='projectSearch' id='projectSearch' autofill=off autofocus placeholder='search / project URL'/>
<br>
Expand Down Expand Up @@ -689,6 +680,7 @@ <h2> Contributors </h2>
// Search
var searchBadgeDb = {index: [], tr: []};
function searchBadgeDbInit() {
searchBadgeDb = {index: [], tr: []};
var trs = document.querySelectorAll('table.badge tr');
for (var i = 0; i < trs.length; i++) {
var tr = trs[i];
Expand Down Expand Up @@ -730,8 +722,8 @@ <h2> Contributors </h2>
for (var i = 0; i < badges.length; i++) {
var link = badges[i].link;
var badge = badges[i].badge;
var name = badges[i].name;
html += '<tr><th>' + name + '</th>' +
var name = badges[i].name + ':';
html += '<tr><th data-link="' + link + '">' + name + '</th>' +
'<td><img src="' + badge + '"></td>' +
'<td><code>' + badge + '</code></td>' +
'</tr>';
Expand All @@ -747,6 +739,8 @@ <h2> Contributors </h2>
if (err != null) { return; }
showSuggestedBadges(res.badges);
suggestButton.disabled = false;
searchBadgeDbInit();
markupDialogInit();
});
suggestButton.disabled = true;
}
Expand Down Expand Up @@ -782,7 +776,10 @@ <h2> Contributors </h2>
// Trim the ending colon `:`.
var trname = tr.firstElementChild.textContent.trim().slice(0, -1);
var trimg = tr.querySelector('img').src;
var th = tr.firstElementChild;
var link = th.dataset.link? th.dataset.link: '';
copyForm.img.value = trimg;
copyForm.url.value = link;
// Set up the input listeners.
copyForm.url.removeEventListener('input', copyFormUrlEventListener);
copyForm.img.removeEventListener('input', copyFormUrlEventListener);
Expand Down

0 comments on commit 0651ff0

Please sign in to comment.