|
|
@ -18,8 +18,6 @@ define([
|
|
|
|
'/bower_components/chainpad-listmap/chainpad-listmap.js',
|
|
|
|
'/bower_components/chainpad-listmap/chainpad-listmap.js',
|
|
|
|
'/customize/messages.js',
|
|
|
|
'/customize/messages.js',
|
|
|
|
|
|
|
|
|
|
|
|
'/common/jscolor.js',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'css!/bower_components/bootstrap/dist/css/bootstrap.min.css',
|
|
|
|
'css!/bower_components/bootstrap/dist/css/bootstrap.min.css',
|
|
|
|
'css!/bower_components/components-font-awesome/css/font-awesome.min.css',
|
|
|
|
'css!/bower_components/components-font-awesome/css/font-awesome.min.css',
|
|
|
|
'less!/drive/app-drive.less',
|
|
|
|
'less!/drive/app-drive.less',
|
|
|
@ -45,7 +43,10 @@ define([
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var APP = window.APP = {
|
|
|
|
var APP = window.APP = {
|
|
|
|
editable: false,
|
|
|
|
editable: false,
|
|
|
|
mobile: function () { return $('body').width() <= 600; }, // Menu and content area are not inline-block anymore for mobiles
|
|
|
|
mobile: function () {
|
|
|
|
|
|
|
|
if (window.matchMedia) { return !window.matchMedia('(any-pointer:fine)').matches; }
|
|
|
|
|
|
|
|
else { return $('body').width() <= 600; }
|
|
|
|
|
|
|
|
},
|
|
|
|
isMac: navigator.platform === "MacIntel",
|
|
|
|
isMac: navigator.platform === "MacIntel",
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -301,6 +302,33 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
APP.selectedFiles = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var isElementSelected = function ($element) {
|
|
|
|
|
|
|
|
var elementId = $element.data("path").slice(-1)[0];
|
|
|
|
|
|
|
|
return APP.selectedFiles.indexOf(elementId) !== -1;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
var selectElement = function ($element) {
|
|
|
|
|
|
|
|
var elementId = $element.data("path").slice(-1)[0];
|
|
|
|
|
|
|
|
if (APP.selectedFiles.indexOf(elementId) === -1) {
|
|
|
|
|
|
|
|
APP.selectedFiles.push(elementId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$element.addClass("cp-app-drive-element-selected");
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
var unselectElement = function ($element) {
|
|
|
|
|
|
|
|
var elementId = $element.data("path").slice(-1)[0];
|
|
|
|
|
|
|
|
var index = APP.selectedFiles.indexOf(elementId);
|
|
|
|
|
|
|
|
if (index !== -1) {
|
|
|
|
|
|
|
|
APP.selectedFiles.splice(index, 1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$element.removeClass("cp-app-drive-element-selected");
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
var findSelectedElements = function () {
|
|
|
|
|
|
|
|
return $(".cp-app-drive-element-selected");
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var createContextMenu = function () {
|
|
|
|
var createContextMenu = function () {
|
|
|
|
var menu = h('div.cp-contextmenu.dropdown.cp-unselectable', [
|
|
|
|
var menu = h('div.cp-contextmenu.dropdown.cp-unselectable', [
|
|
|
|
h('ul.dropdown-menu', {
|
|
|
|
h('ul.dropdown-menu', {
|
|
|
@ -365,16 +393,34 @@ define([
|
|
|
|
'data-icon': AppConfig.applicationsIcon.slide,
|
|
|
|
'data-icon': AppConfig.applicationsIcon.slide,
|
|
|
|
'data-type': 'slide'
|
|
|
|
'data-type': 'slide'
|
|
|
|
}, Messages.button_newslide)),
|
|
|
|
}, Messages.button_newslide)),
|
|
|
|
|
|
|
|
h('li.dropdown-submenu', [
|
|
|
|
|
|
|
|
h('a.cp-app-drive-context-newdocmenu.dropdown-item', {
|
|
|
|
|
|
|
|
'tabindex': '-1',
|
|
|
|
|
|
|
|
'data-icon': "fa-plus",
|
|
|
|
|
|
|
|
}, Messages.fm_morePads || "More pads"), //XXX
|
|
|
|
|
|
|
|
h("ul.dropdown-menu", [
|
|
|
|
h('li', h('a.cp-app-drive-context-newdoc.dropdown-item.cp-app-drive-context-editable', {
|
|
|
|
h('li', h('a.cp-app-drive-context-newdoc.dropdown-item.cp-app-drive-context-editable', {
|
|
|
|
'tabindex': '-1',
|
|
|
|
'tabindex': '-1',
|
|
|
|
'data-icon': AppConfig.applicationsIcon.poll,
|
|
|
|
'data-icon': AppConfig.applicationsIcon.sheet,
|
|
|
|
'data-type': 'poll'
|
|
|
|
'data-type': 'sheet'
|
|
|
|
}, Messages.button_newpoll)),
|
|
|
|
}, Messages.button_newsheet)),
|
|
|
|
h('li', h('a.cp-app-drive-context-newdoc.dropdown-item.cp-app-drive-context-editable', {
|
|
|
|
h('li', h('a.cp-app-drive-context-newdoc.dropdown-item.cp-app-drive-context-editable', {
|
|
|
|
'tabindex': '-1',
|
|
|
|
'tabindex': '-1',
|
|
|
|
'data-icon': AppConfig.applicationsIcon.whiteboard,
|
|
|
|
'data-icon': AppConfig.applicationsIcon.whiteboard,
|
|
|
|
'data-type': 'whiteboard'
|
|
|
|
'data-type': 'whiteboard'
|
|
|
|
}, Messages.button_newwhiteboard)),
|
|
|
|
}, Messages.button_newwhiteboard)),
|
|
|
|
|
|
|
|
h('li', h('a.cp-app-drive-context-newdoc.dropdown-item.cp-app-drive-context-editable', {
|
|
|
|
|
|
|
|
'tabindex': '-1',
|
|
|
|
|
|
|
|
'data-icon': AppConfig.applicationsIcon.kanban,
|
|
|
|
|
|
|
|
'data-type': 'kanban'
|
|
|
|
|
|
|
|
}, Messages.button_newkanban)),
|
|
|
|
|
|
|
|
h('li', h('a.cp-app-drive-context-newdoc.dropdown-item.cp-app-drive-context-editable', {
|
|
|
|
|
|
|
|
'tabindex': '-1',
|
|
|
|
|
|
|
|
'data-icon': AppConfig.applicationsIcon.poll,
|
|
|
|
|
|
|
|
'data-type': 'poll'
|
|
|
|
|
|
|
|
}, Messages.button_newpoll)),
|
|
|
|
|
|
|
|
]),
|
|
|
|
|
|
|
|
]),
|
|
|
|
$separator.clone()[0],
|
|
|
|
$separator.clone()[0],
|
|
|
|
h('li', h('a.cp-app-drive-context-empty.dropdown-item.cp-app-drive-context-editable', {
|
|
|
|
h('li', h('a.cp-app-drive-context-empty.dropdown-item.cp-app-drive-context-editable', {
|
|
|
|
'tabindex': '-1',
|
|
|
|
'tabindex': '-1',
|
|
|
@ -420,6 +466,7 @@ define([
|
|
|
|
}, Messages.fc_remove_sharedfolder)),
|
|
|
|
}, Messages.fc_remove_sharedfolder)),
|
|
|
|
])
|
|
|
|
])
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
|
|
|
|
// add icons to the contextmenu options
|
|
|
|
$(menu).find("li a.dropdown-item").each(function (i, el) {
|
|
|
|
$(menu).find("li a.dropdown-item").each(function (i, el) {
|
|
|
|
var $icon = $("<span>");
|
|
|
|
var $icon = $("<span>");
|
|
|
|
if ($(el).attr('data-icon')) {
|
|
|
|
if ($(el).attr('data-icon')) {
|
|
|
@ -430,21 +477,46 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$(el).prepend($icon);
|
|
|
|
$(el).prepend($icon);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// add events handlers for the contextmenu submenus
|
|
|
|
$(menu).find(".dropdown-submenu").each(function (i, el) {
|
|
|
|
$(menu).find(".dropdown-submenu").each(function (i, el) {
|
|
|
|
var $el = $(el);
|
|
|
|
var $el = $(el);
|
|
|
|
var $a = $el.children().filter("a");
|
|
|
|
var $a = $el.children().filter("a");
|
|
|
|
var $sub = $el.find(".dropdown-menu").first();
|
|
|
|
var $sub = $el.find(".dropdown-menu").first();
|
|
|
|
|
|
|
|
var timeoutId;
|
|
|
|
|
|
|
|
var showSubmenu = function () {
|
|
|
|
|
|
|
|
clearTimeout(timeoutId);
|
|
|
|
|
|
|
|
$sub.toggleClass("left", $el.offset().left + $el.outerWidth() + $sub.outerWidth() > $(window).width());
|
|
|
|
|
|
|
|
$el.siblings().find(".dropdown-menu").hide();
|
|
|
|
|
|
|
|
$sub.show();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
var hideSubmenu = function () {
|
|
|
|
|
|
|
|
$sub.hide();
|
|
|
|
|
|
|
|
$sub.removeClass("left");
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
var mouseOutSubmenu = function () {
|
|
|
|
|
|
|
|
// don't hide immediately the submenu
|
|
|
|
|
|
|
|
timeoutId = setTimeout(hideSubmenu, 100);
|
|
|
|
|
|
|
|
};
|
|
|
|
// Add submenu expand icon
|
|
|
|
// Add submenu expand icon
|
|
|
|
$a.append(h("span.dropdown-toggle"));
|
|
|
|
$a.append(h("span.dropdown-toggle"));
|
|
|
|
// Show / hide submenu
|
|
|
|
// Show / hide submenu
|
|
|
|
$el.hover(function () {
|
|
|
|
$el.hover(function () {
|
|
|
|
setTimeout(function () { // wait for dom to update
|
|
|
|
showSubmenu();
|
|
|
|
$sub.toggleClass("left", $el.offset().left + $el.outerWidth() + $sub.outerWidth() > $(window).width());
|
|
|
|
|
|
|
|
$sub.show();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}, function () {
|
|
|
|
}, function () {
|
|
|
|
$sub.hide();
|
|
|
|
mouseOutSubmenu();
|
|
|
|
$sub.removeClass("left");
|
|
|
|
});
|
|
|
|
|
|
|
|
// handle click event
|
|
|
|
|
|
|
|
$el.click(function (e) {
|
|
|
|
|
|
|
|
var targetItem = $(e.target).closest(".dropdown-item")[0]; // don't close contextmenu if open submenu
|
|
|
|
|
|
|
|
var elTarget = $el.children(".dropdown-item")[0];
|
|
|
|
|
|
|
|
if (targetItem === elTarget) { e.stopPropagation(); }
|
|
|
|
|
|
|
|
if ($el.children().filter(".dropdown-menu:visible").length !== 0) {
|
|
|
|
|
|
|
|
$el.find(".dropdown-menu").hide();
|
|
|
|
|
|
|
|
hideSubmenu();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
showSubmenu();
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return $(menu);
|
|
|
|
return $(menu);
|
|
|
@ -570,7 +642,8 @@ define([
|
|
|
|
var sel = {};
|
|
|
|
var sel = {};
|
|
|
|
|
|
|
|
|
|
|
|
var removeSelected = function (keepObj) {
|
|
|
|
var removeSelected = function (keepObj) {
|
|
|
|
$('.cp-app-drive-element-selected').removeClass("cp-app-drive-element-selected");
|
|
|
|
APP.selectedFiles = [];
|
|
|
|
|
|
|
|
findSelectedElements().removeClass("cp-app-drive-element-selected");
|
|
|
|
var $container = $driveToolbar.find('#cp-app-drive-toolbar-contextbuttons');
|
|
|
|
var $container = $driveToolbar.find('#cp-app-drive-toolbar-contextbuttons');
|
|
|
|
if (!$container.length) { return; }
|
|
|
|
if (!$container.length) { return; }
|
|
|
|
$container.html('');
|
|
|
|
$container.html('');
|
|
|
@ -680,7 +753,9 @@ define([
|
|
|
|
delete sel.move;
|
|
|
|
delete sel.move;
|
|
|
|
$content.find('.cp-app-drive-element-selected-tmp')
|
|
|
|
$content.find('.cp-app-drive-element-selected-tmp')
|
|
|
|
.removeClass('cp-app-drive-element-selected-tmp')
|
|
|
|
.removeClass('cp-app-drive-element-selected-tmp')
|
|
|
|
.addClass('cp-app-drive-element-selected');
|
|
|
|
.each(function (idx, element) {
|
|
|
|
|
|
|
|
selectElement($(element));
|
|
|
|
|
|
|
|
});
|
|
|
|
e.stopPropagation();
|
|
|
|
e.stopPropagation();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -715,7 +790,9 @@ define([
|
|
|
|
// Ctrl+A select all
|
|
|
|
// Ctrl+A select all
|
|
|
|
if (e.which === 65 && (e.ctrlKey || (e.metaKey && APP.isMac))) {
|
|
|
|
if (e.which === 65 && (e.ctrlKey || (e.metaKey && APP.isMac))) {
|
|
|
|
$content.find('.cp-app-drive-element:not(.cp-app-drive-element-selected)')
|
|
|
|
$content.find('.cp-app-drive-element:not(.cp-app-drive-element-selected)')
|
|
|
|
.addClass('cp-app-drive-element-selected');
|
|
|
|
.each(function (idx, element) {
|
|
|
|
|
|
|
|
selectElement($(element));
|
|
|
|
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -728,7 +805,7 @@ define([
|
|
|
|
APP.onElementClick(ev, $(el));
|
|
|
|
APP.onElementClick(ev, $(el));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var $selection = $content.find('.cp-app-drive-element.cp-app-drive-element-selected');
|
|
|
|
var $selection = findSelectedElements();
|
|
|
|
if ($selection.length === 0) { return void click($elements.first()[0]); }
|
|
|
|
if ($selection.length === 0) { return void click($elements.first()[0]); }
|
|
|
|
|
|
|
|
|
|
|
|
var lastIndex = typeof sel.endSelected === "number" ? sel.endSelected :
|
|
|
|
var lastIndex = typeof sel.endSelected === "number" ? sel.endSelected :
|
|
|
@ -847,12 +924,12 @@ define([
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
removeInput();
|
|
|
|
removeInput();
|
|
|
|
removeSelected();
|
|
|
|
|
|
|
|
var $name = $element.find('.cp-app-drive-element-name');
|
|
|
|
var $name = $element.find('.cp-app-drive-element-name');
|
|
|
|
if (!$name.length) {
|
|
|
|
if (!$name.length) {
|
|
|
|
$name = $element.find('> .cp-app-drive-element');
|
|
|
|
$name = $element.find('> .cp-app-drive-element');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$name.hide();
|
|
|
|
$name.hide();
|
|
|
|
|
|
|
|
var isFolder = $element.is(".cp-app-drive-element-folder:not(.cp-app-drive-element-sharedf)");
|
|
|
|
var el = manager.find(path);
|
|
|
|
var el = manager.find(path);
|
|
|
|
var name = manager.isFile(el) ? manager.getTitle(el) : path[path.length - 1];
|
|
|
|
var name = manager.isFile(el) ? manager.getTitle(el) : path[path.length - 1];
|
|
|
|
if (manager.isSharedFolder(el)) {
|
|
|
|
if (manager.isSharedFolder(el)) {
|
|
|
@ -874,14 +951,21 @@ define([
|
|
|
|
var newName = $input.val();
|
|
|
|
var newName = $input.val();
|
|
|
|
if (JSON.stringify(path) === JSON.stringify(currentPath)) {
|
|
|
|
if (JSON.stringify(path) === JSON.stringify(currentPath)) {
|
|
|
|
manager.rename(path, $input.val(), function () {
|
|
|
|
manager.rename(path, $input.val(), function () {
|
|
|
|
|
|
|
|
if (isFolder) {
|
|
|
|
renameFoldersOpened(path, newName);
|
|
|
|
renameFoldersOpened(path, newName);
|
|
|
|
path[path.length - 1] = newName;
|
|
|
|
path[path.length - 1] = newName;
|
|
|
|
|
|
|
|
}
|
|
|
|
APP.displayDirectory(path);
|
|
|
|
APP.displayDirectory(path);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
manager.rename(path, $input.val(), function () {
|
|
|
|
manager.rename(path, $input.val(), function () {
|
|
|
|
|
|
|
|
if (isFolder) {
|
|
|
|
renameFoldersOpened(path, newName);
|
|
|
|
renameFoldersOpened(path, newName);
|
|
|
|
|
|
|
|
unselectElement($element);
|
|
|
|
|
|
|
|
$element.data("path", $element.data("path").slice(0, -1).concat(newName));
|
|
|
|
|
|
|
|
selectElement($element);
|
|
|
|
|
|
|
|
}
|
|
|
|
refresh();
|
|
|
|
refresh();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -902,7 +986,6 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
// We don't want to open the file/folder when clicking on the input
|
|
|
|
// We don't want to open the file/folder when clicking on the input
|
|
|
|
$input.on('click dblclick', function (e) {
|
|
|
|
$input.on('click dblclick', function (e) {
|
|
|
|
removeSelected();
|
|
|
|
|
|
|
|
e.stopPropagation();
|
|
|
|
e.stopPropagation();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
// Remove the browser ability to drag text from the input to avoid
|
|
|
|
// Remove the browser ability to drag text from the input to avoid
|
|
|
@ -1119,8 +1202,9 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
var getSelectedPaths = function ($element) {
|
|
|
|
var getSelectedPaths = function ($element) {
|
|
|
|
var paths = [];
|
|
|
|
var paths = [];
|
|
|
|
if ($('.cp-app-drive-element-selected').length > 1) {
|
|
|
|
if (!$element || $element.length === 0) { return paths; }
|
|
|
|
var $selected = $('.cp-app-drive-element-selected');
|
|
|
|
if (findSelectedElements().length > 1) {
|
|
|
|
|
|
|
|
var $selected = findSelectedElements();
|
|
|
|
$selected.each(function (idx, elmt) {
|
|
|
|
$selected.each(function (idx, elmt) {
|
|
|
|
var ePath = $(elmt).data('path');
|
|
|
|
var ePath = $(elmt).data('path');
|
|
|
|
if (ePath) {
|
|
|
|
if (ePath) {
|
|
|
@ -1149,7 +1233,7 @@ define([
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$driveToolbar.find('cp-app-drive-toolbar-emptytrash').hide();
|
|
|
|
$driveToolbar.find('cp-app-drive-toolbar-emptytrash').hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var $li = $content.find('.cp-app-drive-element-selected');
|
|
|
|
var $li = findSelectedElements();
|
|
|
|
if ($li.length === 0) {
|
|
|
|
if ($li.length === 0) {
|
|
|
|
$li = findDataHolder($tree.find('.cp-app-drive-element-active'));
|
|
|
|
$li = findDataHolder($tree.find('.cp-app-drive-element-active'));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1216,6 +1300,7 @@ define([
|
|
|
|
if (pos+eh <= h && pos >= 0) { return; }
|
|
|
|
if (pos+eh <= h && pos >= 0) { return; }
|
|
|
|
$content.scrollTop(v);
|
|
|
|
$content.scrollTop(v);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 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 = APP.onElementClick = function (e, $element) {
|
|
|
|
var onElementClick = APP.onElementClick = function (e, $element) {
|
|
|
|
// If "Ctrl" is pressed, do not remove the current selection
|
|
|
|
// If "Ctrl" is pressed, do not remove the current selection
|
|
|
@ -1252,34 +1337,33 @@ define([
|
|
|
|
var $el;
|
|
|
|
var $el;
|
|
|
|
removeSelected(true);
|
|
|
|
removeSelected(true);
|
|
|
|
sel.oldSelection.forEach(function (el) {
|
|
|
|
sel.oldSelection.forEach(function (el) {
|
|
|
|
if (!$(el).hasClass("cp-app-drive-element-selected")) {
|
|
|
|
if (!isElementSelected($(el))) {
|
|
|
|
$(el).addClass("cp-app-drive-element-selected");
|
|
|
|
selectElement($(el));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
for (var i = Math.min(sel.startSelected, sel.endSelected);
|
|
|
|
for (var i = Math.min(sel.startSelected, sel.endSelected);
|
|
|
|
i <= Math.max(sel.startSelected, sel.endSelected);
|
|
|
|
i <= Math.max(sel.startSelected, sel.endSelected);
|
|
|
|
i++) {
|
|
|
|
i++) {
|
|
|
|
$el = $($elements.get(i));
|
|
|
|
$el = $($elements.get(i));
|
|
|
|
if (!$el.hasClass("cp-app-drive-element-selected")) {
|
|
|
|
if (!isElementSelected($el)) {
|
|
|
|
$el.addClass("cp-app-drive-element-selected");
|
|
|
|
selectElement($el);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (!$element.hasClass("cp-app-drive-element-selected")) {
|
|
|
|
if (!isElementSelected($element)) {
|
|
|
|
$element.addClass("cp-app-drive-element-selected");
|
|
|
|
selectElement($element);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$element.removeClass("cp-app-drive-element-selected");
|
|
|
|
unselectElement($element);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
updateContextButton();
|
|
|
|
updateContextButton();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var displayMenu = function (e) {
|
|
|
|
// show / hide dropdown separators
|
|
|
|
var $menu = $contextMenu;
|
|
|
|
var hideSeparators = function ($menu) {
|
|
|
|
var showSep = false;
|
|
|
|
var showSep = false;
|
|
|
|
var $lastVisibleSep = null;
|
|
|
|
var $lastVisibleSep = null;
|
|
|
|
// show / hide drop-down divider
|
|
|
|
$menu.children().each(function (i, el) {
|
|
|
|
$menu.find(".dropdown-menu").children().each(function (i, el) {
|
|
|
|
|
|
|
|
var $el = $(el);
|
|
|
|
var $el = $(el);
|
|
|
|
if ($el.is(".dropdown-divider")) {
|
|
|
|
if ($el.is(".dropdown-divider")) {
|
|
|
|
$el.css("display", showSep ? "list-item" : "none");
|
|
|
|
$el.css("display", showSep ? "list-item" : "none");
|
|
|
@ -1291,18 +1375,36 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
if (!showSep && $lastVisibleSep) { $lastVisibleSep.css("display", "none"); } // remove last divider if no options after
|
|
|
|
if (!showSep && $lastVisibleSep) { $lastVisibleSep.css("display", "none"); } // remove last divider if no options after
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// prepare and display contextmenu
|
|
|
|
|
|
|
|
var displayMenu = function (e) {
|
|
|
|
|
|
|
|
var $menu = $contextMenu;
|
|
|
|
// show / hide submenus
|
|
|
|
// show / hide submenus
|
|
|
|
$menu.find(".dropdown-submenu").each(function (i, el) {
|
|
|
|
$menu.find(".dropdown-submenu").each(function (i, el) {
|
|
|
|
var $el = $(el);
|
|
|
|
var $el = $(el);
|
|
|
|
|
|
|
|
$el.children(".dropdown-menu").css("display", "none");
|
|
|
|
$el.find("li").each(function (i, li) {
|
|
|
|
$el.find("li").each(function (i, li) {
|
|
|
|
if ($(li).css("display") !== "none") {
|
|
|
|
if ($(li).css("display") !== "none") {
|
|
|
|
$(el).css("display", "block");
|
|
|
|
$el.css("display", "block");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// show / hide separators
|
|
|
|
|
|
|
|
$menu.find(".dropdown-menu").each(function (i, menu) {
|
|
|
|
|
|
|
|
hideSeparators($(menu));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
// show contextmenu at cursor position
|
|
|
|
$menu.css({ display: "block" });
|
|
|
|
$menu.css({ display: "block" });
|
|
|
|
if (APP.mobile()) { return; }
|
|
|
|
if (APP.mobile()) {
|
|
|
|
|
|
|
|
$menu.css({
|
|
|
|
|
|
|
|
top: ($("#cp-app-drive-toolbar-context-mobile").offset().top + 32) + 'px',
|
|
|
|
|
|
|
|
right: '0px',
|
|
|
|
|
|
|
|
left: ''
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
var h = $menu.outerHeight();
|
|
|
|
var h = $menu.outerHeight();
|
|
|
|
var w = $menu.outerWidth();
|
|
|
|
var w = $menu.outerWidth();
|
|
|
|
var wH = window.innerHeight;
|
|
|
|
var wH = window.innerHeight;
|
|
|
@ -1355,6 +1457,17 @@ define([
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
var $element = findDataHolder($(e.target));
|
|
|
|
var $element = findDataHolder($(e.target));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if clicked from tree
|
|
|
|
|
|
|
|
var fromTree = $element.closest("#cp-app-drive-tree").length;
|
|
|
|
|
|
|
|
if (fromTree) {
|
|
|
|
|
|
|
|
removeSelected();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if clicked on non selected element
|
|
|
|
|
|
|
|
if (!isElementSelected($element)) {
|
|
|
|
|
|
|
|
removeSelected();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (type === 'trash' && !$element.data('path')) { return; }
|
|
|
|
if (type === 'trash' && !$element.data('path')) { return; }
|
|
|
|
|
|
|
|
|
|
|
|
if (!$element.length) {
|
|
|
|
if (!$element.length) {
|
|
|
@ -1363,8 +1476,8 @@ define([
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!$element.hasClass('cp-app-drive-element-selected')) {
|
|
|
|
if (!isElementSelected($element)) {
|
|
|
|
onElementClick(undefined, $element);
|
|
|
|
selectElement($element);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
paths = getSelectedPaths($element);
|
|
|
|
paths = getSelectedPaths($element);
|
|
|
@ -1434,6 +1547,7 @@ define([
|
|
|
|
if (!res) { return; }
|
|
|
|
if (!res) { return; }
|
|
|
|
manager.delete(pathsList, function () {
|
|
|
|
manager.delete(pathsList, function () {
|
|
|
|
pathsList.forEach(removeFoldersOpened);
|
|
|
|
pathsList.forEach(removeFoldersOpened);
|
|
|
|
|
|
|
|
removeSelected();
|
|
|
|
refresh();
|
|
|
|
refresh();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}, null, true);
|
|
|
|
}, null, true);
|
|
|
@ -1444,7 +1558,7 @@ define([
|
|
|
|
var paths = [];
|
|
|
|
var paths = [];
|
|
|
|
var $element = findDataHolder($(ev.target));
|
|
|
|
var $element = findDataHolder($(ev.target));
|
|
|
|
if ($element.hasClass('cp-app-drive-element-selected')) {
|
|
|
|
if ($element.hasClass('cp-app-drive-element-selected')) {
|
|
|
|
var $selected = $('.cp-app-drive-element-selected');
|
|
|
|
var $selected = findSelectedElements();
|
|
|
|
$selected.each(function (idx, elmt) {
|
|
|
|
$selected.each(function (idx, elmt) {
|
|
|
|
var ePath = $(elmt).data('path');
|
|
|
|
var ePath = $(elmt).data('path');
|
|
|
|
if (ePath) {
|
|
|
|
if (ePath) {
|
|
|
@ -1461,7 +1575,7 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
removeSelected();
|
|
|
|
removeSelected();
|
|
|
|
$element.addClass('cp-app-drive-element-selected');
|
|
|
|
selectElement($element);
|
|
|
|
var val = manager.find(path);
|
|
|
|
var val = manager.find(path);
|
|
|
|
if (!val) { return; } // The element is not in the object
|
|
|
|
if (!val) { return; } // The element is not in the object
|
|
|
|
paths = [{
|
|
|
|
paths = [{
|
|
|
@ -1480,7 +1594,13 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
var findDropPath = function (target) {
|
|
|
|
var findDropPath = function (target) {
|
|
|
|
var $target = $(target);
|
|
|
|
var $target = $(target);
|
|
|
|
var $el = findDataHolder($target);
|
|
|
|
var $el;
|
|
|
|
|
|
|
|
if ($target.is(".cp-app-drive-path-element")) {
|
|
|
|
|
|
|
|
$el = $target;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
$el = findDataHolder($target);
|
|
|
|
|
|
|
|
}
|
|
|
|
var newPath = $el.data('path');
|
|
|
|
var newPath = $el.data('path');
|
|
|
|
var dropEl = newPath && manager.find(newPath);
|
|
|
|
var dropEl = newPath && manager.find(newPath);
|
|
|
|
if (newPath && manager.isSharedFolder(dropEl)) {
|
|
|
|
if (newPath && manager.isSharedFolder(dropEl)) {
|
|
|
@ -1608,7 +1728,8 @@ define([
|
|
|
|
$owner.attr('title', Messages.fm_padIsOwnedOther);
|
|
|
|
$owner.attr('title', Messages.fm_padIsOwnedOther);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
var addFileData = function (element, $span) {
|
|
|
|
var thumbsUrls = {};
|
|
|
|
|
|
|
|
var addFileData = function (element, $element) {
|
|
|
|
if (!manager.isFile(element)) { return; }
|
|
|
|
if (!manager.isFile(element)) { return; }
|
|
|
|
|
|
|
|
|
|
|
|
var data = manager.getFileData(element);
|
|
|
|
var data = manager.getFileData(element);
|
|
|
@ -1617,7 +1738,7 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
var hrefData = Hash.parsePadUrl(href);
|
|
|
|
var hrefData = Hash.parsePadUrl(href);
|
|
|
|
if (hrefData.type) {
|
|
|
|
if (hrefData.type) {
|
|
|
|
$span.addClass('cp-border-color-'+hrefData.type);
|
|
|
|
$element.addClass('cp-border-color-'+hrefData.type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var $state = $('<span>', {'class': 'cp-app-drive-element-state'});
|
|
|
|
var $state = $('<span>', {'class': 'cp-app-drive-element-state'});
|
|
|
@ -1637,25 +1758,38 @@ define([
|
|
|
|
var $expire = $expirableIcon.clone().appendTo($state);
|
|
|
|
var $expire = $expirableIcon.clone().appendTo($state);
|
|
|
|
$expire.attr('title', Messages._getKey('fm_expirablePad', [new Date(data.expire).toLocaleString()]));
|
|
|
|
$expire.attr('title', Messages._getKey('fm_expirablePad', [new Date(data.expire).toLocaleString()]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_addOwnership($span, $state, data);
|
|
|
|
_addOwnership($element, $state, data);
|
|
|
|
|
|
|
|
|
|
|
|
var name = manager.getTitle(element);
|
|
|
|
var name = manager.getTitle(element);
|
|
|
|
|
|
|
|
|
|
|
|
// The element with the class '.name' is underlined when the 'li' is hovered
|
|
|
|
// The element with the class '.name' is underlined when the 'li' is hovered
|
|
|
|
var $name = $('<span>', {'class': 'cp-app-drive-element-name'}).text(name);
|
|
|
|
var $name = $('<span>', {'class': 'cp-app-drive-element-name'}).text(name);
|
|
|
|
$span.append($name);
|
|
|
|
$element.append($name);
|
|
|
|
$span.append($state);
|
|
|
|
$element.append($state);
|
|
|
|
$span.attr('title', name);
|
|
|
|
$element.attr('title', name);
|
|
|
|
|
|
|
|
|
|
|
|
var type = Messages.type[hrefData.type] || hrefData.type;
|
|
|
|
// display the thumbnail
|
|
|
|
common.displayThumbnail(href || data.roHref, data.channel, data.password, $span, function ($thumb) {
|
|
|
|
// if the thumbnail has already been displayed once, do not reload it, keep the same url
|
|
|
|
|
|
|
|
if (thumbsUrls[element]) {
|
|
|
|
|
|
|
|
var img = new Image();
|
|
|
|
|
|
|
|
img.src = thumbsUrls[element];
|
|
|
|
|
|
|
|
$element.find('.cp-icon').addClass('cp-app-drive-element-list');
|
|
|
|
|
|
|
|
$element.prepend(img);
|
|
|
|
|
|
|
|
$(img).addClass('cp-app-drive-element-grid cp-app-drive-element-thumbnail');
|
|
|
|
|
|
|
|
$(img).attr("draggable", false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
common.displayThumbnail(href || data.roHref, data.channel, data.password, $element, function ($thumb) {
|
|
|
|
// Called only if the thumbnail exists
|
|
|
|
// Called only if the thumbnail exists
|
|
|
|
// Remove the .hide() added by displayThumnail() because it hides the icon in
|
|
|
|
// Remove the .hide() added by displayThumnail() because it hides the icon in list mode too
|
|
|
|
// list mode too
|
|
|
|
$element.find('.cp-icon').removeAttr('style').addClass('cp-app-drive-element-list');
|
|
|
|
$span.find('.cp-icon').removeAttr('style').addClass('cp-app-drive-element-list');
|
|
|
|
$thumb.addClass('cp-app-drive-element-grid cp-app-drive-element-thumbnail');
|
|
|
|
$thumb.addClass('cp-app-drive-element-grid')
|
|
|
|
$thumb.attr("draggable", false);
|
|
|
|
.addClass('cp-app-drive-element-thumbnail');
|
|
|
|
thumbsUrls[element] = $thumb[0].src;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var type = Messages.type[hrefData.type] || hrefData.type;
|
|
|
|
var $type = $('<span>', {
|
|
|
|
var $type = $('<span>', {
|
|
|
|
'class': 'cp-app-drive-element-type cp-app-drive-element-list'
|
|
|
|
'class': 'cp-app-drive-element-type cp-app-drive-element-list'
|
|
|
|
}).text(type);
|
|
|
|
}).text(type);
|
|
|
@ -1665,7 +1799,7 @@ define([
|
|
|
|
var $cdate = $('<span>', {
|
|
|
|
var $cdate = $('<span>', {
|
|
|
|
'class': 'cp-app-drive-element-ctime cp-app-drive-element-list'
|
|
|
|
'class': 'cp-app-drive-element-ctime cp-app-drive-element-list'
|
|
|
|
}).text(getDate(data.ctime));
|
|
|
|
}).text(getDate(data.ctime));
|
|
|
|
$span.append($type).append($adate).append($cdate);
|
|
|
|
$element.append($type).append($adate).append($cdate);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var addFolderData = function (element, key, $span) {
|
|
|
|
var addFolderData = function (element, key, $span) {
|
|
|
@ -1741,12 +1875,9 @@ define([
|
|
|
|
draggable: true,
|
|
|
|
draggable: true,
|
|
|
|
'class': 'cp-app-drive-element-row'
|
|
|
|
'class': 'cp-app-drive-element-row'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
if (!isFolder && Array.isArray(APP.selectedFiles)) {
|
|
|
|
$element.data('path', newPath);
|
|
|
|
var idx = APP.selectedFiles.indexOf(element);
|
|
|
|
if (isElementSelected($element)) {
|
|
|
|
if (idx !== -1) {
|
|
|
|
selectElement($element);
|
|
|
|
$element.addClass('cp-app-drive-element-selected');
|
|
|
|
|
|
|
|
APP.selectedFiles.splice(idx, 1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$element.prepend($icon).dblclick(function () {
|
|
|
|
$element.prepend($icon).dblclick(function () {
|
|
|
|
if (isFolder) {
|
|
|
|
if (isFolder) {
|
|
|
@ -1762,11 +1893,10 @@ define([
|
|
|
|
addFileData(element, $element);
|
|
|
|
addFileData(element, $element);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$element.addClass(liClass);
|
|
|
|
$element.addClass(liClass);
|
|
|
|
$element.data('path', newPath);
|
|
|
|
|
|
|
|
addDragAndDropHandlers($element, newPath, isFolder, !isTrash);
|
|
|
|
addDragAndDropHandlers($element, newPath, isFolder, !isTrash);
|
|
|
|
$element.click(function(e) {
|
|
|
|
$element.click(function(e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
e.stopPropagation();
|
|
|
|
onElementClick(e, $element, newPath);
|
|
|
|
onElementClick(e, $element);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
if (!isTrash) {
|
|
|
|
if (!isTrash) {
|
|
|
|
$element.contextmenu(openContextMenu('tree'));
|
|
|
|
$element.contextmenu(openContextMenu('tree'));
|
|
|
@ -1917,6 +2047,8 @@ define([
|
|
|
|
} else if (idx > 0 && manager.isFile(el)) {
|
|
|
|
} else if (idx > 0 && manager.isFile(el)) {
|
|
|
|
name = getElementName(path);
|
|
|
|
name = getElementName(path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$span.data("path", path.slice(0, idx + 1));
|
|
|
|
|
|
|
|
addDragAndDropHandlers($span, path.slice(0, idx), true, true);
|
|
|
|
|
|
|
|
|
|
|
|
if (idx === 0) { name = p === SHARED_FOLDER ? name : getPrettyName(p); }
|
|
|
|
if (idx === 0) { name = p === SHARED_FOLDER ? name : getPrettyName(p); }
|
|
|
|
else {
|
|
|
|
else {
|
|
|
@ -2561,22 +2693,19 @@ define([
|
|
|
|
'class': 'cp-app-drive-element cp-app-drive-element-file cp-app-drive-element-row' + roClass,
|
|
|
|
'class': 'cp-app-drive-element cp-app-drive-element-file cp-app-drive-element-row' + roClass,
|
|
|
|
draggable: draggable
|
|
|
|
draggable: draggable
|
|
|
|
});
|
|
|
|
});
|
|
|
|
if (Array.isArray(APP.selectedFiles)) {
|
|
|
|
|
|
|
|
var sidx = APP.selectedFiles.indexOf(id);
|
|
|
|
var path = [rootName, idx];
|
|
|
|
if (sidx !== -1) {
|
|
|
|
$element.data('path', path);
|
|
|
|
$element.addClass('cp-app-drive-element-selected');
|
|
|
|
if (isElementSelected($element)) {
|
|
|
|
APP.selectedFiles.splice(sidx, 1);
|
|
|
|
selectElement($element);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$element.prepend($icon).dblclick(function () {
|
|
|
|
$element.prepend($icon).dblclick(function () {
|
|
|
|
openFile(id);
|
|
|
|
openFile(id);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
addFileData(id, $element);
|
|
|
|
addFileData(id, $element);
|
|
|
|
var path = [rootName, idx];
|
|
|
|
|
|
|
|
$element.data('path', path);
|
|
|
|
|
|
|
|
$element.click(function(e) {
|
|
|
|
$element.click(function(e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
e.stopPropagation();
|
|
|
|
onElementClick(e, $element, path);
|
|
|
|
onElementClick(e, $element);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$element.contextmenu(openContextMenu('default'));
|
|
|
|
$element.contextmenu(openContextMenu('default'));
|
|
|
|
$element.data('context', 'default');
|
|
|
|
$element.data('context', 'default');
|
|
|
@ -2703,8 +2832,8 @@ define([
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
if (manager.isInTrashRoot(parentPath)) { parentPath = [TRASH]; }
|
|
|
|
if (manager.isInTrashRoot(parentPath)) { parentPath = [TRASH]; }
|
|
|
|
else { parentPath.pop(); }
|
|
|
|
else { parentPath.pop(); }
|
|
|
|
APP.selectedFiles = [r.id];
|
|
|
|
|
|
|
|
APP.displayDirectory(parentPath);
|
|
|
|
APP.displayDirectory(parentPath);
|
|
|
|
|
|
|
|
APP.selectedFiles = path.slice(-1);
|
|
|
|
}).appendTo($openDir);
|
|
|
|
}).appendTo($openDir);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$('<a>').text(Messages.fc_prop).click(function () {
|
|
|
|
$('<a>').text(Messages.fc_prop).click(function () {
|
|
|
@ -2795,7 +2924,7 @@ define([
|
|
|
|
$element.data('path', path);
|
|
|
|
$element.data('path', path);
|
|
|
|
$element.click(function(e) {
|
|
|
|
$element.click(function(e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
e.stopPropagation();
|
|
|
|
onElementClick(e, $element, path);
|
|
|
|
onElementClick(e, $element);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$element.contextmenu(openContextMenu('default'));
|
|
|
|
$element.contextmenu(openContextMenu('default'));
|
|
|
|
$element.data('context', 'default');
|
|
|
|
$element.data('context', 'default');
|
|
|
@ -3019,7 +3148,7 @@ define([
|
|
|
|
$context.click(function (e) {
|
|
|
|
$context.click(function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
e.stopPropagation();
|
|
|
|
var $li = $content.find('.cp-app-drive-element-selected');
|
|
|
|
var $li = findSelectedElements();
|
|
|
|
if ($li.length !== 1) {
|
|
|
|
if ($li.length !== 1) {
|
|
|
|
$li = findDataHolder($tree.find('.cp-app-drive-element-active'));
|
|
|
|
$li = findDataHolder($tree.find('.cp-app-drive-element-active'));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -3029,11 +3158,6 @@ define([
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Open the menu
|
|
|
|
// Open the menu
|
|
|
|
$('.cp-contextmenu').css({
|
|
|
|
|
|
|
|
top: ($context.offset().top + 32) + 'px',
|
|
|
|
|
|
|
|
right: '0px',
|
|
|
|
|
|
|
|
left: ''
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$li.contextmenu();
|
|
|
|
$li.contextmenu();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -3101,7 +3225,7 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});*/
|
|
|
|
});*/
|
|
|
|
|
|
|
|
|
|
|
|
var $sel = $content.find('.cp-app-drive-element-selected');
|
|
|
|
var $sel = findSelectedElements();
|
|
|
|
if ($sel.length) {
|
|
|
|
if ($sel.length) {
|
|
|
|
$sel[0].scrollIntoView();
|
|
|
|
$sel[0].scrollIntoView();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -3113,6 +3237,9 @@ define([
|
|
|
|
if (history.isHistoryMode) {
|
|
|
|
if (history.isHistoryMode) {
|
|
|
|
return void _displayDirectory(path, force);
|
|
|
|
return void _displayDirectory(path, force);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!manager.comparePath(currentPath, path)) {
|
|
|
|
|
|
|
|
removeSelected();
|
|
|
|
|
|
|
|
}
|
|
|
|
updateObject(sframeChan, proxy, function () {
|
|
|
|
updateObject(sframeChan, proxy, function () {
|
|
|
|
copyObjectValue(files, proxy.drive);
|
|
|
|
copyObjectValue(files, proxy.drive);
|
|
|
|
updateSharedFolders(sframeChan, manager, files, folders, function () {
|
|
|
|
updateSharedFolders(sframeChan, manager, files, folders, function () {
|
|
|
@ -3463,6 +3590,7 @@ define([
|
|
|
|
if (!res) { return; }
|
|
|
|
if (!res) { return; }
|
|
|
|
manager.delete(pathsList, function () {
|
|
|
|
manager.delete(pathsList, function () {
|
|
|
|
pathsList.forEach(removeFoldersOpened);
|
|
|
|
pathsList.forEach(removeFoldersOpened);
|
|
|
|
|
|
|
|
removeSelected();
|
|
|
|
refresh();
|
|
|
|
refresh();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -3495,6 +3623,7 @@ define([
|
|
|
|
var paths = $contextMenu.data('paths');
|
|
|
|
var paths = $contextMenu.data('paths');
|
|
|
|
var pathsList = [];
|
|
|
|
var pathsList = [];
|
|
|
|
var type = $contextMenu.attr('data-menu-type');
|
|
|
|
var type = $contextMenu.attr('data-menu-type');
|
|
|
|
|
|
|
|
var $this = $(this);
|
|
|
|
|
|
|
|
|
|
|
|
var el, data;
|
|
|
|
var el, data;
|
|
|
|
if (paths.length === 0) {
|
|
|
|
if (paths.length === 0) {
|
|
|
@ -3503,11 +3632,11 @@ define([
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($(this).hasClass("cp-app-drive-context-rename")) {
|
|
|
|
if ($this.hasClass("cp-app-drive-context-rename")) {
|
|
|
|
if (paths.length !== 1) { return; }
|
|
|
|
if (paths.length !== 1) { return; }
|
|
|
|
displayRenameInput(paths[0].element, paths[0].path);
|
|
|
|
displayRenameInput(paths[0].element, paths[0].path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($(this).hasClass("cp-app-drive-context-color")) {
|
|
|
|
else if ($this.hasClass("cp-app-drive-context-color")) {
|
|
|
|
var currentColor = getFolderColor(paths[0].path);
|
|
|
|
var currentColor = getFolderColor(paths[0].path);
|
|
|
|
pickFolderColor(paths[0].element, currentColor, function (color) {
|
|
|
|
pickFolderColor(paths[0].element, currentColor, function (color) {
|
|
|
|
paths.forEach(function (p) {
|
|
|
|
paths.forEach(function (p) {
|
|
|
@ -3516,24 +3645,24 @@ define([
|
|
|
|
refresh();
|
|
|
|
refresh();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if($(this).hasClass("cp-app-drive-context-delete")) {
|
|
|
|
else if($this.hasClass("cp-app-drive-context-delete")) {
|
|
|
|
if (!APP.loggedIn) {
|
|
|
|
if (!APP.loggedIn) {
|
|
|
|
return void deletePaths(paths);
|
|
|
|
return void deletePaths(paths);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
paths.forEach(function (p) { pathsList.push(p.path); });
|
|
|
|
paths.forEach(function (p) { pathsList.push(p.path); });
|
|
|
|
moveElements(pathsList, [TRASH], false, refresh);
|
|
|
|
moveElements(pathsList, [TRASH], false, refresh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($(this).hasClass('cp-app-drive-context-deleteowned')) {
|
|
|
|
else if ($this.hasClass('cp-app-drive-context-deleteowned')) {
|
|
|
|
deleteOwnedPaths(paths);
|
|
|
|
deleteOwnedPaths(paths);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($(this).hasClass('cp-app-drive-context-open')) {
|
|
|
|
else if ($this.hasClass('cp-app-drive-context-open')) {
|
|
|
|
paths.forEach(function (p) {
|
|
|
|
paths.forEach(function (p) {
|
|
|
|
var $element = p.element;
|
|
|
|
var $element = p.element;
|
|
|
|
$element.click();
|
|
|
|
$element.click();
|
|
|
|
$element.dblclick();
|
|
|
|
$element.dblclick();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($(this).hasClass('cp-app-drive-context-openro')) {
|
|
|
|
else if ($this.hasClass('cp-app-drive-context-openro')) {
|
|
|
|
paths.forEach(function (p) {
|
|
|
|
paths.forEach(function (p) {
|
|
|
|
var el = manager.find(p.path);
|
|
|
|
var el = manager.find(p.path);
|
|
|
|
if (paths[0].path[0] === SHARED_FOLDER && APP.newSharedFolder) {
|
|
|
|
if (paths[0].path[0] === SHARED_FOLDER && APP.newSharedFolder) {
|
|
|
@ -3551,10 +3680,10 @@ define([
|
|
|
|
openFile(null, href);
|
|
|
|
openFile(null, href);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($(this).hasClass('cp-app-drive-context-expandall') ||
|
|
|
|
else if ($this.hasClass('cp-app-drive-context-expandall') ||
|
|
|
|
$(this).hasClass('cp-app-drive-context-collapseall')) {
|
|
|
|
$this.hasClass('cp-app-drive-context-collapseall')) {
|
|
|
|
if (paths.length !== 1) { return; }
|
|
|
|
if (paths.length !== 1) { return; }
|
|
|
|
var opened = $(this).hasClass('cp-app-drive-context-expandall');
|
|
|
|
var opened = $this.hasClass('cp-app-drive-context-expandall');
|
|
|
|
var openRecursive = function (path) {
|
|
|
|
var openRecursive = function (path) {
|
|
|
|
setFolderOpened(path, opened);
|
|
|
|
setFolderOpened(path, opened);
|
|
|
|
var folderContent = manager.find(path);
|
|
|
|
var folderContent = manager.find(path);
|
|
|
@ -3577,8 +3706,8 @@ define([
|
|
|
|
openRecursive(paths[0].path);
|
|
|
|
openRecursive(paths[0].path);
|
|
|
|
refresh();
|
|
|
|
refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($(this).hasClass('cp-app-drive-context-download')) {
|
|
|
|
|
|
|
|
console.error('DOWNLOAD');
|
|
|
|
else if ($this.hasClass('cp-app-drive-context-download')) {
|
|
|
|
if (paths.length !== 1) { return; }
|
|
|
|
if (paths.length !== 1) { return; }
|
|
|
|
var path = paths[0];
|
|
|
|
var path = paths[0];
|
|
|
|
el = manager.find(path.path);
|
|
|
|
el = manager.find(path.path);
|
|
|
@ -3627,7 +3756,7 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($(this).hasClass('cp-app-drive-context-share')) {
|
|
|
|
else if ($this.hasClass('cp-app-drive-context-share')) {
|
|
|
|
if (paths.length !== 1) { return; }
|
|
|
|
if (paths.length !== 1) { return; }
|
|
|
|
el = manager.find(paths[0].path);
|
|
|
|
el = manager.find(paths[0].path);
|
|
|
|
var parsed, modal;
|
|
|
|
var parsed, modal;
|
|
|
@ -3678,7 +3807,7 @@ define([
|
|
|
|
wide: Object.keys(friends).length !== 0
|
|
|
|
wide: Object.keys(friends).length !== 0
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($(this).hasClass('cp-app-drive-context-newfolder')) {
|
|
|
|
else if ($this.hasClass('cp-app-drive-context-newfolder')) {
|
|
|
|
if (paths.length !== 1) { return; }
|
|
|
|
if (paths.length !== 1) { return; }
|
|
|
|
var onFolderCreated = function (err, info) {
|
|
|
|
var onFolderCreated = function (err, info) {
|
|
|
|
if (err) { return void logError(err); }
|
|
|
|
if (err) { return void logError(err); }
|
|
|
@ -3691,21 +3820,21 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
manager.addFolder(paths[0].path, null, onFolderCreated);
|
|
|
|
manager.addFolder(paths[0].path, null, onFolderCreated);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($(this).hasClass('cp-app-drive-context-newsharedfolder')) {
|
|
|
|
else if ($this.hasClass('cp-app-drive-context-newsharedfolder')) {
|
|
|
|
if (paths.length !== 1) { return; }
|
|
|
|
if (paths.length !== 1) { return; }
|
|
|
|
addSharedFolderModal(function (obj) {
|
|
|
|
addSharedFolderModal(function (obj) {
|
|
|
|
if (!obj) { return; }
|
|
|
|
if (!obj) { return; }
|
|
|
|
manager.addSharedFolder(paths[0].path, obj, refresh);
|
|
|
|
manager.addSharedFolder(paths[0].path, obj, refresh);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($(this).hasClass("cp-app-drive-context-newdoc")) {
|
|
|
|
else if ($this.hasClass("cp-app-drive-context-newdoc")) {
|
|
|
|
var ntype = $(this).data('type') || 'pad';
|
|
|
|
var ntype = $this.data('type') || 'pad';
|
|
|
|
var path2 = manager.isPathIn(currentPath, [TRASH]) ? '' : currentPath;
|
|
|
|
var path2 = manager.isPathIn(currentPath, [TRASH]) ? '' : currentPath;
|
|
|
|
common.sessionStorage.put(Constants.newPadPathKey, path2, function () {
|
|
|
|
common.sessionStorage.put(Constants.newPadPathKey, path2, function () {
|
|
|
|
common.openURL('/' + ntype + '/');
|
|
|
|
common.openURL('/' + ntype + '/');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($(this).hasClass("cp-app-drive-context-properties")) {
|
|
|
|
else if ($this.hasClass("cp-app-drive-context-properties")) {
|
|
|
|
if (type === 'trash') {
|
|
|
|
if (type === 'trash') {
|
|
|
|
var pPath = paths[0].path;
|
|
|
|
var pPath = paths[0].path;
|
|
|
|
if (paths.length !== 1 || pPath.length !== 4) { return; }
|
|
|
|
if (paths.length !== 1 || pPath.length !== 4) { return; }
|
|
|
@ -3725,7 +3854,7 @@ define([
|
|
|
|
UI.alert($prop[0], undefined, true);
|
|
|
|
UI.alert($prop[0], undefined, true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($(this).hasClass("cp-app-drive-context-hashtag")) {
|
|
|
|
else if ($this.hasClass("cp-app-drive-context-hashtag")) {
|
|
|
|
if (paths.length !== 1) { return; }
|
|
|
|
if (paths.length !== 1) { return; }
|
|
|
|
el = manager.find(paths[0].path);
|
|
|
|
el = manager.find(paths[0].path);
|
|
|
|
data = manager.getFileData(el);
|
|
|
|
data = manager.getFileData(el);
|
|
|
@ -3733,7 +3862,7 @@ define([
|
|
|
|
var href = data.href || data.roHref;
|
|
|
|
var href = data.href || data.roHref;
|
|
|
|
common.updateTags(href);
|
|
|
|
common.updateTags(href);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($(this).hasClass("cp-app-drive-context-empty")) {
|
|
|
|
else if ($this.hasClass("cp-app-drive-context-empty")) {
|
|
|
|
if (paths.length !== 1 || !paths[0].element
|
|
|
|
if (paths.length !== 1 || !paths[0].element
|
|
|
|
|| !manager.comparePath(paths[0].path, [TRASH])) {
|
|
|
|
|| !manager.comparePath(paths[0].path, [TRASH])) {
|
|
|
|
log(Messages.fm_forbidden);
|
|
|
|
log(Messages.fm_forbidden);
|
|
|
@ -3744,13 +3873,13 @@ define([
|
|
|
|
manager.emptyTrash(refresh);
|
|
|
|
manager.emptyTrash(refresh);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($(this).hasClass("cp-app-drive-context-remove")) {
|
|
|
|
else if ($this.hasClass("cp-app-drive-context-remove")) {
|
|
|
|
return void deletePaths(paths);
|
|
|
|
return void deletePaths(paths);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($(this).hasClass("cp-app-drive-context-removesf")) {
|
|
|
|
else if ($this.hasClass("cp-app-drive-context-removesf")) {
|
|
|
|
return void deletePaths(paths);
|
|
|
|
return void deletePaths(paths);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($(this).hasClass("cp-app-drive-context-restore")) {
|
|
|
|
else if ($this.hasClass("cp-app-drive-context-restore")) {
|
|
|
|
if (paths.length !== 1) { return; }
|
|
|
|
if (paths.length !== 1) { return; }
|
|
|
|
var restorePath = paths[0].path;
|
|
|
|
var restorePath = paths[0].path;
|
|
|
|
var restoreName = paths[0].path[paths[0].path.length - 1];
|
|
|
|
var restoreName = paths[0].path[paths[0].path.length - 1];
|
|
|
@ -3767,21 +3896,20 @@ define([
|
|
|
|
manager.restore(restorePath, refresh);
|
|
|
|
manager.restore(restorePath, refresh);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($(this).hasClass("cp-app-drive-context-openparent")) {
|
|
|
|
else if ($this.hasClass("cp-app-drive-context-openparent")) {
|
|
|
|
if (paths.length !== 1) { return; }
|
|
|
|
if (paths.length !== 1) { return; }
|
|
|
|
var parentPath = paths[0].path.slice();
|
|
|
|
var parentPath = paths[0].path.slice();
|
|
|
|
if (manager.isInTrashRoot(parentPath)) { parentPath = [TRASH]; }
|
|
|
|
if (manager.isInTrashRoot(parentPath)) { parentPath = [TRASH]; }
|
|
|
|
else { parentPath.pop(); }
|
|
|
|
else { parentPath.pop(); }
|
|
|
|
el = manager.find(paths[0].path);
|
|
|
|
|
|
|
|
APP.selectedFiles = [el];
|
|
|
|
|
|
|
|
APP.displayDirectory(parentPath);
|
|
|
|
APP.displayDirectory(parentPath);
|
|
|
|
|
|
|
|
APP.selectedFiles = paths[0].path.slice(-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
APP.hideMenu();
|
|
|
|
APP.hideMenu();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$content.on("keydown", function (e) {
|
|
|
|
$(window).on("keydown", function (e) {
|
|
|
|
if (e.which === 113) {
|
|
|
|
if (e.which === 113) { // if F2 key pressed
|
|
|
|
var paths = $contextMenu.data('paths');
|
|
|
|
var paths = getSelectedPaths(findSelectedElements().first());
|
|
|
|
if (paths.length !== 1) { return; }
|
|
|
|
if (paths.length !== 1) { return; }
|
|
|
|
displayRenameInput(paths[0].element, paths[0].path);
|
|
|
|
displayRenameInput(paths[0].element, paths[0].path);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -3793,10 +3921,9 @@ define([
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$appContainer.on('mouseup', function (e) {
|
|
|
|
$appContainer.on('mouseup', function (e) {
|
|
|
|
//if (sel.down) { return; }
|
|
|
|
|
|
|
|
if (e.which !== 1) { return ; }
|
|
|
|
if (e.which !== 1) { return ; }
|
|
|
|
|
|
|
|
if ($(e.target).is(".dropdown-submenu a, .dropdown-submenu a span")) { return; } // if we click on dropdown-submenu, don't close menu
|
|
|
|
APP.hideMenu(e);
|
|
|
|
APP.hideMenu(e);
|
|
|
|
//removeSelected(e);
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$appContainer.on('click', function (e) {
|
|
|
|
$appContainer.on('click', function (e) {
|
|
|
|
if (e.which !== 1) { return ; }
|
|
|
|
if (e.which !== 1) { return ; }
|
|
|
@ -3815,7 +3942,7 @@ define([
|
|
|
|
if (manager.isPathIn(currentPath, [FILES_DATA]) && APP.loggedIn) {
|
|
|
|
if (manager.isPathIn(currentPath, [FILES_DATA]) && APP.loggedIn) {
|
|
|
|
return; // We can't remove elements directly from filesData
|
|
|
|
return; // We can't remove elements directly from filesData
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var $selected = $('.cp-app-drive-element-selected');
|
|
|
|
var $selected = findSelectedElements();
|
|
|
|
if (!$selected.length) { return; }
|
|
|
|
if (!$selected.length) { return; }
|
|
|
|
var paths = [];
|
|
|
|
var paths = [];
|
|
|
|
var isTrash = manager.isPathIn(currentPath, [TRASH]);
|
|
|
|
var isTrash = manager.isPathIn(currentPath, [TRASH]);
|
|
|
|