snappymail/plugins/custom-settings-tab/js/CustomUserSettings.js

81 lines
1.3 KiB
JavaScript

(function () {
if (!window.rl)
{
return;
}
/**
* @constructor
*/
function CustomUserSettings()
{
this.userSkype = ko.observable('');
this.userFacebook = ko.observable('');
this.loading = ko.observable(false);
this.saving = ko.observable(false);
this.savingOrLoading = ko.computed(function () {
return this.loading() || this.saving();
}, this);
}
CustomUserSettings.prototype.customJsonSaveData = function ()
{
var self = this;
if (this.saving())
{
return false;
}
this.saving(true);
rl.pluginRemoteRequest((iError, oData) => {
self.saving(false);
if (!iError)
{
// true
}
else if (rl.Enums.StorageResultType.Abort === iError) {
// show abort
}
else
{
// false
}
}, 'JsonSaveCustomUserData', {
'UserSkype': this.userSkype(),
'UserFacebook': this.userFacebook()
});
};
CustomUserSettings.prototype.onBuild = function () // special function
{
var self = this;
this.loading(true);
rl.pluginRemoteRequest((iError, oData) => {
self.loading(false);
if (!iError)
{
self.userSkype(oData.Result.UserSkype || '');
self.userFacebook(oData.Result.UserFacebook || '');
}
}, 'JsonGetCustomUserData');
};
rl.addSettingsViewModel(CustomUserSettings, 'PluginCustomSettingsTab',
'SETTINGS_CUSTOM_PLUGIN/TAB_NAME', 'custom');
}());