diff --git a/demo/kitchen-sink/demo.js b/demo/kitchen-sink/demo.js index 4bc1c35e30d..812baaa9505 100644 --- a/demo/kitchen-sink/demo.js +++ b/demo/kitchen-sink/demo.js @@ -397,7 +397,9 @@ bindCheckbox("highlight_token", function(checked) { /************** dragover ***************************/ event.addListener(container, "dragover", function(e) { - return event.preventDefault(e); + var types = e.dataTransfer.types; + if (types && Array.prototype.indexOf.call(types, 'Files') !== -1) + return event.preventDefault(e); }); event.addListener(container, "drop", function(e) { diff --git a/demo/kitchen-sink/styles.css b/demo/kitchen-sink/styles.css index fba037731e8..f32a82a0de3 100644 --- a/demo/kitchen-sink/styles.css +++ b/demo/kitchen-sink/styles.css @@ -19,6 +19,7 @@ body { #logo { padding: 15px; margin-left: 70px; + border: none; } #editor-container { diff --git a/lib/ace/css/editor.css b/lib/ace/css/editor.css index 0aee0f71931..81f8fbe69a9 100644 --- a/lib/ace/css/editor.css +++ b/lib/ace/css/editor.css @@ -252,7 +252,7 @@ .ace_gutter-tooltip { background-color: #FFF; - background-image: -webkit-linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1)); + background-image: -webkit-linear-gradient(top, transparent, rgba(0, 0, 0, 0.1)); background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1)); border: 1px solid gray; border-radius: 1px; @@ -342,9 +342,7 @@ -webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2); box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2); } - - - + .ace_fold-widget.ace_invalid { background-color: #FFB4B4; border-color: #DE5555; diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index 9ac41352b4b..30f7ca64866 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -34,7 +34,6 @@ define(function(require, exports, module) { var config = require("./config"); var oop = require("./lib/oop"); var lang = require("./lib/lang"); -var net = require("./lib/net"); var EventEmitter = require("./lib/event_emitter").EventEmitter; var Selection = require("./selection").Selection; var TextMode = require("./mode/text").Mode; diff --git a/lib/ace/lib/dom.js b/lib/ace/lib/dom.js index 345499167a2..74a71123bb1 100644 --- a/lib/ace/lib/dom.js +++ b/lib/ace/lib/dom.js @@ -39,72 +39,86 @@ exports.createElement = function(tag, ns) { document.createElement(tag); }; -exports.setText = function(elem, text) { - if (elem.innerText !== undefined) { - elem.innerText = text; - } - if (elem.textContent !== undefined) { - elem.textContent = text; +if (typeof DOMTokenList === 'function') { + exports.hasCssClass = function(el, name) { + return el.classList.contains(name); + }; + + exports.addCssClass = function(el, name) { + el.classList.add(name); + }; + + exports.removeCssClass = function(el, name) { + el.classList.remove(name); } -}; -exports.hasCssClass = function(el, name) { - var classes = el.className.split(/\s+/g); - return classes.indexOf(name) !== -1; -}; + exports.toggleCssClass = function(el, name) { + el.classList.toggle(name); + } -/* -* Add a CSS class to the list of classes on the given node -*/ -exports.addCssClass = function(el, name) { - if (!exports.hasCssClass(el, name)) { - el.className += " " + name; + exports.setCssClass = function(el, name, include) { + el.classList[include ? 'add' : 'remove'](name); } -}; +} +else { + exports.hasCssClass = function(el, name) { + var classes = el.className.split(/\s+/g); + return classes.indexOf(name) !== -1; + }; -/* -* Remove a CSS class from the list of classes on the given node -*/ -exports.removeCssClass = function(el, name) { - var classes = el.className.split(/\s+/g); - while (true) { - var index = classes.indexOf(name); - if (index == -1) { - break; + /* + * Add a CSS class to the list of classes on the given node + */ + exports.addCssClass = function(el, name) { + if (!exports.hasCssClass(el, name)) { + el.className += " " + name; } - classes.splice(index, 1); - } - el.className = classes.join(" "); -}; + }; -exports.toggleCssClass = function(el, name) { - var classes = el.className.split(/\s+/g), add = true; - while (true) { - var index = classes.indexOf(name); - if (index == -1) { - break; + /* + * Remove a CSS class from the list of classes on the given node + */ + exports.removeCssClass = function(el, name) { + var classes = el.className.split(/\s+/g); + while (true) { + var index = classes.indexOf(name); + if (index == -1) { + break; + } + classes.splice(index, 1); } - add = false; - classes.splice(index, 1); - } - if(add) - classes.push(name); + el.className = classes.join(" "); + }; - el.className = classes.join(" "); - return add; -}; + exports.toggleCssClass = function(el, name) { + var classes = el.className.split(/\s+/g), add = true; + while (true) { + var index = classes.indexOf(name); + if (index == -1) { + break; + } + add = false; + classes.splice(index, 1); + } + if(add) + classes.push(name); -/* - * Add or remove a CSS class from the list of classes on the given node - * depending on the value of include - */ -exports.setCssClass = function(node, className, include) { - if (include) { - exports.addCssClass(node, className); - } else { - exports.removeCssClass(node, className); - } -}; + el.className = classes.join(" "); + return add; + }; + + /* + * Add or remove a CSS class from the list of classes on the given node + * depending on the value of include + */ + exports.setCssClass = function(node, className, include) { + if (include) { + exports.addCssClass(node, className); + } else { + exports.removeCssClass(node, className); + } + }; +} exports.hasCssString = function(id, doc) { var index = 0, sheets; @@ -143,7 +157,7 @@ exports.importCssString = function importCssString(cssText, id, doc) { if (id) style.id = id; - var head = doc.getElementsByTagName("head")[0] || doc.documentElement; + var head = doc.head || doc.getElementsByTagName("head")[0] || doc.documentElement; head.appendChild(style); } }; @@ -156,7 +170,7 @@ exports.importCssStylsheet = function(uri, doc) { link.rel = 'stylesheet'; link.href = uri; - var head = doc.getElementsByTagName("head")[0] || doc.documentElement; + var head = doc.head || doc.getElementsByTagName("head")[0] || doc.documentElement; head.appendChild(link); } }; @@ -273,7 +287,7 @@ exports.getInnerText = function(el) { if (document.body && "textContent" in document.body) return el.textContent; else - return el.innerText || el.textContent || ""; + return el.innerText; }; exports.getParentWindow = function(document) { diff --git a/lib/ace/lib/event.js b/lib/ace/lib/event.js index 06574425215..37cb78462b8 100644 --- a/lib/ace/lib/event.js +++ b/lib/ace/lib/event.js @@ -301,10 +301,10 @@ if (window.postMessage && !useragent.isOldIE) { exports.nextFrame = window.requestAnimationFrame || - window.oRequestAnimationFrame || - window.msRequestAnimationFrame || window.mozRequestAnimationFrame || - window.webkitRequestAnimationFrame; + window.webkitRequestAnimationFrame || + window.msRequestAnimationFrame || + window.oRequestAnimationFrame; if (exports.nextFrame) exports.nextFrame = exports.nextFrame.bind(window); diff --git a/lib/ace/lib/net.js b/lib/ace/lib/net.js index bdb01ab6c95..e125582ed61 100644 --- a/lib/ace/lib/net.js +++ b/lib/ace/lib/net.js @@ -8,12 +8,10 @@ define(function(require, exports, module) { "use strict"; -var useragent = require("./useragent"); - exports.get = function (url, callback) { - var xhr = exports.createXhr(); + var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); - xhr.onreadystatechange = function (evt) { + xhr.onreadystatechange = function () { //Do not explicitly handle errors, those should be //visible via console output in the browser. if (xhr.readyState === 4) { @@ -23,47 +21,19 @@ exports.get = function (url, callback) { xhr.send(null); }; -var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0']; - -exports.createXhr = function() { - //Would love to dump the ActiveX crap in here. Need IE 6 to die first. - var xhr, i, progId; - if (typeof XMLHttpRequest !== "undefined") { - return new XMLHttpRequest(); - } else { - for (i = 0; i < 3; i++) { - progId = progIds[i]; - try { - xhr = new ActiveXObject(progId); - } catch (e) {} - - if (xhr) { - progIds = [progId]; // so faster next time - break; - } - } - } - - if (!xhr) { - throw new Error("createXhr(): XMLHttpRequest not available"); - } - - return xhr; -}; - exports.loadScript = function(path, callback) { - var head = document.getElementsByTagName('head')[0]; + var head = document.head || document.getElementsByTagName('head')[0]; var s = document.createElement('script'); s.src = path; head.appendChild(s); - if (useragent.isOldIE) + if (s.onload !== undefined) + s.onload = callback; + else s.onreadystatechange = function () { this.readyState == 'loaded' && callback(); }; - else - s.onload = callback; }; }); diff --git a/lib/ace/mode/behaviour/css.js b/lib/ace/mode/behaviour/css.js index fd1f4041684..1c35f74439e 100644 --- a/lib/ace/mode/behaviour/css.js +++ b/lib/ace/mode/behaviour/css.js @@ -70,11 +70,19 @@ var CssBehaviour = function () { this.add("colon", "deletion", function (state, action, editor, session, range) { var selected = session.doc.getTextRange(range); if (!range.isMultiLine() && selected === ':') { - var line = session.doc.getLine(range.start.row); - var rightChar = line.substring(range.end.column, range.end.column + 1); - if (rightChar === ';') { - range.end.column ++; - return range; + var cursor = editor.getCursorPosition(); + var iterator = new TokenIterator(session, cursor.row, cursor.column); + var token = iterator.getCurrentToken(); + if (token && token.value.match(/\s+/)) { + token = iterator.stepBackward(); + } + if (token && token.type === 'support.type') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.end.column, range.end.column + 1); + if (rightChar === ';') { + range.end.column ++; + return range; + } } } }); diff --git a/lib/ace/mouse/dragdrop.js b/lib/ace/mouse/dragdrop.js index 88f526b502f..b5c5b167a85 100644 --- a/lib/ace/mouse/dragdrop.js +++ b/lib/ace/mouse/dragdrop.js @@ -43,6 +43,9 @@ var DragdropHandler = function(mouseHandler) { event.addListener(mouseTarget, "dragenter", function(e) { if (editor.getReadOnly()) return; + var types = e.dataTransfer.types; + if (types && Array.prototype.indexOf.call(types, 'Files') !== -1) + return; counter++; if (!dragSelectionMarker) { range = editor.getSelectionRange(); @@ -59,6 +62,9 @@ var DragdropHandler = function(mouseHandler) { event.addListener(mouseTarget, "dragover", function(e) { if (editor.getReadOnly()) return; + var types = e.dataTransfer.types; + if (types && Array.prototype.indexOf.call(types, 'Files') !== -1) + return; x = e.clientX; y = e.clientY; return event.preventDefault(e); @@ -73,6 +79,9 @@ var DragdropHandler = function(mouseHandler) { event.addListener(mouseTarget, "dragleave", function(e) { if (editor.getReadOnly()) return; + var types = e.dataTransfer.types; + if (types && Array.prototype.indexOf.call(types, 'Files') !== -1) + return; counter--; if (counter > 0) return; diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index 6192b1331d4..6d4afcb5d4e 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -36,7 +36,6 @@ var dom = require("./lib/dom"); var event = require("./lib/event"); var useragent = require("./lib/useragent"); var config = require("./config"); -var net = require("./lib/net"); var GutterLayer = require("./layer/gutter").Gutter; var MarkerLayer = require("./layer/marker").Marker; var TextLayer = require("./layer/text").Text;