-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* start of a new icon picker. * edit dom in one single operation * rm old file
- Loading branch information
Showing
13 changed files
with
1,145 additions
and
10,239 deletions.
There are no files selected for viewing
4,869 changes: 0 additions & 4,869 deletions
4,869
apps/dashboard/app/assets/javascripts/fontawesome-iconpicker.js
This file was deleted.
Oops, something went wrong.
4,997 changes: 0 additions & 4,997 deletions
4,997
apps/dashboard/app/javascript/packs/fa/faIconInfo.js
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
'use strict'; | ||
|
||
import ALL_ICONS from 'icons'; | ||
|
||
const ICON_SHOW_ID = "product_icon" | ||
const ICON_SELECT_ID = "product_icon_select" | ||
|
||
function listItem(name) { | ||
return `<li | ||
id="${iconId(name)}" | ||
class="btn btn-outline-dark" | ||
role='button'> | ||
<i class="fas fa-${name} fa-fw"></i> | ||
</li>`; | ||
} | ||
|
||
function iconId(name) { | ||
return `icon_${name.replaceAll('-', '_')}`; | ||
} | ||
|
||
function iconFromId(id) { | ||
const m = id.match(/^icon_([\w+_]+)/); | ||
if(m && m[1]) { return m[1].replaceAll('_','-') }; | ||
} | ||
|
||
function picked(event) { | ||
const icon = iconFromId(event.currentTarget.id); | ||
$(`#${ICON_SHOW_ID}`).attr("class", `fas fa-${icon} fa-fw app-icon`); | ||
$(`#${ICON_SELECT_ID}`).val(`fas://${icon}`) | ||
} | ||
|
||
function populateList() { | ||
const list = $("#icon_picker_list"); | ||
if(list.length == 0 || ALL_ICONS.length == 0) { return; } | ||
|
||
const listContent = ALL_ICONS.map(name => { | ||
return listItem(name); | ||
}).join(''); | ||
list.html(listContent); | ||
|
||
ALL_ICONS.forEach(name => { | ||
$(`#${iconId(name)}`).on('click', (event) => { picked(event)}); | ||
}); | ||
}; | ||
|
||
jQuery(() => { | ||
populateList(); | ||
}) |
Oops, something went wrong.