本文整理汇总了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();
};