|
1 | | -import { gecko, ie, ie_version, mobile, webkit } from "../util/browser"; |
2 | | -import { elt } from "../util/dom"; |
3 | | -import { scrollerGap } from "../util/misc"; |
| 1 | +import { gecko, ie, ie_version, mobile, webkit } from "../util/browser" |
| 2 | +import { elt } from "../util/dom" |
| 3 | +import { scrollerGap } from "../util/misc" |
4 | 4 |
|
5 | 5 | // The display handles the DOM integration, both for input reading |
6 | 6 | // and content drawing. It holds references to DOM nodes and |
7 | 7 | // display-related state. |
8 | 8 |
|
9 | 9 | export function Display(place, doc, input) { |
10 | | - var d = this; |
11 | | - this.input = input; |
| 10 | + var d = this |
| 11 | + this.input = input |
12 | 12 |
|
13 | 13 | // Covers bottom-right square when both scrollbars are present. |
14 | | - d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler"); |
15 | | - d.scrollbarFiller.setAttribute("cm-not-content", "true"); |
| 14 | + d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler") |
| 15 | + d.scrollbarFiller.setAttribute("cm-not-content", "true") |
16 | 16 | // Covers bottom of gutter when coverGutterNextToScrollbar is on |
17 | 17 | // and h scrollbar is present. |
18 | | - d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler"); |
19 | | - d.gutterFiller.setAttribute("cm-not-content", "true"); |
| 18 | + d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler") |
| 19 | + d.gutterFiller.setAttribute("cm-not-content", "true") |
20 | 20 | // Will contain the actual code, positioned to cover the viewport. |
21 | | - d.lineDiv = elt("div", null, "CodeMirror-code"); |
| 21 | + d.lineDiv = elt("div", null, "CodeMirror-code") |
22 | 22 | // Elements are added to these to represent selection and cursors. |
23 | | - d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1"); |
24 | | - d.cursorDiv = elt("div", null, "CodeMirror-cursors"); |
| 23 | + d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1") |
| 24 | + d.cursorDiv = elt("div", null, "CodeMirror-cursors") |
25 | 25 | // A visibility: hidden element used to find the size of things. |
26 | | - d.measure = elt("div", null, "CodeMirror-measure"); |
| 26 | + d.measure = elt("div", null, "CodeMirror-measure") |
27 | 27 | // When lines outside of the viewport are measured, they are drawn in this. |
28 | | - d.lineMeasure = elt("div", null, "CodeMirror-measure"); |
| 28 | + d.lineMeasure = elt("div", null, "CodeMirror-measure") |
29 | 29 | // Wraps everything that needs to exist inside the vertically-padded coordinate system |
30 | 30 | d.lineSpace = elt("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv], |
31 | | - null, "position: relative; outline: none"); |
| 31 | + null, "position: relative; outline: none") |
32 | 32 | // Moved around its parent to cover visible view. |
33 | | - d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative"); |
| 33 | + d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative") |
34 | 34 | // Set to the height of the document, allowing scrolling. |
35 | | - d.sizer = elt("div", [d.mover], "CodeMirror-sizer"); |
36 | | - d.sizerWidth = null; |
| 35 | + d.sizer = elt("div", [d.mover], "CodeMirror-sizer") |
| 36 | + d.sizerWidth = null |
37 | 37 | // Behavior of elts with overflow: auto and padding is |
38 | 38 | // inconsistent across browsers. This is used to ensure the |
39 | 39 | // scrollable area is big enough. |
40 | | - d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;"); |
| 40 | + d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;") |
41 | 41 | // Will contain the gutters, if any. |
42 | | - d.gutters = elt("div", null, "CodeMirror-gutters"); |
43 | | - d.lineGutter = null; |
| 42 | + d.gutters = elt("div", null, "CodeMirror-gutters") |
| 43 | + d.lineGutter = null |
44 | 44 | // Actual scrollable element. |
45 | | - d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll"); |
46 | | - d.scroller.setAttribute("tabIndex", "-1"); |
| 45 | + d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll") |
| 46 | + d.scroller.setAttribute("tabIndex", "-1") |
47 | 47 | // The element in which the editor lives. |
48 | | - d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror"); |
| 48 | + d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror") |
49 | 49 |
|
50 | 50 | // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported) |
51 | | - if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; } |
52 | | - if (!webkit && !(gecko && mobile)) d.scroller.draggable = true; |
| 51 | + if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0 } |
| 52 | + if (!webkit && !(gecko && mobile)) d.scroller.draggable = true |
53 | 53 |
|
54 | 54 | if (place) { |
55 | | - if (place.appendChild) place.appendChild(d.wrapper); |
56 | | - else place(d.wrapper); |
| 55 | + if (place.appendChild) place.appendChild(d.wrapper) |
| 56 | + else place(d.wrapper) |
57 | 57 | } |
58 | 58 |
|
59 | 59 | // Current rendered range (may be bigger than the view window). |
60 | | - d.viewFrom = d.viewTo = doc.first; |
61 | | - d.reportedViewFrom = d.reportedViewTo = doc.first; |
| 60 | + d.viewFrom = d.viewTo = doc.first |
| 61 | + d.reportedViewFrom = d.reportedViewTo = doc.first |
62 | 62 | // Information about the rendered lines. |
63 | | - d.view = []; |
64 | | - d.renderedView = null; |
| 63 | + d.view = [] |
| 64 | + d.renderedView = null |
65 | 65 | // Holds info about a single rendered line when it was rendered |
66 | 66 | // for measurement, while not in view. |
67 | | - d.externalMeasured = null; |
| 67 | + d.externalMeasured = null |
68 | 68 | // Empty space (in pixels) above the view |
69 | | - d.viewOffset = 0; |
70 | | - d.lastWrapHeight = d.lastWrapWidth = 0; |
71 | | - d.updateLineNumbers = null; |
| 69 | + d.viewOffset = 0 |
| 70 | + d.lastWrapHeight = d.lastWrapWidth = 0 |
| 71 | + d.updateLineNumbers = null |
72 | 72 |
|
73 | | - d.nativeBarWidth = d.barHeight = d.barWidth = 0; |
74 | | - d.scrollbarsClipped = false; |
| 73 | + d.nativeBarWidth = d.barHeight = d.barWidth = 0 |
| 74 | + d.scrollbarsClipped = false |
75 | 75 |
|
76 | 76 | // Used to only resize the line number gutter when necessary (when |
77 | 77 | // the amount of lines crosses a boundary that makes its width change) |
78 | | - d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null; |
| 78 | + d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null |
79 | 79 | // Set to true when a non-horizontal-scrolling line widget is |
80 | 80 | // added. As an optimization, line widget aligning is skipped when |
81 | 81 | // this is false. |
82 | | - d.alignWidgets = false; |
| 82 | + d.alignWidgets = false |
83 | 83 |
|
84 | | - d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null; |
| 84 | + d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null |
85 | 85 |
|
86 | 86 | // Tracks the maximum line length so that the horizontal scrollbar |
87 | 87 | // can be kept static when scrolling. |
88 | | - d.maxLine = null; |
89 | | - d.maxLineLength = 0; |
90 | | - d.maxLineChanged = false; |
| 88 | + d.maxLine = null |
| 89 | + d.maxLineLength = 0 |
| 90 | + d.maxLineChanged = false |
91 | 91 |
|
92 | 92 | // Used for measuring wheel scrolling granularity |
93 | | - d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null; |
| 93 | + d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null |
94 | 94 |
|
95 | 95 | // True when shift is held down. |
96 | | - d.shift = false; |
| 96 | + d.shift = false |
97 | 97 |
|
98 | 98 | // Used to track whether anything happened since the context menu |
99 | 99 | // was opened. |
100 | | - d.selForContextMenu = null; |
| 100 | + d.selForContextMenu = null |
101 | 101 |
|
102 | | - d.activeTouch = null; |
| 102 | + d.activeTouch = null |
103 | 103 |
|
104 | | - input.init(d); |
| 104 | + input.init(d) |
105 | 105 | } |
0 commit comments