Code refactoring (5) (es5 -> es2015)

This commit is contained in:
RainLoop Team 2016-07-16 00:29:42 +03:00
parent c148e19ea3
commit cec53b111f
68 changed files with 2210 additions and 2472 deletions

View file

@ -1,51 +1,48 @@
var
ko = require('ko'),
import ko from 'ko';
AppStore = require('Stores/User/App'),
ContactStore = require('Stores/User/Contact'),
import {Magics} from 'Common/Enums';
import {boolToAjax} from 'Common/Utils';
Remote = require('Remote/User/Ajax');
import AppStore from 'Stores/User/App';
import ContactStore from 'Stores/User/Contact';
import Remote from 'Remote/User/Ajax';
/**
* @constructor
*/
function ContactsUserSettings()
class ContactsUserSettings
{
this.contactsAutosave = AppStore.contactsAutosave;
constructor() {
this.contactsAutosave = AppStore.contactsAutosave;
this.allowContactsSync = ContactStore.allowContactsSync;
this.enableContactsSync = ContactStore.enableContactsSync;
this.contactsSyncUrl = ContactStore.contactsSyncUrl;
this.contactsSyncUser = ContactStore.contactsSyncUser;
this.contactsSyncPass = ContactStore.contactsSyncPass;
this.allowContactsSync = ContactStore.allowContactsSync;
this.enableContactsSync = ContactStore.enableContactsSync;
this.contactsSyncUrl = ContactStore.contactsSyncUrl;
this.contactsSyncUser = ContactStore.contactsSyncUser;
this.contactsSyncPass = ContactStore.contactsSyncPass;
this.saveTrigger = ko.computed(function() {
return [
this.saveTrigger = ko.computed(() => [
this.enableContactsSync() ? '1' : '0',
this.contactsSyncUrl(),
this.contactsSyncUser(),
this.contactsSyncPass()
].join('|');
}, this).extend({'throttle': 500});
].join('|')).extend({throttle: Magics.Time500ms});
}
onBuild() {
this.contactsAutosave.subscribe((value) => {
Remote.saveSettings(null, {
'ContactsAutosave': boolToAjax(value)
});
});
this.saveTrigger.subscribe(() => {
Remote.saveContactsSyncData(null,
this.enableContactsSync(),
this.contactsSyncUrl(),
this.contactsSyncUser(),
this.contactsSyncPass()
);
});
}
}
ContactsUserSettings.prototype.onBuild = function()
{
this.contactsAutosave.subscribe(function(bValue) {
Remote.saveSettings(null, {
'ContactsAutosave': bValue ? '1' : '0'
});
});
this.saveTrigger.subscribe(function() {
Remote.saveContactsSyncData(null,
this.enableContactsSync(),
this.contactsSyncUrl(),
this.contactsSyncUser(),
this.contactsSyncPass()
);
}, this);
};
export {ContactsUserSettings, ContactsUserSettings as default};