Skip to content

Commit

Permalink
Fixes for Icon support
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Koshy committed Jan 9, 2017
1 parent b29b52f commit 911f2e0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
35 changes: 26 additions & 9 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,32 @@ $( document ).ready(function() {
hideBookmarkEditor();
});
// create the select options for the bookmarks editor
$.each(domainMatchings, function(dmKey, dmVal) {
if (typeof dmVal.icon != "undefined") {
$('.bookmarks_editor .bookmark_icon_picker').append(
$('<option>')
.val(dmVal.icon)
.html(dmVal.icon)
);
}
});
(function() {
let iconList = [];
$.each(domainMatchings, function(dmKey, dmVal) {
if (typeof dmVal.icon != "undefined") {
if (typeof iconList[dmVal.icon] == "undefined") { // only include the icon once
iconList[dmVal.icon] = true;
$('.bookmarks_editor .bookmark_icon_picker').append(
$('<option>')
.val(dmVal.icon)
.html(dmVal.icon)
);
}
}
});
$('.bookmarks_editor .bookmark_icon').focusin(function() {
let el = $(this);
el.attr('data-original-val', el.val());
el.val('');
});
$('.bookmarks_editor .bookmark_icon').focusout(function() {
let el = $(this);
if ($.trim(el.val()) == '') {
el.val(el.attr('data-original-val'));
}
});
})();

// weather
$('.weather_currently').mouseenter(function() {
Expand Down
8 changes: 4 additions & 4 deletions newtab.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@

</div>
<div class="bookmarks_editor">
<input type="text" class="bookmark_name" placeholder="Name (Google)"/>
<input type="text" class="bookmark_link" placeholder="URL (http://google.com)"/>
<input type="text" class="bookmark_color" placeholder="Color" readonly/>
<input type="text" class="bookmark_icon" placeholder="Icon URL" list="bookmark_icon_picker">
<input type="text" class="prefs_row bookmark_name" placeholder="Name (Google)"/>
<input type="text" class="prefs_row bookmark_link" placeholder="URL (http://google.com)"/>
<input type="text" class="prefs_row bookmark_color" placeholder="Color" readonly/>
<input type="text" class="prefs_row bookmark_icon" placeholder="Icon URL (Click dropdown for options)" list="bookmark_icon_picker">
<datalist id="bookmark_icon_picker" class="bookmark_icon_picker">
<option value=""></option>
</datalist>
Expand Down

0 comments on commit 911f2e0

Please sign in to comment.