thedesk/app/js/ui/menu.js

73 lines
2.2 KiB
JavaScript
Raw Normal View History

2019-05-19 17:39:30 +10:00
function menu() {
localStorage.setItem("menu-done", true);
$("#fukidashi").addClass("hide")
if (!$("#menu").hasClass("appear")) {
$("#menu").addClass("appear")
var left = localStorage.getItem("menu-left");
if (left > $('body').width() - $('#menu').width()) {
left = $('body').width() - $('#menu').width();
} else if (left < 0) {
left = 0;
}
2019-05-19 17:39:30 +10:00
var top = localStorage.getItem("menu-top");
if (top > $('body').height() - $('#menu').height()) {
top = $('body').height() - $('#menu').height();
} else if (top < 0) {
top = 0;
}
$('#menu').css("left", left + "px")
$('#menu').css("top", top + "px")
2019-08-30 02:46:30 +10:00
var height = localStorage.getItem("menu-height");
var width = localStorage.getItem("menu-width");
if(height){
$('#menu').css("height", height + "px")
}else{
$('#menu').css("height", "460px")
}
if(width){
$('#menu').css("width", width + "px")
}
2019-05-19 17:39:30 +10:00
$('#menu').fadeIn();
$("#menu-bar").html("TheDesk " + localStorage.getItem("ver"));
$(".menu-content").addClass("hide");
$("#add-box").removeClass("hide");
$("#left-menu div").removeClass("active");
$("#addColumnMenu").addClass("active");
} else {
$('#menu').fadeOut()
$("#menu").removeClass("appear")
}
}
2019-05-19 17:39:30 +10:00
$(function () {
$("#menu").draggable({
handle: "#menu-bar",
stop: function () {
var left = $('#menu').offset().left;
if (left > $('body').width() - $('#menu').width()) {
left = $('body').width() - $('#menu').width();
} else if (left < 0) {
left = 0;
}
2019-05-19 17:39:30 +10:00
var top = $('#menu').offset().top;
if (top > $('body').height() - $('#menu').height()) {
top = $('body').height() - $('#menu').height();
} else if (top < 0) {
top = 0;
}
2019-05-19 17:39:30 +10:00
localStorage.setItem("menu-left", left);
localStorage.setItem("menu-top", top);
}
});
2019-08-30 02:46:30 +10:00
$("#menu").resizable({
minHeight: 150,
minWidth: 200,
stop: function (event, ui) {
localStorage.setItem("menu-height", ui.size.height);
localStorage.setItem("menu-width", ui.size.width);
}
});
2019-05-19 17:39:30 +10:00
});
function help() {
2019-06-15 03:01:38 +10:00
postMessage(["openUrl", "https://docs.thedesk.top"], "*")
}