MCPcopy
hub / github.com/tholman/zenpen / createEventBindings

Function createEventBindings

js/editor.js:35–74  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33 }
34
35 function createEventBindings() {
36
37 // Key up bindings
38 if ( ZenPen.util.supportsHtmlStorage() ) {
39
40 document.onkeyup = function( event ) {
41 checkTextHighlighting( event );
42 saveState();
43 }
44
45 } else {
46 document.onkeyup = checkTextHighlighting;
47 }
48
49 // Mouse bindings
50 document.onmousedown = checkTextHighlighting;
51 document.onmouseup = function( event ) {
52
53 setTimeout( function() {
54 checkTextHighlighting( event );
55 }, 1);
56 };
57
58 // Window bindings
59 window.addEventListener( 'resize', function( event ) {
60 updateBubblePosition();
61 });
62
63
64 document.body.addEventListener( 'scroll', function() {
65
66 // TODO: Debounce update bubble position to stop excessive redraws
67 updateBubblePosition();
68 });
69
70 // Composition bindings. We need them to distinguish
71 // IME composition from text selection
72 document.addEventListener( 'compositionstart', onCompositionStart );
73 document.addEventListener( 'compositionend', onCompositionEnd );
74 }
75
76
77 function bindElements() {

Callers 1

initFunction · 0.85

Calls 3

checkTextHighlightingFunction · 0.85
updateBubblePositionFunction · 0.85
saveStateFunction · 0.70

Tested by

no test coverage detected