|
|
|
@ -42,6 +42,9 @@ define([
|
|
|
|
|
Pages)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Messages.fm_link = "Link"; // XXX "New Link" ?
|
|
|
|
|
// XXX check for all occurrences of `fm_link` before changing it
|
|
|
|
|
|
|
|
|
|
var APP = window.APP = {
|
|
|
|
|
editable: false,
|
|
|
|
|
online: false,
|
|
|
|
@ -443,6 +446,11 @@ define([
|
|
|
|
|
'data-icon': AppConfig.applicationsIcon.poll,
|
|
|
|
|
'data-type': 'poll'
|
|
|
|
|
}, Messages.button_newpoll)),
|
|
|
|
|
h('li', h('a.cp-app-drive-context-newdoc.dropdown-item.cp-app-drive-context-editable', {
|
|
|
|
|
'tabindex': '-1',
|
|
|
|
|
'data-icon': AppConfig.applicationsIcon.link,
|
|
|
|
|
'data-type': 'link'
|
|
|
|
|
}, Messages.fm_link)),
|
|
|
|
|
]),
|
|
|
|
|
]),
|
|
|
|
|
$separator.clone()[0],
|
|
|
|
@ -1106,11 +1114,24 @@ define([
|
|
|
|
|
common.getMediaTagPreview(mts, idx);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var refresh = APP.refresh = function () {
|
|
|
|
|
APP.displayDirectory(currentPath);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// `app`: true (force open wiht the app), false (force open in preview),
|
|
|
|
|
// falsy (open in preview if default is not using the app)
|
|
|
|
|
var defaultInApp = ['application/pdf'];
|
|
|
|
|
var openFile = function (el, isRo, app) {
|
|
|
|
|
var data = manager.getFileData(el);
|
|
|
|
|
|
|
|
|
|
if (data.static) {
|
|
|
|
|
if (data.href) {
|
|
|
|
|
common.openUnsafeURL(data.href);
|
|
|
|
|
manager.updateStaticAccess(el, refresh);
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!data || (!data.href && !data.roHref)) {
|
|
|
|
|
return void logError("Missing data for the file", el, data);
|
|
|
|
|
}
|
|
|
|
@ -1147,10 +1168,6 @@ define([
|
|
|
|
|
common.openURL(Hash.getNewPadURL(href, obj));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var refresh = APP.refresh = function () {
|
|
|
|
|
APP.displayDirectory(currentPath);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var pickFolderColor = function ($element, currentColor, cb) {
|
|
|
|
|
var colors = ["", "#f23c38", "#ff0073", "#da0eba", "#9d00ac", "#6c19b3", "#4a42b1", "#3d8af0", "#30a0f1", "#1fb9d1", "#009686", "#45b354", "#84c750", "#c6e144", "#faf147", "#fbc423", "#fc9819", "#fd5227", "#775549", "#9c9c9c", "#607a89"];
|
|
|
|
@ -1263,6 +1280,9 @@ define([
|
|
|
|
|
if ($element.is('.cp-border-color-sheet')) {
|
|
|
|
|
hide.push('download');
|
|
|
|
|
}
|
|
|
|
|
if ($element.is('.cp-app-drive-static')) {
|
|
|
|
|
hide.push('access', 'hashtag', 'properties', 'download');
|
|
|
|
|
}
|
|
|
|
|
if ($element.is('.cp-app-drive-element-file')) {
|
|
|
|
|
// No folder in files
|
|
|
|
|
hide.push('color');
|
|
|
|
@ -1899,6 +1919,27 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// In list mode, display metadata from the filesData object
|
|
|
|
|
var addStaticData = function (element, $element, data) {
|
|
|
|
|
$element.addClass('cp-border-color-drive');
|
|
|
|
|
var name = data.name;
|
|
|
|
|
var $name = $('<span>', {'class': 'cp-app-drive-element-name'}).text(name);
|
|
|
|
|
$element.append($name);
|
|
|
|
|
if (getViewMode() === 'grid') {
|
|
|
|
|
$element.attr('title', name); // XXX Util.fixHTML
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var type = Messages.fm_link; // XXX new translation key ("Link")
|
|
|
|
|
var $type = $('<span>', {
|
|
|
|
|
'class': 'cp-app-drive-element-type cp-app-drive-element-list'
|
|
|
|
|
}).text(type);
|
|
|
|
|
var $adate = $('<span>', {
|
|
|
|
|
'class': 'cp-app-drive-element-atime cp-app-drive-element-list'
|
|
|
|
|
}).text(getDate(data.atime));
|
|
|
|
|
var $cdate = $('<span>', {
|
|
|
|
|
'class': 'cp-app-drive-element-ctime cp-app-drive-element-list'
|
|
|
|
|
}).text(getDate(data.ctime));
|
|
|
|
|
$element.append($type).append($adate).append($cdate);
|
|
|
|
|
};
|
|
|
|
|
var _addOwnership = function ($span, $state, data) {
|
|
|
|
|
if (data && Array.isArray(data.owners) && data.owners.indexOf(edPublic) !== -1) {
|
|
|
|
|
var $owned = $ownedIcon.clone().appendTo($state);
|
|
|
|
@ -1914,6 +1955,9 @@ define([
|
|
|
|
|
if (!manager.isFile(element)) { return; }
|
|
|
|
|
|
|
|
|
|
var data = manager.getFileData(element);
|
|
|
|
|
if (data.static) {
|
|
|
|
|
return addStaticData(element, $element, data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Object.keys(data).length) {
|
|
|
|
|
return true;
|
|
|
|
@ -2124,7 +2168,9 @@ define([
|
|
|
|
|
$icon = manager.isFolderEmpty(root[key]) ? $folderEmptyIcon.clone() : $folderIcon.clone();
|
|
|
|
|
$icon.css("color", getFolderColor(path.concat(elPath)));
|
|
|
|
|
}
|
|
|
|
|
var classes = restrictedClass + roClass + liClass;
|
|
|
|
|
|
|
|
|
|
var staticClass = manager.isStaticFile(element) ? '.cp-app-drive-static' : '';
|
|
|
|
|
var classes = restrictedClass + roClass + liClass + staticClass;
|
|
|
|
|
var $element = $(h('li.cp-app-drive-element.cp-app-drive-element-row' + classes, {
|
|
|
|
|
draggable: true
|
|
|
|
|
}));
|
|
|
|
@ -2459,8 +2505,7 @@ define([
|
|
|
|
|
setViewMode(viewMode || 'grid');
|
|
|
|
|
showMode(viewMode);
|
|
|
|
|
|
|
|
|
|
$button.click(function (e) {
|
|
|
|
|
console.error(e);
|
|
|
|
|
$button.click(function () {
|
|
|
|
|
var viewMode = getViewMode();
|
|
|
|
|
var newViewMode = getOppositeViewMode(viewMode);
|
|
|
|
|
setViewMode(newViewMode);
|
|
|
|
@ -2686,6 +2731,63 @@ define([
|
|
|
|
|
});
|
|
|
|
|
$input.click();
|
|
|
|
|
};
|
|
|
|
|
var showLinkModal = function () {
|
|
|
|
|
Messages.fm_link_name = "Link name"; // XXX
|
|
|
|
|
Messages.fm_link_url = "URL";
|
|
|
|
|
Messages.fm_link_warning = "Warning: URL size...";
|
|
|
|
|
var name, url;
|
|
|
|
|
var warning = h('div.alert.alert-warning', [
|
|
|
|
|
h('i.fa.fa-exclamation-triangle'),
|
|
|
|
|
h('span', Messages.fm_link_warning)
|
|
|
|
|
]);
|
|
|
|
|
var content = h('p', [
|
|
|
|
|
warning,
|
|
|
|
|
h('label', {for: 'cp-app-drive-link-name'}, Messages.fm_link_name),
|
|
|
|
|
name = h('input#cp-app-drive-link-name', { autocomplete: 'off' }),
|
|
|
|
|
h('label', {for: 'cp-app-drive-link-url'}, Messages.fm_link_url),
|
|
|
|
|
url = h('input#cp-app-drive-link-url', { type: 'url', autocomplete: 'off' })
|
|
|
|
|
]);
|
|
|
|
|
var $warning = $(warning).hide();
|
|
|
|
|
var $url = $(url).on('change keypress keyup keydown', function () {
|
|
|
|
|
var v = $url.val().trim();
|
|
|
|
|
if (v.length > 200) {
|
|
|
|
|
$warning.show();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$warning.hide();
|
|
|
|
|
});
|
|
|
|
|
var buttons = [{
|
|
|
|
|
className: 'cancel',
|
|
|
|
|
name: Messages.cancelButton,
|
|
|
|
|
onClick: function () {},
|
|
|
|
|
keys: [27]
|
|
|
|
|
}];
|
|
|
|
|
buttons.push({
|
|
|
|
|
className: 'primary',
|
|
|
|
|
// We may want to use a new key here
|
|
|
|
|
iconClass: '.fa.fa-plus',
|
|
|
|
|
name: Messages.tag_add,
|
|
|
|
|
onClick: function () {
|
|
|
|
|
var n = $(name).val().trim();
|
|
|
|
|
var u = $url.val().trim();
|
|
|
|
|
if (!n || !u) { return true; }
|
|
|
|
|
if (!Util.isValidURL(u)) {
|
|
|
|
|
// XXX add style for invalid input? input:invalid
|
|
|
|
|
UI.warn(Messages.error);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
manager.addLink(currentPath, {
|
|
|
|
|
name: n,
|
|
|
|
|
url: u
|
|
|
|
|
}, refresh);
|
|
|
|
|
},
|
|
|
|
|
keys: [13]
|
|
|
|
|
});
|
|
|
|
|
var m = UI.dialog.customModal(content, {
|
|
|
|
|
buttons: buttons
|
|
|
|
|
});
|
|
|
|
|
UI.openCustomModal(m);
|
|
|
|
|
};
|
|
|
|
|
var addNewPadHandlers = function ($block, isInRoot) {
|
|
|
|
|
// Handlers
|
|
|
|
|
if (isInRoot) {
|
|
|
|
@ -2714,6 +2816,7 @@ define([
|
|
|
|
|
}
|
|
|
|
|
$block.find('a.cp-app-drive-new-fileupload, li.cp-app-drive-new-fileupload').click(showUploadFilesModal);
|
|
|
|
|
$block.find('a.cp-app-drive-new-folderupload, li.cp-app-drive-new-folderupload').click(showUploadFolderModal);
|
|
|
|
|
$block.find('a.cp-app-drive-new-link, li.cp-app-drive-new-link').click(showLinkModal);
|
|
|
|
|
}
|
|
|
|
|
$block.find('a.cp-app-drive-new-doc, li.cp-app-drive-new-doc')
|
|
|
|
|
.click(function () {
|
|
|
|
@ -2757,6 +2860,12 @@ define([
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
options.push({tag: 'hr'});
|
|
|
|
|
options.push({
|
|
|
|
|
tag: 'a',
|
|
|
|
|
attributes: {'class': 'cp-app-drive-new-link'},
|
|
|
|
|
content: $('<div>').append(getIcon('link')).html() + Messages.fm_link
|
|
|
|
|
});
|
|
|
|
|
options.push({tag: 'hr'});
|
|
|
|
|
}
|
|
|
|
|
getNewPadTypes().forEach(function (type) {
|
|
|
|
|
var attributes = {
|
|
|
|
@ -3073,6 +3182,13 @@ define([
|
|
|
|
|
$elementFolderUpload.append($('<span>', {'class': 'cp-app-drive-new-name'})
|
|
|
|
|
.text(Messages.uploadFolderButton));
|
|
|
|
|
}
|
|
|
|
|
// Link
|
|
|
|
|
var $elementLink = $('<li>', {
|
|
|
|
|
'class': 'cp-app-drive-new-link cp-app-drive-element-row ' +
|
|
|
|
|
'cp-app-drive-element-grid'
|
|
|
|
|
}).prepend(getIcon('link')).appendTo($container);
|
|
|
|
|
$elementLink.append($('<span>', {'class': 'cp-app-drive-new-name'})
|
|
|
|
|
.text(Messages.fm_link));
|
|
|
|
|
}
|
|
|
|
|
// Pads
|
|
|
|
|
getNewPadTypes().forEach(function (type) {
|
|
|
|
@ -3479,6 +3595,7 @@ define([
|
|
|
|
|
var path = paths[0];
|
|
|
|
|
if (manager.isPathIn(path, [TRASH])) { return; }
|
|
|
|
|
|
|
|
|
|
if (!file.channel) { file.channel = id; }
|
|
|
|
|
if (channels.indexOf(file.channel) !== -1) { return; }
|
|
|
|
|
channels.push(file.channel);
|
|
|
|
|
|
|
|
|
@ -4482,8 +4599,9 @@ define([
|
|
|
|
|
password: data.password
|
|
|
|
|
},
|
|
|
|
|
isTemplate: paths[0].path[0] === 'template',
|
|
|
|
|
title: data.title,
|
|
|
|
|
title: data.title || data.name,
|
|
|
|
|
sharedFolder: sf,
|
|
|
|
|
static: data.static ? data.href : undefined,
|
|
|
|
|
common: common
|
|
|
|
|
};
|
|
|
|
|
if (padType === 'file') {
|
|
|
|
@ -4501,6 +4619,20 @@ define([
|
|
|
|
|
data = manager.getSharedFolderData(el);
|
|
|
|
|
}
|
|
|
|
|
if (!data) { return; }
|
|
|
|
|
if (data.static) {
|
|
|
|
|
sframeChan.query("Q_DRIVE_USEROBJECT", {
|
|
|
|
|
cmd: "addLink",
|
|
|
|
|
teamId: -1,
|
|
|
|
|
data: {
|
|
|
|
|
name: data.name,
|
|
|
|
|
href: data.href,
|
|
|
|
|
path: ['root']
|
|
|
|
|
}
|
|
|
|
|
}, function () {
|
|
|
|
|
UI.log(Messages.saved);
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
sframeChan.query('Q_STORE_IN_TEAM', {
|
|
|
|
|
href: data.href || data.rohref,
|
|
|
|
|
password: data.password,
|
|
|
|
@ -4539,6 +4671,9 @@ define([
|
|
|
|
|
}
|
|
|
|
|
else if ($this.hasClass("cp-app-drive-context-newdoc")) {
|
|
|
|
|
var ntype = $this.data('type') || 'pad';
|
|
|
|
|
if (ntype === 'link') {
|
|
|
|
|
return void showLinkModal();
|
|
|
|
|
}
|
|
|
|
|
var path2 = manager.isPathIn(currentPath, [TRASH]) ? '' : currentPath;
|
|
|
|
|
openIn(ntype, path2, APP.team);
|
|
|
|
|
}
|
|
|
|
|