nifi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joew...@apache.org
Subject [06/51] [abbrv] incubator-nifi git commit: NIFI-27: - Latest version of codemirror.
Date Tue, 16 Dec 2014 18:03:27 GMT
NIFI-27:
- Latest version of codemirror.

Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/9180b7d4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/9180b7d4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/9180b7d4

Branch: refs/heads/NIFI-169
Commit: 9180b7d4a1c05200cddeb946da120643c627037a
Parents: b61a1de
Author: Matt Gilman <matt.c.gilman@gmail.com>
Authored: Wed Dec 10 12:56:04 2014 -0500
Committer: Matt Gilman <matt.c.gilman@gmail.com>
Committed: Wed Dec 10 12:56:04 2014 -0500

----------------------------------------------------------------------
 .../src/main/webapp/WEB-INF/pages/canvas.jsp    |    4 +-
 .../src/main/webapp/js/codemirror/LICENSE       |   38 +-
 .../js/codemirror/addon/edit/matchbrackets.js   |  125 -
 .../js/codemirror/addon/hint/show-hint.css      |   54 +-
 .../js/codemirror/addon/hint/show-hint.js       |  411 -
 .../js/codemirror/lib/codemirror-compressed.js  |   16 +
 .../webapp/js/codemirror/lib/codemirror.css     |  282 +-
 .../main/webapp/js/codemirror/lib/codemirror.js | 8488 ------------------
 8 files changed, 228 insertions(+), 9190 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9180b7d4/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp
----------------------------------------------------------------------
diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp
b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp
index 09c8207..a40b745 100644
--- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp
+++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp
@@ -33,9 +33,7 @@
         <link rel="stylesheet" href="js/jquery/minicolors/jquery.minicolors.css" type="text/css"
/>
         <link rel="stylesheet" href="js/jquery/slickgrid/css/slick.grid.css" type="text/css"
/>
         <link rel="stylesheet" href="js/jquery/slickgrid/css/slick-default-theme.css"
type="text/css" />
-        <script type="text/javascript" src="js/codemirror/lib/codemirror.js"></script>
-        <script type="text/javascript" src="js/codemirror/addon/edit/matchbrackets.js"></script>
-        <script type="text/javascript" src="js/codemirror/addon/hint/show-hint.js"></script>
+        <script type="text/javascript" src="js/codemirror/lib/codemirror-compressed.js"></script>
         <script type="text/javascript" src="js/jquery/jquery-1.7.min.js"></script>
         <script type="text/javascript" src="js/jquery/jquery-ui-1.8.10.custom.min.js"></script>
         <script type="text/javascript" src="js/jquery/jquery.center.js"></script>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9180b7d4/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/LICENSE
----------------------------------------------------------------------
diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/LICENSE
b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/LICENSE
old mode 100755
new mode 100644
index 4f1e9d1..d21bbea
--- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/LICENSE
+++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/LICENSE
@@ -1,19 +1,19 @@
-Copyright (C) 2013 by Marijn Haverbeke <marijnh@gmail.com> and others
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
+Copyright (C) 2014 by Marijn Haverbeke <marijnh@gmail.com> and others
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9180b7d4/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/addon/edit/matchbrackets.js
----------------------------------------------------------------------
diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/addon/edit/matchbrackets.js
b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/addon/edit/matchbrackets.js
deleted file mode 100755
index 5f91f9b..0000000
--- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/addon/edit/matchbrackets.js
+++ /dev/null
@@ -1,125 +0,0 @@
-(function (mod) {
-    if (typeof exports == "object" && typeof module == "object") // CommonJS
-        mod(require("../../lib/codemirror"));
-    else if (typeof define == "function" && define.amd) // AMD
-        define(["../../lib/codemirror"], mod);
-    else // Plain browser env
-        mod(CodeMirror);
-})(function (CodeMirror) {
-    var ie_lt8 = /MSIE \d/.test(navigator.userAgent) &&
-            (document.documentMode == null || document.documentMode < 8);
-
-    var Pos = CodeMirror.Pos;
-
-    var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>",
"}": "{<"};
-
-    function findMatchingBracket(cm, where, strict, config) {
-        var line = cm.getLineHandle(where.line), pos = where.ch - 1;
-        var match = (pos >= 0 && matching[line.text.charAt(pos)]) || matching[line.text.charAt(++pos)];
-        if (!match)
-            return null;
-        var dir = match.charAt(1) == ">" ? 1 : -1;
-        if (strict && (dir > 0) != (pos == where.ch))
-            return null;
-        var style = cm.getTokenTypeAt(Pos(where.line, pos + 1));
-
-        var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir,
style || null, config);
-        return {from: Pos(where.line, pos), to: found && found.pos,
-            match: found && found.ch == match.charAt(0), forward: dir > 0};
-    }
-
-    function scanForBracket(cm, where, dir, style, config) {
-        var maxScanLen = (config && config.maxScanLineLength) || 10000;
-        var maxScanLines = (config && config.maxScanLines) || 500;
-
-        var stack = [], re = /[(){}[\]]/;
-        var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1)
-                : Math.max(cm.firstLine() - 1, where.line - maxScanLines);
-        for (var lineNo = where.line; lineNo != lineEnd; lineNo += dir) {
-            var line = cm.getLine(lineNo);
-            if (!line)
-                continue;
-            var pos = dir > 0 ? 0 : line.length - 1, end = dir > 0 ? line.length :
-1;
-            if (line.length > maxScanLen)
-                continue;
-            if (lineNo == where.line)
-                pos = where.ch - (dir < 0 ? 1 : 0);
-            for (; pos != end; pos += dir) {
-                var ch = line.charAt(pos);
-                if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo,
pos + 1)) == style)) {
-                    var match = matching[ch];
-                    if ((match.charAt(1) == ">") == (dir > 0))
-                        stack.push(ch);
-                    else if (!stack.length)
-                        return {pos: Pos(lineNo, pos), ch: ch};
-                    else
-                        stack.pop();
-                }
-            }
-        }
-    }
-
-    function matchBrackets(cm, autoclear, config) {
-        // Disable brace matching in long lines, since it'll cause hugely slow updates
-        var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000;
-        var marks = [], ranges = cm.listSelections();
-        for (var i = 0; i < ranges.length; i++) {
-            var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head,
false, config);
-            if (match && cm.getLine(match.from.line).length <= maxHighlightLen
&&
-                    match.to && cm.getLine(match.to.line).length <= maxHighlightLen)
{
-                var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket";
-                marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1),
{className: style}));
-                if (match.to)
-                    marks.push(cm.markText(match.to, Pos(match.to.line, match.to.ch + 1),
{className: style}));
-            }
-        }
-
-        if (marks.length) {
-            // Kludge to work around the IE bug from issue #1193, where text
-            // input stops going to the textare whever this fires.
-            if (ie_lt8 && cm.state.focused)
-                cm.display.input.focus();
-
-            var clear = function () {
-                cm.operation(function () {
-                    for (var i = 0; i < marks.length; i++)
-                        marks[i].clear();
-                });
-            };
-            if (autoclear)
-                setTimeout(clear, 800);
-            else
-                return clear;
-        }
-    }
-
-    var currentlyHighlighted = null;
-    function doMatchBrackets(cm) {
-        cm.operation(function () {
-            if (currentlyHighlighted) {
-                currentlyHighlighted();
-                currentlyHighlighted = null;
-            }
-            currentlyHighlighted = matchBrackets(cm, false, cm.state.matchBrackets);
-        });
-    }
-
-    CodeMirror.defineOption("matchBrackets", false, function (cm, val, old) {
-        if (old && old != CodeMirror.Init)
-            cm.off("cursorActivity", doMatchBrackets);
-        if (val) {
-            cm.state.matchBrackets = typeof val == "object" ? val : {};
-            cm.on("cursorActivity", doMatchBrackets);
-        }
-    });
-
-    CodeMirror.defineExtension("matchBrackets", function () {
-        matchBrackets(this, true);
-    });
-    CodeMirror.defineExtension("findMatchingBracket", function (pos, strict) {
-        return findMatchingBracket(this, pos, strict);
-    });
-    CodeMirror.defineExtension("scanForBracket", function (pos, dir, style) {
-        return scanForBracket(this, pos, dir, style);
-    });
-});

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9180b7d4/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/addon/hint/show-hint.css
----------------------------------------------------------------------
diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/addon/hint/show-hint.css
b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/addon/hint/show-hint.css
old mode 100755
new mode 100644
index 44449b2..924e638
--- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/addon/hint/show-hint.css
+++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/addon/hint/show-hint.css
@@ -1,38 +1,38 @@
 .CodeMirror-hints {
-    position: absolute;
-    z-index: 10;
-    overflow: hidden;
-    list-style: none;
+  position: absolute;
+  z-index: 10;
+  overflow: hidden;
+  list-style: none;
 
-    margin: 0;
-    padding: 2px;
+  margin: 0;
+  padding: 2px;
 
-    -webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
-    -moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
-    box-shadow: 2px 3px 5px rgba(0,0,0,.2);
-    border-radius: 3px;
-    border: 1px solid silver;
+  -webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
+  -moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
+  box-shadow: 2px 3px 5px rgba(0,0,0,.2);
+  border-radius: 3px;
+  border: 1px solid silver;
 
-    background: white;
-    font-size: 90%;
-    font-family: monospace;
+  background: white;
+  font-size: 90%;
+  font-family: monospace;
 
-    max-height: 20em;
-    overflow-y: auto;
+  max-height: 20em;
+  overflow-y: auto;
 }
 
 .CodeMirror-hint {
-    margin: 0;
-    padding: 0 4px;
-    border-radius: 2px;
-    max-width: 19em;
-    overflow: hidden;
-    white-space: pre;
-    color: black;
-    cursor: pointer;
+  margin: 0;
+  padding: 0 4px;
+  border-radius: 2px;
+  max-width: 19em;
+  overflow: hidden;
+  white-space: pre;
+  color: black;
+  cursor: pointer;
 }
 
