Special __constructor_end hook to extend js constructors.

This commit is contained in:
RainLoop Team 2013-12-09 19:16:58 +04:00
parent f7106f375c
commit f562d80985
29 changed files with 161 additions and 20 deletions

View file

@ -1116,14 +1116,20 @@ Utils.removeBlockquoteSwitcher = function (oMessageTextBody)
/**
* @param {string} sName
* @param {Function} ViewModelClass
* @param {Function=} AbstractViewModel = KnoinAbstractViewModel
*/
Utils.extendAsViewModel = function (sName, ViewModelClass)
Utils.extendAsViewModel = function (sName, ViewModelClass, AbstractViewModel)
{
if (ViewModelClass)
{
if (!AbstractViewModel)
{
AbstractViewModel = KnoinAbstractViewModel;
}
ViewModelClass.__name = sName;
Plugins.regViewModelHook(sName, ViewModelClass);
_.extend(ViewModelClass.prototype, KnoinAbstractViewModel.prototype);
_.extend(ViewModelClass.prototype, AbstractViewModel.prototype);
}
};

View file

@ -20,6 +20,17 @@ function Knoin()
});
}
/**
* @param {Object} thisObject
*/
Knoin.constructorEnd = function (thisObject)
{
if (Utils.isFunc(thisObject['__constructor_end']))
{
thisObject['__constructor_end'].call(thisObject);
}
};
Knoin.prototype.sDefaultScreenName = '';
Knoin.prototype.oScreens = {};
Knoin.prototype.oBoot = null;

View file

@ -66,6 +66,8 @@ function AdminLoginViewModel()
}, function () {
return !this.submitRequest();
});
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('AdminLoginViewModel', AdminLoginViewModel);

View file

@ -11,6 +11,8 @@ function AdminMenuViewModel(oScreen)
KnoinAbstractViewModel.call(this, 'Left', 'AdminMenu');
this.menu = oScreen.menu;
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('AdminMenuViewModel', AdminMenuViewModel);

View file

@ -10,6 +10,8 @@ function AdminPaneViewModel()
this.adminDomain = ko.observable(RL.settingsGet('AdminDomain'));
this.version = ko.observable(RL.settingsGet('Version'));
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('AdminPaneViewModel', AdminPaneViewModel);

View file

@ -156,6 +156,8 @@ function LoginViewModel()
return bF || bG || bT;
}, this);
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('LoginViewModel', LoginViewModel);

View file

@ -14,6 +14,8 @@ function MailBoxFolderListViewModel()
this.iDropOverTimer = 0;
this.allowContacts = !!RL.settingsGet('ContactsIsAllowed');
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('MailBoxFolderListViewModel', MailBoxFolderListViewModel);

View file

@ -177,6 +177,8 @@ function MailBoxMessageListViewModel()
this.deleteCommand();
}
}, this));
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('MailBoxMessageListViewModel', MailBoxMessageListViewModel);

View file

@ -141,6 +141,8 @@ function MailBoxMessageViewViewModel()
this.messageActiveDom.subscribe(function () {
this.scrollMessageToTop();
}, this);
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('MailBoxMessageViewViewModel', MailBoxMessageViewViewModel);

View file

@ -7,6 +7,7 @@
function MailBoxSystemDropDownViewModel()
{
AbstractSystemDropDownViewModel.call(this);
Knoin.constructorEnd(this);
}
_.extend(MailBoxSystemDropDownViewModel.prototype, AbstractSystemDropDownViewModel.prototype);
Utils.extendAsViewModel('MailBoxSystemDropDownViewModel', MailBoxSystemDropDownViewModel, AbstractSystemDropDownViewModel);

View file

@ -82,6 +82,8 @@ function PopupsActivateViewModel()
}, function () {
return !this.activateProcess() && '' !== this.domain() && '' !== this.key() && !this.activationSuccessed();
});
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsActivateViewModel', PopupsActivateViewModel);

View file

@ -82,6 +82,8 @@ function PopupsAddAccountViewModel()
this.login(this.email());
}
}, this);
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsAddAccountViewModel', PopupsAddAccountViewModel);

View file

@ -27,6 +27,8 @@ function PopupsAdvancedSearchViewModel()
this.cancelCommand();
});
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsAdvancedSearchViewModel', PopupsAdvancedSearchViewModel);

View file

@ -397,6 +397,8 @@ function PopupsComposeViewModel()
});
// this.driveCallback = _.bind(this.driveCallback, this);
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsComposeViewModel', PopupsComposeViewModel);

View file

@ -236,6 +236,8 @@ function PopupsContactsViewModel()
});
this.bDropPageAfterDelete = false;
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsContactsViewModel', PopupsContactsViewModel);

View file

@ -109,6 +109,8 @@ function PopupsDomainViewModel()
this.whiteListCommand = Utils.createCommand(this, function () {
this.whiteListPage(!this.whiteListPage());
});
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsDomainViewModel', PopupsDomainViewModel);

View file

@ -75,6 +75,8 @@ function PopupsFolderClearViewModel()
return !bIsClearing && null !== oFolder;
});
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsFolderClearViewModel', PopupsFolderClearViewModel);

View file

@ -80,6 +80,8 @@ function PopupsFolderCreateViewModel()
});
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsFolderCreateViewModel', PopupsFolderCreateViewModel);

View file

@ -66,6 +66,8 @@ function PopupsFolderSystemViewModel()
this.trashFolder.subscribe(fCallback);
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsFolderSystemViewModel', PopupsFolderSystemViewModel);

View file

@ -94,6 +94,8 @@ function PopupsIdentityViewModel()
this.button = ko.computed(function () {
return Utils.i18n('POPUPS_IDENTITIES/' + (this.edit() ? 'BUTTON_UPDATE_IDENTITY': 'BUTTON_ADD_IDENTITY'));
}, this);
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsIdentityViewModel', PopupsIdentityViewModel);

View file

@ -23,6 +23,8 @@ function PopupsLanguagesViewModel()
RL.data().mainLanguage.subscribe(function () {
this.resetMainLanguage();
}, this);
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsLanguagesViewModel', PopupsLanguagesViewModel);

View file

@ -58,6 +58,8 @@ function PopupsPluginViewModel()
RL.remote().pluginSettingsUpdate(this.onPluginSettingsUpdateResponse, oList);
}, this.hasConfiguration);
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsPluginViewModel', PopupsPluginViewModel);

View file

@ -11,6 +11,8 @@ function SettingsMenuViewModel(oScreen)
KnoinAbstractViewModel.call(this, 'Left', 'SettingsMenu');
this.menu = oScreen.menu;
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('SettingsMenuViewModel', SettingsMenuViewModel);

View file

