add icon_authors editor

This commit is contained in:
Felix Niklas 2015-05-26 21:42:17 +02:00
parent 2158807fd0
commit 4c436ee3e3
3 changed files with 221 additions and 0 deletions

View file

@ -0,0 +1,145 @@
<!doctype html>
<title>Zammad Icons</title>
<style>
html {
padding: 0 14px 14px 0;
}
body {
margin: 28px 28px 14px 14px;
background: hsl(210,14%,97%);
font-family: sans-serif;
font-size: 13px;
}
.icon-holder {
border: 1px solid hsl(199,44%,93%);
background: white;
box-shadow: 0 2px hsl(210,7%,96%);
float: left;
margin: 0 0 14px 14px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
max-width: 200px;
}
.icon {
position: relative;
padding: 14px;
width: 100%;
box-sizing: border-box;
display: flex;
justify-content: center;
}
.icon svg {
width: 128px;
height: 128px;
position: relative;
}
.icon-body {
padding: 14px;
}
.icon-name {
margin: 0 0 7px;
white-space: nowrap;
}
input {
width: 160px;
font: inherit;
border: 1px solid #ddd;
padding: 3px 5px;
}
input:focus {
outline: none;
border-color: hsl(205,74%,61%);
}
.icon:before {
content: "";
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-image:
linear-gradient(45deg, black 25%, transparent 25%, transparent 75%, black 75%, black),
linear-gradient(45deg, black 25%, transparent 25%, transparent 75%, black 75%, black);
background-size: 20px 20px;
background-position: 10px 10px, 40px 40px;
background: hsl(210,14%,94%);
opacity: 0.3;
}
</style>
<?
# Path to image folder
$imageFolder = '../../public/assets/images/icons/';
# Show only these file types from the image folder
$imageTypes = '{*.svg}';
# Set to true if you prefer sorting images by name
# If set to false, images will be sorted by date
$sortByImageName = true;
# Set to false if you want the oldest images to appear first
# This is only used if images are sorted by date (see above)
$newestImagesFirst = true;
# The rest of the code is technical
# Add images to array
$images = glob($imageFolder . $imageTypes, GLOB_BRACE);
$author_data = json_decode(file_get_contents('list.json'), true);
# Sort images
if ($sortByImageName) {
$sortedImages = $images;
natsort($sortedImages);
} else {
# Sort the images based on its 'last modified' time stamp
$sortedImages = array();
$count = count($images);
for ($i = 0; $i < $count; $i++) {
$sortedImages[date('YmdHis', filemtime($images[$i])) . $i] = $images[$i];
}
# Sort images in array
if ($newestImagesFirst) {
krsort($sortedImages);
} else {
ksort($sortedImages);
}
}
?>
<? foreach ($sortedImages as $image): ?>
<?
# Get the name of the image, stripped from image folder path and file type extension
$filename = basename($image);
$name = preg_replace('/\\.[^.\\s]{3,4}$/', '', $filename);
# Begin adding
?>
<div class="icon-holder">
<div class="icon">
<?= file_get_contents($image) ?>
</div>
<div class="icon-body">
<div class="icon-name"><?= $name ?></div>
<input class="icon-author" value="<?= $author_data[$filename] ?>" placeholder="Author" data-filename="<?= $filename ?>">
</div>
</div>
<? endforeach ?>
<script src="../../app/assets/javascripts/app/lib/core/jquery-2.1.1.min.js"></script>
<script>
$('input').on('blur', function(){
var iconList = {}
$('.icon-author').each(function(){
iconList[$(this).attr('data-filename')] = $(this).val()
})
$.post('store.php', { list: iconList })
})
</script>

View file

@ -0,0 +1,67 @@
{
"arrow-down.svg": "Felix Niklas",
"arrow-left.svg": "Felix Niklas",
"arrow-right.svg": "Felix Niklas",
"arrow-up.svg": "Felix Niklas",
"checkbox-checked.svg": "Felix Niklas",
"checkbox.svg": "Felix Niklas",
"checkmark.svg": "Felix Niklas",
"clock.svg": "",
"close.svg": "Felix Niklas",
"cloud.svg": "Felix Niklas",
"cog.svg": "",
"dashboard.svg": "",
"diagonal-cross.svg": "Felix Niklas",
"download.svg": "Felix Niklas",
"email.svg": "",
"facebook.svg": "Global Domain",
"group.svg": "",
"help.svg": "Felix Niklas",
"important.svg": "",
"in-process.svg": "",
"list.svg": "Felix Niklas",
"loading.svg": "Felix Niklas",
"lock-open.svg": "Felix Niklas",
"lock.svg": "Felix Niklas",
"logo.svg": "",
"long-arrow-right.svg": "Felix Niklas",
"magnifier.svg": "Felix Niklas",
"marker.svg": "Felix Niklas",
"message.svg": "Felix Niklas",
"mood-bad.svg": "",
"mood-good.svg": "",
"mood-ok.svg": "",
"mood-super-bad.svg": "",
"mood-supergood.svg": "",
"note.svg": "",
"one-ticket.svg": "",
"organization.svg": "",
"outbound-calls.svg": "",
"overviews.svg": "",
"package.svg": "Felix Niklas",
"paperclip.svg": "Felix Niklas",
"pen.svg": "Felix Niklas",
"person.svg": "",
"phone.svg": "",
"plus.svg": "Felix Niklas",
"priority-modified-inner-circle.svg": "Felix Niklas",
"priority-modified-outer-circle.svg": "Felix Niklas",
"priority.svg": "Felix Niklas",
"radio-checked.svg": "Felix Niklas",
"radio.svg": "Felix Niklas",
"received-calls.svg": "",
"reopening.svg": "",
"reply-all.svg": "Felix Niklas",
"reply.svg": "Felix Niklas",
"signout.svg": "",
"split.svg": "",
"stopwatch.svg": "",
"switchView.svg": "",
"team.svg": "",
"templates.svg": "Felix Niklas",
"tools.svg": "",
"total-tickets.svg": "",
"trash.svg": "Felix Niklas",
"twitter.svg": "",
"user.svg": ""
}

View file

@ -0,0 +1,9 @@
<?
// check for ajax request
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
file_put_contents('list.json', json_encode($_POST['list'], JSON_PRETTY_PRINT));
exit();
}
?>