2014-08-21 23:08:34 +08:00
|
|
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
|
|
|
|
|
|
|
(function (module) {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var
|
|
|
|
ko = require('../External/ko.js'),
|
|
|
|
|
|
|
|
Utils = require('../Common/Utils.js'),
|
2014-08-22 23:08:56 +08:00
|
|
|
|
|
|
|
Remote = require('../Storages/WebMailAjaxRemoteStorage.js'),
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2014-08-22 23:08:56 +08:00
|
|
|
Data = require('../Storages/WebMailDataStorage.js')
|
2014-08-21 23:08:34 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
function SettingsContacts()
|
|
|
|
{
|
2014-08-22 23:08:56 +08:00
|
|
|
this.contactsAutosave = Data.contactsAutosave;
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2014-08-22 23:08:56 +08:00
|
|
|
this.allowContactsSync = Data.allowContactsSync;
|
|
|
|
this.enableContactsSync = Data.enableContactsSync;
|
|
|
|
this.contactsSyncUrl = Data.contactsSyncUrl;
|
|
|
|
this.contactsSyncUser = Data.contactsSyncUser;
|
|
|
|
this.contactsSyncPass = Data.contactsSyncPass;
|
2014-08-21 23:08:34 +08:00
|
|
|
|
|
|
|
this.saveTrigger = ko.computed(function () {
|
|
|
|
return [
|
|
|
|
this.enableContactsSync() ? '1' : '0',
|
|
|
|
this.contactsSyncUrl(),
|
|
|
|
this.contactsSyncUser(),
|
|
|
|
this.contactsSyncPass()
|
|
|
|
].join('|');
|
|
|
|
}, this).extend({'throttle': 500});
|
|
|
|
|
|
|
|
this.saveTrigger.subscribe(function () {
|
|
|
|
Remote.saveContactsSyncData(null,
|
|
|
|
this.enableContactsSync(),
|
|
|
|
this.contactsSyncUrl(),
|
|
|
|
this.contactsSyncUser(),
|
|
|
|
this.contactsSyncPass()
|
|
|
|
);
|
|
|
|
}, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
SettingsContacts.prototype.onBuild = function ()
|
|
|
|
{
|
2014-08-22 23:08:56 +08:00
|
|
|
Data.contactsAutosave.subscribe(function (bValue) {
|
2014-08-21 23:08:34 +08:00
|
|
|
Remote.saveSettings(Utils.emptyFunction, {
|
|
|
|
'ContactsAutosave': bValue ? '1' : '0'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = SettingsContacts;
|
|
|
|
|
|
|
|
}(module));
|