mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Added isFunction()
This commit is contained in:
parent
658ac816c8
commit
fe4dbc729c
6 changed files with 13 additions and 21 deletions
|
|
@ -3,7 +3,8 @@ import { doc, elementById } from 'Common/Globals';
|
||||||
|
|
||||||
export const
|
export const
|
||||||
isArray = Array.isArray,
|
isArray = Array.isArray,
|
||||||
isNonEmptyArray = array => isArray(array) && array.length;
|
isNonEmptyArray = array => isArray(array) && array.length,
|
||||||
|
isFunction = v => typeof v === 'function';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {*} value
|
* @param {*} value
|
||||||
|
|
|
||||||
3
dev/External/ko.js
vendored
3
dev/External/ko.js
vendored
|
|
@ -1,10 +1,9 @@
|
||||||
import { i18n, i18nToNodes, trigger } from 'Common/Translator';
|
import { i18n, i18nToNodes, trigger } from 'Common/Translator';
|
||||||
import { doc, createElement } from 'Common/Globals';
|
import { doc, createElement } from 'Common/Globals';
|
||||||
import { SaveSettingsStep } from 'Common/Enums';
|
import { SaveSettingsStep } from 'Common/Enums';
|
||||||
import { isNonEmptyArray } from 'Common/Utils';
|
import { isNonEmptyArray, isFunction } from 'Common/Utils';
|
||||||
|
|
||||||
const
|
const
|
||||||
isFunction = v => typeof v === 'function',
|
|
||||||
koValue = value => !ko.isObservable(value) && isFunction(value) ? value() : ko.unwrap(value);
|
koValue = value => !ko.isObservable(value) && isFunction(value) ? value() : ko.unwrap(value);
|
||||||
|
|
||||||
ko.bindingHandlers.tooltip = {
|
ko.bindingHandlers.tooltip = {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { isArray, addObservablesTo, addComputablesTo } from 'Common/Utils';
|
import { isArray, isFunction, addObservablesTo, addComputablesTo } from 'Common/Utils';
|
||||||
|
|
||||||
function dispose(disposable) {
|
function dispose(disposable) {
|
||||||
if (disposable && 'function' === typeof disposable.dispose) {
|
if (disposable && isFunction(disposable.dispose)) {
|
||||||
disposable.dispose();
|
disposable.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import ko from 'ko';
|
import ko from 'ko';
|
||||||
|
|
||||||
import { doc, $htmlCL } from 'Common/Globals';
|
import { doc, $htmlCL } from 'Common/Globals';
|
||||||
import { isNonEmptyArray } from 'Common/Utils';
|
import { isNonEmptyArray, isFunction } from 'Common/Utils';
|
||||||
|
|
||||||
let currentScreen = null,
|
let currentScreen = null,
|
||||||
defaultScreenName = '';
|
defaultScreenName = '';
|
||||||
|
|
@ -39,7 +39,7 @@ export function createCommand(fExecute, fCanExecute = true) {
|
||||||
fResult.enabled = ko.observable(true);
|
fResult.enabled = ko.observable(true);
|
||||||
fResult.isCommand = true;
|
fResult.isCommand = true;
|
||||||
|
|
||||||
if (typeof fCanExecute === 'function') {
|
if (isFunction(fCanExecute)) {
|
||||||
fResult.canExecute = ko.computed(() => fResult && fResult.enabled() && fCanExecute.call(null));
|
fResult.canExecute = ko.computed(() => fResult && fResult.enabled() && fCanExecute.call(null));
|
||||||
} else {
|
} else {
|
||||||
fResult.canExecute = ko.computed(() => fResult && fResult.enabled() && !!fCanExecute);
|
fResult.canExecute = ko.computed(() => fResult && fResult.enabled() && !!fCanExecute);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { Scope } from 'Common/Enums';
|
import { Scope } from 'Common/Enums';
|
||||||
import { i18n } from 'Common/Translator';
|
import { i18n } from 'Common/Translator';
|
||||||
|
import { isFunction } from 'Common/Utils';
|
||||||
|
|
||||||
import { AbstractViewPopup } from 'Knoin/AbstractViews';
|
import { AbstractViewPopup } from 'Knoin/AbstractViews';
|
||||||
|
|
||||||
|
|
@ -32,17 +33,13 @@ class AskPopupView extends AbstractViewPopup {
|
||||||
yesClick() {
|
yesClick() {
|
||||||
this.cancelCommand();
|
this.cancelCommand();
|
||||||
|
|
||||||
if (typeof this.fYesAction === 'function') {
|
isFunction(this.fYesAction) && this.fYesAction.call(null);
|
||||||
this.fYesAction.call(null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
noClick() {
|
noClick() {
|
||||||
this.cancelCommand();
|
this.cancelCommand();
|
||||||
|
|
||||||
if (typeof this.fNoAction === 'function') {
|
isFunction(this.fNoAction) && this.fNoAction.call(null);
|
||||||
this.fNoAction.call(null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,8 @@
|
||||||
import ko from 'ko';
|
import ko from 'ko';
|
||||||
|
|
||||||
import {
|
import { Notification } from 'Common/Enums';
|
||||||
Notification
|
|
||||||
} from 'Common/Enums';
|
|
||||||
|
|
||||||
import { ClientSideKeyName } from 'Common/EnumsUser';
|
import { ClientSideKeyName } from 'Common/EnumsUser';
|
||||||
|
import { Settings, SettingsGet } from 'Common/Globals';
|
||||||
import { getNotification, reload as translatorReload, convertLangName } from 'Common/Translator';
|
import { getNotification, reload as translatorReload, convertLangName } from 'Common/Translator';
|
||||||
|
|
||||||
import { LanguageStore } from 'Stores/Language';
|
import { LanguageStore } from 'Stores/Language';
|
||||||
|
|
@ -17,8 +14,6 @@ import Remote from 'Remote/User/Fetch';
|
||||||
import { decorateKoCommands, showScreenPopup } from 'Knoin/Knoin';
|
import { decorateKoCommands, showScreenPopup } from 'Knoin/Knoin';
|
||||||
import { AbstractViewCenter } from 'Knoin/AbstractViews';
|
import { AbstractViewCenter } from 'Knoin/AbstractViews';
|
||||||
|
|
||||||
import { Settings, SettingsGet } from 'Common/Globals';
|
|
||||||
|
|
||||||
import { LanguagesPopupView } from 'View/Popup/Languages';
|
import { LanguagesPopupView } from 'View/Popup/Languages';
|
||||||
|
|
||||||
const
|
const
|
||||||
|
|
@ -131,8 +126,8 @@ class LoginUserView extends AbstractViewCenter {
|
||||||
|
|
||||||
this.emailError(!email);
|
this.emailError(!email);
|
||||||
this.passwordError(!pass);
|
this.passwordError(!pass);
|
||||||
this.formError(!valid);
|
|
||||||
this.additionalCodeError(totp && !code);
|
this.additionalCodeError(totp && !code);
|
||||||
|
this.formError(!valid);
|
||||||
|
|
||||||
if (valid) {
|
if (valid) {
|
||||||
this.submitRequest(true);
|
this.submitRequest(true);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue