2013-05-03 11:57:08 +00:00
|
|
|
/**
|
2014-01-22 10:12:51 +00:00
|
|
|
* @name ContextMenu Module
|
|
|
|
* @description This module is used for the context menu.
|
|
|
|
* @author Tobias Reich
|
|
|
|
* @copyright 2014 by Tobias Reich
|
2013-05-03 11:57:08 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
contextMenu = {
|
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
fns: null,
|
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
show: function(items, mouse_x, mouse_y, orientation) {
|
|
|
|
|
2014-01-28 19:44:25 +00:00
|
|
|
contextMenu.close();
|
2014-01-22 10:12:51 +00:00
|
|
|
|
|
|
|
$("body")
|
|
|
|
.css("overflow", "hidden")
|
2014-01-24 12:49:01 +00:00
|
|
|
.append(build.contextMenu(items));
|
|
|
|
|
2014-01-28 19:44:25 +00:00
|
|
|
// Do not leave the screen
|
2014-01-24 12:49:01 +00:00
|
|
|
if ((mouse_x+$(".contextmenu").outerWidth(true))>$("html").width()) orientation = "left";
|
2014-02-25 22:37:05 +00:00
|
|
|
if ((mouse_y+$(".contextmenu").outerHeight(true))>$("html").height()) mouse_y -= (mouse_y+$(".contextmenu").outerHeight(true)-$("html").height());
|
2014-01-22 10:12:51 +00:00
|
|
|
|
2014-01-31 21:27:58 +00:00
|
|
|
if (mouse_x>$(document).width()) mouse_x = $(document).width();
|
|
|
|
if (mouse_x<0) mouse_x = 0;
|
|
|
|
if (mouse_y>$(document).height()) mouse_y = $(document).height();
|
2014-02-17 15:22:01 +00:00
|
|
|
if (mouse_y<0) mouse_y = 0;
|
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
if (orientation==="left") mouse_x -= $(".contextmenu").outerWidth(true);
|
|
|
|
|
2014-01-31 21:27:58 +00:00
|
|
|
if (mouse_x===null||
|
|
|
|
mouse_x===undefined||
|
2014-02-25 22:37:05 +00:00
|
|
|
isNaN(mouse_x)||
|
2014-01-31 21:27:58 +00:00
|
|
|
mouse_y===null||
|
|
|
|
mouse_y===undefined||
|
2014-02-25 22:37:05 +00:00
|
|
|
isNaN(mouse_y)) {
|
2014-01-31 21:27:58 +00:00
|
|
|
mouse_x = "10px";
|
|
|
|
mouse_y = "10px";
|
2014-01-22 10:12:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$(".contextmenu").css({
|
|
|
|
"top": mouse_y,
|
2014-01-24 12:49:01 +00:00
|
|
|
"left": mouse_x,
|
2014-02-25 22:37:05 +00:00
|
|
|
"opacity": 0.98
|
2014-01-22 10:12:51 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
add: function(e) {
|
|
|
|
|
|
|
|
var mouse_x = e.pageX,
|
2014-01-28 19:44:25 +00:00
|
|
|
mouse_y = e.pageY - $(document).scrollTop(),
|
2014-01-22 10:12:51 +00:00
|
|
|
items;
|
2014-02-17 15:22:01 +00:00
|
|
|
|
2014-02-04 21:26:06 +00:00
|
|
|
upload.notify();
|
2014-01-22 10:12:51 +00:00
|
|
|
|
|
|
|
contextMenu.fns = [
|
|
|
|
function() { $("#upload_files").click() },
|
|
|
|
function() { upload.start.url() },
|
|
|
|
function() { upload.start.dropbox() },
|
|
|
|
function() { upload.start.server() },
|
|
|
|
function() { album.add() }
|
|
|
|
];
|
|
|
|
|
|
|
|
items = [
|
|
|
|
["<a class='icon-picture'></a> Upload Photo", 0],
|
|
|
|
["separator", -1],
|
|
|
|
["<a class='icon-link'></a> Import from Link", 1],
|
|
|
|
["<a class='icon-folder-open'></a> Import from Dropbox", 2],
|
|
|
|
["<a class='icon-hdd'></a> Import from Server", 3],
|
|
|
|
["separator", -1],
|
|
|
|
["<a class='icon-folder-close'></a> New Album", 4]
|
|
|
|
];
|
|
|
|
|
|
|
|
contextMenu.show(items, mouse_x, mouse_y, "left");
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
settings: function(e) {
|
|
|
|
|
|
|
|
var mouse_x = e.pageX,
|
2014-01-28 19:44:25 +00:00
|
|
|
mouse_y = e.pageY - $(document).scrollTop(),
|
2014-01-22 10:12:51 +00:00
|
|
|
items;
|
|
|
|
|
|
|
|
contextMenu.fns = [
|
|
|
|
function() { settings.setLogin() },
|
|
|
|
function() { settings.setSorting() },
|
2014-02-23 21:42:15 +00:00
|
|
|
function() { settings.setDropboxKey() },
|
2014-02-17 15:22:01 +00:00
|
|
|
function() { window.open(lychee.website, "_newtab"); },
|
2014-04-22 10:05:43 +00:00
|
|
|
function() { window.open("plugins/check/", "_newtab"); },
|
2014-01-22 10:12:51 +00:00
|
|
|
function() { lychee.logout() }
|
|
|
|
];
|
|
|
|
|
|
|
|
items = [
|
|
|
|
["<a class='icon-user'></a> Change Login", 0],
|
|
|
|
["<a class='icon-sort'></a> Change Sorting", 1],
|
2014-02-23 21:42:15 +00:00
|
|
|
["<a class='icon-folder-open'></a> Set Dropbox", 2],
|
2014-01-22 10:12:51 +00:00
|
|
|
["separator", -1],
|
2014-02-23 21:42:15 +00:00
|
|
|
["<a class='icon-info-sign'></a> About Lychee", 3],
|
|
|
|
["<a class='icon-dashboard'></a> Diagnostics", 4],
|
|
|
|
["separator", -1],
|
|
|
|
["<a class='icon-signout'></a> Sign Out", 5]
|
2014-01-22 10:12:51 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
contextMenu.show(items, mouse_x, mouse_y, "right");
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
album: function(albumID, e) {
|
2013-05-03 11:57:08 +00:00
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
var mouse_x = e.pageX,
|
2014-01-28 19:44:25 +00:00
|
|
|
mouse_y = e.pageY - $(document).scrollTop(),
|
2013-09-03 09:59:30 +00:00
|
|
|
items;
|
2013-05-03 11:57:08 +00:00
|
|
|
|
2014-02-17 15:22:01 +00:00
|
|
|
if (albumID==="0"||albumID==="f"||albumID==="s") return false;
|
2013-05-03 11:57:08 +00:00
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
contextMenu.fns = [
|
2014-02-02 14:11:46 +00:00
|
|
|
function() { album.setTitle([albumID]) },
|
|
|
|
function() { album.delete([albumID]) }
|
2013-09-03 09:59:30 +00:00
|
|
|
];
|
|
|
|
|
2013-05-03 11:57:08 +00:00
|
|
|
items = [
|
2013-09-03 09:59:30 +00:00
|
|
|
["<a class='icon-edit'></a> Rename", 0],
|
|
|
|
["<a class='icon-trash'></a> Delete", 1]
|
2013-05-03 11:57:08 +00:00
|
|
|
];
|
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
contextMenu.show(items, mouse_x, mouse_y, "right");
|
|
|
|
|
2013-05-03 11:57:08 +00:00
|
|
|
$(".album[data-id='" + albumID + "']").addClass("active");
|
|
|
|
|
|
|
|
},
|
2014-02-17 15:22:01 +00:00
|
|
|
|
2014-01-31 20:22:25 +00:00
|
|
|
albumMulti: function(albumIDs, e) {
|
2014-02-17 15:22:01 +00:00
|
|
|
|
2014-01-31 20:22:25 +00:00
|
|
|
var mouse_x = e.pageX,
|
|
|
|
mouse_y = e.pageY - $(document).scrollTop(),
|
|
|
|
items;
|
|
|
|
|
|
|
|
multiselect.stopResize();
|
|
|
|
|
|
|
|
contextMenu.fns = [
|
|
|
|
function() { album.setTitle(albumIDs) },
|
|
|
|
function() { album.delete(albumIDs) },
|
|
|
|
];
|
|
|
|
|
|
|
|
items = [
|
|
|
|
["<a class='icon-edit'></a> Rename All", 0],
|
|
|
|
["<a class='icon-trash'></a> Delete All", 1]
|
|
|
|
];
|
|
|
|
|
|
|
|
contextMenu.show(items, mouse_x, mouse_y, "right");
|
|
|
|
|
|
|
|
},
|
2013-05-03 11:57:08 +00:00
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
photo: function(photoID, e) {
|
2013-05-03 11:57:08 +00:00
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
var mouse_x = e.pageX,
|
2014-01-28 19:44:25 +00:00
|
|
|
mouse_y = e.pageY - $(document).scrollTop(),
|
2013-09-03 09:59:30 +00:00
|
|
|
items;
|
2013-05-03 11:57:08 +00:00
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
contextMenu.fns = [
|
2014-01-28 19:44:25 +00:00
|
|
|
function() { photo.setStar([photoID]) },
|
2014-02-08 20:19:19 +00:00
|
|
|
function() { photo.editTags([photoID]) },
|
2014-01-28 23:43:06 +00:00
|
|
|
function() { photo.setTitle([photoID]) },
|
2014-01-28 19:44:25 +00:00
|
|
|
function() { contextMenu.move([photoID], e, "right") },
|
2014-01-28 23:43:06 +00:00
|
|
|
function() { photo.delete([photoID]) }
|
2013-09-03 09:59:30 +00:00
|
|
|
];
|
|
|
|
|
2013-05-03 11:57:08 +00:00
|
|
|
items = [
|
2013-09-03 09:59:30 +00:00
|
|
|
["<a class='icon-star'></a> Star", 0],
|
2014-02-08 20:19:19 +00:00
|
|
|
["<a class='icon-tags'></a> Tags", 1],
|
2013-09-03 09:59:30 +00:00
|
|
|
["separator", -1],
|
2014-02-08 20:19:19 +00:00
|
|
|
["<a class='icon-edit'></a> Rename", 2],
|
|
|
|
["<a class='icon-folder-open'></a> Move", 3],
|
|
|
|
["<a class='icon-trash'></a> Delete", 4]
|
2013-05-03 11:57:08 +00:00
|
|
|
];
|
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
contextMenu.show(items, mouse_x, mouse_y, "right");
|
|
|
|
|
2013-05-03 11:57:08 +00:00
|
|
|
$(".photo[data-id='" + photoID + "']").addClass("active");
|
|
|
|
|
|
|
|
},
|
2014-02-17 15:22:01 +00:00
|
|
|
|
2014-01-31 19:11:28 +00:00
|
|
|
photoMulti: function(photoIDs, e) {
|
2014-02-17 15:22:01 +00:00
|
|
|
|
2014-01-28 19:44:25 +00:00
|
|
|
var mouse_x = e.pageX,
|
|
|
|
mouse_y = e.pageY - $(document).scrollTop(),
|
|
|
|
items;
|
|
|
|
|
|
|
|
multiselect.stopResize();
|
|
|
|
|
|
|
|
contextMenu.fns = [
|
2014-01-31 19:11:28 +00:00
|
|
|
function() { photo.setStar(photoIDs) },
|
2014-02-08 20:19:19 +00:00
|
|
|
function() { photo.editTags(photoIDs) },
|
2014-01-31 19:11:28 +00:00
|
|
|
function() { photo.setTitle(photoIDs) },
|
|
|
|
function() { contextMenu.move(photoIDs, e, "right") },
|
|
|
|
function() { photo.delete(photoIDs) }
|
2014-01-28 19:44:25 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
items = [
|
|
|
|
["<a class='icon-star'></a> Star All", 0],
|
2014-02-08 20:19:19 +00:00
|
|
|
["<a class='icon-tags'></a> Tag All", 1],
|
2014-01-28 19:44:25 +00:00
|
|
|
["separator", -1],
|
2014-02-08 20:19:19 +00:00
|
|
|
["<a class='icon-edit'></a> Rename All", 2],
|
|
|
|
["<a class='icon-folder-open'></a> Move All", 3],
|
|
|
|
["<a class='icon-trash'></a> Delete All", 4]
|
2014-01-28 19:44:25 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
contextMenu.show(items, mouse_x, mouse_y, "right");
|
|
|
|
|
|
|
|
},
|
2013-05-03 11:57:08 +00:00
|
|
|
|
2014-03-26 21:22:25 +00:00
|
|
|
photoMore: function(photoID, e) {
|
|
|
|
|
|
|
|
var mouse_x = e.pageX,
|
|
|
|
mouse_y = e.pageY - $(document).scrollTop(),
|
|
|
|
items;
|
|
|
|
|
|
|
|
contextMenu.fns = [
|
|
|
|
function() { window.open(photo.getDirectLink(),"_newtab") },
|
|
|
|
function() { photo.getArchive(photoID) }
|
|
|
|
];
|
|
|
|
|
|
|
|
items = [
|
|
|
|
["<a class='icon-resize-full'></a> Full Photo", 0],
|
|
|
|
["<a class='icon-circle-arrow-down'></a> Download", 1]
|
|
|
|
];
|
|
|
|
|
|
|
|
contextMenu.show(items, mouse_x, mouse_y, "right");
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2014-01-31 19:11:28 +00:00
|
|
|
move: function(photoIDs, e, orientation) {
|
2013-05-03 11:57:08 +00:00
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
var mouse_x = e.pageX,
|
2014-01-28 19:44:25 +00:00
|
|
|
mouse_y = e.pageY - $(document).scrollTop(),
|
2014-01-22 10:12:51 +00:00
|
|
|
items = [];
|
2013-09-03 09:59:30 +00:00
|
|
|
|
2014-01-28 19:44:25 +00:00
|
|
|
contextMenu.close(true);
|
2013-06-17 18:40:04 +00:00
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
if (album.getID()!=="0") {
|
2013-09-03 09:59:30 +00:00
|
|
|
items = [
|
2014-01-31 19:11:28 +00:00
|
|
|
["Unsorted", 0, "photo.setAlbum([" + photoIDs + "], 0)"],
|
2013-09-03 09:59:30 +00:00
|
|
|
["separator", -1]
|
|
|
|
];
|
|
|
|
}
|
2013-05-03 11:57:08 +00:00
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
lychee.api("getAlbums", function(data) {
|
2013-05-03 11:57:08 +00:00
|
|
|
|
2014-02-09 21:30:16 +00:00
|
|
|
if (data.num===0) {
|
2013-09-03 09:59:30 +00:00
|
|
|
items = [["New Album", 0, "album.add()"]];
|
2013-05-03 11:57:08 +00:00
|
|
|
} else {
|
2013-09-03 09:59:30 +00:00
|
|
|
$.each(data.content, function(index) {
|
2014-01-31 19:11:28 +00:00
|
|
|
if (this.id!=album.getID()) items.push([this.title, 0, "photo.setAlbum([" + photoIDs + "], " + this.id + ")"]);
|
2013-05-03 11:57:08 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-01-24 12:49:01 +00:00
|
|
|
if (!visible.photo()) contextMenu.show(items, mouse_x, mouse_y, "right");
|
|
|
|
else contextMenu.show(items, mouse_x, mouse_y, "left");
|
2013-05-03 11:57:08 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
sharePhoto: function(photoID, e) {
|
|
|
|
|
|
|
|
var mouse_x = e.pageX,
|
|
|
|
mouse_y = e.pageY,
|
|
|
|
items;
|
2013-05-03 11:57:08 +00:00
|
|
|
|
|
|
|
mouse_y -= $(document).scrollTop();
|
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
contextMenu.fns = [
|
|
|
|
function() { photo.setPublic(photoID) },
|
|
|
|
function() { photo.share(photoID, 0) },
|
|
|
|
function() { photo.share(photoID, 1) },
|
|
|
|
function() { photo.share(photoID, 2) },
|
2014-01-24 12:49:01 +00:00
|
|
|
function() { photo.share(photoID, 3) },
|
|
|
|
function() { window.open(photo.getDirectLink(),"_newtab") }
|
2013-05-03 11:57:08 +00:00
|
|
|
];
|
2014-02-17 15:22:01 +00:00
|
|
|
|
2014-01-24 12:49:01 +00:00
|
|
|
link = photo.getViewLink(photoID);
|
|
|
|
if (photo.json.public==="2") link = location.href;
|
2013-05-03 11:57:08 +00:00
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
items = [
|
2014-01-24 12:49:01 +00:00
|
|
|
["<input readonly id='link' value='" + link + "'>", -1],
|
2014-01-22 10:12:51 +00:00
|
|
|
["separator", -1],
|
|
|
|
["<a class='icon-eye-close'></a> Make Private", 0],
|
|
|
|
["separator", -1],
|
|
|
|
["<a class='icon-twitter'></a> Twitter", 1],
|
|
|
|
["<a class='icon-facebook'></a> Facebook", 2],
|
|
|
|
["<a class='icon-envelope'></a> Mail", 3],
|
2014-01-24 12:49:01 +00:00
|
|
|
["<a class='icon-hdd'></a> Dropbox", 4],
|
|
|
|
["<a class='icon-link'></a> Direct Link", 5]
|
2014-01-22 10:12:51 +00:00
|
|
|
];
|
2013-06-17 18:40:04 +00:00
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
contextMenu.show(items, mouse_x, mouse_y, "left");
|
2014-02-08 21:11:01 +00:00
|
|
|
$(".contextmenu input").focus().select();
|
2013-09-03 09:59:30 +00:00
|
|
|
|
2013-06-17 18:40:04 +00:00
|
|
|
},
|
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
shareAlbum: function(albumID, e) {
|
|
|
|
|
|
|
|
var mouse_x = e.pageX,
|
|
|
|
mouse_y = e.pageY,
|
|
|
|
items;
|
2013-06-17 18:40:04 +00:00
|
|
|
|
|
|
|
mouse_y -= $(document).scrollTop();
|
|
|
|
|
2013-09-03 09:59:30 +00:00
|
|
|
contextMenu.fns = [
|
|
|
|
function() { album.setPublic(albumID) },
|
|
|
|
function() { password.set(albumID) },
|
|
|
|
function() { album.share(0) },
|
|
|
|
function() { album.share(1) },
|
|
|
|
function() { album.share(2) },
|
|
|
|
function() { password.remove(albumID) }
|
2013-06-17 18:40:04 +00:00
|
|
|
];
|
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
items = [
|
|
|
|
["<input readonly id='link' value='" + location.href + "'>", -1],
|
|
|
|
["separator", -1],
|
|
|
|
["<a class='icon-eye-close'></a> Make Private", 0],
|
|
|
|
["<a class='icon-lock'></a> Set Password", 1],
|
|
|
|
["separator", -1],
|
|
|
|
["<a class='icon-twitter'></a> Twitter", 2],
|
|
|
|
["<a class='icon-facebook'></a> Facebook", 3],
|
|
|
|
["<a class='icon-envelope'></a> Mail", 4],
|
|
|
|
];
|
2013-09-03 09:59:30 +00:00
|
|
|
|
|
|
|
if (album.json.password==true) items[3] = ["<a class='icon-unlock'></a> Remove Password", 5];
|
|
|
|
|
2014-01-22 10:12:51 +00:00
|
|
|
contextMenu.show(items, mouse_x, mouse_y, "left");
|
2014-02-08 21:11:01 +00:00
|
|
|
$(".contextmenu input").focus().select();
|
2013-09-03 09:59:30 +00:00
|
|
|
|
2013-05-03 11:57:08 +00:00
|
|
|
},
|
|
|
|
|
2014-01-28 19:44:25 +00:00
|
|
|
close: function(leaveSelection) {
|
2014-02-17 15:22:01 +00:00
|
|
|
|
2014-01-28 19:44:25 +00:00
|
|
|
if (!visible.contextMenu()) return false;
|
2014-02-17 15:22:01 +00:00
|
|
|
|
2014-01-28 19:44:25 +00:00
|
|
|
contextMenu.fns = [];
|
2014-02-17 15:22:01 +00:00
|
|
|
|
2013-05-03 11:57:08 +00:00
|
|
|
$(".contextmenu_bg, .contextmenu").remove();
|
2014-01-27 19:47:40 +00:00
|
|
|
$("body").css("overflow", "auto");
|
2014-02-17 15:22:01 +00:00
|
|
|
|
2014-01-28 19:44:25 +00:00
|
|
|
if (leaveSelection!==true) {
|
|
|
|
$(".photo.active, .album.active").removeClass("active");
|
|
|
|
if (visible.multiselect()) multiselect.close();
|
|
|
|
}
|
2013-05-03 11:57:08 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-02-25 22:37:05 +00:00
|
|
|
};
|