Use jQuery.slim

Underscore.js _.uniq(_.compact( to native Array.filter((value, index, self) => !!value && self.indexOf(value) == index)
Underscore.js _.compact to native Array.filter(value => !!value)
Underscore.js _.uniq to native Array.filter((value, index, self) => self.indexOf(value) == index)
Underscore.js _.values to native Object.values
Underscore.js _.flatten to native Array.flat
Underscore.js _.union to native Array.concat + unique filter
Underscore.js _.reduce to native Array.reduce
Underscore.js _.escape replaced with advanced htmlspecialchars()
Underscore.js _.memoize replaced
Now Underscore.js is a slim custom version (only _.debounce, _.defer & _.throttle)
This commit is contained in:
djmaze 2020-07-23 16:06:16 +02:00
parent 996a71ad8a
commit dca0ff02ed
27 changed files with 515 additions and 353 deletions

35
dev/External/ko.js vendored
View file

@ -13,7 +13,8 @@ const ko = window.ko,
element.__opentip.deactivate();
}
});
};
},
isFunction = v => typeof v === 'function';
ko.bindingHandlers.updateWidth = {
init: (element, fValueAccessor) => {
@ -145,7 +146,7 @@ ko.bindingHandlers.tooltip = {
Globals = require('Common/Globals');
if (!Globals.bMobileDevice || isMobile) {
const sValue = !ko.isObservable(fValue) && _.isFunction(fValue) ? fValue() : ko.unwrap(fValue);
const sValue = !ko.isObservable(fValue) && isFunction(fValue) ? fValue() : ko.unwrap(fValue);
element.__opentip = new Opentip(element, {
'style': 'rainloopTip',
@ -203,7 +204,7 @@ ko.bindingHandlers.tooltip = {
Globals = require('Common/Globals');
if ((!Globals.bMobileDevice || isMobile) && element.__opentip) {
const sValue = !ko.isObservable(fValue) && _.isFunction(fValue) ? fValue() : ko.unwrap(fValue);
const sValue = !ko.isObservable(fValue) && isFunction(fValue) ? fValue() : ko.unwrap(fValue);
if (sValue) {
element.__opentip.setContent(isI18N ? require('Common/Translator').i18n(sValue) : sValue);
element.__opentip.activate();
@ -240,7 +241,7 @@ ko.bindingHandlers.tooltipErrorTip = {
update: (element, fValueAccessor) => {
const $el = $(element),
fValue = fValueAccessor(),
value = !ko.isObservable(fValue) && _.isFunction(fValue) ? fValue() : ko.unwrap(fValue),
value = !ko.isObservable(fValue) && isFunction(fValue) ? fValue() : ko.unwrap(fValue),
openTips = element.__opentip;
if (openTips) {
@ -797,8 +798,7 @@ ko.bindingHandlers.saveTrigger = {
ko.bindingHandlers.emailsTags = {
init: (element, fValueAccessor, fAllBindingsAccessor) => {
const Utils = require('Common/Utils'),
EmailModel = require('Model/Email').default,
const EmailModel = require('Model/Email').default,
$el = $(element),
fValue = fValueAccessor(),
fAllBindings = fAllBindingsAccessor(),
@ -817,20 +817,18 @@ ko.bindingHandlers.emailsTags = {
inputDelimiters: inputDelimiters,
autoCompleteSource: fAutoCompleteSource,
splitHook: (value) => {
const v = Utils.trim(value);
const v = value.trim();
if (v && inputDelimiters.includes(v.substr(-1))) {
return EmailModel.splitEmailLine(value);
}
return null;
},
parseHook: (input) =>
_.flatten(
input.map(inputValue => {
const values = EmailModel.parseEmailLine(inputValue);
return values.length ? values : inputValue;
})
).map(
item => (_.isObject(item) ? [item.toLine(false), item] : [item, null])
input.map(inputValue => {
const values = EmailModel.parseEmailLine(inputValue);
return values.length ? values : inputValue;
}).flat(Infinity).map(
item => (item.toLine ? [item.toLine(false), item] : [item, null])
),
change: (event) => {
$el.data('EmailsTagsValue', event.target.value);
@ -872,7 +870,7 @@ ko.bindingHandlers.command = {
if (!command.canExecute) {
const __realCanExecute = command.__realCanExecute;
if (_.isFunction(__realCanExecute)) {
if (isFunction(__realCanExecute)) {
command.canExecute = ko.computed(() => command.enabled() && __realCanExecute.call(viewModel, viewModel));
} else {
command.canExecute = ko.computed(() => command.enabled() && !!__realCanExecute);
@ -912,11 +910,10 @@ ko.bindingHandlers.command = {
// extenders
ko.extenders.trimmer = (target) => {
const Utils = require('Common/Utils'),
result = ko.computed({
const result = ko.computed({
read: target,
write: (newValue) => {
target(Utils.trim(newValue.toString()));
target(newValue.toString().trim());
}
});
@ -1116,7 +1113,7 @@ ko.observable.fn.deleteAccessHelper = function() {
ko.observable.fn.validateFunc = function(fFunc) {
this.hasFuncError = ko.observable(false);
if (_.isFunction(fFunc)) {
if (isFunction(fFunc)) {
this.subscribe((value) => {
this.hasFuncError(!fFunc(value));
});