mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-28 11:39:21 +03:00
Removed: twitter, google, dropbox, facebook, owncloud, modernizr from JavaScript
This commit is contained in:
parent
e8d38a6870
commit
4468d5bd22
60 changed files with 7 additions and 4152 deletions
|
|
@ -49,7 +49,6 @@ import AccountStore from 'Stores/User/Account';
|
|||
import FolderStore from 'Stores/User/Folder';
|
||||
import PgpStore from 'Stores/User/Pgp';
|
||||
import MessageStore from 'Stores/User/Message';
|
||||
import SocialStore from 'Stores/Social';
|
||||
|
||||
import Remote from 'Remote/User/Ajax';
|
||||
|
||||
|
|
@ -329,21 +328,6 @@ class ComposePopupView extends AbstractViewNext {
|
|||
this.showBcc.subscribe(this.resizerTrigger);
|
||||
this.showReplyTo.subscribe(this.resizerTrigger);
|
||||
|
||||
this.dropboxEnabled = SocialStore.dropbox.enabled;
|
||||
this.dropboxApiKey = SocialStore.dropbox.apiKey;
|
||||
|
||||
this.driveEnabled = ko.observable(
|
||||
bXMLHttpRequestSupported &&
|
||||
!!Settings.settingsGet('AllowGoogleSocial') &&
|
||||
!!Settings.settingsGet('AllowGoogleSocialDrive') &&
|
||||
!!Settings.settingsGet('GoogleClientID') &&
|
||||
!!Settings.settingsGet('GoogleApiKey')
|
||||
);
|
||||
|
||||
this.driveVisible = ko.observable(false);
|
||||
|
||||
this.driveCallback = _.bind(this.driveCallback, this);
|
||||
|
||||
this.onMessageUploadAttachments = _.bind(this.onMessageUploadAttachments, this);
|
||||
|
||||
this.bDisabeCloseOnEsc = true;
|
||||
|
|
@ -530,28 +514,6 @@ class ComposePopupView extends AbstractViewNext {
|
|||
}
|
||||
}
|
||||
|
||||
@command((self) => self.dropboxEnabled())
|
||||
dropboxCommand() {
|
||||
if (window.Dropbox) {
|
||||
window.Dropbox.choose({
|
||||
success: (files) => {
|
||||
if (files && files[0] && files[0].link) {
|
||||
this.addDropboxAttachment(files[0]);
|
||||
}
|
||||
},
|
||||
linkType: 'direct',
|
||||
multiselect: false
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@command((self) => self.driveEnabled())
|
||||
driveCommand() {
|
||||
this.driveOpenPopup();
|
||||
return true;
|
||||
}
|
||||
|
||||
autosaveFunction() {
|
||||
if (
|
||||
this.modalVisibility() &&
|
||||
|
|
@ -1289,16 +1251,6 @@ class ComposePopupView extends AbstractViewNext {
|
|||
Events.sub('window.resize.real', this.resizerTrigger);
|
||||
Events.sub('window.resize.real', _.debounce(this.resizerTrigger, Magics.Time50ms));
|
||||
|
||||
SocialStore.appendDropbox();
|
||||
|
||||
if (this.driveEnabled()) {
|
||||
$.getScript('https://apis.google.com/js/api.js', () => {
|
||||
if (window.gapi) {
|
||||
this.driveVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
window.setInterval(() => {
|
||||
if (this.modalVisibility() && this.oEditor) {
|
||||
this.oEditor.resize();
|
||||
|
|
@ -1306,137 +1258,6 @@ class ComposePopupView extends AbstractViewNext {
|
|||
}, Magics.Time5s);
|
||||
}
|
||||
|
||||
driveCallback(accessToken, data) {
|
||||
if (
|
||||
data &&
|
||||
window.XMLHttpRequest &&
|
||||
window.google &&
|
||||
data[window.google.picker.Response.ACTION] === window.google.picker.Action.PICKED &&
|
||||
data[window.google.picker.Response.DOCUMENTS] &&
|
||||
data[window.google.picker.Response.DOCUMENTS][0] &&
|
||||
data[window.google.picker.Response.DOCUMENTS][0].id
|
||||
) {
|
||||
const request = new window.XMLHttpRequest();
|
||||
request.open(
|
||||
'GET',
|
||||
'https://www.googleapis.com/drive/v2/files/' + data[window.google.picker.Response.DOCUMENTS][0].id
|
||||
);
|
||||
request.setRequestHeader('Authorization', 'Bearer ' + accessToken);
|
||||
request.addEventListener('load', () => {
|
||||
if (request && request.responseText) {
|
||||
const response = window.JSON.parse(request.responseText),
|
||||
fExport = (item, mimeType, ext) => {
|
||||
if (item && item.exportLinks) {
|
||||
if (item.exportLinks[mimeType]) {
|
||||
response.downloadUrl = item.exportLinks[mimeType];
|
||||
response.title = item.title + '.' + ext;
|
||||
response.mimeType = mimeType;
|
||||
} else if (item.exportLinks['application/pdf']) {
|
||||
response.downloadUrl = item.exportLinks['application/pdf'];
|
||||
response.title = item.title + '.pdf';
|
||||
response.mimeType = 'application/pdf';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (response && !response.downloadUrl && response.mimeType && response.exportLinks) {
|
||||
switch (response.mimeType.toString().toLowerCase()) {
|
||||
case 'application/vnd.google-apps.document':
|
||||
fExport(response, 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'docx');
|
||||
break;
|
||||
case 'application/vnd.google-apps.spreadsheet':
|
||||
fExport(response, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'xlsx');
|
||||
break;
|
||||
case 'application/vnd.google-apps.drawing':
|
||||
fExport(response, 'image/png', 'png');
|
||||
break;
|
||||
case 'application/vnd.google-apps.presentation':
|
||||
fExport(response, 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'pptx');
|
||||
break;
|
||||
default:
|
||||
fExport(response, 'application/pdf', 'pdf');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (response && response.downloadUrl) {
|
||||
this.addDriveAttachment(response, accessToken);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
request.send();
|
||||
}
|
||||
}
|
||||
|
||||
driveCreatePiker(authToken) {
|
||||
if (window.gapi && authToken && authToken.access_token) {
|
||||
window.gapi.load('picker', {
|
||||
callback: () => {
|
||||
if (window.google && window.google.picker) {
|
||||
const drivePicker = new window.google.picker.PickerBuilder()
|
||||
// .addView(window.google.picker.ViewId.FOLDERS)
|
||||
.addView(window.google.picker.ViewId.DOCS)
|
||||
.setAppId(Settings.settingsGet('GoogleClientID'))
|
||||
.setOAuthToken(authToken.access_token)
|
||||
.setCallback(_.bind(this.driveCallback, this, authToken.access_token))
|
||||
.enableFeature(window.google.picker.Feature.NAV_HIDDEN)
|
||||
// .setOrigin(window.location.protocol + '//' + window.location.host)
|
||||
.build();
|
||||
|
||||
drivePicker.setVisible(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
driveOpenPopup() {
|
||||
if (window.gapi) {
|
||||
window.gapi.load('auth', {
|
||||
callback: () => {
|
||||
const authToken = window.gapi.auth.getToken(),
|
||||
fResult = (authResult) => {
|
||||
if (authResult && !authResult.error) {
|
||||
const token = window.gapi.auth.getToken();
|
||||
if (token) {
|
||||
this.driveCreatePiker(token);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
if (!authToken) {
|
||||
window.gapi.auth.authorize(
|
||||
{
|
||||
'client_id': Settings.settingsGet('GoogleClientID'),
|
||||
'scope': 'https://www.googleapis.com/auth/drive.readonly',
|
||||
'immediate': true
|
||||
},
|
||||
(authResult) => {
|
||||
if (!fResult(authResult)) {
|
||||
window.gapi.auth.authorize(
|
||||
{
|
||||
'client_id': Settings.settingsGet('GoogleClientID'),
|
||||
'scope': 'https://www.googleapis.com/auth/drive.readonly',
|
||||
'immediate': false
|
||||
},
|
||||
fResult
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
} else {
|
||||
this.driveCreatePiker(authToken);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} id
|
||||
* @returns {?Object}
|
||||
|
|
@ -1643,83 +1464,6 @@ class ComposePopupView extends AbstractViewNext {
|
|||
return attachment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} dropboxFile
|
||||
* @returns {boolean}
|
||||
*/
|
||||
addDropboxAttachment(dropboxFile) {
|
||||
const attachmentSizeLimit = pInt(Settings.settingsGet('AttachmentLimit')),
|
||||
mSize = dropboxFile.bytes,
|
||||
attachment = this.addAttachmentHelper(dropboxFile.link, dropboxFile.name, mSize);
|
||||
|
||||
if (0 < mSize && 0 < attachmentSizeLimit && attachmentSizeLimit < mSize) {
|
||||
attachment.uploading(false).complete(true);
|
||||
attachment.error(i18n('UPLOAD/ERROR_FILE_IS_TOO_BIG'));
|
||||
return false;
|
||||
}
|
||||
|
||||
Remote.composeUploadExternals(
|
||||
(statusResult, data) => {
|
||||
let result = false;
|
||||
attachment.uploading(false).complete(true);
|
||||
|
||||
if (StorageResultType.Success === statusResult && data && data.Result) {
|
||||
if (data.Result[attachment.id]) {
|
||||
result = true;
|
||||
attachment.tempName(data.Result[attachment.id]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
attachment.error(getUploadErrorDescByCode(UploadErrorCode.FileNoUploaded));
|
||||
}
|
||||
},
|
||||
[dropboxFile.link]
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} driveFile
|
||||
* @param {string} accessToken
|
||||
* @returns {boolean}
|
||||
*/
|
||||
addDriveAttachment(driveFile, accessToken) {
|
||||
const attachmentSizeLimit = pInt(Settings.settingsGet('AttachmentLimit')),
|
||||
size = driveFile.fileSize ? pInt(driveFile.fileSize) : 0,
|
||||
attachment = this.addAttachmentHelper(driveFile.downloadUrl, driveFile.title, size);
|
||||
|
||||
if (0 < size && 0 < attachmentSizeLimit && attachmentSizeLimit < size) {
|
||||
attachment.uploading(false).complete(true);
|
||||
attachment.error(i18n('UPLOAD/ERROR_FILE_IS_TOO_BIG'));
|
||||
return false;
|
||||
}
|
||||
|
||||
Remote.composeUploadDrive(
|
||||
(statusResult, data) => {
|
||||
let result = false;
|
||||
attachment.uploading(false).complete(true);
|
||||
|
||||
if (StorageResultType.Success === statusResult && data && data.Result) {
|
||||
if (data.Result[attachment.id]) {
|
||||
result = true;
|
||||
attachment.tempName(data.Result[attachment.id][0]);
|
||||
attachment.size(pInt(data.Result[attachment.id][1]));
|
||||
}
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
attachment.error(getUploadErrorDescByCode(UploadErrorCode.FileNoUploaded));
|
||||
}
|
||||
},
|
||||
driveFile.downloadUrl,
|
||||
accessToken
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {MessageModel} message
|
||||
* @param {string} type
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import {
|
|||
import { trim, inArray, pInt, convertLangName, triggerAutocompleteInputChange } from 'Common/Utils';
|
||||
|
||||
import { $win } from 'Common/Globals';
|
||||
import { socialFacebook, socialGoogle, socialTwitter } from 'Common/Links';
|
||||
import { getNotification, getNotificationFromResponse, reload as translatorReload } from 'Common/Translator';
|
||||
|
||||
import * as Plugins from 'Common/Plugins';
|
||||
|
|
@ -141,19 +140,6 @@ class LoginUserView extends AbstractViewNext {
|
|||
|
||||
this.signMeVisibility = ko.computed(() => LoginSignMeType.Unused !== this.signMeType());
|
||||
|
||||
this.facebookLoginEnabled = ko.observable(false);
|
||||
this.googleLoginEnabled = ko.observable(false);
|
||||
this.googleGmailLoginEnabled = ko.observable(false);
|
||||
this.twitterLoginEnabled = ko.observable(false);
|
||||
|
||||
this.socialLoginEnabled = ko.computed(() => {
|
||||
const bF = this.facebookLoginEnabled(),
|
||||
bG = this.googleLoginEnabled(),
|
||||
bT = this.twitterLoginEnabled();
|
||||
|
||||
return bF || bG || bT;
|
||||
});
|
||||
|
||||
if (Settings.settingsGet('AdditionalLoginError') && !this.submitError()) {
|
||||
this.submitError(Settings.settingsGet('AdditionalLoginError'));
|
||||
}
|
||||
|
|
@ -163,30 +149,6 @@ class LoginUserView extends AbstractViewNext {
|
|||
return `left=200,top=100,width=${wh},height=${wh},menubar=no,status=no,resizable=yes,scrollbars=yes`;
|
||||
}
|
||||
|
||||
@command((self) => !self.submitRequest() && self.facebookLoginEnabled())
|
||||
facebookCommand() {
|
||||
window.open(socialFacebook(), 'Facebook', this.windowOpenFeatures(500));
|
||||
return true;
|
||||
}
|
||||
|
||||
@command((self) => !self.submitRequest() && self.googleLoginEnabled())
|
||||
googleCommand() {
|
||||
window.open(socialGoogle(), 'Google', this.windowOpenFeatures(550));
|
||||
return true;
|
||||
}
|
||||
|
||||
@command((self) => !self.submitRequest() && self.googleGmailLoginEnabled())
|
||||
googleGmailCommand() {
|
||||
window.open(socialGoogle(true), 'Google', this.windowOpenFeatures(550));
|
||||
return true;
|
||||
}
|
||||
|
||||
@command((self) => !self.submitRequest() && self.twitterLoginEnabled())
|
||||
twitterCommand() {
|
||||
window.open(socialTwitter(), 'Twitter', this.windowOpenFeatures(500));
|
||||
return true;
|
||||
}
|
||||
|
||||
@command((self) => !self.submitRequest())
|
||||
submitCommand() {
|
||||
triggerAutocompleteInputChange();
|
||||
|
|
@ -328,25 +290,7 @@ class LoginUserView extends AbstractViewNext {
|
|||
onBuild() {
|
||||
const signMeLocal = Local.get(ClientSideKeyName.LastSignMe),
|
||||
signMe = (Settings.settingsGet('SignMe') || 'unused').toLowerCase(),
|
||||
jsHash = Settings.appSettingsGet('jsHash'),
|
||||
fSocial = (iErrorCode) => {
|
||||
iErrorCode = pInt(iErrorCode);
|
||||
if (0 === iErrorCode) {
|
||||
this.submitRequest(true);
|
||||
getApp().loginAndLogoutReload(false);
|
||||
} else {
|
||||
this.submitError(getNotification(iErrorCode));
|
||||
}
|
||||
};
|
||||
|
||||
this.facebookLoginEnabled(!!Settings.settingsGet('AllowFacebookSocial'));
|
||||
this.twitterLoginEnabled(!!Settings.settingsGet('AllowTwitterSocial'));
|
||||
this.googleLoginEnabled(
|
||||
!!Settings.settingsGet('AllowGoogleSocial') && !!Settings.settingsGet('AllowGoogleSocialAuth')
|
||||
);
|
||||
this.googleGmailLoginEnabled(
|
||||
!!Settings.settingsGet('AllowGoogleSocial') && !!Settings.settingsGet('AllowGoogleSocialAuthGmail')
|
||||
);
|
||||
jsHash = Settings.appSettingsGet('jsHash');
|
||||
|
||||
switch (signMe) {
|
||||
case LoginSignMeTypeAsString.DefaultOff:
|
||||
|
|
@ -375,18 +319,6 @@ class LoginUserView extends AbstractViewNext {
|
|||
this.email(AppStore.devEmail);
|
||||
this.password(AppStore.devPassword);
|
||||
|
||||
if (this.googleLoginEnabled() || this.googleGmailLoginEnabled()) {
|
||||
window['rl_' + jsHash + '_google_login_service'] = fSocial;
|
||||
}
|
||||
|
||||
if (this.facebookLoginEnabled()) {
|
||||
window['rl_' + jsHash + '_facebook_login_service'] = fSocial;
|
||||
}
|
||||
|
||||
if (this.twitterLoginEnabled()) {
|
||||
window['rl_' + jsHash + '_twitter_login_service'] = fSocial;
|
||||
}
|
||||
|
||||
_.delay(() => {
|
||||
LanguageStore.language.subscribe((value) => {
|
||||
this.langRequest(true);
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ import { attachmentDownload } from 'Common/Links';
|
|||
|
||||
import { getUserPic, storeMessageFlagsToCache } from 'Common/Cache';
|
||||
|
||||
import SocialStore from 'Stores/Social';
|
||||
import AppStore from 'Stores/User/App';
|
||||
import SettingsStore from 'Stores/User/Settings';
|
||||
import AccountStore from 'Stores/User/Account';
|
||||
|
|
@ -144,46 +143,6 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
|
|||
this.downloadAsZipLoading = ko.observable(false);
|
||||
this.downloadAsZipError = ko.observable(false).extend({ falseTimeout: 7000 });
|
||||
|
||||
this.saveToOwnCloudAllowed = ko.computed(
|
||||
() => -1 < inArray('owncloud', this.attachmentsActions()) && this.allowAttachmnetControls()
|
||||
);
|
||||
|
||||
this.saveToOwnCloudLoading = ko.observable(false);
|
||||
this.saveToOwnCloudSuccess = ko.observable(false).extend({ falseTimeout: 2000 });
|
||||
this.saveToOwnCloudError = ko.observable(false).extend({ falseTimeout: 7000 });
|
||||
|
||||
this.saveToOwnCloudSuccess.subscribe((v) => {
|
||||
if (v) {
|
||||
this.saveToOwnCloudError(false);
|
||||
}
|
||||
});
|
||||
|
||||
this.saveToOwnCloudError.subscribe((v) => {
|
||||
if (v) {
|
||||
this.saveToOwnCloudSuccess(false);
|
||||
}
|
||||
});
|
||||
|
||||
this.saveToDropboxAllowed = ko.computed(
|
||||
() => -1 < inArray('dropbox', this.attachmentsActions()) && this.allowAttachmnetControls()
|
||||
);
|
||||
|
||||
this.saveToDropboxLoading = ko.observable(false);
|
||||
this.saveToDropboxSuccess = ko.observable(false).extend({ falseTimeout: 2000 });
|
||||
this.saveToDropboxError = ko.observable(false).extend({ falseTimeout: 7000 });
|
||||
|
||||
this.saveToDropboxSuccess.subscribe((v) => {
|
||||
if (v) {
|
||||
this.saveToDropboxError(false);
|
||||
}
|
||||
});
|
||||
|
||||
this.saveToDropboxError.subscribe((v) => {
|
||||
if (v) {
|
||||
this.saveToDropboxSuccess(false);
|
||||
}
|
||||
});
|
||||
|
||||
this.showAttachmnetControls.subscribe((v) => {
|
||||
if (this.message()) {
|
||||
_.each(this.message().attachments(), (item) => {
|
||||
|
|
@ -243,9 +202,6 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
|
|||
this.spamCommand = createCommandActionHelper(FolderType.Spam, true);
|
||||
this.notSpamCommand = createCommandActionHelper(FolderType.NotSpam, true);
|
||||
|
||||
this.dropboxEnabled = SocialStore.dropbox.enabled;
|
||||
this.dropboxApiKey = SocialStore.dropbox.apiKey;
|
||||
|
||||
// viewer
|
||||
|
||||
this.viewBodyTopValue = ko.observable(0);
|
||||
|
|
@ -606,8 +562,6 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
|
|||
Local.set(ClientSideKeyName.MessageHeaderFullInfo, value ? '1' : '0');
|
||||
});
|
||||
|
||||
SocialStore.appendDropbox();
|
||||
|
||||
this.oHeaderDom = $('.messageItemHeader', dom);
|
||||
this.oHeaderDom = this.oHeaderDom[0] ? this.oHeaderDom : null;
|
||||
|
||||
|
|
@ -956,77 +910,6 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
|
|||
}
|
||||
}
|
||||
|
||||
saveToOwnCloud() {
|
||||
const hashes = this.getAttachmentsHashes();
|
||||
if (0 < hashes.length) {
|
||||
Promises.attachmentsActions('OwnCloud', hashes, this.saveToOwnCloudLoading)
|
||||
.then((result) => {
|
||||
if (result && result.Result) {
|
||||
this.saveToOwnCloudSuccess(true);
|
||||
} else {
|
||||
this.saveToOwnCloudError(true);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
this.saveToOwnCloudError(true);
|
||||
});
|
||||
} else {
|
||||
this.highlightUnselectedAttachments(true);
|
||||
}
|
||||
}
|
||||
|
||||
saveToDropbox() {
|
||||
const files = [],
|
||||
hashes = this.getAttachmentsHashes();
|
||||
|
||||
if (0 < hashes.length) {
|
||||
if (window.Dropbox) {
|
||||
Promises.attachmentsActions('Dropbox', hashes, this.saveToDropboxLoading)
|
||||
.then((result) => {
|
||||
if (result && result.Result && result.Result.Url && result.Result.ShortLife && result.Result.Files) {
|
||||
if (window.Dropbox && isArray(result.Result.Files)) {
|
||||
_.each(result.Result.Files, (item) => {
|
||||
files.push({
|
||||
url: result.Result.Url + attachmentDownload(item.Hash, result.Result.ShortLife),
|
||||
filename: item.FileName
|
||||
});
|
||||
});
|
||||
|
||||
window.Dropbox.save({
|
||||
files: files,
|
||||
progress: () => {
|
||||
this.saveToDropboxLoading(true);
|
||||
this.saveToDropboxError(false);
|
||||
this.saveToDropboxSuccess(false);
|
||||
},
|
||||
cancel: () => {
|
||||
this.saveToDropboxSuccess(false);
|
||||
this.saveToDropboxError(false);
|
||||
this.saveToDropboxLoading(false);
|
||||
},
|
||||
success: () => {
|
||||
this.saveToDropboxSuccess(true);
|
||||
this.saveToDropboxLoading(false);
|
||||
},
|
||||
error: () => {
|
||||
this.saveToDropboxError(true);
|
||||
this.saveToDropboxLoading(false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.saveToDropboxError(true);
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
this.saveToDropboxError(true);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.highlightUnselectedAttachments(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {MessageModel} oMessage
|
||||
* @returns {void}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue