You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2013/10/30 14:43:28 UTC
[34/52] [partial] Remove unneeded ace files and codemirror
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5b8fb9c3/src/fauxton/assets/js/libs/ace/keyboard/vim/maps/operators.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/keyboard/vim/maps/operators.js b/src/fauxton/assets/js/libs/ace/keyboard/vim/maps/operators.js
deleted file mode 100644
index 067562a..0000000
--- a/src/fauxton/assets/js/libs/ace/keyboard/vim/maps/operators.js
+++ /dev/null
@@ -1,195 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Distributed under the BSD license:
- *
- * Copyright (c) 2010, Ajax.org B.V.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Ajax.org B.V. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ***** END LICENSE BLOCK ***** */
-
-define(function(require, exports, module) {
-
-"use strict";
-
-var util = require("./util");
-var registers = require("../registers");
-
-module.exports = {
- "d": {
- selFn: function(editor, range, count, param) {
- registers._default.text = editor.getCopyText();
- registers._default.isLine = util.onVisualLineMode;
- if(util.onVisualLineMode)
- editor.removeLines();
- else
- editor.session.remove(range);
- util.normalMode(editor);
- },
- fn: function(editor, range, count, param) {
- count = count || 1;
- switch (param) {
- case "d":
- registers._default.text = "";
- registers._default.isLine = true;
- for (var i = 0; i < count; i++) {
- editor.selection.selectLine();
- registers._default.text += editor.getCopyText();
- var selRange = editor.getSelectionRange();
- // check if end of the document was reached
- if (!selRange.isMultiLine()) {
- var row = selRange.start.row - 1;
- var col = editor.session.getLine(row).length
- selRange.setStart(row, col);
- editor.session.remove(selRange);
- editor.selection.clearSelection();
- break;
- }
- editor.session.remove(selRange);
- editor.selection.clearSelection();
- }
- registers._default.text = registers._default.text.replace(/\n$/, "");
- break;
- default:
- if (range) {
- editor.selection.setSelectionRange(range);
- registers._default.text = editor.getCopyText();
- registers._default.isLine = false;
- editor.session.remove(range);
- editor.selection.clearSelection();
- }
- }
- }
- },
- "c": {
- selFn: function(editor, range, count, param) {
- editor.session.remove(range);
- util.insertMode(editor);
- },
- fn: function(editor, range, count, param) {
- count = count || 1;
- switch (param) {
- case "c":
- for (var i = 0; i < count; i++) {
- editor.removeLines();
- util.insertMode(editor);
- }
-
- break;
- default:
- if (range) {
-
- // range.end.column ++;
- editor.session.remove(range);
- util.insertMode(editor);
- }
- }
- }
- },
- "y": {
- selFn: function(editor, range, count, param) {
- registers._default.text = editor.getCopyText();
- registers._default.isLine = util.onVisualLineMode;
- editor.selection.clearSelection();
- util.normalMode(editor);
- },
- fn: function(editor, range, count, param) {
- count = count || 1;
- switch (param) {
- case "y":
- var pos = editor.getCursorPosition();
- editor.selection.selectLine();
- for (var i = 0; i < count - 1; i++) {
- editor.selection.moveCursorDown();
- }
- registers._default.text = editor.getCopyText().replace(/\n$/, "");
- editor.selection.clearSelection();
- registers._default.isLine = true;
- editor.moveCursorToPosition(pos);
- break;
- default:
- if (range) {
- var pos = editor.getCursorPosition();
- editor.selection.setSelectionRange(range);
- registers._default.text = editor.getCopyText();
- registers._default.isLine = false;
- editor.selection.clearSelection();
- editor.moveCursorTo(pos.row, pos.column);
- }
- }
- }
- },
- ">": {
- selFn: function(editor, range, count, param) {
- count = count || 1;
- for (var i = 0; i < count; i++) {
- editor.indent();
- }
- util.normalMode(editor);
- },
- fn: function(editor, range, count, param) {
- count = parseInt(count || 1, 10);
- switch (param) {
- case ">":
- var pos = editor.getCursorPosition();
- editor.selection.selectLine();
- for (var i = 0; i < count - 1; i++) {
- editor.selection.moveCursorDown();
- }
- editor.indent();
- editor.selection.clearSelection();
- editor.moveCursorToPosition(pos);
- editor.navigateLineEnd();
- editor.navigateLineStart();
- break;
- }
- }
- },
- "<": {
- selFn: function(editor, range, count, param) {
- count = count || 1;
- for (var i = 0; i < count; i++) {
- editor.blockOutdent();
- }
- util.normalMode(editor);
- },
- fn: function(editor, range, count, param) {
- count = count || 1;
- switch (param) {
- case "<":
- var pos = editor.getCursorPosition();
- editor.selection.selectLine();
- for (var i = 0; i < count - 1; i++) {
- editor.selection.moveCursorDown();
- }
- editor.blockOutdent();
- editor.selection.clearSelection();
- editor.moveCursorToPosition(pos);
- editor.navigateLineEnd();
- editor.navigateLineStart();
- break;
- }
- }
- }
-};
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5b8fb9c3/src/fauxton/assets/js/libs/ace/keyboard/vim/maps/util.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/keyboard/vim/maps/util.js b/src/fauxton/assets/js/libs/ace/keyboard/vim/maps/util.js
deleted file mode 100644
index af0e07c..0000000
--- a/src/fauxton/assets/js/libs/ace/keyboard/vim/maps/util.js
+++ /dev/null
@@ -1,134 +0,0 @@
-define(function(require, exports, module) {
-var registers = require("../registers");
-
-var dom = require("../../../lib/dom");
-dom.importCssString('.insert-mode .ace_cursor{\
- border-left: 2px solid #333333;\
-}\
-.ace_dark.insert-mode .ace_cursor{\
- border-left: 2px solid #eeeeee;\
-}\
-.normal-mode .ace_cursor{\
- border: 0!important;\
- background-color: red;\
- opacity: 0.5;\
-}', 'vimMode');
-
-module.exports = {
- onVisualMode: false,
- onVisualLineMode: false,
- currentMode: 'normal',
- noMode: function(editor) {
- editor.unsetStyle('insert-mode');
- editor.unsetStyle('normal-mode');
- if (editor.commands.recording)
- editor.commands.toggleRecording(editor);
- editor.setOverwrite(false);
- },
- insertMode: function(editor) {
- this.currentMode = 'insert';
- // Switch editor to insert mode
- editor.setStyle('insert-mode');
- editor.unsetStyle('normal-mode');
-
- editor.setOverwrite(false);
- editor.keyBinding.$data.buffer = "";
- editor.keyBinding.$data.state = "insertMode";
- this.onVisualMode = false;
- this.onVisualLineMode = false;
- if(this.onInsertReplaySequence) {
- // Ok, we're apparently replaying ("."), so let's do it
- editor.commands.macro = this.onInsertReplaySequence;
- editor.commands.replay(editor);
- this.onInsertReplaySequence = null;
- this.normalMode(editor);
- } else {
- editor._emit("changeStatus");
- // Record any movements, insertions in insert mode
- if(!editor.commands.recording)
- editor.commands.toggleRecording(editor);
- }
- },
- normalMode: function(editor) {
- // Switch editor to normal mode
- this.currentMode = 'normal';
-
- editor.unsetStyle('insert-mode');
- editor.setStyle('normal-mode');
- editor.clearSelection();
-
- var pos;
- if (!editor.getOverwrite()) {
- pos = editor.getCursorPosition();
- if (pos.column > 0)
- editor.navigateLeft();
- }
-
- editor.setOverwrite(true);
- editor.keyBinding.$data.buffer = "";
- editor.keyBinding.$data.state = "start";
- this.onVisualMode = false;
- this.onVisualLineMode = false;
- editor._emit("changeStatus");
- // Save recorded keystrokes
- if (editor.commands.recording) {
- editor.commands.toggleRecording(editor);
- return editor.commands.macro;
- }
- else {
- return [];
- }
- },
- visualMode: function(editor, lineMode) {
- if (
- (this.onVisualLineMode && lineMode)
- || (this.onVisualMode && !lineMode)
- ) {
- this.normalMode(editor);
- return;
- }
-
- editor.setStyle('insert-mode');
- editor.unsetStyle('normal-mode');
-
- editor._emit("changeStatus");
- if (lineMode) {
- this.onVisualLineMode = true;
- } else {
- this.onVisualMode = true;
- this.onVisualLineMode = false;
- }
- },
- getRightNthChar: function(editor, cursor, ch, n) {
- var line = editor.getSession().getLine(cursor.row);
- var matches = line.substr(cursor.column + 1).split(ch);
-
- return n < matches.length ? matches.slice(0, n).join(ch).length : null;
- },
- getLeftNthChar: function(editor, cursor, ch, n) {
- var line = editor.getSession().getLine(cursor.row);
- var matches = line.substr(0, cursor.column).split(ch);
-
- return n < matches.length ? matches.slice(-1 * n).join(ch).length : null;
- },
- toRealChar: function(ch) {
- if (ch.length === 1)
- return ch;
-
- if (/^shift-./.test(ch))
- return ch[ch.length - 1].toUpperCase();
- else
- return "";
- },
- copyLine: function(editor) {
- var pos = editor.getCursorPosition();
- editor.selection.clearSelection();
- editor.moveCursorTo(pos.row, pos.column);
- editor.selection.selectLine();
- registers._default.isLine = true;
- registers._default.text = editor.getCopyText().replace(/\n$/, "");
- editor.selection.clearSelection();
- editor.moveCursorTo(pos.row, pos.column);
- }
-};
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5b8fb9c3/src/fauxton/assets/js/libs/ace/keyboard/vim/registers.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/keyboard/vim/registers.js b/src/fauxton/assets/js/libs/ace/keyboard/vim/registers.js
deleted file mode 100644
index ef929a3..0000000
--- a/src/fauxton/assets/js/libs/ace/keyboard/vim/registers.js
+++ /dev/null
@@ -1,42 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Distributed under the BSD license:
- *
- * Copyright (c) 2010, Ajax.org B.V.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Ajax.org B.V. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ***** END LICENSE BLOCK ***** */
-
-define(function(require, exports, module) {
-
-"never use strict";
-
-module.exports = {
- _default: {
- text: "",
- isLine: false
- }
-};
-
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5b8fb9c3/src/fauxton/assets/js/libs/ace/layer/cursor.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/layer/cursor.js b/src/fauxton/assets/js/libs/ace/layer/cursor.js
deleted file mode 100644
index 26ade52..0000000
--- a/src/fauxton/assets/js/libs/ace/layer/cursor.js
+++ /dev/null
@@ -1,217 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Distributed under the BSD license:
- *
- * Copyright (c) 2010, Ajax.org B.V.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Ajax.org B.V. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ***** END LICENSE BLOCK ***** */
-
-define(function(require, exports, module) {
-"use strict";
-
-var dom = require("../lib/dom");
-
-var Cursor = function(parentEl) {
- this.element = dom.createElement("div");
- this.element.className = "ace_layer ace_cursor-layer";
- parentEl.appendChild(this.element);
-
- this.isVisible = false;
- this.isBlinking = true;
- this.blinkInterval = 1000;
- this.smoothBlinking = false;
-
- this.cursors = [];
- this.cursor = this.addCursor();
- dom.addCssClass(this.element, "ace_hidden-cursors");
-};
-
-(function() {
-
- this.$padding = 0;
- this.setPadding = function(padding) {
- this.$padding = padding;
- };
-
- this.setSession = function(session) {
- this.session = session;
- };
-
- this.setBlinking = function(blinking) {
- if (blinking != this.isBlinking){
- this.isBlinking = blinking;
- this.restartTimer();
- }
- };
-
- this.setBlinkInterval = function(blinkInterval) {
- if (blinkInterval != this.blinkInterval){
- this.blinkInterval = blinkInterval;
- this.restartTimer();
- }
- };
-
- this.setSmoothBlinking = function(smoothBlinking) {
- if (smoothBlinking != this.smoothBlinking) {
- this.smoothBlinking = smoothBlinking;
- if (smoothBlinking)
- dom.addCssClass(this.element, "ace_smooth-blinking");
- else
- dom.removeCssClass(this.element, "ace_smooth-blinking");
- this.restartTimer();
- }
- };
-
- this.addCursor = function() {
- var el = dom.createElement("div");
- el.className = "ace_cursor";
- this.element.appendChild(el);
- this.cursors.push(el);
- return el;
- };
-
- this.removeCursor = function() {
- if (this.cursors.length > 1) {
- var el = this.cursors.pop();
- el.parentNode.removeChild(el);
- return el;
- }
- };
-
- this.hideCursor = function() {
- this.isVisible = false;
- dom.addCssClass(this.element, "ace_hidden-cursors");
- this.restartTimer();
- };
-
- this.showCursor = function() {
- this.isVisible = true;
- dom.removeCssClass(this.element, "ace_hidden-cursors");
- this.restartTimer();
- };
-
- this.restartTimer = function() {
- clearInterval(this.intervalId);
- clearTimeout(this.timeoutId);
- if (this.smoothBlinking)
- dom.removeCssClass(this.element, "ace_smooth-blinking");
- for (var i = this.cursors.length; i--; )
- this.cursors[i].style.opacity = "";
-
- if (!this.isBlinking || !this.blinkInterval || !this.isVisible)
- return;
-
- if (this.smoothBlinking)
- setTimeout(function(){
- dom.addCssClass(this.element, "ace_smooth-blinking");
- }.bind(this));
-
- var blink = function(){
- this.timeoutId = setTimeout(function() {
- for (var i = this.cursors.length; i--; ) {
- this.cursors[i].style.opacity = 0;
- }
- }.bind(this), 0.6 * this.blinkInterval);
- }.bind(this);
-
- this.intervalId = setInterval(function() {
- for (var i = this.cursors.length; i--; ) {
- this.cursors[i].style.opacity = "";
- }
- blink();
- }.bind(this), this.blinkInterval);
-
- blink();
- };
-
- this.getPixelPosition = function(position, onScreen) {
- if (!this.config || !this.session)
- return {left : 0, top : 0};
-
- if (!position)
- position = this.session.selection.getCursor();
- var pos = this.session.documentToScreenPosition(position);
- var cursorLeft = this.$padding + pos.column * this.config.characterWidth;
- var cursorTop = (pos.row - (onScreen ? this.config.firstRowScreen : 0)) *
- this.config.lineHeight;
-
- return {left : cursorLeft, top : cursorTop};
- };
-
- this.update = function(config) {
- this.config = config;
-
- var selections = this.session.$selectionMarkers;
- var i = 0, cursorIndex = 0;
-
- if (selections === undefined || selections.length === 0){
- selections = [{cursor: null}];
- }
-
- for (var i = 0, n = selections.length; i < n; i++) {
- var pixelPos = this.getPixelPosition(selections[i].cursor, true);
- if ((pixelPos.top > config.height + config.offset ||
- pixelPos.top < -config.offset) && i > 1) {
- continue;
- }
-
- var style = (this.cursors[cursorIndex++] || this.addCursor()).style;
-
- style.left = pixelPos.left + "px";
- style.top = pixelPos.top + "px";
- style.width = config.characterWidth + "px";
- style.height = config.lineHeight + "px";
- }
- while (this.cursors.length > cursorIndex)
- this.removeCursor();
-
- var overwrite = this.session.getOverwrite();
- this.$setOverwrite(overwrite);
-
- // cache for textarea and gutter highlight
- this.$pixelPos = pixelPos;
- this.restartTimer();
- };
-
- this.$setOverwrite = function(overwrite) {
- if (overwrite != this.overwrite) {
- this.overwrite = overwrite;
- if (overwrite)
- dom.addCssClass(this.element, "ace_overwrite-cursors");
- else
- dom.removeCssClass(this.element, "ace_overwrite-cursors");
- }
- };
-
- this.destroy = function() {
- clearInterval(this.intervalId);
- clearTimeout(this.timeoutId);
- };
-
-}).call(Cursor.prototype);
-
-exports.Cursor = Cursor;
-
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5b8fb9c3/src/fauxton/assets/js/libs/ace/layer/gutter.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/layer/gutter.js b/src/fauxton/assets/js/libs/ace/layer/gutter.js
deleted file mode 100644
index c1130d8..0000000
--- a/src/fauxton/assets/js/libs/ace/layer/gutter.js
+++ /dev/null
@@ -1,265 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Distributed under the BSD license:
- *
- * Copyright (c) 2010, Ajax.org B.V.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Ajax.org B.V. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ***** END LICENSE BLOCK ***** */
-
-define(function(require, exports, module) {
-"use strict";
-
-var dom = require("../lib/dom");
-var oop = require("../lib/oop");
-var lang = require("../lib/lang");
-var EventEmitter = require("../lib/event_emitter").EventEmitter;
-
-var Gutter = function(parentEl) {
- this.element = dom.createElement("div");
- this.element.className = "ace_layer ace_gutter-layer";
- parentEl.appendChild(this.element);
- this.setShowFoldWidgets(this.$showFoldWidgets);
-
- this.gutterWidth = 0;
-
- this.$annotations = [];
- this.$updateAnnotations = this.$updateAnnotations.bind(this);
-
- this.$cells = [];
-};
-
-(function() {
-
- oop.implement(this, EventEmitter);
-
- this.setSession = function(session) {
- if (this.session)
- this.session.removeEventListener("change", this.$updateAnnotations);
- this.session = session;
- session.on("change", this.$updateAnnotations);
- };
-
- this.addGutterDecoration = function(row, className){
- if (window.console)
- console.warn && console.warn("deprecated use session.addGutterDecoration");
- this.session.addGutterDecoration(row, className);
- };
-
- this.removeGutterDecoration = function(row, className){
- if (window.console)
- console.warn && console.warn("deprecated use session.removeGutterDecoration");
- this.session.removeGutterDecoration(row, className);
- };
-
- this.setAnnotations = function(annotations) {
- // iterate over sparse array
- this.$annotations = []
- var rowInfo, row;
- for (var i = 0; i < annotations.length; i++) {
- var annotation = annotations[i];
- var row = annotation.row;
- var rowInfo = this.$annotations[row];
- if (!rowInfo)
- rowInfo = this.$annotations[row] = {text: []};
-
- var annoText = annotation.text;
- annoText = annoText ? lang.escapeHTML(annoText) : annotation.html || "";
-
- if (rowInfo.text.indexOf(annoText) === -1)
- rowInfo.text.push(annoText);
-
- var type = annotation.type;
- if (type == "error")
- rowInfo.className = " ace_error";
- else if (type == "warning" && rowInfo.className != " ace_error")
- rowInfo.className = " ace_warning";
- else if (type == "info" && (!rowInfo.className))
- rowInfo.className = " ace_info";
- }
- };
-
- this.$updateAnnotations = function (e) {
- if (!this.$annotations.length)
- return;
- var delta = e.data;
- var range = delta.range;
- var firstRow = range.start.row;
- var len = range.end.row - firstRow;
- if (len === 0) {
- // do nothing
- } else if (delta.action == "removeText" || delta.action == "removeLines") {
- this.$annotations.splice(firstRow, len + 1, null);
- } else {
- var args = Array(len + 1);
- args.unshift(firstRow, 1);
- this.$annotations.splice.apply(this.$annotations, args);
- }
- };
-
- this.update = function(config) {
- var firstRow = config.firstRow;
- var lastRow = config.lastRow;
- var fold = this.session.getNextFoldLine(firstRow);
- var foldStart = fold ? fold.start.row : Infinity;
- var foldWidgets = this.$showFoldWidgets && this.session.foldWidgets;
- var breakpoints = this.session.$breakpoints;
- var decorations = this.session.$decorations;
- var firstLineNumber = this.session.$firstLineNumber;
- var lastLineNumber = 0;
-
- var cell = null;
- var index = -1;
- var row = firstRow;
- while (true) {
- if (row > foldStart) {
- row = fold.end.row + 1;
- fold = this.session.getNextFoldLine(row, fold);
- foldStart = fold ? fold.start.row : Infinity;
- }
- if (row > lastRow) {
- while (this.$cells.length > index + 1) {
- cell = this.$cells.pop();
- this.element.removeChild(cell.element);
- }
- break;
- }
-
- cell = this.$cells[++index];
- if (!cell) {
- cell = {element: null, textNode: null, foldWidget: null};
- cell.element = dom.createElement("div");
- cell.textNode = document.createTextNode('');
- cell.element.appendChild(cell.textNode);
- this.element.appendChild(cell.element);
- this.$cells[index] = cell;
- }
-
- var className = "ace_gutter-cell ";
- if (breakpoints[row])
- className += breakpoints[row];
- if (decorations[row])
- className += decorations[row];
- if (this.$annotations[row])
- className += this.$annotations[row].className;
- if (cell.element.className != className)
- cell.element.className = className;
-
- var height = this.session.getRowLength(row) * config.lineHeight + "px";
- if (height != cell.element.style.height)
- cell.element.style.height = height;
-
- var text = lastLineNumber = row + firstLineNumber;
- if (text != cell.textNode.data)
- cell.textNode.data = text;
-
- if (foldWidgets) {
- var c = foldWidgets[row];
- // check if cached value is invalidated and we need to recompute
- if (c == null)
- c = foldWidgets[row] = this.session.getFoldWidget(row);
- }
-
- if (c) {
- if (!cell.foldWidget) {
- cell.foldWidget = dom.createElement("span");
- cell.element.appendChild(cell.foldWidget);
- }
- var className = "ace_fold-widget ace_" + c;
- if (c == "start" && row == foldStart && row < fold.end.row)
- className += " ace_closed";
- else
- className += " ace_open";
- if (cell.foldWidget.className != className)
- cell.foldWidget.className = className;
-
- var height = config.lineHeight + "px";
- if (cell.foldWidget.style.height != height)
- cell.foldWidget.style.height = height;
- } else {
- if (cell.foldWidget != null) {
- cell.element.removeChild(cell.foldWidget);
- cell.foldWidget = null;
- }
- }
-
- row++;
- }
-
- this.element.style.height = config.minHeight + "px";
-
- if (this.$fixedWidth || this.session.$useWrapMode)
- lastLineNumber = this.session.getLength();
-
- var gutterWidth = lastLineNumber.toString().length * config.characterWidth;
- var padding = this.$padding || this.$computePadding();
- gutterWidth += padding.left + padding.right;
- if (gutterWidth !== this.gutterWidth && !isNaN(gutterWidth)) {
- this.gutterWidth = gutterWidth;
- this.element.style.width = Math.ceil(this.gutterWidth) + "px";
- this._emit("changeGutterWidth", gutterWidth);
- }
- };
-
- this.$fixedWidth = false;
-
- this.$showFoldWidgets = true;
- this.setShowFoldWidgets = function(show) {
- if (show)
- dom.addCssClass(this.element, "ace_folding-enabled");
- else
- dom.removeCssClass(this.element, "ace_folding-enabled");
-
- this.$showFoldWidgets = show;
- this.$padding = null;
- };
-
- this.getShowFoldWidgets = function() {
- return this.$showFoldWidgets;
- };
-
- this.$computePadding = function() {
- if (!this.element.firstChild)
- return {left: 0, right: 0};
- var style = dom.computedStyle(this.element.firstChild);
- this.$padding = {};
- this.$padding.left = parseInt(style.paddingLeft) + 1 || 0;
- this.$padding.right = parseInt(style.paddingRight) || 0;
- return this.$padding;
- };
-
- this.getRegion = function(point) {
- var padding = this.$padding || this.$computePadding();
- var rect = this.element.getBoundingClientRect();
- if (point.x < padding.left + rect.left)
- return "markers";
- if (this.$showFoldWidgets && point.x > rect.right - padding.right)
- return "foldWidgets";
- };
-
-}).call(Gutter.prototype);
-
-exports.Gutter = Gutter;
-
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5b8fb9c3/src/fauxton/assets/js/libs/ace/layer/marker.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/layer/marker.js b/src/fauxton/assets/js/libs/ace/layer/marker.js
deleted file mode 100644
index cd1b992..0000000
--- a/src/fauxton/assets/js/libs/ace/layer/marker.js
+++ /dev/null
@@ -1,218 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Distributed under the BSD license:
- *
- * Copyright (c) 2010, Ajax.org B.V.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Ajax.org B.V. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ***** END LICENSE BLOCK ***** */
-
-define(function(require, exports, module) {
-"use strict";
-
-var Range = require("../range").Range;
-var dom = require("../lib/dom");
-
-var Marker = function(parentEl) {
- this.element = dom.createElement("div");
- this.element.className = "ace_layer ace_marker-layer";
- parentEl.appendChild(this.element);
-};
-
-(function() {
-
- this.$padding = 0;
-
- this.setPadding = function(padding) {
- this.$padding = padding;
- };
- this.setSession = function(session) {
- this.session = session;
- };
-
- this.setMarkers = function(markers) {
- this.markers = markers;
- };
-
- this.update = function(config) {
- var config = config || this.config;
- if (!config)
- return;
-
- this.config = config;
-
-
- var html = [];
- for (var key in this.markers) {
- var marker = this.markers[key];
-
- if (!marker.range) {
- marker.update(html, this, this.session, config);
- continue;
- }
-
- var range = marker.range.clipRows(config.firstRow, config.lastRow);
- if (range.isEmpty()) continue;
-
- range = range.toScreenRange(this.session);
- if (marker.renderer) {
- var top = this.$getTop(range.start.row, config);
- var left = this.$padding + range.start.column * config.characterWidth;
- marker.renderer(html, range, left, top, config);
- } else if (marker.type == "fullLine") {
- this.drawFullLineMarker(html, range, marker.clazz, config);
- } else if (marker.type == "screenLine") {
- this.drawScreenLineMarker(html, range, marker.clazz, config);
- } else if (range.isMultiLine()) {
- if (marker.type == "text")
- this.drawTextMarker(html, range, marker.clazz, config);
- else
- this.drawMultiLineMarker(html, range, marker.clazz, config);
- } else {
- this.drawSingleLineMarker(html, range, marker.clazz + " ace_start", config);
- }
- }
- this.element = dom.setInnerHtml(this.element, html.join(""));
- };
-
- this.$getTop = function(row, layerConfig) {
- return (row - layerConfig.firstRowScreen) * layerConfig.lineHeight;
- };
-
- // Draws a marker, which spans a range of text on multiple lines
- this.drawTextMarker = function(stringBuilder, range, clazz, layerConfig, extraStyle) {
- // selection start
- var row = range.start.row;
-
- var lineRange = new Range(
- row, range.start.column,
- row, this.session.getScreenLastRowColumn(row)
- );
- this.drawSingleLineMarker(stringBuilder, lineRange, clazz + " ace_start", layerConfig, 1, extraStyle);
-
- // selection end
- row = range.end.row;
- lineRange = new Range(row, 0, row, range.end.column);
- this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig, 0, extraStyle);
-
- for (row = range.start.row + 1; row < range.end.row; row++) {
- lineRange.start.row = row;
- lineRange.end.row = row;
- lineRange.end.column = this.session.getScreenLastRowColumn(row);
- this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig, 1, extraStyle);
- }
- };
-
- // Draws a multi line marker, where lines span the full width
- this.drawMultiLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
- // from selection start to the end of the line
- var padding = this.$padding;
- var height = config.lineHeight;
- var top = this.$getTop(range.start.row, config);
- var left = padding + range.start.column * config.characterWidth;
- extraStyle = extraStyle || "";
-
- stringBuilder.push(
- "<div class='", clazz, " ace_start' style='",
- "height:", height, "px;",
- "right:0;",
- "top:", top, "px;",
- "left:", left, "px;", extraStyle, "'></div>"
- );
-
- // from start of the last line to the selection end
- top = this.$getTop(range.end.row, config);
- var width = range.end.column * config.characterWidth;
-
- stringBuilder.push(
- "<div class='", clazz, "' style='",
- "height:", height, "px;",
- "width:", width, "px;",
- "top:", top, "px;",
- "left:", padding, "px;", extraStyle, "'></div>"
- );
-
- // all the complete lines
- height = (range.end.row - range.start.row - 1) * config.lineHeight;
- if (height < 0)
- return;
- top = this.$getTop(range.start.row + 1, config);
-
- stringBuilder.push(
- "<div class='", clazz, "' style='",
- "height:", height, "px;",
- "right:0;",
- "top:", top, "px;",
- "left:", padding, "px;", extraStyle, "'></div>"
- );
- };
-
- // Draws a marker which covers part or whole width of a single screen line
- this.drawSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength, extraStyle) {
- var height = config.lineHeight;
- var width = (range.end.column + (extraLength || 0) - range.start.column) * config.characterWidth;
-
- var top = this.$getTop(range.start.row, config);
- var left = this.$padding + range.start.column * config.characterWidth;
-
- stringBuilder.push(
- "<div class='", clazz, "' style='",
- "height:", height, "px;",
- "width:", width, "px;",
- "top:", top, "px;",
- "left:", left, "px;", extraStyle || "", "'></div>"
- );
- };
-
- this.drawFullLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
- var top = this.$getTop(range.start.row, config);
- var height = config.lineHeight;
- if (range.start.row != range.end.row)
- height += this.$getTop(range.end.row, config) - top;
-
- stringBuilder.push(
- "<div class='", clazz, "' style='",
- "height:", height, "px;",
- "top:", top, "px;",
- "left:0;right:0;", extraStyle || "", "'></div>"
- );
- };
-
- this.drawScreenLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
- var top = this.$getTop(range.start.row, config);
- var height = config.lineHeight;
-
- stringBuilder.push(
- "<div class='", clazz, "' style='",
- "height:", height, "px;",
- "top:", top, "px;",
- "left:0;right:0;", extraStyle || "", "'></div>"
- );
- };
-
-}).call(Marker.prototype);
-
-exports.Marker = Marker;
-
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5b8fb9c3/src/fauxton/assets/js/libs/ace/layer/text.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/layer/text.js b/src/fauxton/assets/js/libs/ace/layer/text.js
deleted file mode 100644
index 54f0ef4..0000000
--- a/src/fauxton/assets/js/libs/ace/layer/text.js
+++ /dev/null
@@ -1,661 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Distributed under the BSD license:
- *
- * Copyright (c) 2010, Ajax.org B.V.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Ajax.org B.V. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ***** END LICENSE BLOCK ***** */
-
-define(function(require, exports, module) {
-"use strict";
-
-var oop = require("../lib/oop");
-var dom = require("../lib/dom");
-var lang = require("../lib/lang");
-var useragent = require("../lib/useragent");
-var EventEmitter = require("../lib/event_emitter").EventEmitter;
-
-var Text = function(parentEl) {
- this.element = dom.createElement("div");
- this.element.className = "ace_layer ace_text-layer";
- parentEl.appendChild(this.element);
-
- this.$characterSize = {width: 0, height: 0};
- this.checkForSizeChanges();
- this.$pollSizeChanges();
-};
-
-(function() {
-
- oop.implement(this, EventEmitter);
-
- this.EOF_CHAR = "\xB6"; //"¶";
- this.EOL_CHAR = "\xAC"; //"¬";
- this.TAB_CHAR = "\u2192"; //"→" "\u21E5";
- this.SPACE_CHAR = "\xB7"; //"·";
- this.$padding = 0;
-
- this.setPadding = function(padding) {
- this.$padding = padding;
- this.element.style.padding = "0 " + padding + "px";
- };
-
- this.getLineHeight = function() {
- return this.$characterSize.height || 0;
- };
-
- this.getCharacterWidth = function() {
- return this.$characterSize.width || 0;
- };
-
- this.checkForSizeChanges = function() {
- var size = this.$measureSizes();
- if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) {
- this.$measureNode.style.fontWeight = "bold";
- var boldSize = this.$measureSizes();
- this.$measureNode.style.fontWeight = "";
- this.$characterSize = size;
- this.allowBoldFonts = boldSize && boldSize.width === size.width && boldSize.height === size.height;
- this._emit("changeCharacterSize", {data: size});
- }
- };
-
- this.$pollSizeChanges = function() {
- var self = this;
- this.$pollSizeChangesTimer = setInterval(function() {
- self.checkForSizeChanges();
- }, 500);
- };
-
- this.$fontStyles = {
- fontFamily : 1,
- fontSize : 1,
- fontWeight : 1,
- fontStyle : 1,
- lineHeight : 1
- };
-
- this.$measureSizes = useragent.isIE || useragent.isOldGecko ? function() {
- var n = 1000;
- if (!this.$measureNode) {
- var measureNode = this.$measureNode = dom.createElement("div");
- var style = measureNode.style;
-
- style.width = style.height = "auto";
- style.left = style.top = (-n * 40) + "px";
-
- style.visibility = "hidden";
- style.position = "fixed";
- style.overflow = "visible";
- style.whiteSpace = "nowrap";
-
- // in FF 3.6 monospace fonts can have a fixed sub pixel width.
- // that's why we have to measure many characters
- // Note: characterWidth can be a float!
- measureNode.innerHTML = lang.stringRepeat("Xy", n);
-
- if (this.element.ownerDocument.body) {
- this.element.ownerDocument.body.appendChild(measureNode);
- } else {
- var container = this.element.parentNode;
- while (!dom.hasCssClass(container, "ace_editor"))
- container = container.parentNode;
- container.appendChild(measureNode);
- }
- }
-
- // Size and width can be null if the editor is not visible or
- // detached from the document
- if (!this.element.offsetWidth)
- return null;
-
- var style = this.$measureNode.style;
- var computedStyle = dom.computedStyle(this.element);
- for (var prop in this.$fontStyles)
- style[prop] = computedStyle[prop];
-
- var size = {
- height: this.$measureNode.offsetHeight,
- width: this.$measureNode.offsetWidth / (n * 2)
- };
-
- // Size and width can be null if the editor is not visible or
- // detached from the document
- if (size.width == 0 || size.height == 0)
- return null;
-
- return size;
- }
- : function() {
- if (!this.$measureNode) {
- var measureNode = this.$measureNode = dom.createElement("div");
- var style = measureNode.style;
-
- style.width = style.height = "auto";
- style.left = style.top = -100 + "px";
-
- style.visibility = "hidden";
- style.position = "fixed";
- style.overflow = "visible";
- style.whiteSpace = "nowrap";
-
- // fixes fractional fixed-width fonts; see http://git.io/CavZNw
- measureNode.innerHTML = lang.stringRepeat("X", 100);
-
- var container = this.element.parentNode;
- while (container && !dom.hasCssClass(container, "ace_editor"))
- container = container.parentNode;
-
- if (!container)
- return this.$measureNode = null;
-
- container.appendChild(measureNode);
- }
-
- var rect = this.$measureNode.getBoundingClientRect();
-
- var size = {
- height: rect.height,
- width: rect.width / 100
- };
-
- // Size and width can be null if the editor is not visible or
- // detached from the document
- if (size.width == 0 || size.height == 0)
- return null;
-
- return size;
- };
-
- this.setSession = function(session) {
- this.session = session;
- this.$computeTabString();
- };
-
- this.showInvisibles = false;
- this.setShowInvisibles = function(showInvisibles) {
- if (this.showInvisibles == showInvisibles)
- return false;
-
- this.showInvisibles = showInvisibles;
- this.$computeTabString();
- return true;
- };
-
- this.displayIndentGuides = true;
- this.setDisplayIndentGuides = function(display) {
- if (this.displayIndentGuides == display)
- return false;
-
- this.displayIndentGuides = display;
- this.$computeTabString();
- return true;
- };
-
- this.$tabStrings = [];
- this.onChangeTabSize =
- this.$computeTabString = function() {
- var tabSize = this.session.getTabSize();
- this.tabSize = tabSize;
- var tabStr = this.$tabStrings = [0];
- for (var i = 1; i < tabSize + 1; i++) {
- if (this.showInvisibles) {
- tabStr.push("<span class='ace_invisible'>"
- + this.TAB_CHAR
- + lang.stringRepeat("\xa0", i - 1)
- + "</span>");
- } else {
- tabStr.push(lang.stringRepeat("\xa0", i));
- }
- }
- if (this.displayIndentGuides) {
- this.$indentGuideRe = /\s\S| \t|\t |\s$/;
- var className = "ace_indent-guide";
- if (this.showInvisibles) {
- className += " ace_invisible";
- var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize);
- var tabContent = this.TAB_CHAR + lang.stringRepeat("\xa0", this.tabSize - 1);
- } else{
- var spaceContent = lang.stringRepeat("\xa0", this.tabSize);
- var tabContent = spaceContent;
- }
-
- this.$tabStrings[" "] = "<span class='" + className + "'>" + spaceContent + "</span>";
- this.$tabStrings["\t"] = "<span class='" + className + "'>" + tabContent + "</span>";
- }
- };
-
- this.updateLines = function(config, firstRow, lastRow) {
- // Due to wrap line changes there can be new lines if e.g.
- // the line to updated wrapped in the meantime.
- if (this.config.lastRow != config.lastRow ||
- this.config.firstRow != config.firstRow) {
- this.scrollLines(config);
- }
- this.config = config;
-
- var first = Math.max(firstRow, config.firstRow);
- var last = Math.min(lastRow, config.lastRow);
-
- var lineElements = this.element.childNodes;
- var lineElementsIdx = 0;
-
- for (var row = config.firstRow; row < first; row++) {
- var foldLine = this.session.getFoldLine(row);
- if (foldLine) {
- if (foldLine.containsRow(first)) {
- first = foldLine.start.row;
- break;
- } else {
- row = foldLine.end.row;
- }
- }
- lineElementsIdx ++;
- }
-
- var row = first;
- var foldLine = this.session.getNextFoldLine(row);
- var foldStart = foldLine ? foldLine.start.row : Infinity;
-
- while (true) {
- if (row > foldStart) {
- row = foldLine.end.row+1;
- foldLine = this.session.getNextFoldLine(row, foldLine);
- foldStart = foldLine ? foldLine.start.row :Infinity;
- }
- if (row > last)
- break;
-
- var lineElement = lineElements[lineElementsIdx++];
- if (lineElement) {
- var html = [];
- this.$renderLine(
- html, row, !this.$useLineGroups(), row == foldStart ? foldLine : false
- );
- dom.setInnerHtml(lineElement, html.join(""));
- }
- row++;
- }
- };
-
- this.scrollLines = function(config) {
- var oldConfig = this.config;
- this.config = config;
-
- if (!oldConfig || oldConfig.lastRow < config.firstRow)
- return this.update(config);
-
- if (config.lastRow < oldConfig.firstRow)
- return this.update(config);
-
- var el = this.element;
- if (oldConfig.firstRow < config.firstRow)
- for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--)
- el.removeChild(el.firstChild);
-
- if (oldConfig.lastRow > config.lastRow)
- for (var row=this.session.getFoldedRowCount(config.lastRow + 1, oldConfig.lastRow); row>0; row--)
- el.removeChild(el.lastChild);
-
- if (config.firstRow < oldConfig.firstRow) {
- var fragment = this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1);
- if (el.firstChild)
- el.insertBefore(fragment, el.firstChild);
- else
- el.appendChild(fragment);
- }
-
- if (config.lastRow > oldConfig.lastRow) {
- var fragment = this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow);
- el.appendChild(fragment);
- }
- };
-
- this.$renderLinesFragment = function(config, firstRow, lastRow) {
- var fragment = this.element.ownerDocument.createDocumentFragment();
- var row = firstRow;
- var foldLine = this.session.getNextFoldLine(row);
- var foldStart = foldLine ? foldLine.start.row : Infinity;
-
- while (true) {
- if (row > foldStart) {
- row = foldLine.end.row+1;
- foldLine = this.session.getNextFoldLine(row, foldLine);
- foldStart = foldLine ? foldLine.start.row : Infinity;
- }
- if (row > lastRow)
- break;
-
- var container = dom.createElement("div");
-
- var html = [];
- // Get the tokens per line as there might be some lines in between
- // beeing folded.
- this.$renderLine(html, row, false, row == foldStart ? foldLine : false);
-
- // don't use setInnerHtml since we are working with an empty DIV
- container.innerHTML = html.join("");
- if (this.$useLineGroups()) {
- container.className = 'ace_line_group';
- fragment.appendChild(container);
- } else {
- var lines = container.childNodes
- while(lines.length)
- fragment.appendChild(lines[0]);
- }
-
- row++;
- }
- return fragment;
- };
-
- this.update = function(config) {
- this.config = config;
-
- var html = [];
- var firstRow = config.firstRow, lastRow = config.lastRow;
-
- var row = firstRow;
- var foldLine = this.session.getNextFoldLine(row);
- var foldStart = foldLine ? foldLine.start.row : Infinity;
-
- while (true) {
- if (row > foldStart) {
- row = foldLine.end.row+1;
- foldLine = this.session.getNextFoldLine(row, foldLine);
- foldStart = foldLine ? foldLine.start.row :Infinity;
- }
- if (row > lastRow)
- break;
-
- if (this.$useLineGroups())
- html.push("<div class='ace_line_group'>")
-
- this.$renderLine(html, row, false, row == foldStart ? foldLine : false);
-
- if (this.$useLineGroups())
- html.push("</div>"); // end the line group
-
- row++;
- }
- this.element = dom.setInnerHtml(this.element, html.join(""));
- };
-
- this.$textToken = {
- "text": true,
- "rparen": true,
- "lparen": true
- };
-
- this.$renderToken = function(stringBuilder, screenColumn, token, value) {
- var self = this;
- var replaceReg = /\t|&|<|( +)|([\x00-\x1f\x80-\xa0\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g;
- var replaceFunc = function(c, a, b, tabIdx, idx4) {
- if (a) {
- return self.showInvisibles ?
- "<span class='ace_invisible'>" + lang.stringRepeat(self.SPACE_CHAR, c.length) + "</span>" :
- lang.stringRepeat("\xa0", c.length);
- } else if (c == "&") {
- return "&";
- } else if (c == "<") {
- return "<";
- } else if (c == "\t") {
- var tabSize = self.session.getScreenTabSize(screenColumn + tabIdx);
- screenColumn += tabSize - 1;
- return self.$tabStrings[tabSize];
- } else if (c == "\u3000") {
- // U+3000 is both invisible AND full-width, so must be handled uniquely
- var classToUse = self.showInvisibles ? "ace_cjk ace_invisible" : "ace_cjk";
- var space = self.showInvisibles ? self.SPACE_CHAR : "";
- screenColumn += 1;
- return "<span class='" + classToUse + "' style='width:" +
- (self.config.characterWidth * 2) +
- "px'>" + space + "</span>";
- } else if (b) {
- return "<span class='ace_invisible ace_invalid'>" + self.SPACE_CHAR + "</span>";
- } else {
- screenColumn += 1;
- return "<span class='ace_cjk' style='width:" +
- (self.config.characterWidth * 2) +
- "px'>" + c + "</span>";
- }
- };
-
- var output = value.replace(replaceReg, replaceFunc);
-
- if (!this.$textToken[token.type]) {
- var classes = "ace_" + token.type.replace(/\./g, " ace_");
- var style = "";
- if (token.type == "fold")
- style = " style='width:" + (token.value.length * this.config.characterWidth) + "px;' ";
- stringBuilder.push("<span class='", classes, "'", style, ">", output, "</span>");
- }
- else {
- stringBuilder.push(output);
- }
- return screenColumn + value.length;
- };
-
- this.renderIndentGuide = function(stringBuilder, value, max) {
- var cols = value.search(this.$indentGuideRe);
- if (cols <= 0 || cols >= max)
- return value;
- if (value[0] == " ") {
- cols -= cols % this.tabSize;
- stringBuilder.push(lang.stringRepeat(this.$tabStrings[" "], cols/this.tabSize));
- return value.substr(cols);
- } else if (value[0] == "\t") {
- stringBuilder.push(lang.stringRepeat(this.$tabStrings["\t"], cols));
- return value.substr(cols);
- }
- return value;
- };
-
- this.$renderWrappedLine = function(stringBuilder, tokens, splits, onlyContents) {
- var chars = 0;
- var split = 0;
- var splitChars = splits[0];
- var screenColumn = 0;
-
- for (var i = 0; i < tokens.length; i++) {
- var token = tokens[i];
- var value = token.value;
- if (i == 0 && this.displayIndentGuides) {
- chars = value.length;
- value = this.renderIndentGuide(stringBuilder, value, splitChars);
- if (!value)
- continue;
- chars -= value.length;
- }
-
- if (chars + value.length < splitChars) {
- screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
- chars += value.length;
- } else {
- while (chars + value.length >= splitChars) {
- screenColumn = this.$renderToken(
- stringBuilder, screenColumn,
- token, value.substring(0, splitChars - chars)
- );
- value = value.substring(splitChars - chars);
- chars = splitChars;
-
- if (!onlyContents) {
- stringBuilder.push("</div>",
- "<div class='ace_line' style='height:",
- this.config.lineHeight, "px'>"
- );
- }
-
- split ++;
- screenColumn = 0;
- splitChars = splits[split] || Number.MAX_VALUE;
- }
- if (value.length != 0) {
- chars += value.length;
- screenColumn = this.$renderToken(
- stringBuilder, screenColumn, token, value
- );
- }
- }
- }
- };
-
- this.$renderSimpleLine = function(stringBuilder, tokens) {
- var screenColumn = 0;
- var token = tokens[0];
- var value = token.value;
- if (this.displayIndentGuides)
- value = this.renderIndentGuide(stringBuilder, value);
- if (value)
- screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
- for (var i = 1; i < tokens.length; i++) {
- token = tokens[i];
- value = token.value;
- screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
- }
- };
-
- // row is either first row of foldline or not in fold
- this.$renderLine = function(stringBuilder, row, onlyContents, foldLine) {
- if (!foldLine && foldLine != false)
- foldLine = this.session.getFoldLine(row);
-
- if (foldLine)
- var tokens = this.$getFoldLineTokens(row, foldLine);
- else
- var tokens = this.session.getTokens(row);
-
-
- if (!onlyContents) {
- stringBuilder.push(
- "<div class='ace_line' style='height:", this.config.lineHeight, "px'>"
- );
- }
-
- if (tokens.length) {
- var splits = this.session.getRowSplitData(row);
- if (splits && splits.length)
- this.$renderWrappedLine(stringBuilder, tokens, splits, onlyContents);
- else
- this.$renderSimpleLine(stringBuilder, tokens);
- }
-
- if (this.showInvisibles) {
- if (foldLine)
- row = foldLine.end.row
-
- stringBuilder.push(
- "<span class='ace_invisible'>",
- row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR,
- "</span>"
- );
- }
- if (!onlyContents)
- stringBuilder.push("</div>");
- };
-
- this.$getFoldLineTokens = function(row, foldLine) {
- var session = this.session;
- var renderTokens = [];
-
- function addTokens(tokens, from, to) {
- var idx = 0, col = 0;
- while ((col + tokens[idx].value.length) < from) {
- col += tokens[idx].value.length;
- idx++;
-
- if (idx == tokens.length)
- return;
- }
- if (col != from) {
- var value = tokens[idx].value.substring(from - col);
- // Check if the token value is longer then the from...to spacing.
- if (value.length > (to - from))
- value = value.substring(0, to - from);
-
- renderTokens.push({
- type: tokens[idx].type,
- value: value
- });
-
- col = from + value.length;
- idx += 1;
- }
-
- while (col < to && idx < tokens.length) {
- var value = tokens[idx].value;
- if (value.length + col > to) {
- renderTokens.push({
- type: tokens[idx].type,
- value: value.substring(0, to - col)
- });
- } else
- renderTokens.push(tokens[idx]);
- col += value.length;
- idx += 1;
- }
- }
-
- var tokens = session.getTokens(row);
- foldLine.walk(function(placeholder, row, column, lastColumn, isNewRow) {
- if (placeholder != null) {
- renderTokens.push({
- type: "fold",
- value: placeholder
- });
- } else {
- if (isNewRow)
- tokens = session.getTokens(row);
-
- if (tokens.length)
- addTokens(tokens, lastColumn, column);
- }
- }, foldLine.end.row, this.session.getLine(foldLine.end.row).length);
-
- return renderTokens;
- };
-
- this.$useLineGroups = function() {
- // For the updateLines function to work correctly, it's important that the
- // child nodes of this.element correspond on a 1-to-1 basis to rows in the
- // document (as distinct from lines on the screen). For sessions that are
- // wrapped, this means we need to add a layer to the node hierarchy (tagged
- // with the class name ace_line_group).
- return this.session.getUseWrapMode();
- };
-
- this.destroy = function() {
- clearInterval(this.$pollSizeChangesTimer);
- if (this.$measureNode)
- this.$measureNode.parentNode.removeChild(this.$measureNode);
- delete this.$measureNode;
- };
-
-}).call(Text.prototype);
-
-exports.Text = Text;
-
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5b8fb9c3/src/fauxton/assets/js/libs/ace/layer/text_test.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/layer/text_test.js b/src/fauxton/assets/js/libs/ace/layer/text_test.js
deleted file mode 100644
index a14a37e..0000000
--- a/src/fauxton/assets/js/libs/ace/layer/text_test.js
+++ /dev/null
@@ -1,126 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Distributed under the BSD license:
- *
- * Copyright (c) 2010, Ajax.org B.V.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Ajax.org B.V. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ***** END LICENSE BLOCK ***** */
-
-if (typeof process !== "undefined") {
- require("amd-loader");
- require("../test/mockdom");
-}
-
-define(function(require, exports, module) {
-"use strict";
-
-var assert = require("../test/assertions");
-var EditSession = require("../edit_session").EditSession;
-var TextLayer = require("./text").Text;
-var JavaScriptMode = require("../mode/javascript").Mode;
-
-module.exports = {
-
- setUp: function(next) {
- this.session = new EditSession("");
- this.session.setMode(new JavaScriptMode());
- this.textLayer = new TextLayer(document.createElement("div"));
- this.textLayer.setSession(this.session);
- this.textLayer.config = {
- characterWidth: 10,
- lineHeight: 20
- };
- next()
- },
-
- "test: render line with hard tabs should render the same as lines with soft tabs" : function() {
- this.session.setValue("a\ta\ta\t\na a a \n");
- this.textLayer.$computeTabString();
-
- // row with hard tabs
- var stringBuilder = [];
- this.textLayer.$renderLine(stringBuilder, 0);
-
- // row with soft tabs
- var stringBuilder2 = [];
- this.textLayer.$renderLine(stringBuilder2, 1);
- assert.equal(stringBuilder.join(""), stringBuilder2.join(""));
- },
-
- "test rendering width of ideographic space (U+3000)" : function() {
- this.session.setValue("\u3000");
-
- var stringBuilder = [];
- this.textLayer.$renderLine(stringBuilder, 0, true);
- assert.equal(stringBuilder.join(""), "<span class='ace_cjk' style='width:20px'></span>");
-
- this.textLayer.setShowInvisibles(true);
- var stringBuilder = [];
- this.textLayer.$renderLine(stringBuilder, 0, true);
- assert.equal(
- stringBuilder.join(""),
- "<span class='ace_cjk ace_invisible' style='width:20px'>" + this.textLayer.SPACE_CHAR + "</span>"
- + "<span class='ace_invisible'>\xB6</span>"
- );
- },
-
- "test rendering of indent guides" : function() {
- var textLayer = this.textLayer
- var EOL = "<span class='ace_invisible'>" + textLayer.EOL_CHAR + "</span>";
- var SPACE = function(i) {return Array(i+1).join("\xa0")}
- var DOT = function(i) {return Array(i+1).join(textLayer.SPACE_CHAR)}
- var TAB = function(i) {return textLayer.TAB_CHAR + SPACE(i-1)}
- function testRender(results) {
- for (var i = results.length; i--; ) {
- var stringBuilder = [];
- textLayer.$renderLine(stringBuilder, i, true);
- assert.equal(stringBuilder.join(""), results[i]);
- }
- }
-
- this.session.setValue(" \n\t\tf\n ");
- testRender([
- "<span class='ace_indent-guide'>" + SPACE(4) + "</span>" + SPACE(2),
- "<span class='ace_indent-guide'>" + SPACE(4) + "</span>" + SPACE(4) + "<span class='ace_identifier'>f</span>",
- SPACE(3)
- ]);
- this.textLayer.setShowInvisibles(true);
- testRender([
- "<span class='ace_indent-guide ace_invisible'>" + DOT(4) + "</span><span class='ace_invisible'>" + DOT(2) + "</span>" + EOL,
- "<span class='ace_indent-guide ace_invisible'>" + TAB(4) + "</span><span class='ace_invisible'>" + TAB(4) + "</span><span class='ace_identifier'>f</span>" + EOL,
- ]);
- this.textLayer.setDisplayIndentGuides(false);
- testRender([
- "<span class='ace_invisible'>" + DOT(6) + "</span>" + EOL,
- "<span class='ace_invisible'>" + TAB(4) + "</span><span class='ace_invisible'>" + TAB(4) + "</span><span class='ace_identifier'>f</span>" + EOL
- ]);
- }
-};
-
-});
-
-if (typeof module !== "undefined" && module === require.main) {
- require("asyncjs").test.testcase(module.exports).exec()
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5b8fb9c3/src/fauxton/assets/js/libs/ace/lib/dom.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/lib/dom.js b/src/fauxton/assets/js/libs/ace/lib/dom.js
deleted file mode 100644
index b372400..0000000
--- a/src/fauxton/assets/js/libs/ace/lib/dom.js
+++ /dev/null
@@ -1,283 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Distributed under the BSD license:
- *
- * Copyright (c) 2010, Ajax.org B.V.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Ajax.org B.V. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ***** END LICENSE BLOCK ***** */
-
-define(function(require, exports, module) {
-"use strict";
-
-if (typeof document == "undefined")
- return;
-
-var XHTML_NS = "http://www.w3.org/1999/xhtml";
-
-exports.getDocumentHead = function(doc) {
- if (!doc)
- doc = document;
- return doc.head || doc.getElementsByTagName("head")[0] || doc.documentElement;
-}
-
-exports.createElement = function(tag, ns) {
- return document.createElementNS ?
- document.createElementNS(ns || XHTML_NS, tag) :
- document.createElement(tag);
-};
-
-exports.hasCssClass = function(el, name) {
- var classes = el.className.split(/\s+/g);
- return classes.indexOf(name) !== -1;
-};
-
-/*
-* 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;
- }
-};
-
-/*
-* 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);
- }
- 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;
- }
- add = false;
- classes.splice(index, 1);
- }
- if(add)
- classes.push(name);
-
- 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 <tt>include</tt>
- */
-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;
- doc = doc || document;
-
- if (doc.createStyleSheet && (sheets = doc.styleSheets)) {
- while (index < sheets.length)
- if (sheets[index++].owningElement.id === id) return true;
- } else if ((sheets = doc.getElementsByTagName("style"))) {
- while (index < sheets.length)
- if (sheets[index++].id === id) return true;
- }
-
- return false;
-};
-
-exports.importCssString = function importCssString(cssText, id, doc) {
- doc = doc || document;
- // If style is already imported return immediately.
- if (id && exports.hasCssString(id, doc))
- return null;
-
- var style;
-
- if (doc.createStyleSheet) {
- style = doc.createStyleSheet();
- style.cssText = cssText;
- if (id)
- style.owningElement.id = id;
- } else {
- style = doc.createElementNS
- ? doc.createElementNS(XHTML_NS, "style")
- : doc.createElement("style");
-
- style.appendChild(doc.createTextNode(cssText));
- if (id)
- style.id = id;
-
- exports.getDocumentHead(doc).appendChild(style);
- }
-};
-
-exports.importCssStylsheet = function(uri, doc) {
- if (doc.createStyleSheet) {
- doc.createStyleSheet(uri);
- } else {
- var link = exports.createElement('link');
- link.rel = 'stylesheet';
- link.href = uri;
-
- exports.getDocumentHead(doc).appendChild(link);
- }
-};
-
-exports.getInnerWidth = function(element) {
- return (
- parseInt(exports.computedStyle(element, "paddingLeft"), 10) +
- parseInt(exports.computedStyle(element, "paddingRight"), 10) +
- element.clientWidth
- );
-};
-
-exports.getInnerHeight = function(element) {
- return (
- parseInt(exports.computedStyle(element, "paddingTop"), 10) +
- parseInt(exports.computedStyle(element, "paddingBottom"), 10) +
- element.clientHeight
- );
-};
-
-if (window.pageYOffset !== undefined) {
- exports.getPageScrollTop = function() {
- return window.pageYOffset;
- };
-
- exports.getPageScrollLeft = function() {
- return window.pageXOffset;
- };
-}
-else {
- exports.getPageScrollTop = function() {
- return document.body.scrollTop;
- };
-
- exports.getPageScrollLeft = function() {
- return document.body.scrollLeft;
- };
-}
-
-if (window.getComputedStyle)
- exports.computedStyle = function(element, style) {
- if (style)
- return (window.getComputedStyle(element, "") || {})[style] || "";
- return window.getComputedStyle(element, "") || {};
- };
-else
- exports.computedStyle = function(element, style) {
- if (style)
- return element.currentStyle[style];
- return element.currentStyle;
- };
-
-exports.scrollbarWidth = function(document) {
- var inner = exports.createElement("ace_inner");
- inner.style.width = "100%";
- inner.style.minWidth = "0px";
- inner.style.height = "200px";
- inner.style.display = "block";
-
- var outer = exports.createElement("ace_outer");
- var style = outer.style;
-
- style.position = "absolute";
- style.left = "-10000px";
- style.overflow = "hidden";
- style.width = "200px";
- style.minWidth = "0px";
- style.height = "150px";
- style.display = "block";
-
- outer.appendChild(inner);
-
- var body = document.documentElement;
- body.appendChild(outer);
-
- var noScrollbar = inner.offsetWidth;
-
- style.overflow = "scroll";
- var withScrollbar = inner.offsetWidth;
-
- if (noScrollbar == withScrollbar) {
- withScrollbar = outer.clientWidth;
- }
-
- body.removeChild(outer);
-
- return noScrollbar-withScrollbar;
-};
-
-/*
- * Optimized set innerHTML. This is faster than plain innerHTML if the element
- * already contains a lot of child elements.
- *
- * See http://blog.stevenlevithan.com/archives/faster-than-innerhtml for details
- */
-exports.setInnerHtml = function(el, innerHtml) {
- var element = el.cloneNode(false);//document.createElement("div");
- element.innerHTML = innerHtml;
- el.parentNode.replaceChild(element, el);
- return element;
-};
-
-if ("textContent" in document.documentElement) {
- exports.setInnerText = function(el, innerText) {
- el.textContent = innerText;
- };
-
- exports.getInnerText = function(el) {
- return el.textContent;
- };
-}
-else {
- exports.setInnerText = function(el, innerText) {
- el.innerText = innerText;
- };
-
- exports.getInnerText = function(el) {
- return el.innerText;
- };
-}
-
-exports.getParentWindow = function(document) {
- return document.defaultView || document.parentWindow;
-};
-
-});