diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/bulletin-board.jsp b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/bulletin-board.jsp index 8669f6c057..62569effd9 100644 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/bulletin-board.jsp +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/bulletin-board.jsp @@ -24,15 +24,15 @@ ${nf.bulletin.board.style.tags} - - - + + + - + ${nf.bulletin.board.script.tags} 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 acdd1478a2..8f50c1fa7e 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 @@ -28,16 +28,14 @@ - - + + - - - - - + + + @@ -48,7 +46,7 @@ - + diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/cluster.jsp b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/cluster.jsp index 33fdbb0183..867ea3fac2 100644 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/cluster.jsp +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/cluster.jsp @@ -24,19 +24,19 @@ ${nf.cluster.style.tags} - - + + - + - + - + diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/counters.jsp b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/counters.jsp index 5b901136fd..2d3576dd2f 100644 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/counters.jsp +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/counters.jsp @@ -24,19 +24,19 @@ ${nf.counters.style.tags} - - + + - + - + - + diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/history.jsp b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/history.jsp index 47eb9ec74a..db064ff24e 100644 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/history.jsp +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/history.jsp @@ -24,19 +24,19 @@ ${nf.history.style.tags} - - + + - + - + - + diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/provenance.jsp b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/provenance.jsp index 742dd3213b..59e8512453 100644 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/provenance.jsp +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/provenance.jsp @@ -25,20 +25,20 @@ - - + + - + - + - + diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/summary.jsp b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/summary.jsp index 983fac9f1e..0c57e65826 100644 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/summary.jsp +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/summary.jsp @@ -25,12 +25,12 @@ - - + + - - + + @@ -38,7 +38,7 @@ - + diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/templates.jsp b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/templates.jsp index d4c41ab537..da479d6a09 100644 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/templates.jsp +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/templates.jsp @@ -24,20 +24,20 @@ ${nf.templates.style.tags} - - + + - + - + - + - + diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/users.jsp b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/users.jsp index a1b511f9bf..ff2bbf1522 100644 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/users.jsp +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/pages/users.jsp @@ -25,20 +25,20 @@ - - + + - + - + - + diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/canvas-header.jsp b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/canvas-header.jsp index ee915c1ed7..8eea811ef8 100644 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/canvas-header.jsp +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/canvas-header.jsp @@ -53,3 +53,4 @@ +
diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/secure-port-configuration.jsp b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/secure-port-configuration.jsp index 200ef72810..bd870188f6 100644 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/secure-port-configuration.jsp +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/secure-port-configuration.jsp @@ -78,4 +78,5 @@ - \ No newline at end of file + +
\ No newline at end of file diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/partials/summary/view-single-node-dialog.jsp b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/partials/summary/view-single-node-dialog.jsp index 9570de5daf..4a3338cf3d 100644 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/partials/summary/view-single-node-dialog.jsp +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/WEB-INF/partials/summary/view-single-node-dialog.jsp @@ -21,3 +21,4 @@
(e.g. my.host:80)
+
diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/css/header.css b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/css/header.css index 1d3ee5a8e7..0f08b47019 100644 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/css/header.css +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/css/header.css @@ -451,34 +451,41 @@ input.search-flow { color: #7098AD; } -li.search-header { +#search-flow-results .ui-autocomplete { + max-height: 400px; + overflow: auto; + border: 1px solid #aaaaaa; + z-index: 1251; + border-radius: 0; +} + +#search-flow-results .ui-menu .ui-menu-item a.ui-state-focus { + background: #D4E0E5 !important; + border: 1px solid #999999; + border-radius: 0; +} + +#search-flow-results li.search-header { font-weight: bold; padding-top: 4px; padding-left: 4px; padding-right: 4px; height: 14px; - float: left; - clear: left; } -.ui-autocomplete { - max-height: 400px; - overflow: auto; -} - -div.search-match-header { +#search-flow-results div.search-match-header { font-weight: normal; margin-left: 19px; } -div.search-match { +#search-flow-results div.search-match { margin-left: 26px; color: #888; font-size: 10px; line-height: 1.4em; } -li.search-no-matches { +#search-flow-results li.search-no-matches { padding: 4px; font-weight: bold; color: #aaa; diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/css/port-configuration.css b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/css/port-configuration.css index 340c2a400b..b8fc87c7df 100644 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/css/port-configuration.css +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/css/port-configuration.css @@ -110,14 +110,26 @@ input.search-users { color: #888; } +#search-users-results .ui-autocomplete { + max-height: 300px; + overflow: auto; + border: 1px solid #aaaaaa; + z-index: 1351; + border-radius: 0; +} + +#search-users-results .ui-menu .ui-menu-item a.ui-state-focus { + background: #D4E0E5 !important; + border: 1px solid #999999; + border-radius: 0; +} + li.search-users-header { font-weight: bold; padding-top: 4px; padding-left: 4px; padding-right: 4px; height: 14px; - float: left; - clear: left; } div.search-users-match-header { diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/css/processor-configuration.css b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/css/processor-configuration.css index 85c8965794..87977f0b76 100644 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/css/processor-configuration.css +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/css/processor-configuration.css @@ -145,6 +145,12 @@ div.relationship-description { margin-top: 5px; } +#run-duration-slider .ui-slider-handle { + border-radius: 0; + border: 1px solid #999; + outline: none; +} + #run-duration-labels { font-family: sans-serif; } diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/css/summary.css b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/css/summary.css index cab21c034d..c10992769c 100644 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/css/summary.css +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/css/summary.css @@ -139,9 +139,18 @@ div.search-match { font-size: 10px; } -.ui-autocomplete { +#search-cluster-results .ui-autocomplete { max-height: 300px; overflow: auto; + border: 1px solid #aaaaaa; + z-index: 1351; + border-radius: 0; +} + +#search-cluster-results .ui-menu .ui-menu-item a.ui-state-focus { + background: #D4E0E5 !important; + border: 1px solid #999999; + border-radius: 0; } input.search-nodes { 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 4f1e9d17f0..d21bbea5a6 --- 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 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 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. 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 5f91f9bd40..0000000000 --- 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); - }); -}); 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 44449b2bb6..924e638f7f --- 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; } 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 c820fddda7..0000000000 --- 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; -}); diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/lib/codemirror-compressed.js b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/lib/codemirror-compressed.js new file mode 100644 index 0000000000..11b3fbc5e5 --- /dev/null +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/lib/codemirror-compressed.js @@ -0,0 +1,16 @@ +/* CodeMirror - Minified & Bundled + Generated on 12/10/2014 with http://codemirror.net/doc/compress.html + Version: 4.8 + + CodeMirror Library: + - codemirror.js + Add-ons: + - matchbrackets.js + - show-hint.js + */ + +!function(a){if("object"==typeof exports&&"object"==typeof module)module.exports=a();else{if("function"==typeof define&&define.amd)return define([],a);this.CodeMirror=a()}}(function(){"use strict";function w(a,b){if(!(this instanceof w))return new w(a,b);this.options=b=b?Qg(b):{},Qg(ie,b,!1),J(b);var c=b.value;"string"==typeof c&&(c=new Lf(c,b.mode)),this.doc=c;var f=this.display=new x(a,c);f.wrapper.CodeMirror=this,F(this),D(this),b.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),b.autofocus&&!o&&_c(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,draggingText:!1,highlight:new Gg,keySeq:null},d&&11>e&&setTimeout(Rg($c,this,!0),20),cd(this),ih(),Ac(this),this.curOp.forceUpdate=!0,Pf(this,c),b.autofocus&&!o||bh()==f.input?setTimeout(Rg(Hd,this),20):Id(this);for(var g in je)je.hasOwnProperty(g)&&je[g](this,b[g],le);P(this);for(var h=0;he&&(c.gutters.style.zIndex=-1,c.scroller.style.paddingRight=0),n&&(g.style.width="0px"),f||(c.scroller.draggable=!0),k&&(c.inputDiv.style.height="1px",c.inputDiv.style.position="absolute"),d&&8>e&&(c.scrollbarH.style.minHeight=c.scrollbarV.style.minWidth="18px"),a&&(a.appendChild?a.appendChild(c.wrapper):a(c.wrapper)),c.viewFrom=c.viewTo=b.first,c.view=[],c.externalMeasured=null,c.viewOffset=0,c.lastWrapHeight=c.lastWrapWidth=0,c.updateLineNumbers=null,c.lineNumWidth=c.lineNumInnerWidth=c.lineNumChars=null,c.prevInput="",c.alignWidgets=!1,c.pollingFast=!1,c.poll=new Gg,c.cachedCharWidth=c.cachedTextHeight=c.cachedPaddingH=null,c.inaccurateSelection=!1,c.maxLine=null,c.maxLineLength=0,c.maxLineChanged=!1,c.wheelDX=c.wheelDY=c.wheelStartX=c.wheelStartY=null,c.shift=!1,c.selForContextMenu=null}function y(a){a.doc.mode=w.getMode(a.options,a.doc.modeOption),z(a)}function z(a){a.doc.iter(function(a){a.stateAfter&&(a.stateAfter=null),a.styles&&(a.styles=null)}),a.doc.frontier=a.doc.first,Tb(a,100),a.state.modeGen++,a.curOp&&Pc(a)}function A(a){a.options.lineWrapping?(eh(a.display.wrapper,"CodeMirror-wrap"),a.display.sizer.style.minWidth=""):(dh(a.display.wrapper,"CodeMirror-wrap"),I(a)),C(a),Pc(a),kc(a),setTimeout(function(){M(a)},100)}function B(a){var b=wc(a.display),c=a.options.lineWrapping,d=c&&Math.max(5,a.display.scroller.clientWidth/xc(a.display)-3);return function(e){if(ef(a.doc,e))return 0;var f=0;if(e.widgets)for(var g=0;gb.maxLineLength&&(b.maxLineLength=c,b.maxLine=a)})}function J(a){var b=Ng(a.gutters,"CodeMirror-linenumbers");-1==b&&a.lineNumbers?a.gutters=a.gutters.concat(["CodeMirror-linenumbers"]):b>-1&&!a.lineNumbers&&(a.gutters=a.gutters.slice(0),a.gutters.splice(b,1))}function K(a){return a.display.scroller.clientHeight-a.display.wrapper.clientHeightb.clientWidth;f&&b.scrollWidth<=b.clientWidth+1&&d>0&&!b.hScrollbarTakesSpace&&(f=!1);var g=e>b.clientHeight;if(g?(c.scrollbarV.style.display="block",c.scrollbarV.style.bottom=f?d+"px":"0",c.scrollbarV.firstChild.style.height=Math.max(0,e-b.clientHeight+(b.barHeight||c.scrollbarV.clientHeight))+"px"):(c.scrollbarV.style.display="",c.scrollbarV.firstChild.style.height="0"),f?(c.scrollbarH.style.display="block",c.scrollbarH.style.right=g?d+"px":"0",c.scrollbarH.firstChild.style.width=b.scrollWidth-b.clientWidth+(b.barWidth||c.scrollbarH.clientWidth)+"px"):(c.scrollbarH.style.display="",c.scrollbarH.firstChild.style.width="0"),f&&g?(c.scrollbarFiller.style.display="block",c.scrollbarFiller.style.height=c.scrollbarFiller.style.width=d+"px"):c.scrollbarFiller.style.display="",f&&a.options.coverGutterNextToScrollbar&&a.options.fixedGutter?(c.gutterFiller.style.display="block",c.gutterFiller.style.height=d+"px",c.gutterFiller.style.width=c.gutters.offsetWidth+"px"):c.gutterFiller.style.display="",!a.state.checkedOverlayScrollbar&&b.clientHeight>0){if(0===d){var h=p&&!l?"12px":"18px";c.scrollbarV.style.minWidth=c.scrollbarH.style.minHeight=h;var i=function(b){pg(b)!=c.scrollbarV&&pg(b)!=c.scrollbarH&&Kc(a,gd)(b)};rg(c.scrollbarV,"mousedown",i),rg(c.scrollbarH,"mousedown",i)}a.state.checkedOverlayScrollbar=!0}}function N(a,b,c){var d=c&&null!=c.top?Math.max(0,c.top):a.scroller.scrollTop;d=Math.floor(d-Xb(a));var e=c&&null!=c.bottom?c.bottom:d+a.wrapper.clientHeight,f=Vf(b,d),g=Vf(b,e);if(c&&c.ensure){var h=c.ensure.from.line,i=c.ensure.to.line;if(f>h)return{from:h,to:Vf(b,Wf(Qf(b,h))+a.wrapper.clientHeight)};if(Math.min(i,b.lastLine())>=g)return{from:Vf(b,Wf(Qf(b,i))-a.wrapper.clientHeight),to:i}}return{from:f,to:Math.max(g,f+1)}}function O(a){var b=a.display,c=b.view;if(b.alignWidgets||b.gutters.firstChild&&a.options.fixedGutter){for(var d=R(b)-b.scroller.scrollLeft+a.doc.scrollLeft,e=b.gutters.offsetWidth,f=d+"px",g=0;g=c.viewFrom&&b.visible.to<=c.viewTo&&(null==c.updateLineNumbers||c.updateLineNumbers>=c.viewTo)&&0==Vc(a))return!1;P(a)&&(Rc(a),b.dims=$(a));var e=d.first+d.size,f=Math.max(b.visible.from-a.options.viewportMargin,d.first),g=Math.min(e,b.visible.to+a.options.viewportMargin);c.viewFromg&&c.viewTo-g<20&&(g=Math.min(e,c.viewTo)),v&&(f=cf(a.doc,f),g=df(a.doc,g));var h=f!=c.viewFrom||g!=c.viewTo||c.lastWrapHeight!=b.wrapperHeight||c.lastWrapWidth!=b.wrapperWidth;Uc(a,f,g),c.viewOffset=Wf(Qf(a.doc,c.viewFrom)),a.display.mover.style.top=c.viewOffset+"px";var i=Vc(a);if(!h&&0==i&&!b.force&&(null==c.updateLineNumbers||c.updateLineNumbers>=c.viewTo))return!1;var j=bh();return i>4&&(c.lineDiv.style.display="none"),_(a,c.updateLineNumbers,b.dims),i>4&&(c.lineDiv.style.display=""),j&&bh()!=j&&j.offsetHeight&&j.focus(),$g(c.cursorDiv),$g(c.selectionDiv),h&&(c.lastWrapHeight=b.wrapperHeight,c.lastWrapWidth=b.wrapperWidth,Tb(a,400)),c.updateLineNumbers=null,!0}function U(a,b){for(var c=b.force,d=b.viewport,e=!0;;e=!1){if(e&&a.options.lineWrapping&&b.oldScrollerWidth!=a.display.scroller.clientWidth)c=!0;else if(c=!1,d&&null!=d.top&&(d={top:Math.min(a.doc.height+Yb(a.display)-Bg-a.display.scroller.clientHeight,d.top)}),b.visible=N(a.display,a.doc,d),b.visible.from>=a.display.viewFrom&&b.visible.to<=a.display.viewTo)break;if(!T(a,b))break;Y(a);var f=L(a);Pb(a),W(a,f),M(a,f)}vg(a,"update",a),(a.display.viewFrom!=b.oldViewFrom||a.display.viewTo!=b.oldViewTo)&&vg(a,"viewportChange",a,a.display.viewFrom,a.display.viewTo)}function V(a,b){var c=new S(a,b);if(T(a,c)){Y(a),U(a,c);var d=L(a);Pb(a),W(a,d),M(a,d)}}function W(a,b){a.display.sizer.style.minHeight=a.display.heightForcer.style.top=b.docHeight+"px",a.display.gutters.style.height=Math.max(b.docHeight,b.clientHeight-Bg)+"px"}function X(a,b){a.display.sizer.offsetWidth+a.display.gutters.offsetWidthe){var i=g.node.offsetTop+g.node.offsetHeight;h=i-c,c=i}else{var j=g.node.getBoundingClientRect();h=j.bottom-j.top}var k=g.line.height-h;if(2>h&&(h=wc(b)),(k>.001||-.001>k)&&(Tf(g.line,h),Z(g.line),g.rest))for(var l=0;l=b&&m.lineNumber;m.changes&&(Ng(m.changes,"gutter")>-1&&(o=!1),ab(a,m,k,c)),o&&($g(m.lineNumber),m.lineNumber.appendChild(document.createTextNode(Q(a.options,k)))),h=m.node.nextSibling}else{var n=ib(a,m,k,c);g.insertBefore(n,h)}k+=m.size}for(;h;)h=i(h)}function ab(a,b,c,d){for(var e=0;ee&&(a.node.style.zIndex=2)),a.node}function cb(a){var b=a.bgClass?a.bgClass+" "+(a.line.bgClass||""):a.line.bgClass;if(b&&(b+=" CodeMirror-linebackground"),a.background)b?a.background.className=b:(a.background.parentNode.removeChild(a.background),a.background=null);else if(b){var c=bb(a);a.background=c.insertBefore(Yg("div",null,b),c.firstChild)}}function db(a,b){var c=a.display.externalMeasured;return c&&c.line==b.line?(a.display.externalMeasured=null,b.measure=c.measure,c.built):zf(a,b)}function eb(a,b){var c=b.text.className,d=db(a,b);b.text==b.node&&(b.node=d.pre),b.text.parentNode.replaceChild(d.pre,b.text),b.text=d.pre,d.bgClass!=b.bgClass||d.textClass!=b.textClass?(b.bgClass=d.bgClass,b.textClass=d.textClass,fb(b)):c&&(b.text.className=c)}function fb(a){cb(a),a.line.wrapClass?bb(a).className=a.line.wrapClass:a.node!=a.text&&(a.node.className="");var b=a.textClass?a.textClass+" "+(a.line.textClass||""):a.line.textClass;a.text.className=b||""}function gb(a,b,c,d){b.gutter&&(b.node.removeChild(b.gutter),b.gutter=null);var e=b.line.gutterMarkers;if(a.options.lineNumbers||e){var f=bb(b),g=b.gutter=f.insertBefore(Yg("div",null,"CodeMirror-gutter-wrapper","left: "+(a.options.fixedGutter?d.fixedPos:-d.gutterTotalWidth)+"px; width: "+d.gutterTotalWidth+"px"),b.text);if(b.line.gutterClass&&(g.className+=" "+b.line.gutterClass),!a.options.lineNumbers||e&&e["CodeMirror-linenumbers"]||(b.lineNumber=g.appendChild(Yg("div",Q(a.options,c),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+d.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+a.display.lineNumInnerWidth+"px"))),e)for(var h=0;h=0){var g=qb(f.from(),e.from()),h=pb(f.to(),e.to()),i=f.empty()?e.from()==e.head:f.from()==f.head;b>=d&&--b,a.splice(--d,2,new sb(i?h:g,i?g:h))}}return new rb(a,b)}function ub(a,b){return new rb([new sb(a,b||a)],0)}function vb(a,b){return Math.max(a.first,Math.min(b,a.first+a.size-1))}function wb(a,b){if(b.linec?mb(c,Qf(a,c).text.length):xb(b,Qf(a,b.line).text.length)}function xb(a,b){var c=a.ch;return null==c||c>b?mb(a.line,b):0>c?mb(a.line,0):a}function yb(a,b){return b>=a.first&&b=f.ch:j.to>f.ch))){if(d&&(tg(k,"beforeCursorEnter"),k.explicitlyCleared)){if(h.markedSpans){--i;continue}break}if(!k.atomic)continue;var l=k.find(0>g?-1:1);if(0==nb(l,f)&&(l.ch+=g,l.ch<0?l=l.line>a.first?wb(a,mb(l.line-1)):null:l.ch>h.text.length&&(l=l.lineb&&(b=0),b=Math.round(b),d=Math.round(d),f.appendChild(Yg("div",null,"CodeMirror-selected","position: absolute; left: "+a+"px; top: "+b+"px; width: "+(null==c?i-a:c)+"px; height: "+(d-b)+"px"))}function k(b,c,d){function m(c,d){return pc(a,mb(b,c),"div",f,d)}var k,l,f=Qf(e,b),g=f.text.length;return xh(Xf(f),c||0,null==d?g:d,function(a,b,e){var n,o,p,f=m(a,"left");if(a==b)n=f,o=p=f.left;else{if(n=m(b-1,"right"),"rtl"==e){var q=f;f=n,n=q}o=f.left,p=n.right}null==c&&0==a&&(o=h),n.top-f.top>3&&(j(o,f.top,null,f.bottom),o=h,f.bottoml.bottom||n.bottom==l.bottom&&n.right>l.right)&&(l=n),h+1>o&&(o=h),j(o,n.top,p-o,n.bottom)}),{start:k,end:l}}var d=a.display,e=a.doc,f=document.createDocumentFragment(),g=Zb(a.display),h=g.left,i=d.lineSpace.offsetWidth-g.right,l=b.from(),m=b.to();if(l.line==m.line)k(l.line,l.ch,m.ch);else{var n=Qf(e,l.line),o=Qf(e,m.line),p=af(n)==af(o),q=k(l.line,l.ch,p?n.text.length+1:null).end,r=k(m.line,p?0:null,m.ch).start;p&&(q.top0?b.blinker=setInterval(function(){b.cursorDiv.style.visibility=(c=!c)?"":"hidden"},a.options.cursorBlinkRate):a.options.cursorBlinkRate<0&&(b.cursorDiv.style.visibility="hidden")}}function Tb(a,b){a.doc.mode.startState&&a.doc.frontier=a.display.viewTo)){var c=+new Date+a.options.workTime,d=re(b.mode,Wb(a,b.frontier)),e=[];b.iter(b.frontier,Math.min(b.first+b.size,a.display.viewTo+500),function(f){if(b.frontier>=a.display.viewFrom){var g=f.styles,h=tf(a,f,d,!0);f.styles=h.styles;var i=f.styleClasses,j=h.classes;j?f.styleClasses=j:i&&(f.styleClasses=null);for(var k=!g||g.length!=f.styles.length||i!=j&&(!i||!j||i.bgClass!=j.bgClass||i.textClass!=j.textClass),l=0;!k&&lc?(Tb(a,a.options.workDelay),!0):void 0}),e.length&&Jc(a,function(){for(var b=0;bg;--h){if(h<=f.first)return f.first;var i=Qf(f,h-1);if(i.stateAfter&&(!c||h<=f.frontier))return h;var j=Hg(i.text,null,a.options.tabSize);(null==e||d>j)&&(e=h-1,d=j)}return e}function Wb(a,b,c){var d=a.doc,e=a.display;if(!d.mode.startState)return!0;var f=Vb(a,b,c),g=f>d.first&&Qf(d,f-1).stateAfter;return g=g?re(d.mode,g):se(d.mode),d.iter(f,b,function(c){vf(a,c.text,g);var h=f==b-1||0==f%5||f>=e.viewFrom&&f2&&f.push((i.bottom+j.top)/2-c.top)}}f.push(c.bottom-c.top)}}function _b(a,b,c){if(a.line==b)return{map:a.measure.map,cache:a.measure.cache};for(var d=0;dc)return{map:a.measure.maps[d],cache:a.measure.caches[d],before:!0}}function ac(a,b){b=af(b);var c=Uf(b),d=a.display.externalMeasured=new Nc(a.doc,b,c);d.lineN=c;var e=d.built=zf(a,d);return d.text=e.pre,_g(a.display.lineMeasure,e.pre),d}function bc(a,b,c,d){return ec(a,dc(a,b),c,d)}function cc(a,b){if(b>=a.display.viewFrom&&b=c.lineN&&bc?(i=0,j=1,k="left"):n>c?(i=c-m,j=i+1):(l==g.length-3||c==n&&g[l+3]>c)&&(j=n-m,i=j-1,c>=n&&(k="right")),null!=i){if(h=g[l+2],m==n&&f==(h.insertLeft?"left":"right")&&(k=f),"left"==f&&0==i)for(;l&&g[l-2]==g[l-3]&&g[l-1].insertLeft;)h=g[(l-=3)+2],k="left";if("right"==f&&i==n-m)for(;ll;l++){for(;i&&Xg(b.line.text.charAt(m+i));)--i;for(;n>m+j&&Xg(b.line.text.charAt(m+j));)++j;if(d&&9>e&&0==i&&j==n-m)o=h.parentNode.getBoundingClientRect();else if(d&&a.options.lineWrapping){var p=Zg(h,i,j).getClientRects();o=p.length?p["right"==f?p.length-1:0]:fc}else o=Zg(h,i,j).getBoundingClientRect()||fc;if(o.left||o.right||0==i)break;j=i,i-=1,k="right"}d&&11>e&&(o=hc(a.display.measure,o))}else{i>0&&(k=f="right");var p;o=a.options.lineWrapping&&(p=h.getClientRects()).length>1?p["right"==f?p.length-1:0]:h.getBoundingClientRect()}if(d&&9>e&&!i&&(!o||!o.left&&!o.right)){var q=h.parentNode.getClientRects()[0];o=q?{left:q.left,right:q.left+xc(a.display),top:q.top,bottom:q.bottom}:fc}for(var r=o.top-b.rect.top,s=o.bottom-b.rect.top,t=(r+s)/2,u=b.view.measure.heights,l=0;lc.from?g(a-1):g(a,d)}d=d||Qf(a.doc,b.line),e||(e=dc(a,d));var i=Xf(d),j=b.ch;if(!i)return g(j);var k=Hh(i,j),l=h(j,k);return null!=Gh&&(l.other=h(j,Gh)),l}function rc(a,b){var c=0,b=wb(a.doc,b);a.options.lineWrapping||(c=xc(a.display)*b.ch);var d=Qf(a.doc,b.line),e=Wf(d)+Xb(a.display);return{left:c,right:c,top:e,bottom:e+d.height}}function sc(a,b,c,d){var e=mb(a,b);return e.xRel=d,c&&(e.outside=!0),e}function tc(a,b,c){var d=a.doc;if(c+=a.display.viewOffset,0>c)return sc(d.first,0,!0,-1);var e=Vf(d,c),f=d.first+d.size-1;if(e>f)return sc(d.first+d.size-1,Qf(d,f).text.length,!0,1);0>b&&(b=0);for(var g=Qf(d,e);;){var h=uc(a,g,e,b,c),i=$e(g),j=i&&i.find(0,!0);if(!i||!(h.ch>j.from.ch||h.ch==j.from.ch&&h.xRel>0))return h;e=Uf(g=j.to.line)}}function uc(a,b,c,d,e){function j(d){var e=qc(a,mb(c,d),"line",b,i);return g=!0,f>e.bottom?e.left-h:fq)return sc(c,n,r,1);for(;;){if(k?n==m||n==Jh(b,m,1):1>=n-m){for(var s=o>d||q-d>=d-o?m:n,t=d-(s==m?o:q);Xg(b.text.charAt(s));)++s;var u=sc(c,s,s==m?p:r,-1>t?-1:t>1?1:0);return u}var v=Math.ceil(l/2),w=m+v;if(k){w=m;for(var x=0;v>x;++x)w=Jh(b,w,1)}var y=j(w);y>d?(n=w,q=y,(r=g)&&(q+=1e3),l=v):(m=w,o=y,p=g,l-=v)}}function wc(a){if(null!=a.cachedTextHeight)return a.cachedTextHeight;if(null==vc){vc=Yg("pre");for(var b=0;49>b;++b)vc.appendChild(document.createTextNode("x")),vc.appendChild(Yg("br"));vc.appendChild(document.createTextNode("x"))}_g(a.measure,vc);var c=vc.offsetHeight/50;return c>3&&(a.cachedTextHeight=c),$g(a.measure),c||1}function xc(a){if(null!=a.cachedCharWidth)return a.cachedCharWidth;var b=Yg("span","xxxxxxxxxx"),c=Yg("pre",[b]);_g(a.measure,c);var d=b.getBoundingClientRect(),e=(d.right-d.left)/10;return e>2&&(a.cachedCharWidth=e),e||10}function Ac(a){a.curOp={cm:a,viewChanged:!1,startHeight:a.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,id:++zc},yc?yc.ops.push(a.curOp):a.curOp.ownsGroup=yc={ops:[a.curOp],delayedCallbacks:[]}}function Bc(a){var b=a.delayedCallbacks,c=0;do{for(;c=c.viewTo)||c.maxLineChanged&&b.options.lineWrapping,a.update=a.mustUpdate&&new S(b,a.mustUpdate&&{top:a.scrollTop,ensure:a.scrollToPos},a.forceUpdate)}function Fc(a){a.updatedDisplay=a.mustUpdate&&T(a.cm,a.update)}function Gc(a){var b=a.cm,c=b.display;a.updatedDisplay&&Y(b),a.barMeasure=L(b),c.maxLineChanged&&!b.options.lineWrapping&&(a.adjustWidthTo=bc(b,c.maxLine,c.maxLine.text.length).left+3,a.maxScrollLeft=Math.max(0,c.sizer.offsetLeft+a.adjustWidthTo+Bg-c.scroller.clientWidth)),(a.updatedDisplay||a.selectionChanged)&&(a.newSelectionNodes=Nb(b))}function Hc(a){var b=a.cm;null!=a.adjustWidthTo&&(b.display.sizer.style.minWidth=a.adjustWidthTo+"px",a.maxScrollLeft1&&M(b),a.updatedDisplay&&U(b,a.update),null==c.wheelStartX||null==a.scrollTop&&null==a.scrollLeft&&!a.scrollToPos||(c.wheelStartX=c.wheelStartY=null),null!=a.scrollTop&&(c.scroller.scrollTop!=a.scrollTop||a.forceScroll)){var e=Math.max(0,Math.min(c.scroller.scrollHeight-c.scroller.clientHeight,a.scrollTop));c.scroller.scrollTop=c.scrollbarV.scrollTop=d.scrollTop=e}if(null!=a.scrollLeft&&(c.scroller.scrollLeft!=a.scrollLeft||a.forceScroll)){var g=Math.max(0,Math.min(c.scroller.scrollWidth-c.scroller.clientWidth,a.scrollLeft));c.scroller.scrollLeft=c.scrollbarH.scrollLeft=d.scrollLeft=g,O(b)}if(a.scrollToPos){var h=Zd(b,wb(d,a.scrollToPos.from),wb(d,a.scrollToPos.to),a.scrollToPos.margin);a.scrollToPos.isCursor&&b.state.focused&&Yd(b,h)}var i=a.maybeHiddenMarkers,j=a.maybeUnhiddenMarkers;if(i)for(var k=0;ka.barMeasure.clientWidth&&a.barMeasure.scrollWidthf;f=e){var g=new Nc(a.doc,Qf(a.doc,f),f);e=f+g.size,d.push(g)}return d}function Pc(a,b,c,d){null==b&&(b=a.doc.first),null==c&&(c=a.doc.first+a.doc.size),d||(d=0);var e=a.display;if(d&&cb)&&(e.updateLineNumbers=b),a.curOp.viewChanged=!0,b>=e.viewTo)v&&cf(a.doc,b)e.viewFrom?Rc(a):(e.viewFrom+=d,e.viewTo+=d);else if(b<=e.viewFrom&&c>=e.viewTo)Rc(a);else if(b<=e.viewFrom){var f=Tc(a,c,c+d,1);f?(e.view=e.view.slice(f.index),e.viewFrom=f.lineN,e.viewTo+=d):Rc(a)}else if(c>=e.viewTo){var f=Tc(a,b,b,-1);f?(e.view=e.view.slice(0,f.index),e.viewTo=f.lineN):Rc(a)}else{var g=Tc(a,b,b,-1),h=Tc(a,c,c+d,1);g&&h?(e.view=e.view.slice(0,g.index).concat(Oc(a,g.lineN,h.lineN)).concat(e.view.slice(h.index)),e.viewTo+=d):Rc(a)}var i=e.externalMeasured;i&&(c=e.lineN&&b=d.viewTo)){var f=d.view[Sc(a,b)];if(null!=f.node){var g=f.changes||(f.changes=[]);-1==Ng(g,c)&&g.push(c)}}}function Rc(a){a.display.viewFrom=a.display.viewTo=a.doc.first,a.display.view=[],a.display.viewOffset=0}function Sc(a,b){if(b>=a.display.viewTo)return null;if(b-=a.display.viewFrom,0>b)return null;for(var c=a.display.view,d=0;db)return d}function Tc(a,b,c,d){var f,e=Sc(a,b),g=a.display.view;if(!v||c==a.doc.first+a.doc.size)return{index:e,lineN:c};for(var h=0,i=a.display.viewFrom;e>h;h++)i+=g[h].size;if(i!=b){if(d>0){if(e==g.length-1)return null;f=i+g[e].size-b,e++}else f=i-b;b+=f,c+=f}for(;cf(a.doc,c)!=c;){if(e==(0>d?0:g.length-1))return null;c+=d*g[e-(0>d?1:0)].size,e+=d}return{index:e,lineN:c}}function Uc(a,b,c){var d=a.display,e=d.view;0==e.length||b>=d.viewTo||c<=d.viewFrom?(d.view=Oc(a,b,c),d.viewFrom=b):(d.viewFrom>b?d.view=Oc(a,b,d.viewFrom).concat(d.view):d.viewFromc&&(d.view=d.view.slice(0,Sc(a,c)))),d.viewTo=c}function Vc(a){for(var b=a.display.view,c=0,d=0;d=9&&a.display.inputHasSelection===g||p&&/[\uf700-\uf7ff]/.test(g))return $c(a),!1;var h=!a.curOp;h&&Ac(a),a.display.shift=!1,8203!=g.charCodeAt(0)||f.sel!=a.display.selForContextMenu||c||(c="\u200b");for(var i=0,j=Math.min(c.length,g.length);j>i&&c.charCodeAt(i)==g.charCodeAt(i);)++i;var k=g.slice(i),l=rh(k),m=null;a.state.pasteIncoming&&f.sel.ranges.length>1&&(Yc&&Yc.join("\n")==k?m=0==f.sel.ranges.length%Yc.length&&Og(Yc,rh):l.length==f.sel.ranges.length&&(m=Og(l,function(a){return[a]})));for(var n=f.sel.ranges.length-1;n>=0;n--){var o=f.sel.ranges[n],q=o.from(),r=o.to();i-1){de(a,v.line,"smart");break}}else u.electricInput&&u.electricInput.test(Qf(f,v.line).text.slice(0,v.ch))&&de(a,v.line,"smart")}}return be(a),a.curOp.updateInput=s,a.curOp.typing=!0,g.length>1e3||g.indexOf("\n")>-1?b.value=a.display.prevInput="":a.display.prevInput=g,h&&Cc(a),a.state.pasteIncoming=a.state.cutIncoming=!1,!0}function $c(a,b){var c,f,g=a.doc;if(a.somethingSelected()){a.display.prevInput="";var h=g.sel.primary();c=th&&(h.to().line-h.from().line>100||(f=a.getSelection()).length>1e3);var i=c?"-":f||a.getSelection();a.display.input.value=i,a.state.focused&&Mg(a.display.input),d&&e>=9&&(a.display.inputHasSelection=i)}else b||(a.display.prevInput=a.display.input.value="",d&&e>=9&&(a.display.inputHasSelection=null));a.display.inaccurateSelection=c}function _c(a){"nocursor"==a.options.readOnly||o&&bh()==a.display.input||a.display.input.focus()}function ad(a){a.state.focused||(_c(a),Hd(a))}function bd(a){return a.options.readOnly||a.doc.cantEdit}function cd(a){function c(){a.state.focused&&setTimeout(Rg(_c,a),0)}function g(b){xg(a,b)||og(b)}function h(c){if(a.somethingSelected())Yc=a.getSelections(),b.inaccurateSelection&&(b.prevInput="",b.inaccurateSelection=!1,b.input.value=Yc.join("\n"),Mg(b.input));else{for(var d=[],e=[],f=0;fe?rg(b.scroller,"dblclick",Kc(a,function(b){if(!xg(a,b)){var c=fd(a,b);if(c&&!nd(a,b)&&!ed(a.display,b)){lg(b);var d=a.findWordAt(c);Bb(a.doc,d.anchor,d.head)}}})):rg(b.scroller,"dblclick",function(b){xg(a,b)||lg(b)}),rg(b.lineSpace,"selectstart",function(a){ed(b,a)||lg(a)}),t||rg(b.scroller,"contextmenu",function(b){Jd(a,b)}),rg(b.scroller,"scroll",function(){b.scroller.clientHeight&&(rd(a,b.scroller.scrollTop),sd(a,b.scroller.scrollLeft,!0),tg(a,"scroll",a))}),rg(b.scrollbarV,"scroll",function(){b.scroller.clientHeight&&rd(a,b.scrollbarV.scrollTop)}),rg(b.scrollbarH,"scroll",function(){b.scroller.clientHeight&&sd(a,b.scrollbarH.scrollLeft)}),rg(b.scroller,"mousewheel",function(b){vd(a,b)}),rg(b.scroller,"DOMMouseScroll",function(b){vd(a,b)}),rg(b.scrollbarH,"mousedown",c),rg(b.scrollbarV,"mousedown",c),rg(b.wrapper,"scroll",function(){b.wrapper.scrollTop=b.wrapper.scrollLeft=0}),rg(b.input,"keyup",function(b){Fd.call(a,b)}),rg(b.input,"input",function(){d&&e>=9&&a.display.inputHasSelection&&(a.display.inputHasSelection=null),Xc(a)}),rg(b.input,"keydown",Kc(a,Dd)),rg(b.input,"keypress",Kc(a,Gd)),rg(b.input,"focus",Rg(Hd,a)),rg(b.input,"blur",Rg(Id,a)),a.options.dragDrop&&(rg(b.scroller,"dragstart",function(b){qd(a,b)}),rg(b.scroller,"dragenter",g),rg(b.scroller,"dragover",g),rg(b.scroller,"drop",Kc(a,pd))),rg(b.scroller,"paste",function(c){ed(b,c)||(a.state.pasteIncoming=!0,_c(a),Xc(a))}),rg(b.input,"paste",function(){if(f&&!a.state.fakedLastChar&&!(new Date-a.state.lastMiddleDown<200)){var c=b.input.selectionStart,d=b.input.selectionEnd;b.input.value+="$",b.input.selectionEnd=d,b.input.selectionStart=c,a.state.fakedLastChar=!0}a.state.pasteIncoming=!0,Xc(a)}),rg(b.input,"cut",h),rg(b.input,"copy",h),k&&rg(b.sizer,"mouseup",function(){bh()==b.input&&b.input.blur(),_c(a)})}function dd(a){var b=a.display;(b.lastWrapHeight!=b.wrapper.clientHeight||b.lastWrapWidth!=b.wrapper.clientWidth)&&(b.cachedCharWidth=b.cachedTextHeight=b.cachedPaddingH=null,a.setSize())}function ed(a,b){for(var c=pg(b);c!=a.wrapper;c=c.parentNode)if(!c||c.ignoreEvents||c.parentNode==a.sizer&&c!=a.mover)return!0}function fd(a,b,c,d){var e=a.display;if(!c){var f=pg(b);if(f==e.scrollbarH||f==e.scrollbarV||f==e.scrollbarFiller||f==e.gutterFiller)return null}var g,h,i=e.lineSpace.getBoundingClientRect();try{g=b.clientX-i.left,h=b.clientY-i.top}catch(b){return null}var k,j=tc(a,g,h);if(d&&1==j.xRel&&(k=Qf(a.doc,j.line).text).length==j.ch){var l=Hg(k,k.length,a.options.tabSize)-k.length;j=mb(j.line,Math.max(0,Math.round((g-Zb(a.display).left)/xc(a.display))-l))}return j}function gd(a){if(!xg(this,a)){var b=this,c=b.display;if(c.shift=a.shiftKey,ed(c,a))return f||(c.scroller.draggable=!1,setTimeout(function(){c.scroller.draggable=!0},100)),void 0;if(!nd(b,a)){var d=fd(b,a);switch(window.focus(),qg(a)){case 1:d?jd(b,a,d):pg(a)==c.scroller&&lg(a);break;case 2:f&&(b.state.lastMiddleDown=+new Date),d&&Bb(b.doc,d),setTimeout(Rg(_c,b),20),lg(a);break;case 3:t&&Jd(b,a)}}}}function jd(a,b,c){setTimeout(Rg(ad,a),0);var e,d=+new Date;id&&id.time>d-400&&0==nb(id.pos,c)?e="triple":hd&&hd.time>d-400&&0==nb(hd.pos,c)?(e="double",id={time:d,pos:c}):(e="single",hd={time:d,pos:c});var f=a.doc.sel,g=p?b.metaKey:b.ctrlKey;a.options.dragDrop&&kh&&!bd(a)&&"single"==e&&f.contains(c)>-1&&f.somethingSelected()?kd(a,b,c,g):ld(a,b,c,e,g)}function kd(a,b,c,g){var h=a.display,i=Kc(a,function(j){f&&(h.scroller.draggable=!1),a.state.draggingText=!1,sg(document,"mouseup",i),sg(h.scroller,"drop",i),Math.abs(b.clientX-j.clientX)+Math.abs(b.clientY-j.clientY)<10&&(lg(j),g||Bb(a.doc,c),_c(a),d&&9==e&&setTimeout(function(){document.body.focus(),_c(a)},20))});f&&(h.scroller.draggable=!0),a.state.draggingText=i,h.scroller.dragDrop&&h.scroller.dragDrop(),rg(document,"mouseup",i),rg(h.scroller,"drop",i)}function ld(a,b,c,d,e){function n(b){if(0!=nb(m,b))if(m=b,"rect"==d){for(var e=[],f=a.options.tabSize,k=Hg(Qf(g,c.line).text,c.ch,f),l=Hg(Qf(g,b.line).text,b.ch,f),n=Math.min(k,l),o=Math.max(k,l),p=Math.min(c.line,b.line),q=Math.min(a.lastLine(),Math.max(c.line,b.line));q>=p;p++){var r=Qf(g,p).text,s=Ig(r,n,f);n==o?e.push(new sb(mb(p,s),mb(p,s))):r.length>s&&e.push(new sb(mb(p,s),mb(p,Ig(r,o,f))))}e.length||e.push(new sb(c,c)),Hb(g,tb(j.ranges.slice(0,i).concat(e),i),{origin:"*mouse",scroll:!1}),a.scrollIntoView(b)}else{var t=h,u=t.anchor,v=b;if("single"!=d){if("double"==d)var w=a.findWordAt(b);else var w=new sb(mb(b.line,0),wb(g,mb(b.line+1,0)));nb(w.anchor,u)>0?(v=w.head,u=qb(t.from(),w.anchor)):(v=w.anchor,u=pb(t.to(),w.head))}var e=j.ranges.slice(0);e[i]=new sb(wb(g,u),v),Hb(g,tb(e,i),Eg)}}function q(b){var c=++p,e=fd(a,b,!0,"rect"==d);if(e)if(0!=nb(e,m)){ad(a),n(e);var h=N(f,g);(e.line>=h.to||e.lineo.bottom?20:0;i&&setTimeout(Kc(a,function(){p==c&&(f.scroller.scrollTop+=i,q(b))}),50)}}function r(b){p=1/0,lg(b),_c(a),sg(document,"mousemove",s),sg(document,"mouseup",t),g.history.lastSelOrigin=null}var f=a.display,g=a.doc;lg(b);var h,i,j=g.sel;if(e&&!b.shiftKey?(i=g.sel.contains(c),h=i>-1?g.sel.ranges[i]:new sb(c,c)):h=g.sel.primary(),b.altKey)d="rect",e||(h=new sb(c,c)),c=fd(a,b,!0,!0),i=-1;else if("double"==d){var k=a.findWordAt(c);h=a.display.shift||g.extend?Ab(g,h,k.anchor,k.head):k}else if("triple"==d){var l=new sb(mb(c.line,0),wb(g,mb(c.line+1,0)));h=a.display.shift||g.extend?Ab(g,h,l.anchor,l.head):l}else h=Ab(g,h,c);e?i>-1?Db(g,i,h,Eg):(i=g.sel.ranges.length,Hb(g,tb(g.sel.ranges.concat([h]),i),{scroll:!1,origin:"*mouse"})):(i=0,Hb(g,new rb([h],0),Eg),j=g.sel);var m=c,o=f.wrapper.getBoundingClientRect(),p=0,s=Kc(a,function(a){qg(a)?q(a):r(a)}),t=Kc(a,r);rg(document,"mousemove",s),rg(document,"mouseup",t)}function md(a,b,c,d,e){try{var f=b.clientX,g=b.clientY}catch(b){return!1}if(f>=Math.floor(a.display.gutters.getBoundingClientRect().right))return!1;d&&lg(b);var h=a.display,i=h.lineDiv.getBoundingClientRect();if(g>i.bottom||!zg(a,c))return ng(b);g-=i.top-h.viewOffset;for(var j=0;j=f){var l=Vf(a.doc,g),m=a.options.gutters[j];return e(a,c,a,l,m,b),ng(b)}}}function nd(a,b){return md(a,b,"gutterClick",!0,vg)}function pd(a){var b=this;if(!xg(b,a)&&!ed(b.display,a)){lg(a),d&&(od=+new Date);var c=fd(b,a,!0),e=a.dataTransfer.files;if(c&&!bd(b))if(e&&e.length&&window.FileReader&&window.File)for(var f=e.length,g=Array(f),h=0,i=function(a,d){var e=new FileReader;e.onload=Kc(b,function(){if(g[d]=e.result,++h==f){c=wb(b.doc,c);var a={from:c,to:c,text:rh(g.join("\n")),origin:"paste"};Rd(b.doc,a),Gb(b.doc,ub(c,Ld(a)))}}),e.readAsText(a)},j=0;f>j;++j)i(e[j],j);else{if(b.state.draggingText&&b.doc.sel.contains(c)>-1)return b.state.draggingText(a),setTimeout(Rg(_c,b),20),void 0;try{var g=a.dataTransfer.getData("Text");if(g){if(b.state.draggingText&&!(p?a.metaKey:a.ctrlKey))var k=b.listSelections();if(Ib(b.doc,ub(c,c)),k)for(var j=0;jh.clientWidth||e&&h.scrollHeight>h.clientHeight){if(e&&p&&f)a:for(var j=c.target,k=g.view;j!=h;j=j.parentNode)for(var l=0;lm?n=Math.max(0,n+m-50):o=Math.min(b.doc.height,o+m+50),V(b,{top:n,bottom:o})}20>td&&(null==g.wheelStartX?(g.wheelStartX=h.scrollLeft,g.wheelStartY=h.scrollTop,g.wheelDX=d,g.wheelDY=e,setTimeout(function(){if(null!=g.wheelStartX){var a=h.scrollLeft-g.wheelStartX,b=h.scrollTop-g.wheelStartY,c=b&&g.wheelDY&&b/g.wheelDY||a&&g.wheelDX&&a/g.wheelDX;g.wheelStartX=g.wheelStartY=null,c&&(ud=(ud*td+c)/(td+1),++td)}},200)):(g.wheelDX+=d,g.wheelDY+=e))}}function wd(a,b,c){if("string"==typeof b&&(b=te[b],!b))return!1;a.display.pollingFast&&Zc(a)&&(a.display.pollingFast=!1);var d=a.display.shift,e=!1;try{bd(a)&&(a.state.suppressEdits=!0),c&&(a.display.shift=!1),e=b(a)!=Cg}finally{a.display.shift=d,a.state.suppressEdits=!1}return e}function xd(a,b,c){for(var d=0;de&&27==a.keyCode&&(a.returnValue=!1);var c=a.keyCode;b.display.shift=16==c||a.shiftKey;var f=Ad(b,a);i&&(Cd=f?c:null,!f&&88==c&&!th&&(p?a.metaKey:a.ctrlKey)&&b.replaceSelection("",null,"cut")),18!=c||/\bCodeMirror-crosshair\b/.test(b.display.lineDiv.className)||Ed(b)}}function Ed(a){function c(a){18!=a.keyCode&&a.altKey||(dh(b,"CodeMirror-crosshair"),sg(document,"keyup",c),sg(document,"mouseover",c))}var b=a.display.lineDiv;eh(b,"CodeMirror-crosshair"),rg(document,"keyup",c),rg(document,"mouseover",c)}function Fd(a){16==a.keyCode&&(this.doc.sel.shift=!1),xg(this,a)}function Gd(a){var b=this;if(!(xg(b,a)||a.ctrlKey&&!a.altKey||p&&a.metaKey)){var c=a.keyCode,f=a.charCode;if(i&&c==Cd)return Cd=null,lg(a),void 0;if(!(i&&(!a.which||a.which<10)||k)||!Ad(b,a)){var g=String.fromCharCode(null==f?c:f);Bd(b,a,g)||(d&&e>=9&&(b.display.inputHasSelection=null),Xc(b))}}}function Hd(a){"nocursor"!=a.options.readOnly&&(a.state.focused||(tg(a,"focus",a),a.state.focused=!0,eh(a.display.wrapper,"CodeMirror-focused"),a.curOp||a.display.selForContextMenu==a.doc.sel||($c(a),f&&setTimeout(Rg($c,a,!0),0))),Wc(a),Sb(a))}function Id(a){a.state.focused&&(tg(a,"blur",a),a.state.focused=!1,dh(a.display.wrapper,"CodeMirror-focused")),clearInterval(a.display.blinker),setTimeout(function(){a.state.focused||(a.display.shift=!1)},150)}function Jd(a,b){function m(){if(null!=c.input.selectionStart){var b=a.somethingSelected(),d=c.input.value="\u200b"+(b?c.input.value:"");c.prevInput=b?"":"\u200b",c.input.selectionStart=1,c.input.selectionEnd=d.length,c.selForContextMenu=a.doc.sel}}function n(){if(c.inputDiv.style.position="relative",c.input.style.cssText=k,d&&9>e&&(c.scrollbarV.scrollTop=c.scroller.scrollTop=h),Wc(a),null!=c.input.selectionStart){(!d||d&&9>e)&&m();var b=0,f=function(){c.selForContextMenu==a.doc.sel&&0==c.input.selectionStart?Kc(a,te.selectAll)(a):b++<10?c.detectingSelectAll=setTimeout(f,500):$c(a)};c.detectingSelectAll=setTimeout(f,200)}}if(!xg(a,b,"contextmenu")){var c=a.display;if(!ed(c,b)&&!Kd(a,b)){var g=fd(a,b),h=c.scroller.scrollTop;if(g&&!i){var j=a.options.resetSelectionOnContextMenu;j&&-1==a.doc.sel.contains(g)&&Kc(a,Hb)(a.doc,ub(g),Dg);var k=c.input.style.cssText;if(c.inputDiv.style.position="absolute",c.input.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(b.clientY-5)+"px; left: "+(b.clientX-5)+"px; z-index: 1000; background: "+(d?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",f)var l=window.scrollY;if(_c(a),f&&window.scrollTo(null,l),$c(a),a.somethingSelected()||(c.input.value=c.prevInput=" "),c.selForContextMenu=a.doc.sel,clearTimeout(c.detectingSelectAll),d&&e>=9&&m(),t){og(b);var o=function(){sg(window,"mouseup",o),setTimeout(n,20)};rg(window,"mouseup",o)}else setTimeout(n,50)}}}}function Kd(a,b){return zg(a,"gutterContextMenu")?md(a,b,"gutterContextMenu",!1,tg):!1}function Md(a,b){if(nb(a,b.from)<0)return a;if(nb(a,b.to)<=0)return Ld(b);var c=a.line+b.text.length-(b.to.line-b.from.line)-1,d=a.ch;return a.line==b.to.line&&(d+=Ld(b).ch-b.to.ch),mb(c,d)}function Nd(a,b){for(var c=[],d=0;d=0;--e)Sd(a,{from:d[e].from,to:d[e].to,text:e?[""]:b.text});else Sd(a,b)}}function Sd(a,b){if(1!=b.text.length||""!=b.text[0]||0!=nb(b.from,b.to)){var c=Nd(a,b);ag(a,b,c,a.cm?a.cm.curOp.id:0/0),Vd(a,b,c,Pe(a,b));var d=[];Of(a,function(a,c){c||-1!=Ng(d,a.history)||(kg(a.history,b),d.push(a.history)),Vd(a,b,null,Pe(a,b))})}}function Td(a,b,c){if(!a.cm||!a.cm.state.suppressEdits){for(var e,d=a.history,f=a.sel,g="undo"==b?d.done:d.undone,h="undo"==b?d.undone:d.done,i=0;i=0;--i){var l=e.changes[i];if(l.origin=b,k&&!Qd(a,l,!1))return g.length=0,void 0;j.push(Zf(a,l));var m=i?Nd(a,l):Lg(g);Vd(a,l,m,Re(a,l)),!i&&a.cm&&a.cm.scrollIntoView({from:l.from,to:Ld(l)});var n=[];Of(a,function(a,b){b||-1!=Ng(n,a.history)||(kg(a.history,l),n.push(a.history)),Vd(a,l,null,Re(a,l))})}}}}function Ud(a,b){if(0!=b&&(a.first+=b,a.sel=new rb(Og(a.sel.ranges,function(a){return new sb(mb(a.anchor.line+b,a.anchor.ch),mb(a.head.line+b,a.head.ch))}),a.sel.primIndex),a.cm)){Pc(a.cm,a.first,a.first-b,b);for(var c=a.cm.display,d=c.viewFrom;da.lastLine())){if(b.from.linef&&(b={from:b.from,to:mb(f,Qf(a,f).text.length),text:[b.text[0]],origin:b.origin}),b.removed=Rf(a,b.from,b.to),c||(c=Nd(a,b)),a.cm?Wd(a.cm,b,d):Hf(a,b,d),Ib(a,c,Dg)}}function Wd(a,b,c){var d=a.doc,e=a.display,f=b.from,g=b.to,h=!1,i=f.line;a.options.lineWrapping||(i=Uf(af(Qf(d,f.line))),d.iter(i,g.line+1,function(a){return a==e.maxLine?(h=!0,!0):void 0})),d.sel.contains(b.from,b.to)>-1&&yg(a),Hf(d,b,c,B(a)),a.options.lineWrapping||(d.iter(i,f.line+b.text.length,function(a){var b=H(a);b>e.maxLineLength&&(e.maxLine=a,e.maxLineLength=b,e.maxLineChanged=!0,h=!1)}),h&&(a.curOp.updateMaxLine=!0)),d.frontier=Math.min(d.frontier,f.line),Tb(a,400);var j=b.text.length-(g.line-f.line)-1;f.line!=g.line||1!=b.text.length||Gf(a.doc,b)?Pc(a,f.line,g.line+1,j):Qc(a,f.line,"text");var k=zg(a,"changes"),l=zg(a,"change");if(l||k){var m={from:f,to:g,text:b.text,removed:b.removed,origin:b.origin};l&&vg(a,"change",a,m),k&&(a.curOp.changeObjs||(a.curOp.changeObjs=[])).push(m)}a.display.selForContextMenu=null}function Xd(a,b,c,d,e){if(d||(d=c),nb(d,c)<0){var f=d;d=c,c=f}"string"==typeof b&&(b=rh(b)),Rd(a,{from:c,to:d,text:b,origin:e})}function Yd(a,b){if(!xg(a,"scrollCursorIntoView")){var c=a.display,d=c.sizer.getBoundingClientRect(),e=null;if(b.top+d.top<0?e=!0:b.bottom+d.top>(window.innerHeight||document.documentElement.clientHeight)&&(e=!1),null!=e&&!m){var f=Yg("div","\u200b",null,"position: absolute; top: "+(b.top-c.viewOffset-Xb(a.display))+"px; height: "+(b.bottom-b.top+Bg)+"px; left: "+b.left+"px; width: 2px;");a.display.lineSpace.appendChild(f),f.scrollIntoView(e),a.display.lineSpace.removeChild(f)}}}function Zd(a,b,c,d){null==d&&(d=0);for(var e=0;5>e;e++){var f=!1,g=qc(a,b),h=c&&c!=b?qc(a,c):g,i=_d(a,Math.min(g.left,h.left),Math.min(g.top,h.top)-d,Math.max(g.left,h.left),Math.max(g.bottom,h.bottom)+d),j=a.doc.scrollTop,k=a.doc.scrollLeft;if(null!=i.scrollTop&&(rd(a,i.scrollTop),Math.abs(a.doc.scrollTop-j)>1&&(f=!0)),null!=i.scrollLeft&&(sd(a,i.scrollLeft),Math.abs(a.doc.scrollLeft-k)>1&&(f=!0)),!f)return g}}function $d(a,b,c,d,e){var f=_d(a,b,c,d,e);null!=f.scrollTop&&rd(a,f.scrollTop),null!=f.scrollLeft&&sd(a,f.scrollLeft)}function _d(a,b,c,d,e){var f=a.display,g=wc(a.display);0>c&&(c=0);var h=a.curOp&&null!=a.curOp.scrollTop?a.curOp.scrollTop:f.scroller.scrollTop,i=f.scroller.clientHeight-Bg,j={};e-c>i&&(e=c+i);var k=a.doc.height+Yb(f),l=g>c,m=e>k-g;if(h>c)j.scrollTop=l?0:c;else if(e>h+i){var n=Math.min(c,(m?k:e)-i);n!=h&&(j.scrollTop=n)}var o=a.curOp&&null!=a.curOp.scrollLeft?a.curOp.scrollLeft:f.scroller.scrollLeft,p=f.scroller.clientWidth-Bg-f.gutters.offsetWidth,q=d-b>p;return q&&(d=b+p),10>b?j.scrollLeft=0:o>b?j.scrollLeft=Math.max(0,b-(q?0:10)):d>p+o-3&&(j.scrollLeft=d+(q?0:10)-p),j}function ae(a,b,c){(null!=b||null!=c)&&ce(a),null!=b&&(a.curOp.scrollLeft=(null==a.curOp.scrollLeft?a.doc.scrollLeft:a.curOp.scrollLeft)+b),null!=c&&(a.curOp.scrollTop=(null==a.curOp.scrollTop?a.doc.scrollTop:a.curOp.scrollTop)+c)}function be(a){ce(a);var b=a.getCursor(),c=b,d=b;a.options.lineWrapping||(c=b.ch?mb(b.line,b.ch-1):b,d=mb(b.line,b.ch+1)),a.curOp.scrollToPos={from:c,to:d,margin:a.options.cursorScrollMargin,isCursor:!0}}function ce(a){var b=a.curOp.scrollToPos;if(b){a.curOp.scrollToPos=null;var c=rc(a,b.from),d=rc(a,b.to),e=_d(a,Math.min(c.left,d.left),Math.min(c.top,d.top)-b.margin,Math.max(c.right,d.right),Math.max(c.bottom,d.bottom)+b.margin);a.scrollTo(e.scrollLeft,e.scrollTop)}}function de(a,b,c,d){var f,e=a.doc;null==c&&(c="add"),"smart"==c&&(e.mode.indent?f=Wb(a,b):c="prev");var g=a.options.tabSize,h=Qf(e,b),i=Hg(h.text,null,g);h.stateAfter&&(h.stateAfter=null);var k,j=h.text.match(/^\s*/)[0];if(d||/\S/.test(h.text)){if("smart"==c&&(k=e.mode.indent(f,h.text.slice(j.length),h.text),k==Cg||k>150)){if(!d)return;c="prev"}}else k=0,c="not";"prev"==c?k=b>e.first?Hg(Qf(e,b-1).text,null,g):0:"add"==c?k=i+a.options.indentUnit:"subtract"==c?k=i-a.options.indentUnit:"number"==typeof c&&(k=i+c),k=Math.max(0,k);var l="",m=0;if(a.options.indentWithTabs)for(var n=Math.floor(k/g);n;--n)m+=g,l+=" ";if(k>m&&(l+=Kg(k-m)),l!=j)Xd(e,l,mb(b,0),mb(b,j.length),"+input");else for(var n=0;n=0;b--)Xd(a.doc,"",d[b].from,d[b].to,"+delete");be(a)})}function ge(a,b,c,d,e){function k(){var b=f+c;return b=a.first+a.size?j=!1:(f=b,i=Qf(a,b))}function l(a){var b=(e?Jh:Kh)(i,g,c,!0);if(null==b){if(a||!k())return j=!1;g=e?(0>c?Bh:Ah)(i):0>c?i.text.length:0}else g=b;return!0}var f=b.line,g=b.ch,h=c,i=Qf(a,f),j=!0;if("char"==d)l();else if("column"==d)l(!0);else if("word"==d||"group"==d)for(var m=null,n="group"==d,o=a.cm&&a.cm.getHelper(b,"wordChars"),p=!0;!(0>c)||l(!p);p=!1){var q=i.text.charAt(g)||"\n",r=Ug(q,o)?"w":n&&"\n"==q?"n":!n||/\s/.test(q)?null:"p";if(!n||p||r||(r="s"),m&&m!=r){0>c&&(c=1,l());break}if(r&&(m=r),c>0&&!l(!p))break}var s=Mb(a,mb(f,g),h,!0);return j||(s.hitSide=!0),s}function he(a,b,c,d){var g,e=a.doc,f=b.left;if("page"==d){var h=Math.min(a.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);g=b.top+c*(h-(0>c?1.5:.5)*wc(a.display))}else"line"==d&&(g=c>0?b.bottom+3:b.top-3);for(;;){var i=tc(a,f,g);if(!i.outside)break;if(0>c?0>=g:g>=e.height){i.hitSide=!0;break}g+=5*c}return i}function ke(a,b,c,d){w.defaults[a]=b,c&&(je[a]=d?function(a,b,d){d!=le&&c(a,b,d)}:c)}function ve(a){for(var c,d,e,f,b=a.split(/-(?!$)/),a=b[b.length-1],g=0;g0||0==g&&f.clearWhenEmpty!==!1)return f;if(f.replacedWith&&(f.collapsed=!0,f.widgetNode=Yg("span",[f.replacedWith],"CodeMirror-widget"),d.handleMouseEvents||(f.widgetNode.ignoreEvents=!0),d.insertLeft&&(f.widgetNode.insertLeft=!0)),f.collapsed){if(_e(a,b.line,b,c,f)||b.line!=c.line&&_e(a,c.line,b,c,f))throw new Error("Inserting collapsed marker partially overlapping an existing one"); +v=!0}f.addToHistory&&ag(a,{from:b,to:c,origin:"markText"},a.sel,0/0);var j,h=b.line,i=a.cm;if(a.iter(h,c.line+1,function(a){i&&f.collapsed&&!i.options.lineWrapping&&af(a)==i.display.maxLine&&(j=!0),f.collapsed&&h!=b.line&&Tf(a,0),Me(a,new Je(f,h==b.line?b.ch:null,h==c.line?c.ch:null)),++h}),f.collapsed&&a.iter(b.line,c.line+1,function(b){ef(a,b)&&Tf(b,0)}),f.clearOnEnter&&rg(f,"beforeCursorEnter",function(){f.clear()}),f.readOnly&&(u=!0,(a.history.done.length||a.history.undone.length)&&a.clearHistory()),f.collapsed&&(f.id=++Ce,f.atomic=!0),i){if(j&&(i.curOp.updateMaxLine=!0),f.collapsed)Pc(i,b.line,c.line+1);else if(f.className||f.title||f.startStyle||f.endStyle)for(var k=b.line;k<=c.line;k++)Qc(i,k,"text");f.atomic&&Kb(i.doc),vg(i,"markerAdded",i,f)}return f}function Fe(a,b,c,d,e){d=Qg(d),d.shared=!1;var f=[De(a,b,c,d,e)],g=f[0],h=d.widgetNode;return Of(a,function(a){h&&(d.widgetNode=h.cloneNode(!0)),f.push(De(a,wb(a,b),wb(a,c),d,e));for(var i=0;i=b:f.to>b);(e||(e=[])).push(new Je(g,f.from,i?null:f.to))}}return e}function Oe(a,b,c){if(a)for(var e,d=0;d=b:f.to>b);if(h||f.from==b&&"bookmark"==g.type&&(!c||f.marker.insertLeft)){var i=null==f.from||(g.inclusiveLeft?f.from<=b:f.from0&&h)for(var l=0;ll;++l)o.push(q);o.push(i)}return o}function Qe(a){for(var b=0;b0)){var k=[i,1],l=nb(j.from,h.from),m=nb(j.to,h.to);(0>l||!g.inclusiveLeft&&!l)&&k.push({from:j.from,to:h.from}),(m>0||!g.inclusiveRight&&!m)&&k.push({from:h.to,to:j.to}),e.splice.apply(e,k),i+=k.length-1}}return e}function Te(a){var b=a.markedSpans;if(b){for(var c=0;c=0&&0>=l||0>=k&&l>=0)&&(0>=k&&(nb(j.to,c)>0||i.marker.inclusiveRight&&e.inclusiveLeft)||k>=0&&(nb(j.from,d)<0||i.marker.inclusiveLeft&&e.inclusiveRight)))return!0}}}function af(a){for(var b;b=Ze(a);)a=b.find(-1,!0).line;return a}function bf(a){for(var b,c;b=$e(a);)a=b.find(1,!0).line,(c||(c=[])).push(a);return c}function cf(a,b){var c=Qf(a,b),d=af(c);return c==d?b:Uf(d)}function df(a,b){if(b>a.lastLine())return b;var d,c=Qf(a,b);if(!ef(a,c))return b;for(;d=$e(c);)c=d.find(1,!0).line;return Uf(c)+1}function ef(a,b){var c=v&&b.markedSpans;if(c)for(var d,e=0;ee;e++){d&&(d[0]=w.innerMode(a,c).mode);var f=a.token(b,c);if(b.pos>b.start)return f}throw new Error("Mode "+a.name+" failed to advance stream.")}function rf(a,b,c,d){function e(a){return{start:k.start,end:k.pos,string:k.current(),type:h||null,state:a?re(f.mode,j):j}}var h,f=a.doc,g=f.mode;b=wb(f,b);var l,i=Qf(f,b.line),j=Wb(a,b.line,c),k=new Ae(i.text,a.options.tabSize);for(d&&(l=[]);(d||k.posa.options.maxHighlightLength?(h=!1,g&&vf(a,b,d,k.pos),k.pos=b.length,l=null):l=of(qf(c,k,d,m),f),m){var n=m[0].name;n&&(l="m-"+(l?n+" "+l:n))}h&&j==l||(ij;){var d=e[i];d>a&&e.splice(i,1,a,e[i+1],d),i+=2,j=Math.min(a,d)}if(b)if(h.opaque)e.splice(c,i-c,a,"cm-overlay "+b),i=c+2;else for(;i>c;c+=2){var f=e[c+1];e[c+1]=(f?f+" ":"")+"cm-overlay "+b}},f)}return{styles:e,classes:f.bgClass||f.textClass?f:null}}function uf(a,b,c){if(!b.styles||b.styles[0]!=a.state.modeGen){var d=tf(a,b,b.stateAfter=Wb(a,Uf(b)));b.styles=d.styles,d.classes?b.styleClasses=d.classes:b.styleClasses&&(b.styleClasses=null),c===a.doc.frontier&&a.doc.frontier++}return b.styles}function vf(a,b,c,d){var e=a.doc.mode,f=new Ae(b,a.options.tabSize);for(f.start=f.pos=d||0,""==b&&pf(e,c);!f.eol()&&f.pos<=a.options.maxHighlightLength;)qf(e,f,c),f.start=f.pos}function yf(a,b){if(!a||/^\s*$/.test(a))return null;var c=b.addModeClass?xf:wf;return c[a]||(c[a]=a.replace(/\S+/g,"cm-$&"))}function zf(a,b){var c=Yg("span",null,null,f?"padding-right: .1px":null),e={pre:Yg("pre",[c]),content:c,col:0,pos:0,cm:a};b.measure={};for(var g=0;g<=(b.rest?b.rest.length:0);g++){var i,h=g?b.rest[g-1]:b.line;e.pos=0,e.addToken=Bf,(d||f)&&a.getOption("lineWrapping")&&(e.addToken=Cf(e.addToken)),qh(a.display.measure)&&(i=Xf(h))&&(e.addToken=Df(e.addToken,i)),e.map=[];var j=b!=a.display.externalMeasured&&Uf(h);Ff(h,e,uf(a,h,j)),h.styleClasses&&(h.styleClasses.bgClass&&(e.bgClass=fh(h.styleClasses.bgClass,e.bgClass||"")),h.styleClasses.textClass&&(e.textClass=fh(h.styleClasses.textClass,e.textClass||""))),0==e.map.length&&e.map.push(0,0,e.content.appendChild(oh(a.display.measure))),0==g?(b.measure.map=e.map,b.measure.cache={}):((b.measure.maps||(b.measure.maps=[])).push(e.map),(b.measure.caches||(b.measure.caches=[])).push({}))}return f&&/\bcm-tab\b/.test(e.content.lastChild.className)&&(e.content.className="cm-tab-wrap-hack"),tg(a,"renderLine",a,b.line,e.pre),e.pre.className&&(e.textClass=fh(e.pre.className,e.textClass||"")),e}function Af(a){var b=Yg("span","\u2022","cm-invalidchar");return b.title="\\u"+a.charCodeAt(0).toString(16),b}function Bf(a,b,c,f,g,h){if(b){var i=a.cm.options.specialChars,j=!1;if(i.test(b))for(var k=document.createDocumentFragment(),l=0;;){i.lastIndex=l;var m=i.exec(b),n=m?m.index-l:b.length-l;if(n){var o=document.createTextNode(b.slice(l,l+n));d&&9>e?k.appendChild(Yg("span",[o])):k.appendChild(o),a.map.push(a.pos,a.pos+n,o),a.col+=n,a.pos+=n}if(!m)break;if(l+=n+1," "==m[0]){var p=a.cm.options.tabSize,q=p-a.col%p,o=k.appendChild(Yg("span",Kg(q),"cm-tab"));a.col+=q}else{var o=a.cm.options.specialCharPlaceholder(m[0]);d&&9>e?k.appendChild(Yg("span",[o])):k.appendChild(o),a.col+=1}a.map.push(a.pos,a.pos+1,o),a.pos++}else{a.col+=b.length;var k=document.createTextNode(b);a.map.push(a.pos,a.pos+b.length,k),d&&9>e&&(j=!0),a.pos+=b.length}if(c||f||g||j){var r=c||"";f&&(r+=f),g&&(r+=g);var s=Yg("span",[k],r);return h&&(s.title=h),a.content.appendChild(s)}a.content.appendChild(k)}}function Cf(a){function b(a){for(var b=" ",c=0;ci&&l.from<=i)break}if(l.to>=j)return a(c,d,e,f,g,h);a(c,d.slice(0,l.to-i),e,f,null,h),f=null,d=d.slice(l.to-i),i=l.to}}}function Ef(a,b,c,d){var e=!d&&c.widgetNode;e&&(a.map.push(a.pos,a.pos+b,e),a.content.appendChild(e)),a.pos+=b}function Ff(a,b,c){var d=a.markedSpans,e=a.text,f=0;if(d)for(var k,m,n,o,p,q,h=e.length,i=0,g=1,j="",l=0;;){if(l==i){m=n=o=p="",q=null,l=1/0;for(var r=[],s=0;si)?(null!=t.to&&l>t.to&&(l=t.to,n=""),u.className&&(m+=" "+u.className),u.startStyle&&t.from==i&&(o+=" "+u.startStyle),u.endStyle&&t.to==l&&(n+=" "+u.endStyle),u.title&&!p&&(p=u.title),u.collapsed&&(!q||Xe(q.marker,u)<0)&&(q=t)):t.from>i&&l>t.from&&(l=t.from),"bookmark"==u.type&&t.from==i&&u.widgetNode&&r.push(u)}if(q&&(q.from||0)==i&&(Ef(b,(null==q.to?h+1:q.to)-i,q.marker,null==q.from),null==q.to))return;if(!q&&r.length)for(var s=0;s=h)break;for(var v=Math.min(h,l);;){if(j){var w=i+j.length;if(!q){var x=w>v?j.slice(0,v-i):j;b.addToken(b,x,k?k+m:m,o,i+x.length==l?n:"",p)}if(w>=v){j=j.slice(v-i),i=v;break}i=w,o=""}j=e.slice(f,f=c[g++]),k=yf(c[g++],b.cm.options)}}else for(var g=1;g1&&a.remove(g.line+1,n-1),a.insert(g.line+1,p)}vg(a,"change",a,b)}function If(a){this.lines=a,this.parent=null;for(var b=0,c=0;bb||b>=a.size)throw new Error("There is no line "+(b+a.first)+" in the document.");for(var c=a;!c.lines;)for(var d=0;;++d){var e=c.children[d],f=e.chunkSize();if(f>b){c=e;break}b-=f}return c.lines[b]}function Rf(a,b,c){var d=[],e=b.line;return a.iter(b.line,c.line+1,function(a){var f=a.text;e==c.line&&(f=f.slice(0,c.ch)),e==b.line&&(f=f.slice(b.ch)),d.push(f),++e}),d}function Sf(a,b,c){var d=[];return a.iter(b,c,function(a){d.push(a.text)}),d}function Tf(a,b){var c=b-a.height;if(c)for(var d=a;d;d=d.parent)d.height+=c}function Uf(a){if(null==a.parent)return null;for(var b=a.parent,c=Ng(b.lines,a),d=b.parent;d;b=d,d=d.parent)for(var e=0;d.children[e]!=b;++e)c+=d.children[e].chunkSize();return c+b.first}function Vf(a,b){var c=a.first;a:do{for(var d=0;db){a=e;continue a}b-=f,c+=e.chunkSize()}return c}while(!a.lines);for(var d=0;db)break;b-=h}return c+d}function Wf(a){a=af(a);for(var b=0,c=a.parent,d=0;d1&&!a.done[a.done.length-2].ranges?(a.done.pop(),Lg(a.done)):void 0}function ag(a,b,c,d){var e=a.history;e.undone.length=0;var g,f=+new Date;if((e.lastOp==d||e.lastOrigin==b.origin&&b.origin&&("+"==b.origin.charAt(0)&&a.cm&&e.lastModTime>f-a.cm.options.historyEventDelay||"*"==b.origin.charAt(0)))&&(g=_f(e,e.lastOp==d))){var h=Lg(g.changes);0==nb(b.from,b.to)&&0==nb(b.from,h.to)?h.to=Ld(b):g.changes.push(Zf(a,b))}else{var i=Lg(e.done);for(i&&i.ranges||dg(a.sel,e.done),g={changes:[Zf(a,b)],generation:e.generation},e.done.push(g);e.done.length>e.undoDepth;)e.done.shift(),e.done[0].ranges||e.done.shift()}e.done.push(c),e.generation=++e.maxGeneration,e.lastModTime=e.lastSelTime=f,e.lastOp=e.lastSelOp=d,e.lastOrigin=e.lastSelOrigin=b.origin,h||tg(a,"historyAdded")}function bg(a,b,c,d){var e=b.charAt(0);return"*"==e||"+"==e&&c.ranges.length==d.ranges.length&&c.somethingSelected()==d.somethingSelected()&&new Date-a.history.lastSelTime<=(a.cm?a.cm.options.historyEventDelay:500)}function cg(a,b,c,d){var e=a.history,f=d&&d.origin;c==e.lastSelOp||f&&e.lastSelOrigin==f&&(e.lastModTime==e.lastSelTime&&e.lastOrigin==f||bg(a,f,Lg(e.done),b))?e.done[e.done.length-1]=b:dg(b,e.done),e.lastSelTime=+new Date,e.lastSelOrigin=f,e.lastSelOp=c,d&&d.clearRedo!==!1&&$f(e.undone)}function dg(a,b){var c=Lg(b);c&&c.ranges&&c.equals(a)||b.push(a)}function eg(a,b,c,d){var e=b["spans_"+a.id],f=0;a.iter(Math.max(a.first,c),Math.min(a.first+a.size,d),function(c){c.markedSpans&&((e||(e=b["spans_"+a.id]={}))[f]=c.markedSpans),++f})}function fg(a){if(!a)return null;for(var c,b=0;b-1&&(Lg(h)[l]=j[l],delete j[l])}}}return e}function ig(a,b,c,d){c0}function Ag(a){a.prototype.on=function(a,b){rg(this,a,b)},a.prototype.off=function(a,b){sg(this,a,b)}}function Gg(){this.id=null}function Ig(a,b,c){for(var d=0,e=0;;){var f=a.indexOf(" ",d);-1==f&&(f=a.length);var g=f-d;if(f==a.length||e+g>=b)return d+Math.min(g,b-e);if(e+=f-d,e+=c-e%c,d=f+1,e>=b)return d}}function Kg(a){for(;Jg.length<=a;)Jg.push(Lg(Jg)+" ");return Jg[a]}function Lg(a){return a[a.length-1]}function Ng(a,b){for(var c=0;c-1&&Tg(a)?!0:b.test(a):Tg(a)}function Vg(a){for(var b in a)if(a.hasOwnProperty(b)&&a[b])return!1;return!0}function Xg(a){return a.charCodeAt(0)>=768&&Wg.test(a)}function Yg(a,b,c,d){var e=document.createElement(a);if(c&&(e.className=c),d&&(e.style.cssText=d),"string"==typeof b)e.appendChild(document.createTextNode(b));else if(b)for(var f=0;f0;--b)a.removeChild(a.firstChild);return a}function _g(a,b){return $g(a).appendChild(b)}function ah(a,b){if(a.contains)return a.contains(b);for(;b=b.parentNode;)if(b==a)return!0}function bh(){return document.activeElement}function ch(a){return new RegExp("(^|\\s)"+a+"(?:$|\\s)\\s*")}function fh(a,b){for(var c=a.split(" "),d=0;d2&&!(d&&8>e))}return nh?Yg("span","\u200b"):Yg("span","\xa0",null,"display: inline-block; width: 1px; margin-right: -1px")}function qh(a){if(null!=ph)return ph;var b=_g(a,document.createTextNode("A\u062eA")),c=Zg(b,0,1).getBoundingClientRect();if(!c||c.left==c.right)return!1;var d=Zg(b,1,2).getBoundingClientRect();return ph=d.right-c.right<3}function vh(a){if(null!=uh)return uh;var b=_g(a,Yg("span","x")),c=b.getBoundingClientRect(),d=Zg(b,0,1).getBoundingClientRect();return uh=Math.abs(c.left-d.left)>1}function xh(a,b,c,d){if(!a)return d(b,c,"ltr");for(var e=!1,f=0;fb||b==c&&g.to==b)&&(d(Math.max(g.from,b),Math.min(g.to,c),1==g.level?"rtl":"ltr"),e=!0)}e||d(b,c,"ltr")}function yh(a){return a.level%2?a.to:a.from}function zh(a){return a.level%2?a.from:a.to}function Ah(a){var b=Xf(a);return b?yh(b[0]):0}function Bh(a){var b=Xf(a);return b?zh(Lg(b)):a.text.length}function Ch(a,b){var c=Qf(a.doc,b),d=af(c);d!=c&&(b=Uf(d));var e=Xf(d),f=e?e[0].level%2?Bh(d):Ah(d):0;return mb(b,f)}function Dh(a,b){for(var c,d=Qf(a.doc,b);c=$e(d);)d=c.find(1,!0).line,b=null;var e=Xf(d),f=e?e[0].level%2?Ah(d):Bh(d):d.text.length;return mb(null==b?Uf(d):b,f)}function Eh(a,b){var c=Ch(a,b.line),d=Qf(a.doc,c.line),e=Xf(d);if(!e||0==e[0].level){var f=Math.max(0,d.text.search(/\S/)),g=b.line==c.line&&b.ch<=f&&b.ch;return mb(c.line,g?0:f)}return c}function Fh(a,b,c){var d=a[0].level;return b==d?!0:c==d?!1:c>b}function Hh(a,b){Gh=null;for(var d,c=0;cb)return c;if(e.from==b||e.to==b){if(null!=d)return Fh(a,e.level,a[d].level)?(e.from!=e.to&&(Gh=d),c):(e.from!=e.to&&(Gh=c),d);d=c}}return d}function Ih(a,b,c,d){if(!d)return b+c;do b+=c;while(b>0&&Xg(a.text.charAt(b)));return b}function Jh(a,b,c,d){var e=Xf(a);if(!e)return Kh(a,b,c,d);for(var f=Hh(e,b),g=e[f],h=Ih(a,b,g.level%2?-c:c,d);;){if(h>g.from&&h0==g.level%2?g.to:g.from);if(g=e[f+=c],!g)return null;h=c>0==g.level%2?Ih(a,g.to,-1,d):Ih(a,g.from,1,d)}}function Kh(a,b,c,d){var e=b+c;if(d)for(;e>0&&Xg(a.text.charAt(e));)e+=c;return 0>e||e>a.text.length?null:e}var a=/gecko\/\d/i.test(navigator.userAgent),b=/MSIE \d/.test(navigator.userAgent),c=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),d=b||c,e=d&&(b?document.documentMode||6:c[1]),f=/WebKit\//.test(navigator.userAgent),g=f&&/Qt\/\d+\.\d+/.test(navigator.userAgent),h=/Chrome\//.test(navigator.userAgent),i=/Opera\//.test(navigator.userAgent),j=/Apple Computer/.test(navigator.vendor),k=/KHTML\//.test(navigator.userAgent),l=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),m=/PhantomJS/.test(navigator.userAgent),n=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),o=n||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),p=n||/Mac/.test(navigator.platform),q=/win/i.test(navigator.platform),r=i&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);r&&(r=Number(r[1])),r&&r>=15&&(i=!1,f=!0);var s=p&&(g||i&&(null==r||12.11>r)),t=a||d&&e>=9,u=!1,v=!1,mb=w.Pos=function(a,b){return this instanceof mb?(this.line=a,this.ch=b,void 0):new mb(a,b)},nb=w.cmpPos=function(a,b){return a.line-b.line||a.ch-b.ch};rb.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(a){if(a==this)return!0;if(a.primIndex!=this.primIndex||a.ranges.length!=this.ranges.length)return!1;for(var b=0;b=0&&nb(a,d.to())<=0)return c}return-1}},sb.prototype={from:function(){return qb(this.anchor,this.head)},to:function(){return pb(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var vc,hd,id,fc={left:0,right:0,top:0,bottom:0},yc=null,zc=0,Yc=null,od=0,td=0,ud=null;d?ud=-.53:a?ud=15:h?ud=-.7:j&&(ud=-1/3);var yd=new Gg,Cd=null,Ld=w.changeEnd=function(a){return a.text?mb(a.from.line+a.text.length-1,Lg(a.text).length+(1==a.text.length?a.from.ch:0)):a.to};w.prototype={constructor:w,focus:function(){window.focus(),_c(this),Xc(this)},setOption:function(a,b){var c=this.options,d=c[a];(c[a]!=b||"mode"==a)&&(c[a]=b,je.hasOwnProperty(a)&&Kc(this,je[a])(this,b,d))},getOption:function(a){return this.options[a]},getDoc:function(){return this.doc},addKeyMap:function(a,b){this.state.keyMaps[b?"push":"unshift"](ze(a))},removeKeyMap:function(a){for(var b=this.state.keyMaps,c=0;cc&&(de(this,e.head.line,a,!0),c=e.head.line,d==this.doc.sel.primIndex&&be(this));else{var f=e.from(),g=e.to(),h=Math.max(c,f.line);c=Math.min(this.lastLine(),g.line-(g.ch?0:1))+1;for(var i=h;c>i;++i)de(this,i,a);var j=this.doc.sel.ranges;0==f.ch&&b.length==j.length&&j[d].from().ch>0&&Db(this.doc,d,new sb(f,j[d].to()),Dg)}}}),getTokenAt:function(a,b){return rf(this,a,b)},getLineTokens:function(a,b){return rf(this,mb(a),b,!0)},getTokenTypeAt:function(a){a=wb(this.doc,a);var f,b=uf(this,Qf(this.doc,a.line)),c=0,d=(b.length-1)/2,e=a.ch;if(0==e)f=b[2];else for(;;){var g=c+d>>1;if((g?b[2*g-1]:0)>=e)d=g;else{if(!(b[2*g+1]h?f:0==h?null:f.slice(0,h-1)},getModeAt:function(a){var b=this.doc.mode;return b.innerMode?w.innerMode(b,this.getTokenAt(a).state).mode:b},getHelper:function(a,b){return this.getHelpers(a,b)[0]},getHelpers:function(a,b){var c=[];if(!qe.hasOwnProperty(b))return qe;var d=qe[b],e=this.getModeAt(a);if("string"==typeof e[b])d[e[b]]&&c.push(d[e[b]]);else if(e[b])for(var f=0;fd&&(a=d,c=!0);var e=Qf(this.doc,a);return nc(this,e,{top:0,left:0},b||"page").top+(c?this.doc.height-Wf(e):0)},defaultTextHeight:function(){return wc(this.display)},defaultCharWidth:function(){return xc(this.display)},setGutterMarker:Lc(function(a,b,c){return ee(this.doc,a,"gutter",function(a){var d=a.gutterMarkers||(a.gutterMarkers={});return d[b]=c,!c&&Vg(d)&&(a.gutterMarkers=null),!0})}),clearGutter:Lc(function(a){var b=this,c=b.doc,d=c.first;c.iter(function(c){c.gutterMarkers&&c.gutterMarkers[a]&&(c.gutterMarkers[a]=null,Qc(b,d,"gutter"),Vg(c.gutterMarkers)&&(c.gutterMarkers=null)),++d})}),addLineWidget:Lc(function(a,b,c){return kf(this,a,b,c)}),removeLineWidget:function(a){a.clear()},lineInfo:function(a){if("number"==typeof a){if(!yb(this.doc,a))return null;var b=a;if(a=Qf(this.doc,a),!a)return null}else{var b=Uf(a);if(null==b)return null}return{line:b,handle:a,text:a.text,gutterMarkers:a.gutterMarkers,textClass:a.textClass,bgClass:a.bgClass,wrapClass:a.wrapClass,widgets:a.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(a,b,c,d,e){var f=this.display;a=qc(this,wb(this.doc,a));var g=a.bottom,h=a.left;if(b.style.position="absolute",f.sizer.appendChild(b),"over"==d)g=a.top;else if("above"==d||"near"==d){var i=Math.max(f.wrapper.clientHeight,this.doc.height),j=Math.max(f.sizer.clientWidth,f.lineSpace.clientWidth); +("above"==d||a.bottom+b.offsetHeight>i)&&a.top>b.offsetHeight?g=a.top-b.offsetHeight:a.bottom+b.offsetHeight<=i&&(g=a.bottom),h+b.offsetWidth>j&&(h=j-b.offsetWidth)}b.style.top=g+"px",b.style.left=b.style.right="","right"==e?(h=f.sizer.clientWidth-b.offsetWidth,b.style.right="0px"):("left"==e?h=0:"middle"==e&&(h=(f.sizer.clientWidth-b.offsetWidth)/2),b.style.left=h+"px"),c&&$d(this,h,g,h+b.offsetWidth,g+b.offsetHeight)},triggerOnKeyDown:Lc(Dd),triggerOnKeyPress:Lc(Gd),triggerOnKeyUp:Fd,execCommand:function(a){return te.hasOwnProperty(a)?te[a](this):void 0},findPosH:function(a,b,c,d){var e=1;0>b&&(e=-1,b=-b);for(var f=0,g=wb(this.doc,a);b>f&&(g=ge(this.doc,g,e,c,d),!g.hitSide);++f);return g},moveH:Lc(function(a,b){var c=this;c.extendSelectionsBy(function(d){return c.display.shift||c.doc.extend||d.empty()?ge(c.doc,d.head,a,b,c.options.rtlMoveVisually):0>a?d.from():d.to()},Fg)}),deleteH:Lc(function(a,b){var c=this.doc.sel,d=this.doc;c.somethingSelected()?d.replaceSelection("",null,"+delete"):fe(this,function(c){var e=ge(d,c.head,a,b,!1);return 0>a?{from:e,to:c.head}:{from:c.head,to:e}})}),findPosV:function(a,b,c,d){var e=1,f=d;0>b&&(e=-1,b=-b);for(var g=0,h=wb(this.doc,a);b>g;++g){var i=qc(this,h,"div");if(null==f?f=i.left:i.left=f,h=he(this,i,e,c),h.hitSide)break}return h},moveV:Lc(function(a,b){var c=this,d=this.doc,e=[],f=!c.display.shift&&!d.extend&&d.sel.somethingSelected();if(d.extendSelectionsBy(function(g){if(f)return 0>a?g.from():g.to();var h=qc(c,g.head,"div");null!=g.goalColumn&&(h.left=g.goalColumn),e.push(h.left);var i=he(c,h,a,b);return"page"==b&&g==d.sel.primary()&&ae(c,null,pc(c,i,"div").top-h.top),i},Fg),e.length)for(var g=0;g0&&h(c.charAt(d-1));)--d;for(;e.5)&&C(this),tg(this,"refresh",this)}),swapDoc:Lc(function(a){var b=this.doc;return b.cm=null,Pf(this,a),kc(this),$c(this),this.scrollTo(a.scrollLeft,a.scrollTop),this.curOp.forceScroll=!0,vg(this,"swapDoc",this,b),b}),getInputField:function(){return this.display.input},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},Ag(w);var ie=w.defaults={},je=w.optionHandlers={},le=w.Init={toString:function(){return"CodeMirror.Init"}};ke("value","",function(a,b){a.setValue(b)},!0),ke("mode",null,function(a,b){a.doc.modeOption=b,y(a)},!0),ke("indentUnit",2,y,!0),ke("indentWithTabs",!1),ke("smartIndent",!0),ke("tabSize",4,function(a){z(a),kc(a),Pc(a)},!0),ke("specialChars",/[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(a,b){a.options.specialChars=new RegExp(b.source+(b.test(" ")?"":"| "),"g"),a.refresh()},!0),ke("specialCharPlaceholder",Af,function(a){a.refresh()},!0),ke("electricChars",!0),ke("rtlMoveVisually",!q),ke("wholeLineUpdateBefore",!0),ke("theme","default",function(a){D(a),E(a)},!0),ke("keyMap","default",function(a,b,c){var d=ze(b),e=c!=w.Init&&ze(c);e&&e.detach&&e.detach(a,d),d.attach&&d.attach(a,e||null)}),ke("extraKeys",null),ke("lineWrapping",!1,A,!0),ke("gutters",[],function(a){J(a.options),E(a)},!0),ke("fixedGutter",!0,function(a,b){a.display.gutters.style.left=b?R(a.display)+"px":"0",a.refresh()},!0),ke("coverGutterNextToScrollbar",!1,M,!0),ke("lineNumbers",!1,function(a){J(a.options),E(a)},!0),ke("firstLineNumber",1,E,!0),ke("lineNumberFormatter",function(a){return a},E,!0),ke("showCursorWhenSelecting",!1,Pb,!0),ke("resetSelectionOnContextMenu",!0),ke("readOnly",!1,function(a,b){"nocursor"==b?(Id(a),a.display.input.blur(),a.display.disabled=!0):(a.display.disabled=!1,b||$c(a))}),ke("disableInput",!1,function(a,b){b||$c(a)},!0),ke("dragDrop",!0),ke("cursorBlinkRate",530),ke("cursorScrollMargin",0),ke("cursorHeight",1,Pb,!0),ke("singleCursorHeightPerLine",!0,Pb,!0),ke("workTime",100),ke("workDelay",100),ke("flattenSpans",!0,z,!0),ke("addModeClass",!1,z,!0),ke("pollInterval",100),ke("undoDepth",200,function(a,b){a.doc.history.undoDepth=b}),ke("historyEventDelay",1250),ke("viewportMargin",10,function(a){a.refresh()},!0),ke("maxHighlightLength",1e4,z,!0),ke("moveInputWithCursor",!0,function(a,b){b||(a.display.inputDiv.style.top=a.display.inputDiv.style.left=0)}),ke("tabindex",null,function(a,b){a.display.input.tabIndex=b||""}),ke("autofocus",null);var me=w.modes={},ne=w.mimeModes={};w.defineMode=function(a,b){w.defaults.mode||"null"==a||(w.defaults.mode=a),arguments.length>2&&(b.dependencies=Array.prototype.slice.call(arguments,2)),me[a]=b},w.defineMIME=function(a,b){ne[a]=b},w.resolveMode=function(a){if("string"==typeof a&&ne.hasOwnProperty(a))a=ne[a];else if(a&&"string"==typeof a.name&&ne.hasOwnProperty(a.name)){var b=ne[a.name];"string"==typeof b&&(b={name:b}),a=Pg(b,a),a.name=b.name}else if("string"==typeof a&&/^[\w\-]+\/[\w\-]+\+xml$/.test(a))return w.resolveMode("application/xml");return"string"==typeof a?{name:a}:a||{name:"null"}},w.getMode=function(a,b){var b=w.resolveMode(b),c=me[b.name];if(!c)return w.getMode(a,"text/plain");var d=c(a,b);if(oe.hasOwnProperty(b.name)){var e=oe[b.name];for(var f in e)e.hasOwnProperty(f)&&(d.hasOwnProperty(f)&&(d["_"+f]=d[f]),d[f]=e[f])}if(d.name=b.name,b.helperType&&(d.helperType=b.helperType),b.modeProps)for(var f in b.modeProps)d[f]=b.modeProps[f];return d},w.defineMode("null",function(){return{token:function(a){a.skipToEnd()}}}),w.defineMIME("text/plain","null");var oe=w.modeExtensions={};w.extendMode=function(a,b){var c=oe.hasOwnProperty(a)?oe[a]:oe[a]={};Qg(b,c)},w.defineExtension=function(a,b){w.prototype[a]=b},w.defineDocExtension=function(a,b){Lf.prototype[a]=b},w.defineOption=ke;var pe=[];w.defineInitHook=function(a){pe.push(a)};var qe=w.helpers={};w.registerHelper=function(a,b,c){qe.hasOwnProperty(a)||(qe[a]=w[a]={_global:[]}),qe[a][b]=c},w.registerGlobalHelper=function(a,b,c,d){w.registerHelper(a,b,d),qe[a]._global.push({pred:c,val:d})};var re=w.copyState=function(a,b){if(b===!0)return b;if(a.copyState)return a.copyState(b);var c={};for(var d in b){var e=b[d];e instanceof Array&&(e=e.concat([])),c[d]=e}return c},se=w.startState=function(a,b,c){return a.startState?a.startState(b,c):!0};w.innerMode=function(a,b){for(;a.innerMode;){var c=a.innerMode(b);if(!c||c.mode==a)break;b=c.state,a=c.mode}return c||{mode:a,state:b}};var te=w.commands={selectAll:function(a){a.setSelection(mb(a.firstLine(),0),mb(a.lastLine()),Dg)},singleSelection:function(a){a.setSelection(a.getCursor("anchor"),a.getCursor("head"),Dg)},killLine:function(a){fe(a,function(b){if(b.empty()){var c=Qf(a.doc,b.head.line).text.length;return b.head.ch==c&&b.head.line0)e=new mb(e.line,e.ch+1),a.replaceRange(f.charAt(e.ch-1)+f.charAt(e.ch-2),mb(e.line,e.ch-2),e,"+transpose");else if(e.line>a.doc.first){var g=Qf(a.doc,e.line-1).text;g&&a.replaceRange(f.charAt(0)+"\n"+g.charAt(g.length-1),mb(e.line-1,g.length-1),mb(e.line,1),"+transpose")}c.push(new sb(e,e))}a.setSelections(c)})},newlineAndIndent:function(a){Jc(a,function(){for(var b=a.listSelections().length,c=0;b>c;c++){var d=a.listSelections()[c];a.replaceRange("\n",d.anchor,d.head,"+input"),a.indentLine(d.from().line+1,null,!0),be(a)}})},toggleOverwrite:function(a){a.toggleOverwrite()}},ue=w.keyMap={};ue.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},ue.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},ue.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars"},ue.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},ue["default"]=p?ue.macDefault:ue.pcDefault,w.normalizeKeyMap=function(a){var b={};for(var c in a)if(a.hasOwnProperty(c)){var d=a[c];if(/^(name|fallthrough|(de|at)tach)$/.test(c))continue;if("..."==d){delete a[c];continue}for(var e=Og(c.split(" "),ve),f=0;f=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){return this.posb},eatSpace:function(){for(var a=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>a},skipToEnd:function(){this.pos=this.string.length},skipTo:function(a){var b=this.string.indexOf(a,this.pos);return b>-1?(this.pos=b,!0):void 0},backUp:function(a){this.pos-=a},column:function(){return this.lastColumnPos0?null:(f&&b!==!1&&(this.pos+=f[0].length),f)}var d=function(a){return c?a.toLowerCase():a},e=this.string.substr(this.pos,a.length);return d(e)==d(a)?(b!==!1&&(this.pos+=a.length),!0):void 0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(a,b){this.lineStart+=a;try{return b()}finally{this.lineStart-=a}}};var Be=w.TextMarker=function(a,b){this.lines=[],this.type=b,this.doc=a};Ag(Be),Be.prototype.clear=function(){if(!this.explicitlyCleared){var a=this.doc.cm,b=a&&!a.curOp;if(b&&Ac(a),zg(this,"clear")){var c=this.find();c&&vg(this,"clear",c.from,c.to)}for(var d=null,e=null,f=0;fa.display.maxLineLength&&(a.display.maxLine=i,a.display.maxLineLength=j,a.display.maxLineChanged=!0)}null!=d&&a&&this.collapsed&&Pc(a,d,e+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,a&&Kb(a.doc)),a&&vg(a,"markerCleared",a,this),b&&Cc(a),this.parent&&this.parent.clear()}},Be.prototype.find=function(a,b){null==a&&"bookmark"==this.type&&(a=1);for(var c,d,e=0;ec;++c){var e=this.lines[c];this.height-=e.height,nf(e),vg(e,"delete")}this.lines.splice(a,b)},collapse:function(a){a.push.apply(a,this.lines)},insertInner:function(a,b,c){this.height+=c,this.lines=this.lines.slice(0,a).concat(b).concat(this.lines.slice(a));for(var d=0;da;++a)if(c(this.lines[a]))return!0}},Jf.prototype={chunkSize:function(){return this.size},removeInner:function(a,b){this.size-=b;for(var c=0;ca){var f=Math.min(b,e-a),g=d.height;if(d.removeInner(a,f),this.height-=g-d.height,e==f&&(this.children.splice(c--,1),d.parent=null),0==(b-=f))break;a=0}else a-=e}if(this.size-b<25&&(this.children.length>1||!(this.children[0]instanceof If))){var h=[];this.collapse(h),this.children=[new If(h)],this.children[0].parent=this}},collapse:function(a){for(var b=0;b=a){if(e.insertInner(a,b,c),e.lines&&e.lines.length>50){for(;e.lines.length>50;){var g=e.lines.splice(e.lines.length-25,25),h=new If(g);e.height-=h.height,this.children.splice(d+1,0,h),h.parent=this}this.maybeSpill()}break}a-=f}},maybeSpill:function(){if(!(this.children.length<=10)){var a=this;do{var b=a.children.splice(a.children.length-5,5),c=new Jf(b);if(a.parent){a.size-=c.size,a.height-=c.height;var e=Ng(a.parent.children,a);a.parent.children.splice(e+1,0,c)}else{var d=new Jf(a.children);d.parent=a,a.children=[d,c],a=d}c.parent=a.parent}while(a.children.length>10);a.parent.maybeSpill()}},iterN:function(a,b,c){for(var d=0;da){var g=Math.min(b,f-a);if(e.iterN(a,g,c))return!0;if(0==(b-=g))break;a=0}else a-=f}}};var Kf=0,Lf=w.Doc=function(a,b,c){if(!(this instanceof Lf))return new Lf(a,b,c);null==c&&(c=0),Jf.call(this,[new If([new lf("",null)])]),this.first=c,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=c;var d=mb(c,0);this.sel=ub(d),this.history=new Yf(null),this.id=++Kf,this.modeOption=b,"string"==typeof a&&(a=rh(a)),Hf(this,{from:d,to:d,text:a}),Hb(this,ub(d),Dg)};Lf.prototype=Pg(Jf.prototype,{constructor:Lf,iter:function(a,b,c){c?this.iterN(a-this.first,b-a,c):this.iterN(this.first,this.first+this.size,a)},insert:function(a,b){for(var c=0,d=0;d=0;f--)Rd(this,d[f]);h?Gb(this,h):this.cm&&be(this.cm)}),undo:Mc(function(){Td(this,"undo")}),redo:Mc(function(){Td(this,"redo")}),undoSelection:Mc(function(){Td(this,"undo",!0)}),redoSelection:Mc(function(){Td(this,"redo",!0)}),setExtending:function(a){this.extend=a},getExtending:function(){return this.extend},historySize:function(){for(var a=this.history,b=0,c=0,d=0;d=a.ch)&&b.push(e.marker.parent||e.marker)}return b},findMarks:function(a,b,c){a=wb(this,a),b=wb(this,b);var d=[],e=a.line;return this.iter(a.line,b.line+1,function(f){var g=f.markedSpans;if(g)for(var h=0;hi.to||null==i.from&&e!=a.line||e==b.line&&i.from>b.ch||c&&!c(i.marker)||d.push(i.marker.parent||i.marker)}++e}),d},getAllMarks:function(){var a=[];return this.iter(function(b){var c=b.markedSpans;if(c)for(var d=0;da?(b=a,!0):(a-=e,++c,void 0)}),wb(this,mb(c,b))},indexFromPos:function(a){a=wb(this,a);var b=a.ch;return a.lineb&&(b=a.from),null!=a.to&&a.toh||h>=b)return g+(b-f);g+=h-f,g+=c-g%c,f=h+1}},Jg=[""],Mg=function(a){a.select()};n?Mg=function(a){a.selectionStart=0,a.selectionEnd=a.value.length}:d&&(Mg=function(a){try{a.select()}catch(b){}}),[].indexOf&&(Ng=function(a,b){return a.indexOf(b)}),[].map&&(Og=function(a,b){return a.map(b)});var Zg,Sg=/[\u00df\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Tg=w.isWordChar=function(a){return/\w/.test(a)||a>"\x80"&&(a.toUpperCase()!=a.toLowerCase()||Sg.test(a))},Wg=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;Zg=document.createRange?function(a,b,c){var d=document.createRange();return d.setEnd(a,c),d.setStart(a,b),d}:function(a,b,c){var d=document.body.createTextRange();try{d.moveToElementText(a.parentNode)}catch(e){return d}return d.collapse(!0),d.moveEnd("character",c),d.moveStart("character",b),d},d&&11>e&&(bh=function(){try{return document.activeElement}catch(a){return document.body}});var lh,nh,ph,dh=w.rmClass=function(a,b){var c=a.className,d=ch(b).exec(c);if(d){var e=c.slice(d.index+d[0].length);a.className=c.slice(0,d.index)+(e?d[1]+e:"")}},eh=w.addClass=function(a,b){var c=a.className;ch(b).test(c)||(a.className+=(c?" ":"")+b)},hh=!1,kh=function(){if(d&&9>e)return!1;var a=Yg("div");return"draggable"in a||"dragDrop"in a}(),rh=w.splitLines=3!="\n\nb".split(/\n/).length?function(a){for(var b=0,c=[],d=a.length;d>=b;){var e=a.indexOf("\n",b);-1==e&&(e=a.length);var f=a.slice(b,"\r"==a.charAt(e-1)?e-1:e),g=f.indexOf("\r");-1!=g?(c.push(f.slice(0,g)),b+=g+1):(c.push(f),b=e+1)}return c}:function(a){return a.split(/\r\n?|\n/)},sh=window.getSelection?function(a){try{return a.selectionStart!=a.selectionEnd}catch(b){return!1}}:function(a){try{var b=a.ownerDocument.selection.createRange()}catch(c){}return b&&b.parentElement()==a?0!=b.compareEndPoints("StartToEnd",b):!1},th=function(){var a=Yg("div");return"oncopy"in a?!0:(a.setAttribute("oncopy","return;"),"function"==typeof a.oncopy)}(),uh=null,wh={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",107:"=",109:"-",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};w.keyNames=wh,function(){for(var a=0;10>a;a++)wh[a+48]=wh[a+96]=String(a);for(var a=65;90>=a;a++)wh[a]=String.fromCharCode(a);for(var a=1;12>=a;a++)wh[a+111]=wh[a+63235]="F"+a}();var Gh,Lh=function(){function c(c){return 247>=c?a.charAt(c):c>=1424&&1524>=c?"R":c>=1536&&1773>=c?b.charAt(c-1536):c>=1774&&2220>=c?"r":c>=8192&&8203>=c?"w":8204==c?"b":"L"}function j(a,b,c){this.level=a,this.from=b,this.to=c}var a="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",b="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",d=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,e=/[stwN]/,f=/[LRr]/,g=/[Lb1n]/,h=/[1n]/,i="L";return function(a){if(!d.test(a))return!1;for(var m,b=a.length,k=[],l=0;b>l;++l)k.push(m=c(a.charCodeAt(l)));for(var l=0,n=i;b>l;++l){var m=k[l];"m"==m?k[l]=n:n=m}for(var l=0,o=i;b>l;++l){var m=k[l];"1"==m&&"r"==o?k[l]="n":f.test(m)&&(o=m,"r"==m&&(k[l]="R"))}for(var l=1,n=k[0];b-1>l;++l){var m=k[l];"+"==m&&"1"==n&&"1"==k[l+1]?k[l]="1":","!=m||n!=k[l+1]||"1"!=n&&"n"!=n||(k[l]=n),n=m}for(var l=0;b>l;++l){var m=k[l];if(","==m)k[l]="N";else if("%"==m){for(var p=l+1;b>p&&"%"==k[p];++p);for(var q=l&&"!"==k[l-1]||b>p&&"1"==k[p]?"1":"N",r=l;p>r;++r)k[r]=q;l=p-1}}for(var l=0,o=i;b>l;++l){var m=k[l];"L"==o&&"1"==m?k[l]="L":f.test(m)&&(o=m)}for(var l=0;b>l;++l)if(e.test(k[l])){for(var p=l+1;b>p&&e.test(k[p]);++p);for(var s="L"==(l?k[l-1]:i),t="L"==(b>p?k[p]:i),q=s||t?"L":"R",r=l;p>r;++r)k[r]=q;l=p-1}for(var v,u=[],l=0;b>l;)if(g.test(k[l])){var w=l;for(++l;b>l&&g.test(k[l]);++l);u.push(new j(0,w,l))}else{var x=l,y=u.length;for(++l;b>l&&"L"!=k[l];++l);for(var r=x;l>r;)if(h.test(k[r])){r>x&&u.splice(y,0,new j(1,x,r));var z=r;for(++r;l>r&&h.test(k[r]);++r);u.splice(y,0,new j(2,z,r)),x=r}else++r;l>x&&u.splice(y,0,new j(1,x,l))}return 1==u[0].level&&(v=a.match(/^\s+/))&&(u[0].from=v[0].length,u.unshift(new j(0,0,v[0].length))),1==Lg(u).level&&(v=a.match(/\s+$/))&&(Lg(u).to-=v[0].length,u.push(new j(0,b-v[0].length,b))),u[0].level!=Lg(u).level&&u.push(new j(u[0].level,b,b)),u}}();return w.version="4.8.0",w}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){function e(a,b,e,g){var h=a.getLineHandle(b.line),i=b.ch-1,j=i>=0&&d[h.text.charAt(i)]||d[h.text.charAt(++i)];if(!j)return null;var k=">"==j.charAt(1)?1:-1;if(e&&k>0!=(i==b.ch))return null;var l=a.getTokenTypeAt(c(b.line,i+1)),m=f(a,c(b.line,i+(k>0?1:0)),k,l||null,g);return null==m?null:{from:c(b.line,i),to:m&&m.pos,match:m&&m.ch==j.charAt(0),forward:k>0}}function f(a,b,e,f,g){for(var h=g&&g.maxScanLineLength||1e4,i=g&&g.maxScanLines||1e3,j=[],k=g&&g.bracketRegex?g.bracketRegex:/[(){}[\]]/,l=e>0?Math.min(b.line+i,a.lastLine()+1):Math.max(a.firstLine()-1,b.line-i),m=b.line;m!=l;m+=e){var n=a.getLine(m);if(n){var o=e>0?0:n.length-1,p=e>0?n.length:-1;if(!(n.length>h))for(m==b.line&&(o=b.ch-(0>e?1:0));o!=p;o+=e){var q=n.charAt(o);if(k.test(q)&&(void 0===f||a.getTokenTypeAt(c(m,o+1))==f)){var r=d[q];if(">"==r.charAt(1)==e>0)j.push(q);else{if(!j.length)return{pos:c(m,o),ch:q};j.pop()}}}}}return m-e==(e>0?a.lastLine():a.firstLine())?!1:null}function g(a,d,f){for(var g=a.state.matchBrackets.maxHighlightLineLength||1e3,h=[],i=a.listSelections(),j=0;j",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"},h=null;a.defineOption("matchBrackets",!1,function(b,c,d){d&&d!=a.Init&&b.off("cursorActivity",i),c&&(b.state.matchBrackets="object"==typeof c?c:{},b.on("cursorActivity",i))}),a.defineExtension("matchBrackets",function(){g(this,!0)}),a.defineExtension("findMatchingBracket",function(a,b,c){return e(this,a,b,c)}),a.defineExtension("scanForBracket",function(a,b,c,d){return f(this,a,b,c,d)})}),function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";function d(a,b){this.cm=a,this.options=this.buildOptions(b),this.widget=this.onClose=null}function e(a){return"string"==typeof a?a:a.text}function f(a,b){function f(a,d){var f;f="string"!=typeof d?function(a){return d(a,b)}:c.hasOwnProperty(d)?c[d]:d,e[a]=f}var c={Up:function(){b.moveFocus(-1)},Down:function(){b.moveFocus(1)},PageUp:function(){b.moveFocus(-b.menuSize()+1,!0)},PageDown:function(){b.moveFocus(b.menuSize()-1,!0)},Home:function(){b.setFocus(0)},End:function(){b.setFocus(b.length-1)},Enter:b.pick,Tab:b.pick,Esc:b.close},d=a.options.customKeys,e=d?{}:c;if(d)for(var g in d)d.hasOwnProperty(g)&&f(g,d[g]);var h=a.options.extraKeys;if(h)for(var g in h)h.hasOwnProperty(g)&&f(g,h[g]);return e}function g(a,b){for(;b&&b!=a;){if("LI"===b.nodeName.toUpperCase()&&b.parentNode==a)return b;b=b.parentNode}}function h(d,h){this.completion=d,this.data=h;var i=this,j=d.cm,k=this.hints=document.createElement("ul");k.className="CodeMirror-hints",this.selectedHint=h.selectedHint||0;for(var l=h.list,m=0;m0){var y=w.bottom-w.top,z=q.top-(q.bottom-w.top);if(z-y>0)k.style.top=(s=q.top-y)+"px",t=!1;else if(y>v){k.style.height=v-5+"px",k.style.top=(s=q.bottom-w.top)+"px";var A=j.getCursor();h.from.ch!=A.ch&&(q=j.cursorCoords(A),k.style.left=(r=q.left)+"px",w=k.getBoundingClientRect())}}var B=w.left-u;if(B>0&&(w.right-w.left>u&&(k.style.width=u-5+"px",B-=w.right-w.left-u),k.style.left=(r=q.left-B)+"px"),j.addKeyMap(this.keyMap=f(d,{moveFocus:function(a,b){i.changeActive(i.selectedHint+a,b)},setFocus:function(a){i.changeActive(a)},menuSize:function(){return i.screenAmount()},length:l.length,close:function(){d.close()},pick:function(){i.pick()},data:h})),d.options.closeOnUnfocus){var C;j.on("blur",this.onBlur=function(){C=setTimeout(function(){d.close()},100)}),j.on("focus",this.onFocus=function(){clearTimeout(C)})}var D=j.getScrollInfo();return j.on("scroll",this.onScroll=function(){var a=j.getScrollInfo(),b=j.getWrapperElement().getBoundingClientRect(),c=s+D.top-a.top,e=c-(window.pageYOffset||(document.documentElement||document.body).scrollTop);return t||(e+=k.offsetHeight),e<=b.top||e>=b.bottom?d.close():(k.style.top=c+"px",k.style.left=r+D.left-a.left+"px",void 0)}),a.on(k,"dblclick",function(a){var b=g(k,a.target||a.srcElement);b&&null!=b.hintId&&(i.changeActive(b.hintId),i.pick())}),a.on(k,"click",function(a){var b=g(k,a.target||a.srcElement);b&&null!=b.hintId&&(i.changeActive(b.hintId),d.options.completeOnSingleClick&&i.pick())}),a.on(k,"mousedown",function(){setTimeout(function(){j.focus()},20)}),a.signal(h,"select",l[0],k.firstChild),!0}var b="CodeMirror-hint",c="CodeMirror-hint-active";a.showHint=function(a,b,c){if(!b)return a.showHint(c);c&&c.async&&(b.async=!0);var d={hint:b};if(c)for(var e in c)d[e]=c[e];return a.showHint(d)},a.defineExtension("showHint",function(b){if(!(this.listSelections().length>1||this.somethingSelected())){this.state.completionActive&&this.state.completionActive.close();var c=this.state.completionActive=new d(this,b),e=c.options.hint;if(e)return a.signal(this,"startCompletion",this),e.async?(e(this,function(a){c.showHints(a)},c.options),void 0):c.showHints(e(this,c.options))}}),d.prototype={close:function(){this.active()&&(this.cm.state.completionActive=null,this.widget&&this.widget.close(),this.onClose&&this.onClose(),a.signal(this.cm,"endCompletion",this.cm))},active:function(){return this.cm.state.completionActive==this},pick:function(b,c){var d=b.list[c];d.hint?d.hint(this.cm,b,d):this.cm.replaceRange(e(d),d.from||b.from,d.to||b.to,"complete"),a.signal(b,"pick",d),this.close()},showHints:function(a){return a&&a.list.length&&this.active()?(this.options.completeSingle&&1==a.list.length?this.pick(a,0):this.showWidget(a),void 0):this.close()},showWidget:function(b){function l(){e||(e=!0,d.close(),d.cm.off("cursorActivity",p),b&&a.signal(b,"close"))}function m(){if(!e){a.signal(b,"update");var c=d.options.hint;c.async?c(d.cm,n,d.options):n(c(d.cm,d.options))}}function n(a){if(b=a,!e){if(!b||!b.list.length)return l();d.widget&&d.widget.close(),d.widget=new h(d,b)}}function o(){c&&(k(c),c=0)}function p(){o();var a=d.cm.getCursor(),b=d.cm.getLine(a.line);a.line!=g.line||b.length-a.ch!=i-g.ch||a.ch=this.data.list.length?b=d?this.data.list.length-1:0:0>b&&(b=d?0:this.data.list.length-1),this.selectedHint!=b){var e=this.hints.childNodes[this.selectedHint];e.className=e.className.replace(" "+c,""),e=this.hints.childNodes[this.selectedHint=b],e.className+=" "+c,e.offsetTopthis.hints.scrollTop+this.hints.clientHeight&&(this.hints.scrollTop=e.offsetTop+e.offsetHeight-this.hints.clientHeight+3),a.signal(this.data,"select",this.data.list[this.selectedHint],e)}},screenAmount:function(){return Math.floor(this.hints.clientHeight/this.hints.firstChild.offsetHeight)||1}},a.registerHelper("hint","auto",function(b,c){var e,d=b.getHelpers(b.getCursor(),"hint");if(d.length)for(var f=0;f,]/,closeOnUnfocus:!0,completeOnSingleClick:!1,container:null,customKeys:null,extraKeys:null};a.defineOption("hintOptions",null)}); \ No newline at end of file diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/lib/codemirror.css b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/lib/codemirror.css old mode 100755 new mode 100644 index 4de1393bea..e2d4ec2048 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/lib/codemirror.css +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/lib/codemirror.css @@ -1,67 +1,97 @@ /* BASICS */ .CodeMirror { - /* Set height, width, borders, and global font properties here */ - font-family: monospace; - height: 300px; + /* Set height, width, borders, and global font properties here */ + font-family: monospace; + height: 300px; } .CodeMirror-scroll { - /* Set scrolling behaviour here */ - overflow: auto; + /* Set scrolling behaviour here */ + overflow: auto; } /* PADDING */ .CodeMirror-lines { - padding: 4px 0; /* Vertical padding around content */ + padding: 4px 0; /* Vertical padding around content */ } .CodeMirror pre { - padding: 0 4px; /* Horizontal padding of content */ + padding: 0 4px; /* Horizontal padding of content */ } .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { - background-color: white; /* The little square between H and V scrollbars */ + background-color: white; /* The little square between H and V scrollbars */ } /* GUTTER */ .CodeMirror-gutters { - border-right: 1px solid #ddd; - background-color: #f7f7f7; - white-space: nowrap; + border-right: 1px solid #ddd; + background-color: #f7f7f7; + white-space: nowrap; } .CodeMirror-linenumbers {} .CodeMirror-linenumber { - padding: 0 3px 0 5px; - min-width: 20px; - text-align: right; - color: #999; - -moz-box-sizing: content-box; - box-sizing: content-box; + padding: 0 3px 0 5px; + min-width: 20px; + text-align: right; + color: #999; + -moz-box-sizing: content-box; + box-sizing: content-box; } +.CodeMirror-guttermarker { color: black; } +.CodeMirror-guttermarker-subtle { color: #999; } + /* CURSOR */ .CodeMirror div.CodeMirror-cursor { - border-left: 1px solid black; + border-left: 1px solid black; } /* Shown when moving in bi-directional text */ .CodeMirror div.CodeMirror-secondarycursor { - border-left: 1px solid silver; + border-left: 1px solid silver; } -.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor { - width: auto; - border: 0; - background: #7e7; +.CodeMirror.cm-fat-cursor div.CodeMirror-cursor { + width: auto; + border: 0; + background: #7e7; } +.CodeMirror.cm-fat-cursor div.CodeMirror-cursors { + z-index: 1; +} + +.cm-animate-fat-cursor { + width: auto; + border: 0; + -webkit-animation: blink 1.06s steps(1) infinite; + -moz-animation: blink 1.06s steps(1) infinite; + animation: blink 1.06s steps(1) infinite; +} +@-moz-keyframes blink { + 0% { background: #7e7; } + 50% { background: none; } + 100% { background: #7e7; } +} +@-webkit-keyframes blink { + 0% { background: #7e7; } + 50% { background: none; } + 100% { background: #7e7; } +} +@keyframes blink { + 0% { background: #7e7; } + 50% { background: none; } + 100% { background: #7e7; } +} + /* Can style cursor different in overwrite (non-insert) mode */ div.CodeMirror-overwrite div.CodeMirror-cursor {} -.cm-tab { display: inline-block; } +.cm-tab { display: inline-block; text-decoration: inherit; } .CodeMirror-ruler { - border-left: 1px solid #ccc; - position: absolute; + border-left: 1px solid #ccc; + position: absolute; } /* DEFAULT THEME */ @@ -70,11 +100,12 @@ div.CodeMirror-overwrite div.CodeMirror-cursor {} .cm-s-default .cm-atom {color: #219;} .cm-s-default .cm-number {color: #164;} .cm-s-default .cm-def {color: #00f;} -.cm-s-default .cm-variable {color: black;} +.cm-s-default .cm-variable, +.cm-s-default .cm-punctuation, +.cm-s-default .cm-property, +.cm-s-default .cm-operator {} .cm-s-default .cm-variable-2 {color: #05a;} .cm-s-default .cm-variable-3 {color: #085;} -.cm-s-default .cm-property {color: black;} -.cm-s-default .cm-operator {color: black;} .cm-s-default .cm-comment {color: #a50;} .cm-s-default .cm-string {color: #a11;} .cm-s-default .cm-string-2 {color: #f50;} @@ -94,12 +125,16 @@ div.CodeMirror-overwrite div.CodeMirror-cursor {} .cm-header, .cm-strong {font-weight: bold;} .cm-em {font-style: italic;} .cm-link {text-decoration: underline;} +.cm-strikethrough {text-decoration: line-through;} .cm-s-default .cm-error {color: #f00;} .cm-invalidchar {color: #f00;} +/* Default styles for common addons */ + div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;} div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;} +.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); } .CodeMirror-activeline-background {background: #e8f2ff;} /* STOP */ @@ -108,152 +143,159 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;} the editor. You probably shouldn't touch them. */ .CodeMirror { - line-height: 1; - position: relative; - overflow: hidden; - background: white; - color: black; + line-height: 1; + position: relative; + overflow: hidden; + background: white; + color: black; } .CodeMirror-scroll { - /* 30px is the magic margin used to hide the element's real scrollbars */ - /* See overflow: hidden in .CodeMirror */ - margin-bottom: -30px; margin-right: -30px; - padding-bottom: 30px; - height: 100%; - outline: none; /* Prevent dragging from highlighting the element */ - position: relative; - -moz-box-sizing: content-box; - box-sizing: content-box; + /* 30px is the magic margin used to hide the element's real scrollbars */ + /* See overflow: hidden in .CodeMirror */ + margin-bottom: -30px; margin-right: -30px; + padding-bottom: 30px; + height: 100%; + outline: none; /* Prevent dragging from highlighting the element */ + position: relative; + -moz-box-sizing: content-box; + box-sizing: content-box; } .CodeMirror-sizer { - position: relative; - border-right: 30px solid transparent; - -moz-box-sizing: content-box; - box-sizing: content-box; + position: relative; + border-right: 30px solid transparent; + -moz-box-sizing: content-box; + box-sizing: content-box; } /* The fake, visible scrollbars. Used to force redraw during scrolling before actuall scrolling happens, thus preventing shaking and flickering artifacts. */ .CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { - position: absolute; - z-index: 6; - display: none; + position: absolute; + z-index: 6; + display: none; } .CodeMirror-vscrollbar { - right: 0; top: 0; - overflow-x: hidden; - overflow-y: scroll; + right: 0; top: 0; + overflow-x: hidden; + overflow-y: scroll; } .CodeMirror-hscrollbar { - bottom: 0; left: 0; - overflow-y: hidden; - overflow-x: scroll; + bottom: 0; left: 0; + overflow-y: hidden; + overflow-x: scroll; } .CodeMirror-scrollbar-filler { - right: 0; bottom: 0; + right: 0; bottom: 0; } .CodeMirror-gutter-filler { - left: 0; bottom: 0; + left: 0; bottom: 0; } .CodeMirror-gutters { - position: absolute; left: 0; top: 0; - padding-bottom: 30px; - z-index: 3; + position: absolute; left: 0; top: 0; + padding-bottom: 30px; + z-index: 3; } .CodeMirror-gutter { - white-space: normal; - height: 100%; - -moz-box-sizing: content-box; - box-sizing: content-box; - padding-bottom: 30px; - margin-bottom: -32px; - display: inline-block; - /* Hack to make IE7 behave */ - *zoom:1; - *display:inline; + white-space: normal; + height: 100%; + -moz-box-sizing: content-box; + box-sizing: content-box; + padding-bottom: 30px; + margin-bottom: -32px; + display: inline-block; + /* Hack to make IE7 behave */ + *zoom:1; + *display:inline; +} +.CodeMirror-gutter-wrapper { + position: absolute; + z-index: 4; + height: 100%; } .CodeMirror-gutter-elt { - position: absolute; - cursor: default; - z-index: 4; + position: absolute; + cursor: default; + z-index: 4; } .CodeMirror-lines { - cursor: text; + cursor: text; + min-height: 1px; /* prevents collapsing before first draw */ } .CodeMirror pre { - /* Reset some styles that the rest of the page might have set */ - -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0; - border-width: 0; - background: transparent; - font-family: inherit; - font-size: inherit; - margin: 0; - white-space: pre; - word-wrap: normal; - line-height: inherit; - color: inherit; - z-index: 2; - position: relative; - overflow: visible; + /* Reset some styles that the rest of the page might have set */ + -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0; + border-width: 0; + background: transparent; + font-family: inherit; + font-size: inherit; + margin: 0; + white-space: pre; + word-wrap: normal; + line-height: inherit; + color: inherit; + z-index: 2; + position: relative; + overflow: visible; } .CodeMirror-wrap pre { - word-wrap: break-word; - white-space: pre-wrap; - word-break: normal; + word-wrap: break-word; + white-space: pre-wrap; + word-break: normal; } .CodeMirror-linebackground { - position: absolute; - left: 0; right: 0; top: 0; bottom: 0; - z-index: 0; + position: absolute; + left: 0; right: 0; top: 0; bottom: 0; + z-index: 0; } .CodeMirror-linewidget { - position: relative; - z-index: 2; - overflow: auto; + position: relative; + z-index: 2; + overflow: auto; } .CodeMirror-widget {} .CodeMirror-wrap .CodeMirror-scroll { - overflow-x: hidden; + overflow-x: hidden; } .CodeMirror-measure { - position: absolute; - width: 100%; - height: 0; - overflow: hidden; - visibility: hidden; + position: absolute; + width: 100%; + height: 0; + overflow: hidden; + visibility: hidden; } .CodeMirror-measure pre { position: static; } .CodeMirror div.CodeMirror-cursor { - position: absolute; - border-right: none; - width: 0; + position: absolute; + border-right: none; + width: 0; } div.CodeMirror-cursors { - visibility: hidden; - position: relative; - z-index: 1; + visibility: hidden; + position: relative; + z-index: 3; } .CodeMirror-focused div.CodeMirror-cursors { - visibility: visible; + visibility: visible; } .CodeMirror-selected { background: #d9d9d9; } .CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; } +.CodeMirror-crosshair { cursor: crosshair; } .cm-searching { - background: #ffa; - background: rgba(255, 255, 0, .4); + background: #ffa; + background: rgba(255, 255, 0, .4); } /* IE7 hack to prevent it from returning funny offsetTops on the spans */ @@ -263,8 +305,14 @@ div.CodeMirror-cursors { .cm-force-border { padding-right: .1px; } @media print { - /* Hide the cursor when printing */ - .CodeMirror div.CodeMirror-cursors { - visibility: hidden; - } + /* Hide the cursor when printing */ + .CodeMirror div.CodeMirror-cursors { + visibility: hidden; + } } + +/* See issue #2901 */ +.cm-tab-wrap-hack:after { content: ''; } + +/* Help users use markselection to safely style text background */ +span.CodeMirror-selectedtext { background: none; } diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/lib/codemirror.js b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/lib/codemirror.js deleted file mode 100755 index a0857200f3..0000000000 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/codemirror/lib/codemirror.js +++ /dev/null @@ -1,8488 +0,0 @@ -// This is CodeMirror (http://codemirror.net), a code editor -// implemented in JavaScript on top of the browser's DOM. -// -// You can find some technical background for some of the code below -// at http://marijnhaverbeke.nl/blog/#cm-internals . - -(function (mod) { - if (typeof exports == "object" && typeof module == "object") // CommonJS - module.exports = mod(); - else if (typeof define == "function" && define.amd) // AMD - return define([], mod); - else // Plain browser env - this.CodeMirror = mod(); -})(function () { - "use strict"; - - // BROWSER SNIFFING - - // Kludges for bugs and behavior differences that can't be feature - // detected are enabled based on userAgent etc sniffing. - - var gecko = /gecko\/\d/i.test(navigator.userAgent); - // ie_uptoN means Internet Explorer version N or lower - var ie_upto10 = /MSIE \d/.test(navigator.userAgent); - var ie_upto7 = ie_upto10 && (document.documentMode == null || document.documentMode < 8); - var ie_upto8 = ie_upto10 && (document.documentMode == null || document.documentMode < 9); - var ie_upto9 = ie_upto10 && (document.documentMode == null || document.documentMode < 10); - var ie_11up = /Trident\/([7-9]|\d{2,})\./.test(navigator.userAgent); - var ie = ie_upto10 || ie_11up; - var webkit = /WebKit\//.test(navigator.userAgent); - var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(navigator.userAgent); - var chrome = /Chrome\//.test(navigator.userAgent); - var presto = /Opera\//.test(navigator.userAgent); - var safari = /Apple Computer/.test(navigator.vendor); - var khtml = /KHTML\//.test(navigator.userAgent); - var mac_geLion = /Mac OS X 1\d\D([7-9]|\d\d)\D/.test(navigator.userAgent); - var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent); - var phantom = /PhantomJS/.test(navigator.userAgent); - - var ios = /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent); - // This is woefully incomplete. Suggestions for alternative methods welcome. - var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent); - var mac = ios || /Mac/.test(navigator.platform); - var windows = /win/i.test(navigator.platform); - - var presto_version = presto && navigator.userAgent.match(/Version\/(\d*\.\d*)/); - if (presto_version) - presto_version = Number(presto_version[1]); - if (presto_version && presto_version >= 15) { - presto = false; - webkit = true; - } - // Some browsers use the wrong event properties to signal cmd/ctrl on OS X - var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11)); - var captureRightClick = gecko || (ie && !ie_upto8); - - // Optimize some code when these features are not used. - var sawReadOnlySpans = false, sawCollapsedSpans = false; - - // EDITOR CONSTRUCTOR - - // A CodeMirror instance represents an editor. This is the object - // that user code is usually dealing with. - - function CodeMirror(place, options) { - if (!(this instanceof CodeMirror)) - return new CodeMirror(place, options); - - this.options = options = options || {}; - // Determine effective options based on given values and defaults. - for (var opt in defaults) - if (!options.hasOwnProperty(opt)) - options[opt] = defaults[opt]; - setGuttersForLineNumbers(options); - - var doc = options.value; - if (typeof doc == "string") - doc = new Doc(doc, options.mode); - this.doc = doc; - - var display = this.display = new Display(place, doc); - display.wrapper.CodeMirror = this; - updateGutters(this); - themeChanged(this); - if (options.lineWrapping) - this.display.wrapper.className += " CodeMirror-wrap"; - if (options.autofocus && !mobile) - focusInput(this); - - this.state = { - keyMaps: [], // stores maps added by addKeyMap - overlays: [], // highlighting overlays, as added by addOverlay - modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info - overwrite: false, focused: false, - suppressEdits: false, // used to disable editing during key handlers when in readOnly mode - pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in readInput - draggingText: false, - highlight: new Delayed() // stores highlight worker timeout - }; - - // Override magic textarea content restore that IE sometimes does - // on our hidden textarea on reload - if (ie_upto10) - setTimeout(bind(resetInput, this, true), 20); - - registerEventHandlers(this); - - var cm = this; - runInOp(this, function () { - cm.curOp.forceUpdate = true; - attachDoc(cm, doc); - - if ((options.autofocus && !mobile) || activeElt() == display.input) - setTimeout(bind(onFocus, cm), 20); - else - onBlur(cm); - - for (var opt in optionHandlers) - if (optionHandlers.hasOwnProperty(opt)) - optionHandlers[opt](cm, options[opt], Init); - for (var i = 0; i < initHooks.length; ++i) - initHooks[i](cm); - }); - } - - // DISPLAY CONSTRUCTOR - - // The display handles the DOM integration, both for input reading - // and content drawing. It holds references to DOM nodes and - // display-related state. - - function Display(place, doc) { - var d = this; - - // The semihidden textarea that is focused when the editor is - // focused, and receives input. - var input = d.input = elt("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none"); - // The textarea is kept positioned near the cursor to prevent the - // fact that it'll be scrolled into view on input from scrolling - // our fake cursor out of view. On webkit, when wrap=off, paste is - // very slow. So make the area wide instead. - if (webkit) - input.style.width = "1000px"; - else - input.setAttribute("wrap", "off"); - // If border: 0; -- iOS fails to open keyboard (issue #1287) - if (ios) - input.style.border = "1px solid black"; - input.setAttribute("autocorrect", "off"); - input.setAttribute("autocapitalize", "off"); - input.setAttribute("spellcheck", "false"); - - // Wraps and hides input textarea - d.inputDiv = elt("div", [input], null, "overflow: hidden; position: relative; width: 3px; height: 0px;"); - // The fake scrollbar elements. - d.scrollbarH = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar"); - d.scrollbarV = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar"); - // Covers bottom-right square when both scrollbars are present. - d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler"); - // Covers bottom of gutter when coverGutterNextToScrollbar is on - // and h scrollbar is present. - d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler"); - // Will contain the actual code, positioned to cover the viewport. - d.lineDiv = elt("div", null, "CodeMirror-code"); - // Elements are added to these to represent selection and cursors. - d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1"); - d.cursorDiv = elt("div", null, "CodeMirror-cursors"); - // A visibility: hidden element used to find the size of things. - d.measure = elt("div", null, "CodeMirror-measure"); - // When lines outside of the viewport are measured, they are drawn in this. - d.lineMeasure = elt("div", null, "CodeMirror-measure"); - // Wraps everything that needs to exist inside the vertically-padded coordinate system - d.lineSpace = elt("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv], - null, "position: relative; outline: none"); - // Moved around its parent to cover visible view. - d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative"); - // Set to the height of the document, allowing scrolling. - d.sizer = elt("div", [d.mover], "CodeMirror-sizer"); - // Behavior of elts with overflow: auto and padding is - // inconsistent across browsers. This is used to ensure the - // scrollable area is big enough. - d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerCutOff + "px; width: 1px;"); - // Will contain the gutters, if any. - d.gutters = elt("div", null, "CodeMirror-gutters"); - d.lineGutter = null; - // Actual scrollable element. - d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll"); - d.scroller.setAttribute("tabIndex", "-1"); - // The element in which the editor lives. - d.wrapper = elt("div", [d.inputDiv, d.scrollbarH, d.scrollbarV, - d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror"); - - // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported) - if (ie_upto7) { - d.gutters.style.zIndex = -1; - d.scroller.style.paddingRight = 0; - } - // Needed to hide big blue blinking cursor on Mobile Safari - if (ios) - input.style.width = "0px"; - if (!webkit) - d.scroller.draggable = true; - // Needed to handle Tab key in KHTML - if (khtml) { - d.inputDiv.style.height = "1px"; - d.inputDiv.style.position = "absolute"; - } - // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8). - if (ie_upto7) - d.scrollbarH.style.minHeight = d.scrollbarV.style.minWidth = "18px"; - - if (place.appendChild) - place.appendChild(d.wrapper); - else - place(d.wrapper); - - // Current rendered range (may be bigger than the view window). - d.viewFrom = d.viewTo = doc.first; - // Information about the rendered lines. - d.view = []; - // Holds info about a single rendered line when it was rendered - // for measurement, while not in view. - d.externalMeasured = null; - // Empty space (in pixels) above the view - d.viewOffset = 0; - d.lastSizeC = 0; - d.updateLineNumbers = null; - - // Used to only resize the line number gutter when necessary (when - // the amount of lines crosses a boundary that makes its width change) - d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null; - // See readInput and resetInput - d.prevInput = ""; - // Set to true when a non-horizontal-scrolling line widget is - // added. As an optimization, line widget aligning is skipped when - // this is false. - d.alignWidgets = false; - // Flag that indicates whether we expect input to appear real soon - // now (after some event like 'keypress' or 'input') and are - // polling intensively. - d.pollingFast = false; - // Self-resetting timeout for the poller - d.poll = new Delayed(); - - d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null; - - // Tracks when resetInput has punted to just putting a short - // string into the textarea instead of the full selection. - d.inaccurateSelection = false; - - // Tracks the maximum line length so that the horizontal scrollbar - // can be kept static when scrolling. - d.maxLine = null; - d.maxLineLength = 0; - d.maxLineChanged = false; - - // Used for measuring wheel scrolling granularity - d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null; - - // True when shift is held down. - d.shift = false; - } - - // STATE UPDATES - - // Used to get the editor into a consistent state again when options change. - - function loadMode(cm) { - cm.doc.mode = CodeMirror.getMode(cm.options, cm.doc.modeOption); - resetModeState(cm); - } - - function resetModeState(cm) { - cm.doc.iter(function (line) { - if (line.stateAfter) - line.stateAfter = null; - if (line.styles) - line.styles = null; - }); - cm.doc.frontier = cm.doc.first; - startWorker(cm, 100); - cm.state.modeGen++; - if (cm.curOp) - regChange(cm); - } - - function wrappingChanged(cm) { - if (cm.options.lineWrapping) { - cm.display.wrapper.className += " CodeMirror-wrap"; - cm.display.sizer.style.minWidth = ""; - } else { - cm.display.wrapper.className = cm.display.wrapper.className.replace(" CodeMirror-wrap", ""); - findMaxLine(cm); - } - estimateLineHeights(cm); - regChange(cm); - clearCaches(cm); - setTimeout(function () { - updateScrollbars(cm); - }, 100); - } - - // Returns a function that estimates the height of a line, to use as - // first approximation until the line becomes visible (and is thus - // properly measurable). - function estimateHeight(cm) { - var th = textHeight(cm.display), wrapping = cm.options.lineWrapping; - var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3); - return function (line) { - if (lineIsHidden(cm.doc, line)) - return 0; - - var widgetsHeight = 0; - if (line.widgets) - for (var i = 0; i < line.widgets.length; i++) { - if (line.widgets[i].height) - widgetsHeight += line.widgets[i].height; - } - - if (wrapping) - return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th; - else - return widgetsHeight + th; - }; - } - - function estimateLineHeights(cm) { - var doc = cm.doc, est = estimateHeight(cm); - doc.iter(function (line) { - var estHeight = est(line); - if (estHeight != line.height) - updateLineHeight(line, estHeight); - }); - } - - function keyMapChanged(cm) { - var map = keyMap[cm.options.keyMap], style = map.style; - cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-keymap-\S+/g, "") + - (style ? " cm-keymap-" + style : ""); - } - - function themeChanged(cm) { - cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") + - cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-"); - clearCaches(cm); - } - - function guttersChanged(cm) { - updateGutters(cm); - regChange(cm); - setTimeout(function () { - alignHorizontally(cm); - }, 20); - } - - // Rebuild the gutter elements, ensure the margin to the left of the - // code matches their width. - function updateGutters(cm) { - var gutters = cm.display.gutters, specs = cm.options.gutters; - removeChildren(gutters); - for (var i = 0; i < specs.length; ++i) { - var gutterClass = specs[i]; - var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + gutterClass)); - if (gutterClass == "CodeMirror-linenumbers") { - cm.display.lineGutter = gElt; - gElt.style.width = (cm.display.lineNumWidth || 1) + "px"; - } - } - gutters.style.display = i ? "" : "none"; - var width = gutters.offsetWidth; - cm.display.sizer.style.marginLeft = width + "px"; - if (i) - cm.display.scrollbarH.style.left = cm.options.fixedGutter ? width + "px" : 0; - } - - // Compute the character length of a line, taking into account - // collapsed ranges (see markText) that might hide parts, and join - // other lines onto it. - function lineLength(line) { - if (line.height == 0) - return 0; - var len = line.text.length, merged, cur = line; - while (merged = collapsedSpanAtStart(cur)) { - var found = merged.find(0, true); - cur = found.from.line; - len += found.from.ch - found.to.ch; - } - cur = line; - while (merged = collapsedSpanAtEnd(cur)) { - var found = merged.find(0, true); - len -= cur.text.length - found.from.ch; - cur = found.to.line; - len += cur.text.length - found.to.ch; - } - return len; - } - - // Find the longest line in the document. - function findMaxLine(cm) { - var d = cm.display, doc = cm.doc; - d.maxLine = getLine(doc, doc.first); - d.maxLineLength = lineLength(d.maxLine); - d.maxLineChanged = true; - doc.iter(function (line) { - var len = lineLength(line); - if (len > d.maxLineLength) { - d.maxLineLength = len; - d.maxLine = line; - } - }); - } - - // Make sure the gutters options contains the element - // "CodeMirror-linenumbers" when the lineNumbers option is true. - function setGuttersForLineNumbers(options) { - var found = indexOf(options.gutters, "CodeMirror-linenumbers"); - if (found == -1 && options.lineNumbers) { - options.gutters = options.gutters.concat(["CodeMirror-linenumbers"]); - } else if (found > -1 && !options.lineNumbers) { - options.gutters = options.gutters.slice(0); - options.gutters.splice(found, 1); - } - } - - // SCROLLBARS - - // Prepare DOM reads needed to update the scrollbars. Done in one - // shot to minimize update/measure roundtrips. - function measureForScrollbars(cm) { - var scroll = cm.display.scroller; - return { - clientHeight: scroll.clientHeight, - barHeight: cm.display.scrollbarV.clientHeight, - scrollWidth: scroll.scrollWidth, clientWidth: scroll.clientWidth, - barWidth: cm.display.scrollbarH.clientWidth, - docHeight: Math.round(cm.doc.height + paddingVert(cm.display)) - }; - } - - // Re-synchronize the fake scrollbars with the actual size of the - // content. - function updateScrollbars(cm, measure) { - if (!measure) - measure = measureForScrollbars(cm); - var d = cm.display; - var scrollHeight = measure.docHeight + scrollerCutOff; - var needsH = measure.scrollWidth > measure.clientWidth; - var needsV = scrollHeight > measure.clientHeight; - if (needsV) { - d.scrollbarV.style.display = "block"; - d.scrollbarV.style.bottom = needsH ? scrollbarWidth(d.measure) + "px" : "0"; - // A bug in IE8 can cause this value to be negative, so guard it. - d.scrollbarV.firstChild.style.height = - Math.max(0, scrollHeight - measure.clientHeight + (measure.barHeight || d.scrollbarV.clientHeight)) + "px"; - } else { - d.scrollbarV.style.display = ""; - d.scrollbarV.firstChild.style.height = "0"; - } - if (needsH) { - d.scrollbarH.style.display = "block"; - d.scrollbarH.style.right = needsV ? scrollbarWidth(d.measure) + "px" : "0"; - d.scrollbarH.firstChild.style.width = - (measure.scrollWidth - measure.clientWidth + (measure.barWidth || d.scrollbarH.clientWidth)) + "px"; - } else { - d.scrollbarH.style.display = ""; - d.scrollbarH.firstChild.style.width = "0"; - } - if (needsH && needsV) { - d.scrollbarFiller.style.display = "block"; - d.scrollbarFiller.style.height = d.scrollbarFiller.style.width = scrollbarWidth(d.measure) + "px"; - } else - d.scrollbarFiller.style.display = ""; - if (needsH && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) { - d.gutterFiller.style.display = "block"; - d.gutterFiller.style.height = scrollbarWidth(d.measure) + "px"; - d.gutterFiller.style.width = d.gutters.offsetWidth + "px"; - } else - d.gutterFiller.style.display = ""; - - if (mac_geLion && scrollbarWidth(d.measure) === 0) { - d.scrollbarV.style.minWidth = d.scrollbarH.style.minHeight = mac_geMountainLion ? "18px" : "12px"; - var barMouseDown = function (e) { - if (e_target(e) != d.scrollbarV && e_target(e) != d.scrollbarH) - operation(cm, onMouseDown)(e); - }; - on(d.scrollbarV, "mousedown", barMouseDown); - on(d.scrollbarH, "mousedown", barMouseDown); - } - } - - // Compute the lines that are visible in a given viewport (defaults - // the the current scroll position). viewPort may contain top, - // height, and ensure (see op.scrollToPos) properties. - function visibleLines(display, doc, viewPort) { - var top = viewPort && viewPort.top != null ? viewPort.top : display.scroller.scrollTop; - top = Math.floor(top - paddingTop(display)); - var bottom = viewPort && viewPort.bottom != null ? viewPort.bottom : top + display.wrapper.clientHeight; - - var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom); - // Ensure is a {from: {line, ch}, to: {line, ch}} object, and - // forces those lines into the viewport (if possible). - if (viewPort && viewPort.ensure) { - var ensureFrom = viewPort.ensure.from.line, ensureTo = viewPort.ensure.to.line; - if (ensureFrom < from) - return {from: ensureFrom, - to: lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight)}; - if (Math.min(ensureTo, doc.lastLine()) >= to) - return {from: lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight), - to: ensureTo}; - } - return {from: from, to: to}; - } - - // LINE NUMBERS - - // Re-align line numbers and gutter marks to compensate for - // horizontal scrolling. - function alignHorizontally(cm) { - var display = cm.display, view = display.view; - if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) - return; - var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft; - var gutterW = display.gutters.offsetWidth, left = comp + "px"; - for (var i = 0; i < view.length; i++) - if (!view[i].hidden) { - if (cm.options.fixedGutter && view[i].gutter) - view[i].gutter.style.left = left; - var align = view[i].alignable; - if (align) - for (var j = 0; j < align.length; j++) - align[j].style.left = left; - } - if (cm.options.fixedGutter) - display.gutters.style.left = (comp + gutterW) + "px"; - } - - // Used to ensure that the line number gutter is still the right - // size for the current document size. Returns true when an update - // is needed. - function maybeUpdateLineNumberWidth(cm) { - if (!cm.options.lineNumbers) - return false; - var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display; - if (last.length != display.lineNumChars) { - var test = display.measure.appendChild(elt("div", [elt("div", last)], - "CodeMirror-linenumber CodeMirror-gutter-elt")); - var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW; - display.lineGutter.style.width = ""; - display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding); - display.lineNumWidth = display.lineNumInnerWidth + padding; - display.lineNumChars = display.lineNumInnerWidth ? last.length : -1; - display.lineGutter.style.width = display.lineNumWidth + "px"; - var width = display.gutters.offsetWidth; - display.scrollbarH.style.left = cm.options.fixedGutter ? width + "px" : 0; - display.sizer.style.marginLeft = width + "px"; - return true; - } - return false; - } - - function lineNumberFor(options, i) { - return String(options.lineNumberFormatter(i + options.firstLineNumber)); - } - - // Computes display.scroller.scrollLeft + display.gutters.offsetWidth, - // but using getBoundingClientRect to get a sub-pixel-accurate - // result. - function compensateForHScroll(display) { - return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left; - } - - // DISPLAY DRAWING - - // Updates the display, selection, and scrollbars, using the - // information in display.view to find out which nodes are no longer - // up-to-date. Tries to bail out early when no changes are needed, - // unless forced is true. - // Returns true if an actual update happened, false otherwise. - function updateDisplay(cm, viewPort, forced) { - var oldFrom = cm.display.viewFrom, oldTo = cm.display.viewTo, updated; - var visible = visibleLines(cm.display, cm.doc, viewPort); - for (var first = true; ; first = false) { - var oldWidth = cm.display.scroller.clientWidth; - if (!updateDisplayInner(cm, visible, forced)) - break; - updated = true; - - // If the max line changed since it was last measured, measure it, - // and ensure the document's width matches it. - if (cm.display.maxLineChanged && !cm.options.lineWrapping) - adjustContentWidth(cm); - - var barMeasure = measureForScrollbars(cm); - updateSelection(cm); - setDocumentHeight(cm, barMeasure); - updateScrollbars(cm, barMeasure); - if (first && cm.options.lineWrapping && oldWidth != cm.display.scroller.clientWidth) { - forced = true; - continue; - } - forced = false; - - // Clip forced viewport to actual scrollable area. - if (viewPort && viewPort.top != null) - viewPort = {top: Math.min(barMeasure.docHeight - scrollerCutOff - barMeasure.clientHeight, viewPort.top)}; - // Updated line heights might result in the drawn area not - // actually covering the viewport. Keep looping until it does. - visible = visibleLines(cm.display, cm.doc, viewPort); - if (visible.from >= cm.display.viewFrom && visible.to <= cm.display.viewTo) - break; - } - - cm.display.updateLineNumbers = null; - if (updated) { - signalLater(cm, "update", cm); - if (cm.display.viewFrom != oldFrom || cm.display.viewTo != oldTo) - signalLater(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo); - } - return updated; - } - - // Does the actual updating of the line display. Bails out - // (returning false) when there is nothing to be done and forced is - // false. - function updateDisplayInner(cm, visible, forced) { - var display = cm.display, doc = cm.doc; - if (!display.wrapper.offsetWidth) { - resetView(cm); - return; - } - - // Bail out if the visible area is already rendered and nothing changed. - if (!forced && visible.from >= display.viewFrom && visible.to <= display.viewTo && - countDirtyView(cm) == 0) - return; - - if (maybeUpdateLineNumberWidth(cm)) - resetView(cm); - var dims = getDimensions(cm); - - // Compute a suitable new viewport (from & to) - var end = doc.first + doc.size; - var from = Math.max(visible.from - cm.options.viewportMargin, doc.first); - var to = Math.min(end, visible.to + cm.options.viewportMargin); - if (display.viewFrom < from && from - display.viewFrom < 20) - from = Math.max(doc.first, display.viewFrom); - if (display.viewTo > to && display.viewTo - to < 20) - to = Math.min(end, display.viewTo); - if (sawCollapsedSpans) { - from = visualLineNo(cm.doc, from); - to = visualLineEndNo(cm.doc, to); - } - - var different = from != display.viewFrom || to != display.viewTo || - display.lastSizeC != display.wrapper.clientHeight; - adjustView(cm, from, to); - - display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom)); - // Position the mover div to align with the current scroll position - cm.display.mover.style.top = display.viewOffset + "px"; - - var toUpdate = countDirtyView(cm); - if (!different && toUpdate == 0 && !forced) - return; - - // For big changes, we hide the enclosing element during the - // update, since that speeds up the operations on most browsers. - var focused = activeElt(); - if (toUpdate > 4) - display.lineDiv.style.display = "none"; - patchDisplay(cm, display.updateLineNumbers, dims); - if (toUpdate > 4) - display.lineDiv.style.display = ""; - // There might have been a widget with a focused element that got - // hidden or updated, if so re-focus it. - if (focused && activeElt() != focused && focused.offsetHeight) - focused.focus(); - - // Prevent selection and cursors from interfering with the scroll - // width. - removeChildren(display.cursorDiv); - removeChildren(display.selectionDiv); - - if (different) { - display.lastSizeC = display.wrapper.clientHeight; - startWorker(cm, 400); - } - - updateHeightsInViewport(cm); - - return true; - } - - function adjustContentWidth(cm) { - var display = cm.display; - var width = measureChar(cm, display.maxLine, display.maxLine.text.length).left; - display.maxLineChanged = false; - var minWidth = Math.max(0, width + 3); - var maxScrollLeft = Math.max(0, display.sizer.offsetLeft + minWidth + scrollerCutOff - display.scroller.clientWidth); - display.sizer.style.minWidth = minWidth + "px"; - if (maxScrollLeft < cm.doc.scrollLeft) - setScrollLeft(cm, Math.min(display.scroller.scrollLeft, maxScrollLeft), true); - } - - function setDocumentHeight(cm, measure) { - cm.display.sizer.style.minHeight = cm.display.heightForcer.style.top = measure.docHeight + "px"; - cm.display.gutters.style.height = Math.max(measure.docHeight, measure.clientHeight - scrollerCutOff) + "px"; - } - - // Read the actual heights of the rendered lines, and update their - // stored heights to match. - function updateHeightsInViewport(cm) { - var display = cm.display; - var prevBottom = display.lineDiv.offsetTop; - for (var i = 0; i < display.view.length; i++) { - var cur = display.view[i], height; - if (cur.hidden) - continue; - if (ie_upto7) { - var bot = cur.node.offsetTop + cur.node.offsetHeight; - height = bot - prevBottom; - prevBottom = bot; - } else { - var box = cur.node.getBoundingClientRect(); - height = box.bottom - box.top; - } - var diff = cur.line.height - height; - if (height < 2) - height = textHeight(display); - if (diff > .001 || diff < -.001) { - updateLineHeight(cur.line, height); - updateWidgetHeight(cur.line); - if (cur.rest) - for (var j = 0; j < cur.rest.length; j++) - updateWidgetHeight(cur.rest[j]); - } - } - } - - // Read and store the height of line widgets associated with the - // given line. - function updateWidgetHeight(line) { - if (line.widgets) - for (var i = 0; i < line.widgets.length; ++i) - line.widgets[i].height = line.widgets[i].node.offsetHeight; - } - - // Do a bulk-read of the DOM positions and sizes needed to draw the - // view, so that we don't interleave reading and writing to the DOM. - function getDimensions(cm) { - var d = cm.display, left = {}, width = {}; - for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) { - left[cm.options.gutters[i]] = n.offsetLeft; - width[cm.options.gutters[i]] = n.offsetWidth; - } - return {fixedPos: compensateForHScroll(d), - gutterTotalWidth: d.gutters.offsetWidth, - gutterLeft: left, - gutterWidth: width, - wrapperWidth: d.wrapper.clientWidth}; - } - - // Sync the actual display DOM structure with display.view, removing - // nodes for lines that are no longer in view, and creating the ones - // that are not there yet, and updating the ones that are out of - // date. - function patchDisplay(cm, updateNumbersFrom, dims) { - var display = cm.display, lineNumbers = cm.options.lineNumbers; - var container = display.lineDiv, cur = container.firstChild; - - function rm(node) { - var next = node.nextSibling; - // Works around a throw-scroll bug in OS X Webkit - if (webkit && mac && cm.display.currentWheelTarget == node) - node.style.display = "none"; - else - node.parentNode.removeChild(node); - return next; - } - - var view = display.view, lineN = display.viewFrom; - // Loop over the elements in the view, syncing cur (the DOM nodes - // in display.lineDiv) with the view as we go. - for (var i = 0; i < view.length; i++) { - var lineView = view[i]; - if (lineView.hidden) { - } else if (!lineView.node) { // Not drawn yet - var node = buildLineElement(cm, lineView, lineN, dims); - container.insertBefore(node, cur); - } else { // Already drawn - while (cur != lineView.node) - cur = rm(cur); - var updateNumber = lineNumbers && updateNumbersFrom != null && - updateNumbersFrom <= lineN && lineView.lineNumber; - if (lineView.changes) { - if (indexOf(lineView.changes, "gutter") > -1) - updateNumber = false; - updateLineForChanges(cm, lineView, lineN, dims); - } - if (updateNumber) { - removeChildren(lineView.lineNumber); - lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN))); - } - cur = lineView.node.nextSibling; - } - lineN += lineView.size; - } - while (cur) - cur = rm(cur); - } - - // When an aspect of a line changes, a string is added to - // lineView.changes. This updates the relevant part of the line's - // DOM structure. - function updateLineForChanges(cm, lineView, lineN, dims) { - for (var j = 0; j < lineView.changes.length; j++) { - var type = lineView.changes[j]; - if (type == "text") - updateLineText(cm, lineView); - else if (type == "gutter") - updateLineGutter(cm, lineView, lineN, dims); - else if (type == "class") - updateLineClasses(lineView); - else if (type == "widget") - updateLineWidgets(lineView, dims); - } - lineView.changes = null; - } - - // Lines with gutter elements, widgets or a background class need to - // be wrapped, and have the extra elements added to the wrapper div - function ensureLineWrapped(lineView) { - if (lineView.node == lineView.text) { - lineView.node = elt("div", null, null, "position: relative"); - if (lineView.text.parentNode) - lineView.text.parentNode.replaceChild(lineView.node, lineView.text); - lineView.node.appendChild(lineView.text); - if (ie_upto7) - lineView.node.style.zIndex = 2; - } - return lineView.node; - } - - function updateLineBackground(lineView) { - var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass; - if (cls) - cls += " CodeMirror-linebackground"; - if (lineView.background) { - if (cls) - lineView.background.className = cls; - else { - lineView.background.parentNode.removeChild(lineView.background); - lineView.background = null; - } - } else if (cls) { - var wrap = ensureLineWrapped(lineView); - lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild); - } - } - - // Wrapper around buildLineContent which will reuse the structure - // in display.externalMeasured when possible. - function getLineContent(cm, lineView) { - var ext = cm.display.externalMeasured; - if (ext && ext.line == lineView.line) { - cm.display.externalMeasured = null; - lineView.measure = ext.measure; - return ext.built; - } - return buildLineContent(cm, lineView); - } - - // Redraw the line's text. Interacts with the background and text - // classes because the mode may output tokens that influence these - // classes. - function updateLineText(cm, lineView) { - var cls = lineView.text.className; - var built = getLineContent(cm, lineView); - if (lineView.text == lineView.node) - lineView.node = built.pre; - lineView.text.parentNode.replaceChild(built.pre, lineView.text); - lineView.text = built.pre; - if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) { - lineView.bgClass = built.bgClass; - lineView.textClass = built.textClass; - updateLineClasses(lineView); - } else if (cls) { - lineView.text.className = cls; - } - } - - function updateLineClasses(lineView) { - updateLineBackground(lineView); - if (lineView.line.wrapClass) - ensureLineWrapped(lineView).className = lineView.line.wrapClass; - else if (lineView.node != lineView.text) - lineView.node.className = ""; - var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass; - lineView.text.className = textClass || ""; - } - - function updateLineGutter(cm, lineView, lineN, dims) { - if (lineView.gutter) { - lineView.node.removeChild(lineView.gutter); - lineView.gutter = null; - } - var markers = lineView.line.gutterMarkers; - if (cm.options.lineNumbers || markers) { - var wrap = ensureLineWrapped(lineView); - var gutterWrap = lineView.gutter = - wrap.insertBefore(elt("div", null, "CodeMirror-gutter-wrapper", "position: absolute; left: " + - (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px"), - lineView.text); - if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"])) - lineView.lineNumber = gutterWrap.appendChild( - elt("div", lineNumberFor(cm.options, lineN), - "CodeMirror-linenumber CodeMirror-gutter-elt", - "left: " + dims.gutterLeft["CodeMirror-linenumbers"] + "px; width: " - + cm.display.lineNumInnerWidth + "px")); - if (markers) - for (var k = 0; k < cm.options.gutters.length; ++k) { - var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id]; - if (found) - gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", "left: " + - dims.gutterLeft[id] + "px; width: " + dims.gutterWidth[id] + "px")); - } - } - } - - function updateLineWidgets(lineView, dims) { - if (lineView.alignable) - lineView.alignable = null; - for (var node = lineView.node.firstChild, next; node; node = next) { - var next = node.nextSibling; - if (node.className == "CodeMirror-linewidget") - lineView.node.removeChild(node); - } - insertLineWidgets(lineView, dims); - } - - // Build a line's DOM representation from scratch - function buildLineElement(cm, lineView, lineN, dims) { - var built = getLineContent(cm, lineView); - lineView.text = lineView.node = built.pre; - if (built.bgClass) - lineView.bgClass = built.bgClass; - if (built.textClass) - lineView.textClass = built.textClass; - - updateLineClasses(lineView); - updateLineGutter(cm, lineView, lineN, dims); - insertLineWidgets(lineView, dims); - return lineView.node; - } - - // A lineView may contain multiple logical lines (when merged by - // collapsed spans). The widgets for all of them need to be drawn. - function insertLineWidgets(lineView, dims) { - insertLineWidgetsFor(lineView.line, lineView, dims, true); - if (lineView.rest) - for (var i = 0; i < lineView.rest.length; i++) - insertLineWidgetsFor(lineView.rest[i], lineView, dims, false); - } - - function insertLineWidgetsFor(line, lineView, dims, allowAbove) { - if (!line.widgets) - return; - var wrap = ensureLineWrapped(lineView); - for (var i = 0, ws = line.widgets; i < ws.length; ++i) { - var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget"); - if (!widget.handleMouseEvents) - node.ignoreEvents = true; - positionLineWidget(widget, node, lineView, dims); - if (allowAbove && widget.above) - wrap.insertBefore(node, lineView.gutter || lineView.text); - else - wrap.appendChild(node); - signalLater(widget, "redraw"); - } - } - - function positionLineWidget(widget, node, lineView, dims) { - if (widget.noHScroll) { - (lineView.alignable || (lineView.alignable = [])).push(node); - var width = dims.wrapperWidth; - node.style.left = dims.fixedPos + "px"; - if (!widget.coverGutter) { - width -= dims.gutterTotalWidth; - node.style.paddingLeft = dims.gutterTotalWidth + "px"; - } - node.style.width = width + "px"; - } - if (widget.coverGutter) { - node.style.zIndex = 5; - node.style.position = "relative"; - if (!widget.noHScroll) - node.style.marginLeft = -dims.gutterTotalWidth + "px"; - } - } - - // POSITION OBJECT - - // A Pos instance represents a position within the text. - var Pos = CodeMirror.Pos = function (line, ch) { - if (!(this instanceof Pos)) - return new Pos(line, ch); - this.line = line; - this.ch = ch; - }; - - // Compare two positions, return 0 if they are the same, a negative - // number when a is less, and a positive number otherwise. - var cmp = CodeMirror.cmpPos = function (a, b) { - return a.line - b.line || a.ch - b.ch; - }; - - function copyPos(x) { - return Pos(x.line, x.ch); - } - function maxPos(a, b) { - return cmp(a, b) < 0 ? b : a; - } - function minPos(a, b) { - return cmp(a, b) < 0 ? a : b; - } - - // SELECTION / CURSOR - - // Selection objects are immutable. A new one is created every time - // the selection changes. A selection is one or more non-overlapping - // (and non-touching) ranges, sorted, and an integer that indicates - // which one is the primary selection (the one that's scrolled into - // view, that getCursor returns, etc). - function Selection(ranges, primIndex) { - this.ranges = ranges; - this.primIndex = primIndex; - } - - Selection.prototype = { - primary: function () { - return this.ranges[this.primIndex]; - }, - equals: function (other) { - if (other == this) - return true; - if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) - return false; - for (var i = 0; i < this.ranges.length; i++) { - var here = this.ranges[i], there = other.ranges[i]; - if (cmp(here.anchor, there.anchor) != 0 || cmp(here.head, there.head) != 0) - return false; - } - return true; - }, - deepCopy: function () { - for (var out = [], i = 0; i < this.ranges.length; i++) - out[i] = new Range(copyPos(this.ranges[i].anchor), copyPos(this.ranges[i].head)); - return new Selection(out, this.primIndex); - }, - somethingSelected: function () { - for (var i = 0; i < this.ranges.length; i++) - if (!this.ranges[i].empty()) - return true; - return false; - }, - contains: function (pos, end) { - if (!end) - end = pos; - for (var i = 0; i < this.ranges.length; i++) { - var range = this.ranges[i]; - if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0) - return i; - } - return -1; - } - }; - - function Range(anchor, head) { - this.anchor = anchor; - this.head = head; - } - - Range.prototype = { - from: function () { - return minPos(this.anchor, this.head); - }, - to: function () { - return maxPos(this.anchor, this.head); - }, - empty: function () { - return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch; - } - }; - - // Take an unsorted, potentially overlapping set of ranges, and - // build a selection out of it. 'Consumes' ranges array (modifying - // it). - function normalizeSelection(ranges, primIndex) { - var prim = ranges[primIndex]; - ranges.sort(function (a, b) { - return cmp(a.from(), b.from()); - }); - primIndex = indexOf(ranges, prim); - for (var i = 1; i < ranges.length; i++) { - var cur = ranges[i], prev = ranges[i - 1]; - if (cmp(prev.to(), cur.from()) >= 0) { - var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to()); - var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head; - if (i <= primIndex) - --primIndex; - ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to)); - } - } - return new Selection(ranges, primIndex); - } - - function simpleSelection(anchor, head) { - return new Selection([new Range(anchor, head || anchor)], 0); - } - - // Most of the external API clips given positions to make sure they - // actually exist within the document. - function clipLine(doc, n) { - return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1)); - } - function clipPos(doc, pos) { - if (pos.line < doc.first) - return Pos(doc.first, 0); - var last = doc.first + doc.size - 1; - if (pos.line > last) - return Pos(last, getLine(doc, last).text.length); - return clipToLen(pos, getLine(doc, pos.line).text.length); - } - function clipToLen(pos, linelen) { - var ch = pos.ch; - if (ch == null || ch > linelen) - return Pos(pos.line, linelen); - else if (ch < 0) - return Pos(pos.line, 0); - else - return pos; - } - function isLine(doc, l) { - return l >= doc.first && l < doc.first + doc.size; - } - function clipPosArray(doc, array) { - for (var out = [], i = 0; i < array.length; i++) - out[i] = clipPos(doc, array[i]); - return out; - } - - // SELECTION UPDATES - - // The 'scroll' parameter given to many of these indicated whether - // the new cursor position should be scrolled into view after - // modifying the selection. - - // If shift is held or the extend flag is set, extends a range to - // include a given position (and optionally a second position). - // Otherwise, simply returns the range between the given positions. - // Used for cursor motion and such. - function extendRange(doc, range, head, other) { - if (doc.cm && doc.cm.display.shift || doc.extend) { - var anchor = range.anchor; - if (other) { - var posBefore = cmp(head, anchor) < 0; - if (posBefore != (cmp(other, anchor) < 0)) { - anchor = head; - head = other; - } else if (posBefore != (cmp(head, other) < 0)) { - head = other; - } - } - return new Range(anchor, head); - } else { - return new Range(other || head, head); - } - } - - // Extend the primary selection range, discard the rest. - function extendSelection(doc, head, other, options) { - setSelection(doc, new Selection([extendRange(doc, doc.sel.primary(), head, other)], 0), options); - } - - // Extend all selections (pos is an array of selections with length - // equal the number of selections) - function extendSelections(doc, heads, options) { - for (var out = [], i = 0; i < doc.sel.ranges.length; i++) - out[i] = extendRange(doc, doc.sel.ranges[i], heads[i], null); - var newSel = normalizeSelection(out, doc.sel.primIndex); - setSelection(doc, newSel, options); - } - - // Updates a single range in the selection. - function replaceOneSelection(doc, i, range, options) { - var ranges = doc.sel.ranges.slice(0); - ranges[i] = range; - setSelection(doc, normalizeSelection(ranges, doc.sel.primIndex), options); - } - - // Reset the selection to a single range. - function setSimpleSelection(doc, anchor, head, options) { - setSelection(doc, simpleSelection(anchor, head), options); - } - - // Give beforeSelectionChange handlers a change to influence a - // selection update. - function filterSelectionChange(doc, sel) { - var obj = { - ranges: sel.ranges, - update: function (ranges) { - this.ranges = []; - for (var i = 0; i < ranges.length; i++) - this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor), - clipPos(doc, ranges[i].head)); - } - }; - signal(doc, "beforeSelectionChange", doc, obj); - if (doc.cm) - signal(doc.cm, "beforeSelectionChange", doc.cm, obj); - if (obj.ranges != sel.ranges) - return normalizeSelection(obj.ranges, obj.ranges.length - 1); - else - return sel; - } - - function setSelectionReplaceHistory(doc, sel, options) { - var done = doc.history.done, last = lst(done); - if (last && last.ranges) { - done[done.length - 1] = sel; - setSelectionNoUndo(doc, sel, options); - } else { - setSelection(doc, sel, options); - } - } - - // Set a new selection. - function setSelection(doc, sel, options) { - setSelectionNoUndo(doc, sel, options); - addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options); - } - - function setSelectionNoUndo(doc, sel, options) { - if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange")) - sel = filterSelectionChange(doc, sel); - - var bias = cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1; - setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true)); - - if (!(options && options.scroll === false) && doc.cm) - ensureCursorVisible(doc.cm); - } - - function setSelectionInner(doc, sel) { - if (sel.equals(doc.sel)) - return; - - doc.sel = sel; - - if (doc.cm) - doc.cm.curOp.updateInput = doc.cm.curOp.selectionChanged = - doc.cm.curOp.cursorActivity = true; - signalLater(doc, "cursorActivity", doc); - } - - // Verify that the selection does not partially select any atomic - // marked ranges. - function reCheckSelection(doc) { - setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false), sel_dontScroll); - } - - // Return a selection that does not partially select any atomic - // ranges. - function skipAtomicInSelection(doc, sel, bias, mayClear) { - var out; - for (var i = 0; i < sel.ranges.length; i++) { - var range = sel.ranges[i]; - var newAnchor = skipAtomic(doc, range.anchor, bias, mayClear); - var newHead = skipAtomic(doc, range.head, bias, mayClear); - if (out || newAnchor != range.anchor || newHead != range.head) { - if (!out) - out = sel.ranges.slice(0, i); - out[i] = new Range(newAnchor, newHead); - } - } - return out ? normalizeSelection(out, sel.primIndex) : sel; - } - - // Ensure a given position is not inside an atomic range. - function skipAtomic(doc, pos, bias, mayClear) { - var flipped = false, curPos = pos; - var dir = bias || 1; - doc.cantEdit = false; - search: for (; ; ) { - var line = getLine(doc, curPos.line); - if (line.markedSpans) { - for (var i = 0; i < line.markedSpans.length; ++i) { - var sp = line.markedSpans[i], m = sp.marker; - if ((sp.from == null || (m.inclusiveLeft ? sp.from <= curPos.ch : sp.from < curPos.ch)) && - (sp.to == null || (m.inclusiveRight ? sp.to >= curPos.ch : sp.to > curPos.ch))) { - if (mayClear) { - signal(m, "beforeCursorEnter"); - if (m.explicitlyCleared) { - if (!line.markedSpans) - break; - else { - --i; - continue; - } - } - } - if (!m.atomic) - continue; - var newPos = m.find(dir < 0 ? -1 : 1); - if (cmp(newPos, curPos) == 0) { - newPos.ch += dir; - if (newPos.ch < 0) { - if (newPos.line > doc.first) - newPos = clipPos(doc, Pos(newPos.line - 1)); - else - newPos = null; - } else if (newPos.ch > line.text.length) { - if (newPos.line < doc.first + doc.size - 1) - newPos = Pos(newPos.line + 1, 0); - else - newPos = null; - } - if (!newPos) { - if (flipped) { - // Driven in a corner -- no valid cursor position found at all - // -- try again *with* clearing, if we didn't already - if (!mayClear) - return skipAtomic(doc, pos, bias, true); - // Otherwise, turn off editing until further notice, and return the start of the doc - doc.cantEdit = true; - return Pos(doc.first, 0); - } - flipped = true; - newPos = pos; - dir = -dir; - } - } - curPos = newPos; - continue search; - } - } - } - return curPos; - } - } - - // SELECTION DRAWING - - // Redraw the selection and/or cursor - function updateSelection(cm) { - var display = cm.display, doc = cm.doc; - var curFragment = document.createDocumentFragment(); - var selFragment = document.createDocumentFragment(); - - for (var i = 0; i < doc.sel.ranges.length; i++) { - var range = doc.sel.ranges[i]; - var collapsed = range.empty(); - if (collapsed || cm.options.showCursorWhenSelecting) - updateSelectionCursor(cm, range, curFragment); - if (!collapsed) - updateSelectionRange(cm, range, selFragment); - } - - // Move the hidden textarea near the cursor to prevent scrolling artifacts - if (cm.options.moveInputWithCursor) { - var headPos = cursorCoords(cm, doc.sel.primary().head, "div"); - var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect(); - var top = Math.max(0, Math.min(display.wrapper.clientHeight - 10, - headPos.top + lineOff.top - wrapOff.top)); - var left = Math.max(0, Math.min(display.wrapper.clientWidth - 10, - headPos.left + lineOff.left - wrapOff.left)); - display.inputDiv.style.top = top + "px"; - display.inputDiv.style.left = left + "px"; - } - - removeChildrenAndAdd(display.cursorDiv, curFragment); - removeChildrenAndAdd(display.selectionDiv, selFragment); - } - - // Draws a cursor for the given range - function updateSelectionCursor(cm, range, output) { - var pos = cursorCoords(cm, range.head, "div"); - - var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor")); - cursor.style.left = pos.left + "px"; - cursor.style.top = pos.top + "px"; - cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px"; - - if (pos.other) { - // Secondary cursor, shown when on a 'jump' in bi-directional text - var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor")); - otherCursor.style.display = ""; - otherCursor.style.left = pos.other.left + "px"; - otherCursor.style.top = pos.other.top + "px"; - otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px"; - } - } - - // Draws the given range as a highlighted selection - function updateSelectionRange(cm, range, output) { - var display = cm.display, doc = cm.doc; - var fragment = document.createDocumentFragment(); - var padding = paddingH(cm.display), leftSide = padding.left, rightSide = display.lineSpace.offsetWidth - padding.right; - - function add(left, top, width, bottom) { - if (top < 0) - top = 0; - fragment.appendChild(elt("div", null, "CodeMirror-selected", "position: absolute; left: " + left + - "px; top: " + top + "px; width: " + (width == null ? rightSide - left : width) + - "px; height: " + (bottom - top) + "px")); - } - - function drawForLine(line, fromArg, toArg) { - var lineObj = getLine(doc, line); - var lineLen = lineObj.text.length; - var start, end; - function coords(ch, bias) { - return charCoords(cm, Pos(line, ch), "div", lineObj, bias); - } - - iterateBidiSections(getOrder(lineObj), fromArg || 0, toArg == null ? lineLen : toArg, function (from, to, dir) { - var leftPos = coords(from, "left"), rightPos, left, right; - if (from == to) { - rightPos = leftPos; - left = right = leftPos.left; - } else { - rightPos = coords(to - 1, "right"); - if (dir == "rtl") { - var tmp = leftPos; - leftPos = rightPos; - rightPos = tmp; - } - left = leftPos.left; - right = rightPos.right; - } - if (fromArg == null && from == 0) - left = leftSide; - if (rightPos.top - leftPos.top > 3) { // Different lines, draw top part - add(left, leftPos.top, null, leftPos.bottom); - left = leftSide; - if (leftPos.bottom < rightPos.top) - add(left, leftPos.bottom, null, rightPos.top); - } - if (toArg == null && to == lineLen) - right = rightSide; - if (!start || leftPos.top < start.top || leftPos.top == start.top && leftPos.left < start.left) - start = leftPos; - if (!end || rightPos.bottom > end.bottom || rightPos.bottom == end.bottom && rightPos.right > end.right) - end = rightPos; - if (left < leftSide + 1) - left = leftSide; - add(left, rightPos.top, right - left, rightPos.bottom); - }); - return {start: start, end: end}; - } - - var sFrom = range.from(), sTo = range.to(); - if (sFrom.line == sTo.line) { - drawForLine(sFrom.line, sFrom.ch, sTo.ch); - } else { - var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line); - var singleVLine = visualLine(fromLine) == visualLine(toLine); - var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end; - var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start; - if (singleVLine) { - if (leftEnd.top < rightStart.top - 2) { - add(leftEnd.right, leftEnd.top, null, leftEnd.bottom); - add(leftSide, rightStart.top, rightStart.left, rightStart.bottom); - } else { - add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom); - } - } - if (leftEnd.bottom < rightStart.top) - add(leftSide, leftEnd.bottom, null, rightStart.top); - } - - output.appendChild(fragment); - } - - // Cursor-blinking - function restartBlink(cm) { - if (!cm.state.focused) - return; - var display = cm.display; - clearInterval(display.blinker); - var on = true; - display.cursorDiv.style.visibility = ""; - if (cm.options.cursorBlinkRate > 0) - display.blinker = setInterval(function () { - display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden"; - }, cm.options.cursorBlinkRate); - } - - // HIGHLIGHT WORKER - - function startWorker(cm, time) { - if (cm.doc.mode.startState && cm.doc.frontier < cm.display.viewTo) - cm.state.highlight.set(time, bind(highlightWorker, cm)); - } - - function highlightWorker(cm) { - var doc = cm.doc; - if (doc.frontier < doc.first) - doc.frontier = doc.first; - if (doc.frontier >= cm.display.viewTo) - return; - var end = +new Date + cm.options.workTime; - var state = copyState(doc.mode, getStateBefore(cm, doc.frontier)); - - runInOp(cm, function () { - doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function (line) { - if (doc.frontier >= cm.display.viewFrom) { // Visible - var oldStyles = line.styles; - line.styles = highlightLine(cm, line, state, true); - var ischange = !oldStyles || oldStyles.length != line.styles.length; - for (var i = 0; !ischange && i < oldStyles.length; ++i) - ischange = oldStyles[i] != line.styles[i]; - if (ischange) - regLineChange(cm, doc.frontier, "text"); - line.stateAfter = copyState(doc.mode, state); - } else { - processLine(cm, line.text, state); - line.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null; - } - ++doc.frontier; - if (+new Date > end) { - startWorker(cm, cm.options.workDelay); - return true; - } - }); - }); - } - - // Finds the line to start with when starting a parse. Tries to - // find a line with a stateAfter, so that it can start with a - // valid state. If that fails, it returns the line with the - // smallest indentation, which tends to need the least context to - // parse correctly. - function findStartLine(cm, n, precise) { - var minindent, minline, doc = cm.doc; - var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100); - for (var search = n; search > lim; --search) { - if (search <= doc.first) - return doc.first; - var line = getLine(doc, search - 1); - if (line.stateAfter && (!precise || search <= doc.frontier)) - return search; - var indented = countColumn(line.text, null, cm.options.tabSize); - if (minline == null || minindent > indented) { - minline = search - 1; - minindent = indented; - } - } - return minline; - } - - function getStateBefore(cm, n, precise) { - var doc = cm.doc, display = cm.display; - if (!doc.mode.startState) - return true; - var pos = findStartLine(cm, n, precise), state = pos > doc.first && getLine(doc, pos - 1).stateAfter; - if (!state) - state = startState(doc.mode); - else - state = copyState(doc.mode, state); - doc.iter(pos, n, function (line) { - processLine(cm, line.text, state); - var save = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo; - line.stateAfter = save ? copyState(doc.mode, state) : null; - ++pos; - }); - if (precise) - doc.frontier = pos; - return state; - } - - // POSITION MEASUREMENT - - function paddingTop(display) { - return display.lineSpace.offsetTop; - } - function paddingVert(display) { - return display.mover.offsetHeight - display.lineSpace.offsetHeight; - } - function paddingH(display) { - if (display.cachedPaddingH) - return display.cachedPaddingH; - var e = removeChildrenAndAdd(display.measure, elt("pre", "x")); - var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle; - return display.cachedPaddingH = {left: parseInt(style.paddingLeft), - right: parseInt(style.paddingRight)}; - } - - // Ensure the lineView.wrapping.heights array is populated. This is - // an array of bottom offsets for the lines that make up a drawn - // line. When lineWrapping is on, there might be more than one - // height. - function ensureLineHeights(cm, lineView, rect) { - var wrapping = cm.options.lineWrapping; - var curWidth = wrapping && cm.display.scroller.clientWidth; - if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) { - var heights = lineView.measure.heights = []; - if (wrapping) { - lineView.measure.width = curWidth; - var rects = lineView.text.firstChild.getClientRects(); - for (var i = 0; i < rects.length - 1; i++) { - var cur = rects[i], next = rects[i + 1]; - if (Math.abs(cur.bottom - next.bottom) > 2) - heights.push((cur.bottom + next.top) / 2 - rect.top); - } - } - heights.push(rect.bottom - rect.top); - } - } - - // Find a line map (mapping character offsets to text nodes) and a - // measurement cache for the given line number. (A line view might - // contain multiple lines when collapsed ranges are present.) - function mapFromLineView(lineView, line, lineN) { - if (lineView.line == line) - return {map: lineView.measure.map, cache: lineView.measure.cache}; - for (var i = 0; i < lineView.rest.length; i++) - if (lineView.rest[i] == line) - return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]}; - for (var i = 0; i < lineView.rest.length; i++) - if (lineNo(lineView.rest[i]) > lineN) - return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i], before: true}; - } - - // Render a line into the hidden node display.externalMeasured. Used - // when measurement is needed for a line that's not in the viewport. - function updateExternalMeasurement(cm, line) { - line = visualLine(line); - var lineN = lineNo(line); - var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN); - view.lineN = lineN; - var built = view.built = buildLineContent(cm, view); - view.text = built.pre; - removeChildrenAndAdd(cm.display.lineMeasure, built.pre); - return view; - } - - // Get a {top, bottom, left, right} box (in line-local coordinates) - // for a given character. - function measureChar(cm, line, ch, bias) { - return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias); - } - - // Find a line view that corresponds to the given line number. - function findViewForLine(cm, lineN) { - if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo) - return cm.display.view[findViewIndex(cm, lineN)]; - var ext = cm.display.externalMeasured; - if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size) - return ext; - } - - // Measurement can be split in two steps, the set-up work that - // applies to the whole line, and the measurement of the actual - // character. Functions like coordsChar, that need to do a lot of - // measurements in a row, can thus ensure that the set-up work is - // only done once. - function prepareMeasureForLine(cm, line) { - var lineN = lineNo(line); - var view = findViewForLine(cm, lineN); - if (view && !view.text) - view = null; - else if (view && view.changes) - updateLineForChanges(cm, view, lineN, getDimensions(cm)); - if (!view) - view = updateExternalMeasurement(cm, line); - - var info = mapFromLineView(view, line, lineN); - return { - line: line, view: view, rect: null, - map: info.map, cache: info.cache, before: info.before, - hasHeights: false - }; - } - - // Given a prepared measurement object, measures the position of an - // actual character (or fetches it from the cache). - function measureCharPrepared(cm, prepared, ch, bias) { - if (prepared.before) - ch = -1; - var key = ch + (bias || ""), found; - if (prepared.cache.hasOwnProperty(key)) { - found = prepared.cache[key]; - } else { - if (!prepared.rect) - prepared.rect = prepared.view.text.getBoundingClientRect(); - if (!prepared.hasHeights) { - ensureLineHeights(cm, prepared.view, prepared.rect); - prepared.hasHeights = true; - } - found = measureCharInner(cm, prepared, ch, bias); - if (!found.bogus) - prepared.cache[key] = found; - } - return {left: found.left, right: found.right, top: found.top, bottom: found.bottom}; - } - - var nullRect = {left: 0, right: 0, top: 0, bottom: 0}; - - function measureCharInner(cm, prepared, ch, bias) { - var map = prepared.map; - - var node, start, end, collapse; - // First, search the line map for the text node corresponding to, - // or closest to, the target character. - for (var i = 0; i < map.length; i += 3) { - var mStart = map[i], mEnd = map[i + 1]; - if (ch < mStart) { - start = 0; - end = 1; - collapse = "left"; - } else if (ch < mEnd) { - start = ch - mStart; - end = start + 1; - } else if (i == map.length - 3 || ch == mEnd && map[i + 3] > ch) { - end = mEnd - mStart; - start = end - 1; - if (ch >= mEnd) - collapse = "right"; - } - if (start != null) { - node = map[i + 2]; - if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right")) - collapse = bias; - if (bias == "left" && start == 0) - while (i && map[i - 2] == map[i - 3] && map[i - 1].insertLeft) { - node = map[(i -= 3) + 2]; - collapse = "left"; - } - if (bias == "right" && start == mEnd - mStart) - while (i < map.length - 3 && map[i + 3] == map[i + 4] && !map[i + 5].insertLeft) { - node = map[(i += 3) + 2]; - collapse = "right"; - } - break; - } - } - - var rect; - if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates. - while (start && isExtendingChar(prepared.line.text.charAt(mStart + start))) - --start; - while (mStart + end < mEnd && isExtendingChar(prepared.line.text.charAt(mStart + end))) - ++end; - if (ie_upto8 && start == 0 && end == mEnd - mStart) { - rect = node.parentNode.getBoundingClientRect(); - } else if (ie && cm.options.lineWrapping) { - var rects = range(node, start, end).getClientRects(); - if (rects.length) - rect = rects[bias == "right" ? rects.length - 1 : 0]; - else - rect = nullRect; - } else { - rect = range(node, start, end).getBoundingClientRect(); - } - } else { // If it is a widget, simply get the box for the whole widget. - if (start > 0) - collapse = bias = "right"; - var rects; - if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1) - rect = rects[bias == "right" ? rects.length - 1 : 0]; - else - rect = node.getBoundingClientRect(); - } - if (ie_upto8 && !start && (!rect || !rect.left && !rect.right)) { - var rSpan = node.parentNode.getClientRects()[0]; - if (rSpan) - rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom}; - else - rect = nullRect; - } - - var top, bot = (rect.bottom + rect.top) / 2 - prepared.rect.top; - var heights = prepared.view.measure.heights; - for (var i = 0; i < heights.length - 1; i++) - if (bot < heights[i]) - break; - top = i ? heights[i - 1] : 0; - bot = heights[i]; - var result = {left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left, - right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left, - top: top, bottom: bot}; - if (!rect.left && !rect.right) - result.bogus = true; - return result; - } - - function clearLineMeasurementCacheFor(lineView) { - if (lineView.measure) { - lineView.measure.cache = {}; - lineView.measure.heights = null; - if (lineView.rest) - for (var i = 0; i < lineView.rest.length; i++) - lineView.measure.caches[i] = {}; - } - } - - function clearLineMeasurementCache(cm) { - cm.display.externalMeasure = null; - removeChildren(cm.display.lineMeasure); - for (var i = 0; i < cm.display.view.length; i++) - clearLineMeasurementCacheFor(cm.display.view[i]); - } - - function clearCaches(cm) { - clearLineMeasurementCache(cm); - cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null; - if (!cm.options.lineWrapping) - cm.display.maxLineChanged = true; - cm.display.lineNumChars = null; - } - - function pageScrollX() { - return window.pageXOffset || (document.documentElement || document.body).scrollLeft; - } - function pageScrollY() { - return window.pageYOffset || (document.documentElement || document.body).scrollTop; - } - - // Converts a {top, bottom, left, right} box from line-local - // coordinates into another coordinate system. Context may be one of - // "line", "div" (display.lineDiv), "local"/null (editor), or "page". - function intoCoordSystem(cm, lineObj, rect, context) { - if (lineObj.widgets) - for (var i = 0; i < lineObj.widgets.length; ++i) - if (lineObj.widgets[i].above) { - var size = widgetHeight(lineObj.widgets[i]); - rect.top += size; - rect.bottom += size; - } - if (context == "line") - return rect; - if (!context) - context = "local"; - var yOff = heightAtLine(lineObj); - if (context == "local") - yOff += paddingTop(cm.display); - else - yOff -= cm.display.viewOffset; - if (context == "page" || context == "window") { - var lOff = cm.display.lineSpace.getBoundingClientRect(); - yOff += lOff.top + (context == "window" ? 0 : pageScrollY()); - var xOff = lOff.left + (context == "window" ? 0 : pageScrollX()); - rect.left += xOff; - rect.right += xOff; - } - rect.top += yOff; - rect.bottom += yOff; - return rect; - } - - // Coverts a box from "div" coords to another coordinate system. - // Context may be "window", "page", "div", or "local"/null. - function fromCoordSystem(cm, coords, context) { - if (context == "div") - return coords; - var left = coords.left, top = coords.top; - // First move into "page" coordinate system - if (context == "page") { - left -= pageScrollX(); - top -= pageScrollY(); - } else if (context == "local" || !context) { - var localBox = cm.display.sizer.getBoundingClientRect(); - left += localBox.left; - top += localBox.top; - } - - var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect(); - return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top}; - } - - function charCoords(cm, pos, context, lineObj, bias) { - if (!lineObj) - lineObj = getLine(cm.doc, pos.line); - return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context); - } - - // Returns a box for a given cursor position, which may have an - // 'other' property containing the position of the secondary cursor - // on a bidi boundary. - function cursorCoords(cm, pos, context, lineObj, preparedMeasure) { - lineObj = lineObj || getLine(cm.doc, pos.line); - if (!preparedMeasure) - preparedMeasure = prepareMeasureForLine(cm, lineObj); - function get(ch, right) { - var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left"); - if (right) - m.left = m.right; - else - m.right = m.left; - return intoCoordSystem(cm, lineObj, m, context); - } - function getBidi(ch, partPos) { - var part = order[partPos], right = part.level % 2; - if (ch == bidiLeft(part) && partPos && part.level < order[partPos - 1].level) { - part = order[--partPos]; - ch = bidiRight(part) - (part.level % 2 ? 0 : 1); - right = true; - } else if (ch == bidiRight(part) && partPos < order.length - 1 && part.level < order[partPos + 1].level) { - part = order[++partPos]; - ch = bidiLeft(part) - part.level % 2; - right = false; - } - if (right && ch == part.to && ch > part.from) - return get(ch - 1); - return get(ch, right); - } - var order = getOrder(lineObj), ch = pos.ch; - if (!order) - return get(ch); - var partPos = getBidiPartAt(order, ch); - var val = getBidi(ch, partPos); - if (bidiOther != null) - val.other = getBidi(ch, bidiOther); - return val; - } - - // Used to cheaply estimate the coordinates for a position. Used for - // intermediate scroll updates. - function estimateCoords(cm, pos) { - var left = 0, pos = clipPos(cm.doc, pos); - if (!cm.options.lineWrapping) - left = charWidth(cm.display) * pos.ch; - var lineObj = getLine(cm.doc, pos.line); - var top = heightAtLine(lineObj) + paddingTop(cm.display); - return {left: left, right: left, top: top, bottom: top + lineObj.height}; - } - - // Positions returned by coordsChar contain some extra information. - // xRel is the relative x position of the input coordinates compared - // to the found position (so xRel > 0 means the coordinates are to - // the right of the character position, for example). When outside - // is true, that means the coordinates lie outside the line's - // vertical range. - function PosWithInfo(line, ch, outside, xRel) { - var pos = Pos(line, ch); - pos.xRel = xRel; - if (outside) - pos.outside = true; - return pos; - } - - // Compute the character position closest to the given coordinates. - // Input must be lineSpace-local ("div" coordinate system). - function coordsChar(cm, x, y) { - var doc = cm.doc; - y += cm.display.viewOffset; - if (y < 0) - return PosWithInfo(doc.first, 0, true, -1); - var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1; - if (lineN > last) - return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, true, 1); - if (x < 0) - x = 0; - - var lineObj = getLine(doc, lineN); - for (; ; ) { - var found = coordsCharInner(cm, lineObj, lineN, x, y); - var merged = collapsedSpanAtEnd(lineObj); - var mergedPos = merged && merged.find(0, true); - if (merged && (found.ch > mergedPos.from.ch || found.ch == mergedPos.from.ch && found.xRel > 0)) - lineN = lineNo(lineObj = mergedPos.to.line); - else - return found; - } - } - - function coordsCharInner(cm, lineObj, lineNo, x, y) { - var innerOff = y - heightAtLine(lineObj); - var wrongLine = false, adjust = 2 * cm.display.wrapper.clientWidth; - var preparedMeasure = prepareMeasureForLine(cm, lineObj); - - function getX(ch) { - var sp = cursorCoords(cm, Pos(lineNo, ch), "line", lineObj, preparedMeasure); - wrongLine = true; - if (innerOff > sp.bottom) - return sp.left - adjust; - else if (innerOff < sp.top) - return sp.left + adjust; - else - wrongLine = false; - return sp.left; - } - - var bidi = getOrder(lineObj), dist = lineObj.text.length; - var from = lineLeft(lineObj), to = lineRight(lineObj); - var fromX = getX(from), fromOutside = wrongLine, toX = getX(to), toOutside = wrongLine; - - if (x > toX) - return PosWithInfo(lineNo, to, toOutside, 1); - // Do a binary search between these bounds. - for (; ; ) { - if (bidi ? to == from || to == moveVisually(lineObj, from, 1) : to - from <= 1) { - var ch = x < fromX || x - fromX <= toX - x ? from : to; - var xDiff = x - (ch == from ? fromX : toX); - while (isExtendingChar(lineObj.text.charAt(ch))) - ++ch; - var pos = PosWithInfo(lineNo, ch, ch == from ? fromOutside : toOutside, - xDiff < -1 ? -1 : xDiff > 1 ? 1 : 0); - return pos; - } - var step = Math.ceil(dist / 2), middle = from + step; - if (bidi) { - middle = from; - for (var i = 0; i < step; ++i) - middle = moveVisually(lineObj, middle, 1); - } - var middleX = getX(middle); - if (middleX > x) { - to = middle; - toX = middleX; - if (toOutside = wrongLine) - toX += 1000; - dist = step; - } - else { - from = middle; - fromX = middleX; - fromOutside = wrongLine; - dist -= step; - } - } - } - - var measureText; - // Compute the default text height. - function textHeight(display) { - if (display.cachedTextHeight != null) - return display.cachedTextHeight; - if (measureText == null) { - measureText = elt("pre"); - // Measure a bunch of lines, for browsers that compute - // fractional heights. - for (var i = 0; i < 49; ++i) { - measureText.appendChild(document.createTextNode("x")); - measureText.appendChild(elt("br")); - } - measureText.appendChild(document.createTextNode("x")); - } - removeChildrenAndAdd(display.measure, measureText); - var height = measureText.offsetHeight / 50; - if (height > 3) - display.cachedTextHeight = height; - removeChildren(display.measure); - return height || 1; - } - - // Compute the default character width. - function charWidth(display) { - if (display.cachedCharWidth != null) - return display.cachedCharWidth; - var anchor = elt("span", "xxxxxxxxxx"); - var pre = elt("pre", [anchor]); - removeChildrenAndAdd(display.measure, pre); - var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10; - if (width > 2) - display.cachedCharWidth = width; - return width || 10; - } - - // OPERATIONS - - // Operations are used to wrap a series of changes to the editor - // state in such a way that each change won't have to update the - // cursor and display (which would be awkward, slow, and - // error-prone). Instead, display updates are batched and then all - // combined and executed at once. - - var nextOpId = 0; - // Start a new operation. - function startOperation(cm) { - cm.curOp = { - viewChanged: false, // Flag that indicates that lines might need to be redrawn - startHeight: cm.doc.height, // Used to detect need to update scrollbar - forceUpdate: false, // Used to force a redraw - updateInput: null, // Whether to reset the input textarea - typing: false, // Whether this reset should be careful to leave existing text (for compositing) - changeObjs: null, // Accumulated changes, for firing change events - cursorActivity: false, // Whether to fire a cursorActivity event - selectionChanged: false, // Whether the selection needs to be redrawn - updateMaxLine: false, // Set when the widest line needs to be determined anew - scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet - scrollToPos: null, // Used to scroll to a specific position - id: ++nextOpId // Unique ID - }; - if (!delayedCallbackDepth++) - delayedCallbacks = []; - } - - // Finish an operation, updating the display and signalling delayed events - function endOperation(cm) { - var op = cm.curOp, doc = cm.doc, display = cm.display; - cm.curOp = null; - - if (op.updateMaxLine) - findMaxLine(cm); - - // If it looks like an update might be needed, call updateDisplay - if (op.viewChanged || op.forceUpdate || op.scrollTop != null || - op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom || - op.scrollToPos.to.line >= display.viewTo) || - display.maxLineChanged && cm.options.lineWrapping) { - var updated = updateDisplay(cm, {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate); - if (cm.display.scroller.offsetHeight) - cm.doc.scrollTop = cm.display.scroller.scrollTop; - } - // If no update was run, but the selection changed, redraw that. - if (!updated && op.selectionChanged) - updateSelection(cm); - if (!updated && op.startHeight != cm.doc.height) - updateScrollbars(cm); - - // Propagate the scroll position to the actual DOM scroller - if (op.scrollTop != null && display.scroller.scrollTop != op.scrollTop) { - var top = Math.max(0, Math.min(display.scroller.scrollHeight - display.scroller.clientHeight, op.scrollTop)); - display.scroller.scrollTop = display.scrollbarV.scrollTop = doc.scrollTop = top; - } - if (op.scrollLeft != null && display.scroller.scrollLeft != op.scrollLeft) { - var left = Math.max(0, Math.min(display.scroller.scrollWidth - display.scroller.clientWidth, op.scrollLeft)); - display.scroller.scrollLeft = display.scrollbarH.scrollLeft = doc.scrollLeft = left; - alignHorizontally(cm); - } - // If we need to scroll a specific position into view, do so. - if (op.scrollToPos) { - var coords = scrollPosIntoView(cm, clipPos(cm.doc, op.scrollToPos.from), - clipPos(cm.doc, op.scrollToPos.to), op.scrollToPos.margin); - if (op.scrollToPos.isCursor && cm.state.focused) - maybeScrollWindow(cm, coords); - } - - if (op.selectionChanged) - restartBlink(cm); - - if (cm.state.focused && op.updateInput) - resetInput(cm, op.typing); - - // Fire events for markers that are hidden/unidden by editing or - // undoing - var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers; - if (hidden) - for (var i = 0; i < hidden.length; ++i) - if (!hidden[i].lines.length) - signal(hidden[i], "hide"); - if (unhidden) - for (var i = 0; i < unhidden.length; ++i) - if (unhidden[i].lines.length) - signal(unhidden[i], "unhide"); - - var delayed; - if (!--delayedCallbackDepth) { - delayed = delayedCallbacks; - delayedCallbacks = null; - } - // Fire change events, and delayed event handlers - if (op.changeObjs) { - for (var i = 0; i < op.changeObjs.length; i++) - signal(cm, "change", cm, op.changeObjs[i]); - signal(cm, "changes", cm, op.changeObjs); - } - if (op.cursorActivity) - signal(cm, "cursorActivity", cm); - if (delayed) - for (var i = 0; i < delayed.length; ++i) - delayed[i](); - } - - // Run the given function in an operation - function runInOp(cm, f) { - if (cm.curOp) - return f(); - startOperation(cm); - try { - return f(); - } - finally { - endOperation(cm); - } - } - // Wraps a function in an operation. Returns the wrapped function. - function operation(cm, f) { - return function () { - if (cm.curOp) - return f.apply(cm, arguments); - startOperation(cm); - try { - return f.apply(cm, arguments); - } - finally { - endOperation(cm); - } - }; - } - // Used to add methods to editor and doc instances, wrapping them in - // operations. - function methodOp(f) { - return function () { - if (this.curOp) - return f.apply(this, arguments); - startOperation(this); - try { - return f.apply(this, arguments); - } - finally { - endOperation(this); - } - }; - } - function docMethodOp(f) { - return function () { - var cm = this.cm; - if (!cm || cm.curOp) - return f.apply(this, arguments); - startOperation(cm); - try { - return f.apply(this, arguments); - } - finally { - endOperation(cm); - } - }; - } - - // VIEW TRACKING - - // These objects are used to represent the visible (currently drawn) - // part of the document. A LineView may correspond to multiple - // logical lines, if those are connected by collapsed ranges. - function LineView(doc, line, lineN) { - // The starting line - this.line = line; - // Continuing lines, if any - this.rest = visualLineContinued(line); - // Number of logical lines in this visual line - this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1; - this.node = this.text = null; - this.hidden = lineIsHidden(doc, line); - } - - // Create a range of LineView objects for the given lines. - function buildViewArray(cm, from, to) { - var array = [], nextPos; - for (var pos = from; pos < to; pos = nextPos) { - var view = new LineView(cm.doc, getLine(cm.doc, pos), pos); - nextPos = pos + view.size; - array.push(view); - } - return array; - } - - // Updates the display.view data structure for a given change to the - // document. From and to are in pre-change coordinates. Lendiff is - // the amount of lines added or subtracted by the change. This is - // used for changes that span multiple lines, or change the way - // lines are divided into visual lines. regLineChange (below) - // registers single-line changes. - function regChange(cm, from, to, lendiff) { - if (from == null) - from = cm.doc.first; - if (to == null) - to = cm.doc.first + cm.doc.size; - if (!lendiff) - lendiff = 0; - - var display = cm.display; - if (lendiff && to < display.viewTo && - (display.updateLineNumbers == null || display.updateLineNumbers > from)) - display.updateLineNumbers = from; - - cm.curOp.viewChanged = true; - - if (from >= display.viewTo) { // Change after - if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo) - resetView(cm); - } else if (to <= display.viewFrom) { // Change before - if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) { - resetView(cm); - } else { - display.viewFrom += lendiff; - display.viewTo += lendiff; - } - } else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap - resetView(cm); - } else if (from <= display.viewFrom) { // Top overlap - var cut = viewCuttingPoint(cm, to, to + lendiff, 1); - if (cut) { - display.view = display.view.slice(cut.index); - display.viewFrom = cut.lineN; - display.viewTo += lendiff; - } else { - resetView(cm); - } - } else if (to >= display.viewTo) { // Bottom overlap - var cut = viewCuttingPoint(cm, from, from, -1); - if (cut) { - display.view = display.view.slice(0, cut.index); - display.viewTo = cut.lineN; - } else { - resetView(cm); - } - } else { // Gap in the middle - var cutTop = viewCuttingPoint(cm, from, from, -1); - var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1); - if (cutTop && cutBot) { - display.view = display.view.slice(0, cutTop.index) - .concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN)) - .concat(display.view.slice(cutBot.index)); - display.viewTo += lendiff; - } else { - resetView(cm); - } - } - - var ext = display.externalMeasured; - if (ext) { - if (to < ext.lineN) - ext.lineN += lendiff; - else if (from < ext.lineN + ext.size) - display.externalMeasured = null; - } - } - - // Register a change to a single line. Type must be one of "text", - // "gutter", "class", "widget" - function regLineChange(cm, line, type) { - cm.curOp.viewChanged = true; - var display = cm.display, ext = cm.display.externalMeasured; - if (ext && line >= ext.lineN && line < ext.lineN + ext.size) - display.externalMeasured = null; - - if (line < display.viewFrom || line >= display.viewTo) - return; - var lineView = display.view[findViewIndex(cm, line)]; - if (lineView.node == null) - return; - var arr = lineView.changes || (lineView.changes = []); - if (indexOf(arr, type) == -1) - arr.push(type); - } - - // Clear the view. - function resetView(cm) { - cm.display.viewFrom = cm.display.viewTo = cm.doc.first; - cm.display.view = []; - cm.display.viewOffset = 0; - } - - // Find the view element corresponding to a given line. Return null - // when the line isn't visible. - function findViewIndex(cm, n) { - if (n >= cm.display.viewTo) - return null; - n -= cm.display.viewFrom; - if (n < 0) - return null; - var view = cm.display.view; - for (var i = 0; i < view.length; i++) { - n -= view[i].size; - if (n < 0) - return i; - } - } - - function viewCuttingPoint(cm, oldN, newN, dir) { - var index = findViewIndex(cm, oldN), diff, view = cm.display.view; - if (!sawCollapsedSpans) - return {index: index, lineN: newN}; - for (var i = 0, n = cm.display.viewFrom; i < index; i++) - n += view[i].size; - if (n != oldN) { - if (dir > 0) { - if (index == view.length - 1) - return null; - diff = (n + view[index].size) - oldN; - index++; - } else { - diff = n - oldN; - } - oldN += diff; - newN += diff; - } - while (visualLineNo(cm.doc, newN) != newN) { - if (index == (dir < 0 ? 0 : view.length - 1)) - return null; - newN += dir * view[index - (dir < 0 ? 1 : 0)].size; - index += dir; - } - return {index: index, lineN: newN}; - } - - // Force the view to cover a given range, adding empty view element - // or clipping off existing ones as needed. - function adjustView(cm, from, to) { - var display = cm.display, view = display.view; - if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) { - display.view = buildViewArray(cm, from, to); - display.viewFrom = from; - } else { - if (display.viewFrom > from) - display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view); - else if (display.viewFrom < from) - display.view = display.view.slice(findViewIndex(cm, from)); - display.viewFrom = from; - if (display.viewTo < to) - display.view = display.view.concat(buildViewArray(cm, display.viewTo, to)); - else if (display.viewTo > to) - display.view = display.view.slice(0, findViewIndex(cm, to)); - } - display.viewTo = to; - } - - // Count the number of lines in the view whose DOM representation is - // out of date (or nonexistent). - function countDirtyView(cm) { - var view = cm.display.view, dirty = 0; - for (var i = 0; i < view.length; i++) { - var lineView = view[i]; - if (!lineView.hidden && (!lineView.node || lineView.changes)) - ++dirty; - } - return dirty; - } - - // INPUT HANDLING - - // Poll for input changes, using the normal rate of polling. This - // runs as long as the editor is focused. - function slowPoll(cm) { - if (cm.display.pollingFast) - return; - cm.display.poll.set(cm.options.pollInterval, function () { - readInput(cm); - if (cm.state.focused) - slowPoll(cm); - }); - } - - // When an event has just come in that is likely to add or change - // something in the input textarea, we poll faster, to ensure that - // the change appears on the screen quickly. - function fastPoll(cm) { - var missed = false; - cm.display.pollingFast = true; - function p() { - var changed = readInput(cm); - if (!changed && !missed) { - missed = true; - cm.display.poll.set(60, p); - } - else { - cm.display.pollingFast = false; - slowPoll(cm); - } - } - cm.display.poll.set(20, p); - } - - // Read input from the textarea, and update the document to match. - // When something is selected, it is present in the textarea, and - // selected (unless it is huge, in which case a placeholder is - // used). When nothing is selected, the cursor sits after previously - // seen text (can be empty), which is stored in prevInput (we must - // not reset the textarea when typing, because that breaks IME). - function readInput(cm) { - var input = cm.display.input, prevInput = cm.display.prevInput, doc = cm.doc; - // Since this is called a *lot*, try to bail out as cheaply as - // possible when it is clear that nothing happened. hasSelection - // will be the case when there is a lot of text in the textarea, - // in which case reading its value would be expensive. - if (!cm.state.focused || hasSelection(input) || isReadOnly(cm) || cm.options.disableInput) - return false; - var text = input.value; - // If nothing changed, bail. - if (text == prevInput && !cm.somethingSelected()) - return false; - // Work around nonsensical selection resetting in IE9/10 - if (ie && !ie_upto8 && cm.display.inputHasSelection === text) { - resetInput(cm); - return false; - } - - var withOp = !cm.curOp; - if (withOp) - startOperation(cm); - cm.display.shift = false; - - // Find the part of the input that is actually new - var same = 0, l = Math.min(prevInput.length, text.length); - while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) - ++same; - var inserted = text.slice(same), textLines = splitLines(inserted); - - // When pasing N lines into N selections, insert one line per selection - var multiPaste = cm.state.pasteIncoming && textLines.length > 1 && doc.sel.ranges.length == textLines.length; - - // Normal behavior is to insert the new text into every selection - for (var i = doc.sel.ranges.length - 1; i >= 0; i--) { - var range = doc.sel.ranges[i]; - var from = range.from(), to = range.to(); - // Handle deletion - if (same < prevInput.length) - from = Pos(from.line, from.ch - (prevInput.length - same)); - // Handle overwrite - else if (cm.state.overwrite && range.empty() && !cm.state.pasteIncoming) - to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length)); - var updateInput = cm.curOp.updateInput; - var changeEvent = {from: from, to: to, text: multiPaste ? [textLines[i]] : textLines, - origin: cm.state.pasteIncoming ? "paste" : cm.state.cutIncoming ? "cut" : "+input"}; - makeChange(cm.doc, changeEvent); - signalLater(cm, "inputRead", cm, changeEvent); - // When an 'electric' character is inserted, immediately trigger a reindent - if (inserted && !cm.state.pasteIncoming && cm.options.electricChars && - cm.options.smartIndent && range.head.ch < 100 && - (!i || doc.sel.ranges[i - 1].head.line != range.head.line)) { - var electric = cm.getModeAt(range.head).electricChars; - if (electric) - for (var j = 0; j < electric.length; j++) - if (inserted.indexOf(electric.charAt(j)) > -1) { - indentLine(cm, range.head.line, "smart"); - break; - } - } - } - ensureCursorVisible(cm); - cm.curOp.updateInput = updateInput; - cm.curOp.typing = true; - - // Don't leave long text in the textarea, since it makes further polling slow - if (text.length > 1000 || text.indexOf("\n") > -1) - input.value = cm.display.prevInput = ""; - else - cm.display.prevInput = text; - if (withOp) - endOperation(cm); - cm.state.pasteIncoming = cm.state.cutIncoming = false; - return true; - } - - // Reset the input to correspond to the selection (or to be empty, - // when not typing and nothing is selected) - function resetInput(cm, typing) { - var minimal, selected, doc = cm.doc; - if (cm.somethingSelected()) { - cm.display.prevInput = ""; - var range = doc.sel.primary(); - minimal = hasCopyEvent && - (range.to().line - range.from().line > 100 || (selected = cm.getSelection()).length > 1000); - var content = minimal ? "-" : selected || cm.getSelection(); - cm.display.input.value = content; - if (cm.state.focused) - selectInput(cm.display.input); - if (ie && !ie_upto8) - cm.display.inputHasSelection = content; - } else if (!typing) { - cm.display.prevInput = cm.display.input.value = ""; - if (ie && !ie_upto8) - cm.display.inputHasSelection = null; - } - cm.display.inaccurateSelection = minimal; - } - - function focusInput(cm) { - if (cm.options.readOnly != "nocursor" && (!mobile || activeElt() != cm.display.input)) - cm.display.input.focus(); - } - - function ensureFocus(cm) { - if (!cm.state.focused) { - focusInput(cm); - onFocus(cm); - } - } - - function isReadOnly(cm) { - return cm.options.readOnly || cm.doc.cantEdit; - } - - // EVENT HANDLERS - - // Attach the necessary event handlers when initializing the editor - function registerEventHandlers(cm) { - var d = cm.display; - on(d.scroller, "mousedown", operation(cm, onMouseDown)); - // Older IE's will not fire a second mousedown for a double click - if (ie_upto10) - on(d.scroller, "dblclick", operation(cm, function (e) { - if (signalDOMEvent(cm, e)) - return; - var pos = posFromMouse(cm, e); - if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) - return; - e_preventDefault(e); - var word = findWordAt(cm.doc, pos); - extendSelection(cm.doc, word.anchor, word.head); - })); - else - on(d.scroller, "dblclick", function (e) { - signalDOMEvent(cm, e) || e_preventDefault(e); - }); - // Prevent normal selection in the editor (we handle our own) - on(d.lineSpace, "selectstart", function (e) { - if (!eventInWidget(d, e)) - e_preventDefault(e); - }); - // Some browsers fire contextmenu *after* opening the menu, at - // which point we can't mess with it anymore. Context menu is - // handled in onMouseDown for these browsers. - if (!captureRightClick) - on(d.scroller, "contextmenu", function (e) { - onContextMenu(cm, e); - }); - - // Sync scrolling between fake scrollbars and real scrollable - // area, ensure viewport is updated when scrolling. - on(d.scroller, "scroll", function () { - if (d.scroller.clientHeight) { - setScrollTop(cm, d.scroller.scrollTop); - setScrollLeft(cm, d.scroller.scrollLeft, true); - signal(cm, "scroll", cm); - } - }); - on(d.scrollbarV, "scroll", function () { - if (d.scroller.clientHeight) - setScrollTop(cm, d.scrollbarV.scrollTop); - }); - on(d.scrollbarH, "scroll", function () { - if (d.scroller.clientHeight) - setScrollLeft(cm, d.scrollbarH.scrollLeft); - }); - - // Listen to wheel events in order to try and update the viewport on time. - on(d.scroller, "mousewheel", function (e) { - onScrollWheel(cm, e); - }); - on(d.scroller, "DOMMouseScroll", function (e) { - onScrollWheel(cm, e); - }); - - // Prevent clicks in the scrollbars from killing focus - function reFocus() { - if (cm.state.focused) - setTimeout(bind(focusInput, cm), 0); - } - on(d.scrollbarH, "mousedown", reFocus); - on(d.scrollbarV, "mousedown", reFocus); - // Prevent wrapper from ever scrolling - on(d.wrapper, "scroll", function () { - d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; - }); - - // When the window resizes, we need to refresh active editors. - var resizeTimer; - function onResize() { - if (resizeTimer == null) - resizeTimer = setTimeout(function () { - resizeTimer = null; - // Might be a text scaling operation, clear size caches. - d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = knownScrollbarWidth = null; - cm.setSize(); - }, 100); - } - on(window, "resize", onResize); - // The above handler holds on to the editor and its data - // structures. Here we poll to unregister it when the editor is no - // longer in the document, so that it can be garbage-collected. - function unregister() { - if (contains(document.body, d.wrapper)) - setTimeout(unregister, 5000); - else - off(window, "resize", onResize); - } - setTimeout(unregister, 5000); - - on(d.input, "keyup", operation(cm, onKeyUp)); - on(d.input, "input", function () { - if (ie && !ie_upto8 && cm.display.inputHasSelection) - cm.display.inputHasSelection = null; - fastPoll(cm); - }); - on(d.input, "keydown", operation(cm, onKeyDown)); - on(d.input, "keypress", operation(cm, onKeyPress)); - on(d.input, "focus", bind(onFocus, cm)); - on(d.input, "blur", bind(onBlur, cm)); - - function drag_(e) { - if (!signalDOMEvent(cm, e)) - e_stop(e); - } - if (cm.options.dragDrop) { - on(d.scroller, "dragstart", function (e) { - onDragStart(cm, e); - }); - on(d.scroller, "dragenter", drag_); - on(d.scroller, "dragover", drag_); - on(d.scroller, "drop", operation(cm, onDrop)); - } - on(d.scroller, "paste", function (e) { - if (eventInWidget(d, e)) - return; - cm.state.pasteIncoming = true; - focusInput(cm); - fastPoll(cm); - }); - on(d.input, "paste", function () { - cm.state.pasteIncoming = true; - fastPoll(cm); - }); - - function prepareCopy(e) { - if (d.inaccurateSelection) { - d.prevInput = ""; - d.inaccurateSelection = false; - d.input.value = cm.getSelection(); - selectInput(d.input); - } - if (e.type == "cut") - cm.state.cutIncoming = true; - } - on(d.input, "cut", prepareCopy); - on(d.input, "copy", prepareCopy); - - // Needed to handle Tab key in KHTML - if (khtml) - on(d.sizer, "mouseup", function () { - if (activeElt() == d.input) - d.input.blur(); - focusInput(cm); - }); - } - - // MOUSE EVENTS - - // Return true when the given mouse event happened in a widget - function eventInWidget(display, e) { - for (var n = e_target(e); n != display.wrapper; n = n.parentNode) { - if (!n || n.ignoreEvents || n.parentNode == display.sizer && n != display.mover) - return true; - } - } - - // Given a mouse event, find the corresponding position. If liberal - // is false, it checks whether a gutter or scrollbar was clicked, - // and returns null if it was. forRect is used by rectangular - // selections, and tries to estimate a character position even for - // coordinates beyond the right of the text. - function posFromMouse(cm, e, liberal, forRect) { - var display = cm.display; - if (!liberal) { - var target = e_target(e); - if (target == display.scrollbarH || target == display.scrollbarV || - target == display.scrollbarFiller || target == display.gutterFiller) - return null; - } - var x, y, space = display.lineSpace.getBoundingClientRect(); - // Fails unpredictably on IE[67] when mouse is dragged around quickly. - try { - x = e.clientX - space.left; - y = e.clientY - space.top; - } - catch (e) { - return null; - } - var coords = coordsChar(cm, x, y), line; - if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) { - var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length; - coords = Pos(coords.line, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff); - } - return coords; - } - - // A mouse down can be a single click, double click, triple click, - // start of selection drag, start of text drag, new cursor - // (ctrl-click), rectangle drag (alt-drag), or xwin - // middle-click-paste. Or it might be a click on something we should - // not interfere with, such as a scrollbar or widget. - function onMouseDown(e) { - if (signalDOMEvent(this, e)) - return; - var cm = this, display = cm.display; - display.shift = e.shiftKey; - - if (eventInWidget(display, e)) { - if (!webkit) { - // Briefly turn off draggability, to allow widgets to do - // normal dragging things. - display.scroller.draggable = false; - setTimeout(function () { - display.scroller.draggable = true; - }, 100); - } - return; - } - if (clickInGutter(cm, e)) - return; - var start = posFromMouse(cm, e); - window.focus(); - - switch (e_button(e)) { - case 1: - if (start) - leftButtonDown(cm, e, start); - else if (e_target(e) == display.scroller) - e_preventDefault(e); - break; - case 2: - if (webkit) - cm.state.lastMiddleDown = +new Date; - if (start) - extendSelection(cm.doc, start); - setTimeout(bind(focusInput, cm), 20); - e_preventDefault(e); - break; - case 3: - if (captureRightClick) - onContextMenu(cm, e); - break; - } - } - - var lastClick, lastDoubleClick; - function leftButtonDown(cm, e, start) { - setTimeout(bind(ensureFocus, cm), 0); - - var now = +new Date, type; - if (lastDoubleClick && lastDoubleClick.time > now - 400 && cmp(lastDoubleClick.pos, start) == 0) { - type = "triple"; - } else if (lastClick && lastClick.time > now - 400 && cmp(lastClick.pos, start) == 0) { - type = "double"; - lastDoubleClick = {time: now, pos: start}; - } else { - type = "single"; - lastClick = {time: now, pos: start}; - } - - var sel = cm.doc.sel, addNew = mac ? e.metaKey : e.ctrlKey; - if (cm.options.dragDrop && dragAndDrop && !addNew && !isReadOnly(cm) && - type == "single" && sel.contains(start) > -1 && sel.somethingSelected()) - leftButtonStartDrag(cm, e, start); - else - leftButtonSelect(cm, e, start, type, addNew); - } - - // Start a text drag. When it ends, see if any dragging actually - // happen, and treat as a click if it didn't. - function leftButtonStartDrag(cm, e, start) { - var display = cm.display; - var dragEnd = operation(cm, function (e2) { - if (webkit) - display.scroller.draggable = false; - cm.state.draggingText = false; - off(document, "mouseup", dragEnd); - off(display.scroller, "drop", dragEnd); - if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) { - e_preventDefault(e2); - extendSelection(cm.doc, start); - focusInput(cm); - // Work around unexplainable focus problem in IE9 (#2127) - if (ie_upto10 && !ie_upto8) - setTimeout(function () { - document.body.focus(); - focusInput(cm); - }, 20); - } - }); - // Let the drag handler handle this. - if (webkit) - display.scroller.draggable = true; - cm.state.draggingText = dragEnd; - // IE's approach to draggable - if (display.scroller.dragDrop) - display.scroller.dragDrop(); - on(document, "mouseup", dragEnd); - on(display.scroller, "drop", dragEnd); - } - - // Normal selection, as opposed to text dragging. - function leftButtonSelect(cm, e, start, type, addNew) { - var display = cm.display, doc = cm.doc; - e_preventDefault(e); - - var ourRange, ourIndex, startSel = doc.sel; - if (addNew) { - ourIndex = doc.sel.contains(start); - if (ourIndex > -1) - ourRange = doc.sel.ranges[ourIndex]; - else - ourRange = new Range(start, start); - } else { - ourRange = doc.sel.primary(); - } - - if (e.altKey) { - type = "rect"; - if (!addNew) - ourRange = new Range(start, start); - start = posFromMouse(cm, e, true, true); - ourIndex = -1; - } else if (type == "double") { - var word = findWordAt(doc, start); - if (cm.display.shift || doc.extend) - ourRange = extendRange(doc, ourRange, word.anchor, word.head); - else - ourRange = word; - } else if (type == "triple") { - var line = new Range(Pos(start.line, 0), clipPos(doc, Pos(start.line + 1, 0))); - if (cm.display.shift || doc.extend) - ourRange = extendRange(doc, ourRange, line.anchor, line.head); - else - ourRange = line; - } else { - ourRange = extendRange(doc, ourRange, start); - } - - if (!addNew) { - ourIndex = 0; - setSelection(doc, new Selection([ourRange], 0), sel_mouse); - } else if (ourIndex > -1) { - replaceOneSelection(doc, ourIndex, ourRange, sel_mouse); - } else { - ourIndex = doc.sel.ranges.length; - setSelection(doc, normalizeSelection(doc.sel.ranges.concat([ourRange]), ourIndex), - {scroll: false, origin: "*mouse"}); - } - - var lastPos = start; - function extendTo(pos) { - if (cmp(lastPos, pos) == 0) - return; - lastPos = pos; - - if (type == "rect") { - var ranges = [], tabSize = cm.options.tabSize; - var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize); - var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize); - var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol); - for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line)); - line <= end; line++) { - var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize); - if (left == right) - ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))); - else if (text.length > leftPos) - ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))); - } - if (!ranges.length) - ranges.push(new Range(start, start)); - setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex), sel_mouse); - } else { - var oldRange = ourRange; - var anchor = oldRange.anchor, head = pos; - if (type != "single") { - if (type == "double") - var range = findWordAt(doc, pos); - else - var range = new Range(Pos(pos.line, 0), clipPos(doc, Pos(pos.line + 1, 0))); - if (cmp(range.anchor, anchor) > 0) { - head = range.head; - anchor = minPos(oldRange.from(), range.anchor); - } else { - head = range.anchor; - anchor = maxPos(oldRange.to(), range.head); - } - } - var ranges = startSel.ranges.slice(0); - ranges[ourIndex] = new Range(clipPos(doc, anchor), head); - setSelection(doc, normalizeSelection(ranges, ourIndex), sel_mouse); - } - } - - var editorSize = display.wrapper.getBoundingClientRect(); - // Used to ensure timeout re-tries don't fire when another extend - // happened in the meantime (clearTimeout isn't reliable -- at - // least on Chrome, the timeouts still happen even when cleared, - // if the clear happens after their scheduled firing time). - var counter = 0; - - function extend(e) { - var curCount = ++counter; - var cur = posFromMouse(cm, e, true, type == "rect"); - if (!cur) - return; - if (cmp(cur, lastPos) != 0) { - ensureFocus(cm); - extendTo(cur); - var visible = visibleLines(display, doc); - if (cur.line >= visible.to || cur.line < visible.from) - setTimeout(operation(cm, function () { - if (counter == curCount) - extend(e); - }), 150); - } else { - var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0; - if (outside) - setTimeout(operation(cm, function () { - if (counter != curCount) - return; - display.scroller.scrollTop += outside; - extend(e); - }), 50); - } - } - - function done(e) { - counter = Infinity; - e_preventDefault(e); - focusInput(cm); - off(document, "mousemove", move); - off(document, "mouseup", up); - doc.history.lastSelOrigin = null; - } - - var move = operation(cm, function (e) { - if ((ie && !ie_upto9) ? !e.buttons : !e_button(e)) - done(e); - else - extend(e); - }); - var up = operation(cm, done); - on(document, "mousemove", move); - on(document, "mouseup", up); - } - - // Determines whether an event happened in the gutter, and fires the - // handlers for the corresponding event. - function gutterEvent(cm, e, type, prevent, signalfn) { - try { - var mX = e.clientX, mY = e.clientY; - } - catch (e) { - return false; - } - if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) - return false; - if (prevent) - e_preventDefault(e); - - var display = cm.display; - var lineBox = display.lineDiv.getBoundingClientRect(); - - if (mY > lineBox.bottom || !hasHandler(cm, type)) - return e_defaultPrevented(e); - mY -= lineBox.top - display.viewOffset; - - for (var i = 0; i < cm.options.gutters.length; ++i) { - var g = display.gutters.childNodes[i]; - if (g && g.getBoundingClientRect().right >= mX) { - var line = lineAtHeight(cm.doc, mY); - var gutter = cm.options.gutters[i]; - signalfn(cm, type, cm, line, gutter, e); - return e_defaultPrevented(e); - } - } - } - - function clickInGutter(cm, e) { - return gutterEvent(cm, e, "gutterClick", true, signalLater); - } - - // Kludge to work around strange IE behavior where it'll sometimes - // re-fire a series of drag-related events right after the drop (#1551) - var lastDrop = 0; - - function onDrop(e) { - var cm = this; - if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) - return; - e_preventDefault(e); - if (ie_upto10) - lastDrop = +new Date; - var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files; - if (!pos || isReadOnly(cm)) - return; - // Might be a file drop, in which case we simply extract the text - // and insert it. - if (files && files.length && window.FileReader && window.File) { - var n = files.length, text = Array(n), read = 0; - var loadFile = function (file, i) { - var reader = new FileReader; - reader.onload = function () { - text[i] = reader.result; - if (++read == n) { - pos = clipPos(cm.doc, pos); - var change = {from: pos, to: pos, text: splitLines(text.join("\n")), origin: "paste"}; - makeChange(cm.doc, change); - setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change))); - } - }; - reader.readAsText(file); - }; - for (var i = 0; i < n; ++i) - loadFile(files[i], i); - } else { // Normal drop - // Don't do a replace if the drop happened inside of the selected text. - if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) { - cm.state.draggingText(e); - // Ensure the editor is re-focused - setTimeout(bind(focusInput, cm), 20); - return; - } - try { - var text = e.dataTransfer.getData("Text"); - if (text) { - var selected = cm.state.draggingText && cm.listSelections(); - setSelectionNoUndo(cm.doc, simpleSelection(pos, pos)); - if (selected) - for (var i = 0; i < selected.length; ++i) - replaceRange(cm.doc, "", selected[i].anchor, selected[i].head, "drag"); - cm.replaceSelection(text, "around", "paste"); - focusInput(cm); - } - } - catch (e) { - } - } - } - - function onDragStart(cm, e) { - if (ie_upto10 && (!cm.state.draggingText || +new Date - lastDrop < 100)) { - e_stop(e); - return; - } - if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) - return; - - e.dataTransfer.setData("Text", cm.getSelection()); - - // Use dummy image instead of default browsers image. - // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there. - if (e.dataTransfer.setDragImage && !safari) { - var img = elt("img", null, null, "position: fixed; left: 0; top: 0;"); - img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="; - if (presto) { - img.width = img.height = 1; - cm.display.wrapper.appendChild(img); - // Force a relayout, or Opera won't use our image for some obscure reason - img._top = img.offsetTop; - } - e.dataTransfer.setDragImage(img, 0, 0); - if (presto) - img.parentNode.removeChild(img); - } - } - - // SCROLL EVENTS - - // Sync the scrollable area and scrollbars, ensure the viewport - // covers the visible area. - function setScrollTop(cm, val) { - if (Math.abs(cm.doc.scrollTop - val) < 2) - return; - cm.doc.scrollTop = val; - if (!gecko) - updateDisplay(cm, {top: val}); - if (cm.display.scroller.scrollTop != val) - cm.display.scroller.scrollTop = val; - if (cm.display.scrollbarV.scrollTop != val) - cm.display.scrollbarV.scrollTop = val; - if (gecko) - updateDisplay(cm); - startWorker(cm, 100); - } - // Sync scroller and scrollbar, ensure the gutter elements are - // aligned. - function setScrollLeft(cm, val, isScroller) { - if (isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) - return; - val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth); - cm.doc.scrollLeft = val; - alignHorizontally(cm); - if (cm.display.scroller.scrollLeft != val) - cm.display.scroller.scrollLeft = val; - if (cm.display.scrollbarH.scrollLeft != val) - cm.display.scrollbarH.scrollLeft = val; - } - - // Since the delta values reported on mouse wheel events are - // unstandardized between browsers and even browser versions, and - // generally horribly unpredictable, this code starts by measuring - // the scroll effect that the first few mouse wheel events have, - // and, from that, detects the way it can convert deltas to pixel - // offsets afterwards. - // - // The reason we want to know the amount a wheel event will scroll - // is that it gives us a chance to update the display before the - // actual scrolling happens, reducing flickering. - - var wheelSamples = 0, wheelPixelsPerUnit = null; - // Fill in a browser-detected starting value on browsers where we - // know one. These don't have to be accurate -- the result of them - // being wrong would just be a slight flicker on the first wheel - // scroll (if it is large enough). - if (ie) - wheelPixelsPerUnit = -.53; - else if (gecko) - wheelPixelsPerUnit = 15; - else if (chrome) - wheelPixelsPerUnit = -.7; - else if (safari) - wheelPixelsPerUnit = -1 / 3; - - function onScrollWheel(cm, e) { - var dx = e.wheelDeltaX, dy = e.wheelDeltaY; - if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) - dx = e.detail; - if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) - dy = e.detail; - else if (dy == null) - dy = e.wheelDelta; - - var display = cm.display, scroll = display.scroller; - // Quit if there's nothing to scroll here - if (!(dx && scroll.scrollWidth > scroll.clientWidth || - dy && scroll.scrollHeight > scroll.clientHeight)) - return; - - // Webkit browsers on OS X abort momentum scrolls when the target - // of the scroll event is removed from the scrollable element. - // This hack (see related code in patchDisplay) makes sure the - // element is kept around. - if (dy && mac && webkit) { - outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) { - for (var i = 0; i < view.length; i++) { - if (view[i].node == cur) { - cm.display.currentWheelTarget = cur; - break outer; - } - } - } - } - - // On some browsers, horizontal scrolling will cause redraws to - // happen before the gutter has been realigned, causing it to - // wriggle around in a most unseemly way. When we have an - // estimated pixels/delta value, we just handle horizontal - // scrolling entirely here. It'll be slightly off from native, but - // better than glitching out. - if (dx && !gecko && !presto && wheelPixelsPerUnit != null) { - if (dy) - setScrollTop(cm, Math.max(0, Math.min(scroll.scrollTop + dy * wheelPixelsPerUnit, scroll.scrollHeight - scroll.clientHeight))); - setScrollLeft(cm, Math.max(0, Math.min(scroll.scrollLeft + dx * wheelPixelsPerUnit, scroll.scrollWidth - scroll.clientWidth))); - e_preventDefault(e); - display.wheelStartX = null; // Abort measurement, if in progress - return; - } - - // 'Project' the visible viewport to cover the area that is being - // scrolled into view (if we know enough to estimate it). - if (dy && wheelPixelsPerUnit != null) { - var pixels = dy * wheelPixelsPerUnit; - var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight; - if (pixels < 0) - top = Math.max(0, top + pixels - 50); - else - bot = Math.min(cm.doc.height, bot + pixels + 50); - updateDisplay(cm, {top: top, bottom: bot}); - } - - if (wheelSamples < 20) { - if (display.wheelStartX == null) { - display.wheelStartX = scroll.scrollLeft; - display.wheelStartY = scroll.scrollTop; - display.wheelDX = dx; - display.wheelDY = dy; - setTimeout(function () { - if (display.wheelStartX == null) - return; - var movedX = scroll.scrollLeft - display.wheelStartX; - var movedY = scroll.scrollTop - display.wheelStartY; - var sample = (movedY && display.wheelDY && movedY / display.wheelDY) || - (movedX && display.wheelDX && movedX / display.wheelDX); - display.wheelStartX = display.wheelStartY = null; - if (!sample) - return; - wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1); - ++wheelSamples; - }, 200); - } else { - display.wheelDX += dx; - display.wheelDY += dy; - } - } - } - - // KEY EVENTS - - // Run a handler that was bound to a key. - function doHandleBinding(cm, bound, dropShift) { - if (typeof bound == "string") { - bound = commands[bound]; - if (!bound) - return false; - } - // Ensure previous input has been read, so that the handler sees a - // consistent view of the document - if (cm.display.pollingFast && readInput(cm)) - cm.display.pollingFast = false; - var prevShift = cm.display.shift, done = false; - try { - if (isReadOnly(cm)) - cm.state.suppressEdits = true; - if (dropShift) - cm.display.shift = false; - done = bound(cm) != Pass; - } finally { - cm.display.shift = prevShift; - cm.state.suppressEdits = false; - } - return done; - } - - // Collect the currently active keymaps. - function allKeyMaps(cm) { - var maps = cm.state.keyMaps.slice(0); - if (cm.options.extraKeys) - maps.push(cm.options.extraKeys); - maps.push(cm.options.keyMap); - return maps; - } - - var maybeTransition; - // Handle a key from the keydown event. - function handleKeyBinding(cm, e) { - // Handle automatic keymap transitions - var startMap = getKeyMap(cm.options.keyMap), next = startMap.auto; - clearTimeout(maybeTransition); - if (next && !isModifierKey(e)) - maybeTransition = setTimeout(function () { - if (getKeyMap(cm.options.keyMap) == startMap) { - cm.options.keyMap = (next.call ? next.call(null, cm) : next); - keyMapChanged(cm); - } - }, 50); - - var name = keyName(e, true), handled = false; - if (!name) - return false; - var keymaps = allKeyMaps(cm); - - if (e.shiftKey) { - // First try to resolve full name (including 'Shift-'). Failing - // that, see if there is a cursor-motion command (starting with - // 'go') bound to the keyname without 'Shift-'. - handled = lookupKey("Shift-" + name, keymaps, function (b) { - return doHandleBinding(cm, b, true); - }) - || lookupKey(name, keymaps, function (b) { - if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion) - return doHandleBinding(cm, b); - }); - } else { - handled = lookupKey(name, keymaps, function (b) { - return doHandleBinding(cm, b); - }); - } - - if (handled) { - e_preventDefault(e); - restartBlink(cm); - signalLater(cm, "keyHandled", cm, name, e); - } - return handled; - } - - // Handle a key from the keypress event - function handleCharBinding(cm, e, ch) { - var handled = lookupKey("'" + ch + "'", allKeyMaps(cm), - function (b) { - return doHandleBinding(cm, b, true); - }); - if (handled) { - e_preventDefault(e); - restartBlink(cm); - signalLater(cm, "keyHandled", cm, "'" + ch + "'", e); - } - return handled; - } - - var lastStoppedKey = null; - function onKeyDown(e) { - var cm = this; - ensureFocus(cm); - if (signalDOMEvent(cm, e)) - return; - // IE does strange things with escape. - if (ie_upto10 && e.keyCode == 27) - e.returnValue = false; - var code = e.keyCode; - cm.display.shift = code == 16 || e.shiftKey; - var handled = handleKeyBinding(cm, e); - if (presto) { - lastStoppedKey = handled ? code : null; - // Opera has no cut event... we try to at least catch the key combo - if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey)) - cm.replaceSelection("", null, "cut"); - } - } - - function onKeyUp(e) { - if (signalDOMEvent(this, e)) - return; - if (e.keyCode == 16) - this.doc.sel.shift = false; - } - - function onKeyPress(e) { - var cm = this; - if (signalDOMEvent(cm, e)) - return; - var keyCode = e.keyCode, charCode = e.charCode; - if (presto && keyCode == lastStoppedKey) { - lastStoppedKey = null; - e_preventDefault(e); - return; - } - if (((presto && (!e.which || e.which < 10)) || khtml) && handleKeyBinding(cm, e)) - return; - var ch = String.fromCharCode(charCode == null ? keyCode : charCode); - if (handleCharBinding(cm, e, ch)) - return; - if (ie && !ie_upto8) - cm.display.inputHasSelection = null; - fastPoll(cm); - } - - // FOCUS/BLUR EVENTS - - function onFocus(cm) { - if (cm.options.readOnly == "nocursor") - return; - if (!cm.state.focused) { - signal(cm, "focus", cm); - cm.state.focused = true; - if (cm.display.wrapper.className.search(/\bCodeMirror-focused\b/) == -1) - cm.display.wrapper.className += " CodeMirror-focused"; - if (!cm.curOp) { - resetInput(cm); - if (webkit) - setTimeout(bind(resetInput, cm, true), 0); // Issue #1730 - } - } - slowPoll(cm); - restartBlink(cm); - } - function onBlur(cm) { - if (cm.state.focused) { - signal(cm, "blur", cm); - cm.state.focused = false; - cm.display.wrapper.className = cm.display.wrapper.className.replace(" CodeMirror-focused", ""); - } - clearInterval(cm.display.blinker); - setTimeout(function () { - if (!cm.state.focused) - cm.display.shift = false; - }, 150); - } - - // CONTEXT MENU HANDLING - - var detectingSelectAll; - // To make the context menu work, we need to briefly unhide the - // textarea (making it as unobtrusive as possible) to let the - // right-click take effect on it. - function onContextMenu(cm, e) { - if (signalDOMEvent(cm, e, "contextmenu")) - return; - var display = cm.display; - if (eventInWidget(display, e) || contextMenuInGutter(cm, e)) - return; - - var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop; - if (!pos || presto) - return; // Opera is difficult. - - // Reset the current text selection only if the click is done outside of the selection - // and 'resetSelectionOnContextMenu' option is true. - var reset = cm.options.resetSelectionOnContextMenu; - if (reset && cm.doc.sel.contains(pos) == -1) - operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll); - - var oldCSS = display.input.style.cssText; - display.inputDiv.style.position = "absolute"; - display.input.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.clientY - 5) + - "px; left: " + (e.clientX - 5) + "px; z-index: 1000; background: " + - (ie ? "rgba(255, 255, 255, .05)" : "transparent") + - "; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);"; - focusInput(cm); - resetInput(cm); - // Adds "Select all" to context menu in FF - if (!cm.somethingSelected()) - display.input.value = display.prevInput = " "; - - // Select-all will be greyed out if there's nothing to select, so - // this adds a zero-width space so that we can later check whether - // it got selected. - function prepareSelectAllHack() { - if (display.input.selectionStart != null) { - var extval = display.input.value = "\u200b" + (cm.somethingSelected() ? display.input.value : ""); - display.prevInput = "\u200b"; - display.input.selectionStart = 1; - display.input.selectionEnd = extval.length; - } - } - function rehide() { - display.inputDiv.style.position = "relative"; - display.input.style.cssText = oldCSS; - if (ie_upto8) - display.scrollbarV.scrollTop = display.scroller.scrollTop = scrollPos; - slowPoll(cm); - - // Try to detect the user choosing select-all - if (display.input.selectionStart != null) { - if (!ie || ie_upto8) - prepareSelectAllHack(); - clearTimeout(detectingSelectAll); - var i = 0, poll = function () { - if (display.prevInput == "\u200b" && display.input.selectionStart == 0) - operation(cm, commands.selectAll)(cm); - else if (i++ < 10) - detectingSelectAll = setTimeout(poll, 500); - else - resetInput(cm); - }; - detectingSelectAll = setTimeout(poll, 200); - } - } - - if (ie && !ie_upto8) - prepareSelectAllHack(); - if (captureRightClick) { - e_stop(e); - var mouseup = function () { - off(window, "mouseup", mouseup); - setTimeout(rehide, 20); - }; - on(window, "mouseup", mouseup); - } else { - setTimeout(rehide, 50); - } - } - - function contextMenuInGutter(cm, e) { - if (!hasHandler(cm, "gutterContextMenu")) - return false; - return gutterEvent(cm, e, "gutterContextMenu", false, signal); - } - - // UPDATING - - // Compute the position of the end of a change (its 'to' property - // refers to the pre-change end). - var changeEnd = CodeMirror.changeEnd = function (change) { - if (!change.text) - return change.to; - return Pos(change.from.line + change.text.length - 1, - lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0)); - }; - - // Adjust a position to refer to the post-change position of the - // same text, or the end of the change if the change covers it. - function adjustForChange(pos, change) { - if (cmp(pos, change.from) < 0) - return pos; - if (cmp(pos, change.to) <= 0) - return changeEnd(change); - - var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch; - if (pos.line == change.to.line) - ch += changeEnd(change).ch - change.to.ch; - return Pos(line, ch); - } - - function computeSelAfterChange(doc, change) { - var out = []; - for (var i = 0; i < doc.sel.ranges.length; i++) { - var range = doc.sel.ranges[i]; - out.push(new Range(adjustForChange(range.anchor, change), - adjustForChange(range.head, change))); - } - return normalizeSelection(out, doc.sel.primIndex); - } - - function offsetPos(pos, old, nw) { - if (pos.line == old.line) - return Pos(nw.line, pos.ch - old.ch + nw.ch); - else - return Pos(nw.line + (pos.line - old.line), pos.ch); - } - - // Used by replaceSelections to allow moving the selection to the - // start or around the replaced test. Hint may be "start" or "around". - function computeReplacedSel(doc, changes, hint) { - var out = []; - var oldPrev = Pos(doc.first, 0), newPrev = oldPrev; - for (var i = 0; i < changes.length; i++) { - var change = changes[i]; - var from = offsetPos(change.from, oldPrev, newPrev); - var to = offsetPos(changeEnd(change), oldPrev, newPrev); - oldPrev = change.to; - newPrev = to; - if (hint == "around") { - var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0; - out[i] = new Range(inv ? to : from, inv ? from : to); - } else { - out[i] = new Range(from, from); - } - } - return new Selection(out, doc.sel.primIndex); - } - - // Allow "beforeChange" event handlers to influence a change - function filterChange(doc, change, update) { - var obj = { - canceled: false, - from: change.from, - to: change.to, - text: change.text, - origin: change.origin, - cancel: function () { - this.canceled = true; - } - }; - if (update) - obj.update = function (from, to, text, origin) { - if (from) - this.from = clipPos(doc, from); - if (to) - this.to = clipPos(doc, to); - if (text) - this.text = text; - if (origin !== undefined) - this.origin = origin; - }; - signal(doc, "beforeChange", doc, obj); - if (doc.cm) - signal(doc.cm, "beforeChange", doc.cm, obj); - - if (obj.canceled) - return null; - return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin}; - } - - // Apply a change to a document, and add it to the document's - // history, and propagating it to all linked documents. - function makeChange(doc, change, ignoreReadOnly) { - if (doc.cm) { - if (!doc.cm.curOp) - return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly); - if (doc.cm.state.suppressEdits) - return; - } - - if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) { - change = filterChange(doc, change, true); - if (!change) - return; - } - - // Possibly split or suppress the update based on the presence - // of read-only spans in its range. - var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to); - if (split) { - for (var i = split.length - 1; i >= 0; --i) - makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text}); - } else { - makeChangeInner(doc, change); - } - } - - function makeChangeInner(doc, change) { - if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) - return; - var selAfter = computeSelAfterChange(doc, change); - addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN); - - makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change)); - var rebased = []; - - linkedDocs(doc, function (doc, sharedHist) { - if (!sharedHist && indexOf(rebased, doc.history) == -1) { - rebaseHist(doc.history, change); - rebased.push(doc.history); - } - makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change)); - }); - } - - // Revert a change stored in a document's history. - function makeChangeFromHistory(doc, type, allowSelectionOnly) { - if (doc.cm && doc.cm.state.suppressEdits) - return; - - var hist = doc.history, event, selAfter = doc.sel; - var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done; - - // Verify that there is a useable event (so that ctrl-z won't - // needlessly clear selection events) - for (var i = 0; i < source.length; i++) { - event = source[i]; - if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges) - break; - } - if (i == source.length) - return; - hist.lastOrigin = hist.lastSelOrigin = null; - - for (; ; ) { - event = source.pop(); - if (event.ranges) { - pushSelectionToHistory(event, dest); - if (allowSelectionOnly && !event.equals(doc.sel)) { - setSelection(doc, event, {clearRedo: false}); - return; - } - selAfter = event; - } - else - break; - } - - // Build up a reverse change object to add to the opposite history - // stack (redo when undoing, and vice versa). - var antiChanges = []; - pushSelectionToHistory(selAfter, dest); - dest.push({changes: antiChanges, generation: hist.generation}); - hist.generation = event.generation || ++hist.maxGeneration; - - var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange"); - - for (var i = event.changes.length - 1; i >= 0; --i) { - var change = event.changes[i]; - change.origin = type; - if (filter && !filterChange(doc, change, false)) { - source.length = 0; - return; - } - - antiChanges.push(historyChangeFromChange(doc, change)); - - var after = i ? computeSelAfterChange(doc, change, null) : lst(source); - makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change)); - if (doc.cm) - ensureCursorVisible(doc.cm); - var rebased = []; - - // Propagate to the linked documents - linkedDocs(doc, function (doc, sharedHist) { - if (!sharedHist && indexOf(rebased, doc.history) == -1) { - rebaseHist(doc.history, change); - rebased.push(doc.history); - } - makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change)); - }); - } - } - - // Sub-views need their line numbers shifted when text is added - // above or below them in the parent document. - function shiftDoc(doc, distance) { - doc.first += distance; - doc.sel = new Selection(map(doc.sel.ranges, function (range) { - return new Range(Pos(range.anchor.line + distance, range.anchor.ch), - Pos(range.head.line + distance, range.head.ch)); - }), doc.sel.primIndex); - if (doc.cm) - regChange(doc.cm, doc.first, doc.first - distance, distance); - } - - // More lower-level change function, handling only a single document - // (not linked ones). - function makeChangeSingleDoc(doc, change, selAfter, spans) { - if (doc.cm && !doc.cm.curOp) - return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans); - - if (change.to.line < doc.first) { - shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line)); - return; - } - if (change.from.line > doc.lastLine()) - return; - - // Clip the change to the size of this doc - if (change.from.line < doc.first) { - var shift = change.text.length - 1 - (doc.first - change.from.line); - shiftDoc(doc, shift); - change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch), - text: [lst(change.text)], origin: change.origin}; - } - var last = doc.lastLine(); - if (change.to.line > last) { - change = {from: change.from, to: Pos(last, getLine(doc, last).text.length), - text: [change.text[0]], origin: change.origin}; - } - - change.removed = getBetween(doc, change.from, change.to); - - if (!selAfter) - selAfter = computeSelAfterChange(doc, change, null); - if (doc.cm) - makeChangeSingleDocInEditor(doc.cm, change, spans); - else - updateDoc(doc, change, spans); - setSelectionNoUndo(doc, selAfter, sel_dontScroll); - } - - // Handle the interaction of a change to a document with the editor - // that this document is part of. - function makeChangeSingleDocInEditor(cm, change, spans) { - var doc = cm.doc, display = cm.display, from = change.from, to = change.to; - - var recomputeMaxLength = false, checkWidthStart = from.line; - if (!cm.options.lineWrapping) { - checkWidthStart = lineNo(visualLine(getLine(doc, from.line))); - doc.iter(checkWidthStart, to.line + 1, function (line) { - if (line == display.maxLine) { - recomputeMaxLength = true; - return true; - } - }); - } - - if (doc.sel.contains(change.from, change.to) > -1) - cm.curOp.cursorActivity = true; - - updateDoc(doc, change, spans, estimateHeight(cm)); - - if (!cm.options.lineWrapping) { - doc.iter(checkWidthStart, from.line + change.text.length, function (line) { - var len = lineLength(line); - if (len > display.maxLineLength) { - display.maxLine = line; - display.maxLineLength = len; - display.maxLineChanged = true; - recomputeMaxLength = false; - } - }); - if (recomputeMaxLength) - cm.curOp.updateMaxLine = true; - } - - // Adjust frontier, schedule worker - doc.frontier = Math.min(doc.frontier, from.line); - startWorker(cm, 400); - - var lendiff = change.text.length - (to.line - from.line) - 1; - // Remember that these lines changed, for updating the display - if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change)) - regLineChange(cm, from.line, "text"); - else - regChange(cm, from.line, to.line + 1, lendiff); - - if (hasHandler(cm, "change") || hasHandler(cm, "changes")) - (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push({ - from: from, to: to, - text: change.text, - removed: change.removed, - origin: change.origin - }); - } - - function replaceRange(doc, code, from, to, origin) { - if (!to) - to = from; - if (cmp(to, from) < 0) { - var tmp = to; - to = from; - from = tmp; - } - if (typeof code == "string") - code = splitLines(code); - makeChange(doc, {from: from, to: to, text: code, origin: origin}); - } - - // SCROLLING THINGS INTO VIEW - - // If an editor sits on the top or bottom of the window, partially - // scrolled out of view, this ensures that the cursor is visible. - function maybeScrollWindow(cm, coords) { - var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null; - if (coords.top + box.top < 0) - doScroll = true; - else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) - doScroll = false; - if (doScroll != null && !phantom) { - var scrollNode = elt("div", "\u200b", null, "position: absolute; top: " + - (coords.top - display.viewOffset - paddingTop(cm.display)) + "px; height: " + - (coords.bottom - coords.top + scrollerCutOff) + "px; left: " + - coords.left + "px; width: 2px;"); - cm.display.lineSpace.appendChild(scrollNode); - scrollNode.scrollIntoView(doScroll); - cm.display.lineSpace.removeChild(scrollNode); - } - } - - // Scroll a given position into view (immediately), verifying that - // it actually became visible (as line heights are accurately - // measured, the position of something may 'drift' during drawing). - function scrollPosIntoView(cm, pos, end, margin) { - if (margin == null) - margin = 0; - for (; ; ) { - var changed = false, coords = cursorCoords(cm, pos); - var endCoords = !end || end == pos ? coords : cursorCoords(cm, end); - var scrollPos = calculateScrollPos(cm, Math.min(coords.left, endCoords.left), - Math.min(coords.top, endCoords.top) - margin, - Math.max(coords.left, endCoords.left), - Math.max(coords.bottom, endCoords.bottom) + margin); - var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft; - if (scrollPos.scrollTop != null) { - setScrollTop(cm, scrollPos.scrollTop); - if (Math.abs(cm.doc.scrollTop - startTop) > 1) - changed = true; - } - if (scrollPos.scrollLeft != null) { - setScrollLeft(cm, scrollPos.scrollLeft); - if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) - changed = true; - } - if (!changed) - return coords; - } - } - - // Scroll a given set of coordinates into view (immediately). - function scrollIntoView(cm, x1, y1, x2, y2) { - var scrollPos = calculateScrollPos(cm, x1, y1, x2, y2); - if (scrollPos.scrollTop != null) - setScrollTop(cm, scrollPos.scrollTop); - if (scrollPos.scrollLeft != null) - setScrollLeft(cm, scrollPos.scrollLeft); - } - - // Calculate a new scroll position needed to scroll the given - // rectangle into view. Returns an object with scrollTop and - // scrollLeft properties. When these are undefined, the - // vertical/horizontal position does not need to be adjusted. - function calculateScrollPos(cm, x1, y1, x2, y2) { - var display = cm.display, snapMargin = textHeight(cm.display); - if (y1 < 0) - y1 = 0; - var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop; - var screen = display.scroller.clientHeight - scrollerCutOff, result = {}; - var docBottom = cm.doc.height + paddingVert(display); - var atTop = y1 < snapMargin, atBottom = y2 > docBottom - snapMargin; - if (y1 < screentop) { - result.scrollTop = atTop ? 0 : y1; - } else if (y2 > screentop + screen) { - var newTop = Math.min(y1, (atBottom ? docBottom : y2) - screen); - if (newTop != screentop) - result.scrollTop = newTop; - } - - var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft; - var screenw = display.scroller.clientWidth - scrollerCutOff; - x1 += display.gutters.offsetWidth; - x2 += display.gutters.offsetWidth; - var gutterw = display.gutters.offsetWidth; - var atLeft = x1 < gutterw + 10; - if (x1 < screenleft + gutterw || atLeft) { - if (atLeft) - x1 = 0; - result.scrollLeft = Math.max(0, x1 - 10 - gutterw); - } else if (x2 > screenw + screenleft - 3) { - result.scrollLeft = x2 + 10 - screenw; - } - return result; - } - - // Store a relative adjustment to the scroll position in the current - // operation (to be applied when the operation finishes). - function addToScrollPos(cm, left, top) { - if (left != null || top != null) - resolveScrollToPos(cm); - if (left != null) - cm.curOp.scrollLeft = (cm.curOp.scrollLeft == null ? cm.doc.scrollLeft : cm.curOp.scrollLeft) + left; - if (top != null) - cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top; - } - - // Make sure that at the end of the operation the current cursor is - // shown. - function ensureCursorVisible(cm) { - resolveScrollToPos(cm); - var cur = cm.getCursor(), from = cur, to = cur; - if (!cm.options.lineWrapping) { - from = cur.ch ? Pos(cur.line, cur.ch - 1) : cur; - to = Pos(cur.line, cur.ch + 1); - } - cm.curOp.scrollToPos = {from: from, to: to, margin: cm.options.cursorScrollMargin, isCursor: true}; - } - - // When an operation has its scrollToPos property set, and another - // scroll action is applied before the end of the operation, this - // 'simulates' scrolling that position into view in a cheap way, so - // that the effect of intermediate scroll commands is not ignored. - function resolveScrollToPos(cm) { - var range = cm.curOp.scrollToPos; - if (range) { - cm.curOp.scrollToPos = null; - var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to); - var sPos = calculateScrollPos(cm, Math.min(from.left, to.left), - Math.min(from.top, to.top) - range.margin, - Math.max(from.right, to.right), - Math.max(from.bottom, to.bottom) + range.margin); - cm.scrollTo(sPos.scrollLeft, sPos.scrollTop); - } - } - - // API UTILITIES - - // Indent the given line. The how parameter can be "smart", - // "add"/null, "subtract", or "prev". When aggressive is false - // (typically set to true for forced single-line indents), empty - // lines are not indented, and places where the mode returns Pass - // are left alone. - function indentLine(cm, n, how, aggressive) { - var doc = cm.doc, state; - if (how == null) - how = "add"; - if (how == "smart") { - // Fall back to "prev" when the mode doesn't have an indentation - // method. - if (!cm.doc.mode.indent) - how = "prev"; - else - state = getStateBefore(cm, n); - } - - var tabSize = cm.options.tabSize; - var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize); - if (line.stateAfter) - line.stateAfter = null; - var curSpaceString = line.text.match(/^\s*/)[0], indentation; - if (!aggressive && !/\S/.test(line.text)) { - indentation = 0; - how = "not"; - } else if (how == "smart") { - indentation = cm.doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text); - if (indentation == Pass) { - if (!aggressive) - return; - how = "prev"; - } - } - if (how == "prev") { - if (n > doc.first) - indentation = countColumn(getLine(doc, n - 1).text, null, tabSize); - else - indentation = 0; - } else if (how == "add") { - indentation = curSpace + cm.options.indentUnit; - } else if (how == "subtract") { - indentation = curSpace - cm.options.indentUnit; - } else if (typeof how == "number") { - indentation = curSpace + how; - } - indentation = Math.max(0, indentation); - - var indentString = "", pos = 0; - if (cm.options.indentWithTabs) - for (var i = Math.floor(indentation / tabSize); i; --i) { - pos += tabSize; - indentString += "\t"; - } - if (pos < indentation) - indentString += spaceStr(indentation - pos); - - if (indentString != curSpaceString) { - replaceRange(cm.doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input"); - } else { - // Ensure that, if the cursor was in the whitespace at the start - // of the line, it is moved to the end of that space. - for (var i = 0; i < doc.sel.ranges.length; i++) { - var range = doc.sel.ranges[i]; - if (range.head.line == n && range.head.ch < curSpaceString.length) { - var pos = Pos(n, curSpaceString.length); - replaceOneSelection(doc, i, new Range(pos, pos)); - break; - } - } - } - line.stateAfter = null; - } - - // Utility for applying a change to a line by handle or number, - // returning the number and optionally registering the line as - // changed. - function changeLine(cm, handle, changeType, op) { - var no = handle, line = handle, doc = cm.doc; - if (typeof handle == "number") - line = getLine(doc, clipLine(doc, handle)); - else - no = lineNo(handle); - if (no == null) - return null; - if (op(line, no)) - regLineChange(cm, no, changeType); - else - return null; - return line; - } - - // Helper for deleting text near the selection(s), used to implement - // backspace, delete, and similar functionality. - function deleteNearSelection(cm, compute) { - var ranges = cm.doc.sel.ranges, kill = []; - // Build up a set of ranges to kill first, merging overlapping - // ranges. - for (var i = 0; i < ranges.length; i++) { - var toKill = compute(ranges[i]); - while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) { - var replaced = kill.pop(); - if (cmp(replaced.from, toKill.from) < 0) { - toKill.from = replaced.from; - break; - } - } - kill.push(toKill); - } - // Next, remove those actual ranges. - runInOp(cm, function () { - for (var i = kill.length - 1; i >= 0; i--) - replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete"); - ensureCursorVisible(cm); - }); - } - - // Used for horizontal relative motion. Dir is -1 or 1 (left or - // right), unit can be "char", "column" (like char, but doesn't - // cross line boundaries), "word" (across next word), or "group" (to - // the start of next group of word or non-word-non-whitespace - // chars). The visually param controls whether, in right-to-left - // text, direction 1 means to move towards the next index in the - // string, or towards the character to the right of the current - // position. The resulting position will have a hitSide=true - // property if it reached the end of the document. - function findPosH(doc, pos, dir, unit, visually) { - var line = pos.line, ch = pos.ch, origDir = dir; - var lineObj = getLine(doc, line); - var possible = true; - function findNextLine() { - var l = line + dir; - if (l < doc.first || l >= doc.first + doc.size) - return (possible = false); - line = l; - return lineObj = getLine(doc, l); - } - function moveOnce(boundToLine) { - var next = (visually ? moveVisually : moveLogically)(lineObj, ch, dir, true); - if (next == null) { - if (!boundToLine && findNextLine()) { - if (visually) - ch = (dir < 0 ? lineRight : lineLeft)(lineObj); - else - ch = dir < 0 ? lineObj.text.length : 0; - } else - return (possible = false); - } else - ch = next; - return true; - } - - if (unit == "char") - moveOnce(); - else if (unit == "column") - moveOnce(true); - else if (unit == "word" || unit == "group") { - var sawType = null, group = unit == "group"; - for (var first = true; ; first = false) { - if (dir < 0 && !moveOnce(!first)) - break; - var cur = lineObj.text.charAt(ch) || "\n"; - var type = isWordChar(cur) ? "w" - : group && cur == "\n" ? "n" - : !group || /\s/.test(cur) ? null - : "p"; - if (group && !first && !type) - type = "s"; - if (sawType && sawType != type) { - if (dir < 0) { - dir = 1; - moveOnce(); - } - break; - } - - if (type) - sawType = type; - if (dir > 0 && !moveOnce(!first)) - break; - } - } - var result = skipAtomic(doc, Pos(line, ch), origDir, true); - if (!possible) - result.hitSide = true; - return result; - } - - // For relative vertical movement. Dir may be -1 or 1. Unit can be - // "page" or "line". The resulting position will have a hitSide=true - // property if it reached the end of the document. - function findPosV(cm, pos, dir, unit) { - var doc = cm.doc, x = pos.left, y; - if (unit == "page") { - var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight); - y = pos.top + dir * (pageSize - (dir < 0 ? 1.5 : .5) * textHeight(cm.display)); - } else if (unit == "line") { - y = dir > 0 ? pos.bottom + 3 : pos.top - 3; - } - for (; ; ) { - var target = coordsChar(cm, x, y); - if (!target.outside) - break; - if (dir < 0 ? y <= 0 : y >= doc.height) { - target.hitSide = true; - break; - } - y += dir * 5; - } - return target; - } - - // Find the word at the given position (as returned by coordsChar). - function findWordAt(doc, pos) { - var line = getLine(doc, pos.line).text; - var start = pos.ch, end = pos.ch; - if (line) { - if ((pos.xRel < 0 || end == line.length) && start) - --start; - else - ++end; - var startChar = line.charAt(start); - var check = isWordChar(startChar) ? isWordChar - : /\s/.test(startChar) ? function (ch) { - return /\s/.test(ch); - } - : function (ch) { - return !/\s/.test(ch) && !isWordChar(ch); - }; - while (start > 0 && check(line.charAt(start - 1))) - --start; - while (end < line.length && check(line.charAt(end))) - ++end; - } - return new Range(Pos(pos.line, start), Pos(pos.line, end)); - } - - // EDITOR METHODS - - // The publicly visible API. Note that methodOp(f) means - // 'wrap f in an operation, performed on its `this` parameter'. - - // This is not the complete set of editor methods. Most of the - // methods defined on the Doc type are also injected into - // CodeMirror.prototype, for backwards compatibility and - // convenience. - - CodeMirror.prototype = { - constructor: CodeMirror, - focus: function () { - window.focus(); - focusInput(this); - fastPoll(this); - }, - setOption: function (option, value) { - var options = this.options, old = options[option]; - if (options[option] == value && option != "mode") - return; - options[option] = value; - if (optionHandlers.hasOwnProperty(option)) - operation(this, optionHandlers[option])(this, value, old); - }, - getOption: function (option) { - return this.options[option]; - }, - getDoc: function () { - return this.doc; - }, - addKeyMap: function (map, bottom) { - this.state.keyMaps[bottom ? "push" : "unshift"](map); - }, - removeKeyMap: function (map) { - var maps = this.state.keyMaps; - for (var i = 0; i < maps.length; ++i) - if (maps[i] == map || (typeof maps[i] != "string" && maps[i].name == map)) { - maps.splice(i, 1); - return true; - } - }, - addOverlay: methodOp(function (spec, options) { - var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec); - if (mode.startState) - throw new Error("Overlays may not be stateful."); - this.state.overlays.push({mode: mode, modeSpec: spec, opaque: options && options.opaque}); - this.state.modeGen++; - regChange(this); - }), - removeOverlay: methodOp(function (spec) { - var overlays = this.state.overlays; - for (var i = 0; i < overlays.length; ++i) { - var cur = overlays[i].modeSpec; - if (cur == spec || typeof spec == "string" && cur.name == spec) { - overlays.splice(i, 1); - this.state.modeGen++; - regChange(this); - return; - } - } - }), - indentLine: methodOp(function (n, dir, aggressive) { - if (typeof dir != "string" && typeof dir != "number") { - if (dir == null) - dir = this.options.smartIndent ? "smart" : "prev"; - else - dir = dir ? "add" : "subtract"; - } - if (isLine(this.doc, n)) - indentLine(this, n, dir, aggressive); - }), - indentSelection: methodOp(function (how) { - var ranges = this.doc.sel.ranges, end = -1; - for (var i = 0; i < ranges.length; i++) { - var range = ranges[i]; - if (!range.empty()) { - var start = Math.max(end, range.from().line); - var to = range.to(); - end = Math.min(this.lastLine(), to.line - (to.ch ? 0 : 1)) + 1; - for (var j = start; j < end; ++j) - indentLine(this, j, how); - } else if (range.head.line > end) { - indentLine(this, range.head.line, how, true); - end = range.head.line; - if (i == this.doc.sel.primIndex) - ensureCursorVisible(this); - } - } - }), - // Fetch the parser token for a given character. Useful for hacks - // that want to inspect the mode state (say, for completion). - getTokenAt: function (pos, precise) { - var doc = this.doc; - pos = clipPos(doc, pos); - var state = getStateBefore(this, pos.line, precise), mode = this.doc.mode; - var line = getLine(doc, pos.line); - var stream = new StringStream(line.text, this.options.tabSize); - while (stream.pos < pos.ch && !stream.eol()) { - stream.start = stream.pos; - var style = mode.token(stream, state); - } - return {start: stream.start, - end: stream.pos, - string: stream.current(), - type: style || null, - state: state}; - }, - getTokenTypeAt: function (pos) { - pos = clipPos(this.doc, pos); - var styles = getLineStyles(this, getLine(this.doc, pos.line)); - var before = 0, after = (styles.length - 1) / 2, ch = pos.ch; - if (ch == 0) - return styles[2]; - for (; ; ) { - var mid = (before + after) >> 1; - if ((mid ? styles[mid * 2 - 1] : 0) >= ch) - after = mid; - else if (styles[mid * 2 + 1] < ch) - before = mid + 1; - else - return styles[mid * 2 + 2]; - } - }, - getModeAt: function (pos) { - var mode = this.doc.mode; - if (!mode.innerMode) - return mode; - return CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode; - }, - getHelper: function (pos, type) { - return this.getHelpers(pos, type)[0]; - }, - getHelpers: function (pos, type) { - var found = []; - if (!helpers.hasOwnProperty(type)) - return helpers; - var help = helpers[type], mode = this.getModeAt(pos); - if (typeof mode[type] == "string") { - if (help[mode[type]]) - found.push(help[mode[type]]); - } else if (mode[type]) { - for (var i = 0; i < mode[type].length; i++) { - var val = help[mode[type][i]]; - if (val) - found.push(val); - } - } else if (mode.helperType && help[mode.helperType]) { - found.push(help[mode.helperType]); - } else if (help[mode.name]) { - found.push(help[mode.name]); - } - for (var i = 0; i < help._global.length; i++) { - var cur = help._global[i]; - if (cur.pred(mode, this) && indexOf(found, cur.val) == -1) - found.push(cur.val); - } - return found; - }, - getStateAfter: function (line, precise) { - var doc = this.doc; - line = clipLine(doc, line == null ? doc.first + doc.size - 1 : line); - return getStateBefore(this, line + 1, precise); - }, - cursorCoords: function (start, mode) { - var pos, range = this.doc.sel.primary(); - if (start == null) - pos = range.head; - else if (typeof start == "object") - pos = clipPos(this.doc, start); - else - pos = start ? range.from() : range.to(); - return cursorCoords(this, pos, mode || "page"); - }, - charCoords: function (pos, mode) { - return charCoords(this, clipPos(this.doc, pos), mode || "page"); - }, - coordsChar: function (coords, mode) { - coords = fromCoordSystem(this, coords, mode || "page"); - return coordsChar(this, coords.left, coords.top); - }, - lineAtHeight: function (height, mode) { - height = fromCoordSystem(this, {top: height, left: 0}, mode || "page").top; - return lineAtHeight(this.doc, height + this.display.viewOffset); - }, - heightAtLine: function (line, mode) { - var end = false, last = this.doc.first + this.doc.size - 1; - if (line < this.doc.first) - line = this.doc.first; - else if (line > last) { - line = last; - end = true; - } - var lineObj = getLine(this.doc, line); - return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page").top + - (end ? this.doc.height - heightAtLine(lineObj) : 0); - }, - defaultTextHeight: function () { - return textHeight(this.display); - }, - defaultCharWidth: function () { - return charWidth(this.display); - }, - setGutterMarker: methodOp(function (line, gutterID, value) { - return changeLine(this, line, "gutter", function (line) { - var markers = line.gutterMarkers || (line.gutterMarkers = {}); - markers[gutterID] = value; - if (!value && isEmpty(markers)) - line.gutterMarkers = null; - return true; - }); - }), - clearGutter: methodOp(function (gutterID) { - var cm = this, doc = cm.doc, i = doc.first; - doc.iter(function (line) { - if (line.gutterMarkers && line.gutterMarkers[gutterID]) { - line.gutterMarkers[gutterID] = null; - regLineChange(cm, i, "gutter"); - if (isEmpty(line.gutterMarkers)) - line.gutterMarkers = null; - } - ++i; - }); - }), - addLineClass: methodOp(function (handle, where, cls) { - return changeLine(this, handle, "class", function (line) { - var prop = where == "text" ? "textClass" : where == "background" ? "bgClass" : "wrapClass"; - if (!line[prop]) - line[prop] = cls; - else if (new RegExp("(?:^|\\s)" + cls + "(?:$|\\s)").test(line[prop])) - return false; - else - line[prop] += " " + cls; - return true; - }); - }), - removeLineClass: methodOp(function (handle, where, cls) { - return changeLine(this, handle, "class", function (line) { - var prop = where == "text" ? "textClass" : where == "background" ? "bgClass" : "wrapClass"; - var cur = line[prop]; - if (!cur) - return false; - else if (cls == null) - line[prop] = null; - else { - var found = cur.match(new RegExp("(?:^|\\s+)" + cls + "(?:$|\\s+)")); - if (!found) - return false; - var end = found.index + found[0].length; - line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null; - } - return true; - }); - }), - addLineWidget: methodOp(function (handle, node, options) { - return addLineWidget(this, handle, node, options); - }), - removeLineWidget: function (widget) { - widget.clear(); - }, - lineInfo: function (line) { - if (typeof line == "number") { - if (!isLine(this.doc, line)) - return null; - var n = line; - line = getLine(this.doc, line); - if (!line) - return null; - } else { - var n = lineNo(line); - if (n == null) - return null; - } - return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers, - textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass, - widgets: line.widgets}; - }, - getViewport: function () { - return {from: this.display.viewFrom, to: this.display.viewTo}; - }, - addWidget: function (pos, node, scroll, vert, horiz) { - var display = this.display; - pos = cursorCoords(this, clipPos(this.doc, pos)); - var top = pos.bottom, left = pos.left; - node.style.position = "absolute"; - display.sizer.appendChild(node); - if (vert == "over") { - top = pos.top; - } else if (vert == "above" || vert == "near") { - var vspace = Math.max(display.wrapper.clientHeight, this.doc.height), - hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth); - // Default to positioning above (if specified and possible); otherwise default to positioning below - if ((vert == 'above' || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight) - top = pos.top - node.offsetHeight; - else if (pos.bottom + node.offsetHeight <= vspace) - top = pos.bottom; - if (left + node.offsetWidth > hspace) - left = hspace - node.offsetWidth; - } - node.style.top = top + "px"; - node.style.left = node.style.right = ""; - if (horiz == "right") { - left = display.sizer.clientWidth - node.offsetWidth; - node.style.right = "0px"; - } else { - if (horiz == "left") - left = 0; - else if (horiz == "middle") - left = (display.sizer.clientWidth - node.offsetWidth) / 2; - node.style.left = left + "px"; - } - if (scroll) - scrollIntoView(this, left, top, left + node.offsetWidth, top + node.offsetHeight); - }, - triggerOnKeyDown: methodOp(onKeyDown), - triggerOnKeyPress: methodOp(onKeyPress), - triggerOnKeyUp: methodOp(onKeyUp), - execCommand: function (cmd) { - if (commands.hasOwnProperty(cmd)) - return commands[cmd](this); - }, - findPosH: function (from, amount, unit, visually) { - var dir = 1; - if (amount < 0) { - dir = -1; - amount = -amount; - } - for (var i = 0, cur = clipPos(this.doc, from); i < amount; ++i) { - cur = findPosH(this.doc, cur, dir, unit, visually); - if (cur.hitSide) - break; - } - return cur; - }, - moveH: methodOp(function (dir, unit) { - var cm = this; - cm.extendSelectionsBy(function (range) { - if (cm.display.shift || cm.doc.extend || range.empty()) - return findPosH(cm.doc, range.head, dir, unit, cm.options.rtlMoveVisually); - else - return dir < 0 ? range.from() : range.to(); - }, sel_move); - }), - deleteH: methodOp(function (dir, unit) { - var sel = this.doc.sel, doc = this.doc; - if (sel.somethingSelected()) - doc.replaceSelection("", null, "+delete"); - else - deleteNearSelection(this, function (range) { - var other = findPosH(doc, range.head, dir, unit, false); - return dir < 0 ? {from: other, to: range.head} : {from: range.head, to: other}; - }); - }), - findPosV: function (from, amount, unit, goalColumn) { - var dir = 1, x = goalColumn; - if (amount < 0) { - dir = -1; - amount = -amount; - } - for (var i = 0, cur = clipPos(this.doc, from); i < amount; ++i) { - var coords = cursorCoords(this, cur, "div"); - if (x == null) - x = coords.left; - else - coords.left = x; - cur = findPosV(this, coords, dir, unit); - if (cur.hitSide) - break; - } - return cur; - }, - moveV: methodOp(function (dir, unit) { - var cm = this, doc = this.doc, goals = []; - var collapse = !cm.display.shift && !doc.extend && doc.sel.somethingSelected(); - doc.extendSelectionsBy(function (range) { - if (collapse) - return dir < 0 ? range.from() : range.to(); - var headPos = cursorCoords(cm, range.head, "div"); - if (range.goalColumn != null) - headPos.left = range.goalColumn; - goals.push(headPos.left); - var pos = findPosV(cm, headPos, dir, unit); - if (unit == "page" && range == doc.sel.primary()) - addToScrollPos(cm, null, charCoords(cm, pos, "div").top - headPos.top); - return pos; - }, sel_move); - if (goals.length) - for (var i = 0; i < doc.sel.ranges.length; i++) - doc.sel.ranges[i].goalColumn = goals[i]; - }), - toggleOverwrite: function (value) { - if (value != null && value == this.state.overwrite) - return; - if (this.state.overwrite = !this.state.overwrite) - this.display.cursorDiv.className += " CodeMirror-overwrite"; - else - this.display.cursorDiv.className = this.display.cursorDiv.className.replace(" CodeMirror-overwrite", ""); - - signal(this, "overwriteToggle", this, this.state.overwrite); - }, - hasFocus: function () { - return activeElt() == this.display.input; - }, - scrollTo: methodOp(function (x, y) { - if (x != null || y != null) - resolveScrollToPos(this); - if (x != null) - this.curOp.scrollLeft = x; - if (y != null) - this.curOp.scrollTop = y; - }), - getScrollInfo: function () { - var scroller = this.display.scroller, co = scrollerCutOff; - return {left: scroller.scrollLeft, top: scroller.scrollTop, - height: scroller.scrollHeight - co, width: scroller.scrollWidth - co, - clientHeight: scroller.clientHeight - co, clientWidth: scroller.clientWidth - co}; - }, - scrollIntoView: methodOp(function (range, margin) { - if (range == null) { - range = {from: this.doc.sel.primary().head, to: null}; - if (margin == null) - margin = this.options.cursorScrollMargin; - } else if (typeof range == "number") { - range = {from: Pos(range, 0), to: null}; - } else if (range.from == null) { - range = {from: range, to: null}; - } - if (!range.to) - range.to = range.from; - range.margin = margin || 0; - - if (range.from.line != null) { - resolveScrollToPos(this); - this.curOp.scrollToPos = range; - } else { - var sPos = calculateScrollPos(this, Math.min(range.from.left, range.to.left), - Math.min(range.from.top, range.to.top) - range.margin, - Math.max(range.from.right, range.to.right), - Math.max(range.from.bottom, range.to.bottom) + range.margin); - this.scrollTo(sPos.scrollLeft, sPos.scrollTop); - } - }), - setSize: methodOp(function (width, height) { - function interpret(val) { - return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val; - } - if (width != null) - this.display.wrapper.style.width = interpret(width); - if (height != null) - this.display.wrapper.style.height = interpret(height); - if (this.options.lineWrapping) - clearLineMeasurementCache(this); - this.curOp.forceUpdate = true; - signal(this, "refresh", this); - }), - operation: function (f) { - return runInOp(this, f); - }, - refresh: methodOp(function () { - var oldHeight = this.display.cachedTextHeight; - regChange(this); - clearCaches(this); - this.scrollTo(this.doc.scrollLeft, this.doc.scrollTop); - if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5) - estimateLineHeights(this); - signal(this, "refresh", this); - }), - swapDoc: methodOp(function (doc) { - var old = this.doc; - old.cm = null; - attachDoc(this, doc); - clearCaches(this); - resetInput(this); - this.scrollTo(doc.scrollLeft, doc.scrollTop); - signalLater(this, "swapDoc", this, old); - return old; - }), - getInputField: function () { - return this.display.input; - }, - getWrapperElement: function () { - return this.display.wrapper; - }, - getScrollerElement: function () { - return this.display.scroller; - }, - getGutterElement: function () { - return this.display.gutters; - } - }; - eventMixin(CodeMirror); - - // OPTION DEFAULTS - - // The default configuration options. - var defaults = CodeMirror.defaults = {}; - // Functions to run when options are changed. - var optionHandlers = CodeMirror.optionHandlers = {}; - - function option(name, deflt, handle, notOnInit) { - CodeMirror.defaults[name] = deflt; - if (handle) - optionHandlers[name] = - notOnInit ? function (cm, val, old) { - if (old != Init) - handle(cm, val, old); - } : handle; - } - - // Passed to option handlers when there is no old value. - var Init = CodeMirror.Init = {toString: function () { - return "CodeMirror.Init"; - }}; - - // These two are, on init, called from the constructor because they - // have to be initialized before the editor can start at all. - option("value", "", function (cm, val) { - cm.setValue(val); - }, true); - option("mode", null, function (cm, val) { - cm.doc.modeOption = val; - loadMode(cm); - }, true); - - option("indentUnit", 2, loadMode, true); - option("indentWithTabs", false); - option("smartIndent", true); - option("tabSize", 4, function (cm) { - resetModeState(cm); - clearCaches(cm); - regChange(cm); - }, true); - option("specialChars", /[\t\u0000-\u0019\u00ad\u200b\u2028\u2029\ufeff]/g, function (cm, val) { - cm.options.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g"); - cm.refresh(); - }, true); - option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function (cm) { - cm.refresh(); - }, true); - option("electricChars", true); - option("rtlMoveVisually", !windows); - option("wholeLineUpdateBefore", true); - - option("theme", "default", function (cm) { - themeChanged(cm); - guttersChanged(cm); - }, true); - option("keyMap", "default", keyMapChanged); - option("extraKeys", null); - - option("lineWrapping", false, wrappingChanged, true); - option("gutters", [], function (cm) { - setGuttersForLineNumbers(cm.options); - guttersChanged(cm); - }, true); - option("fixedGutter", true, function (cm, val) { - cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0"; - cm.refresh(); - }, true); - option("coverGutterNextToScrollbar", false, updateScrollbars, true); - option("lineNumbers", false, function (cm) { - setGuttersForLineNumbers(cm.options); - guttersChanged(cm); - }, true); - option("firstLineNumber", 1, guttersChanged, true); - option("lineNumberFormatter", function (integer) { - return integer; - }, guttersChanged, true); - option("showCursorWhenSelecting", false, updateSelection, true); - - option("resetSelectionOnContextMenu", true); - - option("readOnly", false, function (cm, val) { - if (val == "nocursor") { - onBlur(cm); - cm.display.input.blur(); - cm.display.disabled = true; - } else { - cm.display.disabled = false; - if (!val) - resetInput(cm); - } - }); - option("disableInput", false, function (cm, val) { - if (!val) - resetInput(cm); - }, true); - option("dragDrop", true); - - option("cursorBlinkRate", 530); - option("cursorScrollMargin", 0); - option("cursorHeight", 1); - option("workTime", 100); - option("workDelay", 100); - option("flattenSpans", true, resetModeState, true); - option("addModeClass", false, resetModeState, true); - option("pollInterval", 100); - option("undoDepth", 200, function (cm, val) { - cm.doc.history.undoDepth = val; - }); - option("historyEventDelay", 1250); - option("viewportMargin", 10, function (cm) { - cm.refresh(); - }, true); - option("maxHighlightLength", 10000, resetModeState, true); - option("moveInputWithCursor", true, function (cm, val) { - if (!val) - cm.display.inputDiv.style.top = cm.display.inputDiv.style.left = 0; - }); - - option("tabindex", null, function (cm, val) { - cm.display.input.tabIndex = val || ""; - }); - option("autofocus", null); - - // MODE DEFINITION AND QUERYING - - // Known modes, by name and by MIME - var modes = CodeMirror.modes = {}, mimeModes = CodeMirror.mimeModes = {}; - - // Extra arguments are stored as the mode's dependencies, which is - // used by (legacy) mechanisms like loadmode.js to automatically - // load a mode. (Preferred mechanism is the require/define calls.) - CodeMirror.defineMode = function (name, mode) { - if (!CodeMirror.defaults.mode && name != "null") - CodeMirror.defaults.mode = name; - if (arguments.length > 2) { - mode.dependencies = []; - for (var i = 2; i < arguments.length; ++i) - mode.dependencies.push(arguments[i]); - } - modes[name] = mode; - }; - - CodeMirror.defineMIME = function (mime, spec) { - mimeModes[mime] = spec; - }; - - // Given a MIME type, a {name, ...options} config object, or a name - // string, return a mode config object. - CodeMirror.resolveMode = function (spec) { - if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) { - spec = mimeModes[spec]; - } else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) { - var found = mimeModes[spec.name]; - if (typeof found == "string") - found = {name: found}; - spec = createObj(found, spec); - spec.name = found.name; - } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) { - return CodeMirror.resolveMode("application/xml"); - } - if (typeof spec == "string") - return {name: spec}; - else - return spec || {name: "null"}; - }; - - // Given a mode spec (anything that resolveMode accepts), find and - // initialize an actual mode object. - CodeMirror.getMode = function (options, spec) { - var spec = CodeMirror.resolveMode(spec); - var mfactory = modes[spec.name]; - if (!mfactory) - return CodeMirror.getMode(options, "text/plain"); - var modeObj = mfactory(options, spec); - if (modeExtensions.hasOwnProperty(spec.name)) { - var exts = modeExtensions[spec.name]; - for (var prop in exts) { - if (!exts.hasOwnProperty(prop)) - continue; - if (modeObj.hasOwnProperty(prop)) - modeObj["_" + prop] = modeObj[prop]; - modeObj[prop] = exts[prop]; - } - } - modeObj.name = spec.name; - if (spec.helperType) - modeObj.helperType = spec.helperType; - if (spec.modeProps) - for (var prop in spec.modeProps) - modeObj[prop] = spec.modeProps[prop]; - - return modeObj; - }; - - // Minimal default mode. - CodeMirror.defineMode("null", function () { - return {token: function (stream) { - stream.skipToEnd(); - }}; - }); - CodeMirror.defineMIME("text/plain", "null"); - - // This can be used to attach properties to mode objects from - // outside the actual mode definition. - var modeExtensions = CodeMirror.modeExtensions = {}; - CodeMirror.extendMode = function (mode, properties) { - var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {}); - copyObj(properties, exts); - }; - - // EXTENSIONS - - CodeMirror.defineExtension = function (name, func) { - CodeMirror.prototype[name] = func; - }; - CodeMirror.defineDocExtension = function (name, func) { - Doc.prototype[name] = func; - }; - CodeMirror.defineOption = option; - - var initHooks = []; - CodeMirror.defineInitHook = function (f) { - initHooks.push(f); - }; - - var helpers = CodeMirror.helpers = {}; - CodeMirror.registerHelper = function (type, name, value) { - if (!helpers.hasOwnProperty(type)) - helpers[type] = CodeMirror[type] = {_global: []}; - helpers[type][name] = value; - }; - CodeMirror.registerGlobalHelper = function (type, name, predicate, value) { - CodeMirror.registerHelper(type, name, value); - helpers[type]._global.push({pred: predicate, val: value}); - }; - - // MODE STATE HANDLING - - // Utility functions for working with state. Exported because nested - // modes need to do this for their inner modes. - - var copyState = CodeMirror.copyState = function (mode, state) { - if (state === true) - return state; - if (mode.copyState) - return mode.copyState(state); - var nstate = {}; - for (var n in state) { - var val = state[n]; - if (val instanceof Array) - val = val.concat([]); - nstate[n] = val; - } - return nstate; - }; - - var startState = CodeMirror.startState = function (mode, a1, a2) { - return mode.startState ? mode.startState(a1, a2) : true; - }; - - // Given a mode and a state (for that mode), find the inner mode and - // state at the position that the state refers to. - CodeMirror.innerMode = function (mode, state) { - while (mode.innerMode) { - var info = mode.innerMode(state); - if (!info || info.mode == mode) - break; - state = info.state; - mode = info.mode; - } - return info || {mode: mode, state: state}; - }; - - // STANDARD COMMANDS - - // Commands are parameter-less actions that can be performed on an - // editor, mostly used for keybindings. - var commands = CodeMirror.commands = { - selectAll: function (cm) { - cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll); - }, - singleSelection: function (cm) { - cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll); - }, - killLine: function (cm) { - deleteNearSelection(cm, function (range) { - if (range.empty()) { - var len = getLine(cm.doc, range.head.line).text.length; - if (range.head.ch == len && range.head.line < cm.lastLine()) - return {from: range.head, to: Pos(range.head.line + 1, 0)}; - else - return {from: range.head, to: Pos(range.head.line, len)}; - } else { - return {from: range.from(), to: range.to()}; - } - }); - }, - deleteLine: function (cm) { - deleteNearSelection(cm, function (range) { - return {from: Pos(range.from().line, 0), - to: clipPos(cm.doc, Pos(range.to().line + 1, 0))}; - }); - }, - delLineLeft: function (cm) { - deleteNearSelection(cm, function (range) { - return {from: Pos(range.from().line, 0), to: range.from()}; - }); - }, - undo: function (cm) { - cm.undo(); - }, - redo: function (cm) { - cm.redo(); - }, - undoSelection: function (cm) { - cm.undoSelection(); - }, - redoSelection: function (cm) { - cm.redoSelection(); - }, - goDocStart: function (cm) { - cm.extendSelection(Pos(cm.firstLine(), 0)); - }, - goDocEnd: function (cm) { - cm.extendSelection(Pos(cm.lastLine())); - }, - goLineStart: function (cm) { - cm.extendSelectionsBy(function (range) { - return lineStart(cm, range.head.line); - }, sel_move); - }, - goLineStartSmart: function (cm) { - cm.extendSelectionsBy(function (range) { - var start = lineStart(cm, range.head.line); - var line = cm.getLineHandle(start.line); - var order = getOrder(line); - if (!order || order[0].level == 0) { - var firstNonWS = Math.max(0, line.text.search(/\S/)); - var inWS = range.head.line == start.line && range.head.ch <= firstNonWS && range.head.ch; - return Pos(start.line, inWS ? 0 : firstNonWS); - } - return start; - }, sel_move); - }, - goLineEnd: function (cm) { - cm.extendSelectionsBy(function (range) { - return lineEnd(cm, range.head.line); - }, sel_move); - }, - goLineRight: function (cm) { - cm.extendSelectionsBy(function (range) { - var top = cm.charCoords(range.head, "div").top + 5; - return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div"); - }, sel_move); - }, - goLineLeft: function (cm) { - cm.extendSelectionsBy(function (range) { - var top = cm.charCoords(range.head, "div").top + 5; - return cm.coordsChar({left: 0, top: top}, "div"); - }, sel_move); - }, - goLineUp: function (cm) { - cm.moveV(-1, "line"); - }, - goLineDown: function (cm) { - cm.moveV(1, "line"); - }, - goPageUp: function (cm) { - cm.moveV(-1, "page"); - }, - goPageDown: function (cm) { - cm.moveV(1, "page"); - }, - goCharLeft: function (cm) { - cm.moveH(-1, "char"); - }, - goCharRight: function (cm) { - cm.moveH(1, "char"); - }, - goColumnLeft: function (cm) { - cm.moveH(-1, "column"); - }, - goColumnRight: function (cm) { - cm.moveH(1, "column"); - }, - goWordLeft: function (cm) { - cm.moveH(-1, "word"); - }, - goGroupRight: function (cm) { - cm.moveH(1, "group"); - }, - goGroupLeft: function (cm) { - cm.moveH(-1, "group"); - }, - goWordRight: function (cm) { - cm.moveH(1, "word"); - }, - delCharBefore: function (cm) { - cm.deleteH(-1, "char"); - }, - delCharAfter: function (cm) { - cm.deleteH(1, "char"); - }, - delWordBefore: function (cm) { - cm.deleteH(-1, "word"); - }, - delWordAfter: function (cm) { - cm.deleteH(1, "word"); - }, - delGroupBefore: function (cm) { - cm.deleteH(-1, "group"); - }, - delGroupAfter: function (cm) { - cm.deleteH(1, "group"); - }, - indentAuto: function (cm) { - cm.indentSelection("smart"); - }, - indentMore: function (cm) { - cm.indentSelection("add"); - }, - indentLess: function (cm) { - cm.indentSelection("subtract"); - }, - insertTab: function (cm) { - cm.replaceSelection("\t"); - }, - defaultTab: function (cm) { - if (cm.somethingSelected()) - cm.indentSelection("add"); - else - cm.execCommand("insertTab"); - }, - transposeChars: function (cm) { - runInOp(cm, function () { - var ranges = cm.listSelections(); - for (var i = 0; i < ranges.length; i++) { - var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text; - if (cur.ch > 0 && cur.ch < line.length - 1) - cm.replaceRange(line.charAt(cur.ch) + line.charAt(cur.ch - 1), - Pos(cur.line, cur.ch - 1), Pos(cur.line, cur.ch + 1)); - } - }); - }, - newlineAndIndent: function (cm) { - runInOp(cm, function () { - var len = cm.listSelections().length; - for (var i = 0; i < len; i++) { - var range = cm.listSelections()[i]; - cm.replaceRange("\n", range.anchor, range.head, "+input"); - cm.indentLine(range.from().line + 1, null, true); - ensureCursorVisible(cm); - } - }); - }, - toggleOverwrite: function (cm) { - cm.toggleOverwrite(); - } - }; - - // STANDARD KEYMAPS - - var keyMap = CodeMirror.keyMap = {}; - keyMap.basic = { - "Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown", - "End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown", - "Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore", - "Tab": "defaultTab", "Shift-Tab": "indentAuto", - "Enter": "newlineAndIndent", "Insert": "toggleOverwrite", - "Esc": "singleSelection" - }; - // Note that the save and find-related commands aren't defined by - // default. User code or addons can define them. Unknown commands - // are simply ignored. - keyMap.pcDefault = { - "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo", - "Ctrl-Home": "goDocStart", "Ctrl-Up": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Down": "goDocEnd", - "Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd", - "Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find", - "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll", - "Ctrl-[": "indentLess", "Ctrl-]": "indentMore", - "Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection", - fallthrough: "basic" - }; - keyMap.macDefault = { - "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo", - "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft", - "Alt-Right": "goGroupRight", "Cmd-Left": "goLineStart", "Cmd-Right": "goLineEnd", "Alt-Backspace": "delGroupBefore", - "Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find", - "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll", - "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delLineLeft", - "Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", - fallthrough: ["basic", "emacsy"] - }; - // Very basic readline/emacs-style bindings, which are standard on Mac. - keyMap.emacsy = { - "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown", - "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd", - "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore", - "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars" - }; - keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault; - - // KEYMAP DISPATCH - - function getKeyMap(val) { - if (typeof val == "string") - return keyMap[val]; - else - return val; - } - - // Given an array of keymaps and a key name, call handle on any - // bindings found, until that returns a truthy value, at which point - // we consider the key handled. Implements things like binding a key - // to false stopping further handling and keymap fallthrough. - var lookupKey = CodeMirror.lookupKey = function (name, maps, handle) { - function lookup(map) { - map = getKeyMap(map); - var found = map[name]; - if (found === false) - return "stop"; - if (found != null && handle(found)) - return true; - if (map.nofallthrough) - return "stop"; - - var fallthrough = map.fallthrough; - if (fallthrough == null) - return false; - if (Object.prototype.toString.call(fallthrough) != "[object Array]") - return lookup(fallthrough); - for (var i = 0; i < fallthrough.length; ++i) { - var done = lookup(fallthrough[i]); - if (done) - return done; - } - return false; - } - - for (var i = 0; i < maps.length; ++i) { - var done = lookup(maps[i]); - if (done) - return done != "stop"; - } - }; - - // Modifier key presses don't count as 'real' key presses for the - // purpose of keymap fallthrough. - var isModifierKey = CodeMirror.isModifierKey = function (event) { - var name = keyNames[event.keyCode]; - return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod"; - }; - - // Look up the name of a key as indicated by an event object. - var keyName = CodeMirror.keyName = function (event, noShift) { - if (presto && event.keyCode == 34 && event["char"]) - return false; - var name = keyNames[event.keyCode]; - if (name == null || event.altGraphKey) - return false; - if (event.altKey) - name = "Alt-" + name; - if (flipCtrlCmd ? event.metaKey : event.ctrlKey) - name = "Ctrl-" + name; - if (flipCtrlCmd ? event.ctrlKey : event.metaKey) - name = "Cmd-" + name; - if (!noShift && event.shiftKey) - name = "Shift-" + name; - return name; - }; - - // FROMTEXTAREA - - CodeMirror.fromTextArea = function (textarea, options) { - if (!options) - options = {}; - options.value = textarea.value; - if (!options.tabindex && textarea.tabindex) - options.tabindex = textarea.tabindex; - if (!options.placeholder && textarea.placeholder) - options.placeholder = textarea.placeholder; - // Set autofocus to true if this textarea is focused, or if it has - // autofocus and no other element is focused. - if (options.autofocus == null) { - var hasFocus = activeElt(); - options.autofocus = hasFocus == textarea || - textarea.getAttribute("autofocus") != null && hasFocus == document.body; - } - - function save() { - textarea.value = cm.getValue(); - } - if (textarea.form) { - on(textarea.form, "submit", save); - // Deplorable hack to make the submit method do the right thing. - if (!options.leaveSubmitMethodAlone) { - var form = textarea.form, realSubmit = form.submit; - try { - var wrappedSubmit = form.submit = function () { - save(); - form.submit = realSubmit; - form.submit(); - form.submit = wrappedSubmit; - }; - } catch (e) { - } - } - } - - textarea.style.display = "none"; - var cm = CodeMirror(function (node) { - textarea.parentNode.insertBefore(node, textarea.nextSibling); - }, options); - cm.save = save; - cm.getTextArea = function () { - return textarea; - }; - cm.toTextArea = function () { - save(); - textarea.parentNode.removeChild(cm.getWrapperElement()); - textarea.style.display = ""; - if (textarea.form) { - off(textarea.form, "submit", save); - if (typeof textarea.form.submit == "function") - textarea.form.submit = realSubmit; - } - }; - return cm; - }; - - // STRING STREAM - - // Fed to the mode parsers, provides helper functions to make - // parsers more succinct. - - var StringStream = CodeMirror.StringStream = function (string, tabSize) { - this.pos = this.start = 0; - this.string = string; - this.tabSize = tabSize || 8; - this.lastColumnPos = this.lastColumnValue = 0; - this.lineStart = 0; - }; - - StringStream.prototype = { - eol: function () { - return this.pos >= this.string.length; - }, - sol: function () { - return this.pos == this.lineStart; - }, - peek: function () { - return this.string.charAt(this.pos) || undefined; - }, - next: function () { - if (this.pos < this.string.length) - return this.string.charAt(this.pos++); - }, - eat: function (match) { - var ch = this.string.charAt(this.pos); - if (typeof match == "string") - var ok = ch == match; - else - var ok = ch && (match.test ? match.test(ch) : match(ch)); - if (ok) { - ++this.pos; - return ch; - } - }, - eatWhile: function (match) { - var start = this.pos; - while (this.eat(match)) { - } - return this.pos > start; - }, - eatSpace: function () { - var start = this.pos; - while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) - ++this.pos; - return this.pos > start; - }, - skipToEnd: function () { - this.pos = this.string.length; - }, - skipTo: function (ch) { - var found = this.string.indexOf(ch, this.pos); - if (found > -1) { - this.pos = found; - return true; - } - }, - backUp: function (n) { - this.pos -= n; - }, - column: function () { - if (this.lastColumnPos < this.start) { - this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue); - this.lastColumnPos = this.start; - } - return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0); - }, - indentation: function () { - return countColumn(this.string, null, this.tabSize) - - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0); - }, - match: function (pattern, consume, caseInsensitive) { - if (typeof pattern == "string") { - var cased = function (str) { - return caseInsensitive ? str.toLowerCase() : str; - }; - var substr = this.string.substr(this.pos, pattern.length); - if (cased(substr) == cased(pattern)) { - if (consume !== false) - this.pos += pattern.length; - return true; - } - } else { - var match = this.string.slice(this.pos).match(pattern); - if (match && match.index > 0) - return null; - if (match && consume !== false) - this.pos += match[0].length; - return match; - } - }, - current: function () { - return this.string.slice(this.start, this.pos); - }, - hideFirstChars: function (n, inner) { - this.lineStart += n; - try { - return inner(); - } - finally { - this.lineStart -= n; - } - } - }; - - // TEXTMARKERS - - // Created with markText and setBookmark methods. A TextMarker is a - // handle that can be used to clear or find a marked position in the - // document. Line objects hold arrays (markedSpans) containing - // {from, to, marker} object pointing to such marker objects, and - // indicating that such a marker is present on that line. Multiple - // lines may point to the same marker when it spans across lines. - // The spans will have null for their from/to properties when the - // marker continues beyond the start/end of the line. Markers have - // links back to the lines they currently touch. - - var TextMarker = CodeMirror.TextMarker = function (doc, type) { - this.lines = []; - this.type = type; - this.doc = doc; - }; - eventMixin(TextMarker); - - // Clear the marker. - TextMarker.prototype.clear = function () { - if (this.explicitlyCleared) - return; - var cm = this.doc.cm, withOp = cm && !cm.curOp; - if (withOp) - startOperation(cm); - if (hasHandler(this, "clear")) { - var found = this.find(); - if (found) - signalLater(this, "clear", found.from, found.to); - } - var min = null, max = null; - for (var i = 0; i < this.lines.length; ++i) { - var line = this.lines[i]; - var span = getMarkedSpanFor(line.markedSpans, this); - if (cm && !this.collapsed) - regLineChange(cm, lineNo(line), "text"); - else if (cm) { - if (span.to != null) - max = lineNo(line); - if (span.from != null) - min = lineNo(line); - } - line.markedSpans = removeMarkedSpan(line.markedSpans, span); - if (span.from == null && this.collapsed && !lineIsHidden(this.doc, line) && cm) - updateLineHeight(line, textHeight(cm.display)); - } - if (cm && this.collapsed && !cm.options.lineWrapping) - for (var i = 0; i < this.lines.length; ++i) { - var visual = visualLine(this.lines[i]), len = lineLength(visual); - if (len > cm.display.maxLineLength) { - cm.display.maxLine = visual; - cm.display.maxLineLength = len; - cm.display.maxLineChanged = true; - } - } - - if (min != null && cm && this.collapsed) - regChange(cm, min, max + 1); - this.lines.length = 0; - this.explicitlyCleared = true; - if (this.atomic && this.doc.cantEdit) { - this.doc.cantEdit = false; - if (cm) - reCheckSelection(cm.doc); - } - if (cm) - signalLater(cm, "markerCleared", cm, this); - if (withOp) - endOperation(cm); - }; - - // Find the position of the marker in the document. Returns a {from, - // to} object by default. Side can be passed to get a specific side - // -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the - // Pos objects returned contain a line object, rather than a line - // number (used to prevent looking up the same line twice). - TextMarker.prototype.find = function (side, lineObj) { - if (side == null && this.type == "bookmark") - side = 1; - var from, to; - for (var i = 0; i < this.lines.length; ++i) { - var line = this.lines[i]; - var span = getMarkedSpanFor(line.markedSpans, this); - if (span.from != null) { - from = Pos(lineObj ? line : lineNo(line), span.from); - if (side == -1) - return from; - } - if (span.to != null) { - to = Pos(lineObj ? line : lineNo(line), span.to); - if (side == 1) - return to; - } - } - return from && {from: from, to: to}; - }; - - // Signals that the marker's widget changed, and surrounding layout - // should be recomputed. - TextMarker.prototype.changed = function () { - var pos = this.find(-1, true), widget = this, cm = this.doc.cm; - if (!pos || !cm) - return; - runInOp(cm, function () { - var line = pos.line, lineN = lineNo(pos.line); - var view = findViewForLine(cm, lineN); - if (view) { - clearLineMeasurementCacheFor(view); - cm.curOp.selectionChanged = cm.curOp.forceUpdate = true; - } - cm.curOp.updateMaxLine = true; - if (!lineIsHidden(widget.doc, line) && widget.height != null) { - var oldHeight = widget.height; - widget.height = null; - var dHeight = widgetHeight(widget) - oldHeight; - if (dHeight) - updateLineHeight(line, line.height + dHeight); - } - }); - }; - - TextMarker.prototype.attachLine = function (line) { - if (!this.lines.length && this.doc.cm) { - var op = this.doc.cm.curOp; - if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1) - (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this); - } - this.lines.push(line); - }; - TextMarker.prototype.detachLine = function (line) { - this.lines.splice(indexOf(this.lines, line), 1); - if (!this.lines.length && this.doc.cm) { - var op = this.doc.cm.curOp; - (op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this); - } - }; - - // Collapsed markers have unique ids, in order to be able to order - // them, which is needed for uniquely determining an outer marker - // when they overlap (they may nest, but not partially overlap). - var nextMarkerId = 0; - - // Create a marker, wire it up to the right lines, and - function markText(doc, from, to, options, type) { - // Shared markers (across linked documents) are handled separately - // (markTextShared will call out to this again, once per - // document). - if (options && options.shared) - return markTextShared(doc, from, to, options, type); - // Ensure we are in an operation. - if (doc.cm && !doc.cm.curOp) - return operation(doc.cm, markText)(doc, from, to, options, type); - - var marker = new TextMarker(doc, type), diff = cmp(from, to); - if (options) - copyObj(options, marker); - // Don't connect empty markers unless clearWhenEmpty is false - if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false) - return marker; - if (marker.replacedWith) { - // Showing up as a widget implies collapsed (widget replaces text) - marker.collapsed = true; - marker.widgetNode = elt("span", [marker.replacedWith], "CodeMirror-widget"); - if (!options.handleMouseEvents) - marker.widgetNode.ignoreEvents = true; - if (options.insertLeft) - marker.widgetNode.insertLeft = true; - } - if (marker.collapsed) { - if (conflictingCollapsedRange(doc, from.line, from, to, marker) || - from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker)) - throw new Error("Inserting collapsed marker partially overlapping an existing one"); - sawCollapsedSpans = true; - } - - if (marker.addToHistory) - addChangeToHistory(doc, {from: from, to: to, origin: "markText"}, doc.sel, NaN); - - var curLine = from.line, cm = doc.cm, updateMaxLine; - doc.iter(curLine, to.line + 1, function (line) { - if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine) - updateMaxLine = true; - if (marker.collapsed && curLine != from.line) - updateLineHeight(line, 0); - addMarkedSpan(line, new MarkedSpan(marker, - curLine == from.line ? from.ch : null, - curLine == to.line ? to.ch : null)); - ++curLine; - }); - // lineIsHidden depends on the presence of the spans, so needs a second pass - if (marker.collapsed) - doc.iter(from.line, to.line + 1, function (line) { - if (lineIsHidden(doc, line)) - updateLineHeight(line, 0); - }); - - if (marker.clearOnEnter) - on(marker, "beforeCursorEnter", function () { - marker.clear(); - }); - - if (marker.readOnly) { - sawReadOnlySpans = true; - if (doc.history.done.length || doc.history.undone.length) - doc.clearHistory(); - } - if (marker.collapsed) { - marker.id = ++nextMarkerId; - marker.atomic = true; - } - if (cm) { - // Sync editor state - if (updateMaxLine) - cm.curOp.updateMaxLine = true; - if (marker.collapsed) - regChange(cm, from.line, to.line + 1); - else if (marker.className || marker.title || marker.startStyle || marker.endStyle) - for (var i = from.line; i <= to.line; i++) - regLineChange(cm, i, "text"); - if (marker.atomic) - reCheckSelection(cm.doc); - signalLater(cm, "markerAdded", cm, marker); - } - return marker; - } - - // SHARED TEXTMARKERS - - // A shared marker spans multiple linked documents. It is - // implemented as a meta-marker-object controlling multiple normal - // markers. - var SharedTextMarker = CodeMirror.SharedTextMarker = function (markers, primary) { - this.markers = markers; - this.primary = primary; - for (var i = 0, me = this; i < markers.length; ++i) { - markers[i].parent = this; - on(markers[i], "clear", function () { - me.clear(); - }); - } - }; - eventMixin(SharedTextMarker); - - SharedTextMarker.prototype.clear = function () { - if (this.explicitlyCleared) - return; - this.explicitlyCleared = true; - for (var i = 0; i < this.markers.length; ++i) - this.markers[i].clear(); - signalLater(this, "clear"); - }; - SharedTextMarker.prototype.find = function (side, lineObj) { - return this.primary.find(side, lineObj); - }; - - function markTextShared(doc, from, to, options, type) { - options = copyObj(options); - options.shared = false; - var markers = [markText(doc, from, to, options, type)], primary = markers[0]; - var widget = options.widgetNode; - linkedDocs(doc, function (doc) { - if (widget) - options.widgetNode = widget.cloneNode(true); - markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type)); - for (var i = 0; i < doc.linked.length; ++i) - if (doc.linked[i].isParent) - return; - primary = lst(markers); - }); - return new SharedTextMarker(markers, primary); - } - - // TEXTMARKER SPANS - - function MarkedSpan(marker, from, to) { - this.marker = marker; - this.from = from; - this.to = to; - } - - // Search an array of spans for a span matching the given marker. - function getMarkedSpanFor(spans, marker) { - if (spans) - for (var i = 0; i < spans.length; ++i) { - var span = spans[i]; - if (span.marker == marker) - return span; - } - } - // Remove a span from an array, returning undefined if no spans are - // left (we don't store arrays for lines without spans). - function removeMarkedSpan(spans, span) { - for (var r, i = 0; i < spans.length; ++i) - if (spans[i] != span) - (r || (r = [])).push(spans[i]); - return r; - } - // Add a span to a line. - function addMarkedSpan(line, span) { - line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span]; - span.marker.attachLine(line); - } - - // Used for the algorithm that adjusts markers for a change in the - // document. These functions cut an array of spans at a given - // character position, returning an array of remaining chunks (or - // undefined if nothing remains). - function markedSpansBefore(old, startCh, isInsert) { - if (old) - for (var i = 0, nw; i < old.length; ++i) { - var span = old[i], marker = span.marker; - var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh); - if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) { - var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh); - (nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to)); - } - } - return nw; - } - function markedSpansAfter(old, endCh, isInsert) { - if (old) - for (var i = 0, nw; i < old.length; ++i) { - var span = old[i], marker = span.marker; - var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh); - if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) { - var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh); - (nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh, - span.to == null ? null : span.to - endCh)); - } - } - return nw; - } - - // Given a change object, compute the new set of marker spans that - // cover the line in which the change took place. Removes spans - // entirely within the change, reconnects spans belonging to the - // same marker that appear on both sides of the change, and cuts off - // spans partially within the change. Returns an array of span - // arrays with one element for each line in (after) the change. - function stretchSpansOverChange(doc, change) { - var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans; - var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans; - if (!oldFirst && !oldLast) - return null; - - var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0; - // Get the spans that 'stick out' on both sides - var first = markedSpansBefore(oldFirst, startCh, isInsert); - var last = markedSpansAfter(oldLast, endCh, isInsert); - - // Next, merge those two ends - var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0); - if (first) { - // Fix up .to properties of first - for (var i = 0; i < first.length; ++i) { - var span = first[i]; - if (span.to == null) { - var found = getMarkedSpanFor(last, span.marker); - if (!found) - span.to = startCh; - else if (sameLine) - span.to = found.to == null ? null : found.to + offset; - } - } - } - if (last) { - // Fix up .from in last (or move them into first in case of sameLine) - for (var i = 0; i < last.length; ++i) { - var span = last[i]; - if (span.to != null) - span.to += offset; - if (span.from == null) { - var found = getMarkedSpanFor(first, span.marker); - if (!found) { - span.from = offset; - if (sameLine) - (first || (first = [])).push(span); - } - } else { - span.from += offset; - if (sameLine) - (first || (first = [])).push(span); - } - } - } - // Make sure we didn't create any zero-length spans - if (first) - first = clearEmptySpans(first); - if (last && last != first) - last = clearEmptySpans(last); - - var newMarkers = [first]; - if (!sameLine) { - // Fill gap with whole-line-spans - var gap = change.text.length - 2, gapMarkers; - if (gap > 0 && first) - for (var i = 0; i < first.length; ++i) - if (first[i].to == null) - (gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i].marker, null, null)); - for (var i = 0; i < gap; ++i) - newMarkers.push(gapMarkers); - newMarkers.push(last); - } - return newMarkers; - } - - // Remove spans that are empty and don't have a clearWhenEmpty - // option of false. - function clearEmptySpans(spans) { - for (var i = 0; i < spans.length; ++i) { - var span = spans[i]; - if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false) - spans.splice(i--, 1); - } - if (!spans.length) - return null; - return spans; - } - - // Used for un/re-doing changes from the history. Combines the - // result of computing the existing spans with the set of spans that - // existed in the history (so that deleting around a span and then - // undoing brings back the span). - function mergeOldSpans(doc, change) { - var old = getOldSpans(doc, change); - var stretched = stretchSpansOverChange(doc, change); - if (!old) - return stretched; - if (!stretched) - return old; - - for (var i = 0; i < old.length; ++i) { - var oldCur = old[i], stretchCur = stretched[i]; - if (oldCur && stretchCur) { - spans: for (var j = 0; j < stretchCur.length; ++j) { - var span = stretchCur[j]; - for (var k = 0; k < oldCur.length; ++k) - if (oldCur[k].marker == span.marker) - continue spans; - oldCur.push(span); - } - } else if (stretchCur) { - old[i] = stretchCur; - } - } - return old; - } - - // Used to 'clip' out readOnly ranges when making a change. - function removeReadOnlyRanges(doc, from, to) { - var markers = null; - doc.iter(from.line, to.line + 1, function (line) { - if (line.markedSpans) - for (var i = 0; i < line.markedSpans.length; ++i) { - var mark = line.markedSpans[i].marker; - if (mark.readOnly && (!markers || indexOf(markers, mark) == -1)) - (markers || (markers = [])).push(mark); - } - }); - if (!markers) - return null; - var parts = [{from: from, to: to}]; - for (var i = 0; i < markers.length; ++i) { - var mk = markers[i], m = mk.find(0); - for (var j = 0; j < parts.length; ++j) { - var p = parts[j]; - if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) - continue; - var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to); - if (dfrom < 0 || !mk.inclusiveLeft && !dfrom) - newParts.push({from: p.from, to: m.from}); - if (dto > 0 || !mk.inclusiveRight && !dto) - newParts.push({from: m.to, to: p.to}); - parts.splice.apply(parts, newParts); - j += newParts.length - 1; - } - } - return parts; - } - - // Connect or disconnect spans from a line. - function detachMarkedSpans(line) { - var spans = line.markedSpans; - if (!spans) - return; - for (var i = 0; i < spans.length; ++i) - spans[i].marker.detachLine(line); - line.markedSpans = null; - } - function attachMarkedSpans(line, spans) { - if (!spans) - return; - for (var i = 0; i < spans.length; ++i) - spans[i].marker.attachLine(line); - line.markedSpans = spans; - } - - // Helpers used when computing which overlapping collapsed span - // counts as the larger one. - function extraLeft(marker) { - return marker.inclusiveLeft ? -1 : 0; - } - function extraRight(marker) { - return marker.inclusiveRight ? 1 : 0; - } - - // Returns a number indicating which of two overlapping collapsed - // spans is larger (and thus includes the other). Falls back to - // comparing ids when the spans cover exactly the same range. - function compareCollapsedMarkers(a, b) { - var lenDiff = a.lines.length - b.lines.length; - if (lenDiff != 0) - return lenDiff; - var aPos = a.find(), bPos = b.find(); - var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b); - if (fromCmp) - return -fromCmp; - var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b); - if (toCmp) - return toCmp; - return b.id - a.id; - } - - // Find out whether a line ends or starts in a collapsed span. If - // so, return the marker for that span. - function collapsedSpanAtSide(line, start) { - var sps = sawCollapsedSpans && line.markedSpans, found; - if (sps) - for (var sp, i = 0; i < sps.length; ++i) { - sp = sps[i]; - if (sp.marker.collapsed && (start ? sp.from : sp.to) == null && - (!found || compareCollapsedMarkers(found, sp.marker) < 0)) - found = sp.marker; - } - return found; - } - function collapsedSpanAtStart(line) { - return collapsedSpanAtSide(line, true); - } - function collapsedSpanAtEnd(line) { - return collapsedSpanAtSide(line, false); - } - - // Test whether there exists a collapsed span that partially - // overlaps (covers the start or end, but not both) of a new span. - // Such overlap is not allowed. - function conflictingCollapsedRange(doc, lineNo, from, to, marker) { - var line = getLine(doc, lineNo); - var sps = sawCollapsedSpans && line.markedSpans; - if (sps) - for (var i = 0; i < sps.length; ++i) { - var sp = sps[i]; - if (!sp.marker.collapsed) - continue; - var found = sp.marker.find(0); - var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker); - var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker); - if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) - continue; - if (fromCmp <= 0 && (cmp(found.to, from) || extraRight(sp.marker) - extraLeft(marker)) > 0 || - fromCmp >= 0 && (cmp(found.from, to) || extraLeft(sp.marker) - extraRight(marker)) < 0) - return true; - } - } - - // A visual line is a line as drawn on the screen. Folding, for - // example, can cause multiple logical lines to appear on the same - // visual line. This finds the start of the visual line that the - // given line is part of (usually that is the line itself). - function visualLine(line) { - var merged; - while (merged = collapsedSpanAtStart(line)) - line = merged.find(-1, true).line; - return line; - } - - // Returns an array of logical lines that continue the visual line - // started by the argument, or undefined if there are no such lines. - function visualLineContinued(line) { - var merged, lines; - while (merged = collapsedSpanAtEnd(line)) { - line = merged.find(1, true).line; - (lines || (lines = [])).push(line); - } - return lines; - } - - // Get the line number of the start of the visual line that the - // given line number is part of. - function visualLineNo(doc, lineN) { - var line = getLine(doc, lineN), vis = visualLine(line); - if (line == vis) - return lineN; - return lineNo(vis); - } - // Get the line number of the start of the next visual line after - // the given line. - function visualLineEndNo(doc, lineN) { - if (lineN > doc.lastLine()) - return lineN; - var line = getLine(doc, lineN), merged; - if (!lineIsHidden(doc, line)) - return lineN; - while (merged = collapsedSpanAtEnd(line)) - line = merged.find(1, true).line; - return lineNo(line) + 1; - } - - // Compute whether a line is hidden. Lines count as hidden when they - // are part of a visual line that starts with another line, or when - // they are entirely covered by collapsed, non-widget span. - function lineIsHidden(doc, line) { - var sps = sawCollapsedSpans && line.markedSpans; - if (sps) - for (var sp, i = 0; i < sps.length; ++i) { - sp = sps[i]; - if (!sp.marker.collapsed) - continue; - if (sp.from == null) - return true; - if (sp.marker.widgetNode) - continue; - if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp)) - return true; - } - } - function lineIsHiddenInner(doc, line, span) { - if (span.to == null) { - var end = span.marker.find(1, true); - return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker)); - } - if (span.marker.inclusiveRight && span.to == line.text.length) - return true; - for (var sp, i = 0; i < line.markedSpans.length; ++i) { - sp = line.markedSpans[i]; - if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to && - (sp.to == null || sp.to != span.from) && - (sp.marker.inclusiveLeft || span.marker.inclusiveRight) && - lineIsHiddenInner(doc, line, sp)) - return true; - } - } - - // LINE WIDGETS - - // Line widgets are block elements displayed above or below a line. - - var LineWidget = CodeMirror.LineWidget = function (cm, node, options) { - if (options) - for (var opt in options) - if (options.hasOwnProperty(opt)) - this[opt] = options[opt]; - this.cm = cm; - this.node = node; - }; - eventMixin(LineWidget); - - function adjustScrollWhenAboveVisible(cm, line, diff) { - if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop)) - addToScrollPos(cm, null, diff); - } - - LineWidget.prototype.clear = function () { - var cm = this.cm, ws = this.line.widgets, line = this.line, no = lineNo(line); - if (no == null || !ws) - return; - for (var i = 0; i < ws.length; ++i) - if (ws[i] == this) - ws.splice(i--, 1); - if (!ws.length) - line.widgets = null; - var height = widgetHeight(this); - runInOp(cm, function () { - adjustScrollWhenAboveVisible(cm, line, -height); - regLineChange(cm, no, "widget"); - updateLineHeight(line, Math.max(0, line.height - height)); - }); - }; - LineWidget.prototype.changed = function () { - var oldH = this.height, cm = this.cm, line = this.line; - this.height = null; - var diff = widgetHeight(this) - oldH; - if (!diff) - return; - runInOp(cm, function () { - cm.curOp.forceUpdate = true; - adjustScrollWhenAboveVisible(cm, line, diff); - updateLineHeight(line, line.height + diff); - }); - }; - - function widgetHeight(widget) { - if (widget.height != null) - return widget.height; - if (!contains(document.body, widget.node)) - removeChildrenAndAdd(widget.cm.display.measure, elt("div", [widget.node], null, "position: relative")); - return widget.height = widget.node.offsetHeight; - } - - function addLineWidget(cm, handle, node, options) { - var widget = new LineWidget(cm, node, options); - if (widget.noHScroll) - cm.display.alignWidgets = true; - changeLine(cm, handle, "widget", function (line) { - var widgets = line.widgets || (line.widgets = []); - if (widget.insertAt == null) - widgets.push(widget); - else - widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget); - widget.line = line; - if (!lineIsHidden(cm.doc, line)) { - var aboveVisible = heightAtLine(line) < cm.doc.scrollTop; - updateLineHeight(line, line.height + widgetHeight(widget)); - if (aboveVisible) - addToScrollPos(cm, null, widget.height); - cm.curOp.forceUpdate = true; - } - return true; - }); - return widget; - } - - // LINE DATA STRUCTURE - - // Line objects. These hold state related to a line, including - // highlighting info (the styles array). - var Line = CodeMirror.Line = function (text, markedSpans, estimateHeight) { - this.text = text; - attachMarkedSpans(this, markedSpans); - this.height = estimateHeight ? estimateHeight(this) : 1; - }; - eventMixin(Line); - Line.prototype.lineNo = function () { - return lineNo(this); - }; - - // Change the content (text, markers) of a line. Automatically - // invalidates cached information and tries to re-estimate the - // line's height. - function updateLine(line, text, markedSpans, estimateHeight) { - line.text = text; - if (line.stateAfter) - line.stateAfter = null; - if (line.styles) - line.styles = null; - if (line.order != null) - line.order = null; - detachMarkedSpans(line); - attachMarkedSpans(line, markedSpans); - var estHeight = estimateHeight ? estimateHeight(line) : 1; - if (estHeight != line.height) - updateLineHeight(line, estHeight); - } - - // Detach a line from the document tree and its markers. - function cleanUpLine(line) { - line.parent = null; - detachMarkedSpans(line); - } - - // Run the given mode's parser over a line, calling f for each token. - function runMode(cm, text, mode, state, f, forceToEnd) { - var flattenSpans = mode.flattenSpans; - if (flattenSpans == null) - flattenSpans = cm.options.flattenSpans; - var curStart = 0, curStyle = null; - var stream = new StringStream(text, cm.options.tabSize), style; - if (text == "" && mode.blankLine) - mode.blankLine(state); - while (!stream.eol()) { - if (stream.pos > cm.options.maxHighlightLength) { - flattenSpans = false; - if (forceToEnd) - processLine(cm, text, state, stream.pos); - stream.pos = text.length; - style = null; - } else { - style = mode.token(stream, state); - } - if (cm.options.addModeClass) { - var mName = CodeMirror.innerMode(mode, state).mode.name; - if (mName) - style = "m-" + (style ? mName + " " + style : mName); - } - if (!flattenSpans || curStyle != style) { - if (curStart < stream.start) - f(stream.start, curStyle); - curStart = stream.start; - curStyle = style; - } - stream.start = stream.pos; - } - while (curStart < stream.pos) { - // Webkit seems to refuse to render text nodes longer than 57444 characters - var pos = Math.min(stream.pos, curStart + 50000); - f(pos, curStyle); - curStart = pos; - } - } - - // Compute a style array (an array starting with a mode generation - // -- for invalidation -- followed by pairs of end positions and - // style strings), which is used to highlight the tokens on the - // line. - function highlightLine(cm, line, state, forceToEnd) { - // A styles array always starts with a number identifying the - // mode/overlays that it is based on (for easy invalidation). - var st = [cm.state.modeGen]; - // Compute the base array of styles - runMode(cm, line.text, cm.doc.mode, state, function (end, style) { - st.push(end, style); - }, forceToEnd); - - // Run overlays, adjust style array. - for (var o = 0; o < cm.state.overlays.length; ++o) { - var overlay = cm.state.overlays[o], i = 1, at = 0; - runMode(cm, line.text, overlay.mode, true, function (end, style) { - var start = i; - // Ensure there's a token end at the current position, and that i points at it - while (at < end) { - var i_end = st[i]; - if (i_end > end) - st.splice(i, 1, end, st[i + 1], i_end); - i += 2; - at = Math.min(end, i_end); - } - if (!style) - return; - if (overlay.opaque) { - st.splice(start, i - start, end, style); - i = start + 2; - } else { - for (; start < i; start += 2) { - var cur = st[start + 1]; - st[start + 1] = cur ? cur + " " + style : style; - } - } - }); - } - - return st; - } - - function getLineStyles(cm, line) { - if (!line.styles || line.styles[0] != cm.state.modeGen) - line.styles = highlightLine(cm, line, line.stateAfter = getStateBefore(cm, lineNo(line))); - return line.styles; - } - - // Lightweight form of highlight -- proceed over this line and - // update state, but don't save a style array. Used for lines that - // aren't currently visible. - function processLine(cm, text, state, startAt) { - var mode = cm.doc.mode; - var stream = new StringStream(text, cm.options.tabSize); - stream.start = stream.pos = startAt || 0; - if (text == "" && mode.blankLine) - mode.blankLine(state); - while (!stream.eol() && stream.pos <= cm.options.maxHighlightLength) { - mode.token(stream, state); - stream.start = stream.pos; - } - } - - // Convert a style as returned by a mode (either null, or a string - // containing one or more styles) to a CSS style. This is cached, - // and also looks for line-wide styles. - var styleToClassCache = {}, styleToClassCacheWithMode = {}; - function interpretTokenStyle(style, builder) { - if (!style) - return null; - for (; ; ) { - var lineClass = style.match(/(?:^|\s+)line-(background-)?(\S+)/); - if (!lineClass) - break; - style = style.slice(0, lineClass.index) + style.slice(lineClass.index + lineClass[0].length); - var prop = lineClass[1] ? "bgClass" : "textClass"; - if (builder[prop] == null) - builder[prop] = lineClass[2]; - else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(builder[prop])) - builder[prop] += " " + lineClass[2]; - } - if (/^\s*$/.test(style)) - return null; - var cache = builder.cm.options.addModeClass ? styleToClassCacheWithMode : styleToClassCache; - return cache[style] || - (cache[style] = style.replace(/\S+/g, "cm-$&")); - } - - // Render the DOM representation of the text of a line. Also builds - // up a 'line map', which points at the DOM nodes that represent - // specific stretches of text, and is used by the measuring code. - // The returned object contains the DOM node, this map, and - // information about line-wide styles that were set by the mode. - function buildLineContent(cm, lineView) { - // The padding-right forces the element to have a 'border', which - // is needed on Webkit to be able to get line-level bounding - // rectangles for it (in measureChar). - var content = elt("span", null, null, webkit ? "padding-right: .1px" : null); - var builder = {pre: elt("pre", [content]), content: content, col: 0, pos: 0, cm: cm}; - lineView.measure = {}; - - // Iterate over the logical lines that make up this visual line. - for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) { - var line = i ? lineView.rest[i - 1] : lineView.line, order; - builder.pos = 0; - builder.addToken = buildToken; - // Optionally wire in some hacks into the token-rendering - // algorithm, to deal with browser quirks. - if ((ie || webkit) && cm.getOption("lineWrapping")) - builder.addToken = buildTokenSplitSpaces(builder.addToken); - if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line))) - builder.addToken = buildTokenBadBidi(builder.addToken, order); - builder.map = []; - insertLineContent(line, builder, getLineStyles(cm, line)); - - // Ensure at least a single node is present, for measuring. - if (builder.map.length == 0) - builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure))); - - // Store the map and a cache object for the current logical line - if (i == 0) { - lineView.measure.map = builder.map; - lineView.measure.cache = {}; - } else { - (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map); - (lineView.measure.caches || (lineView.measure.caches = [])).push({}); - } - } - - signal(cm, "renderLine", cm, lineView.line, builder.pre); - return builder; - } - - function defaultSpecialCharPlaceholder(ch) { - var token = elt("span", "\u2022", "cm-invalidchar"); - token.title = "\\u" + ch.charCodeAt(0).toString(16); - return token; - } - - // Build up the DOM representation for a single token, and add it to - // the line map. Takes care to render special characters separately. - function buildToken(builder, text, style, startStyle, endStyle, title) { - if (!text) - return; - var special = builder.cm.options.specialChars, mustWrap = false; - if (!special.test(text)) { - builder.col += text.length; - var content = document.createTextNode(text); - builder.map.push(builder.pos, builder.pos + text.length, content); - if (ie_upto8) - mustWrap = true; - builder.pos += text.length; - } else { - var content = document.createDocumentFragment(), pos = 0; - while (true) { - special.lastIndex = pos; - var m = special.exec(text); - var skipped = m ? m.index - pos : text.length - pos; - if (skipped) { - var txt = document.createTextNode(text.slice(pos, pos + skipped)); - if (ie_upto8) - content.appendChild(elt("span", [txt])); - else - content.appendChild(txt); - builder.map.push(builder.pos, builder.pos + skipped, txt); - builder.col += skipped; - builder.pos += skipped; - } - if (!m) - break; - pos += skipped + 1; - if (m[0] == "\t") { - var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize; - var txt = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab")); - builder.col += tabWidth; - } else { - var txt = builder.cm.options.specialCharPlaceholder(m[0]); - if (ie_upto8) - content.appendChild(elt("span", [txt])); - else - content.appendChild(txt); - builder.col += 1; - } - builder.map.push(builder.pos, builder.pos + 1, txt); - builder.pos++; - } - } - if (style || startStyle || endStyle || mustWrap) { - var fullStyle = style || ""; - if (startStyle) - fullStyle += startStyle; - if (endStyle) - fullStyle += endStyle; - var token = elt("span", [content], fullStyle); - if (title) - token.title = title; - return builder.content.appendChild(token); - } - builder.content.appendChild(content); - } - - function buildTokenSplitSpaces(inner) { - function split(old) { - var out = " "; - for (var i = 0; i < old.length - 2; ++i) - out += i % 2 ? " " : "\u00a0"; - out += " "; - return out; - } - return function (builder, text, style, startStyle, endStyle, title) { - inner(builder, text.replace(/ {3,}/g, split), style, startStyle, endStyle, title); - }; - } - - // Work around nonsense dimensions being reported for stretches of - // right-to-left text. - function buildTokenBadBidi(inner, order) { - return function (builder, text, style, startStyle, endStyle, title) { - style = style ? style + " cm-force-border" : "cm-force-border"; - var start = builder.pos, end = start + text.length; - for (; ; ) { - // Find the part that overlaps with the start of this text - for (var i = 0; i < order.length; i++) { - var part = order[i]; - if (part.to > start && part.from <= start) - break; - } - if (part.to >= end) - return inner(builder, text, style, startStyle, endStyle, title); - inner(builder, text.slice(0, part.to - start), style, startStyle, null, title); - startStyle = null; - text = text.slice(part.to - start); - start = part.to; - } - }; - } - - function buildCollapsedSpan(builder, size, marker, ignoreWidget) { - var widget = !ignoreWidget && marker.widgetNode; - if (widget) { - builder.map.push(builder.pos, builder.pos + size, widget); - builder.content.appendChild(widget); - } - builder.pos += size; - } - - // Outputs a number of spans to make up a line, taking highlighting - // and marked text into account. - function insertLineContent(line, builder, styles) { - var spans = line.markedSpans, allText = line.text, at = 0; - if (!spans) { - for (var i = 1; i < styles.length; i += 2) - builder.addToken(builder, allText.slice(at, at = styles[i]), interpretTokenStyle(styles[i + 1], builder)); - return; - } - - var len = allText.length, pos = 0, i = 1, text = "", style; - var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, title, collapsed; - for (; ; ) { - if (nextChange == pos) { // Update current marker set - spanStyle = spanEndStyle = spanStartStyle = title = ""; - collapsed = null; - nextChange = Infinity; - var foundBookmarks = []; - for (var j = 0; j < spans.length; ++j) { - var sp = spans[j], m = sp.marker; - if (sp.from <= pos && (sp.to == null || sp.to > pos)) { - if (sp.to != null && nextChange > sp.to) { - nextChange = sp.to; - spanEndStyle = ""; - } - if (m.className) - spanStyle += " " + m.className; - if (m.startStyle && sp.from == pos) - spanStartStyle += " " + m.startStyle; - if (m.endStyle && sp.to == nextChange) - spanEndStyle += " " + m.endStyle; - if (m.title && !title) - title = m.title; - if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0)) - collapsed = sp; - } else if (sp.from > pos && nextChange > sp.from) { - nextChange = sp.from; - } - if (m.type == "bookmark" && sp.from == pos && m.widgetNode) - foundBookmarks.push(m); - } - if (collapsed && (collapsed.from || 0) == pos) { - buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos, - collapsed.marker, collapsed.from == null); - if (collapsed.to == null) - return; - } - if (!collapsed && foundBookmarks.length) - for (var j = 0; j < foundBookmarks.length; ++j) - buildCollapsedSpan(builder, 0, foundBookmarks[j]); - } - if (pos >= len) - break; - - var upto = Math.min(len, nextChange); - while (true) { - if (text) { - var end = pos + text.length; - if (!collapsed) { - var tokenText = end > upto ? text.slice(0, upto - pos) : text; - builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle, - spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", title); - } - if (end >= upto) { - text = text.slice(upto - pos); - pos = upto; - break; - } - pos = end; - spanStartStyle = ""; - } - text = allText.slice(at, at = styles[i++]); - style = interpretTokenStyle(styles[i++], builder); - } - } - } - - // DOCUMENT DATA STRUCTURE - - // By default, updates that start and end at the beginning of a line - // are treated specially, in order to make the association of line - // widgets and marker elements with the text behave more intuitive. - function isWholeLineUpdate(doc, change) { - return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" && - (!doc.cm || doc.cm.options.wholeLineUpdateBefore); - } - - // Perform a change on the document data structure. - function updateDoc(doc, change, markedSpans, estimateHeight) { - function spansFor(n) { - return markedSpans ? markedSpans[n] : null; - } - function update(line, text, spans) { - updateLine(line, text, spans, estimateHeight); - signalLater(line, "change", line, change); - } - - var from = change.from, to = change.to, text = change.text; - var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line); - var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line; - - // Adjust the line structure - if (isWholeLineUpdate(doc, change)) { - // This is a whole-line replace. Treated specially to make - // sure line objects move the way they are supposed to. - for (var i = 0, added = []; i < text.length - 1; ++i) - added.push(new Line(text[i], spansFor(i), estimateHeight)); - update(lastLine, lastLine.text, lastSpans); - if (nlines) - doc.remove(from.line, nlines); - if (added.length) - doc.insert(from.line, added); - } else if (firstLine == lastLine) { - if (text.length == 1) { - update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans); - } else { - for (var added = [], i = 1; i < text.length - 1; ++i) - added.push(new Line(text[i], spansFor(i), estimateHeight)); - added.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight)); - update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0)); - doc.insert(from.line + 1, added); - } - } else if (text.length == 1) { - update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0)); - doc.remove(from.line + 1, nlines); - } else { - update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0)); - update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans); - for (var i = 1, added = []; i < text.length - 1; ++i) - added.push(new Line(text[i], spansFor(i), estimateHeight)); - if (nlines > 1) - doc.remove(from.line + 1, nlines - 1); - doc.insert(from.line + 1, added); - } - - signalLater(doc, "change", doc, change); - } - - // The document is represented as a BTree consisting of leaves, with - // chunk of lines in them, and branches, with up to ten leaves or - // other branch nodes below them. The top node is always a branch - // node, and is the document object itself (meaning it has - // additional methods and properties). - // - // All nodes have parent links. The tree is used both to go from - // line numbers to line objects, and to go from objects to numbers. - // It also indexes by height, and is used to convert between height - // and line object, and to find the total height of the document. - // - // See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html - - function LeafChunk(lines) { - this.lines = lines; - this.parent = null; - for (var i = 0, height = 0; i < lines.length; ++i) { - lines[i].parent = this; - height += lines[i].height; - } - this.height = height; - } - - LeafChunk.prototype = { - chunkSize: function () { - return this.lines.length; - }, - // Remove the n lines at offset 'at'. - removeInner: function (at, n) { - for (var i = at, e = at + n; i < e; ++i) { - var line = this.lines[i]; - this.height -= line.height; - cleanUpLine(line); - signalLater(line, "delete"); - } - this.lines.splice(at, n); - }, - // Helper used to collapse a small branch into a single leaf. - collapse: function (lines) { - lines.push.apply(lines, this.lines); - }, - // Insert the given array of lines at offset 'at', count them as - // having the given height. - insertInner: function (at, lines, height) { - this.height += height; - this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at)); - for (var i = 0; i < lines.length; ++i) - lines[i].parent = this; - }, - // Used to iterate over a part of the tree. - iterN: function (at, n, op) { - for (var e = at + n; at < e; ++at) - if (op(this.lines[at])) - return true; - } - }; - - function BranchChunk(children) { - this.children = children; - var size = 0, height = 0; - for (var i = 0; i < children.length; ++i) { - var ch = children[i]; - size += ch.chunkSize(); - height += ch.height; - ch.parent = this; - } - this.size = size; - this.height = height; - this.parent = null; - } - - BranchChunk.prototype = { - chunkSize: function () { - return this.size; - }, - removeInner: function (at, n) { - this.size -= n; - for (var i = 0; i < this.children.length; ++i) { - var child = this.children[i], sz = child.chunkSize(); - if (at < sz) { - var rm = Math.min(n, sz - at), oldHeight = child.height; - child.removeInner(at, rm); - this.height -= oldHeight - child.height; - if (sz == rm) { - this.children.splice(i--, 1); - child.parent = null; - } - if ((n -= rm) == 0) - break; - at = 0; - } else - at -= sz; - } - // If the result is smaller than 25 lines, ensure that it is a - // single leaf node. - if (this.size - n < 25 && - (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) { - var lines = []; - this.collapse(lines); - this.children = [new LeafChunk(lines)]; - this.children[0].parent = this; - } - }, - collapse: function (lines) { - for (var i = 0; i < this.children.length; ++i) - this.children[i].collapse(lines); - }, - insertInner: function (at, lines, height) { - this.size += lines.length; - this.height += height; - for (var i = 0; i < this.children.length; ++i) { - var child = this.children[i], sz = child.chunkSize(); - if (at <= sz) { - child.insertInner(at, lines, height); - if (child.lines && child.lines.length > 50) { - while (child.lines.length > 50) { - var spilled = child.lines.splice(child.lines.length - 25, 25); - var newleaf = new LeafChunk(spilled); - child.height -= newleaf.height; - this.children.splice(i + 1, 0, newleaf); - newleaf.parent = this; - } - this.maybeSpill(); - } - break; - } - at -= sz; - } - }, - // When a node has grown, check whether it should be split. - maybeSpill: function () { - if (this.children.length <= 10) - return; - var me = this; - do { - var spilled = me.children.splice(me.children.length - 5, 5); - var sibling = new BranchChunk(spilled); - if (!me.parent) { // Become the parent node - var copy = new BranchChunk(me.children); - copy.parent = me; - me.children = [copy, sibling]; - me = copy; - } else { - me.size -= sibling.size; - me.height -= sibling.height; - var myIndex = indexOf(me.parent.children, me); - me.parent.children.splice(myIndex + 1, 0, sibling); - } - sibling.parent = me.parent; - } while (me.children.length > 10); - me.parent.maybeSpill(); - }, - iterN: function (at, n, op) { - for (var i = 0; i < this.children.length; ++i) { - var child = this.children[i], sz = child.chunkSize(); - if (at < sz) { - var used = Math.min(n, sz - at); - if (child.iterN(at, used, op)) - return true; - if ((n -= used) == 0) - break; - at = 0; - } else - at -= sz; - } - } - }; - - var nextDocId = 0; - var Doc = CodeMirror.Doc = function (text, mode, firstLine) { - if (!(this instanceof Doc)) - return new Doc(text, mode, firstLine); - if (firstLine == null) - firstLine = 0; - - BranchChunk.call(this, [new LeafChunk([new Line("", null)])]); - this.first = firstLine; - this.scrollTop = this.scrollLeft = 0; - this.cantEdit = false; - this.cleanGeneration = 1; - this.frontier = firstLine; - var start = Pos(firstLine, 0); - this.sel = simpleSelection(start); - this.history = new History(null); - this.id = ++nextDocId; - this.modeOption = mode; - - if (typeof text == "string") - text = splitLines(text); - updateDoc(this, {from: start, to: start, text: text}); - setSelection(this, simpleSelection(start), sel_dontScroll); - }; - - Doc.prototype = createObj(BranchChunk.prototype, { - constructor: Doc, - // Iterate over the document. Supports two forms -- with only one - // argument, it calls that for each line in the document. With - // three, it iterates over the range given by the first two (with - // the second being non-inclusive). - iter: function (from, to, op) { - if (op) - this.iterN(from - this.first, to - from, op); - else - this.iterN(this.first, this.first + this.size, from); - }, - // Non-public interface for adding and removing lines. - insert: function (at, lines) { - var height = 0; - for (var i = 0; i < lines.length; ++i) - height += lines[i].height; - this.insertInner(at - this.first, lines, height); - }, - remove: function (at, n) { - this.removeInner(at - this.first, n); - }, - // From here, the methods are part of the public interface. Most - // are also available from CodeMirror (editor) instances. - - getValue: function (lineSep) { - var lines = getLines(this, this.first, this.first + this.size); - if (lineSep === false) - return lines; - return lines.join(lineSep || "\n"); - }, - setValue: docMethodOp(function (code) { - var top = Pos(this.first, 0), last = this.first + this.size - 1; - makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length), - text: splitLines(code), origin: "setValue"}, true); - setSelection(this, simpleSelection(top)); - }), - replaceRange: function (code, from, to, origin) { - from = clipPos(this, from); - to = to ? clipPos(this, to) : from; - replaceRange(this, code, from, to, origin); - }, - getRange: function (from, to, lineSep) { - var lines = getBetween(this, clipPos(this, from), clipPos(this, to)); - if (lineSep === false) - return lines; - return lines.join(lineSep || "\n"); - }, - getLine: function (line) { - var l = this.getLineHandle(line); - return l && l.text; - }, - getLineHandle: function (line) { - if (isLine(this, line)) - return getLine(this, line); - }, - getLineNumber: function (line) { - return lineNo(line); - }, - getLineHandleVisualStart: function (line) { - if (typeof line == "number") - line = getLine(this, line); - return visualLine(line); - }, - lineCount: function () { - return this.size; - }, - firstLine: function () { - return this.first; - }, - lastLine: function () { - return this.first + this.size - 1; - }, - clipPos: function (pos) { - return clipPos(this, pos); - }, - getCursor: function (start) { - var range = this.sel.primary(), pos; - if (start == null || start == "head") - pos = range.head; - else if (start == "anchor") - pos = range.anchor; - else if (start == "end" || start == "to" || start === false) - pos = range.to(); - else - pos = range.from(); - return pos; - }, - listSelections: function () { - return this.sel.ranges; - }, - somethingSelected: function () { - return this.sel.somethingSelected(); - }, - setCursor: docMethodOp(function (line, ch, options) { - setSimpleSelection(this, clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line), null, options); - }), - setSelection: docMethodOp(function (anchor, head, options) { - setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options); - }), - extendSelection: docMethodOp(function (head, other, options) { - extendSelection(this, clipPos(this, head), other && clipPos(this, other), options); - }), - extendSelections: docMethodOp(function (heads, options) { - extendSelections(this, clipPosArray(this, heads, options)); - }), - extendSelectionsBy: docMethodOp(function (f, options) { - extendSelections(this, map(this.sel.ranges, f), options); - }), - setSelections: docMethodOp(function (ranges, primary, options) { - if (!ranges.length) - return; - for (var i = 0, out = []; i < ranges.length; i++) - out[i] = new Range(clipPos(this, ranges[i].anchor), - clipPos(this, ranges[i].head)); - if (primary == null) - primary = Math.min(ranges.length - 1, this.sel.primIndex); - setSelection(this, normalizeSelection(out, primary), options); - }), - addSelection: docMethodOp(function (anchor, head, options) { - var ranges = this.sel.ranges.slice(0); - ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor))); - setSelection(this, normalizeSelection(ranges, ranges.length - 1), options); - }), - getSelection: function (lineSep) { - var ranges = this.sel.ranges, lines; - for (var i = 0; i < ranges.length; i++) { - var sel = getBetween(this, ranges[i].from(), ranges[i].to()); - lines = lines ? lines.concat(sel) : sel; - } - if (lineSep === false) - return lines; - else - return lines.join(lineSep || "\n"); - }, - getSelections: function (lineSep) { - var parts = [], ranges = this.sel.ranges; - for (var i = 0; i < ranges.length; i++) { - var sel = getBetween(this, ranges[i].from(), ranges[i].to()); - if (lineSep !== false) - sel = sel.join(lineSep || "\n"); - parts[i] = sel; - } - return parts; - }, - replaceSelection: docMethodOp(function (code, collapse, origin) { - var dup = []; - for (var i = 0; i < this.sel.ranges.length; i++) - dup[i] = code; - this.replaceSelections(dup, collapse, origin || "+input"); - }), - replaceSelections: function (code, collapse, origin) { - var changes = [], sel = this.sel; - for (var i = 0; i < sel.ranges.length; i++) { - var range = sel.ranges[i]; - changes[i] = {from: range.from(), to: range.to(), text: splitLines(code[i]), origin: origin}; - } - var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse); - for (var i = changes.length - 1; i >= 0; i--) - makeChange(this, changes[i]); - if (newSel) - setSelectionReplaceHistory(this, newSel); - else if (this.cm) - ensureCursorVisible(this.cm); - }, - undo: docMethodOp(function () { - makeChangeFromHistory(this, "undo"); - }), - redo: docMethodOp(function () { - makeChangeFromHistory(this, "redo"); - }), - undoSelection: docMethodOp(function () { - makeChangeFromHistory(this, "undo", true); - }), - redoSelection: docMethodOp(function () { - makeChangeFromHistory(this, "redo", true); - }), - setExtending: function (val) { - this.extend = val; - }, - getExtending: function () { - return this.extend; - }, - historySize: function () { - var hist = this.history, done = 0, undone = 0; - for (var i = 0; i < hist.done.length; i++) - if (!hist.done[i].ranges) - ++done; - for (var i = 0; i < hist.undone.length; i++) - if (!hist.undone[i].ranges) - ++undone; - return {undo: done, redo: undone}; - }, - clearHistory: function () { - this.history = new History(this.history.maxGeneration); - }, - markClean: function () { - this.cleanGeneration = this.changeGeneration(true); - }, - changeGeneration: function (forceSplit) { - if (forceSplit) - this.history.lastOp = this.history.lastOrigin = null; - return this.history.generation; - }, - isClean: function (gen) { - return this.history.generation == (gen || this.cleanGeneration); - }, - getHistory: function () { - return {done: copyHistoryArray(this.history.done), - undone: copyHistoryArray(this.history.undone)}; - }, - setHistory: function (histData) { - var hist = this.history = new History(this.history.maxGeneration); - hist.done = copyHistoryArray(histData.done.slice(0), null, true); - hist.undone = copyHistoryArray(histData.undone.slice(0), null, true); - }, - markText: function (from, to, options) { - return markText(this, clipPos(this, from), clipPos(this, to), options, "range"); - }, - setBookmark: function (pos, options) { - var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options), - insertLeft: options && options.insertLeft, - clearWhenEmpty: false, shared: options && options.shared}; - pos = clipPos(this, pos); - return markText(this, pos, pos, realOpts, "bookmark"); - }, - findMarksAt: function (pos) { - pos = clipPos(this, pos); - var markers = [], spans = getLine(this, pos.line).markedSpans; - if (spans) - for (var i = 0; i < spans.length; ++i) { - var span = spans[i]; - if ((span.from == null || span.from <= pos.ch) && - (span.to == null || span.to >= pos.ch)) - markers.push(span.marker.parent || span.marker); - } - return markers; - }, - findMarks: function (from, to) { - from = clipPos(this, from); - to = clipPos(this, to); - var found = [], lineNo = from.line; - this.iter(from.line, to.line + 1, function (line) { - var spans = line.markedSpans; - if (spans) - for (var i = 0; i < spans.length; i++) { - var span = spans[i]; - if (!(lineNo == from.line && from.ch > span.to || - span.from == null && lineNo != from.line || - lineNo == to.line && span.from > to.ch)) - found.push(span.marker.parent || span.marker); - } - ++lineNo; - }); - return found; - }, - getAllMarks: function () { - var markers = []; - this.iter(function (line) { - var sps = line.markedSpans; - if (sps) - for (var i = 0; i < sps.length; ++i) - if (sps[i].from != null) - markers.push(sps[i].marker); - }); - return markers; - }, - posFromIndex: function (off) { - var ch, lineNo = this.first; - this.iter(function (line) { - var sz = line.text.length + 1; - if (sz > off) { - ch = off; - return true; - } - off -= sz; - ++lineNo; - }); - return clipPos(this, Pos(lineNo, ch)); - }, - indexFromPos: function (coords) { - coords = clipPos(this, coords); - var index = coords.ch; - if (coords.line < this.first || coords.ch < 0) - return 0; - this.iter(this.first, coords.line, function (line) { - index += line.text.length + 1; - }); - return index; - }, - copy: function (copyHistory) { - var doc = new Doc(getLines(this, this.first, this.first + this.size), this.modeOption, this.first); - doc.scrollTop = this.scrollTop; - doc.scrollLeft = this.scrollLeft; - doc.sel = this.sel; - doc.extend = false; - if (copyHistory) { - doc.history.undoDepth = this.history.undoDepth; - doc.setHistory(this.getHistory()); - } - return doc; - }, - linkedDoc: function (options) { - if (!options) - options = {}; - var from = this.first, to = this.first + this.size; - if (options.from != null && options.from > from) - from = options.from; - if (options.to != null && options.to < to) - to = options.to; - var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from); - if (options.sharedHist) - copy.history = this.history; - (this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist}); - copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}]; - return copy; - }, - unlinkDoc: function (other) { - if (other instanceof CodeMirror) - other = other.doc; - if (this.linked) - for (var i = 0; i < this.linked.length; ++i) { - var link = this.linked[i]; - if (link.doc != other) - continue; - this.linked.splice(i, 1); - other.unlinkDoc(this); - break; - } - // If the histories were shared, split them again - if (other.history == this.history) { - var splitIds = [other.id]; - linkedDocs(other, function (doc) { - splitIds.push(doc.id); - }, true); - other.history = new History(null); - other.history.done = copyHistoryArray(this.history.done, splitIds); - other.history.undone = copyHistoryArray(this.history.undone, splitIds); - } - }, - iterLinkedDocs: function (f) { - linkedDocs(this, f); - }, - getMode: function () { - return this.mode; - }, - getEditor: function () { - return this.cm; - } - }); - - // Public alias. - Doc.prototype.eachLine = Doc.prototype.iter; - - // Set up methods on CodeMirror's prototype to redirect to the editor's document. - var dontDelegate = "iter insert remove copy getEditor".split(" "); - for (var prop in Doc.prototype) - if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0) - CodeMirror.prototype[prop] = (function (method) { - return function () { - return method.apply(this.doc, arguments); - }; - })(Doc.prototype[prop]); - - eventMixin(Doc); - - // Call f for all linked documents. - function linkedDocs(doc, f, sharedHistOnly) { - function propagate(doc, skip, sharedHist) { - if (doc.linked) - for (var i = 0; i < doc.linked.length; ++i) { - var rel = doc.linked[i]; - if (rel.doc == skip) - continue; - var shared = sharedHist && rel.sharedHist; - if (sharedHistOnly && !shared) - continue; - f(rel.doc, shared); - propagate(rel.doc, doc, shared); - } - } - propagate(doc, null, true); - } - - // Attach a document to an editor. - function attachDoc(cm, doc) { - if (doc.cm) - throw new Error("This document is already in use."); - cm.doc = doc; - doc.cm = cm; - estimateLineHeights(cm); - loadMode(cm); - if (!cm.options.lineWrapping) - findMaxLine(cm); - cm.options.mode = doc.modeOption; - regChange(cm); - } - - // LINE UTILITIES - - // Find the line object corresponding to the given line number. - function getLine(doc, n) { - n -= doc.first; - if (n < 0 || n >= doc.size) - throw new Error("There is no line " + (n + doc.first) + " in the document."); - for (var chunk = doc; !chunk.lines; ) { - for (var i = 0; ; ++i) { - var child = chunk.children[i], sz = child.chunkSize(); - if (n < sz) { - chunk = child; - break; - } - n -= sz; - } - } - return chunk.lines[n]; - } - - // Get the part of a document between two positions, as an array of - // strings. - function getBetween(doc, start, end) { - var out = [], n = start.line; - doc.iter(start.line, end.line + 1, function (line) { - var text = line.text; - if (n == end.line) - text = text.slice(0, end.ch); - if (n == start.line) - text = text.slice(start.ch); - out.push(text); - ++n; - }); - return out; - } - // Get the lines between from and to, as array of strings. - function getLines(doc, from, to) { - var out = []; - doc.iter(from, to, function (line) { - out.push(line.text); - }); - return out; - } - - // Update the height of a line, propagating the height change - // upwards to parent nodes. - function updateLineHeight(line, height) { - var diff = height - line.height; - if (diff) - for (var n = line; n; n = n.parent) - n.height += diff; - } - - // Given a line object, find its line number by walking up through - // its parent links. - function lineNo(line) { - if (line.parent == null) - return null; - var cur = line.parent, no = indexOf(cur.lines, line); - for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) { - for (var i = 0; ; ++i) { - if (chunk.children[i] == cur) - break; - no += chunk.children[i].chunkSize(); - } - } - return no + cur.first; - } - - // Find the line at the given vertical position, using the height - // information in the document tree. - function lineAtHeight(chunk, h) { - var n = chunk.first; - outer: do { - for (var i = 0; i < chunk.children.length; ++i) { - var child = chunk.children[i], ch = child.height; - if (h < ch) { - chunk = child; - continue outer; - } - h -= ch; - n += child.chunkSize(); - } - return n; - } while (!chunk.lines); - for (var i = 0; i < chunk.lines.length; ++i) { - var line = chunk.lines[i], lh = line.height; - if (h < lh) - break; - h -= lh; - } - return n + i; - } - - - // Find the height above the given line. - function heightAtLine(lineObj) { - lineObj = visualLine(lineObj); - - var h = 0, chunk = lineObj.parent; - for (var i = 0; i < chunk.lines.length; ++i) { - var line = chunk.lines[i]; - if (line == lineObj) - break; - else - h += line.height; - } - for (var p = chunk.parent; p; chunk = p, p = chunk.parent) { - for (var i = 0; i < p.children.length; ++i) { - var cur = p.children[i]; - if (cur == chunk) - break; - else - h += cur.height; - } - } - return h; - } - - // Get the bidi ordering for the given line (and cache it). Returns - // false for lines that are fully left-to-right, and an array of - // BidiSpan objects otherwise. - function getOrder(line) { - var order = line.order; - if (order == null) - order = line.order = bidiOrdering(line.text); - return order; - } - - // HISTORY - - function History(startGen) { - // Arrays of change events and selections. Doing something adds an - // event to done and clears undo. Undoing moves events from done - // to undone, redoing moves them in the other direction. - this.done = []; - this.undone = []; - this.undoDepth = Infinity; - // Used to track when changes can be merged into a single undo - // event - this.lastModTime = this.lastSelTime = 0; - this.lastOp = null; - this.lastOrigin = this.lastSelOrigin = null; - // Used by the isClean() method - this.generation = this.maxGeneration = startGen || 1; - } - - // Create a history change event from an updateDoc-style change - // object. - function historyChangeFromChange(doc, change) { - var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)}; - attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1); - linkedDocs(doc, function (doc) { - attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1); - }, true); - return histChange; - } - - // Pop all selection events off the end of a history array. Stop at - // a change event. - function clearSelectionEvents(array) { - while (array.length) { - var last = lst(array); - if (last.ranges) - array.pop(); - else - break; - } - } - - // Find the top change event in the history. Pop off selection - // events that are in the way. - function lastChangeEvent(hist, force) { - if (force) { - clearSelectionEvents(hist.done); - return lst(hist.done); - } else if (hist.done.length && !lst(hist.done).ranges) { - return lst(hist.done); - } else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) { - hist.done.pop(); - return lst(hist.done); - } - } - - // Register a change in the history. Merges changes that are within - // a single operation, ore are close together with an origin that - // allows merging (starting with "+") into a single event. - function addChangeToHistory(doc, change, selAfter, opId) { - var hist = doc.history; - hist.undone.length = 0; - var time = +new Date, cur; - - if ((hist.lastOp == opId || - hist.lastOrigin == change.origin && change.origin && - ((change.origin.charAt(0) == "+" && doc.cm && hist.lastModTime > time - doc.cm.options.historyEventDelay) || - change.origin.charAt(0) == "*")) && - (cur = lastChangeEvent(hist, hist.lastOp == opId))) { - // Merge this change into the last event - var last = lst(cur.changes); - if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) { - // Optimized case for simple insertion -- don't want to add - // new changesets for every character typed - last.to = changeEnd(change); - } else { - // Add new sub-event - cur.changes.push(historyChangeFromChange(doc, change)); - } - } else { - // Can not be merged, start a new event. - var before = lst(hist.done); - if (!before || !before.ranges) - pushSelectionToHistory(doc.sel, hist.done); - cur = {changes: [historyChangeFromChange(doc, change)], - generation: hist.generation}; - hist.done.push(cur); - while (hist.done.length > hist.undoDepth) { - hist.done.shift(); - if (!hist.done[0].ranges) - hist.done.shift(); - } - } - hist.done.push(selAfter); - hist.generation = ++hist.maxGeneration; - hist.lastModTime = hist.lastSelTime = time; - hist.lastOp = opId; - hist.lastOrigin = hist.lastSelOrigin = change.origin; - - if (!last) - signal(doc, "historyAdded"); - } - - function selectionEventCanBeMerged(doc, origin, prev, sel) { - var ch = origin.charAt(0); - return ch == "*" || - ch == "+" && - prev.ranges.length == sel.ranges.length && - prev.somethingSelected() == sel.somethingSelected() && - new Date - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500); - } - - // Called whenever the selection changes, sets the new selection as - // the pending selection in the history, and pushes the old pending - // selection into the 'done' array when it was significantly - // different (in number of selected ranges, emptiness, or time). - function addSelectionToHistory(doc, sel, opId, options) { - var hist = doc.history, origin = options && options.origin; - - // A new event is started when the previous origin does not match - // the current, or the origins don't allow matching. Origins - // starting with * are always merged, those starting with + are - // merged when similar and close together in time. - if (opId == hist.lastOp || - (origin && hist.lastSelOrigin == origin && - (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin || - selectionEventCanBeMerged(doc, origin, lst(hist.done), sel)))) - hist.done[hist.done.length - 1] = sel; - else - pushSelectionToHistory(sel, hist.done); - - hist.lastSelTime = +new Date; - hist.lastSelOrigin = origin; - hist.lastOp = opId; - if (options && options.clearRedo !== false) - clearSelectionEvents(hist.undone); - } - - function pushSelectionToHistory(sel, dest) { - var top = lst(dest); - if (!(top && top.ranges && top.equals(sel))) - dest.push(sel); - } - - // Used to store marked span information in the history. - function attachLocalSpans(doc, change, from, to) { - var existing = change["spans_" + doc.id], n = 0; - doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function (line) { - if (line.markedSpans) - (existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans; - ++n; - }); - } - - // When un/re-doing restores text containing marked spans, those - // that have been explicitly cleared should not be restored. - function removeClearedSpans(spans) { - if (!spans) - return null; - for (var i = 0, out; i < spans.length; ++i) { - if (spans[i].marker.explicitlyCleared) { - if (!out) - out = spans.slice(0, i); - } - else if (out) - out.push(spans[i]); - } - return !out ? spans : out.length ? out : null; - } - - // Retrieve and filter the old marked spans stored in a change event. - function getOldSpans(doc, change) { - var found = change["spans_" + doc.id]; - if (!found) - return null; - for (var i = 0, nw = []; i < change.text.length; ++i) - nw.push(removeClearedSpans(found[i])); - return nw; - } - - // Used both to provide a JSON-safe object in .getHistory, and, when - // detaching a document, to split the history in two - function copyHistoryArray(events, newGroup, instantiateSel) { - for (var i = 0, copy = []; i < events.length; ++i) { - var event = events[i]; - if (event.ranges) { - copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event); - continue; - } - var changes = event.changes, newChanges = []; - copy.push({changes: newChanges}); - for (var j = 0; j < changes.length; ++j) { - var change = changes[j], m; - newChanges.push({from: change.from, to: change.to, text: change.text}); - if (newGroup) - for (var prop in change) - if (m = prop.match(/^spans_(\d+)$/)) { - if (indexOf(newGroup, Number(m[1])) > -1) { - lst(newChanges)[prop] = change[prop]; - delete change[prop]; - } - } - } - } - return copy; - } - - // Rebasing/resetting history to deal with externally-sourced changes - - function rebaseHistSelSingle(pos, from, to, diff) { - if (to < pos.line) { - pos.line += diff; - } else if (from < pos.line) { - pos.line = from; - pos.ch = 0; - } - } - - // Tries to rebase an array of history events given a change in the - // document. If the change touches the same lines as the event, the - // event, and everything 'behind' it, is discarded. If the change is - // before the event, the event's positions are updated. Uses a - // copy-on-write scheme for the positions, to avoid having to - // reallocate them all on every rebase, but also avoid problems with - // shared position objects being unsafely updated. - function rebaseHistArray(array, from, to, diff) { - for (var i = 0; i < array.length; ++i) { - var sub = array[i], ok = true; - if (sub.ranges) { - if (!sub.copied) { - sub = array[i] = sub.deepCopy(); - sub.copied = true; - } - for (var j = 0; j < sub.ranges.length; j++) { - rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff); - rebaseHistSelSingle(sub.ranges[j].head, from, to, diff); - } - continue; - } - for (var j = 0; j < sub.changes.length; ++j) { - var cur = sub.changes[j]; - if (to < cur.from.line) { - cur.from = Pos(cur.from.line + diff, cur.from.ch); - cur.to = Pos(cur.to.line + diff, cur.to.ch); - } else if (from <= cur.to.line) { - ok = false; - break; - } - } - if (!ok) { - array.splice(0, i + 1); - i = 0; - } - } - } - - function rebaseHist(hist, change) { - var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1; - rebaseHistArray(hist.done, from, to, diff); - rebaseHistArray(hist.undone, from, to, diff); - } - - // EVENT UTILITIES - - // Due to the fact that we still support jurassic IE versions, some - // compatibility wrappers are needed. - - var e_preventDefault = CodeMirror.e_preventDefault = function (e) { - if (e.preventDefault) - e.preventDefault(); - else - e.returnValue = false; - }; - var e_stopPropagation = CodeMirror.e_stopPropagation = function (e) { - if (e.stopPropagation) - e.stopPropagation(); - else - e.cancelBubble = true; - }; - function e_defaultPrevented(e) { - return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false; - } - var e_stop = CodeMirror.e_stop = function (e) { - e_preventDefault(e); - e_stopPropagation(e); - }; - - function e_target(e) { - return e.target || e.srcElement; - } - function e_button(e) { - var b = e.which; - if (b == null) { - if (e.button & 1) - b = 1; - else if (e.button & 2) - b = 3; - else if (e.button & 4) - b = 2; - } - if (mac && e.ctrlKey && b == 1) - b = 3; - return b; - } - - // EVENT HANDLING - - // Lightweight event framework. on/off also work on DOM nodes, - // registering native DOM handlers. - - var on = CodeMirror.on = function (emitter, type, f) { - if (emitter.addEventListener) - emitter.addEventListener(type, f, false); - else if (emitter.attachEvent) - emitter.attachEvent("on" + type, f); - else { - var map = emitter._handlers || (emitter._handlers = {}); - var arr = map[type] || (map[type] = []); - arr.push(f); - } - }; - - var off = CodeMirror.off = function (emitter, type, f) { - if (emitter.removeEventListener) - emitter.removeEventListener(type, f, false); - else if (emitter.detachEvent) - emitter.detachEvent("on" + type, f); - else { - var arr = emitter._handlers && emitter._handlers[type]; - if (!arr) - return; - for (var i = 0; i < arr.length; ++i) - if (arr[i] == f) { - arr.splice(i, 1); - break; - } - } - }; - - var signal = CodeMirror.signal = function (emitter, type /*, values...*/) { - var arr = emitter._handlers && emitter._handlers[type]; - if (!arr) - return; - var args = Array.prototype.slice.call(arguments, 2); - for (var i = 0; i < arr.length; ++i) - arr[i].apply(null, args); - }; - - // Often, we want to signal events at a point where we are in the - // middle of some work, but don't want the handler to start calling - // other methods on the editor, which might be in an inconsistent - // state or simply not expect any other events to happen. - // signalLater looks whether there are any handlers, and schedules - // them to be executed when the last operation ends, or, if no - // operation is active, when a timeout fires. - var delayedCallbacks, delayedCallbackDepth = 0; - function signalLater(emitter, type /*, values...*/) { - var arr = emitter._handlers && emitter._handlers[type]; - if (!arr) - return; - var args = Array.prototype.slice.call(arguments, 2); - if (!delayedCallbacks) { - ++delayedCallbackDepth; - delayedCallbacks = []; - setTimeout(fireDelayed, 0); - } - function bnd(f) { - return function () { - f.apply(null, args); - }; - } - ; - for (var i = 0; i < arr.length; ++i) - delayedCallbacks.push(bnd(arr[i])); - } - - function fireDelayed() { - --delayedCallbackDepth; - var delayed = delayedCallbacks; - delayedCallbacks = null; - for (var i = 0; i < delayed.length; ++i) - delayed[i](); - } - - // The DOM events that CodeMirror handles can be overridden by - // registering a (non-DOM) handler on the editor for the event name, - // and preventDefault-ing the event in that handler. - function signalDOMEvent(cm, e, override) { - signal(cm, override || e.type, cm, e); - return e_defaultPrevented(e) || e.codemirrorIgnore; - } - - function hasHandler(emitter, type) { - var arr = emitter._handlers && emitter._handlers[type]; - return arr && arr.length > 0; - } - - // Add on and off methods to a constructor's prototype, to make - // registering events on such objects more convenient. - function eventMixin(ctor) { - ctor.prototype.on = function (type, f) { - on(this, type, f); - }; - ctor.prototype.off = function (type, f) { - off(this, type, f); - }; - } - - // MISC UTILITIES - - // Number of pixels added to scroller and sizer to hide scrollbar - var scrollerCutOff = 30; - - // Returned or thrown by various protocols to signal 'I'm not - // handling this'. - var Pass = CodeMirror.Pass = {toString: function () { - return "CodeMirror.Pass"; - }}; - - // Reused option objects for setSelection & friends - var sel_dontScroll = {scroll: false}, sel_mouse = {origin: "*mouse"}, sel_move = {origin: "+move"}; - - function Delayed() { - this.id = null; - } - Delayed.prototype.set = function (ms, f) { - clearTimeout(this.id); - this.id = setTimeout(f, ms); - }; - - // Counts the column offset in a string, taking tabs into account. - // Used mostly to find indentation. - var countColumn = CodeMirror.countColumn = function (string, end, tabSize, startIndex, startValue) { - if (end == null) { - end = string.search(/[^\s\u00a0]/); - if (end == -1) - end = string.length; - } - for (var i = startIndex || 0, n = startValue || 0; ; ) { - var nextTab = string.indexOf("\t", i); - if (nextTab < 0 || nextTab >= end) - return n + (end - i); - n += nextTab - i; - n += tabSize - (n % tabSize); - i = nextTab + 1; - } - }; - - // The inverse of countColumn -- find the offset that corresponds to - // a particular column. - function findColumn(string, goal, tabSize) { - for (var pos = 0, col = 0; ; ) { - var nextTab = string.indexOf("\t", pos); - if (nextTab == -1) - nextTab = string.length; - var skipped = nextTab - pos; - if (nextTab == string.length || col + skipped >= goal) - return pos + Math.min(skipped, goal - col); - col += nextTab - pos; - col += tabSize - (col % tabSize); - pos = nextTab + 1; - if (col >= goal) - return pos; - } - } - - var spaceStrs = [""]; - function spaceStr(n) { - while (spaceStrs.length <= n) - spaceStrs.push(lst(spaceStrs) + " "); - return spaceStrs[n]; - } - - function lst(arr) { - return arr[arr.length - 1]; - } - - var selectInput = function (node) { - node.select(); - }; - if (ios) // Mobile Safari apparently has a bug where select() is broken. - selectInput = function (node) { - node.selectionStart = 0; - node.selectionEnd = node.value.length; - }; - else if (ie) // Suppress mysterious IE10 errors - selectInput = function (node) { - try { - node.select(); - } catch (_e) { - } - }; - - function indexOf(array, elt) { - for (var i = 0; i < array.length; ++i) - if (array[i] == elt) - return i; - return -1; - } - if ([].indexOf) - indexOf = function (array, elt) { - return array.indexOf(elt); - }; - function map(array, f) { - var out = []; - for (var i = 0; i < array.length; i++) - out[i] = f(array[i], i); - return out; - } - if ([].map) - map = function (array, f) { - return array.map(f); - }; - - function createObj(base, props) { - var inst; - if (Object.create) { - inst = Object.create(base); - } else { - var ctor = function () { - }; - ctor.prototype = base; - inst = new ctor(); - } - if (props) - copyObj(props, inst); - return inst; - } - ; - - function copyObj(obj, target) { - if (!target) - target = {}; - for (var prop in obj) - if (obj.hasOwnProperty(prop)) - target[prop] = obj[prop]; - return target; - } - - function bind(f) { - var args = Array.prototype.slice.call(arguments, 1); - return function () { - return f.apply(null, args); - }; - } - - var nonASCIISingleCaseWordChar = /[\u00df\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/; - var isWordChar = CodeMirror.isWordChar = function (ch) { - return /\w/.test(ch) || ch > "\x80" && - (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch)); - }; - - function isEmpty(obj) { - for (var n in obj) - if (obj.hasOwnProperty(n) && obj[n]) - return false; - return true; - } - - // Extending unicode characters. A series of a non-extending char + - // any number of extending chars is treated as a single unit as far - // as editing and measuring is concerned. This is not fully correct, - // since some scripts/fonts/browsers also treat other configurations - // of code points as a group. - var extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/; - function isExtendingChar(ch) { - return ch.charCodeAt(0) >= 768 && extendingChars.test(ch); - } - - // DOM UTILITIES - - function elt(tag, content, className, style) { - var e = document.createElement(tag); - if (className) - e.className = className; - if (style) - e.style.cssText = style; - if (typeof content == "string") - e.appendChild(document.createTextNode(content)); - else if (content) - for (var i = 0; i < content.length; ++i) - e.appendChild(content[i]); - return e; - } - - var range; - if (document.createRange) - range = function (node, start, end) { - var r = document.createRange(); - r.setEnd(node, end); - r.setStart(node, start); - return r; - }; - else - range = function (node, start, end) { - var r = document.body.createTextRange(); - r.moveToElementText(node.parentNode); - r.collapse(true); - r.moveEnd("character", end); - r.moveStart("character", start); - return r; - }; - - function removeChildren(e) { - for (var count = e.childNodes.length; count > 0; --count) - e.removeChild(e.firstChild); - return e; - } - - function removeChildrenAndAdd(parent, e) { - return removeChildren(parent).appendChild(e); - } - - function contains(parent, child) { - if (parent.contains) - return parent.contains(child); - while (child = child.parentNode) - if (child == parent) - return true; - } - - function activeElt() { - return document.activeElement; - } - // Older versions of IE throws unspecified error when touching - // document.activeElement in some cases (during loading, in iframe) - if (ie_upto10) - activeElt = function () { - try { - return document.activeElement; - } - catch (e) { - return document.body; - } - }; - - // FEATURE DETECTION - - // Detect drag-and-drop - var dragAndDrop = function () { - // There is *some* kind of drag-and-drop support in IE6-8, but I - // couldn't get it to work yet. - if (ie_upto8) - return false; - var div = elt('div'); - return "draggable" in div || "dragDrop" in div; - }(); - - var knownScrollbarWidth; - function scrollbarWidth(measure) { - if (knownScrollbarWidth != null) - return knownScrollbarWidth; - var test = elt("div", null, null, "width: 50px; height: 50px; overflow-x: scroll"); - removeChildrenAndAdd(measure, test); - if (test.offsetWidth) - knownScrollbarWidth = test.offsetHeight - test.clientHeight; - return knownScrollbarWidth || 0; - } - - var zwspSupported; - function zeroWidthElement(measure) { - if (zwspSupported == null) { - var test = elt("span", "\u200b"); - removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")])); - if (measure.firstChild.offsetHeight != 0) - zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !ie_upto7; - } - if (zwspSupported) - return elt("span", "\u200b"); - else - return elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px"); - } - - // Feature-detect IE's crummy client rect reporting for bidi text - var badBidiRects; - function hasBadBidiRects(measure) { - if (badBidiRects != null) - return badBidiRects; - var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA")); - var r0 = range(txt, 0, 1).getBoundingClientRect(); - if (r0.left == r0.right) - return false; - var r1 = range(txt, 1, 2).getBoundingClientRect(); - return badBidiRects = (r1.right - r0.right < 3); - } - - // See if "".split is the broken IE version, if so, provide an - // alternative way to split lines. - var splitLines = CodeMirror.splitLines = "\n\nb".split(/\n/).length != 3 ? function (string) { - var pos = 0, result = [], l = string.length; - while (pos <= l) { - var nl = string.indexOf("\n", pos); - if (nl == -1) - nl = string.length; - var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl); - var rt = line.indexOf("\r"); - if (rt != -1) { - result.push(line.slice(0, rt)); - pos += rt + 1; - } else { - result.push(line); - pos = nl + 1; - } - } - return result; - } : function (string) { - return string.split(/\r\n?|\n/); - }; - - var hasSelection = window.getSelection ? function (te) { - try { - return te.selectionStart != te.selectionEnd; - } - catch (e) { - return false; - } - } : function (te) { - try { - var range = te.ownerDocument.selection.createRange(); - } - catch (e) { - } - if (!range || range.parentElement() != te) - return false; - return range.compareEndPoints("StartToEnd", range) != 0; - }; - - var hasCopyEvent = (function () { - var e = elt("div"); - if ("oncopy" in e) - return true; - e.setAttribute("oncopy", "return;"); - return typeof e.oncopy == "function"; - })(); - - // KEY NAMES - - var keyNames = {3: "Enter", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt", - 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End", - 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert", - 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod", 107: "=", 109: "-", 127: "Delete", - 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\", - 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete", - 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"}; - CodeMirror.keyNames = keyNames; - (function () { - // Number keys - for (var i = 0; i < 10; i++) - keyNames[i + 48] = keyNames[i + 96] = String(i); - // Alphabetic keys - for (var i = 65; i <= 90; i++) - keyNames[i] = String.fromCharCode(i); - // Function keys - for (var i = 1; i <= 12; i++) - keyNames[i + 111] = keyNames[i + 63235] = "F" + i; - })(); - - // BIDI HELPERS - - function iterateBidiSections(order, from, to, f) { - if (!order) - return f(from, to, "ltr"); - var found = false; - for (var i = 0; i < order.length; ++i) { - var part = order[i]; - if (part.from < to && part.to > from || from == to && part.to == from) { - f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr"); - found = true; - } - } - if (!found) - f(from, to, "ltr"); - } - - function bidiLeft(part) { - return part.level % 2 ? part.to : part.from; - } - function bidiRight(part) { - return part.level % 2 ? part.from : part.to; - } - - function lineLeft(line) { - var order = getOrder(line); - return order ? bidiLeft(order[0]) : 0; - } - function lineRight(line) { - var order = getOrder(line); - if (!order) - return line.text.length; - return bidiRight(lst(order)); - } - - function lineStart(cm, lineN) { - var line = getLine(cm.doc, lineN); - var visual = visualLine(line); - if (visual != line) - lineN = lineNo(visual); - var order = getOrder(visual); - var ch = !order ? 0 : order[0].level % 2 ? lineRight(visual) : lineLeft(visual); - return Pos(lineN, ch); - } - function lineEnd(cm, lineN) { - var merged, line = getLine(cm.doc, lineN); - while (merged = collapsedSpanAtEnd(line)) { - line = merged.find(1, true).line; - lineN = null; - } - var order = getOrder(line); - var ch = !order ? line.text.length : order[0].level % 2 ? lineLeft(line) : lineRight(line); - return Pos(lineN == null ? lineNo(line) : lineN, ch); - } - - function compareBidiLevel(order, a, b) { - var linedir = order[0].level; - if (a == linedir) - return true; - if (b == linedir) - return false; - return a < b; - } - var bidiOther; - function getBidiPartAt(order, pos) { - bidiOther = null; - for (var i = 0, found; i < order.length; ++i) { - var cur = order[i]; - if (cur.from < pos && cur.to > pos) - return i; - if ((cur.from == pos || cur.to == pos)) { - if (found == null) { - found = i; - } else if (compareBidiLevel(order, cur.level, order[found].level)) { - if (cur.from != cur.to) - bidiOther = found; - return i; - } else { - if (cur.from != cur.to) - bidiOther = i; - return found; - } - } - } - return found; - } - - function moveInLine(line, pos, dir, byUnit) { - if (!byUnit) - return pos + dir; - do - pos += dir; - while (pos > 0 && isExtendingChar(line.text.charAt(pos))); - return pos; - } - - // This is needed in order to move 'visually' through bi-directional - // text -- i.e., pressing left should make the cursor go left, even - // when in RTL text. The tricky part is the 'jumps', where RTL and - // LTR text touch each other. This often requires the cursor offset - // to move more than one unit, in order to visually move one unit. - function moveVisually(line, start, dir, byUnit) { - var bidi = getOrder(line); - if (!bidi) - return moveLogically(line, start, dir, byUnit); - var pos = getBidiPartAt(bidi, start), part = bidi[pos]; - var target = moveInLine(line, start, part.level % 2 ? -dir : dir, byUnit); - - for (; ; ) { - if (target > part.from && target < part.to) - return target; - if (target == part.from || target == part.to) { - if (getBidiPartAt(bidi, target) == pos) - return target; - part = bidi[pos += dir]; - return (dir > 0) == part.level % 2 ? part.to : part.from; - } else { - part = bidi[pos += dir]; - if (!part) - return null; - if ((dir > 0) == part.level % 2) - target = moveInLine(line, part.to, -1, byUnit); - else - target = moveInLine(line, part.from, 1, byUnit); - } - } - } - - function moveLogically(line, start, dir, byUnit) { - var target = start + dir; - if (byUnit) - while (target > 0 && isExtendingChar(line.text.charAt(target))) - target += dir; - return target < 0 || target > line.text.length ? null : target; - } - - // Bidirectional ordering algorithm - // See http://unicode.org/reports/tr9/tr9-13.html for the algorithm - // that this (partially) implements. - - // One-char codes used for character types: - // L (L): Left-to-Right - // R (R): Right-to-Left - // r (AL): Right-to-Left Arabic - // 1 (EN): European Number - // + (ES): European Number Separator - // % (ET): European Number Terminator - // n (AN): Arabic Number - // , (CS): Common Number Separator - // m (NSM): Non-Spacing Mark - // b (BN): Boundary Neutral - // s (B): Paragraph Separator - // t (S): Segment Separator - // w (WS): Whitespace - // N (ON): Other Neutrals - - // Returns null if characters are ordered as they appear - // (left-to-right), or an array of sections ({from, to, level} - // objects) in the order in which they occur visually. - var bidiOrdering = (function () { - // Character types for codepoints 0 to 0xff - var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN"; - // Character types for codepoints 0x600 to 0x6ff - var arabicTypes = "rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm"; - function charType(code) { - if (code <= 0xf7) - return lowTypes.charAt(code); - else if (0x590 <= code && code <= 0x5f4) - return "R"; - else if (0x600 <= code && code <= 0x6ed) - return arabicTypes.charAt(code - 0x600); - else if (0x6ee <= code && code <= 0x8ac) - return "r"; - else if (0x2000 <= code && code <= 0x200b) - return "w"; - else if (code == 0x200c) - return "b"; - else - return "L"; - } - - var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/; - var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/; - // Browsers seem to always treat the boundaries of block elements as being L. - var outerType = "L"; - - function BidiSpan(level, from, to) { - this.level = level; - this.from = from; - this.to = to; - } - - return function (str) { - if (!bidiRE.test(str)) - return false; - var len = str.length, types = []; - for (var i = 0, type; i < len; ++i) - types.push(type = charType(str.charCodeAt(i))); - - // W1. Examine each non-spacing mark (NSM) in the level run, and - // change the type of the NSM to the type of the previous - // character. If the NSM is at the start of the level run, it will - // get the type of sor. - for (var i = 0, prev = outerType; i < len; ++i) { - var type = types[i]; - if (type == "m") - types[i] = prev; - else - prev = type; - } - - // W2. Search backwards from each instance of a European number - // until the first strong type (R, L, AL, or sor) is found. If an - // AL is found, change the type of the European number to Arabic - // number. - // W3. Change all ALs to R. - for (var i = 0, cur = outerType; i < len; ++i) { - var type = types[i]; - if (type == "1" && cur == "r") - types[i] = "n"; - else if (isStrong.test(type)) { - cur = type; - if (type == "r") - types[i] = "R"; - } - } - - // W4. A single European separator between two European numbers - // changes to a European number. A single common separator between - // two numbers of the same type changes to that type. - for (var i = 1, prev = types[0]; i < len - 1; ++i) { - var type = types[i]; - if (type == "+" && prev == "1" && types[i + 1] == "1") - types[i] = "1"; - else if (type == "," && prev == types[i + 1] && - (prev == "1" || prev == "n")) - types[i] = prev; - prev = type; - } - - // W5. A sequence of European terminators adjacent to European - // numbers changes to all European numbers. - // W6. Otherwise, separators and terminators change to Other - // Neutral. - for (var i = 0; i < len; ++i) { - var type = types[i]; - if (type == ",") - types[i] = "N"; - else if (type == "%") { - for (var end = i + 1; end < len && types[end] == "%"; ++end) { - } - var replace = (i && types[i - 1] == "!") || (end < len && types[end] == "1") ? "1" : "N"; - for (var j = i; j < end; ++j) - types[j] = replace; - i = end - 1; - } - } - - // W7. Search backwards from each instance of a European number - // until the first strong type (R, L, or sor) is found. If an L is - // found, then change the type of the European number to L. - for (var i = 0, cur = outerType; i < len; ++i) { - var type = types[i]; - if (cur == "L" && type == "1") - types[i] = "L"; - else if (isStrong.test(type)) - cur = type; - } - - // N1. A sequence of neutrals takes the direction of the - // surrounding strong text if the text on both sides has the same - // direction. European and Arabic numbers act as if they were R in - // terms of their influence on neutrals. Start-of-level-run (sor) - // and end-of-level-run (eor) are used at level run boundaries. - // N2. Any remaining neutrals take the embedding direction. - for (var i = 0; i < len; ++i) { - if (isNeutral.test(types[i])) { - for (var end = i + 1; end < len && isNeutral.test(types[end]); ++end) { - } - var before = (i ? types[i - 1] : outerType) == "L"; - var after = (end < len ? types[end] : outerType) == "L"; - var replace = before || after ? "L" : "R"; - for (var j = i; j < end; ++j) - types[j] = replace; - i = end - 1; - } - } - - // Here we depart from the documented algorithm, in order to avoid - // building up an actual levels array. Since there are only three - // levels (0, 1, 2) in an implementation that doesn't take - // explicit embedding into account, we can build up the order on - // the fly, without following the level-based algorithm. - var order = [], m; - for (var i = 0; i < len; ) { - if (countsAsLeft.test(types[i])) { - var start = i; - for (++i; i < len && countsAsLeft.test(types[i]); ++i) { - } - order.push(new BidiSpan(0, start, i)); - } else { - var pos = i, at = order.length; - for (++i; i < len && types[i] != "L"; ++i) { - } - for (var j = pos; j < i; ) { - if (countsAsNum.test(types[j])) { - if (pos < j) - order.splice(at, 0, new BidiSpan(1, pos, j)); - var nstart = j; - for (++j; j < i && countsAsNum.test(types[j]); ++j) { - } - order.splice(at, 0, new BidiSpan(2, nstart, j)); - pos = j; - } else - ++j; - } - if (pos < i) - order.splice(at, 0, new BidiSpan(1, pos, i)); - } - } - if (order[0].level == 1 && (m = str.match(/^\s+/))) { - order[0].from = m[0].length; - order.unshift(new BidiSpan(0, 0, m[0].length)); - } - if (lst(order).level == 1 && (m = str.match(/\s+$/))) { - lst(order).to -= m[0].length; - order.push(new BidiSpan(0, len - m[0].length, len)); - } - if (order[0].level != lst(order).level) - order.push(new BidiSpan(order[0].level, len, len)); - - return order; - }; - })(); - - // THE END - - CodeMirror.version = "4.0.3"; - - return CodeMirror; -}); diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/d3/LICENSE b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/d3/LICENSE old mode 100755 new mode 100644 index 83602d5e5c..83013469b9 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/d3/LICENSE +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/d3/LICENSE @@ -1,26 +1,26 @@ -Copyright (c) 2013, Michael Bostock -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. - -* The name Michael Bostock may not 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 MICHAEL BOSTOCK 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. +Copyright (c) 2010-2014, Michael Bostock +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. + +* The name Michael Bostock may not 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 MICHAEL BOSTOCK 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. diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/d3/d3.min.js b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/d3/d3.min.js old mode 100755 new mode 100644 index 862fcb2211..ddaf546248 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/d3/d3.min.js +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/d3/d3.min.js @@ -1,5385 +1,5 @@ -d3 = function () { - function n(n) { - return null != n && !isNaN(n) - } - function t(n) { - return n.length - } - function e(n) { - for (var t = 1; n * t % 1; ) - t *= 10; - return t - } - function r(n, t) { - try { - for (var e in t) - Object.defineProperty(n.prototype, e, {value: t[e], enumerable: !1}) - } catch (r) { - n.prototype = t - } - } - function u() { - } - function i() { - } - function o(n, t, e) { - return function () { - var r = e.apply(t, arguments); - return r === t ? n : r - } - } - function a(n, t) { - if (t in n) - return t; - t = t.charAt(0).toUpperCase() + t.substring(1); - for (var e = 0, r = Co.length; r > e; ++e) { - var u = Co[e] + t; - if (u in n) - return u - } - } - function c() { - } - function l() { - } - function s(n) { - function t() { - for (var t, r = e, u = -1, i = r.length; ++u < i; ) - (t = r[u].on) && t.apply(this, arguments); - return n - } - var e = [], r = new u; - return t.on = function (t, u) { - var i, o = r.get(t); - return arguments.length < 2 ? o && o.on : (o && (o.on = null, e = e.slice(0, i = e.indexOf(o)).concat(e.slice(i + 1)), r.remove(t)), u && e.push(r.set(t, {on: u})), n) - }, t - } - function f() { - vo.event.preventDefault() - } - function h() { - for (var n, t = vo.event; n = t.sourceEvent; ) - t = n; - return t - } - function g(n) { - for (var t = new l, e = 0, r = arguments.length; ++e < r; ) - t[arguments[e]] = s(t); - return t.of = function (e, r) { - return function (u) { - try { - var i = u.sourceEvent = vo.event; - u.target = n, vo.event = u, t[u.type].apply(e, r) - } finally { - vo.event = i - } - } - }, t - } - function p(n) { - return jo(n, Oo), n - } - function d(n) { - return"function" == typeof n ? n : function () { - return Lo(n, this) - } - } - function v(n) { - return"function" == typeof n ? n : function () { - return Ho(n, this) - } - } - function m(n, t) { - function e() { - this.removeAttribute(n) - } - function r() { - this.removeAttributeNS(n.space, n.local) - } - function u() { - this.setAttribute(n, t) - } - function i() { - this.setAttributeNS(n.space, n.local, t) - } - function o() { - var e = t.apply(this, arguments); - null == e ? this.removeAttribute(n) : this.setAttribute(n, e) - } - function a() { - var e = t.apply(this, arguments); - null == e ? this.removeAttributeNS(n.space, n.local) : this.setAttributeNS(n.space, n.local, e) - } - return n = vo.ns.qualify(n), null == t ? n.local ? r : e : "function" == typeof t ? n.local ? a : o : n.local ? i : u - } - function y(n) { - return n.trim().replace(/\s+/g, " ") - } - function M(n) { - return new RegExp("(?:^|\\s+)" + vo.requote(n) + "(?:\\s+|$)", "g") - } - function x(n, t) { - function e() { - for (var e = -1; ++e < u; ) - n[e](this, t) - } - function r() { - for (var e = -1, r = t.apply(this, arguments); ++e < u; ) - n[e](this, r) - } - n = n.trim().split(/\s+/).map(b); - var u = n.length; - return"function" == typeof t ? r : e - } - function b(n) { - var t = M(n); - return function (e, r) { - if (u = e.classList) - return r ? u.add(n) : u.remove(n); - var u = e.getAttribute("class") || ""; - r ? (t.lastIndex = 0, t.test(u) || e.setAttribute("class", y(u + " " + n))) : e.setAttribute("class", y(u.replace(t, " "))) - } - } - function _(n, t, e) { - function r() { - this.style.removeProperty(n) - } - function u() { - this.style.setProperty(n, t, e) - } - function i() { - var r = t.apply(this, arguments); - null == r ? this.style.removeProperty(n) : this.style.setProperty(n, r, e) - } - return null == t ? r : "function" == typeof t ? i : u - } - function w(n, t) { - function e() { - delete this[n] - } - function r() { - this[n] = t - } - function u() { - var e = t.apply(this, arguments); - null == e ? delete this[n] : this[n] = e - } - return null == t ? e : "function" == typeof t ? u : r - } - function S(n) { - return"function" == typeof n ? n : (n = vo.ns.qualify(n)).local ? function () { - return Mo.createElementNS(n.space, n.local) - } : function () { - return Mo.createElementNS(this.namespaceURI, n) - } - } - function E(n) { - return{__data__: n} - } - function k(n) { - return function () { - return Po(this, n) - } - } - function A(n) { - return arguments.length || (n = vo.ascending), function (t, e) { - return t && e ? n(t.__data__, e.__data__) : !t - !e - } - } - function N(n, t) { - for (var e = 0, r = n.length; r > e; e++) - for (var u, i = n[e], o = 0, a = i.length; a > o; o++) - (u = i[o]) && t(u, o, e); - return n - } - function q(n) { - return jo(n, Yo), n - } - function T(n) { - var t, e; - return function (r, u, i) { - var o, a = n[i].update, c = a.length; - for (i != e && (e = i, t = 0), u >= t && (t = u + 1); !(o = a[t]) && ++t < c; ) - ; - return o - } - } - function z() { - var n = this.__transition__; - n && ++n.active - } - function C(n, t, e) { - function r() { - var t = this[o]; - t && (this.removeEventListener(n, t, t.$), delete this[o]) - } - function u() { - var u = l(t, yo(arguments)); - r.call(this), this.addEventListener(n, this[o] = u, u.$ = e), u._ = t - } - function i() { - var t, e = new RegExp("^__on([^.]+)" + vo.requote(n) + "$"); - for (var r in this) - if (t = r.match(e)) { - var u = this[r]; - this.removeEventListener(t[1], u, u.$), delete this[r] - } - } - var o = "__on" + n, a = n.indexOf("."), l = D; - a > 0 && (n = n.substring(0, a)); - var s = Uo.get(n); - return s && (n = s, l = j), a ? t ? u : r : t ? c : i - } - function D(n, t) { - return function (e) { - var r = vo.event; - vo.event = e, t[0] = this.__data__; - try { - n.apply(this, t) - } finally { - vo.event = r - } - } - } - function j(n, t) { - var e = D(n, t); - return function (n) { - var t = this, r = n.relatedTarget; - r && (r === t || 8 & r.compareDocumentPosition(t)) || e.call(t, n) - } - } - function L() { - var n = ".dragsuppress-" + ++Zo, t = "touchmove" + n, e = "selectstart" + n, r = "dragstart" + n, u = "click" + n, i = vo.select(bo).on(t, f).on(e, f).on(r, f), o = xo.style, a = o[Vo]; - return o[Vo] = "none", function (t) { - function e() { - i.on(u, null) - } - i.on(n, null), o[Vo] = a, t && (i.on(u, function () { - f(), e() - }, !0), setTimeout(e, 0)) - } - } - function H(n, t) { - var e = n.ownerSVGElement || n; - if (e.createSVGPoint) { - var r = e.createSVGPoint(); - if (0 > Xo && (bo.scrollX || bo.scrollY)) { - e = vo.select("body").append("svg").style({position: "absolute", top: 0, left: 0, margin: 0, padding: 0, border: "none"}, "important"); - var u = e[0][0].getScreenCTM(); - Xo = !(u.f || u.e), e.remove() - } - return Xo ? (r.x = t.pageX, r.y = t.pageY) : (r.x = t.clientX, r.y = t.clientY), r = r.matrixTransform(n.getScreenCTM().inverse()), [r.x, r.y] - } - var i = n.getBoundingClientRect(); - return[t.clientX - i.left - n.clientLeft, t.clientY - i.top - n.clientTop] - } - function F(n) { - return n > 0 ? 1 : 0 > n ? -1 : 0 - } - function P(n) { - return n > 1 ? 0 : -1 > n ? Bo : Math.acos(n) - } - function O(n) { - return n > 1 ? Bo / 2 : -1 > n ? -Bo / 2 : Math.asin(n) - } - function R(n) { - return(Math.exp(n) - Math.exp(-n)) / 2 - } - function Y(n) { - return(Math.exp(n) + Math.exp(-n)) / 2 - } - function I(n) { - return R(n) / Y(n) - } - function U(n) { - return(n = Math.sin(n / 2)) * n - } - function V() { - } - function Z(n, t, e) { - return new X(n, t, e) - } - function X(n, t, e) { - this.h = n, this.s = t, this.l = e - } - function B(n, t, e) { - function r(n) { - return n > 360 ? n -= 360 : 0 > n && (n += 360), 60 > n ? i + (o - i) * n / 60 : 180 > n ? o : 240 > n ? i + (o - i) * (240 - n) / 60 : i - } - function u(n) { - return Math.round(255 * r(n)) - } - var i, o; - return n = isNaN(n) ? 0 : (n %= 360) < 0 ? n + 360 : n, t = isNaN(t) ? 0 : 0 > t ? 0 : t > 1 ? 1 : t, e = 0 > e ? 0 : e > 1 ? 1 : e, o = .5 >= e ? e * (1 + t) : e + t - e * t, i = 2 * e - o, ot(u(n + 120), u(n), u(n - 120)) - } - function $(n, t, e) { - return new W(n, t, e) - } - function W(n, t, e) { - this.h = n, this.c = t, this.l = e - } - function J(n, t, e) { - return isNaN(n) && (n = 0), isNaN(t) && (t = 0), G(e, Math.cos(n *= Jo) * t, Math.sin(n) * t) - } - function G(n, t, e) { - return new K(n, t, e) - } - function K(n, t, e) { - this.l = n, this.a = t, this.b = e - } - function Q(n, t, e) { - var r = (n + 16) / 116, u = r + t / 500, i = r - e / 200; - return u = tt(u) * aa, r = tt(r) * ca, i = tt(i) * la, ot(rt(3.2404542 * u - 1.5371385 * r - .4985314 * i), rt(-.969266 * u + 1.8760108 * r + .041556 * i), rt(.0556434 * u - .2040259 * r + 1.0572252 * i)) - } - function nt(n, t, e) { - return n > 0 ? $(Math.atan2(e, t) * Go, Math.sqrt(t * t + e * e), n) : $(0 / 0, 0 / 0, n) - } - function tt(n) { - return n > .206893034 ? n * n * n : (n - 4 / 29) / 7.787037 - } - function et(n) { - return n > .008856 ? Math.pow(n, 1 / 3) : 7.787037 * n + 4 / 29 - } - function rt(n) { - return Math.round(255 * (.00304 >= n ? 12.92 * n : 1.055 * Math.pow(n, 1 / 2.4) - .055)) - } - function ut(n) { - return ot(n >> 16, 255 & n >> 8, 255 & n) - } - function it(n) { - return ut(n) + "" - } - function ot(n, t, e) { - return new at(n, t, e) - } - function at(n, t, e) { - this.r = n, this.g = t, this.b = e - } - function ct(n) { - return 16 > n ? "0" + Math.max(0, n).toString(16) : Math.min(255, n).toString(16) - } - function lt(n, t, e) { - var r, u, i, o = 0, a = 0, c = 0; - if (r = /([a-z]+)\((.*)\)/i.exec(n)) - switch (u = r[2].split(","), r[1]) { - case"hsl": - return e(parseFloat(u[0]), parseFloat(u[1]) / 100, parseFloat(u[2]) / 100); - case"rgb": - return t(gt(u[0]), gt(u[1]), gt(u[2])) - } - return(i = ha.get(n)) ? t(i.r, i.g, i.b) : (null != n && "#" === n.charAt(0) && (4 === n.length ? (o = n.charAt(1), o += o, a = n.charAt(2), a += a, c = n.charAt(3), c += c) : 7 === n.length && (o = n.substring(1, 3), a = n.substring(3, 5), c = n.substring(5, 7)), o = parseInt(o, 16), a = parseInt(a, 16), c = parseInt(c, 16)), t(o, a, c)) - } - function st(n, t, e) { - var r, u, i = Math.min(n /= 255, t /= 255, e /= 255), o = Math.max(n, t, e), a = o - i, c = (o + i) / 2; - return a ? (u = .5 > c ? a / (o + i) : a / (2 - o - i), r = n == o ? (t - e) / a + (e > t ? 6 : 0) : t == o ? (e - n) / a + 2 : (n - t) / a + 4, r *= 60) : (r = 0 / 0, u = c > 0 && 1 > c ? 0 : r), Z(r, u, c) - } - function ft(n, t, e) { - n = ht(n), t = ht(t), e = ht(e); - var r = et((.4124564 * n + .3575761 * t + .1804375 * e) / aa), u = et((.2126729 * n + .7151522 * t + .072175 * e) / ca), i = et((.0193339 * n + .119192 * t + .9503041 * e) / la); - return G(116 * u - 16, 500 * (r - u), 200 * (u - i)) - } - function ht(n) { - return(n /= 255) <= .04045 ? n / 12.92 : Math.pow((n + .055) / 1.055, 2.4) - } - function gt(n) { - var t = parseFloat(n); - return"%" === n.charAt(n.length - 1) ? Math.round(2.55 * t) : t - } - function pt(n) { - return"function" == typeof n ? n : function () { - return n - } - } - function dt(n) { - return n - } - function vt(n) { - return function (t, e, r) { - return 2 === arguments.length && "function" == typeof e && (r = e, e = null), mt(t, e, n, r) - } - } - function mt(n, t, e, r) { - function u() { - var n, t = c.status; - if (!t && c.responseText || t >= 200 && 300 > t || 304 === t) { - try { - n = e.call(i, c) - } catch (r) { - return o.error.call(i, r), void 0 - } - o.load.call(i, n) - } else - o.error.call(i, c) - } - var i = {}, o = vo.dispatch("beforesend", "progress", "load", "error"), a = {}, c = new XMLHttpRequest, l = null; - return!bo.XDomainRequest || "withCredentials"in c || !/^(http(s)?:)?\/\//.test(n) || (c = new XDomainRequest), "onload"in c ? c.onload = c.onerror = u : c.onreadystatechange = function () { - c.readyState > 3 && u() - }, c.onprogress = function (n) { - var t = vo.event; - vo.event = n; - try { - o.progress.call(i, c) - } finally { - vo.event = t - } - }, i.header = function (n, t) { - return n = (n + "").toLowerCase(), arguments.length < 2 ? a[n] : (null == t ? delete a[n] : a[n] = t + "", i) - }, i.mimeType = function (n) { - return arguments.length ? (t = null == n ? null : n + "", i) : t - }, i.responseType = function (n) { - return arguments.length ? (l = n, i) : l - }, i.response = function (n) { - return e = n, i - }, ["get", "post"].forEach(function (n) { - i[n] = function () { - return i.send.apply(i, [n].concat(yo(arguments))) - } - }), i.send = function (e, r, u) { - if (2 === arguments.length && "function" == typeof r && (u = r, r = null), c.open(e, n, !0), null == t || "accept"in a || (a.accept = t + ",*/*"), c.setRequestHeader) - for (var s in a) - c.setRequestHeader(s, a[s]); - return null != t && c.overrideMimeType && c.overrideMimeType(t), null != l && (c.responseType = l), null != u && i.on("error", u).on("load", function (n) { - u(null, n) - }), o.beforesend.call(i, c), c.send(null == r ? null : r), i - }, i.abort = function () { - return c.abort(), i - }, vo.rebind(i, o, "on"), null == r ? i : i.get(yt(r)) - } - function yt(n) { - return 1 === n.length ? function (t, e) { - n(null == t ? e : null) - } : n - } - function Mt() { - var n = bt(), t = _t() - n; - t > 24 ? (isFinite(t) && (clearTimeout(va), va = setTimeout(Mt, t)), da = 0) : (da = 1, ya(Mt)) - } - function xt(n, t, e) { - var r = arguments.length; - 2 > r && (t = 0), 3 > r && (e = Date.now()), ma.callback = n, ma.time = e + t - } - function bt() { - var n = Date.now(); - for (ma = ga; ma; ) - n >= ma.time && (ma.flush = ma.callback(n - ma.time)), ma = ma.next; - return n - } - function _t() { - for (var n, t = ga, e = 1 / 0; t; ) - t.flush ? t = n ? n.next = t.next : ga = t.next : (t.time < e && (e = t.time), t = (n = t).next); - return pa = n, e - } - function wt(n, t) { - var e = Math.pow(10, 3 * Math.abs(8 - t)); - return{scale: t > 8 ? function (n) { - return n / e - } : function (n) { - return n * e - }, symbol: n} - } - function St(n, t) { - return t - (n ? Math.ceil(Math.log(n) / Math.LN10) : 1) - } - function Et(n) { - return n + "" - } - function kt() { - } - function At(n, t, e) { - var r = e.s = n + t, u = r - n, i = r - u; - e.t = n - i + (t - u) - } - function Nt(n, t) { - n && Ta.hasOwnProperty(n.type) && Ta[n.type](n, t) - } - function qt(n, t, e) { - var r, u = -1, i = n.length - e; - for (t.lineStart(); ++u < i; ) - r = n[u], t.point(r[0], r[1], r[2]); - t.lineEnd() - } - function Tt(n, t) { - var e = -1, r = n.length; - for (t.polygonStart(); ++e < r; ) - qt(n[e], t, 1); - t.polygonEnd() - } - function zt() { - function n(n, t) { - n *= Jo, t = t * Jo / 2 + Bo / 4; - var e = n - r, o = Math.cos(t), a = Math.sin(t), c = i * a, l = u * o + c * Math.cos(e), s = c * Math.sin(e); - Ca.add(Math.atan2(s, l)), r = n, u = o, i = a - } - var t, e, r, u, i; - Da.point = function (o, a) { - Da.point = n, r = (t = o) * Jo, u = Math.cos(a = (e = a) * Jo / 2 + Bo / 4), i = Math.sin(a) - }, Da.lineEnd = function () { - n(t, e) - } - } - function Ct(n) { - var t = n[0], e = n[1], r = Math.cos(e); - return[r * Math.cos(t), r * Math.sin(t), Math.sin(e)] - } - function Dt(n, t) { - return n[0] * t[0] + n[1] * t[1] + n[2] * t[2] - } - function jt(n, t) { - return[n[1] * t[2] - n[2] * t[1], n[2] * t[0] - n[0] * t[2], n[0] * t[1] - n[1] * t[0]] - } - function Lt(n, t) { - n[0] += t[0], n[1] += t[1], n[2] += t[2] - } - function Ht(n, t) { - return[n[0] * t, n[1] * t, n[2] * t] - } - function Ft(n) { - var t = Math.sqrt(n[0] * n[0] + n[1] * n[1] + n[2] * n[2]); - n[0] /= t, n[1] /= t, n[2] /= t - } - function Pt(n) { - return[Math.atan2(n[1], n[0]), O(n[2])] - } - function Ot(n, t) { - return Math.abs(n[0] - t[0]) < $o && Math.abs(n[1] - t[1]) < $o - } - function Rt(n, t) { - n *= Jo; - var e = Math.cos(t *= Jo); - Yt(e * Math.cos(n), e * Math.sin(n), Math.sin(t)) - } - function Yt(n, t, e) { - ++ja, Ha += (n - Ha) / ja, Fa += (t - Fa) / ja, Pa += (e - Pa) / ja - } - function It() { - function n(n, u) { - n *= Jo; - var i = Math.cos(u *= Jo), o = i * Math.cos(n), a = i * Math.sin(n), c = Math.sin(u), l = Math.atan2(Math.sqrt((l = e * c - r * a) * l + (l = r * o - t * c) * l + (l = t * a - e * o) * l), t * o + e * a + r * c); - La += l, Oa += l * (t + (t = o)), Ra += l * (e + (e = a)), Ya += l * (r + (r = c)), Yt(t, e, r) - } - var t, e, r; - Za.point = function (u, i) { - u *= Jo; - var o = Math.cos(i *= Jo); - t = o * Math.cos(u), e = o * Math.sin(u), r = Math.sin(i), Za.point = n, Yt(t, e, r) - } - } - function Ut() { - Za.point = Rt - } - function Vt() { - function n(n, t) { - n *= Jo; - var e = Math.cos(t *= Jo), o = e * Math.cos(n), a = e * Math.sin(n), c = Math.sin(t), l = u * c - i * a, s = i * o - r * c, f = r * a - u * o, h = Math.sqrt(l * l + s * s + f * f), g = r * o + u * a + i * c, p = h && -P(g) / h, d = Math.atan2(h, g); - Ia += p * l, Ua += p * s, Va += p * f, La += d, Oa += d * (r + (r = o)), Ra += d * (u + (u = a)), Ya += d * (i + (i = c)), Yt(r, u, i) - } - var t, e, r, u, i; - Za.point = function (o, a) { - t = o, e = a, Za.point = n, o *= Jo; - var c = Math.cos(a *= Jo); - r = c * Math.cos(o), u = c * Math.sin(o), i = Math.sin(a), Yt(r, u, i) - }, Za.lineEnd = function () { - n(t, e), Za.lineEnd = Ut, Za.point = Rt - } - } - function Zt() { - return!0 - } - function Xt(n, t, e, r, u) { - var i = [], o = []; - if (n.forEach(function (n) { - if (!((t = n.length - 1) <= 0)) { - var t, e = n[0], r = n[t]; - if (Ot(e, r)) { - u.lineStart(); - for (var a = 0; t > a; ++a) - u.point((e = n[a])[0], e[1]); - return u.lineEnd(), void 0 - } - var c = {point: e, points: n, other: null, visited: !1, entry: !0, subject: !0}, l = {point: e, points: [e], other: c, visited: !1, entry: !1, subject: !1}; - c.other = l, i.push(c), o.push(l), c = {point: r, points: [r], other: null, visited: !1, entry: !1, subject: !0}, l = {point: r, points: [r], other: c, visited: !1, entry: !0, subject: !1}, c.other = l, i.push(c), o.push(l) - } - }), o.sort(t), Bt(i), Bt(o), i.length) { - if (e) - for (var a = 1, c = !e(o[0].point), l = o.length; l > a; ++a) - o[a].entry = c = !c; - for (var s, f, h, g = i[0]; ; ) { - for (s = g; s.visited; ) - if ((s = s.next) === g) - return; - f = s.points, u.lineStart(); - do { - if (s.visited = s.other.visited = !0, s.entry) { - if (s.subject) - for (var a = 0; a < f.length; a++) - u.point((h = f[a])[0], h[1]); - else - r(s.point, s.next.point, 1, u); - s = s.next - } else { - if (s.subject) { - f = s.prev.points; - for (var a = f.length; --a >= 0; ) - u.point((h = f[a])[0], h[1]) - } else - r(s.point, s.prev.point, -1, u); - s = s.prev - } - s = s.other, f = s.points - } while (!s.visited); - u.lineEnd() - } - } - } - function Bt(n) { - if (t = n.length) { - for (var t, e, r = 0, u = n[0]; ++r < t; ) - u.next = e = n[r], e.prev = u, u = e; - u.next = e = n[0], e.prev = u - } - } - function $t(n, t, e, r) { - return function (u) { - function i(t, e) { - n(t, e) && u.point(t, e) - } - function o(n, t) { - d.point(n, t) - } - function a() { - v.point = o, d.lineStart() - } - function c() { - v.point = i, d.lineEnd() - } - function l(n, t) { - y.point(n, t), p.push([n, t]) - } - function s() { - y.lineStart(), p = [] - } - function f() { - l(p[0][0], p[0][1]), y.lineEnd(); - var n, t = y.clean(), e = m.buffer(), r = e.length; - if (p.pop(), g.push(p), p = null, r) { - if (1 & t) { - n = e[0]; - var i, r = n.length - 1, o = -1; - for (u.lineStart(); ++o < r; ) - u.point((i = n[o])[0], i[1]); - return u.lineEnd(), void 0 - } - r > 1 && 2 & t && e.push(e.pop().concat(e.shift())), h.push(e.filter(Wt)) - } - } - var h, g, p, d = t(u), v = {point: i, lineStart: a, lineEnd: c, polygonStart: function () { - v.point = l, v.lineStart = s, v.lineEnd = f, h = [], g = [], u.polygonStart() - }, polygonEnd: function () { - v.point = i, v.lineStart = a, v.lineEnd = c, h = vo.merge(h), h.length ? Xt(h, Gt, null, e, u) : r(g) && (u.lineStart(), e(null, null, 1, u), u.lineEnd()), u.polygonEnd(), h = g = null - }, sphere: function () { - u.polygonStart(), u.lineStart(), e(null, null, 1, u), u.lineEnd(), u.polygonEnd() - }}, m = Jt(), y = t(m); - return v - } - } - function Wt(n) { - return n.length > 1 - } - function Jt() { - var n, t = []; - return{lineStart: function () { - t.push(n = []) - }, point: function (t, e) { - n.push([t, e]) - }, lineEnd: c, buffer: function () { - var e = t; - return t = [], n = null, e - }, rejoin: function () { - t.length > 1 && t.push(t.pop().concat(t.shift())) - }} - } - function Gt(n, t) { - return((n = n.point)[0] < 0 ? n[1] - Bo / 2 - $o : Bo / 2 - n[1]) - ((t = t.point)[0] < 0 ? t[1] - Bo / 2 - $o : Bo / 2 - t[1]) - } - function Kt(n, t) { - var e = n[0], r = n[1], u = [Math.sin(e), -Math.cos(e), 0], i = 0, o = !1, a = !1, c = 0; - Ca.reset(); - for (var l = 0, s = t.length; s > l; ++l) { - var f = t[l], h = f.length; - if (h) { - for (var g = f[0], p = g[0], d = g[1] / 2 + Bo / 4, v = Math.sin(d), m = Math.cos(d), y = 1; ; ) { - y === h && (y = 0), n = f[y]; - var M = n[0], x = n[1] / 2 + Bo / 4, b = Math.sin(x), _ = Math.cos(x), w = M - p, S = Math.abs(w) > Bo, E = v * b; - if (Ca.add(Math.atan2(E * Math.sin(w), m * _ + E * Math.cos(w))), Math.abs(x) < $o && (a = !0), i += S ? w + (w >= 0 ? 2 : -2) * Bo : w, S ^ p >= e ^ M >= e) { - var k = jt(Ct(g), Ct(n)); - Ft(k); - var A = jt(u, k); - Ft(A); - var N = (S ^ w >= 0 ? -1 : 1) * O(A[2]); - r > N && (c += S ^ w >= 0 ? 1 : -1) - } - if (!y++) - break; - p = M, v = b, m = _, g = n - } - Math.abs(i) > $o && (o = !0) - } - } - return(!a && !o && 0 > Ca || -$o > i) ^ 1 & c - } - function Qt(n) { - var t, e = 0 / 0, r = 0 / 0, u = 0 / 0; - return{lineStart: function () { - n.lineStart(), t = 1 - }, point: function (i, o) { - var a = i > 0 ? Bo : -Bo, c = Math.abs(i - e); - Math.abs(c - Bo) < $o ? (n.point(e, r = (r + o) / 2 > 0 ? Bo / 2 : -Bo / 2), n.point(u, r), n.lineEnd(), n.lineStart(), n.point(a, r), n.point(i, r), t = 0) : u !== a && c >= Bo && (Math.abs(e - u) < $o && (e -= u * $o), Math.abs(i - a) < $o && (i -= a * $o), r = ne(e, r, i, o), n.point(u, r), n.lineEnd(), n.lineStart(), n.point(a, r), t = 0), n.point(e = i, r = o), u = a - }, lineEnd: function () { - n.lineEnd(), e = r = 0 / 0 - }, clean: function () { - return 2 - t - }} - } - function ne(n, t, e, r) { - var u, i, o = Math.sin(n - e); - return Math.abs(o) > $o ? Math.atan((Math.sin(t) * (i = Math.cos(r)) * Math.sin(e) - Math.sin(r) * (u = Math.cos(t)) * Math.sin(n)) / (u * i * o)) : (t + r) / 2 - } - function te(n, t, e, r) { - var u; - if (null == n) - u = e * Bo / 2, r.point(-Bo, u), r.point(0, u), r.point(Bo, u), r.point(Bo, 0), r.point(Bo, -u), r.point(0, -u), r.point(-Bo, -u), r.point(-Bo, 0), r.point(-Bo, u); - else if (Math.abs(n[0] - t[0]) > $o) { - var i = (n[0] < t[0] ? 1 : -1) * Bo; - u = e * i / 2, r.point(-i, u), r.point(0, u), r.point(i, u) - } else - r.point(t[0], t[1]) - } - function ee(n) { - return Kt(Ba, n) - } - function re(n) { - function t(n, t) { - return Math.cos(n) * Math.cos(t) > o - } - function e(n) { - var e, i, o, c, s; - return{lineStart: function () { - c = o = !1, s = 1 - }, point: function (f, h) { - var g, p = [f, h], d = t(f, h), v = a ? d ? 0 : u(f, h) : d ? u(f + (0 > f ? Bo : -Bo), h) : 0; - if (!e && (c = o = d) && n.lineStart(), d !== o && (g = r(e, p), (Ot(e, g) || Ot(p, g)) && (p[0] += $o, p[1] += $o, d = t(p[0], p[1]))), d !== o) - s = 0, d ? (n.lineStart(), g = r(p, e), n.point(g[0], g[1])) : (g = r(e, p), n.point(g[0], g[1]), n.lineEnd()), e = g; - else if (l && e && a ^ d) { - var m; - v & i || !(m = r(p, e, !0)) || (s = 0, a ? (n.lineStart(), n.point(m[0][0], m[0][1]), n.point(m[1][0], m[1][1]), n.lineEnd()) : (n.point(m[1][0], m[1][1]), n.lineEnd(), n.lineStart(), n.point(m[0][0], m[0][1]))) - } - !d || e && Ot(e, p) || n.point(p[0], p[1]), e = p, o = d, i = v - }, lineEnd: function () { - o && n.lineEnd(), e = null - }, clean: function () { - return s | (c && o) << 1 - }} - } - function r(n, t, e) { - var r = Ct(n), u = Ct(t), i = [1, 0, 0], a = jt(r, u), c = Dt(a, a), l = a[0], s = c - l * l; - if (!s) - return!e && n; - var f = o * c / s, h = -o * l / s, g = jt(i, a), p = Ht(i, f), d = Ht(a, h); - Lt(p, d); - var v = g, m = Dt(p, v), y = Dt(v, v), M = m * m - y * (Dt(p, p) - 1); - if (!(0 > M)) { - var x = Math.sqrt(M), b = Ht(v, (-m - x) / y); - if (Lt(b, p), b = Pt(b), !e) - return b; - var _, w = n[0], S = t[0], E = n[1], k = t[1]; - w > S && (_ = w, w = S, S = _); - var A = S - w, N = Math.abs(A - Bo) < $o, q = N || $o > A; - if (!N && E > k && (_ = E, E = k, k = _), q ? N ? E + k > 0 ^ b[1] < (Math.abs(b[0] - w) < $o ? E : k) : E <= b[1] && b[1] <= k : A > Bo ^ (w <= b[0] && b[0] <= S)) { - var T = Ht(v, (-m + x) / y); - return Lt(T, p), [b, Pt(T)] - } - } - } - function u(t, e) { - var r = a ? n : Bo - n, u = 0; - return-r > t ? u |= 1 : t > r && (u |= 2), -r > e ? u |= 4 : e > r && (u |= 8), u - } - function i(n) { - return Kt(c, n) - } - var o = Math.cos(n), a = o > 0, c = [n, 0], l = Math.abs(o) > $o, s = qe(n, 6 * Jo); - return $t(t, e, s, i) - } - function ue(n, t, e, r) { - function u(r, u) { - return Math.abs(r[0] - n) < $o ? u > 0 ? 0 : 3 : Math.abs(r[0] - e) < $o ? u > 0 ? 2 : 1 : Math.abs(r[1] - t) < $o ? u > 0 ? 1 : 0 : u > 0 ? 3 : 2 - } - function i(n, t) { - return o(n.point, t.point) - } - function o(n, t) { - var e = u(n, 1), r = u(t, 1); - return e !== r ? e - r : 0 === e ? t[1] - n[1] : 1 === e ? n[0] - t[0] : 2 === e ? n[1] - t[1] : t[0] - n[0] - } - function a(u, i) { - var o = i[0] - u[0], a = i[1] - u[1], c = [0, 1]; - return Math.abs(o) < $o && Math.abs(a) < $o ? n <= u[0] && u[0] <= e && t <= u[1] && u[1] <= r : ie(n - u[0], o, c) && ie(u[0] - e, -o, c) && ie(t - u[1], a, c) && ie(u[1] - r, -a, c) ? (c[1] < 1 && (i[0] = u[0] + c[1] * o, i[1] = u[1] + c[1] * a), c[0] > 0 && (u[0] += c[0] * o, u[1] += c[0] * a), !0) : !1 - } - return function (c) { - function l(i) { - var o = u(i, -1), a = s([0 === o || 3 === o ? n : e, o > 1 ? r : t]); - return a - } - function s(n) { - for (var t = 0, e = M.length, r = n[1], u = 0; e > u; ++u) - for (var i, o = 1, a = M[u], c = a.length, l = a[0]; c > o; ++o) - i = a[o], l[1] <= r ? i[1] > r && f(l, i, n) > 0 && ++t : i[1] <= r && f(l, i, n) < 0 && --t, l = i; - return 0 !== t - } - function f(n, t, e) { - return(t[0] - n[0]) * (e[1] - n[1]) - (e[0] - n[0]) * (t[1] - n[1]) - } - function h(i, a, c, l) { - var s = 0, f = 0; - if (null == i || (s = u(i, c)) !== (f = u(a, c)) || o(i, a) < 0 ^ c > 0) { - do - l.point(0 === s || 3 === s ? n : e, s > 1 ? r : t); - while ((s = (s + c + 4) % 4) !== f) - } else - l.point(a[0], a[1]) - } - function g(u, i) { - return u >= n && e >= u && i >= t && r >= i - } - function p(n, t) { - g(n, t) && c.point(n, t) - } - function d() { - T.point = m, M && M.push(x = []), A = !0, k = !1, S = E = 0 / 0 - } - function v() { - y && (m(b, _), w && k && q.rejoin(), y.push(q.buffer())), T.point = p, k && c.lineEnd() - } - function m(n, t) { - n = Math.max(-$a, Math.min($a, n)), t = Math.max(-$a, Math.min($a, t)); - var e = g(n, t); - if (M && x.push([n, t]), A) - b = n, _ = t, w = e, A = !1, e && (c.lineStart(), c.point(n, t)); - else if (e && k) - c.point(n, t); - else { - var r = [S, E], u = [n, t]; - a(r, u) ? (k || (c.lineStart(), c.point(r[0], r[1])), c.point(u[0], u[1]), e || c.lineEnd()) : e && (c.lineStart(), c.point(n, t)) - } - S = n, E = t, k = e - } - var y, M, x, b, _, w, S, E, k, A, N = c, q = Jt(), T = {point: p, lineStart: d, lineEnd: v, polygonStart: function () { - c = q, y = [], M = [] - }, polygonEnd: function () { - c = N, (y = vo.merge(y)).length ? (c.polygonStart(), Xt(y, i, l, h, c), c.polygonEnd()) : s([n, t]) && (c.polygonStart(), c.lineStart(), h(null, null, 1, c), c.lineEnd(), c.polygonEnd()), y = M = x = null - }}; - return T - } - } - function ie(n, t, e) { - if (Math.abs(t) < $o) - return 0 >= n; - var r = n / t; - if (t > 0) { - if (r > e[1]) - return!1; - r > e[0] && (e[0] = r) - } else { - if (r < e[0]) - return!1; - r < e[1] && (e[1] = r) - } - return!0 - } - function oe(n, t) { - function e(e, r) { - return e = n(e, r), t(e[0], e[1]) - } - return n.invert && t.invert && (e.invert = function (e, r) { - return e = t.invert(e, r), e && n.invert(e[0], e[1]) - }), e - } - function ae(n) { - var t = 0, e = Bo / 3, r = _e(n), u = r(t, e); - return u.parallels = function (n) { - return arguments.length ? r(t = n[0] * Bo / 180, e = n[1] * Bo / 180) : [180 * (t / Bo), 180 * (e / Bo)] - }, u - } - function ce(n, t) { - function e(n, t) { - var e = Math.sqrt(i - 2 * u * Math.sin(t)) / u; - return[e * Math.sin(n *= u), o - e * Math.cos(n)] - } - var r = Math.sin(n), u = (r + Math.sin(t)) / 2, i = 1 + r * (2 * u - r), o = Math.sqrt(i) / u; - return e.invert = function (n, t) { - var e = o - t; - return[Math.atan2(n, e) / u, O((i - (n * n + e * e) * u * u) / (2 * u))] - }, e - } - function le() { - function n(n, t) { - Ja += u * n - r * t, r = n, u = t - } - var t, e, r, u; - tc.point = function (i, o) { - tc.point = n, t = r = i, e = u = o - }, tc.lineEnd = function () { - n(t, e) - } - } - function se(n, t) { - Ga > n && (Ga = n), n > Qa && (Qa = n), Ka > t && (Ka = t), t > nc && (nc = t) - } - function fe() { - function n(n, t) { - o.push("M", n, ",", t, i) - } - function t(n, t) { - o.push("M", n, ",", t), a.point = e - } - function e(n, t) { - o.push("L", n, ",", t) - } - function r() { - a.point = n - } - function u() { - o.push("Z") - } - var i = he(4.5), o = [], a = {point: n, lineStart: function () { - a.point = t - }, lineEnd: r, polygonStart: function () { - a.lineEnd = u - }, polygonEnd: function () { - a.lineEnd = r, a.point = n - }, pointRadius: function (n) { - return i = he(n), a - }, result: function () { - if (o.length) { - var n = o.join(""); - return o = [], n - } - }}; - return a - } - function he(n) { - return"m0," + n + "a" + n + "," + n + " 0 1,1 0," + -2 * n + "a" + n + "," + n + " 0 1,1 0," + 2 * n + "z" - } - function ge(n, t) { - Ha += n, Fa += t, ++Pa - } - function pe() { - function n(n, r) { - var u = n - t, i = r - e, o = Math.sqrt(u * u + i * i); - Oa += o * (t + n) / 2, Ra += o * (e + r) / 2, Ya += o, ge(t = n, e = r) - } - var t, e; - rc.point = function (r, u) { - rc.point = n, ge(t = r, e = u) - } - } - function de() { - rc.point = ge - } - function ve() { - function n(n, t) { - var e = n - r, i = t - u, o = Math.sqrt(e * e + i * i); - Oa += o * (r + n) / 2, Ra += o * (u + t) / 2, Ya += o, o = u * n - r * t, Ia += o * (r + n), Ua += o * (u + t), Va += 3 * o, ge(r = n, u = t) - } - var t, e, r, u; - rc.point = function (i, o) { - rc.point = n, ge(t = r = i, e = u = o) - }, rc.lineEnd = function () { - n(t, e) - } - } - function me(n) { - function t(t, e) { - n.moveTo(t, e), n.arc(t, e, o, 0, 2 * Bo) - } - function e(t, e) { - n.moveTo(t, e), a.point = r - } - function r(t, e) { - n.lineTo(t, e) - } - function u() { - a.point = t - } - function i() { - n.closePath() - } - var o = 4.5, a = {point: t, lineStart: function () { - a.point = e - }, lineEnd: u, polygonStart: function () { - a.lineEnd = i - }, polygonEnd: function () { - a.lineEnd = u, a.point = t - }, pointRadius: function (n) { - return o = n, a - }, result: c}; - return a - } - function ye(n) { - function t(t) { - function r(e, r) { - e = n(e, r), t.point(e[0], e[1]) - } - function u() { - M = 0 / 0, S.point = o, t.lineStart() - } - function o(r, u) { - var o = Ct([r, u]), a = n(r, u); - e(M, x, y, b, _, w, M = a[0], x = a[1], y = r, b = o[0], _ = o[1], w = o[2], i, t), t.point(M, x) - } - function a() { - S.point = r, t.lineEnd() - } - function c() { - u(), S.point = l, S.lineEnd = s - } - function l(n, t) { - o(f = n, h = t), g = M, p = x, d = b, v = _, m = w, S.point = o - } - function s() { - e(M, x, y, b, _, w, g, p, f, d, v, m, i, t), S.lineEnd = a, a() - } - var f, h, g, p, d, v, m, y, M, x, b, _, w, S = {point: r, lineStart: u, lineEnd: a, polygonStart: function () { - t.polygonStart(), S.lineStart = c - }, polygonEnd: function () { - t.polygonEnd(), S.lineStart = u - }}; - return S - } - function e(t, i, o, a, c, l, s, f, h, g, p, d, v, m) { - var y = s - t, M = f - i, x = y * y + M * M; - if (x > 4 * r && v--) { - var b = a + g, _ = c + p, w = l + d, S = Math.sqrt(b * b + _ * _ + w * w), E = Math.asin(w /= S), k = Math.abs(Math.abs(w) - 1) < $o ? (o + h) / 2 : Math.atan2(_, b), A = n(k, E), N = A[0], q = A[1], T = N - t, z = q - i, C = M * T - y * z; - (C * C / x > r || Math.abs((y * T + M * z) / x - .5) > .3 || u > a * g + c * p + l * d) && (e(t, i, o, a, c, l, N, q, k, b /= S, _ /= S, w, v, m), m.point(N, q), e(N, q, k, b, _, w, s, f, h, g, p, d, v, m)) - } - } - var r = .5, u = Math.cos(30 * Jo), i = 16; - return t.precision = function (n) { - return arguments.length ? (i = (r = n * n) > 0 && 16, t) : Math.sqrt(r) - }, t - } - function Me(n) { - this.stream = n - } - function xe(n) { - var t = ye(function (t, e) { - return n([t * Go, e * Go]) - }); - return function (n) { - var e = new Me(n = t(n)); - return e.point = function (t, e) { - n.point(t * Jo, e * Jo) - }, e - } - } - function be(n) { - return _e(function () { - return n - })() - } - function _e(n) { - function t(n) { - return n = a(n[0] * Jo, n[1] * Jo), [n[0] * h + c, l - n[1] * h] - } - function e(n) { - return n = a.invert((n[0] - c) / h, (l - n[1]) / h), n && [n[0] * Go, n[1] * Go] - } - function r() { - a = oe(o = Ee(m, y, M), i); - var n = i(d, v); - return c = g - n[0] * h, l = p + n[1] * h, u() - } - function u() { - return s && (s.valid = !1, s = null), t - } - var i, o, a, c, l, s, f = ye(function (n, t) { - return n = i(n, t), [n[0] * h + c, l - n[1] * h] - }), h = 150, g = 480, p = 250, d = 0, v = 0, m = 0, y = 0, M = 0, x = Xa, b = dt, _ = null, w = null; - return t.stream = function (n) { - return s && (s.valid = !1), s = we(o, x(f(b(n)))), s.valid = !0, s - }, t.clipAngle = function (n) { - return arguments.length ? (x = null == n ? (_ = n, Xa) : re((_ = +n) * Jo), u()) : _ - }, t.clipExtent = function (n) { - return arguments.length ? (w = n, b = n ? ue(n[0][0], n[0][1], n[1][0], n[1][1]) : dt, u()) : w - }, t.scale = function (n) { - return arguments.length ? (h = +n, r()) : h - }, t.translate = function (n) { - return arguments.length ? (g = +n[0], p = +n[1], r()) : [g, p] - }, t.center = function (n) { - return arguments.length ? (d = n[0] % 360 * Jo, v = n[1] % 360 * Jo, r()) : [d * Go, v * Go] - }, t.rotate = function (n) { - return arguments.length ? (m = n[0] % 360 * Jo, y = n[1] % 360 * Jo, M = n.length > 2 ? n[2] % 360 * Jo : 0, r()) : [m * Go, y * Go, M * Go] - }, vo.rebind(t, f, "precision"), function () { - return i = n.apply(this, arguments), t.invert = i.invert && e, r() - } - } - function we(n, t) { - var e = new Me(t); - return e.point = function (e, r) { - r = n(e * Jo, r * Jo), e = r[0], t.point(e > Bo ? e - 2 * Bo : -Bo > e ? e + 2 * Bo : e, r[1]) - }, e - } - function Se(n, t) { - return[n, t] - } - function Ee(n, t, e) { - return n ? t || e ? oe(Ae(n), Ne(t, e)) : Ae(n) : t || e ? Ne(t, e) : Se - } - function ke(n) { - return function (t, e) { - return t += n, [t > Bo ? t - 2 * Bo : -Bo > t ? t + 2 * Bo : t, e] - } - } - function Ae(n) { - var t = ke(n); - return t.invert = ke(-n), t - } - function Ne(n, t) { - function e(n, t) { - var e = Math.cos(t), a = Math.cos(n) * e, c = Math.sin(n) * e, l = Math.sin(t), s = l * r + a * u; - return[Math.atan2(c * i - s * o, a * r - l * u), O(s * i + c * o)] - } - var r = Math.cos(n), u = Math.sin(n), i = Math.cos(t), o = Math.sin(t); - return e.invert = function (n, t) { - var e = Math.cos(t), a = Math.cos(n) * e, c = Math.sin(n) * e, l = Math.sin(t), s = l * i - c * o; - return[Math.atan2(c * i + l * o, a * r + s * u), O(s * r - a * u)] - }, e - } - function qe(n, t) { - var e = Math.cos(n), r = Math.sin(n); - return function (u, i, o, a) { - var c = o * t; - null != u ? (u = Te(e, u), i = Te(e, i), (o > 0 ? i > u : u > i) && (u += 2 * o * Bo)) : (u = n + 2 * o * Bo, i = n - .5 * c); - for (var l, s = u; o > 0?s > i:i > s; s -= c) - a.point((l = Pt([e, -r * Math.cos(s), -r * Math.sin(s)]))[0], l[1]) - } - } - function Te(n, t) { - var e = Ct(t); - e[0] -= n, Ft(e); - var r = P(-e[1]); - return((-e[2] < 0 ? -r : r) + 2 * Math.PI - $o) % (2 * Math.PI) - } - function ze(n, t, e) { - var r = vo.range(n, t - $o, e).concat(t); - return function (n) { - return r.map(function (t) { - return[n, t] - }) - } - } - function Ce(n, t, e) { - var r = vo.range(n, t - $o, e).concat(t); - return function (n) { - return r.map(function (t) { - return[t, n] - }) - } - } - function De(n) { - return n.source - } - function je(n) { - return n.target - } - function Le(n, t, e, r) { - var u = Math.cos(t), i = Math.sin(t), o = Math.cos(r), a = Math.sin(r), c = u * Math.cos(n), l = u * Math.sin(n), s = o * Math.cos(e), f = o * Math.sin(e), h = 2 * Math.asin(Math.sqrt(U(r - t) + u * o * U(e - n))), g = 1 / Math.sin(h), p = h ? function (n) { - var t = Math.sin(n *= h) * g, e = Math.sin(h - n) * g, r = e * c + t * s, u = e * l + t * f, o = e * i + t * a; - return[Math.atan2(u, r) * Go, Math.atan2(o, Math.sqrt(r * r + u * u)) * Go] - } : function () { - return[n * Go, t * Go] - }; - return p.distance = h, p - } - function He() { - function n(n, u) { - var i = Math.sin(u *= Jo), o = Math.cos(u), a = Math.abs((n *= Jo) - t), c = Math.cos(a); - uc += Math.atan2(Math.sqrt((a = o * Math.sin(a)) * a + (a = r * i - e * o * c) * a), e * i + r * o * c), t = n, e = i, r = o - } - var t, e, r; - ic.point = function (u, i) { - t = u * Jo, e = Math.sin(i *= Jo), r = Math.cos(i), ic.point = n - }, ic.lineEnd = function () { - ic.point = ic.lineEnd = c - } - } - function Fe(n, t) { - function e(t, e) { - var r = Math.cos(t), u = Math.cos(e), i = n(r * u); - return[i * u * Math.sin(t), i * Math.sin(e)] - } - return e.invert = function (n, e) { - var r = Math.sqrt(n * n + e * e), u = t(r), i = Math.sin(u), o = Math.cos(u); - return[Math.atan2(n * i, r * o), Math.asin(r && e * i / r)] - }, e - } - function Pe(n, t) { - function e(n, t) { - var e = Math.abs(Math.abs(t) - Bo / 2) < $o ? 0 : o / Math.pow(u(t), i); - return[e * Math.sin(i * n), o - e * Math.cos(i * n)] - } - var r = Math.cos(n), u = function (n) { - return Math.tan(Bo / 4 + n / 2) - }, i = n === t ? Math.sin(n) : Math.log(r / Math.cos(t)) / Math.log(u(t) / u(n)), o = r * Math.pow(u(n), i) / i; - return i ? (e.invert = function (n, t) { - var e = o - t, r = F(i) * Math.sqrt(n * n + e * e); - return[Math.atan2(n, e) / i, 2 * Math.atan(Math.pow(o / r, 1 / i)) - Bo / 2] - }, e) : Re - } - function Oe(n, t) { - function e(n, t) { - var e = i - t; - return[e * Math.sin(u * n), i - e * Math.cos(u * n)] - } - var r = Math.cos(n), u = n === t ? Math.sin(n) : (r - Math.cos(t)) / (t - n), i = r / u + n; - return Math.abs(u) < $o ? Se : (e.invert = function (n, t) { - var e = i - t; - return[Math.atan2(n, e) / u, i - F(u) * Math.sqrt(n * n + e * e)] - }, e) - } - function Re(n, t) { - return[n, Math.log(Math.tan(Bo / 4 + t / 2))] - } - function Ye(n) { - var t, e = be(n), r = e.scale, u = e.translate, i = e.clipExtent; - return e.scale = function () { - var n = r.apply(e, arguments); - return n === e ? t ? e.clipExtent(null) : e : n - }, e.translate = function () { - var n = u.apply(e, arguments); - return n === e ? t ? e.clipExtent(null) : e : n - }, e.clipExtent = function (n) { - var o = i.apply(e, arguments); - if (o === e) { - if (t = null == n) { - var a = Bo * r(), c = u(); - i([[c[0] - a, c[1] - a], [c[0] + a, c[1] + a]]) - } - } else - t && (o = null); - return o - }, e.clipExtent(null) - } - function Ie(n, t) { - var e = Math.cos(t) * Math.sin(n); - return[Math.log((1 + e) / (1 - e)) / 2, Math.atan2(Math.tan(t), Math.cos(n))] - } - function Ue(n) { - function t(t) { - function o() { - l.push("M", i(n(s), a)) - } - for (var c, l = [], s = [], f = -1, h = t.length, g = pt(e), p = pt(r); ++f < h; ) - u.call(this, c = t[f], f) ? s.push([+g.call(this, c, f), +p.call(this, c, f)]) : s.length && (o(), s = []); - return s.length && o(), l.length ? l.join("") : null - } - var e = Ve, r = Ze, u = Zt, i = Xe, o = i.key, a = .7; - return t.x = function (n) { - return arguments.length ? (e = n, t) : e - }, t.y = function (n) { - return arguments.length ? (r = n, t) : r - }, t.defined = function (n) { - return arguments.length ? (u = n, t) : u - }, t.interpolate = function (n) { - return arguments.length ? (o = "function" == typeof n ? i = n : (i = fc.get(n) || Xe).key, t) : o - }, t.tension = function (n) { - return arguments.length ? (a = n, t) : a - }, t - } - function Ve(n) { - return n[0] - } - function Ze(n) { - return n[1] - } - function Xe(n) { - return n.join("L") - } - function Be(n) { - return Xe(n) + "Z" - } - function $e(n) { - for (var t = 0, e = n.length, r = n[0], u = [r[0], ",", r[1]]; ++t < e; ) - u.push("H", (r[0] + (r = n[t])[0]) / 2, "V", r[1]); - return e > 1 && u.push("H", r[0]), u.join("") - } - function We(n) { - for (var t = 0, e = n.length, r = n[0], u = [r[0], ",", r[1]]; ++t < e; ) - u.push("V", (r = n[t])[1], "H", r[0]); - return u.join("") - } - function Je(n) { - for (var t = 0, e = n.length, r = n[0], u = [r[0], ",", r[1]]; ++t < e; ) - u.push("H", (r = n[t])[0], "V", r[1]); - return u.join("") - } - function Ge(n, t) { - return n.length < 4 ? Xe(n) : n[1] + nr(n.slice(1, n.length - 1), tr(n, t)) - } - function Ke(n, t) { - return n.length < 3 ? Xe(n) : n[0] + nr((n.push(n[0]), n), tr([n[n.length - 2]].concat(n, [n[1]]), t)) - } - function Qe(n, t) { - return n.length < 3 ? Xe(n) : n[0] + nr(n, tr(n, t)) - } - function nr(n, t) { - if (t.length < 1 || n.length != t.length && n.length != t.length + 2) - return Xe(n); - var e = n.length != t.length, r = "", u = n[0], i = n[1], o = t[0], a = o, c = 1; - if (e && (r += "Q" + (i[0] - 2 * o[0] / 3) + "," + (i[1] - 2 * o[1] / 3) + "," + i[0] + "," + i[1], u = n[1], c = 2), t.length > 1) { - a = t[1], i = n[c], c++, r += "C" + (u[0] + o[0]) + "," + (u[1] + o[1]) + "," + (i[0] - a[0]) + "," + (i[1] - a[1]) + "," + i[0] + "," + i[1]; - for (var l = 2; l < t.length; l++, c++) - i = n[c], a = t[l], r += "S" + (i[0] - a[0]) + "," + (i[1] - a[1]) + "," + i[0] + "," + i[1] - } - if (e) { - var s = n[c]; - r += "Q" + (i[0] + 2 * a[0] / 3) + "," + (i[1] + 2 * a[1] / 3) + "," + s[0] + "," + s[1] - } - return r - } - function tr(n, t) { - for (var e, r = [], u = (1 - t) / 2, i = n[0], o = n[1], a = 1, c = n.length; ++a < c; ) - e = i, i = o, o = n[a], r.push([u * (o[0] - e[0]), u * (o[1] - e[1])]); - return r - } - function er(n) { - if (n.length < 3) - return Xe(n); - var t = 1, e = n.length, r = n[0], u = r[0], i = r[1], o = [u, u, u, (r = n[1])[0]], a = [i, i, i, r[1]], c = [u, ",", i, "L", or(pc, o), ",", or(pc, a)]; - for (n.push(n[e - 1]); ++t <= e; ) - r = n[t], o.shift(), o.push(r[0]), a.shift(), a.push(r[1]), ar(c, o, a); - return n.pop(), c.push("L", r), c.join("") - } - function rr(n) { - if (n.length < 4) - return Xe(n); - for (var t, e = [], r = -1, u = n.length, i = [0], o = [0]; ++r < 3; ) - t = n[r], i.push(t[0]), o.push(t[1]); - for (e.push(or(pc, i) + "," + or(pc, o)), --r; ++r < u; ) - t = n[r], i.shift(), i.push(t[0]), o.shift(), o.push(t[1]), ar(e, i, o); - return e.join("") - } - function ur(n) { - for (var t, e, r = -1, u = n.length, i = u + 4, o = [], a = []; ++r < 4; ) - e = n[r % u], o.push(e[0]), a.push(e[1]); - for (t = [or(pc, o), ",", or(pc, a)], --r; ++r < i; ) - e = n[r % u], o.shift(), o.push(e[0]), a.shift(), a.push(e[1]), ar(t, o, a); - return t.join("") - } - function ir(n, t) { - var e = n.length - 1; - if (e) - for (var r, u, i = n[0][0], o = n[0][1], a = n[e][0] - i, c = n[e][1] - o, l = -1; ++l <= e; ) - r = n[l], u = l / e, r[0] = t * r[0] + (1 - t) * (i + u * a), r[1] = t * r[1] + (1 - t) * (o + u * c); - return er(n) - } - function or(n, t) { - return n[0] * t[0] + n[1] * t[1] + n[2] * t[2] + n[3] * t[3] - } - function ar(n, t, e) { - n.push("C", or(hc, t), ",", or(hc, e), ",", or(gc, t), ",", or(gc, e), ",", or(pc, t), ",", or(pc, e)) - } - function cr(n, t) { - return(t[1] - n[1]) / (t[0] - n[0]) - } - function lr(n) { - for (var t = 0, e = n.length - 1, r = [], u = n[0], i = n[1], o = r[0] = cr(u, i); ++t < e; ) - r[t] = (o + (o = cr(u = i, i = n[t + 1]))) / 2; - return r[t] = o, r - } - function sr(n) { - for (var t, e, r, u, i = [], o = lr(n), a = -1, c = n.length - 1; ++a < c; ) - t = cr(n[a], n[a + 1]), Math.abs(t) < 1e-6 ? o[a] = o[a + 1] = 0 : (e = o[a] / t, r = o[a + 1] / t, u = e * e + r * r, u > 9 && (u = 3 * t / Math.sqrt(u), o[a] = u * e, o[a + 1] = u * r)); - for (a = - 1; ++a <= c; ) - u = (n[Math.min(c, a + 1)][0] - n[Math.max(0, a - 1)][0]) / (6 * (1 + o[a] * o[a])), i.push([u || 0, o[a] * u || 0]); - return i - } - function fr(n) { - return n.length < 3 ? Xe(n) : n[0] + nr(n, sr(n)) - } - function hr(n, t, e, r) { - var u, i, o, a, c, l, s; - return u = r[n], i = u[0], o = u[1], u = r[t], a = u[0], c = u[1], u = r[e], l = u[0], s = u[1], (s - o) * (a - i) - (c - o) * (l - i) > 0 - } - function gr(n, t, e) { - return(e[0] - t[0]) * (n[1] - t[1]) < (e[1] - t[1]) * (n[0] - t[0]) - } - function pr(n, t, e, r) { - var u = n[0], i = e[0], o = t[0] - u, a = r[0] - i, c = n[1], l = e[1], s = t[1] - c, f = r[1] - l, h = (a * (c - l) - f * (u - i)) / (f * o - a * s); - return[u + h * o, c + h * s] - } - function dr(n) { - var t = n[0], e = n[n.length - 1]; - return!(t[0] - e[0] || t[1] - e[1]) - } - function vr(n, t) { - var e = {list: n.map(function (n, t) { - return{index: t, x: n[0], y: n[1]} - }).sort(function (n, t) { - return n.y < t.y ? -1 : n.y > t.y ? 1 : n.x < t.x ? -1 : n.x > t.x ? 1 : 0 - }), bottomSite: null}, r = {list: [], leftEnd: null, rightEnd: null, init: function () { - r.leftEnd = r.createHalfEdge(null, "l"), r.rightEnd = r.createHalfEdge(null, "l"), r.leftEnd.r = r.rightEnd, r.rightEnd.l = r.leftEnd, r.list.unshift(r.leftEnd, r.rightEnd) - }, createHalfEdge: function (n, t) { - return{edge: n, side: t, vertex: null, l: null, r: null} - }, insert: function (n, t) { - t.l = n, t.r = n.r, n.r.l = t, n.r = t - }, leftBound: function (n) { - var t = r.leftEnd; - do - t = t.r; - while (t != r.rightEnd && u.rightOf(t, n)); - return t = t.l - }, del: function (n) { - n.l.r = n.r, n.r.l = n.l, n.edge = null - }, right: function (n) { - return n.r - }, left: function (n) { - return n.l - }, leftRegion: function (n) { - return null == n.edge ? e.bottomSite : n.edge.region[n.side] - }, rightRegion: function (n) { - return null == n.edge ? e.bottomSite : n.edge.region[vc[n.side]] - }}, u = {bisect: function (n, t) { - var e = {region: {l: n, r: t}, ep: {l: null, r: null}}, r = t.x - n.x, u = t.y - n.y, i = r > 0 ? r : -r, o = u > 0 ? u : -u; - return e.c = n.x * r + n.y * u + .5 * (r * r + u * u), i > o ? (e.a = 1, e.b = u / r, e.c /= r) : (e.b = 1, e.a = r / u, e.c /= u), e - }, intersect: function (n, t) { - var e = n.edge, r = t.edge; - if (!e || !r || e.region.r == r.region.r) - return null; - var u = e.a * r.b - e.b * r.a; - if (Math.abs(u) < 1e-10) - return null; - var i, o, a = (e.c * r.b - r.c * e.b) / u, c = (r.c * e.a - e.c * r.a) / u, l = e.region.r, s = r.region.r; - l.y < s.y || l.y == s.y && l.x < s.x ? (i = n, o = e) : (i = t, o = r); - var f = a >= o.region.r.x; - return f && "l" === i.side || !f && "r" === i.side ? null : {x: a, y: c} - }, rightOf: function (n, t) { - var e = n.edge, r = e.region.r, u = t.x > r.x; - if (u && "l" === n.side) - return 1; - if (!u && "r" === n.side) - return 0; - if (1 === e.a) { - var i = t.y - r.y, o = t.x - r.x, a = 0, c = 0; - if (!u && e.b < 0 || u && e.b >= 0 ? c = a = i >= e.b * o : (c = t.x + t.y * e.b > e.c, e.b < 0 && (c = !c), c || (a = 1)), !a) { - var l = r.x - e.region.l.x; - c = e.b * (o * o - i * i) < l * i * (1 + 2 * o / l + e.b * e.b), e.b < 0 && (c = !c) - } - } else { - var s = e.c - e.a * t.x, f = t.y - s, h = t.x - r.x, g = s - r.y; - c = f * f > h * h + g * g - } - return"l" === n.side ? c : !c - }, endPoint: function (n, e, r) { - n.ep[e] = r, n.ep[vc[e]] && t(n) - }, distance: function (n, t) { - var e = n.x - t.x, r = n.y - t.y; - return Math.sqrt(e * e + r * r) - }}, i = {list: [], insert: function (n, t, e) { - n.vertex = t, n.ystar = t.y + e; - for (var r = 0, u = i.list, o = u.length; o > r; r++) { - var a = u[r]; - if (!(n.ystar > a.ystar || n.ystar == a.ystar && t.x > a.vertex.x)) - break - } - u.splice(r, 0, n) - }, del: function (n) { - for (var t = 0, e = i.list, r = e.length; r > t && e[t] != n; ++t) - ; - e.splice(t, 1) - }, empty: function () { - return 0 === i.list.length - }, nextEvent: function (n) { - for (var t = 0, e = i.list, r = e.length; r > t; ++t) - if (e[t] == n) - return e[t + 1]; - return null - }, min: function () { - var n = i.list[0]; - return{x: n.vertex.x, y: n.ystar} - }, extractMin: function () { - return i.list.shift() - }}; - r.init(), e.bottomSite = e.list.shift(); - for (var o, a, c, l, s, f, h, g, p, d, v, m, y, M = e.list.shift(); ; ) - if (i.empty() || (o = i.min()), M && (i.empty() || M.y < o.y || M.y == o.y && M.x < o.x)) - a = r.leftBound(M), c = r.right(a), h = r.rightRegion(a), m = u.bisect(h, M), f = r.createHalfEdge(m, "l"), r.insert(a, f), d = u.intersect(a, f), d && (i.del(a), i.insert(a, d, u.distance(d, M))), a = f, f = r.createHalfEdge(m, "r"), r.insert(a, f), d = u.intersect(f, c), d && i.insert(f, d, u.distance(d, M)), M = e.list.shift(); - else { - if (i.empty()) - break; - a = i.extractMin(), l = r.left(a), c = r.right(a), s = r.right(c), h = r.leftRegion(a), g = r.rightRegion(c), v = a.vertex, u.endPoint(a.edge, a.side, v), u.endPoint(c.edge, c.side, v), r.del(a), i.del(c), r.del(c), y = "l", h.y > g.y && (p = h, h = g, g = p, y = "r"), m = u.bisect(h, g), f = r.createHalfEdge(m, y), r.insert(l, f), u.endPoint(m, vc[y], v), d = u.intersect(l, f), d && (i.del(l), i.insert(l, d, u.distance(d, h))), d = u.intersect(f, s), d && i.insert(f, d, u.distance(d, h)) - } - for (a = r.right(r.leftEnd); a != r.rightEnd; a = r.right(a)) - t(a.edge) - } - function mr(n) { - return n.x - } - function yr(n) { - return n.y - } - function Mr() { - return{leaf: !0, nodes: [], point: null, x: null, y: null} - } - function xr(n, t, e, r, u, i) { - if (!n(t, e, r, u, i)) { - var o = .5 * (e + u), a = .5 * (r + i), c = t.nodes; - c[0] && xr(n, c[0], e, r, o, a), c[1] && xr(n, c[1], o, r, u, a), c[2] && xr(n, c[2], e, a, o, i), c[3] && xr(n, c[3], o, a, u, i) - } - } - function br(n, t) { - n = vo.rgb(n), t = vo.rgb(t); - var e = n.r, r = n.g, u = n.b, i = t.r - e, o = t.g - r, a = t.b - u; - return function (n) { - return"#" + ct(Math.round(e + i * n)) + ct(Math.round(r + o * n)) + ct(Math.round(u + a * n)) - } - } - function _r(n, t) { - var e, r = {}, u = {}; - for (e in n) - e in t ? r[e] = Er(n[e], t[e]) : u[e] = n[e]; - for (e in t) - e in n || (u[e] = t[e]); - return function (n) { - for (e in r) - u[e] = r[e](n); - return u - } - } - function wr(n, t) { - return t -= n = +n, function (e) { - return n + t * e - } - } - function Sr(n, t) { - var e, r, u, i, o, a = 0, c = 0, l = [], s = []; - for (n += "", t += "", mc.lastIndex = 0, r = 0; e = mc.exec(t); ++r) - e.index && l.push(t.substring(a, c = e.index)), s.push({i: l.length, x: e[0]}), l.push(null), a = mc.lastIndex; - for (a < t.length && l.push(t.substring(a)), r = 0, i = s.length; (e = mc.exec(n)) && i > r; ++r) - if (o = s[r], o.x == e[0]) { - if (o.i) - if (null == l[o.i + 1]) - for (l[o.i - 1] += o.x, l.splice(o.i, 1), u = r + 1; i > u; ++u) - s[u].i--; - else - for (l[o.i - 1] += o.x + l[o.i + 1], l.splice(o.i, 2), u = r + 1; i > u; ++u) - s[u].i -= 2; - else if (null == l[o.i + 1]) - l[o.i] = o.x; - else - for (l[o.i] = o.x + l[o.i + 1], l.splice(o.i + 1, 1), u = r + 1; i > u; ++u) - s[u].i--; - s.splice(r, 1), i--, r-- - } else - o.x = wr(parseFloat(e[0]), parseFloat(o.x)); - for (; i > r; ) - o = s.pop(), null == l[o.i + 1] ? l[o.i] = o.x : (l[o.i] = o.x + l[o.i + 1], l.splice(o.i + 1, 1)), i--; - return 1 === l.length ? null == l[0] ? (o = s[0].x, function (n) { - return o(n) + "" - }) : function () { - return t - } : function (n) { - for (r = 0; i > r; ++r) - l[(o = s[r]).i] = o.x(n); - return l.join("") - } - } - function Er(n, t) { - for (var e, r = vo.interpolators.length; --r >= 0 && !(e = vo.interpolators[r](n, t)); ) - ; - return e - } - function kr(n, t) { - var e, r = [], u = [], i = n.length, o = t.length, a = Math.min(n.length, t.length); - for (e = 0; a > e; ++e) - r.push(Er(n[e], t[e])); - for (; i > e; ++e) - u[e] = n[e]; - for (; o > e; ++e) - u[e] = t[e]; - return function (n) { - for (e = 0; a > e; ++e) - u[e] = r[e](n); - return u - } - } - function Ar(n) { - return function (t) { - return 0 >= t ? 0 : t >= 1 ? 1 : n(t) - } - } - function Nr(n) { - return function (t) { - return 1 - n(1 - t) - } - } - function qr(n) { - return function (t) { - return.5 * (.5 > t ? n(2 * t) : 2 - n(2 - 2 * t)) - } - } - function Tr(n) { - return n * n - } - function zr(n) { - return n * n * n - } - function Cr(n) { - if (0 >= n) - return 0; - if (n >= 1) - return 1; - var t = n * n, e = t * n; - return 4 * (.5 > n ? e : 3 * (n - t) + e - .75) - } - function Dr(n) { - return function (t) { - return Math.pow(t, n) - } - } - function jr(n) { - return 1 - Math.cos(n * Bo / 2) - } - function Lr(n) { - return Math.pow(2, 10 * (n - 1)) - } - function Hr(n) { - return 1 - Math.sqrt(1 - n * n) - } - function Fr(n, t) { - var e; - return arguments.length < 2 && (t = .45), arguments.length ? e = t / (2 * Bo) * Math.asin(1 / n) : (n = 1, e = t / 4), function (r) { - return 1 + n * Math.pow(2, 10 * -r) * Math.sin(2 * (r - e) * Bo / t) - } - } - function Pr(n) { - return n || (n = 1.70158), function (t) { - return t * t * ((n + 1) * t - n) - } - } - function Or(n) { - return 1 / 2.75 > n ? 7.5625 * n * n : 2 / 2.75 > n ? 7.5625 * (n -= 1.5 / 2.75) * n + .75 : 2.5 / 2.75 > n ? 7.5625 * (n -= 2.25 / 2.75) * n + .9375 : 7.5625 * (n -= 2.625 / 2.75) * n + .984375 - } - function Rr(n, t) { - n = vo.hcl(n), t = vo.hcl(t); - var e = n.h, r = n.c, u = n.l, i = t.h - e, o = t.c - r, a = t.l - u; - return isNaN(o) && (o = 0, r = isNaN(r) ? t.c : r), isNaN(i) ? (i = 0, e = isNaN(e) ? t.h : e) : i > 180 ? i -= 360 : -180 > i && (i += 360), function (n) { - return J(e + i * n, r + o * n, u + a * n) + "" - } - } - function Yr(n, t) { - n = vo.hsl(n), t = vo.hsl(t); - var e = n.h, r = n.s, u = n.l, i = t.h - e, o = t.s - r, a = t.l - u; - return isNaN(o) && (o = 0, r = isNaN(r) ? t.s : r), isNaN(i) ? (i = 0, e = isNaN(e) ? t.h : e) : i > 180 ? i -= 360 : -180 > i && (i += 360), function (n) { - return B(e + i * n, r + o * n, u + a * n) + "" - } - } - function Ir(n, t) { - n = vo.lab(n), t = vo.lab(t); - var e = n.l, r = n.a, u = n.b, i = t.l - e, o = t.a - r, a = t.b - u; - return function (n) { - return Q(e + i * n, r + o * n, u + a * n) + "" - } - } - function Ur(n, t) { - return t -= n, function (e) { - return Math.round(n + t * e) - } - } - function Vr(n) { - var t = [n.a, n.b], e = [n.c, n.d], r = Xr(t), u = Zr(t, e), i = Xr(Br(e, t, -u)) || 0; - t[0] * e[1] < e[0] * t[1] && (t[0] *= -1, t[1] *= -1, r *= -1, u *= -1), this.rotate = (r ? Math.atan2(t[1], t[0]) : Math.atan2(-e[0], e[1])) * Go, this.translate = [n.e, n.f], this.scale = [r, i], this.skew = i ? Math.atan2(u, i) * Go : 0 - } - function Zr(n, t) { - return n[0] * t[0] + n[1] * t[1] - } - function Xr(n) { - var t = Math.sqrt(Zr(n, n)); - return t && (n[0] /= t, n[1] /= t), t - } - function Br(n, t, e) { - return n[0] += e * t[0], n[1] += e * t[1], n - } - function $r(n, t) { - var e, r = [], u = [], i = vo.transform(n), o = vo.transform(t), a = i.translate, c = o.translate, l = i.rotate, s = o.rotate, f = i.skew, h = o.skew, g = i.scale, p = o.scale; - return a[0] != c[0] || a[1] != c[1] ? (r.push("translate(", null, ",", null, ")"), u.push({i: 1, x: wr(a[0], c[0])}, {i: 3, x: wr(a[1], c[1])})) : c[0] || c[1] ? r.push("translate(" + c + ")") : r.push(""), l != s ? (l - s > 180 ? s += 360 : s - l > 180 && (l += 360), u.push({i: r.push(r.pop() + "rotate(", null, ")") - 2, x: wr(l, s)})) : s && r.push(r.pop() + "rotate(" + s + ")"), f != h ? u.push({i: r.push(r.pop() + "skewX(", null, ")") - 2, x: wr(f, h)}) : h && r.push(r.pop() + "skewX(" + h + ")"), g[0] != p[0] || g[1] != p[1] ? (e = r.push(r.pop() + "scale(", null, ",", null, ")"), u.push({i: e - 4, x: wr(g[0], p[0])}, {i: e - 2, x: wr(g[1], p[1])})) : (1 != p[0] || 1 != p[1]) && r.push(r.pop() + "scale(" + p + ")"), e = u.length, function (n) { - for (var t, i = -1; ++i < e; ) - r[(t = u[i]).i] = t.x(n); - return r.join("") - } - } - function Wr(n, t) { - return t = t - (n = +n) ? 1 / (t - n) : 0, function (e) { - return(e - n) * t - } - } - function Jr(n, t) { - return t = t - (n = +n) ? 1 / (t - n) : 0, function (e) { - return Math.max(0, Math.min(1, (e - n) * t)) - } - } - function Gr(n) { - for (var t = n.source, e = n.target, r = Qr(t, e), u = [t]; t !== r; ) - t = t.parent, u.push(t); - for (var i = u.length; e !== r; ) - u.splice(i, 0, e), e = e.parent; - return u - } - function Kr(n) { - for (var t = [], e = n.parent; null != e; ) - t.push(n), n = e, e = e.parent; - return t.push(n), t - } - function Qr(n, t) { - if (n === t) - return n; - for (var e = Kr(n), r = Kr(t), u = e.pop(), i = r.pop(), o = null; u === i; ) - o = u, u = e.pop(), i = r.pop(); - return o - } - function nu(n) { - n.fixed |= 2 - } - function tu(n) { - n.fixed &= -7 - } - function eu(n) { - n.fixed |= 4, n.px = n.x, n.py = n.y - } - function ru(n) { - n.fixed &= -5 - } - function uu(n, t, e) { - var r = 0, u = 0; - if (n.charge = 0, !n.leaf) - for (var i, o = n.nodes, a = o.length, c = -1; ++c < a; ) - i = o[c], null != i && (uu(i, t, e), n.charge += i.charge, r += i.charge * i.cx, u += i.charge * i.cy); - if (n.point) { - n.leaf || (n.point.x += Math.random() - .5, n.point.y += Math.random() - .5); - var l = t * e[n.point.index]; - n.charge += n.pointCharge = l, r += l * n.point.x, u += l * n.point.y - } - n.cx = r / n.charge, n.cy = u / n.charge - } - function iu(n, t) { - return vo.rebind(n, t, "sort", "children", "value"), n.nodes = n, n.links = lu, n - } - function ou(n) { - return n.children - } - function au(n) { - return n.value - } - function cu(n, t) { - return t.value - n.value - } - function lu(n) { - return vo.merge(n.map(function (n) { - return(n.children || []).map(function (t) { - return{source: n, target: t} - }) - })) - } - function su(n) { - return n.x - } - function fu(n) { - return n.y - } - function hu(n, t, e) { - n.y0 = t, n.y = e - } - function gu(n) { - return vo.range(n.length) - } - function pu(n) { - for (var t = -1, e = n[0].length, r = []; ++t < e; ) - r[t] = 0; - return r - } - function du(n) { - for (var t, e = 1, r = 0, u = n[0][1], i = n.length; i > e; ++e) - (t = n[e][1]) > u && (r = e, u = t); - return r - } - function vu(n) { - return n.reduce(mu, 0) - } - function mu(n, t) { - return n + t[1] - } - function yu(n, t) { - return Mu(n, Math.ceil(Math.log(t.length) / Math.LN2 + 1)) - } - function Mu(n, t) { - for (var e = -1, r = +n[0], u = (n[1] - r) / t, i = []; ++e <= t; ) - i[e] = u * e + r; - return i - } - function xu(n) { - return[vo.min(n), vo.max(n)] - } - function bu(n, t) { - return n.parent == t.parent ? 1 : 2 - } - function _u(n) { - var t = n.children; - return t && t.length ? t[0] : n._tree.thread - } - function wu(n) { - var t, e = n.children; - return e && (t = e.length) ? e[t - 1] : n._tree.thread - } - function Su(n, t) { - var e = n.children; - if (e && (u = e.length)) - for (var r, u, i = -1; ++i < u; ) - t(r = Su(e[i], t), n) > 0 && (n = r); - return n - } - function Eu(n, t) { - return n.x - t.x - } - function ku(n, t) { - return t.x - n.x - } - function Au(n, t) { - return n.depth - t.depth - } - function Nu(n, t) { - function e(n, r) { - var u = n.children; - if (u && (o = u.length)) - for (var i, o, a = null, c = -1; ++c < o; ) - i = u[c], e(i, a), a = i; - t(n, r) - } - e(n, null) - } - function qu(n) { - for (var t, e = 0, r = 0, u = n.children, i = u.length; --i >= 0; ) - t = u[i]._tree, t.prelim += e, t.mod += e, e += t.shift + (r += t.change) - } - function Tu(n, t, e) { - n = n._tree, t = t._tree; - var r = e / (t.number - n.number); - n.change += r, t.change -= r, t.shift += e, t.prelim += e, t.mod += e - } - function zu(n, t, e) { - return n._tree.ancestor.parent == t.parent ? n._tree.ancestor : e - } - function Cu(n, t) { - return n.value - t.value - } - function Du(n, t) { - var e = n._pack_next; - n._pack_next = t, t._pack_prev = n, t._pack_next = e, e._pack_prev = t - } - function ju(n, t) { - n._pack_next = t, t._pack_prev = n - } - function Lu(n, t) { - var e = t.x - n.x, r = t.y - n.y, u = n.r + t.r; - return.999 * u * u > e * e + r * r - } - function Hu(n) { - function t(n) { - s = Math.min(n.x - n.r, s), f = Math.max(n.x + n.r, f), h = Math.min(n.y - n.r, h), g = Math.max(n.y + n.r, g) - } - if ((e = n.children) && (l = e.length)) { - var e, r, u, i, o, a, c, l, s = 1 / 0, f = -1 / 0, h = 1 / 0, g = -1 / 0; - if (e.forEach(Fu), r = e[0], r.x = -r.r, r.y = 0, t(r), l > 1 && (u = e[1], u.x = u.r, u.y = 0, t(u), l > 2)) - for (i = e[2], Ru(r, u, i), t(i), Du(r, i), r._pack_prev = i, Du(i, u), u = r._pack_next, o = 3; l > o; o++) { - Ru(r, u, i = e[o]); - var p = 0, d = 1, v = 1; - for (a = u._pack_next; a !== u; a = a._pack_next, d++) - if (Lu(a, i)) { - p = 1; - break - } - if (1 == p) - for (c = r._pack_prev; c !== a._pack_prev && !Lu(c, i); c = c._pack_prev, v++) - ; - p ? (v > d || d == v && u.r < r.r ? ju(r, u = a) : ju(r = c, u), o--) : (Du(r, i), u = i, t(i)) - } - var m = (s + f) / 2, y = (h + g) / 2, M = 0; - for (o = 0; l > o; o++) - i = e[o], i.x -= m, i.y -= y, M = Math.max(M, i.r + Math.sqrt(i.x * i.x + i.y * i.y)); - n.r = M, e.forEach(Pu) - } - } - function Fu(n) { - n._pack_next = n._pack_prev = n - } - function Pu(n) { - delete n._pack_next, delete n._pack_prev - } - function Ou(n, t, e, r) { - var u = n.children; - if (n.x = t += r * n.x, n.y = e += r * n.y, n.r *= r, u) - for (var i = -1, o = u.length; ++i < o; ) - Ou(u[i], t, e, r) - } - function Ru(n, t, e) { - var r = n.r + e.r, u = t.x - n.x, i = t.y - n.y; - if (r && (u || i)) { - var o = t.r + e.r, a = u * u + i * i; - o *= o, r *= r; - var c = .5 + (r - o) / (2 * a), l = Math.sqrt(Math.max(0, 2 * o * (r + a) - (r -= a) * r - o * o)) / (2 * a); - e.x = n.x + c * u + l * i, e.y = n.y + c * i - l * u - } else - e.x = n.x + r, e.y = n.y - } - function Yu(n) { - return 1 + vo.max(n, function (n) { - return n.y - }) - } - function Iu(n) { - return n.reduce(function (n, t) { - return n + t.x - }, 0) / n.length - } - function Uu(n) { - var t = n.children; - return t && t.length ? Uu(t[0]) : n - } - function Vu(n) { - var t, e = n.children; - return e && (t = e.length) ? Vu(e[t - 1]) : n - } - function Zu(n) { - return{x: n.x, y: n.y, dx: n.dx, dy: n.dy} - } - function Xu(n, t) { - var e = n.x + t[3], r = n.y + t[0], u = n.dx - t[1] - t[3], i = n.dy - t[0] - t[2]; - return 0 > u && (e += u / 2, u = 0), 0 > i && (r += i / 2, i = 0), {x: e, y: r, dx: u, dy: i} - } - function Bu(n) { - var t = n[0], e = n[n.length - 1]; - return e > t ? [t, e] : [e, t] - } - function $u(n) { - return n.rangeExtent ? n.rangeExtent() : Bu(n.range()) - } - function Wu(n, t, e, r) { - var u = e(n[0], n[1]), i = r(t[0], t[1]); - return function (n) { - return i(u(n)) - } - } - function Ju(n, t) { - var e, r = 0, u = n.length - 1, i = n[r], o = n[u]; - return i > o && (e = r, r = u, u = e, e = i, i = o, o = e), n[r] = t.floor(i), n[u] = t.ceil(o), n - } - function Gu(n) { - return n ? {floor: function (t) { - return Math.floor(t / n) * n - }, ceil: function (t) { - return Math.ceil(t / n) * n - }} : Ac - } - function Ku(n, t, e, r) { - var u = [], i = [], o = 0, a = Math.min(n.length, t.length) - 1; - for (n[a] < n[0] && (n = n.slice().reverse(), t = t.slice().reverse()); ++o <= a; ) - u.push(e(n[o - 1], n[o])), i.push(r(t[o - 1], t[o])); - return function (t) { - var e = vo.bisect(n, t, 1, a) - 1; - return i[e](u[e](t)) - } - } - function Qu(n, t, e, r) { - function u() { - var u = Math.min(n.length, t.length) > 2 ? Ku : Wu, c = r ? Jr : Wr; - return o = u(n, t, c, e), a = u(t, n, c, Er), i - } - function i(n) { - return o(n) - } - var o, a; - return i.invert = function (n) { - return a(n) - }, i.domain = function (t) { - return arguments.length ? (n = t.map(Number), u()) : n - }, i.range = function (n) { - return arguments.length ? (t = n, u()) : t - }, i.rangeRound = function (n) { - return i.range(n).interpolate(Ur) - }, i.clamp = function (n) { - return arguments.length ? (r = n, u()) : r - }, i.interpolate = function (n) { - return arguments.length ? (e = n, u()) : e - }, i.ticks = function (t) { - return ri(n, t) - }, i.tickFormat = function (t, e) { - return ui(n, t, e) - }, i.nice = function (t) { - return ti(n, t), u() - }, i.copy = function () { - return Qu(n, t, e, r) - }, u() - } - function ni(n, t) { - return vo.rebind(n, t, "range", "rangeRound", "interpolate", "clamp") - } - function ti(n, t) { - return Ju(n, Gu(ei(n, t)[2])) - } - function ei(n, t) { - null == t && (t = 10); - var e = Bu(n), r = e[1] - e[0], u = Math.pow(10, Math.floor(Math.log(r / t) / Math.LN10)), i = t / r * u; - return.15 >= i ? u *= 10 : .35 >= i ? u *= 5 : .75 >= i && (u *= 2), e[0] = Math.ceil(e[0] / u) * u, e[1] = Math.floor(e[1] / u) * u + .5 * u, e[2] = u, e - } - function ri(n, t) { - return vo.range.apply(vo, ei(n, t)) - } - function ui(n, t, e) { - var r = -Math.floor(Math.log(ei(n, t)[2]) / Math.LN10 + .01); - return vo.format(e ? e.replace(Sa, function (n, t, e, u, i, o, a, c, l, s) { - return[t, e, u, i, o, a, c, l || "." + (r - 2 * ("%" === s)), s].join("") - }) : ",." + r + "f") - } - function ii(n, t, e, r) { - function u(n) { - return(e ? Math.log(0 > n ? 0 : n) : -Math.log(n > 0 ? 0 : -n)) / Math.log(t) - } - function i(n) { - return e ? Math.pow(t, n) : -Math.pow(t, -n) - } - function o(t) { - return n(u(t)) - } - return o.invert = function (t) { - return i(n.invert(t)) - }, o.domain = function (t) { - return arguments.length ? (e = t[0] >= 0, n.domain((r = t.map(Number)).map(u)), o) : r - }, o.base = function (e) { - return arguments.length ? (t = +e, n.domain(r.map(u)), o) : t - }, o.nice = function () { - var t = Ju(r.map(u), e ? Math : qc); - return n.domain(t), r = t.map(i), o - }, o.ticks = function () { - var n = Bu(r), o = [], a = n[0], c = n[1], l = Math.floor(u(a)), s = Math.ceil(u(c)), f = t % 1 ? 2 : t; - if (isFinite(s - l)) { - if (e) { - for (; s > l; l++) - for (var h = 1; f > h; h++) - o.push(i(l) * h); - o.push(i(l)) - } else - for (o.push(i(l)); l++ < s; ) - for (var h = f - 1; h > 0; h--) - o.push(i(l) * h); - for (l = 0; o[l] < a; l++) - ; - for (s = o.length; o[s - 1] > c; s--) - ; - o = o.slice(l, s) - } - return o - }, o.tickFormat = function (n, t) { - if (!arguments.length) - return Nc; - arguments.length < 2 ? t = Nc : "function" != typeof t && (t = vo.format(t)); - var r, a = Math.max(.1, n / o.ticks().length), c = e ? (r = 1e-12, Math.ceil) : (r = -1e-12, Math.floor); - return function (n) { - return n / i(c(u(n) + r)) <= a ? t(n) : "" - } - }, o.copy = function () { - return ii(n.copy(), t, e, r) - }, ni(o, n) - } - function oi(n, t, e) { - function r(t) { - return n(u(t)) - } - var u = ai(t), i = ai(1 / t); - return r.invert = function (t) { - return i(n.invert(t)) - }, r.domain = function (t) { - return arguments.length ? (n.domain((e = t.map(Number)).map(u)), r) : e - }, r.ticks = function (n) { - return ri(e, n) - }, r.tickFormat = function (n, t) { - return ui(e, n, t) - }, r.nice = function (n) { - return r.domain(ti(e, n)) - }, r.exponent = function (o) { - return arguments.length ? (u = ai(t = o), i = ai(1 / t), n.domain(e.map(u)), r) : t - }, r.copy = function () { - return oi(n.copy(), t, e) - }, ni(r, n) - } - function ai(n) { - return function (t) { - return 0 > t ? -Math.pow(-t, n) : Math.pow(t, n) - } - } - function ci(n, t) { - function e(t) { - return o[((i.get(t) || i.set(t, n.push(t))) - 1) % o.length] - } - function r(t, e) { - return vo.range(n.length).map(function (n) { - return t + e * n - }) - } - var i, o, a; - return e.domain = function (r) { - if (!arguments.length) - return n; - n = [], i = new u; - for (var o, a = -1, c = r.length; ++a < c; ) - i.has(o = r[a]) || i.set(o, n.push(o)); - return e[t.t].apply(e, t.a) - }, e.range = function (n) { - return arguments.length ? (o = n, a = 0, t = {t: "range", a: arguments}, e) : o - }, e.rangePoints = function (u, i) { - arguments.length < 2 && (i = 0); - var c = u[0], l = u[1], s = (l - c) / (Math.max(1, n.length - 1) + i); - return o = r(n.length < 2 ? (c + l) / 2 : c + s * i / 2, s), a = 0, t = {t: "rangePoints", a: arguments}, e - }, e.rangeBands = function (u, i, c) { - arguments.length < 2 && (i = 0), arguments.length < 3 && (c = i); - var l = u[1] < u[0], s = u[l - 0], f = u[1 - l], h = (f - s) / (n.length - i + 2 * c); - return o = r(s + h * c, h), l && o.reverse(), a = h * (1 - i), t = {t: "rangeBands", a: arguments}, e - }, e.rangeRoundBands = function (u, i, c) { - arguments.length < 2 && (i = 0), arguments.length < 3 && (c = i); - var l = u[1] < u[0], s = u[l - 0], f = u[1 - l], h = Math.floor((f - s) / (n.length - i + 2 * c)), g = f - s - (n.length - i) * h; - return o = r(s + Math.round(g / 2), h), l && o.reverse(), a = Math.round(h * (1 - i)), t = {t: "rangeRoundBands", a: arguments}, e - }, e.rangeBand = function () { - return a - }, e.rangeExtent = function () { - return Bu(t.a[0]) - }, e.copy = function () { - return ci(n, t) - }, e.domain(n) - } - function li(n, t) { - function e() { - var e = 0, i = t.length; - for (u = []; ++e < i; ) - u[e - 1] = vo.quantile(n, e / i); - return r - } - function r(n) { - return isNaN(n = +n) ? void 0 : t[vo.bisect(u, n)] - } - var u; - return r.domain = function (t) { - return arguments.length ? (n = t.filter(function (n) { - return!isNaN(n) - }).sort(vo.ascending), e()) : n - }, r.range = function (n) { - return arguments.length ? (t = n, e()) : t - }, r.quantiles = function () { - return u - }, r.invertExtent = function (e) { - return e = t.indexOf(e), 0 > e ? [0 / 0, 0 / 0] : [e > 0 ? u[e - 1] : n[0], e < u.length ? u[e] : n[n.length - 1]] - }, r.copy = function () { - return li(n, t) - }, e() - } - function si(n, t, e) { - function r(t) { - return e[Math.max(0, Math.min(o, Math.floor(i * (t - n))))] - } - function u() { - return i = e.length / (t - n), o = e.length - 1, r - } - var i, o; - return r.domain = function (e) { - return arguments.length ? (n = +e[0], t = +e[e.length - 1], u()) : [n, t] - }, r.range = function (n) { - return arguments.length ? (e = n, u()) : e - }, r.invertExtent = function (t) { - return t = e.indexOf(t), t = 0 > t ? 0 / 0 : t / i + n, [t, t + 1 / i] - }, r.copy = function () { - return si(n, t, e) - }, u() - } - function fi(n, t) { - function e(e) { - return e >= e ? t[vo.bisect(n, e)] : void 0 - } - return e.domain = function (t) { - return arguments.length ? (n = t, e) : n - }, e.range = function (n) { - return arguments.length ? (t = n, e) : t - }, e.invertExtent = function (e) { - return e = t.indexOf(e), [n[e - 1], n[e]] - }, e.copy = function () { - return fi(n, t) - }, e - } - function hi(n) { - function t(n) { - return+n - } - return t.invert = t, t.domain = t.range = function (e) { - return arguments.length ? (n = e.map(t), t) : n - }, t.ticks = function (t) { - return ri(n, t) - }, t.tickFormat = function (t, e) { - return ui(n, t, e) - }, t.copy = function () { - return hi(n) - }, t - } - function gi(n) { - return n.innerRadius - } - function pi(n) { - return n.outerRadius - } - function di(n) { - return n.startAngle - } - function vi(n) { - return n.endAngle - } - function mi(n) { - for (var t, e, r, u = -1, i = n.length; ++u < i; ) - t = n[u], e = t[0], r = t[1] + jc, t[0] = e * Math.cos(r), t[1] = e * Math.sin(r); - return n - } - function yi(n) { - function t(t) { - function c() { - d.push("M", a(n(m), f), s, l(n(v.reverse()), f), "Z") - } - for (var h, g, p, d = [], v = [], m = [], y = -1, M = t.length, x = pt(e), b = pt(u), _ = e === r ? function () { - return g - } : pt(r), w = u === i ? function () { - return p - } : pt(i); ++y < M; ) - o.call(this, h = t[y], y) ? (v.push([g = +x.call(this, h, y), p = +b.call(this, h, y)]), m.push([+_.call(this, h, y), +w.call(this, h, y)])) : v.length && (c(), v = [], m = []); - return v.length && c(), d.length ? d.join("") : null - } - var e = Ve, r = Ve, u = 0, i = Ze, o = Zt, a = Xe, c = a.key, l = a, s = "L", f = .7; - return t.x = function (n) { - return arguments.length ? (e = r = n, t) : r - }, t.x0 = function (n) { - return arguments.length ? (e = n, t) : e - }, t.x1 = function (n) { - return arguments.length ? (r = n, t) : r - }, t.y = function (n) { - return arguments.length ? (u = i = n, t) : i - }, t.y0 = function (n) { - return arguments.length ? (u = n, t) : u - }, t.y1 = function (n) { - return arguments.length ? (i = n, t) : i - }, t.defined = function (n) { - return arguments.length ? (o = n, t) : o - }, t.interpolate = function (n) { - return arguments.length ? (c = "function" == typeof n ? a = n : (a = fc.get(n) || Xe).key, l = a.reverse || a, s = a.closed ? "M" : "L", t) : c - }, t.tension = function (n) { - return arguments.length ? (f = n, t) : f - }, t - } - function Mi(n) { - return n.radius - } - function xi(n) { - return[n.x, n.y] - } - function bi(n) { - return function () { - var t = n.apply(this, arguments), e = t[0], r = t[1] + jc; - return[e * Math.cos(r), e * Math.sin(r)] - } - } - function _i() { - return 64 - } - function wi() { - return"circle" - } - function Si(n) { - var t = Math.sqrt(n / Bo); - return"M0," + t + "A" + t + "," + t + " 0 1,1 0," + -t + "A" + t + "," + t + " 0 1,1 0," + t + "Z" - } - function Ei(n, t) { - return jo(n, Yc), n.id = t, n - } - function ki(n, t, e, r) { - var u = n.id; - return N(n, "function" == typeof e ? function (n, i, o) { - n.__transition__[u].tween.set(t, r(e.call(n, n.__data__, i, o))) - } : (e = r(e), function (n) { - n.__transition__[u].tween.set(t, e) - })) - } - function Ai(n) { - return null == n && (n = ""), function () { - this.textContent = n - } - } - function Ni(n, t, e, r) { - var i = n.__transition__ || (n.__transition__ = {active: 0, count: 0}), o = i[e]; - if (!o) { - var a = r.time; - o = i[e] = {tween: new u, time: a, ease: r.ease, delay: r.delay, duration: r.duration}, ++i.count, vo.timer(function (r) { - function u(r) { - return i.active > e ? l() : (i.active = e, o.event && o.event.start.call(n, s, t), o.tween.forEach(function (e, r) { - (r = r.call(n, s, t)) && p.push(r) - }), c(r) ? 1 : (xt(c, 0, a), void 0)) - } - function c(r) { - if (i.active !== e) - return l(); - for (var u = (r - h) / g, a = f(u), c = p.length; c > 0; ) - p[--c].call(n, a); - return u >= 1 ? (o.event && o.event.end.call(n, s, t), l()) : void 0 - } - function l() { - return--i.count ? delete i[e] : delete n.__transition__, 1 - } - var s = n.__data__, f = o.ease, h = o.delay, g = o.duration, p = []; - return r >= h ? u(r) : (xt(u, h, a), void 0) - }, 0, a) - } - } - function qi(n, t) { - n.attr("transform", function (n) { - return"translate(" + t(n) + ",0)" - }) - } - function Ti(n, t) { - n.attr("transform", function (n) { - return"translate(0," + t(n) + ")" - }) - } - function zi() { - this._ = new Date(arguments.length > 1 ? Date.UTC.apply(this, arguments) : arguments[0]) - } - function Ci(n, t, e) { - function r(t) { - var e = n(t), r = i(e, 1); - return r - t > t - e ? e : r - } - function u(e) { - return t(e = n(new $c(e - 1)), 1), e - } - function i(n, e) { - return t(n = new $c(+n), e), n - } - function o(n, r, i) { - var o = u(n), a = []; - if (i > 1) - for (; r > o; ) - e(o) % i || a.push(new Date(+o)), t(o, 1); - else - for (; r > o; ) - a.push(new Date(+o)), t(o, 1); - return a - } - function a(n, t, e) { - try { - $c = zi; - var r = new zi; - return r._ = n, o(r, t, e) - } finally { - $c = Date - } - } - n.floor = n, n.round = r, n.ceil = u, n.offset = i, n.range = o; - var c = n.utc = Di(n); - return c.floor = c, c.round = Di(r), c.ceil = Di(u), c.offset = Di(i), c.range = a, n - } - function Di(n) { - return function (t, e) { - try { - $c = zi; - var r = new zi; - return r._ = t, n(r, e)._ - } finally { - $c = Date - } - } - } - function ji(n) { - function t(t) { - for (var r, u, i, o = [], a = -1, c = 0; ++a < e; ) - 37 === n.charCodeAt(a) && (o.push(n.substring(c, a)), null != (u = gl[r = n.charAt(++a)]) && (r = n.charAt(++a)), (i = pl[r]) && (r = i(t, null == u ? "e" === r ? " " : "0" : u)), o.push(r), c = a + 1); - return o.push(n.substring(c, a)), o.join("") - } - var e = n.length; - return t.parse = function (t) { - var e = {y: 1900, m: 0, d: 1, H: 0, M: 0, S: 0, L: 0}, r = Li(e, n, t, 0); - if (r != t.length) - return null; - "p"in e && (e.H = e.H % 12 + 12 * e.p); - var u = new $c; - return"j"in e ? u.setFullYear(e.y, 0, e.j) : "w"in e && ("W"in e || "U"in e) ? (u.setFullYear(e.y, 0, 1), u.setFullYear(e.y, 0, "W"in e ? (e.w + 6) % 7 + 7 * e.W - (u.getDay() + 5) % 7 : e.w + 7 * e.U - (u.getDay() + 6) % 7)) : u.setFullYear(e.y, e.m, e.d), u.setHours(e.H, e.M, e.S, e.L), u - }, t.toString = function () { - return n - }, t - } - function Li(n, t, e, r) { - for (var u, i, o, a = 0, c = t.length, l = e.length; c > a; ) { - if (r >= l) - return-1; - if (u = t.charCodeAt(a++), 37 === u) { - if (o = t.charAt(a++), i = dl[o in gl ? t.charAt(a++) : o], !i || (r = i(n, e, r)) < 0) - return-1 - } else if (u != e.charCodeAt(r++)) - return-1 - } - return r - } - function Hi(n) { - return new RegExp("^(?:" + n.map(vo.requote).join("|") + ")", "i") - } - function Fi(n) { - for (var t = new u, e = -1, r = n.length; ++e < r; ) - t.set(n[e].toLowerCase(), e); - return t - } - function Pi(n, t, e) { - var r = 0 > n ? "-" : "", u = (r ? -n : n) + "", i = u.length; - return r + (e > i ? new Array(e - i + 1).join(t) + u : u) - } - function Oi(n, t, e) { - ol.lastIndex = 0; - var r = ol.exec(t.substring(e)); - return r ? (n.w = al.get(r[0].toLowerCase()), e + r[0].length) : -1 - } - function Ri(n, t, e) { - ul.lastIndex = 0; - var r = ul.exec(t.substring(e)); - return r ? (n.w = il.get(r[0].toLowerCase()), e + r[0].length) : -1 - } - function Yi(n, t, e) { - vl.lastIndex = 0; - var r = vl.exec(t.substring(e, e + 1)); - return r ? (n.w = +r[0], e + r[0].length) : -1 - } - function Ii(n, t, e) { - vl.lastIndex = 0; - var r = vl.exec(t.substring(e)); - return r ? (n.U = +r[0], e + r[0].length) : -1 - } - function Ui(n, t, e) { - vl.lastIndex = 0; - var r = vl.exec(t.substring(e)); - return r ? (n.W = +r[0], e + r[0].length) : -1 - } - function Vi(n, t, e) { - sl.lastIndex = 0; - var r = sl.exec(t.substring(e)); - return r ? (n.m = fl.get(r[0].toLowerCase()), e + r[0].length) : -1 - } - function Zi(n, t, e) { - cl.lastIndex = 0; - var r = cl.exec(t.substring(e)); - return r ? (n.m = ll.get(r[0].toLowerCase()), e + r[0].length) : -1 - } - function Xi(n, t, e) { - return Li(n, pl.c.toString(), t, e) - } - function Bi(n, t, e) { - return Li(n, pl.x.toString(), t, e) - } - function $i(n, t, e) { - return Li(n, pl.X.toString(), t, e) - } - function Wi(n, t, e) { - vl.lastIndex = 0; - var r = vl.exec(t.substring(e, e + 4)); - return r ? (n.y = +r[0], e + r[0].length) : -1 - } - function Ji(n, t, e) { - vl.lastIndex = 0; - var r = vl.exec(t.substring(e, e + 2)); - return r ? (n.y = Gi(+r[0]), e + r[0].length) : -1 - } - function Gi(n) { - return n + (n > 68 ? 1900 : 2e3) - } - function Ki(n, t, e) { - vl.lastIndex = 0; - var r = vl.exec(t.substring(e, e + 2)); - return r ? (n.m = r[0] - 1, e + r[0].length) : -1 - } - function Qi(n, t, e) { - vl.lastIndex = 0; - var r = vl.exec(t.substring(e, e + 2)); - return r ? (n.d = +r[0], e + r[0].length) : -1 - } - function no(n, t, e) { - vl.lastIndex = 0; - var r = vl.exec(t.substring(e, e + 3)); - return r ? (n.j = +r[0], e + r[0].length) : -1 - } - function to(n, t, e) { - vl.lastIndex = 0; - var r = vl.exec(t.substring(e, e + 2)); - return r ? (n.H = +r[0], e + r[0].length) : -1 - } - function eo(n, t, e) { - vl.lastIndex = 0; - var r = vl.exec(t.substring(e, e + 2)); - return r ? (n.M = +r[0], e + r[0].length) : -1 - } - function ro(n, t, e) { - vl.lastIndex = 0; - var r = vl.exec(t.substring(e, e + 2)); - return r ? (n.S = +r[0], e + r[0].length) : -1 - } - function uo(n, t, e) { - vl.lastIndex = 0; - var r = vl.exec(t.substring(e, e + 3)); - return r ? (n.L = +r[0], e + r[0].length) : -1 - } - function io(n, t, e) { - var r = ml.get(t.substring(e, e += 2).toLowerCase()); - return null == r ? -1 : (n.p = r, e) - } - function oo(n) { - var t = n.getTimezoneOffset(), e = t > 0 ? "-" : "+", r = ~~(Math.abs(t) / 60), u = Math.abs(t) % 60; - return e + Pi(r, "0", 2) + Pi(u, "0", 2) - } - function ao(n, t, e) { - hl.lastIndex = 0; - var r = hl.exec(t.substring(e, e + 1)); - return r ? e + r[0].length : -1 - } - function co(n) { - function t(n) { - try { - $c = zi; - var t = new $c; - return t._ = n, e(t) - } finally { - $c = Date - } - } - var e = ji(n); - return t.parse = function (n) { - try { - $c = zi; - var t = e.parse(n); - return t && t._ - } finally { - $c = Date - } - }, t.toString = e.toString, t - } - function lo(n) { - return n.toISOString() - } - function so(n, t, e) { - function r(t) { - return n(t) - } - function u(n, e) { - var r = n[1] - n[0], u = r / e, i = vo.bisect(Ml, u); - return i == Ml.length ? [t.year, ei(n.map(function (n) { - return n / 31536e6 - }), e)[2]] : i ? t[u / Ml[i - 1] < Ml[i] / u ? i - 1 : i] : [wl, ei(n, e)[2]] - } - return r.invert = function (t) { - return fo(n.invert(t)) - }, r.domain = function (t) { - return arguments.length ? (n.domain(t), r) : n.domain().map(fo) - }, r.nice = function (n, t) { - function e(e) { - return!isNaN(e) && !n.range(e, fo(+e + 1), t).length - } - var i = r.domain(), o = Bu(i), a = null == n ? u(o, 10) : "number" == typeof n && u(o, n); - return a && (n = a[0], t = a[1]), r.domain(Ju(i, t > 1 ? {floor: function (t) { - for (; e(t = n.floor(t)); ) - t = fo(t - 1); - return t - }, ceil: function (t) { - for (; e(t = n.ceil(t)); ) - t = fo(+t + 1); - return t - }} : n)) - }, r.ticks = function (n, t) { - var e = Bu(r.domain()), i = null == n ? u(e, 10) : "number" == typeof n ? u(e, n) : !n.range && [{range: n}, t]; - return i && (n = i[0], t = i[1]), n.range(e[0], fo(+e[1] + 1), t) - }, r.tickFormat = function () { - return e - }, r.copy = function () { - return so(n.copy(), t, e) - }, ni(r, n) - } - function fo(n) { - return new Date(n) - } - function ho(n) { - return function (t) { - for (var e = n.length - 1, r = n[e]; !r[1](t); ) - r = n[--e]; - return r[0](t) - } - } - function go(n) { - return JSON.parse(n.responseText) - } - function po(n) { - var t = Mo.createRange(); - return t.selectNode(Mo.body), t.createContextualFragment(n.responseText) - } - var vo = {version: "3.3.2"}; - Date.now || (Date.now = function () { - return+new Date - }); - var mo = [].slice, yo = function (n) { - return mo.call(n) - }, Mo = document, xo = Mo.documentElement, bo = window; - try { - yo(xo.childNodes)[0].nodeType - } catch (_o) { - yo = function (n) { - for (var t = n.length, e = new Array(t); t--; ) - e[t] = n[t]; - return e - } - } - try { - Mo.createElement("div").style.setProperty("opacity", 0, "") - } catch (wo) { - var So = bo.Element.prototype, Eo = So.setAttribute, ko = So.setAttributeNS, Ao = bo.CSSStyleDeclaration.prototype, No = Ao.setProperty; - So.setAttribute = function (n, t) { - Eo.call(this, n, t + "") - }, So.setAttributeNS = function (n, t, e) { - ko.call(this, n, t, e + "") - }, Ao.setProperty = function (n, t, e) { - No.call(this, n, t + "", e) - } - } - vo.ascending = function (n, t) { - return t > n ? -1 : n > t ? 1 : n >= t ? 0 : 0 / 0 - }, vo.descending = function (n, t) { - return n > t ? -1 : t > n ? 1 : t >= n ? 0 : 0 / 0 - }, vo.min = function (n, t) { - var e, r, u = -1, i = n.length; - if (1 === arguments.length) { - for (; ++u < i && !(null != (e = n[u]) && e >= e); ) - e = void 0; - for (; ++u < i; ) - null != (r = n[u]) && e > r && (e = r) - } else { - for (; ++u < i && !(null != (e = t.call(n, n[u], u)) && e >= e); ) - e = void 0; - for (; ++u < i; ) - null != (r = t.call(n, n[u], u)) && e > r && (e = r) - } - return e - }, vo.max = function (n, t) { - var e, r, u = -1, i = n.length; - if (1 === arguments.length) { - for (; ++u < i && !(null != (e = n[u]) && e >= e); ) - e = void 0; - for (; ++u < i; ) - null != (r = n[u]) && r > e && (e = r) - } else { - for (; ++u < i && !(null != (e = t.call(n, n[u], u)) && e >= e); ) - e = void 0; - for (; ++u < i; ) - null != (r = t.call(n, n[u], u)) && r > e && (e = r) - } - return e - }, vo.extent = function (n, t) { - var e, r, u, i = -1, o = n.length; - if (1 === arguments.length) { - for (; ++i < o && !(null != (e = u = n[i]) && e >= e); ) - e = u = void 0; - for (; ++i < o; ) - null != (r = n[i]) && (e > r && (e = r), r > u && (u = r)) - } else { - for (; ++i < o && !(null != (e = u = t.call(n, n[i], i)) && e >= e); ) - e = void 0; - for (; ++i < o; ) - null != (r = t.call(n, n[i], i)) && (e > r && (e = r), r > u && (u = r)) - } - return[e, u] - }, vo.sum = function (n, t) { - var e, r = 0, u = n.length, i = -1; - if (1 === arguments.length) - for (; ++i < u; ) - isNaN(e = +n[i]) || (r += e); - else - for (; ++i < u; ) - isNaN(e = +t.call(n, n[i], i)) || (r += e); - return r - }, vo.mean = function (t, e) { - var r, u = t.length, i = 0, o = -1, a = 0; - if (1 === arguments.length) - for (; ++o < u; ) - n(r = t[o]) && (i += (r - i) / ++a); - else - for (; ++o < u; ) - n(r = e.call(t, t[o], o)) && (i += (r - i) / ++a); - return a ? i : void 0 - }, vo.quantile = function (n, t) { - var e = (n.length - 1) * t + 1, r = Math.floor(e), u = +n[r - 1], i = e - r; - return i ? u + i * (n[r] - u) : u - }, vo.median = function (t, e) { - return arguments.length > 1 && (t = t.map(e)), t = t.filter(n), t.length ? vo.quantile(t.sort(vo.ascending), .5) : void 0 - }, vo.bisector = function (n) { - return{left: function (t, e, r, u) { - for (arguments.length < 3 && (r = 0), arguments.length < 4 && (u = t.length); u > r; ) { - var i = r + u >>> 1; - n.call(t, t[i], i) < e ? r = i + 1 : u = i - } - return r - }, right: function (t, e, r, u) { - for (arguments.length < 3 && (r = 0), arguments.length < 4 && (u = t.length); u > r; ) { - var i = r + u >>> 1; - e < n.call(t, t[i], i) ? u = i : r = i + 1 - } - return r - }} - }; - var qo = vo.bisector(function (n) { - return n - }); - vo.bisectLeft = qo.left, vo.bisect = vo.bisectRight = qo.right, vo.shuffle = function (n) { - for (var t, e, r = n.length; r; ) - e = 0 | Math.random() * r--, t = n[r], n[r] = n[e], n[e] = t; - return n - }, vo.permute = function (n, t) { - for (var e = t.length, r = new Array(e); e--; ) - r[e] = n[t[e]]; - return r - }, vo.pairs = function (n) { - for (var t, e = 0, r = n.length - 1, u = n[0], i = new Array(0 > r ? 0 : r); r > e; ) - i[e] = [t = u, u = n[++e]]; - return i - }, vo.zip = function () { - if (!(u = arguments.length)) - return[]; - for (var n = -1, e = vo.min(arguments, t), r = new Array(e); ++n < e; ) - for (var u, i = -1, o = r[n] = new Array(u); ++i < u; ) - o[i] = arguments[i][n]; - return r - }, vo.transpose = function (n) { - return vo.zip.apply(vo, n) - }, vo.keys = function (n) { - var t = []; - for (var e in n) - t.push(e); - return t - }, vo.values = function (n) { - var t = []; - for (var e in n) - t.push(n[e]); - return t - }, vo.entries = function (n) { - var t = []; - for (var e in n) - t.push({key: e, value: n[e]}); - return t - }, vo.merge = function (n) { - return Array.prototype.concat.apply([], n) - }, vo.range = function (n, t, r) { - if (arguments.length < 3 && (r = 1, arguments.length < 2 && (t = n, n = 0)), 1 / 0 === (t - n) / r) - throw new Error("infinite range"); - var u, i = [], o = e(Math.abs(r)), a = -1; - if (n *= o, t *= o, r *= o, 0 > r) - for (; (u = n + r * ++a) > t; ) - i.push(u / o); - else - for (; (u = n + r * ++a) < t; ) - i.push(u / o); - return i - }, vo.map = function (n) { - var t = new u; - if (n instanceof u) - n.forEach(function (n, e) { - t.set(n, e) - }); - else - for (var e in n) - t.set(e, n[e]); - return t - }, r(u, {has: function (n) { - return To + n in this - }, get: function (n) { - return this[To + n] - }, set: function (n, t) { - return this[To + n] = t - }, remove: function (n) { - return n = To + n, n in this && delete this[n] - }, keys: function () { - var n = []; - return this.forEach(function (t) { - n.push(t) - }), n - }, values: function () { - var n = []; - return this.forEach(function (t, e) { - n.push(e) - }), n - }, entries: function () { - var n = []; - return this.forEach(function (t, e) { - n.push({key: t, value: e}) - }), n - }, forEach: function (n) { - for (var t in this) - t.charCodeAt(0) === zo && n.call(this, t.substring(1), this[t]) - }}); - var To = "\0", zo = To.charCodeAt(0); - vo.nest = function () { - function n(t, a, c) { - if (c >= o.length) - return r ? r.call(i, a) : e ? a.sort(e) : a; - for (var l, s, f, h, g = -1, p = a.length, d = o[c++], v = new u; ++g < p; ) - (h = v.get(l = d(s = a[g]))) ? h.push(s) : v.set(l, [s]); - return t ? (s = t(), f = function (e, r) { - s.set(e, n(t, r, c)) - }) : (s = {}, f = function (e, r) { - s[e] = n(t, r, c) - }), v.forEach(f), s - } - function t(n, e) { - if (e >= o.length) - return n; - var r = [], u = a[e++]; - return n.forEach(function (n, u) { - r.push({key: n, values: t(u, e)}) - }), u ? r.sort(function (n, t) { - return u(n.key, t.key) - }) : r - } - var e, r, i = {}, o = [], a = []; - return i.map = function (t, e) { - return n(e, t, 0) - }, i.entries = function (e) { - return t(n(vo.map, e, 0), 0) - }, i.key = function (n) { - return o.push(n), i - }, i.sortKeys = function (n) { - return a[o.length - 1] = n, i - }, i.sortValues = function (n) { - return e = n, i - }, i.rollup = function (n) { - return r = n, i - }, i - }, vo.set = function (n) { - var t = new i; - if (n) - for (var e = 0, r = n.length; r > e; ++e) - t.add(n[e]); - return t - }, r(i, {has: function (n) { - return To + n in this - }, add: function (n) { - return this[To + n] = !0, n - }, remove: function (n) { - return n = To + n, n in this && delete this[n] - }, values: function () { - var n = []; - return this.forEach(function (t) { - n.push(t) - }), n - }, forEach: function (n) { - for (var t in this) - t.charCodeAt(0) === zo && n.call(this, t.substring(1)) - }}), vo.behavior = {}, vo.rebind = function (n, t) { - for (var e, r = 1, u = arguments.length; ++r < u; ) - n[e = arguments[r]] = o(n, t, t[e]); - return n - }; - var Co = ["webkit", "ms", "moz", "Moz", "o", "O"]; - vo.dispatch = function () { - for (var n = new l, t = -1, e = arguments.length; ++t < e; ) - n[arguments[t]] = s(n); - return n - }, l.prototype.on = function (n, t) { - var e = n.indexOf("."), r = ""; - if (e >= 0 && (r = n.substring(e + 1), n = n.substring(0, e)), n) - return arguments.length < 2 ? this[n].on(r) : this[n].on(r, t); - if (2 === arguments.length) { - if (null == t) - for (n in this) - this.hasOwnProperty(n) && this[n].on(r, null); - return this - } - }, vo.event = null, vo.requote = function (n) { - return n.replace(Do, "\\$&") - }; - var Do = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g, jo = {}.__proto__ ? function (n, t) { - n.__proto__ = t - } : function (n, t) { - for (var e in t) - n[e] = t[e] - }, Lo = function (n, t) { - return t.querySelector(n) - }, Ho = function (n, t) { - return t.querySelectorAll(n) - }, Fo = xo[a(xo, "matchesSelector")], Po = function (n, t) { - return Fo.call(n, t) - }; - "function" == typeof Sizzle && (Lo = function (n, t) { - return Sizzle(n, t)[0] || null - }, Ho = function (n, t) { - return Sizzle.uniqueSort(Sizzle(n, t)) - }, Po = Sizzle.matchesSelector), vo.selection = function () { - return Io - }; - var Oo = vo.selection.prototype = []; - Oo.select = function (n) { - var t, e, r, u, i = []; - n = d(n); - for (var o = -1, a = this.length; ++o < a; ) { - i.push(t = []), t.parentNode = (r = this[o]).parentNode; - for (var c = -1, l = r.length; ++c < l; ) - (u = r[c]) ? (t.push(e = n.call(u, u.__data__, c, o)), e && "__data__"in u && (e.__data__ = u.__data__)) : t.push(null) - } - return p(i) - }, Oo.selectAll = function (n) { - var t, e, r = []; - n = v(n); - for (var u = -1, i = this.length; ++u < i; ) - for (var o = this[u], a = -1, c = o.length; ++a < c; ) - (e = o[a]) && (r.push(t = yo(n.call(e, e.__data__, a, u))), t.parentNode = e); - return p(r) - }; - var Ro = {svg: "http://www.w3.org/2000/svg", xhtml: "http://www.w3.org/1999/xhtml", xlink: "http://www.w3.org/1999/xlink", xml: "http://www.w3.org/XML/1998/namespace", xmlns: "http://www.w3.org/2000/xmlns/"}; - vo.ns = {prefix: Ro, qualify: function (n) { - var t = n.indexOf(":"), e = n; - return t >= 0 && (e = n.substring(0, t), n = n.substring(t + 1)), Ro.hasOwnProperty(e) ? {space: Ro[e], local: n} : n - }}, Oo.attr = function (n, t) { - if (arguments.length < 2) { - if ("string" == typeof n) { - var e = this.node(); - return n = vo.ns.qualify(n), n.local ? e.getAttributeNS(n.space, n.local) : e.getAttribute(n) - } - for (t in n) - this.each(m(t, n[t])); - return this - } - return this.each(m(n, t)) - }, Oo.classed = function (n, t) { - if (arguments.length < 2) { - if ("string" == typeof n) { - var e = this.node(), r = (n = n.trim().split(/^|\s+/g)).length, u = -1; - if (t = e.classList) { - for (; ++u < r; ) - if (!t.contains(n[u])) - return!1 - } else - for (t = e.getAttribute("class"); ++u < r; ) - if (!M(n[u]).test(t)) - return!1; - return!0 - } - for (t in n) - this.each(x(t, n[t])); - return this - } - return this.each(x(n, t)) - }, Oo.style = function (n, t, e) { - var r = arguments.length; - if (3 > r) { - if ("string" != typeof n) { - 2 > r && (t = ""); - for (e in n) - this.each(_(e, n[e], t)); - return this - } - if (2 > r) - return bo.getComputedStyle(this.node(), null).getPropertyValue(n); - e = "" - } - return this.each(_(n, t, e)) - }, Oo.property = function (n, t) { - if (arguments.length < 2) { - if ("string" == typeof n) - return this.node()[n]; - for (t in n) - this.each(w(t, n[t])); - return this - } - return this.each(w(n, t)) - }, Oo.text = function (n) { - return arguments.length ? this.each("function" == typeof n ? function () { - var t = n.apply(this, arguments); - this.textContent = null == t ? "" : t - } : null == n ? function () { - this.textContent = "" - } : function () { - this.textContent = n - }) : this.node().textContent - }, Oo.html = function (n) { - return arguments.length ? this.each("function" == typeof n ? function () { - var t = n.apply(this, arguments); - this.innerHTML = null == t ? "" : t - } : null == n ? function () { - this.innerHTML = "" - } : function () { - this.innerHTML = n - }) : this.node().innerHTML - }, Oo.append = function (n) { - return n = S(n), this.select(function () { - return this.appendChild(n.apply(this, arguments)) - }) - }, Oo.insert = function (n, t) { - return n = S(n), t = d(t), this.select(function () { - return this.insertBefore(n.apply(this, arguments), t.apply(this, arguments)) - }) - }, Oo.remove = function () { - return this.each(function () { - var n = this.parentNode; - n && n.removeChild(this) - }) - }, Oo.data = function (n, t) { - function e(n, e) { - var r, i, o, a = n.length, f = e.length, h = Math.min(a, f), g = new Array(f), p = new Array(f), d = new Array(a); - if (t) { - var v, m = new u, y = new u, M = []; - for (r = - 1; ++r < a; ) - v = t.call(i = n[r], i.__data__, r), m.has(v) ? d[r] = i : m.set(v, i), M.push(v); - for (r = - 1; ++r < f; ) - v = t.call(e, o = e[r], r), (i = m.get(v)) ? (g[r] = i, i.__data__ = o) : y.has(v) || (p[r] = E(o)), y.set(v, o), m.remove(v); - for (r = - 1; ++r < a; ) - m.has(M[r]) && (d[r] = n[r]) - } else { - for (r = - 1; ++r < h; ) - i = n[r], o = e[r], i ? (i.__data__ = o, g[r] = i) : p[r] = E(o); - for (; f > r; ++r) - p[r] = E(e[r]); - for (; a > r; ++r) - d[r] = n[r] - } - p.update = g, p.parentNode = g.parentNode = d.parentNode = n.parentNode, c.push(p), l.push(g), s.push(d) - } - var r, i, o = -1, a = this.length; - if (!arguments.length) { - for (n = new Array(a = (r = this[0]).length); ++o < a; ) - (i = r[o]) && (n[o] = i.__data__); - return n - } - var c = q([]), l = p([]), s = p([]); - if ("function" == typeof n) - for (; ++o < a; ) - e(r = this[o], n.call(r, r.parentNode.__data__, o)); - else - for (; ++o < a; ) - e(r = this[o], n); - return l.enter = function () { - return c - }, l.exit = function () { - return s - }, l - }, Oo.datum = function (n) { - return arguments.length ? this.property("__data__", n) : this.property("__data__") - }, Oo.filter = function (n) { - var t, e, r, u = []; - "function" != typeof n && (n = k(n)); - for (var i = 0, o = this.length; o > i; i++) { - u.push(t = []), t.parentNode = (e = this[i]).parentNode; - for (var a = 0, c = e.length; c > a; a++) - (r = e[a]) && n.call(r, r.__data__, a) && t.push(r) - } - return p(u) - }, Oo.order = function () { - for (var n = -1, t = this.length; ++n < t; ) - for (var e, r = this[n], u = r.length - 1, i = r[u]; --u >= 0; ) - (e = r[u]) && (i && i !== e.nextSibling && i.parentNode.insertBefore(e, i), i = e); - return this - }, Oo.sort = function (n) { - n = A.apply(this, arguments); - for (var t = -1, e = this.length; ++t < e; ) - this[t].sort(n); - return this.order() - }, Oo.each = function (n) { - return N(this, function (t, e, r) { - n.call(t, t.__data__, e, r) - }) - }, Oo.call = function (n) { - var t = yo(arguments); - return n.apply(t[0] = this, t), this - }, Oo.empty = function () { - return!this.node() - }, Oo.node = function () { - for (var n = 0, t = this.length; t > n; n++) - for (var e = this[n], r = 0, u = e.length; u > r; r++) { - var i = e[r]; - if (i) - return i - } - return null - }, Oo.size = function () { - var n = 0; - return this.each(function () { - ++n - }), n - }; - var Yo = []; - vo.selection.enter = q, vo.selection.enter.prototype = Yo, Yo.append = Oo.append, Yo.empty = Oo.empty, Yo.node = Oo.node, Yo.call = Oo.call, Yo.size = Oo.size, Yo.select = function (n) { - for (var t, e, r, u, i, o = [], a = -1, c = this.length; ++a < c; ) { - r = (u = this[a]).update, o.push(t = []), t.parentNode = u.parentNode; - for (var l = -1, s = u.length; ++l < s; ) - (i = u[l]) ? (t.push(r[l] = e = n.call(u.parentNode, i.__data__, l, a)), e.__data__ = i.__data__) : t.push(null) - } - return p(o) - }, Yo.insert = function (n, t) { - return arguments.length < 2 && (t = T(this)), Oo.insert.call(this, n, t) - }, Oo.transition = function () { - for (var n, t, e = Fc || ++Ic, r = [], u = Pc || {time: Date.now(), ease: Cr, delay: 0, duration: 250}, i = -1, o = this.length; ++i < o; ) { - r.push(n = []); - for (var a = this[i], c = -1, l = a.length; ++c < l; ) - (t = a[c]) && Ni(t, c, e, u), n.push(t) - } - return Ei(r, e) - }, Oo.interrupt = function () { - return this.each(z) - }, vo.select = function (n) { - var t = ["string" == typeof n ? Lo(n, Mo) : n]; - return t.parentNode = xo, p([t]) - }, vo.selectAll = function (n) { - var t = yo("string" == typeof n ? Ho(n, Mo) : n); - return t.parentNode = xo, p([t]) - }; - var Io = vo.select(xo); - Oo.on = function (n, t, e) { - var r = arguments.length; - if (3 > r) { - if ("string" != typeof n) { - 2 > r && (t = !1); - for (e in n) - this.each(C(e, n[e], t)); - return this - } - if (2 > r) - return(r = this.node()["__on" + n]) && r._; - e = !1 - } - return this.each(C(n, t, e)) - }; - var Uo = vo.map({mouseenter: "mouseover", mouseleave: "mouseout"}); - Uo.forEach(function (n) { - "on" + n in Mo && Uo.remove(n) - }); - var Vo = a(xo.style, "userSelect"), Zo = 0; - vo.mouse = function (n) { - return H(n, h()) - }; - var Xo = /WebKit/.test(bo.navigator.userAgent) ? -1 : 0; - vo.touches = function (n, t) { - return arguments.length < 2 && (t = h().touches), t ? yo(t).map(function (t) { - var e = H(n, t); - return e.identifier = t.identifier, e - }) : [] - }, vo.behavior.drag = function () { - function n() { - this.on("mousedown.drag", o).on("touchstart.drag", a) - } - function t() { - return vo.event.changedTouches[0].identifier - } - function e(n, t) { - return vo.touches(n).filter(function (n) { - return n.identifier === t - })[0] - } - function r(n, t, e, r) { - return function () { - function o() { - if (!s) - return a(); - var n = t(s, g), e = n[0] - d[0], r = n[1] - d[1]; - v |= e | r, d = n, f({type: "drag", x: n[0] + c[0], y: n[1] + c[1], dx: e, dy: r}) - } - function a() { - m.on(e + "." + p, null).on(r + "." + p, null), y(v && vo.event.target === h), f({type: "dragend"}) - } - var c, l = this, s = l.parentNode, f = u.of(l, arguments), h = vo.event.target, g = n(), p = null == g ? "drag" : "drag-" + g, d = t(s, g), v = 0, m = vo.select(bo).on(e + "." + p, o).on(r + "." + p, a), y = L(); - i ? (c = i.apply(l, arguments), c = [c.x - d[0], c.y - d[1]]) : c = [0, 0], f({type: "dragstart"}) - } - } - var u = g(n, "drag", "dragstart", "dragend"), i = null, o = r(c, vo.mouse, "mousemove", "mouseup"), a = r(t, e, "touchmove", "touchend"); - return n.origin = function (t) { - return arguments.length ? (i = t, n) : i - }, vo.rebind(n, u, "on") - }; - var Bo = Math.PI, $o = 1e-6, Wo = $o * $o, Jo = Bo / 180, Go = 180 / Bo, Ko = Math.SQRT2, Qo = 2, na = 4; - vo.interpolateZoom = function (n, t) { - function e(n) { - var t = n * y; - if (m) { - var e = Y(d), o = i / (Qo * h) * (e * I(Ko * t + d) - R(d)); - return[r + o * l, u + o * s, i * e / Y(Ko * t + d)] - } - return[r + n * l, u + n * s, i * Math.exp(Ko * t)] - } - var r = n[0], u = n[1], i = n[2], o = t[0], a = t[1], c = t[2], l = o - r, s = a - u, f = l * l + s * s, h = Math.sqrt(f), g = (c * c - i * i + na * f) / (2 * i * Qo * h), p = (c * c - i * i - na * f) / (2 * c * Qo * h), d = Math.log(Math.sqrt(g * g + 1) - g), v = Math.log(Math.sqrt(p * p + 1) - p), m = v - d, y = (m || Math.log(c / i)) / Ko; - return e.duration = 1e3 * y, e - }, vo.behavior.zoom = function () { - function n(n) { - n.on(A, l).on(ra + ".zoom", h).on(N, p).on("dblclick.zoom", d).on(T, s) - } - function t(n) { - return[(n[0] - S.x) / S.k, (n[1] - S.y) / S.k] - } - function e(n) { - return[n[0] * S.k + S.x, n[1] * S.k + S.y] - } - function r(n) { - S.k = Math.max(k[0], Math.min(k[1], n)) - } - function u(n, t) { - t = e(t), S.x += n[0] - t[0], S.y += n[1] - t[1] - } - function i() { - b && b.domain(x.range().map(function (n) { - return(n - S.x) / S.k - }).map(x.invert)), w && w.domain(_.range().map(function (n) { - return(n - S.y) / S.k - }).map(_.invert)) - } - function o(n) { - n({type: "zoomstart"}) - } - function a(n) { - i(), n({type: "zoom", scale: S.k, translate: [S.x, S.y]}) - } - function c(n) { - n({type: "zoomend"}) - } - function l() { - function n() { - s = 1, u(vo.mouse(r), h), a(i) - } - function e() { - f.on(N, bo === r ? p : null).on(q, null), g(s && vo.event.target === l), c(i) - } - var r = this, i = j.of(r, arguments), l = vo.event.target, s = 0, f = vo.select(bo).on(N, n).on(q, e), h = t(vo.mouse(r)), g = L(); - z.call(r), o(i) - } - function s() { - function n() { - var n = vo.touches(d); - return p = S.k, g = {}, n.forEach(function (n) { - g[n.identifier] = t(n) - }), n - } - function e() { - var t = Date.now(), e = n(); - if (1 === e.length) { - if (500 > t - M) { - var i = e[0], o = g[i.identifier]; - r(2 * S.k), u(i, o), f(), a(v) - } - M = t - } else if (e.length > 1) { - var i = e[0], c = e[1], l = i[0] - c[0], s = i[1] - c[1]; - m = l * l + s * s - } - } - function i() { - var n = vo.touches(d), t = n[0], e = g[t.identifier]; - if (i = n[1]) { - var i, o = g[i.identifier], c = vo.event.scale; - if (null == c) { - var l = (l = i[0] - t[0]) * l + (l = i[1] - t[1]) * l; - c = m && Math.sqrt(l / m) - } - t = [(t[0] + i[0]) / 2, (t[1] + i[1]) / 2], e = [(e[0] + o[0]) / 2, (e[1] + o[1]) / 2], r(c * p) - } - M = null, u(t, e), a(v) - } - function h() { - vo.event.touches.length ? n() : (y.on(C, null).on(D, null), x.on(A, l).on(T, s), b(), c(v)) - } - var g, p, d = this, v = j.of(d, arguments), m = 0, y = vo.select(bo).on(C, i).on(D, h), x = vo.select(d).on(A, null).on(T, e), b = L(); - z.call(d), e(), o(v) - } - function h() { - var n = j.of(this, arguments); - y ? clearTimeout(y) : (z.call(this), o(n)), y = setTimeout(function () { - y = null, c(n) - }, 50), f(); - var e = m || vo.mouse(this); - v || (v = t(e)), r(Math.pow(2, .002 * ta()) * S.k), u(e, v), a(n) - } - function p() { - v = null - } - function d() { - var n = j.of(this, arguments), e = vo.mouse(this), i = t(e), l = Math.log(S.k) / Math.LN2; - o(n), r(Math.pow(2, vo.event.shiftKey ? Math.ceil(l) - 1 : Math.floor(l) + 1)), u(e, i), a(n), c(n) - } - var v, m, y, M, x, b, _, w, S = {x: 0, y: 0, k: 1}, E = [960, 500], k = ea, A = "mousedown.zoom", N = "mousemove.zoom", q = "mouseup.zoom", T = "touchstart.zoom", C = "touchmove.zoom", D = "touchend.zoom", j = g(n, "zoomstart", "zoom", "zoomend"); - return n.event = function (n) { - n.each(function () { - var n = j.of(this, arguments), t = S; - Fc ? vo.select(this).transition().each("start.zoom", function () { - S = this.__chart__ || {x: 0, y: 0, k: 1}, o(n) - }).tween("zoom:zoom", function () { - var e = E[0], r = E[1], u = e / 2, i = r / 2, o = vo.interpolateZoom([(u - S.x) / S.k, (i - S.y) / S.k, e / S.k], [(u - t.x) / t.k, (i - t.y) / t.k, e / t.k]); - return function (t) { - var r = o(t), c = e / r[2]; - this.__chart__ = S = {x: u - r[0] * c, y: i - r[1] * c, k: c}, a(n) - } - }).each("end.zoom", function () { - c(n) - }) : (this.__chart__ = S, o(n), a(n), c(n)) - }) - }, n.translate = function (t) { - return arguments.length ? (S = {x: +t[0], y: +t[1], k: S.k}, i(), n) : [S.x, S.y] - }, n.scale = function (t) { - return arguments.length ? (S = {x: S.x, y: S.y, k: +t}, i(), n) : S.k - }, n.scaleExtent = function (t) { - return arguments.length ? (k = null == t ? ea : [+t[0], +t[1]], n) : k - }, n.center = function (t) { - return arguments.length ? (m = t && [+t[0], +t[1]], n) : m - }, n.size = function (t) { - return arguments.length ? (E = t && [+t[0], +t[1]], n) : E - }, n.x = function (t) { - return arguments.length ? (b = t, x = t.copy(), S = {x: 0, y: 0, k: 1}, n) : b - }, n.y = function (t) { - return arguments.length ? (w = t, _ = t.copy(), S = {x: 0, y: 0, k: 1}, n) : w - }, vo.rebind(n, j, "on") - }; - var ta, ea = [0, 1 / 0], ra = "onwheel"in Mo ? (ta = function () { - return-vo.event.deltaY * (vo.event.deltaMode ? 120 : 1) - }, "wheel") : "onmousewheel"in Mo ? (ta = function () { - return vo.event.wheelDelta - }, "mousewheel") : (ta = function () { - return-vo.event.detail - }, "MozMousePixelScroll"); - V.prototype.toString = function () { - return this.rgb() + "" - }, vo.hsl = function (n, t, e) { - return 1 === arguments.length ? n instanceof X ? Z(n.h, n.s, n.l) : lt("" + n, st, Z) : Z(+n, +t, +e) - }; - var ua = X.prototype = new V; - ua.brighter = function (n) { - return n = Math.pow(.7, arguments.length ? n : 1), Z(this.h, this.s, this.l / n) - }, ua.darker = function (n) { - return n = Math.pow(.7, arguments.length ? n : 1), Z(this.h, this.s, n * this.l) - }, ua.rgb = function () { - return B(this.h, this.s, this.l) - }, vo.hcl = function (n, t, e) { - return 1 === arguments.length ? n instanceof W ? $(n.h, n.c, n.l) : n instanceof K ? nt(n.l, n.a, n.b) : nt((n = ft((n = vo.rgb(n)).r, n.g, n.b)).l, n.a, n.b) : $(+n, +t, +e) - }; - var ia = W.prototype = new V; - ia.brighter = function (n) { - return $(this.h, this.c, Math.min(100, this.l + oa * (arguments.length ? n : 1))) - }, ia.darker = function (n) { - return $(this.h, this.c, Math.max(0, this.l - oa * (arguments.length ? n : 1))) - }, ia.rgb = function () { - return J(this.h, this.c, this.l).rgb() - }, vo.lab = function (n, t, e) { - return 1 === arguments.length ? n instanceof K ? G(n.l, n.a, n.b) : n instanceof W ? J(n.l, n.c, n.h) : ft((n = vo.rgb(n)).r, n.g, n.b) : G(+n, +t, +e) - }; - var oa = 18, aa = .95047, ca = 1, la = 1.08883, sa = K.prototype = new V; - sa.brighter = function (n) { - return G(Math.min(100, this.l + oa * (arguments.length ? n : 1)), this.a, this.b) - }, sa.darker = function (n) { - return G(Math.max(0, this.l - oa * (arguments.length ? n : 1)), this.a, this.b) - }, sa.rgb = function () { - return Q(this.l, this.a, this.b) - }, vo.rgb = function (n, t, e) { - return 1 === arguments.length ? n instanceof at ? ot(n.r, n.g, n.b) : lt("" + n, ot, B) : ot(~~n, ~~t, ~~e) - }; - var fa = at.prototype = new V; - fa.brighter = function (n) { - n = Math.pow(.7, arguments.length ? n : 1); - var t = this.r, e = this.g, r = this.b, u = 30; - return t || e || r ? (t && u > t && (t = u), e && u > e && (e = u), r && u > r && (r = u), ot(Math.min(255, ~~(t / n)), Math.min(255, ~~(e / n)), Math.min(255, ~~(r / n)))) : ot(u, u, u) - }, fa.darker = function (n) { - return n = Math.pow(.7, arguments.length ? n : 1), ot(~~(n * this.r), ~~(n * this.g), ~~(n * this.b)) - }, fa.hsl = function () { - return st(this.r, this.g, this.b) - }, fa.toString = function () { - return"#" + ct(this.r) + ct(this.g) + ct(this.b) - }; - var ha = vo.map({aliceblue: 15792383, antiquewhite: 16444375, aqua: 65535, aquamarine: 8388564, azure: 15794175, beige: 16119260, bisque: 16770244, black: 0, blanchedalmond: 16772045, blue: 255, blueviolet: 9055202, brown: 10824234, burlywood: 14596231, cadetblue: 6266528, chartreuse: 8388352, chocolate: 13789470, coral: 16744272, cornflowerblue: 6591981, cornsilk: 16775388, crimson: 14423100, cyan: 65535, darkblue: 139, darkcyan: 35723, darkgoldenrod: 12092939, darkgray: 11119017, darkgreen: 25600, darkgrey: 11119017, darkkhaki: 12433259, darkmagenta: 9109643, darkolivegreen: 5597999, darkorange: 16747520, darkorchid: 10040012, darkred: 9109504, darksalmon: 15308410, darkseagreen: 9419919, darkslateblue: 4734347, darkslategray: 3100495, darkslategrey: 3100495, darkturquoise: 52945, darkviolet: 9699539, deeppink: 16716947, deepskyblue: 49151, dimgray: 6908265, dimgrey: 6908265, dodgerblue: 2003199, firebrick: 11674146, floralwhite: 16775920, forestgreen: 2263842, fuchsia: 16711935, gainsboro: 14474460, ghostwhite: 16316671, gold: 16766720, goldenrod: 14329120, gray: 8421504, green: 32768, greenyellow: 11403055, grey: 8421504, honeydew: 15794160, hotpink: 16738740, indianred: 13458524, indigo: 4915330, ivory: 16777200, khaki: 15787660, lavender: 15132410, lavenderblush: 16773365, lawngreen: 8190976, lemonchiffon: 16775885, lightblue: 11393254, lightcoral: 15761536, lightcyan: 14745599, lightgoldenrodyellow: 16448210, lightgray: 13882323, lightgreen: 9498256, lightgrey: 13882323, lightpink: 16758465, lightsalmon: 16752762, lightseagreen: 2142890, lightskyblue: 8900346, lightslategray: 7833753, lightslategrey: 7833753, lightsteelblue: 11584734, lightyellow: 16777184, lime: 65280, limegreen: 3329330, linen: 16445670, magenta: 16711935, maroon: 8388608, mediumaquamarine: 6737322, mediumblue: 205, mediumorchid: 12211667, mediumpurple: 9662683, mediumseagreen: 3978097, mediumslateblue: 8087790, mediumspringgreen: 64154, mediumturquoise: 4772300, mediumvioletred: 13047173, midnightblue: 1644912, mintcream: 16121850, mistyrose: 16770273, moccasin: 16770229, navajowhite: 16768685, navy: 128, oldlace: 16643558, olive: 8421376, olivedrab: 7048739, orange: 16753920, orangered: 16729344, orchid: 14315734, palegoldenrod: 15657130, palegreen: 10025880, paleturquoise: 11529966, palevioletred: 14381203, papayawhip: 16773077, peachpuff: 16767673, peru: 13468991, pink: 16761035, plum: 14524637, powderblue: 11591910, purple: 8388736, red: 16711680, rosybrown: 12357519, royalblue: 4286945, saddlebrown: 9127187, salmon: 16416882, sandybrown: 16032864, seagreen: 3050327, seashell: 16774638, sienna: 10506797, silver: 12632256, skyblue: 8900331, slateblue: 6970061, slategray: 7372944, slategrey: 7372944, snow: 16775930, springgreen: 65407, steelblue: 4620980, tan: 13808780, teal: 32896, thistle: 14204888, tomato: 16737095, turquoise: 4251856, violet: 15631086, wheat: 16113331, white: 16777215, whitesmoke: 16119285, yellow: 16776960, yellowgreen: 10145074}); - ha.forEach(function (n, t) { - ha.set(n, ut(t)) - }), vo.functor = pt, vo.xhr = vt(dt), vo.dsv = function (n, t) { - function e(n, e, i) { - arguments.length < 3 && (i = e, e = null); - var o = vo.xhr(n, t, i); - return o.row = function (n) { - return arguments.length ? o.response(null == (e = n) ? r : u(n)) : e - }, o.row(e) - } - function r(n) { - return e.parse(n.responseText) - } - function u(n) { - return function (t) { - return e.parse(t.responseText, n) - } - } - function o(t) { - return t.map(a).join(n) - } - function a(n) { - return c.test(n) ? '"' + n.replace(/\"/g, '""') + '"' : n - } - var c = new RegExp('["' + n + "\n]"), l = n.charCodeAt(0); - return e.parse = function (n, t) { - var r; - return e.parseRows(n, function (n, e) { - if (r) - return r(n, e - 1); - var u = new Function("d", "return {" + n.map(function (n, t) { - return JSON.stringify(n) + ": d[" + t + "]" - }).join(",") + "}"); - r = t ? function (n, e) { - return t(u(n), e) - } : u - }) - }, e.parseRows = function (n, t) { - function e() { - if (s >= c) - return o; - if (u) - return u = !1, i; - var t = s; - if (34 === n.charCodeAt(t)) { - for (var e = t; e++ < c; ) - if (34 === n.charCodeAt(e)) { - if (34 !== n.charCodeAt(e + 1)) - break; - ++e - } - s = e + 2; - var r = n.charCodeAt(e + 1); - return 13 === r ? (u = !0, 10 === n.charCodeAt(e + 2) && ++s) : 10 === r && (u = !0), n.substring(t + 1, e).replace(/""/g, '"') - } - for (; c > s; ) { - var r = n.charCodeAt(s++), a = 1; - if (10 === r) - u = !0; - else if (13 === r) - u = !0, 10 === n.charCodeAt(s) && (++s, ++a); - else if (r !== l) - continue; - return n.substring(t, s - a) - } - return n.substring(t) - } - for (var r, u, i = {}, o = {}, a = [], c = n.length, s = 0, f = 0; (r = e()) !== o; ) { - for (var h = []; r !== i && r !== o; ) - h.push(r), r = e(); - (!t || (h = t(h, f++))) && a.push(h) - } - return a - }, e.format = function (t) { - if (Array.isArray(t[0])) - return e.formatRows(t); - var r = new i, u = []; - return t.forEach(function (n) { - for (var t in n) - r.has(t) || u.push(r.add(t)) - }), [u.map(a).join(n)].concat(t.map(function (t) { - return u.map(function (n) { - return a(t[n]) - }).join(n) - })).join("\n") - }, e.formatRows = function (n) { - return n.map(o).join("\n") - }, e - }, vo.csv = vo.dsv(",", "text/csv"), vo.tsv = vo.dsv(" ", "text/tab-separated-values"); - var ga, pa, da, va, ma, ya = bo[a(bo, "requestAnimationFrame")] || function (n) { - setTimeout(n, 17) - }; - vo.timer = function (n, t, e) { - var r = arguments.length; - 2 > r && (t = 0), 3 > r && (e = Date.now()); - var u = e + t, i = {callback: n, time: u, next: null}; - pa ? pa.next = i : ga = i, pa = i, da || (va = clearTimeout(va), da = 1, ya(Mt)) - }, vo.timer.flush = function () { - bt(), _t() - }; - var Ma = ".", xa = ",", ba = [3, 3], _a = "$", wa = ["y", "z", "a", "f", "p", "n", "\xb5", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"].map(wt); - vo.formatPrefix = function (n, t) { - var e = 0; - return n && (0 > n && (n *= -1), t && (n = vo.round(n, St(n, t))), e = 1 + Math.floor(1e-12 + Math.log(n) / Math.LN10), e = Math.max(-24, Math.min(24, 3 * Math.floor((0 >= e ? e + 1 : e - 1) / 3)))), wa[8 + e / 3] - }, vo.round = function (n, t) { - return t ? Math.round(n * (t = Math.pow(10, t))) / t : Math.round(n) - }, vo.format = function (n) { - var t = Sa.exec(n), e = t[1] || " ", r = t[2] || ">", u = t[3] || "", i = t[4] || "", o = t[5], a = +t[6], c = t[7], l = t[8], s = t[9], f = 1, h = "", g = !1; - switch (l && (l = +l.substring(1)), (o || "0" === e && "=" === r) && (o = e = "0", r = "=", c && (a -= Math.floor((a - 1) / 4))), s) { - case"n": - c = !0, s = "g"; - break; - case"%": - f = 100, h = "%", s = "f"; - break; - case"p": - f = 100, h = "%", s = "r"; - break; - case"b": - case"o": - case"x": - case"X": - "#" === i && (i = "0" + s.toLowerCase()); - case"c": - case"d": - g = !0, l = 0; - break; - case"s": - f = -1, s = "r" - } - "#" === i ? i = "" : "$" === i && (i = _a), "r" != s || l || (s = "g"), null != l && ("g" == s ? l = Math.max(1, Math.min(21, l)) : ("e" == s || "f" == s) && (l = Math.max(0, Math.min(20, l)))), s = Ea.get(s) || Et; - var p = o && c; - return function (n) { - if (g && n % 1) - return""; - var t = 0 > n || 0 === n && 0 > 1 / n ? (n = -n, "-") : u; - if (0 > f) { - var d = vo.formatPrefix(n, l); - n = d.scale(n), h = d.symbol - } else - n *= f; - n = s(n, l); - var v = n.lastIndexOf("."), m = 0 > v ? n : n.substring(0, v), y = 0 > v ? "" : Ma + n.substring(v + 1); - !o && c && (m = ka(m)); - var M = i.length + m.length + y.length + (p ? 0 : t.length), x = a > M ? new Array(M = a - M + 1).join(e) : ""; - return p && (m = ka(x + m)), t += i, n = m + y, ("<" === r ? t + n + x : ">" === r ? x + t + n : "^" === r ? x.substring(0, M >>= 1) + t + n + x.substring(M) : t + (p ? n : x + n)) + h - } - }; - var Sa = /(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i, Ea = vo.map({b: function (n) { - return n.toString(2) - }, c: function (n) { - return String.fromCharCode(n) - }, o: function (n) { - return n.toString(8) - }, x: function (n) { - return n.toString(16) - }, X: function (n) { - return n.toString(16).toUpperCase() - }, g: function (n, t) { - return n.toPrecision(t) - }, e: function (n, t) { - return n.toExponential(t) - }, f: function (n, t) { - return n.toFixed(t) - }, r: function (n, t) { - return(n = vo.round(n, St(n, t))).toFixed(Math.max(0, Math.min(20, St(n * (1 + 1e-15), t)))) - }}), ka = dt; - if (ba) { - var Aa = ba.length; - ka = function (n) { - for (var t = n.length, e = [], r = 0, u = ba[0]; t > 0 && u > 0; ) - e.push(n.substring(t -= u, t + u)), u = ba[r = (r + 1) % Aa]; - return e.reverse().join(xa) - } - } - vo.geo = {}, kt.prototype = {s: 0, t: 0, add: function (n) { - At(n, this.t, Na), At(Na.s, this.s, this), this.s ? this.t += Na.t : this.s = Na.t - }, reset: function () { - this.s = this.t = 0 - }, valueOf: function () { - return this.s - }}; - var Na = new kt; - vo.geo.stream = function (n, t) { - n && qa.hasOwnProperty(n.type) ? qa[n.type](n, t) : Nt(n, t) - }; - var qa = {Feature: function (n, t) { - Nt(n.geometry, t) - }, FeatureCollection: function (n, t) { - for (var e = n.features, r = -1, u = e.length; ++r < u; ) - Nt(e[r].geometry, t) - }}, Ta = {Sphere: function (n, t) { - t.sphere() - }, Point: function (n, t) { - n = n.coordinates, t.point(n[0], n[1], n[2]) - }, MultiPoint: function (n, t) { - for (var e = n.coordinates, r = -1, u = e.length; ++r < u; ) - n = e[r], t.point(n[0], n[1], n[2]) - }, LineString: function (n, t) { - qt(n.coordinates, t, 0) - }, MultiLineString: function (n, t) { - for (var e = n.coordinates, r = -1, u = e.length; ++r < u; ) - qt(e[r], t, 0) - }, Polygon: function (n, t) { - Tt(n.coordinates, t) - }, MultiPolygon: function (n, t) { - for (var e = n.coordinates, r = -1, u = e.length; ++r < u; ) - Tt(e[r], t) - }, GeometryCollection: function (n, t) { - for (var e = n.geometries, r = -1, u = e.length; ++r < u; ) - Nt(e[r], t) - }}; - vo.geo.area = function (n) { - return za = 0, vo.geo.stream(n, Da), za - }; - var za, Ca = new kt, Da = {sphere: function () { - za += 4 * Bo - }, point: c, lineStart: c, lineEnd: c, polygonStart: function () { - Ca.reset(), Da.lineStart = zt - }, polygonEnd: function () { - var n = 2 * Ca; - za += 0 > n ? 4 * Bo + n : n, Da.lineStart = Da.lineEnd = Da.point = c - }}; - vo.geo.bounds = function () { - function n(n, t) { - M.push(x = [s = n, h = n]), f > t && (f = t), t > g && (g = t) - } - function t(t, e) { - var r = Ct([t * Jo, e * Jo]); - if (m) { - var u = jt(m, r), i = [u[1], -u[0], 0], o = jt(i, u); - Ft(o), o = Pt(o); - var c = t - p, l = c > 0 ? 1 : -1, d = o[0] * Go * l, v = Math.abs(c) > 180; - if (v ^ (d > l * p && l * t > d)) { - var y = o[1] * Go; - y > g && (g = y) - } else if (d = (d + 360) % 360 - 180, v ^ (d > l * p && l * t > d)) { - var y = -o[1] * Go; - f > y && (f = y) - } else - f > e && (f = e), e > g && (g = e); - v ? p > t ? a(s, t) > a(s, h) && (h = t) : a(t, h) > a(s, h) && (s = t) : h >= s ? (s > t && (s = t), t > h && (h = t)) : t > p ? a(s, t) > a(s, h) && (h = t) : a(t, h) > a(s, h) && (s = t) - } else - n(t, e); - m = r, p = t - } - function e() { - b.point = t - } - function r() { - x[0] = s, x[1] = h, b.point = n, m = null - } - function u(n, e) { - if (m) { - var r = n - p; - y += Math.abs(r) > 180 ? r + (r > 0 ? 360 : -360) : r - } else - d = n, v = e; - Da.point(n, e), t(n, e) - } - function i() { - Da.lineStart() - } - function o() { - u(d, v), Da.lineEnd(), Math.abs(y) > $o && (s = -(h = 180)), x[0] = s, x[1] = h, m = null - } - function a(n, t) { - return(t -= n) < 0 ? t + 360 : t - } - function c(n, t) { - return n[0] - t[0] - } - function l(n, t) { - return t[0] <= t[1] ? t[0] <= n && n <= t[1] : n < t[0] || t[1] < n - } - var s, f, h, g, p, d, v, m, y, M, x, b = {point: n, lineStart: e, lineEnd: r, polygonStart: function () { - b.point = u, b.lineStart = i, b.lineEnd = o, y = 0, Da.polygonStart() - }, polygonEnd: function () { - Da.polygonEnd(), b.point = n, b.lineStart = e, b.lineEnd = r, 0 > Ca ? (s = -(h = 180), f = -(g = 90)) : y > $o ? g = 90 : -$o > y && (f = -90), x[0] = s, x[1] = h - }}; - return function (n) { - g = h = -(s = f = 1 / 0), M = [], vo.geo.stream(n, b); - var t = M.length; - if (t) { - M.sort(c); - for (var e, r = 1, u = M[0], i = [u]; t > r; ++r) - e = M[r], l(e[0], u) || l(e[1], u) ? (a(u[0], e[1]) > a(u[0], u[1]) && (u[1] = e[1]), a(e[0], u[1]) > a(u[0], u[1]) && (u[0] = e[0])) : i.push(u = e); - for (var o, e, p = -1 / 0, t = i.length - 1, r = 0, u = i[t]; t >= r; u = e, ++r) - e = i[r], (o = a(u[1], e[0])) > p && (p = o, s = e[0], h = u[1]) - } - return M = x = null, 1 / 0 === s || 1 / 0 === f ? [[0 / 0, 0 / 0], [0 / 0, 0 / 0]] : [[s, f], [h, g]] - } - }(), vo.geo.centroid = function (n) { - ja = La = Ha = Fa = Pa = Oa = Ra = Ya = Ia = Ua = Va = 0, vo.geo.stream(n, Za); - var t = Ia, e = Ua, r = Va, u = t * t + e * e + r * r; - return Wo > u && (t = Oa, e = Ra, r = Ya, $o > La && (t = Ha, e = Fa, r = Pa), u = t * t + e * e + r * r, Wo > u) ? [0 / 0, 0 / 0] : [Math.atan2(e, t) * Go, O(r / Math.sqrt(u)) * Go] - }; - var ja, La, Ha, Fa, Pa, Oa, Ra, Ya, Ia, Ua, Va, Za = {sphere: c, point: Rt, lineStart: It, lineEnd: Ut, polygonStart: function () { - Za.lineStart = Vt - }, polygonEnd: function () { - Za.lineStart = It - }}, Xa = $t(Zt, Qt, te, ee), Ba = [-Bo, 0], $a = 1e9; - vo.geo.clipExtent = function () { - var n, t, e, r, u, i, o = {stream: function (n) { - return u && (u.valid = !1), u = i(n), u.valid = !0, u - }, extent: function (a) { - return arguments.length ? (i = ue(n = +a[0][0], t = +a[0][1], e = +a[1][0], r = +a[1][1]), u && (u.valid = !1, u = null), o) : [[n, t], [e, r]] - }}; - return o.extent([[0, 0], [960, 500]]) - }, (vo.geo.conicEqualArea = function () { - return ae(ce) - }).raw = ce, vo.geo.albers = function () { - return vo.geo.conicEqualArea().rotate([96, 0]).center([-.6, 38.7]).parallels([29.5, 45.5]).scale(1070) - }, vo.geo.albersUsa = function () { - function n(n) { - var i = n[0], o = n[1]; - return t = null, e(i, o), t || (r(i, o), t) || u(i, o), t - } - var t, e, r, u, i = vo.geo.albers(), o = vo.geo.conicEqualArea().rotate([154, 0]).center([-2, 58.5]).parallels([55, 65]), a = vo.geo.conicEqualArea().rotate([157, 0]).center([-3, 19.9]).parallels([8, 18]), c = {point: function (n, e) { - t = [n, e] - }}; - return n.invert = function (n) { - var t = i.scale(), e = i.translate(), r = (n[0] - e[0]) / t, u = (n[1] - e[1]) / t; - return(u >= .12 && .234 > u && r >= -.425 && -.214 > r ? o : u >= .166 && .234 > u && r >= -.214 && -.115 > r ? a : i).invert(n) - }, n.stream = function (n) { - var t = i.stream(n), e = o.stream(n), r = a.stream(n); - return{point: function (n, u) { - t.point(n, u), e.point(n, u), r.point(n, u) - }, sphere: function () { - t.sphere(), e.sphere(), r.sphere() - }, lineStart: function () { - t.lineStart(), e.lineStart(), r.lineStart() - }, lineEnd: function () { - t.lineEnd(), e.lineEnd(), r.lineEnd() - }, polygonStart: function () { - t.polygonStart(), e.polygonStart(), r.polygonStart() - }, polygonEnd: function () { - t.polygonEnd(), e.polygonEnd(), r.polygonEnd() - }} - }, n.precision = function (t) { - return arguments.length ? (i.precision(t), o.precision(t), a.precision(t), n) : i.precision() - }, n.scale = function (t) { - return arguments.length ? (i.scale(t), o.scale(.35 * t), a.scale(t), n.translate(i.translate())) : i.scale() - }, n.translate = function (t) { - if (!arguments.length) - return i.translate(); - var l = i.scale(), s = +t[0], f = +t[1]; - return e = i.translate(t).clipExtent([[s - .455 * l, f - .238 * l], [s + .455 * l, f + .238 * l]]).stream(c).point, r = o.translate([s - .307 * l, f + .201 * l]).clipExtent([[s - .425 * l + $o, f + .12 * l + $o], [s - .214 * l - $o, f + .234 * l - $o]]).stream(c).point, u = a.translate([s - .205 * l, f + .212 * l]).clipExtent([[s - .214 * l + $o, f + .166 * l + $o], [s - .115 * l - $o, f + .234 * l - $o]]).stream(c).point, n - }, n.scale(1070) - }; - var Wa, Ja, Ga, Ka, Qa, nc, tc = {point: c, lineStart: c, lineEnd: c, polygonStart: function () { - Ja = 0, tc.lineStart = le - }, polygonEnd: function () { - tc.lineStart = tc.lineEnd = tc.point = c, Wa += Math.abs(Ja / 2) - }}, ec = {point: se, lineStart: c, lineEnd: c, polygonStart: c, polygonEnd: c}, rc = {point: ge, lineStart: pe, lineEnd: de, polygonStart: function () { - rc.lineStart = ve - }, polygonEnd: function () { - rc.point = ge, rc.lineStart = pe, rc.lineEnd = de - }}; - vo.geo.transform = function (n) { - return{stream: function (t) { - var e = new Me(t); - for (var r in n) - e[r] = n[r]; - return e - }} - }, Me.prototype = {point: function (n, t) { - this.stream.point(n, t) - }, sphere: function () { - this.stream.sphere() - }, lineStart: function () { - this.stream.lineStart() - }, lineEnd: function () { - this.stream.lineEnd() - }, polygonStart: function () { - this.stream.polygonStart() - }, polygonEnd: function () { - this.stream.polygonEnd() - }}, vo.geo.path = function () { - function n(n) { - return n && ("function" == typeof a && i.pointRadius(+a.apply(this, arguments)), o && o.valid || (o = u(i)), vo.geo.stream(n, o)), i.result() - } - function t() { - return o = null, n - } - var e, r, u, i, o, a = 4.5; - return n.area = function (n) { - return Wa = 0, vo.geo.stream(n, u(tc)), Wa - }, n.centroid = function (n) { - return Ha = Fa = Pa = Oa = Ra = Ya = Ia = Ua = Va = 0, vo.geo.stream(n, u(rc)), Va ? [Ia / Va, Ua / Va] : Ya ? [Oa / Ya, Ra / Ya] : Pa ? [Ha / Pa, Fa / Pa] : [0 / 0, 0 / 0] - }, n.bounds = function (n) { - return Qa = nc = -(Ga = Ka = 1 / 0), vo.geo.stream(n, u(ec)), [[Ga, Ka], [Qa, nc]] - }, n.projection = function (n) { - return arguments.length ? (u = (e = n) ? n.stream || xe(n) : dt, t()) : e - }, n.context = function (n) { - return arguments.length ? (i = null == (r = n) ? new fe : new me(n), "function" != typeof a && i.pointRadius(a), t()) : r - }, n.pointRadius = function (t) { - return arguments.length ? (a = "function" == typeof t ? t : (i.pointRadius(+t), +t), n) : a - }, n.projection(vo.geo.albersUsa()).context(null) - }, vo.geo.projection = be, vo.geo.projectionMutator = _e, (vo.geo.equirectangular = function () { - return be(Se) - }).raw = Se.invert = Se, vo.geo.rotation = function (n) { - function t(t) { - return t = n(t[0] * Jo, t[1] * Jo), t[0] *= Go, t[1] *= Go, t - } - return n = Ee(n[0] % 360 * Jo, n[1] * Jo, n.length > 2 ? n[2] * Jo : 0), t.invert = function (t) { - return t = n.invert(t[0] * Jo, t[1] * Jo), t[0] *= Go, t[1] *= Go, t - }, t - }, vo.geo.circle = function () { - function n() { - var n = "function" == typeof r ? r.apply(this, arguments) : r, t = Ee(-n[0] * Jo, -n[1] * Jo, 0).invert, u = []; - return e(null, null, 1, {point: function (n, e) { - u.push(n = t(n, e)), n[0] *= Go, n[1] *= Go - }}), {type: "Polygon", coordinates: [u]} - } - var t, e, r = [0, 0], u = 6; - return n.origin = function (t) { - return arguments.length ? (r = t, n) : r - }, n.angle = function (r) { - return arguments.length ? (e = qe((t = +r) * Jo, u * Jo), n) : t - }, n.precision = function (r) { - return arguments.length ? (e = qe(t * Jo, (u = +r) * Jo), n) : u - }, n.angle(90) - }, vo.geo.distance = function (n, t) { - var e, r = (t[0] - n[0]) * Jo, u = n[1] * Jo, i = t[1] * Jo, o = Math.sin(r), a = Math.cos(r), c = Math.sin(u), l = Math.cos(u), s = Math.sin(i), f = Math.cos(i); - return Math.atan2(Math.sqrt((e = f * o) * e + (e = l * s - c * f * a) * e), c * s + l * f * a) - }, vo.geo.graticule = function () { - function n() { - return{type: "MultiLineString", coordinates: t()} - } - function t() { - return vo.range(Math.ceil(i / v) * v, u, v).map(h).concat(vo.range(Math.ceil(l / m) * m, c, m).map(g)).concat(vo.range(Math.ceil(r / p) * p, e, p).filter(function (n) { - return Math.abs(n % v) > $o - }).map(s)).concat(vo.range(Math.ceil(a / d) * d, o, d).filter(function (n) { - return Math.abs(n % m) > $o - }).map(f)) - } - var e, r, u, i, o, a, c, l, s, f, h, g, p = 10, d = p, v = 90, m = 360, y = 2.5; - return n.lines = function () { - return t().map(function (n) { - return{type: "LineString", coordinates: n} - }) - }, n.outline = function () { - return{type: "Polygon", coordinates: [h(i).concat(g(c).slice(1), h(u).reverse().slice(1), g(l).reverse().slice(1))]} - }, n.extent = function (t) { - return arguments.length ? n.majorExtent(t).minorExtent(t) : n.minorExtent() - }, n.majorExtent = function (t) { - return arguments.length ? (i = +t[0][0], u = +t[1][0], l = +t[0][1], c = +t[1][1], i > u && (t = i, i = u, u = t), l > c && (t = l, l = c, c = t), n.precision(y)) : [[i, l], [u, c]] - }, n.minorExtent = function (t) { - return arguments.length ? (r = +t[0][0], e = +t[1][0], a = +t[0][1], o = +t[1][1], r > e && (t = r, r = e, e = t), a > o && (t = a, a = o, o = t), n.precision(y)) : [[r, a], [e, o]] - }, n.step = function (t) { - return arguments.length ? n.majorStep(t).minorStep(t) : n.minorStep() - }, n.majorStep = function (t) { - return arguments.length ? (v = +t[0], m = +t[1], n) : [v, m] - }, n.minorStep = function (t) { - return arguments.length ? (p = +t[0], d = +t[1], n) : [p, d] - }, n.precision = function (t) { - return arguments.length ? (y = +t, s = ze(a, o, 90), f = Ce(r, e, y), h = ze(l, c, 90), g = Ce(i, u, y), n) : y - }, n.majorExtent([[-180, -90 + $o], [180, 90 - $o]]).minorExtent([[-180, -80 - $o], [180, 80 + $o]]) - }, vo.geo.greatArc = function () { - function n() { - return{type: "LineString", coordinates: [t || r.apply(this, arguments), e || u.apply(this, arguments)]} - } - var t, e, r = De, u = je; - return n.distance = function () { - return vo.geo.distance(t || r.apply(this, arguments), e || u.apply(this, arguments)) - }, n.source = function (e) { - return arguments.length ? (r = e, t = "function" == typeof e ? null : e, n) : r - }, n.target = function (t) { - return arguments.length ? (u = t, e = "function" == typeof t ? null : t, n) : u - }, n.precision = function () { - return arguments.length ? n : 0 - }, n - }, vo.geo.interpolate = function (n, t) { - return Le(n[0] * Jo, n[1] * Jo, t[0] * Jo, t[1] * Jo) - }, vo.geo.length = function (n) { - return uc = 0, vo.geo.stream(n, ic), uc - }; - var uc, ic = {sphere: c, point: c, lineStart: He, lineEnd: c, polygonStart: c, polygonEnd: c}, oc = Fe(function (n) { - return Math.sqrt(2 / (1 + n)) - }, function (n) { - return 2 * Math.asin(n / 2) - }); - (vo.geo.azimuthalEqualArea = function () { - return be(oc) - }).raw = oc; - var ac = Fe(function (n) { - var t = Math.acos(n); - return t && t / Math.sin(t) - }, dt); - (vo.geo.azimuthalEquidistant = function () { - return be(ac) - }).raw = ac, (vo.geo.conicConformal = function () { - return ae(Pe) - }).raw = Pe, (vo.geo.conicEquidistant = function () { - return ae(Oe) - }).raw = Oe; - var cc = Fe(function (n) { - return 1 / n - }, Math.atan); - (vo.geo.gnomonic = function () { - return be(cc) - }).raw = cc, Re.invert = function (n, t) { - return[n, 2 * Math.atan(Math.exp(t)) - Bo / 2] - }, (vo.geo.mercator = function () { - return Ye(Re) - }).raw = Re; - var lc = Fe(function () { - return 1 - }, Math.asin); - (vo.geo.orthographic = function () { - return be(lc) - }).raw = lc; - var sc = Fe(function (n) { - return 1 / (1 + n) - }, function (n) { - return 2 * Math.atan(n) - }); - (vo.geo.stereographic = function () { - return be(sc) - }).raw = sc, Ie.invert = function (n, t) { - return[Math.atan2(R(n), Math.cos(t)), O(Math.sin(t) / Y(n))] - }, (vo.geo.transverseMercator = function () { - return Ye(Ie) - }).raw = Ie, vo.geom = {}, vo.svg = {}, vo.svg.line = function () { - return Ue(dt) - }; - var fc = vo.map({linear: Xe, "linear-closed": Be, step: $e, "step-before": We, "step-after": Je, basis: er, "basis-open": rr, "basis-closed": ur, bundle: ir, cardinal: Qe, "cardinal-open": Ge, "cardinal-closed": Ke, monotone: fr}); - fc.forEach(function (n, t) { - t.key = n, t.closed = /-closed$/.test(n) - }); - var hc = [0, 2 / 3, 1 / 3, 0], gc = [0, 1 / 3, 2 / 3, 0], pc = [0, 1 / 6, 2 / 3, 1 / 6]; - vo.geom.hull = function (n) { - function t(n) { - if (n.length < 3) - return[]; - var t, u, i, o, a, c, l, s, f, h, g, p, d = pt(e), v = pt(r), m = n.length, y = m - 1, M = [], x = [], b = 0; - if (d === Ve && r === Ze) - t = n; - else - for (i = 0, t = []; m > i; ++i) - t.push([+d.call(this, u = n[i], i), +v.call(this, u, i)]); - for (i = 1; m > i; ++i) - (t[i][1] < t[b][1] || t[i][1] == t[b][1] && t[i][0] < t[b][0]) && (b = i); - for (i = 0; m > i; ++i) - i !== b && (c = t[i][1] - t[b][1], a = t[i][0] - t[b][0], M.push({angle: Math.atan2(c, a), index: i})); - for (M.sort(function (n, t) { - return n.angle - t.angle - }), g = M[0].angle, h = M[0].index, f = 0, i = 1; y > i; ++i) { - if (o = M[i].index, g == M[i].angle) { - if (a = t[h][0] - t[b][0], c = t[h][1] - t[b][1], l = t[o][0] - t[b][0], s = t[o][1] - t[b][1], a * a + c * c >= l * l + s * s) { - M[i].index = -1; - continue - } - M[f].index = -1 - } - g = M[i].angle, f = i, h = o - } - for (x.push(b), i = 0, o = 0; 2 > i; ++o) - M[o].index > -1 && (x.push(M[o].index), i++); - for (p = x.length; y > o; ++o) - if (!(M[o].index < 0)) { - for (; !hr(x[p - 2], x[p - 1], M[o].index, t); ) - --p; - x[p++] = M[o].index - } - var _ = []; - for (i = p - 1; i >= 0; --i) - _.push(n[x[i]]); - return _ - } - var e = Ve, r = Ze; - return arguments.length ? t(n) : (t.x = function (n) { - return arguments.length ? (e = n, t) : e - }, t.y = function (n) { - return arguments.length ? (r = n, t) : r - }, t) - }, vo.geom.polygon = function (n) { - return jo(n, dc), n - }; - var dc = vo.geom.polygon.prototype = []; - dc.area = function () { - for (var n, t = -1, e = this.length, r = this[e - 1], u = 0; ++t < e; ) - n = r, r = this[t], u += n[1] * r[0] - n[0] * r[1]; - return.5 * u - }, dc.centroid = function (n) { - var t, e, r = -1, u = this.length, i = 0, o = 0, a = this[u - 1]; - for (arguments.length || (n = - 1 / (6 * this.area())); ++r < u; ) - t = a, a = this[r], e = t[0] * a[1] - a[0] * t[1], i += (t[0] + a[0]) * e, o += (t[1] + a[1]) * e; - return[i * n, o * n] - }, dc.clip = function (n) { - for (var t, e, r, u, i, o, a = dr(n), c = -1, l = this.length - dr(this), s = this[l - 1]; ++c < l; ) { - for (t = n.slice(), n.length = 0, u = this[c], i = t[(r = t.length - a) - 1], e = - 1; ++e < r; ) - o = t[e], gr(o, s, u) ? (gr(i, s, u) || n.push(pr(i, o, s, u)), n.push(o)) : gr(i, s, u) && n.push(pr(i, o, s, u)), i = o; - a && n.push(n[0]), s = u - } - return n - }, vo.geom.delaunay = function (n) { - var t = n.map(function () { - return[] - }), e = []; - return vr(n, function (e) { - t[e.region.l.index].push(n[e.region.r.index]) - }), t.forEach(function (t, r) { - var u = n[r], i = u[0], o = u[1]; - t.forEach(function (n) { - n.angle = Math.atan2(n[0] - i, n[1] - o) - }), t.sort(function (n, t) { - return n.angle - t.angle - }); - for (var a = 0, c = t.length - 1; c > a; a++) - e.push([u, t[a], t[a + 1]]) - }), e - }, vo.geom.voronoi = function (n) { - function t(n) { - var t, i, o, a = n.map(function () { - return[] - }), c = pt(e), l = pt(r), s = n.length, f = 1e6; - if (c === Ve && l === Ze) - t = n; - else - for (t = new Array(s), o = 0; s > o; ++o) - t[o] = [+c.call(this, i = n[o], o), +l.call(this, i, o)]; - if (vr(t, function (n) { - var t, e, r, u, i, o; - 1 === n.a && n.b >= 0 ? (t = n.ep.r, e = n.ep.l) : (t = n.ep.l, e = n.ep.r), 1 === n.a ? (i = t ? t.y : -f, r = n.c - n.b * i, o = e ? e.y : f, u = n.c - n.b * o) : (r = t ? t.x : -f, i = n.c - n.a * r, u = e ? e.x : f, o = n.c - n.a * u); - var c = [r, i], l = [u, o]; - a[n.region.l.index].push(c, l), a[n.region.r.index].push(c, l) - }), a = a.map(function (n, e) { - var r = t[e][0], u = t[e][1], i = n.map(function (n) { - return Math.atan2(n[0] - r, n[1] - u) - }), o = vo.range(n.length).sort(function (n, t) { - return i[n] - i[t] - }); - return o.filter(function (n, t) { - return!t || i[n] - i[o[t - 1]] > $o - }).map(function (t) { - return n[t] - }) - }), a.forEach(function (n, e) { - var r = n.length; - if (!r) - return n.push([-f, -f], [-f, f], [f, f], [f, -f]); - if (!(r > 2)) { - var u = t[e], i = n[0], o = n[1], a = u[0], c = u[1], l = i[0], s = i[1], h = o[0], g = o[1], p = Math.abs(h - l), d = g - s; - if (Math.abs(d) < $o) { - var v = s > c ? -f : f; - n.push([-f, v], [f, v]) - } else if ($o > p) { - var m = l > a ? -f : f; - n.push([m, -f], [m, f]) - } else { - var v = (l - a) * (g - s) > (h - l) * (s - c) ? f : -f, y = Math.abs(d) - p; - Math.abs(y) < $o ? n.push([0 > d ? v : -v, v]) : (y > 0 && (v *= -1), n.push([-f, v], [f, v])) - } - } - }), u) - for (o = 0; s > o; ++o) - u.clip(a[o]); - for (o = 0; s > o; ++o) - a[o].point = n[o]; - return a - } - var e = Ve, r = Ze, u = null; - return arguments.length ? t(n) : (t.x = function (n) { - return arguments.length ? (e = n, t) : e - }, t.y = function (n) { - return arguments.length ? (r = n, t) : r - }, t.clipExtent = function (n) { - if (!arguments.length) - return u && [u[0], u[2]]; - if (null == n) - u = null; - else { - var e = +n[0][0], r = +n[0][1], i = +n[1][0], o = +n[1][1]; - u = vo.geom.polygon([[e, r], [e, o], [i, o], [i, r]]) - } - return t - }, t.size = function (n) { - return arguments.length ? t.clipExtent(n && [[0, 0], n]) : u && u[2] - }, t.links = function (n) { - var t, u, i, o = n.map(function () { - return[] - }), a = [], c = pt(e), l = pt(r), s = n.length; - if (c === Ve && l === Ze) - t = n; - else - for (t = new Array(s), i = 0; s > i; ++i) - t[i] = [+c.call(this, u = n[i], i), +l.call(this, u, i)]; - return vr(t, function (t) { - var e = t.region.l.index, r = t.region.r.index; - o[e][r] || (o[e][r] = o[r][e] = !0, a.push({source: n[e], target: n[r]})) - }), a - }, t.triangles = function (n) { - if (e === Ve && r === Ze) - return vo.geom.delaunay(n); - for (var t, u = new Array(c), i = pt(e), o = pt(r), a = -1, c = n.length; ++a < c; ) - (u[a] = [+i.call(this, t = n[a], a), +o.call(this, t, a)]).data = t; - return vo.geom.delaunay(u).map(function (n) { - return n.map(function (n) { - return n.data - }) - }) - }, t) - }; - var vc = {l: "r", r: "l"}; - vo.geom.quadtree = function (n, t, e, r, u) { - function i(n) { - function i(n, t, e, r, u, i, o, a) { - if (!isNaN(e) && !isNaN(r)) - if (n.leaf) { - var c = n.x, s = n.y; - if (null != c) - if (Math.abs(c - e) + Math.abs(s - r) < .01) - l(n, t, e, r, u, i, o, a); - else { - var f = n.point; - n.x = n.y = n.point = null, l(n, f, c, s, u, i, o, a), l(n, t, e, r, u, i, o, a) - } - else - n.x = e, n.y = r, n.point = t - } else - l(n, t, e, r, u, i, o, a) - } - function l(n, t, e, r, u, o, a, c) { - var l = .5 * (u + a), s = .5 * (o + c), f = e >= l, h = r >= s, g = (h << 1) + f; - n.leaf = !1, n = n.nodes[g] || (n.nodes[g] = Mr()), f ? u = l : a = l, h ? o = s : c = s, i(n, t, e, r, u, o, a, c) - } - var s, f, h, g, p, d, v, m, y, M = pt(a), x = pt(c); - if (null != t) - d = t, v = e, m = r, y = u; - else if (m = y = -(d = v = 1 / 0), f = [], h = [], p = n.length, o) - for (g = 0; p > g; ++g) - s = n[g], s.x < d && (d = s.x), s.y < v && (v = s.y), s.x > m && (m = s.x), s.y > y && (y = s.y), f.push(s.x), h.push(s.y); - else - for (g = 0; p > g; ++g) { - var b = +M(s = n[g], g), _ = +x(s, g); - d > b && (d = b), v > _ && (v = _), b > m && (m = b), _ > y && (y = _), f.push(b), h.push(_) - } - var w = m - d, S = y - v; - w > S ? y = v + w : m = d + S; - var E = Mr(); - if (E.add = function (n) { - i(E, n, +M(n, ++g), +x(n, g), d, v, m, y) - }, E.visit = function (n) { - xr(n, E, d, v, m, y) - }, g = -1, null == t) { - for (; ++g < p; ) - i(E, n[g], f[g], h[g], d, v, m, y); - --g - } else - n.forEach(E.add); - return f = h = n = s = null, E - } - var o, a = Ve, c = Ze; - return(o = arguments.length) ? (a = mr, c = yr, 3 === o && (u = e, r = t, e = t = 0), i(n)) : (i.x = function (n) { - return arguments.length ? (a = n, i) : a - }, i.y = function (n) { - return arguments.length ? (c = n, i) : c - }, i.extent = function (n) { - return arguments.length ? (null == n ? t = e = r = u = null : (t = +n[0][0], e = +n[0][1], r = +n[1][0], u = +n[1][1]), i) : null == t ? null : [[t, e], [r, u]] - }, i.size = function (n) { - return arguments.length ? (null == n ? t = e = r = u = null : (t = e = 0, r = +n[0], u = +n[1]), i) : null == t ? null : [r - t, u - e] - }, i) - }, vo.interpolateRgb = br, vo.interpolateObject = _r, vo.interpolateNumber = wr, vo.interpolateString = Sr; - var mc = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g; - vo.interpolate = Er, vo.interpolators = [function (n, t) { - var e = typeof t; - return("string" === e ? ha.has(t) || /^(#|rgb\(|hsl\()/.test(t) ? br : Sr : t instanceof V ? br : "object" === e ? Array.isArray(t) ? kr : _r : wr)(n, t) - }], vo.interpolateArray = kr; - var yc = function () { - return dt - }, Mc = vo.map({linear: yc, poly: Dr, quad: function () { - return Tr - }, cubic: function () { - return zr - }, sin: function () { - return jr - }, exp: function () { - return Lr - }, circle: function () { - return Hr - }, elastic: Fr, back: Pr, bounce: function () { - return Or - }}), xc = vo.map({"in": dt, out: Nr, "in-out": qr, "out-in": function (n) { - return qr(Nr(n)) - }}); - vo.ease = function (n) { - var t = n.indexOf("-"), e = t >= 0 ? n.substring(0, t) : n, r = t >= 0 ? n.substring(t + 1) : "in"; - return e = Mc.get(e) || yc, r = xc.get(r) || dt, Ar(r(e.apply(null, Array.prototype.slice.call(arguments, 1)))) - }, vo.interpolateHcl = Rr, vo.interpolateHsl = Yr, vo.interpolateLab = Ir, vo.interpolateRound = Ur, vo.transform = function (n) { - var t = Mo.createElementNS(vo.ns.prefix.svg, "g"); - return(vo.transform = function (n) { - if (null != n) { - t.setAttribute("transform", n); - var e = t.transform.baseVal.consolidate() - } - return new Vr(e ? e.matrix : bc) - })(n) - }, Vr.prototype.toString = function () { - return"translate(" + this.translate + ")rotate(" + this.rotate + ")skewX(" + this.skew + ")scale(" + this.scale + ")" - }; - var bc = {a: 1, b: 0, c: 0, d: 1, e: 0, f: 0}; - vo.interpolateTransform = $r, vo.layout = {}, vo.layout.bundle = function () { - return function (n) { - for (var t = [], e = -1, r = n.length; ++e < r; ) - t.push(Gr(n[e])); - return t - } - }, vo.layout.chord = function () { - function n() { - var n, l, f, h, g, p = {}, d = [], v = vo.range(i), m = []; - for (e = [], r = [], n = 0, h = -1; ++h < i; ) { - for (l = 0, g = - 1; ++g < i; ) - l += u[h][g]; - d.push(l), m.push(vo.range(i)), n += l - } - for (o && v.sort(function (n, t) { - return o(d[n], d[t]) - }), a && m.forEach(function (n, t) { - n.sort(function (n, e) { - return a(u[t][n], u[t][e]) - }) - }), n = (2 * Bo - s * i) / n, l = 0, h = -1; ++h < i; ) { - for (f = l, g = -1; ++g < i; ) { - var y = v[h], M = m[y][g], x = u[y][M], b = l, _ = l += x * n; - p[y + "-" + M] = {index: y, subindex: M, startAngle: b, endAngle: _, value: x} - } - r[y] = {index: y, startAngle: f, endAngle: l, value: (l - f) / n}, l += s - } - for (h = - 1; ++h < i; ) - for (g = h - 1; ++g < i; ) { - var w = p[h + "-" + g], S = p[g + "-" + h]; - (w.value || S.value) && e.push(w.value < S.value ? {source: S, target: w} : {source: w, target: S}) - } - c && t() - } - function t() { - e.sort(function (n, t) { - return c((n.source.value + n.target.value) / 2, (t.source.value + t.target.value) / 2) - }) - } - var e, r, u, i, o, a, c, l = {}, s = 0; - return l.matrix = function (n) { - return arguments.length ? (i = (u = n) && u.length, e = r = null, l) : u - }, l.padding = function (n) { - return arguments.length ? (s = n, e = r = null, l) : s - }, l.sortGroups = function (n) { - return arguments.length ? (o = n, e = r = null, l) : o - }, l.sortSubgroups = function (n) { - return arguments.length ? (a = n, e = null, l) : a - }, l.sortChords = function (n) { - return arguments.length ? (c = n, e && t(), l) : c - }, l.chords = function () { - return e || n(), e - }, l.groups = function () { - return r || n(), r - }, l - }, vo.layout.force = function () { - function n(n) { - return function (t, e, r, u) { - if (t.point !== n) { - var i = t.cx - n.x, o = t.cy - n.y, a = 1 / Math.sqrt(i * i + o * o); - if (d > (u - e) * a) { - var c = t.charge * a * a; - return n.px -= i * c, n.py -= o * c, !0 - } - if (t.point && isFinite(a)) { - var c = t.pointCharge * a * a; - n.px -= i * c, n.py -= o * c - } - } - return!t.charge - } - } - function t(n) { - n.px = vo.event.x, n.py = vo.event.y, a.resume() - } - var e, r, u, i, o, a = {}, c = vo.dispatch("start", "tick", "end"), l = [1, 1], s = .9, f = _c, h = wc, g = -30, p = .1, d = .8, v = [], m = []; - return a.tick = function () { - if ((r *= .99) < .005) - return c.end({type: "end", alpha: r = 0}), !0; - var t, e, a, f, h, d, y, M, x, b = v.length, _ = m.length; - for (e = 0; _ > e; ++e) - a = m[e], f = a.source, h = a.target, M = h.x - f.x, x = h.y - f.y, (d = M * M + x * x) && (d = r * i[e] * ((d = Math.sqrt(d)) - u[e]) / d, M *= d, x *= d, h.x -= M * (y = f.weight / (h.weight + f.weight)), h.y -= x * y, f.x += M * (y = 1 - y), f.y += x * y); - if ((y = r * p) && (M = l[0] / 2, x = l[1] / 2, e = -1, y)) - for (; ++e < b; ) - a = v[e], a.x += (M - a.x) * y, a.y += (x - a.y) * y; - if (g) - for (uu(t = vo.geom.quadtree(v), r, o), e = - 1; ++e < b; ) - (a = v[e]).fixed || t.visit(n(a)); - for (e = - 1; ++e < b; ) - a = v[e], a.fixed ? (a.x = a.px, a.y = a.py) : (a.x -= (a.px - (a.px = a.x)) * s, a.y -= (a.py - (a.py = a.y)) * s); - c.tick({type: "tick", alpha: r}) - }, a.nodes = function (n) { - return arguments.length ? (v = n, a) : v - }, a.links = function (n) { - return arguments.length ? (m = n, a) : m - }, a.size = function (n) { - return arguments.length ? (l = n, a) : l - }, a.linkDistance = function (n) { - return arguments.length ? (f = "function" == typeof n ? n : +n, a) : f - }, a.distance = a.linkDistance, a.linkStrength = function (n) { - return arguments.length ? (h = "function" == typeof n ? n : +n, a) : h - }, a.friction = function (n) { - return arguments.length ? (s = +n, a) : s - }, a.charge = function (n) { - return arguments.length ? (g = "function" == typeof n ? n : +n, a) : g - }, a.gravity = function (n) { - return arguments.length ? (p = +n, a) : p - }, a.theta = function (n) { - return arguments.length ? (d = +n, a) : d - }, a.alpha = function (n) { - return arguments.length ? (n = +n, r ? r = n > 0 ? n : 0 : n > 0 && (c.start({type: "start", alpha: r = n}), vo.timer(a.tick)), a) : r - }, a.start = function () { - function n(n, r) { - for (var u, i = t(e), o = -1, a = i.length; ++o < a; ) - if (!isNaN(u = i[o][n])) - return u; - return Math.random() * r - } - function t() { - if (!c) { - for (c = [], r = 0; p > r; ++r) - c[r] = []; - for (r = 0; d > r; ++r) { - var n = m[r]; - c[n.source.index].push(n.target), c[n.target.index].push(n.source) - } - } - return c[e] - } - var e, r, c, s, p = v.length, d = m.length, y = l[0], M = l[1]; - for (e = 0; p > e; ++e) - (s = v[e]).index = e, s.weight = 0; - for (e = 0; d > e; ++e) - s = m[e], "number" == typeof s.source && (s.source = v[s.source]), "number" == typeof s.target && (s.target = v[s.target]), ++s.source.weight, ++s.target.weight; - for (e = 0; p > e; ++e) - s = v[e], isNaN(s.x) && (s.x = n("x", y)), isNaN(s.y) && (s.y = n("y", M)), isNaN(s.px) && (s.px = s.x), isNaN(s.py) && (s.py = s.y); - if (u = [], "function" == typeof f) - for (e = 0; d > e; ++e) - u[e] = +f.call(this, m[e], e); - else - for (e = 0; d > e; ++e) - u[e] = f; - if (i = [], "function" == typeof h) - for (e = 0; d > e; ++e) - i[e] = +h.call(this, m[e], e); - else - for (e = 0; d > e; ++e) - i[e] = h; - if (o = [], "function" == typeof g) - for (e = 0; p > e; ++e) - o[e] = +g.call(this, v[e], e); - else - for (e = 0; p > e; ++e) - o[e] = g; - return a.resume() - }, a.resume = function () { - return a.alpha(.1) - }, a.stop = function () { - return a.alpha(0) - }, a.drag = function () { - return e || (e = vo.behavior.drag().origin(dt).on("dragstart.force", nu).on("drag.force", t).on("dragend.force", tu)), arguments.length ? (this.on("mouseover.force", eu).on("mouseout.force", ru).call(e), void 0) : e - }, vo.rebind(a, c, "on") - }; - var _c = 20, wc = 1; - vo.layout.hierarchy = function () { - function n(t, o, a) { - var c = u.call(e, t, o); - if (t.depth = o, a.push(t), c && (l = c.length)) { - for (var l, s, f = -1, h = t.children = [], g = 0, p = o + 1; ++f < l; ) - s = n(c[f], p, a), s.parent = t, h.push(s), g += s.value; - r && h.sort(r), i && (t.value = g) - } else - i && (t.value = +i.call(e, t, o) || 0); - return t - } - function t(n, r) { - var u = n.children, o = 0; - if (u && (a = u.length)) - for (var a, c = -1, l = r + 1; ++c < a; ) - o += t(u[c], l); - else - i && (o = +i.call(e, n, r) || 0); - return i && (n.value = o), o - } - function e(t) { - var e = []; - return n(t, 0, e), e - } - var r = cu, u = ou, i = au; - return e.sort = function (n) { - return arguments.length ? (r = n, e) : r - }, e.children = function (n) { - return arguments.length ? (u = n, e) : u - }, e.value = function (n) { - return arguments.length ? (i = n, e) : i - }, e.revalue = function (n) { - return t(n, 0), n - }, e - }, vo.layout.partition = function () { - function n(t, e, r, u) { - var i = t.children; - if (t.x = e, t.y = t.depth * u, t.dx = r, t.dy = u, i && (o = i.length)) { - var o, a, c, l = -1; - for (r = t.value?r / t.value:0; ++l < o; ) - n(a = i[l], e, c = a.value * r, u), e += c - } - } - function t(n) { - var e = n.children, r = 0; - if (e && (u = e.length)) - for (var u, i = -1; ++i < u; ) - r = Math.max(r, t(e[i])); - return 1 + r - } - function e(e, i) { - var o = r.call(this, e, i); - return n(o[0], 0, u[0], u[1] / t(o[0])), o - } - var r = vo.layout.hierarchy(), u = [1, 1]; - return e.size = function (n) { - return arguments.length ? (u = n, e) : u - }, iu(e, r) - }, vo.layout.pie = function () { - function n(i) { - var o = i.map(function (e, r) { - return+t.call(n, e, r) - }), a = +("function" == typeof r ? r.apply(this, arguments) : r), c = (("function" == typeof u ? u.apply(this, arguments) : u) - a) / vo.sum(o), l = vo.range(i.length); - null != e && l.sort(e === Sc ? function (n, t) { - return o[t] - o[n] - } : function (n, t) { - return e(i[n], i[t]) - }); - var s = []; - return l.forEach(function (n) { - var t; - s[n] = {data: i[n], value: t = o[n], startAngle: a, endAngle: a += t * c} - }), s - } - var t = Number, e = Sc, r = 0, u = 2 * Bo; - return n.value = function (e) { - return arguments.length ? (t = e, n) : t - }, n.sort = function (t) { - return arguments.length ? (e = t, n) : e - }, n.startAngle = function (t) { - return arguments.length ? (r = t, n) : r - }, n.endAngle = function (t) { - return arguments.length ? (u = t, n) : u - }, n - }; - var Sc = {}; - vo.layout.stack = function () { - function n(a, c) { - var l = a.map(function (e, r) { - return t.call(n, e, r) - }), s = l.map(function (t) { - return t.map(function (t, e) { - return[i.call(n, t, e), o.call(n, t, e)] - }) - }), f = e.call(n, s, c); - l = vo.permute(l, f), s = vo.permute(s, f); - var h, g, p, d = r.call(n, s, c), v = l.length, m = l[0].length; - for (g = 0; m > g; ++g) - for (u.call(n, l[0][g], p = d[g], s[0][g][1]), h = 1; v > h; ++h) - u.call(n, l[h][g], p += s[h - 1][g][1], s[h][g][1]); - return a - } - var t = dt, e = gu, r = pu, u = hu, i = su, o = fu; - return n.values = function (e) { - return arguments.length ? (t = e, n) : t - }, n.order = function (t) { - return arguments.length ? (e = "function" == typeof t ? t : Ec.get(t) || gu, n) : e - }, n.offset = function (t) { - return arguments.length ? (r = "function" == typeof t ? t : kc.get(t) || pu, n) : r - }, n.x = function (t) { - return arguments.length ? (i = t, n) : i - }, n.y = function (t) { - return arguments.length ? (o = t, n) : o - }, n.out = function (t) { - return arguments.length ? (u = t, n) : u - }, n - }; - var Ec = vo.map({"inside-out": function (n) { - var t, e, r = n.length, u = n.map(du), i = n.map(vu), o = vo.range(r).sort(function (n, t) { - return u[n] - u[t] - }), a = 0, c = 0, l = [], s = []; - for (t = 0; r > t; ++t) - e = o[t], c > a ? (a += i[e], l.push(e)) : (c += i[e], s.push(e)); - return s.reverse().concat(l) - }, reverse: function (n) { - return vo.range(n.length).reverse() - }, "default": gu}), kc = vo.map({silhouette: function (n) { - var t, e, r, u = n.length, i = n[0].length, o = [], a = 0, c = []; - for (e = 0; i > e; ++e) { - for (t = 0, r = 0; u > t; t++) - r += n[t][e][1]; - r > a && (a = r), o.push(r) - } - for (e = 0; i > e; ++e) - c[e] = (a - o[e]) / 2; - return c - }, wiggle: function (n) { - var t, e, r, u, i, o, a, c, l, s = n.length, f = n[0], h = f.length, g = []; - for (g[0] = c = l = 0, e = 1; h > e; ++e) { - for (t = 0, u = 0; s > t; ++t) - u += n[t][e][1]; - for (t = 0, i = 0, a = f[e][0] - f[e - 1][0]; s > t; ++t) { - for (r = 0, o = (n[t][e][1] - n[t][e - 1][1]) / (2 * a); t > r; ++r) - o += (n[r][e][1] - n[r][e - 1][1]) / a; - i += o * n[t][e][1] - } - g[e] = c -= u ? i / u * a : 0, l > c && (l = c) - } - for (e = 0; h > e; ++e) - g[e] -= l; - return g - }, expand: function (n) { - var t, e, r, u = n.length, i = n[0].length, o = 1 / u, a = []; - for (e = 0; i > e; ++e) { - for (t = 0, r = 0; u > t; t++) - r += n[t][e][1]; - if (r) - for (t = 0; u > t; t++) - n[t][e][1] /= r; - else - for (t = 0; u > t; t++) - n[t][e][1] = o - } - for (e = 0; i > e; ++e) - a[e] = 0; - return a - }, zero: pu}); - vo.layout.histogram = function () { - function n(n, i) { - for (var o, a, c = [], l = n.map(e, this), s = r.call(this, l, i), f = u.call(this, s, l, i), i = -1, h = l.length, g = f.length - 1, p = t ? 1 : 1 / h; ++i < g; ) - o = c[i] = [], o.dx = f[i + 1] - (o.x = f[i]), o.y = 0; - if (g > 0) - for (i = - 1; ++i < h; ) - a = l[i], a >= s[0] && a <= s[1] && (o = c[vo.bisect(f, a, 1, g) - 1], o.y += p, o.push(n[i])); - return c - } - var t = !0, e = Number, r = xu, u = yu; - return n.value = function (t) { - return arguments.length ? (e = t, n) : e - }, n.range = function (t) { - return arguments.length ? (r = pt(t), n) : r - }, n.bins = function (t) { - return arguments.length ? (u = "number" == typeof t ? function (n) { - return Mu(n, t) - } : pt(t), n) : u - }, n.frequency = function (e) { - return arguments.length ? (t = !!e, n) : t - }, n - }, vo.layout.tree = function () { - function n(n, i) { - function o(n, t) { - var r = n.children, u = n._tree; - if (r && (i = r.length)) { - for (var i, a, l, s = r[0], f = s, h = -1; ++h < i; ) - l = r[h], o(l, a), f = c(l, a, f), a = l; - qu(n); - var g = .5 * (s._tree.prelim + l._tree.prelim); - t ? (u.prelim = t._tree.prelim + e(n, t), u.mod = u.prelim - g) : u.prelim = g - } else - t && (u.prelim = t._tree.prelim + e(n, t)) - } - function a(n, t) { - n.x = n._tree.prelim + t; - var e = n.children; - if (e && (r = e.length)) { - var r, u = -1; - for (t += n._tree.mod; ++u < r; ) - a(e[u], t) - } - } - function c(n, t, r) { - if (t) { - for (var u, i = n, o = n, a = t, c = n.parent.children[0], l = i._tree.mod, s = o._tree.mod, f = a._tree.mod, h = c._tree.mod; a = wu(a), i = _u(i), a && i; ) - c = _u(c), o = wu(o), o._tree.ancestor = n, u = a._tree.prelim + f - i._tree.prelim - l + e(a, i), u > 0 && (Tu(zu(a, n, r), n, u), l += u, s += u), f += a._tree.mod, l += i._tree.mod, h += c._tree.mod, s += o._tree.mod; - a && !wu(o) && (o._tree.thread = a, o._tree.mod += f - s), i && !_u(c) && (c._tree.thread = i, c._tree.mod += l - h, r = n) - } - return r - } - var l = t.call(this, n, i), s = l[0]; - Nu(s, function (n, t) { - n._tree = {ancestor: n, prelim: 0, mod: 0, change: 0, shift: 0, number: t ? t._tree.number + 1 : 0} - }), o(s), a(s, -s._tree.prelim); - var f = Su(s, ku), h = Su(s, Eu), g = Su(s, Au), p = f.x - e(f, h) / 2, d = h.x + e(h, f) / 2, v = g.depth || 1; - return Nu(s, u ? function (n) { - n.x *= r[0], n.y = n.depth * r[1], delete n._tree - } : function (n) { - n.x = (n.x - p) / (d - p) * r[0], n.y = n.depth / v * r[1], delete n._tree - }), l - } - var t = vo.layout.hierarchy().sort(null).value(null), e = bu, r = [1, 1], u = !1; - return n.separation = function (t) { - return arguments.length ? (e = t, n) : e - }, n.size = function (t) { - return arguments.length ? (u = null == (r = t), n) : u ? null : r - }, n.nodeSize = function (t) { - return arguments.length ? (u = null != (r = t), n) : u ? r : null - }, iu(n, t) - }, vo.layout.pack = function () { - function n(n, i) { - var o = e.call(this, n, i), a = o[0], c = u[0], l = u[1], s = null == t ? Math.sqrt : "function" == typeof t ? t : function () { - return t - }; - if (a.x = a.y = 0, Nu(a, function (n) { - n.r = +s(n.value) - }), Nu(a, Hu), r) { - var f = r * (t ? 1 : Math.max(2 * a.r / c, 2 * a.r / l)) / 2; - Nu(a, function (n) { - n.r += f - }), Nu(a, Hu), Nu(a, function (n) { - n.r -= f - }) - } - return Ou(a, c / 2, l / 2, t ? 1 : 1 / Math.max(2 * a.r / c, 2 * a.r / l)), o - } - var t, e = vo.layout.hierarchy().sort(Cu), r = 0, u = [1, 1]; - return n.size = function (t) { - return arguments.length ? (u = t, n) : u - }, n.radius = function (e) { - return arguments.length ? (t = null == e || "function" == typeof e ? e : +e, n) : t - }, n.padding = function (t) { - return arguments.length ? (r = +t, n) : r - }, iu(n, e) - }, vo.layout.cluster = function () { - function n(n, i) { - var o, a = t.call(this, n, i), c = a[0], l = 0; - Nu(c, function (n) { - var t = n.children; - t && t.length ? (n.x = Iu(t), n.y = Yu(t)) : (n.x = o ? l += e(n, o) : 0, n.y = 0, o = n) - }); - var s = Uu(c), f = Vu(c), h = s.x - e(s, f) / 2, g = f.x + e(f, s) / 2; - return Nu(c, u ? function (n) { - n.x = (n.x - c.x) * r[0], n.y = (c.y - n.y) * r[1] - } : function (n) { - n.x = (n.x - h) / (g - h) * r[0], n.y = (1 - (c.y ? n.y / c.y : 1)) * r[1] - }), a - } - var t = vo.layout.hierarchy().sort(null).value(null), e = bu, r = [1, 1], u = !1; - return n.separation = function (t) { - return arguments.length ? (e = t, n) : e - }, n.size = function (t) { - return arguments.length ? (u = null == (r = t), n) : u ? null : r - }, n.nodeSize = function (t) { - return arguments.length ? (u = null != (r = t), n) : u ? r : null - }, iu(n, t) - }, vo.layout.treemap = function () { - function n(n, t) { - for (var e, r, u = -1, i = n.length; ++u < i; ) - r = (e = n[u]).value * (0 > t ? 0 : t), e.area = isNaN(r) || 0 >= r ? 0 : r - } - function t(e) { - var i = e.children; - if (i && i.length) { - var o, a, c, l = f(e), s = [], h = i.slice(), p = 1 / 0, d = "slice" === g ? l.dx : "dice" === g ? l.dy : "slice-dice" === g ? 1 & e.depth ? l.dy : l.dx : Math.min(l.dx, l.dy); - for (n(h, l.dx * l.dy / e.value), s.area = 0; (c = h.length) > 0; ) - s.push(o = h[c - 1]), s.area += o.area, "squarify" !== g || (a = r(s, d)) <= p ? (h.pop(), p = a) : (s.area -= s.pop().area, u(s, d, l, !1), d = Math.min(l.dx, l.dy), s.length = s.area = 0, p = 1 / 0); - s.length && (u(s, d, l, !0), s.length = s.area = 0), i.forEach(t) - } - } - function e(t) { - var r = t.children; - if (r && r.length) { - var i, o = f(t), a = r.slice(), c = []; - for (n(a, o.dx * o.dy / t.value), c.area = 0; i = a.pop(); ) - c.push(i), c.area += i.area, null != i.z && (u(c, i.z ? o.dx : o.dy, o, !a.length), c.length = c.area = 0); - r.forEach(e) - } - } - function r(n, t) { - for (var e, r = n.area, u = 0, i = 1 / 0, o = -1, a = n.length; ++o < a; ) - (e = n[o].area) && (i > e && (i = e), e > u && (u = e)); - return r *= r, t *= t, r ? Math.max(t * u * p / r, r / (t * i * p)) : 1 / 0 - } - function u(n, t, e, r) { - var u, i = -1, o = n.length, a = e.x, l = e.y, s = t ? c(n.area / t) : 0; - if (t == e.dx) { - for ((r || s > e.dy) && (s = e.dy); ++i < o; ) - u = n[i], u.x = a, u.y = l, u.dy = s, a += u.dx = Math.min(e.x + e.dx - a, s ? c(u.area / s) : 0); - u.z = !0, u.dx += e.x + e.dx - a, e.y += s, e.dy -= s - } else { - for ((r || s > e.dx) && (s = e.dx); ++i < o; ) - u = n[i], u.x = a, u.y = l, u.dx = s, l += u.dy = Math.min(e.y + e.dy - l, s ? c(u.area / s) : 0); - u.z = !1, u.dy += e.y + e.dy - l, e.x += s, e.dx -= s - } - } - function i(r) { - var u = o || a(r), i = u[0]; - return i.x = 0, i.y = 0, i.dx = l[0], i.dy = l[1], o && a.revalue(i), n([i], i.dx * i.dy / i.value), (o ? e : t)(i), h && (o = u), u - } - var o, a = vo.layout.hierarchy(), c = Math.round, l = [1, 1], s = null, f = Zu, h = !1, g = "squarify", p = .5 * (1 + Math.sqrt(5)); - return i.size = function (n) { - return arguments.length ? (l = n, i) : l - }, i.padding = function (n) { - function t(t) { - var e = n.call(i, t, t.depth); - return null == e ? Zu(t) : Xu(t, "number" == typeof e ? [e, e, e, e] : e) - } - function e(t) { - return Xu(t, n) - } - if (!arguments.length) - return s; - var r; - return f = null == (s = n) ? Zu : "function" == (r = typeof n) ? t : "number" === r ? (n = [n, n, n, n], e) : e, i - }, i.round = function (n) { - return arguments.length ? (c = n ? Math.round : Number, i) : c != Number - }, i.sticky = function (n) { - return arguments.length ? (h = n, o = null, i) : h - }, i.ratio = function (n) { - return arguments.length ? (p = n, i) : p - }, i.mode = function (n) { - return arguments.length ? (g = n + "", i) : g - }, iu(i, a) - }, vo.random = {normal: function (n, t) { - var e = arguments.length; - return 2 > e && (t = 1), 1 > e && (n = 0), function () { - var e, r, u; - do - e = 2 * Math.random() - 1, r = 2 * Math.random() - 1, u = e * e + r * r; - while (!u || u > 1); - return n + t * e * Math.sqrt(-2 * Math.log(u) / u) - } - }, logNormal: function () { - var n = vo.random.normal.apply(vo, arguments); - return function () { - return Math.exp(n()) - } - }, irwinHall: function (n) { - return function () { - for (var t = 0, e = 0; n > e; e++) - t += Math.random(); - return t / n - } - }}, vo.scale = {}; - var Ac = {floor: dt, ceil: dt}; - vo.scale.linear = function () { - return Qu([0, 1], [0, 1], Er, !1) - }, vo.scale.log = function () { - return ii(vo.scale.linear().domain([0, 1]), 10, !0, [1, 10]) - }; - var Nc = vo.format(".0e"), qc = {floor: function (n) { - return-Math.ceil(-n) - }, ceil: function (n) { - return-Math.floor(-n) - }}; - vo.scale.pow = function () { - return oi(vo.scale.linear(), 1, [0, 1]) - }, vo.scale.sqrt = function () { - return vo.scale.pow().exponent(.5) - }, vo.scale.ordinal = function () { - return ci([], {t: "range", a: [[]]}) - }, vo.scale.category10 = function () { - return vo.scale.ordinal().range(Tc) - }, vo.scale.category20 = function () { - return vo.scale.ordinal().range(zc) - }, vo.scale.category20b = function () { - return vo.scale.ordinal().range(Cc) - }, vo.scale.category20c = function () { - return vo.scale.ordinal().range(Dc) - }; - var Tc = [2062260, 16744206, 2924588, 14034728, 9725885, 9197131, 14907330, 8355711, 12369186, 1556175].map(it), zc = [2062260, 11454440, 16744206, 16759672, 2924588, 10018698, 14034728, 16750742, 9725885, 12955861, 9197131, 12885140, 14907330, 16234194, 8355711, 13092807, 12369186, 14408589, 1556175, 10410725].map(it), Cc = [3750777, 5395619, 7040719, 10264286, 6519097, 9216594, 11915115, 13556636, 9202993, 12426809, 15186514, 15190932, 8666169, 11356490, 14049643, 15177372, 8077683, 10834324, 13528509, 14589654].map(it), Dc = [3244733, 7057110, 10406625, 13032431, 15095053, 16616764, 16625259, 16634018, 3253076, 7652470, 10607003, 13101504, 7695281, 10394312, 12369372, 14342891, 6513507, 9868950, 12434877, 14277081].map(it); - vo.scale.quantile = function () { - return li([], []) - }, vo.scale.quantize = function () { - return si(0, 1, [0, 1]) - }, vo.scale.threshold = function () { - return fi([.5], [0, 1]) - }, vo.scale.identity = function () { - return hi([0, 1]) - }, vo.svg.arc = function () { - function n() { - var n = t.apply(this, arguments), i = e.apply(this, arguments), o = r.apply(this, arguments) + jc, a = u.apply(this, arguments) + jc, c = (o > a && (c = o, o = a, a = c), a - o), l = Bo > c ? "0" : "1", s = Math.cos(o), f = Math.sin(o), h = Math.cos(a), g = Math.sin(a); - return c >= Lc ? n ? "M0," + i + "A" + i + "," + i + " 0 1,1 0," + -i + "A" + i + "," + i + " 0 1,1 0," + i + "M0," + n + "A" + n + "," + n + " 0 1,0 0," + -n + "A" + n + "," + n + " 0 1,0 0," + n + "Z" : "M0," + i + "A" + i + "," + i + " 0 1,1 0," + -i + "A" + i + "," + i + " 0 1,1 0," + i + "Z" : n ? "M" + i * s + "," + i * f + "A" + i + "," + i + " 0 " + l + ",1 " + i * h + "," + i * g + "L" + n * h + "," + n * g + "A" + n + "," + n + " 0 " + l + ",0 " + n * s + "," + n * f + "Z" : "M" + i * s + "," + i * f + "A" + i + "," + i + " 0 " + l + ",1 " + i * h + "," + i * g + "L0,0" + "Z" - } - var t = gi, e = pi, r = di, u = vi; - return n.innerRadius = function (e) { - return arguments.length ? (t = pt(e), n) : t - }, n.outerRadius = function (t) { - return arguments.length ? (e = pt(t), n) : e - }, n.startAngle = function (t) { - return arguments.length ? (r = pt(t), n) : r - }, n.endAngle = function (t) { - return arguments.length ? (u = pt(t), n) : u - }, n.centroid = function () { - var n = (t.apply(this, arguments) + e.apply(this, arguments)) / 2, i = (r.apply(this, arguments) + u.apply(this, arguments)) / 2 + jc; - return[Math.cos(i) * n, Math.sin(i) * n] - }, n - }; - var jc = -Bo / 2, Lc = 2 * Bo - 1e-6; - vo.svg.line.radial = function () { - var n = Ue(mi); - return n.radius = n.x, delete n.x, n.angle = n.y, delete n.y, n - }, We.reverse = Je, Je.reverse = We, vo.svg.area = function () { - return yi(dt) - }, vo.svg.area.radial = function () { - var n = yi(mi); - return n.radius = n.x, delete n.x, n.innerRadius = n.x0, delete n.x0, n.outerRadius = n.x1, delete n.x1, n.angle = n.y, delete n.y, n.startAngle = n.y0, delete n.y0, n.endAngle = n.y1, delete n.y1, n - }, vo.svg.chord = function () { - function n(n, a) { - var c = t(this, i, n, a), l = t(this, o, n, a); - return"M" + c.p0 + r(c.r, c.p1, c.a1 - c.a0) + (e(c, l) ? u(c.r, c.p1, c.r, c.p0) : u(c.r, c.p1, l.r, l.p0) + r(l.r, l.p1, l.a1 - l.a0) + u(l.r, l.p1, c.r, c.p0)) + "Z" - } - function t(n, t, e, r) { - var u = t.call(n, e, r), i = a.call(n, u, r), o = c.call(n, u, r) + jc, s = l.call(n, u, r) + jc; - return{r: i, a0: o, a1: s, p0: [i * Math.cos(o), i * Math.sin(o)], p1: [i * Math.cos(s), i * Math.sin(s)]} - } - function e(n, t) { - return n.a0 == t.a0 && n.a1 == t.a1 - } - function r(n, t, e) { - return"A" + n + "," + n + " 0 " + +(e > Bo) + ",1 " + t - } - function u(n, t, e, r) { - return"Q 0,0 " + r - } - var i = De, o = je, a = Mi, c = di, l = vi; - return n.radius = function (t) { - return arguments.length ? (a = pt(t), n) : a - }, n.source = function (t) { - return arguments.length ? (i = pt(t), n) : i - }, n.target = function (t) { - return arguments.length ? (o = pt(t), n) : o - }, n.startAngle = function (t) { - return arguments.length ? (c = pt(t), n) : c - }, n.endAngle = function (t) { - return arguments.length ? (l = pt(t), n) : l - }, n - }, vo.svg.diagonal = function () { - function n(n, u) { - var i = t.call(this, n, u), o = e.call(this, n, u), a = (i.y + o.y) / 2, c = [i, {x: i.x, y: a}, {x: o.x, y: a}, o]; - return c = c.map(r), "M" + c[0] + "C" + c[1] + " " + c[2] + " " + c[3] - } - var t = De, e = je, r = xi; - return n.source = function (e) { - return arguments.length ? (t = pt(e), n) : t - }, n.target = function (t) { - return arguments.length ? (e = pt(t), n) : e - }, n.projection = function (t) { - return arguments.length ? (r = t, n) : r - }, n - }, vo.svg.diagonal.radial = function () { - var n = vo.svg.diagonal(), t = xi, e = n.projection; - return n.projection = function (n) { - return arguments.length ? e(bi(t = n)) : t - }, n - }, vo.svg.symbol = function () { - function n(n, r) { - return(Hc.get(t.call(this, n, r)) || Si)(e.call(this, n, r)) - } - var t = wi, e = _i; - return n.type = function (e) { - return arguments.length ? (t = pt(e), n) : t - }, n.size = function (t) { - return arguments.length ? (e = pt(t), n) : e - }, n - }; - var Hc = vo.map({circle: Si, cross: function (n) { - var t = Math.sqrt(n / 5) / 2; - return"M" + -3 * t + "," + -t + "H" + -t + "V" + -3 * t + "H" + t + "V" + -t + "H" + 3 * t + "V" + t + "H" + t + "V" + 3 * t + "H" + -t + "V" + t + "H" + -3 * t + "Z" - }, diamond: function (n) { - var t = Math.sqrt(n / (2 * Rc)), e = t * Rc; - return"M0," + -t + "L" + e + ",0" + " 0," + t + " " + -e + ",0" + "Z" - }, square: function (n) { - var t = Math.sqrt(n) / 2; - return"M" + -t + "," + -t + "L" + t + "," + -t + " " + t + "," + t + " " + -t + "," + t + "Z" - }, "triangle-down": function (n) { - var t = Math.sqrt(n / Oc), e = t * Oc / 2; - return"M0," + e + "L" + t + "," + -e + " " + -t + "," + -e + "Z" - }, "triangle-up": function (n) { - var t = Math.sqrt(n / Oc), e = t * Oc / 2; - return"M0," + -e + "L" + t + "," + e + " " + -t + "," + e + "Z" - }}); - vo.svg.symbolTypes = Hc.keys(); - var Fc, Pc, Oc = Math.sqrt(3), Rc = Math.tan(30 * Jo), Yc = [], Ic = 0; - Yc.call = Oo.call, Yc.empty = Oo.empty, Yc.node = Oo.node, Yc.size = Oo.size, vo.transition = function (n) { - return arguments.length ? Fc ? n.transition() : n : Io.transition() - }, vo.transition.prototype = Yc, Yc.select = function (n) { - var t, e, r, u = this.id, i = []; - n = d(n); - for (var o = -1, a = this.length; ++o < a; ) { - i.push(t = []); - for (var c = this[o], l = -1, s = c.length; ++l < s; ) - (r = c[l]) && (e = n.call(r, r.__data__, l, o)) ? ("__data__"in r && (e.__data__ = r.__data__), Ni(e, l, u, r.__transition__[u]), t.push(e)) : t.push(null) - } - return Ei(i, u) - }, Yc.selectAll = function (n) { - var t, e, r, u, i, o = this.id, a = []; - n = v(n); - for (var c = -1, l = this.length; ++c < l; ) - for (var s = this[c], f = -1, h = s.length; ++f < h; ) - if (r = s[f]) { - i = r.__transition__[o], e = n.call(r, r.__data__, f, c), a.push(t = []); - for (var g = -1, p = e.length; ++g < p; ) - (u = e[g]) && Ni(u, g, o, i), t.push(u) - } - return Ei(a, o) - }, Yc.filter = function (n) { - var t, e, r, u = []; - "function" != typeof n && (n = k(n)); - for (var i = 0, o = this.length; o > i; i++) { - u.push(t = []); - for (var e = this[i], a = 0, c = e.length; c > a; a++) - (r = e[a]) && n.call(r, r.__data__, a) && t.push(r) - } - return Ei(u, this.id) - }, Yc.tween = function (n, t) { - var e = this.id; - return arguments.length < 2 ? this.node().__transition__[e].tween.get(n) : N(this, null == t ? function (t) { - t.__transition__[e].tween.remove(n) - } : function (r) { - r.__transition__[e].tween.set(n, t) - }) - }, Yc.attr = function (n, t) { - function e() { - this.removeAttribute(a) - } - function r() { - this.removeAttributeNS(a.space, a.local) - } - function u(n) { - return null == n ? e : (n += "", function () { - var t, e = this.getAttribute(a); - return e !== n && (t = o(e, n), function (n) { - this.setAttribute(a, t(n)) - }) - }) - } - function i(n) { - return null == n ? r : (n += "", function () { - var t, e = this.getAttributeNS(a.space, a.local); - return e !== n && (t = o(e, n), function (n) { - this.setAttributeNS(a.space, a.local, t(n)) - }) - }) - } - if (arguments.length < 2) { - for (t in n) - this.attr(t, n[t]); - return this - } - var o = "transform" == n ? $r : Er, a = vo.ns.qualify(n); - return ki(this, "attr." + n, t, a.local ? i : u) - }, Yc.attrTween = function (n, t) { - function e(n, e) { - var r = t.call(this, n, e, this.getAttribute(u)); - return r && function (n) { - this.setAttribute(u, r(n)) - } - } - function r(n, e) { - var r = t.call(this, n, e, this.getAttributeNS(u.space, u.local)); - return r && function (n) { - this.setAttributeNS(u.space, u.local, r(n)) - } - } - var u = vo.ns.qualify(n); - return this.tween("attr." + n, u.local ? r : e) - }, Yc.style = function (n, t, e) { - function r() { - this.style.removeProperty(n) - } - function u(t) { - return null == t ? r : (t += "", function () { - var r, u = bo.getComputedStyle(this, null).getPropertyValue(n); - return u !== t && (r = Er(u, t), function (t) { - this.style.setProperty(n, r(t), e) - }) - }) - } - var i = arguments.length; - if (3 > i) { - if ("string" != typeof n) { - 2 > i && (t = ""); - for (e in n) - this.style(e, n[e], t); - return this - } - e = "" - } - return ki(this, "style." + n, t, u) - }, Yc.styleTween = function (n, t, e) { - function r(r, u) { - var i = t.call(this, r, u, bo.getComputedStyle(this, null).getPropertyValue(n)); - return i && function (t) { - this.style.setProperty(n, i(t), e) - } - } - return arguments.length < 3 && (e = ""), this.tween("style." + n, r) - }, Yc.text = function (n) { - return ki(this, "text", n, Ai) - }, Yc.remove = function () { - return this.each("end.transition", function () { - var n; - this.__transition__.count < 2 && (n = this.parentNode) && n.removeChild(this) - }) - }, Yc.ease = function (n) { - var t = this.id; - return arguments.length < 1 ? this.node().__transition__[t].ease : ("function" != typeof n && (n = vo.ease.apply(vo, arguments)), N(this, function (e) { - e.__transition__[t].ease = n - })) - }, Yc.delay = function (n) { - var t = this.id; - return N(this, "function" == typeof n ? function (e, r, u) { - e.__transition__[t].delay = +n.call(e, e.__data__, r, u) - } : (n = +n, function (e) { - e.__transition__[t].delay = n - })) - }, Yc.duration = function (n) { - var t = this.id; - return N(this, "function" == typeof n ? function (e, r, u) { - e.__transition__[t].duration = Math.max(1, n.call(e, e.__data__, r, u)) - } : (n = Math.max(1, n), function (e) { - e.__transition__[t].duration = n - })) - }, Yc.each = function (n, t) { - var e = this.id; - if (arguments.length < 2) { - var r = Pc, u = Fc; - Fc = e, N(this, function (t, r, u) { - Pc = t.__transition__[e], n.call(t, t.__data__, r, u) - }), Pc = r, Fc = u - } else - N(this, function (r) { - var u = r.__transition__[e]; - (u.event || (u.event = vo.dispatch("start", "end"))).on(n, t) - }); - return this - }, Yc.transition = function () { - for (var n, t, e, r, u = this.id, i = ++Ic, o = [], a = 0, c = this.length; c > a; a++) { - o.push(n = []); - for (var t = this[a], l = 0, s = t.length; s > l; l++) - (e = t[l]) && (r = Object.create(e.__transition__[u]), r.delay += r.duration, Ni(e, l, i, r)), n.push(e) - } - return Ei(o, i) - }, vo.svg.axis = function () { - function n(n) { - n.each(function () { - var n, l = vo.select(this), s = null == c ? e.ticks ? e.ticks.apply(e, a) : e.domain() : c, f = null == t ? e.tickFormat ? e.tickFormat.apply(e, a) : dt : t, h = l.selectAll(".tick").data(s, dt), g = h.enter().insert("g", ".domain").attr("class", "tick").style("opacity", 1e-6), p = vo.transition(h.exit()).style("opacity", 1e-6).remove(), d = vo.transition(h).style("opacity", 1), v = $u(e), m = l.selectAll(".domain").data([0]), y = (m.enter().append("path").attr("class", "domain"), vo.transition(m)), M = e.copy(), x = this.__chart__ || M; - this.__chart__ = M, g.append("line"), g.append("text"); - var b = g.select("line"), _ = d.select("line"), w = h.select("text").text(f), S = g.select("text"), E = d.select("text"); - switch (r) { - case"bottom": - n = qi, b.attr("y2", u), S.attr("y", Math.max(u, 0) + o), _.attr("x2", 0).attr("y2", u), E.attr("x", 0).attr("y", Math.max(u, 0) + o), w.attr("dy", ".71em").style("text-anchor", "middle"), y.attr("d", "M" + v[0] + "," + i + "V0H" + v[1] + "V" + i); - break; - case"top": - n = qi, b.attr("y2", -u), S.attr("y", -(Math.max(u, 0) + o)), _.attr("x2", 0).attr("y2", -u), E.attr("x", 0).attr("y", -(Math.max(u, 0) + o)), w.attr("dy", "0em").style("text-anchor", "middle"), y.attr("d", "M" + v[0] + "," + -i + "V0H" + v[1] + "V" + -i); - break; - case"left": - n = Ti, b.attr("x2", -u), S.attr("x", -(Math.max(u, 0) + o)), _.attr("x2", -u).attr("y2", 0), E.attr("x", -(Math.max(u, 0) + o)).attr("y", 0), w.attr("dy", ".32em").style("text-anchor", "end"), y.attr("d", "M" + -i + "," + v[0] + "H0V" + v[1] + "H" + -i); - break; - case"right": - n = Ti, b.attr("x2", u), S.attr("x", Math.max(u, 0) + o), _.attr("x2", u).attr("y2", 0), E.attr("x", Math.max(u, 0) + o).attr("y", 0), w.attr("dy", ".32em").style("text-anchor", "start"), y.attr("d", "M" + i + "," + v[0] + "H0V" + v[1] + "H" + i) - } - if (e.rangeBand) { - var k = M.rangeBand() / 2, A = function (n) { - return M(n) + k - }; - g.call(n, A), d.call(n, A) - } else - g.call(n, x), d.call(n, M), p.call(n, M) - }) - } - var t, e = vo.scale.linear(), r = Uc, u = 6, i = 6, o = 3, a = [10], c = null; - return n.scale = function (t) { - return arguments.length ? (e = t, n) : e - }, n.orient = function (t) { - return arguments.length ? (r = t in Vc ? t + "" : Uc, n) : r - }, n.ticks = function () { - return arguments.length ? (a = arguments, n) : a - }, n.tickValues = function (t) { - return arguments.length ? (c = t, n) : c - }, n.tickFormat = function (e) { - return arguments.length ? (t = e, n) : t - }, n.tickSize = function (t) { - var e = arguments.length; - return e ? (u = +t, i = +arguments[e - 1], n) : u - }, n.innerTickSize = function (t) { - return arguments.length ? (u = +t, n) : u - }, n.outerTickSize = function (t) { - return arguments.length ? (i = +t, n) : i - }, n.tickPadding = function (t) { - return arguments.length ? (o = +t, n) : o - }, n.tickSubdivide = function () { - return arguments.length && n - }, n - }; - var Uc = "bottom", Vc = {top: 1, right: 1, bottom: 1, left: 1}; - vo.svg.brush = function () { - function n(i) { - i.each(function () { - var i = vo.select(this).style("pointer-events", "all").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)").on("mousedown.brush", u).on("touchstart.brush", u), o = i.selectAll(".background").data([0]); - o.enter().append("rect").attr("class", "background").style("visibility", "hidden").style("cursor", "crosshair"), i.selectAll(".extent").data([0]).enter().append("rect").attr("class", "extent").style("cursor", "move"); - var a = i.selectAll(".resize").data(v, dt); - a.exit().remove(), a.enter().append("g").attr("class", function (n) { - return"resize " + n - }).style("cursor", function (n) { - return Zc[n] - }).append("rect").attr("x", function (n) { - return/[ew]$/.test(n) ? -3 : null - }).attr("y", function (n) { - return/^[ns]/.test(n) ? -3 : null - }).attr("width", 6).attr("height", 6).style("visibility", "hidden"), a.style("display", n.empty() ? "none" : null); - var s, f = vo.transition(i), h = vo.transition(o); - c && (s = $u(c), h.attr("x", s[0]).attr("width", s[1] - s[0]), e(f)), l && (s = $u(l), h.attr("y", s[0]).attr("height", s[1] - s[0]), r(f)), t(f) - }) - } - function t(n) { - n.selectAll(".resize").attr("transform", function (n) { - return"translate(" + s[+/e$/.test(n)] + "," + h[+/^s/.test(n)] + ")" - }) - } - function e(n) { - n.select(".extent").attr("x", s[0]), n.selectAll(".extent,.n>rect,.s>rect").attr("width", s[1] - s[0]) - } - function r(n) { - n.select(".extent").attr("y", h[0]), n.selectAll(".extent,.e>rect,.w>rect").attr("height", h[1] - h[0]) - } - function u() { - function u() { - var n = vo.event.changedTouches; - return n ? vo.touches(_, n)[0] : vo.mouse(_) - } - function g() { - 32 == vo.event.keyCode && (q || (x = null, z[0] -= s[1], z[1] -= h[1], q = 2), f()) - } - function v() { - 32 == vo.event.keyCode && 2 == q && (z[0] += s[1], z[1] += h[1], q = 0, f()) - } - function m() { - var n = u(), i = !1; - b && (n[0] += b[0], n[1] += b[1]), q || (vo.event.altKey ? (x || (x = [(s[0] + s[1]) / 2, (h[0] + h[1]) / 2]), z[0] = s[+(n[0] < x[0])], z[1] = h[+(n[1] < x[1])]) : x = null), A && y(n, c, 0) && (e(E), i = !0), N && y(n, l, 1) && (r(E), i = !0), i && (t(E), S({type: "brush", mode: q ? "move" : "resize"})) - } - function y(n, t, e) { - var r, u, a = $u(t), c = a[0], l = a[1], f = z[e], g = e ? h : s, v = g[1] - g[0]; - return q && (c -= f, l -= v + f), r = (e ? d : p) ? Math.max(c, Math.min(l, n[e])) : n[e], q ? u = (r += f) + v : (x && (f = Math.max(c, Math.min(l, 2 * x[e] - r))), r > f ? (u = r, r = f) : u = f), g[0] != r || g[1] != u ? (e ? o = null : i = null, g[0] = r, g[1] = u, !0) : void 0 - } - function M() { - m(), E.style("pointer-events", "all").selectAll(".resize").style("display", n.empty() ? "none" : null), vo.select("body").style("cursor", null), C.on("mousemove.brush", null).on("mouseup.brush", null).on("touchmove.brush", null).on("touchend.brush", null).on("keydown.brush", null).on("keyup.brush", null), T(), S({type: "brushend"}) - } - var x, b, _ = this, w = vo.select(vo.event.target), S = a.of(_, arguments), E = vo.select(_), k = w.datum(), A = !/^(n|s)$/.test(k) && c, N = !/^(e|w)$/.test(k) && l, q = w.classed("extent"), T = L(), z = u(), C = vo.select(bo).on("keydown.brush", g).on("keyup.brush", v); - if (vo.event.changedTouches ? C.on("touchmove.brush", m).on("touchend.brush", M) : C.on("mousemove.brush", m).on("mouseup.brush", M), E.interrupt().selectAll("*").interrupt(), q) - z[0] = s[0] - z[0], z[1] = h[0] - z[1]; - else if (k) { - var D = +/w$/.test(k), j = +/^n/.test(k); - b = [s[1 - D] - z[0], h[1 - j] - z[1]], z[0] = s[D], z[1] = h[j] - } else - vo.event.altKey && (x = z.slice()); - E.style("pointer-events", "none").selectAll(".resize").style("display", null), vo.select("body").style("cursor", w.style("cursor")), S({type: "brushstart"}), m() - } - var i, o, a = g(n, "brushstart", "brush", "brushend"), c = null, l = null, s = [0, 0], h = [0, 0], p = !0, d = !0, v = Xc[0]; - return n.event = function (n) { - n.each(function () { - var n = a.of(this, arguments), t = {x: s, y: h, i: i, j: o}, e = this.__chart__ || t; - this.__chart__ = t, Fc ? vo.select(this).transition().each("start.brush", function () { - i = e.i, o = e.j, s = e.x, h = e.y, n({type: "brushstart"}) - }).tween("brush:brush", function () { - var e = kr(s, t.x), r = kr(h, t.y); - return i = o = null, function (u) { - s = t.x = e(u), h = t.y = r(u), n({type: "brush", mode: "resize"}) - } - }).each("end.brush", function () { - i = t.i, o = t.j, n({type: "brush", mode: "resize"}), n({type: "brushend"}) - }) : (n({type: "brushstart"}), n({type: "brush", mode: "resize"}), n({type: "brushend"})) - }) - }, n.x = function (t) { - return arguments.length ? (c = t, v = Xc[!c << 1 | !l], n) : c - }, n.y = function (t) { - return arguments.length ? (l = t, v = Xc[!c << 1 | !l], n) : l - }, n.clamp = function (t) { - return arguments.length ? (c && l ? (p = !!t[0], d = !!t[1]) : c ? p = !!t : l && (d = !!t), n) : c && l ? [p, d] : c ? p : l ? d : null - }, n.extent = function (t) { - var e, r, u, a, f; - return arguments.length ? (c && (e = t[0], r = t[1], l && (e = e[0], r = r[0]), i = [e, r], c.invert && (e = c(e), r = c(r)), e > r && (f = e, e = r, r = f), (e != s[0] || r != s[1]) && (s = [e, r])), l && (u = t[0], a = t[1], c && (u = u[1], a = a[1]), o = [u, a], l.invert && (u = l(u), a = l(a)), u > a && (f = u, u = a, a = f), (u != h[0] || a != h[1]) && (h = [u, a])), n) : (c && (i ? (e = i[0], r = i[1]) : (e = s[0], r = s[1], c.invert && (e = c.invert(e), r = c.invert(r)), e > r && (f = e, e = r, r = f))), l && (o ? (u = o[0], a = o[1]) : (u = h[0], a = h[1], l.invert && (u = l.invert(u), a = l.invert(a)), u > a && (f = u, u = a, a = f))), c && l ? [[e, u], [r, a]] : c ? [e, r] : l && [u, a]) - }, n.clear = function () { - return n.empty() || (s = [0, 0], h = [0, 0], i = o = null), n - }, n.empty = function () { - return!!c && s[0] == s[1] || !!l && h[0] == h[1] - }, vo.rebind(n, a, "on") - }; - var Zc = {n: "ns-resize", e: "ew-resize", s: "ns-resize", w: "ew-resize", nw: "nwse-resize", ne: "nesw-resize", se: "nwse-resize", sw: "nesw-resize"}, Xc = [["n", "e", "s", "w", "nw", "ne", "se", "sw"], ["e", "w"], ["n", "s"], []], Bc = vo.time = {}, $c = Date, Wc = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; - zi.prototype = {getDate: function () { - return this._.getUTCDate() - }, getDay: function () { - return this._.getUTCDay() - }, getFullYear: function () { - return this._.getUTCFullYear() - }, getHours: function () { - return this._.getUTCHours() - }, getMilliseconds: function () { - return this._.getUTCMilliseconds() - }, getMinutes: function () { - return this._.getUTCMinutes() - }, getMonth: function () { - return this._.getUTCMonth() - }, getSeconds: function () { - return this._.getUTCSeconds() - }, getTime: function () { - return this._.getTime() - }, getTimezoneOffset: function () { - return 0 - }, valueOf: function () { - return this._.valueOf() - }, setDate: function () { - Jc.setUTCDate.apply(this._, arguments) - }, setDay: function () { - Jc.setUTCDay.apply(this._, arguments) - }, setFullYear: function () { - Jc.setUTCFullYear.apply(this._, arguments) - }, setHours: function () { - Jc.setUTCHours.apply(this._, arguments) - }, setMilliseconds: function () { - Jc.setUTCMilliseconds.apply(this._, arguments) - }, setMinutes: function () { - Jc.setUTCMinutes.apply(this._, arguments) - }, setMonth: function () { - Jc.setUTCMonth.apply(this._, arguments) - }, setSeconds: function () { - Jc.setUTCSeconds.apply(this._, arguments) - }, setTime: function () { - Jc.setTime.apply(this._, arguments) - }}; - var Jc = Date.prototype, Gc = "%a %b %e %X %Y", Kc = "%m/%d/%Y", Qc = "%H:%M:%S", nl = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], tl = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], el = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], rl = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; - Bc.year = Ci(function (n) { - return n = Bc.day(n), n.setMonth(0, 1), n - }, function (n, t) { - n.setFullYear(n.getFullYear() + t) - }, function (n) { - return n.getFullYear() - }), Bc.years = Bc.year.range, Bc.years.utc = Bc.year.utc.range, Bc.day = Ci(function (n) { - var t = new $c(2e3, 0); - return t.setFullYear(n.getFullYear(), n.getMonth(), n.getDate()), t - }, function (n, t) { - n.setDate(n.getDate() + t) - }, function (n) { - return n.getDate() - 1 - }), Bc.days = Bc.day.range, Bc.days.utc = Bc.day.utc.range, Bc.dayOfYear = function (n) { - var t = Bc.year(n); - return Math.floor((n - t - 6e4 * (n.getTimezoneOffset() - t.getTimezoneOffset())) / 864e5) - }, Wc.forEach(function (n, t) { - n = n.toLowerCase(), t = 7 - t; - var e = Bc[n] = Ci(function (n) { - return(n = Bc.day(n)).setDate(n.getDate() - (n.getDay() + t) % 7), n - }, function (n, t) { - n.setDate(n.getDate() + 7 * Math.floor(t)) - }, function (n) { - var e = Bc.year(n).getDay(); - return Math.floor((Bc.dayOfYear(n) + (e + t) % 7) / 7) - (e !== t) - }); - Bc[n + "s"] = e.range, Bc[n + "s"].utc = e.utc.range, Bc[n + "OfYear"] = function (n) { - var e = Bc.year(n).getDay(); - return Math.floor((Bc.dayOfYear(n) + (e + t) % 7) / 7) - } - }), Bc.week = Bc.sunday, Bc.weeks = Bc.sunday.range, Bc.weeks.utc = Bc.sunday.utc.range, Bc.weekOfYear = Bc.sundayOfYear, Bc.format = ji; - var ul = Hi(nl), il = Fi(nl), ol = Hi(tl), al = Fi(tl), cl = Hi(el), ll = Fi(el), sl = Hi(rl), fl = Fi(rl), hl = /^%/, gl = {"-": "", _: " ", 0: "0"}, pl = {a: function (n) { - return tl[n.getDay()] - }, A: function (n) { - return nl[n.getDay()] - }, b: function (n) { - return rl[n.getMonth()] - }, B: function (n) { - return el[n.getMonth()] - }, c: ji(Gc), d: function (n, t) { - return Pi(n.getDate(), t, 2) - }, e: function (n, t) { - return Pi(n.getDate(), t, 2) - }, H: function (n, t) { - return Pi(n.getHours(), t, 2) - }, I: function (n, t) { - return Pi(n.getHours() % 12 || 12, t, 2) - }, j: function (n, t) { - return Pi(1 + Bc.dayOfYear(n), t, 3) - }, L: function (n, t) { - return Pi(n.getMilliseconds(), t, 3) - }, m: function (n, t) { - return Pi(n.getMonth() + 1, t, 2) - }, M: function (n, t) { - return Pi(n.getMinutes(), t, 2) - }, p: function (n) { - return n.getHours() >= 12 ? "PM" : "AM" - }, S: function (n, t) { - return Pi(n.getSeconds(), t, 2) - }, U: function (n, t) { - return Pi(Bc.sundayOfYear(n), t, 2) - }, w: function (n) { - return n.getDay() - }, W: function (n, t) { - return Pi(Bc.mondayOfYear(n), t, 2) - }, x: ji(Kc), X: ji(Qc), y: function (n, t) { - return Pi(n.getFullYear() % 100, t, 2) - }, Y: function (n, t) { - return Pi(n.getFullYear() % 1e4, t, 4) - }, Z: oo, "%": function () { - return"%" - }}, dl = {a: Oi, A: Ri, b: Vi, B: Zi, c: Xi, d: Qi, e: Qi, H: to, I: to, j: no, L: uo, m: Ki, M: eo, p: io, S: ro, U: Ii, w: Yi, W: Ui, x: Bi, X: $i, y: Ji, Y: Wi, "%": ao}, vl = /^\s*\d+/, ml = vo.map({am: 0, pm: 1}); - ji.utc = co; - var yl = co("%Y-%m-%dT%H:%M:%S.%LZ"); - ji.iso = Date.prototype.toISOString && +new Date("2000-01-01T00:00:00.000Z") ? lo : yl, lo.parse = function (n) { - var t = new Date(n); - return isNaN(t) ? null : t - }, lo.toString = yl.toString, Bc.second = Ci(function (n) { - return new $c(1e3 * Math.floor(n / 1e3)) - }, function (n, t) { - n.setTime(n.getTime() + 1e3 * Math.floor(t)) - }, function (n) { - return n.getSeconds() - }), Bc.seconds = Bc.second.range, Bc.seconds.utc = Bc.second.utc.range, Bc.minute = Ci(function (n) { - return new $c(6e4 * Math.floor(n / 6e4)) - }, function (n, t) { - n.setTime(n.getTime() + 6e4 * Math.floor(t)) - }, function (n) { - return n.getMinutes() - }), Bc.minutes = Bc.minute.range, Bc.minutes.utc = Bc.minute.utc.range, Bc.hour = Ci(function (n) { - var t = n.getTimezoneOffset() / 60; - return new $c(36e5 * (Math.floor(n / 36e5 - t) + t)) - }, function (n, t) { - n.setTime(n.getTime() + 36e5 * Math.floor(t)) - }, function (n) { - return n.getHours() - }), Bc.hours = Bc.hour.range, Bc.hours.utc = Bc.hour.utc.range, Bc.month = Ci(function (n) { - return n = Bc.day(n), n.setDate(1), n - }, function (n, t) { - n.setMonth(n.getMonth() + t) - }, function (n) { - return n.getMonth() - }), Bc.months = Bc.month.range, Bc.months.utc = Bc.month.utc.range; - var Ml = [1e3, 5e3, 15e3, 3e4, 6e4, 3e5, 9e5, 18e5, 36e5, 108e5, 216e5, 432e5, 864e5, 1728e5, 6048e5, 2592e6, 7776e6, 31536e6], xl = [[Bc.second, 1], [Bc.second, 5], [Bc.second, 15], [Bc.second, 30], [Bc.minute, 1], [Bc.minute, 5], [Bc.minute, 15], [Bc.minute, 30], [Bc.hour, 1], [Bc.hour, 3], [Bc.hour, 6], [Bc.hour, 12], [Bc.day, 1], [Bc.day, 2], [Bc.week, 1], [Bc.month, 1], [Bc.month, 3], [Bc.year, 1]], bl = [[ji("%Y"), Zt], [ji("%B"), function (n) { - return n.getMonth() - }], [ji("%b %d"), function (n) { - return 1 != n.getDate() - }], [ji("%a %d"), function (n) { - return n.getDay() && 1 != n.getDate() - }], [ji("%I %p"), function (n) { - return n.getHours() - }], [ji("%I:%M"), function (n) { - return n.getMinutes() - }], [ji(":%S"), function (n) { - return n.getSeconds() - }], [ji(".%L"), function (n) { - return n.getMilliseconds() - }]], _l = ho(bl); - xl.year = Bc.year, Bc.scale = function () { - return so(vo.scale.linear(), xl, _l) - }; - var wl = {range: function (n, t, e) { - return vo.range(+n, +t, e).map(fo) - }}, Sl = xl.map(function (n) { - return[n[0].utc, n[1]] - }), El = [[co("%Y"), Zt], [co("%B"), function (n) { - return n.getUTCMonth() - }], [co("%b %d"), function (n) { - return 1 != n.getUTCDate() - }], [co("%a %d"), function (n) { - return n.getUTCDay() && 1 != n.getUTCDate() - }], [co("%I %p"), function (n) { - return n.getUTCHours() - }], [co("%I:%M"), function (n) { - return n.getUTCMinutes() - }], [co(":%S"), function (n) { - return n.getUTCSeconds() - }], [co(".%L"), function (n) { - return n.getUTCMilliseconds() - }]], kl = ho(El); - return Sl.year = Bc.year.utc, Bc.scale.utc = function () { - return so(vo.scale.linear(), Sl, kl) - }, vo.text = vt(function (n) { - return n.responseText - }), vo.json = function (n, t) { - return mt(n, "application/json", go, t) - }, vo.html = function (n, t) { - return mt(n, "text/html", po, t) - }, vo.xml = vt(function (n) { - return n.responseXML - }), vo -}(); \ No newline at end of file +!function(){function n(n,t){return t>n?-1:n>t?1:n>=t?0:0/0}function t(n){return null===n?0/0:+n}function e(n){return!isNaN(n)}function r(n){return{left:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)<0?r=i+1:u=i}return r},right:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)>0?u=i:r=i+1}return r}}}function u(n){return n.length}function i(n){for(var t=1;n*t%1;)t*=10;return t}function o(n,t){for(var e in t)Object.defineProperty(n.prototype,e,{value:t[e],enumerable:!1})}function a(){this._=Object.create(null)}function c(n){return(n+="")===da||n[0]===ma?ma+n:n}function l(n){return(n+="")[0]===ma?n.slice(1):n}function s(n){return c(n)in this._}function f(n){return(n=c(n))in this._&&delete this._[n]}function h(){var n=[];for(var t in this._)n.push(l(t));return n}function g(){var n=0;for(var t in this._)++n;return n}function p(){for(var n in this._)return!1;return!0}function v(){this._=Object.create(null)}function d(n,t,e){return function(){var r=e.apply(t,arguments);return r===t?n:r}}function m(n,t){if(t in n)return t;t=t.charAt(0).toUpperCase()+t.slice(1);for(var e=0,r=ya.length;r>e;++e){var u=ya[e]+t;if(u in n)return u}}function y(){}function M(){}function x(n){function t(){for(var t,r=e,u=-1,i=r.length;++ue;e++)for(var u,i=n[e],o=0,a=i.length;a>o;o++)(u=i[o])&&t(u,o,e);return n}function O(n){return xa(n,Aa),n}function Y(n){var t,e;return function(r,u,i){var o,a=n[i].update,c=a.length;for(i!=e&&(e=i,t=0),u>=t&&(t=u+1);!(o=a[t])&&++t0&&(n=n.slice(0,a));var l=Ca.get(n);return l&&(n=l,c=V),a?t?u:r:t?y:i}function Z(n,t){return function(e){var r=ta.event;ta.event=e,t[0]=this.__data__;try{n.apply(this,t)}finally{ta.event=r}}}function V(n,t){var e=Z(n,t);return function(n){var t=this,r=n.relatedTarget;r&&(r===t||8&r.compareDocumentPosition(t))||e.call(t,n)}}function X(){var n=".dragsuppress-"+ ++qa,t="click"+n,e=ta.select(oa).on("touchmove"+n,b).on("dragstart"+n,b).on("selectstart"+n,b);if(za){var r=ia.style,u=r[za];r[za]="none"}return function(i){if(e.on(n,null),za&&(r[za]=u),i){var o=function(){e.on(t,null)};e.on(t,function(){b(),o()},!0),setTimeout(o,0)}}}function $(n,t){t.changedTouches&&(t=t.changedTouches[0]);var e=n.ownerSVGElement||n;if(e.createSVGPoint){var r=e.createSVGPoint();if(0>La&&(oa.scrollX||oa.scrollY)){e=ta.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var u=e[0][0].getScreenCTM();La=!(u.f||u.e),e.remove()}return La?(r.x=t.pageX,r.y=t.pageY):(r.x=t.clientX,r.y=t.clientY),r=r.matrixTransform(n.getScreenCTM().inverse()),[r.x,r.y]}var i=n.getBoundingClientRect();return[t.clientX-i.left-n.clientLeft,t.clientY-i.top-n.clientTop]}function B(){return ta.event.changedTouches[0].identifier}function W(){return ta.event.target}function J(){return oa}function G(n){return n>0?1:0>n?-1:0}function K(n,t,e){return(t[0]-n[0])*(e[1]-n[1])-(t[1]-n[1])*(e[0]-n[0])}function Q(n){return n>1?0:-1>n?Da:Math.acos(n)}function nt(n){return n>1?ja:-1>n?-ja:Math.asin(n)}function tt(n){return((n=Math.exp(n))-1/n)/2}function et(n){return((n=Math.exp(n))+1/n)/2}function rt(n){return((n=Math.exp(2*n))-1)/(n+1)}function ut(n){return(n=Math.sin(n/2))*n}function it(){}function ot(n,t,e){return this instanceof ot?(this.h=+n,this.s=+t,void(this.l=+e)):arguments.length<2?n instanceof ot?new ot(n.h,n.s,n.l):xt(""+n,bt,ot):new ot(n,t,e)}function at(n,t,e){function r(n){return n>360?n-=360:0>n&&(n+=360),60>n?i+(o-i)*n/60:180>n?o:240>n?i+(o-i)*(240-n)/60:i}function u(n){return Math.round(255*r(n))}var i,o;return n=isNaN(n)?0:(n%=360)<0?n+360:n,t=isNaN(t)?0:0>t?0:t>1?1:t,e=0>e?0:e>1?1:e,o=.5>=e?e*(1+t):e+t-e*t,i=2*e-o,new dt(u(n+120),u(n),u(n-120))}function ct(n,t,e){return this instanceof ct?(this.h=+n,this.c=+t,void(this.l=+e)):arguments.length<2?n instanceof ct?new ct(n.h,n.c,n.l):n instanceof st?ht(n.l,n.a,n.b):ht((n=_t((n=ta.rgb(n)).r,n.g,n.b)).l,n.a,n.b):new ct(n,t,e)}function lt(n,t,e){return isNaN(n)&&(n=0),isNaN(t)&&(t=0),new st(e,Math.cos(n*=Fa)*t,Math.sin(n)*t)}function st(n,t,e){return this instanceof st?(this.l=+n,this.a=+t,void(this.b=+e)):arguments.length<2?n instanceof st?new st(n.l,n.a,n.b):n instanceof ct?lt(n.h,n.c,n.l):_t((n=dt(n)).r,n.g,n.b):new st(n,t,e)}function ft(n,t,e){var r=(n+16)/116,u=r+t/500,i=r-e/200;return u=gt(u)*Ja,r=gt(r)*Ga,i=gt(i)*Ka,new dt(vt(3.2404542*u-1.5371385*r-.4985314*i),vt(-.969266*u+1.8760108*r+.041556*i),vt(.0556434*u-.2040259*r+1.0572252*i))}function ht(n,t,e){return n>0?new ct(Math.atan2(e,t)*Ha,Math.sqrt(t*t+e*e),n):new ct(0/0,0/0,n)}function gt(n){return n>.206893034?n*n*n:(n-4/29)/7.787037}function pt(n){return n>.008856?Math.pow(n,1/3):7.787037*n+4/29}function vt(n){return Math.round(255*(.00304>=n?12.92*n:1.055*Math.pow(n,1/2.4)-.055))}function dt(n,t,e){return this instanceof dt?(this.r=~~n,this.g=~~t,void(this.b=~~e)):arguments.length<2?n instanceof dt?new dt(n.r,n.g,n.b):xt(""+n,dt,at):new dt(n,t,e)}function mt(n){return new dt(n>>16,255&n>>8,255&n)}function yt(n){return mt(n)+""}function Mt(n){return 16>n?"0"+Math.max(0,n).toString(16):Math.min(255,n).toString(16)}function xt(n,t,e){var r,u,i,o=0,a=0,c=0;if(r=/([a-z]+)\((.*)\)/i.exec(n))switch(u=r[2].split(","),r[1]){case"hsl":return e(parseFloat(u[0]),parseFloat(u[1])/100,parseFloat(u[2])/100);case"rgb":return t(St(u[0]),St(u[1]),St(u[2]))}return(i=tc.get(n))?t(i.r,i.g,i.b):(null==n||"#"!==n.charAt(0)||isNaN(i=parseInt(n.slice(1),16))||(4===n.length?(o=(3840&i)>>4,o=o>>4|o,a=240&i,a=a>>4|a,c=15&i,c=c<<4|c):7===n.length&&(o=(16711680&i)>>16,a=(65280&i)>>8,c=255&i)),t(o,a,c))}function bt(n,t,e){var r,u,i=Math.min(n/=255,t/=255,e/=255),o=Math.max(n,t,e),a=o-i,c=(o+i)/2;return a?(u=.5>c?a/(o+i):a/(2-o-i),r=n==o?(t-e)/a+(e>t?6:0):t==o?(e-n)/a+2:(n-t)/a+4,r*=60):(r=0/0,u=c>0&&1>c?0:r),new ot(r,u,c)}function _t(n,t,e){n=wt(n),t=wt(t),e=wt(e);var r=pt((.4124564*n+.3575761*t+.1804375*e)/Ja),u=pt((.2126729*n+.7151522*t+.072175*e)/Ga),i=pt((.0193339*n+.119192*t+.9503041*e)/Ka);return st(116*u-16,500*(r-u),200*(u-i))}function wt(n){return(n/=255)<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function St(n){var t=parseFloat(n);return"%"===n.charAt(n.length-1)?Math.round(2.55*t):t}function kt(n){return"function"==typeof n?n:function(){return n}}function Et(n){return n}function At(n){return function(t,e,r){return 2===arguments.length&&"function"==typeof e&&(r=e,e=null),Nt(t,e,n,r)}}function Nt(n,t,e,r){function u(){var n,t=c.status;if(!t&&zt(c)||t>=200&&300>t||304===t){try{n=e.call(i,c)}catch(r){return o.error.call(i,r),void 0}o.load.call(i,n)}else o.error.call(i,c)}var i={},o=ta.dispatch("beforesend","progress","load","error"),a={},c=new XMLHttpRequest,l=null;return!oa.XDomainRequest||"withCredentials"in c||!/^(http(s)?:)?\/\//.test(n)||(c=new XDomainRequest),"onload"in c?c.onload=c.onerror=u:c.onreadystatechange=function(){c.readyState>3&&u()},c.onprogress=function(n){var t=ta.event;ta.event=n;try{o.progress.call(i,c)}finally{ta.event=t}},i.header=function(n,t){return n=(n+"").toLowerCase(),arguments.length<2?a[n]:(null==t?delete a[n]:a[n]=t+"",i)},i.mimeType=function(n){return arguments.length?(t=null==n?null:n+"",i):t},i.responseType=function(n){return arguments.length?(l=n,i):l},i.response=function(n){return e=n,i},["get","post"].forEach(function(n){i[n]=function(){return i.send.apply(i,[n].concat(ra(arguments)))}}),i.send=function(e,r,u){if(2===arguments.length&&"function"==typeof r&&(u=r,r=null),c.open(e,n,!0),null==t||"accept"in a||(a.accept=t+",*/*"),c.setRequestHeader)for(var s in a)c.setRequestHeader(s,a[s]);return null!=t&&c.overrideMimeType&&c.overrideMimeType(t),null!=l&&(c.responseType=l),null!=u&&i.on("error",u).on("load",function(n){u(null,n)}),o.beforesend.call(i,c),c.send(null==r?null:r),i},i.abort=function(){return c.abort(),i},ta.rebind(i,o,"on"),null==r?i:i.get(Ct(r))}function Ct(n){return 1===n.length?function(t,e){n(null==t?e:null)}:n}function zt(n){var t=n.responseType;return t&&"text"!==t?n.response:n.responseText}function qt(){var n=Lt(),t=Tt()-n;t>24?(isFinite(t)&&(clearTimeout(ic),ic=setTimeout(qt,t)),uc=0):(uc=1,ac(qt))}function Lt(){var n=Date.now();for(oc=ec;oc;)n>=oc.t&&(oc.f=oc.c(n-oc.t)),oc=oc.n;return n}function Tt(){for(var n,t=ec,e=1/0;t;)t.f?t=n?n.n=t.n:ec=t.n:(t.t8?function(n){return n/e}:function(n){return n*e},symbol:n}}function Pt(n){var t=n.decimal,e=n.thousands,r=n.grouping,u=n.currency,i=r&&e?function(n,t){for(var u=n.length,i=[],o=0,a=r[0],c=0;u>0&&a>0&&(c+a+1>t&&(a=Math.max(1,t-c)),i.push(n.substring(u-=a,u+a)),!((c+=a+1)>t));)a=r[o=(o+1)%r.length];return i.reverse().join(e)}:Et;return function(n){var e=lc.exec(n),r=e[1]||" ",o=e[2]||">",a=e[3]||"-",c=e[4]||"",l=e[5],s=+e[6],f=e[7],h=e[8],g=e[9],p=1,v="",d="",m=!1,y=!0;switch(h&&(h=+h.substring(1)),(l||"0"===r&&"="===o)&&(l=r="0",o="="),g){case"n":f=!0,g="g";break;case"%":p=100,d="%",g="f";break;case"p":p=100,d="%",g="r";break;case"b":case"o":case"x":case"X":"#"===c&&(v="0"+g.toLowerCase());case"c":y=!1;case"d":m=!0,h=0;break;case"s":p=-1,g="r"}"$"===c&&(v=u[0],d=u[1]),"r"!=g||h||(g="g"),null!=h&&("g"==g?h=Math.max(1,Math.min(21,h)):("e"==g||"f"==g)&&(h=Math.max(0,Math.min(20,h)))),g=sc.get(g)||Ut;var M=l&&f;return function(n){var e=d;if(m&&n%1)return"";var u=0>n||0===n&&0>1/n?(n=-n,"-"):"-"===a?"":a;if(0>p){var c=ta.formatPrefix(n,h);n=c.scale(n),e=c.symbol+d}else n*=p;n=g(n,h);var x,b,_=n.lastIndexOf(".");if(0>_){var w=y?n.lastIndexOf("e"):-1;0>w?(x=n,b=""):(x=n.substring(0,w),b=n.substring(w))}else x=n.substring(0,_),b=t+n.substring(_+1);!l&&f&&(x=i(x,1/0));var S=v.length+x.length+b.length+(M?0:u.length),k=s>S?new Array(S=s-S+1).join(r):"";return M&&(x=i(k+x,k.length?s-b.length:1/0)),u+=v,n=x+b,("<"===o?u+n+k:">"===o?k+u+n:"^"===o?k.substring(0,S>>=1)+u+n+k.substring(S):u+(M?n:k+n))+e}}}function Ut(n){return n+""}function jt(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function Ft(n,t,e){function r(t){var e=n(t),r=i(e,1);return r-t>t-e?e:r}function u(e){return t(e=n(new hc(e-1)),1),e}function i(n,e){return t(n=new hc(+n),e),n}function o(n,r,i){var o=u(n),a=[];if(i>1)for(;r>o;)e(o)%i||a.push(new Date(+o)),t(o,1);else for(;r>o;)a.push(new Date(+o)),t(o,1);return a}function a(n,t,e){try{hc=jt;var r=new jt;return r._=n,o(r,t,e)}finally{hc=Date}}n.floor=n,n.round=r,n.ceil=u,n.offset=i,n.range=o;var c=n.utc=Ht(n);return c.floor=c,c.round=Ht(r),c.ceil=Ht(u),c.offset=Ht(i),c.range=a,n}function Ht(n){return function(t,e){try{hc=jt;var r=new jt;return r._=t,n(r,e)._}finally{hc=Date}}}function Ot(n){function t(n){function t(t){for(var e,u,i,o=[],a=-1,c=0;++aa;){if(r>=l)return-1;if(u=t.charCodeAt(a++),37===u){if(o=t.charAt(a++),i=C[o in pc?t.charAt(a++):o],!i||(r=i(n,e,r))<0)return-1}else if(u!=e.charCodeAt(r++))return-1}return r}function r(n,t,e){_.lastIndex=0;var r=_.exec(t.slice(e));return r?(n.w=w.get(r[0].toLowerCase()),e+r[0].length):-1}function u(n,t,e){x.lastIndex=0;var r=x.exec(t.slice(e));return r?(n.w=b.get(r[0].toLowerCase()),e+r[0].length):-1}function i(n,t,e){E.lastIndex=0;var r=E.exec(t.slice(e));return r?(n.m=A.get(r[0].toLowerCase()),e+r[0].length):-1}function o(n,t,e){S.lastIndex=0;var r=S.exec(t.slice(e));return r?(n.m=k.get(r[0].toLowerCase()),e+r[0].length):-1}function a(n,t,r){return e(n,N.c.toString(),t,r)}function c(n,t,r){return e(n,N.x.toString(),t,r)}function l(n,t,r){return e(n,N.X.toString(),t,r)}function s(n,t,e){var r=M.get(t.slice(e,e+=2).toLowerCase());return null==r?-1:(n.p=r,e)}var f=n.dateTime,h=n.date,g=n.time,p=n.periods,v=n.days,d=n.shortDays,m=n.months,y=n.shortMonths;t.utc=function(n){function e(n){try{hc=jt;var t=new hc;return t._=n,r(t)}finally{hc=Date}}var r=t(n);return e.parse=function(n){try{hc=jt;var t=r.parse(n);return t&&t._}finally{hc=Date}},e.toString=r.toString,e},t.multi=t.utc.multi=ae;var M=ta.map(),x=It(v),b=Zt(v),_=It(d),w=Zt(d),S=It(m),k=Zt(m),E=It(y),A=Zt(y);p.forEach(function(n,t){M.set(n.toLowerCase(),t)});var N={a:function(n){return d[n.getDay()]},A:function(n){return v[n.getDay()]},b:function(n){return y[n.getMonth()]},B:function(n){return m[n.getMonth()]},c:t(f),d:function(n,t){return Yt(n.getDate(),t,2)},e:function(n,t){return Yt(n.getDate(),t,2)},H:function(n,t){return Yt(n.getHours(),t,2)},I:function(n,t){return Yt(n.getHours()%12||12,t,2)},j:function(n,t){return Yt(1+fc.dayOfYear(n),t,3)},L:function(n,t){return Yt(n.getMilliseconds(),t,3)},m:function(n,t){return Yt(n.getMonth()+1,t,2)},M:function(n,t){return Yt(n.getMinutes(),t,2)},p:function(n){return p[+(n.getHours()>=12)]},S:function(n,t){return Yt(n.getSeconds(),t,2)},U:function(n,t){return Yt(fc.sundayOfYear(n),t,2)},w:function(n){return n.getDay()},W:function(n,t){return Yt(fc.mondayOfYear(n),t,2)},x:t(h),X:t(g),y:function(n,t){return Yt(n.getFullYear()%100,t,2)},Y:function(n,t){return Yt(n.getFullYear()%1e4,t,4)},Z:ie,"%":function(){return"%"}},C={a:r,A:u,b:i,B:o,c:a,d:Qt,e:Qt,H:te,I:te,j:ne,L:ue,m:Kt,M:ee,p:s,S:re,U:Xt,w:Vt,W:$t,x:c,X:l,y:Wt,Y:Bt,Z:Jt,"%":oe};return t}function Yt(n,t,e){var r=0>n?"-":"",u=(r?-n:n)+"",i=u.length;return r+(e>i?new Array(e-i+1).join(t)+u:u)}function It(n){return new RegExp("^(?:"+n.map(ta.requote).join("|")+")","i")}function Zt(n){for(var t=new a,e=-1,r=n.length;++e68?1900:2e3)}function Kt(n,t,e){vc.lastIndex=0;var r=vc.exec(t.slice(e,e+2));return r?(n.m=r[0]-1,e+r[0].length):-1}function Qt(n,t,e){vc.lastIndex=0;var r=vc.exec(t.slice(e,e+2));return r?(n.d=+r[0],e+r[0].length):-1}function ne(n,t,e){vc.lastIndex=0;var r=vc.exec(t.slice(e,e+3));return r?(n.j=+r[0],e+r[0].length):-1}function te(n,t,e){vc.lastIndex=0;var r=vc.exec(t.slice(e,e+2));return r?(n.H=+r[0],e+r[0].length):-1}function ee(n,t,e){vc.lastIndex=0;var r=vc.exec(t.slice(e,e+2));return r?(n.M=+r[0],e+r[0].length):-1}function re(n,t,e){vc.lastIndex=0;var r=vc.exec(t.slice(e,e+2));return r?(n.S=+r[0],e+r[0].length):-1}function ue(n,t,e){vc.lastIndex=0;var r=vc.exec(t.slice(e,e+3));return r?(n.L=+r[0],e+r[0].length):-1}function ie(n){var t=n.getTimezoneOffset(),e=t>0?"-":"+",r=0|va(t)/60,u=va(t)%60;return e+Yt(r,"0",2)+Yt(u,"0",2)}function oe(n,t,e){dc.lastIndex=0;var r=dc.exec(t.slice(e,e+1));return r?e+r[0].length:-1}function ae(n){for(var t=n.length,e=-1;++e=0?1:-1,a=o*e,c=Math.cos(t),l=Math.sin(t),s=i*l,f=u*c+s*Math.cos(a),h=s*o*Math.sin(a);_c.add(Math.atan2(h,f)),r=n,u=c,i=l}var t,e,r,u,i;wc.point=function(o,a){wc.point=n,r=(t=o)*Fa,u=Math.cos(a=(e=a)*Fa/2+Da/4),i=Math.sin(a)},wc.lineEnd=function(){n(t,e)}}function pe(n){var t=n[0],e=n[1],r=Math.cos(e);return[r*Math.cos(t),r*Math.sin(t),Math.sin(e)]}function ve(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]}function de(n,t){return[n[1]*t[2]-n[2]*t[1],n[2]*t[0]-n[0]*t[2],n[0]*t[1]-n[1]*t[0]]}function me(n,t){n[0]+=t[0],n[1]+=t[1],n[2]+=t[2]}function ye(n,t){return[n[0]*t,n[1]*t,n[2]*t]}function Me(n){var t=Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);n[0]/=t,n[1]/=t,n[2]/=t}function xe(n){return[Math.atan2(n[1],n[0]),nt(n[2])]}function be(n,t){return va(n[0]-t[0])a;++a)u.point((e=n[a])[0],e[1]);return u.lineEnd(),void 0}var c=new qe(e,n,null,!0),l=new qe(e,null,c,!1);c.o=l,i.push(c),o.push(l),c=new qe(r,n,null,!1),l=new qe(r,null,c,!0),c.o=l,i.push(c),o.push(l)}}),o.sort(t),ze(i),ze(o),i.length){for(var a=0,c=e,l=o.length;l>a;++a)o[a].e=c=!c;for(var s,f,h=i[0];;){for(var g=h,p=!0;g.v;)if((g=g.n)===h)return;s=g.z,u.lineStart();do{if(g.v=g.o.v=!0,g.e){if(p)for(var a=0,l=s.length;l>a;++a)u.point((f=s[a])[0],f[1]);else r(g.x,g.n.x,1,u);g=g.n}else{if(p){s=g.p.z;for(var a=s.length-1;a>=0;--a)u.point((f=s[a])[0],f[1])}else r(g.x,g.p.x,-1,u);g=g.p}g=g.o,s=g.z,p=!p}while(!g.v);u.lineEnd()}}}function ze(n){if(t=n.length){for(var t,e,r=0,u=n[0];++r0){for(b||(i.polygonStart(),b=!0),i.lineStart();++o1&&2&t&&e.push(e.pop().concat(e.shift())),g.push(e.filter(Te))}var g,p,v,d=t(i),m=u.invert(r[0],r[1]),y={point:o,lineStart:c,lineEnd:l,polygonStart:function(){y.point=s,y.lineStart=f,y.lineEnd=h,g=[],p=[]},polygonEnd:function(){y.point=o,y.lineStart=c,y.lineEnd=l,g=ta.merge(g);var n=Fe(m,p);g.length?(b||(i.polygonStart(),b=!0),Ce(g,De,n,e,i)):n&&(b||(i.polygonStart(),b=!0),i.lineStart(),e(null,null,1,i),i.lineEnd()),b&&(i.polygonEnd(),b=!1),g=p=null},sphere:function(){i.polygonStart(),i.lineStart(),e(null,null,1,i),i.lineEnd(),i.polygonEnd()}},M=Re(),x=t(M),b=!1;return y}}function Te(n){return n.length>1}function Re(){var n,t=[];return{lineStart:function(){t.push(n=[])},point:function(t,e){n.push([t,e])},lineEnd:y,buffer:function(){var e=t;return t=[],n=null,e},rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))}}}function De(n,t){return((n=n.x)[0]<0?n[1]-ja-Ta:ja-n[1])-((t=t.x)[0]<0?t[1]-ja-Ta:ja-t[1])}function Pe(n){var t,e=0/0,r=0/0,u=0/0;return{lineStart:function(){n.lineStart(),t=1},point:function(i,o){var a=i>0?Da:-Da,c=va(i-e);va(c-Da)0?ja:-ja),n.point(u,r),n.lineEnd(),n.lineStart(),n.point(a,r),n.point(i,r),t=0):u!==a&&c>=Da&&(va(e-u)Ta?Math.atan((Math.sin(t)*(i=Math.cos(r))*Math.sin(e)-Math.sin(r)*(u=Math.cos(t))*Math.sin(n))/(u*i*o)):(t+r)/2}function je(n,t,e,r){var u;if(null==n)u=e*ja,r.point(-Da,u),r.point(0,u),r.point(Da,u),r.point(Da,0),r.point(Da,-u),r.point(0,-u),r.point(-Da,-u),r.point(-Da,0),r.point(-Da,u);else if(va(n[0]-t[0])>Ta){var i=n[0]a;++a){var l=t[a],s=l.length;if(s)for(var f=l[0],h=f[0],g=f[1]/2+Da/4,p=Math.sin(g),v=Math.cos(g),d=1;;){d===s&&(d=0),n=l[d];var m=n[0],y=n[1]/2+Da/4,M=Math.sin(y),x=Math.cos(y),b=m-h,_=b>=0?1:-1,w=_*b,S=w>Da,k=p*M;if(_c.add(Math.atan2(k*_*Math.sin(w),v*x+k*Math.cos(w))),i+=S?b+_*Pa:b,S^h>=e^m>=e){var E=de(pe(f),pe(n));Me(E);var A=de(u,E);Me(A);var N=(S^b>=0?-1:1)*nt(A[2]);(r>N||r===N&&(E[0]||E[1]))&&(o+=S^b>=0?1:-1)}if(!d++)break;h=m,p=M,v=x,f=n}}return(-Ta>i||Ta>i&&0>_c)^1&o}function He(n){function t(n,t){return Math.cos(n)*Math.cos(t)>i}function e(n){var e,i,c,l,s;return{lineStart:function(){l=c=!1,s=1},point:function(f,h){var g,p=[f,h],v=t(f,h),d=o?v?0:u(f,h):v?u(f+(0>f?Da:-Da),h):0;if(!e&&(l=c=v)&&n.lineStart(),v!==c&&(g=r(e,p),(be(e,g)||be(p,g))&&(p[0]+=Ta,p[1]+=Ta,v=t(p[0],p[1]))),v!==c)s=0,v?(n.lineStart(),g=r(p,e),n.point(g[0],g[1])):(g=r(e,p),n.point(g[0],g[1]),n.lineEnd()),e=g;else if(a&&e&&o^v){var m;d&i||!(m=r(p,e,!0))||(s=0,o?(n.lineStart(),n.point(m[0][0],m[0][1]),n.point(m[1][0],m[1][1]),n.lineEnd()):(n.point(m[1][0],m[1][1]),n.lineEnd(),n.lineStart(),n.point(m[0][0],m[0][1])))}!v||e&&be(e,p)||n.point(p[0],p[1]),e=p,c=v,i=d},lineEnd:function(){c&&n.lineEnd(),e=null},clean:function(){return s|(l&&c)<<1}}}function r(n,t,e){var r=pe(n),u=pe(t),o=[1,0,0],a=de(r,u),c=ve(a,a),l=a[0],s=c-l*l;if(!s)return!e&&n;var f=i*c/s,h=-i*l/s,g=de(o,a),p=ye(o,f),v=ye(a,h);me(p,v);var d=g,m=ve(p,d),y=ve(d,d),M=m*m-y*(ve(p,p)-1);if(!(0>M)){var x=Math.sqrt(M),b=ye(d,(-m-x)/y);if(me(b,p),b=xe(b),!e)return b;var _,w=n[0],S=t[0],k=n[1],E=t[1];w>S&&(_=w,w=S,S=_);var A=S-w,N=va(A-Da)A;if(!N&&k>E&&(_=k,k=E,E=_),C?N?k+E>0^b[1]<(va(b[0]-w)Da^(w<=b[0]&&b[0]<=S)){var z=ye(d,(-m+x)/y);return me(z,p),[b,xe(z)]}}}function u(t,e){var r=o?n:Da-n,u=0;return-r>t?u|=1:t>r&&(u|=2),-r>e?u|=4:e>r&&(u|=8),u}var i=Math.cos(n),o=i>0,a=va(i)>Ta,c=gr(n,6*Fa);return Le(t,e,c,o?[0,-n]:[-Da,n-Da])}function Oe(n,t,e,r){return function(u){var i,o=u.a,a=u.b,c=o.x,l=o.y,s=a.x,f=a.y,h=0,g=1,p=s-c,v=f-l;if(i=n-c,p||!(i>0)){if(i/=p,0>p){if(h>i)return;g>i&&(g=i)}else if(p>0){if(i>g)return;i>h&&(h=i)}if(i=e-c,p||!(0>i)){if(i/=p,0>p){if(i>g)return;i>h&&(h=i)}else if(p>0){if(h>i)return;g>i&&(g=i)}if(i=t-l,v||!(i>0)){if(i/=v,0>v){if(h>i)return;g>i&&(g=i)}else if(v>0){if(i>g)return;i>h&&(h=i)}if(i=r-l,v||!(0>i)){if(i/=v,0>v){if(i>g)return;i>h&&(h=i)}else if(v>0){if(h>i)return;g>i&&(g=i)}return h>0&&(u.a={x:c+h*p,y:l+h*v}),1>g&&(u.b={x:c+g*p,y:l+g*v}),u}}}}}}function Ye(n,t,e,r){function u(r,u){return va(r[0]-n)0?0:3:va(r[0]-e)0?2:1:va(r[1]-t)0?1:0:u>0?3:2}function i(n,t){return o(n.x,t.x)}function o(n,t){var e=u(n,1),r=u(t,1);return e!==r?e-r:0===e?t[1]-n[1]:1===e?n[0]-t[0]:2===e?n[1]-t[1]:t[0]-n[0]}return function(a){function c(n){for(var t=0,e=d.length,r=n[1],u=0;e>u;++u)for(var i,o=1,a=d[u],c=a.length,l=a[0];c>o;++o)i=a[o],l[1]<=r?i[1]>r&&K(l,i,n)>0&&++t:i[1]<=r&&K(l,i,n)<0&&--t,l=i;return 0!==t}function l(i,a,c,l){var s=0,f=0;if(null==i||(s=u(i,c))!==(f=u(a,c))||o(i,a)<0^c>0){do l.point(0===s||3===s?n:e,s>1?r:t);while((s=(s+c+4)%4)!==f)}else l.point(a[0],a[1])}function s(u,i){return u>=n&&e>=u&&i>=t&&r>=i}function f(n,t){s(n,t)&&a.point(n,t)}function h(){C.point=p,d&&d.push(m=[]),S=!0,w=!1,b=_=0/0}function g(){v&&(p(y,M),x&&w&&A.rejoin(),v.push(A.buffer())),C.point=f,w&&a.lineEnd()}function p(n,t){n=Math.max(-Uc,Math.min(Uc,n)),t=Math.max(-Uc,Math.min(Uc,t));var e=s(n,t);if(d&&m.push([n,t]),S)y=n,M=t,x=e,S=!1,e&&(a.lineStart(),a.point(n,t));else if(e&&w)a.point(n,t);else{var r={a:{x:b,y:_},b:{x:n,y:t}};N(r)?(w||(a.lineStart(),a.point(r.a.x,r.a.y)),a.point(r.b.x,r.b.y),e||a.lineEnd(),k=!1):e&&(a.lineStart(),a.point(n,t),k=!1)}b=n,_=t,w=e}var v,d,m,y,M,x,b,_,w,S,k,E=a,A=Re(),N=Oe(n,t,e,r),C={point:f,lineStart:h,lineEnd:g,polygonStart:function(){a=A,v=[],d=[],k=!0},polygonEnd:function(){a=E,v=ta.merge(v);var t=c([n,r]),e=k&&t,u=v.length;(e||u)&&(a.polygonStart(),e&&(a.lineStart(),l(null,null,1,a),a.lineEnd()),u&&Ce(v,i,t,l,a),a.polygonEnd()),v=d=m=null}};return C}}function Ie(n){var t=0,e=Da/3,r=ir(n),u=r(t,e);return u.parallels=function(n){return arguments.length?r(t=n[0]*Da/180,e=n[1]*Da/180):[180*(t/Da),180*(e/Da)]},u}function Ze(n,t){function e(n,t){var e=Math.sqrt(i-2*u*Math.sin(t))/u;return[e*Math.sin(n*=u),o-e*Math.cos(n)]}var r=Math.sin(n),u=(r+Math.sin(t))/2,i=1+r*(2*u-r),o=Math.sqrt(i)/u;return e.invert=function(n,t){var e=o-t;return[Math.atan2(n,e)/u,nt((i-(n*n+e*e)*u*u)/(2*u))]},e}function Ve(){function n(n,t){Fc+=u*n-r*t,r=n,u=t}var t,e,r,u;Zc.point=function(i,o){Zc.point=n,t=r=i,e=u=o},Zc.lineEnd=function(){n(t,e)}}function Xe(n,t){Hc>n&&(Hc=n),n>Yc&&(Yc=n),Oc>t&&(Oc=t),t>Ic&&(Ic=t)}function $e(){function n(n,t){o.push("M",n,",",t,i)}function t(n,t){o.push("M",n,",",t),a.point=e}function e(n,t){o.push("L",n,",",t)}function r(){a.point=n}function u(){o.push("Z")}var i=Be(4.5),o=[],a={point:n,lineStart:function(){a.point=t},lineEnd:r,polygonStart:function(){a.lineEnd=u},polygonEnd:function(){a.lineEnd=r,a.point=n},pointRadius:function(n){return i=Be(n),a},result:function(){if(o.length){var n=o.join("");return o=[],n}}};return a}function Be(n){return"m0,"+n+"a"+n+","+n+" 0 1,1 0,"+-2*n+"a"+n+","+n+" 0 1,1 0,"+2*n+"z"}function We(n,t){Ec+=n,Ac+=t,++Nc}function Je(){function n(n,r){var u=n-t,i=r-e,o=Math.sqrt(u*u+i*i);Cc+=o*(t+n)/2,zc+=o*(e+r)/2,qc+=o,We(t=n,e=r)}var t,e;Xc.point=function(r,u){Xc.point=n,We(t=r,e=u)}}function Ge(){Xc.point=We}function Ke(){function n(n,t){var e=n-r,i=t-u,o=Math.sqrt(e*e+i*i);Cc+=o*(r+n)/2,zc+=o*(u+t)/2,qc+=o,o=u*n-r*t,Lc+=o*(r+n),Tc+=o*(u+t),Rc+=3*o,We(r=n,u=t)}var t,e,r,u;Xc.point=function(i,o){Xc.point=n,We(t=r=i,e=u=o)},Xc.lineEnd=function(){n(t,e)}}function Qe(n){function t(t,e){n.moveTo(t+o,e),n.arc(t,e,o,0,Pa)}function e(t,e){n.moveTo(t,e),a.point=r}function r(t,e){n.lineTo(t,e)}function u(){a.point=t}function i(){n.closePath()}var o=4.5,a={point:t,lineStart:function(){a.point=e},lineEnd:u,polygonStart:function(){a.lineEnd=i},polygonEnd:function(){a.lineEnd=u,a.point=t},pointRadius:function(n){return o=n,a},result:y};return a}function nr(n){function t(n){return(a?r:e)(n)}function e(t){return rr(t,function(e,r){e=n(e,r),t.point(e[0],e[1])})}function r(t){function e(e,r){e=n(e,r),t.point(e[0],e[1])}function r(){M=0/0,S.point=i,t.lineStart()}function i(e,r){var i=pe([e,r]),o=n(e,r);u(M,x,y,b,_,w,M=o[0],x=o[1],y=e,b=i[0],_=i[1],w=i[2],a,t),t.point(M,x)}function o(){S.point=e,t.lineEnd()}function c(){r(),S.point=l,S.lineEnd=s}function l(n,t){i(f=n,h=t),g=M,p=x,v=b,d=_,m=w,S.point=i}function s(){u(M,x,y,b,_,w,g,p,f,v,d,m,a,t),S.lineEnd=o,o()}var f,h,g,p,v,d,m,y,M,x,b,_,w,S={point:e,lineStart:r,lineEnd:o,polygonStart:function(){t.polygonStart(),S.lineStart=c},polygonEnd:function(){t.polygonEnd(),S.lineStart=r}};return S}function u(t,e,r,a,c,l,s,f,h,g,p,v,d,m){var y=s-t,M=f-e,x=y*y+M*M;if(x>4*i&&d--){var b=a+g,_=c+p,w=l+v,S=Math.sqrt(b*b+_*_+w*w),k=Math.asin(w/=S),E=va(va(w)-1)i||va((y*z+M*q)/x-.5)>.3||o>a*g+c*p+l*v)&&(u(t,e,r,a,c,l,N,C,E,b/=S,_/=S,w,d,m),m.point(N,C),u(N,C,E,b,_,w,s,f,h,g,p,v,d,m))}}var i=.5,o=Math.cos(30*Fa),a=16;return t.precision=function(n){return arguments.length?(a=(i=n*n)>0&&16,t):Math.sqrt(i)},t}function tr(n){var t=nr(function(t,e){return n([t*Ha,e*Ha])});return function(n){return or(t(n))}}function er(n){this.stream=n}function rr(n,t){return{point:t,sphere:function(){n.sphere()},lineStart:function(){n.lineStart()},lineEnd:function(){n.lineEnd()},polygonStart:function(){n.polygonStart()},polygonEnd:function(){n.polygonEnd()}}}function ur(n){return ir(function(){return n})()}function ir(n){function t(n){return n=a(n[0]*Fa,n[1]*Fa),[n[0]*h+c,l-n[1]*h]}function e(n){return n=a.invert((n[0]-c)/h,(l-n[1])/h),n&&[n[0]*Ha,n[1]*Ha]}function r(){a=Ae(o=lr(m,y,M),i);var n=i(v,d);return c=g-n[0]*h,l=p+n[1]*h,u()}function u(){return s&&(s.valid=!1,s=null),t}var i,o,a,c,l,s,f=nr(function(n,t){return n=i(n,t),[n[0]*h+c,l-n[1]*h]}),h=150,g=480,p=250,v=0,d=0,m=0,y=0,M=0,x=Pc,b=Et,_=null,w=null;return t.stream=function(n){return s&&(s.valid=!1),s=or(x(o,f(b(n)))),s.valid=!0,s},t.clipAngle=function(n){return arguments.length?(x=null==n?(_=n,Pc):He((_=+n)*Fa),u()):_},t.clipExtent=function(n){return arguments.length?(w=n,b=n?Ye(n[0][0],n[0][1],n[1][0],n[1][1]):Et,u()):w},t.scale=function(n){return arguments.length?(h=+n,r()):h},t.translate=function(n){return arguments.length?(g=+n[0],p=+n[1],r()):[g,p]},t.center=function(n){return arguments.length?(v=n[0]%360*Fa,d=n[1]%360*Fa,r()):[v*Ha,d*Ha]},t.rotate=function(n){return arguments.length?(m=n[0]%360*Fa,y=n[1]%360*Fa,M=n.length>2?n[2]%360*Fa:0,r()):[m*Ha,y*Ha,M*Ha]},ta.rebind(t,f,"precision"),function(){return i=n.apply(this,arguments),t.invert=i.invert&&e,r()}}function or(n){return rr(n,function(t,e){n.point(t*Fa,e*Fa)})}function ar(n,t){return[n,t]}function cr(n,t){return[n>Da?n-Pa:-Da>n?n+Pa:n,t]}function lr(n,t,e){return n?t||e?Ae(fr(n),hr(t,e)):fr(n):t||e?hr(t,e):cr}function sr(n){return function(t,e){return t+=n,[t>Da?t-Pa:-Da>t?t+Pa:t,e]}}function fr(n){var t=sr(n);return t.invert=sr(-n),t}function hr(n,t){function e(n,t){var e=Math.cos(t),a=Math.cos(n)*e,c=Math.sin(n)*e,l=Math.sin(t),s=l*r+a*u;return[Math.atan2(c*i-s*o,a*r-l*u),nt(s*i+c*o)]}var r=Math.cos(n),u=Math.sin(n),i=Math.cos(t),o=Math.sin(t);return e.invert=function(n,t){var e=Math.cos(t),a=Math.cos(n)*e,c=Math.sin(n)*e,l=Math.sin(t),s=l*i-c*o;return[Math.atan2(c*i+l*o,a*r+s*u),nt(s*r-a*u)]},e}function gr(n,t){var e=Math.cos(n),r=Math.sin(n);return function(u,i,o,a){var c=o*t;null!=u?(u=pr(e,u),i=pr(e,i),(o>0?i>u:u>i)&&(u+=o*Pa)):(u=n+o*Pa,i=n-.5*c);for(var l,s=u;o>0?s>i:i>s;s-=c)a.point((l=xe([e,-r*Math.cos(s),-r*Math.sin(s)]))[0],l[1])}}function pr(n,t){var e=pe(t);e[0]-=n,Me(e);var r=Q(-e[1]);return((-e[2]<0?-r:r)+2*Math.PI-Ta)%(2*Math.PI)}function vr(n,t,e){var r=ta.range(n,t-Ta,e).concat(t);return function(n){return r.map(function(t){return[n,t]})}}function dr(n,t,e){var r=ta.range(n,t-Ta,e).concat(t);return function(n){return r.map(function(t){return[t,n]})}}function mr(n){return n.source}function yr(n){return n.target}function Mr(n,t,e,r){var u=Math.cos(t),i=Math.sin(t),o=Math.cos(r),a=Math.sin(r),c=u*Math.cos(n),l=u*Math.sin(n),s=o*Math.cos(e),f=o*Math.sin(e),h=2*Math.asin(Math.sqrt(ut(r-t)+u*o*ut(e-n))),g=1/Math.sin(h),p=h?function(n){var t=Math.sin(n*=h)*g,e=Math.sin(h-n)*g,r=e*c+t*s,u=e*l+t*f,o=e*i+t*a;return[Math.atan2(u,r)*Ha,Math.atan2(o,Math.sqrt(r*r+u*u))*Ha]}:function(){return[n*Ha,t*Ha]};return p.distance=h,p}function xr(){function n(n,u){var i=Math.sin(u*=Fa),o=Math.cos(u),a=va((n*=Fa)-t),c=Math.cos(a);$c+=Math.atan2(Math.sqrt((a=o*Math.sin(a))*a+(a=r*i-e*o*c)*a),e*i+r*o*c),t=n,e=i,r=o}var t,e,r;Bc.point=function(u,i){t=u*Fa,e=Math.sin(i*=Fa),r=Math.cos(i),Bc.point=n},Bc.lineEnd=function(){Bc.point=Bc.lineEnd=y}}function br(n,t){function e(t,e){var r=Math.cos(t),u=Math.cos(e),i=n(r*u);return[i*u*Math.sin(t),i*Math.sin(e)]}return e.invert=function(n,e){var r=Math.sqrt(n*n+e*e),u=t(r),i=Math.sin(u),o=Math.cos(u);return[Math.atan2(n*i,r*o),Math.asin(r&&e*i/r)]},e}function _r(n,t){function e(n,t){o>0?-ja+Ta>t&&(t=-ja+Ta):t>ja-Ta&&(t=ja-Ta);var e=o/Math.pow(u(t),i);return[e*Math.sin(i*n),o-e*Math.cos(i*n)]}var r=Math.cos(n),u=function(n){return Math.tan(Da/4+n/2)},i=n===t?Math.sin(n):Math.log(r/Math.cos(t))/Math.log(u(t)/u(n)),o=r*Math.pow(u(n),i)/i;return i?(e.invert=function(n,t){var e=o-t,r=G(i)*Math.sqrt(n*n+e*e);return[Math.atan2(n,e)/i,2*Math.atan(Math.pow(o/r,1/i))-ja]},e):Sr}function wr(n,t){function e(n,t){var e=i-t;return[e*Math.sin(u*n),i-e*Math.cos(u*n)]}var r=Math.cos(n),u=n===t?Math.sin(n):(r-Math.cos(t))/(t-n),i=r/u+n;return va(u)u;u++){for(;r>1&&K(n[e[r-2]],n[e[r-1]],n[u])<=0;)--r;e[r++]=u}return e.slice(0,r)}function zr(n,t){return n[0]-t[0]||n[1]-t[1]}function qr(n,t,e){return(e[0]-t[0])*(n[1]-t[1])<(e[1]-t[1])*(n[0]-t[0])}function Lr(n,t,e,r){var u=n[0],i=e[0],o=t[0]-u,a=r[0]-i,c=n[1],l=e[1],s=t[1]-c,f=r[1]-l,h=(a*(c-l)-f*(u-i))/(f*o-a*s);return[u+h*o,c+h*s]}function Tr(n){var t=n[0],e=n[n.length-1];return!(t[0]-e[0]||t[1]-e[1])}function Rr(){tu(this),this.edge=this.site=this.circle=null}function Dr(n){var t=ol.pop()||new Rr;return t.site=n,t}function Pr(n){Xr(n),rl.remove(n),ol.push(n),tu(n)}function Ur(n){var t=n.circle,e=t.x,r=t.cy,u={x:e,y:r},i=n.P,o=n.N,a=[n];Pr(n);for(var c=i;c.circle&&va(e-c.circle.x)s;++s)l=a[s],c=a[s-1],Kr(l.edge,c.site,l.site,u);c=a[0],l=a[f-1],l.edge=Jr(c.site,l.site,null,u),Vr(c),Vr(l)}function jr(n){for(var t,e,r,u,i=n.x,o=n.y,a=rl._;a;)if(r=Fr(a,o)-i,r>Ta)a=a.L;else{if(u=i-Hr(a,o),!(u>Ta)){r>-Ta?(t=a.P,e=a):u>-Ta?(t=a,e=a.N):t=e=a;break}if(!a.R){t=a;break}a=a.R}var c=Dr(n);if(rl.insert(t,c),t||e){if(t===e)return Xr(t),e=Dr(t.site),rl.insert(c,e),c.edge=e.edge=Jr(t.site,c.site),Vr(t),Vr(e),void 0;if(!e)return c.edge=Jr(t.site,c.site),void 0;Xr(t),Xr(e);var l=t.site,s=l.x,f=l.y,h=n.x-s,g=n.y-f,p=e.site,v=p.x-s,d=p.y-f,m=2*(h*d-g*v),y=h*h+g*g,M=v*v+d*d,x={x:(d*y-g*M)/m+s,y:(h*M-v*y)/m+f};Kr(e.edge,l,p,x),c.edge=Jr(l,n,null,x),e.edge=Jr(n,p,null,x),Vr(t),Vr(e)}}function Fr(n,t){var e=n.site,r=e.x,u=e.y,i=u-t;if(!i)return r;var o=n.P;if(!o)return-1/0;e=o.site;var a=e.x,c=e.y,l=c-t;if(!l)return a;var s=a-r,f=1/i-1/l,h=s/l;return f?(-h+Math.sqrt(h*h-2*f*(s*s/(-2*l)-c+l/2+u-i/2)))/f+r:(r+a)/2}function Hr(n,t){var e=n.N;if(e)return Fr(e,t);var r=n.site;return r.y===t?r.x:1/0}function Or(n){this.site=n,this.edges=[]}function Yr(n){for(var t,e,r,u,i,o,a,c,l,s,f=n[0][0],h=n[1][0],g=n[0][1],p=n[1][1],v=el,d=v.length;d--;)if(i=v[d],i&&i.prepare())for(a=i.edges,c=a.length,o=0;c>o;)s=a[o].end(),r=s.x,u=s.y,l=a[++o%c].start(),t=l.x,e=l.y,(va(r-t)>Ta||va(u-e)>Ta)&&(a.splice(o,0,new Qr(Gr(i.site,s,va(r-f)Ta?{x:f,y:va(t-f)Ta?{x:va(e-p)Ta?{x:h,y:va(t-h)Ta?{x:va(e-g)=-Ra)){var g=c*c+l*l,p=s*s+f*f,v=(f*g-l*p)/h,d=(c*p-s*g)/h,f=d+a,m=al.pop()||new Zr;m.arc=n,m.site=u,m.x=v+o,m.y=f+Math.sqrt(v*v+d*d),m.cy=f,n.circle=m;for(var y=null,M=il._;M;)if(m.yd||d>=a)return;if(h>p){if(i){if(i.y>=l)return}else i={x:d,y:c};e={x:d,y:l}}else{if(i){if(i.yr||r>1)if(h>p){if(i){if(i.y>=l)return}else i={x:(c-u)/r,y:c};e={x:(l-u)/r,y:l}}else{if(i){if(i.yg){if(i){if(i.x>=a)return}else i={x:o,y:r*o+u};e={x:a,y:r*a+u}}else{if(i){if(i.xi||f>o||r>h||u>g)){if(p=n.point){var p,v=t-p[0],d=e-p[1],m=v*v+d*d;if(c>m){var y=Math.sqrt(c=m);r=t-y,u=e-y,i=t+y,o=e+y,a=p}}for(var M=n.nodes,x=.5*(s+h),b=.5*(f+g),_=t>=x,w=e>=b,S=w<<1|_,k=S+4;k>S;++S)if(n=M[3&S])switch(3&S){case 0:l(n,s,f,x,b);break;case 1:l(n,x,f,h,b);break;case 2:l(n,s,b,x,g);break;case 3:l(n,x,b,h,g)}}}(n,r,u,i,o),a}function gu(n,t){n=ta.rgb(n),t=ta.rgb(t);var e=n.r,r=n.g,u=n.b,i=t.r-e,o=t.g-r,a=t.b-u;return function(n){return"#"+Mt(Math.round(e+i*n))+Mt(Math.round(r+o*n))+Mt(Math.round(u+a*n))}}function pu(n,t){var e,r={},u={};for(e in n)e in t?r[e]=mu(n[e],t[e]):u[e]=n[e];for(e in t)e in n||(u[e]=t[e]);return function(n){for(e in r)u[e]=r[e](n);return u}}function vu(n,t){return n=+n,t=+t,function(e){return n*(1-e)+t*e}}function du(n,t){var e,r,u,i=ll.lastIndex=sl.lastIndex=0,o=-1,a=[],c=[];for(n+="",t+="";(e=ll.exec(n))&&(r=sl.exec(t));)(u=r.index)>i&&(u=t.slice(i,u),a[o]?a[o]+=u:a[++o]=u),(e=e[0])===(r=r[0])?a[o]?a[o]+=r:a[++o]=r:(a[++o]=null,c.push({i:o,x:vu(e,r)})),i=sl.lastIndex;return ir;++r)a[(e=c[r]).i]=e.x(n);return a.join("")})}function mu(n,t){for(var e,r=ta.interpolators.length;--r>=0&&!(e=ta.interpolators[r](n,t)););return e}function yu(n,t){var e,r=[],u=[],i=n.length,o=t.length,a=Math.min(n.length,t.length);for(e=0;a>e;++e)r.push(mu(n[e],t[e]));for(;i>e;++e)u[e]=n[e];for(;o>e;++e)u[e]=t[e];return function(n){for(e=0;a>e;++e)u[e]=r[e](n);return u}}function Mu(n){return function(t){return 0>=t?0:t>=1?1:n(t)}}function xu(n){return function(t){return 1-n(1-t)}}function bu(n){return function(t){return.5*(.5>t?n(2*t):2-n(2-2*t))}}function _u(n){return n*n}function wu(n){return n*n*n}function Su(n){if(0>=n)return 0;if(n>=1)return 1;var t=n*n,e=t*n;return 4*(.5>n?e:3*(n-t)+e-.75)}function ku(n){return function(t){return Math.pow(t,n)}}function Eu(n){return 1-Math.cos(n*ja)}function Au(n){return Math.pow(2,10*(n-1))}function Nu(n){return 1-Math.sqrt(1-n*n)}function Cu(n,t){var e;return arguments.length<2&&(t=.45),arguments.length?e=t/Pa*Math.asin(1/n):(n=1,e=t/4),function(r){return 1+n*Math.pow(2,-10*r)*Math.sin((r-e)*Pa/t)}}function zu(n){return n||(n=1.70158),function(t){return t*t*((n+1)*t-n)}}function qu(n){return 1/2.75>n?7.5625*n*n:2/2.75>n?7.5625*(n-=1.5/2.75)*n+.75:2.5/2.75>n?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375}function Lu(n,t){n=ta.hcl(n),t=ta.hcl(t);var e=n.h,r=n.c,u=n.l,i=t.h-e,o=t.c-r,a=t.l-u;return isNaN(o)&&(o=0,r=isNaN(r)?t.c:r),isNaN(i)?(i=0,e=isNaN(e)?t.h:e):i>180?i-=360:-180>i&&(i+=360),function(n){return lt(e+i*n,r+o*n,u+a*n)+""}}function Tu(n,t){n=ta.hsl(n),t=ta.hsl(t);var e=n.h,r=n.s,u=n.l,i=t.h-e,o=t.s-r,a=t.l-u;return isNaN(o)&&(o=0,r=isNaN(r)?t.s:r),isNaN(i)?(i=0,e=isNaN(e)?t.h:e):i>180?i-=360:-180>i&&(i+=360),function(n){return at(e+i*n,r+o*n,u+a*n)+""}}function Ru(n,t){n=ta.lab(n),t=ta.lab(t);var e=n.l,r=n.a,u=n.b,i=t.l-e,o=t.a-r,a=t.b-u;return function(n){return ft(e+i*n,r+o*n,u+a*n)+""}}function Du(n,t){return t-=n,function(e){return Math.round(n+t*e)}}function Pu(n){var t=[n.a,n.b],e=[n.c,n.d],r=ju(t),u=Uu(t,e),i=ju(Fu(e,t,-u))||0;t[0]*e[1]180?s+=360:s-l>180&&(l+=360),u.push({i:r.push(r.pop()+"rotate(",null,")")-2,x:vu(l,s)})):s&&r.push(r.pop()+"rotate("+s+")"),f!=h?u.push({i:r.push(r.pop()+"skewX(",null,")")-2,x:vu(f,h)}):h&&r.push(r.pop()+"skewX("+h+")"),g[0]!=p[0]||g[1]!=p[1]?(e=r.push(r.pop()+"scale(",null,",",null,")"),u.push({i:e-4,x:vu(g[0],p[0])},{i:e-2,x:vu(g[1],p[1])})):(1!=p[0]||1!=p[1])&&r.push(r.pop()+"scale("+p+")"),e=u.length,function(n){for(var t,i=-1;++i=0;)e.push(u[r])}function Qu(n,t){for(var e=[n],r=[];null!=(n=e.pop());)if(r.push(n),(i=n.children)&&(u=i.length))for(var u,i,o=-1;++oe;++e)(t=n[e][1])>u&&(r=e,u=t);return r}function si(n){return n.reduce(fi,0)}function fi(n,t){return n+t[1]}function hi(n,t){return gi(n,Math.ceil(Math.log(t.length)/Math.LN2+1))}function gi(n,t){for(var e=-1,r=+n[0],u=(n[1]-r)/t,i=[];++e<=t;)i[e]=u*e+r;return i}function pi(n){return[ta.min(n),ta.max(n)]}function vi(n,t){return n.value-t.value}function di(n,t){var e=n._pack_next;n._pack_next=t,t._pack_prev=n,t._pack_next=e,e._pack_prev=t}function mi(n,t){n._pack_next=t,t._pack_prev=n}function yi(n,t){var e=t.x-n.x,r=t.y-n.y,u=n.r+t.r;return.999*u*u>e*e+r*r}function Mi(n){function t(n){s=Math.min(n.x-n.r,s),f=Math.max(n.x+n.r,f),h=Math.min(n.y-n.r,h),g=Math.max(n.y+n.r,g)}if((e=n.children)&&(l=e.length)){var e,r,u,i,o,a,c,l,s=1/0,f=-1/0,h=1/0,g=-1/0;if(e.forEach(xi),r=e[0],r.x=-r.r,r.y=0,t(r),l>1&&(u=e[1],u.x=u.r,u.y=0,t(u),l>2))for(i=e[2],wi(r,u,i),t(i),di(r,i),r._pack_prev=i,di(i,u),u=r._pack_next,o=3;l>o;o++){wi(r,u,i=e[o]);var p=0,v=1,d=1;for(a=u._pack_next;a!==u;a=a._pack_next,v++)if(yi(a,i)){p=1;break}if(1==p)for(c=r._pack_prev;c!==a._pack_prev&&!yi(c,i);c=c._pack_prev,d++);p?(d>v||v==d&&u.ro;o++)i=e[o],i.x-=m,i.y-=y,M=Math.max(M,i.r+Math.sqrt(i.x*i.x+i.y*i.y));n.r=M,e.forEach(bi)}}function xi(n){n._pack_next=n._pack_prev=n}function bi(n){delete n._pack_next,delete n._pack_prev}function _i(n,t,e,r){var u=n.children;if(n.x=t+=r*n.x,n.y=e+=r*n.y,n.r*=r,u)for(var i=-1,o=u.length;++i=0;)t=u[i],t.z+=e,t.m+=e,e+=t.s+(r+=t.c)}function Ci(n,t,e){return n.a.parent===t.parent?n.a:e}function zi(n){return 1+ta.max(n,function(n){return n.y})}function qi(n){return n.reduce(function(n,t){return n+t.x},0)/n.length}function Li(n){var t=n.children;return t&&t.length?Li(t[0]):n}function Ti(n){var t,e=n.children;return e&&(t=e.length)?Ti(e[t-1]):n}function Ri(n){return{x:n.x,y:n.y,dx:n.dx,dy:n.dy}}function Di(n,t){var e=n.x+t[3],r=n.y+t[0],u=n.dx-t[1]-t[3],i=n.dy-t[0]-t[2];return 0>u&&(e+=u/2,u=0),0>i&&(r+=i/2,i=0),{x:e,y:r,dx:u,dy:i}}function Pi(n){var t=n[0],e=n[n.length-1];return e>t?[t,e]:[e,t]}function Ui(n){return n.rangeExtent?n.rangeExtent():Pi(n.range())}function ji(n,t,e,r){var u=e(n[0],n[1]),i=r(t[0],t[1]);return function(n){return i(u(n))}}function Fi(n,t){var e,r=0,u=n.length-1,i=n[r],o=n[u];return i>o&&(e=r,r=u,u=e,e=i,i=o,o=e),n[r]=t.floor(i),n[u]=t.ceil(o),n}function Hi(n){return n?{floor:function(t){return Math.floor(t/n)*n},ceil:function(t){return Math.ceil(t/n)*n}}:bl}function Oi(n,t,e,r){var u=[],i=[],o=0,a=Math.min(n.length,t.length)-1;for(n[a]2?Oi:ji,c=r?Yu:Ou;return o=u(n,t,c,e),a=u(t,n,c,mu),i}function i(n){return o(n)}var o,a;return i.invert=function(n){return a(n)},i.domain=function(t){return arguments.length?(n=t.map(Number),u()):n},i.range=function(n){return arguments.length?(t=n,u()):t},i.rangeRound=function(n){return i.range(n).interpolate(Du)},i.clamp=function(n){return arguments.length?(r=n,u()):r},i.interpolate=function(n){return arguments.length?(e=n,u()):e},i.ticks=function(t){return Xi(n,t)},i.tickFormat=function(t,e){return $i(n,t,e)},i.nice=function(t){return Zi(n,t),u()},i.copy=function(){return Yi(n,t,e,r)},u()}function Ii(n,t){return ta.rebind(n,t,"range","rangeRound","interpolate","clamp")}function Zi(n,t){return Fi(n,Hi(Vi(n,t)[2]))}function Vi(n,t){null==t&&(t=10);var e=Pi(n),r=e[1]-e[0],u=Math.pow(10,Math.floor(Math.log(r/t)/Math.LN10)),i=t/r*u;return.15>=i?u*=10:.35>=i?u*=5:.75>=i&&(u*=2),e[0]=Math.ceil(e[0]/u)*u,e[1]=Math.floor(e[1]/u)*u+.5*u,e[2]=u,e}function Xi(n,t){return ta.range.apply(ta,Vi(n,t))}function $i(n,t,e){var r=Vi(n,t);if(e){var u=lc.exec(e);if(u.shift(),"s"===u[8]){var i=ta.formatPrefix(Math.max(va(r[0]),va(r[1])));return u[7]||(u[7]="."+Bi(i.scale(r[2]))),u[8]="f",e=ta.format(u.join("")),function(n){return e(i.scale(n))+i.symbol}}u[7]||(u[7]="."+Wi(u[8],r)),e=u.join("")}else e=",."+Bi(r[2])+"f";return ta.format(e)}function Bi(n){return-Math.floor(Math.log(n)/Math.LN10+.01)}function Wi(n,t){var e=Bi(t[2]);return n in _l?Math.abs(e-Bi(Math.max(va(t[0]),va(t[1]))))+ +("e"!==n):e-2*("%"===n)}function Ji(n,t,e,r){function u(n){return(e?Math.log(0>n?0:n):-Math.log(n>0?0:-n))/Math.log(t)}function i(n){return e?Math.pow(t,n):-Math.pow(t,-n)}function o(t){return n(u(t))}return o.invert=function(t){return i(n.invert(t))},o.domain=function(t){return arguments.length?(e=t[0]>=0,n.domain((r=t.map(Number)).map(u)),o):r},o.base=function(e){return arguments.length?(t=+e,n.domain(r.map(u)),o):t},o.nice=function(){var t=Fi(r.map(u),e?Math:Sl);return n.domain(t),r=t.map(i),o},o.ticks=function(){var n=Pi(r),o=[],a=n[0],c=n[1],l=Math.floor(u(a)),s=Math.ceil(u(c)),f=t%1?2:t;if(isFinite(s-l)){if(e){for(;s>l;l++)for(var h=1;f>h;h++)o.push(i(l)*h);o.push(i(l))}else for(o.push(i(l));l++0;h--)o.push(i(l)*h);for(l=0;o[l]c;s--);o=o.slice(l,s)}return o},o.tickFormat=function(n,t){if(!arguments.length)return wl;arguments.length<2?t=wl:"function"!=typeof t&&(t=ta.format(t));var r,a=Math.max(.1,n/o.ticks().length),c=e?(r=1e-12,Math.ceil):(r=-1e-12,Math.floor);return function(n){return n/i(c(u(n)+r))<=a?t(n):""}},o.copy=function(){return Ji(n.copy(),t,e,r)},Ii(o,n)}function Gi(n,t,e){function r(t){return n(u(t))}var u=Ki(t),i=Ki(1/t);return r.invert=function(t){return i(n.invert(t))},r.domain=function(t){return arguments.length?(n.domain((e=t.map(Number)).map(u)),r):e},r.ticks=function(n){return Xi(e,n)},r.tickFormat=function(n,t){return $i(e,n,t)},r.nice=function(n){return r.domain(Zi(e,n))},r.exponent=function(o){return arguments.length?(u=Ki(t=o),i=Ki(1/t),n.domain(e.map(u)),r):t},r.copy=function(){return Gi(n.copy(),t,e)},Ii(r,n)}function Ki(n){return function(t){return 0>t?-Math.pow(-t,n):Math.pow(t,n)}}function Qi(n,t){function e(e){return i[((u.get(e)||("range"===t.t?u.set(e,n.push(e)):0/0))-1)%i.length]}function r(t,e){return ta.range(n.length).map(function(n){return t+e*n})}var u,i,o;return e.domain=function(r){if(!arguments.length)return n;n=[],u=new a;for(var i,o=-1,c=r.length;++on?[0/0,0/0]:[n>0?a[n-1]:r[0],nt?0/0:t/i+n,[t,t+1/i]},r.copy=function(){return to(n,t,e)},u()}function eo(n,t){function e(e){return e>=e?t[ta.bisect(n,e)]:void 0}return e.domain=function(t){return arguments.length?(n=t,e):n},e.range=function(n){return arguments.length?(t=n,e):t},e.invertExtent=function(e){return e=t.indexOf(e),[n[e-1],n[e]]},e.copy=function(){return eo(n,t)},e}function ro(n){function t(n){return+n}return t.invert=t,t.domain=t.range=function(e){return arguments.length?(n=e.map(t),t):n},t.ticks=function(t){return Xi(n,t)},t.tickFormat=function(t,e){return $i(n,t,e)},t.copy=function(){return ro(n)},t}function uo(){return 0}function io(n){return n.innerRadius}function oo(n){return n.outerRadius}function ao(n){return n.startAngle}function co(n){return n.endAngle}function lo(n){return n&&n.padAngle}function so(n,t,e,r){return(n-e)*t-(t-r)*n>0?0:1}function fo(n,t,e,r,u){var i=n[0]-t[0],o=n[1]-t[1],a=(u?r:-r)/Math.sqrt(i*i+o*o),c=a*o,l=-a*i,s=n[0]+c,f=n[1]+l,h=t[0]+c,g=t[1]+l,p=(s+h)/2,v=(f+g)/2,d=h-s,m=g-f,y=d*d+m*m,M=e-r,x=s*g-h*f,b=(0>m?-1:1)*Math.sqrt(M*M*y-x*x),_=(x*m-d*b)/y,w=(-x*d-m*b)/y,S=(x*m+d*b)/y,k=(-x*d+m*b)/y,E=_-p,A=w-v,N=S-p,C=k-v;return E*E+A*A>N*N+C*C&&(_=S,w=k),[[_-c,w-l],[_*e/M,w*e/M]]}function ho(n){function t(t){function o(){l.push("M",i(n(s),a))}for(var c,l=[],s=[],f=-1,h=t.length,g=kt(e),p=kt(r);++f1&&u.push("H",r[0]),u.join("")}function mo(n){for(var t=0,e=n.length,r=n[0],u=[r[0],",",r[1]];++t1){a=t[1],i=n[c],c++,r+="C"+(u[0]+o[0])+","+(u[1]+o[1])+","+(i[0]-a[0])+","+(i[1]-a[1])+","+i[0]+","+i[1];for(var l=2;l9&&(u=3*t/Math.sqrt(u),o[a]=u*e,o[a+1]=u*r));for(a=-1;++a<=c;)u=(n[Math.min(c,a+1)][0]-n[Math.max(0,a-1)][0])/(6*(1+o[a]*o[a])),i.push([u||0,o[a]*u||0]);return i}function To(n){return n.length<3?go(n):n[0]+_o(n,Lo(n))}function Ro(n){for(var t,e,r,u=-1,i=n.length;++ur)return s();var u=i[i.active];u&&(--i.count,delete i[i.active],u.event&&u.event.interrupt.call(n,n.__data__,u.index)),i.active=r,o.event&&o.event.start.call(n,n.__data__,t),o.tween.forEach(function(e,r){(r=r.call(n,n.__data__,t))&&v.push(r)}),h=o.ease,f=o.duration,ta.timer(function(){return p.c=l(e||1)?Ne:l,1},0,c)}function l(e){if(i.active!==r)return 1;for(var u=e/f,a=h(u),c=v.length;c>0;)v[--c].call(n,a);return u>=1?(o.event&&o.event.end.call(n,n.__data__,t),s()):void 0}function s(){return--i.count?delete i[r]:delete n[e],1}var f,h,g=o.delay,p=oc,v=[];return p.t=g+c,u>=g?a(u-g):(p.c=a,void 0)},0,c)}}function Bo(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate("+(isFinite(r)?r:e(n))+",0)"})}function Wo(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate(0,"+(isFinite(r)?r:e(n))+")"})}function Jo(n){return n.toISOString()}function Go(n,t,e){function r(t){return n(t)}function u(n,e){var r=n[1]-n[0],u=r/e,i=ta.bisect(Wl,u);return i==Wl.length?[t.year,Vi(n.map(function(n){return n/31536e6}),e)[2]]:i?t[u/Wl[i-1]1?{floor:function(t){for(;e(t=n.floor(t));)t=Ko(t-1);return t},ceil:function(t){for(;e(t=n.ceil(t));)t=Ko(+t+1);return t}}:n))},r.ticks=function(n,t){var e=Pi(r.domain()),i=null==n?u(e,10):"number"==typeof n?u(e,n):!n.range&&[{range:n},t];return i&&(n=i[0],t=i[1]),n.range(e[0],Ko(+e[1]+1),1>t?1:t)},r.tickFormat=function(){return e},r.copy=function(){return Go(n.copy(),t,e)},Ii(r,n)}function Ko(n){return new Date(n)}function Qo(n){return JSON.parse(n.responseText)}function na(n){var t=ua.createRange();return t.selectNode(ua.body),t.createContextualFragment(n.responseText)}var ta={version:"3.5.2"};Date.now||(Date.now=function(){return+new Date});var ea=[].slice,ra=function(n){return ea.call(n)},ua=document,ia=ua.documentElement,oa=window;try{ra(ia.childNodes)[0].nodeType}catch(aa){ra=function(n){for(var t=n.length,e=new Array(t);t--;)e[t]=n[t];return e}}try{ua.createElement("div").style.setProperty("opacity",0,"")}catch(ca){var la=oa.Element.prototype,sa=la.setAttribute,fa=la.setAttributeNS,ha=oa.CSSStyleDeclaration.prototype,ga=ha.setProperty;la.setAttribute=function(n,t){sa.call(this,n,t+"")},la.setAttributeNS=function(n,t,e){fa.call(this,n,t,e+"")},ha.setProperty=function(n,t,e){ga.call(this,n,t+"",e)}}ta.ascending=n,ta.descending=function(n,t){return n>t?-1:t>n?1:t>=n?0:0/0},ta.min=function(n,t){var e,r,u=-1,i=n.length;if(1===arguments.length){for(;++u=r){e=r;break}for(;++ur&&(e=r)}else{for(;++u=r){e=r;break}for(;++ur&&(e=r)}return e},ta.max=function(n,t){var e,r,u=-1,i=n.length;if(1===arguments.length){for(;++u=r){e=r;break}for(;++ue&&(e=r)}else{for(;++u=r){e=r;break}for(;++ue&&(e=r)}return e},ta.extent=function(n,t){var e,r,u,i=-1,o=n.length;if(1===arguments.length){for(;++i=r){e=u=r;break}for(;++ir&&(e=r),r>u&&(u=r))}else{for(;++i=r){e=u=r;break}for(;++ir&&(e=r),r>u&&(u=r))}return[e,u]},ta.sum=function(n,t){var r,u=0,i=n.length,o=-1;if(1===arguments.length)for(;++o1?c/(s-1):void 0},ta.deviation=function(){var n=ta.variance.apply(this,arguments);return n?Math.sqrt(n):n};var pa=r(n);ta.bisectLeft=pa.left,ta.bisect=ta.bisectRight=pa.right,ta.bisector=function(t){return r(1===t.length?function(e,r){return n(t(e),r)}:t)},ta.shuffle=function(n,t,e){(i=arguments.length)<3&&(e=n.length,2>i&&(t=0));for(var r,u,i=e-t;i;)u=0|Math.random()*i--,r=n[i+t],n[i+t]=n[u+t],n[u+t]=r;return n},ta.permute=function(n,t){for(var e=t.length,r=new Array(e);e--;)r[e]=n[t[e]];return r},ta.pairs=function(n){for(var t,e=0,r=n.length-1,u=n[0],i=new Array(0>r?0:r);r>e;)i[e]=[t=u,u=n[++e]];return i},ta.zip=function(){if(!(r=arguments.length))return[];for(var n=-1,t=ta.min(arguments,u),e=new Array(t);++n=0;)for(r=n[u],t=r.length;--t>=0;)e[--o]=r[t];return e};var va=Math.abs;ta.range=function(n,t,e){if(arguments.length<3&&(e=1,arguments.length<2&&(t=n,n=0)),1/0===(t-n)/e)throw new Error("infinite range");var r,u=[],o=i(va(e)),a=-1;if(n*=o,t*=o,e*=o,0>e)for(;(r=n+e*++a)>t;)u.push(r/o);else for(;(r=n+e*++a)=i.length)return r?r.call(u,o):e?o.sort(e):o;for(var l,s,f,h,g=-1,p=o.length,v=i[c++],d=new a;++g=i.length)return n;var r=[],u=o[e++];return n.forEach(function(n,u){r.push({key:n,values:t(u,e)})}),u?r.sort(function(n,t){return u(n.key,t.key)}):r}var e,r,u={},i=[],o=[];return u.map=function(t,e){return n(e,t,0)},u.entries=function(e){return t(n(ta.map,e,0),0)},u.key=function(n){return i.push(n),u},u.sortKeys=function(n){return o[i.length-1]=n,u},u.sortValues=function(n){return e=n,u},u.rollup=function(n){return r=n,u},u},ta.set=function(n){var t=new v;if(n)for(var e=0,r=n.length;r>e;++e)t.add(n[e]);return t},o(v,{has:s,add:function(n){return this._[c(n+="")]=!0,n},remove:f,values:h,size:g,empty:p,forEach:function(n){for(var t in this._)n.call(this,l(t))}}),ta.behavior={},ta.rebind=function(n,t){for(var e,r=1,u=arguments.length;++r=0&&(r=n.slice(e+1),n=n.slice(0,e)),n)return arguments.length<2?this[n].on(r):this[n].on(r,t);if(2===arguments.length){if(null==t)for(n in this)this.hasOwnProperty(n)&&this[n].on(r,null);return this}},ta.event=null,ta.requote=function(n){return n.replace(Ma,"\\$&")};var Ma=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,xa={}.__proto__?function(n,t){n.__proto__=t}:function(n,t){for(var e in t)n[e]=t[e]},ba=function(n,t){return t.querySelector(n)},_a=function(n,t){return t.querySelectorAll(n)},wa=ia.matches||ia[m(ia,"matchesSelector")],Sa=function(n,t){return wa.call(n,t)};"function"==typeof Sizzle&&(ba=function(n,t){return Sizzle(n,t)[0]||null},_a=Sizzle,Sa=Sizzle.matchesSelector),ta.selection=function(){return Na};var ka=ta.selection.prototype=[];ka.select=function(n){var t,e,r,u,i=[];n=k(n);for(var o=-1,a=this.length;++o=0&&(e=n.slice(0,t),n=n.slice(t+1)),Ea.hasOwnProperty(e)?{space:Ea[e],local:n}:n}},ka.attr=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node();return n=ta.ns.qualify(n),n.local?e.getAttributeNS(n.space,n.local):e.getAttribute(n)}for(t in n)this.each(A(t,n[t]));return this}return this.each(A(n,t))},ka.classed=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node(),r=(n=z(n)).length,u=-1;if(t=e.classList){for(;++ur){if("string"!=typeof n){2>r&&(t="");for(e in n)this.each(T(e,n[e],t));return this}if(2>r)return oa.getComputedStyle(this.node(),null).getPropertyValue(n);e=""}return this.each(T(n,t,e))},ka.property=function(n,t){if(arguments.length<2){if("string"==typeof n)return this.node()[n];for(t in n)this.each(R(t,n[t]));return this}return this.each(R(n,t))},ka.text=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.textContent=null==t?"":t}:null==n?function(){this.textContent=""}:function(){this.textContent=n}):this.node().textContent},ka.html=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.innerHTML=null==t?"":t}:null==n?function(){this.innerHTML=""}:function(){this.innerHTML=n}):this.node().innerHTML},ka.append=function(n){return n=D(n),this.select(function(){return this.appendChild(n.apply(this,arguments))})},ka.insert=function(n,t){return n=D(n),t=k(t),this.select(function(){return this.insertBefore(n.apply(this,arguments),t.apply(this,arguments)||null)})},ka.remove=function(){return this.each(P)},ka.data=function(n,t){function e(n,e){var r,u,i,o=n.length,f=e.length,h=Math.min(o,f),g=new Array(f),p=new Array(f),v=new Array(o);if(t){var d,m=new a,y=new Array(o);for(r=-1;++rr;++r)p[r]=U(e[r]);for(;o>r;++r)v[r]=n[r]}p.update=g,p.parentNode=g.parentNode=v.parentNode=n.parentNode,c.push(p),l.push(g),s.push(v)}var r,u,i=-1,o=this.length;if(!arguments.length){for(n=new Array(o=(r=this[0]).length);++ii;i++){u.push(t=[]),t.parentNode=(e=this[i]).parentNode;for(var a=0,c=e.length;c>a;a++)(r=e[a])&&n.call(r,r.__data__,a,i)&&t.push(r)}return S(u)},ka.order=function(){for(var n=-1,t=this.length;++n=0;)(e=r[u])&&(i&&i!==e.nextSibling&&i.parentNode.insertBefore(e,i),i=e);return this},ka.sort=function(n){n=F.apply(this,arguments);for(var t=-1,e=this.length;++tn;n++)for(var e=this[n],r=0,u=e.length;u>r;r++){var i=e[r];if(i)return i}return null},ka.size=function(){var n=0;return H(this,function(){++n}),n};var Aa=[];ta.selection.enter=O,ta.selection.enter.prototype=Aa,Aa.append=ka.append,Aa.empty=ka.empty,Aa.node=ka.node,Aa.call=ka.call,Aa.size=ka.size,Aa.select=function(n){for(var t,e,r,u,i,o=[],a=-1,c=this.length;++ar){if("string"!=typeof n){2>r&&(t=!1);for(e in n)this.each(I(e,n[e],t));return this}if(2>r)return(r=this.node()["__on"+n])&&r._;e=!1}return this.each(I(n,t,e))};var Ca=ta.map({mouseenter:"mouseover",mouseleave:"mouseout"});Ca.forEach(function(n){"on"+n in ua&&Ca.remove(n)});var za="onselectstart"in ua?null:m(ia.style,"userSelect"),qa=0;ta.mouse=function(n){return $(n,_())};var La=/WebKit/.test(oa.navigator.userAgent)?-1:0;ta.touch=function(n,t,e){if(arguments.length<3&&(e=t,t=_().changedTouches),t)for(var r,u=0,i=t.length;i>u;++u)if((r=t[u]).identifier===e)return $(n,r)},ta.behavior.drag=function(){function n(){this.on("mousedown.drag",u).on("touchstart.drag",i)}function t(n,t,u,i,o){return function(){function a(){var n,e,r=t(h,v);r&&(n=r[0]-M[0],e=r[1]-M[1],p|=n|e,M=r,g({type:"drag",x:r[0]+l[0],y:r[1]+l[1],dx:n,dy:e}))}function c(){t(h,v)&&(m.on(i+d,null).on(o+d,null),y(p&&ta.event.target===f),g({type:"dragend"}))}var l,s=this,f=ta.event.target,h=s.parentNode,g=e.of(s,arguments),p=0,v=n(),d=".drag"+(null==v?"":"-"+v),m=ta.select(u()).on(i+d,a).on(o+d,c),y=X(),M=t(h,v);r?(l=r.apply(s,arguments),l=[l.x-M[0],l.y-M[1]]):l=[0,0],g({type:"dragstart"})}}var e=w(n,"drag","dragstart","dragend"),r=null,u=t(y,ta.mouse,J,"mousemove","mouseup"),i=t(B,ta.touch,W,"touchmove","touchend");return n.origin=function(t){return arguments.length?(r=t,n):r},ta.rebind(n,e,"on")},ta.touches=function(n,t){return arguments.length<2&&(t=_().touches),t?ra(t).map(function(t){var e=$(n,t);return e.identifier=t.identifier,e}):[]};var Ta=1e-6,Ra=Ta*Ta,Da=Math.PI,Pa=2*Da,Ua=Pa-Ta,ja=Da/2,Fa=Da/180,Ha=180/Da,Oa=Math.SQRT2,Ya=2,Ia=4;ta.interpolateZoom=function(n,t){function e(n){var t=n*y;if(m){var e=et(v),o=i/(Ya*h)*(e*rt(Oa*t+v)-tt(v));return[r+o*l,u+o*s,i*e/et(Oa*t+v)]}return[r+n*l,u+n*s,i*Math.exp(Oa*t)]}var r=n[0],u=n[1],i=n[2],o=t[0],a=t[1],c=t[2],l=o-r,s=a-u,f=l*l+s*s,h=Math.sqrt(f),g=(c*c-i*i+Ia*f)/(2*i*Ya*h),p=(c*c-i*i-Ia*f)/(2*c*Ya*h),v=Math.log(Math.sqrt(g*g+1)-g),d=Math.log(Math.sqrt(p*p+1)-p),m=d-v,y=(m||Math.log(c/i))/Oa;return e.duration=1e3*y,e},ta.behavior.zoom=function(){function n(n){n.on(z,s).on(Xa+".zoom",h).on("dblclick.zoom",g).on(T,f)}function t(n){return[(n[0]-k.x)/k.k,(n[1]-k.y)/k.k]}function e(n){return[n[0]*k.k+k.x,n[1]*k.k+k.y]}function r(n){k.k=Math.max(A[0],Math.min(A[1],n))}function u(n,t){t=e(t),k.x+=n[0]-t[0],k.y+=n[1]-t[1]}function i(t,e,i,o){t.__chart__={x:k.x,y:k.y,k:k.k},r(Math.pow(2,o)),u(v=e,i),t=ta.select(t),N>0&&(t=t.transition().duration(N)),t.call(n.event)}function o(){x&&x.domain(M.range().map(function(n){return(n-k.x)/k.k}).map(M.invert)),S&&S.domain(_.range().map(function(n){return(n-k.y)/k.k}).map(_.invert))}function a(n){C++||n({type:"zoomstart"})}function c(n){o(),n({type:"zoom",scale:k.k,translate:[k.x,k.y]})}function l(n){--C||n({type:"zoomend"}),v=null}function s(){function n(){s=1,u(ta.mouse(r),h),c(o)}function e(){f.on(q,null).on(L,null),g(s&&ta.event.target===i),l(o)}var r=this,i=ta.event.target,o=R.of(r,arguments),s=0,f=ta.select(oa).on(q,n).on(L,e),h=t(ta.mouse(r)),g=X();Fl.call(r),a(o)}function f(){function n(){var n=ta.touches(p);return g=k.k,n.forEach(function(n){n.identifier in d&&(d[n.identifier]=t(n))}),n}function e(){var t=ta.event.target;ta.select(t).on(x,o).on(_,h),w.push(t);for(var e=ta.event.changedTouches,r=0,u=e.length;u>r;++r)d[e[r].identifier]=null;var a=n(),c=Date.now();if(1===a.length){if(500>c-y){var l=a[0];i(p,l,d[l.identifier],Math.floor(Math.log(k.k)/Math.LN2)+1),b()}y=c}else if(a.length>1){var l=a[0],s=a[1],f=l[0]-s[0],g=l[1]-s[1];m=f*f+g*g}}function o(){var n,t,e,i,o=ta.touches(p);Fl.call(p);for(var a=0,l=o.length;l>a;++a,i=null)if(e=o[a],i=d[e.identifier]){if(t)break;n=e,t=i}if(i){var s=(s=e[0]-n[0])*s+(s=e[1]-n[1])*s,f=m&&Math.sqrt(s/m);n=[(n[0]+e[0])/2,(n[1]+e[1])/2],t=[(t[0]+i[0])/2,(t[1]+i[1])/2],r(f*g)}y=null,u(n,t),c(v)}function h(){if(ta.event.touches.length){for(var t=ta.event.changedTouches,e=0,r=t.length;r>e;++e)delete d[t[e].identifier];for(var u in d)return void n()}ta.selectAll(w).on(M,null),S.on(z,s).on(T,f),E(),l(v)}var g,p=this,v=R.of(p,arguments),d={},m=0,M=".zoom-"+ta.event.changedTouches[0].identifier,x="touchmove"+M,_="touchend"+M,w=[],S=ta.select(p),E=X();e(),a(v),S.on(z,null).on(T,e)}function h(){var n=R.of(this,arguments);m?clearTimeout(m):(p=t(v=d||ta.mouse(this)),Fl.call(this),a(n)),m=setTimeout(function(){m=null,l(n)},50),b(),r(Math.pow(2,.002*Za())*k.k),u(v,p),c(n)}function g(){var n=ta.mouse(this),e=Math.log(k.k)/Math.LN2;i(this,n,t(n),ta.event.shiftKey?Math.ceil(e)-1:Math.floor(e)+1)}var p,v,d,m,y,M,x,_,S,k={x:0,y:0,k:1},E=[960,500],A=Va,N=250,C=0,z="mousedown.zoom",q="mousemove.zoom",L="mouseup.zoom",T="touchstart.zoom",R=w(n,"zoomstart","zoom","zoomend");return n.event=function(n){n.each(function(){var n=R.of(this,arguments),t=k;Ul?ta.select(this).transition().each("start.zoom",function(){k=this.__chart__||{x:0,y:0,k:1},a(n)}).tween("zoom:zoom",function(){var e=E[0],r=E[1],u=v?v[0]:e/2,i=v?v[1]:r/2,o=ta.interpolateZoom([(u-k.x)/k.k,(i-k.y)/k.k,e/k.k],[(u-t.x)/t.k,(i-t.y)/t.k,e/t.k]);return function(t){var r=o(t),a=e/r[2];this.__chart__=k={x:u-r[0]*a,y:i-r[1]*a,k:a},c(n)}}).each("interrupt.zoom",function(){l(n)}).each("end.zoom",function(){l(n)}):(this.__chart__=k,a(n),c(n),l(n))})},n.translate=function(t){return arguments.length?(k={x:+t[0],y:+t[1],k:k.k},o(),n):[k.x,k.y]},n.scale=function(t){return arguments.length?(k={x:k.x,y:k.y,k:+t},o(),n):k.k},n.scaleExtent=function(t){return arguments.length?(A=null==t?Va:[+t[0],+t[1]],n):A},n.center=function(t){return arguments.length?(d=t&&[+t[0],+t[1]],n):d},n.size=function(t){return arguments.length?(E=t&&[+t[0],+t[1]],n):E},n.duration=function(t){return arguments.length?(N=+t,n):N},n.x=function(t){return arguments.length?(x=t,M=t.copy(),k={x:0,y:0,k:1},n):x},n.y=function(t){return arguments.length?(S=t,_=t.copy(),k={x:0,y:0,k:1},n):S},ta.rebind(n,R,"on")};var Za,Va=[0,1/0],Xa="onwheel"in ua?(Za=function(){return-ta.event.deltaY*(ta.event.deltaMode?120:1)},"wheel"):"onmousewheel"in ua?(Za=function(){return ta.event.wheelDelta},"mousewheel"):(Za=function(){return-ta.event.detail},"MozMousePixelScroll");ta.color=it,it.prototype.toString=function(){return this.rgb()+""},ta.hsl=ot;var $a=ot.prototype=new it;$a.brighter=function(n){return n=Math.pow(.7,arguments.length?n:1),new ot(this.h,this.s,this.l/n)},$a.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new ot(this.h,this.s,n*this.l)},$a.rgb=function(){return at(this.h,this.s,this.l)},ta.hcl=ct;var Ba=ct.prototype=new it;Ba.brighter=function(n){return new ct(this.h,this.c,Math.min(100,this.l+Wa*(arguments.length?n:1)))},Ba.darker=function(n){return new ct(this.h,this.c,Math.max(0,this.l-Wa*(arguments.length?n:1)))},Ba.rgb=function(){return lt(this.h,this.c,this.l).rgb()},ta.lab=st;var Wa=18,Ja=.95047,Ga=1,Ka=1.08883,Qa=st.prototype=new it;Qa.brighter=function(n){return new st(Math.min(100,this.l+Wa*(arguments.length?n:1)),this.a,this.b)},Qa.darker=function(n){return new st(Math.max(0,this.l-Wa*(arguments.length?n:1)),this.a,this.b)},Qa.rgb=function(){return ft(this.l,this.a,this.b)},ta.rgb=dt;var nc=dt.prototype=new it;nc.brighter=function(n){n=Math.pow(.7,arguments.length?n:1);var t=this.r,e=this.g,r=this.b,u=30;return t||e||r?(t&&u>t&&(t=u),e&&u>e&&(e=u),r&&u>r&&(r=u),new dt(Math.min(255,t/n),Math.min(255,e/n),Math.min(255,r/n))):new dt(u,u,u)},nc.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new dt(n*this.r,n*this.g,n*this.b)},nc.hsl=function(){return bt(this.r,this.g,this.b)},nc.toString=function(){return"#"+Mt(this.r)+Mt(this.g)+Mt(this.b)};var tc=ta.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});tc.forEach(function(n,t){tc.set(n,mt(t))}),ta.functor=kt,ta.xhr=At(Et),ta.dsv=function(n,t){function e(n,e,i){arguments.length<3&&(i=e,e=null);var o=Nt(n,t,null==e?r:u(e),i);return o.row=function(n){return arguments.length?o.response(null==(e=n)?r:u(n)):e},o}function r(n){return e.parse(n.responseText)}function u(n){return function(t){return e.parse(t.responseText,n)}}function i(t){return t.map(o).join(n)}function o(n){return a.test(n)?'"'+n.replace(/\"/g,'""')+'"':n}var a=new RegExp('["'+n+"\n]"),c=n.charCodeAt(0);return e.parse=function(n,t){var r;return e.parseRows(n,function(n,e){if(r)return r(n,e-1);var u=new Function("d","return {"+n.map(function(n,t){return JSON.stringify(n)+": d["+t+"]"}).join(",")+"}");r=t?function(n,e){return t(u(n),e)}:u})},e.parseRows=function(n,t){function e(){if(s>=l)return o;if(u)return u=!1,i;var t=s;if(34===n.charCodeAt(t)){for(var e=t;e++s;){var r=n.charCodeAt(s++),a=1;if(10===r)u=!0;else if(13===r)u=!0,10===n.charCodeAt(s)&&(++s,++a);else if(r!==c)continue;return n.slice(t,s-a)}return n.slice(t)}for(var r,u,i={},o={},a=[],l=n.length,s=0,f=0;(r=e())!==o;){for(var h=[];r!==i&&r!==o;)h.push(r),r=e();t&&null==(h=t(h,f++))||a.push(h)}return a},e.format=function(t){if(Array.isArray(t[0]))return e.formatRows(t);var r=new v,u=[];return t.forEach(function(n){for(var t in n)r.has(t)||u.push(r.add(t))}),[u.map(o).join(n)].concat(t.map(function(t){return u.map(function(n){return o(t[n])}).join(n)})).join("\n")},e.formatRows=function(n){return n.map(i).join("\n")},e},ta.csv=ta.dsv(",","text/csv"),ta.tsv=ta.dsv(" ","text/tab-separated-values");var ec,rc,uc,ic,oc,ac=oa[m(oa,"requestAnimationFrame")]||function(n){setTimeout(n,17)};ta.timer=function(n,t,e){var r=arguments.length;2>r&&(t=0),3>r&&(e=Date.now());var u=e+t,i={c:n,t:u,f:!1,n:null};rc?rc.n=i:ec=i,rc=i,uc||(ic=clearTimeout(ic),uc=1,ac(qt))},ta.timer.flush=function(){Lt(),Tt()},ta.round=function(n,t){return t?Math.round(n*(t=Math.pow(10,t)))/t:Math.round(n)};var cc=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(Dt);ta.formatPrefix=function(n,t){var e=0;return n&&(0>n&&(n*=-1),t&&(n=ta.round(n,Rt(n,t))),e=1+Math.floor(1e-12+Math.log(n)/Math.LN10),e=Math.max(-24,Math.min(24,3*Math.floor((e-1)/3)))),cc[8+e/3]};var lc=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,sc=ta.map({b:function(n){return n.toString(2)},c:function(n){return String.fromCharCode(n)},o:function(n){return n.toString(8)},x:function(n){return n.toString(16)},X:function(n){return n.toString(16).toUpperCase()},g:function(n,t){return n.toPrecision(t)},e:function(n,t){return n.toExponential(t)},f:function(n,t){return n.toFixed(t)},r:function(n,t){return(n=ta.round(n,Rt(n,t))).toFixed(Math.max(0,Math.min(20,Rt(n*(1+1e-15),t))))}}),fc=ta.time={},hc=Date;jt.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){gc.setUTCDate.apply(this._,arguments)},setDay:function(){gc.setUTCDay.apply(this._,arguments)},setFullYear:function(){gc.setUTCFullYear.apply(this._,arguments)},setHours:function(){gc.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){gc.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){gc.setUTCMinutes.apply(this._,arguments)},setMonth:function(){gc.setUTCMonth.apply(this._,arguments)},setSeconds:function(){gc.setUTCSeconds.apply(this._,arguments)},setTime:function(){gc.setTime.apply(this._,arguments)}};var gc=Date.prototype;fc.year=Ft(function(n){return n=fc.day(n),n.setMonth(0,1),n},function(n,t){n.setFullYear(n.getFullYear()+t)},function(n){return n.getFullYear()}),fc.years=fc.year.range,fc.years.utc=fc.year.utc.range,fc.day=Ft(function(n){var t=new hc(2e3,0);return t.setFullYear(n.getFullYear(),n.getMonth(),n.getDate()),t},function(n,t){n.setDate(n.getDate()+t)},function(n){return n.getDate()-1}),fc.days=fc.day.range,fc.days.utc=fc.day.utc.range,fc.dayOfYear=function(n){var t=fc.year(n);return Math.floor((n-t-6e4*(n.getTimezoneOffset()-t.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(n,t){t=7-t;var e=fc[n]=Ft(function(n){return(n=fc.day(n)).setDate(n.getDate()-(n.getDay()+t)%7),n},function(n,t){n.setDate(n.getDate()+7*Math.floor(t))},function(n){var e=fc.year(n).getDay();return Math.floor((fc.dayOfYear(n)+(e+t)%7)/7)-(e!==t)});fc[n+"s"]=e.range,fc[n+"s"].utc=e.utc.range,fc[n+"OfYear"]=function(n){var e=fc.year(n).getDay();return Math.floor((fc.dayOfYear(n)+(e+t)%7)/7)}}),fc.week=fc.sunday,fc.weeks=fc.sunday.range,fc.weeks.utc=fc.sunday.utc.range,fc.weekOfYear=fc.sundayOfYear;var pc={"-":"",_:" ",0:"0"},vc=/^\s*\d+/,dc=/^%/;ta.locale=function(n){return{numberFormat:Pt(n),timeFormat:Ot(n)}};var mc=ta.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});ta.format=mc.numberFormat,ta.geo={},ce.prototype={s:0,t:0,add:function(n){le(n,this.t,yc),le(yc.s,this.s,this),this.s?this.t+=yc.t:this.s=yc.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var yc=new ce;ta.geo.stream=function(n,t){n&&Mc.hasOwnProperty(n.type)?Mc[n.type](n,t):se(n,t)};var Mc={Feature:function(n,t){se(n.geometry,t)},FeatureCollection:function(n,t){for(var e=n.features,r=-1,u=e.length;++rn?4*Da+n:n,wc.lineStart=wc.lineEnd=wc.point=y}};ta.geo.bounds=function(){function n(n,t){M.push(x=[s=n,h=n]),f>t&&(f=t),t>g&&(g=t)}function t(t,e){var r=pe([t*Fa,e*Fa]);if(m){var u=de(m,r),i=[u[1],-u[0],0],o=de(i,u);Me(o),o=xe(o);var c=t-p,l=c>0?1:-1,v=o[0]*Ha*l,d=va(c)>180;if(d^(v>l*p&&l*t>v)){var y=o[1]*Ha;y>g&&(g=y)}else if(v=(v+360)%360-180,d^(v>l*p&&l*t>v)){var y=-o[1]*Ha;f>y&&(f=y)}else f>e&&(f=e),e>g&&(g=e);d?p>t?a(s,t)>a(s,h)&&(h=t):a(t,h)>a(s,h)&&(s=t):h>=s?(s>t&&(s=t),t>h&&(h=t)):t>p?a(s,t)>a(s,h)&&(h=t):a(t,h)>a(s,h)&&(s=t)}else n(t,e);m=r,p=t}function e(){b.point=t}function r(){x[0]=s,x[1]=h,b.point=n,m=null}function u(n,e){if(m){var r=n-p;y+=va(r)>180?r+(r>0?360:-360):r}else v=n,d=e;wc.point(n,e),t(n,e)}function i(){wc.lineStart()}function o(){u(v,d),wc.lineEnd(),va(y)>Ta&&(s=-(h=180)),x[0]=s,x[1]=h,m=null}function a(n,t){return(t-=n)<0?t+360:t}function c(n,t){return n[0]-t[0]}function l(n,t){return t[0]<=t[1]?t[0]<=n&&n<=t[1]:n_c?(s=-(h=180),f=-(g=90)):y>Ta?g=90:-Ta>y&&(f=-90),x[0]=s,x[1]=h}};return function(n){g=h=-(s=f=1/0),M=[],ta.geo.stream(n,b);var t=M.length;if(t){M.sort(c);for(var e,r=1,u=M[0],i=[u];t>r;++r)e=M[r],l(e[0],u)||l(e[1],u)?(a(u[0],e[1])>a(u[0],u[1])&&(u[1]=e[1]),a(e[0],u[1])>a(u[0],u[1])&&(u[0]=e[0])):i.push(u=e);for(var o,e,p=-1/0,t=i.length-1,r=0,u=i[t];t>=r;u=e,++r)e=i[r],(o=a(u[1],e[0]))>p&&(p=o,s=e[0],h=u[1])}return M=x=null,1/0===s||1/0===f?[[0/0,0/0],[0/0,0/0]]:[[s,f],[h,g]]}}(),ta.geo.centroid=function(n){Sc=kc=Ec=Ac=Nc=Cc=zc=qc=Lc=Tc=Rc=0,ta.geo.stream(n,Dc);var t=Lc,e=Tc,r=Rc,u=t*t+e*e+r*r;return Ra>u&&(t=Cc,e=zc,r=qc,Ta>kc&&(t=Ec,e=Ac,r=Nc),u=t*t+e*e+r*r,Ra>u)?[0/0,0/0]:[Math.atan2(e,t)*Ha,nt(r/Math.sqrt(u))*Ha]};var Sc,kc,Ec,Ac,Nc,Cc,zc,qc,Lc,Tc,Rc,Dc={sphere:y,point:_e,lineStart:Se,lineEnd:ke,polygonStart:function(){Dc.lineStart=Ee},polygonEnd:function(){Dc.lineStart=Se}},Pc=Le(Ne,Pe,je,[-Da,-Da/2]),Uc=1e9;ta.geo.clipExtent=function(){var n,t,e,r,u,i,o={stream:function(n){return u&&(u.valid=!1),u=i(n),u.valid=!0,u},extent:function(a){return arguments.length?(i=Ye(n=+a[0][0],t=+a[0][1],e=+a[1][0],r=+a[1][1]),u&&(u.valid=!1,u=null),o):[[n,t],[e,r]]}};return o.extent([[0,0],[960,500]])},(ta.geo.conicEqualArea=function(){return Ie(Ze)}).raw=Ze,ta.geo.albers=function(){return ta.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},ta.geo.albersUsa=function(){function n(n){var i=n[0],o=n[1];return t=null,e(i,o),t||(r(i,o),t)||u(i,o),t}var t,e,r,u,i=ta.geo.albers(),o=ta.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),a=ta.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),c={point:function(n,e){t=[n,e]}};return n.invert=function(n){var t=i.scale(),e=i.translate(),r=(n[0]-e[0])/t,u=(n[1]-e[1])/t;return(u>=.12&&.234>u&&r>=-.425&&-.214>r?o:u>=.166&&.234>u&&r>=-.214&&-.115>r?a:i).invert(n)},n.stream=function(n){var t=i.stream(n),e=o.stream(n),r=a.stream(n);return{point:function(n,u){t.point(n,u),e.point(n,u),r.point(n,u)},sphere:function(){t.sphere(),e.sphere(),r.sphere()},lineStart:function(){t.lineStart(),e.lineStart(),r.lineStart()},lineEnd:function(){t.lineEnd(),e.lineEnd(),r.lineEnd()},polygonStart:function(){t.polygonStart(),e.polygonStart(),r.polygonStart()},polygonEnd:function(){t.polygonEnd(),e.polygonEnd(),r.polygonEnd()}}},n.precision=function(t){return arguments.length?(i.precision(t),o.precision(t),a.precision(t),n):i.precision()},n.scale=function(t){return arguments.length?(i.scale(t),o.scale(.35*t),a.scale(t),n.translate(i.translate())):i.scale()},n.translate=function(t){if(!arguments.length)return i.translate();var l=i.scale(),s=+t[0],f=+t[1];return e=i.translate(t).clipExtent([[s-.455*l,f-.238*l],[s+.455*l,f+.238*l]]).stream(c).point,r=o.translate([s-.307*l,f+.201*l]).clipExtent([[s-.425*l+Ta,f+.12*l+Ta],[s-.214*l-Ta,f+.234*l-Ta]]).stream(c).point,u=a.translate([s-.205*l,f+.212*l]).clipExtent([[s-.214*l+Ta,f+.166*l+Ta],[s-.115*l-Ta,f+.234*l-Ta]]).stream(c).point,n},n.scale(1070)};var jc,Fc,Hc,Oc,Yc,Ic,Zc={point:y,lineStart:y,lineEnd:y,polygonStart:function(){Fc=0,Zc.lineStart=Ve},polygonEnd:function(){Zc.lineStart=Zc.lineEnd=Zc.point=y,jc+=va(Fc/2)}},Vc={point:Xe,lineStart:y,lineEnd:y,polygonStart:y,polygonEnd:y},Xc={point:We,lineStart:Je,lineEnd:Ge,polygonStart:function(){Xc.lineStart=Ke},polygonEnd:function(){Xc.point=We,Xc.lineStart=Je,Xc.lineEnd=Ge}};ta.geo.path=function(){function n(n){return n&&("function"==typeof a&&i.pointRadius(+a.apply(this,arguments)),o&&o.valid||(o=u(i)),ta.geo.stream(n,o)),i.result()}function t(){return o=null,n}var e,r,u,i,o,a=4.5;return n.area=function(n){return jc=0,ta.geo.stream(n,u(Zc)),jc},n.centroid=function(n){return Ec=Ac=Nc=Cc=zc=qc=Lc=Tc=Rc=0,ta.geo.stream(n,u(Xc)),Rc?[Lc/Rc,Tc/Rc]:qc?[Cc/qc,zc/qc]:Nc?[Ec/Nc,Ac/Nc]:[0/0,0/0]},n.bounds=function(n){return Yc=Ic=-(Hc=Oc=1/0),ta.geo.stream(n,u(Vc)),[[Hc,Oc],[Yc,Ic]]},n.projection=function(n){return arguments.length?(u=(e=n)?n.stream||tr(n):Et,t()):e},n.context=function(n){return arguments.length?(i=null==(r=n)?new $e:new Qe(n),"function"!=typeof a&&i.pointRadius(a),t()):r},n.pointRadius=function(t){return arguments.length?(a="function"==typeof t?t:(i.pointRadius(+t),+t),n):a},n.projection(ta.geo.albersUsa()).context(null)},ta.geo.transform=function(n){return{stream:function(t){var e=new er(t);for(var r in n)e[r]=n[r];return e}}},er.prototype={point:function(n,t){this.stream.point(n,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},ta.geo.projection=ur,ta.geo.projectionMutator=ir,(ta.geo.equirectangular=function(){return ur(ar)}).raw=ar.invert=ar,ta.geo.rotation=function(n){function t(t){return t=n(t[0]*Fa,t[1]*Fa),t[0]*=Ha,t[1]*=Ha,t}return n=lr(n[0]%360*Fa,n[1]*Fa,n.length>2?n[2]*Fa:0),t.invert=function(t){return t=n.invert(t[0]*Fa,t[1]*Fa),t[0]*=Ha,t[1]*=Ha,t},t},cr.invert=ar,ta.geo.circle=function(){function n(){var n="function"==typeof r?r.apply(this,arguments):r,t=lr(-n[0]*Fa,-n[1]*Fa,0).invert,u=[];return e(null,null,1,{point:function(n,e){u.push(n=t(n,e)),n[0]*=Ha,n[1]*=Ha}}),{type:"Polygon",coordinates:[u]}}var t,e,r=[0,0],u=6;return n.origin=function(t){return arguments.length?(r=t,n):r},n.angle=function(r){return arguments.length?(e=gr((t=+r)*Fa,u*Fa),n):t},n.precision=function(r){return arguments.length?(e=gr(t*Fa,(u=+r)*Fa),n):u},n.angle(90)},ta.geo.distance=function(n,t){var e,r=(t[0]-n[0])*Fa,u=n[1]*Fa,i=t[1]*Fa,o=Math.sin(r),a=Math.cos(r),c=Math.sin(u),l=Math.cos(u),s=Math.sin(i),f=Math.cos(i);return Math.atan2(Math.sqrt((e=f*o)*e+(e=l*s-c*f*a)*e),c*s+l*f*a)},ta.geo.graticule=function(){function n(){return{type:"MultiLineString",coordinates:t()}}function t(){return ta.range(Math.ceil(i/d)*d,u,d).map(h).concat(ta.range(Math.ceil(l/m)*m,c,m).map(g)).concat(ta.range(Math.ceil(r/p)*p,e,p).filter(function(n){return va(n%d)>Ta}).map(s)).concat(ta.range(Math.ceil(a/v)*v,o,v).filter(function(n){return va(n%m)>Ta}).map(f))}var e,r,u,i,o,a,c,l,s,f,h,g,p=10,v=p,d=90,m=360,y=2.5;return n.lines=function(){return t().map(function(n){return{type:"LineString",coordinates:n}})},n.outline=function(){return{type:"Polygon",coordinates:[h(i).concat(g(c).slice(1),h(u).reverse().slice(1),g(l).reverse().slice(1))]}},n.extent=function(t){return arguments.length?n.majorExtent(t).minorExtent(t):n.minorExtent()},n.majorExtent=function(t){return arguments.length?(i=+t[0][0],u=+t[1][0],l=+t[0][1],c=+t[1][1],i>u&&(t=i,i=u,u=t),l>c&&(t=l,l=c,c=t),n.precision(y)):[[i,l],[u,c]]},n.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],a=+t[0][1],o=+t[1][1],r>e&&(t=r,r=e,e=t),a>o&&(t=a,a=o,o=t),n.precision(y)):[[r,a],[e,o]]},n.step=function(t){return arguments.length?n.majorStep(t).minorStep(t):n.minorStep()},n.majorStep=function(t){return arguments.length?(d=+t[0],m=+t[1],n):[d,m]},n.minorStep=function(t){return arguments.length?(p=+t[0],v=+t[1],n):[p,v]},n.precision=function(t){return arguments.length?(y=+t,s=vr(a,o,90),f=dr(r,e,y),h=vr(l,c,90),g=dr(i,u,y),n):y},n.majorExtent([[-180,-90+Ta],[180,90-Ta]]).minorExtent([[-180,-80-Ta],[180,80+Ta]])},ta.geo.greatArc=function(){function n(){return{type:"LineString",coordinates:[t||r.apply(this,arguments),e||u.apply(this,arguments)]}}var t,e,r=mr,u=yr;return n.distance=function(){return ta.geo.distance(t||r.apply(this,arguments),e||u.apply(this,arguments))},n.source=function(e){return arguments.length?(r=e,t="function"==typeof e?null:e,n):r},n.target=function(t){return arguments.length?(u=t,e="function"==typeof t?null:t,n):u},n.precision=function(){return arguments.length?n:0},n},ta.geo.interpolate=function(n,t){return Mr(n[0]*Fa,n[1]*Fa,t[0]*Fa,t[1]*Fa)},ta.geo.length=function(n){return $c=0,ta.geo.stream(n,Bc),$c};var $c,Bc={sphere:y,point:y,lineStart:xr,lineEnd:y,polygonStart:y,polygonEnd:y},Wc=br(function(n){return Math.sqrt(2/(1+n))},function(n){return 2*Math.asin(n/2)});(ta.geo.azimuthalEqualArea=function(){return ur(Wc)}).raw=Wc;var Jc=br(function(n){var t=Math.acos(n);return t&&t/Math.sin(t)},Et);(ta.geo.azimuthalEquidistant=function(){return ur(Jc)}).raw=Jc,(ta.geo.conicConformal=function(){return Ie(_r)}).raw=_r,(ta.geo.conicEquidistant=function(){return Ie(wr)}).raw=wr;var Gc=br(function(n){return 1/n},Math.atan);(ta.geo.gnomonic=function(){return ur(Gc)}).raw=Gc,Sr.invert=function(n,t){return[n,2*Math.atan(Math.exp(t))-ja]},(ta.geo.mercator=function(){return kr(Sr)}).raw=Sr;var Kc=br(function(){return 1},Math.asin);(ta.geo.orthographic=function(){return ur(Kc)}).raw=Kc;var Qc=br(function(n){return 1/(1+n)},function(n){return 2*Math.atan(n)});(ta.geo.stereographic=function(){return ur(Qc)}).raw=Qc,Er.invert=function(n,t){return[-t,2*Math.atan(Math.exp(n))-ja]},(ta.geo.transverseMercator=function(){var n=kr(Er),t=n.center,e=n.rotate;return n.center=function(n){return n?t([-n[1],n[0]]):(n=t(),[n[1],-n[0]])},n.rotate=function(n){return n?e([n[0],n[1],n.length>2?n[2]+90:90]):(n=e(),[n[0],n[1],n[2]-90])},e([0,0,90])}).raw=Er,ta.geom={},ta.geom.hull=function(n){function t(n){if(n.length<3)return[];var t,u=kt(e),i=kt(r),o=n.length,a=[],c=[];for(t=0;o>t;t++)a.push([+u.call(this,n[t],t),+i.call(this,n[t],t),t]);for(a.sort(zr),t=0;o>t;t++)c.push([a[t][0],-a[t][1]]);var l=Cr(a),s=Cr(c),f=s[0]===l[0],h=s[s.length-1]===l[l.length-1],g=[];for(t=l.length-1;t>=0;--t)g.push(n[a[l[t]][2]]);for(t=+f;t=r&&l.x<=i&&l.y>=u&&l.y<=o?[[r,o],[i,o],[i,u],[r,u]]:[];s.point=n[a]}),t}function e(n){return n.map(function(n,t){return{x:Math.round(i(n,t)/Ta)*Ta,y:Math.round(o(n,t)/Ta)*Ta,i:t}})}var r=Ar,u=Nr,i=r,o=u,a=cl;return n?t(n):(t.links=function(n){return iu(e(n)).edges.filter(function(n){return n.l&&n.r}).map(function(t){return{source:n[t.l.i],target:n[t.r.i]}})},t.triangles=function(n){var t=[];return iu(e(n)).cells.forEach(function(e,r){for(var u,i,o=e.site,a=e.edges.sort(Ir),c=-1,l=a.length,s=a[l-1].edge,f=s.l===o?s.r:s.l;++c=l,h=r>=s,g=h<<1|f;n.leaf=!1,n=n.nodes[g]||(n.nodes[g]=su()),f?u=l:a=l,h?o=s:c=s,i(n,t,e,r,u,o,a,c)}var s,f,h,g,p,v,d,m,y,M=kt(a),x=kt(c);if(null!=t)v=t,d=e,m=r,y=u;else if(m=y=-(v=d=1/0),f=[],h=[],p=n.length,o)for(g=0;p>g;++g)s=n[g],s.xm&&(m=s.x),s.y>y&&(y=s.y),f.push(s.x),h.push(s.y);else for(g=0;p>g;++g){var b=+M(s=n[g],g),_=+x(s,g);v>b&&(v=b),d>_&&(d=_),b>m&&(m=b),_>y&&(y=_),f.push(b),h.push(_)}var w=m-v,S=y-d;w>S?y=d+w:m=v+S;var k=su();if(k.add=function(n){i(k,n,+M(n,++g),+x(n,g),v,d,m,y)},k.visit=function(n){fu(n,k,v,d,m,y)},k.find=function(n){return hu(k,n[0],n[1],v,d,m,y)},g=-1,null==t){for(;++g=0?n.slice(0,t):n,r=t>=0?n.slice(t+1):"in";return e=hl.get(e)||fl,r=gl.get(r)||Et,Mu(r(e.apply(null,ea.call(arguments,1))))},ta.interpolateHcl=Lu,ta.interpolateHsl=Tu,ta.interpolateLab=Ru,ta.interpolateRound=Du,ta.transform=function(n){var t=ua.createElementNS(ta.ns.prefix.svg,"g");return(ta.transform=function(n){if(null!=n){t.setAttribute("transform",n);var e=t.transform.baseVal.consolidate()}return new Pu(e?e.matrix:pl)})(n)},Pu.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var pl={a:1,b:0,c:0,d:1,e:0,f:0};ta.interpolateTransform=Hu,ta.layout={},ta.layout.bundle=function(){return function(n){for(var t=[],e=-1,r=n.length;++ea*a/d){if(p>c){var l=t.charge/c;n.px-=i*l,n.py-=o*l}return!0}if(t.point&&c&&p>c){var l=t.pointCharge/c;n.px-=i*l,n.py-=o*l}}return!t.charge}}function t(n){n.px=ta.event.x,n.py=ta.event.y,a.resume()}var e,r,u,i,o,a={},c=ta.dispatch("start","tick","end"),l=[1,1],s=.9,f=vl,h=dl,g=-30,p=ml,v=.1,d=.64,m=[],y=[];return a.tick=function(){if((r*=.99)<.005)return c.end({type:"end",alpha:r=0}),!0;var t,e,a,f,h,p,d,M,x,b=m.length,_=y.length;for(e=0;_>e;++e)a=y[e],f=a.source,h=a.target,M=h.x-f.x,x=h.y-f.y,(p=M*M+x*x)&&(p=r*i[e]*((p=Math.sqrt(p))-u[e])/p,M*=p,x*=p,h.x-=M*(d=f.weight/(h.weight+f.weight)),h.y-=x*d,f.x+=M*(d=1-d),f.y+=x*d);if((d=r*v)&&(M=l[0]/2,x=l[1]/2,e=-1,d))for(;++e0?n:0:n>0&&(c.start({type:"start",alpha:r=n}),ta.timer(a.tick)),a):r},a.start=function(){function n(n,r){if(!e){for(e=new Array(c),a=0;c>a;++a)e[a]=[];for(a=0;l>a;++a){var u=y[a];e[u.source.index].push(u.target),e[u.target.index].push(u.source)}}for(var i,o=e[t],a=-1,l=o.length;++at;++t)(r=m[t]).index=t,r.weight=0;for(t=0;s>t;++t)r=y[t],"number"==typeof r.source&&(r.source=m[r.source]),"number"==typeof r.target&&(r.target=m[r.target]),++r.source.weight,++r.target.weight;for(t=0;c>t;++t)r=m[t],isNaN(r.x)&&(r.x=n("x",p)),isNaN(r.y)&&(r.y=n("y",v)),isNaN(r.px)&&(r.px=r.x),isNaN(r.py)&&(r.py=r.y);if(u=[],"function"==typeof f)for(t=0;s>t;++t)u[t]=+f.call(this,y[t],t);else for(t=0;s>t;++t)u[t]=f;if(i=[],"function"==typeof h)for(t=0;s>t;++t)i[t]=+h.call(this,y[t],t);else for(t=0;s>t;++t)i[t]=h;if(o=[],"function"==typeof g)for(t=0;c>t;++t)o[t]=+g.call(this,m[t],t);else for(t=0;c>t;++t)o[t]=g;return a.resume()},a.resume=function(){return a.alpha(.1)},a.stop=function(){return a.alpha(0)},a.drag=function(){return e||(e=ta.behavior.drag().origin(Et).on("dragstart.force",Xu).on("drag.force",t).on("dragend.force",$u)),arguments.length?(this.on("mouseover.force",Bu).on("mouseout.force",Wu).call(e),void 0):e},ta.rebind(a,c,"on")};var vl=20,dl=1,ml=1/0;ta.layout.hierarchy=function(){function n(u){var i,o=[u],a=[];for(u.depth=0;null!=(i=o.pop());)if(a.push(i),(l=e.call(n,i,i.depth))&&(c=l.length)){for(var c,l,s;--c>=0;)o.push(s=l[c]),s.parent=i,s.depth=i.depth+1;r&&(i.value=0),i.children=l}else r&&(i.value=+r.call(n,i,i.depth)||0),delete i.children;return Qu(u,function(n){var e,u;t&&(e=n.children)&&e.sort(t),r&&(u=n.parent)&&(u.value+=n.value)}),a}var t=ei,e=ni,r=ti;return n.sort=function(e){return arguments.length?(t=e,n):t},n.children=function(t){return arguments.length?(e=t,n):e},n.value=function(t){return arguments.length?(r=t,n):r},n.revalue=function(t){return r&&(Ku(t,function(n){n.children&&(n.value=0)}),Qu(t,function(t){var e;t.children||(t.value=+r.call(n,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},n},ta.layout.partition=function(){function n(t,e,r,u){var i=t.children;if(t.x=e,t.y=t.depth*u,t.dx=r,t.dy=u,i&&(o=i.length)){var o,a,c,l=-1;for(r=t.value?r/t.value:0;++lf?-1:1),p=(f-c*g)/ta.sum(l),v=ta.range(c),d=[];return null!=e&&v.sort(e===yl?function(n,t){return l[t]-l[n]}:function(n,t){return e(o[n],o[t])}),v.forEach(function(n){d[n]={data:o[n],value:a=l[n],startAngle:s,endAngle:s+=a*p+g,padAngle:h}}),d}var t=Number,e=yl,r=0,u=Pa,i=0;return n.value=function(e){return arguments.length?(t=e,n):t},n.sort=function(t){return arguments.length?(e=t,n):e},n.startAngle=function(t){return arguments.length?(r=t,n):r},n.endAngle=function(t){return arguments.length?(u=t,n):u},n.padAngle=function(t){return arguments.length?(i=t,n):i},n};var yl={};ta.layout.stack=function(){function n(a,c){if(!(h=a.length))return a;var l=a.map(function(e,r){return t.call(n,e,r)}),s=l.map(function(t){return t.map(function(t,e){return[i.call(n,t,e),o.call(n,t,e)]})}),f=e.call(n,s,c);l=ta.permute(l,f),s=ta.permute(s,f);var h,g,p,v,d=r.call(n,s,c),m=l[0].length;for(p=0;m>p;++p)for(u.call(n,l[0][p],v=d[p],s[0][p][1]),g=1;h>g;++g)u.call(n,l[g][p],v+=s[g-1][p][1],s[g][p][1]);return a}var t=Et,e=ai,r=ci,u=oi,i=ui,o=ii;return n.values=function(e){return arguments.length?(t=e,n):t},n.order=function(t){return arguments.length?(e="function"==typeof t?t:Ml.get(t)||ai,n):e},n.offset=function(t){return arguments.length?(r="function"==typeof t?t:xl.get(t)||ci,n):r},n.x=function(t){return arguments.length?(i=t,n):i},n.y=function(t){return arguments.length?(o=t,n):o},n.out=function(t){return arguments.length?(u=t,n):u},n};var Ml=ta.map({"inside-out":function(n){var t,e,r=n.length,u=n.map(li),i=n.map(si),o=ta.range(r).sort(function(n,t){return u[n]-u[t]}),a=0,c=0,l=[],s=[];for(t=0;r>t;++t)e=o[t],c>a?(a+=i[e],l.push(e)):(c+=i[e],s.push(e));return s.reverse().concat(l)},reverse:function(n){return ta.range(n.length).reverse()},"default":ai}),xl=ta.map({silhouette:function(n){var t,e,r,u=n.length,i=n[0].length,o=[],a=0,c=[];for(e=0;i>e;++e){for(t=0,r=0;u>t;t++)r+=n[t][e][1];r>a&&(a=r),o.push(r)}for(e=0;i>e;++e)c[e]=(a-o[e])/2;return c},wiggle:function(n){var t,e,r,u,i,o,a,c,l,s=n.length,f=n[0],h=f.length,g=[];for(g[0]=c=l=0,e=1;h>e;++e){for(t=0,u=0;s>t;++t)u+=n[t][e][1];for(t=0,i=0,a=f[e][0]-f[e-1][0];s>t;++t){for(r=0,o=(n[t][e][1]-n[t][e-1][1])/(2*a);t>r;++r)o+=(n[r][e][1]-n[r][e-1][1])/a;i+=o*n[t][e][1]}g[e]=c-=u?i/u*a:0,l>c&&(l=c)}for(e=0;h>e;++e)g[e]-=l;return g},expand:function(n){var t,e,r,u=n.length,i=n[0].length,o=1/u,a=[];for(e=0;i>e;++e){for(t=0,r=0;u>t;t++)r+=n[t][e][1];if(r)for(t=0;u>t;t++)n[t][e][1]/=r;else for(t=0;u>t;t++)n[t][e][1]=o}for(e=0;i>e;++e)a[e]=0;return a},zero:ci});ta.layout.histogram=function(){function n(n,i){for(var o,a,c=[],l=n.map(e,this),s=r.call(this,l,i),f=u.call(this,s,l,i),i=-1,h=l.length,g=f.length-1,p=t?1:1/h;++i0)for(i=-1;++i=s[0]&&a<=s[1]&&(o=c[ta.bisect(f,a,1,g)-1],o.y+=p,o.push(n[i]));return c}var t=!0,e=Number,r=pi,u=hi;return n.value=function(t){return arguments.length?(e=t,n):e},n.range=function(t){return arguments.length?(r=kt(t),n):r},n.bins=function(t){return arguments.length?(u="number"==typeof t?function(n){return gi(n,t)}:kt(t),n):u},n.frequency=function(e){return arguments.length?(t=!!e,n):t},n},ta.layout.pack=function(){function n(n,i){var o=e.call(this,n,i),a=o[0],c=u[0],l=u[1],s=null==t?Math.sqrt:"function"==typeof t?t:function(){return t};if(a.x=a.y=0,Qu(a,function(n){n.r=+s(n.value)}),Qu(a,Mi),r){var f=r*(t?1:Math.max(2*a.r/c,2*a.r/l))/2;Qu(a,function(n){n.r+=f}),Qu(a,Mi),Qu(a,function(n){n.r-=f})}return _i(a,c/2,l/2,t?1:1/Math.max(2*a.r/c,2*a.r/l)),o}var t,e=ta.layout.hierarchy().sort(vi),r=0,u=[1,1];return n.size=function(t){return arguments.length?(u=t,n):u},n.radius=function(e){return arguments.length?(t=null==e||"function"==typeof e?e:+e,n):t},n.padding=function(t){return arguments.length?(r=+t,n):r},Gu(n,e)},ta.layout.tree=function(){function n(n,u){var s=o.call(this,n,u),f=s[0],h=t(f);if(Qu(h,e),h.parent.m=-h.z,Ku(h,r),l)Ku(f,i);else{var g=f,p=f,v=f;Ku(f,function(n){n.xp.x&&(p=n),n.depth>v.depth&&(v=n)});var d=a(g,p)/2-g.x,m=c[0]/(p.x+a(p,g)/2+d),y=c[1]/(v.depth||1);Ku(f,function(n){n.x=(n.x+d)*m,n.y=n.depth*y})}return s}function t(n){for(var t,e={A:null,children:[n]},r=[e];null!=(t=r.pop());)for(var u,i=t.children,o=0,a=i.length;a>o;++o)r.push((i[o]=u={_:i[o],parent:t,children:(u=i[o].children)&&u.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:o}).a=u);return e.children[0]}function e(n){var t=n.children,e=n.parent.children,r=n.i?e[n.i-1]:null;if(t.length){Ni(n);var i=(t[0].z+t[t.length-1].z)/2;r?(n.z=r.z+a(n._,r._),n.m=n.z-i):n.z=i}else r&&(n.z=r.z+a(n._,r._));n.parent.A=u(n,r,n.parent.A||e[0])}function r(n){n._.x=n.z+n.parent.m,n.m+=n.parent.m}function u(n,t,e){if(t){for(var r,u=n,i=n,o=t,c=u.parent.children[0],l=u.m,s=i.m,f=o.m,h=c.m;o=Ei(o),u=ki(u),o&&u;)c=ki(c),i=Ei(i),i.a=n,r=o.z+f-u.z-l+a(o._,u._),r>0&&(Ai(Ci(o,n,e),n,r),l+=r,s+=r),f+=o.m,l+=u.m,h+=c.m,s+=i.m;o&&!Ei(i)&&(i.t=o,i.m+=f-s),u&&!ki(c)&&(c.t=u,c.m+=l-h,e=n)}return e}function i(n){n.x*=c[0],n.y=n.depth*c[1]}var o=ta.layout.hierarchy().sort(null).value(null),a=Si,c=[1,1],l=null;return n.separation=function(t){return arguments.length?(a=t,n):a},n.size=function(t){return arguments.length?(l=null==(c=t)?i:null,n):l?null:c},n.nodeSize=function(t){return arguments.length?(l=null==(c=t)?null:i,n):l?c:null},Gu(n,o)},ta.layout.cluster=function(){function n(n,i){var o,a=t.call(this,n,i),c=a[0],l=0;Qu(c,function(n){var t=n.children;t&&t.length?(n.x=qi(t),n.y=zi(t)):(n.x=o?l+=e(n,o):0,n.y=0,o=n)});var s=Li(c),f=Ti(c),h=s.x-e(s,f)/2,g=f.x+e(f,s)/2;return Qu(c,u?function(n){n.x=(n.x-c.x)*r[0],n.y=(c.y-n.y)*r[1]}:function(n){n.x=(n.x-h)/(g-h)*r[0],n.y=(1-(c.y?n.y/c.y:1))*r[1]}),a}var t=ta.layout.hierarchy().sort(null).value(null),e=Si,r=[1,1],u=!1;return n.separation=function(t){return arguments.length?(e=t,n):e},n.size=function(t){return arguments.length?(u=null==(r=t),n):u?null:r},n.nodeSize=function(t){return arguments.length?(u=null!=(r=t),n):u?r:null},Gu(n,t)},ta.layout.treemap=function(){function n(n,t){for(var e,r,u=-1,i=n.length;++ut?0:t),e.area=isNaN(r)||0>=r?0:r}function t(e){var i=e.children;if(i&&i.length){var o,a,c,l=f(e),s=[],h=i.slice(),p=1/0,v="slice"===g?l.dx:"dice"===g?l.dy:"slice-dice"===g?1&e.depth?l.dy:l.dx:Math.min(l.dx,l.dy);for(n(h,l.dx*l.dy/e.value),s.area=0;(c=h.length)>0;)s.push(o=h[c-1]),s.area+=o.area,"squarify"!==g||(a=r(s,v))<=p?(h.pop(),p=a):(s.area-=s.pop().area,u(s,v,l,!1),v=Math.min(l.dx,l.dy),s.length=s.area=0,p=1/0);s.length&&(u(s,v,l,!0),s.length=s.area=0),i.forEach(t)}}function e(t){var r=t.children;if(r&&r.length){var i,o=f(t),a=r.slice(),c=[];for(n(a,o.dx*o.dy/t.value),c.area=0;i=a.pop();)c.push(i),c.area+=i.area,null!=i.z&&(u(c,i.z?o.dx:o.dy,o,!a.length),c.length=c.area=0);r.forEach(e)}}function r(n,t){for(var e,r=n.area,u=0,i=1/0,o=-1,a=n.length;++oe&&(i=e),e>u&&(u=e));return r*=r,t*=t,r?Math.max(t*u*p/r,r/(t*i*p)):1/0}function u(n,t,e,r){var u,i=-1,o=n.length,a=e.x,l=e.y,s=t?c(n.area/t):0;if(t==e.dx){for((r||s>e.dy)&&(s=e.dy);++ie.dx)&&(s=e.dx);++ie&&(t=1),1>e&&(n=0),function(){var e,r,u;do e=2*Math.random()-1,r=2*Math.random()-1,u=e*e+r*r;while(!u||u>1);return n+t*e*Math.sqrt(-2*Math.log(u)/u)}},logNormal:function(){var n=ta.random.normal.apply(ta,arguments);return function(){return Math.exp(n())}},bates:function(n){var t=ta.random.irwinHall(n);return function(){return t()/n}},irwinHall:function(n){return function(){for(var t=0,e=0;n>e;e++)t+=Math.random();return t}}},ta.scale={};var bl={floor:Et,ceil:Et};ta.scale.linear=function(){return Yi([0,1],[0,1],mu,!1)};var _l={s:1,g:1,p:1,r:1,e:1};ta.scale.log=function(){return Ji(ta.scale.linear().domain([0,1]),10,!0,[1,10])};var wl=ta.format(".0e"),Sl={floor:function(n){return-Math.ceil(-n)},ceil:function(n){return-Math.floor(-n)}};ta.scale.pow=function(){return Gi(ta.scale.linear(),1,[0,1])},ta.scale.sqrt=function(){return ta.scale.pow().exponent(.5)},ta.scale.ordinal=function(){return Qi([],{t:"range",a:[[]]})},ta.scale.category10=function(){return ta.scale.ordinal().range(kl)},ta.scale.category20=function(){return ta.scale.ordinal().range(El)},ta.scale.category20b=function(){return ta.scale.ordinal().range(Al)},ta.scale.category20c=function(){return ta.scale.ordinal().range(Nl)};var kl=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(yt),El=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(yt),Al=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(yt),Nl=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(yt);ta.scale.quantile=function(){return no([],[])},ta.scale.quantize=function(){return to(0,1,[0,1])},ta.scale.threshold=function(){return eo([.5],[0,1])},ta.scale.identity=function(){return ro([0,1])},ta.svg={},ta.svg.arc=function(){function n(){var n=Math.max(0,+e.apply(this,arguments)),l=Math.max(0,+r.apply(this,arguments)),s=o.apply(this,arguments)-ja,f=a.apply(this,arguments)-ja,h=Math.abs(f-s),g=s>f?0:1;if(n>l&&(p=l,l=n,n=p),h>=Ua)return t(l,g)+(n?t(n,1-g):"")+"Z";var p,v,d,m,y,M,x,b,_,w,S,k,E=0,A=0,N=[];if((m=(+c.apply(this,arguments)||0)/2)&&(d=i===Cl?Math.sqrt(n*n+l*l):+i.apply(this,arguments),g||(A*=-1),l&&(A=nt(d/l*Math.sin(m))),n&&(E=nt(d/n*Math.sin(m)))),l){y=l*Math.cos(s+A),M=l*Math.sin(s+A),x=l*Math.cos(f-A),b=l*Math.sin(f-A);var C=Math.abs(f-s-2*A)<=Da?0:1;if(A&&so(y,M,x,b)===g^C){var z=(s+f)/2;y=l*Math.cos(z),M=l*Math.sin(z),x=b=null}}else y=M=0;if(n){_=n*Math.cos(f-E),w=n*Math.sin(f-E),S=n*Math.cos(s+E),k=n*Math.sin(s+E);var q=Math.abs(s-f+2*E)<=Da?0:1;if(E&&so(_,w,S,k)===1-g^q){var L=(s+f)/2;_=n*Math.cos(L),w=n*Math.sin(L),S=k=null}}else _=w=0;if((p=Math.min(Math.abs(l-n)/2,+u.apply(this,arguments)))>.001){v=l>n^g?0:1;var T=null==S?[_,w]:null==x?[y,M]:Lr([y,M],[S,k],[x,b],[_,w]),R=y-T[0],D=M-T[1],P=x-T[0],U=b-T[1],j=1/Math.sin(Math.acos((R*P+D*U)/(Math.sqrt(R*R+D*D)*Math.sqrt(P*P+U*U)))/2),F=Math.sqrt(T[0]*T[0]+T[1]*T[1]);if(null!=x){var H=Math.min(p,(l-F)/(j+1)),O=fo(null==S?[_,w]:[S,k],[y,M],l,H,g),Y=fo([x,b],[_,w],l,H,g);p===H?N.push("M",O[0],"A",H,",",H," 0 0,",v," ",O[1],"A",l,",",l," 0 ",1-g^so(O[1][0],O[1][1],Y[1][0],Y[1][1]),",",g," ",Y[1],"A",H,",",H," 0 0,",v," ",Y[0]):N.push("M",O[0],"A",H,",",H," 0 1,",v," ",Y[0])}else N.push("M",y,",",M);if(null!=S){var I=Math.min(p,(n-F)/(j-1)),Z=fo([y,M],[S,k],n,-I,g),V=fo([_,w],null==x?[y,M]:[x,b],n,-I,g);p===I?N.push("L",V[0],"A",I,",",I," 0 0,",v," ",V[1],"A",n,",",n," 0 ",g^so(V[1][0],V[1][1],Z[1][0],Z[1][1]),",",1-g," ",Z[1],"A",I,",",I," 0 0,",v," ",Z[0]):N.push("L",V[0],"A",I,",",I," 0 0,",v," ",Z[0])}else N.push("L",_,",",w)}else N.push("M",y,",",M),null!=x&&N.push("A",l,",",l," 0 ",C,",",g," ",x,",",b),N.push("L",_,",",w),null!=S&&N.push("A",n,",",n," 0 ",q,",",1-g," ",S,",",k);return N.push("Z"),N.join("")}function t(n,t){return"M0,"+n+"A"+n+","+n+" 0 1,"+t+" 0,"+-n+"A"+n+","+n+" 0 1,"+t+" 0,"+n}var e=io,r=oo,u=uo,i=Cl,o=ao,a=co,c=lo;return n.innerRadius=function(t){return arguments.length?(e=kt(t),n):e},n.outerRadius=function(t){return arguments.length?(r=kt(t),n):r},n.cornerRadius=function(t){return arguments.length?(u=kt(t),n):u},n.padRadius=function(t){return arguments.length?(i=t==Cl?Cl:kt(t),n):i},n.startAngle=function(t){return arguments.length?(o=kt(t),n):o},n.endAngle=function(t){return arguments.length?(a=kt(t),n):a},n.padAngle=function(t){return arguments.length?(c=kt(t),n):c},n.centroid=function(){var n=(+e.apply(this,arguments)+ +r.apply(this,arguments))/2,t=(+o.apply(this,arguments)+ +a.apply(this,arguments))/2-ja;return[Math.cos(t)*n,Math.sin(t)*n]},n};var Cl="auto";ta.svg.line=function(){return ho(Et)};var zl=ta.map({linear:go,"linear-closed":po,step:vo,"step-before":mo,"step-after":yo,basis:So,"basis-open":ko,"basis-closed":Eo,bundle:Ao,cardinal:bo,"cardinal-open":Mo,"cardinal-closed":xo,monotone:To});zl.forEach(function(n,t){t.key=n,t.closed=/-closed$/.test(n)});var ql=[0,2/3,1/3,0],Ll=[0,1/3,2/3,0],Tl=[0,1/6,2/3,1/6];ta.svg.line.radial=function(){var n=ho(Ro);return n.radius=n.x,delete n.x,n.angle=n.y,delete n.y,n},mo.reverse=yo,yo.reverse=mo,ta.svg.area=function(){return Do(Et)},ta.svg.area.radial=function(){var n=Do(Ro);return n.radius=n.x,delete n.x,n.innerRadius=n.x0,delete n.x0,n.outerRadius=n.x1,delete n.x1,n.angle=n.y,delete n.y,n.startAngle=n.y0,delete n.y0,n.endAngle=n.y1,delete n.y1,n},ta.svg.chord=function(){function n(n,a){var c=t(this,i,n,a),l=t(this,o,n,a);return"M"+c.p0+r(c.r,c.p1,c.a1-c.a0)+(e(c,l)?u(c.r,c.p1,c.r,c.p0):u(c.r,c.p1,l.r,l.p0)+r(l.r,l.p1,l.a1-l.a0)+u(l.r,l.p1,c.r,c.p0))+"Z"}function t(n,t,e,r){var u=t.call(n,e,r),i=a.call(n,u,r),o=c.call(n,u,r)-ja,s=l.call(n,u,r)-ja;return{r:i,a0:o,a1:s,p0:[i*Math.cos(o),i*Math.sin(o)],p1:[i*Math.cos(s),i*Math.sin(s)]}}function e(n,t){return n.a0==t.a0&&n.a1==t.a1}function r(n,t,e){return"A"+n+","+n+" 0 "+ +(e>Da)+",1 "+t}function u(n,t,e,r){return"Q 0,0 "+r}var i=mr,o=yr,a=Po,c=ao,l=co;return n.radius=function(t){return arguments.length?(a=kt(t),n):a},n.source=function(t){return arguments.length?(i=kt(t),n):i},n.target=function(t){return arguments.length?(o=kt(t),n):o},n.startAngle=function(t){return arguments.length?(c=kt(t),n):c},n.endAngle=function(t){return arguments.length?(l=kt(t),n):l},n},ta.svg.diagonal=function(){function n(n,u){var i=t.call(this,n,u),o=e.call(this,n,u),a=(i.y+o.y)/2,c=[i,{x:i.x,y:a},{x:o.x,y:a},o];return c=c.map(r),"M"+c[0]+"C"+c[1]+" "+c[2]+" "+c[3]}var t=mr,e=yr,r=Uo;return n.source=function(e){return arguments.length?(t=kt(e),n):t},n.target=function(t){return arguments.length?(e=kt(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},ta.svg.diagonal.radial=function(){var n=ta.svg.diagonal(),t=Uo,e=n.projection;return n.projection=function(n){return arguments.length?e(jo(t=n)):t},n},ta.svg.symbol=function(){function n(n,r){return(Rl.get(t.call(this,n,r))||Oo)(e.call(this,n,r))}var t=Ho,e=Fo;return n.type=function(e){return arguments.length?(t=kt(e),n):t},n.size=function(t){return arguments.length?(e=kt(t),n):e},n};var Rl=ta.map({circle:Oo,cross:function(n){var t=Math.sqrt(n/5)/2;return"M"+-3*t+","+-t+"H"+-t+"V"+-3*t+"H"+t+"V"+-t+"H"+3*t+"V"+t+"H"+t+"V"+3*t+"H"+-t+"V"+t+"H"+-3*t+"Z"},diamond:function(n){var t=Math.sqrt(n/(2*Pl)),e=t*Pl;return"M0,"+-t+"L"+e+",0"+" 0,"+t+" "+-e+",0"+"Z"},square:function(n){var t=Math.sqrt(n)/2;return"M"+-t+","+-t+"L"+t+","+-t+" "+t+","+t+" "+-t+","+t+"Z"},"triangle-down":function(n){var t=Math.sqrt(n/Dl),e=t*Dl/2;return"M0,"+e+"L"+t+","+-e+" "+-t+","+-e+"Z"},"triangle-up":function(n){var t=Math.sqrt(n/Dl),e=t*Dl/2;return"M0,"+-e+"L"+t+","+e+" "+-t+","+e+"Z"}});ta.svg.symbolTypes=Rl.keys();var Dl=Math.sqrt(3),Pl=Math.tan(30*Fa);ka.transition=function(n){for(var t,e,r=Ul||++Ol,u=Xo(n),i=[],o=jl||{time:Date.now(),ease:Su,delay:0,duration:250},a=-1,c=this.length;++ai;i++){u.push(t=[]);for(var e=this[i],a=0,c=e.length;c>a;a++)(r=e[a])&&n.call(r,r.__data__,a,i)&&t.push(r)}return Io(u,this.namespace,this.id)},Hl.tween=function(n,t){var e=this.id,r=this.namespace;return arguments.length<2?this.node()[r][e].tween.get(n):H(this,null==t?function(t){t[r][e].tween.remove(n)}:function(u){u[r][e].tween.set(n,t)})},Hl.attr=function(n,t){function e(){this.removeAttribute(a)}function r(){this.removeAttributeNS(a.space,a.local)}function u(n){return null==n?e:(n+="",function(){var t,e=this.getAttribute(a);return e!==n&&(t=o(e,n),function(n){this.setAttribute(a,t(n))})})}function i(n){return null==n?r:(n+="",function(){var t,e=this.getAttributeNS(a.space,a.local);return e!==n&&(t=o(e,n),function(n){this.setAttributeNS(a.space,a.local,t(n))})})}if(arguments.length<2){for(t in n)this.attr(t,n[t]);return this}var o="transform"==n?Hu:mu,a=ta.ns.qualify(n);return Zo(this,"attr."+n,t,a.local?i:u)},Hl.attrTween=function(n,t){function e(n,e){var r=t.call(this,n,e,this.getAttribute(u));return r&&function(n){this.setAttribute(u,r(n))}}function r(n,e){var r=t.call(this,n,e,this.getAttributeNS(u.space,u.local));return r&&function(n){this.setAttributeNS(u.space,u.local,r(n))}}var u=ta.ns.qualify(n);return this.tween("attr."+n,u.local?r:e)},Hl.style=function(n,t,e){function r(){this.style.removeProperty(n)}function u(t){return null==t?r:(t+="",function(){var r,u=oa.getComputedStyle(this,null).getPropertyValue(n);return u!==t&&(r=mu(u,t),function(t){this.style.setProperty(n,r(t),e)})})}var i=arguments.length;if(3>i){if("string"!=typeof n){2>i&&(t="");for(e in n)this.style(e,n[e],t);return this}e=""}return Zo(this,"style."+n,t,u)},Hl.styleTween=function(n,t,e){function r(r,u){var i=t.call(this,r,u,oa.getComputedStyle(this,null).getPropertyValue(n));return i&&function(t){this.style.setProperty(n,i(t),e)}}return arguments.length<3&&(e=""),this.tween("style."+n,r)},Hl.text=function(n){return Zo(this,"text",n,Vo)},Hl.remove=function(){var n=this.namespace;return this.each("end.transition",function(){var t;this[n].count<2&&(t=this.parentNode)&&t.removeChild(this)})},Hl.ease=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].ease:("function"!=typeof n&&(n=ta.ease.apply(ta,arguments)),H(this,function(r){r[e][t].ease=n}))},Hl.delay=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].delay:H(this,"function"==typeof n?function(r,u,i){r[e][t].delay=+n.call(r,r.__data__,u,i)}:(n=+n,function(r){r[e][t].delay=n}))},Hl.duration=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].duration:H(this,"function"==typeof n?function(r,u,i){r[e][t].duration=Math.max(1,n.call(r,r.__data__,u,i))}:(n=Math.max(1,n),function(r){r[e][t].duration=n}))},Hl.each=function(n,t){var e=this.id,r=this.namespace;if(arguments.length<2){var u=jl,i=Ul;try{Ul=e,H(this,function(t,u,i){jl=t[r][e],n.call(t,t.__data__,u,i)})}finally{jl=u,Ul=i}}else H(this,function(u){var i=u[r][e];(i.event||(i.event=ta.dispatch("start","end","interrupt"))).on(n,t)});return this},Hl.transition=function(){for(var n,t,e,r,u=this.id,i=++Ol,o=this.namespace,a=[],c=0,l=this.length;l>c;c++){a.push(n=[]);for(var t=this[c],s=0,f=t.length;f>s;s++)(e=t[s])&&(r=e[o][u],$o(e,s,o,i,{time:r.time,ease:r.ease,delay:r.delay+r.duration,duration:r.duration})),n.push(e)}return Io(a,o,i)},ta.svg.axis=function(){function n(n){n.each(function(){var n,l=ta.select(this),s=this.__chart__||e,f=this.__chart__=e.copy(),h=null==c?f.ticks?f.ticks.apply(f,a):f.domain():c,g=null==t?f.tickFormat?f.tickFormat.apply(f,a):Et:t,p=l.selectAll(".tick").data(h,f),v=p.enter().insert("g",".domain").attr("class","tick").style("opacity",Ta),d=ta.transition(p.exit()).style("opacity",Ta).remove(),m=ta.transition(p.order()).style("opacity",1),y=Math.max(u,0)+o,M=Ui(f),x=l.selectAll(".domain").data([0]),b=(x.enter().append("path").attr("class","domain"),ta.transition(x));v.append("line"),v.append("text");var _,w,S,k,E=v.select("line"),A=m.select("line"),N=p.select("text").text(g),C=v.select("text"),z=m.select("text"),q="top"===r||"left"===r?-1:1;if("bottom"===r||"top"===r?(n=Bo,_="x",S="y",w="x2",k="y2",N.attr("dy",0>q?"0em":".71em").style("text-anchor","middle"),b.attr("d","M"+M[0]+","+q*i+"V0H"+M[1]+"V"+q*i)):(n=Wo,_="y",S="x",w="y2",k="x2",N.attr("dy",".32em").style("text-anchor",0>q?"end":"start"),b.attr("d","M"+q*i+","+M[0]+"H0V"+M[1]+"H"+q*i)),E.attr(k,q*u),C.attr(S,q*y),A.attr(w,0).attr(k,q*u),z.attr(_,0).attr(S,q*y),f.rangeBand){var L=f,T=L.rangeBand()/2;s=f=function(n){return L(n)+T}}else s.rangeBand?s=f:d.call(n,f,s);v.call(n,s,f),m.call(n,f,f)})}var t,e=ta.scale.linear(),r=Yl,u=6,i=6,o=3,a=[10],c=null;return n.scale=function(t){return arguments.length?(e=t,n):e},n.orient=function(t){return arguments.length?(r=t in Il?t+"":Yl,n):r},n.ticks=function(){return arguments.length?(a=arguments,n):a},n.tickValues=function(t){return arguments.length?(c=t,n):c},n.tickFormat=function(e){return arguments.length?(t=e,n):t},n.tickSize=function(t){var e=arguments.length;return e?(u=+t,i=+arguments[e-1],n):u},n.innerTickSize=function(t){return arguments.length?(u=+t,n):u},n.outerTickSize=function(t){return arguments.length?(i=+t,n):i},n.tickPadding=function(t){return arguments.length?(o=+t,n):o},n.tickSubdivide=function(){return arguments.length&&n},n};var Yl="bottom",Il={top:1,right:1,bottom:1,left:1};ta.svg.brush=function(){function n(i){i.each(function(){var i=ta.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",u).on("touchstart.brush",u),o=i.selectAll(".background").data([0]);o.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),i.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var a=i.selectAll(".resize").data(p,Et);a.exit().remove(),a.enter().append("g").attr("class",function(n){return"resize "+n}).style("cursor",function(n){return Zl[n]}).append("rect").attr("x",function(n){return/[ew]$/.test(n)?-3:null}).attr("y",function(n){return/^[ns]/.test(n)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),a.style("display",n.empty()?"none":null);var s,f=ta.transition(i),h=ta.transition(o);c&&(s=Ui(c),h.attr("x",s[0]).attr("width",s[1]-s[0]),e(f)),l&&(s=Ui(l),h.attr("y",s[0]).attr("height",s[1]-s[0]),r(f)),t(f)})}function t(n){n.selectAll(".resize").attr("transform",function(n){return"translate("+s[+/e$/.test(n)]+","+f[+/^s/.test(n)]+")"})}function e(n){n.select(".extent").attr("x",s[0]),n.selectAll(".extent,.n>rect,.s>rect").attr("width",s[1]-s[0])}function r(n){n.select(".extent").attr("y",f[0]),n.selectAll(".extent,.e>rect,.w>rect").attr("height",f[1]-f[0])}function u(){function u(){32==ta.event.keyCode&&(N||(y=null,z[0]-=s[1],z[1]-=f[1],N=2),b())}function p(){32==ta.event.keyCode&&2==N&&(z[0]+=s[1],z[1]+=f[1],N=0,b())}function v(){var n=ta.mouse(x),u=!1;M&&(n[0]+=M[0],n[1]+=M[1]),N||(ta.event.altKey?(y||(y=[(s[0]+s[1])/2,(f[0]+f[1])/2]),z[0]=s[+(n[0]p?(u=r,r=p):u=p),v[0]!=r||v[1]!=u?(e?o=null:i=null,v[0]=r,v[1]=u,!0):void 0}function m(){v(),S.style("pointer-events","all").selectAll(".resize").style("display",n.empty()?"none":null),ta.select("body").style("cursor",null),q.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),C(),w({type:"brushend"})}var y,M,x=this,_=ta.select(ta.event.target),w=a.of(x,arguments),S=ta.select(x),k=_.datum(),E=!/^(n|s)$/.test(k)&&c,A=!/^(e|w)$/.test(k)&&l,N=_.classed("extent"),C=X(),z=ta.mouse(x),q=ta.select(oa).on("keydown.brush",u).on("keyup.brush",p);if(ta.event.changedTouches?q.on("touchmove.brush",v).on("touchend.brush",m):q.on("mousemove.brush",v).on("mouseup.brush",m),S.interrupt().selectAll("*").interrupt(),N)z[0]=s[0]-z[0],z[1]=f[0]-z[1];else if(k){var L=+/w$/.test(k),T=+/^n/.test(k);M=[s[1-L]-z[0],f[1-T]-z[1]],z[0]=s[L],z[1]=f[T]}else ta.event.altKey&&(y=z.slice());S.style("pointer-events","none").selectAll(".resize").style("display",null),ta.select("body").style("cursor",_.style("cursor")),w({type:"brushstart"}),v()}var i,o,a=w(n,"brushstart","brush","brushend"),c=null,l=null,s=[0,0],f=[0,0],h=!0,g=!0,p=Vl[0];return n.event=function(n){n.each(function(){var n=a.of(this,arguments),t={x:s,y:f,i:i,j:o},e=this.__chart__||t;this.__chart__=t,Ul?ta.select(this).transition().each("start.brush",function(){i=e.i,o=e.j,s=e.x,f=e.y,n({type:"brushstart"})}).tween("brush:brush",function(){var e=yu(s,t.x),r=yu(f,t.y);return i=o=null,function(u){s=t.x=e(u),f=t.y=r(u),n({type:"brush",mode:"resize"})}}).each("end.brush",function(){i=t.i,o=t.j,n({type:"brush",mode:"resize"}),n({type:"brushend"})}):(n({type:"brushstart"}),n({type:"brush",mode:"resize"}),n({type:"brushend"}))})},n.x=function(t){return arguments.length?(c=t,p=Vl[!c<<1|!l],n):c},n.y=function(t){return arguments.length?(l=t,p=Vl[!c<<1|!l],n):l},n.clamp=function(t){return arguments.length?(c&&l?(h=!!t[0],g=!!t[1]):c?h=!!t:l&&(g=!!t),n):c&&l?[h,g]:c?h:l?g:null},n.extent=function(t){var e,r,u,a,h;return arguments.length?(c&&(e=t[0],r=t[1],l&&(e=e[0],r=r[0]),i=[e,r],c.invert&&(e=c(e),r=c(r)),e>r&&(h=e,e=r,r=h),(e!=s[0]||r!=s[1])&&(s=[e,r])),l&&(u=t[0],a=t[1],c&&(u=u[1],a=a[1]),o=[u,a],l.invert&&(u=l(u),a=l(a)),u>a&&(h=u,u=a,a=h),(u!=f[0]||a!=f[1])&&(f=[u,a])),n):(c&&(i?(e=i[0],r=i[1]):(e=s[0],r=s[1],c.invert&&(e=c.invert(e),r=c.invert(r)),e>r&&(h=e,e=r,r=h))),l&&(o?(u=o[0],a=o[1]):(u=f[0],a=f[1],l.invert&&(u=l.invert(u),a=l.invert(a)),u>a&&(h=u,u=a,a=h))),c&&l?[[e,u],[r,a]]:c?[e,r]:l&&[u,a])},n.clear=function(){return n.empty()||(s=[0,0],f=[0,0],i=o=null),n},n.empty=function(){return!!c&&s[0]==s[1]||!!l&&f[0]==f[1]},ta.rebind(n,a,"on")};var Zl={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Vl=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],Xl=fc.format=mc.timeFormat,$l=Xl.utc,Bl=$l("%Y-%m-%dT%H:%M:%S.%LZ");Xl.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Jo:Bl,Jo.parse=function(n){var t=new Date(n);return isNaN(t)?null:t},Jo.toString=Bl.toString,fc.second=Ft(function(n){return new hc(1e3*Math.floor(n/1e3))},function(n,t){n.setTime(n.getTime()+1e3*Math.floor(t))},function(n){return n.getSeconds()}),fc.seconds=fc.second.range,fc.seconds.utc=fc.second.utc.range,fc.minute=Ft(function(n){return new hc(6e4*Math.floor(n/6e4))},function(n,t){n.setTime(n.getTime()+6e4*Math.floor(t))},function(n){return n.getMinutes()}),fc.minutes=fc.minute.range,fc.minutes.utc=fc.minute.utc.range,fc.hour=Ft(function(n){var t=n.getTimezoneOffset()/60;return new hc(36e5*(Math.floor(n/36e5-t)+t))},function(n,t){n.setTime(n.getTime()+36e5*Math.floor(t))},function(n){return n.getHours()}),fc.hours=fc.hour.range,fc.hours.utc=fc.hour.utc.range,fc.month=Ft(function(n){return n=fc.day(n),n.setDate(1),n},function(n,t){n.setMonth(n.getMonth()+t)},function(n){return n.getMonth()}),fc.months=fc.month.range,fc.months.utc=fc.month.utc.range;var Wl=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Jl=[[fc.second,1],[fc.second,5],[fc.second,15],[fc.second,30],[fc.minute,1],[fc.minute,5],[fc.minute,15],[fc.minute,30],[fc.hour,1],[fc.hour,3],[fc.hour,6],[fc.hour,12],[fc.day,1],[fc.day,2],[fc.week,1],[fc.month,1],[fc.month,3],[fc.year,1]],Gl=Xl.multi([[".%L",function(n){return n.getMilliseconds()}],[":%S",function(n){return n.getSeconds()}],["%I:%M",function(n){return n.getMinutes()}],["%I %p",function(n){return n.getHours()}],["%a %d",function(n){return n.getDay()&&1!=n.getDate()}],["%b %d",function(n){return 1!=n.getDate()}],["%B",function(n){return n.getMonth()}],["%Y",Ne]]),Kl={range:function(n,t,e){return ta.range(Math.ceil(n/e)*e,+t,e).map(Ko)},floor:Et,ceil:Et};Jl.year=fc.year,fc.scale=function(){return Go(ta.scale.linear(),Jl,Gl)};var Ql=Jl.map(function(n){return[n[0].utc,n[1]]}),ns=$l.multi([[".%L",function(n){return n.getUTCMilliseconds()}],[":%S",function(n){return n.getUTCSeconds()}],["%I:%M",function(n){return n.getUTCMinutes()}],["%I %p",function(n){return n.getUTCHours()}],["%a %d",function(n){return n.getUTCDay()&&1!=n.getUTCDate()}],["%b %d",function(n){return 1!=n.getUTCDate()}],["%B",function(n){return n.getUTCMonth()}],["%Y",Ne]]);Ql.year=fc.year.utc,fc.scale.utc=function(){return Go(ta.scale.linear(),Ql,ns)},ta.text=At(function(n){return n.responseText}),ta.json=function(n,t){return Nt(n,"application/json",Qo,t)},ta.html=function(n,t){return Nt(n,"text/html",na,t)},ta.xml=At(function(n){return n.responseXML}),"function"==typeof define&&define.amd?define(ta):"object"==typeof module&&module.exports&&(module.exports=ta),this.d3=ta}(); \ No newline at end of file diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/combo/jquery.combo.js b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/combo/jquery.combo.js index 3b98a4d857..30f0be9ba1 100644 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/combo/jquery.combo.js +++ b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/combo/jquery.combo.js @@ -93,7 +93,7 @@ // ensure we found the selected option if (isDefinedAndNotNull(selectedOption)) { - $(comboText).removeClass('selected-disabled-option').attr('title', selectedOption.text).text(selectedOption.text).data('text', selectedOption.text); + $(comboText).removeClass('selected-disabled-option').attr('title', selectedOption.text).text(selectedOption.text).data('text', selectedOption.text).width(combo.outerWidth() - 25); // if the selected option is disabled show it if (selectedOption.disabled === true) { @@ -245,9 +245,6 @@ // add the drop down arrow $('
').appendTo(combo); - // set the width of the combo text - comboText.width($(combo).outerWidth() - 25); - // set the selection if (isDefinedAndNotNull(options.selectedOption)) { selectOption(combo, options.selectedOption.text, options.selectedOption.value); diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png deleted file mode 100755 index 5b5dab2ab7..0000000000 Binary files a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png and /dev/null differ diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png deleted file mode 100755 index ac8b229af9..0000000000 Binary files a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png and /dev/null differ diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png deleted file mode 100755 index ad3d6346e0..0000000000 Binary files a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png and /dev/null differ diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png deleted file mode 100755 index 42ccba269b..0000000000 Binary files a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png and /dev/null differ diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png deleted file mode 100755 index 5a46b47cb1..0000000000 Binary files a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png and /dev/null differ diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png deleted file mode 100755 index 86c2baa655..0000000000 Binary files a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png and /dev/null differ diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png deleted file mode 100755 index 4443fdc1a1..0000000000 Binary files a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png and /dev/null differ diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png deleted file mode 100755 index 7c9fa6c6ed..0000000000 Binary files a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png and /dev/null differ diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-icons_222222_256x240.png b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-icons_222222_256x240.png deleted file mode 100755 index b273ff111d..0000000000 Binary files a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-icons_222222_256x240.png and /dev/null differ diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-icons_2e83ff_256x240.png b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-icons_2e83ff_256x240.png deleted file mode 100755 index 09d1cdc856..0000000000 Binary files a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-icons_2e83ff_256x240.png and /dev/null differ diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-icons_454545_256x240.png b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-icons_454545_256x240.png deleted file mode 100755 index df33621813..0000000000 Binary files a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-icons_454545_256x240.png and /dev/null differ diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-icons_888888_256x240.png b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-icons_888888_256x240.png deleted file mode 100755 index 6d02426c11..0000000000 Binary files a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-icons_888888_256x240.png and /dev/null differ diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-icons_cd0a0a_256x240.png b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-icons_cd0a0a_256x240.png deleted file mode 100755 index 2ab019b73e..0000000000 Binary files a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-icons_cd0a0a_256x240.png and /dev/null differ diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-icons_ffffff_256x240.png b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-icons_ffffff_256x240.png deleted file mode 100755 index 0be0ad330e..0000000000 Binary files a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/images/ui-icons_ffffff_256x240.png and /dev/null differ diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/jquery-ui-1.8.10.custom.css b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/jquery-ui-1.8.10.custom.css deleted file mode 100755 index 38bce7f574..0000000000 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/css/smoothness/jquery-ui-1.8.10.custom.css +++ /dev/null @@ -1,625 +0,0 @@ -/* - * jQuery UI CSS Framework 1.8.10 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Theming/API - */ - -/* Layout helpers -----------------------------------*/ -.ui-helper-hidden { display: none; } -.ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); } -.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; } -.ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } -.ui-helper-clearfix { display: inline-block; } -/* required comment for clearfix to work in Opera \*/ -* html .ui-helper-clearfix { height:1%; } -.ui-helper-clearfix { display:block; } -/* end clearfix */ -.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); } - - -/* Interaction Cues -----------------------------------*/ -.ui-state-disabled { cursor: default !important; } - - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; } - - -/* Misc visuals -----------------------------------*/ - -/* Overlays */ -.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } - - -/* - * jQuery UI CSS Framework 1.8.10 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Theming/API - * - * To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Verdana,Arial,sans-serif&fwDefault=normal&fsDefault=1.1em&cornerRadius=4px&bgColorHeader=cccccc&bgTextureHeader=03_highlight_soft.png&bgImgOpacityHeader=75&borderColorHeader=aaaaaa&fcHeader=222222&iconColorHeader=222222&bgColorContent=ffffff&bgTextureContent=01_flat.png&bgImgOpacityContent=75&borderColorContent=aaaaaa&fcContent=222222&iconColorContent=222222&bgColorDefault=e6e6e6&bgTextureDefault=02_glass.png&bgImgOpacityDefault=75&borderColorDefault=d3d3d3&fcDefault=555555&iconColorDefault=888888&bgColorHover=dadada&bgTextureHover=02_glass.png&bgImgOpacityHover=75&borderColorHover=999999&fcHover=212121&iconColorHover=454545&bgColorActive=ffffff&bgTextureActive=02_glass.png&bgImgOpacityActive=65&borderColorActive=aaaaaa&fcActive=212121&iconColorActive=454545&bgColorHighlight=fbf9ee&bgTextureHighlight=02_glass.png&bgImgOpacityHighlight=55&borderColorHighlight=fcefa1&fcHighlight=363636&iconColorHighlight=2e83ff&bgColorError=fef1ec&bgTextureError=02_glass.png&bgImgOpacityError=95&borderColorError=cd0a0a&fcError=cd0a0a&iconColorError=cd0a0a&bgColorOverlay=aaaaaa&bgTextureOverlay=01_flat.png&bgImgOpacityOverlay=0&opacityOverlay=30&bgColorShadow=aaaaaa&bgTextureShadow=01_flat.png&bgImgOpacityShadow=0&opacityShadow=30&thicknessShadow=8px&offsetTopShadow=-8px&offsetLeftShadow=-8px&cornerRadiusShadow=8px - */ - - -/* Component containers -----------------------------------*/ -.ui-widget { font-family: Verdana,Arial,sans-serif; font-size: 1.1em; } -.ui-widget .ui-widget { font-size: 1em; } -.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Verdana,Arial,sans-serif; font-size: 1em; } -.ui-widget-content a { color: #222222; } -.ui-widget-header a { color: #222222; } - -.ui-widget-header { border: 1px solid #aaaaaa; background: #cccccc url(images/ui-bg_highlight-soft_75_cccccc_1x100.png) 50% 50% repeat-x; color: #222222; font-weight: bold; } -.ui-widget-content { border: 1px solid #aaaaaa; background: #ffffff url(images/ui-bg_flat_75_ffffff_40x100.png) 50% 50% repeat-x; color: #222222; } - -/* Interaction states -----------------------------------*/ -/*.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #d3d3d3; background: #e6e6e6 url(images/ui-bg_glass_75_e6e6e6_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #555555; }*/ -.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { - background: #e6e6e6 url(images/ui-bg_glass_75_e6e6e6_1x400.png) 50% 50% repeat-x; - font-weight: normal; - color: #555555; -} - -.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #555555; text-decoration: none; } -/*.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #999999; background: #dadada url(images/ui-bg_glass_75_dadada_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #212121; }*/ -.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { - font-weight: normal; - color: #212121; - outline: none; -} - -/* override the highlight when hovering over certain elements */ -li.ui-menu-item .ui-state-hover { - background: #D4E0E5 !important; - border: 1px solid #999999; -} - -.ui-state-hover a, .ui-state-hover a:hover { color: #212121; text-decoration: none; } -.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #aaaaaa; background: #ffffff url(images/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #212121; } -.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #212121; text-decoration: none; } -.ui-widget :active { outline: none; } - -/* Interaction Cues -----------------------------------*/ -/*.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #fcefa1; background: #fbf9ee url(images/ui-bg_glass_55_fbf9ee_1x400.png) 50% 50% repeat-x; color: #363636; }*/ -.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight { - background: #FFE8B3; - color: #363636; -} -.ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #363636; } -.ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #cd0a0a; background: #fef1ec url(images/ui-bg_glass_95_fef1ec_1x400.png) 50% 50% repeat-x; color: #cd0a0a; } -.ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #cd0a0a; } -.ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #cd0a0a; } -.ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; } -.ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; } -.ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; } - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_222222_256x240.png); } -.ui-widget-content .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); } -.ui-widget-header .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); } -/*.ui-state-default .ui-icon { background-image: url(images/ui-icons_888888_256x240.png); }*/ -.ui-state-default .ui-icon { - background-image: url(images/ui-icons_ffffff_256x240.png); -} -.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_454545_256x240.png); } -.ui-state-active .ui-icon {background-image: url(images/ui-icons_454545_256x240.png); } -.ui-state-highlight .ui-icon {background-image: url(images/ui-icons_2e83ff_256x240.png); } -.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_cd0a0a_256x240.png); } - -/* positioning */ -.ui-icon-carat-1-n { background-position: 0 0; } -.ui-icon-carat-1-ne { background-position: -16px 0; } -.ui-icon-carat-1-e { background-position: -32px 0; } -.ui-icon-carat-1-se { background-position: -48px 0; } -.ui-icon-carat-1-s { background-position: -64px 0; } -.ui-icon-carat-1-sw { background-position: -80px 0; } -.ui-icon-carat-1-w { background-position: -96px 0; } -.ui-icon-carat-1-nw { background-position: -112px 0; } -.ui-icon-carat-2-n-s { background-position: -128px 0; } -.ui-icon-carat-2-e-w { background-position: -144px 0; } -.ui-icon-triangle-1-n { background-position: 0 -16px; } -.ui-icon-triangle-1-ne { background-position: -16px -16px; } -.ui-icon-triangle-1-e { background-position: -32px -16px; } -.ui-icon-triangle-1-se { background-position: -48px -16px; } -.ui-icon-triangle-1-s { background-position: -64px -16px; } -.ui-icon-triangle-1-sw { background-position: -80px -16px; } -.ui-icon-triangle-1-w { background-position: -96px -16px; } -.ui-icon-triangle-1-nw { background-position: -112px -16px; } -.ui-icon-triangle-2-n-s { background-position: -128px -16px; } -.ui-icon-triangle-2-e-w { background-position: -144px -16px; } -.ui-icon-arrow-1-n { background-position: 0 -32px; } -.ui-icon-arrow-1-ne { background-position: -16px -32px; } -.ui-icon-arrow-1-e { background-position: -32px -32px; } -.ui-icon-arrow-1-se { background-position: -48px -32px; } -.ui-icon-arrow-1-s { background-position: -64px -32px; } -.ui-icon-arrow-1-sw { background-position: -80px -32px; } -.ui-icon-arrow-1-w { background-position: -96px -32px; } -.ui-icon-arrow-1-nw { background-position: -112px -32px; } -.ui-icon-arrow-2-n-s { background-position: -128px -32px; } -.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; } -.ui-icon-arrow-2-e-w { background-position: -160px -32px; } -.ui-icon-arrow-2-se-nw { background-position: -176px -32px; } -.ui-icon-arrowstop-1-n { background-position: -192px -32px; } -.ui-icon-arrowstop-1-e { background-position: -208px -32px; } -.ui-icon-arrowstop-1-s { background-position: -224px -32px; } -.ui-icon-arrowstop-1-w { background-position: -240px -32px; } -.ui-icon-arrowthick-1-n { background-position: 0 -48px; } -.ui-icon-arrowthick-1-ne { background-position: -16px -48px; } -.ui-icon-arrowthick-1-e { background-position: -32px -48px; } -.ui-icon-arrowthick-1-se { background-position: -48px -48px; } -.ui-icon-arrowthick-1-s { background-position: -64px -48px; } -.ui-icon-arrowthick-1-sw { background-position: -80px -48px; } -.ui-icon-arrowthick-1-w { background-position: -96px -48px; } -.ui-icon-arrowthick-1-nw { background-position: -112px -48px; } -.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; } -.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; } -.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; } -.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; } -.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; } -.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; } -.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; } -.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; } -.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; } -.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; } -.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; } -.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; } -.ui-icon-arrowreturn-1-w { background-position: -64px -64px; } -.ui-icon-arrowreturn-1-n { background-position: -80px -64px; } -.ui-icon-arrowreturn-1-e { background-position: -96px -64px; } -.ui-icon-arrowreturn-1-s { background-position: -112px -64px; } -.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; } -.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; } -.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; } -.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; } -.ui-icon-arrow-4 { background-position: 0 -80px; } -.ui-icon-arrow-4-diag { background-position: -16px -80px; } -.ui-icon-extlink { background-position: -32px -80px; } -.ui-icon-newwin { background-position: -48px -80px; } -.ui-icon-refresh { background-position: -64px -80px; } -.ui-icon-shuffle { background-position: -80px -80px; } -.ui-icon-transfer-e-w { background-position: -96px -80px; } -.ui-icon-transferthick-e-w { background-position: -112px -80px; } -.ui-icon-folder-collapsed { background-position: 0 -96px; } -.ui-icon-folder-open { background-position: -16px -96px; } -.ui-icon-document { background-position: -32px -96px; } -.ui-icon-document-b { background-position: -48px -96px; } -.ui-icon-note { background-position: -64px -96px; } -.ui-icon-mail-closed { background-position: -80px -96px; } -.ui-icon-mail-open { background-position: -96px -96px; } -.ui-icon-suitcase { background-position: -112px -96px; } -.ui-icon-comment { background-position: -128px -96px; } -.ui-icon-person { background-position: -144px -96px; } -.ui-icon-print { background-position: -160px -96px; } -.ui-icon-trash { background-position: -176px -96px; } -.ui-icon-locked { background-position: -192px -96px; } -.ui-icon-unlocked { background-position: -208px -96px; } -.ui-icon-bookmark { background-position: -224px -96px; } -.ui-icon-tag { background-position: -240px -96px; } -.ui-icon-home { background-position: 0 -112px; } -.ui-icon-flag { background-position: -16px -112px; } -.ui-icon-calendar { background-position: -32px -112px; } -.ui-icon-cart { background-position: -48px -112px; } -.ui-icon-pencil { background-position: -64px -112px; } -.ui-icon-clock { background-position: -80px -112px; } -.ui-icon-disk { background-position: -96px -112px; } -.ui-icon-calculator { background-position: -112px -112px; } -.ui-icon-zoomin { background-position: -128px -112px; } -.ui-icon-zoomout { background-position: -144px -112px; } -.ui-icon-search { background-position: -160px -112px; } -.ui-icon-wrench { background-position: -176px -112px; } -.ui-icon-gear { background-position: -192px -112px; } -.ui-icon-heart { background-position: -208px -112px; } -.ui-icon-star { background-position: -224px -112px; } -.ui-icon-link { background-position: -240px -112px; } -.ui-icon-cancel { background-position: 0 -128px; } -.ui-icon-plus { background-position: -16px -128px; } -.ui-icon-plusthick { background-position: -32px -128px; } -.ui-icon-minus { background-position: -48px -128px; } -.ui-icon-minusthick { background-position: -64px -128px; } -.ui-icon-close { background-position: -80px -128px; } -.ui-icon-closethick { background-position: -96px -128px; } -.ui-icon-key { background-position: -112px -128px; } -.ui-icon-lightbulb { background-position: -128px -128px; } -.ui-icon-scissors { background-position: -144px -128px; } -.ui-icon-clipboard { background-position: -160px -128px; } -.ui-icon-copy { background-position: -176px -128px; } -.ui-icon-contact { background-position: -192px -128px; } -.ui-icon-image { background-position: -208px -128px; } -.ui-icon-video { background-position: -224px -128px; } -.ui-icon-script { background-position: -240px -128px; } -.ui-icon-alert { background-position: 0 -144px; } -.ui-icon-info { background-position: -16px -144px; } -.ui-icon-notice { background-position: -32px -144px; } -.ui-icon-help { background-position: -48px -144px; } -.ui-icon-check { background-position: -64px -144px; } -.ui-icon-bullet { background-position: -80px -144px; } -.ui-icon-radio-off { background-position: -96px -144px; } -.ui-icon-radio-on { background-position: -112px -144px; } -.ui-icon-pin-w { background-position: -128px -144px; } -.ui-icon-pin-s { background-position: -144px -144px; } -.ui-icon-play { background-position: 0 -160px; } -.ui-icon-pause { background-position: -16px -160px; } -.ui-icon-seek-next { background-position: -32px -160px; } -.ui-icon-seek-prev { background-position: -48px -160px; } -.ui-icon-seek-end { background-position: -64px -160px; } -.ui-icon-seek-start { background-position: -80px -160px; } -/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */ -.ui-icon-seek-first { background-position: -80px -160px; } -.ui-icon-stop { background-position: -96px -160px; } -.ui-icon-eject { background-position: -112px -160px; } -.ui-icon-volume-off { background-position: -128px -160px; } -.ui-icon-volume-on { background-position: -144px -160px; } -.ui-icon-power { background-position: 0 -176px; } -.ui-icon-signal-diag { background-position: -16px -176px; } -.ui-icon-signal { background-position: -32px -176px; } -.ui-icon-battery-0 { background-position: -48px -176px; } -.ui-icon-battery-1 { background-position: -64px -176px; } -.ui-icon-battery-2 { background-position: -80px -176px; } -.ui-icon-battery-3 { background-position: -96px -176px; } -.ui-icon-circle-plus { background-position: 0 -192px; } -.ui-icon-circle-minus { background-position: -16px -192px; } -.ui-icon-circle-close { background-position: -32px -192px; } -.ui-icon-circle-triangle-e { background-position: -48px -192px; } -.ui-icon-circle-triangle-s { background-position: -64px -192px; } -.ui-icon-circle-triangle-w { background-position: -80px -192px; } -.ui-icon-circle-triangle-n { background-position: -96px -192px; } -.ui-icon-circle-arrow-e { background-position: -112px -192px; } -.ui-icon-circle-arrow-s { background-position: -128px -192px; } -.ui-icon-circle-arrow-w { background-position: -144px -192px; } -.ui-icon-circle-arrow-n { background-position: -160px -192px; } -.ui-icon-circle-zoomin { background-position: -176px -192px; } -.ui-icon-circle-zoomout { background-position: -192px -192px; } -.ui-icon-circle-check { background-position: -208px -192px; } -.ui-icon-circlesmall-plus { background-position: 0 -208px; } -.ui-icon-circlesmall-minus { background-position: -16px -208px; } -.ui-icon-circlesmall-close { background-position: -32px -208px; } -.ui-icon-squaresmall-plus { background-position: -48px -208px; } -.ui-icon-squaresmall-minus { background-position: -64px -208px; } -.ui-icon-squaresmall-close { background-position: -80px -208px; } -.ui-icon-grip-dotted-vertical { background-position: 0 -224px; } -.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; } -.ui-icon-grip-solid-vertical { background-position: -32px -224px; } -.ui-icon-grip-solid-horizontal { background-position: -48px -224px; } -.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; } -.ui-icon-grip-diagonal-se { background-position: -80px -224px; } - - -/* Misc visuals -----------------------------------*/ - -/* Corner radius */ -/* -.ui-corner-tl { -moz-border-radius-topleft: 4px; -webkit-border-top-left-radius: 4px; border-top-left-radius: 4px; } -.ui-corner-tr { -moz-border-radius-topright: 4px; -webkit-border-top-right-radius: 4px; border-top-right-radius: 4px; } -.ui-corner-bl { -moz-border-radius-bottomleft: 4px; -webkit-border-bottom-left-radius: 4px; border-bottom-left-radius: 4px; } -.ui-corner-br { -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 4px; border-bottom-right-radius: 4px; } -.ui-corner-top { -moz-border-radius-topleft: 4px; -webkit-border-top-left-radius: 4px; border-top-left-radius: 4px; -moz-border-radius-topright: 4px; -webkit-border-top-right-radius: 4px; border-top-right-radius: 4px; } -.ui-corner-bottom { -moz-border-radius-bottomleft: 4px; -webkit-border-bottom-left-radius: 4px; border-bottom-left-radius: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 4px; border-bottom-right-radius: 4px; } -.ui-corner-right { -moz-border-radius-topright: 4px; -webkit-border-top-right-radius: 4px; border-top-right-radius: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 4px; border-bottom-right-radius: 4px; } -.ui-corner-left { -moz-border-radius-topleft: 4px; -webkit-border-top-left-radius: 4px; border-top-left-radius: 4px; -moz-border-radius-bottomleft: 4px; -webkit-border-bottom-left-radius: 4px; border-bottom-left-radius: 4px; } -.ui-corner-all { -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; } -*/ - -/* Overlays */ -.ui-widget-overlay { background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); } -.ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); -moz-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; }/* - * jQuery UI Resizable 1.8.10 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Resizable#theming - */ -.ui-resizable { position: relative;} -.ui-resizable-handle { position: absolute;font-size: 0.1px;z-index: 99999; display: block;} -.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; } -.ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0; } -.ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0; } -.ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0; height: 100%; } -.ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0; height: 100%; } -.ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; } -.ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; } -.ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; } -.ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;}/* - * jQuery UI Selectable 1.8.10 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Selectable#theming - */ -.ui-selectable-helper { position: absolute; z-index: 100; border:1px dotted black; } -/* - * jQuery UI Accordion 1.8.10 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Accordion#theming - */ -/* IE/Win - Fix animation bug - #4615 */ -.ui-accordion { width: 100%; } -.ui-accordion .ui-accordion-header { cursor: pointer; position: relative; margin-top: 1px; zoom: 1; } -.ui-accordion .ui-accordion-li-fix { display: inline; } -.ui-accordion .ui-accordion-header-active { border-bottom: 0 !important; } -.ui-accordion .ui-accordion-header a { display: block; font-size: 1em; padding: .5em .5em .5em .7em; } -.ui-accordion-icons .ui-accordion-header a { padding-left: 2.2em; } -.ui-accordion .ui-accordion-header .ui-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; } -.ui-accordion .ui-accordion-content { padding: 1em 2.2em; border-top: 0; margin-top: -2px; position: relative; top: 1px; margin-bottom: 2px; overflow: auto; display: none; zoom: 1; } -.ui-accordion .ui-accordion-content-active { display: block; } -/* - * jQuery UI Autocomplete 1.8.10 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Autocomplete#theming - */ -/*.ui-autocomplete { position: absolute; cursor: default; } */ -.ui-autocomplete { - position: absolute; - cursor: default; - border: 1px solid #aaaaaa; -} - -/* workarounds */ -* html .ui-autocomplete { width:1px; } /* without this, the menu expands to 100% in IE6 */ - -/* - * jQuery UI Menu 1.8.10 - * - * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Menu#theming - */ -.ui-menu { - list-style:none; - padding: 2px; - margin: 0; - display:block; - float: left; -} -.ui-menu .ui-menu { - margin-top: -3px; -} -.ui-menu .ui-menu-item { - margin:0; - padding: 0; - zoom: 1; - float: left; - clear: left; - width: 100%; -} -.ui-menu .ui-menu-item a { - text-decoration:none; - display:block; - padding:.2em .4em; - line-height:1.5; - zoom:1; -} -.ui-menu .ui-menu-item a.ui-state-hover, -.ui-menu .ui-menu-item a.ui-state-active { - font-weight: normal; - margin: -1px; -} -/* - * jQuery UI Button 1.8.10 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Button#theming - */ -.ui-button { display: inline-block; position: relative; padding: 0; margin-right: .1em; text-decoration: none !important; cursor: pointer; text-align: center; zoom: 1; overflow: visible; } /* the overflow property removes extra width in IE */ -.ui-button-icon-only { width: 2.2em; } /* to make room for the icon, a width needs to be set here */ -button.ui-button-icon-only { width: 2.4em; } /* button elements seem to need a little more width */ -.ui-button-icons-only { width: 3.4em; } -button.ui-button-icons-only { width: 3.7em; } - -/*button text element */ -.ui-button .ui-button-text { display: block; line-height: 1.4; } -.ui-button-text-only .ui-button-text { padding: .4em 1em; } -.ui-button-icon-only .ui-button-text, .ui-button-icons-only .ui-button-text { padding: .4em; text-indent: -9999999px; } -.ui-button-text-icon-primary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 1em .4em 2.1em; } -.ui-button-text-icon-secondary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 2.1em .4em 1em; } -.ui-button-text-icons .ui-button-text { padding-left: 2.1em; padding-right: 2.1em; } -/* no icon support for input elements, provide padding by default */ -input.ui-button { padding: .4em 1em; } - -/*button icon element(s) */ -.ui-button-icon-only .ui-icon, .ui-button-text-icon-primary .ui-icon, .ui-button-text-icon-secondary .ui-icon, .ui-button-text-icons .ui-icon, .ui-button-icons-only .ui-icon { position: absolute; top: 50%; margin-top: -8px; } -.ui-button-icon-only .ui-icon { left: 50%; margin-left: -8px; } -.ui-button-text-icon-primary .ui-button-icon-primary, .ui-button-text-icons .ui-button-icon-primary, .ui-button-icons-only .ui-button-icon-primary { left: .5em; } -.ui-button-text-icon-secondary .ui-button-icon-secondary, .ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; } -.ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; } - -/*button sets*/ -.ui-buttonset { margin-right: 7px; } -.ui-buttonset .ui-button { margin-left: 0; margin-right: -.3em; } - -/* workarounds */ -button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra padding in Firefox */ -/* - * jQuery UI Dialog 1.8.10 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Dialog#theming - */ -.ui-dialog { position: absolute; padding: .2em; width: 300px; overflow: hidden; } -.ui-dialog .ui-dialog-titlebar { padding: .4em 1em; position: relative; } -.ui-dialog .ui-dialog-title { float: left; margin: .1em 16px .1em 0; } -.ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; } -.ui-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; } -.ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { padding: 0; } -.ui-dialog .ui-dialog-content { position: relative; border: 0; padding: .5em 1em; background: none; overflow: auto; zoom: 1; } -.ui-dialog .ui-dialog-buttonpane { text-align: left; border-width: 1px 0 0 0; background-image: none; margin: .5em 0 0 0; padding: .3em 1em .5em .4em; } -.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { float: right; } -.ui-dialog .ui-dialog-buttonpane button { margin: .5em .4em .5em 0; cursor: pointer; } -.ui-dialog .ui-resizable-se { width: 14px; height: 14px; right: 3px; bottom: 3px; } -.ui-draggable .ui-dialog-titlebar { cursor: move; } -/* - * jQuery UI Slider 1.8.10 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Slider#theming - */ -.ui-slider { position: relative; text-align: left; } -/*.ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.2em; height: 1.2em; cursor: default; }*/ -.ui-slider .ui-slider-handle { - border: 1px solid #999999; - position: absolute; - z-index: 2; - width: 1.2em; - height: 1.2em; - cursor: default; -} -.ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0; } - -.ui-slider-horizontal { height: .8em; } -.ui-slider-horizontal .ui-slider-handle { top: -.3em; margin-left: -.6em; } -.ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; } -.ui-slider-horizontal .ui-slider-range-min { left: 0; } -.ui-slider-horizontal .ui-slider-range-max { right: 0; } - -.ui-slider-vertical { width: .8em; height: 100px; } -.ui-slider-vertical .ui-slider-handle { left: -.3em; margin-left: 0; margin-bottom: -.6em; } -.ui-slider-vertical .ui-slider-range { left: 0; width: 100%; } -.ui-slider-vertical .ui-slider-range-min { bottom: 0; } -.ui-slider-vertical .ui-slider-range-max { top: 0; }/* - * jQuery UI Tabs 1.8.10 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Tabs#theming - */ -.ui-tabs { position: relative; padding: .2em; zoom: 1; } /* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */ -.ui-tabs .ui-tabs-nav { margin: 0; padding: .2em .2em 0; } -.ui-tabs .ui-tabs-nav li { list-style: none; float: left; position: relative; top: 1px; margin: 0 .2em 1px 0; border-bottom: 0 !important; padding: 0; white-space: nowrap; } -.ui-tabs .ui-tabs-nav li a { float: left; padding: .5em 1em; text-decoration: none; } -.ui-tabs .ui-tabs-nav li.ui-tabs-selected { margin-bottom: 0; padding-bottom: 1px; } -.ui-tabs .ui-tabs-nav li.ui-tabs-selected a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-state-processing a { cursor: text; } -.ui-tabs .ui-tabs-nav li a, .ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a { cursor: pointer; } /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */ -.ui-tabs .ui-tabs-panel { display: block; border-width: 0; padding: 1em 1.4em; background: none; } -.ui-tabs .ui-tabs-hide { display: none !important; } -/* - * jQuery UI Datepicker 1.8.10 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Datepicker#theming - */ -/*.ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; }*/ -.ui-datepicker { - width: 17em; - padding: .2em .2em 0; - border: 1px solid #aaa; - display: none; -} -.ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; } -.ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; } -/*.ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; }*/ -.ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { - top: 1px; - border: 1px solid #aaa; - cursor: pointer; -} -.ui-datepicker .ui-datepicker-prev { left:2px; } -.ui-datepicker .ui-datepicker-next { right:2px; } -.ui-datepicker .ui-datepicker-prev-hover { left:1px; } -.ui-datepicker .ui-datepicker-next-hover { right:1px; } -.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; } -.ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; } -.ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; } -.ui-datepicker select.ui-datepicker-month-year {width: 100%;} -.ui-datepicker select.ui-datepicker-month, -.ui-datepicker select.ui-datepicker-year { width: 49%;} -.ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; } -.ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; } -.ui-datepicker td { border: 0; padding: 1px; } -.ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; } -.ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; } -.ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; } -.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; } - -/* with multiple calendars */ -.ui-datepicker.ui-datepicker-multi { width:auto; } -.ui-datepicker-multi .ui-datepicker-group { float:left; } -.ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; } -.ui-datepicker-multi-2 .ui-datepicker-group { width:50%; } -.ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; } -.ui-datepicker-multi-4 .ui-datepicker-group { width:25%; } -.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; } -.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; } -.ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; } -.ui-datepicker-row-break { clear:both; width:100%; } - -/* RTL support */ -.ui-datepicker-rtl { direction: rtl; } -.ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; } -.ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; } -.ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; } -.ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; } -.ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; } -.ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; } -.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; } -.ui-datepicker-rtl .ui-datepicker-group { float:right; } -.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; } -.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; } - -/* IE6 IFRAME FIX (taken from datepicker 1.5.3 */ -.ui-datepicker-cover { - display: none; /*sorry for IE5*/ - display/**/: block; /*sorry for IE5*/ - position: absolute; /*must have*/ - z-index: -1; /*must have*/ - filter: mask(); /*must have*/ - top: -4px; /*must have*/ - left: -4px; /*must have*/ - width: 200px; /*must have*/ - height: 200px; /*must have*/ -}/* - * jQuery UI Progressbar 1.8.10 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Progressbar#theming - */ -.ui-progressbar { height:2em; text-align: left; } -.ui-progressbar .ui-progressbar-value {margin: -1px; height:100%; } \ No newline at end of file diff --git a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/jquery-1.7.js b/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/jquery-1.7.js deleted file mode 100755 index f9563e16b8..0000000000 --- a/nar-bundles/framework-bundle/framework/web/nifi-web-ui/src/main/webapp/js/jquery/jquery-1.7.js +++ /dev/null @@ -1,9017 +0,0 @@ -/*! - * jQuery JavaScript Library v1.7 - * http://jquery.com/ - * - * Copyright 2011, John Resig - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * Includes Sizzle.js - * http://sizzlejs.com/ - * Copyright 2011, The Dojo Foundation - * Released under the MIT, BSD, and GPL Licenses. - * - * Date: Thu Nov 3 16:18:21 2011 -0400 - */ -(function (window, undefined) { - -// Use the correct document accordingly with window argument (sandbox) - var document = window.document, - navigator = window.navigator, - location = window.location; - var jQuery = (function () { - -// Define a local copy of jQuery - var jQuery = function (selector, context) { - // The jQuery object is actually just the init constructor 'enhanced' - return new jQuery.fn.init(selector, context, rootjQuery); - }, - // Map over jQuery in case of overwrite - _jQuery = window.jQuery, - // Map over the $ in case of overwrite - _$ = window.$, - // A central reference to the root jQuery(document) - rootjQuery, - // A simple way to check for HTML strings or ID strings - // Prioritize #id over to avoid XSS via location.hash (#9521) - quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/, - // Check if a string has a non-whitespace character in it - rnotwhite = /\S/, - // Used for trimming whitespace - trimLeft = /^\s+/, - trimRight = /\s+$/, - // Check for digits - rdigit = /\d/, - // Match a standalone tag - rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/, - // JSON RegExp - rvalidchars = /^[\],:{}\s]*$/, - rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, - rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, - rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, - // Useragent RegExp - rwebkit = /(webkit)[ \/]([\w.]+)/, - ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/, - rmsie = /(msie) ([\w.]+)/, - rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/, - // Matches dashed string for camelizing - rdashAlpha = /-([a-z]|[0-9])/ig, - rmsPrefix = /^-ms-/, - // Used by jQuery.camelCase as callback to replace() - fcamelCase = function (all, letter) { - return (letter + "").toUpperCase(); - }, - // Keep a UserAgent string for use with jQuery.browser - userAgent = navigator.userAgent, - // For matching the engine and version of the browser - browserMatch, - // The deferred used on DOM ready - readyList, - // The ready event handler - DOMContentLoaded, - // Save a reference to some core methods - toString = Object.prototype.toString, - hasOwn = Object.prototype.hasOwnProperty, - push = Array.prototype.push, - slice = Array.prototype.slice, - trim = String.prototype.trim, - indexOf = Array.prototype.indexOf, - // [[Class]] -> type pairs - class2type = {}; - - jQuery.fn = jQuery.prototype = { - constructor: jQuery, - init: function (selector, context, rootjQuery) { - var match, elem, ret, doc; - - // Handle $(""), $(null), or $(undefined) - if (!selector) { - return this; - } - - // Handle $(DOMElement) - if (selector.nodeType) { - this.context = this[0] = selector; - this.length = 1; - return this; - } - - // The body element only exists once, optimize finding it - if (selector === "body" && !context && document.body) { - this.context = document; - this[0] = document.body; - this.selector = selector; - this.length = 1; - return this; - } - - // Handle HTML strings - if (typeof selector === "string") { - // Are we dealing with HTML string or an ID? - if (selector.charAt(0) === "<" && selector.charAt(selector.length - 1) === ">" && selector.length >= 3) { - // Assume that strings that start and end with <> are HTML and skip the regex check - match = [null, selector, null]; - - } else { - match = quickExpr.exec(selector); - } - - // Verify a match, and that no context was specified for #id - if (match && (match[1] || !context)) { - - // HANDLE: $(html) -> $(array) - if (match[1]) { - context = context instanceof jQuery ? context[0] : context; - doc = (context ? context.ownerDocument || context : document); - - // If a single string is passed in and it's a single tag - // just do a createElement and skip the rest - ret = rsingleTag.exec(selector); - - if (ret) { - if (jQuery.isPlainObject(context)) { - selector = [document.createElement(ret[1])]; - jQuery.fn.attr.call(selector, context, true); - - } else { - selector = [doc.createElement(ret[1])]; - } - - } else { - ret = jQuery.buildFragment([match[1]], [doc]); - selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes; - } - - return jQuery.merge(this, selector); - - // HANDLE: $("#id") - } else { - elem = document.getElementById(match[2]); - - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - if (elem && elem.parentNode) { - // Handle the case where IE and Opera return items - // by name instead of ID - if (elem.id !== match[2]) { - return rootjQuery.find(selector); - } - - // Otherwise, we inject the element directly into the jQuery object - this.length = 1; - this[0] = elem; - } - - this.context = document; - this.selector = selector; - return this; - } - - // HANDLE: $(expr, $(...)) - } else if (!context || context.jquery) { - return (context || rootjQuery).find(selector); - - // HANDLE: $(expr, context) - // (which is just equivalent to: $(context).find(expr) - } else { - return this.constructor(context).find(selector); - } - - // HANDLE: $(function) - // Shortcut for document ready - } else if (jQuery.isFunction(selector)) { - return rootjQuery.ready(selector); - } - - if (selector.selector !== undefined) { - this.selector = selector.selector; - this.context = selector.context; - } - - return jQuery.makeArray(selector, this); - }, - // Start with an empty selector - selector: "", - // The current version of jQuery being used - jquery: "1.7", - // The default length of a jQuery object is 0 - length: 0, - // The number of elements contained in the matched element set - size: function () { - return this.length; - }, - toArray: function () { - return slice.call(this, 0); - }, - // Get the Nth element in the matched element set OR - // Get the whole matched element set as a clean array - get: function (num) { - return num == null ? - // Return a 'clean' array - this.toArray() : - // Return just the object - (num < 0 ? this[ this.length + num ] : this[ num ]); - }, - // Take an array of elements and push it onto the stack - // (returning the new matched element set) - pushStack: function (elems, name, selector) { - // Build a new jQuery matched element set - var ret = this.constructor(); - - if (jQuery.isArray(elems)) { - push.apply(ret, elems); - - } else { - jQuery.merge(ret, elems); - } - - // Add the old object onto the stack (as a reference) - ret.prevObject = this; - - ret.context = this.context; - - if (name === "find") { - ret.selector = this.selector + (this.selector ? " " : "") + selector; - } else if (name) { - ret.selector = this.selector + "." + name + "(" + selector + ")"; - } - - // Return the newly-formed element set - return ret; - }, - // Execute a callback for every element in the matched set. - // (You can seed the arguments with an array of args, but this is - // only used internally.) - each: function (callback, args) { - return jQuery.each(this, callback, args); - }, - ready: function (fn) { - // Attach the listeners - jQuery.bindReady(); - - // Add the callback - readyList.add(fn); - - return this; - }, - eq: function (i) { - return i === -1 ? - this.slice(i) : - this.slice(i, +i + 1); - }, - first: function () { - return this.eq(0); - }, - last: function () { - return this.eq(-1); - }, - slice: function () { - return this.pushStack(slice.apply(this, arguments), - "slice", slice.call(arguments).join(",")); - }, - map: function (callback) { - return this.pushStack(jQuery.map(this, function (elem, i) { - return callback.call(elem, i, elem); - })); - }, - end: function () { - return this.prevObject || this.constructor(null); - }, - // For internal use only. - // Behaves like an Array's method, not like a jQuery method. - push: push, - sort: [].sort, - splice: [].splice - }; - -// Give the init function the jQuery prototype for later instantiation - jQuery.fn.init.prototype = jQuery.fn; - - jQuery.extend = jQuery.fn.extend = function () { - var options, name, src, copy, copyIsArray, clone, - target = arguments[0] || {}, - i = 1, - length = arguments.length, - deep = false; - - // Handle a deep copy situation - if (typeof target === "boolean") { - deep = target; - target = arguments[1] || {}; - // skip the boolean and the target - i = 2; - } - - // Handle case when target is a string or something (possible in deep copy) - if (typeof target !== "object" && !jQuery.isFunction(target)) { - target = {}; - } - - // extend jQuery itself if only one argument is passed - if (length === i) { - target = this; - --i; - } - - for (; i < length; i++) { - // Only deal with non-null/undefined values - if ((options = arguments[ i ]) != null) { - // Extend the base object - for (name in options) { - src = target[ name ]; - copy = options[ name ]; - - // Prevent never-ending loop - if (target === copy) { - continue; - } - - // Recurse if we're merging plain objects or arrays - if (deep && copy && (jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)))) { - if (copyIsArray) { - copyIsArray = false; - clone = src && jQuery.isArray(src) ? src : []; - - } else { - clone = src && jQuery.isPlainObject(src) ? src : {}; - } - - // Never move original objects, clone them - target[ name ] = jQuery.extend(deep, clone, copy); - - // Don't bring in undefined values - } else if (copy !== undefined) { - target[ name ] = copy; - } - } - } - } - - // Return the modified object - return target; - }; - - jQuery.extend({ - noConflict: function (deep) { - if (window.$ === jQuery) { - window.$ = _$; - } - - if (deep && window.jQuery === jQuery) { - window.jQuery = _jQuery; - } - - return jQuery; - }, - // Is the DOM ready to be used? Set to true once it occurs. - isReady: false, - // A counter to track how many items to wait for before - // the ready event fires. See #6781 - readyWait: 1, - // Hold (or release) the ready event - holdReady: function (hold) { - if (hold) { - jQuery.readyWait++; - } else { - jQuery.ready(true); - } - }, - // Handle when the DOM is ready - ready: function (wait) { - // Either a released hold or an DOMready/load event and not yet ready - if ((wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady)) { - // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). - if (!document.body) { - return setTimeout(jQuery.ready, 1); - } - - // Remember that the DOM is ready - jQuery.isReady = true; - - // If a normal DOM Ready event fired, decrement, and wait if need be - if (wait !== true && --jQuery.readyWait > 0) { - return; - } - - // If there are functions bound, to execute - readyList.fireWith(document, [jQuery]); - - // Trigger any bound ready events - if (jQuery.fn.trigger) { - jQuery(document).trigger("ready").unbind("ready"); - } - } - }, - bindReady: function () { - if (readyList) { - return; - } - - readyList = jQuery.Callbacks("once memory"); - - // Catch cases where $(document).ready() is called after the - // browser event has already occurred. - if (document.readyState === "complete") { - // Handle it asynchronously to allow scripts the opportunity to delay ready - return setTimeout(jQuery.ready, 1); - } - - // Mozilla, Opera and webkit nightlies currently support this event - if (document.addEventListener) { - // Use the handy event callback - document.addEventListener("DOMContentLoaded", DOMContentLoaded, false); - - // A fallback to window.onload, that will always work - window.addEventListener("load", jQuery.ready, false); - - // If IE event model is used - } else if (document.attachEvent) { - // ensure firing before onload, - // maybe late but safe also for iframes - document.attachEvent("onreadystatechange", DOMContentLoaded); - - // A fallback to window.onload, that will always work - window.attachEvent("onload", jQuery.ready); - - // If IE and not a frame - // continually check to see if the document is ready - var toplevel = false; - - try { - toplevel = window.frameElement == null; - } catch (e) { - } - - if (document.documentElement.doScroll && toplevel) { - doScrollCheck(); - } - } - }, - // See test/unit/core.js for details concerning isFunction. - // Since version 1.3, DOM methods and functions like alert - // aren't supported. They return false on IE (#2968). - isFunction: function (obj) { - return jQuery.type(obj) === "function"; - }, - isArray: Array.isArray || function (obj) { - return jQuery.type(obj) === "array"; - }, - // A crude way of determining if an object is a window - isWindow: function (obj) { - return obj && typeof obj === "object" && "setInterval" in obj; - }, - isNumeric: function (obj) { - return obj != null && rdigit.test(obj) && !isNaN(obj); - }, - type: function (obj) { - return obj == null ? - String(obj) : - class2type[ toString.call(obj) ] || "object"; - }, - isPlainObject: function (obj) { - // Must be an Object. - // Because of IE, we also have to check the presence of the constructor property. - // Make sure that DOM nodes and window objects don't pass through, as well - if (!obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow(obj)) { - return false; - } - - try { - // Not own constructor property must be Object - if (obj.constructor && - !hasOwn.call(obj, "constructor") && - !hasOwn.call(obj.constructor.prototype, "isPrototypeOf")) { - return false; - } - } catch (e) { - // IE8,9 Will throw exceptions on certain host objects #9897 - return false; - } - - // Own properties are enumerated firstly, so to speed up, - // if last one is own, then all properties are own. - - var key; - for (key in obj) { - } - - return key === undefined || hasOwn.call(obj, key); - }, - isEmptyObject: function (obj) { - for (var name in obj) { - return false; - } - return true; - }, - error: function (msg) { - throw msg; - }, - parseJSON: function (data) { - if (typeof data !== "string" || !data) { - return null; - } - - // Make sure leading/trailing whitespace is removed (IE can't handle it) - data = jQuery.trim(data); - - // Attempt to parse using the native JSON parser first - if (window.JSON && window.JSON.parse) { - return window.JSON.parse(data); - } - - // Make sure the incoming data is actual JSON - // Logic borrowed from http://json.org/json2.js - if (rvalidchars.test(data.replace(rvalidescape, "@") - .replace(rvalidtokens, "]") - .replace(rvalidbraces, ""))) { - - return (new Function("return " + data))(); - - } - jQuery.error("Invalid JSON: " + data); - }, - // Cross-browser xml parsing - parseXML: function (data) { - var xml, tmp; - try { - if (window.DOMParser) { // Standard - tmp = new DOMParser(); - xml = tmp.parseFromString(data, "text/xml"); - } else { // IE - xml = new ActiveXObject("Microsoft.XMLDOM"); - xml.async = "false"; - xml.loadXML(data); - } - } catch (e) { - xml = undefined; - } - if (!xml || !xml.documentElement || xml.getElementsByTagName("parsererror").length) { - jQuery.error("Invalid XML: " + data); - } - return xml; - }, - noop: function () { - }, - // Evaluates a script in a global context - // Workarounds based on findings by Jim Driscoll - // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context - globalEval: function (data) { - if (data && rnotwhite.test(data)) { - // We use execScript on Internet Explorer - // We use an anonymous function so that context is window - // rather than jQuery in Firefox - (window.execScript || function (data) { - window[ "eval" ].call(window, data); - })(data); - } - }, - // Convert dashed to camelCase; used by the css and data modules - // Microsoft forgot to hump their vendor prefix (#9572) - camelCase: function (string) { - return string.replace(rmsPrefix, "ms-").replace(rdashAlpha, fcamelCase); - }, - nodeName: function (elem, name) { - return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); - }, - // args is for internal usage only - each: function (object, callback, args) { - var name, i = 0, - length = object.length, - isObj = length === undefined || jQuery.isFunction(object); - - if (args) { - if (isObj) { - for (name in object) { - if (callback.apply(object[ name ], args) === false) { - break; - } - } - } else { - for (; i < length; ) { - if (callback.apply(object[ i++ ], args) === false) { - break; - } - } - } - - // A special, fast, case for the most common use of each - } else { - if (isObj) { - for (name in object) { - if (callback.call(object[ name ], name, object[ name ]) === false) { - break; - } - } - } else { - for (; i < length; ) { - if (callback.call(object[ i ], i, object[ i++ ]) === false) { - break; - } - } - } - } - - return object; - }, - // Use native String.trim function wherever possible - trim: trim ? - function (text) { - return text == null ? - "" : - trim.call(text); - } : - // Otherwise use our own trimming functionality - function (text) { - return text == null ? - "" : - text.toString().replace(trimLeft, "").replace(trimRight, ""); - }, - // results is for internal usage only - makeArray: function (array, results) { - var ret = results || []; - - if (array != null) { - // The window, strings (and functions) also have 'length' - // The extra typeof function check is to prevent crashes - // in Safari 2 (See: #3039) - // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 - var type = jQuery.type(array); - - if (array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow(array)) { - push.call(ret, array); - } else { - jQuery.merge(ret, array); - } - } - - return ret; - }, - inArray: function (elem, array, i) { - var len; - - if (array) { - if (indexOf) { - return indexOf.call(array, elem, i); - } - - len = array.length; - i = i ? i < 0 ? Math.max(0, len + i) : i : 0; - - for (; i < len; i++) { - // Skip accessing in sparse arrays - if (i in array && array[ i ] === elem) { - return i; - } - } - } - - return -1; - }, - merge: function (first, second) { - var i = first.length, - j = 0; - - if (typeof second.length === "number") { - for (var l = second.length; j < l; j++) { - first[ i++ ] = second[ j ]; - } - - } else { - while (second[j] !== undefined) { - first[ i++ ] = second[ j++ ]; - } - } - - first.length = i; - - return first; - }, - grep: function (elems, callback, inv) { - var ret = [], retVal; - inv = !!inv; - - // Go through the array, only saving the items - // that pass the validator function - for (var i = 0, length = elems.length; i < length; i++) { - retVal = !!callback(elems[ i ], i); - if (inv !== retVal) { - ret.push(elems[ i ]); - } - } - - return ret; - }, - // arg is for internal usage only - map: function (elems, callback, arg) { - var value, key, ret = [], - i = 0, - length = elems.length, - // jquery objects are treated as arrays - isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ((length > 0 && elems[ 0 ] && elems[ length - 1 ]) || length === 0 || jQuery.isArray(elems)); - - // Go through the array, translating each of the items to their - if (isArray) { - for (; i < length; i++) { - value = callback(elems[ i ], i, arg); - - if (value != null) { - ret[ ret.length ] = value; - } - } - - // Go through every key on the object, - } else { - for (key in elems) { - value = callback(elems[ key ], key, arg); - - if (value != null) { - ret[ ret.length ] = value; - } - } - } - - // Flatten any nested arrays - return ret.concat.apply([], ret); - }, - // A global GUID counter for objects - guid: 1, - // Bind a function to a context, optionally partially applying any - // arguments. - proxy: function (fn, context) { - if (typeof context === "string") { - var tmp = fn[ context ]; - context = fn; - fn = tmp; - } - - // Quick check to determine if target is callable, in the spec - // this throws a TypeError, but we will just return undefined. - if (!jQuery.isFunction(fn)) { - return undefined; - } - - // Simulated bind - var args = slice.call(arguments, 2), - proxy = function () { - return fn.apply(context, args.concat(slice.call(arguments))); - }; - - // Set the guid of unique handler to the same of original handler, so it can be removed - proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++; - - return proxy; - }, - // Mutifunctional method to get and set values to a collection - // The value/s can optionally be executed if it's a function - access: function (elems, key, value, exec, fn, pass) { - var length = elems.length; - - // Setting many attributes - if (typeof key === "object") { - for (var k in key) { - jQuery.access(elems, k, key[k], exec, fn, value); - } - return elems; - } - - // Setting one attribute - if (value !== undefined) { - // Optionally, function values get executed if exec is true - exec = !pass && exec && jQuery.isFunction(value); - - for (var i = 0; i < length; i++) { - fn(elems[i], key, exec ? value.call(elems[i], i, fn(elems[i], key)) : value, pass); - } - - return elems; - } - - // Getting an attribute - return length ? fn(elems[0], key) : undefined; - }, - now: function () { - return (new Date()).getTime(); - }, - // Use of jQuery.browser is frowned upon. - // More details: http://docs.jquery.com/Utilities/jQuery.browser - uaMatch: function (ua) { - ua = ua.toLowerCase(); - - var match = rwebkit.exec(ua) || - ropera.exec(ua) || - rmsie.exec(ua) || - ua.indexOf("compatible") < 0 && rmozilla.exec(ua) || - []; - - return {browser: match[1] || "", version: match[2] || "0"}; - }, - sub: function () { - function jQuerySub(selector, context) { - return new jQuerySub.fn.init(selector, context); - } - jQuery.extend(true, jQuerySub, this); - jQuerySub.superclass = this; - jQuerySub.fn = jQuerySub.prototype = this(); - jQuerySub.fn.constructor = jQuerySub; - jQuerySub.sub = this.sub; - jQuerySub.fn.init = function init(selector, context) { - if (context && context instanceof jQuery && !(context instanceof jQuerySub)) { - context = jQuerySub(context); - } - - return jQuery.fn.init.call(this, selector, context, rootjQuerySub); - }; - jQuerySub.fn.init.prototype = jQuerySub.fn; - var rootjQuerySub = jQuerySub(document); - return jQuerySub; - }, - browser: {} - }); - -// Populate the class2type map - jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function (i, name) { - class2type[ "[object " + name + "]" ] = name.toLowerCase(); - }); - - browserMatch = jQuery.uaMatch(userAgent); - if (browserMatch.browser) { - jQuery.browser[ browserMatch.browser ] = true; - jQuery.browser.version = browserMatch.version; - } - -// Deprecated, use jQuery.browser.webkit instead - if (jQuery.browser.webkit) { - jQuery.browser.safari = true; - } - -// IE doesn't match non-breaking spaces with \s - if (rnotwhite.test("\xA0")) { - trimLeft = /^[\s\xA0]+/; - trimRight = /[\s\xA0]+$/; - } - -// All jQuery objects should point back to these - rootjQuery = jQuery(document); - -// Cleanup functions for the document ready method - if (document.addEventListener) { - DOMContentLoaded = function () { - document.removeEventListener("DOMContentLoaded", DOMContentLoaded, false); - jQuery.ready(); - }; - - } else if (document.attachEvent) { - DOMContentLoaded = function () { - // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). - if (document.readyState === "complete") { - document.detachEvent("onreadystatechange", DOMContentLoaded); - jQuery.ready(); - } - }; - } - -// The DOM ready check for Internet Explorer - function doScrollCheck() { - if (jQuery.isReady) { - return; - } - - try { - // If IE is used, use the trick by Diego Perini - // http://javascript.nwbox.com/IEContentLoaded/ - document.documentElement.doScroll("left"); - } catch (e) { - setTimeout(doScrollCheck, 1); - return; - } - - // and execute any waiting functions - jQuery.ready(); - } - -// Expose jQuery as an AMD module, but only for AMD loaders that -// understand the issues with loading multiple versions of jQuery -// in a page that all might call define(). The loader will indicate -// they have special allowances for multiple jQuery versions by -// specifying define.amd.jQuery = true. Register as a named module, -// since jQuery can be concatenated with other files that may use define, -// but not use a proper concatenation script that understands anonymous -// AMD modules. A named AMD is safest and most robust way to register. -// Lowercase jquery is used because AMD module names are derived from -// file names, and jQuery is normally delivered in a lowercase file name. - if (typeof define === "function" && define.amd && define.amd.jQuery) { - define("jquery", [], function () { - return jQuery; - }); - } - - return jQuery; - - })(); - - -// String to Object flags format cache - var flagsCache = {}; - -// Convert String-formatted flags into Object-formatted ones and store in cache - function createFlags(flags) { - var object = flagsCache[ flags ] = {}, - i, length; - flags = flags.split(/\s+/); - for (i = 0, length = flags.length; i < length; i++) { - object[ flags[i] ] = true; - } - return object; - } - - /* - * Create a callback list using the following parameters: - * - * flags: an optional list of space-separated flags that will change how - * the callback list behaves - * - * By default a callback list will act like an event callback list and can be - * "fired" multiple times. - * - * Possible flags: - * - * once: will ensure the callback list can only be fired once (like a Deferred) - * - * memory: will keep track of previous values and will call any callback added - * after the list has been fired right away with the latest "memorized" - * values (like a Deferred) - * - * unique: will ensure a callback can only be added once (no duplicate in the list) - * - * stopOnFalse: interrupt callings when a callback returns false - * - */ - jQuery.Callbacks = function (flags) { - - // Convert flags from String-formatted to Object-formatted - // (we check in cache first) - flags = flags ? (flagsCache[ flags ] || createFlags(flags)) : {}; - - var // Actual callback list - list = [], - // Stack of fire calls for repeatable lists - stack = [], - // Last fire value (for non-forgettable lists) - memory, - // Flag to know if list is currently firing - firing, - // First callback to fire (used internally by add and fireWith) - firingStart, - // End of the loop when firing - firingLength, - // Index of currently firing callback (modified by remove if needed) - firingIndex, - // Add one or several callbacks to the list - add = function (args) { - var i, - length, - elem, - type, - actual; - for (i = 0, length = args.length; i < length; i++) { - elem = args[ i ]; - type = jQuery.type(elem); - if (type === "array") { - // Inspect recursively - add(elem); - } else if (type === "function") { - // Add if not in unique mode and callback is not in - if (!flags.unique || !self.has(elem)) { - list.push(elem); - } - } - } - }, - // Fire callbacks - fire = function (context, args) { - args = args || []; - memory = !flags.memory || [context, args]; - firing = true; - firingIndex = firingStart || 0; - firingStart = 0; - firingLength = list.length; - for (; list && firingIndex < firingLength; firingIndex++) { - if (list[ firingIndex ].apply(context, args) === false && flags.stopOnFalse) { - memory = true; // Mark as halted - break; - } - } - firing = false; - if (list) { - if (!flags.once) { - if (stack && stack.length) { - memory = stack.shift(); - self.fireWith(memory[ 0 ], memory[ 1 ]); - } - } else if (memory === true) { - self.disable(); - } else { - list = []; - } - } - }, - // Actual Callbacks object - self = { - // Add a callback or a collection of callbacks to the list - add: function () { - if (list) { - var length = list.length; - add(arguments); - // Do we need to add the callbacks to the - // current firing batch? - if (firing) { - firingLength = list.length; - // With memory, if we're not firing then - // we should call right away, unless previous - // firing was halted (stopOnFalse) - } else if (memory && memory !== true) { - firingStart = length; - fire(memory[ 0 ], memory[ 1 ]); - } - } - return this; - }, - // Remove a callback from the list - remove: function () { - if (list) { - var args = arguments, - argIndex = 0, - argLength = args.length; - for (; argIndex < argLength; argIndex++) { - for (var i = 0; i < list.length; i++) { - if (args[ argIndex ] === list[ i ]) { - // Handle firingIndex and firingLength - if (firing) { - if (i <= firingLength) { - firingLength--; - if (i <= firingIndex) { - firingIndex--; - } - } - } - // Remove the element - list.splice(i--, 1); - // If we have some unicity property then - // we only need to do this once - if (flags.unique) { - break; - } - } - } - } - } - return this; - }, - // Control if a given callback is in the list - has: function (fn) { - if (list) { - var i = 0, - length = list.length; - for (; i < length; i++) { - if (fn === list[ i ]) { - return true; - } - } - } - return false; - }, - // Remove all callbacks from the list - empty: function () { - list = []; - return this; - }, - // Have the list do nothing anymore - disable: function () { - list = stack = memory = undefined; - return this; - }, - // Is it disabled? - disabled: function () { - return !list; - }, - // Lock the list in its current state - lock: function () { - stack = undefined; - if (!memory || memory === true) { - self.disable(); - } - return this; - }, - // Is it locked? - locked: function () { - return !stack; - }, - // Call all callbacks with the given context and arguments - fireWith: function (context, args) { - if (stack) { - if (firing) { - if (!flags.once) { - stack.push([context, args]); - } - } else if (!(flags.once && memory)) { - fire(context, args); - } - } - return this; - }, - // Call all the callbacks with the given arguments - fire: function () { - self.fireWith(this, arguments); - return this; - }, - // To know if the callbacks have already been called at least once - fired: function () { - return !!memory; - } - }; - - return self; - }; - - - - - var // Static reference to slice - sliceDeferred = [].slice; - - jQuery.extend({ - Deferred: function (func) { - var doneList = jQuery.Callbacks("once memory"), - failList = jQuery.Callbacks("once memory"), - progressList = jQuery.Callbacks("memory"), - state = "pending", - lists = { - resolve: doneList, - reject: failList, - notify: progressList - }, - promise = { - done: doneList.add, - fail: failList.add, - progress: progressList.add, - state: function () { - return state; - }, - // Deprecated - isResolved: doneList.fired, - isRejected: failList.fired, - then: function (doneCallbacks, failCallbacks, progressCallbacks) { - deferred.done(doneCallbacks).fail(failCallbacks).progress(progressCallbacks); - return this; - }, - always: function () { - return deferred.done.apply(deferred, arguments).fail.apply(deferred, arguments); - }, - pipe: function (fnDone, fnFail, fnProgress) { - return jQuery.Deferred(function (newDefer) { - jQuery.each({ - done: [fnDone, "resolve"], - fail: [fnFail, "reject"], - progress: [fnProgress, "notify"] - }, function (handler, data) { - var fn = data[ 0 ], - action = data[ 1 ], - returned; - if (jQuery.isFunction(fn)) { - deferred[ handler ](function () { - returned = fn.apply(this, arguments); - if (returned && jQuery.isFunction(returned.promise)) { - returned.promise().then(newDefer.resolve, newDefer.reject, newDefer.notify); - } else { - newDefer[ action + "With" ](this === deferred ? newDefer : this, [returned]); - } - }); - } else { - deferred[ handler ](newDefer[ action ]); - } - }); - }).promise(); - }, - // Get a promise for this deferred - // If obj is provided, the promise aspect is added to the object - promise: function (obj) { - if (obj == null) { - obj = promise; - } else { - for (var key in promise) { - obj[ key ] = promise[ key ]; - } - } - return obj; - } - }, - deferred = promise.promise({}), - key; - - for (key in lists) { - deferred[ key ] = lists[ key ].fire; - deferred[ key + "With" ] = lists[ key ].fireWith; - } - - // Handle state - deferred.done(function () { - state = "resolved"; - }, failList.disable, progressList.lock).fail(function () { - state = "rejected"; - }, doneList.disable, progressList.lock); - - // Call given func if any - if (func) { - func.call(deferred, deferred); - } - - // All done! - return deferred; - }, - // Deferred helper - when: function (firstParam) { - var args = sliceDeferred.call(arguments, 0), - i = 0, - length = args.length, - pValues = new Array(length), - count = length, - pCount = length, - deferred = length <= 1 && firstParam && jQuery.isFunction(firstParam.promise) ? - firstParam : - jQuery.Deferred(), - promise = deferred.promise(); - function resolveFunc(i) { - return function (value) { - args[ i ] = arguments.length > 1 ? sliceDeferred.call(arguments, 0) : value; - if (!(--count)) { - deferred.resolveWith(deferred, args); - } - }; - } - function progressFunc(i) { - return function (value) { - pValues[ i ] = arguments.length > 1 ? sliceDeferred.call(arguments, 0) : value; - deferred.notifyWith(promise, pValues); - }; - } - if (length > 1) { - for (; i < length; i++) { - if (args[ i ] && args[ i ].promise && jQuery.isFunction(args[ i ].promise)) { - args[ i ].promise().then(resolveFunc(i), deferred.reject, progressFunc(i)); - } else { - --count; - } - } - if (!count) { - deferred.resolveWith(deferred, args); - } - } else if (deferred !== firstParam) { - deferred.resolveWith(deferred, length ? [firstParam] : []); - } - return promise; - } - }); - - - - - jQuery.support = (function () { - - var div = document.createElement("div"), - documentElement = document.documentElement, - all, - a, - select, - opt, - input, - marginDiv, - support, - fragment, - body, - testElementParent, - testElement, - testElementStyle, - tds, - events, - eventName, - i, - isSupported; - - // Preliminary tests - div.setAttribute("className", "t"); - div.innerHTML = "
a"; - - - all = div.getElementsByTagName("*"); - a = div.getElementsByTagName("a")[ 0 ]; - - // Can't get basic test support - if (!all || !all.length || !a) { - return {}; - } - - // First batch of supports tests - select = document.createElement("select"); - opt = select.appendChild(document.createElement("option")); - input = div.getElementsByTagName("input")[ 0 ]; - - support = { - // IE strips leading whitespace when .innerHTML is used - leadingWhitespace: (div.firstChild.nodeType === 3), - // Make sure that tbody elements aren't automatically inserted - // IE will insert them into empty tables - tbody: !div.getElementsByTagName("tbody").length, - // Make sure that link elements get serialized correctly by innerHTML - // This requires a wrapper element in IE - htmlSerialize: !!div.getElementsByTagName("link").length, - // Get the style information from getAttribute - // (IE uses .cssText instead) - style: /top/.test(a.getAttribute("style")), - // Make sure that URLs aren't manipulated - // (IE normalizes it by default) - hrefNormalized: (a.getAttribute("href") === "/a"), - // Make sure that element opacity exists - // (IE uses filter instead) - // Use a regex to work around a WebKit issue. See #5145 - opacity: /^0.55/.test(a.style.opacity), - // Verify style float existence - // (IE uses styleFloat instead of cssFloat) - cssFloat: !!a.style.cssFloat, - // Make sure unknown elements (like HTML5 elems) are handled appropriately - unknownElems: !!div.getElementsByTagName("nav").length, - // Make sure that if no value is specified for a checkbox - // that it defaults to "on". - // (WebKit defaults to "" instead) - checkOn: (input.value === "on"), - // Make sure that a selected-by-default option has a working selected property. - // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) - optSelected: opt.selected, - // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) - getSetAttribute: div.className !== "t", - // Tests for enctype support on a form(#6743) - enctype: !!document.createElement("form").enctype, - // Will be defined later - submitBubbles: true, - changeBubbles: true, - focusinBubbles: false, - deleteExpando: true, - noCloneEvent: true, - inlineBlockNeedsLayout: false, - shrinkWrapBlocks: false, - reliableMarginRight: true - }; - - // Make sure checked status is properly cloned - input.checked = true; - support.noCloneChecked = input.cloneNode(true).checked; - - // Make sure that the options inside disabled selects aren't marked as disabled - // (WebKit marks them as disabled) - select.disabled = true; - support.optDisabled = !opt.disabled; - - // Test to see if it's possible to delete an expando from an element - // Fails in Internet Explorer - try { - delete div.test; - } catch (e) { - support.deleteExpando = false; - } - - if (!div.addEventListener && div.attachEvent && div.fireEvent) { - div.attachEvent("onclick", function () { - // Cloning a node shouldn't copy over any - // bound event handlers (IE does this) - support.noCloneEvent = false; - }); - div.cloneNode(true).fireEvent("onclick"); - } - - // Check if a radio maintains its value - // after being appended to the DOM - input = document.createElement("input"); - input.value = "t"; - input.setAttribute("type", "radio"); - support.radioValue = input.value === "t"; - - input.setAttribute("checked", "checked"); - div.appendChild(input); - fragment = document.createDocumentFragment(); - fragment.appendChild(div.lastChild); - - // WebKit doesn't clone checked state correctly in fragments - support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked; - - div.innerHTML = ""; - - // Figure out if the W3C box model works as expected - div.style.width = div.style.paddingLeft = "1px"; - - // We don't want to do body-related feature tests on frameset - // documents, which lack a body. So we use - // document.getElementsByTagName("body")[0], which is undefined in - // frameset documents, while document.body isn’t. (7398) - body = document.getElementsByTagName("body")[ 0 ]; - // We use our own, invisible, body unless the body is already present - // in which case we use a div (#9239) - testElement = document.createElement(body ? "div" : "body"); - testElementStyle = { - visibility: "hidden", - width: 0, - height: 0, - border: 0, - margin: 0, - background: "none" - }; - if (body) { - jQuery.extend(testElementStyle, { - position: "absolute", - left: "-999px", - top: "-999px" - }); - } - for (i in testElementStyle) { - testElement.style[ i ] = testElementStyle[ i ]; - } - testElement.appendChild(div); - testElementParent = body || documentElement; - testElementParent.insertBefore(testElement, testElementParent.firstChild); - - // Check if a disconnected checkbox will retain its checked - // value of true after appended to the DOM (IE6/7) - support.appendChecked = input.checked; - - support.boxModel = div.offsetWidth === 2; - - if ("zoom" in div.style) { - // Check if natively block-level elements act like inline-block - // elements when setting their display to 'inline' and giving - // them layout - // (IE < 8 does this) - div.style.display = "inline"; - div.style.zoom = 1; - support.inlineBlockNeedsLayout = (div.offsetWidth === 2); - - // Check if elements with layout shrink-wrap their children - // (IE 6 does this) - div.style.display = ""; - div.innerHTML = "
"; - support.shrinkWrapBlocks = (div.offsetWidth !== 2); - } - - div.innerHTML = "
t
"; - tds = div.getElementsByTagName("td"); - - // Check if table cells still have offsetWidth/Height when they are set - // to display:none and there are still other visible table cells in a - // table row; if so, offsetWidth/Height are not reliable for use when - // determining if an element has been hidden directly using - // display:none (it is still safe to use offsets if a parent element is - // hidden; don safety goggles and see bug #4512 for more information). - // (only IE 8 fails this test) - isSupported = (tds[ 0 ].offsetHeight === 0); - - tds[ 0 ].style.display = ""; - tds[ 1 ].style.display = "none"; - - // Check if empty table cells still have offsetWidth/Height - // (IE < 8 fail this test) - support.reliableHiddenOffsets = isSupported && (tds[ 0 ].offsetHeight === 0); - div.innerHTML = ""; - - // Check if div with explicit width and no margin-right incorrectly - // gets computed margin-right based on width of container. For more - // info see bug #3333 - // Fails in WebKit before Feb 2011 nightlies - // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right - if (document.defaultView && document.defaultView.getComputedStyle) { - marginDiv = document.createElement("div"); - marginDiv.style.width = "0"; - marginDiv.style.marginRight = "0"; - div.appendChild(marginDiv); - support.reliableMarginRight = - (parseInt((document.defaultView.getComputedStyle(marginDiv, null) || {marginRight: 0}).marginRight, 10) || 0) === 0; - } - - // Technique from Juriy Zaytsev - // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/ - // We only care about the case where non-standard event systems - // are used, namely in IE. Short-circuiting here helps us to - // avoid an eval call (in setAttribute) which can cause CSP - // to go haywire. See: https://developer.mozilla.org/en/Security/CSP - if (div.attachEvent) { - for (i in { - submit: 1, - change: 1, - focusin: 1 - }) { - eventName = "on" + i; - isSupported = (eventName in div); - if (!isSupported) { - div.setAttribute(eventName, "return;"); - isSupported = (typeof div[ eventName ] === "function"); - } - support[ i + "Bubbles" ] = isSupported; - } - } - - // Run fixed position tests at doc ready to avoid a crash - // related to the invisible body in IE8 - jQuery(function () { - var container, outer, inner, table, td, offsetSupport, - conMarginTop = 1, - ptlm = "position:absolute;top:0;left:0;width:1px;height:1px;margin:0;", - vb = "visibility:hidden;border:0;", - style = "style='" + ptlm + "border:5px solid #000;padding:0;'", - html = "
" + - "" + - "
"; - - // Reconstruct a container - body = document.getElementsByTagName("body")[0]; - if (!body) { - // Return for frameset docs that don't have a body - // These tests cannot be done - return; - } - - container = document.createElement("div"); - container.style.cssText = vb + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px"; - body.insertBefore(container, body.firstChild); - - // Construct a test element - testElement = document.createElement("div"); - testElement.style.cssText = ptlm + vb; - - testElement.innerHTML = html; - container.appendChild(testElement); - outer = testElement.firstChild; - inner = outer.firstChild; - td = outer.nextSibling.firstChild.firstChild; - - offsetSupport = { - doesNotAddBorder: (inner.offsetTop !== 5), - doesAddBorderForTableAndCells: (td.offsetTop === 5) - }; - - inner.style.position = "fixed"; - inner.style.top = "20px"; - - // safari subtracts parent border width here which is 5px - offsetSupport.fixedPosition = (inner.offsetTop === 20 || inner.offsetTop === 15); - inner.style.position = inner.style.top = ""; - - outer.style.overflow = "hidden"; - outer.style.position = "relative"; - - offsetSupport.subtractsBorderForOverflowNotVisible = (inner.offsetTop === -5); - offsetSupport.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== conMarginTop); - - body.removeChild(container); - testElement = container = null; - - jQuery.extend(support, offsetSupport); - }); - - testElement.innerHTML = ""; - testElementParent.removeChild(testElement); - - // Null connected elements to avoid leaks in IE - testElement = fragment = select = opt = body = marginDiv = div = input = null; - - return support; - })(); - -// Keep track of boxModel - jQuery.boxModel = jQuery.support.boxModel; - - - - - var rbrace = /^(?:\{.*\}|\[.*\])$/, - rmultiDash = /([A-Z])/g; - - jQuery.extend({ - cache: {}, - // Please use with caution - uuid: 0, - // Unique for each copy of jQuery on the page - // Non-digits removed to match rinlinejQuery - expando: "jQuery" + (jQuery.fn.jquery + Math.random()).replace(/\D/g, ""), - // The following elements throw uncatchable exceptions if you - // attempt to add expando properties to them. - noData: { - "embed": true, - // Ban all objects except for Flash (which handle expandos) - "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", - "applet": true - }, - hasData: function (elem) { - elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; - return !!elem && !isEmptyDataObject(elem); - }, - data: function (elem, name, data, pvt /* Internal Use Only */) { - if (!jQuery.acceptData(elem)) { - return; - } - - var privateCache, thisCache, ret, - internalKey = jQuery.expando, - getByName = typeof name === "string", - // We have to handle DOM nodes and JS objects differently because IE6-7 - // can't GC object references properly across the DOM-JS boundary - isNode = elem.nodeType, - // Only DOM nodes need the global jQuery cache; JS object data is - // attached directly to the object so GC can occur automatically - cache = isNode ? jQuery.cache : elem, - // Only defining an ID for JS objects if its cache already exists allows - // the code to shortcut on the same path as a DOM node with no cache - id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando, - isEvents = name === "events"; - - // Avoid doing any more work than we need to when trying to get data on an - // object that has no data at all - if ((!id || !cache[id] || (!isEvents && !pvt && !cache[id].data)) && getByName && data === undefined) { - return; - } - - if (!id) { - // Only DOM nodes need a new unique ID for each element since their data - // ends up in the global cache - if (isNode) { - elem[ jQuery.expando ] = id = ++jQuery.uuid; - } else { - id = jQuery.expando; - } - } - - if (!cache[ id ]) { - cache[ id ] = {}; - - // Avoids exposing jQuery metadata on plain JS objects when the object - // is serialized using JSON.stringify - if (!isNode) { - cache[ id ].toJSON = jQuery.noop; - } - } - - // An object can be passed to jQuery.data instead of a key/value pair; this gets - // shallow copied over onto the existing cache - if (typeof name === "object" || typeof name === "function") { - if (pvt) { - cache[ id ] = jQuery.extend(cache[ id ], name); - } else { - cache[ id ].data = jQuery.extend(cache[ id ].data, name); - } - } - - privateCache = thisCache = cache[ id ]; - - // jQuery data() is stored in a separate object inside the object's internal data - // cache in order to avoid key collisions between internal data and user-defined - // data. - if (!pvt) { - if (!thisCache.data) { - thisCache.data = {}; - } - - thisCache = thisCache.data; - } - - if (data !== undefined) { - thisCache[ jQuery.camelCase(name) ] = data; - } - - // Users should not attempt to inspect the internal events object using jQuery.data, - // it is undocumented and subject to change. But does anyone listen? No. - if (isEvents && !thisCache[ name ]) { - return privateCache.events; - } - - // Check for both converted-to-camel and non-converted data property names - // If a data property was specified - if (getByName) { - - // First Try to find as-is property data - ret = thisCache[ name ]; - - // Test for null|undefined property data - if (ret == null) { - - // Try to find the camelCased property - ret = thisCache[ jQuery.camelCase(name) ]; - } - } else { - ret = thisCache; - } - - return ret; - }, - removeData: function (elem, name, pvt /* Internal Use Only */) { - if (!jQuery.acceptData(elem)) { - return; - } - - var thisCache, i, l, - // Reference to internal data cache key - internalKey = jQuery.expando, - isNode = elem.nodeType, - // See jQuery.data for more information - cache = isNode ? jQuery.cache : elem, - // See jQuery.data for more information - id = isNode ? elem[ jQuery.expando ] : jQuery.expando; - - // If there is already no cache entry for this object, there is no - // purpose in continuing - if (!cache[ id ]) { - return; - } - - if (name) { - - thisCache = pvt ? cache[ id ] : cache[ id ].data; - - if (thisCache) { - - // Support space separated names - if (jQuery.isArray(name)) { - name = name; - } else if (name in thisCache) { - name = [name]; - } else { - - // split the camel cased version by spaces - name = jQuery.camelCase(name); - if (name in thisCache) { - name = [name]; - } else { - name = name.split(" "); - } - } - - for (i = 0, l = name.length; i < l; i++) { - delete thisCache[ name[i] ]; - } - - // If there is no data left in the cache, we want to continue - // and let the cache object itself get destroyed - if (!(pvt ? isEmptyDataObject : jQuery.isEmptyObject)(thisCache)) { - return; - } - } - } - - // See jQuery.data for more information - if (!pvt) { - delete cache[ id ].data; - - // Don't destroy the parent cache unless the internal data object - // had been the only thing left in it - if (!isEmptyDataObject(cache[ id ])) { - return; - } - } - - // Browsers that fail expando deletion also refuse to delete expandos on - // the window, but it will allow it on all other JS objects; other browsers - // don't care - // Ensure that `cache` is not a window object #10080 - if (jQuery.support.deleteExpando || !cache.setInterval) { - delete cache[ id ]; - } else { - cache[ id ] = null; - } - - // We destroyed the cache and need to eliminate the expando on the node to avoid - // false lookups in the cache for entries that no longer exist - if (isNode) { - // IE does not allow us to delete expando properties from nodes, - // nor does it have a removeAttribute function on Document nodes; - // we must handle all of these cases - if (jQuery.support.deleteExpando) { - delete elem[ jQuery.expando ]; - } else if (elem.removeAttribute) { - elem.removeAttribute(jQuery.expando); - } else { - elem[ jQuery.expando ] = null; - } - } - }, - // For internal use only. - _data: function (elem, name, data) { - return jQuery.data(elem, name, data, true); - }, - // A method for determining if a DOM node can handle the data expando - acceptData: function (elem) { - if (elem.nodeName) { - var match = jQuery.noData[ elem.nodeName.toLowerCase() ]; - - if (match) { - return !(match === true || elem.getAttribute("classid") !== match); - } - } - - return true; - } - }); - - jQuery.fn.extend({ - data: function (key, value) { - var parts, attr, name, - data = null; - - if (typeof key === "undefined") { - if (this.length) { - data = jQuery.data(this[0]); - - if (this[0].nodeType === 1 && !jQuery._data(this[0], "parsedAttrs")) { - attr = this[0].attributes; - for (var i = 0, l = attr.length; i < l; i++) { - name = attr[i].name; - - if (name.indexOf("data-") === 0) { - name = jQuery.camelCase(name.substring(5)); - - dataAttr(this[0], name, data[ name ]); - } - } - jQuery._data(this[0], "parsedAttrs", true); - } - } - - return data; - - } else if (typeof key === "object") { - return this.each(function () { - jQuery.data(this, key); - }); - } - - parts = key.split("."); - parts[1] = parts[1] ? "." + parts[1] : ""; - - if (value === undefined) { - data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); - - // Try to fetch any internally stored data first - if (data === undefined && this.length) { - data = jQuery.data(this[0], key); - data = dataAttr(this[0], key, data); - } - - return data === undefined && parts[1] ? - this.data(parts[0]) : - data; - - } else { - return this.each(function () { - var $this = jQuery(this), - args = [parts[0], value]; - - $this.triggerHandler("setData" + parts[1] + "!", args); - jQuery.data(this, key, value); - $this.triggerHandler("changeData" + parts[1] + "!", args); - }); - } - }, - removeData: function (key) { - return this.each(function () { - jQuery.removeData(this, key); - }); - } - }); - - function dataAttr(elem, key, data) { - // If nothing was found internally, try to fetch any - // data from the HTML5 data-* attribute - if (data === undefined && elem.nodeType === 1) { - - var name = "data-" + key.replace(rmultiDash, "-$1").toLowerCase(); - - data = elem.getAttribute(name); - - if (typeof data === "string") { - try { - data = data === "true" ? true : - data === "false" ? false : - data === "null" ? null : - jQuery.isNumeric(data) ? parseFloat(data) : - rbrace.test(data) ? jQuery.parseJSON(data) : - data; - } catch (e) { - } - - // Make sure we set the data so it isn't changed later - jQuery.data(elem, key, data); - - } else { - data = undefined; - } - } - - return data; - } - -// checks a cache object for emptiness - function isEmptyDataObject(obj) { - for (var name in obj) { - - // if the public data object is empty, the private is still empty - if (name === "data" && jQuery.isEmptyObject(obj[name])) { - continue; - } - if (name !== "toJSON") { - return false; - } - } - - return true; - } - - - - - function handleQueueMarkDefer(elem, type, src) { - var deferDataKey = type + "defer", - queueDataKey = type + "queue", - markDataKey = type + "mark", - defer = jQuery._data(elem, deferDataKey); - if (defer && - (src === "queue" || !jQuery._data(elem, queueDataKey)) && - (src === "mark" || !jQuery._data(elem, markDataKey))) { - // Give room for hard-coded callbacks to fire first - // and eventually mark/queue something else on the element - setTimeout(function () { - if (!jQuery._data(elem, queueDataKey) && - !jQuery._data(elem, markDataKey)) { - jQuery.removeData(elem, deferDataKey, true); - defer.fire(); - } - }, 0); - } - } - - jQuery.extend({ - _mark: function (elem, type) { - if (elem) { - type = (type || "fx") + "mark"; - jQuery._data(elem, type, (jQuery._data(elem, type) || 0) + 1); - } - }, - _unmark: function (force, elem, type) { - if (force !== true) { - type = elem; - elem = force; - force = false; - } - if (elem) { - type = type || "fx"; - var key = type + "mark", - count = force ? 0 : ((jQuery._data(elem, key) || 1) - 1); - if (count) { - jQuery._data(elem, key, count); - } else { - jQuery.removeData(elem, key, true); - handleQueueMarkDefer(elem, type, "mark"); - } - } - }, - queue: function (elem, type, data) { - var q; - if (elem) { - type = (type || "fx") + "queue"; - q = jQuery._data(elem, type); - - // Speed up dequeue by getting out quickly if this is just a lookup - if (data) { - if (!q || jQuery.isArray(data)) { - q = jQuery._data(elem, type, jQuery.makeArray(data)); - } else { - q.push(data); - } - } - return q || []; - } - }, - dequeue: function (elem, type) { - type = type || "fx"; - - var queue = jQuery.queue(elem, type), - fn = queue.shift(), - hooks = {}; - - // If the fx queue is dequeued, always remove the progress sentinel - if (fn === "inprogress") { - fn = queue.shift(); - } - - if (fn) { - // Add a progress sentinel to prevent the fx queue from being - // automatically dequeued - if (type === "fx") { - queue.unshift("inprogress"); - } - - jQuery._data(elem, type + ".run", hooks); - fn.call(elem, function () { - jQuery.dequeue(elem, type); - }, hooks); - } - - if (!queue.length) { - jQuery.removeData(elem, type + "queue " + type + ".run", true); - handleQueueMarkDefer(elem, type, "queue"); - } - } - }); - - jQuery.fn.extend({ - queue: function (type, data) { - if (typeof type !== "string") { - data = type; - type = "fx"; - } - - if (data === undefined) { - return jQuery.queue(this[0], type); - } - return this.each(function () { - var queue = jQuery.queue(this, type, data); - - if (type === "fx" && queue[0] !== "inprogress") { - jQuery.dequeue(this, type); - } - }); - }, - dequeue: function (type) { - return this.each(function () { - jQuery.dequeue(this, type); - }); - }, - // Based off of the plugin by Clint Helfers, with permission. - // http://blindsignals.com/index.php/2009/07/jquery-delay/ - delay: function (time, type) { - time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; - type = type || "fx"; - - return this.queue(type, function (next, hooks) { - var timeout = setTimeout(next, time); - hooks.stop = function () { - clearTimeout(timeout); - }; - }); - }, - clearQueue: function (type) { - return this.queue(type || "fx", []); - }, - // Get a promise resolved when queues of a certain type - // are emptied (fx is the type by default) - promise: function (type, object) { - if (typeof type !== "string") { - object = type; - type = undefined; - } - type = type || "fx"; - var defer = jQuery.Deferred(), - elements = this, - i = elements.length, - count = 1, - deferDataKey = type + "defer", - queueDataKey = type + "queue", - markDataKey = type + "mark", - tmp; - function resolve() { - if (!(--count)) { - defer.resolveWith(elements, [elements]); - } - } - while (i--) { - if ((tmp = jQuery.data(elements[ i ], deferDataKey, undefined, true) || - (jQuery.data(elements[ i ], queueDataKey, undefined, true) || - jQuery.data(elements[ i ], markDataKey, undefined, true)) && - jQuery.data(elements[ i ], deferDataKey, jQuery.Callbacks("once memory"), true))) { - count++; - tmp.add(resolve); - } - } - resolve(); - return defer.promise(); - } - }); - - - - - var rclass = /[\n\t\r]/g, - rspace = /\s+/, - rreturn = /\r/g, - rtype = /^(?:button|input)$/i, - rfocusable = /^(?:button|input|object|select|textarea)$/i, - rclickable = /^a(?:rea)?$/i, - rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, - getSetAttribute = jQuery.support.getSetAttribute, - nodeHook, boolHook, fixSpecified; - - jQuery.fn.extend({ - attr: function (name, value) { - return jQuery.access(this, name, value, true, jQuery.attr); - }, - removeAttr: function (name) { - return this.each(function () { - jQuery.removeAttr(this, name); - }); - }, - prop: function (name, value) { - return jQuery.access(this, name, value, true, jQuery.prop); - }, - removeProp: function (name) { - name = jQuery.propFix[ name ] || name; - return this.each(function () { - // try/catch handles cases where IE balks (such as removing a property on window) - try { - this[ name ] = undefined; - delete this[ name ]; - } catch (e) { - } - }); - }, - addClass: function (value) { - var classNames, i, l, elem, - setClass, c, cl; - - if (jQuery.isFunction(value)) { - return this.each(function (j) { - jQuery(this).addClass(value.call(this, j, this.className)); - }); - } - - if (value && typeof value === "string") { - classNames = value.split(rspace); - - for (i = 0, l = this.length; i < l; i++) { - elem = this[ i ]; - - if (elem.nodeType === 1) { - if (!elem.className && classNames.length === 1) { - elem.className = value; - - } else { - setClass = " " + elem.className + " "; - - for (c = 0, cl = classNames.length; c < cl; c++) { - if (!~setClass.indexOf(" " + classNames[ c ] + " ")) { - setClass += classNames[ c ] + " "; - } - } - elem.className = jQuery.trim(setClass); - } - } - } - } - - return this; - }, - removeClass: function (value) { - var classNames, i, l, elem, className, c, cl; - - if (jQuery.isFunction(value)) { - return this.each(function (j) { - jQuery(this).removeClass(value.call(this, j, this.className)); - }); - } - - if ((value && typeof value === "string") || value === undefined) { - classNames = (value || "").split(rspace); - - for (i = 0, l = this.length; i < l; i++) { - elem = this[ i ]; - - if (elem.nodeType === 1 && elem.className) { - if (value) { - className = (" " + elem.className + " ").replace(rclass, " "); - for (c = 0, cl = classNames.length; c < cl; c++) { - className = className.replace(" " + classNames[ c ] + " ", " "); - } - elem.className = jQuery.trim(className); - - } else { - elem.className = ""; - } - } - } - } - - return this; - }, - toggleClass: function (value, stateVal) { - var type = typeof value, - isBool = typeof stateVal === "boolean"; - - if (jQuery.isFunction(value)) { - return this.each(function (i) { - jQuery(this).toggleClass(value.call(this, i, this.className, stateVal), stateVal); - }); - } - - return this.each(function () { - if (type === "string") { - // toggle individual class names - var className, - i = 0, - self = jQuery(this), - state = stateVal, - classNames = value.split(rspace); - - while ((className = classNames[ i++ ])) { - // check each className given, space seperated list - state = isBool ? state : !self.hasClass(className); - self[ state ? "addClass" : "removeClass" ](className); - } - - } else if (type === "undefined" || type === "boolean") { - if (this.className) { - // store className if set - jQuery._data(this, "__className__", this.className); - } - - // toggle whole className - this.className = this.className || value === false ? "" : jQuery._data(this, "__className__") || ""; - } - }); - }, - hasClass: function (selector) { - var className = " " + selector + " ", - i = 0, - l = this.length; - for (; i < l; i++) { - if (this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf(className) > -1) { - return true; - } - } - - return false; - }, - val: function (value) { - var hooks, ret, isFunction, - elem = this[0]; - - if (!arguments.length) { - if (elem) { - hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ]; - - if (hooks && "get" in hooks && (ret = hooks.get(elem, "value")) !== undefined) { - return ret; - } - - ret = elem.value; - - return typeof ret === "string" ? - // handle most common string cases - ret.replace(rreturn, "") : - // handle cases where value is null/undef or number - ret == null ? "" : ret; - } - - return undefined; - } - - isFunction = jQuery.isFunction(value); - - return this.each(function (i) { - var self = jQuery(this), val; - - if (this.nodeType !== 1) { - return; - } - - if (isFunction) { - val = value.call(this, i, self.val()); - } else { - val = value; - } - - // Treat null/undefined as ""; convert numbers to string - if (val == null) { - val = ""; - } else if (typeof val === "number") { - val += ""; - } else if (jQuery.isArray(val)) { - val = jQuery.map(val, function (value) { - return value == null ? "" : value + ""; - }); - } - - hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ]; - - // If set returns undefined, fall back to normal setting - if (!hooks || !("set" in hooks) || hooks.set(this, val, "value") === undefined) { - this.value = val; - } - }); - } - }); - - jQuery.extend({ - valHooks: { - option: { - get: function (elem) { - // attributes.value is undefined in Blackberry 4.7 but - // uses .value. See #6932 - var val = elem.attributes.value; - return !val || val.specified ? elem.value : elem.text; - } - }, - select: { - get: function (elem) { - var value, i, max, option, - index = elem.selectedIndex, - values = [], - options = elem.options, - one = elem.type === "select-one"; - - // Nothing was selected - if (index < 0) { - return null; - } - - // Loop through all the selected options - i = one ? index : 0; - max = one ? index + 1 : options.length; - for (; i < max; i++) { - option = options[ i ]; - - // Don't return options that are disabled or in a disabled optgroup - if (option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && - (!option.parentNode.disabled || !jQuery.nodeName(option.parentNode, "optgroup"))) { - - // Get the specific value for the option - value = jQuery(option).val(); - - // We don't need an array for one selects - if (one) { - return value; - } - - // Multi-Selects return an array - values.push(value); - } - } - - // Fixes Bug #2551 -- select.val() broken in IE after form.reset() - if (one && !values.length && options.length) { - return jQuery(options[ index ]).val(); - } - - return values; - }, - set: function (elem, value) { - var values = jQuery.makeArray(value); - - jQuery(elem).find("option").each(function () { - this.selected = jQuery.inArray(jQuery(this).val(), values) >= 0; - }); - - if (!values.length) { - elem.selectedIndex = -1; - } - return values; - } - } - }, - attrFn: { - val: true, - css: true, - html: true, - text: true, - data: true, - width: true, - height: true, - offset: true - }, - attr: function (elem, name, value, pass) { - var ret, hooks, notxml, - nType = elem.nodeType; - - // don't get/set attributes on text, comment and attribute nodes - if (!elem || nType === 3 || nType === 8 || nType === 2) { - return undefined; - } - - if (pass && name in jQuery.attrFn) { - return jQuery(elem)[ name ](value); - } - - // Fallback to prop when attributes are not supported - if (!("getAttribute" in elem)) { - return jQuery.prop(elem, name, value); - } - - notxml = nType !== 1 || !jQuery.isXMLDoc(elem); - - // All attributes are lowercase - // Grab necessary hook if one is defined - if (notxml) { - name = name.toLowerCase(); - hooks = jQuery.attrHooks[ name ] || (rboolean.test(name) ? boolHook : nodeHook); - } - - if (value !== undefined) { - - if (value === null) { - jQuery.removeAttr(elem, name); - return undefined; - - } else if (hooks && "set" in hooks && notxml && (ret = hooks.set(elem, value, name)) !== undefined) { - return ret; - - } else { - elem.setAttribute(name, "" + value); - return value; - } - - } else if (hooks && "get" in hooks && notxml && (ret = hooks.get(elem, name)) !== null) { - return ret; - - } else { - - ret = elem.getAttribute(name); - - // Non-existent attributes return null, we normalize to undefined - return ret === null ? - undefined : - ret; - } - }, - removeAttr: function (elem, value) { - var propName, attrNames, name, l, - i = 0; - - if (elem.nodeType === 1) { - attrNames = (value || "").split(rspace); - l = attrNames.length; - - for (; i < l; i++) { - name = attrNames[ i ].toLowerCase(); - propName = jQuery.propFix[ name ] || name; - - // See #9699 for explanation of this approach (setting first, then removal) - jQuery.attr(elem, name, ""); - elem.removeAttribute(getSetAttribute ? name : propName); - - // Set corresponding property to false for boolean attributes - if (rboolean.test(name) && propName in elem) { - elem[ propName ] = false; - } - } - } - }, - attrHooks: { - type: { - set: function (elem, value) { - // We can't allow the type property to be changed (since it causes problems in IE) - if (rtype.test(elem.nodeName) && elem.parentNode) { - jQuery.error("type property can't be changed"); - } else if (!jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input")) { - // Setting the type on a radio button after the value resets the value in IE6-9 - // Reset value to it's default in case type is set after value - // This is for element creation - var val = elem.value; - elem.setAttribute("type", value); - if (val) { - elem.value = val; - } - return value; - } - } - }, - // Use the value property for back compat - // Use the nodeHook for button elements in IE6/7 (#1954) - value: { - get: function (elem, name) { - if (nodeHook && jQuery.nodeName(elem, "button")) { - return nodeHook.get(elem, name); - } - return name in elem ? - elem.value : - null; - }, - set: function (elem, value, name) { - if (nodeHook && jQuery.nodeName(elem, "button")) { - return nodeHook.set(elem, value, name); - } - // Does not return so that setAttribute is also used - elem.value = value; - } - } - }, - propFix: { - tabindex: "tabIndex", - readonly: "readOnly", - "for": "htmlFor", - "class": "className", - maxlength: "maxLength", - cellspacing: "cellSpacing", - cellpadding: "cellPadding", - rowspan: "rowSpan", - colspan: "colSpan", - usemap: "useMap", - frameborder: "frameBorder", - contenteditable: "contentEditable" - }, - prop: function (elem, name, value) { - var ret, hooks, notxml, - nType = elem.nodeType; - - // don't get/set properties on text, comment and attribute nodes - if (!elem || nType === 3 || nType === 8 || nType === 2) { - return undefined; - } - - notxml = nType !== 1 || !jQuery.isXMLDoc(elem); - - if (notxml) { - // Fix name and attach hooks - name = jQuery.propFix[ name ] || name; - hooks = jQuery.propHooks[ name ]; - } - - if (value !== undefined) { - if (hooks && "set" in hooks && (ret = hooks.set(elem, value, name)) !== undefined) { - return ret; - - } else { - return (elem[ name ] = value); - } - - } else { - if (hooks && "get" in hooks && (ret = hooks.get(elem, name)) !== null) { - return ret; - - } else { - return elem[ name ]; - } - } - }, - propHooks: { - tabIndex: { - get: function (elem) { - // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set - // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ - var attributeNode = elem.getAttributeNode("tabindex"); - - return attributeNode && attributeNode.specified ? - parseInt(attributeNode.value, 10) : - rfocusable.test(elem.nodeName) || rclickable.test(elem.nodeName) && elem.href ? - 0 : - undefined; - } - } - } - }); - -// Add the tabIndex propHook to attrHooks for back-compat (different case is intentional) - jQuery.attrHooks.tabindex = jQuery.propHooks.tabIndex; - -// Hook for boolean attributes - boolHook = { - get: function (elem, name) { - // Align boolean attributes with corresponding properties - // Fall back to attribute presence where some booleans are not supported - var attrNode, - property = jQuery.prop(elem, name); - return property === true || typeof property !== "boolean" && (attrNode = elem.getAttributeNode(name)) && attrNode.nodeValue !== false ? - name.toLowerCase() : - undefined; - }, - set: function (elem, value, name) { - var propName; - if (value === false) { - // Remove boolean attributes when set to false - jQuery.removeAttr(elem, name); - } else { - // value is true since we know at this point it's type boolean and not false - // Set boolean attributes to the same name and set the DOM property - propName = jQuery.propFix[ name ] || name; - if (propName in elem) { - // Only set the IDL specifically if it already exists on the element - elem[ propName ] = true; - } - - elem.setAttribute(name, name.toLowerCase()); - } - return name; - } - }; - -// IE6/7 do not support getting/setting some attributes with get/setAttribute - if (!getSetAttribute) { - - fixSpecified = { - name: true, - id: true - }; - - // Use this for any attribute in IE6/7 - // This fixes almost every IE6/7 issue - nodeHook = jQuery.valHooks.button = { - get: function (elem, name) { - var ret; - ret = elem.getAttributeNode(name); - return ret && (fixSpecified[ name ] ? ret.nodeValue !== "" : ret.specified) ? - ret.nodeValue : - undefined; - }, - set: function (elem, value, name) { - // Set the existing or create a new attribute node - var ret = elem.getAttributeNode(name); - if (!ret) { - ret = document.createAttribute(name); - elem.setAttributeNode(ret); - } - return (ret.nodeValue = value + ""); - } - }; - - // Apply the nodeHook to tabindex - jQuery.attrHooks.tabindex.set = nodeHook.set; - - // Set width and height to auto instead of 0 on empty string( Bug #8150 ) - // This is for removals - jQuery.each(["width", "height"], function (i, name) { - jQuery.attrHooks[ name ] = jQuery.extend(jQuery.attrHooks[ name ], { - set: function (elem, value) { - if (value === "") { - elem.setAttribute(name, "auto"); - return value; - } - } - }); - }); - - // Set contenteditable to false on removals(#10429) - // Setting to empty string throws an error as an invalid value - jQuery.attrHooks.contenteditable = { - get: nodeHook.get, - set: function (elem, value, name) { - if (value === "") { - value = "false"; - } - nodeHook.set(elem, value, name); - } - }; - } - - -// Some attributes require a special call on IE - if (!jQuery.support.hrefNormalized) { - jQuery.each(["href", "src", "width", "height"], function (i, name) { - jQuery.attrHooks[ name ] = jQuery.extend(jQuery.attrHooks[ name ], { - get: function (elem) { - var ret = elem.getAttribute(name, 2); - return ret === null ? undefined : ret; - } - }); - }); - } - - if (!jQuery.support.style) { - jQuery.attrHooks.style = { - get: function (elem) { - // Return undefined in the case of empty string - // Normalize to lowercase since IE uppercases css property names - return elem.style.cssText.toLowerCase() || undefined; - }, - set: function (elem, value) { - return (elem.style.cssText = "" + value); - } - }; - } - -// Safari mis-reports the default selected property of an option -// Accessing the parent's selectedIndex property fixes it - if (!jQuery.support.optSelected) { - jQuery.propHooks.selected = jQuery.extend(jQuery.propHooks.selected, { - get: function (elem) { - var parent = elem.parentNode; - - if (parent) { - parent.selectedIndex; - - // Make sure that it also works with optgroups, see #5701 - if (parent.parentNode) { - parent.parentNode.selectedIndex; - } - } - return null; - } - }); - } - -// IE6/7 call enctype encoding - if (!jQuery.support.enctype) { - jQuery.propFix.enctype = "encoding"; - } - -// Radios and checkboxes getter/setter - if (!jQuery.support.checkOn) { - jQuery.each(["radio", "checkbox"], function () { - jQuery.valHooks[ this ] = { - get: function (elem) { - // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified - return elem.getAttribute("value") === null ? "on" : elem.value; - } - }; - }); - } - jQuery.each(["radio", "checkbox"], function () { - jQuery.valHooks[ this ] = jQuery.extend(jQuery.valHooks[ this ], { - set: function (elem, value) { - if (jQuery.isArray(value)) { - return (elem.checked = jQuery.inArray(jQuery(elem).val(), value) >= 0); - } - } - }); - }); - - - - - var rnamespaces = /\.(.*)$/, - rformElems = /^(?:textarea|input|select)$/i, - rperiod = /\./g, - rspaces = / /g, - rescape = /[^\w\s.|`]/g, - rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/, - rhoverHack = /\bhover(\.\S+)?/, - rkeyEvent = /^key/, - rmouseEvent = /^(?:mouse|contextmenu)|click/, - rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/, - quickParse = function (selector) { - var quick = rquickIs.exec(selector); - if (quick) { - // 0 1 2 3 - // [ _, tag, id, class ] - quick[1] = (quick[1] || "").toLowerCase(); - quick[3] = quick[3] && new RegExp("(?:^|\\s)" + quick[3] + "(?:\\s|$)"); - } - return quick; - }, - quickIs = function (elem, m) { - return ( - (!m[1] || elem.nodeName.toLowerCase() === m[1]) && - (!m[2] || elem.id === m[2]) && - (!m[3] || m[3].test(elem.className)) - ); - }, - hoverHack = function (events) { - return jQuery.event.special.hover ? events : events.replace(rhoverHack, "mouseenter$1 mouseleave$1"); - }; - - /* - * Helper functions for managing events -- not part of the public interface. - * Props to Dean Edwards' addEvent library for many of the ideas. - */ - jQuery.event = { - add: function (elem, types, handler, data, selector) { - - var elemData, eventHandle, events, - t, tns, type, namespaces, handleObj, - handleObjIn, quick, handlers, special; - - // Don't attach events to noData or text/comment nodes (allow plain objects tho) - if (elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data(elem))) { - return; - } - - // Caller can pass in an object of custom data in lieu of the handler - if (handler.handler) { - handleObjIn = handler; - handler = handleObjIn.handler; - } - - // Make sure that the handler has a unique ID, used to find/remove it later - if (!handler.guid) { - handler.guid = jQuery.guid++; - } - - // Init the element's event structure and main handler, if this is the first - events = elemData.events; - if (!events) { - elemData.events = events = {}; - } - eventHandle = elemData.handle; - if (!eventHandle) { - elemData.handle = eventHandle = function (e) { - // Discard the second event of a jQuery.event.trigger() and - // when an event is called after a page has unloaded - return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ? - jQuery.event.dispatch.apply(eventHandle.elem, arguments) : - undefined; - }; - // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events - eventHandle.elem = elem; - } - - // Handle multiple events separated by a space - // jQuery(...).bind("mouseover mouseout", fn); - types = hoverHack(types).split(" "); - for (t = 0; t < types.length; t++) { - - tns = rtypenamespace.exec(types[t]) || []; - type = tns[1]; - namespaces = (tns[2] || "").split(".").sort(); - - // If event changes its type, use the special event handlers for the changed type - special = jQuery.event.special[ type ] || {}; - - // If selector defined, determine special event api type, otherwise given type - type = (selector ? special.delegateType : special.bindType) || type; - - // Update special based on newly reset type - special = jQuery.event.special[ type ] || {}; - - // handleObj is passed to all event handlers - handleObj = jQuery.extend({ - type: type, - origType: tns[1], - data: data, - handler: handler, - guid: handler.guid, - selector: selector, - namespace: namespaces.join(".") - }, handleObjIn); - - // Delegated event; pre-analyze selector so it's processed quickly on event dispatch - if (selector) { - handleObj.quick = quickParse(selector); - if (!handleObj.quick && jQuery.expr.match.POS.test(selector)) { - handleObj.isPositional = true; - } - } - - // Init the event handler queue if we're the first - handlers = events[ type ]; - if (!handlers) { - handlers = events[ type ] = []; - handlers.delegateCount = 0; - - // Only use addEventListener/attachEvent if the special events handler returns false - if (!special.setup || special.setup.call(elem, data, namespaces, eventHandle) === false) { - // Bind the global event handler to the element - if (elem.addEventListener) { - elem.addEventListener(type, eventHandle, false); - - } else if (elem.attachEvent) { - elem.attachEvent("on" + type, eventHandle); - } - } - } - - if (special.add) { - special.add.call(elem, handleObj); - - if (!handleObj.handler.guid) { - handleObj.handler.guid = handler.guid; - } - } - - // Add to the element's handler list, delegates in front - if (selector) { - handlers.splice(handlers.delegateCount++, 0, handleObj); - } else { - handlers.push(handleObj); - } - - // Keep track of which events have ever been used, for event optimization - jQuery.event.global[ type ] = true; - } - - // Nullify elem to prevent memory leaks in IE - elem = null; - }, - global: {}, - // Detach an event or set of events from an element - remove: function (elem, types, handler, selector) { - - var elemData = jQuery.hasData(elem) && jQuery._data(elem), - t, tns, type, namespaces, origCount, - j, events, special, handle, eventType, handleObj; - - if (!elemData || !(events = elemData.events)) { - return; - } - - // Once for each type.namespace in types; type may be omitted - types = hoverHack(types || "").split(" "); - for (t = 0; t < types.length; t++) { - tns = rtypenamespace.exec(types[t]) || []; - type = tns[1]; - namespaces = tns[2]; - - // Unbind all events (on this namespace, if provided) for the element - if (!type) { - namespaces = namespaces ? "." + namespaces : ""; - for (j in events) { - jQuery.event.remove(elem, j + namespaces, handler, selector); - } - return; - } - - special = jQuery.event.special[ type ] || {}; - type = (selector ? special.delegateType : special.bindType) || type; - eventType = events[ type ] || []; - origCount = eventType.length; - namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null; - - // Only need to loop for special events or selective removal - if (handler || namespaces || selector || special.remove) { - for (j = 0; j < eventType.length; j++) { - handleObj = eventType[ j ]; - - if (!handler || handler.guid === handleObj.guid) { - if (!namespaces || namespaces.test(handleObj.namespace)) { - if (!selector || selector === handleObj.selector || selector === "**" && handleObj.selector) { - eventType.splice(j--, 1); - - if (handleObj.selector) { - eventType.delegateCount--; - } - if (special.remove) { - special.remove.call(elem, handleObj); - } - } - } - } - } - } else { - // Removing all events - eventType.length = 0; - } - - // Remove generic event handler if we removed something and no more handlers exist - // (avoids potential for endless recursion during removal of special event handlers) - if (eventType.length === 0 && origCount !== eventType.length) { - if (!special.teardown || special.teardown.call(elem, namespaces) === false) { - jQuery.removeEvent(elem, type, elemData.handle); - } - - delete events[ type ]; - } - } - - // Remove the expando if it's no longer used - if (jQuery.isEmptyObject(events)) { - handle = elemData.handle; - if (handle) { - handle.elem = null; - } - - // removeData also checks for emptiness and clears the expando if empty - // so use it instead of delete - jQuery.removeData(elem, ["events", "handle"], true); - } - }, - // Events that are safe to short-circuit if no handlers are attached. - // Native DOM events should not be added, they may have inline handlers. - customEvent: { - "getData": true, - "setData": true, - "changeData": true - }, - trigger: function (event, data, elem, onlyHandlers) { - // Don't do events on text and comment nodes - if (elem && (elem.nodeType === 3 || elem.nodeType === 8)) { - return; - } - - // Event object or event type - var type = event.type || event, - namespaces = [], - cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType; - - if (type.indexOf("!") >= 0) { - // Exclusive events trigger only for the exact event (no namespaces) - type = type.slice(0, -1); - exclusive = true; - } - - if (type.indexOf(".") >= 0) { - // Namespaced trigger; create a regexp to match event type in handle() - namespaces = type.split("."); - type = namespaces.shift(); - namespaces.sort(); - } - - if ((!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ]) { - // No jQuery handlers for this event type, and it can't have inline handlers - return; - } - - // Caller can pass in an Event, Object, or just an event type string - event = typeof event === "object" ? - // jQuery.Event object - event[ jQuery.expando ] ? event : - // Object literal - new jQuery.Event(type, event) : - // Just the event type (string) - new jQuery.Event(type); - - event.type = type; - event.isTrigger = true; - event.exclusive = exclusive; - event.namespace = namespaces.join("."); - event.namespace_re = event.namespace ? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") : null; - ontype = type.indexOf(":") < 0 ? "on" + type : ""; - - // triggerHandler() and global events don't bubble or run the default action - if (onlyHandlers || !elem) { - event.preventDefault(); - } - - // Handle a global trigger - if (!elem) { - - // TODO: Stop taunting the data cache; remove global events and always attach to document - cache = jQuery.cache; - for (i in cache) { - if (cache[ i ].events && cache[ i ].events[ type ]) { - jQuery.event.trigger(event, data, cache[ i ].handle.elem, true); - } - } - return; - } - - // Clean up the event in case it is being reused - event.result = undefined; - if (!event.target) { - event.target = elem; - } - - // Clone any incoming data and prepend the event, creating the handler arg list - data = data != null ? jQuery.makeArray(data) : []; - data.unshift(event); - - // Allow special events to draw outside the lines - special = jQuery.event.special[ type ] || {}; - if (special.trigger && special.trigger.apply(elem, data) === false) { - return; - } - - // Determine event propagation path in advance, per W3C events spec (#9951) - // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) - eventPath = [[elem, special.bindType || type]]; - if (!onlyHandlers && !special.noBubble && !jQuery.isWindow(elem)) { - - bubbleType = special.delegateType || type; - old = null; - for (cur = elem.parentNode; cur; cur = cur.parentNode) { - eventPath.push([cur, bubbleType]); - old = cur; - } - - // Only add window if we got to document (e.g., not plain obj or detached DOM) - if (old && old === elem.ownerDocument) { - eventPath.push([old.defaultView || old.parentWindow || window, bubbleType]); - } - } - - // Fire handlers on the event path - for (i = 0; i < eventPath.length; i++) { - - cur = eventPath[i][0]; - event.type = eventPath[i][1]; - - handle = (jQuery._data(cur, "events") || {})[ event.type ] && jQuery._data(cur, "handle"); - if (handle) { - handle.apply(cur, data); - } - handle = ontype && cur[ ontype ]; - if (handle && jQuery.acceptData(cur)) { - handle.apply(cur, data); - } - - if (event.isPropagationStopped()) { - break; - } - } - event.type = type; - - // If nobody prevented the default action, do it now - if (!event.isDefaultPrevented()) { - - if ((!special._default || special._default.apply(elem.ownerDocument, data) === false) && - !(type === "click" && jQuery.nodeName(elem, "a")) && jQuery.acceptData(elem)) { - - // Call a native DOM method on the target with the same name name as the event. - // Can't use an .isFunction() check here because IE6/7 fails that test. - // Don't do default actions on window, that's where global variables be (#6170) - // IE<9 dies on focus/blur to hidden element (#1486) - if (ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow(elem)) { - - // Don't re-trigger an onFOO event when we call its FOO() method - old = elem[ ontype ]; - - if (old) { - elem[ ontype ] = null; - } - - // Prevent re-triggering of the same event, since we already bubbled it above - jQuery.event.triggered = type; - elem[ type ](); - jQuery.event.triggered = undefined; - - if (old) { - elem[ ontype ] = old; - } - } - } - } - - return event.result; - }, - dispatch: function (event) { - - // Make a writable jQuery.Event from the native event object - event = jQuery.event.fix(event || window.event); - - var handlers = ((jQuery._data(this, "events") || {})[ event.type ] || []), - delegateCount = handlers.delegateCount, - args = [].slice.call(arguments, 0), - run_all = !event.exclusive && !event.namespace, - specialHandle = (jQuery.event.special[ event.type ] || {}).handle, - handlerQueue = [], - i, j, cur, ret, selMatch, matched, matches, handleObj, sel, hit, related; - - // Use the fix-ed jQuery.Event rather than the (read-only) native event - args[0] = event; - event.delegateTarget = this; - - // Determine handlers that should run if there are delegated events - // Avoid disabled elements in IE (#6911) and non-left-click bubbling in Firefox (#3861) - if (delegateCount && !event.target.disabled && !(event.button && event.type === "click")) { - - for (cur = event.target; cur != this; cur = cur.parentNode || this) { - selMatch = {}; - matches = []; - for (i = 0; i < delegateCount; i++) { - handleObj = handlers[ i ]; - sel = handleObj.selector; - hit = selMatch[ sel ]; - - if (handleObj.isPositional) { - // Since .is() does not work for positionals; see http://jsfiddle.net/eJ4yd/3/ - hit = (hit || (selMatch[ sel ] = jQuery(sel))).index(cur) >= 0; - } else if (hit === undefined) { - hit = selMatch[ sel ] = (handleObj.quick ? quickIs(cur, handleObj.quick) : jQuery(cur).is(sel)); - } - if (hit) { - matches.push(handleObj); - } - } - if (matches.length) { - handlerQueue.push({elem: cur, matches: matches}); - } - } - } - - // Add the remaining (directly-bound) handlers - if (handlers.length > delegateCount) { - handlerQueue.push({elem: this, matches: handlers.slice(delegateCount)}); - } - - // Run delegates first; they may want to stop propagation beneath us - for (i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++) { - matched = handlerQueue[ i ]; - event.currentTarget = matched.elem; - - for (j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++) { - handleObj = matched.matches[ j ]; - - // Triggered event must either 1) be non-exclusive and have no namespace, or - // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). - if (run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test(handleObj.namespace)) { - - event.data = handleObj.data; - event.handleObj = handleObj; - - ret = (specialHandle || handleObj.handler).apply(matched.elem, args); - - if (ret !== undefined) { - event.result = ret; - if (ret === false) { - event.preventDefault(); - event.stopPropagation(); - } - } - } - } - } - - return event.result; - }, - // Includes some event props shared by KeyEvent and MouseEvent - // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 *** - props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), - fixHooks: {}, - keyHooks: { - props: "char charCode key keyCode".split(" "), - filter: function (event, original) { - - // Add which for key events - if (event.which == null) { - event.which = original.charCode != null ? original.charCode : original.keyCode; - } - - return event; - } - }, - mouseHooks: { - props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement wheelDelta".split(" "), - filter: function (event, original) { - var eventDoc, doc, body, - button = original.button, - fromElement = original.fromElement; - - // Calculate pageX/Y if missing and clientX/Y available - if (event.pageX == null && original.clientX != null) { - eventDoc = event.target.ownerDocument || document; - doc = eventDoc.documentElement; - body = eventDoc.body; - - event.pageX = original.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0); - event.pageY = original.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); - } - - // Add relatedTarget, if necessary - if (!event.relatedTarget && fromElement) { - event.relatedTarget = fromElement === event.target ? original.toElement : fromElement; - } - - // Add which for click: 1 === left; 2 === middle; 3 === right - // Note: button is not normalized, so don't use it - if (!event.which && button !== undefined) { - event.which = (button & 1 ? 1 : (button & 2 ? 3 : (button & 4 ? 2 : 0))); - } - - return event; - } - }, - fix: function (event) { - if (event[ jQuery.expando ]) { - return event; - } - - // Create a writable copy of the event object and normalize some properties - var i, prop, - originalEvent = event, - fixHook = jQuery.event.fixHooks[ event.type ] || {}, - copy = fixHook.props ? this.props.concat(fixHook.props) : this.props; - - event = jQuery.Event(originalEvent); - - for (i = copy.length; i; ) { - prop = copy[ --i ]; - event[ prop ] = originalEvent[ prop ]; - } - - // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2) - if (!event.target) { - event.target = originalEvent.srcElement || document; - } - - // Target should not be a text node (#504, Safari) - if (event.target.nodeType === 3) { - event.target = event.target.parentNode; - } - - // For mouse/key events; add metaKey if it's not there (#3368, IE6/7/8) - if (event.metaKey === undefined) { - event.metaKey = event.ctrlKey; - } - - return fixHook.filter ? fixHook.filter(event, originalEvent) : event; - }, - special: { - ready: { - // Make sure the ready event is setup - setup: jQuery.bindReady - }, - focus: { - delegateType: "focusin", - noBubble: true - }, - blur: { - delegateType: "focusout", - noBubble: true - }, - beforeunload: { - setup: function (data, namespaces, eventHandle) { - // We only want to do this special case on windows - if (jQuery.isWindow(this)) { - this.onbeforeunload = eventHandle; - } - }, - teardown: function (namespaces, eventHandle) { - if (this.onbeforeunload === eventHandle) { - this.onbeforeunload = null; - } - } - } - }, - simulate: function (type, elem, event, bubble) { - // Piggyback on a donor event to simulate a different one. - // Fake originalEvent to avoid donor's stopPropagation, but if the - // simulated event prevents default then we do the same on the donor. - var e = jQuery.extend( - new jQuery.Event(), - event, - {type: type, - isSimulated: true, - originalEvent: {} - } - ); - if (bubble) { - jQuery.event.trigger(e, null, elem); - } else { - jQuery.event.dispatch.call(elem, e); - } - if (e.isDefaultPrevented()) { - event.preventDefault(); - } - } - }; - -// Some plugins are using, but it's undocumented/deprecated and will be removed. -// The 1.7 special event interface should provide all the hooks needed now. - jQuery.event.handle = jQuery.event.dispatch; - - jQuery.removeEvent = document.removeEventListener ? - function (elem, type, handle) { - if (elem.removeEventListener) { - elem.removeEventListener(type, handle, false); - } - } : - function (elem, type, handle) { - if (elem.detachEvent) { - elem.detachEvent("on" + type, handle); - } - }; - - jQuery.Event = function (src, props) { - // Allow instantiation without the 'new' keyword - if (!(this instanceof jQuery.Event)) { - return new jQuery.Event(src, props); - } - - // Event object - if (src && src.type) { - this.originalEvent = src; - this.type = src.type; - - // Events bubbling up the document may have been marked as prevented - // by a handler lower down the tree; reflect the correct value. - this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false || - src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse; - - // Event type - } else { - this.type = src; - } - - // Put explicitly provided properties onto the event object - if (props) { - jQuery.extend(this, props); - } - - // Create a timestamp if incoming event doesn't have one - this.timeStamp = src && src.timeStamp || jQuery.now(); - - // Mark it as fixed - this[ jQuery.expando ] = true; - }; - - function returnFalse() { - return false; - } - function returnTrue() { - return true; - } - -// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding -// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html - jQuery.Event.prototype = { - preventDefault: function () { - this.isDefaultPrevented = returnTrue; - - var e = this.originalEvent; - if (!e) { - return; - } - - // if preventDefault exists run it on the original event - if (e.preventDefault) { - e.preventDefault(); - - // otherwise set the returnValue property of the original event to false (IE) - } else { - e.returnValue = false; - } - }, - stopPropagation: function () { - this.isPropagationStopped = returnTrue; - - var e = this.originalEvent; - if (!e) { - return; - } - // if stopPropagation exists run it on the original event - if (e.stopPropagation) { - e.stopPropagation(); - } - // otherwise set the cancelBubble property of the original event to true (IE) - e.cancelBubble = true; - }, - stopImmediatePropagation: function () { - this.isImmediatePropagationStopped = returnTrue; - this.stopPropagation(); - }, - isDefaultPrevented: returnFalse, - isPropagationStopped: returnFalse, - isImmediatePropagationStopped: returnFalse - }; - -// Create mouseenter/leave events using mouseover/out and event-time checks - jQuery.each({ - mouseenter: "mouseover", - mouseleave: "mouseout" - }, function (orig, fix) { - jQuery.event.special[ orig ] = jQuery.event.special[ fix ] = { - delegateType: fix, - bindType: fix, - handle: function (event) { - var target = this, - related = event.relatedTarget, - handleObj = event.handleObj, - selector = handleObj.selector, - oldType, ret; - - // For a real mouseover/out, always call the handler; for - // mousenter/leave call the handler if related is outside the target. - // NB: No relatedTarget if the mouse left/entered the browser window - if (!related || handleObj.origType === event.type || (related !== target && !jQuery.contains(target, related))) { - oldType = event.type; - event.type = handleObj.origType; - ret = handleObj.handler.apply(this, arguments); - event.type = oldType; - } - return ret; - } - }; - }); - -// IE submit delegation - if (!jQuery.support.submitBubbles) { - - jQuery.event.special.submit = { - setup: function () { - // Only need this for delegated form submit events - if (jQuery.nodeName(this, "form")) { - return false; - } - - // Lazy-add a submit handler when a descendant form may potentially be submitted - jQuery.event.add(this, "click._submit keypress._submit", function (e) { - // Node name check avoids a VML-related crash in IE (#9807) - var elem = e.target, - form = jQuery.nodeName(elem, "input") || jQuery.nodeName(elem, "button") ? elem.form : undefined; - if (form && !form._submit_attached) { - jQuery.event.add(form, "submit._submit", function (event) { - // Form was submitted, bubble the event up the tree - if (this.parentNode) { - jQuery.event.simulate("submit", this.parentNode, event, true); - } - }); - form._submit_attached = true; - } - }); - // return undefined since we don't need an event listener - }, - teardown: function () { - // Only need this for delegated form submit events - if (jQuery.nodeName(this, "form")) { - return false; - } - - // Remove delegated handlers; cleanData eventually reaps submit handlers attached above - jQuery.event.remove(this, "._submit"); - } - }; - } - -// IE change delegation and checkbox/radio fix - if (!jQuery.support.changeBubbles) { - - jQuery.event.special.change = { - setup: function () { - - if (rformElems.test(this.nodeName)) { - // IE doesn't fire change on a check/radio until blur; trigger it on click - // after a propertychange. Eat the blur-change in special.change.handle. - // This still fires onchange a second time for check/radio after blur. - if (this.type === "checkbox" || this.type === "radio") { - jQuery.event.add(this, "propertychange._change", function (event) { - if (event.originalEvent.propertyName === "checked") { - this._just_changed = true; - } - }); - jQuery.event.add(this, "click._change", function (event) { - if (this._just_changed) { - this._just_changed = false; - jQuery.event.simulate("change", this, event, true); - } - }); - } - return false; - } - // Delegated event; lazy-add a change handler on descendant inputs - jQuery.event.add(this, "beforeactivate._change", function (e) { - var elem = e.target; - - if (rformElems.test(elem.nodeName) && !elem._change_attached) { - jQuery.event.add(elem, "change._change", function (event) { - if (this.parentNode && !event.isSimulated) { - jQuery.event.simulate("change", this.parentNode, event, true); - } - }); - elem._change_attached = true; - } - }); - }, - handle: function (event) { - var elem = event.target; - - // Swallow native change events from checkbox/radio, we already triggered them above - if (this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox")) { - return event.handleObj.handler.apply(this, arguments); - } - }, - teardown: function () { - jQuery.event.remove(this, "._change"); - - return rformElems.test(this.nodeName); - } - }; - } - -// Create "bubbling" focus and blur events - if (!jQuery.support.focusinBubbles) { - jQuery.each({focus: "focusin", blur: "focusout"}, function (orig, fix) { - - // Attach a single capturing handler while someone wants focusin/focusout - var attaches = 0, - handler = function (event) { - jQuery.event.simulate(fix, event.target, jQuery.event.fix(event), true); - }; - - jQuery.event.special[ fix ] = { - setup: function () { - if (attaches++ === 0) { - document.addEventListener(orig, handler, true); - } - }, - teardown: function () { - if (--attaches === 0) { - document.removeEventListener(orig, handler, true); - } - } - }; - }); - } - - jQuery.fn.extend({ - on: function (types, selector, data, fn, /*INTERNAL*/ one) { - var origFn, type; - - // Types can be a map of types/handlers - if (typeof types === "object") { - // ( types-Object, selector, data ) - if (typeof selector !== "string") { - // ( types-Object, data ) - data = selector; - selector = undefined; - } - for (type in types) { - this.on(type, selector, data, types[ type ], one); - } - return this; - } - - if (data == null && fn == null) { - // ( types, fn ) - fn = selector; - data = selector = undefined; - } else if (fn == null) { - if (typeof selector === "string") { - // ( types, selector, fn ) - fn = data; - data = undefined; - } else { - // ( types, data, fn ) - fn = data; - data = selector; - selector = undefined; - } - } - if (fn === false) { - fn = returnFalse; - } else if (!fn) { - return this; - } - - if (one === 1) { - origFn = fn; - fn = function (event) { - // Can use an empty set, since event contains the info - jQuery().off(event); - return origFn.apply(this, arguments); - }; - // Use same guid so caller can remove using origFn - fn.guid = origFn.guid || (origFn.guid = jQuery.guid++); - } - return this.each(function () { - jQuery.event.add(this, types, fn, data, selector); - }); - }, - one: function (types, selector, data, fn) { - return this.on.call(this, types, selector, data, fn, 1); - }, - off: function (types, selector, fn) { - if (types && types.preventDefault && types.handleObj) { - // ( event ) dispatched jQuery.Event - var handleObj = types.handleObj; - jQuery(types.delegateTarget).off( - handleObj.namespace ? handleObj.type + "." + handleObj.namespace : handleObj.type, - handleObj.selector, - handleObj.handler - ); - return this; - } - if (typeof types === "object") { - // ( types-object [, selector] ) - for (var type in types) { - this.off(type, selector, types[ type ]); - } - return this; - } - if (selector === false || typeof selector === "function") { - // ( types [, fn] ) - fn = selector; - selector = undefined; - } - if (fn === false) { - fn = returnFalse; - } - return this.each(function () { - jQuery.event.remove(this, types, fn, selector); - }); - }, - bind: function (types, data, fn) { - return this.on(types, null, data, fn); - }, - unbind: function (types, fn) { - return this.off(types, null, fn); - }, - live: function (types, data, fn) { - jQuery(this.context).on(types, this.selector, data, fn); - return this; - }, - die: function (types, fn) { - jQuery(this.context).off(types, this.selector || "**", fn); - return this; - }, - delegate: function (selector, types, data, fn) { - return this.on(types, selector, data, fn); - }, - undelegate: function (selector, types, fn) { - // ( namespace ) or ( selector, types [, fn] ) - return arguments.length == 1 ? this.off(selector, "**") : this.off(types, selector, fn); - }, - trigger: function (type, data) { - return this.each(function () { - jQuery.event.trigger(type, data, this); - }); - }, - triggerHandler: function (type, data) { - if (this[0]) { - return jQuery.event.trigger(type, data, this[0], true); - } - }, - toggle: function (fn) { - // Save reference to arguments for access in closure - var args = arguments, - guid = fn.guid || jQuery.guid++, - i = 0, - toggler = function (event) { - // Figure out which function to execute - var lastToggle = (jQuery._data(this, "lastToggle" + fn.guid) || 0) % i; - jQuery._data(this, "lastToggle" + fn.guid, lastToggle + 1); - - // Make sure that clicks stop - event.preventDefault(); - - // and execute the function - return args[ lastToggle ].apply(this, arguments) || false; - }; - - // link all the functions, so any of them can unbind this click handler - toggler.guid = guid; - while (i < args.length) { - args[ i++ ].guid = guid; - } - - return this.click(toggler); - }, - hover: function (fnOver, fnOut) { - return this.mouseenter(fnOver).mouseleave(fnOut || fnOver); - } - }); - - jQuery.each(("blur focus focusin focusout load resize scroll unload click dblclick " + - "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + - "change select submit keydown keypress keyup error contextmenu").split(" "), function (i, name) { - - // Handle event binding - jQuery.fn[ name ] = function (data, fn) { - if (fn == null) { - fn = data; - data = null; - } - - return arguments.length > 0 ? - this.bind(name, data, fn) : - this.trigger(name); - }; - - if (jQuery.attrFn) { - jQuery.attrFn[ name ] = true; - } - - if (rkeyEvent.test(name)) { - jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks; - } - - if (rmouseEvent.test(name)) { - jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks; - } - }); - - - - /*! - * Sizzle CSS Selector Engine - * Copyright 2011, The Dojo Foundation - * Released under the MIT, BSD, and GPL Licenses. - * More information: http://sizzlejs.com/ - */ - (function () { - - var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, - expando = "sizcache" + (Math.random() + '').replace('.', ''), - done = 0, - toString = Object.prototype.toString, - hasDuplicate = false, - baseHasDuplicate = true, - rBackslash = /\\/g, - rReturn = /\r\n/g, - rNonWord = /\W/; - -// Here we check if the JavaScript engine is using some sort of -// optimization where it does not always call our comparision -// function. If that is the case, discard the hasDuplicate value. -// Thus far that includes Google Chrome. - [0, 0].sort(function () { - baseHasDuplicate = false; - return 0; - }); - - var Sizzle = function (selector, context, results, seed) { - results = results || []; - context = context || document; - - var origContext = context; - - if (context.nodeType !== 1 && context.nodeType !== 9) { - return []; - } - - if (!selector || typeof selector !== "string") { - return results; - } - - var m, set, checkSet, extra, ret, cur, pop, i, - prune = true, - contextXML = Sizzle.isXML(context), - parts = [], - soFar = selector; - - // Reset the position of the chunker regexp (start from head) - do { - chunker.exec(""); - m = chunker.exec(soFar); - - if (m) { - soFar = m[3]; - - parts.push(m[1]); - - if (m[2]) { - extra = m[3]; - break; - } - } - } while (m); - - if (parts.length > 1 && origPOS.exec(selector)) { - - if (parts.length === 2 && Expr.relative[ parts[0] ]) { - set = posProcess(parts[0] + parts[1], context, seed); - - } else { - set = Expr.relative[ parts[0] ] ? - [context] : - Sizzle(parts.shift(), context); - - while (parts.length) { - selector = parts.shift(); - - if (Expr.relative[ selector ]) { - selector += parts.shift(); - } - - set = posProcess(selector, set, seed); - } - } - - } else { - // Take a shortcut and set the context if the root selector is an ID - // (but not if it'll be faster if the inner selector is an ID) - if (!seed && parts.length > 1 && context.nodeType === 9 && !contextXML && - Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1])) { - - ret = Sizzle.find(parts.shift(), context, contextXML); - context = ret.expr ? - Sizzle.filter(ret.expr, ret.set)[0] : - ret.set[0]; - } - - if (context) { - ret = seed ? - {expr: parts.pop(), set: makeArray(seed)} : - Sizzle.find(parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML); - - set = ret.expr ? - Sizzle.filter(ret.expr, ret.set) : - ret.set; - - if (parts.length > 0) { - checkSet = makeArray(set); - - } else { - prune = false; - } - - while (parts.length) { - cur = parts.pop(); - pop = cur; - - if (!Expr.relative[ cur ]) { - cur = ""; - } else { - pop = parts.pop(); - } - - if (pop == null) { - pop = context; - } - - Expr.relative[ cur ](checkSet, pop, contextXML); - } - - } else { - checkSet = parts = []; - } - } - - if (!checkSet) { - checkSet = set; - } - - if (!checkSet) { - Sizzle.error(cur || selector); - } - - if (toString.call(checkSet) === "[object Array]") { - if (!prune) { - results.push.apply(results, checkSet); - - } else if (context && context.nodeType === 1) { - for (i = 0; checkSet[i] != null; i++) { - if (checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i]))) { - results.push(set[i]); - } - } - - } else { - for (i = 0; checkSet[i] != null; i++) { - if (checkSet[i] && checkSet[i].nodeType === 1) { - results.push(set[i]); - } - } - } - - } else { - makeArray(checkSet, results); - } - - if (extra) { - Sizzle(extra, origContext, results, seed); - Sizzle.uniqueSort(results); - } - - return results; - }; - - Sizzle.uniqueSort = function (results) { - if (sortOrder) { - hasDuplicate = baseHasDuplicate; - results.sort(sortOrder); - - if (hasDuplicate) { - for (var i = 1; i < results.length; i++) { - if (results[i] === results[ i - 1 ]) { - results.splice(i--, 1); - } - } - } - } - - return results; - }; - - Sizzle.matches = function (expr, set) { - return Sizzle(expr, null, null, set); - }; - - Sizzle.matchesSelector = function (node, expr) { - return Sizzle(expr, null, null, [node]).length > 0; - }; - - Sizzle.find = function (expr, context, isXML) { - var set, i, len, match, type, left; - - if (!expr) { - return []; - } - - for (i = 0, len = Expr.order.length; i < len; i++) { - type = Expr.order[i]; - - if ((match = Expr.leftMatch[ type ].exec(expr))) { - left = match[1]; - match.splice(1, 1); - - if (left.substr(left.length - 1) !== "\\") { - match[1] = (match[1] || "").replace(rBackslash, ""); - set = Expr.find[ type ](match, context, isXML); - - if (set != null) { - expr = expr.replace(Expr.match[ type ], ""); - break; - } - } - } - } - - if (!set) { - set = typeof context.getElementsByTagName !== "undefined" ? - context.getElementsByTagName("*") : - []; - } - - return {set: set, expr: expr}; - }; - - Sizzle.filter = function (expr, set, inplace, not) { - var match, anyFound, - type, found, item, filter, left, - i, pass, - old = expr, - result = [], - curLoop = set, - isXMLFilter = set && set[0] && Sizzle.isXML(set[0]); - - while (expr && set.length) { - for (type in Expr.filter) { - if ((match = Expr.leftMatch[ type ].exec(expr)) != null && match[2]) { - filter = Expr.filter[ type ]; - left = match[1]; - - anyFound = false; - - match.splice(1, 1); - - if (left.substr(left.length - 1) === "\\") { - continue; - } - - if (curLoop === result) { - result = []; - } - - if (Expr.preFilter[ type ]) { - match = Expr.preFilter[ type ](match, curLoop, inplace, result, not, isXMLFilter); - - if (!match) { - anyFound = found = true; - - } else if (match === true) { - continue; - } - } - - if (match) { - for (i = 0; (item = curLoop[i]) != null; i++) { - if (item) { - found = filter(item, match, i, curLoop); - pass = not ^ found; - - if (inplace && found != null) { - if (pass) { - anyFound = true; - - } else { - curLoop[i] = false; - } - - } else if (pass) { - result.push(item); - anyFound = true; - } - } - } - } - - if (found !== undefined) { - if (!inplace) { - curLoop = result; - } - - expr = expr.replace(Expr.match[ type ], ""); - - if (!anyFound) { - return []; - } - - break; - } - } - } - - // Improper expression - if (expr === old) { - if (anyFound == null) { - Sizzle.error(expr); - - } else { - break; - } - } - - old = expr; - } - - return curLoop; - }; - - Sizzle.error = function (msg) { - throw "Syntax error, unrecognized expression: " + msg; - }; - - /** - * Utility function for retreiving the text value of an array of DOM nodes - * @param {Array|Element} elem - */ - var getText = Sizzle.getText = function (elem) { - var i, node, - nodeType = elem.nodeType, - ret = ""; - - if (nodeType) { - if (nodeType === 1) { - // Use textContent || innerText for elements - if (typeof elem.textContent === 'string') { - return elem.textContent; - } else if (typeof elem.innerText === 'string') { - // Replace IE's carriage returns - return elem.innerText.replace(rReturn, ''); - } else { - // Traverse it's children - for (elem = elem.firstChild; elem; elem = elem.nextSibling) { - ret += getText(elem); - } - } - } else if (nodeType === 3 || nodeType === 4) { - return elem.nodeValue; - } - } else { - - // If no nodeType, this is expected to be an array - for (i = 0; (node = elem[i]); i++) { - // Do not traverse comment nodes - if (node.nodeType !== 8) { - ret += getText(node); - } - } - } - return ret; - }; - - var Expr = Sizzle.selectors = { - order: ["ID", "NAME", "TAG"], - match: { - ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, - CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, - NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, - ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/, - TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, - CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/, - POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/, - PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ - }, - leftMatch: {}, - attrMap: { - "class": "className", - "for": "htmlFor" - }, - attrHandle: { - href: function (elem) { - return elem.getAttribute("href"); - }, - type: function (elem) { - return elem.getAttribute("type"); - } - }, - relative: { - "+": function (checkSet, part) { - var isPartStr = typeof part === "string", - isTag = isPartStr && !rNonWord.test(part), - isPartStrNotTag = isPartStr && !isTag; - - if (isTag) { - part = part.toLowerCase(); - } - - for (var i = 0, l = checkSet.length, elem; i < l; i++) { - if ((elem = checkSet[i])) { - while ((elem = elem.previousSibling) && elem.nodeType !== 1) { - } - - checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ? - elem || false : - elem === part; - } - } - - if (isPartStrNotTag) { - Sizzle.filter(part, checkSet, true); - } - }, - ">": function (checkSet, part) { - var elem, - isPartStr = typeof part === "string", - i = 0, - l = checkSet.length; - - if (isPartStr && !rNonWord.test(part)) { - part = part.toLowerCase(); - - for (; i < l; i++) { - elem = checkSet[i]; - - if (elem) { - var parent = elem.parentNode; - checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false; - } - } - - } else { - for (; i < l; i++) { - elem = checkSet[i]; - - if (elem) { - checkSet[i] = isPartStr ? - elem.parentNode : - elem.parentNode === part; - } - } - - if (isPartStr) { - Sizzle.filter(part, checkSet, true); - } - } - }, - "": function (checkSet, part, isXML) { - var nodeCheck, - doneName = done++, - checkFn = dirCheck; - - if (typeof part === "string" && !rNonWord.test(part)) { - part = part.toLowerCase(); - nodeCheck = part; - checkFn = dirNodeCheck; - } - - checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML); - }, - "~": function (checkSet, part, isXML) { - var nodeCheck, - doneName = done++, - checkFn = dirCheck; - - if (typeof part === "string" && !rNonWord.test(part)) { - part = part.toLowerCase(); - nodeCheck = part; - checkFn = dirNodeCheck; - } - - checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML); - } - }, - find: { - ID: function (match, context, isXML) { - if (typeof context.getElementById !== "undefined" && !isXML) { - var m = context.getElementById(match[1]); - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - return m && m.parentNode ? [m] : []; - } - }, - NAME: function (match, context) { - if (typeof context.getElementsByName !== "undefined") { - var ret = [], - results = context.getElementsByName(match[1]); - - for (var i = 0, l = results.length; i < l; i++) { - if (results[i].getAttribute("name") === match[1]) { - ret.push(results[i]); - } - } - - return ret.length === 0 ? null : ret; - } - }, - TAG: function (match, context) { - if (typeof context.getElementsByTagName !== "undefined") { - return context.getElementsByTagName(match[1]); - } - } - }, - preFilter: { - CLASS: function (match, curLoop, inplace, result, not, isXML) { - match = " " + match[1].replace(rBackslash, "") + " "; - - if (isXML) { - return match; - } - - for (var i = 0, elem; (elem = curLoop[i]) != null; i++) { - if (elem) { - if (not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0)) { - if (!inplace) { - result.push(elem); - } - - } else if (inplace) { - curLoop[i] = false; - } - } - } - - return false; - }, - ID: function (match) { - return match[1].replace(rBackslash, ""); - }, - TAG: function (match, curLoop) { - return match[1].replace(rBackslash, "").toLowerCase(); - }, - CHILD: function (match) { - if (match[1] === "nth") { - if (!match[2]) { - Sizzle.error(match[0]); - } - - match[2] = match[2].replace(/^\+|\s*/g, ''); - - // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' - var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec( - match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || - !/\D/.test(match[2]) && "0n+" + match[2] || match[2]); - - // calculate the numbers (first)n+(last) including if they are negative - match[2] = (test[1] + (test[2] || 1)) - 0; - match[3] = test[3] - 0; - } - else if (match[2]) { - Sizzle.error(match[0]); - } - - // TODO: Move to normal caching system - match[0] = done++; - - return match; - }, - ATTR: function (match, curLoop, inplace, result, not, isXML) { - var name = match[1] = match[1].replace(rBackslash, ""); - - if (!isXML && Expr.attrMap[name]) { - match[1] = Expr.attrMap[name]; - } - - // Handle if an un-quoted value was used - match[4] = (match[4] || match[5] || "").replace(rBackslash, ""); - - if (match[2] === "~=") { - match[4] = " " + match[4] + " "; - } - - return match; - }, - PSEUDO: function (match, curLoop, inplace, result, not) { - if (match[1] === "not") { - // If we're dealing with a complex expression, or a simple one - if ((chunker.exec(match[3]) || "").length > 1 || /^\w/.test(match[3])) { - match[3] = Sizzle(match[3], null, null, curLoop); - - } else { - var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); - - if (!inplace) { - result.push.apply(result, ret); - } - - return false; - } - - } else if (Expr.match.POS.test(match[0]) || Expr.match.CHILD.test(match[0])) { - return true; - } - - return match; - }, - POS: function (match) { - match.unshift(true); - - return match; - } - }, - filters: { - enabled: function (elem) { - return elem.disabled === false && elem.type !== "hidden"; - }, - disabled: function (elem) { - return elem.disabled === true; - }, - checked: function (elem) { - return elem.checked === true; - }, - selected: function (elem) { - // Accessing this property makes selected-by-default - // options in Safari work properly - if (elem.parentNode) { - elem.parentNode.selectedIndex; - } - - return elem.selected === true; - }, - parent: function (elem) { - return !!elem.firstChild; - }, - empty: function (elem) { - return !elem.firstChild; - }, - has: function (elem, i, match) { - return !!Sizzle(match[3], elem).length; - }, - header: function (elem) { - return (/h\d/i).test(elem.nodeName); - }, - text: function (elem) { - var attr = elem.getAttribute("type"), type = elem.type; - // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) - // use getAttribute instead to test this case - return elem.nodeName.toLowerCase() === "input" && "text" === type && (attr === type || attr === null); - }, - radio: function (elem) { - return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type; - }, - checkbox: function (elem) { - return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type; - }, - file: function (elem) { - return elem.nodeName.toLowerCase() === "input" && "file" === elem.type; - }, - password: function (elem) { - return elem.nodeName.toLowerCase() === "input" && "password" === elem.type; - }, - submit: function (elem) { - var name = elem.nodeName.toLowerCase(); - return (name === "input" || name === "button") && "submit" === elem.type; - }, - image: function (elem) { - return elem.nodeName.toLowerCase() === "input" && "image" === elem.type; - }, - reset: function (elem) { - var name = elem.nodeName.toLowerCase(); - return (name === "input" || name === "button") && "reset" === elem.type; - }, - button: function (elem) { - var name = elem.nodeName.toLowerCase(); - return name === "input" && "button" === elem.type || name === "button"; - }, - input: function (elem) { - return (/input|select|textarea|button/i).test(elem.nodeName); - }, - focus: function (elem) { - return elem === elem.ownerDocument.activeElement; - } - }, - setFilters: { - first: function (elem, i) { - return i === 0; - }, - last: function (elem, i, match, array) { - return i === array.length - 1; - }, - even: function (elem, i) { - return i % 2 === 0; - }, - odd: function (elem, i) { - return i % 2 === 1; - }, - lt: function (elem, i, match) { - return i < match[3] - 0; - }, - gt: function (elem, i, match) { - return i > match[3] - 0; - }, - nth: function (elem, i, match) { - return match[3] - 0 === i; - }, - eq: function (elem, i, match) { - return match[3] - 0 === i; - } - }, - filter: { - PSEUDO: function (elem, match, i, array) { - var name = match[1], - filter = Expr.filters[ name ]; - - if (filter) { - return filter(elem, i, match, array); - - } else if (name === "contains") { - return (elem.textContent || elem.innerText || getText([elem]) || "").indexOf(match[3]) >= 0; - - } else if (name === "not") { - var not = match[3]; - - for (var j = 0, l = not.length; j < l; j++) { - if (not[j] === elem) { - return false; - } - } - - return true; - - } else { - Sizzle.error(name); - } - }, - CHILD: function (elem, match) { - var first, last, - doneName, parent, cache, - count, diff, - type = match[1], - node = elem; - - switch (type) { - case "only": - case "first": - while ((node = node.previousSibling)) { - if (node.nodeType === 1) { - return false; - } - } - - if (type === "first") { - return true; - } - - node = elem; - - case "last": - while ((node = node.nextSibling)) { - if (node.nodeType === 1) { - return false; - } - } - - return true; - - case "nth": - first = match[2]; - last = match[3]; - - if (first === 1 && last === 0) { - return true; - } - - doneName = match[0]; - parent = elem.parentNode; - - if (parent && (parent[ expando ] !== doneName || !elem.nodeIndex)) { - count = 0; - - for (node = parent.firstChild; node; node = node.nextSibling) { - if (node.nodeType === 1) { - node.nodeIndex = ++count; - } - } - - parent[ expando ] = doneName; - } - - diff = elem.nodeIndex - last; - - if (first === 0) { - return diff === 0; - - } else { - return (diff % first === 0 && diff / first >= 0); - } - } - }, - ID: function (elem, match) { - return elem.nodeType === 1 && elem.getAttribute("id") === match; - }, - TAG: function (elem, match) { - return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match; - }, - CLASS: function (elem, match) { - return (" " + (elem.className || elem.getAttribute("class")) + " ") - .indexOf(match) > -1; - }, - ATTR: function (elem, match) { - var name = match[1], - result = Sizzle.attr ? - Sizzle.attr(elem, name) : - Expr.attrHandle[ name ] ? - Expr.attrHandle[ name ](elem) : - elem[ name ] != null ? - elem[ name ] : - elem.getAttribute(name), - value = result + "", - type = match[2], - check = match[4]; - - return result == null ? - type === "!=" : - !type && Sizzle.attr ? - result != null : - type === "=" ? - value === check : - type === "*=" ? - value.indexOf(check) >= 0 : - type === "~=" ? - (" " + value + " ").indexOf(check) >= 0 : - !check ? - value && result !== false : - type === "!=" ? - value !== check : - type === "^=" ? - value.indexOf(check) === 0 : - type === "$=" ? - value.substr(value.length - check.length) === check : - type === "|=" ? - value === check || value.substr(0, check.length + 1) === check + "-" : - false; - }, - POS: function (elem, match, i, array) { - var name = match[2], - filter = Expr.setFilters[ name ]; - - if (filter) { - return filter(elem, i, match, array); - } - } - } - }; - - var origPOS = Expr.match.POS, - fescape = function (all, num) { - return "\\" + (num - 0 + 1); - }; - - for (var type in Expr.match) { - Expr.match[ type ] = new RegExp(Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source)); - Expr.leftMatch[ type ] = new RegExp(/(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape)); - } - - var makeArray = function (array, results) { - array = Array.prototype.slice.call(array, 0); - - if (results) { - results.push.apply(results, array); - return results; - } - - return array; - }; - -// Perform a simple check to determine if the browser is capable of -// converting a NodeList to an array using builtin methods. -// Also verifies that the returned array holds DOM nodes -// (which is not the case in the Blackberry browser) - try { - Array.prototype.slice.call(document.documentElement.childNodes, 0)[0].nodeType; - -// Provide a fallback method if it does not work - } catch (e) { - makeArray = function (array, results) { - var i = 0, - ret = results || []; - - if (toString.call(array) === "[object Array]") { - Array.prototype.push.apply(ret, array); - - } else { - if (typeof array.length === "number") { - for (var l = array.length; i < l; i++) { - ret.push(array[i]); - } - - } else { - for (; array[i]; i++) { - ret.push(array[i]); - } - } - } - - return ret; - }; - } - - var sortOrder, siblingCheck; - - if (document.documentElement.compareDocumentPosition) { - sortOrder = function (a, b) { - if (a === b) { - hasDuplicate = true; - return 0; - } - - if (!a.compareDocumentPosition || !b.compareDocumentPosition) { - return a.compareDocumentPosition ? -1 : 1; - } - - return a.compareDocumentPosition(b) & 4 ? -1 : 1; - }; - - } else { - sortOrder = function (a, b) { - // The nodes are identical, we can exit early - if (a === b) { - hasDuplicate = true; - return 0; - - // Fallback to using sourceIndex (in IE) if it's available on both nodes - } else if (a.sourceIndex && b.sourceIndex) { - return a.sourceIndex - b.sourceIndex; - } - - var al, bl, - ap = [], - bp = [], - aup = a.parentNode, - bup = b.parentNode, - cur = aup; - - // If the nodes are siblings (or identical) we can do a quick check - if (aup === bup) { - return siblingCheck(a, b); - - // If no parents were found then the nodes are disconnected - } else if (!aup) { - return -1; - - } else if (!bup) { - return 1; - } - - // Otherwise they're somewhere else in the tree so we need - // to build up a full list of the parentNodes for comparison - while (cur) { - ap.unshift(cur); - cur = cur.parentNode; - } - - cur = bup; - - while (cur) { - bp.unshift(cur); - cur = cur.parentNode; - } - - al = ap.length; - bl = bp.length; - - // Start walking down the tree looking for a discrepancy - for (var i = 0; i < al && i < bl; i++) { - if (ap[i] !== bp[i]) { - return siblingCheck(ap[i], bp[i]); - } - } - - // We ended someplace up the tree so do a sibling check - return i === al ? - siblingCheck(a, bp[i], -1) : - siblingCheck(ap[i], b, 1); - }; - - siblingCheck = function (a, b, ret) { - if (a === b) { - return ret; - } - - var cur = a.nextSibling; - - while (cur) { - if (cur === b) { - return -1; - } - - cur = cur.nextSibling; - } - - return 1; - }; - } - -// Check to see if the browser returns elements by name when -// querying by getElementById (and provide a workaround) - (function () { - // We're going to inject a fake input element with a specified name - var form = document.createElement("div"), - id = "script" + (new Date()).getTime(), - root = document.documentElement; - - form.innerHTML = ""; - - // Inject it into the root element, check its status, and remove it quickly - root.insertBefore(form, root.firstChild); - - // The workaround has to do additional checks after a getElementById - // Which slows things down for other browsers (hence the branching) - if (document.getElementById(id)) { - Expr.find.ID = function (match, context, isXML) { - if (typeof context.getElementById !== "undefined" && !isXML) { - var m = context.getElementById(match[1]); - - return m ? - m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? - [m] : - undefined : - []; - } - }; - - Expr.filter.ID = function (elem, match) { - var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); - - return elem.nodeType === 1 && node && node.nodeValue === match; - }; - } - - root.removeChild(form); - - // release memory in IE - root = form = null; - })(); - - (function () { - // Check to see if the browser returns only elements - // when doing getElementsByTagName("*") - - // Create a fake element - var div = document.createElement("div"); - div.appendChild(document.createComment("")); - - // Make sure no comments are found - if (div.getElementsByTagName("*").length > 0) { - Expr.find.TAG = function (match, context) { - var results = context.getElementsByTagName(match[1]); - - // Filter out possible comments - if (match[1] === "*") { - var tmp = []; - - for (var i = 0; results[i]; i++) { - if (results[i].nodeType === 1) { - tmp.push(results[i]); - } - } - - results = tmp; - } - - return results; - }; - } - - // Check to see if an attribute returns normalized href attributes - div.innerHTML = ""; - - if (div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && - div.firstChild.getAttribute("href") !== "#") { - - Expr.attrHandle.href = function (elem) { - return elem.getAttribute("href", 2); - }; - } - - // release memory in IE - div = null; - })(); - - if (document.querySelectorAll) { - (function () { - var oldSizzle = Sizzle, - div = document.createElement("div"), - id = "__sizzle__"; - - div.innerHTML = "

"; - - // Safari can't handle uppercase or unicode characters when - // in quirks mode. - if (div.querySelectorAll && div.querySelectorAll(".TEST").length === 0) { - return; - } - - Sizzle = function (query, context, extra, seed) { - context = context || document; - - // Only use querySelectorAll on non-XML documents - // (ID selectors don't work in non-HTML documents) - if (!seed && !Sizzle.isXML(context)) { - // See if we find a selector to speed up - var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(query); - - if (match && (context.nodeType === 1 || context.nodeType === 9)) { - // Speed-up: Sizzle("TAG") - if (match[1]) { - return makeArray(context.getElementsByTagName(query), extra); - - // Speed-up: Sizzle(".CLASS") - } else if (match[2] && Expr.find.CLASS && context.getElementsByClassName) { - return makeArray(context.getElementsByClassName(match[2]), extra); - } - } - - if (context.nodeType === 9) { - // Speed-up: Sizzle("body") - // The body element only exists once, optimize finding it - if (query === "body" && context.body) { - return makeArray([context.body], extra); - - // Speed-up: Sizzle("#ID") - } else if (match && match[3]) { - var elem = context.getElementById(match[3]); - - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - if (elem && elem.parentNode) { - // Handle the case where IE and Opera return items - // by name instead of ID - if (elem.id === match[3]) { - return makeArray([elem], extra); - } - - } else { - return makeArray([], extra); - } - } - - try { - return makeArray(context.querySelectorAll(query), extra); - } catch (qsaError) { - } - - // qSA works strangely on Element-rooted queries - // We can work around this by specifying an extra ID on the root - // and working up from there (Thanks to Andrew Dupont for the technique) - // IE 8 doesn't work on object elements - } else if (context.nodeType === 1 && context.nodeName.toLowerCase() !== "object") { - var oldContext = context, - old = context.getAttribute("id"), - nid = old || id, - hasParent = context.parentNode, - relativeHierarchySelector = /^\s*[+~]/.test(query); - - if (!old) { - context.setAttribute("id", nid); - } else { - nid = nid.replace(/'/g, "\\$&"); - } - if (relativeHierarchySelector && hasParent) { - context = context.parentNode; - } - - try { - if (!relativeHierarchySelector || hasParent) { - return makeArray(context.querySelectorAll("[id='" + nid + "'] " + query), extra); - } - - } catch (pseudoError) { - } finally { - if (!old) { - oldContext.removeAttribute("id"); - } - } - } - } - - return oldSizzle(query, context, extra, seed); - }; - - for (var prop in oldSizzle) { - Sizzle[ prop ] = oldSizzle[ prop ]; - } - - // release memory in IE - div = null; - })(); - } - - (function () { - var html = document.documentElement, - matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector; - - if (matches) { - // Check to see if it's possible to do matchesSelector - // on a disconnected node (IE 9 fails this) - var disconnectedMatch = !matches.call(document.createElement("div"), "div"), - pseudoWorks = false; - - try { - // This should fail with an exception - // Gecko does not error, returns false instead - matches.call(document.documentElement, "[test!='']:sizzle"); - - } catch (pseudoError) { - pseudoWorks = true; - } - - Sizzle.matchesSelector = function (node, expr) { - // Make sure that attribute selectors are quoted - expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); - - if (!Sizzle.isXML(node)) { - try { - if (pseudoWorks || !Expr.match.PSEUDO.test(expr) && !/!=/.test(expr)) { - var ret = matches.call(node, expr); - - // IE 9's matchesSelector returns false on disconnected nodes - if (ret || !disconnectedMatch || - // As well, disconnected nodes are said to be in a document - // fragment in IE 9, so check for that - node.document && node.document.nodeType !== 11) { - return ret; - } - } - } catch (e) { - } - } - - return Sizzle(expr, null, null, [node]).length > 0; - }; - } - })(); - - (function () { - var div = document.createElement("div"); - - div.innerHTML = "
"; - - // Opera can't find a second classname (in 9.6) - // Also, make sure that getElementsByClassName actually exists - if (!div.getElementsByClassName || div.getElementsByClassName("e").length === 0) { - return; - } - - // Safari caches class attributes, doesn't catch changes (in 3.2) - div.lastChild.className = "e"; - - if (div.getElementsByClassName("e").length === 1) { - return; - } - - Expr.order.splice(1, 0, "CLASS"); - Expr.find.CLASS = function (match, context, isXML) { - if (typeof context.getElementsByClassName !== "undefined" && !isXML) { - return context.getElementsByClassName(match[1]); - } - }; - - // release memory in IE - div = null; - })(); - - function dirNodeCheck(dir, cur, doneName, checkSet, nodeCheck, isXML) { - for (var i = 0, l = checkSet.length; i < l; i++) { - var elem = checkSet[i]; - - if (elem) { - var match = false; - - elem = elem[dir]; - - while (elem) { - if (elem[ expando ] === doneName) { - match = checkSet[elem.sizset]; - break; - } - - if (elem.nodeType === 1 && !isXML) { - elem[ expando ] = doneName; - elem.sizset = i; - } - - if (elem.nodeName.toLowerCase() === cur) { - match = elem; - break; - } - - elem = elem[dir]; - } - - checkSet[i] = match; - } - } - } - - function dirCheck(dir, cur, doneName, checkSet, nodeCheck, isXML) { - for (var i = 0, l = checkSet.length; i < l; i++) { - var elem = checkSet[i]; - - if (elem) { - var match = false; - - elem = elem[dir]; - - while (elem) { - if (elem[ expando ] === doneName) { - match = checkSet[elem.sizset]; - break; - } - - if (elem.nodeType === 1) { - if (!isXML) { - elem[ expando ] = doneName; - elem.sizset = i; - } - - if (typeof cur !== "string") { - if (elem === cur) { - match = true; - break; - } - - } else if (Sizzle.filter(cur, [elem]).length > 0) { - match = elem; - break; - } - } - - elem = elem[dir]; - } - - checkSet[i] = match; - } - } - } - - if (document.documentElement.contains) { - Sizzle.contains = function (a, b) { - return a !== b && (a.contains ? a.contains(b) : true); - }; - - } else if (document.documentElement.compareDocumentPosition) { - Sizzle.contains = function (a, b) { - return !!(a.compareDocumentPosition(b) & 16); - }; - - } else { - Sizzle.contains = function () { - return false; - }; - } - - Sizzle.isXML = function (elem) { - // documentElement is verified for cases where it doesn't yet exist - // (such as loading iframes in IE - #4833) - var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; - - return documentElement ? documentElement.nodeName !== "HTML" : false; - }; - - var posProcess = function (selector, context, seed) { - var match, - tmpSet = [], - later = "", - root = context.nodeType ? [context] : context; - - // Position selectors must be done after the filter - // And so must :not(positional) so we move all PSEUDOs to the end - while ((match = Expr.match.PSEUDO.exec(selector))) { - later += match[0]; - selector = selector.replace(Expr.match.PSEUDO, ""); - } - - selector = Expr.relative[selector] ? selector + "*" : selector; - - for (var i = 0, l = root.length; i < l; i++) { - Sizzle(selector, root[i], tmpSet, seed); - } - - return Sizzle.filter(later, tmpSet); - }; - -// EXPOSE -// Override sizzle attribute retrieval - Sizzle.attr = jQuery.attr; - Sizzle.selectors.attrMap = {}; - jQuery.find = Sizzle; - jQuery.expr = Sizzle.selectors; - jQuery.expr[":"] = jQuery.expr.filters; - jQuery.unique = Sizzle.uniqueSort; - jQuery.text = Sizzle.getText; - jQuery.isXMLDoc = Sizzle.isXML; - jQuery.contains = Sizzle.contains; - - - })(); - - - var runtil = /Until$/, - rparentsprev = /^(?:parents|prevUntil|prevAll)/, - // Note: This RegExp should be improved, or likely pulled from Sizzle - rmultiselector = /,/, - isSimple = /^.[^:#\[\.,]*$/, - slice = Array.prototype.slice, - POS = jQuery.expr.match.POS, - // methods guaranteed to produce a unique set when starting from a unique set - guaranteedUnique = { - children: true, - contents: true, - next: true, - prev: true - }; - - jQuery.fn.extend({ - find: function (selector) { - var self = this, - i, l; - - if (typeof selector !== "string") { - return jQuery(selector).filter(function () { - for (i = 0, l = self.length; i < l; i++) { - if (jQuery.contains(self[ i ], this)) { - return true; - } - } - }); - } - - var ret = this.pushStack("", "find", selector), - length, n, r; - - for (i = 0, l = this.length; i < l; i++) { - length = ret.length; - jQuery.find(selector, this[i], ret); - - if (i > 0) { - // Make sure that the results are unique - for (n = length; n < ret.length; n++) { - for (r = 0; r < length; r++) { - if (ret[r] === ret[n]) { - ret.splice(n--, 1); - break; - } - } - } - } - } - - return ret; - }, - has: function (target) { - var targets = jQuery(target); - return this.filter(function () { - for (var i = 0, l = targets.length; i < l; i++) { - if (jQuery.contains(this, targets[i])) { - return true; - } - } - }); - }, - not: function (selector) { - return this.pushStack(winnow(this, selector, false), "not", selector); - }, - filter: function (selector) { - return this.pushStack(winnow(this, selector, true), "filter", selector); - }, - is: function (selector) { - return !!selector && ( - typeof selector === "string" ? - // If this is a positional selector, check membership in the returned set - // so $("p:first").is("p:last") won't return true for a doc with two "p". - POS.test(selector) ? - jQuery(selector, this.context).index(this[0]) >= 0 : - jQuery.filter(selector, this).length > 0 : - this.filter(selector).length > 0); - }, - closest: function (selectors, context) { - var ret = [], i, l, cur = this[0]; - - // Array (deprecated as of jQuery 1.7) - if (jQuery.isArray(selectors)) { - var level = 1; - - while (cur && cur.ownerDocument && cur !== context) { - for (i = 0; i < selectors.length; i++) { - - if (jQuery(cur).is(selectors[ i ])) { - ret.push({selector: selectors[ i ], elem: cur, level: level}); - } - } - - cur = cur.parentNode; - level++; - } - - return ret; - } - - // String - var pos = POS.test(selectors) || typeof selectors !== "string" ? - jQuery(selectors, context || this.context) : - 0; - - for (i = 0, l = this.length; i < l; i++) { - cur = this[i]; - - while (cur) { - if (pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors)) { - ret.push(cur); - break; - - } else { - cur = cur.parentNode; - if (!cur || !cur.ownerDocument || cur === context || cur.nodeType === 11) { - break; - } - } - } - } - - ret = ret.length > 1 ? jQuery.unique(ret) : ret; - - return this.pushStack(ret, "closest", selectors); - }, - // Determine the position of an element within - // the matched set of elements - index: function (elem) { - - // No argument, return index in parent - if (!elem) { - return (this[0] && this[0].parentNode) ? this.prevAll().length : -1; - } - - // index in selector - if (typeof elem === "string") { - return jQuery.inArray(this[0], jQuery(elem)); - } - - // Locate the position of the desired element - return jQuery.inArray( - // If it receives a jQuery object, the first element is used - elem.jquery ? elem[0] : elem, this); - }, - add: function (selector, context) { - var set = typeof selector === "string" ? - jQuery(selector, context) : - jQuery.makeArray(selector && selector.nodeType ? [selector] : selector), - all = jQuery.merge(this.get(), set); - - return this.pushStack(isDisconnected(set[0]) || isDisconnected(all[0]) ? - all : - jQuery.unique(all)); - }, - andSelf: function () { - return this.add(this.prevObject); - } - }); - -// A painfully simple check to see if an element is disconnected -// from a document (should be improved, where feasible). - function isDisconnected(node) { - return !node || !node.parentNode || node.parentNode.nodeType === 11; - } - - jQuery.each({ - parent: function (elem) { - var parent = elem.parentNode; - return parent && parent.nodeType !== 11 ? parent : null; - }, - parents: function (elem) { - return jQuery.dir(elem, "parentNode"); - }, - parentsUntil: function (elem, i, until) { - return jQuery.dir(elem, "parentNode", until); - }, - next: function (elem) { - return jQuery.nth(elem, 2, "nextSibling"); - }, - prev: function (elem) { - return jQuery.nth(elem, 2, "previousSibling"); - }, - nextAll: function (elem) { - return jQuery.dir(elem, "nextSibling"); - }, - prevAll: function (elem) { - return jQuery.dir(elem, "previousSibling"); - }, - nextUntil: function (elem, i, until) { - return jQuery.dir(elem, "nextSibling", until); - }, - prevUntil: function (elem, i, until) { - return jQuery.dir(elem, "previousSibling", until); - }, - siblings: function (elem) { - return jQuery.sibling(elem.parentNode.firstChild, elem); - }, - children: function (elem) { - return jQuery.sibling(elem.firstChild); - }, - contents: function (elem) { - return jQuery.nodeName(elem, "iframe") ? - elem.contentDocument || elem.contentWindow.document : - jQuery.makeArray(elem.childNodes); - } - }, function (name, fn) { - jQuery.fn[ name ] = function (until, selector) { - var ret = jQuery.map(this, fn, until), - // The variable 'args' was introduced in - // https://github.com/jquery/jquery/commit/52a0238 - // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed. - // http://code.google.com/p/v8/issues/detail?id=1050 - args = slice.call(arguments); - - if (!runtil.test(name)) { - selector = until; - } - - if (selector && typeof selector === "string") { - ret = jQuery.filter(selector, ret); - } - - ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique(ret) : ret; - - if ((this.length > 1 || rmultiselector.test(selector)) && rparentsprev.test(name)) { - ret = ret.reverse(); - } - - return this.pushStack(ret, name, args.join(",")); - }; - }); - - jQuery.extend({ - filter: function (expr, elems, not) { - if (not) { - expr = ":not(" + expr + ")"; - } - - return elems.length === 1 ? - jQuery.find.matchesSelector(elems[0], expr) ? [elems[0]] : [] : - jQuery.find.matches(expr, elems); - }, - dir: function (elem, dir, until) { - var matched = [], - cur = elem[ dir ]; - - while (cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery(cur).is(until))) { - if (cur.nodeType === 1) { - matched.push(cur); - } - cur = cur[dir]; - } - return matched; - }, - nth: function (cur, result, dir, elem) { - result = result || 1; - var num = 0; - - for (; cur; cur = cur[dir]) { - if (cur.nodeType === 1 && ++num === result) { - break; - } - } - - return cur; - }, - sibling: function (n, elem) { - var r = []; - - for (; n; n = n.nextSibling) { - if (n.nodeType === 1 && n !== elem) { - r.push(n); - } - } - - return r; - } - }); - -// Implement the identical functionality for filter and not - function winnow(elements, qualifier, keep) { - - // Can't pass null or undefined to indexOf in Firefox 4 - // Set to 0 to skip string check - qualifier = qualifier || 0; - - if (jQuery.isFunction(qualifier)) { - return jQuery.grep(elements, function (elem, i) { - var retVal = !!qualifier.call(elem, i, elem); - return retVal === keep; - }); - - } else if (qualifier.nodeType) { - return jQuery.grep(elements, function (elem, i) { - return (elem === qualifier) === keep; - }); - - } else if (typeof qualifier === "string") { - var filtered = jQuery.grep(elements, function (elem) { - return elem.nodeType === 1; - }); - - if (isSimple.test(qualifier)) { - return jQuery.filter(qualifier, filtered, !keep); - } else { - qualifier = jQuery.filter(qualifier, filtered); - } - } - - return jQuery.grep(elements, function (elem, i) { - return (jQuery.inArray(elem, qualifier) >= 0) === keep; - }); - } - - - - - function createSafeFragment(document) { - var list = nodeNames.split(" "), - safeFrag = document.createDocumentFragment(); - - if (safeFrag.createElement) { - while (list.length) { - safeFrag.createElement( - list.pop() - ); - } - } - return safeFrag; - } - - var nodeNames = "abbr article aside audio canvas datalist details figcaption figure footer " + - "header hgroup mark meter nav output progress section summary time video", - rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, - rleadingWhitespace = /^\s+/, - rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig, - rtagName = /<([\w:]+)/, - rtbody = /", ""], - legend: [1, "
", "
"], - thead: [1, "", "
"], - tr: [2, "", "
"], - td: [3, "", "
"], - col: [2, "", "
"], - area: [1, "", ""], - _default: [0, "", ""] - }, - safeFragment = createSafeFragment(document); - - wrapMap.optgroup = wrapMap.option; - wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; - wrapMap.th = wrapMap.td; - -// IE can't serialize and - + + diff --git a/nar-bundles/monitor-threshold-bundle/ui/src/main/webapp/js/jquery/jqgrid/css/ellipsis-xbl.xml b/nar-bundles/monitor-threshold-bundle/ui/src/main/webapp/js/jquery/jqgrid/css/ellipsis-xbl.xml deleted file mode 100644 index ea0bdf8a00..0000000000 --- a/nar-bundles/monitor-threshold-bundle/ui/src/main/webapp/js/jquery/jqgrid/css/ellipsis-xbl.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - diff --git a/nar-bundles/monitor-threshold-bundle/ui/src/main/webapp/js/jquery/jqgrid/css/ui.jqgrid.css b/nar-bundles/monitor-threshold-bundle/ui/src/main/webapp/js/jquery/jqgrid/css/ui.jqgrid.css old mode 100755 new mode 100644 index a3baeeda4b..11594b11f5 --- a/nar-bundles/monitor-threshold-bundle/ui/src/main/webapp/js/jquery/jqgrid/css/ui.jqgrid.css +++ b/nar-bundles/monitor-threshold-bundle/ui/src/main/webapp/js/jquery/jqgrid/css/ui.jqgrid.css @@ -1,181 +1,120 @@ /*Grid*/ -.ui-jqgrid {position: relative; font-size:11px;} -.ui-jqgrid .ui-jqgrid-view {position: relative;left:0px; top: 0px; padding: .0em;} - +.ui-jqgrid {position: relative;} +.ui-jqgrid .ui-jqgrid-view {position: relative;left:0; top: 0; padding: 0; font-size:11px;} /* caption*/ -.ui-jqgrid .ui-jqgrid-titlebar {padding: .3em .2em .2em .3em; position: relative; border-left: 0px none;border-right: 0px none; border-top: 0px none;} -.ui-jqgrid .ui-jqgrid-title { float: left; margin: .1em 0 .2em; } -.ui-jqgrid .ui-jqgrid-titlebar-close { position: absolute;top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height:18px;}.ui-jqgrid .ui-jqgrid-titlebar-close span { display: block; margin: 1px; } +.ui-jqgrid .ui-jqgrid-titlebar {padding: .3em .2em .2em .3em; position: relative; font-size: 12px; border-left: 0 none;border-right: 0 none; border-top: 0 none;} +.ui-jqgrid .ui-jqgrid-caption {text-align: left;} +.ui-jqgrid .ui-jqgrid-title { margin: .1em 0 .2em; } +.ui-jqgrid .ui-jqgrid-titlebar-close { position: absolute;top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height:18px; cursor:pointer;} +.ui-jqgrid .ui-jqgrid-titlebar-close span { display: block; margin: 1px; } .ui-jqgrid .ui-jqgrid-titlebar-close:hover { padding: 0; } - /* header*/ -/*.ui-jqgrid .ui-jqgrid-hdiv {position: relative; margin: 0em;padding: 0em; overflow-x: hidden; overflow-y: auto; border-left: 0px none !important; border-top : 0px none !important; border-right : 0px none !important;}*/ -.ui-jqgrid .ui-jqgrid-hdiv { - position: relative; - margin: 0em; - padding: 0em; - overflow-x: hidden; - overflow-y: auto; - border-left: 0px none !important; - border-top : 0px none !important; - border-right : 0px none !important; - border-bottom: 1px solid #666; - background-image: url(../../../../images/bgTableHeader.png); - background-repeat: repeat-x; -} - +.ui-jqgrid .ui-jqgrid-hdiv {position: relative; margin: 0;padding: 0; overflow-x: hidden; border-left: 0 none !important; border-top : 0 none !important; border-right : 0 none !important;} .ui-jqgrid .ui-jqgrid-hbox {float: left; padding-right: 20px;} -.ui-jqgrid .ui-jqgrid-htable {table-layout:fixed;margin:0em;} -/*.ui-jqgrid .ui-jqgrid-htable th {height:22px;padding: 0 2px 0 2px;}*/ -.ui-jqgrid .ui-jqgrid-htable th { - height: 26px; - padding: 0 2px; - border-right: 1px solid #172B31; - border-bottom: 1px solid #365C6A; - background-image: url(../../../../images/bgTableHeader.png); - background-repeat: repeat-x; -} -/*.ui-jqgrid .ui-jqgrid-htable th div {overflow: hidden; position:relative; height:17px;}*/ -.ui-jqgrid .ui-jqgrid-htable th div { - overflow: hidden; - position: relative; - padding-top: 8px; - left: 4px; - height: 17px; - color: #fff; - font-weight: bold; -} -/*.ui-th-column, .ui-jqgrid .ui-jqgrid-htable th.ui-th-column {overflow: hidden;white-space: nowrap;text-align:center;border-top : 0px none;border-bottom : 0px none;}*/ -.ui-th-column, .ui-jqgrid .ui-jqgrid-htable th.ui-th-column { - overflow: hidden; - white-space: nowrap; - border-top: 0px none; - border-bottom: 0px none; -} -.ui-th-ltr, .ui-jqgrid .ui-jqgrid-htable th.ui-th-ltr {border-left : 0px none;} -.ui-th-rtl, .ui-jqgrid .ui-jqgrid-htable th.ui-th-rtl {border-right : 0px none;} +.ui-jqgrid .ui-jqgrid-htable {table-layout:fixed;margin:0;} +.ui-jqgrid .ui-jqgrid-htable th {height:22px;padding: 0 2px 0 2px;} +.ui-jqgrid .ui-jqgrid-htable th div {overflow: hidden; position:relative; height:17px;} +.ui-th-column, .ui-jqgrid .ui-jqgrid-htable th.ui-th-column {overflow: hidden;white-space: nowrap;text-align:center;border-top : 0 none;border-bottom : 0 none;} +.ui-th-ltr, .ui-jqgrid .ui-jqgrid-htable th.ui-th-ltr {border-left : 0 none;} +.ui-th-rtl, .ui-jqgrid .ui-jqgrid-htable th.ui-th-rtl {border-right : 0 none;} +.ui-first-th-ltr {border-right: 1px solid; } +.ui-first-th-rtl {border-left: 1px solid; } .ui-jqgrid .ui-th-div-ie {white-space: nowrap; zoom :1; height:17px;} -/*.ui-jqgrid .ui-jqgrid-resize {height:20px !important;position: relative; cursor :e-resize;display: inline;overflow: hidden;}*/ -.ui-jqgrid .ui-jqgrid-resize { - height: 26px !important; - position: relative; - cursor: e-resize; - display: inline; - overflow: hidden; - z-index: 1; -} +.ui-jqgrid .ui-jqgrid-resize {height:20px !important;position: relative; cursor :e-resize;display: inline;overflow: hidden;} .ui-jqgrid .ui-grid-ico-sort {overflow:hidden;position:absolute;display:inline; cursor: pointer !important;} -/*.ui-jqgrid .ui-icon-asc {margin-top:-3px; height:12px;}*/ -.ui-jqgrid .ui-icon-asc { - margin-left: 5px; - margin-top: -5px; - height: 12px; -} -/*.ui-jqgrid .ui-icon-desc {margin-top:3px;height:12px;}*/ -.ui-jqgrid .ui-icon-desc { - height: 12px; - margin-top: 2px; - margin-left: 4px; -} -.ui-jqgrid .ui-i-asc {margin-top:0px;height:16px;} -.ui-jqgrid .ui-i-desc {margin-top:0px;margin-left:13px;height:16px;} +.ui-jqgrid .ui-icon-asc {margin-top:-3px; height:12px;} +.ui-jqgrid .ui-icon-desc {margin-top:3px;height:12px;} +.ui-jqgrid .ui-i-asc {margin-top:0;height:16px;} +.ui-jqgrid .ui-i-desc {margin-top:0;margin-left:13px;height:16px;} .ui-jqgrid .ui-jqgrid-sortable {cursor:pointer;} .ui-jqgrid tr.ui-search-toolbar th { border-top-width: 1px !important; border-top-color: inherit !important; border-top-style: ridge !important } -tr.ui-search-toolbar input {margin: 1px 0px 0px 0px} -tr.ui-search-toolbar select {margin: 1px 0px 0px 0px} - +tr.ui-search-toolbar input {margin: 1px 0 0 0} +tr.ui-search-toolbar select {margin: 1px 0 0 0} /* body */ -.ui-jqgrid .ui-jqgrid-bdiv {position: relative; margin: 0em; padding:0; overflow: auto; text-align:left;} -.ui-jqgrid .ui-jqgrid-btable {table-layout:fixed; margin:0em;} -/*.ui-jqgrid tr.jqgrow td {font-weight: normal; overflow: hidden; white-space: pre; height: 22px;padding: 0 2px 0 2px;border-bottom-width: 1px; border-bottom-color: inherit; border-bottom-style: solid;}*/ -.ui-jqgrid tr.jqgrow td { - font-weight: normal; - overflow: hidden; - padding: 2px; - border-bottom-width: 1px; - border-bottom-color: #aaa; - border-bottom-style: solid; -} -/*.ui-jqgrid tr.ui-row-ltr td {text-align:left;border-right-width: 1px; border-right-color: inherit; border-right-style: solid;}*/ -.ui-jqgrid tr.ui-row-ltr td { - vertical-align: middle; - padding: 6px 3px 4px 2px; - text-align: left; -} +.ui-jqgrid .ui-jqgrid-bdiv {position: relative; margin: 0; padding:0; overflow: auto; text-align:left;} +.ui-jqgrid .ui-jqgrid-btable {table-layout:fixed; margin:0; outline-style: none; } +.ui-jqgrid tr.jqgrow { outline-style: none; } +.ui-jqgrid tr.jqgroup { outline-style: none; } +.ui-jqgrid tr.jqgrow td {font-weight: normal; overflow: hidden; white-space: pre; height: 22px;padding: 0 2px 0 2px;border-bottom-width: 1px; border-bottom-color: inherit; border-bottom-style: solid;} +.ui-jqgrid tr.jqgfirstrow td {padding: 0 2px 0 2px;border-right-width: 1px; border-right-style: solid;} +.ui-jqgrid tr.jqgroup td {font-weight: normal; overflow: hidden; white-space: pre; height: 22px;padding: 0 2px 0 2px;border-bottom-width: 1px; border-bottom-color: inherit; border-bottom-style: solid;} +.ui-jqgrid tr.jqfoot td {font-weight: bold; overflow: hidden; white-space: pre; height: 22px;padding: 0 2px 0 2px;border-bottom-width: 1px; border-bottom-color: inherit; border-bottom-style: solid;} +.ui-jqgrid tr.ui-row-ltr td {text-align:left;border-right-width: 1px; border-right-color: inherit; border-right-style: solid;} .ui-jqgrid tr.ui-row-rtl td {text-align:right;border-left-width: 1px; border-left-color: inherit; border-left-style: solid;} -.ui-jqgrid td.jqgrid-rownum { padding: 0 2px 0 2px; margin: 0px; border: 0px none;} -.ui-jqgrid .ui-jqgrid-resize-mark { width:2px; left:0; background-color:#777; cursor: e-resize; cursor: col-resize; position:absolute; top:0; height:100px; overflow:hidden; display:none; border:0 none;} - +.ui-jqgrid td.jqgrid-rownum { padding: 0 2px 0 2px; margin: 0; border: 0 none;} +.ui-jqgrid .ui-jqgrid-resize-mark { width:2px; left:0; background-color:#777; cursor: e-resize; cursor: col-resize; position:absolute; top:0; height:100px; overflow:hidden; display:none; border:0 none; z-index: 99999;} /* footer */ -.ui-jqgrid .ui-jqgrid-sdiv {position: relative; margin: 0em;padding: 0em; overflow: hidden; border-left: 0px none !important; border-top : 0px none !important; border-right : 0px none !important;} -.ui-jqgrid .ui-jqgrid-ftable {table-layout:fixed; margin-bottom:0em;} +.ui-jqgrid .ui-jqgrid-sdiv {position: relative; margin: 0;padding: 0; overflow: hidden; border-left: 0 none !important; border-top : 0 none !important; border-right : 0 none !important;} +.ui-jqgrid .ui-jqgrid-ftable {table-layout:fixed; margin-bottom:0;} .ui-jqgrid tr.footrow td {font-weight: bold; overflow: hidden; white-space:nowrap; height: 21px;padding: 0 2px 0 2px;border-top-width: 1px; border-top-color: inherit; border-top-style: solid;} .ui-jqgrid tr.footrow-ltr td {text-align:left;border-right-width: 1px; border-right-color: inherit; border-right-style: solid;} .ui-jqgrid tr.footrow-rtl td {text-align:right;border-left-width: 1px; border-left-color: inherit; border-left-style: solid;} - /* Pager*/ -.ui-jqgrid .ui-jqgrid-pager { border-left: 0px none !important;border-right: 0px none !important; border-bottom: 0px none !important; margin: 0px !important; padding: 0px !important; position: relative; height: 25px;white-space: nowrap;overflow: hidden;} +.ui-jqgrid .ui-jqgrid-pager { border-left: 0 none !important;border-right: 0 none !important; border-bottom: 0 none !important; margin: 0 !important; padding: 0 !important; position: relative; height: 25px;white-space: nowrap;overflow: hidden;font-size:11px;} .ui-jqgrid .ui-pager-control {position: relative;} -.ui-jqgrid .ui-pg-table {position: relative; padding-bottom:2px; width:auto; margin: 0em;} +.ui-jqgrid .ui-pg-table {position: relative; padding-bottom:2px; width:auto; margin: 0;} .ui-jqgrid .ui-pg-table td {font-weight:normal; vertical-align:middle; padding:1px;} .ui-jqgrid .ui-pg-button { height:19px !important;} .ui-jqgrid .ui-pg-button span { display: block; margin: 1px; float:left;} -/*.ui-jqgrid .ui-pg-button:hover { padding: 0px; }*/ -.ui-jqgrid .ui-pg-button:hover { - padding: 1px; -} +.ui-jqgrid .ui-pg-button:hover { padding: 0; } .ui-jqgrid .ui-state-disabled:hover {padding:1px;} -.ui-jqgrid .ui-pg-input { height:13px;font-size:.8em; margin: 0em;} -.ui-jqgrid .ui-pg-selbox {font-size:.8em; line-height:18px; display:block; height:18px; margin: 0em;} +.ui-jqgrid .ui-pg-input { height:13px;font-size:.8em; margin: 0;} +.ui-jqgrid .ui-pg-selbox {font-size:.8em; line-height:18px; display:block; height:18px; margin: 0;} .ui-jqgrid .ui-separator {height: 18px; border-left: 1px solid #ccc ; border-right: 1px solid #ccc ; margin: 1px; float: right;} .ui-jqgrid .ui-paging-info {font-weight: normal;height:19px; margin-top:3px;margin-right:4px;} -.ui-jqgrid .ui-jqgrid-pager .ui-pg-div {padding:1px 0;float:left;list-style-image:none;list-style-position:outside;list-style-type:none;position:relative;} +.ui-jqgrid .ui-jqgrid-pager .ui-pg-div {padding:1px 0;float:left;position:relative;} .ui-jqgrid .ui-jqgrid-pager .ui-pg-button { cursor:pointer; } .ui-jqgrid .ui-jqgrid-pager .ui-pg-div span.ui-icon {float:left;margin:0 2px;} -.ui-jqgrid td input, .ui-jqgrid td select .ui-jqgrid td textarea { margin: 0em;} +.ui-jqgrid td input, .ui-jqgrid td select .ui-jqgrid td textarea { margin: 0;} .ui-jqgrid td textarea {width:auto;height:auto;} -.ui-jqgrid .ui-jqgrid-toppager {border-left: 0px none !important;border-right: 0px none !important; border-top: 0px none !important; margin: 0px !important; padding: 0px !important; position: relative; height: 25px !important;white-space: nowrap;overflow: hidden;} - -/* subgrid */ +.ui-jqgrid .ui-jqgrid-toppager {border-left: 0 none !important;border-right: 0 none !important; border-top: 0 none !important; margin: 0 !important; padding: 0 !important; position: relative; height: 25px !important;white-space: nowrap;overflow: hidden;} +.ui-jqgrid .ui-jqgrid-toppager .ui-pg-div {padding:1px 0;float:left;position:relative;} +.ui-jqgrid .ui-jqgrid-toppager .ui-pg-button { cursor:pointer; } +.ui-jqgrid .ui-jqgrid-toppager .ui-pg-div span.ui-icon {float:left;margin:0 2px;} +/*subgrid*/ .ui-jqgrid .ui-jqgrid-btable .ui-sgcollapsed span {display: block;} -.ui-jqgrid .ui-subgrid {margin:0em;padding:0em; width:100%;} +.ui-jqgrid .ui-subgrid {margin:0;padding:0; width:100%;} .ui-jqgrid .ui-subgrid table {table-layout: fixed;} .ui-jqgrid .ui-subgrid tr.ui-subtblcell td {height:18px;border-right-width: 1px; border-right-color: inherit; border-right-style: solid;border-bottom-width: 1px; border-bottom-color: inherit; border-bottom-style: solid;} -.ui-jqgrid .ui-subgrid td.subgrid-data {border-top: 0px none !important;} -.ui-jqgrid .ui-subgrid td.subgrid-cell {border-width: 0px 0px 1px 0px;} +.ui-jqgrid .ui-subgrid td.subgrid-data {border-top: 0 none !important;} +.ui-jqgrid .ui-subgrid td.subgrid-cell {border-width: 0 0 1px 0;} .ui-jqgrid .ui-th-subgrid {height:20px;} - /* loading */ -.ui-jqgrid .loading {position: absolute; top: 45%;left: 45%;width: auto;z-index:101;padding: 6px; margin: 5px;text-align: center;font-weight: bold;display: none;border-width: 2px !important;} +.ui-jqgrid .loading {position: absolute; top: 45%;left: 45%;width: auto;z-index:101;padding: 6px; margin: 5px;text-align: center;font-weight: bold;display: none;border-width: 2px !important; font-size:11px;} .ui-jqgrid .jqgrid-overlay {display:none;z-index:100;} -* html .jqgrid-overlay {width: expression(this.parentNode.offsetWidth+'px');height: expression(this.parentNode.offsetHeight+'px');} -* .jqgrid-overlay iframe {position:absolute;top:0;left:0;z-index:-1;width: expression(this.parentNode.offsetWidth+'px');height: expression(this.parentNode.offsetHeight+'px');} +/* IE * html .jqgrid-overlay {width: expression(this.parentNode.offsetWidth+'px');height: expression(this.parentNode.offsetHeight+'px');} */ +* .jqgrid-overlay iframe {position:absolute;top:0;left:0;z-index:-1;} +/* IE width: expression(this.parentNode.offsetWidth+'px');height: expression(this.parentNode.offsetHeight+'px');}*/ /* end loading div */ - /* toolbar */ -.ui-jqgrid .ui-userdata {border-left: 0px none; border-right: 0px none; height : 21px;overflow: hidden; } - +.ui-jqgrid .ui-userdata {border-left: 0 none; border-right: 0 none; height : 21px;overflow: hidden; } /*Modal Window */ .ui-jqdialog { display: none; width: 300px; position: absolute; padding: .2em; font-size:11px; overflow:visible;} .ui-jqdialog .ui-jqdialog-titlebar { padding: .3em .2em; position: relative; } .ui-jqdialog .ui-jqdialog-title { margin: .1em 0 .2em; } -.ui-jqdialog .ui-jqdialog-titlebar-close { position: absolute; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; } +.ui-jqdialog .ui-jqdialog-titlebar-close { position: absolute; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; cursor:pointer;} + .ui-jqdialog .ui-jqdialog-titlebar-close span { display: block; margin: 1px; } .ui-jqdialog .ui-jqdialog-titlebar-close:hover, .ui-jqdialog .ui-jqdialog-titlebar-close:focus { padding: 0; } .ui-jqdialog-content, .ui-jqdialog .ui-jqdialog-content { border: 0; padding: .3em .2em; background: none; height:auto;} .ui-jqdialog .ui-jqconfirm {padding: .4em 1em; border-width:3px;position:absolute;bottom:10px;right:10px;overflow:visible;display:none;height:80px;width:220px;text-align:center;} +.ui-jqdialog>.ui-resizable-se { bottom: -3px; right: -3px} +.ui-jqgrid>.ui-resizable-se { bottom: -3px; right: -3px } /* end Modal window*/ - /* Form edit */ -.ui-jqdialog-content .FormGrid {margin: 0px;} -.ui-jqdialog-content .EditTable { width: 100%; margin-bottom:0em;} -.ui-jqdialog-content .DelTable { width: 100%; margin-bottom:0em;} -.EditTable td input, .EditTable td select, .EditTable td textarea {margin: 0em;} +.ui-jqdialog-content .FormGrid {margin: 0;} +.ui-jqdialog-content .EditTable { width: 100%; margin-bottom:0;} +.ui-jqdialog-content .DelTable { width: 100%; margin-bottom:0;} +.EditTable td input, .EditTable td select, .EditTable td textarea {margin: 0;} .EditTable td textarea { width:auto; height:auto;} -.ui-jqdialog-content td.EditButton {text-align: right;border-top: 0px none;border-left: 0px none;border-right: 0px none; padding-bottom:5px; padding-top:5px;} -.ui-jqdialog-content td.navButton {text-align: center; border-left: 0px none;border-top: 0px none;border-right: 0px none; padding-bottom:5px; padding-top:5px;} -.ui-jqdialog-content .CaptionTD {text-align: left; vertical-align: top;border-left: 0px none;border-right: 0px none; border-bottom: 0px none; padding: 1px;white-space: nowrap;} -.ui-jqdialog-content .DataTD {padding: 1px;border-left: 0px none;border-right: 0px none; border-bottom: 0px none; vertical-align: top;} +.ui-jqdialog-content td.EditButton {text-align: right;border-top: 0 none;border-left: 0 none;border-right: 0 none; padding-bottom:5px; padding-top:5px;} +.ui-jqdialog-content td.navButton {text-align: center; border-left: 0 none;border-top: 0 none;border-right: 0 none; padding-bottom:5px; padding-top:5px;} +.ui-jqdialog-content input.FormElement {padding:.3em} +.ui-jqdialog-content select.FormElement {padding:.3em} +.ui-jqdialog-content .data-line {padding-top:.1em;border: 0 none;} + +.ui-jqdialog-content .CaptionTD {vertical-align: middle;border: 0 none; padding: 2px;white-space: nowrap;} +.ui-jqdialog-content .DataTD {padding: 2px; border: 0 none; vertical-align: top;} .ui-jqdialog-content .form-view-data {white-space:pre} .fm-button { display: inline-block; margin:0 4px 0 0; padding: .4em .5em; text-decoration:none !important; cursor:pointer; position: relative; text-align: center; zoom: 1; } .fm-button-icon-left { padding-left: 1.9em; } @@ -184,29 +123,49 @@ tr.ui-search-toolbar select {margin: 1px 0px 0px 0px} .fm-button-icon-right .ui-icon { left: auto; right: .2em; margin-left: 0; position: absolute; top: 50%; margin-top: -8px;} #nData, #pData { float: left; margin:3px;padding: 0; width: 15px; } /* End Eorm edit */ - /*.ui-jqgrid .edit-cell {}*/ -.ui-jqgrid .selected-row, div.ui-jqgrid .selected-row td {font-style : normal;border-left: 0px none;} - +.ui-jqgrid .selected-row, div.ui-jqgrid .selected-row td {font-style : normal;border-left: 0 none;} +/* inline edit actions button*/ +.ui-inline-del.ui-state-hover span, .ui-inline-edit.ui-state-hover span, +.ui-inline-save.ui-state-hover span, .ui-inline-cancel.ui-state-hover span { + margin: -1px; +} /* Tree Grid */ .ui-jqgrid .tree-wrap {float: left; position: relative;height: 18px;white-space: nowrap;overflow: hidden;} .ui-jqgrid .tree-minus {position: absolute; height: 18px; width: 18px; overflow: hidden;} .ui-jqgrid .tree-plus {position: absolute; height: 18px; width: 18px; overflow: hidden;} .ui-jqgrid .tree-leaf {position: absolute; height: 18px; width: 18px;overflow: hidden;} .ui-jqgrid .treeclick {cursor: pointer;} - /* moda dialog */ -.jqmOverlay { background-color: #000; } -* iframe.jqm {position:absolute;top:0;left:0;z-index:-1;width: expression(this.parentNode.offsetWidth+'px');height: expression(this.parentNode.offsetHeight+'px');} +* iframe.jqm {position:absolute;top:0;left:0;z-index:-1;} +/* width: expression(this.parentNode.offsetWidth+'px');height: expression(this.parentNode.offsetHeight+'px');}*/ .ui-jqgrid-dnd tr td {border-right-width: 1px; border-right-color: inherit; border-right-style: solid; height:20px} - /* RTL Support */ -.ui-jqgrid .ui-jqgrid-title-rtl {float:right;margin: .1em 0 .2em; } +.ui-jqgrid .ui-jqgrid-caption-rtl {text-align: right;} .ui-jqgrid .ui-jqgrid-hbox-rtl {float: right; padding-left: 20px;} -.ui-jqgrid .ui-jqgrid-resize-ltr {float: right;margin: -2px -2px -2px 0px;} -.ui-jqgrid .ui-jqgrid-resize-rtl {float: left;margin: -2px 0px -1px -3px;} -.ui-jqgrid .ui-sort-rtl {left:0px;} +.ui-jqgrid .ui-jqgrid-resize-ltr {float: right;margin: -2px -2px -2px 0;} +.ui-jqgrid .ui-jqgrid-resize-rtl {float: left;margin: -2px 0 -1px -3px;} +.ui-jqgrid .ui-sort-rtl {left:0;} .ui-jqgrid .tree-wrap-ltr {float: left;} .ui-jqgrid .tree-wrap-rtl {float: right;} -.ui-jqgrid .ui-ellipsis {text-overflow:ellipsis; -moz-binding:url('ellipsis-xbl.xml#ellipsis');} +.ui-jqgrid .ui-ellipsis {-moz-text-overflow:ellipsis;text-overflow:ellipsis;} +/* Toolbar Search Menu */ +.ui-search-menu { position: absolute; padding: 2px 5px;} +.ui-jqgrid .ui-search-table { padding: 0; border: 0 none; height:20px; width:100%;} +.ui-jqgrid .ui-search-table .ui-search-oper { width:20px; } +a.g-menu-item, a.soptclass, a.clearsearchclass { cursor: pointer; } +.ui-jqgrid .ui-search-table .ui-search-input>input, +.ui-jqgrid .ui-search-table .ui-search-input>select +{ + display: block; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; +} +.ui-jqgrid .ui-jqgrid-view input, +.ui-jqgrid .ui-jqgrid-view select, +.ui-jqgrid .ui-jqgrid-view textarea, +.ui-jqgrid .ui-jqgrid-view button { + font-size: 11px +} diff --git a/nar-bundles/monitor-threshold-bundle/ui/src/main/webapp/js/jquery/jqgrid/js/i18n/grid.locale-en.js b/nar-bundles/monitor-threshold-bundle/ui/src/main/webapp/js/jquery/jqgrid/js/i18n/grid.locale-en.js old mode 100755 new mode 100644 index 7b12acfa1b..6929885ecf --- a/nar-bundles/monitor-threshold-bundle/ui/src/main/webapp/js/jquery/jqgrid/js/i18n/grid.locale-en.js +++ b/nar-bundles/monitor-threshold-bundle/ui/src/main/webapp/js/jquery/jqgrid/js/i18n/grid.locale-en.js @@ -1,5 +1,170 @@ -(function (a) { - a.jgrid = {defaults: {recordtext: "View {0} - {1} of {2}", emptyrecords: "No records to view", loadtext: "Loading...", pgtext: "Page {0} of {1}"}, search: {caption: "Search...", Find: "Find", Reset: "Reset", odata: ["equal", "not equal", "less", "less or equal", "greater", "greater or equal", "begins with", "does not begin with", "is in", "is not in", "ends with", "does not end with", "contains", "does not contain"], groupOps: [{op: "AND", text: "all"}, {op: "OR", text: "any"}], matchText: " match", rulesText: " rules"}, edit: {addCaption: "Add Record", editCaption: "Edit Record", bSubmit: "Submit", bCancel: "Cancel", bClose: "Close", saveData: "Data has been changed! Save changes?", bYes: "Yes", bNo: "No", bExit: "Cancel", msg: {required: "Field is required", number: "Please, enter valid number", minValue: "value must be greater than or equal to ", maxValue: "value must be less than or equal to", email: "is not a valid e-mail", integer: "Please, enter valid integer value", date: "Please, enter valid date value", url: "is not a valid URL. Prefix required ('http://' or 'https://')", nodefined: " is not defined!", novalue: " return value is required!", customarray: "Custom function should return array!", customfcheck: "Custom function should be present in case of custom checking!"}}, view: {caption: "View Record", bClose: "Close"}, del: {caption: "Delete", msg: "Delete selected record(s)?", bSubmit: "Delete", bCancel: "Cancel"}, nav: {edittext: "", edittitle: "Edit selected row", addtext: "", addtitle: "Add new row", deltext: "", deltitle: "Delete selected row", searchtext: "", searchtitle: "Find records", refreshtext: "", refreshtitle: "Reload Grid", alertcap: "Warning", alerttext: "Please, select row", viewtext: "", viewtitle: "View selected row"}, col: {caption: "Select columns", bSubmit: "Ok", bCancel: "Cancel"}, errors: {errcap: "Error", nourl: "No url is set", norecords: "No records to process", model: "Length of colNames <> colModel!"}, formatter: {integer: {thousandsSeparator: " ", defaultValue: "0"}, number: {decimalSeparator: ".", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: "0.00"}, currency: {decimalSeparator: ".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix: "", defaultValue: "0.00"}, date: {dayNames: ["Sun", "Mon", "Tue", "Wed", "Thr", "Fri", "Sat", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], monthNames: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], AmPm: ["am", "pm", "AM", "PM"], S: function (b) { - return b < 11 || b > 13 ? ["st", "nd", "rd", "th"][Math.min((b - 1) % 10, 3)] : "th" - }, srcformat: "Y-m-d", newformat: "d/m/Y", masks: {ISO8601Long: "Y-m-d H:i:s", ISO8601Short: "Y-m-d", ShortDate: "n/j/Y", LongDate: "l, F d, Y", FullDateTime: "l, F d, Y g:i:s A", MonthDay: "F d", ShortTime: "g:i A", LongTime: "g:i:s A", SortableDateTime: "Y-m-d\\TH:i:s", UniversalSortableDateTime: "Y-m-d H:i:sO", YearMonth: "F, Y"}, reformatAfterEdit: false}, baseLinkUrl: "", showAction: "", target: "", checkbox: {disabled: true}, idName: "id"}} -})(jQuery); \ No newline at end of file +;(function($){ +/** + * jqGrid English Translation + * Tony Tomov tony@trirand.com + * http://trirand.com/blog/ + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html +**/ +$.jgrid = $.jgrid || {}; +$.extend($.jgrid,{ + defaults : { + recordtext: "View {0} - {1} of {2}", + emptyrecords: "No records to view", + loadtext: "Loading...", + pgtext : "Page {0} of {1}" + }, + search : { + caption: "Search...", + Find: "Find", + Reset: "Reset", + odata: [{ oper:'eq', text:'equal'},{ oper:'ne', text:'not equal'},{ oper:'lt', text:'less'},{ oper:'le', text:'less or equal'},{ oper:'gt', text:'greater'},{ oper:'ge', text:'greater or equal'},{ oper:'bw', text:'begins with'},{ oper:'bn', text:'does not begin with'},{ oper:'in', text:'is in'},{ oper:'ni', text:'is not in'},{ oper:'ew', text:'ends with'},{ oper:'en', text:'does not end with'},{ oper:'cn', text:'contains'},{ oper:'nc', text:'does not contain'},{ oper:'nu', text:'is null'},{ oper:'nn', text:'is not null'}], + groupOps: [{ op: "AND", text: "all" },{ op: "OR", text: "any" }], + operandTitle : "Click to select search operation.", + resetTitle : "Reset Search Value" + }, + edit : { + addCaption: "Add Record", + editCaption: "Edit Record", + bSubmit: "Submit", + bCancel: "Cancel", + bClose: "Close", + saveData: "Data has been changed! Save changes?", + bYes : "Yes", + bNo : "No", + bExit : "Cancel", + msg: { + required:"Field is required", + number:"Please, enter valid number", + minValue:"value must be greater than or equal to ", + maxValue:"value must be less than or equal to", + email: "is not a valid e-mail", + integer: "Please, enter valid integer value", + date: "Please, enter valid date value", + url: "is not a valid URL. Prefix required ('http://' or 'https://')", + nodefined : " is not defined!", + novalue : " return value is required!", + customarray : "Custom function should return array!", + customfcheck : "Custom function should be present in case of custom checking!" + + } + }, + view : { + caption: "View Record", + bClose: "Close" + }, + del : { + caption: "Delete", + msg: "Delete selected record(s)?", + bSubmit: "Delete", + bCancel: "Cancel" + }, + nav : { + edittext: "", + edittitle: "Edit selected row", + addtext:"", + addtitle: "Add new row", + deltext: "", + deltitle: "Delete selected row", + searchtext: "", + searchtitle: "Find records", + refreshtext: "", + refreshtitle: "Reload Grid", + alertcap: "Warning", + alerttext: "Please, select row", + viewtext: "", + viewtitle: "View selected row" + }, + col : { + caption: "Select columns", + bSubmit: "Ok", + bCancel: "Cancel" + }, + errors : { + errcap : "Error", + nourl : "No url is set", + norecords: "No records to process", + model : "Length of colNames <> colModel!" + }, + formatter : { + integer : {thousandsSeparator: ",", defaultValue: '0'}, + number : {decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 2, defaultValue: '0.00'}, + currency : {decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0.00'}, + date : { + dayNames: [ + "Sun", "Mon", "Tue", "Wed", "Thr", "Fri", "Sat", + "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" + ], + monthNames: [ + "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", + "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" + ], + AmPm : ["am","pm","AM","PM"], + S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th';}, + srcformat: 'Y-m-d', + newformat: 'n/j/Y', + parseRe : /[#%\\\/:_;.,\t\s-]/, + masks : { + // see http://php.net/manual/en/function.date.php for PHP format used in jqGrid + // and see http://docs.jquery.com/UI/Datepicker/formatDate + // and https://github.com/jquery/globalize#dates for alternative formats used frequently + // one can find on https://github.com/jquery/globalize/tree/master/lib/cultures many + // information about date, time, numbers and currency formats used in different countries + // one should just convert the information in PHP format + ISO8601Long:"Y-m-d H:i:s", + ISO8601Short:"Y-m-d", + // short date: + // n - Numeric representation of a month, without leading zeros + // j - Day of the month without leading zeros + // Y - A full numeric representation of a year, 4 digits + // example: 3/1/2012 which means 1 March 2012 + ShortDate: "n/j/Y", // in jQuery UI Datepicker: "M/d/yyyy" + // long date: + // l - A full textual representation of the day of the week + // F - A full textual representation of a month + // d - Day of the month, 2 digits with leading zeros + // Y - A full numeric representation of a year, 4 digits + LongDate: "l, F d, Y", // in jQuery UI Datepicker: "dddd, MMMM dd, yyyy" + // long date with long time: + // l - A full textual representation of the day of the week + // F - A full textual representation of a month + // d - Day of the month, 2 digits with leading zeros + // Y - A full numeric representation of a year, 4 digits + // g - 12-hour format of an hour without leading zeros + // i - Minutes with leading zeros + // s - Seconds, with leading zeros + // A - Uppercase Ante meridiem and Post meridiem (AM or PM) + FullDateTime: "l, F d, Y g:i:s A", // in jQuery UI Datepicker: "dddd, MMMM dd, yyyy h:mm:ss tt" + // month day: + // F - A full textual representation of a month + // d - Day of the month, 2 digits with leading zeros + MonthDay: "F d", // in jQuery UI Datepicker: "MMMM dd" + // short time (without seconds) + // g - 12-hour format of an hour without leading zeros + // i - Minutes with leading zeros + // A - Uppercase Ante meridiem and Post meridiem (AM or PM) + ShortTime: "g:i A", // in jQuery UI Datepicker: "h:mm tt" + // long time (with seconds) + // g - 12-hour format of an hour without leading zeros + // i - Minutes with leading zeros + // s - Seconds, with leading zeros + // A - Uppercase Ante meridiem and Post meridiem (AM or PM) + LongTime: "g:i:s A", // in jQuery UI Datepicker: "h:mm:ss tt" + SortableDateTime: "Y-m-d\\TH:i:s", + UniversalSortableDateTime: "Y-m-d H:i:sO", + // month with year + // Y - A full numeric representation of a year, 4 digits + // F - A full textual representation of a month + YearMonth: "F, Y" // in jQuery UI Datepicker: "MMMM, yyyy" + }, + reformatAfterEdit : false + }, + baseLinkUrl: '', + showAction: '', + target: '', + checkbox : {disabled:true}, + idName : 'id' + } +}); +})(jQuery); diff --git a/nar-bundles/monitor-threshold-bundle/ui/src/main/webapp/js/jquery/jqgrid/js/jquery.jqGrid.min.js b/nar-bundles/monitor-threshold-bundle/ui/src/main/webapp/js/jquery/jqgrid/js/jquery.jqGrid.min.js old mode 100755 new mode 100644 index 5ce272fb39..340d0a008c --- a/nar-bundles/monitor-threshold-bundle/ui/src/main/webapp/js/jquery/jqgrid/js/jquery.jqGrid.min.js +++ b/nar-bundles/monitor-threshold-bundle/ui/src/main/webapp/js/jquery/jqgrid/js/jquery.jqGrid.min.js @@ -1,416 +1,545 @@ /* - * jqGrid 3.6.5 - jQuery Grid - * Copyright (c) 2008, Tony Tomov, tony@trirand.com - * Dual licensed under the MIT and GPL licenses - * http://www.opensource.org/licenses/mit-license.php - * http://www.gnu.org/licenses/gpl-2.0.html - * Date:2010-05-05 - * Modules: grid.base.js; jquery.fmatter.js; grid.custom.js; grid.common.js; grid.formedit.js; jquery.searchFilter.js; grid.inlinedit.js; grid.celledit.js; jqModal.js; jqDnR.js; grid.subgrid.js; grid.treegrid.js; grid.import.js; JsonXml.js; grid.setcolumns.js; grid.postext.js; grid.tbltogrid.js; grid.jqueryui.js; - */ -(function(b){b.jgrid = b.jgrid || {}; b.extend(b.jgrid, {htmlDecode:function(f){if (f == " " || f == " " || f.length == 1 && f.charCodeAt(0) == 160)return""; return!f?f:String(f).replace(/&/g, "&").replace(/>/g, ">").replace(/</g, "<").replace(/"/g, '"')}, htmlEncode:function(f){return!f?f:String(f).replace(/&/g, "&").replace(/>/g, ">").replace(/])*>/gi; if (f)return(f = f.replace(k, "")) && f !== " " && f !== " "?f.replace(/\"/g, "'"):""; else return f}, stringToDoc:function(f){var k; if (typeof f !== "string")return f; try{k = (new DOMParser).parseFromString(f, "text/xml")} catch (i){k = new ActiveXObject("Microsoft.XMLDOM"); - k.async = false; k.loadXML(f)}return k && k.documentElement && k.documentElement.tagName != "parsererror"?k:null}, parse:function(f){f = f; if (f.substr(0, 9) == "while(1);")f = f.substr(9); if (f.substr(0, 2) == "/*")f = f.substr(2, f.length - 4); f || (f = "{}"); return b.jgrid.useJSON === true && typeof JSON === "object" && typeof JSON.parse === "function"?JSON.parse(f):eval("(" + f + ")")}, jqID:function(f){f += ""; return f.replace(/([\.\:\[\]])/g, "\\$1")}, ajaxOptions:{}, extend:function(f){b.extend(b.fn.jqGrid, f); this.no_legacy_api || b.fn.extend(f)}}); - b.fn.jqGrid = function(f){if (typeof f == "string"){var k = b.fn.jqGrid[f]; if (!k)throw"jqGrid - No such method: " + f; var i = b.makeArray(arguments).slice(1); return k.apply(this, i)}return this.each(function(){if (!this.grid){var h = b.extend(true, {url:"", height:150, page:1, rowNum:20, records:0, pager:"", pgbuttons:true, pginput:true, colModel:[], rowList:[], colNames:[], sortorder:"asc", sortname:"", datatype:"xml", mtype:"GET", altRows:false, selarrrow:[], savedRow:[], shrinkToFit:true, xmlReader:{}, jsonReader:{}, subGrid:false, - subGridModel:[], reccount:0, lastpage:0, lastsort:0, selrow:null, beforeSelectRow:null, onSelectRow:null, onSortCol:null, ondblClickRow:null, onRightClickRow:null, onPaging:null, onSelectAll:null, loadComplete:null, gridComplete:null, loadError:null, loadBeforeSend:null, afterInsertRow:null, beforeRequest:null, onHeaderClick:null, viewrecords:false, loadonce:false, multiselect:false, multikey:false, editurl:null, search:false, caption:"", hidegrid:true, hiddengrid:false, postData:{}, userData:{}, treeGrid:false, treeGridModel:"nested", - treeReader:{}, treeANode: - 1, ExpandColumn:null, tree_root_level:0, prmNames:{page:"page", rows:"rows", sort:"sidx", order:"sord", search:"_search", nd:"nd", id:"id", oper:"oper", editoper:"edit", addoper:"add", deloper:"del", subgridid:"id", npage:null}, forceFit:false, gridstate:"visible", cellEdit:false, cellsubmit:"remote", nv:0, loadui:"enable", toolbar:[false, ""], scroll:false, multiboxonly:false, deselectAfterSort:true, scrollrows:false, autowidth:false, scrollOffset:18, cellLayout:5, subGridWidth:20, multiselectWidth:20, - gridview:false, rownumWidth:25, rownumbers:false, pagerpos:"center", recordpos:"right", footerrow:false, userDataOnFooter:false, hoverrows:true, altclass:"ui-priority-secondary", viewsortcols:[false, "vertical", true], resizeclass:"", autoencode:false, remapColumns:[], ajaxGridOptions:{}, direction:"ltr", toppager:false, headertitles:false, scrollTimeout:200}, b.jgrid.defaults, f || {}), g = {headers:[], cols:[], footers:[], dragStart:function(c, d, e){this.resizing = {idx:c, startX:d.clientX, sOL:e[0]}; this.hDiv.style.cursor = "col-resize"; - this.curGbox = b("#rs_m" + h.id, "#gbox_" + h.id); this.curGbox.css({display:"block", left:e[0], top:e[1], height:e[2]}); b.isFunction(h.resizeStart) && h.resizeStart.call(this, d, c); document.onselectstart = function(){return false}}, dragMove:function(c){if (this.resizing){var d = c.clientX - this.resizing.startX; c = this.headers[this.resizing.idx]; var e = h.direction === "ltr"?c.width + d:c.width - d, l; if (e > 33){this.curGbox.css({left:this.resizing.sOL + d}); if (h.forceFit === true){l = this.headers[this.resizing.idx + h.nv]; d = h.direction === - "ltr"?l.width - d:l.width + d; if (d > 33){c.newWidth = e; l.newWidth = d}} else{this.newWidth = h.direction === "ltr"?h.tblwidth + d:h.tblwidth - d; c.newWidth = e}}}}, dragEnd:function(){this.hDiv.style.cursor = "default"; if (this.resizing){var c = this.resizing.idx, d = this.headers[c].newWidth || this.headers[c].width; d = parseInt(d, 10); this.resizing = false; b("#rs_m" + h.id).css("display", "none"); h.colModel[c].width = d; this.headers[c].width = d; this.headers[c].el.style.width = d + "px"; if (this.cols.length > 0)this.cols[c].style.width = d + "px"; - if (this.footers.length > 0)this.footers[c].style.width = d + "px"; if (h.forceFit === true){d = this.headers[c + h.nv].newWidth || this.headers[c + h.nv].width; this.headers[c + h.nv].width = d; this.headers[c + h.nv].el.style.width = d + "px"; if (this.cols.length > 0)this.cols[c + h.nv].style.width = d + "px"; if (this.footers.length > 0)this.footers[c + h.nv].style.width = d + "px"; h.colModel[c + h.nv].width = d} else{h.tblwidth = this.newWidth || h.tblwidth; b("table:first", this.bDiv).css("width", h.tblwidth + "px"); b("table:first", this.hDiv).css("width", - h.tblwidth + "px"); this.hDiv.scrollLeft = this.bDiv.scrollLeft; if (h.footerrow){b("table:first", this.sDiv).css("width", h.tblwidth + "px"); this.sDiv.scrollLeft = this.bDiv.scrollLeft}}b.isFunction(h.resizeStop) && h.resizeStop.call(this, d, c)}this.curGbox = null; document.onselectstart = function(){return true}}, populateVisible:function(){g.timer && clearTimeout(g.timer); g.timer = null; var c = b(g.bDiv).height(); if (c){var d = b("table:first", g.bDiv), e = b("> tbody > tr:visible:first", d).outerHeight() || g.prevRowHeight; if (e){g.prevRowHeight = - e; var l = h.rowNum, n = g.scrollTop = g.bDiv.scrollTop, o = Math.round(d.position().top) - n, p = o + d.height(); e = e * l; var w, y, s; if (o <= 0 && (h.lastpage === undefined || parseInt((p + n + e - 1) / e, 10) <= h.lastpage)){y = parseInt((c - p + e - 1) / e, 10); if (p >= 0 || y < 2 || h.scroll === true){w = Math.round((p + n) / e) + 1; o = - 1} else o = 1}if (o > 0){w = parseInt(n / e, 10) + 1; y = parseInt((n + c) / e, 10) + 2 - w; s = true}if (y)if (!(h.lastpage && w > h.lastpage))if (g.hDiv.loading)g.timer = setTimeout(g.populateVisible, h.scrollTimeout); else{h.page = w; if (s){g.selectionPreserver(d[0]); g.emptyRows(g.bDiv, - false)}g.populate(y)}}}}, scrollGrid:function(){if (h.scroll){var c = g.bDiv.scrollTop; if (c != g.scrollTop){g.scrollTop = c; g.timer && clearTimeout(g.timer); g.timer = setTimeout(g.populateVisible, 200)}}g.hDiv.scrollLeft = g.bDiv.scrollLeft; if (h.footerrow)g.sDiv.scrollLeft = g.bDiv.scrollLeft}, selectionPreserver:function(c){var d = c.p, e = d.selrow, l = d.selarrrow?b.makeArray(d.selarrrow):null, n = c.grid.bDiv.scrollLeft, o = d.gridComplete; d.gridComplete = function(){d.selrow = null; d.selarrrow = []; if (d.multiselect && l && l.length > - 0)for (var p = 0; p < l.length; p++)l[p] != e && b(c).jqGrid("setSelection", l[p], false); e && b(c).jqGrid("setSelection", e, false); c.grid.bDiv.scrollLeft = n; d.gridComplete = o; d.gridComplete && o()}}}; this.p = h; var j, m, a; if (this.p.colNames.length === 0)for (j = 0; j < this.p.colModel.length; j++)this.p.colNames[j] = this.p.colModel[j].label || this.p.colModel[j].name; if (this.p.colNames.length !== this.p.colModel.length)alert(b.jgrid.errors.model); else{var q = b("
"), t, x = b.browser.msie?true:false, C = b.browser.safari? - true:false; a = this; a.p.direction = b.trim(a.p.direction.toLowerCase()); if (b.inArray(a.p.direction, ["ltr", "rtl"]) == - 1)a.p.direction = "ltr"; m = a.p.direction; b(q).insertBefore(this); b(this).appendTo(q).removeClass("scroll"); var K = b("
"); b(K).insertBefore(q).attr({id:"gbox_" + this.id, dir:m}); b(q).appendTo(K).attr("id", "gview_" + this.id); t = x && b.browser.version <= 6?'': - ""; b("
").append(t).insertBefore(q); b("
" + this.p.loadtext + "
").insertBefore(q); b(this).attr({cellSpacing:"0", cellPadding:"0", border:"0", role:"grid", "aria-multiselectable":!!this.p.multiselect, "aria-labelledby":"gbox_" + this.id}); var J = function(c, d){c = parseInt(c, 10); return isNaN(c)?d?d:0:c}, F = function(c, d, e){var l = a.p.colModel[c], n = l.align, o = 'style="', - p = l.classes, w = l.name; if (n)o += "text-align:" + n + ";"; if (l.hidden === true)o += "display:none;"; if (d === 0)o += "width: " + g.headers[c].width + "px;"; o += '"' + (p !== undefined?' class="' + p + '"':"") + (l.title && e?' title="' + b.jgrid.stripHtml(e) + '"':""); o += ' aria-describedby="' + a.p.id + "_" + w + '"'; return o}, Q = function(c){return c === undefined || c === null || c === ""?" ":a.p.autoencode?b.jgrid.htmlEncode(c):c + ""}, M = function(c, d, e, l, n){e = a.p.colModel[e]; if (typeof e.formatter !== "undefined"){c = {rowId:c, colModel:e, gid:a.p.id}; d = b.isFunction(e.formatter)? - e.formatter.call(a, d, c, l, n):b.fmatter?b.fn.fmatter(e.formatter, d, c, l, n):Q(d)} else d = Q(d); return d}, R = function(c, d, e, l, n){c = M(c, d, e, n, "add"); return'" + c + ""}, u = function(c, d, e){c = ''; d = F(d, e, ""); return'" + c + ""}, la = function(c, d, e, l){e = (parseInt(e, 10) - 1) * parseInt(l, 10) + 1 + d; c = F(c, d, ""); return'" + e + ""}, ca = function(c){var d, e = [], l = 0, n; for (n = 0; n < a.p.colModel.length; n++){d = a.p.colModel[n]; if (d.name !== "cb" && d.name !== "subgrid" && d.name !== "rn"){e[l] = c == "xml"?d.xmlmap || d.name:d.jsonmap || d.name; l++}}return e}, fa = function(c){var d = a.p.remapColumns; if (!d || !d.length)d = b.map(a.p.colModel, function(e, l){return l}); if (c)d = b.map(d, function(e){return e < c?null:e - c}); return d}, aa = function(c, d){a.p.deepempty?b("tbody:first tr", c).remove():b("tbody:first", - c).empty(); if (d && a.p.scroll){b(">div:first", c).css({height:"auto"}).children("div:first").css({height:0, display:"none"}); c.scrollTop = 0}}, U = function(c, d){var e, l, n, o; if (typeof d === "function")return d(c); e = c[d]; if (e === undefined){if (typeof d === "string")n = d.split("."); try{if (o = n.length)for (e = c; e && o--; ){l = n.shift(); e = e[l]}} catch (p){}}return e}, ia = function(c, d, e, l, n){var o = new Date; a.p.reccount = 0; if (b.isXMLDoc(c)){if (a.p.treeANode === - 1 && !a.p.scroll){aa(d, false); e = 0} else e = e > 0?e:0; var p, w = 0, y, s, r = 0, v = 0, - z = 0, D, N, L = [], P, G = {}, da = a.rows.length, E, W, B = [], S = 0, ga = a.p.altRows === true?" " + a.p.altclass:""; a.p.xmlReader.repeatitems || (L = ca("xml")); D = a.p.keyIndex === false?a.p.xmlReader.id:a.p.keyIndex; if (L.length > 0 && !isNaN(D)){if (a.p.remapColumns && a.p.remapColumns.length)D = b.inArray(D, a.p.remapColumns); D = L[D]}N = (D + "").indexOf("[") === - 1?L.length?function(X, V){return b(D, X).text() || V}:function(X, V){return b(a.p.xmlReader.cell, X).eq(D).text() || V}:function(X, V){return X.getAttribute(D.replace(/[\[\]]/g, "")) || V}; a.p.userData = - {}; b(a.p.xmlReader.page, c).each(function(){a.p.page = this.textContent || this.text || 0}); b(a.p.xmlReader.total, c).each(function(){a.p.lastpage = this.textContent || this.text; if (a.p.lastpage === undefined)a.p.lastpage = 1}); b(a.p.xmlReader.records, c).each(function(){a.p.records = this.textContent || this.text || 0}); b(a.p.xmlReader.userdata, c).each(function(){a.p.userData[this.getAttribute("name")] = this.textContent || this.text}); c = b(a.p.xmlReader.root + " " + a.p.xmlReader.row, c); var ha = c.length, O = 0; if (c && ha){var ma = parseInt(a.p.rowNum, - 10), wa = a.p.scroll?(parseInt(a.p.page, 10) - 1) * ma + 1:1; if (n)ma *= n + 1; for (n = b.isFunction(a.p.afterInsertRow); O < ha; ){E = c[O]; W = N(E, wa + O); p = e === 0?0:e + 1; p = (p + O) % 2 == 1?ga:""; B[S++] = ''; if (a.p.rownumbers === true){B[S++] = la(0, O, a.p.page, a.p.rowNum); z = 1}if (a.p.multiselect === true){B[S++] = u(W, z, O); r = 1}if (a.p.subGrid === true){B[S++] = b(a).jqGrid("addSubGridCell", r + z, O + e); v = 1}if (a.p.xmlReader.repeatitems){P || (P = fa(r + v + z)); var za = b(a.p.xmlReader.cell, - E); b.each(P, function(X){var V = za[this]; if (!V)return false; y = V.textContent || V.text; G[a.p.colModel[X + r + v + z].name] = y; B[S++] = R(W, y, X + r + v + z, O + e, E)})} else for (p = 0; p < L.length; p++){y = b(L[p], E).text(); G[a.p.colModel[p + r + v + z].name] = y; B[S++] = R(W, y, p + r + v + z, O + e, E)}B[S++] = ""; if (a.p.gridview === false){if (a.p.treeGrid === true){p = a.p.treeANode >= - 1?a.p.treeANode:0; s = b(B.join(""))[0]; try{b(a).jqGrid("setTreeNode", G, s)} catch (Fa){}da === 0?b("tbody:first", d).append(s):b(a.rows[O + p + e]).after(s)} else b("tbody:first", d).append(B.join("")); - if (a.p.subGrid === true)try{b(a).jqGrid("addSubGrid", a.rows[a.rows.length - 1], r + z)} catch (Ga){}n && a.p.afterInsertRow.call(a, W, G, E); B = []; S = 0}G = {}; w++; O++; if (w == ma)break}}a.p.gridview === true && b("tbody:first", d).append(B.join("")); a.p.totaltime = new Date - o; if (w > 0){a.grid.cols = a.rows[0].cells; if (a.p.records === 0)a.p.records = ha}B = null; if (!a.p.treeGrid && !a.p.scroll)a.grid.bDiv.scrollTop = 0; a.p.reccount = w; a.p.treeANode = - 1; a.p.userDataOnFooter && b(a).jqGrid("footerData", "set", a.p.userData, true); l || na(false, true)}}, - ra = function(c, d, e, l, n){var o = new Date; a.p.reccount = 0; if (c){if (a.p.treeANode === - 1 && !a.p.scroll){aa(d, false); e = 0} else e = e > 0?e:0; var p = 0, w, y, s, r = [], v, z = 0, D = 0, N = 0, L, P, G, da = {}, E, W = a.rows.length, B; s = []; E = 0; var S = a.p.altRows === true?" " + a.p.altclass:""; a.p.page = U(c, a.p.jsonReader.page) || 0; G = U(c, a.p.jsonReader.total); a.p.lastpage = G === undefined?1:G; a.p.records = U(c, a.p.jsonReader.records) || 0; a.p.userData = U(c, a.p.jsonReader.userdata) || {}; a.p.jsonReader.repeatitems || (v = r = ca("json")); G = a.p.keyIndex === false?a.p.jsonReader.id: - a.p.keyIndex; if (r.length > 0 && !isNaN(G)){if (a.p.remapColumns && a.p.remapColumns.length)G = b.inArray(G, a.p.remapColumns); G = r[G]}if (P = U(c, a.p.jsonReader.root)){L = P.length; c = 0; var ga = parseInt(a.p.rowNum, 10), ha = a.p.scroll?(parseInt(a.p.page, 10) - 1) * ga + 1:1; if (n)ga *= n + 1; for (var O = b.isFunction(a.p.afterInsertRow); c < L; ){n = P[c]; B = U(n, G); if (B === undefined){B = ha + c; if (r.length === 0)if (a.p.jsonReader.cell)B = n[a.p.jsonReader.cell][G] || B}w = e === 0?0:e + 1; w = (w + c) % 2 == 1?S:""; s[E++] = ''; if (a.p.rownumbers === true){s[E++] = la(0, c, a.p.page, a.p.rowNum); N = 1}if (a.p.multiselect){s[E++] = u(B, N, c); z = 1}if (a.p.subGrid){s[E++] = b(a).jqGrid("addSubGridCell", z + N, c + e); D = 1}if (a.p.jsonReader.repeatitems){if (a.p.jsonReader.cell)n = U(n, a.p.jsonReader.cell); v || (v = fa(z + D + N))}for (y = 0; y < v.length; y++){w = U(n, v[y]); s[E++] = R(B, w, y + z + D + N, c + e, n); da[a.p.colModel[y + z + D + N].name] = w}s[E++] = ""; if (a.p.gridview === false){if (a.p.treeGrid === true){E = a.p.treeANode >= - 1?a.p.treeANode:0; s = b(s.join(""))[0]; - try{b(a).jqGrid("setTreeNode", da, s)} catch (ma){}W === 0?b("tbody:first", d).append(s):b(a.rows[c + E + e]).after(s)} else b("tbody:first", d).append(s.join("")); if (a.p.subGrid === true)try{b(a).jqGrid("addSubGrid", a.rows[a.rows.length - 1], z + N)} catch (wa){}O && a.p.afterInsertRow.call(a, B, da, n); s = []; E = 0}da = {}; p++; c++; if (p == ga)break}a.p.gridview === true && b("tbody:first", d).append(s.join("")); a.p.totaltime = new Date - o; if (p > 0){a.grid.cols = a.rows[0].cells; if (a.p.records === 0)a.p.records = L}}if (!a.p.treeGrid && !a.p.scroll)a.grid.bDiv.scrollTop = - 0; a.p.reccount = p; a.p.treeANode = - 1; a.p.userDataOnFooter && b(a).jqGrid("footerData", "set", a.p.userData, true); l || na(false, true)}}, na = function(c, d){var e, l, n, o, p, w, y, s = ""; n = parseInt(a.p.page, 10) - 1; if (n < 0)n = 0; n *= parseInt(a.p.rowNum, 10); p = n + a.p.reccount; if (a.p.scroll){e = b("tbody:first > tr", a.grid.bDiv); n = p - e.length; if (l = e.outerHeight()){e = n * l; l = parseInt(a.p.records, 10) * l; b(">div:first", a.grid.bDiv).css({height:l}).children("div:first").css({height:e, display:e?"":"none"})}}s = a.p.pager?a.p.pager:""; s += a.p.toppager? - s?"," + a.p.toppager:a.p.toppager:""; if (s){y = b.jgrid.formatter.integer || {}; if (a.p.loadonce){e = l = 1; a.p.lastpage = a.page = 1; b(".selbox", s).attr("disabled", true)} else{e = J(a.p.page); l = J(a.p.lastpage); b(".selbox", s).attr("disabled", false)}if (a.p.pginput === true){b(".ui-pg-input", s).val(a.p.page); b("#sp_1", s).html(b.fmatter?b.fmatter.util.NumberFormat(a.p.lastpage, y):a.p.lastpage)}if (a.p.viewrecords)if (a.p.reccount === 0)b(".ui-paging-info", s).html(a.p.emptyrecords); else{o = n + 1; w = a.p.records; if (b.fmatter){o = b.fmatter.util.NumberFormat(o, - y); p = b.fmatter.util.NumberFormat(p, y); w = b.fmatter.util.NumberFormat(w, y)}b(".ui-paging-info", s).html(b.jgrid.format(a.p.recordtext, o, p, w))}if (a.p.pgbuttons === true){if (e <= 0)e = l = 0; if (e == 1 || e === 0){b("#first, #prev", a.p.pager).addClass("ui-state-disabled").removeClass("ui-state-hover"); a.p.toppager && b("#first_t, #prev_t", a.p.toppager).addClass("ui-state-disabled").removeClass("ui-state-hover")} else{b("#first, #prev", a.p.pager).removeClass("ui-state-disabled"); a.p.toppager && b("#first_t, #prev_t", a.p.toppager).removeClass("ui-state-disabled")}if (e == - l || e === 0){b("#next, #last", a.p.pager).addClass("ui-state-disabled").removeClass("ui-state-hover"); a.p.toppager && b("#next_t, #last_t", a.p.toppager).addClass("ui-state-disabled").removeClass("ui-state-hover")} else{b("#next, #last", a.p.pager).removeClass("ui-state-disabled"); a.p.toppager && b("#next_t, #last_t", a.p.toppager).removeClass("ui-state-disabled")}}}c === true && a.p.rownumbers === true && b("td.jqgrid-rownum", a.rows).each(function(r){b(this).html(n + 1 + r)}); d && a.p.jqgdnd && b(a).jqGrid("gridDnD", "updateDnD"); - b.isFunction(a.p.gridComplete) && a.p.gridComplete.call(a)}, Y = function(c){if (!a.grid.hDiv.loading){var d = a.p.scroll && c === false, e = {}, l, n = a.p.prmNames; if (a.p.page <= 0)a.p.page = 1; if (n.search !== null)e[n.search] = a.p.search; if (n.nd !== null)e[n.nd] = (new Date).getTime(); if (n.rows !== null)e[n.rows] = a.p.rowNum; if (n.page !== null)e[n.page] = a.p.page; if (n.sort !== null)e[n.sort] = a.p.sortname; if (n.order !== null)e[n.order] = a.p.sortorder; var o = a.p.loadComplete, p = b.isFunction(o); p || (o = null); var w = 0; c = c || 1; if (c > 1)if (n.npage !== - null){e[n.npage] = c; w = c - 1; c = 1} else o = function(s){p && a.p.loadComplete.call(a, s); a.grid.hDiv.loading = false; a.p.page++; Y(c - 1)}; else n.npage !== null && delete a.p.postData[n.npage]; b.extend(a.p.postData, e); var y = !a.p.scroll?0:a.rows.length - 1; if (b.isFunction(a.p.datatype))a.p.datatype.call(a, a.p.postData, "load_" + a.p.id); else{b.isFunction(a.p.beforeRequest) && a.p.beforeRequest.call(a); l = a.p.datatype.toLowerCase(); switch (l){case "json":case "jsonp":case "xml":case "script":b.ajax(b.extend({url:a.p.url, type:a.p.mtype, - dataType:l, data:b.isFunction(a.p.serializeGridData)?a.p.serializeGridData.call(a, a.p.postData):a.p.postData, success:function(s){l === "xml"?ia(s, a.grid.bDiv, y, c > 1, w):ra(s, a.grid.bDiv, y, c > 1, w); o && o.call(a, s); d && a.grid.populateVisible(); if (a.p.loadonce || a.p.treeGrid)a.p.datatype = "local"; ja()}, error:function(s, r, v){b.isFunction(a.p.loadError) && a.p.loadError.call(a, s, r, v); ja()}, beforeSend:function(s){oa(); b.isFunction(a.p.loadBeforeSend) && a.p.loadBeforeSend.call(a, s)}}, b.jgrid.ajaxOptions, a.p.ajaxGridOptions)); - break; case "xmlstring":oa(); e = b.jgrid.stringToDoc(a.p.datastr); p && a.p.loadComplete.call(a, e); ia(e, a.grid.bDiv); a.p.datatype = "local"; a.p.datastr = null; ja(); break; case "jsonstring":oa(); e = typeof a.p.datastr == "string"?b.jgrid.parse(a.p.datastr):a.p.datastr; p && a.p.loadComplete.call(a, e); ra(e, a.grid.bDiv); a.p.datatype = "local"; a.p.datastr = null; ja(); break; case "local":case "clientside":oa(); a.p.datatype = "local"; p && a.p.loadComplete.call(a, ""); Aa(); na(true, true); ja(); break}}}}, oa = function(){a.grid.hDiv.loading = - true; if (!a.p.hiddengrid)switch (a.p.loadui){case "disable":break; case "enable":b("#load_" + a.p.id).show(); break; case "block":b("#lui_" + a.p.id).show(); b("#load_" + a.p.id).show(); break}}, ja = function(){a.grid.hDiv.loading = false; switch (a.p.loadui){case "disable":break; case "enable":b("#load_" + a.p.id).hide(); break; case "block":b("#lui_" + a.p.id).hide(); b("#load_" + a.p.id).hide(); break}}, Aa = function(){var c = /[\$,%]/g, d = [], e = 0, l, n, o, p = a.p.sortorder == "asc"?1: - 1, w = false, y; b.each(a.p.colModel, function(r){if (this.index == - a.p.sortname || this.name == a.p.sortname){if (a.p.lastsort == r)w = true; e = r; l = this.sorttype; return false}}); o = l == "float" || l == "number" || l == "currency"?function(r){r = parseFloat(r.replace(c, "")); return isNaN(r)?0:r}:l == "int" || l == "integer"?function(r){return J(r.replace(c, ""), 0)}:l == "date" || l == "datetime"?function(r){return Ba(a.p.colModel[e].datefmt || "Y-m-d", r).getTime()}:b.isFunction(l)?l:function(r){return b.trim(r.toUpperCase())}; y = a.p.colModel[e]; b.each(a.rows, function(r, v){try{n = b.unformat(b(v).children("td").eq(e), - {rowId:v.id, colModel:y}, e, true)} catch (z){n = b(v).children("td").eq(e).text()}v.sortKey = o(n); d[r] = this}); if (a.p.treeGrid)b(a).jqGrid("SortTree", p); else{w?d.reverse():d.sort(function(r, v){if (r.sortKey < v.sortKey)return - p; if (r.sortKey > v.sortKey)return p; return 0}); if (d[0]){b("td", d[0]).each(function(r){b(this).css("width", g.headers[r].width + "px")}); a.grid.cols = d[0].cells}var s = ""; if (a.p.altRows)s = a.p.altclass; b.each(d, function(r, v){if (s)r % 2 == 1?b(v).addClass(s):b(v).removeClass(s); b("tbody", a.grid.bDiv).append(v); - v.sortKey = null})}a.grid.bDiv.scrollTop = 0}, Ba = function(c, d){var e = {m:1, d:1, y:1970, h:0, i:0, s:0}, l, n, o; if (d = b.trim(d)){d = d.split(/[\\\/:_;.\t\T\s-]/); c = c.split(/[\\\/:_;.\t\T\s-]/); var p = b.jgrid.formatter.date.monthNames, w = b.jgrid.formatter.date.AmPm, y = function(s, r){if (s === 0){if (r == 12)r = 0} else if (r != 12)r += 12; return r}; l = 0; for (n = c.length; l < n; l++){if (c[l] == "M"){o = b.inArray(d[l], p); if (o !== - 1 && o < 12)d[l] = o + 1}if (c[l] == "F"){o = b.inArray(d[l], p); if (o !== - 1 && o > 11)d[l] = o + 1 - 12}if (c[l] == "a"){o = b.inArray(d[l], w); if (o !== - - 1 && o < 2 && d[l] == w[o]){d[l] = o; e.h = y(d[l], e.h)}}if (c[l] == "A"){o = b.inArray(d[l], w); if (o !== - 1 && o > 1 && d[l] == w[o]){d[l] = o - 2; e.h = y(d[l], e.h)}}e[c[l].toLowerCase()] = parseInt(d[l], 10)}e.m = parseInt(e.m, 10) - 1; c = e.y; if (c >= 70 && c <= 99)e.y = 1900 + e.y; else if (c >= 0 && c <= 69)e.y = 2E3 + e.y}return new Date(e.y, e.m, e.d, e.h, e.i, e.s, 0)}; t = function(c, d){var e = "", l = "", n = "", o, p, w, y, s = function(r){var v; if (b.isFunction(a.p.onPaging))v = - a.p.onPaging.call(a, r); a.p.selrow = null; if (a.p.multiselect){a.p.selarrrow = []; b("#cb_" + b.jgrid.jqID(a.p.id), a.grid.hDiv).attr("checked", false)}a.p.savedRow = []; if (v == "stop")return false; return true}; c = c.substr(1); o = "pg_" + c; p = c + "_left"; w = c + "_center"; y = c + "_right"; b("#" + c).append("
").attr("dir", "ltr"); if (a.p.rowList.length > 0){n = ""; n += ""}if (m == "rtl")l += n; if (a.p.pginput === true)e = "" + b.jgrid.format(a.p.pgtext || "", "", - "") + ""; if (a.p.pgbuttons === true){p = ["first" + d, "prev" + d, "next" + d, "last" + d]; m == "rtl" && p.reverse(); l += ""; l += ""; l += e != ""?"" + e + "": - ""; l += ""; l += ""} else if (e != "")l += e; if (m == "ltr")l += n; l += ""; a.p.viewrecords === true && b("td#" + c + "_" + a.p.recordpos, "#" + o).append("
"); b("td#" + c + "_" + a.p.pagerpos, "#" + o).append(l); n = b(".ui-jqgrid").css("font-size") || - "11px"; b("body").append(""); l = b(l).clone().appendTo("#testpg").width(); b("#testpg").remove(); if (l > 0){if (e != "")l += 50; b("td#" + c + "_" + a.p.pagerpos, "#" + o).width(l)}a.p._nvtd = []; a.p._nvtd[0] = l?Math.floor((a.p.width - l) / 2):Math.floor(a.p.width / 3); a.p._nvtd[1] = 0; l = null; b(".ui-pg-selbox", "#" + o).bind("change", function(){a.p.page = Math.round(a.p.rowNum * (a.p.page - 1) / this.value - 0.5) + 1; a.p.rowNum = this.value; - if (d)b(".ui-pg-selbox", a.p.pager).val(this.value); else a.p.toppager && b(".ui-pg-selbox", a.p.toppager).val(this.value); if (!s("records"))return false; Y(); return false}); if (a.p.pgbuttons === true){b(".ui-pg-button", "#" + o).hover(function(){if (b(this).hasClass("ui-state-disabled"))this.style.cursor = "default"; else{b(this).addClass("ui-state-hover"); this.style.cursor = "pointer"}}, function(){if (!b(this).hasClass("ui-state-disabled")){b(this).removeClass("ui-state-hover"); this.style.cursor = "default"}}); b("#first" + - d + ", #prev" + d + ", #next" + d + ", #last" + d, "#" + c).click(function(){var r = J(a.p.page, 1), v = J(a.p.lastpage, 1), z = false, D = true, N = true, L = true, P = true; if (v === 0 || v === 1)P = L = N = D = false; else if (v > 1 && r >= 1)if (r === 1)N = D = false; else{if (!(r > 1 && r < v))if (r === v)P = L = false} else if (v > 1 && r === 0){P = L = false; r = v - 1}if (this.id === "first" + d && D){a.p.page = 1; z = true}if (this.id === "prev" + d && N){a.p.page = r - 1; z = true}if (this.id === "next" + d && L){a.p.page = r + 1; z = true}if (this.id === "last" + d && P){a.p.page = v; z = true}if (z){if (!s(this.id))return false; Y()}return false})}a.p.pginput === - true && b("input.ui-pg-input", "#" + o).keypress(function(r){if ((r.charCode?r.charCode:r.keyCode?r.keyCode:0) == 13){a.p.page = b(this).val() > 0?b(this).val():a.p.page; if (!s("user"))return false; Y(); return false}return this})}; var xa = function(c, d, e, l){if (a.p.colModel[d].sortable)if (!(a.p.savedRow.length > 0)){if (!e){if (a.p.lastsort == d)if (a.p.sortorder == "asc")a.p.sortorder = "desc"; else{if (a.p.sortorder == "desc")a.p.sortorder = "asc"} else a.p.sortorder = a.p.colModel[d].firstsortorder || "asc"; a.p.page = 1}if (l)if (a.p.lastsort == - d && a.p.sortorder == l && !e)return; else a.p.sortorder = l; e = b("thead:first", a.grid.hDiv).get(0); b("tr th:eq(" + a.p.lastsort + ") span.ui-grid-ico-sort", e).addClass("ui-state-disabled"); b("tr th:eq(" + a.p.lastsort + ")", e).attr("aria-selected", "false"); b("tr th:eq(" + d + ") span.ui-icon-" + a.p.sortorder, e).removeClass("ui-state-disabled"); b("tr th:eq(" + d + ")", e).attr("aria-selected", "true"); if (!a.p.viewsortcols[0])if (a.p.lastsort != d){b("tr th:eq(" + a.p.lastsort + ") span.s-ico", e).hide(); b("tr th:eq(" + d + ") span.s-ico", - e).show()}c = c.substring(5); a.p.sortname = a.p.colModel[d].index || c; e = a.p.sortorder; if (b.isFunction(a.p.onSortCol))if (a.p.onSortCol.call(a, c, d, e) == "stop"){a.p.lastsort = d; return}if (a.p.datatype == "local")a.p.deselectAfterSort && b(a).jqGrid("resetSelection"); else{a.p.selrow = null; a.p.multiselect && b("#cb_" + b.jgrid.jqID(a.p.id), a.grid.hDiv).attr("checked", false); a.p.selarrrow = []; a.p.savedRow = []; a.p.scroll && aa(a.grid.bDiv, true)}a.p.subGrid && a.p.datatype == "local" && b("td.sgexpanded", "#" + a.p.id).each(function(){b(this).trigger("click")}); - Y(); a.p.lastsort = d; if (a.p.sortname != c && d)a.p.lastsort = d}}, Ca = function(c){var d = c, e; for (e = c + 1; e < a.p.colModel.length; e++)if (a.p.colModel[e].hidden !== true){d = e; break}return d - c}, Da = function(c){var d, e = {}, l = C?0:a.p.cellLayout; for (d = e[0] = e[1] = e[2] = 0; d <= c; d++)if (a.p.colModel[d].hidden === false)e[0] += a.p.colModel[d].width + l; if (a.p.direction == "rtl")e[0] = a.p.width - e[0]; e[0] -= a.grid.bDiv.scrollLeft; if (b(a.grid.cDiv).is(":visible"))e[1] += b(a.grid.cDiv).height() + parseInt(b(a.grid.cDiv).css("padding-top"), 10) + - parseInt(b(a.grid.cDiv).css("padding-bottom"), 10); if (a.p.toolbar[0] === true && (a.p.toolbar[1] == "top" || a.p.toolbar[1] == "both"))e[1] += b(a.grid.uDiv).height() + parseInt(b(a.grid.uDiv).css("border-top-width"), 10) + parseInt(b(a.grid.uDiv).css("border-bottom-width"), 10); if (a.p.toppager)e[1] += b(a.grid.topDiv).height() + parseInt(b(a.grid.topDiv).css("border-bottom-width"), 10); e[2] += b(a.grid.bDiv).height() + b(a.grid.hDiv).height(); return e}; this.p.id = this.id; if (b.inArray(a.p.multikey, ["shiftKey", "altKey", "ctrlKey"]) == - - 1)a.p.multikey = false; a.p.keyIndex = false; for (j = 0; j < a.p.colModel.length; j++)if (a.p.colModel[j].key === true){a.p.keyIndex = j; break}a.p.sortorder = a.p.sortorder.toLowerCase(); if (this.p.treeGrid === true)try{b(this).jqGrid("setTreeGrid")} catch (Ha){}if (this.p.subGrid)try{b(a).jqGrid("setSubGrid")} catch (Ia){}if (this.p.multiselect){this.p.colNames.unshift(""); this.p.colModel.unshift({name:"cb", width:C?a.p.multiselectWidth + a.p.cellLayout: - a.p.multiselectWidth, sortable:false, resizable:false, hidedlg:true, search:false, align:"center", fixed:true})}if (this.p.rownumbers){this.p.colNames.unshift(""); this.p.colModel.unshift({name:"rn", width:a.p.rownumWidth, sortable:false, resizable:false, hidedlg:true, search:false, align:"center", fixed:true})}a.p.xmlReader = b.extend(true, {root:"rows", row:"row", page:"rows>page", total:"rows>total", records:"rows>records", repeatitems:true, cell:"cell", id:"[id]", userdata:"userdata", subgrid:{root:"rows", row:"row", repeatitems:true, - cell:"cell"}}, a.p.xmlReader); a.p.jsonReader = b.extend(true, {root:"rows", page:"page", total:"total", records:"records", repeatitems:true, cell:"cell", id:"id", userdata:"userdata", subgrid:{root:"rows", repeatitems:true, cell:"cell"}}, a.p.jsonReader); if (a.p.scroll){a.p.pgbuttons = false; a.p.pginput = false; a.p.rowList = []}var H = "", ya, ba, sa, ka, pa, I, A, ea; ba = ea = ""; if (a.p.shrinkToFit === true && a.p.forceFit === true)for (j = a.p.colModel.length - 1; j >= 0; j--)if (!a.p.colModel[j].hidden){a.p.colModel[j].resizable = - false; break}if (a.p.viewsortcols[1] == "horizontal"){ea = " ui-i-asc"; ba = " ui-i-desc"}ya = x?"class='ui-th-div-ie'":""; ea = ""; for (j = 0; j < this.p.colNames.length; j++){ba = a.p.headertitles?' title="' + b.jgrid.stripHtml(a.p.colNames[j]) + - '"':""; H += ""; ba = a.p.colModel[j].index || a.p.colModel[j].name; H += "
" + a.p.colNames[j]; a.p.colModel[j].width = a.p.colModel[j].width?parseInt(a.p.colModel[j].width, 10):150; if (typeof a.p.colModel[j].title !== "boolean")a.p.colModel[j].title = true; if (ba == a.p.sortname)a.p.lastsort = j; H += ea + "
"}H += ""; b(this).append(H); b("thead tr:first th", - this).hover(function(){b(this).addClass("ui-state-hover")}, function(){b(this).removeClass("ui-state-hover")}); if (this.p.multiselect){var ta = [], qa; b("#cb_" + b.jgrid.jqID(a.p.id), this).bind("click", function(){if (this.checked){b("[id^=jqg_]", a.rows).attr("checked", true); b(a.rows).each(function(c){if (!b(this).hasClass("subgrid")){b(this).addClass("ui-state-highlight").attr("aria-selected", "true"); a.p.selarrrow[c] = a.p.selrow = this.id}}); qa = true; ta = []} else{b("[id^=jqg_]", a.rows).attr("checked", false); b(a.rows).each(function(c){if (!b(this).hasClass("subgrid")){b(this).removeClass("ui-state-highlight").attr("aria-selected", - "false"); ta[c] = this.id}}); a.p.selarrrow = []; a.p.selrow = null; qa = false}if (b.isFunction(a.p.onSelectAll))a.p.onSelectAll.call(a, qa?a.p.selarrrow:ta, qa)})}if (a.p.autowidth === true){H = b(K).innerWidth(); a.p.width = H > 0?H:"nw"}(function(){var c = 0, d = a.p.cellLayout, e = 0, l, n = a.p.scrollOffset, o, p = false, w, y = 0, s = 0, r = 0, v; if (C)d = 0; b.each(a.p.colModel, function(){if (typeof this.hidden === "undefined")this.hidden = false; if (this.hidden === false){c += J(this.width, 0); if (this.fixed){y += this.width; s += this.width + d} else e++; r++}}); - if (isNaN(a.p.width))a.p.width = g.width = c; else g.width = a.p.width; a.p.tblwidth = c; if (a.p.shrinkToFit === false && a.p.forceFit === true)a.p.forceFit = false; if (a.p.shrinkToFit === true && e > 0){w = g.width - d * e - s; if (!isNaN(a.p.height)){w -= n; p = true}c = 0; b.each(a.p.colModel, function(z){if (this.hidden === false && !this.fixed){this.width = o = Math.round(w * this.width / (a.p.tblwidth - y)); c += o; l = z}}); v = 0; if (p){if (g.width - s - (c + d * e) !== n)v = g.width - s - (c + d * e) - n} else if (!p && Math.abs(g.width - s - (c + d * e)) !== 1)v = g.width - s - (c + d * e); a.p.colModel[l].width += - v; a.p.tblwidth = c + v + y + r * d; if (a.p.tblwidth > a.p.width){a.p.colModel[l].width -= a.p.tblwidth - parseInt(a.p.width, 10); a.p.tblwidth = a.p.width}}})(); b(K).css("width", g.width + "px").append("
 
"); b(q).css("width", g.width + "px"); H = b("thead:first", a).get(0); var ua = ""; q = b("tr:first", H); a.p.disableClick = false; b("th", q).each(function(c){sa = a.p.colModel[c].width; if (typeof a.p.colModel[c].resizable === "undefined")a.p.colModel[c].resizable = true; if (a.p.colModel[c].resizable){ka = document.createElement("span"); b(ka).html(" ").addClass("ui-jqgrid-resize ui-jqgrid-resize-" + m); b.browser.opera || b(ka).css("cursor", "col-resize"); b(this).addClass(a.p.resizeclass)} else ka = ""; b(this).css("width", sa + "px").prepend(ka); a.p.colModel[c].hidden && b(this).css("display", "none"); - g.headers[c] = {width:sa, el:this}; pa = a.p.colModel[c].sortable; if (typeof pa !== "boolean")pa = a.p.colModel[c].sortable = true; var d = a.p.colModel[c].name; d == "cb" || d == "subgrid" || d == "rn" || a.p.viewsortcols[2] && b("div", this).addClass("ui-jqgrid-sortable"); if (pa)if (a.p.viewsortcols[0]){b("div span.s-ico", this).show(); c == a.p.lastsort && b("div span.ui-icon-" + a.p.sortorder, this).removeClass("ui-state-disabled")} else if (c == a.p.lastsort){b("div span.s-ico", this).show(); b("div span.ui-icon-" + a.p.sortorder, this).removeClass("ui-state-disabled")}ua += - ""}).mousedown(function(c){if (b(c.target).closest("th>span.ui-jqgrid-resize").length == 1){var d = b.jgrid.getCellIndex(this); if (a.p.forceFit === true)a.p.nv = Ca(d); g.dragStart(d, c, Da(d)); return false}}).click(function(c){if (a.p.disableClick)return a.p.disableClick = false; var d = "th>div.ui-jqgrid-sortable", e, l; a.p.viewsortcols[2] || (d = "th>div>span>span.ui-grid-ico-sort"); c = b(c.target).closest(d); if (c.length == 1){d = b.jgrid.getCellIndex(this); if (!a.p.viewsortcols[2]){e = - true; l = c.attr("sort")}xa(b("div", this)[0].id, d, e, l); return false}}); if (a.p.sortable && b.fn.sortable)try{b(a).jqGrid("sortableColumns", q)} catch (Ja){}ua += "
 
"; this.appendChild(document.createElement("tbody")); b(this).addClass("ui-jqgrid-btable"); q = b("
").append(H); var T = a.p.caption && a.p.hiddengrid === true?true:false; H = b("
"); g.hDiv = document.createElement("div"); b(g.hDiv).css({width:g.width + "px"}).addClass("ui-state-default ui-jqgrid-hdiv").append(H); b(H).append(q); T && b(g.hDiv).hide(); if (a.p.pager){if (typeof a.p.pager == "string"){if (a.p.pager.substr(0, 1) != "#")a.p.pager = "#" + a.p.pager} else a.p.pager = "#" + b(a.p.pager).attr("id"); b(a.p.pager).css({width:g.width + "px"}).appendTo(K).addClass("ui-state-default ui-jqgrid-pager ui-corner-bottom"); T && b(a.p.pager).hide(); t(a.p.pager, "")}a.p.cellEdit === - false && a.p.hoverrows === true && b(a).bind("mouseover", function(c){A = b(c.target).closest("tr.jqgrow"); b(A).attr("class") !== "subgrid" && b(A).addClass("ui-state-hover"); return false}).bind("mouseout", function(c){A = b(c.target).closest("tr.jqgrow"); b(A).removeClass("ui-state-hover"); return false}); var Z, $; b(a).before(g.hDiv).click(function(c){I = c.target; var d = b(I).hasClass("cbox"); A = b(I, a.rows).closest("tr.jqgrow"); if (b(A).length === 0)return this; var e = true; if (b.isFunction(a.p.beforeSelectRow))e = a.p.beforeSelectRow.call(a, - A[0].id, c); if (I.tagName == "A" || (I.tagName == "INPUT" || I.tagName == "TEXTAREA" || I.tagName == "OPTION" || I.tagName == "SELECT") && !d)return this; if (e === true){if (a.p.cellEdit === true)if (a.p.multiselect && d)b(a).jqGrid("setSelection", A[0].id, true); else{Z = A[0].rowIndex; $ = b.jgrid.getCellIndex(I); try{b(a).jqGrid("editCell", Z, $, true)} catch (l){}} else if (a.p.multikey)if (c[a.p.multikey])b(a).jqGrid("setSelection", A[0].id, true); else{if (a.p.multiselect && d){d = b("[id^=jqg_]", A).attr("checked"); b("[id^=jqg_]", A).attr("checked", - !d)}} else{if (a.p.multiselect && a.p.multiboxonly)if (!d){b(a.p.selarrrow).each(function(n, o){n = a.rows.namedItem(o); b(n).removeClass("ui-state-highlight"); b("#jqg_" + b.jgrid.jqID(o), n).attr("checked", false)}); a.p.selarrrow = []; b("#cb_" + b.jgrid.jqID(a.p.id), a.grid.hDiv).attr("checked", false)}b(a).jqGrid("setSelection", A[0].id, true)}if (b.isFunction(a.p.onCellSelect)){Z = A[0].id; $ = b.jgrid.getCellIndex(I); a.p.onCellSelect.call(a, Z, $, b(I).html(), c)}c.stopPropagation()} else return this}).bind("reloadGrid", function(c, - d){if (a.p.treeGrid === true)a.p.datatype = a.p.treedatatype; d && d.current && a.grid.selectionPreserver(a); if (a.p.datatype == "local")b(a).jqGrid("resetSelection"); else if (!a.p.treeGrid){a.p.selrow = null; if (a.p.multiselect){a.p.selarrrow = []; b("#cb_" + b.jgrid.jqID(a.p.id), a.grid.hDiv).attr("checked", false)}a.p.savedRow = []; a.p.scroll && aa(a.grid.bDiv, true)}if (d && d.page){c = d.page; if (c > a.p.lastpage)c = a.p.lastpage; if (c < 1)c = 1; a.p.page = c; a.grid.bDiv.scrollTop = a.grid.prevRowHeight?(c - 1) * a.grid.prevRowHeight * a.p.rowNum: - 0}if (a.grid.prevRowHeight && a.p.scroll){delete a.p.lastpage; a.grid.populateVisible()} else a.grid.populate(); return false}); b.isFunction(this.p.ondblClickRow) && b(this).dblclick(function(c){I = c.target; A = b(I, a.rows).closest("tr.jqgrow"); if (b(A).length === 0)return false; Z = A[0].rowIndex; $ = b.jgrid.getCellIndex(I); a.p.ondblClickRow.call(a, b(A).attr("id"), Z, $, c); return false}); b.isFunction(this.p.onRightClickRow) && b(this).bind("contextmenu", function(c){I = c.target; A = b(I, a.rows).closest("tr.jqgrow"); if (b(A).length === - 0)return false; a.p.multiselect || b(a).jqGrid("setSelection", A[0].id, true); Z = A[0].rowIndex; $ = b.jgrid.getCellIndex(I); a.p.onRightClickRow.call(a, b(A).attr("id"), Z, $, c); return false}); g.bDiv = document.createElement("div"); b(g.bDiv).append(b('
').append("
").append(this)).addClass("ui-jqgrid-bdiv").css({height:a.p.height + (isNaN(a.p.height)?"":"px"), width:g.width + "px"}).scroll(g.scrollGrid); b("table:first", g.bDiv).css({width:a.p.tblwidth + - "px"}); if (x){b("tbody", this).size() == 2 && b("tbody:first", this).remove(); a.p.multikey && b(g.bDiv).bind("selectstart", function(){return false})} else a.p.multikey && b(g.bDiv).bind("mousedown", function(){return false}); T && b(g.bDiv).hide(); g.cDiv = document.createElement("div"); var va = a.p.hidegrid === true?b("").addClass("ui-jqgrid-titlebar-close HeaderButton").hover(function(){va.addClass("ui-state-hover")}, function(){va.removeClass("ui-state-hover")}).append("").css(m == - "rtl"?"left":"right", "0px"):""; b(g.cDiv).append(va).append("" + a.p.caption + "").addClass("ui-jqgrid-titlebar ui-widget-header ui-corner-top ui-helper-clearfix"); b(g.cDiv).insertBefore(g.hDiv); if (a.p.toolbar[0]){g.uDiv = document.createElement("div"); if (a.p.toolbar[1] == "top")b(g.uDiv).insertBefore(g.hDiv); else a.p.toolbar[1] == "bottom" && b(g.uDiv).insertAfter(g.hDiv); if (a.p.toolbar[1] == "both"){g.ubDiv = document.createElement("div"); b(g.uDiv).insertBefore(g.hDiv).addClass("ui-userdata ui-state-default").attr("id", - "t_" + this.id); b(g.ubDiv).insertAfter(g.hDiv).addClass("ui-userdata ui-state-default").attr("id", "tb_" + this.id); T && b(g.ubDiv).hide()} else b(g.uDiv).width(g.width).addClass("ui-userdata ui-state-default").attr("id", "t_" + this.id); T && b(g.uDiv).hide()}if (a.p.toppager){a.p.toppager = a.p.id + "_toppager"; g.topDiv = b("
")[0]; a.p.toppager = "#" + a.p.toppager; b(g.topDiv).insertBefore(g.hDiv).addClass("ui-state-default ui-jqgrid-toppager").width(g.width); t(a.p.toppager, "_t")}if (a.p.footerrow){g.sDiv = - b("
")[0]; H = b("
"); b(g.sDiv).append(H).insertAfter(g.hDiv).width(g.width); b(H).append(ua); g.footers = b(".ui-jqgrid-ftable", g.sDiv)[0].rows[0].cells; if (a.p.rownumbers)g.footers[0].className = "ui-state-default jqgrid-rownum"; T && b(g.sDiv).hide()}if (a.p.caption){var Ea = a.p.datatype; if (a.p.hidegrid === true){b(".ui-jqgrid-titlebar-close", g.cDiv).click(function(c){var d = b.isFunction(a.p.onHeaderClick); if (a.p.gridstate == - "visible"){b(".ui-jqgrid-bdiv, .ui-jqgrid-hdiv", "#gview_" + a.p.id).slideUp("fast"); a.p.pager && b(a.p.pager).slideUp("fast"); a.p.toppager && b(a.p.toppager).slideUp("fast"); if (a.p.toolbar[0] === true){a.p.toolbar[1] == "both" && b(g.ubDiv).slideUp("fast"); b(g.uDiv).slideUp("fast")}a.p.footerrow && b(".ui-jqgrid-sdiv", "#gbox_" + a.p.id).slideUp("fast"); b("span", this).removeClass("ui-icon-circle-triangle-n").addClass("ui-icon-circle-triangle-s"); a.p.gridstate = "hidden"; b("#gbox_" + a.p.id).hasClass("ui-resizable") && - b(".ui-resizable-handle", "#gbox_" + a.p.id).hide(); if (d)T || a.p.onHeaderClick.call(a, a.p.gridstate, c)} else if (a.p.gridstate == "hidden"){b(".ui-jqgrid-hdiv, .ui-jqgrid-bdiv", "#gview_" + a.p.id).slideDown("fast"); a.p.pager && b(a.p.pager).slideDown("fast"); a.p.toppager && b(a.p.toppager).slideDown("fast"); if (a.p.toolbar[0] === true){a.p.toolbar[1] == "both" && b(g.ubDiv).slideDown("fast"); b(g.uDiv).slideDown("fast")}a.p.footerrow && b(".ui-jqgrid-sdiv", "#gbox_" + a.p.id).slideDown("fast"); b("span", this).removeClass("ui-icon-circle-triangle-s").addClass("ui-icon-circle-triangle-n"); - if (T){a.p.datatype = Ea; Y(); T = false}a.p.gridstate = "visible"; b("#gbox_" + a.p.id).hasClass("ui-resizable") && b(".ui-resizable-handle", "#gbox_" + a.p.id).show(); d && a.p.onHeaderClick.call(a, a.p.gridstate, c)}return false}); if (T){a.p.datatype = "local"; b(".ui-jqgrid-titlebar-close", g.cDiv).trigger("click")}}} else b(g.cDiv).hide(); b(g.hDiv).after(g.bDiv).mousemove(function(c){if (g.resizing){g.dragMove(c); return false}}); b(".ui-jqgrid-labels", g.hDiv).bind("selectstart", function(){return false}); b(document).mouseup(function(){if (g.resizing){g.dragEnd(); - return false}return true}); this.updateColumns = function(){var c = this.rows[0], d = this; if (c){b("td", c).each(function(e){b(this).css("width", d.grid.headers[e].width + "px")}); this.grid.cols = c.cells}return this}; a.formatCol = F; a.sortData = xa; a.updatepager = na; a.formatter = function(c, d, e, l, n){return M(c, d, e, l, n)}; b.extend(g, {populate:Y, emptyRows:aa}); this.grid = g; a.addXmlData = function(c){ia(c, a.grid.bDiv)}; a.addJSONData = function(c){ra(c, a.grid.bDiv)}; Y(); a.p.hiddengrid = false; b(window).unload(function(){a = null})}}})}; - b.jgrid.extend({getGridParam:function(f){var k = this[0]; if (k.grid)return f?typeof k.p[f] != "undefined"?k.p[f]:null:k.p}, setGridParam:function(f){return this.each(function(){this.grid && typeof f === "object" && b.extend(true, this.p, f)})}, getDataIDs:function(){var f = [], k = 0, i; this.each(function(){if ((i = this.rows.length) && i > 0)for (; k < i; ){f[k] = this.rows[k].id; k++}}); return f}, setSelection:function(f, k){return this.each(function(){function i(a){var q = b(h.grid.bDiv)[0].clientHeight, t = b(h.grid.bDiv)[0].scrollTop, - x = h.rows[a].offsetTop; a = h.rows[a].clientHeight; if (x + a >= q + t)b(h.grid.bDiv)[0].scrollTop = x - (q + t) + a + t; else if (x < q + t)if (x < t)b(h.grid.bDiv)[0].scrollTop = x}var h = this, g, j, m; if (f !== undefined){k = k === false?false:true; if (j = h.rows.namedItem(f + "")){if (h.p.scrollrows === true){g = h.rows.namedItem(f).rowIndex; g >= 0 && i(g)}if (h.p.multiselect){h.p.selrow = j.id; m = b.inArray(h.p.selrow, h.p.selarrrow); if (m === - 1){j.className !== "ui-subgrid" && b(j).addClass("ui-state-highlight").attr("aria-selected", "true"); g = true; b("#jqg_" + b.jgrid.jqID(h.p.selrow), - h.rows[j.rowIndex]).attr("checked", g); h.p.selarrrow.push(h.p.selrow); h.p.onSelectRow && k && h.p.onSelectRow.call(h, h.p.selrow, g)} else{j.className !== "ui-subgrid" && b(j).removeClass("ui-state-highlight").attr("aria-selected", "false"); g = false; b("#jqg_" + b.jgrid.jqID(h.p.selrow), h.rows[j.rowIndex]).attr("checked", g); h.p.selarrrow.splice(m, 1); h.p.onSelectRow && k && h.p.onSelectRow.call(h, h.p.selrow, g); j = h.p.selarrrow[0]; h.p.selrow = j === undefined?null:j}} else if (j.className !== "ui-subgrid"){h.p.selrow && b(h.rows.namedItem(h.p.selrow)).removeClass("ui-state-highlight").attr("aria-selected", - "false"); h.p.selrow = j.id; b(j).addClass("ui-state-highlight").attr("aria-selected", "true"); h.p.onSelectRow && k && h.p.onSelectRow.call(h, h.p.selrow, true)}}}})}, resetSelection:function(){return this.each(function(){var f = this, k; if (f.p.multiselect){b(f.p.selarrrow).each(function(i, h){k = f.rows.namedItem(h); b(k).removeClass("ui-state-highlight").attr("aria-selected", "false"); b("#jqg_" + b.jgrid.jqID(h), k).attr("checked", false)}); b("#cb_" + b.jgrid.jqID(f.p.id), f.grid.hDiv).attr("checked", false); f.p.selarrrow = - []} else if (f.p.selrow){b("tr#" + b.jgrid.jqID(f.p.selrow), f.grid.bDiv).removeClass("ui-state-highlight").attr("aria-selected", "false"); f.p.selrow = null}f.p.savedRow = []})}, getRowData:function(f){var k = {}, i, h = false, g, j = 0; this.each(function(){var m = this, a, q; if (typeof f == "undefined"){h = true; i = []; g = m.rows.length} else{q = m.rows.namedItem(f); if (!q)return k; g = 1}for (; j < g; ){if (h)q = m.rows[j]; b("td", q).each(function(t){a = m.p.colModel[t].name; if (a !== "cb" && a !== "subgrid")if (m.p.treeGrid === true && a == m.p.ExpandColumn)k[a] = - b.jgrid.htmlDecode(b("span:first", this).html()); else try{k[a] = b.unformat(this, {rowId:q.id, colModel:m.p.colModel[t]}, t)} catch (x){k[a] = b.jgrid.htmlDecode(b(this).html())}}); j++; if (h){i.push(k); k = {}}}}); return i?i:k}, delRowData:function(f){var k = false, i, h, g; this.each(function(){var j = this; if (i = j.rows.namedItem(f)){g = i.rowIndex; b(i).remove(); j.p.records--; j.p.reccount--; j.updatepager(true, false); k = true; if (j.p.multiselect){h = b.inArray(f, j.p.selarrrow); h != - 1 && j.p.selarrrow.splice(h, 1)}if (f == j.p.selrow)j.p.selrow = - null} else return false; g === 0 && k && j.updateColumns(); if (j.p.altRows === true && k){var m = j.p.altclass; b(j.rows).each(function(a){a % 2 == 1?b(this).addClass(m):b(this).removeClass(m)})}}); return k}, setRowData:function(f, k, i){var h, g = false, j; this.each(function(){var m = this, a, q, t = typeof i; if (!m.grid)return false; q = m.rows.namedItem(f); if (!q)return false; k && b(this.p.colModel).each(function(x){h = this.name; if (k[h] !== undefined){a = m.formatter(f, k[h], x, k, "edit"); j = this.title?{title:b.jgrid.stripHtml(a)}:{}; m.p.treeGrid === - true && h == m.p.ExpandColumn?b("td:eq(" + x + ") > span:first", q).html(a).attr(j):b("td:eq(" + x + ")", q).html(a).attr(j); g = true}}); if (t === "string")b(q).addClass(i); else t === "object" && b(q).css(i)}); return g}, addRowData:function(f, k, i, h){i || (i = "last"); var g = false, j, m, a, q, t, x, C, K, J = "", F, Q, M, R; if (k){if (b.isArray(k)){F = true; i = "last"; Q = f} else{k = [k]; F = false}this.each(function(){var u = this, la = k.length; t = u.p.rownumbers === true?1:0; a = u.p.multiselect === true?1:0; q = u.p.subGrid === true?1:0; if (!F)if (typeof f != "undefined")f += - ""; else{f = u.p.records + 1 + ""; if (u.p.keyIndex !== false){Q = u.p.colModel[u.p.keyIndex + a + q + t].name; if (typeof k[0][Q] != "undefined")f = k[0][Q]}}M = u.p.altclass; for (var ca = 0, fa = "", aa = b.isFunction(u.p.afterInsertRow)?true:false; ca < la; ){R = k[ca]; m = ""; if (F){try{f = R[Q]} catch (U){f = u.p.records + 1}fa = u.p.altRows === true?(u.rows.length - 1) % 2 === 0?M:"":""}if (t){J = u.formatCol(t, 1, ""); m += '0"}if (a){K = ''; J = u.formatCol(t, 1, ""); m += '" + K + ""}if (q)m += b(u).jqGrid("addSubGridCell", a + t, 1); for (C = a + q + t; C < this.p.colModel.length; C++){j = this.p.colModel[C].name; K = u.formatter(f, R[j], C, R, "add"); J = u.formatCol(C, 1, K); m += '" + K + ""}m = '' + m + ""; if (u.p.subGrid === true){m = b(m)[0]; b(u).jqGrid("addSubGrid", - m, a + t)}if (u.rows.length === 0)b("table:first", u.grid.bDiv).append(m); else switch (i){case "last":b(u.rows[u.rows.length - 1]).after(m); break; case "first":b(u.rows[0]).before(m); break; case "after":if (x = u.rows.namedItem(h))b(u.rows[x.rowIndex + 1]).hasClass("ui-subgrid")?b(u.rows[x.rowIndex + 1]).after(m):b(x).after(m); break; case "before":if (x = u.rows.namedItem(h)){b(x).before(m); x = x.rowIndex}break}u.p.records++; u.p.reccount++; if (!u.grid.cols || !u.grid.cols.length)u.grid.cols = u.rows[0].cells; if (i === "first" || i === - "before" && x <= 1 || u.rows.length === 1)u.updateColumns(); aa && u.p.afterInsertRow.call(u, f, R, R); ca++}if (u.p.altRows === true && !F)if (i == "last")(u.rows.length - 1) % 2 == 1 && b(u.rows[u.rows.length - 1]).addClass(M); else b(u.rows).each(function(ia){ia % 2 == 1?b(this).addClass(M):b(this).removeClass(M)}); u.updatepager(true, true); g = true})}return g}, footerData:function(f, k, i){function h(q){for (var t in q)if (q.hasOwnProperty(t))return false; return true}var g, j = false, m = {}, a; if (typeof f == "undefined")f = "get"; if (typeof i != "boolean")i = - true; f = f.toLowerCase(); this.each(function(){var q = this, t; if (!q.grid || !q.p.footerrow)return false; if (f == "set")if (h(k))return false; j = true; b(this.p.colModel).each(function(x){g = this.name; if (f == "set"){if (k[g] !== undefined){t = i?q.formatter("", k[g], x, k, "edit"):k[g]; a = this.title?{title:b.jgrid.stripHtml(t)}:{}; b("tr.footrow td:eq(" + x + ")", q.grid.sDiv).html(t).attr(a); j = true}} else if (f == "get")m[g] = b("tr.footrow td:eq(" + x + ")", q.grid.sDiv).html()})}); return f == "get"?m:j}, ShowHideCol:function(f, k){return this.each(function(){var i = - this, h = false; if (i.grid){if (typeof f === "string")f = [f]; k = k != "none"?"":"none"; var g = k == ""?true:false; b(this.p.colModel).each(function(j){if (b.inArray(this.name, f) !== - 1 && this.hidden === g){b("tr", i.grid.hDiv).each(function(){b("th:eq(" + j + ")", this).css("display", k)}); b(i.rows).each(function(m){b("td:eq(" + j + ")", i.rows[m]).css("display", k)}); i.p.footerrow && b("td:eq(" + j + ")", i.grid.sDiv).css("display", k); if (k == "none")i.p.tblwidth -= this.width; else i.p.tblwidth += this.width; this.hidden = !g; h = true}}); if (h === true){b("table:first", - i.grid.hDiv).width(i.p.tblwidth); b("table:first", i.grid.bDiv).width(i.p.tblwidth); i.grid.hDiv.scrollLeft = i.grid.bDiv.scrollLeft; if (i.p.footerrow){b("table:first", i.grid.sDiv).width(i.p.tblwidth); i.grid.sDiv.scrollLeft = i.grid.bDiv.scrollLeft}}}})}, hideCol:function(f){return this.each(function(){b(this).jqGrid("ShowHideCol", f, "none")})}, showCol:function(f){return this.each(function(){b(this).jqGrid("ShowHideCol", f, "")})}, remapColumns:function(f, k, i){function h(m){var a; a = m.length?b.makeArray(m):b.extend({}, - m); b.each(f, function(q){m[q] = a[this]})}function g(m, a){b(">tr" + (a || ""), m).each(function(){var q = this, t = b.makeArray(q.cells); b.each(f, function(){var x = t[this]; x && q.appendChild(x)})})}var j = this.get(0); h(j.p.colModel); h(j.p.colNames); h(j.grid.headers); g(b("thead:first", j.grid.hDiv), i && ":not(.ui-jqgrid-labels)"); k && g(b("tbody:first", j.grid.bDiv), ".jqgrow"); j.p.footerrow && g(b("tbody:first", j.grid.sDiv)); if (j.p.remapColumns)if (j.p.remapColumns.length)h(j.p.remapColumns); else j.p.remapColumns = b.makeArray(f); - j.p.lastsort = b.inArray(j.p.lastsort, f); if (j.p.treeGrid)j.p.expColInd = b.inArray(j.p.expColInd, f)}, setGridWidth:function(f, k){return this.each(function(){var i = this, h, g = 0, j = i.p.cellLayout, m, a = 0, q = false, t = i.p.scrollOffset, x, C = 0, K = 0, J = 0, F; if (i.grid){if (typeof k != "boolean")k = i.p.shrinkToFit; if (!isNaN(f)){f = parseInt(f, 10); i.grid.width = i.p.width = f; b("#gbox_" + i.p.id).css("width", f + "px"); b("#gview_" + i.p.id).css("width", f + "px"); b(i.grid.bDiv).css("width", f + "px"); b(i.grid.hDiv).css("width", f + "px"); i.p.pager && - b(i.p.pager).css("width", f + "px"); i.p.toppager && b(i.p.toppager).css("width", f + "px"); if (i.p.toolbar[0] === true){b(i.grid.uDiv).css("width", f + "px"); i.p.toolbar[1] == "both" && b(i.grid.ubDiv).css("width", f + "px")}i.p.footerrow && b(i.grid.sDiv).css("width", f + "px"); if (k === false && i.p.forceFit === true)i.p.forceFit = false; if (k === true){if (b.browser.safari)j = 0; b.each(i.p.colModel, function(){if (this.hidden === false){g += parseInt(this.width, 10); if (this.fixed){K += this.width; C += this.width + j} else a++; J++}}); if (a !== 0){i.p.tblwidth = - g; x = f - j * a - C; if (!isNaN(i.p.height))q = true; x -= t; g = 0; var Q = i.grid.cols.length > 0; b.each(i.p.colModel, function(M){if (this.hidden === false && !this.fixed){h = Math.round(x * this.width / (i.p.tblwidth - K)); if (!(h < 0)){this.width = h; g += h; i.grid.headers[M].width = h; i.grid.headers[M].el.style.width = h + "px"; if (i.p.footerrow)i.grid.footers[M].style.width = h + "px"; if (Q)i.grid.cols[M].style.width = h + "px"; m = M}}}); F = 0; if (q){if (f - C - (g + j * a) !== t)F = f - C - (g + j * a) - t} else if (Math.abs(f - - C - (g + j * a)) !== 1)F = f - C - (g + j * a); i.p.colModel[m].width += F; i.p.tblwidth = g + F + K + j * J; if (i.p.tblwidth > f){q = i.p.tblwidth - parseInt(f, 10); i.p.tblwidth = f; h = i.p.colModel[m].width -= q} else h = i.p.colModel[m].width; i.grid.headers[m].width = h; i.grid.headers[m].el.style.width = h + "px"; if (Q)i.grid.cols[m].style.width = h + "px"; b("table:first", i.grid.bDiv).css("width", i.p.tblwidth + "px"); b("table:first", i.grid.hDiv).css("width", i.p.tblwidth + "px"); i.grid.hDiv.scrollLeft = i.grid.bDiv.scrollLeft; if (i.p.footerrow){i.grid.footers[m].style.width = - h + "px"; b("table:first", i.grid.sDiv).css("width", i.p.tblwidth + "px")}}}}}})}, setGridHeight:function(f){return this.each(function(){var k = this; if (k.grid){b(k.grid.bDiv).css({height:f + (isNaN(f)?"":"px")}); k.p.height = f; k.p.scroll && k.grid.populateVisible()}})}, setCaption:function(f){return this.each(function(){this.p.caption = f; b("span.ui-jqgrid-title", this.grid.cDiv).html(f); b(this.grid.cDiv).show()})}, setLabel:function(f, k, i, h){return this.each(function(){var g = this, j = - 1; if (g.grid){if (isNaN(f))b(g.p.colModel).each(function(q){if (this.name == - f){j = q; return false}}); else j = parseInt(f, 10); if (j >= 0){var m = b("tr.ui-jqgrid-labels th:eq(" + j + ")", g.grid.hDiv); if (k){var a = b(".s-ico", m); b("[id^=jqgh_]", m).empty().html(k).append(a); g.p.colNames[j] = k}if (i)typeof i === "string"?b(m).addClass(i):b(m).css(i); typeof h === "object" && b(m).attr(h)}}})}, setCell:function(f, k, i, h, g, j){return this.each(function(){var m = this, a = - 1, q, t; if (m.grid){if (isNaN(k))b(m.p.colModel).each(function(C){if (this.name == k){a = C; return false}}); else a = parseInt(k, 10); if (a >= 0)if (q = m.rows.namedItem(f)){var x = - b("td:eq(" + a + ")", q); if (i !== "" || j === true){q = m.formatter(f, i, a, q, "edit"); t = m.p.colModel[a].title?{title:b.jgrid.stripHtml(q)}:{}; m.p.treeGrid && b(".tree-wrap", b(x)).length > 0?b("span", b(x)).html(q).attr(t):b(x).html(q).attr(t)}if (typeof h === "string")b(x).addClass(h); else h && b(x).css(h); typeof g === "object" && b(x).attr(g)}}})}, getCell:function(f, k){var i = false; this.each(function(){var h = this, g = - 1; if (h.grid){if (isNaN(k))b(h.p.colModel).each(function(a){if (this.name === k){g = a; return false}}); else g = parseInt(k, - 10); if (g >= 0){var j = h.rows.namedItem(f); if (j)try{i = b.unformat(b("td:eq(" + g + ")", j), {rowId:j.id, colModel:h.p.colModel[g]}, g)} catch (m){i = b.jgrid.htmlDecode(b("td:eq(" + g + ")", j).html())}}}}); return i}, getCol:function(f, k, i){var h = [], g, j = 0; k = typeof k != "boolean"?false:k; if (typeof i == "undefined")i = false; this.each(function(){var m = this, a = - 1; if (m.grid){if (isNaN(f))b(m.p.colModel).each(function(C){if (this.name === f){a = C; return false}}); else a = parseInt(f, 10); if (a >= 0){var q = m.rows.length, t = 0; if (q && q > 0){for (; t < q; ){try{g = - b.unformat(b(m.rows[t].cells[a]), {rowId:m.rows[t].id, colModel:m.p.colModel[a]}, a)} catch (x){g = b.jgrid.htmlDecode(m.rows[t].cells[a].innerHTML)}if (i)j += parseFloat(g); else if (k)h.push({id:m.rows[t].id, value:g}); else h[t] = g; t++}if (i)switch (i.toLowerCase()){case "sum":h = j; break; case "avg":h = j / q; break; case "count":h = q; break}}}}}); return h}, clearGridData:function(f){return this.each(function(){var k = this; if (k.grid){if (typeof f != "boolean")f = false; b("tbody:first tr", k.grid.bDiv).remove(); k.p.footerrow && f && - b(".ui-jqgrid-ftable td", k.grid.sDiv).html(" "); k.p.selrow = null; k.p.selarrrow = []; k.p.savedRow = []; k.p.records = 0; k.p.page = "0"; k.p.lastpage = "0"; k.p.reccount = 0; k.updatepager(true, false)}})}, getInd:function(f, k){var i = false, h; this.each(function(){if (h = this.rows.namedItem(f))i = k === true?h:h.rowIndex}); return i}})})(jQuery); - (function(c){function u(a, b, d, e, g){var h = b; if (c.fn.fmatter[a])h = c.fn.fmatter[a](b, d, e, g); return h}c.fmatter = {}; c.fn.fmatter = function(a, b, d, e, g){d = c.extend({}, c.jgrid.formatter, d); return u(a, b, d, e, g)}; c.fmatter.util = {NumberFormat:function(a, b){isNumber(a) || (a *= 1); if (isNumber(a)){var d = a < 0, e = a + "", g = b.decimalSeparator?b.decimalSeparator:"."; if (isNumber(b.decimalPlaces)){var h = b.decimalPlaces; e = Math.pow(10, h); e = Math.round(a * e) / e + ""; a = e.lastIndexOf("."); if (h > 0){if (a < 0){e += g; a = e.length - 1} else if (g !== ".")e = - e.replace(".", g); for (; e.length - 1 - a < h; )e += "0"}}if (b.thousandsSeparator){h = b.thousandsSeparator; a = e.lastIndexOf(g); a = a > - 1?a:e.length; g = e.substring(a); for (var f = - 1, i = a; i > 0; i--){f++; if (f % 3 === 0 && i !== a && (!d || i > 1))g = h + g; g = e.charAt(i - 1) + g}e = g}e = b.prefix?b.prefix + e:e; return e = b.suffix?e + b.suffix:e} else return a}, DateFormat:function(a, b, d, e){var g = function(m, r){m = String(m); for (r = parseInt(r, 10) || 2; m.length < r; )m = "0" + m; return m}, h = {m:1, d:1, y:1970, h:0, i:0, s:0, u:0}, f = 0, i, k, j = ["i18n"]; j.i18n = {dayNames:e.dayNames, - monthNames:e.monthNames}; if (a in e.masks)a = e.masks[a]; if (b.constructor === Date)f = b; else{b = b.split(/[\\\/:_;.\t\T\s-]/); a = a.split(/[\\\/:_;.\t\T\s-]/); i = 0; for (k = a.length; i < k; i++){if (a[i] == "M"){f = c.inArray(b[i], j.i18n.monthNames); if (f !== - 1 && f < 12)b[i] = f + 1}if (a[i] == "F"){f = c.inArray(b[i], j.i18n.monthNames); if (f !== - 1 && f > 11)b[i] = f + 1 - 12}h[a[i].toLowerCase()] = parseInt(b[i], 10)}h.m = parseInt(h.m, 10) - 1; f = h.y; if (f >= 70 && f <= 99)h.y = 1900 + h.y; else if (f >= 0 && f <= 69)h.y = 2E3 + h.y; f = new Date(h.y, h.m, h.d, h.h, h.i, h.s, h.u)}if (d in - e.masks)d = e.masks[d]; else d || (d = "Y-m-d"); h = f.getHours(); a = f.getMinutes(); b = f.getDate(); i = f.getMonth() + 1; k = f.getTimezoneOffset(); var l = f.getSeconds(), o = f.getMilliseconds(), n = f.getDay(), p = f.getFullYear(), q = (n + 6) % 7 + 1, s = (new Date(p, i - 1, b) - new Date(p, 0, 1)) / 864E5, t = {d:g(b), D:j.i18n.dayNames[n], j:b, l:j.i18n.dayNames[n + 7], N:q, S:e.S(b), w:n, z:s, W:q < 5?Math.floor((s + q - 1) / 7) + 1:Math.floor((s + q - 1) / 7) || (((new Date(p - 1, 0, 1)).getDay() + 6) % 7 < 4?53:52), F:j.i18n.monthNames[i - 1 + 12], m:g(i), M:j.i18n.monthNames[i - 1], n:i, t:"?", - L:"?", o:"?", Y:p, y:String(p).substring(2), a:h < 12?e.AmPm[0]:e.AmPm[1], A:h < 12?e.AmPm[2]:e.AmPm[3], B:"?", g:h % 12 || 12, G:h, h:g(h % 12 || 12), H:g(h), i:g(a), s:g(l), u:o, e:"?", I:"?", O:(k > 0?"-":"+") + g(Math.floor(Math.abs(k) / 60) * 100 + Math.abs(k) % 60, 4), P:"?", T:(String(f).match(/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g) || [""]).pop().replace(/[^-+\dA-Z]/g, ""), Z:"?", c:"?", r:"?", U:Math.floor(f / 1E3)}; return d.replace(/\\.|[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]/g, - function(m){return m in t?t[m]:m.substring(1)})}}; c.fn.fmatter.defaultFormat = function(a, b){return isValue(a) && a !== ""?a:b.defaultValue?b.defaultValue:" "}; c.fn.fmatter.email = function(a, b){return isEmpty(a)?c.fn.fmatter.defaultFormat(a, b):'
' + a + ""}; c.fn.fmatter.checkbox = function(a, b){var d = c.extend({}, b.checkbox); isUndefined(b.colModel.formatoptions) || (d = c.extend({}, d, b.colModel.formatoptions)); b = d.disabled === true?"disabled":""; if (isEmpty(a) || isUndefined(a))a = c.fn.fmatter.defaultFormat(a, - d); a += ""; a = a.toLowerCase(); return'"}; c.fn.fmatter.link = function(a, b){var d = {target:b.target}, e = ""; isUndefined(b.colModel.formatoptions) || (d = c.extend({}, d, b.colModel.formatoptions)); if (d.target)e = "target=" + d.target; return isEmpty(a)?c.fn.fmatter.defaultFormat(a, b):"' + a + ""}; c.fn.fmatter.showlink = function(a, b){var d = {baseLinkUrl:b.baseLinkUrl, showAction:b.showAction, - addParam:b.addParam || "", target:b.target, idName:b.idName}, e = ""; isUndefined(b.colModel.formatoptions) || (d = c.extend({}, d, b.colModel.formatoptions)); if (d.target)e = "target=" + d.target; d = d.baseLinkUrl + d.showAction + "?" + d.idName + "=" + b.rowId + d.addParam; return isString(a)?"' + a + "":c.fn.fmatter.defaultFormat(a, b)}; c.fn.fmatter.integer = function(a, b){var d = c.extend({}, b.integer); isUndefined(b.colModel.formatoptions) || (d = c.extend({}, d, b.colModel.formatoptions)); if (isEmpty(a))return d.defaultValue; - return c.fmatter.util.NumberFormat(a, d)}; c.fn.fmatter.number = function(a, b){var d = c.extend({}, b.number); isUndefined(b.colModel.formatoptions) || (d = c.extend({}, d, b.colModel.formatoptions)); if (isEmpty(a))return d.defaultValue; return c.fmatter.util.NumberFormat(a, d)}; c.fn.fmatter.currency = function(a, b){var d = c.extend({}, b.currency); isUndefined(b.colModel.formatoptions) || (d = c.extend({}, d, b.colModel.formatoptions)); if (isEmpty(a))return d.defaultValue; return c.fmatter.util.NumberFormat(a, d)}; c.fn.fmatter.date = - function(a, b, d, e){d = c.extend({}, b.date); isUndefined(b.colModel.formatoptions) || (d = c.extend({}, d, b.colModel.formatoptions)); return!d.reformatAfterEdit && e == "edit"?c.fn.fmatter.defaultFormat(a, b):isEmpty(a)?c.fn.fmatter.defaultFormat(a, b):c.fmatter.util.DateFormat(d.srcformat, a, d.newformat, d)}; c.fn.fmatter.select = function(a, b){a += ""; var d = false, e = []; if (!isUndefined(b.colModel.editoptions))d = b.colModel.editoptions.value; if (d){var g = b.colModel.editoptions.multiple === true?true:false, h = [], f; if (g){h = a.split(","); - h = c.map(h, function(l){return c.trim(l)})}if (isString(d))for (var i = d.split(";"), k = 0, j = 0; j < i.length; j++){f = i[j].split(":"); if (f.length > 2)f[1] = jQuery.map(f, function(l, o){if (o > 0)return l}).join(":"); if (g){if (jQuery.inArray(f[0], h) > - 1){e[k] = f[1]; k++}} else if (c.trim(f[0]) == c.trim(a)){e[0] = f[1]; break}} else if (isObject(d))if (g)e = jQuery.map(h, function(l){return d[l]}); else e[0] = d[a] || ""}a = e.join(", "); return a == ""?c.fn.fmatter.defaultFormat(a, b):a}; c.fn.fmatter.rowactions = function(a, b, d, e){switch (d){case "edit":d = - function(){c("tr#" + a + " div.ui-inline-edit, tr#" + a + " div.ui-inline-del", "#" + b).show(); c("tr#" + a + " div.ui-inline-save, tr#" + a + " div.ui-inline-cancel", "#" + b).hide()}; c("#" + b).jqGrid("editRow", a, e, null, null, null, {oper:"edit"}, d, null, d); c("tr#" + a + " div.ui-inline-edit, tr#" + a + " div.ui-inline-del", "#" + b).hide(); c("tr#" + a + " div.ui-inline-save, tr#" + a + " div.ui-inline-cancel", "#" + b).show(); break; case "save":c("#" + b).jqGrid("saveRow", a, null, null); c("tr#" + a + " div.ui-inline-edit, tr#" + a + " div.ui-inline-del", "#" + - b).show(); c("tr#" + a + " div.ui-inline-save, tr#" + a + " div.ui-inline-cancel", "#" + b).hide(); break; case "cancel":c("#" + b).jqGrid("restoreRow", a); c("tr#" + a + " div.ui-inline-edit, tr#" + a + " div.ui-inline-del", "#" + b).show(); c("tr#" + a + " div.ui-inline-save, tr#" + a + " div.ui-inline-cancel", "#" + b).hide(); break}}; c.fn.fmatter.actions = function(a, b){a = {keys:false, editbutton:true, delbutton:true}; isUndefined(b.colModel.formatoptions) || (a = c.extend(a, b.colModel.formatoptions)); var d = b.rowId, e = "", g; if (typeof d == "undefined" || - isEmpty(d))return""; if (a.editbutton){g = "onclick=$.fn.fmatter.rowactions('" + d + "','" + b.gid + "','edit'," + a.keys + ");"; e = e + "
"}if (a.delbutton){g = "onclick=jQuery('#" + b.gid + "').jqGrid('delGridRow','" + d + "');"; e = e + "
"}g = "onclick=$.fn.fmatter.rowactions('" + d + "','" + b.gid + "','save',false);"; e = e + ""; g = "onclick=$.fn.fmatter.rowactions('" + d + "','" + b.gid + "','cancel',false);"; return e = e + "
"}; c.unformat = function(a, b, d, e){var g, h = b.colModel.formatter, f = b.colModel.formatoptions || {}, i = /([\.\*\_\'\(\)\{\}\+\?\\])/g; unformatFunc = b.colModel.unformat || c.fn.fmatter[h] && c.fn.fmatter[h].unformat; if (typeof unformatFunc !== "undefined" && isFunction(unformatFunc))g = unformatFunc(c(a).text(), b, a); else if (typeof h !== "undefined" && isString(h)){g = c.jgrid.formatter || {}; switch (h){case "integer":f = c.extend({}, g.integer, f); b = f.thousandsSeparator.replace(i, "\\$1"); b = new RegExp(b, "g"); g = - c(a).text().replace(b, ""); break; case "number":f = c.extend({}, g.number, f); b = f.thousandsSeparator.replace(i, "\\$1"); b = new RegExp(b, "g"); g = c(a).text().replace(b, "").replace(f.decimalSeparator, "."); break; case "currency":f = c.extend({}, g.currency, f); b = f.thousandsSeparator.replace(i, "\\$1"); b = new RegExp(b, "g"); g = c(a).text().replace(b, "").replace(f.decimalSeparator, ".").replace(f.prefix, "").replace(f.suffix, ""); break; case "checkbox":f = b.colModel.editoptions?b.colModel.editoptions.value.split(":"):["Yes", "No"]; - g = c("input", a).attr("checked")?f[0]:f[1]; break; case "select":g = c.unformat.select(a, b, d, e); break; case "actions":return""; default:g = c(a).text()}}return g?g:e === true?c(a).text():c.jgrid.htmlDecode(c(a).html())}; c.unformat.select = function(a, b, d, e){d = []; a = c(a).text(); if (e === true)return a; b = c.extend({}, b.colModel.editoptions); if (b.value){var g = b.value; b = b.multiple === true?true:false; e = []; var h; if (b){e = a.split(","); e = c.map(e, function(j){return c.trim(j)})}if (isString(g))for (var f = g.split(";"), i = 0, k = 0; k < f.length; k++){h = - f[k].split(":"); if (b){if (jQuery.inArray(h[1], e) > - 1){d[i] = h[0]; i++}} else if (c.trim(h[1]) == c.trim(a)){d[0] = h[0]; break}} else if (isObject(g)){b || (e[0] = a); d = jQuery.map(e, function(j){var l; c.each(g, function(o, n){if (n == j){l = o; return false}}); if (l)return l})}return d.join(", ")} else return a || ""}; isValue = function(a){return isObject(a) || isString(a) || isNumber(a) || isBoolean(a)}; isBoolean = function(a){return typeof a === "boolean"}; isNull = function(a){return a === null}; isNumber = function(a){return typeof a === "number" && - isFinite(a)}; isString = function(a){return typeof a === "string"}; isEmpty = function(a){if (!isString(a) && isValue(a))return false; else if (!isValue(a))return true; a = c.trim(a).replace(/\ \;/ig, "").replace(/\ \;/ig, ""); return a === ""}; isUndefined = function(a){return typeof a === "undefined"}; isObject = function(a){return a && (typeof a === "object" || isFunction(a)) || false}; isFunction = function(a){return typeof a === "function"}})(jQuery); - (function(a){a.jgrid.extend({getColProp:function(g){var d = {}, b = this[0]; if (b.grid){b = b.p.colModel; for (var n = 0; n < b.length; n++)if (b[n].name == g){d = b[n]; break}return d}}, setColProp:function(g, d){return this.each(function(){if (this.grid)if (d)for (var b = this.p.colModel, n = 0; n < b.length; n++)if (b[n].name == g){a.extend(this.p.colModel[n], d); break}})}, sortGrid:function(g, d, b){return this.each(function(){var n = this, s = - 1; if (n.grid){if (!g)g = n.p.sortname; for (var q = 0; q < n.p.colModel.length; q++)if (n.p.colModel[q].index == - g || n.p.colModel[q].name == g){s = q; break}if (s != - 1){q = n.p.colModel[s].sortable; if (typeof q !== "boolean")q = true; if (typeof d !== "boolean")d = false; q && n.sortData("jqgh_" + g, s, d, b)}}})}, GridDestroy:function(){return this.each(function(){if (this.grid){this.p.pager && a(this.p.pager).remove(); var g = this.id; try{a("#gbox_" + g).remove()} catch (d){}}})}, GridUnload:function(){return this.each(function(){if (this.grid){var g = {id:a(this).attr("id"), cl:a(this).attr("class")}; this.p.pager && a(this.p.pager).empty().removeClass("ui-state-default ui-jqgrid-pager corner-bottom"); - var d = document.createElement("table"); a(d).attr({id:g.id}); d.className = g.cl; g = this.id; a(d).removeClass("ui-jqgrid-btable"); if (a(this.p.pager).parents("#gbox_" + g).length === 1){a(d).insertBefore("#gbox_" + g).show(); a(this.p.pager).insertBefore("#gbox_" + g)} else a(d).insertBefore("#gbox_" + g).show(); a("#gbox_" + g).remove()}})}, setGridState:function(g){return this.each(function(){if (this.grid){var d = this; if (g == "hidden"){a(".ui-jqgrid-bdiv, .ui-jqgrid-hdiv", "#gview_" + d.p.id).slideUp("fast"); d.p.pager && a(d.p.pager).slideUp("fast"); - d.p.toppager && a(d.p.toppager).slideUp("fast"); if (d.p.toolbar[0] === true){d.p.toolbar[1] == "both" && a(d.grid.ubDiv).slideUp("fast"); a(d.grid.uDiv).slideUp("fast")}d.p.footerrow && a(".ui-jqgrid-sdiv", "#gbox_" + d.p.id).slideUp("fast"); a(".ui-jqgrid-titlebar-close span", d.grid.cDiv).removeClass("ui-icon-circle-triangle-n").addClass("ui-icon-circle-triangle-s"); d.p.gridstate = "hidden"} else if (g == "visible"){a(".ui-jqgrid-hdiv, .ui-jqgrid-bdiv", "#gview_" + d.p.id).slideDown("fast"); d.p.pager && a(d.p.pager).slideDown("fast"); - d.p.toppager && a(d.p.toppager).slideDown("fast"); if (d.p.toolbar[0] === true){d.p.toolbar[1] == "both" && a(d.grid.ubDiv).slideDown("fast"); a(d.grid.uDiv).slideDown("fast")}d.p.footerrow && a(".ui-jqgrid-sdiv", "#gbox_" + d.p.id).slideDown("fast"); a(".ui-jqgrid-titlebar-close span", d.grid.cDiv).removeClass("ui-icon-circle-triangle-s").addClass("ui-icon-circle-triangle-n"); d.p.gridstate = "visible"}}})}, updateGridRows:function(g, d, b){var n, s = false, q; this.each(function(){var h = this, l, o, c, f; if (!h.grid)return false; - d || (d = "id"); g && g.length > 0 && a(g).each(function(){c = this; if (o = h.rows.namedItem(c[d])){f = c[d]; if (b === true)if (h.p.jsonReader.repeatitems === true){if (h.p.jsonReader.cell)c = c[h.p.jsonReader.cell]; for (var e = 0; e < c.length; e++){l = h.formatter(f, c[e], e, c, "edit"); q = h.p.colModel[e].title?{title:a.jgrid.stripHtml(l)}:{}; h.p.treeGrid === true && n == h.p.ExpandColumn?a("td:eq(" + e + ") > span:first", o).html(l).attr(q):a("td:eq(" + e + ")", o).html(l).attr(q)}return s = true}a(h.p.colModel).each(function(m){n = b === true?this.jsonmap || - this.name:this.name; if (c[n] !== undefined){l = h.formatter(f, c[n], m, c, "edit"); q = this.title?{title:a.jgrid.stripHtml(l)}:{}; h.p.treeGrid === true && n == h.p.ExpandColumn?a("td:eq(" + m + ") > span:first", o).html(l).attr(q):a("td:eq(" + m + ")", o).html(l).attr(q); s = true}})}})}); return s}, filterGrid:function(g, d){d = a.extend({gridModel:false, gridNames:false, gridToolbar:false, filterModel:[], formtype:"horizontal", autosearch:true, formclass:"filterform", tableclass:"filtertable", buttonclass:"filterbutton", searchButton:"Search", - clearButton:"Clear", enableSearch:false, enableClear:false, beforeSearch:null, afterSearch:null, beforeClear:null, afterClear:null, url:"", marksearched:true}, d || {}); return this.each(function(){var b = this; this.p = d; if (this.p.filterModel.length === 0 && this.p.gridModel === false)alert("No filter is set"); else if (g){this.p.gridid = g.indexOf("#") != - 1?g:"#" + g; var n = a(this.p.gridid).jqGrid("getGridParam", "colModel"); if (n){if (this.p.gridModel === true){var s = a(this.p.gridid)[0], q; a.each(n, function(f){var e = []; this.search = - this.search === false?false:true; q = this.editrules && this.editrules.searchhidden === true?true:this.hidden === true?false:true; if (this.search === true && q === true){e.label = b.p.gridNames === true?s.p.colNames[f]:""; e.name = this.name; e.index = this.index || this.name; e.stype = this.edittype || "text"; if (e.stype != "select")e.stype = "text"; e.defval = this.defval || ""; e.surl = this.surl || ""; e.sopt = this.editoptions || {}; e.width = this.width; b.p.filterModel.push(e)}})} else a.each(b.p.filterModel, function(){for (var f = 0; f < n.length; f++)if (this.name == - n[f].name){this.index = n[f].index || this.name; break}if (!this.index)this.index = this.name}); var h = function(){var f = {}, e = 0, m, i = a(b.p.gridid)[0], k; i.p.searchdata = {}; a.isFunction(b.p.beforeSearch) && b.p.beforeSearch(); a.each(b.p.filterModel, function(){k = this.index; switch (this.stype){case "select":if (m = a("select[name=" + k + "]", b).val()){f[k] = m; b.p.marksearched && a("#jqgh_" + this.name, i.grid.hDiv).addClass("dirty-cell"); e++} else{b.p.marksearched && a("#jqgh_" + this.name, i.grid.hDiv).removeClass("dirty-cell"); try{delete i.p.postData[this.index]} catch (r){}}break; - default:if (m = a("input[name=" + k + "]", b).val()){f[k] = m; b.p.marksearched && a("#jqgh_" + this.name, i.grid.hDiv).addClass("dirty-cell"); e++} else{b.p.marksearched && a("#jqgh_" + this.name, i.grid.hDiv).removeClass("dirty-cell"); try{delete i.p.postData[this.index]} catch (u){}}}}); var p = e > 0?true:false; a.extend(i.p.postData, f); var j; if (b.p.url){j = a(i).jqGrid("getGridParam", "url"); a(i).jqGrid("setGridParam", {url:b.p.url})}a(i).jqGrid("setGridParam", {search:p}).trigger("reloadGrid", [{page:1}]); j && a(i).jqGrid("setGridParam", - {url:j}); a.isFunction(b.p.afterSearch) && b.p.afterSearch()}, l = function(){var f = {}, e, m = 0, i = a(b.p.gridid)[0], k; a.isFunction(b.p.beforeClear) && b.p.beforeClear(); a.each(b.p.filterModel, function(){k = this.index; e = this.defval?this.defval:""; if (!this.stype)this.stype = "text"; switch (this.stype){case "select":var r; a("select[name=" + k + "] option", b).each(function(v){if (v === 0)this.selected = true; if (a(this).text() == e){this.selected = true; r = a(this).val(); return false}}); if (r){f[k] = r; b.p.marksearched && a("#jqgh_" + this.name, - i.grid.hDiv).addClass("dirty-cell"); m++} else{b.p.marksearched && a("#jqgh_" + this.name, i.grid.hDiv).removeClass("dirty-cell"); try{delete i.p.postData[this.index]} catch (u){}}break; case "text":a("input[name=" + k + "]", b).val(e); if (e){f[k] = e; b.p.marksearched && a("#jqgh_" + this.name, i.grid.hDiv).addClass("dirty-cell"); m++} else{b.p.marksearched && a("#jqgh_" + this.name, i.grid.hDiv).removeClass("dirty-cell"); try{delete i.p.postData[this.index]} catch (t){}}break}}); var p = m > 0?true:false; a.extend(i.p.postData, f); var j; - if (b.p.url){j = a(i).jqGrid("getGridParam", "url"); a(i).jqGrid("setGridParam", {url:b.p.url})}a(i).jqGrid("setGridParam", {search:p}).trigger("reloadGrid", [{page:1}]); j && a(i).jqGrid("setGridParam", {url:j}); a.isFunction(b.p.afterClear) && b.p.afterClear()}, o = a("
"), c = a("
"); a(o).append(c); (function(){var f = document.createElement("tr"), - e, m, i, k; b.p.formtype == "horizontal" && a(c).append(f); a.each(b.p.filterModel, function(p){i = document.createElement("td"); a(i).append(""); k = document.createElement("td"); var j = this; if (!this.stype)this.stype = "text"; switch (this.stype){case "select":if (this.surl)a(k).load(this.surl, function(){j.defval && a("select", this).val(j.defval); a("select", this).attr({name:j.index || j.name, id:"sg_" + j.name}); j.sopt && a("select", this).attr(j.sopt); b.p.gridToolbar === true && j.width && - a("select", this).width(j.width); b.p.autosearch === true && a("select", this).change(function(){h(); return false})}); else if (j.sopt.value){var r = j.sopt.value, u = document.createElement("select"); a(u).attr({name:j.index || j.name, id:"sg_" + j.name}).attr(j.sopt); var t; if (typeof r === "string"){p = r.split(";"); for (var v = 0; v < p.length; v++){r = p[v].split(":"); t = document.createElement("option"); t.value = r[0]; t.innerHTML = r[1]; if (r[1] == j.defval)t.selected = "selected"; u.appendChild(t)}} else if (typeof r === "object")for (v in r)if (r.hasOwnProperty(v)){p++; - t = document.createElement("option"); t.value = v; t.innerHTML = r[v]; if (r[v] == j.defval)t.selected = "selected"; u.appendChild(t)}b.p.gridToolbar === true && j.width && a(u).width(j.width); a(k).append(u); b.p.autosearch === true && a(u).change(function(){h(); return false})}break; case "text":u = this.defval?this.defval:""; a(k).append(""); j.sopt && a("input", k).attr(j.sopt); if (b.p.gridToolbar === true && j.width)a.browser.msie?a("input", k).width(j.width - - 4):a("input", k).width(j.width - 2); b.p.autosearch === true && a("input", k).keypress(function(w){if ((w.charCode?w.charCode:w.keyCode?w.keyCode:0) == 13){h(); return false}return this}); break}if (b.p.formtype == "horizontal"){b.p.gridToolbar === true && b.p.gridNames === false?a(f).append(k):a(f).append(i).append(k); a(f).append(k)} else{e = document.createElement("tr"); a(e).append(i).append(k); a(c).append(e)}}); k = document.createElement("td"); if (b.p.enableSearch === true){m = ""; a(k).append(m); a("input#sButton", k).click(function(){h(); return false})}if (b.p.enableClear === true){m = ""; a(k).append(m); a("input#cButton", k).click(function(){l(); return false})}if (b.p.enableClear === true || b.p.enableSearch === true)if (b.p.formtype == "horizontal")a(f).append(k); else{e = document.createElement("tr"); a(e).append(" ").append(k); a(c).append(e)}})(); a(this).append(o); - this.triggerSearch = h; this.clearSearch = l} else alert("Could not get grid colModel")} else alert("No target grid is set!")})}, filterToolbar:function(g){g = a.extend({autosearch:true, searchOnEnter:true, beforeSearch:null, afterSearch:null, beforeClear:null, afterClear:null, searchurl:"", stringResult:false, groupOp:"AND"}, g || {}); return this.each(function(){function d(h, l){var o = a(h); o[0] && jQuery.each(l, function(){this.data !== undefined?o.bind(this.type, this.data, this.fn):o.bind(this.type, this.fn)})}var b = this, n = - function(){var h = {}, l = 0, o, c, f = {}; a.each(b.p.colModel, function(){c = this.index || this.name; var j = this.searchoptions && this.searchoptions.sopt?this.searchoptions.sopt[0]:"bw"; switch (this.stype){case "select":if (o = a("select[name=" + c + "]", b.grid.hDiv).val()){h[c] = o; f[c] = j; l++} else try{delete b.p.postData[c]} catch (r){}break; case "text":if (o = a("input[name=" + c + "]", b.grid.hDiv).val()){h[c] = o; f[c] = j; l++} else try{delete b.p.postData[c]} catch (u){}break}}); var e = l > 0?true:false; if (g.stringResult){var m = '{"groupOp":"' + - g.groupOp + '","rules":[', i = 0; a.each(h, function(j, r){if (i > 0)m += ","; m += '{"field":"' + j + '",'; m += '"op":"' + f[j] + '",'; m += '"data":"' + r + '"}'; i++}); m += "]}"; a.extend(b.p.postData, {filters:m})} else a.extend(b.p.postData, h); var k; if (b.p.searchurl){k = b.p.url; a(b).jqGrid("setGridParam", {url:b.p.searchurl})}var p = false; if (a.isFunction(g.beforeSearch))p = g.beforeSearch.call(b); p || a(b).jqGrid("setGridParam", {search:e}).trigger("reloadGrid", [{page:1}]); k && a(b).jqGrid("setGridParam", {url:k}); a.isFunction(g.afterSearch) && - g.afterSearch()}, s = a(""), q; a.each(b.p.colModel, function(){var h = this, l, o, c, f; o = a(""); l = a("
"); this.hidden === true && a(o).css("display", "none"); this.search = this.search === false?false:true; if (typeof this.stype == "undefined")this.stype = "text"; c = a.extend({}, this.searchoptions || {}); if (this.search)switch (this.stype){case "select":if (f = - this.surl || c.dataUrl)a.ajax(a.extend({url:f, dataType:"html", complete:function(p){if (c.buildSelect !== undefined)(p = c.buildSelect(p)) && a(l).append(p); else a(l).append(p.responseText); c.defaultValue && a("select", l).val(c.defaultValue); a("select", l).attr({name:h.index || h.name, id:"gs_" + h.name}); c.attr && a("select", l).attr(c.attr); a("select", l).css({width:"100%"}); c.dataInit !== undefined && c.dataInit(a("select", l)[0]); c.dataEvents !== undefined && d(a("select", l)[0], c.dataEvents); g.autosearch === true && a("select", - l).change(function(){n(); return false}); p = null}}, a.jgrid.ajaxOptions, b.p.ajaxSelectOptions || {})); else{var e; if (h.searchoptions && h.searchoptions.value)e = h.searchoptions.value; else if (h.editoptions && h.editoptions.value)e = h.editoptions.value; if (e){f = document.createElement("select"); f.style.width = "100%"; a(f).attr({name:h.index || h.name, id:"gs_" + h.name}); var m, i; if (typeof e === "string"){e = e.split(";"); for (var k = 0; k < e.length; k++){m = e[k].split(":"); i = document.createElement("option"); i.value = m[0]; i.innerHTML = - m[1]; f.appendChild(i)}} else if (typeof e === "object")for (m in e)if (e.hasOwnProperty(m)){i = document.createElement("option"); i.value = m; i.innerHTML = e[m]; f.appendChild(i)}c.defaultValue && a(f).val(c.defaultValue); c.attr && a(f).attr(c.attr); c.dataInit !== undefined && c.dataInit(f); c.dataEvents !== undefined && d(f, c.dataEvents); a(l).append(f); g.autosearch === true && a(f).change(function(){n(); return false})}}break; case "text":f = c.defaultValue?c.defaultValue:""; a(l).append(""); c.attr && a("input", l).attr(c.attr); c.dataInit !== undefined && c.dataInit(a("input", l)[0]); c.dataEvents !== undefined && d(a("input", l)[0], c.dataEvents); if (g.autosearch === true)g.searchOnEnter?a("input", l).keypress(function(p){if ((p.charCode?p.charCode:p.keyCode?p.keyCode:0) == 13){n(); return false}return this}):a("input", l).keydown(function(p){switch (p.which){case 9:case 16:case 37:case 38:case 39:case 40:case 27:break; default:q && clearTimeout(q); q = setTimeout(function(){n()}, - 500)}}); break}a(o).append(l); a(s).append(o)}); a("table thead", b.grid.hDiv).append(s); this.triggerToolbar = n; this.clearToolbar = function(h){var l = {}, o, c = 0, f; h = typeof h != "boolean"?true:h; a.each(b.p.colModel, function(){o = this.searchoptions && this.searchoptions.defaultValue?this.searchoptions.defaultValue:""; f = this.index || this.name; switch (this.stype){case "select":var j; a("select[name=" + f + "] option", b.grid.hDiv).each(function(t){if (t === 0)this.selected = true; if (a(this).text() == o){this.selected = true; j = a(this).val(); - return false}}); if (j){l[f] = j; c++} else try{delete b.p.postData[f]} catch (r){}break; case "text":a("input[name=" + f + "]", b.grid.hDiv).val(o); if (o){l[f] = o; c++} else try{delete b.p.postData[f]} catch (u){}break}}); var e = c > 0?true:false; if (g.stringResult){var m = '{"groupOp":"' + g.groupOp + '","rules":[', i = 0; a.each(l, function(j, r){if (i > 0)m += ","; m += '{"field":"' + j + '",'; m += '"op":"eq",'; m += '"data":"' + r + '"}'; i++}); m += "]}"; a.extend(b.p.postData, {filters:m})} else a.extend(b.p.postData, l); var k; if (b.p.searchurl){k = b.p.url; - a(b).jqGrid("setGridParam", {url:b.p.searchurl})}var p = false; if (a.isFunction(g.beforeClear))p = g.beforeClear.call(b); p || h && a(b).jqGrid("setGridParam", {search:e}).trigger("reloadGrid", [{page:1}]); k && a(b).jqGrid("setGridParam", {url:k}); a.isFunction(g.afterClear) && g.afterClear()}; this.toggleToolbar = function(){var h = a("tr.ui-search-toolbar", b.grid.hDiv); h.css("display") == "none"?h.show():h.hide()}})}})})(jQuery); - var showModal = function(a){a.w.show()}, closeModal = function(a){a.w.hide().attr("aria-hidden", "true"); a.o && a.o.remove()}, hideModal = function(a, b){b = jQuery.extend({jqm:true, gb:""}, b || {}); if (b.onClose){var c = b.onClose(a); if (typeof c == "boolean" && !c)return}if (jQuery.fn.jqm && b.jqm === true)jQuery(a).attr("aria-hidden", "true").jqmHide(); else{if (b.gb != "")try{jQuery(".jqgrid-overlay:first", b.gb).hide()} catch (e){}jQuery(a).hide().attr("aria-hidden", "true")}}; - function findPos(a){var b = 0, c = 0; if (a.offsetParent){do{b += a.offsetLeft; c += a.offsetTop}while (a = a.offsetParent)}return[b, c]} -var createModal = function(a, b, c, e, f, h){var d = document.createElement("div"), g; g = jQuery(c.gbox).attr("dir") == "rtl"?true:false; d.className = "ui-widget ui-widget-content ui-corner-all ui-jqdialog"; d.id = a.themodal; var i = document.createElement("div"); i.className = "ui-jqdialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix"; i.id = a.modalhead; jQuery(i).append("" + c.caption + ""); var j = jQuery("").hover(function(){j.addClass("ui-state-hover")}, - function(){j.removeClass("ui-state-hover")}).append(""); jQuery(i).append(j); if (g){d.dir = "rtl"; jQuery(".ui-jqdialog-title", i).css("float", "right"); jQuery(".ui-jqdialog-titlebar-close", i).css("left", "0.3em")} else{d.dir = "ltr"; jQuery(".ui-jqdialog-title", i).css("float", "left"); jQuery(".ui-jqdialog-titlebar-close", i).css("right", "0.3em")}var l = document.createElement("div"); jQuery(l).addClass("ui-jqdialog-content ui-widget-content").attr("id", a.modalcontent); - jQuery(l).append(b); d.appendChild(l); jQuery(d).prepend(i); h === true?jQuery("body").append(d):jQuery(d).insertBefore(e); if (typeof c.jqModal === "undefined")c.jqModal = true; b = {}; if (jQuery.fn.jqm && c.jqModal === true){if (c.left === 0 && c.top === 0){e = []; e = findPos(f); c.left = e[0] + 4; c.top = e[1] + 4}b.top = c.top + "px"; b.left = c.left} else if (c.left !== 0 || c.top !== 0){b.left = c.left; b.top = c.top + "px"}jQuery("a.ui-jqdialog-titlebar-close", i).click(function(){var n = jQuery("#" + a.themodal).data("onClose") || c.onClose, k = jQuery("#" + a.themodal).data("gbox") || - c.gbox; hideModal("#" + a.themodal, {gb:k, jqm:c.jqModal, onClose:n}); return false}); if (c.width === 0 || !c.width)c.width = 300; if (c.height === 0 || !c.height)c.height = 200; if (!c.zIndex)c.zIndex = 950; f = 0; if (g && b.left && !h){f = jQuery(c.gbox).width() - (!isNaN(c.width)?parseInt(c.width, 10):0) - 8; b.left = parseInt(b.left, 10) + parseInt(f, 10)}if (b.left)b.left += "px"; jQuery(d).css(jQuery.extend({width:isNaN(c.width)?"auto":c.width + "px", height:isNaN(c.height)?"auto":c.height + "px", zIndex:c.zIndex, overflow:"hidden"}, b)).attr({tabIndex:"-1", - role:"dialog", "aria-labelledby":a.modalhead, "aria-hidden":"true"}); if (typeof c.drag == "undefined")c.drag = true; if (typeof c.resize == "undefined")c.resize = true; if (c.drag){jQuery(i).css("cursor", "move"); if (jQuery.fn.jqDrag)jQuery(d).jqDrag(i); else try{jQuery(d).draggable({handle:jQuery("#" + i.id)})} catch (q){}}if (c.resize)if (jQuery.fn.jqResize){jQuery(d).append("
"); jQuery("#" + a.themodal).jqResize(".jqResize", - a.scrollelm?"#" + a.scrollelm:false)} else try{jQuery(d).resizable({handles:"se, sw", alsoResize:a.scrollelm?"#" + a.scrollelm:false})} catch (o){}c.closeOnEscape === true && jQuery(d).keydown(function(n){if (n.which == 27){n = jQuery("#" + a.themodal).data("onClose") || c.onClose; hideModal(this, {gb:c.gbox, jqm:c.jqModal, onClose:n})}})}, viewModal = function(a, b){b = jQuery.extend({toTop:true, overlay:10, modal:false, onShow:showModal, onHide:closeModal, gbox:"", jqm:true, jqM:true}, b || {}); if (jQuery.fn.jqm && b.jqm === true)b.jqM?jQuery(a).attr("aria-hidden", - "false").jqm(b).jqmShow():jQuery(a).attr("aria-hidden", "false").jqmShow(); else{if (b.gbox != ""){jQuery(".jqgrid-overlay:first", b.gbox).show(); jQuery(a).data("gbox", b.gbox)}jQuery(a).show().attr("aria-hidden", "false"); try{jQuery(":input:visible", a)[0].focus()} catch (c){}}}; - function info_dialog(a, b, c, e){var f = {width:290, height:"auto", dataheight:"auto", drag:true, resize:false, caption:"" + a + "", left:250, top:170, zIndex:1E3, jqModal:true, modal:false, closeOnEscape:true, align:"center", buttonalign:"center", buttons:[]}; jQuery.extend(f, e || {}); var h = f.jqModal; if (jQuery.fn.jqm && !h)h = false; a = ""; if (f.buttons.length > 0)for (e = 0; e < f.buttons.length; e++){if (typeof f.buttons[e].id == "undefined")f.buttons[e].id = "info_button_" + e; a += "" + - f.buttons[e].text + ""}e = isNaN(f.dataheight)?f.dataheight:f.dataheight + "px"; var d = "
"; d += "
" + b + "
"; d += c?"
" + - c + "" + a + "
":a != ""?"
" + a + "
":""; d += "
"; try{jQuery("#info_dialog").attr("aria-hidden") == "false" && hideModal("#info_dialog", {jqm:h}); jQuery("#info_dialog").remove()} catch (g){}createModal({themodal:"info_dialog", modalhead:"info_head", modalcontent:"info_content", scrollelm:"infocnt"}, d, f, "", "", true); a && jQuery.each(f.buttons, - function(j){jQuery("#" + this.id, "#info_id").bind("click", function(){f.buttons[j].onClick.call(jQuery("#info_dialog")); return false})}); jQuery("#closedialog", "#info_id").click(function(j){hideModal("#info_dialog", {jqm:h}); return false}); jQuery(".fm-button", "#info_dialog").hover(function(){jQuery(this).addClass("ui-state-hover")}, function(){jQuery(this).removeClass("ui-state-hover")}); viewModal("#info_dialog", {onHide:function(j){j.w.hide().remove(); j.o && j.o.remove()}, modal:f.modal, jqm:h}); try{$("#info_dialog").focus()} catch (i){}} -function createEl(a, b, c, e, f){function h(k, m){if (jQuery.isFunction(m.dataInit)){k.id = m.id; m.dataInit(k); delete m.id; delete m.dataInit}if (m.dataEvents){jQuery.each(m.dataEvents, function(){this.data !== undefined?jQuery(k).bind(this.type, this.data, this.fn):jQuery(k).bind(this.type, this.fn)}); delete m.dataEvents}return m}var d = ""; b.defaultValue && delete b.defaultValue; switch (a){case "textarea":d = document.createElement("textarea"); if (e)b.cols || jQuery(d).css({width:"98%"}); else if (!b.cols)b.cols = 20; if (!b.rows)b.rows = - 2; if (c == " " || c == " " || c.length == 1 && c.charCodeAt(0) == 160)c = ""; d.value = c; b = h(d, b); jQuery(d).attr(b).attr({role:"textbox", multiline:"true"}); break; case "checkbox":d = document.createElement("input"); d.type = "checkbox"; if (b.value){var g = b.value.split(":"); if (c === g[0]){d.checked = true; d.defaultChecked = true}d.value = g[0]; jQuery(d).attr("offval", g[1]); try{delete b.value} catch (i){}} else{g = c.toLowerCase(); if (g.search(/(false|0|no|off|undefined)/i) < 0 && g !== ""){d.checked = true; d.defaultChecked = true; d.value = -c} else d.value = "on"; jQuery(d).attr("offval", "off")}b = h(d, b); jQuery(d).attr(b).attr("role", "checkbox"); break; case "select":d = document.createElement("select"); d.setAttribute("role", "select"); var j, l = []; if (b.multiple === true){j = true; d.multiple = "multiple"; $(d).attr("aria-multiselectable", "true")} else j = false; if (typeof b.dataUrl != "undefined")jQuery.ajax(jQuery.extend({url:b.dataUrl, type:"GET", complete:function(k, m){try{delete b.dataUrl; delete b.value} catch (r){}if (typeof b.buildSelect != "undefined"){k = b.buildSelect(k); - k = jQuery(k).html(); delete b.buildSelect} else k = jQuery(k.responseText).html(); if (k){jQuery(d).append(k); b = h(d, b); if (typeof b.size === "undefined")b.size = j?3:1; if (j){l = c.split(","); l = jQuery.map(l, function(p){return jQuery.trim(p)})} else l[0] = jQuery.trim(c); jQuery(d).attr(b); setTimeout(function(){jQuery("option", d).each(function(p){if (p === 0)this.selected = ""; $(this).attr("role", "option"); if (jQuery.inArray(jQuery.trim(jQuery(this).text()), l) > - 1 || jQuery.inArray(jQuery.trim(jQuery(this).val()), l) > - 1){this.selected = - "selected"; if (!j)return false}})}, 0)}}}, f || {})); else if (b.value){if (j){l = c.split(","); l = jQuery.map(l, function(k){return jQuery.trim(k)}); if (typeof b.size === "undefined")b.size = 3} else b.size = 1; if (typeof b.value === "function")b.value = b.value(); if (typeof b.value === "string"){e = b.value.split(";"); for (g = 0; g < e.length; g++){f = e[g].split(":"); if (f.length > 2)f[1] = jQuery.map(f, function(k, m){if (m > 0)return k}).join(":"); a = document.createElement("option"); a.setAttribute("role", "option"); a.value = f[0]; a.innerHTML = f[1]; - if (!j && (jQuery.trim(f[0]) == jQuery.trim(c) || jQuery.trim(f[1]) == jQuery.trim(c)))a.selected = "selected"; if (j && (jQuery.inArray(jQuery.trim(f[1]), l) > - 1 || jQuery.inArray(jQuery.trim(f[0]), l) > - 1))a.selected = "selected"; d.appendChild(a)}} else if (typeof b.value === "object"){e = b.value; for (g in e)if (e.hasOwnProperty(g)){a = document.createElement("option"); a.setAttribute("role", "option"); a.value = g; a.innerHTML = e[g]; if (!j && (jQuery.trim(g) == jQuery.trim(c) || jQuery.trim(e[g]) == jQuery.trim(c)))a.selected = "selected"; if (j && - (jQuery.inArray(jQuery.trim(e[g]), l) > - 1 || jQuery.inArray(jQuery.trim(g), l) > - 1))a.selected = "selected"; d.appendChild(a)}}b = h(d, b); try{delete b.value} catch (q){}jQuery(d).attr(b)}break; case "text":case "password":case "button":g = a == "button"?"button":"textbox"; d = document.createElement("input"); d.type = a; d.value = c; b = h(d, b); if (a != "button")if (e)b.size || jQuery(d).css({width:"98%"}); else if (!b.size)b.size = 20; jQuery(d).attr(b).attr("role", g); break; case "image":case "file":d = document.createElement("input"); d.type = - a; b = h(d, b); jQuery(d).attr(b); break; case "custom":d = document.createElement("span"); try{if (jQuery.isFunction(b.custom_element)){var o = b.custom_element.call(this, c, b); if (o){o = jQuery(o).addClass("customelement").attr({id:b.id, name:b.name}); jQuery(d).empty().append(o)} else throw"e2"; } else throw"e1"; } catch (n){n == "e1" && info_dialog(jQuery.jgrid.errors.errcap, "function 'custom_element' " + jQuery.jgrid.edit.msg.nodefined, jQuery.jgrid.edit.bClose); n == "e2"?info_dialog(jQuery.jgrid.errors.errcap, "function 'custom_element' " + - jQuery.jgrid.edit.msg.novalue, jQuery.jgrid.edit.bClose):info_dialog(jQuery.jgrid.errors.errcap, n.message, jQuery.jgrid.edit.bClose)}break}return d}function daysInFebruary(a){return a % 4 === 0 && (a % 100 !== 0 || a % 400 === 0)?29:28}function DaysArray(a){for (var b = 1; b <= a; b++){this[b] = 31; if (b == 4 || b == 6 || b == 9 || b == 11)this[b] = 30; if (b == 2)this[b] = 29}return this} -function checkDate(a, b){var c = {}, e; a = a.toLowerCase(); e = a.indexOf("/") != - 1?"/":a.indexOf("-") != - 1?"-":a.indexOf(".") != - 1?".":"/"; a = a.split(e); b = b.split(e); if (b.length != 3)return false; e = - 1; for (var f, h = - 1, d = - 1, g = 0; g < a.length; g++){f = isNaN(b[g])?0:parseInt(b[g], 10); c[a[g]] = f; f = a[g]; if (f.indexOf("y") != - 1)e = g; if (f.indexOf("m") != - 1)d = g; if (f.indexOf("d") != - 1)h = g}f = a[e] == "y" || a[e] == "yyyy"?4:a[e] == "yy"?2: - 1; g = DaysArray(12); var i; if (e === - 1)return false; else{i = c[a[e]].toString(); if (f == 2 && i.length == 1)f = 1; if (i.length != - f || c[a[e]] === 0 && b[e] != "00")return false}if (d === - 1)return false; else{i = c[a[d]].toString(); if (i.length < 1 || c[a[d]] < 1 || c[a[d]] > 12)return false}if (h === - 1)return false; else{i = c[a[h]].toString(); if (i.length < 1 || c[a[h]] < 1 || c[a[h]] > 31 || c[a[d]] == 2 && c[a[h]] > daysInFebruary(c[a[e]]) || c[a[h]] > g[c[a[d]]])return false}return true}function isEmpty(a){return a.match(/^s+$/) || a == ""?true:false} -function checkTime(a){var b = /^(\d{1,2}):(\d{2})([ap]m)?$/; if (!isEmpty(a))if (a = a.match(b)){if (a[3]){if (a[1] < 1 || a[1] > 12)return false} else if (a[1] > 23)return false; if (a[2] > 59)return false} else return false; return true} -function checkValues(a, b, c){var e, f, h; if (typeof b == "string"){f = 0; for (len = c.p.colModel.length; f < len; f++)if (c.p.colModel[f].name == b){e = c.p.colModel[f].editrules; b = f; try{h = c.p.colModel[f].formoptions.label} catch (d){}break}} else if (b >= 0)e = c.p.colModel[b].editrules; if (e){h || (h = c.p.colNames[b]); if (e.required === true)if (a.match(/^s+$/) || a == "")return[false, h + ": " + jQuery.jgrid.edit.msg.required, ""]; f = e.required === false?false:true; if (e.number === true)if (!(f === false && isEmpty(a)))if (isNaN(a))return[false, h + ": " + - jQuery.jgrid.edit.msg.number, ""]; if (typeof e.minValue != "undefined" && !isNaN(e.minValue))if (parseFloat(a) < parseFloat(e.minValue))return[false, h + ": " + jQuery.jgrid.edit.msg.minValue + " " + e.minValue, ""]; if (typeof e.maxValue != "undefined" && !isNaN(e.maxValue))if (parseFloat(a) > parseFloat(e.maxValue))return[false, h + ": " + jQuery.jgrid.edit.msg.maxValue + " " + e.maxValue, ""]; var g; if (e.email === true)if (!(f === false && isEmpty(a))){g = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i; - if (!g.test(a))return[false, h + ": " + jQuery.jgrid.edit.msg.email, ""]}if (e.integer === true)if (!(f === false && isEmpty(a))){if (isNaN(a))return[false, h + ": " + jQuery.jgrid.edit.msg.integer, ""]; if (a % 1 !== 0 || a.indexOf(".") != - 1)return[false, h + ": " + jQuery.jgrid.edit.msg.integer, ""]}if (e.date === true)if (!(f === false && isEmpty(a))){b = c.p.colModel[b].datefmt || "Y-m-d"; if (!checkDate(b, a))return[false, h + ": " + jQuery.jgrid.edit.msg.date + " - " + b, ""]}if (e.time === true)if (!(f === false && isEmpty(a)))if (!checkTime(a))return[false, h + - ": " + jQuery.jgrid.edit.msg.date + " - hh:mm (am/pm)", ""]; if (e.url === true)if (!(f === false && isEmpty(a))){g = /^(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i; if (!g.test(a))return[false, h + ": " + jQuery.jgrid.edit.msg.url, ""]}if (e.custom === true)if (!(f === false && isEmpty(a)))if (jQuery.isFunction(e.custom_func)){a = e.custom_func.call(c, a, h); return jQuery.isArray(a)?a:[false, jQuery.jgrid.edit.msg.customarray, ""]} else return[false, jQuery.jgrid.edit.msg.customfcheck, - ""]}return[true, "", ""]}; - (function(a){var c = null; a.jgrid.extend({searchGrid:function(d){d = a.extend({recreateFilter:false, drag:true, sField:"searchField", sValue:"searchString", sOper:"searchOper", sFilter:"filters", loadDefaults:true, beforeShowSearch:null, afterShowSearch:null, onInitializeSearch:null, closeAfterSearch:false, closeAfterReset:false, closeOnEscape:false, multipleSearch:false, cloneSearchRowOnAdd:true, sopt:null, stringResult:undefined, onClose:null, useDataProxy:false, overlay:true}, a.jgrid.search, d || {}); return this.each(function(){function b(o, - s){s = o.p.postData[s.sFilter]; if (typeof s == "string")s = a.jgrid.parse(s); if (s){s.groupOp && o.SearchFilter.setGroupOp(s.groupOp); if (s.rules){var y, J = 0, k = s.rules.length; for (y = false; J < k; J++){y = s.rules[J]; if (y.field !== undefined && y.op !== undefined && y.data !== undefined)(y = o.SearchFilter.setFilter({sfref:o.SearchFilter.$.find(".sf:last"), filter:a.extend({}, y)})) && o.SearchFilter.add()}}}}function q(o){var s = o !== undefined, y = a("#" + z.p.id), J = {}; if (d.multipleSearch === false){J[d.sField] = o.rules[0].field; J[d.sValue] = - o.rules[0].data; J[d.sOper] = o.rules[0].op} else J[d.sFilter] = o; y[0].p.search = s; a.extend(y[0].p.postData, J); y.trigger("reloadGrid", [{page:1}]); d.closeAfterSearch && t(a("#" + h))}function D(o){o = o !== undefined; var s = a("#" + z.p.id), y = []; s[0].p.search = o; if (d.multipleSearch === false)y[d.sField] = y[d.sValue] = y[d.sOper] = ""; else y[d.sFilter] = ""; a.extend(s[0].p.postData, y); s.trigger("reloadGrid", [{page:1}]); d.closeAfterReset && t(a("#" + h))}function t(o){if (d.onClose){var s = d.onClose(o); if (typeof s == "boolean" && !s)return}o.hide(); - d.overlay === true && a(".jqgrid-overlay:first", "#gbox_" + z.p.id).hide()}function F(){var o = a(".ui-searchFilter").length; if (o > 1){var s = a("#" + h).css("zIndex"); a("#" + h).css({zIndex:parseInt(s, 10) + o})}a("#" + h).show(); d.overlay === true && a(".jqgrid-overlay:first", "#gbox_" + z.p.id).show(); try{a(":input:visible", "#" + h)[0].focus()} catch (y){}}var z = this; if (z.grid)if (a.fn.searchFilter){var h = "fbox_" + z.p.id; d.recreateFilter === true && a("#" + h).remove(); if (a("#" + h).html() != null){a.isFunction(d.beforeShowSearch) && d.beforeShowSearch(a("#" + - h)); F(); a.isFunction(d.afterShowSearch) && d.afterShowSearch(a("#" + h))} else{var p = [], H = a("#" + z.p.id).jqGrid("getGridParam", "colNames"), f = a("#" + z.p.id).jqGrid("getGridParam", "colModel"), l = ["eq", "ne", "lt", "le", "gt", "ge", "bw", "bn", "in", "ni", "ew", "en", "cn", "nc"], e, j, m, u = []; if (d.sopt !== null)for (e = m = 0; e < d.sopt.length; e++){if ((j = a.inArray(d.sopt[e], l)) != - 1){u[m] = {op:d.sopt[e], text:d.odata[j]}; m++}} else for (e = 0; e < l.length; e++)u[e] = {op:l[e], text:d.odata[e]}; a.each(f, function(o, s){var y = typeof s.search === "undefined"? - true:s.search, J = s.hidden === true; o = a.extend({}, {text:H[o], itemval:s.index || s.name}, this.searchoptions); s = o.searchhidden === true; if (typeof o.sopt !== "undefined"){m = 0; o.ops = []; if (o.sopt.length > 0)for (e = 0; e < o.sopt.length; e++)if ((j = a.inArray(o.sopt[e], l)) != - 1){o.ops[m] = {op:o.sopt[e], text:d.odata[j]}; m++}}if (typeof this.stype === "undefined")this.stype = "text"; if (this.stype == "select")if (o.dataUrl === undefined){var k; if (o.value)k = o.value; else if (this.editoptions)k = this.editoptions.value; if (k){o.dataValues = []; if (typeof k === - "string"){k = k.split(";"); var i; for (e = 0; e < k.length; e++){i = k[e].split(":"); o.dataValues[e] = {value:i[0], text:i[1]}}} else if (typeof k === "object"){e = 0; for (i in k)if (k.hasOwnProperty(i)){o.dataValues[e] = {value:i, text:k[i]}; e++}}}}if (s && y || y && !J)p.push(o)}); if (p.length > 0){a("").insertBefore("#gview_" + z.p.id); if (d.stringResult === undefined)d.stringResult = d.multipleSearch; z.SearchFilter = a("#" + h).searchFilter(p, {groupOps:d.groupOps, operators:u, onClose:t, resetText:d.Reset, - searchText:d.Find, windowTitle:d.caption, rulesText:d.rulesText, matchText:d.matchText, onSearch:q, onReset:D, stringResult:d.stringResult, ajaxSelectOptions:a.extend({}, a.jgrid.ajaxOptions, z.p.ajaxSelectOptions || {}), clone:d.cloneSearchRowOnAdd}); a(".ui-widget-overlay", "#" + h).remove(); z.p.direction == "rtl" && a(".ui-closer", "#" + h).css("float", "left"); if (d.drag === true){a("#" + h + " table thead tr:first td:first").css("cursor", "move"); if (jQuery.fn.jqDrag)a("#" + h).jqDrag(a("#" + h + " table thead tr:first td:first")); - else try{a("#" + h).draggable({handle:a("#" + h + " table thead tr:first td:first")})} catch (Q){}}if (d.multipleSearch === false){a(".ui-del, .ui-add, .ui-del, .ui-add-last, .matchText, .rulesText", "#" + h).hide(); a("select[name='groupOp']", "#" + h).hide()}d.multipleSearch === true && d.loadDefaults === true && b(z, d); a.isFunction(d.onInitializeSearch) && d.onInitializeSearch(a("#" + h)); a.isFunction(d.beforeShowSearch) && d.beforeShowSearch(a("#" + h)); F(); a.isFunction(d.afterShowSearch) && d.afterShowSearch(a("#" + h)); d.closeOnEscape === - true && a("#" + h).keydown(function(o){o.which == 27 && t(a("#" + h))})}}}})}, editGridRow:function(d, b){c = b = a.extend({top:0, left:0, width:300, height:"auto", dataheight:"auto", modal:false, drag:true, resize:true, url:null, mtype:"POST", clearAfterAdd:true, closeAfterEdit:false, reloadAfterSubmit:true, onInitializeForm:null, beforeInitData:null, beforeShowForm:null, afterShowForm:null, beforeSubmit:null, afterSubmit:null, onclickSubmit:null, afterComplete:null, onclickPgButtons:null, afterclickPgButtons:null, editData:{}, recreateForm:false, - jqModal:true, closeOnEscape:false, addedrow:"first", topinfo:"", bottominfo:"", saveicon:[], closeicon:[], savekey:[false, 13], navkeys:[false, 38, 40], checkOnSubmit:false, checkOnUpdate:false, _savedData:{}, processing:false, onClose:null, ajaxEditOptions:{}, serializeEditData:null, viewPagerButtons:true}, a.jgrid.edit, b || {}); return this.each(function(){function q(g, n){g === 0?a("#pData", "#" + j + "_2").addClass("ui-state-disabled"):a("#pData", "#" + j + "_2").removeClass("ui-state-disabled"); g == n?a("#nData", "#" + j + "_2").addClass("ui-state-disabled"): - a("#nData", "#" + j + "_2").removeClass("ui-state-disabled")}function D(){var g = a(f).jqGrid("getDataIDs"), n = a("#id_g", "#" + j).val(); return[a.inArray(n, g), g]}function t(){var g = true; a("#FormError", "#" + j).hide(); if (c.checkOnUpdate){k = {}; i = {}; F(); w = a.extend({}, k, i); if (O = H(w, c._savedData)){a("#" + e).data("disabled", true); a(".confirm", "#" + m.themodal).show(); g = false}}return g}function F(){a(".FormElement", "#" + j).each(function(){var g = a(".customelement", this); if (g.length){var n = g[0].name; a.each(f.p.colModel, function(){if (this.name == - n && this.editoptions && a.isFunction(this.editoptions.custom_value)){try{k[n] = this.editoptions.custom_value(a("#" + n, "#" + j), "get"); if (k[n] === undefined)throw"e1"; } catch (r){r == "e1"?info_dialog(jQuery.jgrid.errors.errcap, "function 'custom_value' " + a.jgrid.edit.msg.novalue, jQuery.jgrid.edit.bClose):info_dialog(jQuery.jgrid.errors.errcap, r.message, jQuery.jgrid.edit.bClose)}return true}})} else{switch (a(this).get(0).type){case "checkbox":if (a(this).attr("checked"))k[this.name] = a(this).val(); else{g = a(this).attr("offval"); - k[this.name] = g}break; case "select-one":k[this.name] = a("option:selected", this).val(); i[this.name] = a("option:selected", this).text(); break; case "select-multiple":k[this.name] = a(this).val(); k[this.name] = k[this.name]?k[this.name].join(","):""; var v = []; a("option:selected", this).each(function(r, E){v[r] = a(E).text()}); i[this.name] = v.join(","); break; case "password":case "text":case "textarea":case "button":k[this.name] = a(this).val(); break}if (f.p.autoencode)k[this.name] = a.jgrid.htmlEncode(k[this.name])}}); return true} - function z(g, n, v, r){for (var E, A, B, M = 0, x, P, C, T = [], G = false, V = "", R = 1; R <= r; R++)V += "  "; if (g != "_empty")G = a(n).jqGrid("getInd", g); a(n.p.colModel).each(function(U){E = this.name; P = (A = this.editrules && this.editrules.edithidden === true?false:this.hidden === true?true:false)?"style='display:none'":""; if (E !== "cb" && E !== "subgrid" && this.editable === true && E !== "rn"){if (G === false)x = ""; else if (E == n.p.ExpandColumn && - n.p.treeGrid === true)x = a("td:eq(" + U + ")", n.rows[G]).text(); else try{x = a.unformat(a("td:eq(" + U + ")", n.rows[G]), {rowId:g, colModel:this}, U)} catch (ca){x = a("td:eq(" + U + ")", n.rows[G]).html()}var W = a.extend({}, this.editoptions || {}, {id:E, name:E}), X = a.extend({}, {elmprefix:"", elmsuffix:"", rowabove:false, rowcontent:""}, this.formoptions || {}), ba = parseInt(X.rowpos, 10) || M + 1, da = parseInt((parseInt(X.colpos, 10) || 1) * 2, 10); if (g == "_empty" && W.defaultValue)x = a.isFunction(W.defaultValue)?W.defaultValue():W.defaultValue; if (!this.edittype)this.edittype = - "text"; if (f.p.autoencode)x = a.jgrid.htmlDecode(x); C = createEl(this.edittype, W, x, false, a.extend({}, a.jgrid.ajaxOptions, n.p.ajaxSelectOptions || {})); if (x == "" && this.edittype == "checkbox")x = a(C).attr("offval"); if (x == "" && this.edittype == "select")x = a("option:eq(0)", C).text(); if (c.checkOnSubmit || c.checkOnUpdate)c._savedData[E] = x; a(C).addClass("FormElement"); B = a(v).find("tr[rowpos=" + ba + "]"); if (X.rowabove){W = a("" + X.rowcontent + ""); a(v).append(W); W[0].rp = ba}if (B.length === - 0){B = a("").addClass("FormData").attr("id", "tr_" + E); a(B).append(V); a(v).append(B); B[0].rp = ba}a("td:eq(" + (da - 2) + ")", B[0]).html(typeof X.label === "undefined"?n.p.colNames[U]:X.label); a("td:eq(" + (da - 1) + ")", B[0]).append(X.elmprefix).append(C).append(X.elmsuffix); T[M] = U; M++}}); if (M > 0){R = a(""); R[0].rp = M + 999; a(v).append(R); if (c.checkOnSubmit || c.checkOnUpdate)c._savedData[n.p.id + "_id"] = g}return T}function h(g, n, v){var r, E = 0, A, B, M, x, P; if (c.checkOnSubmit || c.checkOnUpdate){c._savedData = {}; c._savedData[n.p.id + "_id"] = g}var C = n.p.colModel; if (g == "_empty"){a(C).each(function(){r = this.name; M = a.extend({}, this.editoptions || {}); B = a("#" + a.jgrid.jqID(r), "#" + v); if (B[0] != null){x = ""; if (M.defaultValue){x = a.isFunction(M.defaultValue)?M.defaultValue():M.defaultValue; if (B[0].type == "checkbox"){P = - x.toLowerCase(); if (P.search(/(false|0|no|off|undefined)/i) < 0 && P !== ""){B[0].checked = true; B[0].defaultChecked = true; B[0].value = x} else B.attr({checked:"", defaultChecked:""})} else B.val(x)} else if (B[0].type == "checkbox"){B[0].checked = false; B[0].defaultChecked = false; x = a(B).attr("offval")} else if (B[0].type.substr(0, 6) == "select")B[0].selectedIndex = 0; else B.val(x); if (c.checkOnSubmit === true || c.checkOnUpdate)c._savedData[r] = x}}); a("#id_g", "#" + v).val(g)} else{var T = a(n).jqGrid("getInd", g, true); if (T){a("td", T).each(function(G){r = - C[G].name; if (r !== "cb" && r !== "subgrid" && r !== "rn" && C[G].editable === true){if (r == n.p.ExpandColumn && n.p.treeGrid === true)A = a(this).text(); else try{A = a.unformat(this, {rowId:g, colModel:C[G]}, G)} catch (V){A = a(this).html()}if (f.p.autoencode)A = a.jgrid.htmlDecode(A); if (c.checkOnSubmit === true || c.checkOnUpdate)c._savedData[r] = A; r = a.jgrid.jqID(r); switch (C[G].edittype){case "password":case "text":case "button":case "image":a("#" + r, "#" + v).val(A); break; case "textarea":if (A == " " || A == " " || A.length == 1 && A.charCodeAt(0) == - 160)A = ""; a("#" + r, "#" + v).val(A); break; case "select":var R = A.split(","); R = a.map(R, function(ca){return a.trim(ca)}); a("#" + r + " option", "#" + v).each(function(){this.selected = !C[G].editoptions.multiple && (R[0] == a.trim(a(this).text()) || R[0] == a.trim(a(this).val()))?true:C[G].editoptions.multiple?a.inArray(a.trim(a(this).text()), R) > - 1 || a.inArray(a.trim(a(this).val()), R) > - 1?true:false:false}); break; case "checkbox":A += ""; if (C[G].editoptions && C[G].editoptions.value)if (C[G].editoptions.value.split(":")[0] == A){a("#" + - r, "#" + v).attr("checked", true); a("#" + r, "#" + v).attr("defaultChecked", true)} else{a("#" + r, "#" + v).attr("checked", false); a("#" + r, "#" + v).attr("defaultChecked", "")} else{A = A.toLowerCase(); if (A.search(/(false|0|no|off|undefined)/i) < 0 && A !== ""){a("#" + r, "#" + v).attr("checked", true); a("#" + r, "#" + v).attr("defaultChecked", true)} else{a("#" + r, "#" + v).attr("checked", false); a("#" + r, "#" + v).attr("defaultChecked", "")}}break; case "custom":try{if (C[G].editoptions && a.isFunction(C[G].editoptions.custom_value))C[G].editoptions.custom_value(a("#" + - r, "#" + v), "set", A); else throw"e1"; } catch (U){U == "e1"?info_dialog(jQuery.jgrid.errors.errcap, "function 'custom_value' " + a.jgrid.edit.msg.nodefined, jQuery.jgrid.edit.bClose):info_dialog(jQuery.jgrid.errors.errcap, U.message, jQuery.jgrid.edit.bClose)}break}E++}}); E > 0 && a("#id_g", "#" + j).val(g)}}}function p(){var g, n = [true, "", ""], v = {}, r = f.p.prmNames, E, A; if (a.isFunction(c.beforeCheckValues)){var B = c.beforeCheckValues(k, a("#" + e), k[f.p.id + "_id"] == "_empty"?r.addoper:r.editoper); if (B && typeof B === "object")k = B}for (var M in k)if (k.hasOwnProperty(M)){n = - checkValues(k[M], M, f); if (n[0] === false)break}if (n[0]){if (a.isFunction(c.onclickSubmit))v = c.onclickSubmit(c, k) || {}; if (a.isFunction(c.beforeSubmit))n = c.beforeSubmit(k, a("#" + e))}if (n[0] && !c.processing){c.processing = true; a("#sData", "#" + j + "_2").addClass("ui-state-active"); A = r.oper; E = r.id; k[A] = a.trim(k[f.p.id + "_id"]) == "_empty"?r.addoper:r.editoper; if (k[A] != r.addoper)k[E] = k[f.p.id + "_id"]; else if (k[E] === undefined)k[E] = k[f.p.id + "_id"]; delete k[f.p.id + "_id"]; k = a.extend(k, c.editData, v); v = a.extend({url:c.url? - c.url:a(f).jqGrid("getGridParam", "editurl"), type:c.mtype, data:a.isFunction(c.serializeEditData)?c.serializeEditData(k):k, complete:function(x, P){if (P != "success"){n[0] = false; n[1] = a.isFunction(c.errorTextFormat)?c.errorTextFormat(x):P + " Status: '" + x.statusText + "'. Error code: " + x.status} else if (a.isFunction(c.afterSubmit))n = c.afterSubmit(x, k); if (n[0] === false){a("#FormError>td", "#" + j).html(n[1]); a("#FormError", "#" + j).show()} else{a.each(f.p.colModel, function(){if (i[this.name] && this.formatter && this.formatter == - "select")try{delete i[this.name]} catch (G){}}); k = a.extend(k, i); f.p.autoencode && a.each(k, function(G, V){k[G] = a.jgrid.htmlDecode(V)}); if (k[A] == r.addoper){n[2] || (n[2] = parseInt(f.p.records, 10) + 1); k[E] = n[2]; if (c.closeAfterAdd){if (c.reloadAfterSubmit)a(f).trigger("reloadGrid"); else{a(f).jqGrid("addRowData", n[2], k, b.addedrow); a(f).jqGrid("setSelection", n[2])}hideModal("#" + m.themodal, {gb:"#gbox_" + l, jqm:b.jqModal, onClose:c.onClose})} else if (c.clearAfterAdd){c.reloadAfterSubmit?a(f).trigger("reloadGrid"):a(f).jqGrid("addRowData", - n[2], k, b.addedrow); h("_empty", f, e)} else c.reloadAfterSubmit?a(f).trigger("reloadGrid"):a(f).jqGrid("addRowData", n[2], k, b.addedrow)} else{if (c.reloadAfterSubmit){a(f).trigger("reloadGrid"); c.closeAfterEdit || setTimeout(function(){a(f).jqGrid("setSelection", k[E])}, 1E3)} else f.p.treeGrid === true?a(f).jqGrid("setTreeRow", k[E], k):a(f).jqGrid("setRowData", k[E], k); c.closeAfterEdit && hideModal("#" + m.themodal, {gb:"#gbox_" + l, jqm:b.jqModal, onClose:c.onClose})}if (a.isFunction(c.afterComplete)){g = x; setTimeout(function(){c.afterComplete(g, - k, a("#" + e)); g = null}, 500)}}c.processing = false; if (c.checkOnSubmit || c.checkOnUpdate){a("#" + e).data("disabled", false); if (c._savedData[f.p.id + "_id"] != "_empty")for (var C in c._savedData)if (k[C])c._savedData[C] = k[C]}a("#sData", "#" + j + "_2").removeClass("ui-state-active"); try{a(":input:visible", "#" + e)[0].focus()} catch (T){}}, error:function(x, P, C){a("#FormError>td", "#" + j).html(P + " : " + C); a("#FormError", "#" + j).show(); c.processing = false; a("#" + e).data("disabled", false); a("#sData", "#" + j + "_2").removeClass("ui-state-active")}}, - a.jgrid.ajaxOptions, c.ajaxEditOptions); if (!v.url && !c.useDataProxy)if (a.isFunction(f.p.dataProxy))c.useDataProxy = true; else{n[0] = false; n[1] += " " + a.jgrid.errors.nourl}if (n[0])c.useDataProxy?f.p.dataProxy.call(f, v, "set_" + f.p.id):a.ajax(v)}if (n[0] === false){a("#FormError>td", "#" + j).html(n[1]); a("#FormError", "#" + j).show()}}function H(g, n){var v = false, r; for (r in g)if (g[r] != n[r]){v = true; break}return v}var f = this; if (f.grid && d){var l = f.p.id, e = "FrmGrid_" + l, j = "TblGrid_" + l, m = {themodal:"editmod" + l, modalhead:"edithd" + - l, modalcontent:"editcnt" + l, scrollelm:e}, u = a.isFunction(c.beforeShowForm)?c.beforeShowForm:false, Q = a.isFunction(c.afterShowForm)?c.afterShowForm:false, o = a.isFunction(c.beforeInitData)?c.beforeInitData:false, s = a.isFunction(c.onInitializeForm)?c.onInitializeForm:false, y = 1, J = 0, k, i, w, O; if (d == "new"){d = "_empty"; b.caption = b.addCaption} else b.caption = b.editCaption; b.recreateForm === true && a("#" + m.themodal).html() != null && a("#" + m.themodal).remove(); var S = true; if (b.checkOnUpdate && b.jqModal && !b.modal)S = false; if (a("#" + - m.themodal).html() != null){a(".ui-jqdialog-title", "#" + m.modalhead).html(b.caption); a("#FormError", "#" + j).hide(); if (c.topinfo){a(".topinfo", "#" + j + "_2").html(c.topinfo); a(".tinfo", "#" + j + "_2").show()} else a(".tinfo", "#" + j + "_2").hide(); if (c.bottominfo){a(".bottominfo", "#" + j + "_2").html(c.bottominfo); a(".binfo", "#" + j + "_2").show()} else a(".binfo", "#" + j + "_2").hide(); o && o(a("#" + e)); h(d, f, e); d == "_empty" || !c.viewPagerButtons?a("#pData, #nData", "#" + j + "_2").hide():a("#pData, #nData", "#" + j + "_2").show(); if (c.processing === - true){c.processing = false; a("#sData", "#" + j + "_2").removeClass("ui-state-active")}if (a("#" + e).data("disabled") === true){a(".confirm", "#" + m.themodal).hide(); a("#" + e).data("disabled", false)}u && u(a("#" + e)); a("#" + m.themodal).data("onClose", c.onClose); viewModal("#" + m.themodal, {gbox:"#gbox_" + l, jqm:b.jqModal, jqM:false, closeoverlay:S, modal:b.modal}); S || a(".jqmOverlay").click(function(){if (!t())return false; hideModal("#" + m.themodal, {gb:"#gbox_" + l, jqm:b.jqModal, onClose:c.onClose}); return false}); Q && Q(a("#" + e))} else{a(f.p.colModel).each(function(){var g = - this.formoptions; y = Math.max(y, g?g.colpos || 0:0); J = Math.max(J, g?g.rowpos || 0:0)}); var I = isNaN(b.dataheight)?b.dataheight:b.dataheight + "px", K; I = a("
").data("disabled", false); var L = a("
"); a(I).append(L); K = a(""); K[0].rp = 0; a(L).append(K); K = a("" + c.topinfo + ""); K[0].rp = 0; a(L).append(K); o && o(a("#" + e)); K = (o = f.p.direction == "rtl"?true:false)?"nData":"pData"; var N = o?"pData":"nData"; z(d, f, L, y); K = ""; N = ""; - var Z = "" + b.bSubmit + "", $ = "" + b.bCancel + ""; K = ""; K += ""; K += "
" + Z + $ + "
"; if (J > 0){var aa = []; a.each(a(L)[0].rows, function(g, n){aa[g] = n}); aa.sort(function(g, n){if (g.rp > n.rp)return 1; if (g.rp < n.rp)return - 1; return 0}); a.each(aa, function(g, n){a("tbody", L).append(n)})}b.gbox = "#gbox_" + l; var Y = false; if (b.closeOnEscape === true){b.closeOnEscape = false; Y = true}I = a("").append(I).append(K); createModal(m, I, b, "#gview_" + f.p.id, a("#gview_" + f.p.id)[0]); if (o){a("#pData, #nData", "#" + j + "_2").css("float", "right"); a(".EditButton", "#" + j + - "_2").css("text-align", "left")}c.topinfo && a(".tinfo", "#" + j + "_2").show(); c.bottominfo && a(".binfo", "#" + j + "_2").show(); K = I = null; a("#" + m.themodal).keydown(function(g){var n = g.target; if (a("#" + e).data("disabled") === true)return false; if (c.savekey[0] === true && g.which == c.savekey[1])if (n.tagName != "TEXTAREA"){a("#sData", "#" + j + "_2").trigger("click"); return false}if (g.which === 27){if (!t())return false; Y && hideModal(this, {gb:b.gbox, jqm:b.jqModal, onClose:c.onClose}); return false}if (c.navkeys[0] === true){if (a("#id_g", - "#" + j).val() == "_empty")return true; if (g.which == c.navkeys[1]){a("#pData", "#" + j + "_2").trigger("click"); return false}if (g.which == c.navkeys[2]){a("#nData", "#" + j + "_2").trigger("click"); return false}}}); if (b.checkOnUpdate){a("a.ui-jqdialog-titlebar-close span", "#" + m.themodal).removeClass("jqmClose"); a("a.ui-jqdialog-titlebar-close", "#" + m.themodal).unbind("click").click(function(){if (!t())return false; hideModal("#" + m.themodal, {gb:"#gbox_" + l, jqm:b.jqModal, onClose:c.onClose}); return false})}b.saveicon = a.extend([true, - "left", "ui-icon-disk"], b.saveicon); b.closeicon = a.extend([true, "left", "ui-icon-close"], b.closeicon); if (b.saveicon[0] === true)a("#sData", "#" + j + "_2").addClass(b.saveicon[1] == "right"?"fm-button-icon-right":"fm-button-icon-left").append(""); if (b.closeicon[0] === true)a("#cData", "#" + j + "_2").addClass(b.closeicon[1] == "right"?"fm-button-icon-right":"fm-button-icon-left").append(""); if (c.checkOnSubmit || c.checkOnUpdate){Z = - "" + b.bYes + ""; N = "" + b.bNo + ""; $ = "" + b.bExit + ""; I = b.zIndex || 999; I++; a("
" + b.saveData + "

" + Z + N + $ + "
").insertAfter("#" + e); a("#sNew", "#" + m.themodal).click(function(){p(); a("#" + e).data("disabled", false); a(".confirm", "#" + m.themodal).hide(); return false}); a("#nNew", "#" + m.themodal).click(function(){a(".confirm", "#" + - m.themodal).hide(); a("#" + e).data("disabled", false); setTimeout(function(){a(":input", "#" + e)[0].focus()}, 0); return false}); a("#cNew", "#" + m.themodal).click(function(){a(".confirm", "#" + m.themodal).hide(); a("#" + e).data("disabled", false); hideModal("#" + m.themodal, {gb:"#gbox_" + l, jqm:b.jqModal, onClose:c.onClose}); return false})}s && s(a("#" + e)); d == "_empty" || !c.viewPagerButtons?a("#pData,#nData", "#" + j + "_2").hide():a("#pData,#nData", "#" + j + "_2").show(); u && u(a("#" + e)); a("#" + m.themodal).data("onClose", c.onClose); - viewModal("#" + m.themodal, {gbox:"#gbox_" + l, jqm:b.jqModal, closeoverlay:S, modal:b.modal}); S || a(".jqmOverlay").click(function(){if (!t())return false; hideModal("#" + m.themodal, {gb:"#gbox_" + l, jqm:b.jqModal, onClose:c.onClose}); return false}); Q && Q(a("#" + e)); a(".fm-button", "#" + m.themodal).hover(function(){a(this).addClass("ui-state-hover")}, function(){a(this).removeClass("ui-state-hover")}); a("#sData", "#" + j + "_2").click(function(){k = {}; i = {}; a("#FormError", "#" + j).hide(); F(); if (k[f.p.id + "_id"] == "_empty")p(); else if (b.checkOnSubmit === - true){w = a.extend({}, k, i); if (O = H(w, c._savedData)){a("#" + e).data("disabled", true); a(".confirm", "#" + m.themodal).show()} else p()} else p(); return false}); a("#cData", "#" + j + "_2").click(function(){if (!t())return false; hideModal("#" + m.themodal, {gb:"#gbox_" + l, jqm:b.jqModal, onClose:c.onClose}); return false}); a("#nData", "#" + j + "_2").click(function(){if (!t())return false; a("#FormError", "#" + j).hide(); var g = D(); g[0] = parseInt(g[0], 10); if (g[0] != - 1 && g[1][g[0] + 1]){a.isFunction(b.onclickPgButtons) && b.onclickPgButtons("next", - a("#" + e), g[1][g[0]]); h(g[1][g[0] + 1], f, e); a(f).jqGrid("setSelection", g[1][g[0] + 1]); a.isFunction(b.afterclickPgButtons) && b.afterclickPgButtons("next", a("#" + e), g[1][g[0] + 1]); q(g[0] + 1, g[1].length - 1)}return false}); a("#pData", "#" + j + "_2").click(function(){if (!t())return false; a("#FormError", "#" + j).hide(); var g = D(); if (g[0] != - 1 && g[1][g[0] - 1]){a.isFunction(b.onclickPgButtons) && b.onclickPgButtons("prev", a("#" + e), g[1][g[0]]); h(g[1][g[0] - 1], f, e); a(f).jqGrid("setSelection", g[1][g[0] - 1]); a.isFunction(b.afterclickPgButtons) && - b.afterclickPgButtons("prev", a("#" + e), g[1][g[0] - 1]); q(g[0] - 1, g[1].length - 1)}return false})}u = D(); q(u[0], u[1].length - 1)}})}, viewGridRow:function(d, b){b = a.extend({top:0, left:0, width:0, height:"auto", dataheight:"auto", modal:false, drag:true, resize:true, jqModal:true, closeOnEscape:false, labelswidth:"30%", closeicon:[], navkeys:[false, 38, 40], onClose:null, beforeShowForm:null, viewPagerButtons:true}, a.jgrid.view, b || {}); return this.each(function(){function q(){if (b.closeOnEscape === true || b.navkeys[0] === true)setTimeout(function(){a(".ui-jqdialog-titlebar-close", - "#" + l.modalhead).focus()}, 0)}function D(i, w){i === 0?a("#pData", "#" + f + "_2").addClass("ui-state-disabled"):a("#pData", "#" + f + "_2").removeClass("ui-state-disabled"); i == w?a("#nData", "#" + f + "_2").addClass("ui-state-disabled"):a("#nData", "#" + f + "_2").removeClass("ui-state-disabled")}function t(){var i = a(h).jqGrid("getDataIDs"), w = a("#id_g", "#" + f).val(); return[a.inArray(w, i), i]}function F(i, w, O, S){for (var I, K, L, N = 0, Z, $, aa = [], Y = false, g = "  ", n = "", v = ["integer", "number", "currency"], r = 0, E = 0, A, B, M, x = 1; x <= S; x++)n += x == 1?g:"  "; a(w.p.colModel).each(function(){K = this.editrules && this.editrules.edithidden === true?false:this.hidden === true?true:false; if (!K && this.align === "right")if (this.formatter && a.inArray(this.formatter, v) !== - 1)r = - Math.max(r, parseInt(this.width, 10)); else E = Math.max(E, parseInt(this.width, 10))}); A = r !== 0?r:E !== 0?E:0; Y = a(w).jqGrid("getInd", i); a(w.p.colModel).each(function(P){I = this.name; B = false; $ = (K = this.editrules && this.editrules.edithidden === true?false:this.hidden === true?true:false)?"style='display:none'":""; M = typeof this.viewable != "boolean"?true:this.viewable; if (I !== "cb" && I !== "subgrid" && I !== "rn" && M){Z = Y === false?"":I == w.p.ExpandColumn && w.p.treeGrid === true?a("td:eq(" + P + ")", w.rows[Y]).text():a("td:eq(" + P + ")", w.rows[Y]).html(); - B = this.align === "right" && A !== 0?true:false; a.extend({}, this.editoptions || {}, {id:I, name:I}); var C = a.extend({}, {rowabove:false, rowcontent:""}, this.formoptions || {}), T = parseInt(C.rowpos, 10) || N + 1, G = parseInt((parseInt(C.colpos, 10) || 1) * 2, 10); if (C.rowabove){var V = a("" + C.rowcontent + ""); a(O).append(V); V[0].rp = T}L = a(O).find("tr[rowpos=" + T + "]"); if (L.length === 0){L = a("").addClass("FormData").attr("id", "trv_" + I); a(L).append(n); a(O).append(L); - L[0].rp = T}a("td:eq(" + (G - 2) + ")", L[0]).html("" + (typeof C.label === "undefined"?w.p.colNames[P]:C.label) + ""); a("td:eq(" + (G - 1) + ")", L[0]).append("" + Z + "").attr("id", "v_" + I); B && a("td:eq(" + (G - 1) + ") span", L[0]).css({"text-align":"right", width:A + "px"}); aa[N] = P; N++}}); if (N > 0){i = a(""); i[0].rp = N + 99; a(O).append(i)}return aa} - function z(i, w){var O, S, I = 0, K, L; if (L = a(w).jqGrid("getInd", i, true)){a("td", L).each(function(N){O = w.p.colModel[N].name; S = w.p.colModel[N].editrules && w.p.colModel[N].editrules.edithidden === true?false:w.p.colModel[N].hidden === true?true:false; if (O !== "cb" && O !== "subgrid" && O !== "rn"){K = O == w.p.ExpandColumn && w.p.treeGrid === true?a(this).text():a(this).html(); a.extend({}, w.p.colModel[N].editoptions || {}); O = a.jgrid.jqID("v_" + O); a("#" + O + " span", "#" + f).html(K); S && a("#" + O, "#" + f).parents("tr:first").hide(); I++}}); I > - 0 && a("#id_g", "#" + f).val(i)}}var h = this; if (h.grid && d){if (!b.imgpath)b.imgpath = h.p.imgpath; var p = h.p.id, H = "ViewGrid_" + p, f = "ViewTbl_" + p, l = {themodal:"viewmod" + p, modalhead:"viewhd" + p, modalcontent:"viewcnt" + p, scrollelm:H}, e = 1, j = 0; if (a("#" + l.themodal).html() != null){a(".ui-jqdialog-title", "#" + l.modalhead).html(b.caption); a("#FormError", "#" + f).hide(); z(d, h); a.isFunction(b.beforeShowForm) && b.beforeShowForm(a("#" + H)); viewModal("#" + l.themodal, {gbox:"#gbox_" + p, jqm:b.jqModal, jqM:false, modal:b.modal}); q()} else{a(h.p.colModel).each(function(){var i = - this.formoptions; e = Math.max(e, i?i.colpos || 0:0); j = Math.max(j, i?i.rowpos || 0:0)}); var m = isNaN(b.dataheight)?b.dataheight:b.dataheight + "px", u = a("
"), Q = a("
"); a(u).append(Q); F(d, h, Q, e); m = h.p.direction == "rtl"?true:false; var o = "", s = "", y = "" + b.bClose + ""; if (j > 0){var J = []; a.each(a(Q)[0].rows, function(i, w){J[i] = w}); J.sort(function(i, w){if (i.rp > w.rp)return 1; - if (i.rp < w.rp)return - 1; return 0}); a.each(J, function(i, w){a("tbody", Q).append(w)})}b.gbox = "#gbox_" + p; var k = false; if (b.closeOnEscape === true){b.closeOnEscape = false; k = true}u = a("").append(u).append("
" + y + "
"); createModal(l, u, b, "#gview_" + h.p.id, a("#gview_" + h.p.id)[0]); - if (m){a("#pData, #nData", "#" + f + "_2").css("float", "right"); a(".EditButton", "#" + f + "_2").css("text-align", "left")}b.viewPagerButtons || a("#pData, #nData", "#" + f + "_2").hide(); u = null; a("#" + l.themodal).keydown(function(i){if (i.which === 27){k && hideModal(this, {gb:b.gbox, jqm:b.jqModal, onClose:b.onClose}); return false}if (b.navkeys[0] === true){if (i.which === b.navkeys[1]){a("#pData", "#" + f + "_2").trigger("click"); return false}if (i.which === b.navkeys[2]){a("#nData", "#" + f + "_2").trigger("click"); return false}}}); b.closeicon = - a.extend([true, "left", "ui-icon-close"], b.closeicon); if (b.closeicon[0] === true)a("#cData", "#" + f + "_2").addClass(b.closeicon[1] == "right"?"fm-button-icon-right":"fm-button-icon-left").append(""); a.isFunction(b.beforeShowForm) && b.beforeShowForm(a("#" + H)); viewModal("#" + l.themodal, {gbox:"#gbox_" + p, jqm:b.jqModal, modal:b.modal}); a(".fm-button:not(.ui-state-disabled)", "#" + f + "_2").hover(function(){a(this).addClass("ui-state-hover")}, function(){a(this).removeClass("ui-state-hover")}); - q(); a("#cData", "#" + f + "_2").click(function(){hideModal("#" + l.themodal, {gb:"#gbox_" + p, jqm:b.jqModal, onClose:b.onClose}); return false}); a("#nData", "#" + f + "_2").click(function(){a("#FormError", "#" + f).hide(); var i = t(); i[0] = parseInt(i[0], 10); if (i[0] != - 1 && i[1][i[0] + 1]){a.isFunction(b.onclickPgButtons) && b.onclickPgButtons("next", a("#" + H), i[1][i[0]]); z(i[1][i[0] + 1], h); a(h).jqGrid("setSelection", i[1][i[0] + 1]); a.isFunction(b.afterclickPgButtons) && b.afterclickPgButtons("next", a("#" + H), i[1][i[0] + 1]); D(i[0] + 1, i[1].length - - 1)}q(); return false}); a("#pData", "#" + f + "_2").click(function(){a("#FormError", "#" + f).hide(); var i = t(); if (i[0] != - 1 && i[1][i[0] - 1]){a.isFunction(b.onclickPgButtons) && b.onclickPgButtons("prev", a("#" + H), i[1][i[0]]); z(i[1][i[0] - 1], h); a(h).jqGrid("setSelection", i[1][i[0] - 1]); a.isFunction(b.afterclickPgButtons) && b.afterclickPgButtons("prev", a("#" + H), i[1][i[0] - 1]); D(i[0] - 1, i[1].length - 1)}q(); return false})}m = t(); D(m[0], m[1].length - 1)}})}, delGridRow:function(d, b){c = b = a.extend({top:0, left:0, width:240, height:"auto", - dataheight:"auto", modal:false, drag:true, resize:true, url:"", mtype:"POST", reloadAfterSubmit:true, beforeShowForm:null, afterShowForm:null, beforeSubmit:null, onclickSubmit:null, afterSubmit:null, jqModal:true, closeOnEscape:false, delData:{}, delicon:[], cancelicon:[], onClose:null, ajaxDelOptions:{}, processing:false, serializeDelData:null, useDataProxy:false}, a.jgrid.del, b || {}); return this.each(function(){var q = this; if (q.grid)if (d){var D = typeof b.beforeShowForm === "function"?true:false, t = typeof b.afterShowForm === - "function"?true:false, F = q.p.id, z = {}, h = "DelTbl_" + F, p, H, f, l, e = {themodal:"delmod" + F, modalhead:"delhd" + F, modalcontent:"delcnt" + F, scrollelm:h}; if (jQuery.isArray(d))d = d.join(); if (a("#" + e.themodal).html() != null){a("#DelData>td", "#" + h).text(d); a("#DelError", "#" + h).hide(); if (c.processing === true){c.processing = false; a("#dData", "#" + h).removeClass("ui-state-active")}D && b.beforeShowForm(a("#" + h)); viewModal("#" + e.themodal, {gbox:"#gbox_" + F, jqm:b.jqModal, jqM:false, modal:b.modal})} else{var j = isNaN(b.dataheight)?b.dataheight: - b.dataheight + "px"; j = "
"; j += ""; j += ""; j += ""; j += '"; j += "
' + b.msg + "
 
"; j += "
" + ("" + b.bSubmit + "") + " " + ("" + b.bCancel + "") + "
"; b.gbox = "#gbox_" + F; createModal(e, j, b, "#gview_" + q.p.id, a("#gview_" + q.p.id)[0]); a(".fm-button", - "#" + h + "_2").hover(function(){a(this).addClass("ui-state-hover")}, function(){a(this).removeClass("ui-state-hover")}); b.delicon = a.extend([true, "left", "ui-icon-scissors"], b.delicon); b.cancelicon = a.extend([true, "left", "ui-icon-cancel"], b.cancelicon); if (b.delicon[0] === true)a("#dData", "#" + h + "_2").addClass(b.delicon[1] == "right"?"fm-button-icon-right":"fm-button-icon-left").append(""); if (b.cancelicon[0] === true)a("#eData", "#" + h + "_2").addClass(b.cancelicon[1] == - "right"?"fm-button-icon-right":"fm-button-icon-left").append(""); a("#dData", "#" + h + "_2").click(function(){var m = [true, ""]; z = {}; var u = a("#DelData>td", "#" + h).text(); if (typeof b.onclickSubmit === "function")z = b.onclickSubmit(c, u) || {}; if (typeof b.beforeSubmit === "function")m = b.beforeSubmit(u); if (m[0] && !c.processing){c.processing = true; a(this).addClass("ui-state-active"); f = q.p.prmNames; p = a.extend({}, c.delData, z); l = f.oper; p[l] = f.deloper; H = f.id; p[H] = u; var Q = a.extend({url:c.url? - c.url:a(q).jqGrid("getGridParam", "editurl"), type:b.mtype, data:a.isFunction(b.serializeDelData)?b.serializeDelData(p):p, complete:function(o, s){if (s != "success"){m[0] = false; m[1] = a.isFunction(c.errorTextFormat)?c.errorTextFormat(o):s + " Status: '" + o.statusText + "'. Error code: " + o.status} else if (typeof c.afterSubmit === "function")m = c.afterSubmit(o, p); if (m[0] === false){a("#DelError>td", "#" + h).html(m[1]); a("#DelError", "#" + h).show()} else{if (c.reloadAfterSubmit)a(q).trigger("reloadGrid"); else{s = []; s = u.split(","); - if (q.p.treeGrid === true)try{a(q).jqGrid("delTreeNode", s[0])} catch (y){} else for (var J = 0; J < s.length; J++)a(q).jqGrid("delRowData", s[J]); q.p.selrow = null; q.p.selarrrow = []}a.isFunction(c.afterComplete) && setTimeout(function(){c.afterComplete(o, u)}, 500)}c.processing = false; a("#dData", "#" + h + "_2").removeClass("ui-state-active"); m[0] && hideModal("#" + e.themodal, {gb:"#gbox_" + F, jqm:b.jqModal, onClose:c.onClose})}, error:function(o, s, y){a("#DelError>td", "#" + h).html(s + " : " + y); a("#DelError", "#" + h).show(); c.processing = - false; a("#dData", "#" + h + "_2").removeClass("ui-state-active")}}, a.jgrid.ajaxOptions, b.ajaxDelOptions); if (!Q.url && !c.useDataProxy)if (a.isFunction(q.p.dataProxy))c.useDataProxy = true; else{m[0] = false; m[1] += " " + a.jgrid.errors.nourl}if (m[0])c.useDataProxy?q.p.dataProxy.call(q, Q, "del_" + q.p.id):a.ajax(Q)}if (m[0] === false){a("#DelError>td", "#" + h).html(m[1]); a("#DelError", "#" + h).show()}return false}); a("#eData", "#" + h + "_2").click(function(){hideModal("#" + e.themodal, {gb:"#gbox_" + F, jqm:b.jqModal, onClose:c.onClose}); - return false}); D && b.beforeShowForm(a("#" + h)); viewModal("#" + e.themodal, {gbox:"#gbox_" + F, jqm:b.jqModal, modal:b.modal})}t && b.afterShowForm(a("#" + h)); b.closeOnEscape === true && setTimeout(function(){a(".ui-jqdialog-titlebar-close", "#" + e.modalhead).focus()}, 0)}})}, navGrid:function(d, b, q, D, t, F, z){b = a.extend({edit:true, editicon:"ui-icon-pencil", add:true, addicon:"ui-icon-plus", del:true, delicon:"ui-icon-trash", search:true, searchicon:"ui-icon-search", refresh:true, refreshicon:"ui-icon-refresh", refreshstate:"firstpage", - view:false, viewicon:"ui-icon-document", position:"left", closeOnEscape:true, beforeRefresh:null, afterRefresh:null, cloneToTop:false}, a.jgrid.nav, b || {}); return this.each(function(){var h = {themodal:"alertmod", modalhead:"alerthd", modalcontent:"alertcnt"}, p = this, H, f, l; if (!(!p.grid || typeof d != "string")){if (a("#" + h.themodal).html() === null){if (typeof window.innerWidth != "undefined"){H = window.innerWidth; f = window.innerHeight} else if (typeof document.documentElement != "undefined" && typeof document.documentElement.clientWidth != - "undefined" && document.documentElement.clientWidth !== 0){H = document.documentElement.clientWidth; f = document.documentElement.clientHeight} else{H = 1024; f = 768}createModal(h, "
" + b.alerttext + "
", {gbox:"#gbox_" + p.p.id, jqModal:true, drag:true, resize:true, caption:b.alertcap, top:f / 2 - 25, left:H / 2 - 100, width:200, height:"auto", closeOnEscape:b.closeOnEscape}, "", "", true)}H = 1; if (b.cloneToTop && p.p.toppager)H = 2; for (f = 0; f < H; f++){var e = a(""), - j, m; if (f === 0){j = d; m = p.p.id; if (j == p.p.toppager){m += "_top"; H = 1}} else{j = p.p.toppager; m = p.p.id + "_top"}p.p.direction == "rtl" && a(e).attr("dir", "rtl").css("float", "right"); if (b.add){D = D || {}; l = a(""); a(l).append("
" + b.addtext + "
"); a("tr", e).append(l); a(l, e).attr({title:b.addtitle || "", id:D.id || "add_" + m}).click(function(){a(this).hasClass("ui-state-disabled") || (typeof b.addfunc == "function"?b.addfunc(): - a(p).jqGrid("editGridRow", "new", D)); return false}).hover(function(){a(this).hasClass("ui-state-disabled") || a(this).addClass("ui-state-hover")}, function(){a(this).removeClass("ui-state-hover")}); l = null}if (b.edit){l = a(""); q = q || {}; a(l).append("
" + b.edittext + "
"); a("tr", e).append(l); a(l, e).attr({title:b.edittitle || "", id:q.id || "edit_" + m}).click(function(){if (!a(this).hasClass("ui-state-disabled")){var u = - p.p.selrow; if (u)typeof b.editfunc == "function"?b.editfunc(u):a(p).jqGrid("editGridRow", u, q); else{viewModal("#" + h.themodal, {gbox:"#gbox_" + p.p.id, jqm:true}); a("#jqg_alrt").focus()}}return false}).hover(function(){a(this).hasClass("ui-state-disabled") || a(this).addClass("ui-state-hover")}, function(){a(this).removeClass("ui-state-hover")}); l = null}if (b.view){l = a(""); z = z || {}; a(l).append("
" + b.viewtext + - "
"); a("tr", e).append(l); a(l, e).attr({title:b.viewtitle || "", id:z.id || "view_" + m}).click(function(){if (!a(this).hasClass("ui-state-disabled")){var u = p.p.selrow; if (u)a(p).jqGrid("viewGridRow", u, z); else{viewModal("#" + h.themodal, {gbox:"#gbox_" + p.p.id, jqm:true}); a("#jqg_alrt").focus()}}return false}).hover(function(){a(this).hasClass("ui-state-disabled") || a(this).addClass("ui-state-hover")}, function(){a(this).removeClass("ui-state-hover")}); l = null}if (b.del){l = a(""); - t = t || {}; a(l).append("
" + b.deltext + "
"); a("tr", e).append(l); a(l, e).attr({title:b.deltitle || "", id:t.id || "del_" + m}).click(function(){if (!a(this).hasClass("ui-state-disabled")){var u; if (p.p.multiselect){u = p.p.selarrrow; if (u.length === 0)u = null} else u = p.p.selrow; if (u)"function" == typeof b.delfunc?b.delfunc(u):a(p).jqGrid("delGridRow", u, t); else{viewModal("#" + h.themodal, {gbox:"#gbox_" + p.p.id, jqm:true}); a("#jqg_alrt").focus()}}return false}).hover(function(){a(this).hasClass("ui-state-disabled") || - a(this).addClass("ui-state-hover")}, function(){a(this).removeClass("ui-state-hover")}); l = null}if (b.add || b.edit || b.del || b.view)a("tr", e).append(""); if (b.search){l = a(""); F = F || {}; a(l).append("
" + b.searchtext + "
"); a("tr", e).append(l); a(l, e).attr({title:b.searchtitle || "", id:F.id || "search_" + - m}).click(function(){a(this).hasClass("ui-state-disabled") || a(p).jqGrid("searchGrid", F); return false}).hover(function(){a(this).hasClass("ui-state-disabled") || a(this).addClass("ui-state-hover")}, function(){a(this).removeClass("ui-state-hover")}); l = null}if (b.refresh){l = a(""); a(l).append("
" + b.refreshtext + "
"); a("tr", e).append(l); a(l, e).attr({title:b.refreshtitle || "", id:"refresh_" + m}).click(function(){if (!a(this).hasClass("ui-state-disabled")){a.isFunction(b.beforeRefresh) && - b.beforeRefresh(); p.p.search = false; try{a("#fbox_" + p.p.id).searchFilter().reset(); a.isFunction(p.clearToolbar) && p.clearToolbar(false)} catch (u){}switch (b.refreshstate){case "firstpage":a(p).trigger("reloadGrid", [{page:1}]); break; case "current":a(p).trigger("reloadGrid", [{current:true}]); break}a.isFunction(b.afterRefresh) && b.afterRefresh()}return false}).hover(function(){a(this).hasClass("ui-state-disabled") || a(this).addClass("ui-state-hover")}, function(){a(this).removeClass("ui-state-hover")}); l = null}l = - a(".ui-jqgrid").css("font-size") || "11px"; a("body").append(""); l = a(e).clone().appendTo("#testpg2").width(); a("#testpg2").remove(); a(j + "_" + b.position, j).append(e); if (p.p._nvtd){if (l > p.p._nvtd[0]){a(j + "_" + b.position, j).width(l); p.p._nvtd[0] = l}p.p._nvtd[1] = l}e = l = l = null}}})}, navButtonAdd:function(d, b){b = a.extend({caption:"newButton", title:"", buttonicon:"ui-icon-newwin", onClickButton:null, position:"last", - cursor:"pointer"}, b || {}); return this.each(function(){if (this.grid){if (d.indexOf("#") !== 0)d = "#" + d; var q = a(".navtable", d)[0], D = this; if (q){var t = a(""); b.buttonicon.toString().toUpperCase() == "NONE"?a(t).addClass("ui-pg-button ui-corner-all").append("
" + b.caption + "
"):a(t).addClass("ui-pg-button ui-corner-all").append("
" + b.caption + "
"); b.id && a(t).attr("id", b.id); if (b.position == "first")q.rows[0].cells.length === - 0?a("tr", q).append(t):a("tr td:eq(0)", q).before(t); else a("tr", q).append(t); a(t, q).attr("title", b.title || "").click(function(F){a(this).hasClass("ui-state-disabled") || a.isFunction(b.onClickButton) && b.onClickButton.call(D, F); return false}).hover(function(){a(this).hasClass("ui-state-disabled") || a(this).addClass("ui-state-hover")}, function(){a(this).removeClass("ui-state-hover")})}}})}, navSeparatorAdd:function(d, b){b = a.extend({sepclass:"ui-separator", sepcontent:""}, b || {}); return this.each(function(){if (this.grid){if (d.indexOf("#") !== - 0)d = "#" + d; var q = a(".navtable", d)[0]; if (q){var D = "" + b.sepcontent + ""; a("tr", q).append(D)}}})}, GridToForm:function(d, b){return this.each(function(){var q = this; if (q.grid){var D = a(q).jqGrid("getRowData", d); if (D)for (var t in D)a("[name=" + t + "]", b).is("input:radio") || a("[name=" + t + "]", b).is("input:checkbox")?a("[name=" + t + "]", b).each(function(){a(this).val() == D[t]?a(this).attr("checked", "checked"):a(this).attr("checked", - "")}):a("[name=" + t + "]", b).val(D[t])}})}, FormToGrid:function(d, b, q, D){return this.each(function(){var t = this; if (t.grid){q || (q = "set"); D || (D = "first"); var F = a(b).serializeArray(), z = {}; a.each(F, function(h, p){z[p.name] = p.value}); if (q == "add")a(t).jqGrid("addRowData", d, z, D); else q == "set" && a(t).jqGrid("setRowData", d, z)}})}})})(jQuery); - jQuery.fn.searchFilter = function(k, H){function I(e, l, v){this.$ = e; this.add = function(a){a == null?e.find(".ui-add-last").click():e.find(".sf:eq(" + a + ") .ui-add").click(); return this}; this.del = function(a){a == null?e.find(".sf:last .ui-del").click():e.find(".sf:eq(" + a + ") .ui-del").click(); return this}; this.search = function(){e.find(".ui-search").click(); return this}; this.reset = function(){e.find(".ui-reset").click(); return this}; this.close = function(){e.find(".ui-closer").click(); return this}; if (l != null){function C(){jQuery(this).toggleClass("ui-state-hover"); - return false}function D(a){jQuery(this).toggleClass("ui-state-active", a.type == "mousedown"); return false}function m(a, b){return""}function w(a, b, d){return""}function E(a, b){a = e.find("tr.sf td.data " + a); a[0] != null && b(a)}function F(a, b){var d = e.find("tr.sf td.data " + a); d[0] != null && jQuery.each(b, function(){this.data != null?d.bind(this.type, this.data, this.fn):d.bind(this.type, this.fn)})}var f = jQuery.extend({}, - jQuery.fn.searchFilter.defaults, v), n = - 1, r = ""; jQuery.each(f.groupOps, function(){r += m(this.op, this.text)}); r = ""; e.html("").addClass("ui-searchFilter").append("
 
" + - f.windowTitle + "
 
" + - f.resetText + "" + f.searchText + "" + f.matchText + " " + r + " " + f.rulesText + " 
"); - var x = e.find("tr.sf"), G = x.find("td.fields"), y = x.find("td.ops"), o = x.find("td.data"), s = ""; jQuery.each(f.operators, function(){s += m(this.op, this.text)}); s = w("default", s, true); y.append(s); o.append(""); var t = "", z = false, p = false; jQuery.each(l, function(a){t += m(this.itemval, this.text); if (this.ops != null){z = true; var b = ""; jQuery.each(this.ops, function(){b += m(this.op, this.text)}); b = w("field" + a, b, true); y.append(b)}if (this.dataUrl != null){if (a > n)n = a; p = true; - var d = this.dataEvents, c = this.dataInit, g = this.buildSelect; jQuery.ajax(jQuery.extend({url:this.dataUrl, complete:function(h){h = g != null?jQuery("
").append(g(h)):jQuery("
").append(h.responseText); h.find("select").addClass("field" + a).hide(); o.append(h.html()); c && E(".field" + a, c); d && F(".field" + a, d); a == n && e.find("tr.sf td.fields select[name='field']").change()}}, f.ajaxSelectOptions))} else if (this.dataValues != null){p = true; var i = ""; jQuery.each(this.dataValues, function(){i += m(this.value, this.text)}); - i = w("field" + a, i, true); o.append(i)} else if (this.dataEvents != null || this.dataInit != null){p = true; i = ""; o.append(i)}this.dataInit != null && a != n && E(".field" + a, this.dataInit); this.dataEvents != null && a != n && F(".field" + a, this.dataEvents)}); t = ""; G.append(t); l = G.find("select[name='field']"); z?l.change(function(a){var b = a.target.selectedIndex; a = jQuery(a.target).parents("tr.sf").find("td.ops"); a.find("select").removeAttr("name").hide(); b = a.find(".field" + - b); if (b[0] == null)b = a.find(".default"); b.attr("name", "op").show()}):y.find(".default").attr("name", "op").show(); p?l.change(function(a){var b = a.target.selectedIndex; a = jQuery(a.target).parents("tr.sf").find("td.data"); a.find("select,input").removeClass("vdata").hide(); b = a.find(".field" + b); if (b[0] == null)b = a.find(".default"); b.show().addClass("vdata")}):o.find(".default").show().addClass("vdata"); if (z || p)l.change(); e.find(".ui-state-default").hover(C, C).mousedown(D).mouseup(D); e.find(".ui-closer").click(function(){f.onClose(jQuery(e.selector)); - return false}); e.find(".ui-del").click(function(a){a = jQuery(a.target).parents(".sf"); if (a.siblings(".sf").length > 0){f.datepickerFix === true && jQuery.fn.datepicker !== undefined && a.find(".hasDatepicker").datepicker("destroy"); a.remove()} else{a.find("select[name='field']")[0].selectedIndex = 0; a.find("select[name='op']")[0].selectedIndex = 0; a.find(".data input").val(""); a.find(".data select").each(function(){this.selectedIndex = 0}); a.find("select[name='field']").change()}return false}); e.find(".ui-add").click(function(a){a = - jQuery(a.target).parents(".sf"); var b = a.clone(true).insertAfter(a); b.find(".ui-state-default").removeClass("ui-state-hover ui-state-active"); if (f.clone){b.find("select[name='field']")[0].selectedIndex = a.find("select[name='field']")[0].selectedIndex; if (b.find("select[name='op']")[0] != null)b.find("select[name='op']").focus()[0].selectedIndex = a.find("select[name='op']")[0].selectedIndex; var d = b.find("select.vdata"); if (d[0] != null)d[0].selectedIndex = a.find("select.vdata")[0].selectedIndex} else{b.find(".data input").val(""); - b.find("select[name='field']").focus()}f.datepickerFix === true && jQuery.fn.datepicker !== undefined && a.find(".hasDatepicker").each(function(){var c = jQuery.data(this, "datepicker").settings; b.find("#" + this.id).unbind().removeAttr("id").removeClass("hasDatepicker").datepicker(c)}); b.find("select[name='field']").change(); return false}); e.find(".ui-search").click(function(){var a = jQuery(e.selector), b, d = a.find("select[name='groupOp'] :selected").val(); b = f.stringResult?'{"groupOp":"' + d + '","rules":[':{groupOp:d, - rules:[]}; a.find(".sf").each(function(c){var g = jQuery(this).find("select[name='field'] :selected").val(), i = jQuery(this).find("select[name='op'] :selected").val(), h = jQuery(this).find("input.vdata,select.vdata :selected").val(); h += ""; h = h.replace(/\\/g, "\\\\").replace(/\"/g, '\\"'); if (f.stringResult){if (c > 0)b += ","; b += '{"field":"' + g + '",'; b += '"op":"' + i + '",'; b += '"data":"' + h + '"}'} else b.rules.push({field:g, op:i, data:h})}); if (f.stringResult)b += "]}"; f.onSearch(b); return false}); e.find(".ui-reset").click(function(){var a = - jQuery(e.selector); a.find(".ui-del").click(); a.find("select[name='groupOp']")[0].selectedIndex = 0; f.onReset(); return false}); e.find(".ui-add-last").click(function(){var a = jQuery(e.selector + " .sf:last"), b = a.clone(true).insertAfter(a); b.find(".ui-state-default").removeClass("ui-state-hover ui-state-active"); b.find(".data input").val(""); b.find("select[name='field']").focus(); f.datepickerFix === true && jQuery.fn.datepicker !== undefined && a.find(".hasDatepicker").each(function(){var d = jQuery.data(this, "datepicker").settings; - b.find("#" + this.id).unbind().removeAttr("id").removeClass("hasDatepicker").datepicker(d)}); b.find("select[name='field']").change(); return false}); this.setGroupOp = function(a){selDOMobj = this.$.find("select[name='groupOp']")[0]; var b = {}, d = selDOMobj.options.length, c; for (c = 0; c < d; c++)b[selDOMobj.options[c].value] = c; selDOMobj.selectedIndex = b[a]; $(selDOMobj).change()}; this.setFilter = function(a){var b = a.sfref; a = a.filter; var d = [], c, g, i, h, j = {}; selDOMobj = b.find("select[name='field']")[0]; c = 0; for (i = selDOMobj.options.length; c < - i; c++){j[selDOMobj.options[c].value] = {index:c, ops:{}}; d.push(selDOMobj.options[c].value)}c = 0; for (i = d.length; c < i; c++){if (selDOMobj = b.find(".ops > select[class='field" + c + "']")[0]){g = 0; for (h = selDOMobj.options.length; g < h; g++)j[d[c]].ops[selDOMobj.options[g].value] = g}if (selDOMobj = b.find(".data > select[class='field" + c + "']")[0]){j[d[c]].data = {}; g = 0; for (h = selDOMobj.options.length; g < h; g++)j[d[c]].data[selDOMobj.options[g].value] = g}}var u, q, A, B; d = a.field; if (j[d])u = j[d].index; if (u != null){q = j[d].ops[a.op]; if (q === - undefined){c = 0; for (i = v.operators.length; c < i; c++)if (v.operators[c].op == a.op){q = c; break}}A = a.data; B = j[d].data == null? - 1:j[d].data[A]}if (u != null && q != null && B != null){b.find("select[name='field']")[0].selectedIndex = u; b.find("select[name='field']").change(); b.find("select[name='op']")[0].selectedIndex = q; b.find("input.vdata").val(A); if (b = b.find("select.vdata")[0])b.selectedIndex = B; return true} else return false}}}return new I(this, k, H)}; jQuery.fn.searchFilter.version = "1.2.9"; - jQuery.fn.searchFilter.defaults = {clone:true, datepickerFix:true, onReset:function(k){alert("Reset Clicked. Data Returned: " + k)}, onSearch:function(k){alert("Search Clicked. Data Returned: " + k)}, onClose:function(k){k.hide()}, groupOps:[{op:"AND", text:"all"}, {op:"OR", text:"any"}], operators:[{op:"eq", text:"is equal to"}, {op:"ne", text:"is not equal to"}, {op:"lt", text:"is less than"}, {op:"le", text:"is less or equal to"}, {op:"gt", text:"is greater than"}, {op:"ge", text:"is greater or equal to"}, {op:"in", text:"is in"}, - {op:"ni", text:"is not in"}, {op:"bw", text:"begins with"}, {op:"bn", text:"does not begin with"}, {op:"ew", text:"ends with"}, {op:"en", text:"does not end with"}, {op:"cn", text:"contains"}, {op:"nc", text:"does not contain"}], matchText:"match", rulesText:"rules", resetText:"Reset", searchText:"Search", stringResult:true, windowTitle:"Search Rules", ajaxSelectOptions:{}}; - (function(a){a.jgrid.extend({editRow:function(d, t, i, n, o, u, s, c, f){return this.each(function(){var b = this, k, l, r = 0, p = null, q = {}, h, g; if (b.grid){h = a(b).jqGrid("getInd", d, true); if (h !== false)if ((a(h).attr("editable") || "0") == "0" && !a(h).hasClass("not-editable-row")){g = b.p.colModel; a("td", h).each(function(j){k = g[j].name; var v = b.p.treeGrid === true && k == b.p.ExpandColumn; if (v)l = a("span:first", this).html(); else try{l = a.unformat(this, {rowId:d, colModel:g[j]}, j)} catch (m){l = a(this).html()}if (k != "cb" && k != "subgrid" && k != - "rn"){if (b.p.autoencode)l = a.jgrid.htmlDecode(l); q[k] = l; if (g[j].editable === true){if (p === null)p = j; v?a("span:first", this).html(""):a(this).html(""); var e = a.extend({}, g[j].editoptions || {}, {id:d + "_" + k, name:k}); if (!g[j].edittype)g[j].edittype = "text"; e = createEl(g[j].edittype, e, l, true, a.extend({}, a.jgrid.ajaxOptions, b.p.ajaxSelectOptions || {})); a(e).addClass("editable"); v?a("span:first", this).append(e):a(this).append(e); g[j].edittype == "select" && g[j].editoptions.multiple === true && a.browser.msie && a(e).width(a(e).width()); - r++}}}); if (r > 0){q.id = d; b.p.savedRow.push(q); a(h).attr("editable", "1"); a("td:eq(" + p + ") input", h).focus(); t === true && a(h).bind("keydown", function(j){j.keyCode === 27 && a(b).jqGrid("restoreRow", d, f); if (j.keyCode === 13){if (j.target.tagName == "TEXTAREA")return true; a(b).jqGrid("saveRow", d, n, o, u, s, c, f); return false}j.stopPropagation()}); a.isFunction(i) && i(d)}}}})}, saveRow:function(d, t, i, n, o, u, s){return this.each(function(){var c = this, f, b = {}, k = {}, l, r, p, q; if (c.grid){q = a(c).jqGrid("getInd", d, true); if (q !== false){l = - a(q).attr("editable"); i = i?i:c.p.editurl; if (l === "1"){var h; a("td", q).each(function(m){h = c.p.colModel[m]; f = h.name; if (f != "cb" && f != "subgrid" && h.editable === true && f != "rn"){switch (h.edittype){case "checkbox":var e = ["Yes", "No"]; if (h.editoptions)e = h.editoptions.value.split(":"); b[f] = a("input", this).attr("checked")?e[0]:e[1]; break; case "text":case "password":case "textarea":case "button":b[f] = a("input, textarea", this).val(); break; case "select":if (h.editoptions.multiple){e = a("select", this); var x = []; b[f] = a(e).val(); - b[f] = b[f]?b[f].join(","):""; a("select > option:selected", this).each(function(y, z){x[y] = a(z).text()}); k[f] = x.join(",")} else{b[f] = a("select>option:selected", this).val(); k[f] = a("select>option:selected", this).text()}if (h.formatter && h.formatter == "select")k = {}; break; case "custom":try{if (h.editoptions && a.isFunction(h.editoptions.custom_value)){b[f] = h.editoptions.custom_value(a(".customelement", this), "get"); if (b[f] === undefined)throw"e2"; } else throw"e1"; } catch (w){w == "e1" && info_dialog(jQuery.jgrid.errors.errcap, - "function 'custom_value' " + a.jgrid.edit.msg.nodefined, jQuery.jgrid.edit.bClose); w == "e2"?info_dialog(jQuery.jgrid.errors.errcap, "function 'custom_value' " + a.jgrid.edit.msg.novalue, jQuery.jgrid.edit.bClose):info_dialog(jQuery.jgrid.errors.errcap, w.message, jQuery.jgrid.edit.bClose)}break}p = checkValues(b[f], m, c); if (p[0] === false){p[1] = b[f] + " " + p[1]; return false}if (c.p.autoencode)b[f] = a.jgrid.htmlEncode(b[f])}}); if (p[0] === false)try{var g = findPos(a("#" + d)[0]); info_dialog(a.jgrid.errors.errcap, p[1], a.jgrid.edit.bClose, - {left:g[0], top:g[1]})} catch (j){alert(p[1])} else{if (b){var v; g = c.p.prmNames; v = g.oper; l = g.id; b[v] = g.editoper; b[l] = d; if (typeof c.p.inlineData == "undefined")c.p.inlineData = {}; if (typeof n == "undefined")n = {}; b = a.extend({}, b, c.p.inlineData, n)}if (i == "clientArray"){b = a.extend({}, b, k); c.p.autoencode && a.each(b, function(m, e){b[m] = a.jgrid.htmlDecode(e)}); l = a(c).jqGrid("setRowData", d, b); a(q).attr("editable", "0"); for (g = 0; g < c.p.savedRow.length; g++)if (c.p.savedRow[g].id == d){r = g; break}r >= 0 && c.p.savedRow.splice(r, 1); - a.isFunction(o) && o(d, l)} else{a("#lui_" + c.p.id).show(); a.ajax(a.extend({url:i, data:a.isFunction(c.p.serializeRowData)?c.p.serializeRowData(b):b, type:"POST", complete:function(m, e){a("#lui_" + c.p.id).hide(); if (e === "success")if ((a.isFunction(t)?t(m):true) === true){c.p.autoencode && a.each(b, function(x, w){b[x] = a.jgrid.htmlDecode(w)}); b = a.extend({}, b, k); a(c).jqGrid("setRowData", d, b); a(q).attr("editable", "0"); for (e = 0; e < c.p.savedRow.length; e++)if (c.p.savedRow[e].id == d){r = e; break}r >= 0 && c.p.savedRow.splice(r, 1); - a.isFunction(o) && o(d, m)} else a(c).jqGrid("restoreRow", d, s)}, error:function(m, e){a("#lui_" + c.p.id).hide(); a.isFunction(u)?u(d, m, e):alert("Error Row: " + d + " Result: " + m.status + ":" + m.statusText + " Status: " + e)}}, a.jgrid.ajaxOptions, c.p.ajaxRowOptions || {}))}a(q).unbind("keydown")}}}}})}, restoreRow:function(d, t){return this.each(function(){var i = this, n, o, u = {}; if (i.grid){o = a(i).jqGrid("getInd", d, true); if (o !== false){for (var s = 0; s < i.p.savedRow.length; s++)if (i.p.savedRow[s].id == d){n = s; break}if (n >= 0){if (a.isFunction(a.fn.datepicker))try{a("input.hasDatepicker", - "#" + o.id).datepicker("hide")} catch (c){}a.each(i.p.colModel, function(){if (this.editable === true && this.name in i.p.savedRow[n])u[this.name] = i.p.savedRow[n][this.name]}); a(i).jqGrid("setRowData", d, u); a(o).attr("editable", "0").unbind("keydown"); i.p.savedRow.splice(n, 1)}a.isFunction(t) && t(d)}}})}})})(jQuery); - (function(b){b.jgrid.extend({editCell:function(d, e, a){return this.each(function(){var c = this, h, f, g; if (!(!c.grid || c.p.cellEdit !== true)){e = parseInt(e, 10); c.p.selrow = c.rows[d].id; c.p.knv || b(c).jqGrid("GridNav"); if (c.p.savedRow.length > 0){if (a === true)if (d == c.p.iRow && e == c.p.iCol)return; b(c).jqGrid("saveCell", c.p.savedRow[0].id, c.p.savedRow[0].ic)} else window.setTimeout(function(){b("#" + c.p.knv).attr("tabindex", "-1").focus()}, 0); h = c.p.colModel[e].name; if (!(h == "subgrid" || h == "cb" || h == "rn")){g = b("td:eq(" + e + - ")", c.rows[d]); if (c.p.colModel[e].editable === true && a === true && !g.hasClass("not-editable-cell")){if (parseInt(c.p.iCol, 10) >= 0 && parseInt(c.p.iRow, 10) >= 0){b("td:eq(" + c.p.iCol + ")", c.rows[c.p.iRow]).removeClass("edit-cell ui-state-highlight"); b(c.rows[c.p.iRow]).removeClass("selected-row ui-state-hover")}b(g).addClass("edit-cell ui-state-highlight"); b(c.rows[d]).addClass("selected-row ui-state-hover"); try{f = b.unformat(g, {rowId:c.rows[d].id, colModel:c.p.colModel[e]}, e)} catch (k){f = b(g).html()}if (c.p.autoencode)f = - b.jgrid.htmlDecode(f); if (!c.p.colModel[e].edittype)c.p.colModel[e].edittype = "text"; c.p.savedRow.push({id:d, ic:e, name:h, v:f}); if (b.isFunction(c.p.formatCell)){var j = c.p.formatCell(c.rows[d].id, h, f, d, e); if (j !== undefined)f = j}j = b.extend({}, c.p.colModel[e].editoptions || {}, {id:d + "_" + h, name:h}); var i = createEl(c.p.colModel[e].edittype, j, f, true, b.extend({}, b.jgrid.ajaxOptions, c.p.ajaxSelectOptions || {})); b.isFunction(c.p.beforeEditCell) && c.p.beforeEditCell(c.rows[d].id, h, f, d, e); b(g).html("").append(i).attr("tabindex", - "0"); window.setTimeout(function(){b(i).focus()}, 0); b("input, select, textarea", g).bind("keydown", function(l){if (l.keyCode === 27)if (b("input.hasDatepicker", g).length > 0)b(".ui-datepicker").is(":hidden")?b(c).jqGrid("restoreCell", d, e):b("input.hasDatepicker", g).datepicker("hide"); else b(c).jqGrid("restoreCell", d, e); l.keyCode === 13 && b(c).jqGrid("saveCell", d, e); if (l.keyCode == 9)if (c.grid.hDiv.loading)return false; else l.shiftKey?b(c).jqGrid("prevCell", d, e):b(c).jqGrid("nextCell", d, e); l.stopPropagation()}); - b.isFunction(c.p.afterEditCell) && c.p.afterEditCell(c.rows[d].id, h, f, d, e)} else{if (parseInt(c.p.iCol, 10) >= 0 && parseInt(c.p.iRow, 10) >= 0){b("td:eq(" + c.p.iCol + ")", c.rows[c.p.iRow]).removeClass("edit-cell ui-state-highlight"); b(c.rows[c.p.iRow]).removeClass("selected-row ui-state-hover")}g.addClass("edit-cell ui-state-highlight"); b(c.rows[d]).addClass("selected-row ui-state-hover"); if (b.isFunction(c.p.onSelectCell)){f = g.html().replace(/\ \;/ig, ""); c.p.onSelectCell(c.rows[d].id, h, f, d, e)}}c.p.iCol = e; c.p.iRow = - d}}})}, saveCell:function(d, e){return this.each(function(){var a = this, c; if (!(!a.grid || a.p.cellEdit !== true)){c = a.p.savedRow.length >= 1?0:null; if (c !== null){var h = b("td:eq(" + e + ")", a.rows[d]), f, g, k = a.p.colModel[e], j = k.name, i = b.jgrid.jqID(j); switch (k.edittype){case "select":if (k.editoptions.multiple){i = b("#" + d + "_" + i, a.rows[d]); var l = []; if (f = b(i).val())f.join(","); else f = ""; b("option:selected", i).each(function(m, p){l[m] = b(p).text()}); g = l.join(",")} else{f = b("#" + d + "_" + i + ">option:selected", a.rows[d]).val(); - g = b("#" + d + "_" + i + ">option:selected", a.rows[d]).text()}if (k.formatter)g = f; break; case "checkbox":var n = ["Yes", "No"]; if (k.editoptions)n = k.editoptions.value.split(":"); g = f = b("#" + d + "_" + i, a.rows[d]).attr("checked")?n[0]:n[1]; break; case "password":case "text":case "textarea":case "button":g = f = b("#" + d + "_" + i, a.rows[d]).val(); break; case "custom":try{if (k.editoptions && b.isFunction(k.editoptions.custom_value)){f = k.editoptions.custom_value(b(".customelement", h), "get"); if (f === undefined)throw"e2"; else g = f} else throw"e1"; - } catch (q){q == "e1" && info_dialog(jQuery.jgrid.errors.errcap, "function 'custom_value' " + b.jgrid.edit.msg.nodefined, jQuery.jgrid.edit.bClose); q == "e2"?info_dialog(jQuery.jgrid.errors.errcap, "function 'custom_value' " + b.jgrid.edit.msg.novalue, jQuery.jgrid.edit.bClose):info_dialog(jQuery.jgrid.errors.errcap, q.message, jQuery.jgrid.edit.bClose)}break}if (g != a.p.savedRow[c].v){if (b.isFunction(a.p.beforeSaveCell))if (c = a.p.beforeSaveCell(a.rows[d].id, j, f, d, e))f = c; var r = checkValues(f, e, a); if (r[0] === true){c = {}; - if (b.isFunction(a.p.beforeSubmitCell))(c = a.p.beforeSubmitCell(a.rows[d].id, j, f, d, e)) || (c = {}); b("input.hasDatepicker", h).length > 0 && b("input.hasDatepicker", h).datepicker("hide"); if (a.p.cellsubmit == "remote")if (a.p.cellurl){var o = {}; if (a.p.autoencode)f = b.jgrid.htmlEncode(f); o[j] = f; n = a.p.prmNames; k = n.id; i = n.oper; o[k] = a.rows[d].id; o[i] = n.editoper; o = b.extend(c, o); b("#lui_" + a.p.id).show(); a.grid.hDiv.loading = true; b.ajax(b.extend({url:a.p.cellurl, data:b.isFunction(a.p.serializeCellData)?a.p.serializeCellData(o): - o, type:"POST", complete:function(m, p){b("#lui_" + a.p.id).hide(); a.grid.hDiv.loading = false; if (p == "success")if (b.isFunction(a.p.afterSubmitCell)){m = a.p.afterSubmitCell(m, o.id, j, f, d, e); if (m[0] === true){b(h).empty(); b(a).jqGrid("setCell", a.rows[d].id, e, g, false, false, true); b(h).addClass("dirty-cell"); b(a.rows[d]).addClass("edited"); b.isFunction(a.p.afterSaveCell) && a.p.afterSaveCell(a.rows[d].id, j, f, d, e); a.p.savedRow.splice(0, 1)} else{info_dialog(b.jgrid.errors.errcap, m[1], b.jgrid.edit.bClose); b(a).jqGrid("restoreCell", - d, e)}} else{b(h).empty(); b(a).jqGrid("setCell", a.rows[d].id, e, g, false, false, true); b(h).addClass("dirty-cell"); b(a.rows[d]).addClass("edited"); b.isFunction(a.p.afterSaveCell) && a.p.afterSaveCell(a.rows[d].id, j, f, d, e); a.p.savedRow.splice(0, 1)}}, error:function(m, p){b("#lui_" + a.p.id).hide(); a.grid.hDiv.loading = false; b.isFunction(a.p.errorCell)?a.p.errorCell(m, p):info_dialog(b.jgrid.errors.errcap, m.status + " : " + m.statusText + "
" + p, b.jgrid.edit.bClose); b(a).jqGrid("restoreCell", d, e)}}, b.jgrid.ajaxOptions, - a.p.ajaxCellOptions || {}))} else try{info_dialog(b.jgrid.errors.errcap, b.jgrid.errors.nourl, b.jgrid.edit.bClose); b(a).jqGrid("restoreCell", d, e)} catch (s){}if (a.p.cellsubmit == "clientArray"){b(h).empty(); b(a).jqGrid("setCell", a.rows[d].id, e, g, false, false, true); b(h).addClass("dirty-cell"); b(a.rows[d]).addClass("edited"); b.isFunction(a.p.afterSaveCell) && a.p.afterSaveCell(a.rows[d].id, j, f, d, e); a.p.savedRow.splice(0, 1)}} else try{window.setTimeout(function(){info_dialog(b.jgrid.errors.errcap, f + " " + r[1], b.jgrid.edit.bClose)}, - 100); b(a).jqGrid("restoreCell", d, e)} catch (t){}} else b(a).jqGrid("restoreCell", d, e)}b.browser.opera?b("#" + a.p.knv).attr("tabindex", "-1").focus():window.setTimeout(function(){b("#" + a.p.knv).attr("tabindex", "-1").focus()}, 0)}})}, restoreCell:function(d, e){return this.each(function(){var a = this, c; if (!(!a.grid || a.p.cellEdit !== true)){c = a.p.savedRow.length >= 1?0:null; if (c !== null){var h = b("td:eq(" + e + ")", a.rows[d]); if (b.isFunction(b.fn.datepicker))try{b("input.hasDatepicker", h).datepicker("hide")} catch (f){}b(h).empty().attr("tabindex", - "-1"); b(a).jqGrid("setCell", a.rows[d].id, e, a.p.savedRow[c].v, false, false, true); a.p.savedRow.splice(0, 1)}window.setTimeout(function(){b("#" + a.p.knv).attr("tabindex", "-1").focus()}, 0)}})}, nextCell:function(d, e){return this.each(function(){var a = this, c = false; if (!(!a.grid || a.p.cellEdit !== true)){for (var h = e + 1; h < a.p.colModel.length; h++)if (a.p.colModel[h].editable === true){c = h; break}if (c !== false)b(a).jqGrid("editCell", d, c, true); else a.p.savedRow.length > 0 && b(a).jqGrid("saveCell", d, e)}})}, prevCell:function(d, - e){return this.each(function(){var a = this, c = false; if (!(!a.grid || a.p.cellEdit !== true)){for (var h = e - 1; h >= 0; h--)if (a.p.colModel[h].editable === true){c = h; break}if (c !== false)b(a).jqGrid("editCell", d, c, true); else a.p.savedRow.length > 0 && b(a).jqGrid("saveCell", d, e)}})}, GridNav:function(){return this.each(function(){function d(g, k, j){if (j.substr(0, 1) == "v"){var i = b(a.grid.bDiv)[0].clientHeight, l = b(a.grid.bDiv)[0].scrollTop, n = a.rows[g].offsetTop + a.rows[g].clientHeight, q = a.rows[g].offsetTop; if (j == "vd")if (n >= i)b(a.grid.bDiv)[0].scrollTop = - b(a.grid.bDiv)[0].scrollTop + a.rows[g].clientHeight; if (j == "vu")if (q < l)b(a.grid.bDiv)[0].scrollTop = b(a.grid.bDiv)[0].scrollTop - a.rows[g].clientHeight}if (j == "h"){j = b(a.grid.bDiv)[0].clientWidth; i = b(a.grid.bDiv)[0].scrollLeft; l = a.rows[g].cells[k].offsetLeft; if (a.rows[g].cells[k].offsetLeft + a.rows[g].cells[k].clientWidth >= j + parseInt(i, 10))b(a.grid.bDiv)[0].scrollLeft = b(a.grid.bDiv)[0].scrollLeft + a.rows[g].cells[k].clientWidth; else if (l < i)b(a.grid.bDiv)[0].scrollLeft = b(a.grid.bDiv)[0].scrollLeft - a.rows[g].cells[k].clientWidth}} - function e(g, k){var j, i; if (k == "lft"){j = g + 1; for (i = g; i >= 0; i--)if (a.p.colModel[i].hidden !== true){j = i; break}}if (k == "rgt"){j = g - 1; for (i = g; i < a.p.colModel.length; i++)if (a.p.colModel[i].hidden !== true){j = i; break}}return j}var a = this; if (!(!a.grid || a.p.cellEdit !== true)){a.p.knv = a.p.id + "_kn"; var c = b(""), h, f; b(c).insertBefore(a.grid.cDiv); - b("#" + a.p.knv).focus().keydown(function(g){f = g.keyCode; if (a.p.direction == "rtl")if (f == 37)f = 39; else if (f == 39)f = 37; switch (f){case 38:if (a.p.iRow - 1 >= 0){d(a.p.iRow - 1, a.p.iCol, "vu"); b(a).jqGrid("editCell", a.p.iRow - 1, a.p.iCol, false)}break; case 40:if (a.p.iRow + 1 <= a.rows.length - 1){d(a.p.iRow + 1, a.p.iCol, "vd"); b(a).jqGrid("editCell", a.p.iRow + 1, a.p.iCol, false)}break; case 37:if (a.p.iCol - 1 >= 0){h = e(a.p.iCol - 1, "lft"); d(a.p.iRow, h, "h"); b(a).jqGrid("editCell", a.p.iRow, h, false)}break; case 39:if (a.p.iCol + 1 <= a.p.colModel.length - - 1){h = e(a.p.iCol + 1, "rgt"); d(a.p.iRow, h, "h"); b(a).jqGrid("editCell", a.p.iRow, h, false)}break; case 13:parseInt(a.p.iCol, 10) >= 0 && parseInt(a.p.iRow, 10) >= 0 && b(a).jqGrid("editCell", a.p.iRow, a.p.iCol, true); break}return false})}})}, getChangedCells:function(d){var e = []; d || (d = "all"); this.each(function(){var a = this, c; !a.grid || a.p.cellEdit !== true || b(a.rows).each(function(h){var f = {}; if (b(this).hasClass("edited")){b("td", this).each(function(g){c = a.p.colModel[g].name; if (c !== "cb" && c !== "subgrid")if (d == "dirty"){if (b(this).hasClass("dirty-cell"))try{f[c] = - b.unformat(this, {rowId:a.rows[h].id, colModel:a.p.colModel[g]}, g)} catch (k){f[c] = b.jgrid.htmlDecode(b(this).html())}} else try{f[c] = b.unformat(this, {rowId:a.rows[h].id, colModel:a.p.colModel[g]}, g)} catch (j){f[c] = b.jgrid.htmlDecode(b(this).html())}}); f.id = this.id; e.push(f)}})}); return e}})})(jQuery); - (function(b){b.fn.jqm = function(a){var f = {overlay:50, closeoverlay:true, overlayClass:"jqmOverlay", closeClass:"jqmClose", trigger:".jqModal", ajax:e, ajaxText:"", target:e, modal:e, toTop:e, onShow:e, onHide:e, onLoad:e}; return this.each(function(){if (this._jqm)return i[this._jqm].c = b.extend({}, i[this._jqm].c, a); l++; this._jqm = l; i[l] = {c:b.extend(f, b.jqm.params, a), a:e, w:b(this).addClass("jqmID" + l), s:l}; f.trigger && b(this).jqmAddTrigger(f.trigger)})}; b.fn.jqmAddClose = function(a){return o(this, a, "jqmHide")}; b.fn.jqmAddTrigger = - function(a){return o(this, a, "jqmShow")}; b.fn.jqmShow = function(a){return this.each(function(){b.jqm.open(this._jqm, a)})}; b.fn.jqmHide = function(a){return this.each(function(){b.jqm.close(this._jqm, a)})}; b.jqm = {hash:{}, open:function(a, f){var c = i[a], d = c.c, h = "." + d.closeClass, g = parseInt(c.w.css("z-index")); g = g > 0?g:3E3; var j = b("
").css({height:"100%", width:"100%", position:"fixed", left:0, top:0, "z-index":g - 1, opacity:d.overlay / 100}); if (c.a)return e; c.t = f; c.a = true; c.w.css("z-index", g); if (d.modal){k[0] || - setTimeout(function(){p("bind")}, 1); k.push(a)} else if (d.overlay > 0)d.closeoverlay && c.w.jqmAddClose(j); else j = e; c.o = j?j.addClass(d.overlayClass).prependTo("body"):e; if (q){b("html,body").css({height:"100%", width:"100%"}); if (j){j = j.css({position:"absolute"})[0]; for (var m in{Top:1, Left:1})j.style.setExpression(m.toLowerCase(), "(_=(document.documentElement.scroll" + m + " || document.body.scroll" + m + "))+'px'")}}if (d.ajax){a = d.target || c.w; g = d.ajax; a = typeof a == "string"?b(a, c.w):b(a); g = g.substr(0, 1) == "@"?b(f).attr(g.substring(1)): - g; a.html(d.ajaxText).load(g, function(){d.onLoad && d.onLoad.call(this, c); h && c.w.jqmAddClose(b(h, c.w)); r(c)})} else h && c.w.jqmAddClose(b(h, c.w)); d.toTop && c.o && c.w.before('').insertAfter(c.o); d.onShow?d.onShow(c):c.w.show(); r(c); return e}, close:function(a){a = i[a]; if (!a.a)return e; a.a = e; if (k[0]){k.pop(); k[0] || p("unbind")}a.c.toTop && a.o && b("#jqmP" + a.w[0]._jqm).after(a.w).remove(); if (a.c.onHide)a.c.onHide(a); else{a.w.hide(); a.o && a.o.remove()}return e}, params:{}}; var l = - 0, i = b.jqm.hash, k = [], q = b.browser.msie && b.browser.version == "6.0", e = false, r = function(a){var f = b('').css({opacity:0}); if (q)if (a.o)a.o.html('

').prepend(f); else b("iframe.jqm", a.w)[0] || a.w.prepend(f); s(a)}, s = function(a){try{b(":input:visible", a.w)[0].focus()} catch (f){}}, p = function(a){b(document)[a]("keypress", n)[a]("keydown", n)[a]("mousedown", n)}, n = function(a){var f = i[k[k.length - 1]]; (a = !b(a.target).parents(".jqmID" + - f.s)[0]) && s(f); return!a}, o = function(a, f, c){return a.each(function(){var d = this._jqm; b(f).each(function(){if (!this[c]){this[c] = []; b(this).click(function(){for (var h in{jqmShow:1, jqmHide:1})for (var g in this[h])i[this[h][g]] && i[this[h][g]].w[h](this); return e})}this[c].push(d)})})}})(jQuery); - (function(b){b.fn.jqDrag = function(a){return l(this, a, "d")}; b.fn.jqResize = function(a, e){return l(this, a, "r", e)}; b.jqDnR = {dnr:{}, e:0, drag:function(a){if (c.k == "d")d.css({left:c.X + a.pageX - c.pX, top:c.Y + a.pageY - c.pY}); else{d.css({width:Math.max(a.pageX - c.pX + c.W, 0), height:Math.max(a.pageY - c.pY + c.H, 0)}); M1 && f.css({width:Math.max(a.pageX - M1.pX + M1.W, 0), height:Math.max(a.pageY - M1.pY + M1.H, 0)})}return false}, stop:function(){b(document).unbind("mousemove", i.drag).unbind("mouseup", i.stop)}}; var i = b.jqDnR, c = i.dnr, - d = i.e, f, l = function(a, e, n, m){return a.each(function(){e = e?b(e, a):a; e.bind("mousedown", {e:a, k:n}, function(g){var j = g.data, h = {}; d = j.e; f = m?b(m):false; if (d.css("position") != "relative")try{d.position(h)} catch (o){}c = {X:h.left || k("left") || 0, Y:h.top || k("top") || 0, W:k("width") || d[0].scrollWidth || 0, H:k("height") || d[0].scrollHeight || 0, pX:g.pageX, pY:g.pageY, k:j.k}; M1 = f && j.k != "d"?{X:h.left || f1("left") || 0, Y:h.top || f1("top") || 0, W:f[0].offsetWidth || f1("width") || 0, H:f[0].offsetHeight || f1("height") || 0, pX:g.pageX, pY:g.pageY, - k:j.k}:false; b(document).mousemove(b.jqDnR.drag).mouseup(b.jqDnR.stop); return false})})}, k = function(a){return parseInt(d.css(a)) || false}; f1 = function(a){return parseInt(f.css(a)) || false}})(jQuery); - (function(a){a.jgrid.extend({setSubGrid:function(){return this.each(function(){var e = this; e.p.colNames.unshift(""); e.p.colModel.unshift({name:"subgrid", width:a.browser.safari?e.p.subGridWidth + e.p.cellLayout:e.p.subGridWidth, sortable:false, resizable:false, hidedlg:true, search:false, fixed:true}); e = e.p.subGridModel; if (e[0]){e[0].align = a.extend([], e[0].align || []); for (var c = 0; c < e[0].name.length; c++)e[0].align[c] = e[0].align[c] || "left"}})}, addSubGridCell:function(e, c){var b = "", n, k; this.each(function(){b = - this.formatCol(e, c); n = this.p.gridview; k = this.p.id}); return n === false?'":'"}, addSubGrid:function(e, c){return this.each(function(){var b = this; if (b.grid){var n, k, p, t, s, u, o; a("td:eq(" + c + ")", e).click(function(){if (a(this).hasClass("sgcollapsed")){p = b.p.id; n = a(this).parent(); - t = c >= 1?" ":""; k = a(n).attr("id"); o = true; if (a.isFunction(b.p.subGridBeforeExpand))o = b.p.subGridBeforeExpand(p + "_" + k, k); if (o === false)return false; s = 0; a.each(b.p.colModel, function(){if (this.hidden === true || this.name == "rn" || this.name == "cb")s++}); u = "" + t + "

"; a(this).parent().after(u + "
"); a.isFunction(b.p.subGridRowExpanded)?b.p.subGridRowExpanded(p + "_" + k, k):x(n); a(this).html("").removeClass("sgcollapsed").addClass("sgexpanded")} else if (a(this).hasClass("sgexpanded")){o = true; if (a.isFunction(b.p.subGridRowColapsed)){n = a(this).parent(); k = a(n).attr("id"); o = b.p.subGridRowColapsed(p + "_" + k, k)}if (o === false)return false; a(this).parent().next().remove(".ui-subgrid"); - a(this).html("").removeClass("sgexpanded").addClass("sgcollapsed")}return false}); var x = function(g){var j, f, d, h; j = a(g).attr("id"); f = {nd_:(new Date).getTime()}; f[b.p.prmNames.subgridid] = j; if (!b.p.subGridModel[0])return false; if (b.p.subGridModel[0].params)for (h = 0; h < b.p.subGridModel[0].params.length; h++)for (d = 0; d < b.p.colModel.length; d++)if (b.p.colModel[d].name == b.p.subGridModel[0].params[h])f[b.p.colModel[d].name] = a("td:eq(" + - d + ")", g).text().replace(/\ \;/ig, ""); if (!b.grid.hDiv.loading){b.grid.hDiv.loading = true; a("#load_" + b.p.id).show(); if (!b.p.subgridtype)b.p.subgridtype = b.p.datatype; if (a.isFunction(b.p.subgridtype))b.p.subgridtype(f); else b.p.subgridtype = b.p.subgridtype.toLowerCase(); switch (b.p.subgridtype){case "xml":case "json":a.ajax(a.extend({type:b.p.mtype, url:b.p.subGridUrl, dataType:b.p.subgridtype, data:a.isFunction(b.p.serializeSubGridData)?b.p.serializeSubGridData(f):f, complete:function(i){b.p.subgridtype == - "xml"?v(i.responseXML, j):w(a.jgrid.parse(i.responseText), j)}}, a.jgrid.ajaxOptions, b.p.ajaxSubgridOptions || {})); break}}return false}, r = function(g, j, f){j = a("").html(j); a(g).append(j)}, v = function(g, j){var f, d, h, i = a("
"), l = a(""); for (d = 0; d < b.p.subGridModel[0].name.length; d++){f = a(""); a(f).html(b.p.subGridModel[0].name[d]); - a(f).width(b.p.subGridModel[0].width[d]); a(l).append(f)}a(i).append(l); if (g){h = b.p.xmlReader.subgrid; a(h.root + " " + h.row, g).each(function(){l = a(""); if (h.repeatitems === true)a(h.cell, this).each(function(q){r(l, a(this).text() || " ", q)}); else{var m = b.p.subGridModel[0].mapping || b.p.subGridModel[0].name; if (m)for (d = 0; d < m.length; d++)r(l, a(m[d], this).text() || " ", d)}a(i).append(l)})}g = a("table:first", b.grid.bDiv).attr("id") + "_"; a("#" + g + j).append(i); b.grid.hDiv.loading = - false; a("#load_" + b.p.id).hide(); return false}, w = function(g, j){var f, d, h, i, l = a("
"), m = a(""); for (d = 0; d < b.p.subGridModel[0].name.length; d++){f = a(""); a(f).html(b.p.subGridModel[0].name[d]); a(f).width(b.p.subGridModel[0].width[d]); a(m).append(f)}a(l).append(m); if (g){f = b.p.jsonReader.subgrid; g = g[f.root]; if (typeof g !== "undefined")for (d = 0; d < - g.length; d++){h = g[d]; m = a(""); if (f.repeatitems === true){if (f.cell)h = h[f.cell]; for (i = 0; i < h.length; i++)r(m, h[i] || " ", i)} else{var q = b.p.subGridModel[0].mapping || b.p.subGridModel[0].name; if (q.length)for (i = 0; i < q.length; i++)r(m, h[q[i]] || " ", i)}a(l).append(m)}}d = a("table:first", b.grid.bDiv).attr("id") + "_"; a("#" + d + j).append(l); b.grid.hDiv.loading = false; a("#load_" + b.p.id).hide(); return false}; b.subGridXml = function(g, j){v(g, j)}; b.subGridJson = function(g, - j){w(g, j)}}})}, expandSubGridRow:function(e){return this.each(function(){var c = this; if (c.grid || e)if (c.p.subGrid === true)if (c = a(this).jqGrid("getInd", e, true))(c = a("td.sgcollapsed", c)[0]) && a(c).trigger("click")})}, collapseSubGridRow:function(e){return this.each(function(){var c = this; if (c.grid || e)if (c.p.subGrid === true)if (c = a(this).jqGrid("getInd", e, true))(c = a("td.sgexpanded", c)[0]) && a(c).trigger("click")})}, toggleSubGridRow:function(e){return this.each(function(){var c = this; if (c.grid || e)if (c.p.subGrid === - true)if (c = a(this).jqGrid("getInd", e, true)){var b = a("td.sgcollapsed", c)[0]; if (b)a(b).trigger("click"); else(b = a("td.sgexpanded", c)[0]) && a(b).trigger("click")}})}})})(jQuery); - (function(d){d.jgrid.extend({setTreeNode:function(a, c){return this.each(function(){var b = this; if (b.grid && b.p.treeGrid){var e = b.p.expColInd, f = b.p.treeReader.expanded_field, j = b.p.treeReader.leaf_field, k = b.p.treeReader.level_field; c.level = a[k]; if (b.p.treeGridModel == "nested"){c.lft = a[b.p.treeReader.left_field]; c.rgt = a[b.p.treeReader.right_field]; a[j] || (a[j] = parseInt(c.rgt, 10) === parseInt(c.lft, 10) + 1?"true":"false")} else c.parent_id = a[b.p.treeReader.parent_id_field]; var g = parseInt(c.level, 10), i; if (b.p.tree_root_level === - 0){i = g + 1; g = g} else{i = g; g = g - 1}i = "
"; i += "
").prepend(i); d(".treeclick", c).bind("click", function(h){h = d(h.target || h.srcElement, b.rows).parents("tr.jqgrow")[0].rowIndex; if (!b.rows[h].isLeaf)if (b.rows[h].expanded){d(b).jqGrid("collapseRow", b.rows[h]); d(b).jqGrid("collapseNode", b.rows[h])} else{d(b).jqGrid("expandRow", b.rows[h]); d(b).jqGrid("expandNode", b.rows[h])}return false}); b.p.ExpandColClick === true && d("span", c).css("cursor", "pointer").bind("click", - function(h){h = d(h.target || h.srcElement, b.rows).parents("tr.jqgrow")[0].rowIndex; if (!b.rows[h].isLeaf)if (b.rows[h].expanded){d(b).jqGrid("collapseRow", b.rows[h]); d(b).jqGrid("collapseNode", b.rows[h])} else{d(b).jqGrid("expandRow", b.rows[h]); d(b).jqGrid("expandNode", b.rows[h])}d(b).jqGrid("setSelection", b.rows[h].id); return false})}})}, setTreeGrid:function(){return this.each(function(){var a = this, c = 0; if (a.p.treeGrid){a.p.treedatatype || d.extend(a.p, {treedatatype:a.p.datatype}); a.p.subGrid = false; a.p.altRows = - false; a.p.pgbuttons = false; a.p.pginput = false; a.p.multiselect = false; a.p.rowList = []; a.p.treeIcons = d.extend({plus:"ui-icon-triangle-1-" + (a.p.direction == "rtl"?"w":"e"), minus:"ui-icon-triangle-1-s", leaf:"ui-icon-radio-off"}, a.p.treeIcons || {}); if (a.p.treeGridModel == "nested")a.p.treeReader = d.extend({level_field:"level", left_field:"lft", right_field:"rgt", leaf_field:"isLeaf", expanded_field:"expanded"}, a.p.treeReader); else if (a.p.treeGridModel == "adjacency")a.p.treeReader = d.extend({level_field:"level", parent_id_field:"parent", - leaf_field:"isLeaf", expanded_field:"expanded"}, a.p.treeReader); for (var b in a.p.colModel)if (a.p.colModel.hasOwnProperty(b)){if (a.p.colModel[b].name == a.p.ExpandColumn){a.p.expColInd = c; break}c++}if (!a.p.expColInd)a.p.expColInd = 0; d.each(a.p.treeReader, function(e, f){if (f){a.p.colNames.push(f); a.p.colModel.push({name:f, width:1, hidden:true, sortable:false, resizable:false, hidedlg:true, editable:true, search:false})}})}})}, expandRow:function(a){this.each(function(){var c = this; if (c.grid && c.p.treeGrid){var b = - d(c).jqGrid("getNodeChildren", a); d(b).each(function(){d(this).css("display", ""); this.expanded && d(c).jqGrid("expandRow", this)})}})}, collapseRow:function(a){this.each(function(){var c = this; if (c.grid && c.p.treeGrid){var b = d(c).jqGrid("getNodeChildren", a); d(b).each(function(){d(this).css("display", "none"); this.expanded && d(c).jqGrid("collapseRow", this)})}})}, getRootNodes:function(){var a = []; this.each(function(){var c = this; if (c.grid && c.p.treeGrid)switch (c.p.treeGridModel){case "nested":var b = c.p.treeReader.level_field; - d(c.rows).each(function(){parseInt(this[b], 10) === parseInt(c.p.tree_root_level, 10) && a.push(this)}); break; case "adjacency":d(c.rows).each(function(){if (this.parent_id === null || String(this.parent_id).toLowerCase() == "null")a.push(this)}); break}}); return a}, getNodeDepth:function(a){var c = null; this.each(function(){var b = this; if (this.grid && this.p.treeGrid)switch (b.p.treeGridModel){case "nested":c = parseInt(a.level, 10) - parseInt(this.p.tree_root_level, 10); break; case "adjacency":c = d(b).jqGrid("getNodeAncestors", - a).length; break}}); return c}, getNodeParent:function(a){var c = null; this.each(function(){var b = this; if (b.grid && b.p.treeGrid)switch (b.p.treeGridModel){case "nested":var e = parseInt(a.lft, 10), f = parseInt(a.rgt, 10), j = parseInt(a.level, 10); d(this.rows).each(function(){if (parseInt(this.level, 10) === j - 1 && parseInt(this.lft, 10) < e && parseInt(this.rgt, 10) > f){c = this; return false}}); break; case "adjacency":d(this.rows).each(function(){if (this.id == a.parent_id){c = this; return false}}); break}}); return c}, getNodeChildren:function(a){var c = - []; this.each(function(){var b = this; if (b.grid && b.p.treeGrid)switch (b.p.treeGridModel){case "nested":var e = parseInt(a.lft, 10), f = parseInt(a.rgt, 10), j = parseInt(a.level, 10); d(this.rows).each(function(){parseInt(this.level, 10) === j + 1 && parseInt(this.lft, 10) > e && parseInt(this.rgt, 10) < f && c.push(this)}); break; case "adjacency":d(this.rows).each(function(){this.parent_id == a.id && c.push(this)}); break}}); return c}, getFullTreeNode:function(a){var c = []; this.each(function(){var b = this, e; if (b.grid && b.p.treeGrid)switch (b.p.treeGridModel){case "nested":var f = - parseInt(a.lft, 10), j = parseInt(a.rgt, 10), k = parseInt(a.level, 10); d(this.rows).each(function(){parseInt(this.level, 10) >= k && parseInt(this.lft, 10) >= f && parseInt(this.lft, 10) <= j && c.push(this)}); break; case "adjacency":c.push(a); d(this.rows).each(function(g){e = c.length; for (g = 0; g < e; g++)if (c[g].id == this.parent_id){c.push(this); break}}); break}}); return c}, getNodeAncestors:function(a){var c = []; this.each(function(){if (this.grid && this.p.treeGrid)for (var b = d(this).jqGrid("getNodeParent", a); b; ){c.push(b); b = d(this).jqGrid("getNodeParent", - b)}}); return c}, isVisibleNode:function(a){var c = true; this.each(function(){var b = this; if (b.grid && b.p.treeGrid){b = d(b).jqGrid("getNodeAncestors", a); d(b).each(function(){c = c && this.expanded; if (!c)return false})}}); return c}, isNodeLoaded:function(a){var c; this.each(function(){var b = this; if (b.grid && b.p.treeGrid)c = a.loaded !== undefined?a.loaded:a.isLeaf || d(b).jqGrid("getNodeChildren", a).length > 0?true:false}); return c}, expandNode:function(a){return this.each(function(){if (this.grid && this.p.treeGrid)if (!a.expanded)if (d(this).jqGrid("isNodeLoaded", - a)){a.expanded = true; d("div.treeclick", a).removeClass(this.p.treeIcons.plus + " tree-plus").addClass(this.p.treeIcons.minus + " tree-minus")} else{a.expanded = true; d("div.treeclick", a).removeClass(this.p.treeIcons.plus + " tree-plus").addClass(this.p.treeIcons.minus + " tree-minus"); this.p.treeANode = a.rowIndex; this.p.datatype = this.p.treedatatype; this.p.treeGridModel == "nested"?d(this).jqGrid("setGridParam", {postData:{nodeid:a.id, n_left:a.lft, n_right:a.rgt, n_level:a.level}}):d(this).jqGrid("setGridParam", {postData:{nodeid:a.id, - parentid:a.parent_id, n_level:a.level}}); d(this).trigger("reloadGrid"); this.p.treeGridModel == "nested"?d(this).jqGrid("setGridParam", {postData:{nodeid:"", n_left:"", n_right:"", n_level:""}}):d(this).jqGrid("setGridParam", {postData:{nodeid:"", parentid:"", n_level:""}})}})}, collapseNode:function(a){return this.each(function(){if (this.grid && this.p.treeGrid)if (a.expanded){a.expanded = false; d("div.treeclick", a).removeClass(this.p.treeIcons.minus + " tree-minus").addClass(this.p.treeIcons.plus + " tree-plus")}})}, - SortTree:function(a){return this.each(function(){if (this.grid && this.p.treeGrid){var c, b, e, f = [], j = this, k = d(this).jqGrid("getRootNodes"); k.sort(function(g, i){if (g.sortKey < i.sortKey)return - a; if (g.sortKey > i.sortKey)return a; return 0}); if (k[0]){d("td", k[0]).each(function(g){d(this).css("width", j.grid.headers[g].width + "px")}); j.grid.cols = k[0].cells}c = 0; for (b = k.length; c < b; c++){e = k[c]; f.push(e); d(this).jqGrid("collectChildrenSortTree", f, e, a)}d.each(f, function(g, i){d("tbody", j.grid.bDiv).append(i); i.sortKey = - null})}})}, collectChildrenSortTree:function(a, c, b){return this.each(function(){if (this.grid && this.p.treeGrid){var e, f, j, k = d(this).jqGrid("getNodeChildren", c); k.sort(function(g, i){if (g.sortKey < i.sortKey)return - b; if (g.sortKey > i.sortKey)return b; return 0}); e = 0; for (f = k.length; e < f; e++){j = k[e]; a.push(j); d(this).jqGrid("collectChildrenSortTree", a, j, b)}}})}, setTreeRow:function(a, c){var b = false; this.each(function(){var e = this; if (e.grid && e.p.treeGrid)b = d(e).jqGrid("setRowData", a, c)}); return b}, delTreeNode:function(a){return this.each(function(){var c = - this; if (c.grid && c.p.treeGrid){var b = d(c).jqGrid("getInd", a, true); if (b){var e = d(c).jqGrid("getNodeChildren", b); if (e.length > 0)for (var f = 0; f < e.length; f++)d(c).jqGrid("delRowData", e[f].id); d(c).jqGrid("delRowData", b.id)}}})}})})(jQuery); - (function(b){b.jgrid.extend({jqGridImport:function(a){a = b.extend({imptype:"xml", impstring:"", impurl:"", mtype:"GET", impData:{}, xmlGrid:{config:"roots>grid", data:"roots>rows"}, jsonGrid:{config:"grid", data:"data"}, ajaxOptions:{}}, a || {}); return this.each(function(){var e = this, c = function(d, g){var f = b(g.xmlGrid.config, d)[0]; g = b(g.xmlGrid.data, d)[0]; var k; if (xmlJsonClass.xml2json && b.jgrid.parse){f = xmlJsonClass.xml2json(f, " "); f = b.jgrid.parse(f); for (var h in f)if (f.hasOwnProperty(h))k = f[h]; if (g){h = f.grid.datatype; - f.grid.datatype = "xmlstring"; f.grid.datastr = d; b(e).jqGrid(k).jqGrid("setGridParam", {datatype:h})} else b(e).jqGrid(k)} else alert("xml2json or parse are not present")}, i = function(d, g){if (d && typeof d == "string"){var f = b.jgrid.parse(d); d = f[g.jsonGrid.config]; if (g = f[g.jsonGrid.data]){f = d.datatype; d.datatype = "jsonstring"; d.datastr = g; b(e).jqGrid(d).jqGrid("setGridParam", {datatype:f})} else b(e).jqGrid(d)}}; switch (a.imptype){case "xml":b.ajax(b.extend({url:a.impurl, type:a.mtype, data:a.impData, dataType:"xml", - complete:function(d, g){if (g == "success"){c(d.responseXML, a); b.isFunction(a.importComplete) && a.importComplete(d)}}}, a.ajaxOptions)); break; case "xmlstring":if (a.impstring && typeof a.impstring == "string"){var j = b.jgrid.stringToDoc(a.impstring); if (j){c(j, a); b.isFunction(a.importComplete) && a.importComplete(j); a.impstring = null}j = null}break; case "json":b.ajax(b.extend({url:a.impurl, type:a.mtype, data:a.impData, dataType:"json", complete:function(d, g){if (g == "success"){i(d.responseText, a); b.isFunction(a.importComplete) && - a.importComplete(d)}}}, a.ajaxOptions)); break; case "jsonstring":if (a.impstring && typeof a.impstring == "string"){i(a.impstring, a); b.isFunction(a.importComplete) && a.importComplete(a.impstring); a.impstring = null}break}})}, jqGridExport:function(a){a = b.extend({exptype:"xmlstring", root:"grid", ident:"\t"}, a || {}); var e = null; this.each(function(){if (this.grid){var c = b.extend({}, b(this).jqGrid("getGridParam")); if (c.rownumbers){c.colNames.splice(0, 1); c.colModel.splice(0, 1)}if (c.multiselect){c.colNames.splice(0, 1); - c.colModel.splice(0, 1)}if (c.subGrid){c.colNames.splice(0, 1); c.colModel.splice(0, 1)}c.knv = null; if (c.treeGrid)for (var i in c.treeReader)if (c.treeReader.hasOwnProperty(i)){c.colNames.splice(c.colNames.length - 1); c.colModel.splice(c.colModel.length - 1)}switch (a.exptype){case "xmlstring":e = "<" + a.root + ">" + xmlJsonClass.json2xml(c, a.ident) + ""; break; case "jsonstring":e = "{" + xmlJsonClass.toJson(c, a.root, a.ident) + "}"; if (c.postData.filters !== undefined){e = e.replace(/filters":"/, 'filters":'); e = e.replace(/}]}"/, - "}]}")}break}}}); return e}, excelExport:function(a){a = b.extend({exptype:"remote", url:null, oper:"oper", tag:"excel", exportOptions:{}}, a || {}); return this.each(function(){$t = this; if (this.grid)if (a.exptype == "remote"){var e = b.extend({}, this.p.postData); e[a.oper] = a.tag; e = jQuery.param(e); window.location = a.url + "?" + e}})}})})(jQuery); - var xmlJsonClass = {xml2json:function(a, b){if (a.nodeType === 9)a = a.documentElement; a = this.toJson(this.toObj(this.removeWhite(a)), a.nodeName, "\t"); return"{\n" + b + (b?a.replace(/\t/g, b):a.replace(/\t|\n/g, "")) + "\n}"}, json2xml:function(a, b){var g = function(d, c, j){var i = "", k, h; if (d instanceof Array)if (d.length === 0)i += j + "<" + c + ">__EMPTY_ARRAY_\n"; else{k = 0; for (h = d.length; k < h; k += 1){var l = j + g(d[k], c, j + "\t") + "\n"; i += l}} else if (typeof d === "object"){k = false; i += j + "<" + c; for (h in d)if (d.hasOwnProperty(h))if (h.charAt(0) === - "@")i += " " + h.substr(1) + '="' + d[h].toString() + '"'; else k = true; i += k?">":"/>"; if (k){for (h in d)if (d.hasOwnProperty(h))if (h === "#text")i += d[h]; else if (h === "#cdata")i += ""; else if (h.charAt(0) !== "@")i += g(d[h], h, j + "\t"); i += (i.charAt(i.length - 1) === "\n"?j:"") + ""}} else i += typeof d === "function"?j + "<" + c + ">":d.toString() === '""' || d.toString().length === 0?j + "<" + c + ">__EMPTY_STRING_":j + "<" + c + ">" + d.toString() + ""; return i}, e = "", f; for (f in a)if (a.hasOwnProperty(f))e += - g(a[f], f, ""); return b?e.replace(/\t/g, b):e.replace(/\t|\n/g, "")}, toObj:function(a){var b = {}, g = /function/i; if (a.nodeType === 1){if (a.attributes.length){var e; for (e = 0; e < a.attributes.length; e += 1)b["@" + a.attributes[e].nodeName] = (a.attributes[e].nodeValue || "").toString()}if (a.firstChild){var f = e = 0, d = false, c; for (c = a.firstChild; c; c = c.nextSibling)if (c.nodeType === 1)d = true; else if (c.nodeType === 3 && c.nodeValue.match(/[^ \f\n\r\t\v]/))e += 1; else if (c.nodeType === 4)f += 1; if (d)if (e < 2 && f < 2){this.removeWhite(a); for (c = - a.firstChild; c; c = c.nextSibling)if (c.nodeType === 3)b["#text"] = this.escape(c.nodeValue); else if (c.nodeType === 4)if (g.test(c.nodeValue))b[c.nodeName] = [b[c.nodeName], c.nodeValue]; else b["#cdata"] = this.escape(c.nodeValue); else if (b[c.nodeName])if (b[c.nodeName]instanceof Array)b[c.nodeName][b[c.nodeName].length] = this.toObj(c); else b[c.nodeName] = [b[c.nodeName], this.toObj(c)]; else b[c.nodeName] = this.toObj(c)} else if (a.attributes.length)b["#text"] = this.escape(this.innerXml(a)); else b = this.escape(this.innerXml(a)); - else if (e)if (a.attributes.length)b["#text"] = this.escape(this.innerXml(a)); else{b = this.escape(this.innerXml(a)); if (b === "__EMPTY_ARRAY_")b = "[]"; else if (b === "__EMPTY_STRING_")b = ""} else if (f)if (f > 1)b = this.escape(this.innerXml(a)); else for (c = a.firstChild; c; c = c.nextSibling)if (g.test(a.firstChild.nodeValue)){b = a.firstChild.nodeValue; break} else b["#cdata"] = this.escape(c.nodeValue)}if (!a.attributes.length && !a.firstChild)b = null} else if (a.nodeType === 9)b = this.toObj(a.documentElement); else alert("unhandled node type: " + - a.nodeType); return b}, toJson:function(a, b, g){var e = b?'"' + b + '"':""; if (a === "[]")e += b?":[]":"[]"; else if (a instanceof Array){var f, d, c = []; d = 0; for (f = a.length; d < f; d += 1)c[d] = this.toJson(a[d], "", g + "\t"); e += (b?":[":"[") + (c.length > 1?"\n" + g + "\t" + c.join(",\n" + g + "\t") + "\n" + g:c.join("")) + "]"} else if (a === null)e += (b && ":") + "null"; else if (typeof a === "object"){f = []; for (d in a)if (a.hasOwnProperty(d))f[f.length] = this.toJson(a[d], d, g + "\t"); e += (b?":{":"{") + (f.length > 1?"\n" + g + "\t" + f.join(",\n" + g + "\t") + "\n" + g:f.join("")) + - "}"} else if (typeof a === "string"){g = /function/i; f = a.toString(); e += /(^-?\d+\.?\d*$)/.test(f) || g.test(f) || f === "false" || f === "true"?(b && ":") + f:(b && ":") + '"' + a + '"'} else e += (b && ":") + a.toString(); return e}, innerXml:function(a){var b = ""; if ("innerHTML"in a)b = a.innerHTML; else{var g = function(e){var f = "", d; if (e.nodeType === 1){f += "<" + e.nodeName; for (d = 0; d < e.attributes.length; d += 1)f += " " + e.attributes[d].nodeName + '="' + (e.attributes[d].nodeValue || "").toString() + '"'; if (e.firstChild){f += ">"; for (d = e.firstChild; d; d = d.nextSibling)f += - g(d); f += ""} else f += "/>"} else if (e.nodeType === 3)f += e.nodeValue; else if (e.nodeType === 4)f += ""; return f}; for (a = a.firstChild; a; a = a.nextSibling)b += g(a)}return b}, escape:function(a){return a.replace(/[\\]/g, "\\\\").replace(/[\"]/g, '\\"').replace(/[\n]/g, "\\n").replace(/[\r]/g, "\\r")}, removeWhite:function(a){a.normalize(); var b; for (b = a.firstChild; b; )if (b.nodeType === 3)if (b.nodeValue.match(/[^ \f\n\r\t\v]/))b = b.nextSibling; else{var g = b.nextSibling; a.removeChild(b); - b = g} else{b.nodeType === 1 && this.removeWhite(b); b = b.nextSibling}return a}}; - (function(b){b.jgrid.extend({setColumns:function(a){a = b.extend({top:0, left:0, width:200, height:"auto", dataheight:"auto", modal:false, drag:true, beforeShowForm:null, afterShowForm:null, afterSubmitForm:null, closeOnEscape:true, ShrinkToFit:false, jqModal:false, saveicon:[true, "left", "ui-icon-disk"], closeicon:[true, "left", "ui-icon-close"], onClose:null, colnameview:true, closeAfterSubmit:true, updateAfterCheck:false, recreateForm:false}, b.jgrid.col, a || {}); return this.each(function(){var c = this; if (c.grid){var j = typeof a.beforeShowForm === - "function"?true:false, k = typeof a.afterShowForm === "function"?true:false, l = typeof a.afterSubmitForm === "function"?true:false, e = c.p.id, d = "ColTbl_" + e, f = {themodal:"colmod" + e, modalhead:"colhd" + e, modalcontent:"colcnt" + e, scrollelm:d}; a.recreateForm === true && b("#" + f.themodal).html() != null && b("#" + f.themodal).remove(); if (b("#" + f.themodal).html() != null){j && a.beforeShowForm(b("#" + d)); viewModal("#" + f.themodal, {gbox:"#gbox_" + e, jqm:a.jqModal, jqM:false, modal:a.modal})} else{var g = isNaN(a.dataheight)?a.dataheight:a.dataheight + - "px"; g = "
"; g += ""; for (i = 0; i < this.p.colNames.length; i++)c.p.colModel[i].hidedlg || (g += ""); g += "
"; g += "
" + (!a.updateAfterCheck?"" + a.bSubmit + "":"") + " " + ("" + - a.bCancel + "") + "
"; a.gbox = "#gbox_" + e; createModal(f, g, a, "#gview_" + c.p.id, b("#gview_" + c.p.id)[0]); if (a.saveicon[0] == true)b("#dData", "#" + d + "_2").addClass(a.saveicon[1] == "right"?"fm-button-icon-right":"fm-button-icon-left").append(""); if (a.closeicon[0] == true)b("#eData", "#" + d + "_2").addClass(a.closeicon[1] == "right"?"fm-button-icon-right":"fm-button-icon-left").append(""); a.updateAfterCheck? - b(":input", "#" + d).click(function(){var h = this.id.substr(4); if (h){this.checked?b(c).jqGrid("showCol", h):b(c).jqGrid("hideCol", h); a.ShrinkToFit === true && b(c).jqGrid("setGridWidth", c.grid.width - 0.0010, true)}return this}):b("#dData", "#" + d + "_2").click(function(){for (i = 0; i < c.p.colModel.length; i++)if (!c.p.colModel[i].hidedlg){var h = c.p.colModel[i].name.replace(".", "\\."); if (b("#col_" + h, "#" + d).attr("checked")){b(c).jqGrid("showCol", c.p.colModel[i].name); b("#col_" + h, "#" + d).attr("defaultChecked", true)} else{b(c).jqGrid("hideCol", - c.p.colModel[i].name); b("#col_" + h, "#" + d).attr("defaultChecked", "")}}a.ShrinkToFit === true && b(c).jqGrid("setGridWidth", c.grid.width - 0.0010, true); a.closeAfterSubmit && hideModal("#" + f.themodal, {gb:"#gbox_" + e, jqm:a.jqModal, onClose:a.onClose}); l && a.afterSubmitForm(b("#" + d)); return false}); b("#eData", "#" + d + "_2").click(function(){hideModal("#" + f.themodal, {gb:"#gbox_" + e, jqm:a.jqModal, onClose:a.onClose}); return false}); b("#dData, #eData", "#" + d + "_2").hover(function(){b(this).addClass("ui-state-hover")}, function(){b(this).removeClass("ui-state-hover")}); - j && a.beforeShowForm(b("#" + d)); viewModal("#" + f.themodal, {gbox:"#gbox_" + e, jqm:a.jqModal, jqM:true, modal:a.modal})}k && a.afterShowForm(b("#" + d))}})}})})(jQuery); - (function(c){c.jgrid.extend({getPostData:function(){var a = this[0]; if (a.grid)return a.p.postData}, setPostData:function(a){var b = this[0]; if (b.grid)if (typeof a === "object")b.p.postData = a; else alert("Error: cannot add a non-object postData value. postData unchanged.")}, appendPostData:function(a){var b = this[0]; if (b.grid)typeof a === "object"?c.extend(b.p.postData, a):alert("Error: cannot append a non-object postData value. postData unchanged.")}, setPostDataItem:function(a, b){var d = this[0]; if (d.grid)d.p.postData[a] = - b}, getPostDataItem:function(a){var b = this[0]; if (b.grid)return b.p.postData[a]}, removePostDataItem:function(a){var b = this[0]; b.grid && delete b.p.postData[a]}, getUserData:function(){var a = this[0]; if (a.grid)return a.p.userData}, getUserDataItem:function(a){var b = this[0]; if (b.grid)return b.p.userData[a]}})})(jQuery); - function tableToGrid(o, p){jQuery(o).each(function(){if (!this.grid){jQuery(this).width("99%"); var a = jQuery(this).width(), f = jQuery("input[type=checkbox]:first", jQuery(this)), l = jQuery("input[type=radio]:first", jQuery(this)), b = f.length > 0, q = !b && l.length > 0, m = b || q; f = f.attr("name") || l.attr("name"); var c = [], g = []; jQuery("th", jQuery(this)).each(function(){if (c.length === 0 && m){c.push({name:"__selection__", index:"__selection__", width:0, hidden:true}); g.push("__selection__")} else{c.push({name:jQuery(this).attr("id") || - jQuery.trim(jQuery.jgrid.stripHtml(jQuery(this).html())).split(" ").join("_"), index:jQuery(this).attr("id") || jQuery.trim(jQuery.jgrid.stripHtml(jQuery(this).html())).split(" ").join("_"), width:jQuery(this).width() || 150}); g.push(jQuery(this).html())}}); var e = [], h = [], i = []; jQuery("tbody > tr", jQuery(this)).each(function(){var j = {}, d = 0; jQuery("td", jQuery(this)).each(function(){if (d === 0 && m){var k = jQuery("input", jQuery(this)), n = k.attr("value"); h.push(n || e.length); k.attr("checked") && i.push(n); j[c[d].name] = - k.attr("value")} else j[c[d].name] = jQuery(this).html(); d++}); d > 0 && e.push(j)}); jQuery(this).empty(); jQuery(this).addClass("scroll"); jQuery(this).jqGrid($.extend({datatype:"local", width:a, colNames:g, colModel:c, multiselect:b}, p || {})); for (a = 0; a < e.length; a++){b = null; if (h.length > 0)if ((b = h[a]) && b.replace)b = encodeURIComponent(b).replace(/[.\-%]/g, "_"); if (b === null)b = a + 1; jQuery(this).jqGrid("addRowData", b, e[a])}for (a = 0; a < i.length; a++)jQuery(this).jqGrid("setSelection", i[a])}})}; - (function(a){if (a.browser.msie && a.browser.version == 8)a.expr[":"].hidden = function(b){return b.offsetWidth === 0 || b.offsetHeight === 0 || b.style.display == "none"}; a.jgrid._multiselect = false; if (a.ui)if (a.ui.multiselect){if (a.ui.multiselect.prototype._setSelected){var q = a.ui.multiselect.prototype._setSelected; a.ui.multiselect.prototype._setSelected = function(b, i){b = q.call(this, b, i); if (i && this.selectedList){var c = this.element; this.selectedList.find("li").each(function(){a(this).data("optionLink") && a(this).data("optionLink").remove().appendTo(c)})}return b}}if (a.ui.multiselect.prototype.destroy)a.ui.multiselect.prototype.destroy = - function(){this.element.show(); this.container.remove(); a.Widget === undefined?a.widget.prototype.destroy.apply(this, arguments):a.Widget.prototype.destroy.apply(this, arguments)}; a.jgrid._multiselect = true}a.jgrid.extend({sortableColumns:function(b){return this.each(function(){function i(){c.p.disableClick = true}var c = this, g = {tolerance:"pointer", axis:"x", scrollSensitivity:"1", items:">th:not(:has(#jqgh_cb,#jqgh_rn,#jqgh_subgrid),:hidden)", placeholder:{element:function(e){return a(document.createElement(e[0].nodeName)).addClass(e[0].className + - " ui-sortable-placeholder ui-state-highlight").removeClass("ui-sortable-helper")[0]}, update:function(e, h){h.height(e.currentItem.innerHeight() - parseInt(e.currentItem.css("paddingTop") || 0, 10) - parseInt(e.currentItem.css("paddingBottom") || 0, 10)); h.width(e.currentItem.innerWidth() - parseInt(e.currentItem.css("paddingLeft") || 0, 10) - parseInt(e.currentItem.css("paddingRight") || 0, 10))}}, update:function(e, h){e = a(h.item).parent(); e = a(">th", e); var j = {}; a.each(c.p.colModel, function(m){j[this.name] = m}); var l = []; - e.each(function(){var m = a(">div", this).get(0).id.replace(/^jqgh_/, ""); m in j && l.push(j[m])}); a(c).jqGrid("remapColumns", l, true, true); a.isFunction(c.p.sortable.update) && c.p.sortable.update(l); setTimeout(function(){c.p.disableClick = false}, 50)}}; if (c.p.sortable.options)a.extend(g, c.p.sortable.options); else if (a.isFunction(c.p.sortable))c.p.sortable = {update:c.p.sortable}; if (g.start){var d = g.start; g.start = function(e, h){i(); d.call(this, e, h)}} else g.start = i; if (c.p.sortable.exclude)g.items += ":not(" + c.p.sortable.exclude + - ")"; b.sortable(g).data("sortable").floating = true})}, columnChooser:function(b){function i(f, k, p){if (k >= 0){var o = f.slice(), r = o.splice(k, Math.max(f.length - k, k)); if (k > f.length)k = f.length; o[k] = p; return o.concat(r)}}function c(f, k){if (f)if (typeof f == "string")a.fn[f] && a.fn[f].apply(k, a.makeArray(arguments).slice(2)); else a.isFunction(f) && f.apply(k, a.makeArray(arguments).slice(2))}var g = this; if (!a("#colchooser_" + g[0].p.id).length){var d = a('
'), - e = a("select", d); b = a.extend({width:420, height:240, classname:null, done:function(f){f && g.jqGrid("remapColumns", f, true)}, msel:"multiselect", dlog:"dialog", dlog_opts:function(f){var k = {}; k[f.bSubmit] = function(){f.apply_perm(); f.cleanup(false)}; k[f.bCancel] = function(){f.cleanup(true)}; return{buttons:k, close:function(){f.cleanup(true)}, modal:false, resizable:false, width:f.width + 20}}, apply_perm:function(){a("option", e).each(function(){this.selected?g.jqGrid("showCol", h[this.value].name):g.jqGrid("hideCol", - h[this.value].name)}); var f = []; a("option[selected]", e).each(function(){f.push(parseInt(this.value, 10))}); a.each(f, function(){delete l[h[parseInt(this, 10)].name]}); a.each(l, function(){var k = parseInt(this, 10); f = i(f, k, k)}); b.done && b.done.call(g, f)}, cleanup:function(f){c(b.dlog, d, "destroy"); c(b.msel, e, "destroy"); d.remove(); f && b.done && b.done.call(g)}, msel_opts:{}}, a.jgrid.col, b || {}); if (a.ui)if (a.ui.multiselect)if (b.msel == "multiselect"){if (!a.jgrid._multiselect){alert("Multiselect plugin loaded after jqGrid. Please load the plugin before the jqGrid!"); - return}b.msel_opts = a.extend(a.ui.multiselect.defaults, b.msel_opts)}b.caption && d.attr("title", b.caption); if (b.classname){d.addClass(b.classname); e.addClass(b.classname)}if (b.width){a(">div", d).css({width:b.width, margin:"0 auto"}); e.css("width", b.width)}if (b.height){a(">div", d).css("height", b.height); e.css("height", b.height - 10)}var h = g.jqGrid("getGridParam", "colModel"), j = g.jqGrid("getGridParam", "colNames"), l = {}, m = []; e.empty(); a.each(h, function(f){l[this.name] = f; if (this.hidedlg)this.hidden || m.push(f); - else e.append("")}); var n = a.isFunction(b.dlog_opts)?b.dlog_opts.call(g, b):b.dlog_opts; c(b.dlog, d, n); n = a.isFunction(b.msel_opts)?b.msel_opts.call(g, b):b.msel_opts; c(b.msel, e, n)}}, sortableRows:function(b){return this.each(function(){var i = this; if (i.grid)if (!i.p.treeGrid)if (a.fn.sortable){b = a.extend({cursor:"move", axis:"y", items:".jqgrow"}, b || {}); if (b.start && a.isFunction(b.start)){b._start_ = b.start; delete b.start} else b._start_ = - false; if (b.update && a.isFunction(b.update)){b._update_ = b.update; delete b.update} else b._update_ = false; b.start = function(c, g){a(g.item).css("border-width", "0px"); a("td", g.item).each(function(h){this.style.width = i.grid.cols[h].style.width}); if (i.p.subGrid){var d = a(g.item).attr("id"); try{a(i).jqGrid("collapseSubGridRow", d)} catch (e){}}b._start_ && b._start_.apply(this, [c, g])}; b.update = function(c, g){a(g.item).css("border-width", ""); i.updateColumns(); i.p.rownumbers === true && a("td.jqgrid-rownum", i.rows).each(function(d){a(this).html(d + - 1)}); b._update_ && b._update_.apply(this, [c, g])}; a("tbody:first", i).sortable(b); a("tbody:first", i).disableSelection()}})}, gridDnD:function(b){return this.each(function(){function i(){var d = a.data(c, "dnd"); a("tr.jqgrow:not(.ui-draggable)", c).draggable(a.isFunction(d.drag)?d.drag.call(a(c), d):d.drag)}var c = this; if (c.grid)if (!c.p.treeGrid)if (a.fn.draggable && a.fn.droppable){a("#jqgrid_dnd").html() === null && a("body").append("
"); if (typeof b == "string" && b == - "updateDnD" && c.p.jqgdnd === true)i(); else{b = a.extend({drag:function(d){return a.extend({start:function(e, h){if (c.p.subGrid){var j = a(h.helper).attr("id"); try{a(c).jqGrid("collapseSubGridRow", j)} catch (l){}}for (j = 0; j < a.data(c, "dnd").connectWith.length; j++)a(a.data(c, "dnd").connectWith[j]).jqGrid("getGridParam", "reccount") == "0" && a(a.data(c, "dnd").connectWith[j]).jqGrid("addRowData", "jqg_empty_row", {}); h.helper.addClass("ui-state-highlight"); a("td", h.helper).each(function(m){this.style.width = c.grid.headers[m].width + - "px"}); d.onstart && a.isFunction(d.onstart) && d.onstart.call(a(c), e, h)}, stop:function(e, h){if (h.helper.dropped){var j = a(h.helper).attr("id"); a(c).jqGrid("delRowData", j)}for (j = 0; j < a.data(c, "dnd").connectWith.length; j++)a(a.data(c, "dnd").connectWith[j]).jqGrid("delRowData", "jqg_empty_row"); d.onstop && a.isFunction(d.onstop) && d.onstop.call(a(c), e, h)}}, d.drag_opts || {})}, drop:function(d){return a.extend({accept:function(e){var h = a(e).closest("table.ui-jqgrid-btable"); if (a.data(h[0], "dnd") !== undefined){e = a.data(h[0], - "dnd").connectWith; return a.inArray("#" + this.id, e) != - 1?true:false}return e}, drop:function(e, h){var j = a(h.draggable).attr("id"); j = a("#" + c.id).jqGrid("getRowData", j); if (!d.dropbyname){var l = 0, m = {}, n, f = a("#" + this.id).jqGrid("getGridParam", "colModel"); try{for (var k in j){if (j.hasOwnProperty(k) && f[l]){n = f[l].name; m[n] = j[k]}l++}j = m} catch (p){}}h.helper.dropped = true; if (d.beforedrop && a.isFunction(d.beforedrop)){n = d.beforedrop.call(this, e, h, j, a("#" + c.id), a(this)); if (typeof n != "undefined" && n !== null && typeof n == - "object")j = n}if (h.helper.dropped){var o; if (d.autoid)if (a.isFunction(d.autoid))o = d.autoid.call(this, j); else{o = Math.ceil(Math.random() * 1E3); o = d.autoidprefix + o}a("#" + this.id).jqGrid("addRowData", o, j, d.droppos)}d.ondrop && a.isFunction(d.ondrop) && d.ondrop.call(this, e, h, j)}}, d.drop_opts || {})}, onstart:null, onstop:null, beforedrop:null, ondrop:null, drop_opts:{activeClass:"ui-state-active", hoverClass:"ui-state-hover"}, drag_opts:{revert:"invalid", helper:"clone", cursor:"move", appendTo:"#jqgrid_dnd", zIndex:5E3}, - dropbyname:false, droppos:"first", autoid:true, autoidprefix:"dnd_"}, b || {}); if (b.connectWith){b.connectWith = b.connectWith.split(","); b.connectWith = a.map(b.connectWith, function(d){return a.trim(d)}); a.data(c, "dnd", b); c.p.reccount != "0" && !c.p.jqgdnd && i(); c.p.jqgdnd = true; for (var g = 0; g < b.connectWith.length; g++)a(b.connectWith[g]).droppable(a.isFunction(b.drop)?b.drop.call(a(c), b):b.drop)}}}})}, gridResize:function(b){return this.each(function(){var i = this; if (i.grid && a.fn.resizable){b = a.extend({}, b || {}); if (b.alsoResize){b._alsoResize_ = - b.alsoResize; delete b.alsoResize} else b._alsoResize_ = false; if (b.stop && a.isFunction(b.stop)){b._stop_ = b.stop; delete b.stop} else b._stop_ = false; b.stop = function(c, g){a(i).jqGrid("setGridParam", {height:a("#gview_" + i.p.id + " .ui-jqgrid-bdiv").height()}); a(i).jqGrid("setGridWidth", g.size.width, b.shrinkToFit); b._stop_ && b._stop_.call(i, c, g)}; b.alsoResize = b._alsoResize_?eval("(" + ("{'#gview_" + i.p.id + " .ui-jqgrid-bdiv':true,'" + b._alsoResize_ + "':true}") + ")"):a(".ui-jqgrid-bdiv", "#gview_" + i.p.id); delete b._alsoResize_; - a("#gbox_" + i.p.id).resizable(b)}})}})})(jQuery); +* jqGrid 4.6.0 - jQuery Grid +* Copyright (c) 2008, Tony Tomov, tony@trirand.com +* Dual licensed under the MIT or GPL licenses +* http://www.opensource.org/licenses/mit-license.php +* http://www.gnu.org/licenses/gpl-2.0.html +* Date:2014-02-20 +* Modules: grid.base.js; jquery.fmatter.js; grid.custom.js; grid.common.js; grid.formedit.js; grid.filter.js; grid.inlinedit.js; grid.celledit.js; jqModal.js; jqDnR.js; grid.subgrid.js; grid.grouping.js; grid.treegrid.js; grid.pivot.js; grid.import.js; JsonXml.js; grid.tbltogrid.js; grid.jqueryui.js; +*/ +(function(b){b.jgrid=b.jgrid||{};b.extend(b.jgrid,{version:"4.6.0",htmlDecode:function(b){return b&&(" "===b||" "===b||1===b.length&&160===b.charCodeAt(0))?"":b?String(b).replace(/>/g,">").replace(/</g,"<").replace(/"/g,'"').replace(/&/g,"&"):b},htmlEncode:function(b){return b?String(b).replace(/&/g,"&").replace(/\"/g,""").replace(//g,">"):b},format:function(e){var f=b.makeArray(arguments).slice(1);null==e&&(e="");return e.replace(/\{(\d+)\}/g, +function(b,d){return f[d]})},msie:"Microsoft Internet Explorer"===navigator.appName,msiever:function(){var b=-1;null!=/MSIE ([0-9]{1,}[.0-9]{0,})/.exec(navigator.userAgent)&&(b=parseFloat(RegExp.$1));return b},getCellIndex:function(e){e=b(e);if(e.is("tr"))return-1;e=(e.is("td")||e.is("th")?e:e.closest("td,th"))[0];return b.jgrid.msie?b.inArray(e,e.parentNode.cells):e.cellIndex},stripHtml:function(b){b=String(b);var f=/<("[^"]*"|'[^']*'|[^'">])*>/gi;return b?(b=b.replace(f,""))&&" "!==b&&" "!== +b?b.replace(/\"/g,"'"):"":b},stripPref:function(e,f){var c=b.type(e);if("string"===c||"number"===c)e=String(e),f=""!==e?String(f).replace(String(e),""):f;return f},parse:function(e){"while(1);"===e.substr(0,9)&&(e=e.substr(9));"/*"===e.substr(0,2)&&(e=e.substr(2,e.length-4));e||(e="{}");return!0===b.jgrid.useJSON&&"object"===typeof JSON&&"function"===typeof JSON.parse?JSON.parse(e):eval("("+e+")")},parseDate:function(e,f,c,d){var a=/^\/Date\((([-+])?[0-9]+)(([-+])([0-9]{2})([0-9]{2}))?\)\/$/,l="string"=== +typeof f?f.match(a):null,a=function(a,b){a=String(a);for(b=parseInt(b,10)||2;a.lengthl&&(f[k]=l+1,g.m=f[k])),"F"===e[k]&&(l=b.inArray(f[k],d.monthNames,12),-1!==l&&11l&&f[k]===d.AmPm[l]&&(f[k]=l,g.h=h(f[k],g.h))),"A"===e[k]&&(l=b.inArray(f[k],d.AmPm),-1!==l&&1=h?g.y=1900+g.y:0<=h&&69>=h&&(g.y=2E3+g.y);h=new Date(g.y,g.m,g.d,g.h,g.i,g.s,g.u);0q?Math.floor((x+q-1)/7)+1:Math.floor((x+q-1)/7)|| +(4>((new Date(p-1,0,1)).getDay()+6)%7?53:52),F:d.monthNames[m-1+12],m:a(m),M:d.monthNames[m-1],n:m,t:"?",L:"?",o:"?",Y:p,y:String(p).substring(2),a:12>e?d.AmPm[0]:d.AmPm[1],A:12>e?d.AmPm[2]:d.AmPm[3],B:"?",g:e%12||12,G:e,h:a(e%12||12),H:a(e),i:a(f),s:a(k),u:n,e:"?",I:"?",O:(0?@\[\\\]\^`{|}~]/g,"\\$&")},guid:1,uidPref:"jqg",randId:function(e){return(e||b.jgrid.uidPref)+b.jgrid.guid++},getAccessor:function(b,f){var c,d,a=[],l;if("function"===typeof f)return f(b);c=b[f];if(void 0===c)try{if("string"===typeof f&& +(a=f.split(".")),l=a.length)for(c=b;c&&l--;)d=a.shift(),c=c[d]}catch(g){}return c},getXmlData:function(e,f,c){var d="string"===typeof f?f.match(/^(.*)\[(\w+)\]$/):null;if("function"===typeof f)return f(e);if(d&&d[2])return d[1]?b(d[1],e).attr(d[2]):b(e).attr(d[2]);e=b(f,e);return c?e:0
"), +f=e.appendTo("body").find("td").width();e.remove();return 0.1b?d:0;l||"number"===typeof a||"number"===typeof b||(a=String(a),b=String(b));return ab?d:0};this._performSort=function(){0!==x.length&&(a=d._doSort(a,0))};this._doSort=function(a,b){var l=x[b].by,e=x[b].dir,g=x[b].type,c=x[b].datefmt,f=x[b].sfunc;if(b===x.length-1)return d._getOrder(a,l,e,g,c,f);b++;l=d._getGroup(a,l,e,g,c);e=[];for(g=0;g",c)};this.less=function(a,b,c){return d._compareValues(d.less,a,b,"<",c)};this.greaterOrEquals=function(a,b,c){return d._compareValues(d.greaterOrEquals,a,b,">=",c)};this.lessOrEquals=function(a,b,c){return d._compareValues(d.lessOrEquals,a,b,"<=",c)};this.startsWith=function(a,c){var e=null==c?a:c,e=g?b.trim(e.toString()).length:e.toString().length;G?d._append(d._getStr("jQuery.jgrid.getAccessor(this,'"+ +a+"')")+".substr(0,"+e+") == "+d._getStr('"'+d._toStr(c)+'"')):(null!=c&&(e=g?b.trim(c.toString()).length:c.toString().length),d._append(d._getStr("this")+".substr(0,"+e+") == "+d._getStr('"'+d._toStr(a)+'"')));d._setCommand(d.startsWith,a);d._resetNegate();return d};this.endsWith=function(a,c){var e=null==c?a:c,e=g?b.trim(e.toString()).length:e.toString().length;G?d._append(d._getStr("jQuery.jgrid.getAccessor(this,'"+a+"')")+".substr("+d._getStr("jQuery.jgrid.getAccessor(this,'"+a+"')")+".length-"+ +e+","+e+') == "'+d._toStr(c)+'"'):d._append(d._getStr("this")+".substr("+d._getStr("this")+'.length-"'+d._toStr(a)+'".length,"'+d._toStr(a)+'".length) == "'+d._toStr(a)+'"');d._setCommand(d.endsWith,a);d._resetNegate();return d};this.contains=function(a,b){G?d._append(d._getStr("jQuery.jgrid.getAccessor(this,'"+a+"')")+'.indexOf("'+d._toStr(b)+'",0) > -1'):d._append(d._getStr("this")+'.indexOf("'+d._toStr(a)+'",0) > -1');d._setCommand(d.contains,a);d._resetNegate();return d};this.groupBy=function(b, +c,e,l){return d._hasData()?d._getGroup(a,b,c,e,l):null};this.orderBy=function(a,c,e,l,g){c=null==c?"a":b.trim(c.toString().toLowerCase());null==e&&(e="text");null==l&&(l="Y-m-d");null==g&&(g=!1);if("desc"===c||"descending"===c)c="d";if("asc"===c||"ascending"===c)c="a";x.push({by:a,dir:c,type:e,datefmt:l,sfunc:g});return d};return d}(e,null)},getMethod:function(e){return this.getAccessor(b.fn.jqGrid,e)},extend:function(e){b.extend(b.fn.jqGrid,e);this.no_legacy_api||b.fn.extend(e)}});b.fn.jqGrid=function(e){if("string"=== +typeof e){var f=b.jgrid.getMethod(e);if(!f)throw"jqGrid - No such method: "+e;var c=b.makeArray(arguments).slice(1);return f.apply(this,c)}return this.each(function(){if(!this.grid){var d=b.extend(!0,{url:"",height:150,page:1,rowNum:20,rowTotal:null,records:0,pager:"",pgbuttons:!0,pginput:!0,colModel:[],rowList:[],colNames:[],sortorder:"asc",sortname:"",datatype:"xml",mtype:"GET",altRows:!1,selarrrow:[],savedRow:[],shrinkToFit:!0,xmlReader:{},jsonReader:{},subGrid:!1,subGridModel:[],reccount:0,lastpage:0, +lastsort:0,selrow:null,beforeSelectRow:null,onSelectRow:null,onSortCol:null,ondblClickRow:null,onRightClickRow:null,onPaging:null,onSelectAll:null,onInitGrid:null,loadComplete:null,gridComplete:null,loadError:null,loadBeforeSend:null,afterInsertRow:null,beforeRequest:null,beforeProcessing:null,onHeaderClick:null,viewrecords:!1,loadonce:!1,multiselect:!1,multikey:!1,editurl:null,search:!1,caption:"",hidegrid:!0,hiddengrid:!1,postData:{},userData:{},treeGrid:!1,treeGridModel:"nested",treeReader:{}, +treeANode:-1,ExpandColumn:null,tree_root_level:0,prmNames:{page:"page",rows:"rows",sort:"sidx",order:"sord",search:"_search",nd:"nd",id:"id",oper:"oper",editoper:"edit",addoper:"add",deloper:"del",subgridid:"id",npage:null,totalrows:"totalrows"},forceFit:!1,gridstate:"visible",cellEdit:!1,cellsubmit:"remote",nv:0,loadui:"enable",toolbar:[!1,""],scroll:!1,multiboxonly:!1,deselectAfterSort:!0,scrollrows:!1,autowidth:!1,scrollOffset:18,cellLayout:5,subGridWidth:20,multiselectWidth:20,gridview:!1,rownumWidth:25, +rownumbers:!1,pagerpos:"center",recordpos:"right",footerrow:!1,userDataOnFooter:!1,hoverrows:!0,altclass:"ui-priority-secondary",viewsortcols:[!1,"vertical",!0],resizeclass:"",autoencode:!1,remapColumns:[],ajaxGridOptions:{},direction:"ltr",toppager:!1,headertitles:!1,scrollTimeout:40,data:[],_index:{},grouping:!1,groupingView:{groupField:[],groupOrder:[],groupText:[],groupColumnShow:[],groupSummary:[],showSummaryOnHide:!1,sortitems:[],sortnames:[],summary:[],summaryval:[],plusicon:"ui-icon-circlesmall-plus", +minusicon:"ui-icon-circlesmall-minus",displayField:[],groupSummaryPos:[],formatDisplayField:[],_locgr:!1},ignoreCase:!1,cmTemplate:{},idPrefix:"",multiSort:!1},b.jgrid.defaults,e||{}),a=this,c={headers:[],cols:[],footers:[],dragStart:function(c,e,g){var f=b(this.bDiv).offset().left;this.resizing={idx:c,startX:e.clientX,sOL:e.clientX-f};this.hDiv.style.cursor="col-resize";this.curGbox=b("#rs_m"+b.jgrid.jqID(d.id),"#gbox_"+b.jgrid.jqID(d.id));this.curGbox.css({display:"block",left:e.clientX-f,top:g[1], +height:g[2]});b(a).triggerHandler("jqGridResizeStart",[e,c]);b.isFunction(d.resizeStart)&&d.resizeStart.call(a,e,c);document.onselectstart=function(){return!1}},dragMove:function(a){if(this.resizing){var b=a.clientX-this.resizing.startX;a=this.headers[this.resizing.idx];var c="ltr"===d.direction?a.width+b:a.width-b,e;33=k&&(void 0===d.lastpage||parseInt((m+g+f-1)/f,10)<=d.lastpage)&&(n=parseInt((a-m+f-1)/f,10),0<=m||2>n||!0===d.scroll?(E=Math.round((m+g)/f)+1,k=-1):k=1);0d.lastpage||1===d.lastpage||E===d.page&&E===d.lastpage)||(c.hDiv.loading?c.timer=setTimeout(c.populateVisible,d.scrollTimeout):(d.page=E,C&&(c.selectionPreserver(e[0]), +c.emptyRows.call(e[0],!1,!1)),c.populate(n)))}}},scrollGrid:function(a){if(d.scroll){var b=c.bDiv.scrollTop;void 0===c.scrollTop&&(c.scrollTop=0);b!==c.scrollTop&&(c.scrollTop=b,c.timer&&clearTimeout(c.timer),c.timer=setTimeout(c.populateVisible,d.scrollTimeout))}c.hDiv.scrollLeft=c.bDiv.scrollLeft;d.footerrow&&(c.sDiv.scrollLeft=c.bDiv.scrollLeft);a&&a.stopPropagation()},selectionPreserver:function(a){var c=a.p,d=c.selrow,e=c.selarrrow?b.makeArray(c.selarrrow):null,f=a.grid.bDiv.scrollLeft,g=function(){var h; +c.selrow=null;c.selarrrow=[];if(c.multiselect&&e&&0=document.documentMode)alert("Grid can not be used in this ('quirks') mode!");else{b(this).empty().attr("tabindex", +"0");this.p=d;this.p.useProp=!!b.fn.prop;var g,f;if(0===this.p.colNames.length)for(g=0;g
"),n=b.jgrid.msie;a.p.direction=b.trim(a.p.direction.toLowerCase());-1===b.inArray(a.p.direction,["ltr","rtl"])&&(a.p.direction="ltr");f=a.p.direction;b(k).insertBefore(this);b(this).removeClass("scroll").appendTo(k); +var m=b("
");b(m).attr({id:"gbox_"+this.id,dir:f}).insertBefore(k);b(k).attr("id","gview_"+this.id).appendTo(m);b("
").insertBefore(k);b("
"+this.p.loadtext+"
").insertBefore(k);b(this).attr({cellspacing:"0",cellpadding:"0",border:"0",role:"grid","aria-multiselectable":!!this.p.multiselect, +"aria-labelledby":"gbox_"+this.id});var r=function(a,b){a=parseInt(a,10);return isNaN(a)?b||0:a},p=function(d,e,f,g,pa,h){var k=a.p.colModel[d],m=k.align,E='style="',n=k.classes,C=k.name,A=[];m&&(E+="text-align:"+m+";");!0===k.hidden&&(E+="display:none;");if(0===e)E+="width: "+c.headers[d].width+"px;";else if(k.cellattr&&b.isFunction(k.cellattr)&&(d=k.cellattr.call(a,pa,f,g,k,h))&&"string"===typeof d)if(d=d.replace(/style/i,"style").replace(/title/i,"title"),-1"+b+""},U=function(b,c,d,e){e='";return'"+e+""},M=function(a,b,c,d){c=(parseInt(c,10)-1)*parseInt(d,10)+1+b;return'"+c+""},ea=function(b){var c,d=[],e=0,f;for(f=0;f"},K=function(c,d,e,f,g){var h=new Date,l="local"!==a.p.datatype&&a.p.loadonce||"xmlstring"===a.p.datatype,k=a.p.xmlReader,m="local"===a.p.datatype?"local":"xml";l&&(a.p.data=[],a.p._index={},a.p.localReader.id="_id_");a.p.reccount=0;if(b.isXMLDoc(c)){-1!==a.p.treeANode||a.p.scroll?e=1=a.p.page&&(a.p.page=1);if(c&&S){g&&(D*=g+1);g=b.isFunction(a.p.afterInsertRow); +var F=!1,J;a.p.grouping&&(F=!0===a.p.groupingView.groupCollapse,J=b.jgrid.getMethod("groupingPrepare"));for(;I");a.p.grouping&&(y.push(s),a.p.groupingView._locgr||J.call(n,v,I),s=[]);if(l||!0===a.p.treeGrid)v._id_=b.jgrid.stripPref(a.p.idPrefix,H),a.p.data.push(v),a.p._index[v._id_]=a.p.data.length-1;!1===a.p.gridview&&(b("tbody:first",d).append(s.join("")),n.triggerHandler("jqGridAfterInsertRow",[H,v,w]),g&&a.p.afterInsertRow.call(a,H,v,w), +s=[]);v={};R++;I++;if(R===D)break}}!0===a.p.gridview&&(A=-1=a.p.page&&(a.p.page=1);var I=parseInt(a.p.rowNum,10),F=a.p.scroll?b.jgrid.randId():1,J=!1,K;g&&(I*=g+1);"local"!==a.p.datatype||a.p.deselectAfterSort||(J=!0);var N=b.isFunction(a.p.afterInsertRow),P=[],Q=!1,O;a.p.grouping&&(Q=!0===a.p.groupingView.groupCollapse,O=b.jgrid.getMethod("groupingPrepare"));for(;A");a.p.grouping&&(P.push(L),a.p.groupingView._locgr||O.call(m,w,A),L=[]);if(l||!0===a.p.treeGrid)w._id_=b.jgrid.stripPref(a.p.idPrefix,s),a.p.data.push(w),a.p._index[w._id_]=a.p.data.length-1;!1===a.p.gridview&&(b("#"+b.jgrid.jqID(a.p.id)+" tbody:first").append(L.join("")),m.triggerHandler("jqGridAfterInsertRow", +[s,w,g]),N&&a.p.afterInsertRow.call(a,s,w,g),L=[]);w={};n++;A++;if(n===I)break}!0===a.p.gridview&&(H=-1=a.p.page&&(a.p.page=Math.min(1,a.p.lastpage));null!==f.search&&(e[f.search]=a.p.search);null!==f.nd&&(e[f.nd]=(new Date).getTime());null!==f.rows&&(e[f.rows]=a.p.rowNum);null!==f.page&&(e[f.page]=a.p.page);null!==f.sort&&(e[f.sort]=a.p.sortname);null!==f.order&&(e[f.order]=a.p.sortorder);null!==a.p.rowTotal&&null!==f.totalrows&&(e[f.totalrows]=a.p.rowTotal);var h=b.isFunction(a.p.loadComplete),k=h?a.p.loadComplete: +null,l=0;c=c||1;1
").attr("dir","ltr");if(0";k+=""}"rtl"===f&&(g+=k);!0===a.p.pginput&&(d=""+b.jgrid.format(a.p.pgtext||"","","")+"");!0===a.p.pgbuttons? +(m=["first"+e,"prev"+e,"next"+e,"last"+e],"rtl"===f&&m.reverse(),g+="",g+="",g=g+(""!==d?""+d+"": +"")+(""),g+=""):""!==d&&(g+=d);"ltr"===f&&(g+=k);g+="";!0===a.p.viewrecords&&b("td#"+c+"_"+a.p.recordpos,"#"+l).append("
");b("td#"+c+"_"+a.p.pagerpos,"#"+l).append(g);k=b(".ui-jqgrid").css("font-size")|| +"11px";b(document.body).append("");g=b(g).clone().appendTo("#testpg").width();b("#testpg").remove();0"),this.p.colModel.unshift({name:"cb",width:b.jgrid.cell_width?a.p.multiselectWidth+a.p.cellLayout:a.p.multiselectWidth,sortable:!1,resizable:!1,hidedlg:!0,search:!1,align:"center",fixed:!0}));this.p.rownumbers&&(this.p.colNames.unshift(""),this.p.colModel.unshift({name:"rn",width:a.p.rownumWidth, +sortable:!1,resizable:!1,hidedlg:!0,search:!1,align:"center",fixed:!0}));a.p.xmlReader=b.extend(!0,{root:"rows",row:"row",page:"rows>page",total:"rows>total",records:"rows>records",repeatitems:!0,cell:"cell",id:"[id]",userdata:"userdata",subgrid:{root:"rows",row:"row",repeatitems:!0,cell:"cell"}},a.p.xmlReader);a.p.jsonReader=b.extend(!0,{root:"rows",page:"page",total:"total",records:"records",repeatitems:!0,cell:"cell",id:"id",userdata:"userdata",subgrid:{root:"rows",repeatitems:!0,cell:"cell"}}, +a.p.jsonReader);a.p.localReader=b.extend(!0,{root:"rows",page:"page",total:"total",records:"records",repeatitems:!1,cell:"cell",id:"id",userdata:"userdata",subgrid:{root:"rows",repeatitems:!0,cell:"cell"}},a.p.localReader);a.p.scroll&&(a.p.pgbuttons=!1,a.p.pginput=!1,a.p.rowList=[]);a.p.data.length&&O();var D="",ta,F,ja,fa,ka,y,t,ba,ua=ba="",ga=[],va=[];F=[];if(!0===a.p.shrinkToFit&&!0===a.p.forceFit)for(g=a.p.colModel.length-1;0<=g;g--)if(!a.p.colModel[g].hidden){a.p.colModel[g].resizable= +!1;break}"horizontal"===a.p.viewsortcols[1]&&(ba=" ui-i-asc",ua=" ui-i-desc");ta=n?"class='ui-th-div-ie'":"";ba="");if(a.p.multiSort)for(ga=a.p.sortname.split(","),g=0;g",F=a.p.colModel[g].index||a.p.colModel[g].name,D+="
"+a.p.colNames[g],a.p.colModel[g].width=a.p.colModel[g].width?parseInt(a.p.colModel[g].width,10): +150,"boolean"!==typeof a.p.colModel[g].title&&(a.p.colModel[g].title=!0),a.p.colModel[g].lso="",F===a.p.sortname&&(a.p.lastsort=g),a.p.multiSort&&(F=b.inArray(F,ga),-1!==F&&(a.p.colModel[g].lso=va[F])),D+=ba+"
";D+="";ba=null;b(this).append(D);b("thead tr:first th",this).hover(function(){b(this).addClass("ui-state-hover")},function(){b(this).removeClass("ui-state-hover")});if(this.p.multiselect){var la=[],ca;b("#cb_"+b.jgrid.jqID(a.p.id),this).bind("click",function(){a.p.selarrrow= +[];var c=!0===a.p.frozenColumns?a.p.id+"_frozen":"";this.checked?(b(a.rows).each(function(d){0c&&(this.hidden=!a.p.groupingView.groupColumnShow[c])}this.widthOrg=k=r(this.width,0);!1===this.hidden&&(d+=k+e,this.fixed?p+=k+e:g++)});isNaN(a.p.width)&&(a.p.width=d+(!1!==a.p.shrinkToFit||isNaN(a.p.height)?0:h));c.width=a.p.width;a.p.tblwidth=d;!1===a.p.shrinkToFit&&!0===a.p.forceFit&&(a.p.forceFit=!1);!0===a.p.shrinkToFit&&0a.p.width&&(a.p.colModel[f].width-=a.p.tblwidth-parseInt(a.p.width,10),a.p.tblwidth=a.p.width))})();b(m).css("width",c.width+"px").append("
 
");b(k).css("width",c.width+"px");var D=b("thead:first",a).get(0),V="";a.p.footerrow&&(V+="");var k=b("tr:first",D),da="";a.p.disableClick=!1;b("th",k).each(function(d){ja=a.p.colModel[d].width;void 0===a.p.colModel[d].resizable&&(a.p.colModel[d].resizable= +!0);a.p.colModel[d].resizable?(fa=document.createElement("span"),b(fa).html(" ").addClass("ui-jqgrid-resize ui-jqgrid-resize-"+f).css("cursor","col-resize"),b(this).addClass(a.p.resizeclass)):fa="";b(this).css("width",ja+"px").prepend(fa);fa=null;var e="";a.p.colModel[d].hidden&&(b(this).css("display","none"),e="display:none;");da+="";c.headers[d]={width:ja,el:this};ka=a.p.colModel[d].sortable;"boolean"!==typeof ka&&(ka=a.p.colModel[d].sortable= +!0);e=a.p.colModel[d].name;"cb"!==e&&"subgrid"!==e&&"rn"!==e&&a.p.viewsortcols[2]&&b(">div",this).addClass("ui-jqgrid-sortable");ka&&(a.p.multiSort?a.p.viewsortcols[0]?(b("div span.s-ico",this).show(),a.p.colModel[d].lso&&b("div span.ui-icon-"+a.p.colModel[d].lso,this).removeClass("ui-state-disabled")):a.p.colModel[d].lso&&(b("div span.s-ico",this).show(),b("div span.ui-icon-"+a.p.colModel[d].lso,this).removeClass("ui-state-disabled")):a.p.viewsortcols[0]?(b("div span.s-ico",this).show(),d===a.p.lastsort&& +b("div span.ui-icon-"+a.p.sortorder,this).removeClass("ui-state-disabled")):d===a.p.lastsort&&(b("div span.s-ico",this).show(),b("div span.ui-icon-"+a.p.sortorder,this).removeClass("ui-state-disabled")));a.p.footerrow&&(V+="")}).mousedown(function(d){if(1===b(d.target).closest("th>span.ui-jqgrid-resize").length){var e=sa(this);if(!0===a.p.forceFit){var g=a.p,f=e,h;for(h=e+1;h
 
").append(D),J=a.p.caption&&!0===a.p.hiddengrid?!0:!1;g=b("
");D=null;c.hDiv=document.createElement("div");b(c.hDiv).css({width:c.width+"px"}).addClass("ui-state-default ui-jqgrid-hdiv").append(g);b(g).append(k);k=null;J&&b(c.hDiv).hide();a.p.pager&&("string"===typeof a.p.pager?"#"!==a.p.pager.substr(0,1)&&(a.p.pager="#"+a.p.pager):a.p.pager="#"+b(a.p.pager).attr("id"),b(a.p.pager).css({width:c.width+"px"}).addClass("ui-state-default ui-jqgrid-pager ui-corner-bottom").appendTo(m),J&&b(a.p.pager).hide(),qa(a.p.pager,""));!1=== +a.p.cellEdit&&!0===a.p.hoverrows&&b(a).bind("mouseover",function(a){t=b(a.target).closest("tr.jqgrow");"ui-subgrid"!==b(t).attr("class")&&b(t).addClass("ui-state-hover")}).bind("mouseout",function(a){t=b(a.target).closest("tr.jqgrow");b(t).removeClass("ui-state-hover")});var B,N,ma;b(a).before(c.hDiv).click(function(c){y=c.target;t=b(y,a.rows).closest("tr.jqgrow");if(0===b(t).length||-1a.p.lastpage&&(e=a.p.lastpage);1>e&&(e=1);a.p.page=e;a.grid.bDiv.scrollTop=a.grid.prevRowHeight?(e-1)*a.grid.prevRowHeight*a.p.rowNum:0}a.grid.prevRowHeight&&a.p.scroll?(delete a.p.lastpage,a.grid.populateVisible()):a.grid.populate(); +!0===a.p._inlinenav&&b(a).jqGrid("showAddEditButtons");return!1}).dblclick(function(c){y=c.target;t=b(y,a.rows).closest("tr.jqgrow");0!==b(t).length&&(B=t[0].rowIndex,N=b.jgrid.getCellIndex(y),b(a).triggerHandler("jqGridDblClickRow",[b(t).attr("id"),B,N,c]),b.isFunction(a.p.ondblClickRow)&&a.p.ondblClickRow.call(a,b(t).attr("id"),B,N,c))}).bind("contextmenu",function(c){y=c.target;t=b(y,a.rows).closest("tr.jqgrow");0!==b(t).length&&(a.p.multiselect||b(a).jqGrid("setSelection",t[0].id,!0,c),B=t[0].rowIndex, +N=b.jgrid.getCellIndex(y),b(a).triggerHandler("jqGridRightClickRow",[b(t).attr("id"),B,N,c]),b.isFunction(a.p.onRightClickRow)&&a.p.onRightClickRow.call(a,b(t).attr("id"),B,N,c))});c.bDiv=document.createElement("div");n&&"auto"===String(a.p.height).toLowerCase()&&(a.p.height="100%");b(c.bDiv).append(b('
').append("
").append(this)).addClass("ui-jqgrid-bdiv").css({height:a.p.height+(isNaN(a.p.height)?"":"px"), +width:c.width+"px"}).scroll(c.scrollGrid);b("table:first",c.bDiv).css({width:a.p.tblwidth+"px"});b.support.tbody||2===b("tbody",this).length&&b("tbody:gt(0)",this).remove();a.p.multikey&&(b.jgrid.msie?b(c.bDiv).bind("selectstart",function(){return!1}):b(c.bDiv).bind("mousedown",function(){return!1}));J&&b(c.bDiv).hide();c.cDiv=document.createElement("div");var na=!0===a.p.hidegrid?b("").hover(function(){na.addClass("ui-state-hover")}, +function(){na.removeClass("ui-state-hover")}).append("").css("rtl"===f?"left":"right","0px"):"";b(c.cDiv).append(na).append(""+a.p.caption+"").addClass("ui-jqgrid-titlebar ui-jqgrid-caption"+("rtl"===f?"-rtl":"")+" ui-widget-header ui-corner-top ui-helper-clearfix");b(c.cDiv).insertBefore(c.hDiv);a.p.toolbar[0]&&(c.uDiv=document.createElement("div"),"top"===a.p.toolbar[1]?b(c.uDiv).insertBefore(c.hDiv):"bottom"=== +a.p.toolbar[1]&&b(c.uDiv).insertAfter(c.hDiv),"both"===a.p.toolbar[1]?(c.ubDiv=document.createElement("div"),b(c.uDiv).addClass("ui-userdata ui-state-default").attr("id","t_"+this.id).insertBefore(c.hDiv),b(c.ubDiv).addClass("ui-userdata ui-state-default").attr("id","tb_"+this.id).insertAfter(c.hDiv),J&&b(c.ubDiv).hide()):b(c.uDiv).width(c.width).addClass("ui-userdata ui-state-default").attr("id","t_"+this.id),J&&b(c.uDiv).hide());a.p.toppager&&(a.p.toppager=b.jgrid.jqID(a.p.id)+"_toppager",c.topDiv= +b("
")[0],a.p.toppager="#"+a.p.toppager,b(c.topDiv).addClass("ui-state-default ui-jqgrid-toppager").width(c.width).insertBefore(c.hDiv),qa(a.p.toppager,"_t"));a.p.footerrow&&(c.sDiv=b("
")[0],g=b("
"),b(c.sDiv).append(g).width(c.width).insertAfter(c.hDiv),b(g).append(V),c.footers=b(".ui-jqgrid-ftable",c.sDiv)[0].rows[0].cells,a.p.rownumbers&&(c.footers[0].className="ui-state-default jqgrid-rownum"), +J&&b(c.sDiv).hide());g=null;if(a.p.caption){var ya=a.p.datatype;!0===a.p.hidegrid&&(b(".ui-jqgrid-titlebar-close",c.cDiv).click(function(d){var e=b.isFunction(a.p.onHeaderClick),g=".ui-jqgrid-bdiv, .ui-jqgrid-hdiv, .ui-jqgrid-pager, .ui-jqgrid-sdiv",f,h=this;!0===a.p.toolbar[0]&&("both"===a.p.toolbar[1]&&(g+=", #"+b(c.ubDiv).attr("id")),g+=", #"+b(c.uDiv).attr("id"));f=b(g,"#gview_"+b.jgrid.jqID(a.p.id)).length;"visible"===a.p.gridstate?b(g,"#gbox_"+b.jgrid.jqID(a.p.id)).slideUp("fast",function(){f--; +0===f&&(b("span",h).removeClass("ui-icon-circle-triangle-n").addClass("ui-icon-circle-triangle-s"),a.p.gridstate="hidden",b("#gbox_"+b.jgrid.jqID(a.p.id)).hasClass("ui-resizable")&&b(".ui-resizable-handle","#gbox_"+b.jgrid.jqID(a.p.id)).hide(),b(a).triggerHandler("jqGridHeaderClick",[a.p.gridstate,d]),e&&(J||a.p.onHeaderClick.call(a,a.p.gridstate,d)))}):"hidden"===a.p.gridstate&&b(g,"#gbox_"+b.jgrid.jqID(a.p.id)).slideDown("fast",function(){f--;0===f&&(b("span",h).removeClass("ui-icon-circle-triangle-s").addClass("ui-icon-circle-triangle-n"), +J&&(a.p.datatype=ya,Q(),J=!1),a.p.gridstate="visible",b("#gbox_"+b.jgrid.jqID(a.p.id)).hasClass("ui-resizable")&&b(".ui-resizable-handle","#gbox_"+b.jgrid.jqID(a.p.id)).show(),b(a).triggerHandler("jqGridHeaderClick",[a.p.gridstate,d]),e&&(J||a.p.onHeaderClick.call(a,a.p.gridstate,d)))});return!1}),J&&(a.p.datatype="local",b(".ui-jqgrid-titlebar-close",c.cDiv).trigger("click")))}else b(c.cDiv).hide();b(c.hDiv).after(c.bDiv).mousemove(function(a){if(c.resizing)return c.dragMove(a),!1});b(".ui-jqgrid-labels", +c.hDiv).bind("selectstart",function(){return!1});b(document).bind("mouseup.jqGrid"+a.p.id,function(){return c.resizing?(c.dragEnd(),!1):!0});a.formatCol=p;a.sortData=ra;a.updatepager=function(c,d){var e,g,f,h,k,l,m,n="",p=a.p.pager?"_"+b.jgrid.jqID(a.p.pager.substr(1)):"",q=a.p.toppager?"_"+a.p.toppager.substr(1):"";f=parseInt(a.p.page,10)-1;0>f&&(f=0);f*=parseInt(a.p.rowNum,10);k=f+a.p.reccount;if(a.p.scroll){e=b("tbody:first > tr:gt(0)",a.grid.bDiv);f=k-e.length;a.p.reccount=e.length;if(e=e.outerHeight()|| +a.grid.prevRowHeight)g=f*e,m=parseInt(a.p.records,10)*e,b(">div:first",a.grid.bDiv).css({height:m}).children("div:first").css({height:g,display:g?"":"none"}),0==a.grid.bDiv.scrollTop&&1=e&&(e=g=0),1===e||0===e?(b("#first"+ +p+", #prev"+p).addClass("ui-state-disabled").removeClass("ui-state-hover"),a.p.toppager&&b("#first_t"+q+", #prev_t"+q).addClass("ui-state-disabled").removeClass("ui-state-hover")):(b("#first"+p+", #prev"+p).removeClass("ui-state-disabled"),a.p.toppager&&b("#first_t"+q+", #prev_t"+q).removeClass("ui-state-disabled")),e===g||0===e?(b("#next"+p+", #last"+p).addClass("ui-state-disabled").removeClass("ui-state-hover"),a.p.toppager&&b("#next_t"+q+", #last_t"+q).addClass("ui-state-disabled").removeClass("ui-state-hover")): +(b("#next"+p+", #last"+p).removeClass("ui-state-disabled"),a.p.toppager&&b("#next_t"+q+", #last_t"+q).removeClass("ui-state-disabled")));!0===c&&!0===a.p.rownumbers&&b(">td.jqgrid-rownum",a.rows).each(function(a){b(this).html(f+1+a)});d&&a.p.jqgdnd&&b(a).jqGrid("gridDnD","updateDnD");b(a).triggerHandler("jqGridGridComplete");b.isFunction(a.p.gridComplete)&&a.p.gridComplete.call(a);b(a).triggerHandler("jqGridAfterGridComplete")};a.refreshIndex=O;a.setHeadCheckBox=ha;a.constructTr=$;a.formatter=function(a, +b,c,d,e){return x(a,b,c,d,e)};b.extend(c,{populate:Q,emptyRows:X,beginReq:P,endReq:T});this.grid=c;a.addXmlData=function(b){K(b,a.grid.bDiv)};a.addJSONData=function(b){Y(b,a.grid.bDiv)};this.grid.cols=this.rows[0].cells;b(a).triggerHandler("jqGridInitGrid");b.isFunction(a.p.onInitGrid)&&a.p.onInitGrid.call(a);Q();a.p.hiddengrid=!1}}}})};b.jgrid.extend({getGridParam:function(b){var f=this[0];if(f&&f.grid)return b?void 0!==f.p[b]?f.p[b]:null:f.p},setGridParam:function(e){return this.each(function(){this.grid&& +"object"===typeof e&&b.extend(!0,this.p,e)})},getGridRowById:function(e){var f;this.each(function(){try{for(var c=this.rows.length;c--;)if(e.toString()===this.rows[c].id){f=this.rows[c];break}}catch(d){f=b(this.grid.bDiv).find("#"+b.jgrid.jqID(e))}});return f},getDataIDs:function(){var e=[],f=0,c,d=0;this.each(function(){if((c=this.rows.length)&&0=d+g?b(this.grid.bDiv)[0].scrollTop=h-(d+g)+l+g:h span:first",k).html(h).attr(l):b("td[role='gridcell']:eq("+a+")",k).html(h).attr(l))}),"local"===g.p.datatype){var r=b.jgrid.stripPref(g.p.idPrefix,e),p=g.p._index[r],q;if(g.p.treeGrid)for(q in g.p.treeReader)g.p.treeReader.hasOwnProperty(q)&& +delete m[g.p.treeReader[q]];void 0!==p&&(g.p.data[p]=b.extend(!0,g.p.data[p],m));m=null}}catch(x){a=!1}a&&("string"===n?b(k).addClass(c):null!==c&&"object"===n&&b(k).css(c),b(g).triggerHandler("jqGridAfterGridComplete"))});return a},addRowData:function(e,f,c,d){c||(c="last");var a=!1,l,g,h,k,n,m,r,p,q="",x,G,U,M,ea,W;f&&(b.isArray(f)?(x=!0,c="last",G=e):(f=[f],x=!1),this.each(function(){var X=f.length;n=!0===this.p.rownumbers?1:0;h=!0===this.p.multiselect?1:0;k=!0===this.p.subGrid?1:0;x||(void 0!== +e?e=String(e):(e=b.jgrid.randId(),!1!==this.p.keyIndex&&(G=this.p.colModel[this.p.keyIndex+h+k+n].name,void 0!==f[0][G]&&(e=f[0][G]))));U=this.p.altclass;for(var O=0,$="",K={},Y=b.isFunction(this.p.afterInsertRow)?!0:!1;O0");h&&(p='',q=this.formatCol(n,1,"",null,e,!0),g[g.length]='"+p+"");k&&(g[g.length]=b(this).jqGrid("addSubGridCell",h+n,1));for(r=h+k+n;r"+p+"";g.unshift(this.constructTr(e,!1,$,K,M,!1)); +g[g.length]="";if(0===this.rows.length)b("table:first",this.grid.bDiv).append(g.join(""));else switch(c){case "last":b(this.rows[this.rows.length-1]).after(g.join(""));m=this.rows.length-1;break;case "first":b(this.rows[0]).after(g.join(""));m=1;break;case "after":if(m=b(this).jqGrid("getGridRowById",d))b(this.rows[m.rowIndex+1]).hasClass("ui-subgrid")?b(this.rows[m.rowIndex+1]).after(g):b(m).after(g.join("")),m=m.rowIndex+1;break;case "before":if(m=b(this).jqGrid("getGridRowById",d))b(m).before(g.join("")), +m=m.rowIndex-1}!0===this.p.subGrid&&b(this).jqGrid("addSubGrid",h+n,m);this.p.records++;this.p.reccount++;b(this).triggerHandler("jqGridAfterInsertRow",[e,M,M]);Y&&this.p.afterInsertRow.call(this,e,M,M);O++;"local"===this.p.datatype&&(K[this.p.localReader.id]=W,this.p._index[W]=this.p.data.length,this.p.data.push(K),K={})}!0!==this.p.altRows||x||("last"===c?1===(this.rows.length-1)%2&&b(this.rows[this.rows.length-1]).addClass(U):b(this.rows).each(function(a){1===a%2?b(this).addClass(U):b(this).removeClass(U)})); +this.updatepager(!0,!0);a=!0}));return a},footerData:function(e,f,c){function d(a){for(var b in a)if(a.hasOwnProperty(b))return!1;return!0}var a,l=!1,g={},h;void 0==e&&(e="get");"boolean"!==typeof c&&(c=!0);e=e.toLowerCase();this.each(function(){var k=this,n;if(!k.grid||!k.p.footerrow||"set"===e&&d(f))return!1;l=!0;b(this.p.colModel).each(function(d){a=this.name;"set"===e?void 0!==f[a]&&(n=c?k.formatter("",f[a],d,f,"edit"):f[a],h=this.title?{title:b.jgrid.stripHtml(n)}:{},b("tr.footrow td:eq("+d+ +")",k.grid.sDiv).html(n).attr(h),l=!0):"get"===e&&(g[a]=b("tr.footrow td:eq("+d+")",k.grid.sDiv).html())})});return"get"===e?g:l},showHideCol:function(e,f){return this.each(function(){var c=this,d=!1,a=b.jgrid.cell_width?0:c.p.cellLayout,l;if(c.grid){"string"===typeof e&&(e=[e]);f="none"!==f?"":"none";var g=""===f?!0:!1,h=c.p.groupHeader&&("object"===typeof c.p.groupHeader||b.isFunction(c.p.groupHeader));h&&b(c).jqGrid("destroyGroupHeader",!1);b(this.p.colModel).each(function(h){if(-1!==b.inArray(this.name, +e)&&this.hidden===g){if(!0===c.p.frozenColumns&&!0===this.frozen)return!0;b("tr[role=rowheader]",c.grid.hDiv).each(function(){b(this.cells[h]).css("display",f)});b(c.rows).each(function(){b(this).hasClass("jqgroup")||b(this.cells[h]).css("display",f)});c.p.footerrow&&b("tr.footrow td:eq("+h+")",c.grid.sDiv).css("display",f);l=parseInt(this.width,10);c.p.tblwidth="none"===f?c.p.tblwidth-(l+a):c.p.tblwidth+(l+a);this.hidden=!g;d=!0;b(c).triggerHandler("jqGridShowHideCol",[g,this.name,h])}});!0===d&& +(!0!==c.p.shrinkToFit||isNaN(c.p.height)||(c.p.tblwidth+=parseInt(c.p.scrollOffset,10)),b(c).jqGrid("setGridWidth",!0===c.p.shrinkToFit?c.p.tblwidth:c.p.width));h&&b(c).jqGrid("setGroupHeaders",c.p.groupHeader)}})},hideCol:function(e){return this.each(function(){b(this).jqGrid("showHideCol",e,"none")})},showCol:function(e){return this.each(function(){b(this).jqGrid("showHideCol",e,"")})},remapColumns:function(e,f,c){function d(a){var c;c=a.length?b.makeArray(a):b.extend({},a);b.each(e,function(b){a[b]= +c[this]})}function a(a,c){b(">tr"+(c||""),a).each(function(){var a=this,c=b.makeArray(a.cells);b.each(e,function(){var b=c[this];b&&a.appendChild(b)})})}var l=this.get(0);d(l.p.colModel);d(l.p.colNames);d(l.grid.headers);a(b("thead:first",l.grid.hDiv),c&&":not(.ui-jqgrid-labels)");f&&a(b("#"+b.jgrid.jqID(l.p.id)+" tbody:first"),".jqgfirstrow, tr.jqgrow, tr.jqfoot");l.p.footerrow&&a(b("tbody:first",l.grid.sDiv));l.p.remapColumns&&(l.p.remapColumns.length?d(l.p.remapColumns):l.p.remapColumns=b.makeArray(e)); +l.p.lastsort=b.inArray(l.p.lastsort,e);l.p.treeGrid&&(l.p.expColInd=b.inArray(l.p.expColInd,e));b(l).triggerHandler("jqGridRemapColumns",[e,f,c])},setGridWidth:function(e,f){return this.each(function(){if(this.grid){var c=this,d,a=0,l=b.jgrid.cell_width?0:c.p.cellLayout,g,h=0,k=!1,n=c.p.scrollOffset,m,r=0,p;"boolean"!==typeof f&&(f=c.p.shrinkToFit);if(!isNaN(e)){e=parseInt(e,10);c.grid.width=c.p.width=e;b("#gbox_"+b.jgrid.jqID(c.p.id)).css("width",e+"px");b("#gview_"+b.jgrid.jqID(c.p.id)).css("width", +e+"px");b(c.grid.bDiv).css("width",e+"px");b(c.grid.hDiv).css("width",e+"px");c.p.pager&&b(c.p.pager).css("width",e+"px");c.p.toppager&&b(c.p.toppager).css("width",e+"px");!0===c.p.toolbar[0]&&(b(c.grid.uDiv).css("width",e+"px"),"both"===c.p.toolbar[1]&&b(c.grid.ubDiv).css("width",e+"px"));c.p.footerrow&&b(c.grid.sDiv).css("width",e+"px");!1===f&&!0===c.p.forceFit&&(c.p.forceFit=!1);if(!0===f){b.each(c.p.colModel,function(){!1===this.hidden&&(d=this.widthOrg,a+=d+l,this.fixed?r+=d+l:h++)});if(0=== +h)return;c.p.tblwidth=a;m=e-l*h-r;!isNaN(c.p.height)&&(b(c.grid.bDiv)[0].clientHeightd||(this.width=d,a+=d,c.grid.headers[b].width=d,c.grid.headers[b].el.style.width=d+"px",c.p.footerrow&&(c.grid.footers[b].style.width=d+"px"),q&&(c.grid.cols[b].style.width=d+"px"),g=b))});if(!g)return; +p=0;k?e-r-(a+l*h)!==n&&(p=e-r-(a+l*h)-n):1!==Math.abs(e-r-(a+l*h))&&(p=e-r-(a+l*h));c.p.colModel[g].width+=p;c.p.tblwidth=a+p+l*h+r;c.p.tblwidth>e?(k=c.p.tblwidth-parseInt(e,10),c.p.tblwidth=e,d=c.p.colModel[g].width-=k):d=c.p.colModel[g].width;c.grid.headers[g].width=d;c.grid.headers[g].el.style.width=d+"px";q&&(c.grid.cols[g].style.width=d+"px");c.p.footerrow&&(c.grid.footers[g].style.width=d+"px")}c.p.tblwidth&&(b("table:first",c.grid.bDiv).css("width",c.p.tblwidth+"px"),b("table:first",c.grid.hDiv).css("width", +c.p.tblwidth+"px"),c.grid.hDiv.scrollLeft=c.grid.bDiv.scrollLeft,c.p.footerrow&&b("table:first",c.grid.sDiv).css("width",c.p.tblwidth+"px"))}}})},setGridHeight:function(e){return this.each(function(){if(this.grid){var f=b(this.grid.bDiv);f.css({height:e+(isNaN(e)?"":"px")});!0===this.p.frozenColumns&&b("#"+b.jgrid.jqID(this.p.id)+"_frozen").parent().height(f.height()-16);this.p.height=e;this.p.scroll&&this.grid.populateVisible()}})},setCaption:function(e){return this.each(function(){this.p.caption= +e;b("span.ui-jqgrid-title, span.ui-jqgrid-title-rtl",this.grid.cDiv).html(e);b(this.grid.cDiv).show()})},setLabel:function(e,f,c,d){return this.each(function(){var a=-1;if(this.grid&&void 0!==e&&(b(this.p.colModel).each(function(b){if(this.name===e)return a=b,!1}),0<=a)){var l=b("tr.ui-jqgrid-labels th:eq("+a+")",this.grid.hDiv);if(f){var g=b(".s-ico",l);b("[id^=jqgh_]",l).empty().html(f).append(g);this.p.colNames[a]=f}c&&("string"===typeof c?b(l).addClass(c):b(l).css(c));"object"===typeof d&&b(l).attr(d)}})}, +setCell:function(e,f,c,d,a,l){return this.each(function(){var g=-1,h,k;if(this.grid&&(isNaN(f)?b(this.p.colModel).each(function(a){if(this.name===f)return g=a,!1}):g=parseInt(f,10),0<=g&&(h=b(this).jqGrid("getGridRowById",e)))){var n=b("td:eq("+g+")",h);if(""!==c||!0===l)h=this.formatter(e,c,g,h,"edit"),k=this.p.colModel[g].title?{title:b.jgrid.stripHtml(h)}:{},this.p.treeGrid&&0c,e=String(c),f=b.decimalSeparator||".",g;if(a.fmatter.isNumber(b.decimalPlaces)){var h=b.decimalPlaces,e=Math.pow(10,h),e=String(Math.round(c*e)/e);g=e.lastIndexOf(".");if(0g?(e+=f,g=e.length-1):"."!==f&& +(e=e.replace(".",f));e.length-1-g'+c+"
"};a.fn.fmatter.checkbox=function(c,b){var d=a.extend({},b.checkbox),e;void 0!==b.colModel&&void 0!==b.colModel.formatoptions&&(d=a.extend({},d,b.colModel.formatoptions));e=!0===d.disabled?'disabled="disabled"':"";if(a.fmatter.isEmpty(c)||void 0===c)c=a.fn.fmatter.defaultFormat(c,d);c=String(c);c=(c+"").toLowerCase();return'c.search(/(false|f|0|no|n|off|undefined)/i)?" checked='checked' ":"")+' value="'+c+'" offval="no" '+e+"/>"};a.fn.fmatter.link=function(c, +b){var d={target:b.target},e="";void 0!==b.colModel&&void 0!==b.colModel.formatoptions&&(d=a.extend({},d,b.colModel.formatoptions));d.target&&(e="target="+d.target);return a.fmatter.isEmpty(c)?a.fn.fmatter.defaultFormat(c,b):"'+c+""};a.fn.fmatter.showlink=function(c,b){var d={baseLinkUrl:b.baseLinkUrl,showAction:b.showAction,addParam:b.addParam||"",target:b.target,idName:b.idName},e="";void 0!==b.colModel&&void 0!==b.colModel.formatoptions&&(d=a.extend({},d,b.colModel.formatoptions)); +d.target&&(e="target="+d.target);d=d.baseLinkUrl+d.showAction+"?"+d.idName+"="+b.rowId+d.addParam;return a.fmatter.isString(c)||a.fmatter.isNumber(c)?"'+c+"":a.fn.fmatter.defaultFormat(c,b)};a.fn.fmatter.integer=function(c,b){var d=a.extend({},b.integer);void 0!==b.colModel&&void 0!==b.colModel.formatoptions&&(d=a.extend({},d,b.colModel.formatoptions));return a.fmatter.isEmpty(c)?d.defaultValue:a.fmatter.util.NumberFormat(c,d)};a.fn.fmatter.number=function(c,b){var d=a.extend({}, +b.number);void 0!==b.colModel&&void 0!==b.colModel.formatoptions&&(d=a.extend({},d,b.colModel.formatoptions));return a.fmatter.isEmpty(c)?d.defaultValue:a.fmatter.util.NumberFormat(c,d)};a.fn.fmatter.currency=function(c,b){var d=a.extend({},b.currency);void 0!==b.colModel&&void 0!==b.colModel.formatoptions&&(d=a.extend({},d,b.colModel.formatoptions));return a.fmatter.isEmpty(c)?d.defaultValue:a.fmatter.util.NumberFormat(c,d)};a.fn.fmatter.date=function(c,b,d,e){d=a.extend({},b.date);void 0!==b.colModel&& +void 0!==b.colModel.formatoptions&&(d=a.extend({},d,b.colModel.formatoptions));return d.reformatAfterEdit||"edit"!==e?a.fmatter.isEmpty(c)?a.fn.fmatter.defaultFormat(c,b):a.jgrid.parseDate(d.srcformat,c,d.newformat,d):a.fn.fmatter.defaultFormat(c,b)};a.fn.fmatter.select=function(c,b){c=String(c);var d=!1,e=[],f,g;void 0!==b.colModel.formatoptions?(d=b.colModel.formatoptions.value,f=void 0===b.colModel.formatoptions.separator?":":b.colModel.formatoptions.separator,g=void 0===b.colModel.formatoptions.delimiter? +";":b.colModel.formatoptions.delimiter):void 0!==b.colModel.editoptions&&(d=b.colModel.editoptions.value,f=void 0===b.colModel.editoptions.separator?":":b.colModel.editoptions.separator,g=void 0===b.colModel.editoptions.delimiter?";":b.colModel.editoptions.delimiter);if(d){var h=!0===b.colModel.editoptions.multiple?!0:!1,l=[];h&&(l=c.split(","),l=a.map(l,function(b){return a.trim(b)}));if(a.fmatter.isString(d)){var k=d.split(g),m=0,n;for(n=0;n div",e):a(this).parent(),k={extraparam:{}},m=function(b){a.isFunction(k.afterRestore)&&k.afterRestore.call(f,b);l.find("div.ui-inline-edit,div.ui-inline-del").show();l.find("div.ui-inline-save,div.ui-inline-cancel").hide()};void 0!==h.formatoptions&&(k=a.extend(k,h.formatoptions));void 0!==g.editOptions&&(k.editOptions=g.editOptions);void 0!==g.delOptions&&(k.delOptions=g.delOptions);b.hasClass("jqgrid-new-row")&&(k.extraparam[g.prmNames.oper]= +g.prmNames.addoper);b={keys:k.keys,oneditfunc:k.onEdit,successfunc:k.onSuccess,url:k.url,extraparam:k.extraparam,aftersavefunc:function(b,c){a.isFunction(k.afterSave)&&k.afterSave.call(f,b,c);l.find("div.ui-inline-edit,div.ui-inline-del").show();l.find("div.ui-inline-save,div.ui-inline-cancel").hide()},errorfunc:k.onError,afterrestorefunc:m,restoreAfterError:k.restoreAfterError,mtype:k.mtype};switch(c){case "edit":e.jqGrid("editRow",d,b);l.find("div.ui-inline-edit,div.ui-inline-del").hide();l.find("div.ui-inline-save,div.ui-inline-cancel").show(); +e.triggerHandler("jqGridAfterGridComplete");break;case "save":e.jqGrid("saveRow",d,b)&&(l.find("div.ui-inline-edit,div.ui-inline-del").show(),l.find("div.ui-inline-save,div.ui-inline-cancel").hide(),e.triggerHandler("jqGridAfterGridComplete"));break;case "cancel":e.jqGrid("restoreRow",d,m);l.find("div.ui-inline-edit,div.ui-inline-del").show();l.find("div.ui-inline-save,div.ui-inline-cancel").hide();e.triggerHandler("jqGridAfterGridComplete");break;case "del":e.jqGrid("delGridRow",d,k.delOptions); +break;case "formedit":e.jqGrid("setSelection",d),e.jqGrid("editGridRow",d,k.editOptions)}};a.fn.fmatter.actions=function(c,b){var d={keys:!1,editbutton:!0,delbutton:!0,editformbutton:!1},e=b.rowId,f="";void 0!==b.colModel.formatoptions&&(d=a.extend(d,b.colModel.formatoptions));if(void 0===e||a.fmatter.isEmpty(e))return"";d.editformbutton?f+="
":d.editbutton&&(f+="
");d.delbutton&&(f+="
");f+="";f+="";return"
"+f+"
"};a.unformat=function(c, +b,d,e){var f,g=b.colModel.formatter,h=b.colModel.formatoptions||{},l=/([\.\*\_\'\(\)\{\}\+\?\\])/g,k=b.colModel.unformat||a.fn.fmatter[g]&&a.fn.fmatter[g].unformat;if(void 0!==k&&a.isFunction(k))f=k.call(this,a(c).text(),b,c);else if(void 0!==g&&a.fmatter.isString(g))switch(f=a.jgrid.formatter||{},g){case "integer":h=a.extend({},f.integer,h);b=h.thousandsSeparator.replace(l,"\\$1");b=RegExp(b,"g");f=a(c).text().replace(b,"");break;case "number":h=a.extend({},f.number,h);b=h.thousandsSeparator.replace(l, +"\\$1");b=RegExp(b,"g");f=a(c).text().replace(b,"").replace(h.decimalSeparator,".");break;case "currency":h=a.extend({},f.currency,h);b=h.thousandsSeparator.replace(l,"\\$1");b=RegExp(b,"g");f=a(c).text();h.prefix&&h.prefix.length&&(f=f.substr(h.prefix.length));h.suffix&&h.suffix.length&&(f=f.substr(0,f.length-h.suffix.length));f=f.replace(b,"").replace(h.decimalSeparator,".");break;case "checkbox":h=b.colModel.editoptions?b.colModel.editoptions.value.split(":"):["Yes","No"];f=a("input",c).is(":checked")? +h[0]:h[1];break;case "select":f=a.unformat.select(c,b,d,e);break;case "actions":return"";default:f=a(c).text()}return void 0!==f?f:!0===e?a(c).text():a.jgrid.htmlDecode(a(c).html())};a.unformat.select=function(c,b,d,e){d=[];c=a(c).text();if(!0===e)return c;e=a.extend({},void 0!==b.colModel.formatoptions?b.colModel.formatoptions:b.colModel.editoptions);b=void 0===e.separator?":":e.separator;var f=void 0===e.delimiter?";":e.delimiter;if(e.value){var g=e.value;e=!0===e.multiple?!0:!1;var h=[];e&&(h= +c.split(","),h=a.map(h,function(b){return a.trim(b)}));if(a.fmatter.isString(g)){var l=g.split(f),k=0,m;for(m=0;m",ge:">=",bw:"^",bn:"!^","in":"=",ni:"!=",ew:"|",en:"!@",cn:"~",nc:"!~",nu:"#",nn:"!#"}},a.jgrid.search,b||{});return this.each(function(){var c=this;if(!this.ftoolbar){var d=function(){var d={},f=0,g,m,e={},q;a.each(c.p.colModel,function(){var l=a("#gs_"+a.jgrid.jqID(this.name),!0===this.frozen&&!0===c.p.frozenColumns?c.grid.fhDiv:c.grid.hDiv);m=this.index|| +this.name;q=b.searchOperators?l.parent().prev().children("a").attr("soper")||b.defaultSearch:this.searchoptions&&this.searchoptions.sopt?this.searchoptions.sopt[0]:"select"===this.stype?"eq":b.defaultSearch;if((g="custom"===this.stype&&a.isFunction(this.searchoptions.custom_value)&&0';g=a(e).attr("soper");var k,h=[],q,p=0,l=a(e).attr("colname");for(k=c.p.colModel.length;p
'+b.operands[b.odata[q].oper]+""+b.odata[q].text+"
");f+="";a("body").append(f);a("#sopt_menu").addClass("ui-menu ui-widget ui-widget-content ui-corner-all");a("#sopt_menu > li > a").hover(function(){a(this).addClass("ui-state-hover")}, +function(){a(this).removeClass("ui-state-hover")}).click(function(f){f=a(this).attr("value");var g=a(this).attr("oper");a(c).triggerHandler("jqGridToolbarSelectOper",[f,g,e]);a("#sopt_menu").hide();a(e).text(g).attr("soper",f);!0===b.autosearch&&(g=a(e).parent().next().children()[0],(a(g).val()||"nu"===f||"nn"===f)&&d())})},k=a(""),e;a.each(c.p.colModel,function(h){var f=this,g,m;m="";var x="=",q,p=a(""),l=a("
"),n=a("
");!0===this.hidden&&a(p).css("display","none");this.search=!1===this.search?!1:!0;void 0===this.stype&&(this.stype="text");g=a.extend({},this.searchoptions||{});if(this.search){if(b.searchOperators){m=g.sopt?g.sopt[0]: +"select"===f.stype?"eq":b.defaultSearch;for(q=0;q"+x+""}a("td:eq(0)",n).attr("colindex",h).append(m);void 0===g.clearSearch&&(g.clearSearch=!0);g.clearSearch?(m=b.resetTitle||"Clear Search Value",a("td:eq(2)",n).append(""+ +b.resetIcon+"")):a("td:eq(2)",n).hide();switch(this.stype){case "select":if(m=this.surl||g.dataUrl)a(l).append(n),a.ajax(a.extend({url:m,dataType:"html",success:function(e){void 0!==g.buildSelect?(e=g.buildSelect(e))&&a("td:eq(1)",n).append(e):a("td:eq(1)",n).append(e);void 0!==g.defaultValue&&a("select",l).val(g.defaultValue);a("select",l).attr({name:f.index||f.name,id:"gs_"+f.name});g.attr&&a("select",l).attr(g.attr);a("select",l).css({width:"100%"});a.jgrid.bindEv.call(c,a("select",l)[0],g); +!0===b.autosearch&&a("select",l).change(function(){d();return!1});e=null}},a.jgrid.ajaxOptions,c.p.ajaxSelectOptions||{}));else{var r,w,u;f.searchoptions?(r=void 0===f.searchoptions.value?"":f.searchoptions.value,w=void 0===f.searchoptions.separator?":":f.searchoptions.separator,u=void 0===f.searchoptions.delimiter?";":f.searchoptions.delimiter):f.editoptions&&(r=void 0===f.editoptions.value?"":f.editoptions.value,w=void 0===f.editoptions.separator?":":f.editoptions.separator,u=void 0===f.editoptions.delimiter? +";":f.editoptions.delimiter);if(r){var t=document.createElement("select");t.style.width="100%";a(t).attr({name:f.index||f.name,id:"gs_"+f.name});var v;if("string"===typeof r)for(m=r.split(u),v=0;v");a(l).append(n);g.attr&&a("input",l).attr(g.attr);a.jgrid.bindEv.call(c,a("input",l)[0],g);!0===b.autosearch&&(b.searchOnEnter?a("input",l).keypress(function(a){return 13=== +(a.charCode||a.keyCode||0)?(d(),!1):this}):a("input",l).keydown(function(a){switch(a.which){case 13:return!1;case 9:case 16:case 37:case 38:case 39:case 40:case 27:break;default:e&&clearTimeout(e),e=setTimeout(function(){d()},500)}}));break;case "custom":a("td:eq(1)",n).append("");a(l).append(n);try{if(a.isFunction(g.custom_element))if(t=g.custom_element.call(c,void 0!==g.defaultValue?g.defaultValue:"",g))t=a(t).addClass("customelement"), +a(l).find(">span").append(t);else throw"e2";else throw"e1";}catch(y){"e1"===y&&a.jgrid.info_dialog(a.jgrid.errors.errcap,"function 'custom_element' "+a.jgrid.edit.msg.nodefined,a.jgrid.edit.bClose),"e2"===y?a.jgrid.info_dialog(a.jgrid.errors.errcap,"function 'custom_element' "+a.jgrid.edit.msg.novalue,a.jgrid.edit.bClose):a.jgrid.info_dialog(a.jgrid.errors.errcap,"string"===typeof y?y:y.message,a.jgrid.edit.bClose)}}}a(p).append(l);a(k).append(p);b.searchOperators||a("td:eq(0)",n).hide()});a("table thead", +c.grid.hDiv).append(k);b.searchOperators&&(a(".soptclass",k).click(function(b){var c=a(this).offset();h(this,c.left,c.top);b.stopPropagation()}),a("body").on("click",function(b){"soptclass"!==b.target.className&&a("#sopt_menu").hide()}));a(".clearsearchclass",k).click(function(e){e=a(this).parents("tr:first");var f=parseInt(a("td.ui-search-oper",e).attr("colindex"),10),g=a.extend({},c.p.colModel[f].searchoptions||{}),g=g.defaultValue?g.defaultValue:"";"select"===c.p.colModel[f].stype?g?a("td.ui-search-input select", +e).val(g):a("td.ui-search-input select",e)[0].selectedIndex=0:a("td.ui-search-input input",e).val(g);!0===b.autosearch&&d()});this.ftoolbar=!0;this.triggerToolbar=d;this.clearToolbar=function(d){var f={},g=0,e;d="boolean"!==typeof d?!0:d;a.each(c.p.colModel,function(){var b,d=a("#gs_"+a.jgrid.jqID(this.name),!0===this.frozen&&!0===c.p.frozenColumns?c.grid.fhDiv:c.grid.hDiv);this.searchoptions&&void 0!==this.searchoptions.defaultValue&&(b=this.searchoptions.defaultValue);e=this.index||this.name;switch(this.stype){case "select":d.find("option").each(function(c){0=== +c&&(this.selected=!0);if(a(this).val()===b)return this.selected=!0,!1});if(void 0!==b)f[e]=b,g++;else try{delete c.p.postData[e]}catch(h){}break;case "text":d.val(b||"");if(void 0!==b)f[e]=b,g++;else try{delete c.p.postData[e]}catch(k){}break;case "custom":a.isFunction(this.searchoptions.custom_value)&&0",{role:"rowheader"}).addClass("ui-jqgrid-labels"); +k=d.headers;d=0;for(h=k.length;d",{role:"row","aria-hidden":"true"}).addClass("jqg-first-row-header").css("height","auto"):n.empty();var r,w=function(a,b){var c=b.length,d;for(d=0;d",{role:"rowheader"}).addClass("ui-jqgrid-labels jqg-third-row-header");for(c=0;c",{role:"gridcell"}).css(e).addClass("ui-first-th-"+this.p.direction).appendTo(n),s.style.width="",e=w(d.name,b.groupHeaders),0<=e){e=b.groupHeaders[e];h=e.numberOfColumns;g=e.titleText;for(e=d=0;e").attr({role:"columnheader"}).addClass("ui-state-default ui-th-column-header ui-th-"+ +this.p.direction).css({height:"22px","border-top":"0 none"}).html(g);0",{role:"columnheader"}).addClass("ui-state-default ui-th-column-header ui-th-"+this.p.direction).css({display:d.hidden?"none":"","border-top":"0 none"}).insertBefore(f),k.append(s)):(k.append(s),h--);m=a(this).children("thead");m.prepend(n);k.insertAfter(l); +p.append(m);b.useColSpanStyle&&(p.find("span.ui-jqgrid-resize").each(function(){var b=a(this).parent();b.is(":visible")&&(this.style.cssText="height: "+b.height()+"px !important; cursor: col-resize;")}),p.find("div.ui-jqgrid-sortable").each(function(){var b=a(this),c=b.parent();c.is(":visible")&&c.is(":has(span.ui-jqgrid-resize)")&&b.css("top",(c.height()-b.outerHeight())/2+"px")}));r=m.find("tr.jqg-first-row-header");a(this).bind("jqGridResizeStop.setGroupHeaders",function(a,b,c){r.find("th").eq(c).width(b)})})}, +setFrozenColumns:function(){return this.each(function(){if(this.grid){var b=this,c=b.p.colModel,d=0,h=c.length,k=-1,e=!1;if(!0!==b.p.subGrid&&!0!==b.p.treeGrid&&!0!==b.p.cellEdit&&!b.p.sortable&&!b.p.scroll){b.p.rownumbers&&d++;for(b.p.multiselect&&d++;d
');b.grid.fbDiv=a('
');a("#gview_"+a.jgrid.jqID(b.p.id)).append(b.grid.fhDiv);c=a(".ui-jqgrid-htable","#gview_"+a.jgrid.jqID(b.p.id)).clone(!0);if(b.p.groupHeader){a("tr.jqg-first-row-header, tr.jqg-third-row-header", +c).each(function(){a("th:gt("+k+")",this).remove()});var s=-1,f=-1,g,m;a("tr.jqg-second-row-header th",c).each(function(){g=parseInt(a(this).attr("colspan"),10);if(m=parseInt(a(this).attr("rowspan"),10))s++,f++;g&&(s+=g,f++);if(s===k)return!1});s!==k&&(f=k);a("tr.jqg-second-row-header",c).each(function(){a("th:gt("+f+")",this).remove()})}else a("tr",c).each(function(){a("th:gt("+k+")",this).remove()});a(c).width(1);a(b.grid.fhDiv).append(c).mousemove(function(a){if(b.grid.resizing)return b.grid.dragMove(a), +!1});a(b).bind("jqGridResizeStop.setFrozenColumns",function(c,d,e){c=a(".ui-jqgrid-htable",b.grid.fhDiv);a("th:eq("+e+")",c).width(d);c=a(".ui-jqgrid-btable",b.grid.fbDiv);a("tr:first td:eq("+e+")",c).width(d)});a(b).bind("jqGridSortCol.setFrozenColumns",function(c,d,e){c=a("tr.ui-jqgrid-labels:last th:eq("+b.p.lastsort+")",b.grid.fhDiv);d=a("tr.ui-jqgrid-labels:last th:eq("+e+")",b.grid.fhDiv);a("span.ui-grid-ico-sort",c).addClass("ui-state-disabled");a(c).attr("aria-selected","false");a("span.ui-icon-"+ +b.p.sortorder,d).removeClass("ui-state-disabled");a(d).attr("aria-selected","true");b.p.viewsortcols[0]||b.p.lastsort===e||(a("span.s-ico",c).hide(),a("span.s-ico",d).show())});a("#gview_"+a.jgrid.jqID(b.p.id)).append(b.grid.fbDiv);a(b.grid.bDiv).scroll(function(){a(b.grid.fbDiv).scrollTop(a(this).scrollTop())});!0===b.p.hoverrows&&a("#"+a.jgrid.jqID(b.p.id)).unbind("mouseover").unbind("mouseout");a(b).bind("jqGridAfterGridComplete.setFrozenColumns",function(){a("#"+a.jgrid.jqID(b.p.id)+"_frozen").remove(); +a(b.grid.fbDiv).height(a(b.grid.bDiv).height()-16);var c=a("#"+a.jgrid.jqID(b.p.id)).clone(!0);a("tr[role=row]",c).each(function(){a("td[role=gridcell]:gt("+k+")",this).remove()});a(c).width(1).attr("id",b.p.id+"_frozen");a(b.grid.fbDiv).append(c);!0===b.p.hoverrows&&(a("tr.jqgrow",c).hover(function(){a(this).addClass("ui-state-hover");a("#"+a.jgrid.jqID(this.id),"#"+a.jgrid.jqID(b.p.id)).addClass("ui-state-hover")},function(){a(this).removeClass("ui-state-hover");a("#"+a.jgrid.jqID(this.id),"#"+ +a.jgrid.jqID(b.p.id)).removeClass("ui-state-hover")}),a("tr.jqgrow","#"+a.jgrid.jqID(b.p.id)).hover(function(){a(this).addClass("ui-state-hover");a("#"+a.jgrid.jqID(this.id),"#"+a.jgrid.jqID(b.p.id)+"_frozen").addClass("ui-state-hover")},function(){a(this).removeClass("ui-state-hover");a("#"+a.jgrid.jqID(this.id),"#"+a.jgrid.jqID(b.p.id)+"_frozen").removeClass("ui-state-hover")}));c=null});b.grid.hDiv.loading||a(b).triggerHandler("jqGridAfterGridComplete");b.p.frozenColumns=!0}}}})},destroyFrozenColumns:function(){return this.each(function(){if(this.grid&& +!0===this.p.frozenColumns){a(this.grid.fhDiv).remove();a(this.grid.fbDiv).remove();this.grid.fhDiv=null;this.grid.fbDiv=null;a(this).unbind(".setFrozenColumns");if(!0===this.p.hoverrows){var b;a("#"+a.jgrid.jqID(this.p.id)).bind("mouseover",function(c){b=a(c.target).closest("tr.jqgrow");"ui-subgrid"!==a(b).attr("class")&&a(b).addClass("ui-state-hover")}).bind("mouseout",function(c){b=a(c.target).closest("tr.jqgrow");a(b).removeClass("ui-state-hover")})}this.p.frozenColumns=!1}})}})})(jQuery); +(function(a){a.extend(a.jgrid,{showModal:function(a){a.w.show()},closeModal:function(a){a.w.hide().attr("aria-hidden","true");a.o&&a.o.remove()},hideModal:function(d,b){b=a.extend({jqm:!0,gb:""},b||{});if(b.onClose){var c=b.gb&&"string"===typeof b.gb&&"#gbox_"===b.gb.substr(0,6)?b.onClose.call(a("#"+b.gb.substr(6))[0],d):b.onClose(d);if("boolean"===typeof c&&!c)return}if(a.fn.jqm&&!0===b.jqm)a(d).attr("aria-hidden","true").jqmHide();else{if(""!==b.gb)try{a(".jqgrid-overlay:first",b.gb).hide()}catch(g){}a(d).hide().attr("aria-hidden", +"true")}},findPos:function(a){var b=0,c=0;if(a.offsetParent){do b+=a.offsetLeft,c+=a.offsetTop;while(a=a.offsetParent)}return[b,c]},createModal:function(d,b,c,g,e,h,f){c=a.extend(!0,{},a.jgrid.jqModal||{},c);var k=document.createElement("div"),l,m=this;f=a.extend({},f||{});l="rtl"===a(c.gbox).attr("dir")?!0:!1;k.className="ui-widget ui-widget-content ui-corner-all ui-jqdialog";k.id=d.themodal;var n=document.createElement("div");n.className="ui-jqdialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix"; +n.id=d.modalhead;a(n).append(""+c.caption+"");var q=a("").hover(function(){q.addClass("ui-state-hover")},function(){q.removeClass("ui-state-hover")}).append("");a(n).append(q);l?(k.dir="rtl",a(".ui-jqdialog-title",n).css("float","right"),a(".ui-jqdialog-titlebar-close",n).css("left","0.3em")):(k.dir="ltr",a(".ui-jqdialog-title",n).css("float","left"),a(".ui-jqdialog-titlebar-close", +n).css("right","0.3em"));var p=document.createElement("div");a(p).addClass("ui-jqdialog-content ui-widget-content").attr("id",d.modalcontent);a(p).append(b);k.appendChild(p);a(k).prepend(n);!0===h?a("body").append(k):"string"===typeof h?a(h).append(k):a(k).insertBefore(g);a(k).css(f);void 0===c.jqModal&&(c.jqModal=!0);b={};if(a.fn.jqm&&!0===c.jqModal)0===c.left&&0===c.top&&c.overlay&&(f=[],f=a.jgrid.findPos(e),c.left=f[0]+4,c.top=f[1]+4),b.top=c.top+"px",b.left=c.left;else if(0!==c.left||0!==c.top)b.left= +c.left,b.top=c.top+"px";a("a.ui-jqdialog-titlebar-close",n).click(function(){var b=a("#"+a.jgrid.jqID(d.themodal)).data("onClose")||c.onClose,e=a("#"+a.jgrid.jqID(d.themodal)).data("gbox")||c.gbox;m.hideModal("#"+a.jgrid.jqID(d.themodal),{gb:e,jqm:c.jqModal,onClose:b});return!1});0!==c.width&&c.width||(c.width=300);0!==c.height&&c.height||(c.height=200);c.zIndex||(g=a(g).parents("*[role=dialog]").filter(":first").css("z-index"),c.zIndex=g?parseInt(g,10)+2:950);g=0;l&&b.left&&!h&&(g=a(c.gbox).width()- +(isNaN(c.width)?0:parseInt(c.width,10))-8,b.left=parseInt(b.left,10)+parseInt(g,10));b.left&&(b.left+="px");a(k).css(a.extend({width:isNaN(c.width)?"auto":c.width+"px",height:isNaN(c.height)?"auto":c.height+"px",zIndex:c.zIndex,overflow:"hidden"},b)).attr({tabIndex:"-1",role:"dialog","aria-labelledby":d.modalhead,"aria-hidden":"true"});void 0===c.drag&&(c.drag=!0);void 0===c.resize&&(c.resize=!0);if(c.drag)if(a(n).css("cursor","move"),a.fn.jqDrag)a(k).jqDrag(n);else try{a(k).draggable({handle:a("#"+ +a.jgrid.jqID(n.id))})}catch(r){}if(c.resize)if(a.fn.jqResize)a(k).append("
"),a("#"+a.jgrid.jqID(d.themodal)).jqResize(".jqResize",d.scrollelm?"#"+a.jgrid.jqID(d.scrollelm):!1);else try{a(k).resizable({handles:"se, sw",alsoResize:d.scrollelm?"#"+a.jgrid.jqID(d.scrollelm):!1})}catch(s){}!0===c.closeOnEscape&&a(k).keydown(function(b){27==b.which&&(b=a("#"+a.jgrid.jqID(d.themodal)).data("onClose")||c.onClose, +m.hideModal("#"+a.jgrid.jqID(d.themodal),{gb:c.gbox,jqm:c.jqModal,onClose:b}))})},viewModal:function(d,b){b=a.extend({toTop:!0,overlay:10,modal:!1,overlayClass:"ui-widget-overlay",onShow:a.jgrid.showModal,onHide:a.jgrid.closeModal,gbox:"",jqm:!0,jqM:!0},b||{});if(a.fn.jqm&&!0===b.jqm)b.jqM?a(d).attr("aria-hidden","false").jqm(b).jqmShow():a(d).attr("aria-hidden","false").jqmShow();else{""!==b.gbox&&(a(".jqgrid-overlay:first",b.gbox).show(),a(d).data("gbox",b.gbox));a(d).show().attr("aria-hidden", +"false");try{a(":input:visible",d)[0].focus()}catch(c){}}},info_dialog:function(d,b,c,g){var e={width:290,height:"auto",dataheight:"auto",drag:!0,resize:!1,left:250,top:170,zIndex:1E3,jqModal:!0,modal:!1,closeOnEscape:!0,align:"center",buttonalign:"center",buttons:[]};a.extend(!0,e,a.jgrid.jqModal||{},{caption:""+d+""},g||{});var h=e.jqModal,f=this;a.fn.jqm&&!h&&(h=!1);d="";if(0"+e.buttons[g].text+"";g=isNaN(e.dataheight)?e.dataheight:e.dataheight+"px";b="
"+("
"+b+"
");b+=c?"
"+ +c+""+d+"
":""!==d?"
"+d+"
":"";b+="
";try{"false"===a("#info_dialog").attr("aria-hidden")&&a.jgrid.hideModal("#info_dialog",{jqm:h}),a("#info_dialog").remove()}catch(k){}a.jgrid.createModal({themodal:"info_dialog",modalhead:"info_head",modalcontent:"info_content",scrollelm:"infocnt"},b,e,"","",!0);d&&a.each(e.buttons, +function(b){a("#"+a.jgrid.jqID(this.id),"#info_id").bind("click",function(){e.buttons[b].onClick.call(a("#info_dialog"));return!1})});a("#closedialog","#info_id").click(function(){f.hideModal("#info_dialog",{jqm:h,onClose:a("#info_dialog").data("onClose")||e.onClose,gb:a("#info_dialog").data("gbox")||e.gbox});return!1});a(".fm-button","#info_dialog").hover(function(){a(this).addClass("ui-state-hover")},function(){a(this).removeClass("ui-state-hover")});a.isFunction(e.beforeOpen)&&e.beforeOpen();a.jgrid.viewModal("#info_dialog", +{onHide:function(a){a.w.hide().remove();a.o&&a.o.remove()},modal:e.modal,jqm:h});a.isFunction(e.afterOpen)&&e.afterOpen();try{a("#info_dialog").focus()}catch(l){}},bindEv:function(d,b){a.isFunction(b.dataInit)&&b.dataInit.call(this,d,b);b.dataEvents&&a.each(b.dataEvents,function(){void 0!==this.data?a(d).bind(this.type,this.data,this.fn):a(d).bind(this.type,this.fn)})},createEl:function(d,b,c,g,e){function h(b,d,c){var e="dataInit dataEvents dataUrl buildSelect sopt searchhidden defaultValue attr custom_element custom_value".split(" "); +void 0!==c&&a.isArray(c)&&a.merge(e,c);a.each(d,function(d,c){-1===a.inArray(d,e)&&a(b).attr(d,c)});d.hasOwnProperty("id")||a(b).attr("id",a.jgrid.randId())}var f="",k=this;switch(d){case "textarea":f=document.createElement("textarea");g?b.cols||a(f).css({width:"98%"}):b.cols||(b.cols=20);b.rows||(b.rows=2);if(" "===c||" "===c||1===c.length&&160===c.charCodeAt(0))c="";f.value=c;h(f,b);a(f).attr({role:"textbox",multiline:"true"});break;case "checkbox":f=document.createElement("input");f.type= +"checkbox";b.value?(d=b.value.split(":"),c===d[0]&&(f.checked=!0,f.defaultChecked=!0),f.value=d[0],a(f).attr("offval",d[1])):(d=(c+"").toLowerCase(),0>d.search(/(false|f|0|no|n|off|undefined)/i)&&""!==d?(f.checked=!0,f.defaultChecked=!0,f.value=c):f.value="on",a(f).attr("offval","off"));h(f,b,["value"]);a(f).attr("role","checkbox");break;case "select":f=document.createElement("select");f.setAttribute("role","select");g=[];!0===b.multiple?(d=!0,f.multiple="multiple",a(f).attr("aria-multiselectable", +"true")):d=!1;if(void 0!==b.dataUrl){d=b.name?String(b.id).substring(0,String(b.id).length-String(b.name).length-1):String(b.id);var l=b.postData||e.postData;k.p&&k.p.idPrefix&&(d=a.jgrid.stripPref(k.p.idPrefix,d));a.ajax(a.extend({url:a.isFunction(b.dataUrl)?b.dataUrl.call(k,d,c,String(b.name)):b.dataUrl,type:"GET",dataType:"html",data:a.isFunction(l)?l.call(k,d,c,String(b.name)):l,context:{elem:f,options:b,vl:c},success:function(b){var d=[],c=this.elem,e=this.vl,f=a.extend({},this.options),g=!0=== +f.multiple;b=a.isFunction(f.buildSelect)?f.buildSelect.call(k,b):b;"string"===typeof b&&(b=a(a.trim(b)).html());b&&(a(c).append(b),h(c,f,l?["postData"]:void 0),void 0===f.size&&(f.size=g?3:1),g?(d=e.split(","),d=a.map(d,function(b){return a.trim(b)})):d[0]=a.trim(e),setTimeout(function(){a("option",c).each(function(b){0===b&&c.multiple&&(this.selected=!1);a(this).attr("role","option");if(-1l.length||1>c[a[f]]||12l.length)&&!(h=1>c[a[g]])&&!(h=31(0!==e%4||0===e%100&&0!==e%400?28:29);h=h||c[a[g]]>k[c[a[f]]]}return h?!1:!0},isEmpty:function(a){return a.match(/^\s+$/)||""===a?!0:!1},checkTime:function(d){var b=/^(\d{1,2}):(\d{2})([apAP][Mm])?$/;if(!a.jgrid.isEmpty(d))if(d=d.match(b)){if(d[3]){if(1>d[1]||12parseFloat(e.maxValue))return[!1,h+": "+a.jgrid.edit.msg.maxValue+" "+e.maxValue,""];if(!(!0!==e.email||!1===c&&a.jgrid.isEmpty(d)||(g=/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, +g.test(d))))return[!1,h+": "+a.jgrid.edit.msg.email,""];if(!(!0!==e.integer||!1===c&&a.jgrid.isEmpty(d)||!isNaN(d)&&0===d%1&&-1===d.indexOf(".")))return[!1,h+": "+a.jgrid.edit.msg.integer,""];if(!(!0!==e.date||!1===c&&a.jgrid.isEmpty(d)||(f[b].formatoptions&&f[b].formatoptions.newformat?(f=f[b].formatoptions.newformat,a.jgrid.formatter.date.masks.hasOwnProperty(f)&&(f=a.jgrid.formatter.date.masks[f])):f=f[b].datefmt||"Y-m-d",a.jgrid.checkDate(f,d))))return[!1,h+": "+a.jgrid.edit.msg.date+" - "+f, +""];if(!0===e.time&&!(!1===c&&a.jgrid.isEmpty(d)||a.jgrid.checkTime(d)))return[!1,h+": "+a.jgrid.edit.msg.date+" - hh:mm (am/pm)",""];if(!(!0!==e.url||!1===c&&a.jgrid.isEmpty(d)||(g=/^(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i,g.test(d))))return[!1,h+": "+a.jgrid.edit.msg.url,""];if(!0===e.custom&&(!1!==c||!a.jgrid.isEmpty(d)))return a.isFunction(e.custom_func)?(d=e.custom_func.call(this,d,h,b),a.isArray(d)?d:[!1,a.jgrid.edit.msg.customarray, +""]):[!1,a.jgrid.edit.msg.customfcheck,""]}return[!0,"",""]}})})(jQuery); +(function(a){var b={};a.jgrid.extend({searchGrid:function(b){b=a.extend(!0,{recreateFilter:!1,drag:!0,sField:"searchField",sValue:"searchString",sOper:"searchOper",sFilter:"filters",loadDefaults:!0,beforeShowSearch:null,afterShowSearch:null,onInitializeSearch:null,afterRedraw:null,afterChange:null,closeAfterSearch:!1,closeAfterReset:!1,closeOnEscape:!1,searchOnEnter:!1,multipleSearch:!1,multipleGroup:!1,top:0,left:0,jqModal:!0,modal:!1,resize:!0,width:450,height:"auto",dataheight:"auto",showQuery:!1, +errorcheck:!0,sopt:null,stringResult:void 0,onClose:null,onSearch:null,onReset:null,toTop:!0,overlay:30,columns:[],tmplNames:null,tmplFilters:null,tmplLabel:" Template: ",showOnLoad:!1,layer:null,operands:{eq:"=",ne:"<>",lt:"<",le:"<=",gt:">",ge:">=",bw:"LIKE",bn:"NOT LIKE","in":"IN",ni:"NOT IN",ew:"LIKE",en:"NOT LIKE",cn:"LIKE",nc:"NOT LIKE",nu:"IS NULL",nn:"ISNOT NULL"}},a.jgrid.search,b||{});return this.each(function(){function c(c){w=a(e).triggerHandler("jqGridFilterBeforeShow",[c]);void 0=== +w&&(w=!0);w&&a.isFunction(b.beforeShowSearch)&&(w=b.beforeShowSearch.call(e,c));w&&(a.jgrid.viewModal("#"+a.jgrid.jqID(s.themodal),{gbox:"#gbox_"+a.jgrid.jqID(h),jqm:b.jqModal,modal:b.modal,overlay:b.overlay,toTop:b.toTop}),a(e).triggerHandler("jqGridFilterAfterShow",[c]),a.isFunction(b.afterShowSearch)&&b.afterShowSearch.call(e,c))}var e=this;if(e.grid){var h="fbox_"+e.p.id,w=!0,t=!0,s={themodal:"searchmod"+h,modalhead:"searchhd"+h,modalcontent:"searchcnt"+h,scrollelm:h},r=e.p.postData[b.sFilter]; +"string"===typeof r&&(r=a.jgrid.parse(r));!0===b.recreateFilter&&a("#"+a.jgrid.jqID(s.themodal)).remove();if(void 0!==a("#"+a.jgrid.jqID(s.themodal))[0])c(a("#fbox_"+a.jgrid.jqID(+e.p.id)));else{var f=a("
").insertBefore("#gview_"+a.jgrid.jqID(e.p.id)),k="left",u="";"rtl"===e.p.direction&&(k="right",u=" style='text-align:left'",f.attr("dir","rtl"));var x=a.extend([],e.p.colModel),d=""+ +b.Find+"",v=""+b.Reset+"",g="",m="",p,q=!1,y=-1;b.showQuery&&(g="Query");b.columns.length?(x=b.columns,y=0,p=x[0].index||x[0].name):a.each(x,function(a,b){b.label||(b.label=e.p.colNames[a]);if(!q){var c= +void 0===b.search?!0:b.search,d=!0===b.hidden;if(b.searchoptions&&!0===b.searchoptions.searchhidden&&c||c&&!d)q=!0,p=b.index||b.name,y=a}});if(!r&&p||!1===b.multipleSearch){var D="eq";0<=y&&x[y].searchoptions&&x[y].searchoptions.sopt?D=x[y].searchoptions.sopt[0]:b.sopt&&b.sopt.length&&(D=b.sopt[0]);r={groupOp:"AND",rules:[{field:p,op:D,data:""}]}}q=!1;b.tmplNames&&b.tmplNames.length&&(q=!0,m=b.tmplLabel,m+="");k="

"+v+m+""+g+d+"
";h=a.jgrid.jqID(h);a("#"+h).jqFilter({columns:x,filter:b.loadDefaults?r:null,showQuery:b.showQuery,errorcheck:b.errorcheck,sopt:b.sopt, +groupButton:b.multipleGroup,ruleButtons:b.multipleSearch,afterRedraw:b.afterRedraw,ops:b.odata,operands:b.operands,ajaxSelectOptions:e.p.ajaxSelectOptions,groupOps:b.groupOps,onChange:function(){this.p.showQuery&&a(".query",this).html(this.toUserFriendlyString());a.isFunction(b.afterChange)&&b.afterChange.call(e,a("#"+h),b)},direction:e.p.direction,id:e.p.id});f.append(k);q&&b.tmplFilters&&b.tmplFilters.length&&a(".ui-template",f).bind("change",function(){var c=a(this).val();"default"===c?a("#"+h).jqFilter("addFilter", +r):a("#"+h).jqFilter("addFilter",b.tmplFilters[parseInt(c,10)]);return!1});!0===b.multipleGroup&&(b.multipleSearch=!0);a(e).triggerHandler("jqGridFilterInitialize",[a("#"+h)]);a.isFunction(b.onInitializeSearch)&&b.onInitializeSearch.call(e,a("#"+h));b.gbox="#gbox_"+h;b.layer?a.jgrid.createModal(s,f,b,"#gview_"+a.jgrid.jqID(e.p.id),a("#gbox_"+a.jgrid.jqID(e.p.id))[0],"#"+a.jgrid.jqID(b.layer),{position:"relative"}):a.jgrid.createModal(s,f,b,"#gview_"+a.jgrid.jqID(e.p.id),a("#gbox_"+a.jgrid.jqID(e.p.id))[0]); +(b.searchOnEnter||b.closeOnEscape)&&a("#"+a.jgrid.jqID(s.themodal)).keydown(function(c){var d=a(c.target);if(b.searchOnEnter&&13===c.which&&!(d.hasClass("add-group")||d.hasClass("add-rule")||d.hasClass("delete-group")||d.hasClass("delete-rule")||d.hasClass("fm-button")&&d.is("[id$=_query]")))return a("#"+h+"_search").click(),!1;if(b.closeOnEscape&&27===c.which)return a("#"+a.jgrid.jqID(s.modalhead)).find(".ui-jqdialog-titlebar-close").click(),!1});g&&a("#"+h+"_query").bind("click",function(){a(".queryresult", +f).toggle();return!1});void 0===b.stringResult&&(b.stringResult=b.multipleSearch);a("#"+h+"_search").bind("click",function(){var c=a("#"+h),d={},n,g;c.find(".input-elm:focus").change();g=c.jqFilter("filterData");if(b.errorcheck&&(c[0].hideError(),b.showQuery||c.jqFilter("toSQLString"),c[0].p.error))return c[0].showError(),!1;if(b.stringResult){try{n=xmlJsonClass.toJson(g,"","",!1)}catch(f){try{n=JSON.stringify(g)}catch(k){}}"string"===typeof n&&(d[b.sFilter]=n,a.each([b.sField,b.sValue,b.sOper],function(){d[this]= +""}))}else b.multipleSearch?(d[b.sFilter]=g,a.each([b.sField,b.sValue,b.sOper],function(){d[this]=""})):(d[b.sField]=g.rules[0].field,d[b.sValue]=g.rules[0].data,d[b.sOper]=g.rules[0].op,d[b.sFilter]="");e.p.search=!0;a.extend(e.p.postData,d);t=a(e).triggerHandler("jqGridFilterSearch");void 0===t&&(t=!0);t&&a.isFunction(b.onSearch)&&(t=b.onSearch.call(e,e.p.filters));!1!==t&&a(e).trigger("reloadGrid",[{page:1}]);b.closeAfterSearch&&a.jgrid.hideModal("#"+a.jgrid.jqID(s.themodal),{gb:"#gbox_"+a.jgrid.jqID(e.p.id), +jqm:b.jqModal,onClose:b.onClose});return!1});a("#"+h+"_reset").bind("click",function(){var c={},d=a("#"+h);e.p.search=!1;e.p.resetsearch=!0;!1===b.multipleSearch?c[b.sField]=c[b.sValue]=c[b.sOper]="":c[b.sFilter]="";d[0].resetFilter();q&&a(".ui-template",f).val("default");a.extend(e.p.postData,c);t=a(e).triggerHandler("jqGridFilterReset");void 0===t&&(t=!0);t&&a.isFunction(b.onReset)&&(t=b.onReset.call(e));!1!==t&&a(e).trigger("reloadGrid",[{page:1}]);b.closeAfterReset&&a.jgrid.hideModal("#"+a.jgrid.jqID(s.themodal), +{gb:"#gbox_"+a.jgrid.jqID(e.p.id),jqm:b.jqModal,onClose:b.onClose});return!1});c(a("#"+h));a(".fm-button:not(.ui-state-disabled)",f).hover(function(){a(this).addClass("ui-state-hover")},function(){a(this).removeClass("ui-state-hover")})}}})},editGridRow:function(z,c){c=a.extend(!0,{top:0,left:0,width:300,datawidth:"auto",height:"auto",dataheight:"auto",modal:!1,overlay:30,drag:!0,resize:!0,url:null,mtype:"POST",clearAfterAdd:!0,closeAfterEdit:!1,reloadAfterSubmit:!0,onInitializeForm:null,beforeInitData:null, +beforeShowForm:null,afterShowForm:null,beforeSubmit:null,afterSubmit:null,onclickSubmit:null,afterComplete:null,onclickPgButtons:null,afterclickPgButtons:null,editData:{},recreateForm:!1,jqModal:!0,closeOnEscape:!1,addedrow:"first",topinfo:"",bottominfo:"",saveicon:[],closeicon:[],savekey:[!1,13],navkeys:[!1,38,40],checkOnSubmit:!1,checkOnUpdate:!1,_savedData:{},processing:!1,onClose:null,ajaxEditOptions:{},serializeEditData:null,viewPagerButtons:!0,overlayClass:"ui-widget-overlay"},a.jgrid.edit, +c||{});b[a(this)[0].p.id]=c;return this.each(function(){function e(){a(p+" > tbody > tr > td > .FormElement").each(function(){var b=a(".customelement",this);if(b.length){var c=a(b[0]).attr("name");a.each(d.p.colModel,function(){if(this.name===c&&this.editoptions&&a.isFunction(this.editoptions.custom_value)){try{if(l[c]=this.editoptions.custom_value.call(d,a("#"+a.jgrid.jqID(c),p),"get"),void 0===l[c])throw"e1";}catch(b){"e1"===b?a.jgrid.info_dialog(a.jgrid.errors.errcap,"function 'custom_value' "+ +a.jgrid.edit.msg.novalue,a.jgrid.edit.bClose):a.jgrid.info_dialog(a.jgrid.errors.errcap,b.message,a.jgrid.edit.bClose)}return!0}})}else{switch(a(this).get(0).type){case "checkbox":a(this).is(":checked")?l[this.name]=a(this).val():(b=a(this).attr("offval"),l[this.name]=b);break;case "select-one":l[this.name]=a("option:selected",this).val();break;case "select-multiple":l[this.name]=a(this).val();l[this.name]=l[this.name]?l[this.name].join(","):"";a("option:selected",this).each(function(b,c){a(c).text()}); +break;case "password":case "text":case "textarea":case "button":l[this.name]=a(this).val()}d.p.autoencode&&(l[this.name]=a.jgrid.htmlEncode(l[this.name]))}});return!0}function h(c,e,n,f){var k,l,p,h=0,q,m,r,C=[],u=!1,z="",t;for(t=1;t<=f;t++)z+="  ";"_empty"!==c&&(u=a(e).jqGrid("getInd",c));a(e.p.colModel).each(function(t){k=this.name;m=(l=this.editrules&&!0===this.editrules.edithidden?!1:!0===this.hidden?!0:!1)?"style='display:none'":""; +if("cb"!==k&&"subgrid"!==k&&!0===this.editable&&"rn"!==k){if(!1===u)q="";else if(k===e.p.ExpandColumn&&!0===e.p.treeGrid)q=a("td[role='gridcell']:eq("+t+")",e.rows[u]).text();else{try{q=a.unformat.call(e,a("td[role='gridcell']:eq("+t+")",e.rows[u]),{rowId:c,colModel:this},t)}catch(w){q=this.edittype&&"textarea"===this.edittype?a("td[role='gridcell']:eq("+t+")",e.rows[u]).text():a("td[role='gridcell']:eq("+t+")",e.rows[u]).html()}if(!q||" "===q||" "===q||1===q.length&&160===q.charCodeAt(0))q= +""}var s=a.extend({},this.editoptions||{},{id:k,name:k}),y=a.extend({},{elmprefix:"",elmsuffix:"",rowabove:!1,rowcontent:""},this.formoptions||{}),v=parseInt(y.rowpos,10)||h+1,A=parseInt(2*(parseInt(y.colpos,10)||1),10);"_empty"===c&&s.defaultValue&&(q=a.isFunction(s.defaultValue)?s.defaultValue.call(d):s.defaultValue);this.edittype||(this.edittype="text");d.p.autoencode&&(q=a.jgrid.htmlDecode(q));r=a.jgrid.createEl.call(d,this.edittype,s,q,!1,a.extend({},a.jgrid.ajaxOptions,e.p.ajaxSelectOptions|| +{}));if(b[d.p.id].checkOnSubmit||b[d.p.id].checkOnUpdate)b[d.p.id]._savedData[k]=q;a(r).addClass("FormElement");-1"+y.rowcontent+"");a(n).append(x);x[0].rp=v}0===p.length&&(p=a("").addClass("FormData").attr("id","tr_"+k),a(p).append(z),a(n).append(p), +p[0].rp=v);a("td:eq("+(A-2)+")",p[0]).html(void 0===y.label?e.p.colNames[t]:y.label);a("td:eq("+(A-1)+")",p[0]).append(y.elmprefix).append(r).append(y.elmsuffix);"custom"===this.edittype&&a.isFunction(s.custom_value)&&s.custom_value.call(d,a("#"+k,"#"+g),"set",q);a.jgrid.bindEv.call(d,r,s);C[h]=t;h++}});0