(cm, options)
| 19 | CodeMirror.defineOption("scrollButtonHeight", 0); |
| 20 | |
| 21 | function Annotation(cm, options) { |
| 22 | this.cm = cm; |
| 23 | this.options = options; |
| 24 | this.buttonHeight = options.scrollButtonHeight || cm.getOption("scrollButtonHeight"); |
| 25 | this.annotations = []; |
| 26 | this.doRedraw = this.doUpdate = null; |
| 27 | this.div = cm.getWrapperElement().appendChild(document.createElement("div")); |
| 28 | this.div.style.cssText = "position: absolute; right: 0; top: 0; z-index: 7; pointer-events: none"; |
| 29 | this.computeScale(); |
| 30 | |
| 31 | function scheduleRedraw(delay) { |
| 32 | clearTimeout(self.doRedraw); |
| 33 | self.doRedraw = setTimeout(function() { self.redraw(); }, delay); |
| 34 | } |
| 35 | |
| 36 | var self = this; |
| 37 | cm.on("refresh", this.resizeHandler = function() { |
| 38 | clearTimeout(self.doUpdate); |
| 39 | self.doUpdate = setTimeout(function() { |
| 40 | if (self.computeScale()) scheduleRedraw(20); |
| 41 | }, 100); |
| 42 | }); |
| 43 | cm.on("markerAdded", this.resizeHandler); |
| 44 | cm.on("markerCleared", this.resizeHandler); |
| 45 | if (options.listenForChanges !== false) |
| 46 | cm.on("change", this.changeHandler = function() { |
| 47 | scheduleRedraw(250); |
| 48 | }); |
| 49 | } |
| 50 | |
| 51 | Annotation.prototype.computeScale = function() { |
| 52 | var cm = this.cm; |
nothing calls this directly
no test coverage detected