Code refactoring

This commit is contained in:
RainLoop Team 2014-10-18 17:43:44 +04:00
parent 345e7c58af
commit 8cf8b94d39
103 changed files with 664 additions and 659 deletions

View file

@ -0,0 +1,56 @@
(function () {
'use strict';
var
ko = require('ko'),
Remote = require('Storage/User/Remote'),
Data = require('Storage/User/Data')
;
/**
* @constructor
*/
function ContactsUserSetting()
{
this.contactsAutosave = Data.contactsAutosave;
this.allowContactsSync = Data.allowContactsSync;
this.enableContactsSync = Data.enableContactsSync;
this.contactsSyncUrl = Data.contactsSyncUrl;
this.contactsSyncUser = Data.contactsSyncUser;
this.contactsSyncPass = Data.contactsSyncPass;
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);
}
ContactsUserSetting.prototype.onBuild = function ()
{
Data.contactsAutosave.subscribe(function (bValue) {
Remote.saveSettings(null, {
'ContactsAutosave': bValue ? '1' : '0'
});
});
};
module.exports = ContactsUserSetting;
}());