clean up some dead code and do a quick optimizing pass

pull/1/head
ansuz 5 years ago
parent 27793c6755
commit b5a05c1de3

@ -595,54 +595,38 @@ define([
}, opts); }, opts);
var input = h('input.cp-password-input', attributes); var input = h('input.cp-password-input', attributes);
//var reveal = UI.createCheckbox('cp-password-reveal', Messages.password_show);
var eye = h('span.fa.fa-eye.cp-password-reveal'); var eye = h('span.fa.fa-eye.cp-password-reveal');
/* var $eye = $(eye);
$(reveal).find('input').on('change', function () { var $input = $(input);
if($(this).is(':checked')) {
$(input).prop('type', 'text');
$(input).focus();
return;
}
$(input).prop('type', 'password');
$(input).focus();
});
*/
if (displayEye) { if (displayEye) {
$(eye).mousedown(function () { $eye.mousedown(function () {
$(input).prop('type', 'text'); $input.prop('type', 'text');
$(input).focus(); $input.focus();
}).mouseup(function(){ }).mouseup(function(){
$(input).prop('type', 'password'); $input.prop('type', 'password');
$(input).focus(); $input.focus();
}).mouseout(function(){ }).mouseout(function(){
$(input).prop('type', 'password'); $input.prop('type', 'password');
$(input).focus(); $input.focus();
}); });
} else { } else {
$(eye).click(function () { $eye.click(function () {
if ($(this).hasClass('fa-eye')) { if ($eye.hasClass('fa-eye')) {
$(input).prop('type', 'text'); $input.prop('type', 'text');
$(input).focus(); $input.focus();
$(this).removeClass('fa-eye').addClass('fa-eye-slash'); $eye.removeClass('fa-eye').addClass('fa-eye-slash');
return; return;
} }
$(input).prop('type', 'password'); $input.prop('type', 'password');
$(input).focus(); $input.focus();
$(this).removeClass('fa-eye-slash').addClass('fa-eye'); $eye.removeClass('fa-eye-slash').addClass('fa-eye');
}); });
} }
/*if (displayEye) {
$(reveal).hide();
} else {
$(eye).hide();
}*/
return h('span.cp-password-container', [ return h('span.cp-password-container', [
input, input,
//reveal,
eye eye
]); ]);
}; };
@ -685,12 +669,6 @@ define([
var LOADING = 'cp-loading'; var LOADING = 'cp-loading';
/*var getRandomTip = function () {
if (!Messages.tips || !Object.keys(Messages.tips).length) { return ''; }
var keys = Object.keys(Messages.tips);
var rdm = Math.floor(Math.random() * keys.length);
return Messages.tips[keys[rdm]];
};*/
var loading = { var loading = {
error: false, error: false,
driveState: 0, driveState: 0,
@ -700,7 +678,7 @@ define([
config = config || {}; config = config || {};
var loadingText = config.loadingText; var loadingText = config.loadingText;
var todo = function () { var todo = function () {
var $loading = $('#' + LOADING); //.show(); var $loading = $('#' + LOADING);
$loading.css('display', ''); $loading.css('display', '');
$loading.removeClass('cp-loading-hidden'); $loading.removeClass('cp-loading-hidden');
$('.cp-loading-spinner-container').show(); $('.cp-loading-spinner-container').show();
@ -963,19 +941,21 @@ define([
$.extend(markOpts, opts.mark || {}); $.extend(markOpts, opts.mark || {});
var input = h('input', inputOpts); var input = h('input', inputOpts);
var $input = $(input);
var mark = h('span.cp-checkmark-mark', markOpts); var mark = h('span.cp-checkmark-mark', markOpts);
var $mark = $(mark);
var label = h('span.cp-checkmark-label', labelTxt); var label = h('span.cp-checkmark-label', labelTxt);
$(mark).keydown(function (e) { $mark.keydown(function (e) {
if (e.which === 32) { if (e.which === 32) {
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
$(input).prop('checked', !$(input).is(':checked')); $input.prop('checked', !$input.is(':checked'));
$(input).change(); $input.change();
} }
}); });
$(input).change(function () { $(mark).focus(); }); $input.change(function () { $mark.focus(); });
return h('label.cp-checkmark', labelOpts, [ return h('label.cp-checkmark', labelOpts, [
input, input,
@ -1049,28 +1029,30 @@ define([
setHTML(h('div.cp-corner-footer'), footer) setHTML(h('div.cp-corner-footer'), footer)
]); ]);
var $popup = $(popup);
$(minimize).click(function () { $(minimize).click(function () {
$(popup).addClass('cp-minimized'); $popup.addClass('cp-minimized');
}); });
$(maximize).click(function () { $(maximize).click(function () {
$(popup).removeClass('cp-minimized'); $popup.removeClass('cp-minimized');
}); });
if (opts.hidden) { if (opts.hidden) {
$(popup).addClass('cp-minimized'); $popup.addClass('cp-minimized');
} }
if (opts.big) { if (opts.big) {
$(popup).addClass('cp-corner-big'); $popup.addClass('cp-corner-big');
} }
var hide = function () { var hide = function () {
$(popup).hide(); $popup.hide();
}; };
var show = function () { var show = function () {
$(popup).show(); $popup.show();
}; };
var deletePopup = function () { var deletePopup = function () {
$(popup).remove(); $popup.remove();
}; };
$('body').append(popup); $('body').append(popup);

@ -694,7 +694,7 @@ define([
if (data.atime) { if (data.atime) {
$d.append(h('div.cp-app-prop', [Messages.fm_lastAccess, h('br'), h('span.cp-app-prop-content', new Date(data.atime).toLocaleString())])); $d.append(h('div.cp-app-prop', [Messages.fm_lastAccess, h('br'), h('span.cp-app-prop-content', new Date(data.atime).toLocaleString())]));
} }
if (common.isLoggedIn()) { if (common.isLoggedIn()) {
// check the size of this file... // check the size of this file...
var bytes = 0; var bytes = 0;
@ -1039,7 +1039,7 @@ define([
present: present present: present
}); });
}; };
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'));
@ -1121,7 +1121,7 @@ define([
onClose: config.onClose, onClose: config.onClose,
}); });
// Share with contacts tab // Share with contacts tab
var hasFriends = Object.keys(config.friends || {}).length !== 0; var hasFriends = Object.keys(config.friends || {}).length !== 0;
var onFriendShare = Util.mkEvent(); var onFriendShare = Util.mkEvent();
@ -1133,7 +1133,7 @@ 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 contactsContent = h('div.cp-share-modal'); var contactsContent = h('div.cp-share-modal');
$(contactsContent).append(friendsList); $(contactsContent).append(friendsList);
@ -1170,11 +1170,12 @@ define([
}]; }];
var embed = h('div.cp-share-modal', embedContent); var embed = h('div.cp-share-modal', embedContent);
var $embed = $(embed);
// 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());
}); });
var frameEmbed = UI.dialog.customModal(embed, { var frameEmbed = UI.dialog.customModal(embed, {
@ -1207,7 +1208,7 @@ define([
var modal = UI.dialog.tabs(tabs); var modal = UI.dialog.tabs(tabs);
$(modal).find('.alertify-tabs-titles').after(rights); $(modal).find('.alertify-tabs-titles').after(rights);
// 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);
@ -1282,7 +1283,7 @@ 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]
@ -1294,7 +1295,7 @@ define([
onClose: config.onClose, onClose: config.onClose,
}); });
// share with contacts tab // share with contacts tab
var hasFriends = Object.keys(config.friends || {}).length !== 0; var hasFriends = Object.keys(config.friends || {}).length !== 0;
var friendsObject = hasFriends ? createShareWithFriends(config, null, getLinkValue) : { var friendsObject = hasFriends ? createShareWithFriends(config, null, getLinkValue) : {
@ -1369,7 +1370,6 @@ define([
return modal; return modal;
}; };
UIElements.createInviteTeamModal = function (config) { UIElements.createInviteTeamModal = function (config) {
var common = config.common; var common = config.common;
var hasFriends = Object.keys(config.friends || {}).length !== 0; var hasFriends = Object.keys(config.friends || {}).length !== 0;
@ -2346,7 +2346,7 @@ define([
prettyUsage = Messages._getKey('formattedMB', [usage]); prettyUsage = Messages._getKey('formattedMB', [usage]);
prettyLimit = Messages._getKey('formattedMB', [limit]); prettyLimit = Messages._getKey('formattedMB', [limit]);
} }
if (quota < 0.8) { $usage.addClass('cp-limit-usage-normal'); } if (quota < 0.8) { $usage.addClass('cp-limit-usage-normal'); }
else if (quota < 1) { $usage.addClass('cp-limit-usage-warning'); } else if (quota < 1) { $usage.addClass('cp-limit-usage-warning'); }
else { $usage.addClass('cp-limit-usage-above'); } else { $usage.addClass('cp-limit-usage-above'); }
@ -3526,15 +3526,16 @@ define([
if (isError) { error = setHTML(h('p.cp-password-error'), Messages.password_error); } if (isError) { error = setHTML(h('p.cp-password-error'), Messages.password_error); }
var info = h('p.cp-password-info', Messages.password_info); var info = h('p.cp-password-info', Messages.password_info);
var password = UI.passwordInput({placeholder: Messages.password_placeholder}); var password = UI.passwordInput({placeholder: Messages.password_placeholder});
var $password = $(password);
var button = h('button', Messages.password_submit); var button = h('button', Messages.password_submit);
cfg = cfg || {}; cfg = cfg || {};
if (cfg.value && !isError) { if (cfg.value && !isError) {
$(password).find('.cp-password-input').val(cfg.value); $password.find('.cp-password-input').val(cfg.value);
} }
var submit = function () { var submit = function () {
var value = $(password).find('.cp-password-input').val(); var value = $password.find('.cp-password-input').val();
UI.addLoadingScreen(); UI.addLoadingScreen();
common.getSframeChannel().query('Q_PAD_PASSWORD_VALUE', value, function (err, data) { common.getSframeChannel().query('Q_PAD_PASSWORD_VALUE', value, function (err, data) {
if (!data) { if (!data) {
@ -3542,7 +3543,7 @@ define([
} }
}); });
}; };
$(password).find('.cp-password-input').on('keydown', function (e) { if (e.which === 13) { submit(); } }); $password.find('.cp-password-input').on('keydown', function (e) { if (e.which === 13) { submit(); } });
$(button).on('click', function () { submit(); }); $(button).on('click', function () { submit(); });
@ -3556,7 +3557,7 @@ define([
]); ]);
UI.errorLoadingScreen(block); UI.errorLoadingScreen(block);
$(password).find('.cp-password-input').focus(); $password.find('.cp-password-input').focus();
}; };
var crowdfundingState = false; var crowdfundingState = false;

Loading…
Cancel
Save