X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/86c45b3bfdf6bdc52252b6565cad63a8cc7c2b5f..b264c171a5885976ef8f077be37e7cc83bf8a0fd:/project/static/js/lib/codemirror/codemirror.js diff --git a/project/static/js/lib/codemirror/codemirror.js b/project/static/js/lib/codemirror/codemirror.js index 25da6f74..97e2657b 100644 --- a/project/static/js/lib/codemirror/codemirror.js +++ b/project/static/js/lib/codemirror/codemirror.js @@ -55,34 +55,20 @@ var CodeMirror = (function(){ function wrapLineNumberDiv(place) { return function(node) { - var container = document.createElement("DIV"), nums = document.createElement("DIV"), scroller = document.createElement("DIV"); - + container.style.position = "relative"; nums.style.position = "absolute"; - nums.style.height = "100%"; + nums.style.height = "100%"; if (nums.style.setExpression) { try {nums.style.setExpression("height", "this.previousSibling.offsetHeight + 'px'");} catch(e) {} // Seems to throw 'Not Implemented' on some IE8 versions } nums.style.top = "0px"; - nums.style.overflow = "hidden"; - - container.style.position = "absolute"; - container.style.left = "0px"; - container.style.right = "0px"; - container.style.bottom = "0px"; - container.style.top = "0px"; - - node.style.position = "absolute"; - node.style.top = "0px"; - node.style.right = "0px"; - node.style.bottom = "0px"; - node.style.left = "16px" - + nums.style.overflow = "hidden"; place(container); - container.appendChild(node); + container.appendChild(node); container.appendChild(nums); scroller.className = "CodeMirror-line-numbers"; nums.appendChild(scroller); @@ -91,7 +77,7 @@ var CodeMirror = (function(){ function applyLineNumbers(frame) { var win = frame.contentWindow, doc = win.document, - nums = frame.parentNode.nextSibling, scroller = nums.firstChild; + nums = frame.nextSibling, scroller = nums.firstChild; var nextNum = 1, barWidth = null; function sizeBar() { @@ -106,7 +92,7 @@ var CodeMirror = (function(){ if (nums.offsetWidth != barWidth) { barWidth = nums.offsetWidth; - // nums.style.left = "-" + (frame.parentNode.style.marginLeft = barWidth + "px"); + nums.style.left = "-" + (frame.parentNode.style.marginLeft = barWidth + "px"); } } function update() { @@ -139,8 +125,8 @@ var CodeMirror = (function(){ frame.frameBorder = 0; frame.src = "javascript:false;"; frame.style.border = "0"; - frame.style.width = "100%"; - frame.style.height = "100%"; + frame.style.width = options.width; + frame.style.height = options.height; // display: block occasionally suppresses some Firefox bugs, so we // always add it, redundant as it sounds. frame.style.display = "block"; @@ -149,44 +135,8 @@ var CodeMirror = (function(){ var node = place; place = function(n){node.appendChild(n);}; } - - var iframe_container = document.createElement("DIV"); - iframe_container.appendChild(frame); - - var content_wrapper = document.createElement("DIV"); - content_wrapper.appendChild(iframe_container); - content_wrapper.style.position = 'relative'; - content_wrapper.className = 'CodeMirror-content-wrapper'; - content_wrapper.style.width = options.width; - content_wrapper.style.height = options.height; - - iframe_container.style.position = 'absolute'; - iframe_container.style.top = '0px'; - iframe_container.style.right = '0px'; - iframe_container.style.bottom = '0px'; - iframe_container.style.left = '0px'; - - if (options.lineNumbers) { - iframe_container.style.left = '28px'; - - var nums = document.createElement("DIV"), - scroller = document.createElement("DIV"); - - nums.style.position = "absolute"; - nums.style.height = "100%"; - - nums.style.top = "0px"; - nums.style.left = "0px"; - nums.style.overflow = "hidden"; - - scroller.className = "CodeMirror-line-numbers"; - nums.appendChild(scroller); - content_wrapper.appendChild(nums); - - iframe_container.style.right = nums.width; - } - - place(content_wrapper); + if (options.lineNumbers) place = wrapLineNumberDiv(place); + place(frame); // Link back to this object, so that the editor can fetch options // and add a reference to itself.