-.CodeMirror-hint-active {
-    background: #08f;
-    color: white;
+li.CodeMirror-hint-active {
+  background: #08f;
+  color: white;
 }

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9180b7d4/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/addon/hint/show-hint.js
----------------------------------------------------------------------
diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/addon/hint/show-hint.js
b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/addon/hint/show-hint.js
deleted file mode 100755
index c820fdd..0000000
--- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/addon/hint/show-hint.js
+++ /dev/null
@@ -1,411 +0,0 @@
-(function (mod) {
-    if (typeof exports == "object" && typeof module == "object") // CommonJS
-        mod(require("../../lib/codemirror"));
-    else if (typeof define == "function" && define.amd) // AMD
-        define(["../../lib/codemirror"], mod);
-    else // Plain browser env
-        mod(CodeMirror);
-})(function (CodeMirror) {
-    "use strict";
-
-    var HINT_ELEMENT_CLASS = "CodeMirror-hint";
-    var ACTIVE_HINT_ELEMENT_CLASS = "CodeMirror-hint-active";
-
-    CodeMirror.showHint = function (cm, getHints, options) {
-        // We want a single cursor position.
-        if (cm.listSelections().length > 1 || cm.somethingSelected())
-            return;
-        if (getHints == null) {
-            if (options && options.async)
-                return;
-            else
-                getHints = CodeMirror.hint.auto;
-        }
-
-        if (cm.state.completionActive)
-            cm.state.completionActive.close();
-
-        var completion = cm.state.completionActive = new Completion(cm, getHints, options
|| {});
-        CodeMirror.signal(cm, "startCompletion", cm);
-        if (completion.options.async)
-            getHints(cm, function (hints) {
-                completion.showHints(hints);
-            }, completion.options);
-        else
-            return completion.showHints(getHints(cm, completion.options));
-    };
-
-    function Completion(cm, getHints, options) {
-        this.cm = cm;
-        this.getHints = getHints;
-        this.options = options;
-        this.widget = this.onClose = null;
-    }
-
-    Completion.prototype = {
-        close: function () {
-            if (!this.active())
-                return;
-            this.cm.state.completionActive = null;
-
-            if (this.widget)
-                this.widget.close();
-            if (this.onClose)
-                this.onClose();
-            CodeMirror.signal(this.cm, "endCompletion", this.cm);
-        },
-        active: function () {
-            return this.cm.state.completionActive == this;
-        },
-        pick: function (data, i) {
-            var completion = data.list[i];
-            if (completion.hint)
-                completion.hint(this.cm, data, completion);
-            else
-                this.cm.replaceRange(getText(completion), completion.from || data.from, completion.to
|| data.to);
-            CodeMirror.signal(data, "pick", completion);
-            this.close();
-        },
-        showHints: function (data) {
-            if (!data || !data.list.length || !this.active())
-                return this.close();
-
-            if (this.options.completeSingle != false && data.list.length == 1)
-                this.pick(data, 0);
-            else
-                this.showWidget(data);
-        },
-        showWidget: function (data) {
-            this.widget = new Widget(this, data);
-            CodeMirror.signal(data, "shown");
-
-            var debounce = 0, completion = this, finished;
-            var closeOn = this.options.closeCharacters || /[\s()\[\]{};:>,]/;
-            var startPos = this.cm.getCursor(), startLen = this.cm.getLine(startPos.line).length;
-
-            var requestAnimationFrame = window.requestAnimationFrame || function (fn) {
-                return setTimeout(fn, 1000 / 60);
-            };
-            var cancelAnimationFrame = window.cancelAnimationFrame || clearTimeout;
-
-            function done() {
-                if (finished)
-                    return;
-                finished = true;
-                completion.close();
-                completion.cm.off("cursorActivity", activity);
-                if (data)
-                    CodeMirror.signal(data, "close");
-            }
-
-            function update() {
-                if (finished)
-                    return;
-                CodeMirror.signal(data, "update");
-                if (completion.options.async)
-                    completion.getHints(completion.cm, finishUpdate, completion.options);
-                else
-                    finishUpdate(completion.getHints(completion.cm, completion.options));
-            }
-            function finishUpdate(data_) {
-                data = data_;
-                if (finished)
-                    return;
-                if (!data || !data.list.length)
-                    return done();
-                completion.widget = new Widget(completion, data);
-            }
-
-            function clearDebounce() {
-                if (debounce) {
-                    cancelAnimationFrame(debounce);
-                    debounce = 0;
-                }
-            }
-
-            function activity() {
-                clearDebounce();
-                var pos = completion.cm.getCursor(), line = completion.cm.getLine(pos.line);
-                if (pos.line != startPos.line || line.length - pos.ch != startLen - startPos.ch
||
-                        pos.ch < startPos.ch || completion.cm.somethingSelected() ||
-                        (pos.ch && closeOn.test(line.charAt(pos.ch - 1)))) {
-                    completion.close();
-                } else {
-                    debounce = requestAnimationFrame(update);
-                    if (completion.widget)
-                        completion.widget.close();
-                }
-            }
-            this.cm.on("cursorActivity", activity);
-            this.onClose = done;
-        }
-    };
-
-    function getText(completion) {
-        if (typeof completion == "string")
-            return completion;
-        else
-            return completion.text;
-    }
-
-    function buildKeyMap(options, handle) {
-        var baseMap = {
-            Up: function () {
-                handle.moveFocus(-1);
-            },
-            Down: function () {
-                handle.moveFocus(1);
-            },
-            PageUp: function () {
-                handle.moveFocus(-handle.menuSize() + 1, true);
-            },
-            PageDown: function () {
-                handle.moveFocus(handle.menuSize() - 1, true);
-            },
-            Home: function () {
-                handle.setFocus(0);
-            },
-            End: function () {
-                handle.setFocus(handle.length - 1);
-            },
-            Enter: handle.pick,
-            Tab: handle.pick,
-            Esc: handle.close
-        };
-        var ourMap = options.customKeys ? {} : baseMap;
-        function addBinding(key, val) {
-            var bound;
-            if (typeof val != "string")
-                bound = function (cm) {
-                    return val(cm, handle);
-                };
-            // This mechanism is deprecated
-            else if (baseMap.hasOwnProperty(val))
-                bound = baseMap[val];
-            else
-                bound = val;
-            ourMap[key] = bound;
-        }
-        if (options.customKeys)
-            for (var key in options.customKeys)
-                if (options.customKeys.hasOwnProperty(key))
-                    addBinding(key, options.customKeys[key]);
-        if (options.extraKeys)
-            for (var key in options.extraKeys)
-                if (options.extraKeys.hasOwnProperty(key))
-                    addBinding(key, options.extraKeys[key]);
-        return ourMap;
-    }
-
-    function getHintElement(hintsElement, el) {
-        while (el && el != hintsElement) {
-            if (el.nodeName.toUpperCase() === "LI" && el.parentNode == hintsElement)
-                return el;
-            el = el.parentNode;
-        }
-    }
-
-    function Widget(completion, data) {
-        this.completion = completion;
-        this.data = data;
-        var widget = this, cm = completion.cm, options = completion.options;
-
-        var hints = this.hints = document.createElement("ul");
-        hints.className = "CodeMirror-hints";
-        this.selectedHint = options.getDefaultSelection ? options.getDefaultSelection(cm,
options, data) : 0;
-
-        var completions = data.list;
-        for (var i = 0; i < completions.length; ++i) {
-            var elt = hints.appendChild(document.createElement("li")), cur = completions[i];
-            var className = HINT_ELEMENT_CLASS + (i != this.selectedHint ? "" : " " + ACTIVE_HINT_ELEMENT_CLASS);
-            if (cur.className != null)
-                className = cur.className + " " + className;
-            elt.className = className;
-            if (cur.render)
-                cur.render(elt, data, cur);
-            else
-                elt.appendChild(document.createTextNode(cur.displayText || getText(cur)));
-            elt.hintId = i;
-        }
-
-        var pos = cm.cursorCoords(options.alignWithWord !== false ? data.from : null);
-        var left = pos.left, top = pos.bottom, below = true;
-        hints.style.left = left + "px";
-        hints.style.top = top + "px";
-        // If we're at the edge of the screen, then we want the menu to appear on the left
of the cursor.
-        var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth);
-        var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight);
-        (options.container || document.body).appendChild(hints);
-        var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH;
-        if (overlapY > 0) {
-            var height = box.bottom - box.top, curTop = box.top - (pos.bottom - pos.top);
-            if (curTop - height > 0) { // Fits above cursor
-                hints.style.top = (top = curTop - height) + "px";
-                below = false;
-            } else if (height > winH) {
-                hints.style.height = (winH - 5) + "px";
-                hints.style.top = (top = pos.bottom - box.top) + "px";
-                var cursor = cm.getCursor();
-                if (data.from.ch != cursor.ch) {
-                    pos = cm.cursorCoords(cursor);
-                    hints.style.left = (left = pos.left) + "px";
-                    box = hints.getBoundingClientRect();
-                }
-            }
-        }
-        var overlapX = box.left - winW;
-        if (overlapX > 0) {
-            if (box.right - box.left > winW) {
-                hints.style.width = (winW - 5) + "px";
-                overlapX -= (box.right - box.left) - winW;
-            }
-            hints.style.left = (left = pos.left - overlapX) + "px";
-        }
-
-        cm.addKeyMap(this.keyMap = buildKeyMap(options, {
-            moveFocus: function (n, avoidWrap) {
-                widget.changeActive(widget.selectedHint + n, avoidWrap);
-            },
-            setFocus: function (n) {
-                widget.changeActive(n);
-            },
-            menuSize: function () {
-                return widget.screenAmount();
-            },
-            length: completions.length,
-            close: function () {
-                completion.close();
-            },
-            pick: function () {
-                widget.pick();
-            },
-            data: data
-        }));
-
-        if (options.closeOnUnfocus !== false) {
-            var closingOnBlur;
-            cm.on("blur", this.onBlur = function () {
-                closingOnBlur = setTimeout(function () {
-                    completion.close();
-                }, 100);
-            });
-            cm.on("focus", this.onFocus = function () {
-                clearTimeout(closingOnBlur);
-            });
-        }
-
-        var startScroll = cm.getScrollInfo();
-        cm.on("scroll", this.onScroll = function () {
-            var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect();
-            var newTop = top + startScroll.top - curScroll.top;
-            var point = newTop - (window.pageYOffset || (document.documentElement || document.body).scrollTop);
-            if (!below)
-                point += hints.offsetHeight;
-            if (point <= editor.top || point >= editor.bottom)
-                return completion.close();
-            hints.style.top = newTop + "px";
-            hints.style.left = (left + startScroll.left - curScroll.left) + "px";
-        });
-
-        CodeMirror.on(hints, "dblclick", function (e) {
-            var t = getHintElement(hints, e.target || e.srcElement);
-            if (t && t.hintId != null) {
-                widget.changeActive(t.hintId);
-                widget.pick();
-            }
-        });
-
-        CodeMirror.on(hints, "click", function (e) {
-            var t = getHintElement(hints, e.target || e.srcElement);
-            if (t && t.hintId != null) {
-                widget.changeActive(t.hintId);
-                if (options.completeOnSingleClick)
-                    widget.pick();
-            }
-        });
-
-        CodeMirror.on(hints, "mousedown", function () {
-            setTimeout(function () {
-                cm.focus();
-            }, 20);
-        });
-
-        CodeMirror.signal(data, "select", completions[0], hints.firstChild);
-        return true;
-    }
-
-    Widget.prototype = {
-        close: function () {
-            if (this.completion.widget != this)
-                return;
-            this.completion.widget = null;
-            this.hints.parentNode.removeChild(this.hints);
-            this.completion.cm.removeKeyMap(this.keyMap);
-
-            var cm = this.completion.cm;
-            if (this.completion.options.closeOnUnfocus !== false) {
-                cm.off("blur", this.onBlur);
-                cm.off("focus", this.onFocus);
-            }
-            cm.off("scroll", this.onScroll);
-        },
-        pick: function () {
-            this.completion.pick(this.data, this.selectedHint);
-        },
-        changeActive: function (i, avoidWrap) {
-            if (i >= this.data.list.length)
-                i = avoidWrap ? this.data.list.length - 1 : 0;
-            else if (i < 0)
-                i = avoidWrap ? 0 : this.data.list.length - 1;
-            if (this.selectedHint == i)
-                return;
-            var node = this.hints.childNodes[this.selectedHint];
-            node.className = node.className.replace(" " + ACTIVE_HINT_ELEMENT_CLASS, "");
-            node = this.hints.childNodes[this.selectedHint = i];
-            node.className += " " + ACTIVE_HINT_ELEMENT_CLASS;
-            if (node.offsetTop < this.hints.scrollTop)
-                this.hints.scrollTop = node.offsetTop - 3;
-            else if (node.offsetTop + node.offsetHeight > this.hints.scrollTop + this.hints.clientHeight)
-                this.hints.scrollTop = node.offsetTop + node.offsetHeight - this.hints.clientHeight
+ 3;
-            CodeMirror.signal(this.data, "select", this.data.list[this.selectedHint], node);
-        },
-        screenAmount: function () {
-            return Math.floor(this.hints.clientHeight / this.hints.firstChild.offsetHeight)
|| 1;
-        }
-    };
-
-    CodeMirror.registerHelper("hint", "auto", function (cm, options) {
-        var helpers = cm.getHelpers(cm.getCursor(), "hint"), words;
-        if (helpers.length) {
-            for (var i = 0; i < helpers.length; i++) {
-                var cur = helpers[i](cm, options);
-                if (cur && cur.list.length)
-                    return cur;
-            }
-        } else if (words = cm.getHelper(cm.getCursor(), "hintWords")) {
-            if (words)
-                return CodeMirror.hint.fromList(cm, {words: words});
-        } else if (CodeMirror.hint.anyword) {
-            return CodeMirror.hint.anyword(cm, options);
-        }
-    });
-
-    CodeMirror.registerHelper("hint", "fromList", function (cm, options) {
-        var cur = cm.getCursor(), token = cm.getTokenAt(cur);
-        var found = [];
-        for (var i = 0; i < options.words.length; i++) {
-            var word = options.words[i];
-            if (word.slice(0, token.string.length) == token.string)
-                found.push(word);
-        }
-
-        if (found.length)
-            return {
-                list: found,
-                from: CodeMirror.Pos(cur.line, token.start),
-                to: CodeMirror.Pos(cur.line, token.end)
-            };
-    });
-
-    CodeMirror.commands.autocomplete = CodeMirror.showHint;
-});


Mime
View raw message