Plugin system enhancements (Custom user's settings tabs)

This commit is contained in:
RainLoop Team 2015-02-19 05:01:59 +04:00
parent a3f28b09f6
commit 9a58fd0a66
13 changed files with 398 additions and 16 deletions

View file

@ -0,0 +1,73 @@
(function () {
/**
* @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.customAjaxSaveData = function ()
{
var self = this;
if (this.saving())
{
return false;
}
this.saving(true);
window.rl.pluginRemoteRequest(function (sResult, oData) {
self.saving(false);
if (window.rl.Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
// true
}
else
{
// false
}
}, 'AjaxSaveCustomUserData', {
'UserSkype': this.userSkype(),
'UserFacebook': this.userFacebook()
});
};
CustomUserSettings.prototype.onBuild = function () // special function
{
var self = this;
this.loading(true);
window.rl.pluginRemoteRequest(function (sResult, oData) {
self.loading(false);
if (window.rl.Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
self.userSkype(oData.Result.UserSkype || '');
self.userFacebook(oData.Result.UserFacebook || '');
}
}, 'AjaxGetCustomUserData');
};
window.rl.addSettingsViewModel(CustomUserSettings, 'PluginCustomSettingsTag',
'SETTINGS_CUSTOM_PLUGIN/TAB_NAME', 'custom');
}());