Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh on save + Emoji Formtype #20

Merged
merged 2 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 40 additions & 33 deletions utils/formtypes.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,40 @@
module.exports = {
slider: (min, max, step, disabled, themeOptions = {}) => {
return {
type: 'slider',
min,
max,
step,
disabled,
themeOptions
}
},
date: (disabled, themeOptions = {}) => {
return {
type: 'date',
disabled,
themeOptions
}
},
numberPicker: (disabled, themeOptions = {}) => {
return {
type: 'numberPicker',
disabled,
themeOptions
}
},
tagInput: (disabled, themeOptions = {}) => {
return {
type: 'tagInput',
disabled,
themeOptions
}
}
}
module.exports = {
emojiPicker: (disabled, themeOptions = {}) => {
return {
type: 'emojiPicker',
disabled,
themeOptions
}
},
slider: (min, max, step, disabled, themeOptions = {}) => {
return {
type: 'slider',
min,
max,
step,
disabled,
themeOptions
}
},
date: (disabled, themeOptions = {}) => {
return {
type: 'date',
disabled,
themeOptions
}
},
numberPicker: (disabled, themeOptions = {}) => {
return {
type: 'numberPicker',
disabled,
themeOptions
}
},
tagInput: (disabled, themeOptions = {}) => {
return {
type: 'tagInput',
disabled,
themeOptions
}
}
}
182 changes: 180 additions & 2 deletions views/components/formTypes/emojiPicker.ejs
Original file line number Diff line number Diff line change
@@ -1,2 +1,180 @@
<% if(!Allowed.allowed){ %><span style="color: red;"><%- Allowed.errorMessage %></span><br><% } %>
<button class="emojipicker">Emoji picker</button>
<style>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}

img {
display: block;
}


.emoji-picker {
background-color: #303841;
width: 400px;
border-radius: 5px;
height: 400px;
display: flex;
}

.emoji-selectables {
background-color: #212427;
width: 45px;
height: 100%;
padding: 10px 15px;
display: flex;
flex-direction: column;
align-items: center;
}

.emoji-selectables span {
margin-bottom: 7px;
cursor: pointer;
}

.emoji-selectables span.active img {
filter: none;
}

.emoji-selectables span img {
width: 25px;
display: block;
display: flex;
align-items: center;
filter: grayscale(100%)
}

.emoji-content div {
width: 100%;

flex-wrap: wrap;
justify-content: center;
padding: 5px;
}

.emoji-content span {
display: block;
padding: 5px;
cursor: pointer;
}

.emoji-content span:hover {
transform: scale(1.1);
background-color: #3f4953;
border-radius: 5px;
}

.picker-emoji-content {
display: none;

}

.picker-emoji-sel.face {
color: aliceblue;
font-size: 10px;
}

.picker-emoji-content.active {
display: flex;
display: flex;
height: 100%;
overflow-y: scroll;
}

.emoji-content span img {
width: 32px;
height: 32px;
}


.picker-emoji-content::-webkit-scrollbar-thumb {
height: 10px;
background-color: #65B88D;
border-radius: 100px;
}

.picker-emoji-content::-webkit-scrollbar-track {
background-color: #303841;
}

.picker-emoji-content::-webkit-scrollbar {
width: 6px;
}

img {
display: block;
}
</style>
<link href="https://www.jqueryscript.net/css/jquerysctipttop.css" rel="stylesheet" type="text/css">

<% if(!Allowed.allowed){ %>
<span style="color: red;">
<%- Allowed.errorMessage %>
</span>
<br>
<% } %>

<% console.log(actual[s.categoryId][option.optionId]) %>

<input defaultValue="<%= actual[s.categoryId][option.optionId] || "" %>" class="d-none" type="text" id="<%= option.optionId %>" formType="emojiPicker" type="text" onchange="optionEdited(this)">

<div class="dropdown">
<a href="javascript:;" class="btn bg-transparent" data-bs-toggle="dropdown" id="navbarDropdownMenuLink2" style="width: fit-content; height: fit-content; aspect-ratio: 1/1; justify-content: center; display: flex; align-items: center; max-width: 100px; <% if (option.optionType.disabled && !Allowed.allowed) { %>border-color: red;<% } %>">
<% if(actual[s.categoryId][option.optionId]){ %>
<% if (/\d/.test(actual[s.categoryId][option.optionId])) { %>
<img src="https://cdn.discordapp.com/emojis/<%= actual[s.categoryId][option.optionId] %>.png" style="width: 72px; height: 72px;">
<% } else { %>
<span style="font-size: 20px;"><%= actual[s.categoryId][option.optionId] %></span>
<% } %>
<% } %>
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink2">
<div id="emojis">
</div>
</div>
</div>

