mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 21:19:21 +03:00
Remove more unused knockout code
This commit is contained in:
parent
d0f5828751
commit
ff6fb41812
14 changed files with 224 additions and 399 deletions
|
|
@ -4,9 +4,9 @@ function makeEventHandlerShortcut(eventName) {
|
|||
ko.bindingHandlers[eventName] = {
|
||||
'init': function(element, valueAccessor, allBindings, viewModel, bindingContext) {
|
||||
var newValueAccessor = () => {
|
||||
var result = {};
|
||||
result[eventName] = valueAccessor();
|
||||
return result;
|
||||
return {
|
||||
[eventName]: valueAccessor()
|
||||
};
|
||||
};
|
||||
return ko.bindingHandlers['event']['init'].call(this, element, newValueAccessor, allBindings, viewModel, bindingContext);
|
||||
}
|
||||
|
|
@ -25,25 +25,19 @@ ko.bindingHandlers['event'] = {
|
|||
return;
|
||||
|
||||
try {
|
||||
// Take all the event args, and prefix with the viewmodel
|
||||
var argsForHandler = ko.utils.makeArray(arguments);
|
||||
viewModel = bindingContext['$data'];
|
||||
argsForHandler.unshift(viewModel);
|
||||
handlerReturnValue = handlerFunction.apply(viewModel, argsForHandler);
|
||||
// Take all the event args, and prefix with the viewmodel
|
||||
handlerReturnValue = handlerFunction.apply(viewModel, [viewModel, ...arguments]);
|
||||
} finally {
|
||||
if (handlerReturnValue !== true) { // Normally we want to prevent default action. Developer can override this be explicitly returning true.
|
||||
if (event.preventDefault)
|
||||
event.preventDefault();
|
||||
else
|
||||
event.returnValue = false;
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
var bubble = allBindings.get(eventName + 'Bubble') !== false;
|
||||
if (!bubble) {
|
||||
event.cancelBubble = true;
|
||||
if (event.stopPropagation)
|
||||
event.stopPropagation();
|
||||
event.stopPropagation();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ ko.bindingHandlers['foreach'] = {
|
|||
// The value will be unwrapped and tracked within the template binding
|
||||
// (See https://github.com/SteveSanderson/knockout/issues/523)
|
||||
if ((!unwrappedValue) || typeof unwrappedValue.length == "number")
|
||||
return { 'foreach': modelValue, 'templateEngine': ko.nativeTemplateEngine.instance };
|
||||
return { 'foreach': modelValue };
|
||||
|
||||
// If unwrappedValue.data is the array, preserve all relevant options and unwrap again value so we get updates
|
||||
ko.utils.unwrapObservable(modelValue);
|
||||
|
|
@ -23,8 +23,7 @@ ko.bindingHandlers['foreach'] = {
|
|||
'beforeRemove': unwrappedValue['beforeRemove'],
|
||||
'afterRender': unwrappedValue['afterRender'],
|
||||
'beforeMove': unwrappedValue['beforeMove'],
|
||||
'afterMove': unwrappedValue['afterMove'],
|
||||
'templateEngine': ko.nativeTemplateEngine.instance
|
||||
'afterMove': unwrappedValue['afterMove']
|
||||
};
|
||||
};
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue