mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 20:19:22 +03:00
Replace babel command decorators with proper knockout command decorators
This commit is contained in:
parent
b6d8fa5b3f
commit
540b12ed26
27 changed files with 181 additions and 132 deletions
15
dev/External/ko.js
vendored
15
dev/External/ko.js
vendored
|
|
@ -86,23 +86,10 @@ ko.bindingHandlers.command = {
|
|||
init: (element, fValueAccessor, fAllBindingsAccessor, viewModel, bindingContext) => {
|
||||
const command = fValueAccessor();
|
||||
|
||||
if (!command || !command.isCommand) {
|
||||
if (!command || !command.enabled || !command.canExecute) {
|
||||
throw new Error('Value should be a command');
|
||||
}
|
||||
|
||||
if (!command.enabled) {
|
||||
command.enabled = ko.observable(true);
|
||||
}
|
||||
|
||||
if (!command.canExecute) {
|
||||
const __realCanExecute = command.__realCanExecute;
|
||||
if (isFunction(__realCanExecute)) {
|
||||
command.canExecute = ko.computed(() => command.enabled() && __realCanExecute.call(viewModel, viewModel));
|
||||
} else {
|
||||
command.canExecute = ko.computed(() => command.enabled() && !!__realCanExecute);
|
||||
}
|
||||
}
|
||||
|
||||
element.classList.add('command');
|
||||
ko.bindingHandlers['FORM'==element.nodeName ? 'submit' : 'click'].init(
|
||||
element,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue