split share modal into 3 tabs

pull/1/head
David Benqué 5 years ago
parent b5ff5a3b20
commit 874dce748d

@ -1023,6 +1023,7 @@ define([
return div; return div;
}; };
/// Share Modal Creation
UIElements.createShareModal = function (config) { UIElements.createShareModal = function (config) {
var origin = config.origin; var origin = config.origin;
var pathname = config.pathname; var pathname = config.pathname;
@ -1031,40 +1032,42 @@ define([
if (!hashes || (!hashes.editHash && !hashes.viewHash)) { return; } if (!hashes || (!hashes.editHash && !hashes.viewHash)) { return; }
function createAccessRights(group_name) {
var rights = [
h('label', Messages.share_linkAccess),
h('br'),
UI.createRadio(group_name, 'cp-share-editable-false',
Messages.share_linkView, true, { mark: {tabindex:1} }),
UI.createRadio(group_name, 'cp-share-present',
Messages.share_linkPresent, false, { mark: {tabindex:1} }), // XXX only show this if code or slide pad
UI.createRadio(group_name, 'cp-share-editable-true',
Messages.share_linkEdit, false, { mark: {tabindex:1} }),
h('br'),
];
return rights;
};
// Share link tab // Share link tab
var hasFriends = Object.keys(config.friends || {}).length !== 0;
var onFriendShare = Util.mkEvent();
var friendsList = hasFriends ? createShareWithFriends(config, onFriendShare) : undefined;
var friendsUIClass = hasFriends ? '.cp-share-columns' : '';
var content = []; var content = [];
var sfContent = [ var sfContent = [
h('label', Messages.sharedFolders_share), h('label', Messages.sharedFolders_share),
h('br'), h('br'),
]; ];
var shareContent = [ var linkAccessRights = createAccessRights('link-rights');
h('label', Messages.share_linkAccess),
h('br'),
UI.createRadio('cp-share-editable', 'cp-share-editable-true',
Messages.share_linkEdit, true, { mark: {tabindex:1} }),
UI.createRadio('cp-share-editable', 'cp-share-editable-false',
Messages.share_linkView, false, { mark: {tabindex:1} }),
h('br'),
];
var padContent = [ var padContent = [
h('label', Messages.share_linkOptions),
h('br'),
UI.createCheckbox('cp-share-embed', Messages.share_linkEmbed, false, { mark: {tabindex:1} }), UI.createCheckbox('cp-share-embed', Messages.share_linkEmbed, false, { mark: {tabindex:1} }),
UI.createCheckbox('cp-share-present', Messages.share_linkPresent, false, { mark: {tabindex:1} }),
h('br'), h('br'),
]; ];
if (config.sharedFolder) { Array.prototype.push.apply(content, sfContent); } if (config.sharedFolder) { Array.prototype.push.apply(content, sfContent); }
Array.prototype.push.apply(content, shareContent); Array.prototype.push.apply(content, linkAccessRights);
if (!config.sharedFolder) { Array.prototype.push.apply(content, padContent); } if (!config.sharedFolder) { Array.prototype.push.apply(content, padContent); }
content.push(UI.dialog.selectable('', { id: 'cp-share-link-preview', tabindex: 1 })); content.push(UI.dialog.selectable('', { id: 'cp-share-link-preview', tabindex: 1 }));
var mainShareColumn = h('div.cp-share-column.contains-nav', content); // XXX remove LESS code for cp-share-columns if not using anymore
var link = h('div.cp-share-modal' + friendsUIClass); //var mainShareColumn = h('div.cp-share-column.contains-nav', content);
var link = h('div.cp-share-modal', content);
var saveValue = function () { var saveValue = function () {
var edit = Util.isChecked($(link).find('#cp-share-editable-true')); var edit = Util.isChecked($(link).find('#cp-share-editable-true'));
var embed = Util.isChecked($(link).find('#cp-share-embed')); var embed = Util.isChecked($(link).find('#cp-share-embed'));
@ -1075,7 +1078,7 @@ define([
present: present present: present
}); });
}; };
onFriendShare.reg(saveValue);
var getLinkValue = function (initValue) { var getLinkValue = function (initValue) {
var val = initValue || {}; var val = initValue || {};
var edit = val.edit !== undefined ? val.edit : Util.isChecked($(link).find('#cp-share-editable-true')); var edit = val.edit !== undefined ? val.edit : Util.isChecked($(link).find('#cp-share-editable-true'));
@ -1118,8 +1121,7 @@ define([
} }
var $link = $(link); var $link = $(link);
$(mainShareColumn).append(UI.dialog.getButtons(shareButtons, config.onClose)).appendTo($link); $link.append(UI.dialog.getButtons(shareButtons, config.onClose));
$(friendsList).appendTo($link);
if (!hashes.editHash) { if (!hashes.editHash) {
$(link).find('#cp-share-editable-false').attr('checked', true); $(link).find('#cp-share-editable-false').attr('checked', true);
@ -1139,6 +1141,26 @@ define([
onClose: config.onClose, onClose: config.onClose,
}); });
// Share with contacts tab
var hasFriends = Object.keys(config.friends || {}).length !== 0;
var onFriendShare = Util.mkEvent();
var friendsList = hasFriends ? createShareWithFriends(config, onFriendShare) : undefined;
// var friendsUIClass = hasFriends ? '.cp-share-columns' : '';
onFriendShare.reg(saveValue);
contactsAccessRights = createAccessRights('contact-rights');
var contacts = h('.cp-share-modal', contactsAccessRights);
var $contacts = $(contacts);
$(friendsList).appendTo($contacts);
var frameContacts = UI.dialog.customModal(contacts, {
buttons: linkButtons,
onClose: config.onClose,
});
// Embed tab // Embed tab
var getEmbedValue = function () { var getEmbedValue = function () {
var hash = hashes.viewHash || hashes.editHash; var hash = hashes.viewHash || hashes.editHash;
@ -1148,7 +1170,6 @@ define([
return '<iframe src="' + url + '"></iframe>'; return '<iframe src="' + url + '"></iframe>';
}; };
var embed = h('div.cp-share-modal', [ var embed = h('div.cp-share-modal', [
h('h3', Messages.viewEmbedTitle),
h('p', Messages.viewEmbedTag), h('p', Messages.viewEmbedTag),
h('br'), h('br'),
UI.dialog.selectable(getEmbedValue()) UI.dialog.selectable(getEmbedValue())
@ -1177,6 +1198,9 @@ define([
var tabs = [{ var tabs = [{
title: Messages.share_linkCategory, title: Messages.share_linkCategory,
content: frameLink content: frameLink
}, {
title: "Contacts",
content: frameContacts
}, { }, {
title: Messages.share_embedCategory, title: Messages.share_embedCategory,
content: frameEmbed content: frameEmbed

@ -173,7 +173,6 @@
"viewOpenTitle": "Open this pad in read-only mode in a new tab", "viewOpenTitle": "Open this pad in read-only mode in a new tab",
"fileShare": "Copy link", "fileShare": "Copy link",
"getEmbedCode": "Get embed code", "getEmbedCode": "Get embed code",
"viewEmbedTitle": "Embed the pad in an external page",
"viewEmbedTag": "To embed this pad, include this iframe in your page wherever you want. You can style it using CSS or HTML attributes.", "viewEmbedTag": "To embed this pad, include this iframe in your page wherever you want. You can style it using CSS or HTML attributes.",
"fileEmbedTitle": "Embed the file in an external page", "fileEmbedTitle": "Embed the file in an external page",
"fileEmbedScript": "To embed this file, include this script once in your page to load the Media Tag:", "fileEmbedScript": "To embed this file, include this script once in your page to load the Media Tag:",
@ -980,13 +979,12 @@
"properties_passwordWarning": "The password was successfully changed but we were unable to update your CryptDrive with the new data. You may have to remove the old version of the pad manually.<br>Press OK to reload and update your access rights.", "properties_passwordWarning": "The password was successfully changed but we were unable to update your CryptDrive with the new data. You may have to remove the old version of the pad manually.<br>Press OK to reload and update your access rights.",
"properties_passwordSuccess": "The password was successfully changed.<br>Press OK to reload and update your access rights.", "properties_passwordSuccess": "The password was successfully changed.<br>Press OK to reload and update your access rights.",
"properties_changePasswordButton": "Submit", "properties_changePasswordButton": "Submit",
"share_linkCategory": "Share link", "share_linkCategory": "Link",
"share_linkAccess": "Access rights", "share_linkAccess": "Access rights",
"share_linkEdit": "Edit", "share_linkEdit": "Edit",
"share_linkView": "View", "share_linkView": "View",
"share_linkOptions": "Link options", "share_linkEmbed": "Embed mode (hide toolbar and user list)",
"share_linkEmbed": "Embed mode (toolbar and userlist hidden)", "share_linkPresent": "Present (hide editable sections)",
"share_linkPresent": "Present mode (editable sections hidden)",
"share_linkOpen": "Open in new tab", "share_linkOpen": "Open in new tab",
"share_linkCopy": "Copy to clipboard", "share_linkCopy": "Copy to clipboard",
"share_embedCategory": "Embed", "share_embedCategory": "Embed",

Loading…
Cancel
Save