Added artist and song radios, added play button on artist pages, added artist page menu (needs glyph)

This commit is contained in:
booploops 2021-12-15 17:55:07 -08:00
parent 147f056270
commit 2837c9d57e
4 changed files with 127 additions and 43 deletions

View file

@ -14,31 +14,6 @@ Vue.component('lyrics-view', {
});
// This is going to suck to code
var CiderContextMenus = {
mediaitem: function (mediaitem) {
this.items = [
{
"name": "Add to Library",
"action": function(song) {
console.log("Adding song to library");
console.log(mediaitem.attributes.name)
}
},
{
"name": "Add to Playlist",
"action": function(song) {
console.log("Adding song to playlist");
}
},
{
"name": "Add to Queue",
"action": function(song) {
console.log("Adding song to queue");
}
}
]
}
}
var CiderContextMenu = {
Menu: function (event) {
this.items = []
@ -48,11 +23,10 @@ var CiderContextMenu = {
var menu = document.createElement("div");
menu.classList.add("context-menu-body");
menuBackground.classList.add("context-menu");
menu.style.left = event.clientX + "px";
menu.style.top = event.clientY + "px";
menu.style.left = 0 + "px";
menu.style.top = 0 + "px";
menu.style.position = "absolute";
menu.style.zIndex = "99909";
menu.style.minWidth = "120px"
// when menubackground is clicked, remove it
menuBackground.addEventListener("click", function () {
@ -64,6 +38,8 @@ var CiderContextMenu = {
menuBackground.appendChild(menu);
document.body.appendChild(menuBackground);
// for each item in menudata create a menu item
for (var i = 0; i < menudata.items.length; i++) {
var item = document.createElement("button")
@ -73,13 +49,17 @@ var CiderContextMenu = {
item.onclick = menudata.items[i].action
menu.appendChild(item)
}
// if menu would be off the screen, move it into view
if (event.clientX + menu.offsetWidth > window.innerWidth) {
menu.style.width = (menu.offsetWidth + 10) + "px";
menu.style.left = event.clientX + "px";
menu.style.top = event.clientY + "px";
// if menu would be off the screen, move it into view, but preserve the width
if (menu.offsetLeft + menu.offsetWidth > window.innerWidth) {
menu.style.left = (window.innerWidth - menu.offsetWidth) + "px";
}
if (event.clientY + menu.offsetHeight > window.innerHeight) {
if (menu.offsetTop + menu.offsetHeight > window.innerHeight) {
menu.style.top = (window.innerHeight - menu.offsetHeight) + "px";
}
return menuBackground;
}
}