|
|
@ -334,6 +334,29 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var updateContextButton = function () {
|
|
|
|
|
|
|
|
var $li = $content.find('.selected');
|
|
|
|
|
|
|
|
if ($li.length !== 1) {
|
|
|
|
|
|
|
|
$li = $tree.find('.element.active').closest('li');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var $button = $driveToolbar.find('#contextButton');
|
|
|
|
|
|
|
|
if ($li.length !== 1
|
|
|
|
|
|
|
|
|| !$._data($li[0], 'events').contextmenu
|
|
|
|
|
|
|
|
|| $._data($li[0], 'events').contextmenu.length === 0) {
|
|
|
|
|
|
|
|
$button.hide();
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$button.show();
|
|
|
|
|
|
|
|
$button.css({
|
|
|
|
|
|
|
|
background: '#000'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
window.setTimeout(function () {
|
|
|
|
|
|
|
|
$button.css({
|
|
|
|
|
|
|
|
background: ''
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}, 500);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Add the "selected" class to the "li" corresponding to the clicked element
|
|
|
|
// Add the "selected" class to the "li" corresponding to the clicked element
|
|
|
|
var onElementClick = function (e, $element, path) {
|
|
|
|
var onElementClick = function (e, $element, path) {
|
|
|
|
// If "Ctrl" is pressed, do not remove the current selection
|
|
|
|
// If "Ctrl" is pressed, do not remove the current selection
|
|
|
@ -354,14 +377,7 @@ define([
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$element.removeClass("selected");
|
|
|
|
$element.removeClass("selected");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$driveToolbar.find('#contextButton').css({
|
|
|
|
updateContextButton();
|
|
|
|
background: '#000'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
window.setTimeout(function () {
|
|
|
|
|
|
|
|
$driveToolbar.find('#contextButton').css({
|
|
|
|
|
|
|
|
background: ''
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}, 500);
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Open the selected context menu on the closest "li" element
|
|
|
|
// Open the selected context menu on the closest "li" element
|
|
|
@ -408,7 +424,7 @@ define([
|
|
|
|
var openDirectoryContextMenu = function (e) {
|
|
|
|
var openDirectoryContextMenu = function (e) {
|
|
|
|
var $element = $(e.target).closest('li');
|
|
|
|
var $element = $(e.target).closest('li');
|
|
|
|
$contextMenu.find('li').show();
|
|
|
|
$contextMenu.find('li').show();
|
|
|
|
if ($element.find('.file-element').length) {
|
|
|
|
if ($element.is('.file-element')) {
|
|
|
|
$contextMenu.find('a.newfolder').parent('li').hide();
|
|
|
|
$contextMenu.find('a.newfolder').parent('li').hide();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$contextMenu.find('a.open_ro').parent('li').hide();
|
|
|
|
$contextMenu.find('a.open_ro').parent('li').hide();
|
|
|
@ -420,7 +436,7 @@ define([
|
|
|
|
var openDefaultContextMenu = function (e) {
|
|
|
|
var openDefaultContextMenu = function (e) {
|
|
|
|
var $element = $(e.target).closest('li');
|
|
|
|
var $element = $(e.target).closest('li');
|
|
|
|
$defaultContextMenu.find('li').show();
|
|
|
|
$defaultContextMenu.find('li').show();
|
|
|
|
if ($element.find('.file-element').length) {
|
|
|
|
if ($element.is('.file-element')) {
|
|
|
|
$defaultContextMenu.find('a.newfolder').parent('li').hide();
|
|
|
|
$defaultContextMenu.find('a.newfolder').parent('li').hide();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$defaultContextMenu.find('a.open_ro').parent('li').hide();
|
|
|
|
$defaultContextMenu.find('a.open_ro').parent('li').hide();
|
|
|
@ -1215,6 +1231,8 @@ define([
|
|
|
|
var $icon = getFileIcon(file.href);
|
|
|
|
var $icon = getFileIcon(file.href);
|
|
|
|
var $element = $('<li>', { 'class': 'file-element element' });
|
|
|
|
var $element = $('<li>', { 'class': 'file-element element' });
|
|
|
|
addFileData(file.href, file.title, $element, false);
|
|
|
|
addFileData(file.href, file.title, $element, false);
|
|
|
|
|
|
|
|
$element.data('path', [FILES_DATA, allfiles.indexOf(file)]);
|
|
|
|
|
|
|
|
$element.data('element', file.href);
|
|
|
|
$element.prepend($icon).dblclick(function () {
|
|
|
|
$element.prepend($icon).dblclick(function () {
|
|
|
|
openFile(file.href);
|
|
|
|
openFile(file.href);
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -1324,6 +1342,7 @@ define([
|
|
|
|
if (APP.mobile) {
|
|
|
|
if (APP.mobile) {
|
|
|
|
var $context = $('<button>', {'class': 'element right dropdown-bar', id: 'contextButton'});
|
|
|
|
var $context = $('<button>', {'class': 'element right dropdown-bar', id: 'contextButton'});
|
|
|
|
$context.append($('<span>', {'class': 'fa fa-caret-down'}));
|
|
|
|
$context.append($('<span>', {'class': 'fa fa-caret-down'}));
|
|
|
|
|
|
|
|
$context.appendTo($toolbar.find('.rightside'));
|
|
|
|
$context.click(function (e) {
|
|
|
|
$context.click(function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
e.stopPropagation();
|
|
|
@ -1331,14 +1350,20 @@ define([
|
|
|
|
if ($li.length !== 1) {
|
|
|
|
if ($li.length !== 1) {
|
|
|
|
$li = $tree.find('.element.active').closest('li');
|
|
|
|
$li = $tree.find('.element.active').closest('li');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Close if already opened
|
|
|
|
|
|
|
|
if ($iframe.find('.contextMenu:visible').length) {
|
|
|
|
|
|
|
|
module.hideMenu();
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Open the menu
|
|
|
|
$iframe.find('.contextMenu').css({
|
|
|
|
$iframe.find('.contextMenu').css({
|
|
|
|
top: ($li.offset().top + 10) + 'px',
|
|
|
|
top: ($context.offset().top + 32) + 'px',
|
|
|
|
left: ($li.offset().left + 50) + 'px'
|
|
|
|
right: '0px'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$li.contextmenu();
|
|
|
|
$li.contextmenu();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$context.appendTo($toolbar.find('.rightside'));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
updateContextButton();
|
|
|
|
|
|
|
|
|
|
|
|
// NewButton can be undefined if we're in read only mode
|
|
|
|
// NewButton can be undefined if we're in read only mode
|
|
|
|
$toolbar.find('.leftside').append(createNewButton(isInRoot));
|
|
|
|
$toolbar.find('.leftside').append(createNewButton(isInRoot));
|
|
|
@ -1623,7 +1648,10 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($(this).hasClass('open_ro')) {
|
|
|
|
else if ($(this).hasClass('open_ro')) {
|
|
|
|
var el = filesOp.findElement(files, path);
|
|
|
|
var el = filesOp.findElement(files, path);
|
|
|
|
if (filesOp.isFolder(el)) { return; }
|
|
|
|
if (filesOp.isPathInFilesData(path)) {
|
|
|
|
|
|
|
|
el = el.href;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!el || filesOp.isFolder(el)) { return; }
|
|
|
|
var roUrl = getReadOnlyUrl(el);
|
|
|
|
var roUrl = getReadOnlyUrl(el);
|
|
|
|
openFile(roUrl);
|
|
|
|
openFile(roUrl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|