@ -7,6 +7,8 @@
function SettingsPaneViewModel()
{
KnoinAbstractViewModel.call(this, 'Right', 'SettingsPane');
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('SettingsPaneViewModel', SettingsPaneViewModel);

View file

@ -7,6 +7,7 @@
function SettingsSystemDropDownViewModel()
{
AbstractSystemDropDownViewModel.call(this);
Knoin.constructorEnd(this);
}
_.extend(SettingsSystemDropDownViewModel.prototype, AbstractSystemDropDownViewModel.prototype);
Utils.extendAsViewModel('SettingsSystemDropDownViewModel', SettingsSystemDropDownViewModel, AbstractSystemDropDownViewModel);

View file

@ -1703,14 +1703,20 @@ Utils.removeBlockquoteSwitcher = function (oMessageTextBody)
/**
* @param {string} sName
* @param {Function} ViewModelClass
* @param {Function=} AbstractViewModel = KnoinAbstractViewModel
*/
Utils.extendAsViewModel = function (sName, ViewModelClass)
Utils.extendAsViewModel = function (sName, ViewModelClass, AbstractViewModel)
{
if (ViewModelClass)
{
if (!AbstractViewModel)
{
AbstractViewModel = KnoinAbstractViewModel;
}
ViewModelClass.__name = sName;
Plugins.regViewModelHook(sName, ViewModelClass);
_.extend(ViewModelClass.prototype, KnoinAbstractViewModel.prototype);
_.extend(ViewModelClass.prototype, AbstractViewModel.prototype);
}
};
@ -3613,6 +3619,17 @@ function Knoin()
});
}
/**
* @param {Object} thisObject
*/
Knoin.constructorEnd = function (thisObject)
{
if (Utils.isFunc(thisObject['__constructor_end']))
{
thisObject['__constructor_end'].call(thisObject);
}
};
Knoin.prototype.sDefaultScreenName = '';
Knoin.prototype.oScreens = {};
Knoin.prototype.oBoot = null;
@ -4501,6 +4518,8 @@ function PopupsDomainViewModel()
this.whiteListCommand = Utils.createCommand(this, function () {
this.whiteListPage(!this.whiteListPage());
});
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsDomainViewModel', PopupsDomainViewModel);
@ -4654,6 +4673,8 @@ function PopupsPluginViewModel()
RL.remote().pluginSettingsUpdate(this.onPluginSettingsUpdateResponse, oList);
}, this.hasConfiguration);
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsPluginViewModel', PopupsPluginViewModel);
@ -4788,6 +4809,8 @@ function PopupsActivateViewModel()
}, function () {
return !this.activateProcess() && '' !== this.domain() && '' !== this.key() && !this.activationSuccessed();
});
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsActivateViewModel', PopupsActivateViewModel);
@ -4837,6 +4860,8 @@ function PopupsLanguagesViewModel()
RL.data().mainLanguage.subscribe(function () {
this.resetMainLanguage();
}, this);
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsLanguagesViewModel', PopupsLanguagesViewModel);
@ -4938,6 +4963,8 @@ function AdminLoginViewModel()
}, function () {
return !this.submitRequest();
});
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('AdminLoginViewModel', AdminLoginViewModel);
@ -4968,6 +4995,8 @@ function AdminMenuViewModel(oScreen)
KnoinAbstractViewModel.call(this, 'Left', 'AdminMenu');
this.menu = oScreen.menu;
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('AdminMenuViewModel', AdminMenuViewModel);
@ -4987,6 +5016,8 @@ function AdminPaneViewModel()
this.adminDomain = ko.observable(RL.settingsGet('AdminDomain'));
this.version = ko.observable(RL.settingsGet('Version'));
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('AdminPaneViewModel', AdminPaneViewModel);

File diff suppressed because one or more lines are too long

View file