<script src="/js/core/DisMojiPicker.js"></script>
<script src="https://twemoji.maxcdn.com/v/latest/twemoji.min.js" crossorigin="anonymous"></script>
<% if(!option.optionType.disabled && Allowed.allowed){ %>
<script>
const emojis = <%- JSON.stringify(bot.guilds.cache.get(req.params.id).emojis.cache.map(e => {
return {
animated: e.animated,
name: e.name,
id: e.id
}
})) %>
$(".dropdown").click(function(e){
e.stopPropagation();
})
$("#emojis").disMojiPicker(emojis)
$("#emojis").picker(emoji => {
let custom = {}

if (emoji)
$("#navbarDropdownMenuLink2").dropdown("toggle")

if (emojis.find(x => x.name === emoji)) {
custom = emojis.find(x => x.name === emoji)
}

$("#<%= option.optionId %>").val(custom ? custom.id : emoji)
$("#<%= option.optionId %>").trigger("change")

console.log(custom)

if (custom?.id)
return $("#navbarDropdownMenuLink2").html(
`<img src="https://cdn.discordapp.com/emojis/${custom.id}.${custom.animated ? "gif" : "png"}" alt="${custom.name}" style="width: 72px; height: 72px;"/>`
)
else $("#navbarDropdownMenuLink2").html(`
<span style="width: 72px; height: 72px;">
${twemoji.parse(emoji)}
</span>
`)
});
twemoji.parse(document.body, "<%= bot.guilds.cache.get(req.params.id).emojis.cache.map(e => e.id) %>");
</script>
<% } %>
48 changes: 24 additions & 24 deletions views/settings.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -435,30 +435,30 @@
</div>
</main>

<!-- Core JS Files -->
<script id="helper" category="<%= req.params.category %>" gid="<%= req.params.id %>"
src="/js/dashboard/functions.js"></script>
<script src="../assets/js/core/popper.min.js"></script>
<script src="../assets/js/core/bootstrap.min.js"></script>
<script src="../assets/js/plugins/perfect-scrollbar.min.js"></script>
<script src="../assets/js/plugins/smooth-scrollbar.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/bootstrap.tagsinput/0.4.2/bootstrap-tagsinput.min.js"></script>
<script>
var win = navigator.platform.indexOf('Win') > -1;
if (win && document.querySelector('#sidenav-scrollbar')) {
var options = {
damping: '0.5'
}
Scrollbar.init(document.querySelector('#sidenav-scrollbar'), options);
}
</script>
<script>
$(document).ready(function () {
<% if (req.query.error === "premiumRequired") { %>
sweetalert("error", "<%= themeConfig?.sweetalert?.error?.requirePremium || 'Premium is required for this category' %>", 2000);
window.history.replaceState({}, title, window.location.href.split('?')[0]);
<!-- Core JS Files -->
<script id="helper" category="<%= req.params.category %>" gid="<%= req.params.id %>" refresh="<%= settings.find(s => s.categoryId === req.params?.category)?.refreshOnSave || false %>"
src="/js/dashboard/functions.js"></script>
<script src="../assets/js/core/popper.min.js"></script>
<script src="../assets/js/core/bootstrap.min.js"></script>
<script src="../assets/js/plugins/perfect-scrollbar.min.js"></script>
<script src="../assets/js/plugins/smooth-scrollbar.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/bootstrap.tagsinput/0.4.2/bootstrap-tagsinput.min.js"></script>
<script>
var win = navigator.platform.indexOf('Win') > -1;
if (win && document.querySelector('#sidenav-scrollbar')) {
var options = {
damping: '0.5'
}
Scrollbar.init(document.querySelector('#sidenav-scrollbar'), options);
}
</script>
<script>
$(document).ready(function () {
<% if ( req.query.error === "premiumRequired" ) { %>
sweetalert("error", "<%= themeConfig?.sweetalert?.error?.requirePremium || 'Premium is required for this category' %>", 2000);
window.history.replaceState({}, title, window.location.href.split('?')[0]);
<% } %>
$('.multiSelect').select2({ closeOnSelect: true });
$(".tags").select2({ theme: "classic", tags: true })
Expand Down
Loading