snappymail/dev/Settings/User/Contacts.js

56 lines
1.2 KiB
JavaScript
Raw Normal View History

2014-08-21 23:08:34 +08:00
2014-09-05 06:49:03 +08:00
(function () {
2014-08-21 23:08:34 +08:00
2014-08-25 23:49:01 +08:00
'use strict';
2014-08-21 23:08:34 +08:00
var
2014-08-25 23:49:01 +08:00
ko = require('ko'),
2014-08-25 15:10:51 +08:00
2014-10-18 21:43:44 +08:00
Remote = require('Storage/User/Remote'),
Data = require('Storage/User/Data')
2014-08-21 23:08:34 +08:00
;
/**
* @constructor
*/
2014-10-18 21:43:44 +08:00
function ContactsUserSetting()
2014-08-21 23:08:34 +08:00
{
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);
}
2014-10-18 21:43:44 +08:00
ContactsUserSetting.prototype.onBuild = function ()
2014-08-21 23:08:34 +08:00
{
2014-08-22 23:08:56 +08:00
Data.contactsAutosave.subscribe(function (bValue) {
Remote.saveSettings(null, {
2014-08-21 23:08:34 +08:00
'ContactsAutosave': bValue ? '1' : '0'
});
});
};
2014-10-18 21:43:44 +08:00
module.exports = ContactsUserSetting;
2014-08-21 23:08:34 +08:00
2014-09-05 06:49:03 +08:00
}());