()
| 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() { |
no test coverage detected