Added export contacts (vCard)

This commit is contained in:
RainLoop Team 2014-04-29 00:34:34 +04:00
parent c25b5bfef7
commit c248292f07
37 changed files with 489 additions and 237 deletions

View file

@ -1,5 +1,5 @@
/*! RainLoop Webmail Main Module (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (window, $, ko, crossroads, hasher, moment, Jua, _, ifvisible, key) {
/*! RainLoop Webmail Main Module (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (window, $, ko, crossroads, hasher, moment, Jua, _, ifvisible, key) {
'use strict';
@ -75,7 +75,7 @@ var
$document = $(window.document),
NotificationClass = window.Notification && window.Notification.requestPermission ? window.Notification : null
;
;
/*jshint onevar: false*/
/**
* @type {?RainLoopApp}
@ -86,7 +86,7 @@ var
$proxyDiv = $('<div></div>')
;
/*jshint onevar: true*/
/**
* @type {?}
*/
@ -235,7 +235,7 @@ if (Globals.bAllowPdfPreview && navigator && navigator.mimeTypes)
return oType && 'application/pdf' === oType.type;
});
}
Consts.Defaults = {};
Consts.Values = {};
Consts.DataImages = {};
@ -353,7 +353,7 @@ Consts.DataImages.UserDotPic = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA
* @type {string}
*/
Consts.DataImages.TranspPic = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII=';
/**
* @enum {string}
*/
@ -725,7 +725,7 @@ Enums.Notification = {
'UnknownNotification': 999,
'UnknownError': 999
};
Utils.trim = $.trim;
Utils.inArray = $.inArray;
Utils.isArray = _.isArray;
@ -2463,7 +2463,7 @@ Utils.detectDropdownVisibility = _.debounce(function () {
Globals.dropdownVisibility(!!_.find(BootstrapDropdowns, function (oItem) {
return oItem.hasClass('open');
}));
}, 50);
}, 50);
// Base64 encode / decode
// http://www.webtoolkit.info/
@ -2626,7 +2626,7 @@ Base64 = {
}
};
/*jslint bitwise: false*/
/*jslint bitwise: false*/
ko.bindingHandlers.tooltip = {
'init': function (oElement, fValueAccessor) {
if (!Globals.bMobileDevice)
@ -3333,7 +3333,7 @@ ko.observable.fn.validateFunc = function (fFunc)
return this;
};
/**
* @constructor
*/
@ -3561,6 +3561,22 @@ LinkBuilder.prototype.getUserPicUrlFromHash = function (sHash)
return this.sServer + '/Raw/' + this.sSpecSuffix + '/UserPic/' + sHash + '/' + this.sVersion + '/';
};
/**
* @return {string}
*/
LinkBuilder.prototype.exportContactsVcf = function ()
{
return this.sServer + '/Raw/' + this.sSpecSuffix + '/ContactsVcf/';
};
/**
* @return {string}
*/
LinkBuilder.prototype.exportContactsCsv = function ()
{
return this.sServer + '/Raw/' + this.sSpecSuffix + '/ContactsCsv/';
};
/**
* @return {string}
*/
@ -3631,7 +3647,7 @@ LinkBuilder.prototype.socialFacebook = function ()
{
return this.sServer + 'SocialFacebook' + ('' !== this.sSpecSuffix ? '/' + this.sSpecSuffix + '/' : '');
};
/**
* @type {Object}
*/
@ -3725,7 +3741,7 @@ Plugins.settingsGet = function (sPluginSection, sName)
};
function NewHtmlEditorWrapper(oElement, fOnBlur, fOnReady, fOnModeChange)
{
var self = this;
@ -3945,7 +3961,7 @@ NewHtmlEditorWrapper.prototype.clear = function (bFocus)
this.setHtml('', bFocus);
};
/**
* @constructor
* @param {koProperty} oKoList
@ -4653,7 +4669,7 @@ Selector.prototype.on = function (sEventName, fCallback)
{
this.oCallbacks[sEventName] = fCallback;
};
/**
* @constructor
*/
@ -4727,7 +4743,7 @@ CookieDriver.prototype.get = function (sKey)
return mResult;
};
/**
* @constructor
*/
@ -4798,7 +4814,7 @@ LocalStorageDriver.prototype.get = function (sKey)
return mResult;
};
/**
* @constructor
*/
@ -4841,7 +4857,7 @@ LocalStorage.prototype.get = function (iKey)
{
return this.oDriver ? this.oDriver.get('p' + iKey) : null;
};
/**
* @constructor
*/
@ -4854,7 +4870,7 @@ KnoinAbstractBoot.prototype.bootstart = function ()
{
};
/**
* @param {string=} sPosition = ''
* @param {string=} sTemplate = ''
@ -4940,7 +4956,7 @@ KnoinAbstractViewModel.prototype.registerPopupEscapeKey = function ()
return true;
});
};
/**
* @param {string} sScreenName
* @param {?=} aViewModels = []
@ -5016,7 +5032,7 @@ KnoinAbstractScreen.prototype.__start = function ()
this.oCross = oRoute;
}
};
/**
* @constructor
*/
@ -5414,7 +5430,7 @@ Knoin.prototype.bootstart = function ()
};
kn = new Knoin();
/**
* @param {string=} sEmail
* @param {string=} sName
@ -5778,7 +5794,7 @@ EmailModel.prototype.inputoTagLine = function ()
{
return 0 < this.name.length ? this.name + ' (' + this.email + ')' : this.email;
};
/**
* @constructor
*/
@ -5895,7 +5911,7 @@ ContactModel.prototype.lineAsCcc = function ()
return aResult.join(' ');
};
/**
* @param {number=} iType = Enums.ContactPropertyType.Unknown
* @param {string=} sTypeStr = ''
@ -5919,7 +5935,7 @@ function ContactPropertyModel(iType, sTypeStr, sValue, bFocused, sPlaceholder)
return sPlaceholder ? Utils.i18n(sPlaceholder) : '';
}, this);
}
/**
* @constructor
*/
@ -6155,7 +6171,7 @@ AttachmentModel.prototype.iconClass = function ()
return sClass;
};
/**
* @constructor
* @param {string} sId
@ -6216,7 +6232,7 @@ ComposeAttachmentModel.prototype.initByUploadJson = function (oJsonAttachment)
}
return bResult;
};
};
/**
* @constructor
*/
@ -7410,7 +7426,7 @@ MessageModel.prototype.flagHash = function ()
return [this.deleted(), this.unseen(), this.flagged(), this.answered(), this.forwarded(),
this.isReadReceipt()].join('');
};
/**
* @constructor
*/
@ -7742,7 +7758,7 @@ FolderModel.prototype.printableFullName = function ()
{
return this.fullName.split(this.delimiter).join(' / ');
};
/**
* @param {string} sEmail
* @param {boolean=} bCanBeDelete = true
@ -7763,7 +7779,7 @@ AccountModel.prototype.email = '';
AccountModel.prototype.changeAccountLink = function ()
{
return RL.link().change(this.email);
};
};
/**
* @param {string} sId
* @param {string} sEmail
@ -7799,7 +7815,7 @@ IdentityModel.prototype.formattedNameForEmail = function ()
var sName = this.name();
return '' === sName ? this.email() : '"' + Utils.quoteName(sName) + '" <' + this.email() + '>';
};
/**
* @param {string} iIndex
* @param {string} sGuID
@ -7830,7 +7846,7 @@ OpenPgpKeyModel.prototype.user = '';
OpenPgpKeyModel.prototype.email = '';
OpenPgpKeyModel.prototype.armor = '';
OpenPgpKeyModel.prototype.isPrivate = false;
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -7926,7 +7942,7 @@ PopupsFolderClearViewModel.prototype.onShow = function (oFolder)
this.selectedFolder(oFolder);
}
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -8036,7 +8052,7 @@ PopupsFolderCreateViewModel.prototype.onFocus = function ()
{
this.folderName.focused(true);
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -8149,7 +8165,7 @@ PopupsFolderSystemViewModel.prototype.onShow = function (iNotificationType)
this.notification(sNotification);
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -9638,7 +9654,7 @@ PopupsComposeViewModel.prototype.triggerForResize = function ()
this.editorResizeThrottle();
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -9658,6 +9674,7 @@ function PopupsContactsViewModel()
this.allowContactsSync = RL.data().allowContactsSync;
this.enableContactsSync = RL.data().enableContactsSync;
this.allowExport = !Globals.bMobileDevice;
this.search = ko.observable('');
this.contactsCount = ko.observable(0);
@ -9956,6 +9973,16 @@ PopupsContactsViewModel.prototype.addNewPhone = function ()
this.addNewProperty(Enums.ContactPropertyType.Phone, 'Mobile');
};
PopupsContactsViewModel.prototype.exportVcf = function ()
{
RL.download(RL.link().exportContactsVcf());
};
PopupsContactsViewModel.prototype.exportCsv = function ()
{
RL.download(RL.link().exportContactsCsv());
};
PopupsContactsViewModel.prototype.initUploader = function ()
{
if (this.importUploaderButton())
@ -10223,7 +10250,7 @@ PopupsContactsViewModel.prototype.onHide = function ()
oItem.checked(false);
});
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -10359,7 +10386,7 @@ PopupsAdvancedSearchViewModel.prototype.onFocus = function ()
{
this.fromFocus(true);
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -10476,7 +10503,7 @@ PopupsAddAccountViewModel.prototype.onBuild = function ()
{
this.allowCustomLogin(!!RL.settingsGet('AllowCustomLogin'));
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -10562,7 +10589,7 @@ PopupsAddOpenPgpKeyViewModel.prototype.onFocus = function ()
{
this.key.focus(true);
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -10602,7 +10629,7 @@ PopupsViewOpenPgpKeyViewModel.prototype.onShow = function (oOpenPgpKey)
this.key(oOpenPgpKey.armor);
}
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -10690,7 +10717,7 @@ PopupsGenerateNewOpenPgpKeyViewModel.prototype.onFocus = function ()
{
this.email.focus(true);
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -10930,7 +10957,7 @@ PopupsComposeOpenPgpViewModel.prototype.onShow = function (fCallback, sText, sFr
this.to(aRec);
this.text(sText);
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -11078,7 +11105,7 @@ PopupsIdentityViewModel.prototype.onFocus = function ()
this.email.focused(true);
}
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -11138,7 +11165,7 @@ PopupsLanguagesViewModel.prototype.changeLanguage = function (sLang)
RL.data().mainLanguage(sLang);
this.cancelCommand();
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -11192,7 +11219,7 @@ PopupsTwoFactorTestViewModel.prototype.onFocus = function ()
{
this.code.focused(true);
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -11298,7 +11325,7 @@ PopupsAskViewModel.prototype.onBuild = function ()
}, this));
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -11343,7 +11370,7 @@ PopupsKeyboardShortcutsHelpViewModel.prototype.onBuild = function (oDom)
}
}, this));
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -11655,7 +11682,7 @@ LoginViewModel.prototype.selectLanguage = function ()
kn.showScreenPopup(PopupsLanguagesViewModel);
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -11737,7 +11764,7 @@ AbstractSystemDropDownViewModel.prototype.onBuild = function ()
}
});
};
/**
* @constructor
* @extends AbstractSystemDropDownViewModel
@ -11749,7 +11776,7 @@ function MailBoxSystemDropDownViewModel()
}
Utils.extendAsViewModel('MailBoxSystemDropDownViewModel', MailBoxSystemDropDownViewModel, AbstractSystemDropDownViewModel);
/**
* @constructor
* @extends AbstractSystemDropDownViewModel
@ -11761,7 +11788,7 @@ function SettingsSystemDropDownViewModel()
}
Utils.extendAsViewModel('SettingsSystemDropDownViewModel', SettingsSystemDropDownViewModel, AbstractSystemDropDownViewModel);
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -11954,7 +11981,7 @@ MailBoxFolderListViewModel.prototype.contactsClick = function ()
kn.showScreenPopup(PopupsContactsViewModel);
}
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -12848,7 +12875,7 @@ MailBoxMessageListViewModel.prototype.initUploaderForAppend = function ()
;
return !!oJua;
};
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -13512,7 +13539,7 @@ MailBoxMessageViewViewModel.prototype.readReceipt = function (oMessage)
RL.reloadFlagsCurrentMessageListAndMessageFromCache();
}
};
/**
* @param {?} oScreen
*
@ -13539,7 +13566,7 @@ SettingsMenuViewModel.prototype.backToMailBoxClick = function ()
{
kn.setHash(RL.link().inbox());
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -13572,7 +13599,7 @@ SettingsPaneViewModel.prototype.backToMailBoxClick = function ()
{
kn.setHash(RL.link().inbox());
};
/**
* @constructor
*/
@ -13732,7 +13759,7 @@ SettingsGeneral.prototype.selectLanguage = function ()
{
kn.showScreenPopup(PopupsLanguagesViewModel);
};
/**
* @constructor
*/
@ -13782,7 +13809,7 @@ SettingsContacts.prototype.onBuild = function ()
//{
//
//};
/**
* @constructor
*/
@ -13863,7 +13890,7 @@ SettingsAccounts.prototype.deleteAccount = function (oAccountToRemove)
}
}
};
/**
* @constructor
*/
@ -13951,7 +13978,7 @@ SettingsIdentity.prototype.onBuild = function ()
}, 50);
};
/**
* @constructor
*/
@ -14109,7 +14136,7 @@ SettingsIdentities.prototype.onBuild = function (oDom)
});
}, 50);
};
};
/**
* @constructor
*/
@ -14259,7 +14286,7 @@ SettingsSecurity.prototype.onBuild = function ()
this.processing(true);
RL.remote().getTwoFactor(this.onResult);
};
/**
* @constructor
*/
@ -14326,7 +14353,7 @@ function SettingsSocialScreen()
}
Utils.addSettingsViewModel(SettingsSocialScreen, 'SettingsSocial', 'SETTINGS_LABELS/LABEL_SOCIAL_NAME', 'social');
/**
* @constructor
*/
@ -14431,7 +14458,7 @@ SettingsChangePasswordScreen.prototype.onChangePasswordResponse = function (sRes
Utils.getNotification(Enums.Notification.CouldNotSaveNewPassword));
}
};
/**
* @constructor
*/
@ -14626,7 +14653,7 @@ SettingsFolders.prototype.unSubscribeFolder = function (oFolder)
oFolder.subScribed(false);
};
/**
* @constructor
*/
@ -14851,7 +14878,7 @@ SettingsThemes.prototype.initCustomThemeUploader = function ()
return false;
};
/**
* @constructor
*/
@ -14919,7 +14946,7 @@ SettingsOpenPGP.prototype.deleteOpenPgpKey = function (oOpenPgpKeyToRemove)
RL.reloadOpenPgpKeys();
}
}
};
};
/**
* @constructor
*/
@ -15049,7 +15076,7 @@ AbstractData.prototype.populateDataOnStart = function()
this.contactsIsAllowed(!!RL.settingsGet('ContactsIsAllowed'));
};
/**
* @constructor
* @extends AbstractData
@ -15137,6 +15164,9 @@ function WebMailDataStorage()
this.contacts.loading = ko.observable(false).extend({'throttle': 200});
this.contacts.importing = ko.observable(false).extend({'throttle': 200});
this.contacts.syncing = ko.observable(false).extend({'throttle': 200});
this.contacts.exportingVcf = ko.observable(false).extend({'throttle': 200});
this.contacts.exportingCsv = ko.observable(false).extend({'throttle': 200});
this.contacts.skipNextSync = false;
this.allowContactsSync = ko.observable(false);
@ -16301,7 +16331,7 @@ WebMailDataStorage.prototype.findSelfPrivateKey = function (sPassword)
{
return this.findPrivateKeyByEmail(this.accountEmail(), sPassword);
};
/**
* @constructor
*/
@ -16575,7 +16605,7 @@ AbstractAjaxRemoteStorage.prototype.jsVersion = function (fCallback, sVersion)
'Version': sVersion
});
};
/**
* @constructor
* @extends AbstractAjaxRemoteStorage
@ -17365,7 +17395,7 @@ WebMailAjaxRemoteStorage.prototype.socialUsers = function (fCallback)
this.defaultRequest(fCallback, 'SocialUsers');
};
/**
* @constructor
*/
@ -17442,7 +17472,7 @@ AbstractCacheStorage.prototype.setEmailsPicsHashesData = function (oData)
{
this.oEmailsPicsHashes = oData;
};
/**
* @constructor
* @extends AbstractCacheStorage
@ -17760,7 +17790,7 @@ WebMailCacheStorage.prototype.storeMessageFlagsToCacheByFolderAndUid = function
this.setMessageFlagsToCache(sFolder, sUid, aFlags);
}
};
/**
* @param {Array} aViewModels
* @constructor
@ -17938,7 +17968,7 @@ AbstractSettings.prototype.routes = function ()
['', oRules]
];
};
/**
* @constructor
* @extends KnoinAbstractScreen
@ -17953,7 +17983,7 @@ _.extend(LoginScreen.prototype, KnoinAbstractScreen.prototype);
LoginScreen.prototype.onShow = function ()
{
RL.setTitle('');
};
};
/**
* @constructor
* @extends KnoinAbstractScreen
@ -18124,7 +18154,7 @@ MailBoxScreen.prototype.routes = function ()
[/^([^\/]*)$/, {'normalize_': fNormS}]
];
};
/**
* @constructor
* @extends AbstractSettings
@ -18153,7 +18183,7 @@ SettingsScreen.prototype.onShow = function ()
RL.setTitle(this.sSettingsTitle);
RL.data().keyScope(Enums.KeyState.Settings);
};
/**
* @constructor
* @extends KnoinAbstractBoot
@ -18489,7 +18519,7 @@ AbstractApp.prototype.bootstart = function ()
ssm.ready();
};
/**
* @constructor
* @extends AbstractApp
@ -19771,7 +19801,7 @@ RainLoopApp.prototype.bootstart = function ()
* @type {RainLoopApp}
*/
RL = new RainLoopApp();
$html.addClass(Globals.bMobileDevice ? 'mobile' : 'no-mobile');
$window.keydown(Utils.killCtrlAandS).keyup(Utils.killCtrlAandS);
@ -19822,9 +19852,9 @@ window['__RLBOOT'] = function (fCall) {
window['__RLBOOT'] = null;
});
};
if (window.SimplePace) {
window.SimplePace.add(10);
}
}
}(window, jQuery, ko, crossroads, hasher, moment, Jua, _, ifvisible, key));