Repository navigation
Expand file tree
/
Copy pathmain.js
More file actions
1 lines (1 loc) · 2.03 KB
/
Copy pathmain.js
File metadata and controls
1 lines (1 loc) · 2.03 KB
1
define(function(require,exports,module){var EditorManager=brackets.getModule("editor/EditorManager"),PerfUtils=brackets.getModule("utils/PerfUtils"),requestAnimFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(callback){window.setTimeout(callback,1e3/60)},STRING_FIRSTPAINT="Typing Speed: First repaint",STRING_PAINTBEFORECHANGE="Typing Speed: Paint before DOM update",STRING_ONCHANGE="Typing Speed: DOM update complete",STRING_PAINTAFTERCHANGE="Typing Speed: Paint after DOM update";function _getInputField(editor){return editor._codeMirror.getInputField()}function initTypingSpeedLogging(){var editor=null,inputField=null,inProgress=!1,inputChangedHandler=function(){if(!inProgress){inProgress=!0,PerfUtils.markStart([STRING_FIRSTPAINT,STRING_PAINTBEFORECHANGE,STRING_ONCHANGE,STRING_PAINTAFTERCHANGE]);var repaintBeforeChangeHandler=function(){PerfUtils.isActive(STRING_FIRSTPAINT)&&PerfUtils.addMeasurement(STRING_FIRSTPAINT),PerfUtils.isActive(STRING_ONCHANGE)&&(PerfUtils.updateMeasurement(STRING_PAINTBEFORECHANGE),requestAnimFrame(repaintBeforeChangeHandler))},repaintAfterChangeHandler=function(){PerfUtils.addMeasurement(STRING_PAINTAFTERCHANGE),PerfUtils.finalizeMeasurement(STRING_PAINTBEFORECHANGE),inProgress=!1},onChangeHandler=function(event,editor,change){PerfUtils.addMeasurement(STRING_ONCHANGE),editor.off("change.typingSpeedLogger",onChangeHandler),requestAnimFrame(repaintAfterChangeHandler)};requestAnimFrame(repaintBeforeChangeHandler),editor.on("change.typingSpeedLogger",onChangeHandler)}},updateFocusedEditor=function(focusedEditor){editor&&inputField.removeEventListener("input",inputChangedHandler,!0),focusedEditor&&(editor=focusedEditor,(inputField=_getInputField(focusedEditor)).addEventListener("input",inputChangedHandler,!0))};EditorManager.on("activeEditorChange",function(event,focusedEditor){updateFocusedEditor(focusedEditor)}),updateFocusedEditor(EditorManager.getFocusedEditor())}initTypingSpeedLogging()});