本文整理匯總了TypeScript中@ephox/katamari.Type.isFunction方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Type.isFunction方法的具體用法?TypeScript Type.isFunction怎麽用?TypeScript Type.isFunction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@ephox/katamari.Type
的用法示例。
在下文中一共展示了Type.isFunction方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: Event
const fireEvent = (elem: Element, event: string) => {
let evt;
if (Type.isFunction(Event)) {
evt = new Event(event, {
bubbles: true,
cancelable: true
});
} else { // support IE
evt = document.createEvent('Event');
evt.initEvent(event, true, true);
}
elem.dom().dispatchEvent(evt);
};
示例2: function
const renderThemeUi = function (editor) {
const settings = editor.settings, elm = editor.getElement();
editor.orgDisplay = elm.style.display;
if (Type.isString(settings.theme)) {
return renderFromLoadedTheme(editor);
} else if (Type.isFunction(settings.theme)) {
return renderFromThemeFunc(editor);
} else {
return renderThemeFalse(editor);
}
};
示例3: Event
Chain.op(function (elm: Element) {
const element: HTMLElement = elm.dom();
// NOTE we can't fake a paste event here.
let event;
if (Type.isFunction(Event)) {
event = new Event(name, {
bubbles: true,
cancelable: true
});
} else { // support IE
event = document.createEvent('Event');
event.initEvent(name, true, true);
}
element.dispatchEvent(event);
}),
示例4: function
const toString = function (obj) {
if (Type.isFunction(obj)) {
return Object.prototype.toString.call(obj);
}
return !isEmpty(obj) ? '' + obj : '';
};
示例5: function
//.........這裏部分代碼省略.........
blobInfo,
status: false,
error
};
};
const resolvePending = function (blobUri, result) {
Tools.each(pendingPromises[blobUri], function (resolve) {
resolve(result);
});
delete pendingPromises[blobUri];
};
const uploadBlobInfo = function (blobInfo, handler, openNotification) {
uploadStatus.markPending(blobInfo.blobUri());
return new Promise(function (resolve) {
let notification, progress;
const noop = function () {
};
try {
const closeNotification = function () {
if (notification) {
notification.close();
progress = noop; // Once it's closed it's closed
}
};
const success = function (url) {
closeNotification();
uploadStatus.markUploaded(blobInfo.blobUri(), url);
resolvePending(blobInfo.blobUri(), handlerSuccess(blobInfo, url));
resolve(handlerSuccess(blobInfo, url));
};
const failure = function (error) {
closeNotification();
uploadStatus.removeFailed(blobInfo.blobUri());
resolvePending(blobInfo.blobUri(), handlerFailure(blobInfo, error));
resolve(handlerFailure(blobInfo, error));
};
progress = function (percent) {
if (percent < 0 || percent > 100) {
return;
}
if (!notification) {
notification = openNotification();
}
notification.progressBar.value(percent);
};
handler(blobInfo, success, failure, progress);
} catch (ex) {
resolve(handlerFailure(blobInfo, ex.message));
}
});
};
const isDefaultHandler = function (handler) {
return handler === defaultHandler;
};
const pendingUploadBlobInfo = function (blobInfo) {
const blobUri = blobInfo.blobUri();
return new Promise(function (resolve) {
pendingPromises[blobUri] = pendingPromises[blobUri] || [];
pendingPromises[blobUri].push(resolve);
});
};
const uploadBlobs = function (blobInfos, openNotification) {
blobInfos = Tools.grep(blobInfos, function (blobInfo) {
return !uploadStatus.isUploaded(blobInfo.blobUri());
});
return Promise.all(Tools.map(blobInfos, function (blobInfo) {
return uploadStatus.isPending(blobInfo.blobUri()) ?
pendingUploadBlobInfo(blobInfo) : uploadBlobInfo(blobInfo, settings.handler, openNotification);
}));
};
const upload = function (blobInfos, openNotification) {
return (!settings.url && isDefaultHandler(settings.handler)) ? noUpload() : uploadBlobs(blobInfos, openNotification);
};
if (Type.isFunction(settings.handler) === false) {
settings.handler = defaultHandler;
}
return {
upload
};
}
示例6: function
const hasSelectionModifyApi = function (editor) {
return Type.isFunction(editor.selection.getSel().modify);
};
示例7:
export const getValidationHandler = (editor: Editor): Option<UrlValidationHandler> => {
const validatorHandler = editor.settings.filepicker_validator_handler;
return Type.isFunction(validatorHandler) ? Option.some(validatorHandler) : Option.none();
};