thedesk/app/js/ui/menu.js

78 lines
2.3 KiB
JavaScript
Raw Permalink Normal View History

2019-05-19 17:39:30 +10:00
function menu() {
2020-08-02 17:08:07 +10:00
localStorage.setItem("menu-done", true)
2019-05-19 17:39:30 +10:00
$("#fukidashi").addClass("hide")
if (!$("#menu").hasClass("appear")) {
$("#menu").addClass("appear")
2020-08-02 17:08:07 +10:00
var left = localStorage.getItem("menu-left")
2019-05-19 17:39:30 +10:00
if (left > $('body').width() - $('#menu').width()) {
2020-08-02 17:08:07 +10:00
left = $('body').width() - $('#menu').width()
2019-05-19 17:39:30 +10:00
} else if (left < 0) {
2020-08-02 17:08:07 +10:00
left = 0
}
2020-08-02 17:08:07 +10:00
var top = localStorage.getItem("menu-top")
2019-05-19 17:39:30 +10:00
if (top > $('body').height() - $('#menu').height()) {
2020-08-02 17:08:07 +10:00
top = $('body').height() - $('#menu').height()
2019-05-19 17:39:30 +10:00
} else if (top < 0) {
2020-08-02 17:08:07 +10:00
top = 0
2019-05-19 17:39:30 +10:00
}
$('#menu').css("left", left + "px")
$('#menu').css("top", top + "px")
2020-08-02 17:08:07 +10:00
var height = localStorage.getItem("menu-height")
var width = localStorage.getItem("menu-width")
2019-08-30 02:46:30 +10:00
if(height){
$('#menu').css("height", height + "px")
}else{
$('#menu').css("height", "460px")
}
if(width){
$('#menu').css("width", width + "px")
}
2020-08-02 17:08:07 +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")
$("#addColumnMenu").click()
2019-05-19 17:39:30 +10:00
} else {
$('#menu').fadeOut()
$("#menu").removeClass("appear")
}
}
2019-05-19 17:39:30 +10:00
$(function () {
$("#menu").draggable({
handle: "#menu-bar",
stop: function () {
2020-08-02 17:08:07 +10:00
var left = $('#menu').offset().left
2019-05-19 17:39:30 +10:00
if (left > $('body').width() - $('#menu').width()) {
2020-08-02 17:08:07 +10:00
left = $('body').width() - $('#menu').width()
2019-05-19 17:39:30 +10:00
} else if (left < 0) {
2020-08-02 17:08:07 +10:00
left = 0
}
2020-08-02 17:08:07 +10:00
var top = $('#menu').offset().top
2019-05-19 17:39:30 +10:00
if (top > $('body').height() - $('#menu').height()) {
2020-08-02 17:08:07 +10:00
top = $('body').height() - $('#menu').height()
2019-05-19 17:39:30 +10:00
} else if (top < 0) {
2020-08-02 17:08:07 +10:00
top = 0
}
2020-08-02 17:08:07 +10:00
localStorage.setItem("menu-left", left)
localStorage.setItem("menu-top", top)
2019-05-19 17:39:30 +10:00
}
2020-08-02 17:08:07 +10:00
})
2019-08-30 02:46:30 +10:00
$("#menu").resizable({
minHeight: 150,
minWidth: 200,
stop: function (event, ui) {
2020-08-02 17:08:07 +10:00
localStorage.setItem("menu-height", ui.size.height)
localStorage.setItem("menu-width", ui.size.width)
2019-08-30 02:46:30 +10:00
}
2020-08-02 17:08:07 +10:00
})
})
2019-05-19 17:39:30 +10:00
function help() {
2020-08-02 17:08:07 +10:00
$("#left-menu a").removeClass("active")
$("#helpMenu").addClass("active")
$(".menu-content").addClass("hide")
$("#help-box").removeClass("hide")
2019-10-31 03:00:06 +11:00
postMessage(["sendSinmpleIpc", "getLogs"], "*")
}