@ -1703,14 +1703,20 @@ Utils.removeBlockquoteSwitcher = function (oMessageTextBody)
/**
* @param {string} sName
* @param {Function} ViewModelClass
* @param {Function=} AbstractViewModel = KnoinAbstractViewModel
*/
Utils.extendAsViewModel = function (sName, ViewModelClass)
Utils.extendAsViewModel = function (sName, ViewModelClass, AbstractViewModel)
{
if (ViewModelClass)
{
if (!AbstractViewModel)
{
AbstractViewModel = KnoinAbstractViewModel;
}
ViewModelClass.__name = sName;
Plugins.regViewModelHook(sName, ViewModelClass);
_.extend(ViewModelClass.prototype, KnoinAbstractViewModel.prototype);
_.extend(ViewModelClass.prototype, AbstractViewModel.prototype);
}
};
@ -5033,6 +5039,17 @@ function Knoin()
});
}
/**
* @param {Object} thisObject
*/
Knoin.constructorEnd = function (thisObject)
{
if (Utils.isFunc(thisObject['__constructor_end']))
{
thisObject['__constructor_end'].call(thisObject);
}
};
Knoin.prototype.sDefaultScreenName = '';
Knoin.prototype.oScreens = {};
Knoin.prototype.oBoot = null;
@ -7555,6 +7572,8 @@ function PopupsFolderClearViewModel()
return !bIsClearing && null !== oFolder;
});
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsFolderClearViewModel', PopupsFolderClearViewModel);
@ -7654,6 +7673,8 @@ function PopupsFolderCreateViewModel()
});
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsFolderCreateViewModel', PopupsFolderCreateViewModel);
@ -7744,6 +7765,8 @@ function PopupsFolderSystemViewModel()
this.trashFolder.subscribe(fCallback);
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsFolderSystemViewModel', PopupsFolderSystemViewModel);
@ -8177,6 +8200,8 @@ function PopupsComposeViewModel()
});
// this.driveCallback = _.bind(this.driveCallback, this);
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsComposeViewModel', PopupsComposeViewModel);
@ -9393,6 +9418,8 @@ function PopupsContactsViewModel()
});
this.bDropPageAfterDelete = false;
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsContactsViewModel', PopupsContactsViewModel);
@ -9659,6 +9686,8 @@ function PopupsAdvancedSearchViewModel()
this.cancelCommand();
});
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsAdvancedSearchViewModel', PopupsAdvancedSearchViewModel);
@ -9818,6 +9847,8 @@ function PopupsAddAccountViewModel()
this.login(this.email());
}
}, this);
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsAddAccountViewModel', PopupsAddAccountViewModel);
@ -9942,6 +9973,8 @@ function PopupsIdentityViewModel()
this.button = ko.computed(function () {
return Utils.i18n('POPUPS_IDENTITIES/' + (this.edit() ? 'BUTTON_UPDATE_IDENTITY': 'BUTTON_ADD_IDENTITY'));
}, this);
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsIdentityViewModel', PopupsIdentityViewModel);
@ -10015,6 +10048,8 @@ function PopupsLanguagesViewModel()
RL.data().mainLanguage.subscribe(function () {
this.resetMainLanguage();
}, this);
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('PopupsLanguagesViewModel', PopupsLanguagesViewModel);
@ -10206,6 +10241,8 @@ function LoginViewModel()
return bF || bG || bT;
}, this);
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('LoginViewModel', LoginViewModel);
@ -10392,9 +10429,10 @@ AbstractSystemDropDownViewModel.prototype.logoutClick = function ()
function MailBoxSystemDropDownViewModel()
{
AbstractSystemDropDownViewModel.call(this);
Knoin.constructorEnd(this);
}
_.extend(MailBoxSystemDropDownViewModel.prototype, AbstractSystemDropDownViewModel.prototype);
Utils.extendAsViewModel('MailBoxSystemDropDownViewModel', MailBoxSystemDropDownViewModel, AbstractSystemDropDownViewModel);
/**
* @constructor
@ -10403,9 +10441,10 @@ _.extend(MailBoxSystemDropDownViewModel.prototype, AbstractSystemDropDownViewMod
function SettingsSystemDropDownViewModel()
{
AbstractSystemDropDownViewModel.call(this);
Knoin.constructorEnd(this);
}
_.extend(SettingsSystemDropDownViewModel.prototype, AbstractSystemDropDownViewModel.prototype);
Utils.extendAsViewModel('SettingsSystemDropDownViewModel', SettingsSystemDropDownViewModel, AbstractSystemDropDownViewModel);
/**
* @constructor
@ -10421,6 +10460,8 @@ function MailBoxFolderListViewModel()
this.iDropOverTimer = 0;
this.allowContacts = !!RL.settingsGet('ContactsIsAllowed');
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('MailBoxFolderListViewModel', MailBoxFolderListViewModel);
@ -10697,6 +10738,8 @@ function MailBoxMessageListViewModel()
this.deleteCommand();
}
}, this));
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('MailBoxMessageListViewModel', MailBoxMessageListViewModel);
@ -11494,6 +11537,8 @@ function MailBoxMessageViewViewModel()
this.messageActiveDom.subscribe(function () {
this.scrollMessageToTop();
}, this);
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('MailBoxMessageViewViewModel', MailBoxMessageViewViewModel);
@ -11683,6 +11728,8 @@ function SettingsMenuViewModel(oScreen)
KnoinAbstractViewModel.call(this, 'Left', 'SettingsMenu');
this.menu = oScreen.menu;
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('SettingsMenuViewModel', SettingsMenuViewModel);
@ -11704,6 +11751,8 @@ SettingsMenuViewModel.prototype.backToMailBoxClick = function ()
function SettingsPaneViewModel()
{
KnoinAbstractViewModel.call(this, 'Right', 'SettingsPane');
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('SettingsPaneViewModel', SettingsPaneViewModel);

File diff suppressed because one or more lines are too long