review and lint

pull/1/head
David Benqué 5 years ago
parent 1703186ebf
commit 754fa9dab2

@ -226,7 +226,7 @@
width: 100%; width: 100%;
font-size: 100%; font-size: 100%;
padding: @alertify_padding-base; padding: @alertify_padding-base;
&[readonly]{ &[readonly] {
background-color: @alertify-light-bg; background-color: @alertify-light-bg;
color: @cryptpad_text_col; color: @cryptpad_text_col;
border-color: @alertify-input-fg; border-color: @alertify-input-fg;
@ -348,8 +348,8 @@
nav { nav {
padding: @alertify_padding-base; padding: @alertify_padding-base;
text-align: right; text-align: right;
button{ button {
margin:0px !important; margin: 0px !important;
&:not(:last-child) { &:not(:last-child) {
margin-right: @alertify_padding-base !important; margin-right: @alertify_padding-base !important;
} }

@ -66,7 +66,7 @@
padding: 8px 12px; padding: 8px 12px;
margin: 1em; margin: 1em;
width: 300px; width: 300px;
&[type="text"]{ &[type="text"] {
background-color: @colortheme_modal-input-fg; background-color: @colortheme_modal-input-fg;
color: @cryptpad_text_col; color: @cryptpad_text_col;
border: 1px solid @colortheme_modal-input; border: 1px solid @colortheme_modal-input;

@ -5,11 +5,11 @@
} }
& { & {
// Share modal // Share modal
.msg.cp-inline-radio-group{ .msg.cp-inline-radio-group {
.radio-group{ .radio-group {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
.cp-radio{ .cp-radio {
margin-right: 30px; margin-right: 30px;
} }
} }

@ -194,7 +194,7 @@ define([
if (tab.icon) { if (tab.icon) {
var icon = h('i', {class: tab.icon}); var icon = h('i', {class: tab.icon});
$(title).prepend(' ').prepend(icon); $(title).prepend(' ').prepend(icon);
}; }
$(title).click(function () { $(title).click(function () {
titles.forEach(function (t) { $(t).removeClass('alertify-tabs-active'); }); titles.forEach(function (t) { $(t).removeClass('alertify-tabs-active'); });
contents.forEach(function (c) { $(c).removeClass('alertify-tabs-content-active'); }); contents.forEach(function (c) { $(c).removeClass('alertify-tabs-content-active'); });

@ -937,7 +937,6 @@ define([
name: Messages.share_withFriends, name: Messages.share_withFriends,
onClick: function () { onClick: function () {
var href = Hash.getRelativeHref(linkGetter()); var href = Hash.getRelativeHref(linkGetter());
console.log(href);
var $friends = $div.find('.cp-usergrid-user.cp-selected'); var $friends = $div.find('.cp-usergrid-user.cp-selected');
$friends.each(function (i, el) { $friends.each(function (i, el) {
var curve = $(el).attr('data-curve'); var curve = $(el).attr('data-curve');
@ -1026,7 +1025,6 @@ define([
}; };
}; };
/// Share Modal Creation XXX remove this flag
UIElements.createShareModal = function (config) { UIElements.createShareModal = function (config) {
var origin = config.origin; var origin = config.origin;
var pathname = config.pathname; var pathname = config.pathname;
@ -1050,10 +1048,11 @@ define([
Messages.share_linkEdit, false, { mark: {tabindex:1} })]) Messages.share_linkEdit, false, { mark: {tabindex:1} })])
]); ]);
var $rights = $(rights);
var saveValue = function () { var saveValue = function () {
var edit = Util.isChecked($(rights).find('#cp-share-editable-true')); var edit = Util.isChecked($rights.find('#cp-share-editable-true'));
var present = Util.isChecked($(rights).find('#cp-share-present')); var present = Util.isChecked($rights.find('#cp-share-present'));
common.setAttribute(['general', 'share'], { common.setAttribute(['general', 'share'], {
edit: edit, edit: edit,
present: present present: present
@ -1062,9 +1061,9 @@ define([
var getLinkValue = function (initValue) { var getLinkValue = function (initValue) {
var val = initValue || {}; var val = initValue || {};
var edit = val.edit !== undefined ? val.edit : Util.isChecked($(rights).find('#cp-share-editable-true')); var edit = val.edit !== undefined ? val.edit : Util.isChecked($rights.find('#cp-share-editable-true'));
var embed = val.embed; var embed = val.embed;
var present = val.present !== undefined ? val.present : Util.isChecked($(rights).find('#cp-share-present')); var present = val.present !== undefined ? val.present : Util.isChecked($rights.find('#cp-share-present'));
var hash = (!hashes.viewHash || (edit && hashes.editHash)) ? hashes.editHash : hashes.viewHash; var hash = (!hashes.viewHash || (edit && hashes.editHash)) ? hashes.editHash : hashes.viewHash;
var href = origin + pathname + '#' + hash; var href = origin + pathname + '#' + hash;
var parsed = Hash.parsePadUrl(href); var parsed = Hash.parsePadUrl(href);
@ -1072,10 +1071,12 @@ define([
}; };
var makeCancelButton = function() { var makeCancelButton = function() {
return {className: 'cancel', return {
className: 'cancel',
name: Messages.cancel, name: Messages.cancel,
onClick: function () {}, onClick: function () {},
keys: [27]}; keys: [27]
};
}; };
// Share link tab // Share link tab
@ -1089,6 +1090,7 @@ define([
linkContent.push(UI.dialog.selectable('', { id: 'cp-share-link-preview', tabindex: 1 })); linkContent.push(UI.dialog.selectable('', { id: 'cp-share-link-preview', tabindex: 1 }));
var link = h('div.cp-share-modal', linkContent); var link = h('div.cp-share-modal', linkContent);
var $link = $(link);
var linkButtons = [ var linkButtons = [
makeCancelButton(), makeCancelButton(),
@ -1098,7 +1100,7 @@ define([
onClick: function () { onClick: function () {
saveValue(); saveValue();
var v = getLinkValue({ var v = getLinkValue({
embed: Util.isChecked($(link).find('#cp-share-embed')) embed: Util.isChecked($link.find('#cp-share-embed'))
}); });
window.open(v); window.open(v);
}, },
@ -1110,7 +1112,7 @@ define([
onClick: function () { onClick: function () {
saveValue(); saveValue();
var v = getLinkValue({ var v = getLinkValue({
embed: Util.isChecked($(link).find('#cp-share-embed')) embed: Util.isChecked($link.find('#cp-share-embed'))
}); });
var success = Clipboard.copy(v); var success = Clipboard.copy(v);
if (success) { UI.log(Messages.shareSuccess); } if (success) { UI.log(Messages.shareSuccess); }
@ -1120,15 +1122,15 @@ define([
]; ];
// update values for link preview when radio btns change // update values for link preview when radio btns change
$(link).find('#cp-share-link-preview').val(getLinkValue()); $link.find('#cp-share-link-preview').val(getLinkValue());
$(rights).find('input[type="radio"]').on('change', function () { $rights.find('input[type="radio"]').on('change', function () {
$(link).find('#cp-share-link-preview').val(getLinkValue({ $link.find('#cp-share-link-preview').val(getLinkValue({
embed: Util.isChecked($(link).find('#cp-share-embed')) embed: Util.isChecked($link.find('#cp-share-embed'))
})); }));
}); });
$(link).find('input[type="checkbox"]').on('change', function () { $link.find('input[type="checkbox"]').on('change', function () {
$(link).find('#cp-share-link-preview').val(getLinkValue({ $link.find('#cp-share-link-preview').val(getLinkValue({
embed: Util.isChecked($(link).find('#cp-share-embed')) embed: Util.isChecked($link.find('#cp-share-embed'))
})); }));
}); });
@ -1150,7 +1152,6 @@ define([
onFriendShare.reg(saveValue); onFriendShare.reg(saveValue);
// XXX Don't display access rights if no contacts // XXX Don't display access rights if no contacts
/// var contactsAccessRights = hasFriends ? createAccessRights('contact-rights') : '';
var contactsContent = h('div.cp-share-modal'); var contactsContent = h('div.cp-share-modal');
$(contactsContent).append(friendsList); $(contactsContent).append(friendsList);
@ -1190,7 +1191,7 @@ define([
// update values for link preview when radio btns change // update values for link preview when radio btns change
$(embed).find('#cp-embed-link-preview').val(getEmbedValue()); $(embed).find('#cp-embed-link-preview').val(getEmbedValue());
$(rights).find('input[type="radio"]').on('change', function () { $rights.find('input[type="radio"]').on('change', function () {
$(embed).find('#cp-embed-link-preview').val(getEmbedValue()); $(embed).find('#cp-embed-link-preview').val(getEmbedValue());
}); });
@ -1227,41 +1228,41 @@ define([
// XXX // XXX
// disable edit share options if you don't have edit rights // disable edit share options if you don't have edit rights
if (!hashes.editHash) { if (!hashes.editHash) {
$(rights).find('#cp-share-editable-false').attr('checked', true); $rights.find('#cp-share-editable-false').attr('checked', true);
$(rights).find('#cp-share-editable-true').removeAttr('checked').attr('disabled', true); $rights.find('#cp-share-editable-true').removeAttr('checked').attr('disabled', true);
} else if (!hashes.viewHash) { } else if (!hashes.viewHash) {
$(rights).find('#cp-share-editable-false').removeAttr('checked').attr('disabled', true); $rights.find('#cp-share-editable-false').removeAttr('checked').attr('disabled', true);
$(rights).find('#cp-share-present').removeAttr('checked').attr('disabled', true); $rights.find('#cp-share-present').removeAttr('checked').attr('disabled', true);
$(rights).find('#cp-share-editable-true').attr('checked', true); $rights.find('#cp-share-editable-true').attr('checked', true);
} }
common.getAttribute(['general', 'share'], function (err, val) { common.getAttribute(['general', 'share'], function (err, val) {
val = val || {}; val = val || {};
if (val.present && canPresent) { if (val.present && canPresent) {
$(rights).find('#cp-share-editable-false').prop('checked', false); $rights.find('#cp-share-editable-false').prop('checked', false);
$(rights).find('#cp-share-editable-true').prop('checked', false); $rights.find('#cp-share-editable-true').prop('checked', false);
$(rights).find('#cp-share-present').prop('checked', true); $rights.find('#cp-share-present').prop('checked', true);
} else if ((val.edit === false && hashes.viewHash) || !hashes.editHash) { } else if ((val.edit === false && hashes.viewHash) || !hashes.editHash) {
$(rights).find('#cp-share-editable-false').prop('checked', true); $rights.find('#cp-share-editable-false').prop('checked', true);
$(rights).find('#cp-share-editable-true').prop('checked', false); $rights.find('#cp-share-editable-true').prop('checked', false);
$(rights).find('#cp-share-present').prop('checked', false); $rights.find('#cp-share-present').prop('checked', false);
} else { } else {
$(rights).find('#cp-share-editable-true').prop('checked', true); $rights.find('#cp-share-editable-true').prop('checked', true);
$(rights).find('#cp-share-editable-false').prop('checked', false); $rights.find('#cp-share-editable-false').prop('checked', false);
$(rights).find('#cp-share-present').prop('checked', false); $rights.find('#cp-share-present').prop('checked', false);
} }
delete val.embed; delete val.embed;
if (!canPresent) { if (!canPresent) {
delete val.present; delete val.present;
} }
$(link).find('#cp-share-link-preview').val(getLinkValue(val)); $link.find('#cp-share-link-preview').val(getLinkValue(val));
}); });
common.getMetadataMgr().onChange(function () { common.getMetadataMgr().onChange(function () {
// "hashes" is only available is the secure "share" app // "hashes" is only available is the secure "share" app
var _hashes = common.getMetadataMgr().getPrivateData().hashes; var _hashes = common.getMetadataMgr().getPrivateData().hashes;
if (!_hashes) { return; } if (!_hashes) { return; }
hashes = _hashes; hashes = _hashes;
$(link).find('#cp-share-link-preview').val(getLinkValue()); $link.find('#cp-share-link-preview').val(getLinkValue());
}); });
return modal; return modal;
}; };
@ -1300,7 +1301,8 @@ define([
onClick: function () { onClick: function () {
var v = getLinkValue(); var v = getLinkValue();
var success = Clipboard.copy(v); var success = Clipboard.copy(v);
if (success) { UI.log(Messages.shareSuccess); } if (success) { UI.log(Messages.shareSuccess);
}
}, },
keys: [13] keys: [13]
} }

@ -2559,7 +2559,6 @@ define([
var roParsed = Hash.parsePadUrl(data.roHref) || {}; var roParsed = Hash.parsePadUrl(data.roHref) || {};
if (!parsed.hash && !roParsed.hash) { return void console.error("Invalid href: "+(data.href || data.roHref)); } if (!parsed.hash && !roParsed.hash) { return void console.error("Invalid href: "+(data.href || data.roHref)); }
var friends = common.getFriends(); var friends = common.getFriends();
var teams = common.getMetadataMgr().getPrivateData().teams;
var ro = folders[id] && folders[id].version >= 2; var ro = folders[id] && folders[id].version >= 2;
var modal = UIElements.createShareModal({ var modal = UIElements.createShareModal({
teamId: APP.team, teamId: APP.team,
@ -4049,7 +4048,6 @@ define([
el = manager.find(paths[0].path); el = manager.find(paths[0].path);
var parsed, modal; var parsed, modal;
var friends = common.getFriends(); var friends = common.getFriends();
var teams = common.getMetadataMgr().getPrivateData().teams;
if (manager.isFolder(el) && !manager.isSharedFolder(el)) { // Folder if (manager.isFolder(el) && !manager.isSharedFolder(el)) { // Folder
// if folder is inside SF // if folder is inside SF

@ -38,8 +38,6 @@ define([
: UIElements.createShareModal; : UIElements.createShareModal;
var friends = common.getFriends(); var friends = common.getFriends();
var teams = priv.teams;
var _wide = Object.keys(friends).length || Object.keys(teams).length;
var modal = f({ var modal = f({
origin: origin, origin: origin,

Loading…
Cancel
Save