OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
_backup
/
tinymce
/
tinymce
/
src
/
core
/
main
/
ts
/
api
/
util
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
02/20/2020 06:12:10 AM
rwxr-xr-x
📄
Class.ts
4.15 KB
02/20/2020 06:12:13 AM
rw-r--r--
📄
Color.ts
5.3 KB
02/20/2020 06:12:14 AM
rw-r--r--
📄
Delay.ts
6.14 KB
02/20/2020 06:12:14 AM
rw-r--r--
📄
EventDispatcher.ts
10.97 KB
02/20/2020 06:12:15 AM
rw-r--r--
📄
FakeStorage.ts
986 bytes
02/20/2020 06:12:15 AM
rw-r--r--
📄
I18n.ts
4.92 KB
02/20/2020 06:12:16 AM
rw-r--r--
📄
JSON.ts
1.63 KB
02/20/2020 06:12:16 AM
rw-r--r--
📄
JSONP.ts
1 KB
02/20/2020 06:12:17 AM
rw-r--r--
📄
JSONRequest.ts
3.36 KB
02/20/2020 06:12:17 AM
rw-r--r--
📄
LocalStorage.ts
866 bytes
02/20/2020 06:12:18 AM
rw-r--r--
📄
Observable.ts
4.92 KB
02/20/2020 06:12:18 AM
rw-r--r--
📄
Promise.ts
5.46 KB
02/20/2020 06:12:19 AM
rw-r--r--
📄
Tools.ts
12.15 KB
02/20/2020 06:12:19 AM
rw-r--r--
📄
URI.ts
12.03 KB
02/20/2020 06:12:20 AM
rw-r--r--
📄
VK.ts
1.22 KB
02/20/2020 06:12:20 AM
rw-r--r--
📄
XHR.ts
3.78 KB
02/20/2020 06:12:21 AM
rw-r--r--
Editing: Delay.ts
Close
/** * Copyright (c) Tiny Technologies, Inc. All rights reserved. * Licensed under the LGPL or a commercial license. * For LGPL see License.txt in the project root for license information. * For commercial licenses see https://www.tiny.cloud/ */ import { clearInterval, clearTimeout, document, HTMLElement, setInterval, setTimeout, window } from '@ephox/dom-globals'; import Editor from '../Editor'; import Promise from './Promise'; type DebounceFunc = (...args: any[]) => { stop: () => void; }; interface Delay { requestAnimationFrame (callback: () => void, element?: HTMLElement): void; setEditorInterval (editor: Editor, callback: () => void, time?: number): number; setEditorTimeout (editor: Editor, callback: () => void, time?: number): number; setInterval (callback: () => void, time?: number): number; setTimeout (callback: () => void, time?: number): number; clearInterval (id: number): void; clearTimeout (id: number): void; debounce (callback: (...args: any[]) => void, time?: number): DebounceFunc; throttle (callback: (...args: any[]) => void, time?: number): DebounceFunc; } /** * Utility class for working with delayed actions like setTimeout. * * @class tinymce.util.Delay */ let requestAnimationFramePromise; const requestAnimationFrame = function (callback, element?) { let i, requestAnimationFrameFunc: any = window.requestAnimationFrame; const vendors = ['ms', 'moz', 'webkit']; const featurefill = function (callback) { window.setTimeout(callback, 0); }; for (i = 0; i < vendors.length && !requestAnimationFrameFunc; i++) { requestAnimationFrameFunc = window[vendors[i] + 'RequestAnimationFrame']; } if (!requestAnimationFrameFunc) { requestAnimationFrameFunc = featurefill; } requestAnimationFrameFunc(callback, element); }; const wrappedSetTimeout = function (callback, time?) { if (typeof time !== 'number') { time = 0; } return setTimeout(callback, time); }; const wrappedSetInterval = function (callback: Function, time?: number): number { if (typeof time !== 'number') { time = 1; // IE 8 needs it to be > 0 } return setInterval(callback, time); }; const wrappedClearTimeout = function (id: number) { return clearTimeout(id); }; const wrappedClearInterval = function (id: number) { return clearInterval(id); }; const debounce = function (callback: (...args: any[]) => void, time?: number): DebounceFunc { let timer, func; func = function (...args) { clearTimeout(timer); timer = wrappedSetTimeout(function () { callback.apply(this, args); }, time); }; func.stop = function () { clearTimeout(timer); }; return func; }; const Delay: Delay = { /** * Requests an animation frame and fallbacks to a timeout on older browsers. * * @method requestAnimationFrame * @param {function} callback Callback to execute when a new frame is available. * @param {DOMElement} element Optional element to scope it to. */ requestAnimationFrame (callback, element?) { if (requestAnimationFramePromise) { requestAnimationFramePromise.then(callback); return; } requestAnimationFramePromise = new Promise(function (resolve) { if (!element) { element = document.body; } requestAnimationFrame(resolve, element); }).then(callback); }, /** * Sets a timer in ms and executes the specified callback when the timer runs out. * * @method setTimeout * @param {function} callback Callback to execute when timer runs out. * @param {Number} time Optional time to wait before the callback is executed, defaults to 0. * @return {Number} Timeout id number. */ setTimeout: wrappedSetTimeout, /** * Sets an interval timer in ms and executes the specified callback at every interval of that time. * * @method setInterval * @param {function} callback Callback to execute when interval time runs out. * @param {Number} time Optional time to wait before the callback is executed, defaults to 0. * @return {Number} Timeout id number. */ setInterval: wrappedSetInterval, /** * Sets an editor timeout it's similar to setTimeout except that it checks if the editor instance is * still alive when the callback gets executed. * * @method setEditorTimeout * @param {tinymce.Editor} editor Editor instance to check the removed state on. * @param {function} callback Callback to execute when timer runs out. * @param {Number} time Optional time to wait before the callback is executed, defaults to 0. * @return {Number} Timeout id number. */ setEditorTimeout (editor, callback, time?) { return wrappedSetTimeout(function () { if (!editor.removed) { callback(); } }, time); }, /** * Sets an interval timer it's similar to setInterval except that it checks if the editor instance is * still alive when the callback gets executed. * * @method setEditorInterval * @param {function} callback Callback to execute when interval time runs out. * @param {Number} time Optional time to wait before the callback is executed, defaults to 0. * @return {Number} Timeout id number. */ setEditorInterval (editor, callback, time?) { let timer; timer = wrappedSetInterval(function () { if (!editor.removed) { callback(); } else { clearInterval(timer); } }, time); return timer; }, /** * Creates debounced callback function that only gets executed once within the specified time. * * @method debounce * @param {function} callback Callback to execute when timer finishes. * @param {Number} time Optional time to wait before the callback is executed, defaults to 0. * @return {Function} debounced function callback. */ debounce, // Throttle needs to be debounce due to backwards compatibility. throttle: debounce, /** * Clears an interval timer so it won't execute. * * @method clearInterval * @param {Number} Interval timer id number. */ clearInterval: wrappedClearInterval, /** * Clears an timeout timer so it won't execute. * * @method clearTimeout * @param {Number} Timeout timer id number. */ clearTimeout: wrappedClearTimeout }; export default Delay;