new version of codemirror + enable liquid colorization + minify codemirror + cmd+S works on Safari, Firox and Chrome

This commit is contained in:
dinedine 2011-01-12 16:54:09 +01:00
parent b397a34c47
commit 0fcd8d5a3c
24 changed files with 1246 additions and 536 deletions

2
.gitignore vendored
View File

@ -6,6 +6,7 @@ tmp/**/*
rerun.txt
uploads
spec/tmp
public/assets
public/sites
public/uploads
public/stylesheets/all.css
@ -29,4 +30,3 @@ config/deploy.rb
perf/test.rb
gem_graph.png
sites/

View File

@ -57,7 +57,7 @@ javascripts:
image_picker:
- public/javascripts/admin/plugins/json2.js
- public/javascripts/admin/plugins/scrollTo.js
- public/javascripts/admin/plugins/codemirror/codemirror.js
- public/javascripts/admin/plugins/codemirror/codemirror.min.js
- public/javascripts/admin/plugins/fancybox.js
- public/javascripts/admin/plugins/plupload/plupload.full.js
- public/javascripts/admin/plugins/imagepicker.js

View File

@ -19,27 +19,26 @@ $.growl.settings.dockCss = {
/* ___ codemirror ___ */
var addCodeMirrorEditor = function(type, el, parser) {
if (type == 'liquid') type = 'xml';
var parserfile = "parse" + type + ".js";
if (parser != undefined) parserfile = parser;
parser = (parser || 'Liquid') + 'Parser';
var editor = CodeMirror.fromTextArea(el.attr('id'), {
height: "400px",
parserfile: parserfile,
stylesheet: [
"/stylesheets/admin/plugins/codemirror/csscolors.css",
"/stylesheets/admin/plugins/codemirror/xmlcolors.css",
"/stylesheets/admin/plugins/codemirror/javascriptcolors.css",
"/stylesheets/admin/plugins/codemirror/liquidcolors.css"],
path: "/javascripts/admin/plugins/codemirror/",
basefiles: '/javascripts/admin/plugins/codemirror/codemirror_base.min.js',
continuousScanning: 500,
reindentOnLoad: true,
initCallback: function(editor) {
jQuery(editor.frame.contentDocument).keypress(function(event) {
jQuery(editor.frame.contentDocument).keydown(function(event) {
jQuery(document).trigger(event);
});
editor.setParser(parser);
}
});
CodeMirrorEditors.push({ 'el': el, 'editor': editor });
}
@ -88,6 +87,9 @@ $(document).ready(function() {
});
$('.formtastic li.error input').eq(0).focus();
// nifty code editor
$('code.html textarea').each(function() { addCodeMirrorEditor('liquid', $(this)); });
// save form in AJAX
$('form.save-with-shortcut').saveWithShortcut();
@ -123,9 +125,6 @@ $(document).ready(function() {
// nifty checkboxes
$('.formtastic li.toggle input[type=checkbox]').checkToggle();
// nifty code editor
$('code.html textarea').each(function() { addCodeMirrorEditor('liquid', $(this)); });
// site selector
$('#site-selector').selectmenu({ style: 'dropdown', width: 395, offsetTop: 8, change: function(event, ui) {
$('#site-selector').parent().submit();

View File

@ -1,13 +1,23 @@
$.cmd = function(key, callback, args) {
$.cmd = function(key, callback, args, options) {
var keyCode = key.charCodeAt(0);
var altKeyCode = keyCode + (32 * (keyCode < 97 ? 1 : -1));
options = (options || { ignoreCase: false });
if (!options.ignoreCase) altKeyCode = null;
$(document).keydown(function(e) {
var isCtrl = false;
$(document).keydown(function(e) {
if(!args) args=[]; // IE barks when args is null
if(e.metaKey) isCtrl = true;
if(e.keyCode == key.charCodeAt(0) && isCtrl) {
callback.apply(this, args);
return false;
}
}).keyup(function(e) {
if(e.ctrlKey) isCtrl = false;
});
if (!args) args = []; // IE barks when args is null
if (e.ctrlKey || e.metaKey) isCtrl = true;
if ((keyCode == e.which || altKeyCode == e.which) && isCtrl) {
e.preventDefault();
callback.apply(this, args);
return false;
}
});
};

View File

@ -1,4 +1,4 @@
/* CodeMirror main module
/* CodeMirror main module (http://codemirror.net/)
*
* Implements the CodeMirror constructor and prototype, which take care
* of initializing the editor frame, and providing the outside interface.
@ -21,12 +21,18 @@ var CodeMirror = (function(){
for (var i = 0; i < array.length; i++)
action(array[i]);
}
function createHTMLElement(el) {
if (document.createElementNS && document.documentElement.namespaceURI !== null)
return document.createElementNS("http://www.w3.org/1999/xhtml", el)
else
return document.createElement(el)
}
// These default options can be overridden by passing a set of
// options to a specific CodeMirror constructor. See manual.html for
// their meaning.
setDefaults(CodeMirrorConfig, {
stylesheet: "",
stylesheet: [],
path: "",
parserfile: [],
basefiles: ["util.js", "stringstream.js", "select.js", "undo.js", "editor.js", "tokenize.js"],
@ -37,6 +43,7 @@ var CodeMirror = (function(){
lineNumberTime: 50,
continuousScanning: false,
saveFunction: null,
onLoad: null,
onChange: null,
undoDepth: 50,
undoDelay: 800,
@ -45,20 +52,29 @@ var CodeMirror = (function(){
readOnly: false,
width: "",
height: "300px",
minHeight: 100,
autoMatchParens: false,
markParen: null,
unmarkParen: null,
parserConfig: null,
tabMode: "indent", // or "spaces", "default", "shift"
enterMode: "indent", // or "keep", "flat"
electricChars: true,
reindentOnLoad: false,
activeTokens: null,
cursorActivity: null,
onCursorActivity: null,
lineNumbers: false,
firstLineNumber: 1,
onLineNumberClick: null,
indentUnit: 2,
domain: null
domain: null,
noScriptCaching: false,
incrementalLoading: false
});
function addLineNumberDiv(container) {
var nums = document.createElement("DIV"),
scroller = document.createElement("DIV");
function addLineNumberDiv(container, firstNum) {
var nums = createHTMLElement("div"),
scroller = createHTMLElement("div");
nums.style.position = "absolute";
nums.style.height = "100%";
if (nums.style.setExpression) {
@ -66,27 +82,33 @@ var CodeMirror = (function(){
catch(e) {} // Seems to throw 'Not Implemented' on some IE8 versions
}
nums.style.top = "0px";
nums.style.left = "0px";
nums.style.overflow = "hidden";
container.appendChild(nums);
scroller.className = "CodeMirror-line-numbers";
nums.appendChild(scroller);
scroller.innerHTML = "<div>" + firstNum + "</div>";
return nums;
}
function frameHTML(options) {
if (typeof options.parserfile == "string")
options.parserfile = [options.parserfile];
if (typeof options.basefiles == "string")
options.basefiles = [options.basefiles];
if (typeof options.stylesheet == "string")
options.stylesheet = [options.stylesheet];
var html = ["<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"><html><head>"];
// Hack to work around a bunch of IE8-specific problems.
html.push("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=EmulateIE7\"/>");
var queryStr = options.noScriptCaching ? "?nocache=" + new Date().getTime().toString(16) : "";
forEach(options.stylesheet, function(file) {
html.push("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + file + "\"/>");
html.push("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + file + queryStr + "\"/>");
});
forEach(options.basefiles.concat(options.parserfile), function(file) {
html.push("<script type=\"text/javascript\" src=\"" + options.path + file + "\"><" + "/script>");
if (!/^https?:/.test(file)) file = options.path + file;
html.push("<script type=\"text/javascript\" src=\"" + file + queryStr + "\"><" + "/script>");
});
html.push("</head><body style=\"border-width: 0;\" class=\"editbox\" spellcheck=\"" +
(options.disableSpellcheck ? "false" : "true") + "\"></body></html>");
@ -96,15 +118,16 @@ var CodeMirror = (function(){
var internetExplorer = document.selection && window.ActiveXObject && /MSIE/.test(navigator.userAgent);
function CodeMirror(place, options) {
// Backward compatibility for deprecated options.
if (options.dumbTabs) options.tabMode = "spaces";
else if (options.normalTab) options.tabMode = "default";
// Use passed options, if any, to override defaults.
this.options = options = options || {};
setDefaults(options, CodeMirrorConfig);
var frame = this.frame = document.createElement("IFRAME");
// Backward compatibility for deprecated options.
if (options.dumbTabs) options.tabMode = "spaces";
else if (options.normalTab) options.tabMode = "default";
if (options.cursorActivity) options.onCursorActivity = options.cursorActivity;
var frame = this.frame = createHTMLElement("iframe");
if (options.iframeClass) frame.className = options.iframeClass;
frame.frameBorder = 0;
frame.style.border = "0";
@ -114,17 +137,18 @@ var CodeMirror = (function(){
// always add it, redundant as it sounds.
frame.style.display = "block";
var div = this.wrapping = document.createElement("DIV");
var div = this.wrapping = createHTMLElement("div");
div.style.position = "relative";
div.className = "CodeMirror-wrapping";
div.style.width = options.width;
div.style.height = options.height;
div.style.height = (options.height == "dynamic") ? options.minHeight + "px" : options.height;
// This is used by Editor.reroutePasteEvent
var teHack = this.textareaHack = document.createElement("TEXTAREA");
var teHack = this.textareaHack = createHTMLElement("textarea");
div.appendChild(teHack);
teHack.style.position = "absolute";
teHack.style.left = "-10000px";
teHack.style.width = "10px";
teHack.tabIndex = 100000;
// Link back to this object, so that the editor can fetch options
// and add a reference to itself.
@ -136,13 +160,13 @@ var CodeMirror = (function(){
"document.write(window.frameElement.CodeMirror.html);document.close();})()";
}
else {
frame.src = "javascript:false";
frame.src = "javascript:;";
}
if (place.appendChild) place.appendChild(div);
else place(div);
div.appendChild(frame);
if (options.lineNumbers) this.lineNumbers = addLineNumberDiv(div);
if (options.lineNumbers) this.lineNumbers = addLineNumberDiv(div, options.firstLineNumber);
this.win = frame.contentWindow;
if (!options.domain || !internetExplorer) {
@ -154,9 +178,12 @@ var CodeMirror = (function(){
CodeMirror.prototype = {
init: function() {
// Deprecated, but still supported.
if (this.options.initCallback) this.options.initCallback(this);
if (this.options.onLoad) this.options.onLoad(this);
if (this.options.lineNumbers) this.activateLineNumbers();
if (this.options.reindentOnLoad) this.reindent();
if (this.options.height == "dynamic") this.setDynamicHeight();
},
getCode: function() {return this.editor.getCode();},
@ -167,7 +194,8 @@ var CodeMirror = (function(){
focusIfIE: function() {
// in IE, a lot of selection-related functionality only works when the frame is focused
if (this.win.select.ie_selection) this.focus();
if (this.win.select.ie_selection && document.activeElement != this.frame)
this.focus();
},
focus: function() {
this.win.focus();
@ -194,7 +222,7 @@ var CodeMirror = (function(){
grabKeys: function(callback, filter) {this.editor.grabKeys(callback, filter);},
ungrabKeys: function() {this.editor.ungrabKeys();},
setParser: function(name) { this.editor.setParser(name); },
setParser: function(name, parserConfig) {this.editor.setParser(name, parserConfig);},
setSpellcheck: function(on) {this.win.document.body.spellcheck = on;},
setStylesheet: function(names) {
if (typeof names === "string") names = [names];
@ -244,14 +272,15 @@ var CodeMirror = (function(){
setIndentUnit: function(unit) {this.win.indentUnit = unit;},
setUndoDepth: function(depth) {this.editor.history.maxDepth = depth;},
setTabMode: function(mode) {this.options.tabMode = mode;},
setEnterMode: function(mode) {this.options.enterMode = mode;},
setLineNumbers: function(on) {
if (on && !this.lineNumbers) {
this.lineNumbers = addLineNumberDiv(this.wrapping);
this.lineNumbers = addLineNumberDiv(this.wrapping,this.options.firstLineNumber);
this.activateLineNumbers();
}
else if (!on && this.lineNumbers) {
this.wrapping.removeChild(this.lineNumbers);
this.wrapping.style.marginLeft = "";
this.wrapping.style.paddingLeft = "";
this.lineNumbers = null;
}
},
@ -294,15 +323,25 @@ var CodeMirror = (function(){
cursorLine: function() {
return this.cursorPosition().line;
},
cursorCoords: function(start) {return this.editor.cursorCoords(start);},
activateLineNumbers: function() {
var frame = this.frame, win = frame.contentWindow, doc = win.document, body = doc.body,
nums = this.lineNumbers, scroller = nums.firstChild, self = this;
var barWidth = null;
nums.onclick = function(e) {
var handler = self.options.onLineNumberClick;
if (handler) {
var div = (e || window.event).target || (e || window.event).srcElement;
var num = div == nums ? NaN : Number(div.innerHTML);
if (!isNaN(num)) handler(num, div);
}
};
function sizeBar() {
if (frame.offsetWidth == 0) return;
for (var root = frame; root.parentNode; root = root.parentNode);
for (var root = frame; root.parentNode; root = root.parentNode){}
if (!nums.parentNode || root != document || !win.Editor) {
// Clear event handlers (their nodes might already be collected, so try/catch)
try{clear();}catch(e){}
@ -312,7 +351,7 @@ var CodeMirror = (function(){
if (nums.offsetWidth != barWidth) {
barWidth = nums.offsetWidth;
nums.style.left = "-" + (frame.parentNode.style.marginLeft = barWidth + "px");
frame.parentNode.style.paddingLeft = barWidth + "px";
}
}
function doScroll() {
@ -323,68 +362,84 @@ var CodeMirror = (function(){
sizeBar();
var sizeInterval = setInterval(sizeBar, 500);
function ensureEnoughLineNumbers(fill) {
var lineHeight = scroller.firstChild.offsetHeight;
if (lineHeight == 0) return;
var targetHeight = 50 + Math.max(body.offsetHeight, Math.max(frame.offsetHeight, body.scrollHeight || 0)),
lastNumber = Math.ceil(targetHeight / lineHeight);
for (var i = scroller.childNodes.length; i <= lastNumber; i++) {
var div = createHTMLElement("div");
div.appendChild(document.createTextNode(fill ? String(i + self.options.firstLineNumber) : "\u00a0"));
scroller.appendChild(div);
}
}
function nonWrapping() {
var nextNum = 1, pending;
function update() {
var target = 50 + Math.max(body.offsetHeight, Math.max(frame.offsetHeight, body.scrollHeight || 0));
var endTime = new Date().getTime() + self.options.lineNumberTime;
while (scroller.offsetHeight < target && (!scroller.firstChild || scroller.offsetHeight)) {
scroller.appendChild(document.createElement("DIV"));
scroller.lastChild.innerHTML = nextNum++;
if (new Date().getTime() > endTime) {
if (pending) clearTimeout(pending);
pending = setTimeout(update, self.options.lineNumberDelay);
break;
}
}
ensureEnoughLineNumbers(true);
doScroll();
}
var onScroll = win.addEventHandler(win, "scroll", update, true),
self.updateNumbers = update;
var onScroll = win.addEventHandler(win, "scroll", doScroll, true),
onResize = win.addEventHandler(win, "resize", update, true);
clear = function(){onScroll(); onResize(); if (pending) clearTimeout(pending);};
clear = function(){
onScroll(); onResize();
if (self.updateNumbers == update) self.updateNumbers = null;
};
update();
}
function wrapping() {
var node, lineNum, next, pos;
function addNum(n) {
if (!lineNum) lineNum = scroller.appendChild(document.createElement("DIV"));
lineNum.innerHTML = n;
function wrapping() {
var node, lineNum, next, pos, changes = [], styleNums = self.options.styleNumbers;
function setNum(n, node) {
// Does not typically happen (but can, if you mess with the
// document during the numbering)
if (!lineNum) lineNum = scroller.appendChild(createHTMLElement("div"));
if (styleNums) styleNums(lineNum, node, n);
// Changes are accumulated, so that the document layout
// doesn't have to be recomputed during the pass
changes.push(lineNum); changes.push(n);
pos = lineNum.offsetHeight + lineNum.offsetTop;
lineNum = lineNum.nextSibling;
}
function commitChanges() {
for (var i = 0; i < changes.length; i += 2)
changes[i].innerHTML = changes[i + 1];
changes = [];
}
function work() {
if (!scroller.parentNode || scroller.parentNode != self.lineNumbers) return;
var endTime = new Date().getTime() + self.options.lineNumberTime;
while (node) {
addNum(next++);
setNum(next++, node.previousSibling);
for (; node && !win.isBR(node); node = node.nextSibling) {
var bott = node.offsetTop + node.offsetHeight;
while (scroller.offsetHeight && bott - 3 > pos) addNum("&nbsp;");
while (scroller.offsetHeight && bott - 3 > pos) setNum("&nbsp;");
}
if (node) node = node.nextSibling;
if (new Date().getTime() > endTime) {
commitChanges();
pending = setTimeout(work, self.options.lineNumberDelay);
return;
}
}
// While there are un-processed number DIVs, or the scroller is smaller than the frame...
var target = 50 + Math.max(body.offsetHeight, Math.max(frame.offsetHeight, body.scrollHeight || 0));
while (lineNum || (scroller.offsetHeight < target && (!scroller.firstChild || scroller.offsetHeight)))
addNum(next++);
while (lineNum) setNum(next++);
commitChanges();
doScroll();
}
function start() {
function start(firstTime) {
doScroll();
ensureEnoughLineNumbers(firstTime);
node = body.firstChild;
lineNum = scroller.firstChild;
pos = 0;
next = 1;
next = self.options.firstLineNumber;
work();
}
start();
start(true);
var pending = null;
function update() {
if (pending) clearTimeout(pending);
@ -401,7 +456,38 @@ var CodeMirror = (function(){
onResize();
};
}
(this.options.textWrapping ? wrapping : nonWrapping)();
(this.options.textWrapping || this.options.styleNumbers ? wrapping : nonWrapping)();
},
setDynamicHeight: function() {
var self = this, activity = self.options.onCursorActivity, win = self.win, body = win.document.body,
lineHeight = null, timeout = null, vmargin = 2 * self.frame.offsetTop;
body.style.overflowY = "hidden";
win.document.documentElement.style.overflowY = "hidden";
this.frame.scrolling = "no";
function updateHeight() {
var trailingLines = 0, node = body.lastChild, computedHeight;
while (node && win.isBR(node)) {
if (!node.hackBR) trailingLines++;
node = node.previousSibling;
}
if (node) {
lineHeight = node.offsetHeight;
computedHeight = node.offsetTop + (1 + trailingLines) * lineHeight;
}
else if (lineHeight) {
computedHeight = trailingLines * lineHeight;
}
if (computedHeight)
self.wrapping.style.height = Math.max(vmargin + computedHeight, self.options.minHeight) + "px";
}
setTimeout(updateHeight, 300);
self.options.onCursorActivity = function(x) {
if (activity) activity(x);
clearTimeout(timeout);
timeout = setTimeout(updateHeight, 100);
};
}
};
@ -426,14 +512,23 @@ var CodeMirror = (function(){
options.height = area.style.height;
if (options.content == null) options.content = area.value;
function updateField() {
area.value = mirror.getCode();
}
if (area.form) {
function updateField() {
area.value = mirror.getCode();
}
if (typeof area.form.addEventListener == "function")
area.form.addEventListener("submit", updateField, false);
else
area.form.attachEvent("onsubmit", updateField);
var realSubmit = area.form.submit;
function wrapSubmit() {
updateField();
// Can't use realSubmit.apply because IE6 is too stupid
area.form.submit = realSubmit;
area.form.submit();
area.form.submit = wrapSubmit;
}
area.form.submit = wrapSubmit;
}
function insert(frame) {
@ -445,6 +540,20 @@ var CodeMirror = (function(){
area.style.display = "none";
var mirror = new CodeMirror(insert, options);
mirror.save = updateField;
mirror.toTextArea = function() {
updateField();
area.parentNode.removeChild(mirror.wrapping);
area.style.display = "";
if (area.form) {
area.form.submit = realSubmit;
if (typeof area.form.removeEventListener == "function")
area.form.removeEventListener("submit", updateField, false);
else
area.form.detachEvent("onsubmit", updateField);
}
};
return mirror;
};
@ -453,7 +562,7 @@ var CodeMirror = (function(){
var match;
if (window.opera)
return Number(window.opera.version()) >= 9.52;
else if (/Apple Computers, Inc/.test(navigator.vendor) && (match = navigator.userAgent.match(/Version\/(\d+(?:\.\d+)?)\./)))
else if (/Apple Computer, Inc/.test(navigator.vendor) && (match = navigator.userAgent.match(/Version\/(\d+(?:\.\d+)?)\./)))
return Number(match[1]) >= 3;
else if (document.selection && window.ActiveXObject && (match = navigator.userAgent.match(/MSIE (\d+(?:\.\d*)?)\b/)))
return Number(match[1]) >= 6;

View File

@ -0,0 +1,23 @@
var CodeMirrorConfig=window.CodeMirrorConfig||{},CodeMirror=function(){function D(a,b){for(var c in b)a.hasOwnProperty(c)||(a[c]=b[c])}function E(a,b){for(var c=0;c<a.length;c++)b(a[c])}function s(a){return document.createElementNS&&document.documentElement.namespaceURI!==null?document.createElementNS("http://www.w3.org/1999/xhtml",a):document.createElement(a)}function F(a,b){var c=s("div"),d=s("div");c.style.position="absolute";c.style.height="100%";if(c.style.setExpression)try{c.style.setExpression("height",
"this.previousSibling.offsetHeight + 'px'")}catch(h){}c.style.top="0px";c.style.left="0px";c.style.overflow="hidden";a.appendChild(c);d.className="CodeMirror-line-numbers";c.appendChild(d);d.innerHTML="<div>"+b+"</div>";return c}function G(a){if(typeof a.parserfile=="string")a.parserfile=[a.parserfile];if(typeof a.basefiles=="string")a.basefiles=[a.basefiles];if(typeof a.stylesheet=="string")a.stylesheet=[a.stylesheet];var b=['<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head>'];
b.push('<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>');var c=a.noScriptCaching?"?nocache="+(new Date).getTime().toString(16):"";E(a.stylesheet,function(d){b.push('<link rel="stylesheet" type="text/css" href="'+d+c+'"/>')});E(a.basefiles.concat(a.parserfile),function(d){/^https?:/.test(d)||(d=a.path+d);b.push('<script type="text/javascript" src="'+d+c+'"><\/script>')});b.push('</head><body style="border-width: 0;" class="editbox" spellcheck="'+(a.disableSpellcheck?"false":"true")+'"></body></html>');
return b.join("")}function t(a,b){this.options=b=b||{};D(b,CodeMirrorConfig);if(b.dumbTabs)b.tabMode="spaces";else if(b.normalTab)b.tabMode="default";if(b.cursorActivity)b.onCursorActivity=b.cursorActivity;var c=this.frame=s("iframe");if(b.iframeClass)c.className=b.iframeClass;c.frameBorder=0;c.style.border="0";c.style.width="100%";c.style.height="100%";c.style.display="block";var d=this.wrapping=s("div");d.style.position="relative";d.className="CodeMirror-wrapping";d.style.width=b.width;d.style.height=
b.height=="dynamic"?b.minHeight+"px":b.height;var h=this.textareaHack=s("textarea");d.appendChild(h);h.style.position="absolute";h.style.left="-10000px";h.style.width="10px";h.tabIndex=1E5;c.CodeMirror=this;if(b.domain&&H){this.html=G(b);c.src="javascript:(function(){document.open();"+(b.domain?'document.domain="'+b.domain+'";':"")+"document.write(window.frameElement.CodeMirror.html);document.close();})()"}else c.src="javascript:;";a.appendChild?a.appendChild(d):a(d);d.appendChild(c);if(b.lineNumbers)this.lineNumbers=
F(d,b.firstLineNumber);this.win=c.contentWindow;if(!b.domain||!H){this.win.document.open();this.win.document.write(G(b));this.win.document.close()}}D(CodeMirrorConfig,{stylesheet:[],path:"",parserfile:[],basefiles:["util.js","stringstream.js","select.js","undo.js","editor.js","tokenize.js"],iframeClass:null,passDelay:200,passTime:50,lineNumberDelay:200,lineNumberTime:50,continuousScanning:false,saveFunction:null,onLoad:null,onChange:null,undoDepth:50,undoDelay:800,disableSpellcheck:true,textWrapping:true,
readOnly:false,width:"",height:"300px",minHeight:100,autoMatchParens:false,markParen:null,unmarkParen:null,parserConfig:null,tabMode:"indent",enterMode:"indent",electricChars:true,reindentOnLoad:false,activeTokens:null,onCursorActivity:null,lineNumbers:false,firstLineNumber:1,onLineNumberClick:null,indentUnit:2,domain:null,noScriptCaching:false,incrementalLoading:false});var H=document.selection&&window.ActiveXObject&&/MSIE/.test(navigator.userAgent);t.prototype={init:function(){this.options.initCallback&&
this.options.initCallback(this);this.options.onLoad&&this.options.onLoad(this);this.options.lineNumbers&&this.activateLineNumbers();this.options.reindentOnLoad&&this.reindent();this.options.height=="dynamic"&&this.setDynamicHeight()},getCode:function(){return this.editor.getCode()},setCode:function(a){this.editor.importCode(a)},selection:function(){this.focusIfIE();return this.editor.selectedText()},reindent:function(){this.editor.reindent()},reindentSelection:function(){this.focusIfIE();this.editor.reindentSelection(null)},
focusIfIE:function(){this.win.select.ie_selection&&document.activeElement!=this.frame&&this.focus()},focus:function(){this.win.focus();this.editor.selectionSnapshot&&this.win.select.setBookmark(this.win.document.body,this.editor.selectionSnapshot)},replaceSelection:function(a){this.focus();this.editor.replaceSelection(a);return true},replaceChars:function(a,b,c){this.editor.replaceChars(a,b,c)},getSearchCursor:function(a,b,c){return this.editor.getSearchCursor(a,b,c)},undo:function(){this.editor.history.undo()},
redo:function(){this.editor.history.redo()},historySize:function(){return this.editor.history.historySize()},clearHistory:function(){this.editor.history.clear()},grabKeys:function(a,b){this.editor.grabKeys(a,b)},ungrabKeys:function(){this.editor.ungrabKeys()},setParser:function(a,b){this.editor.setParser(a,b)},setSpellcheck:function(a){this.win.document.body.spellcheck=a},setStylesheet:function(a){if(typeof a==="string")a=[a];for(var b={},c={},d=this.win.document.getElementsByTagName("link"),h=0,
e;e=d[h];h++)if(e.rel.indexOf("stylesheet")!==-1)for(var f=0;f<a.length;f++){var n=a[f];if(e.href.substring(e.href.length-n.length)===n){b[e.href]=true;c[n]=true}}for(h=0;e=d[h];h++)if(e.rel.indexOf("stylesheet")!==-1)e.disabled=!(e.href in b);for(f=0;f<a.length;f++){n=a[f];if(!(n in c)){e=this.win.document.createElement("link");e.rel="stylesheet";e.type="text/css";e.href=n;this.win.document.getElementsByTagName("head")[0].appendChild(e)}}},setTextWrapping:function(a){if(a!=this.options.textWrapping){this.win.document.body.style.whiteSpace=
a?"":"nowrap";this.options.textWrapping=a;if(this.lineNumbers){this.setLineNumbers(false);this.setLineNumbers(true)}}},setIndentUnit:function(a){this.win.indentUnit=a},setUndoDepth:function(a){this.editor.history.maxDepth=a},setTabMode:function(a){this.options.tabMode=a},setEnterMode:function(a){this.options.enterMode=a},setLineNumbers:function(a){if(a&&!this.lineNumbers){this.lineNumbers=F(this.wrapping,this.options.firstLineNumber);this.activateLineNumbers()}else if(!a&&this.lineNumbers){this.wrapping.removeChild(this.lineNumbers);
this.wrapping.style.paddingLeft="";this.lineNumbers=null}},cursorPosition:function(a){this.focusIfIE();return this.editor.cursorPosition(a)},firstLine:function(){return this.editor.firstLine()},lastLine:function(){return this.editor.lastLine()},nextLine:function(a){return this.editor.nextLine(a)},prevLine:function(a){return this.editor.prevLine(a)},lineContent:function(a){return this.editor.lineContent(a)},setLineContent:function(a,b){this.editor.setLineContent(a,b)},removeLine:function(a){this.editor.removeLine(a)},
insertIntoLine:function(a,b,c){this.editor.insertIntoLine(a,b,c)},selectLines:function(a,b,c,d){this.win.focus();this.editor.selectLines(a,b,c,d)},nthLine:function(a){for(var b=this.firstLine();a>1&&b!==false;a--)b=this.nextLine(b);return b},lineNumber:function(a){for(var b=0;a!==false;){b++;a=this.prevLine(a)}return b},jumpToLine:function(a){if(typeof a=="number")a=this.nthLine(a);this.selectLines(a,0);this.win.focus()},currentLine:function(){return this.lineNumber(this.cursorLine())},cursorLine:function(){return this.cursorPosition().line},
cursorCoords:function(a){return this.editor.cursorCoords(a)},activateLineNumbers:function(){function a(){if(e.offsetWidth!=0){for(var g=e;g.parentNode;g=g.parentNode);if(!i.parentNode||g!=document||!f.Editor){try{y()}catch(k){}clearInterval(J)}else if(i.offsetWidth!=z){z=i.offsetWidth;e.parentNode.style.paddingLeft=z+"px"}}}function b(){i.scrollTop=q.scrollTop||n.documentElement.scrollTop||0}function c(g){var k=l.firstChild.offsetHeight;if(k!=0){k=Math.ceil((50+Math.max(q.offsetHeight,Math.max(e.offsetHeight,
q.scrollHeight||0)))/k);for(var o=l.childNodes.length;o<=k;o++){var w=s("div");w.appendChild(document.createTextNode(g?String(o+j.options.firstLineNumber):"\u00a0"));l.appendChild(w)}}}function d(){function g(){c(true);b()}j.updateNumbers=g;var k=f.addEventHandler(f,"scroll",b,true),o=f.addEventHandler(f,"resize",g,true);y=function(){k();o();if(j.updateNumbers==g)j.updateNumbers=null};g()}function h(){function g(p,A){r||(r=l.appendChild(s("div")));I&&I(r,A,p);u.push(r);u.push(p);B=r.offsetHeight+
r.offsetTop;r=r.nextSibling}function k(){for(var p=0;p<u.length;p+=2)u[p].innerHTML=u[p+1];u=[]}function o(){if(!(!l.parentNode||l.parentNode!=j.lineNumbers)){for(var p=(new Date).getTime()+j.options.lineNumberTime;m;){for(g(C++,m.previousSibling);m&&!f.isBR(m);m=m.nextSibling)for(var A=m.offsetTop+m.offsetHeight;l.offsetHeight&&A-3>B;)g("&nbsp;");if(m)m=m.nextSibling;if((new Date).getTime()>p){k();v=setTimeout(o,j.options.lineNumberDelay);return}}for(;r;)g(C++);k();b()}}function w(p){b();c(p);m=
q.firstChild;r=l.firstChild;B=0;C=j.options.firstLineNumber;o()}function x(){v&&clearTimeout(v);if(j.editor.allClean())w();else v=setTimeout(x,200)}var m,r,C,B,u=[],I=j.options.styleNumbers;w(true);var v=null;j.updateNumbers=x;var K=f.addEventHandler(f,"scroll",b,true),L=f.addEventHandler(f,"resize",x,true);y=function(){v&&clearTimeout(v);if(j.updateNumbers==x)j.updateNumbers=null;K();L()}}var e=this.frame,f=e.contentWindow,n=f.document,q=n.body,i=this.lineNumbers,l=i.firstChild,j=this,z=null;i.onclick=
function(g){var k=j.options.onLineNumberClick;if(k){g=(g||window.event).target||(g||window.event).srcElement;var o=g==i?NaN:Number(g.innerHTML);isNaN(o)||k(o,g)}};var y=function(){};a();var J=setInterval(a,500);(this.options.textWrapping||this.options.styleNumbers?h:d)()},setDynamicHeight:function(){function a(){for(var q=0,i=h.lastChild,l;i&&d.isBR(i);){i.hackBR||q++;i=i.previousSibling}if(i){e=i.offsetHeight;l=i.offsetTop+(1+q)*e}else if(e)l=q*e;if(l)b.wrapping.style.height=Math.max(n+l,b.options.minHeight)+
"px"}var b=this,c=b.options.onCursorActivity,d=b.win,h=d.document.body,e=null,f=null,n=2*b.frame.offsetTop;h.style.overflowY="hidden";d.document.documentElement.style.overflowY="hidden";this.frame.scrolling="no";setTimeout(a,300);b.options.onCursorActivity=function(q){c&&c(q);clearTimeout(f);f=setTimeout(a,100)}}};t.InvalidLineHandle={toString:function(){return"CodeMirror.InvalidLineHandle"}};t.replace=function(a){if(typeof a=="string")a=document.getElementById(a);return function(b){a.parentNode.replaceChild(b,
a)}};t.fromTextArea=function(a,b){function c(){a.value=e.getCode()}if(typeof a=="string")a=document.getElementById(a);b=b||{};if(a.style.width&&b.width==null)b.width=a.style.width;if(a.style.height&&b.height==null)b.height=a.style.height;if(b.content==null)b.content=a.value;if(a.form){typeof a.form.addEventListener=="function"?a.form.addEventListener("submit",c,false):a.form.attachEvent("onsubmit",c);var d=a.form.submit,h=function(){c();a.form.submit=d;a.form.submit();a.form.submit=h};a.form.submit=
h}a.style.display="none";var e=new t(function(f){a.nextSibling?a.parentNode.insertBefore(f,a.nextSibling):a.parentNode.appendChild(f)},b);e.save=c;e.toTextArea=function(){c();a.parentNode.removeChild(e.wrapping);a.style.display="";if(a.form){a.form.submit=d;typeof a.form.removeEventListener=="function"?a.form.removeEventListener("submit",c,false):a.form.detachEvent("onsubmit",c)}};return e};t.isProbablySupported=function(){var a;return window.opera?Number(window.opera.version())>=9.52:/Apple Computer, Inc/.test(navigator.vendor)&&
(a=navigator.userAgent.match(/Version\/(\d+(?:\.\d+)?)\./))?Number(a[1])>=3:document.selection&&window.ActiveXObject&&(a=navigator.userAgent.match(/MSIE (\d+(?:\.\d*)?)\b/))?Number(a[1])>=6:(a=navigator.userAgent.match(/gecko\/(\d{8})/i))?Number(a[1])>=20050901:(a=navigator.userAgent.match(/AppleWebKit\/(\d+)/))?Number(a[1])>=525:null};return t}();

View File

@ -0,0 +1,118 @@
function method(g,p){return function(){g[p].apply(g,arguments)}}var StopIteration={toString:function(){return"StopIteration"}};function forEach(g,p){if(g.next)try{for(;;)p(g.next())}catch(k){if(k!=StopIteration)throw k;}else for(var m=0;m<g.length;m++)p(g[m])}function map(g,p){var k=[];forEach(g,function(m){k.push(p(m))});return k}function matcher(g){return function(p){return g.test(p)}}function hasClass(g,p){var k=g.className;return k&&RegExp("(^| )"+p+"($| )").test(k)}
function removeClass(g,p){g.className=g.className.replace(RegExp(" "+p+"\\b","g"),"");return g}function insertAfter(g,p){p.parentNode.insertBefore(g,p.nextSibling);return g}function removeElement(g){g.parentNode&&g.parentNode.removeChild(g)}function clearElement(g){for(;g.firstChild;)g.removeChild(g.firstChild)}function isAncestor(g,p){for(;p=p.parentNode;)if(g==p)return true;return false}var nbsp="\u00a0",matching={"{":"}","[":"]","(":")","}":"{","]":"[",")":"("};
function normalizeEvent(g){if(!g.stopPropagation){g.stopPropagation=function(){this.cancelBubble=true};g.preventDefault=function(){this.returnValue=false}}if(!g.stop)g.stop=function(){this.stopPropagation();this.preventDefault()};if(g.type=="keypress"){g.code=g.charCode==null?g.keyCode:g.charCode;g.character=String.fromCharCode(g.code)}return g}
function addEventHandler(g,p,k,m){function s(n){k(normalizeEvent(n||window.event))}if(typeof g.addEventListener=="function"){g.addEventListener(p,s,false);if(m)return function(){g.removeEventListener(p,s,false)}}else{g.attachEvent("on"+p,s);if(m)return function(){g.detachEvent("on"+p,s)}}}function nodeText(g){return g.textContent||g.innerText||g.nodeValue||""}function nodeTop(g){for(var p=0;g.offsetParent;){p+=g.offsetTop;g=g.offsetParent}return p}
function isBR(g){g=g.nodeName;return g=="BR"||g=="br"}function isSpan(g){g=g.nodeName;return g=="SPAN"||g=="span"};var stringStream=function(g){function p(){for(;m==k.length;){s+=k;k="";m=0;try{k=g.next()}catch(n){if(n!=StopIteration)throw n;else return false}}return true}var k="",m=0,s="";return{peek:function(){if(!p())return null;return k.charAt(m)},next:function(){if(!p())if(s.length>0)throw"End of stringstream reached without emptying buffer ('"+s+"').";else throw StopIteration;return k.charAt(m++)},get:function(){var n=s;s="";if(m>0){n+=k.slice(0,m);k=k.slice(m);m=0}return n},push:function(n){k=k.slice(0,
m)+n+k.slice(m)},lookAhead:function(n,t,a,d){function c(j){return d?j.toLowerCase():j}n=c(n);var b=false,e=s,f=m;for(a&&this.nextWhileMatches(/[\s\u00a0]/);;){a=m+n.length;var h=k.length-m;if(a<=k.length){b=n==c(k.slice(m,a));m=a;break}else if(n.slice(0,h)==c(k.slice(m))){s+=k;k="";try{k=g.next()}catch(i){if(i!=StopIteration)throw i;break}m=0;n=n.slice(h)}else break}if(!(b&&t)){k=s.slice(e.length)+k;m=f;s=e}return b},lookAheadRegex:function(n,t){if(n.source.charAt(0)!="^")throw Error("Regexps passed to lookAheadRegex must start with ^");
for(;k.indexOf("\n",m)==-1;)try{k+=g.next()}catch(a){if(a!=StopIteration)throw a;break}var d=k.slice(m).match(n);if(d&&t)m+=d[0].length;return d},more:function(){return this.peek()!==null},applies:function(n){var t=this.peek();return t!==null&&n(t)},nextWhile:function(n){for(var t;(t=this.peek())!==null&&n(t);)this.next()},matches:function(n){var t=this.peek();return t!==null&&n.test(t)},nextWhileMatches:function(n){for(var t;(t=this.peek())!==null&&n.test(t);)this.next()},equals:function(n){return n===
this.peek()},endOfLine:function(){var n=this.peek();return n==null||n=="\n"}}};var select={};
(function(){function g(b,e){for(;b&&b.parentNode!=e;)b=b.parentNode;return b}function p(b,e){for(;!b.previousSibling&&b.parentNode!=e;)b=b.parentNode;return g(b.previousSibling,e)}function k(b){var e=b.nextSibling;if(e){for(;e.firstChild;)e=e.firstChild;return e.nodeType==3||isBR(e)?e:k(e)}else{for(b=b.parentNode;b&&!b.nextSibling;)b=b.parentNode;return b&&k(b)}}select.ie_selection=document.selection&&document.selection.createRangeCollection;select.scrollToNode=function(b,e){if(b){for(var f=b,h=document.body,
i=document.documentElement,j=!f.nextSibling||!f.nextSibling.nextSibling||!f.nextSibling.nextSibling.nextSibling,q=0;f&&!f.offsetTop;){q++;f=f.previousSibling}if(q==0)j=false;if(!(webkit&&f&&f.offsetTop==5&&f.offsetLeft==5)){q=q*(f?f.offsetHeight:0);var l=0,r=b?b.offsetWidth:0;for(f=f;f&&f.offsetParent;){q+=f.offsetTop;isBR(f)||(l+=f.offsetLeft);f=f.offsetParent}f=h.scrollLeft||i.scrollLeft||0;h=h.scrollTop||i.scrollTop||0;var o=false,w=window.innerWidth||i.clientWidth||0;if(e||r<w){if(e){var A=select.offsetInNode(b),
v=nodeText(b).length;if(v)l+=r*(A/v)}r=l-f;if(r<0||r>w){f=l;o=true}}l=q-h;if(l<0||j||l>(window.innerHeight||i.clientHeight||0)-50){h=j?1E6:q;o=true}o&&window.scrollTo(f,h)}}};select.scrollToCursor=function(b){select.scrollToNode(select.selectionTopNode(b,true)||b.firstChild,true)};var m=null;select.snapshotChanged=function(){if(m)m.changed=true};select.snapshotReplaceNode=function(b,e,f,h){function i(j){if(b==j.node){m.changed=true;if(f&&j.offset>f)j.offset-=f;else{j.node=e;j.offset+=h||0}}else if(select.ie_selection&&
j.offset==0&&j.node==k(b))m.changed=true}if(m){i(m.start);i(m.end)}};select.snapshotMove=function(b,e,f,h,i){function j(q){if(b==q.node&&(!i||q.offset==0)){m.changed=true;q.node=e;q.offset=h?Math.max(0,q.offset+f):f}}if(m){j(m.start);j(m.end)}};if(select.ie_selection){var s=function(){var b=document.selection;return b&&(b.createRange||b.createTextRange)()},n=function(b){function e(r){for(var o=null;!o&&r;){o=r.nextSibling;r=r.parentNode}return f(o)}function f(r){for(;r&&r.firstChild;)r=r.firstChild;
return{node:r,offset:0}}var h=s();h.collapse(b);b=h.parentElement();if(!isAncestor(document.body,b))return null;if(!b.firstChild)return f(b);var i=h.duplicate();i.moveToElementText(b);i.collapse(true);for(var j=b.firstChild;j;j=j.nextSibling){if(j.nodeType==3){var q=j.nodeValue.length;i.move("character",q)}else{i.moveToElementText(j);i.collapse(false)}var l=h.compareEndPoints("StartToStart",i);if(l==0)return e(j);if(l!=1){if(j.nodeType!=3)return f(j);i.setEndPoint("StartToEnd",h);return{node:j,offset:q-
i.text.length}}}return e(b)};select.markSelection=function(){m=null;if(document.selection){var b=n(true),e=n(false);if(b&&e)m={start:b,end:e,changed:false}}};select.selectMarked=function(){function b(h){var i=document.body.createTextRange(),j=h.node;if(j)if(j.nodeType==3){i.moveToElementText(j.parentNode);for(h=h.offset;j.previousSibling;){j=j.previousSibling;h+=(j.innerText||"").length}i.move("character",h)}else{i.moveToElementText(j);i.collapse(true)}else{i.moveToElementText(document.body);i.collapse(false)}return i}
if(m&&m.changed){var e=b(m.start),f=b(m.end);e.setEndPoint("StartToEnd",f);e.select()}};select.offsetInNode=function(b){var e=s();if(!e)return 0;var f=e.duplicate();try{f.moveToElementText(b)}catch(h){return 0}e.setEndPoint("StartToStart",f);return e.text.length};select.selectionTopNode=function(b,e){function f(o,w){if(w.nodeType==3){for(var A=0,v=w.previousSibling;v&&v.nodeType==3;){A+=v.nodeValue.length;v=v.previousSibling}if(v){try{o.moveToElementText(v)}catch(x){return false}o.collapse(false)}else o.moveToElementText(w.parentNode);
A&&o.move("character",A)}else try{o.moveToElementText(w)}catch(H){return false}return true}var h=s();if(!h)return false;var i=h.duplicate();h.collapse(e);var j=h.parentElement();if(j&&isAncestor(b,j)){i.moveToElementText(j);if(h.compareEndPoints("StartToStart",i)==1)return g(j,b)}e=0;for(j=b.childNodes.length-1;e<j;){var q=Math.ceil((j+e)/2),l=b.childNodes[q];if(!l)return false;if(!f(i,l))return false;if(h.compareEndPoints("StartToStart",i)==1)e=q;else j=q-1}if(e==0){h=s();i=h.duplicate();try{i.moveToElementText(b)}catch(r){return null}if(h.compareEndPoints("StartToStart",
i)==0)return null}return b.childNodes[e]||null};select.focusAfterNode=function(b,e){var f=document.body.createTextRange();f.moveToElementText(b||e);f.collapse(!b);f.select()};select.somethingSelected=function(){var b=s();return b&&b.text!=""};var t=function(b){var e=s();if(e){e.pasteHTML(b);e.collapse(false);e.select()}};select.insertNewlineAtCursor=function(){t("<br>")};select.insertTabAtCursor=function(){t("\u00a0\u00a0\u00a0\u00a0")};select.cursorPos=function(b,e){var f=s();if(!f)return null;for(var h=
select.selectionTopNode(b,e);h&&!isBR(h);)h=h.previousSibling;var i=f.duplicate();f.collapse(e);if(h){i.moveToElementText(h);i.collapse(false)}else{try{i.moveToElementText(b)}catch(j){return null}i.collapse(true)}f.setEndPoint("StartToStart",i);return{node:h,offset:f.text.length}};select.setCursorPos=function(b,e,f){function h(j){var q=document.body.createTextRange();if(j.node){q.moveToElementText(j.node);q.collapse(false)}else{q.moveToElementText(b);q.collapse(true)}q.move("character",j.offset);
return q}var i=h(e);f&&f!=e&&i.setEndPoint("EndToEnd",h(f));i.select()};select.getBookmark=function(b){var e=select.cursorPos(b,true);b=select.cursorPos(b,false);if(e&&b)return{from:e,to:b}};select.setBookmark=function(b,e){e&&select.setCursorPos(b,e.from,e.to)}}else{var a=function(b,e){for(;b.nodeType!=3&&!isBR(b);){var f=b.childNodes[e]||b.nextSibling;for(e=0;!f&&b.parentNode;){b=b.parentNode;f=b.nextSibling}b=f;if(!f)break}return{node:b,offset:e}};select.markSelection=function(){var b=window.getSelection();
if(!b||b.rangeCount==0)return m=null;b=b.getRangeAt(0);m={start:a(b.startContainer,b.startOffset),end:a(b.endContainer,b.endOffset),changed:false}};select.selectMarked=function(){function b(){if(f.start.node==f.end.node&&f.start.offset==f.end.offset){var i=window.getSelection();if(!i||i.rangeCount==0)return true;i=i.getRangeAt(0);i=a(i.startContainer,i.startOffset);return f.start.node!=i.node||f.start.offset!=i.offset}}function e(i,j){if(i.node)i.offset==0?h["set"+j+"Before"](i.node):h["set"+j](i.node,
i.offset);else h.setStartAfter(document.body.lastChild||document.body)}var f=m;if(f&&(f.changed||webkit&&b())){var h=document.createRange();e(f.end,"End");e(f.start,"Start");d(h)}};var d=function(b){var e=window.getSelection();if(e){e.removeAllRanges();e.addRange(b)}},c=function(){var b=window.getSelection();return!b||b.rangeCount==0?false:b.getRangeAt(0)};select.selectionTopNode=function(b,e){var f=c();if(!f)return false;var h=e?f.startContainer:f.endContainer,i=e?f.startOffset:f.endOffset;window.opera&&
!e&&f.endContainer==b&&f.endOffset==f.startOffset+1&&b.childNodes[f.startOffset]&&isBR(b.childNodes[f.startOffset])&&i--;return h.nodeType==3?i>0?g(h,b):p(h,b):h.nodeName.toUpperCase()=="HTML"?i==1?null:b.lastChild:h==b?i==0?null:h.childNodes[i-1]:i==h.childNodes.length?g(h,b):i==0?p(h,b):g(h.childNodes[i-1],b)};select.focusAfterNode=function(b,e){var f=document.createRange();f.setStartBefore(e.firstChild||e);if(b&&!b.firstChild)f.setEndAfter(b);else b?f.setEnd(b,b.childNodes.length):f.setEndBefore(e.firstChild||
e);f.collapse(false);d(f)};select.somethingSelected=function(){var b=c();return b&&!b.collapsed};select.offsetInNode=function(b){var e=c();if(!e)return 0;e=e.cloneRange();e.setStartBefore(b);return e.toString().length};select.insertNodeAtCursor=function(b){var e=c();if(e){e.deleteContents();e.insertNode(b);webkitLastLineHack(document.body);if(window.opera&&isBR(b)&&isSpan(b.parentNode)){e=b.nextSibling;var f=b.parentNode,h=f.parentNode;h.insertBefore(b,f.nextSibling);for(f="";e&&e.nodeType==3;e=e.nextSibling){f+=
e.nodeValue;removeElement(e)}h.insertBefore(makePartSpan(f,document),b.nextSibling)}e=document.createRange();e.selectNode(b);e.collapse(false);d(e)}};select.insertNewlineAtCursor=function(){select.insertNodeAtCursor(document.createElement("BR"))};select.insertTabAtCursor=function(){select.insertNodeAtCursor(document.createTextNode("\u00a0\u00a0\u00a0\u00a0"))};select.cursorPos=function(b,e){var f=c();if(f){for(var h=select.selectionTopNode(b,e);h&&!isBR(h);)h=h.previousSibling;f=f.cloneRange();f.collapse(e);
h?f.setStartAfter(h):f.setStartBefore(b);f=f.toString();return{node:h,offset:f.length}}};select.setCursorPos=function(b,e,f){function h(j,q,l){function r(v){v.nodeType==3?o.push(v):forEach(v.childNodes,r)}if(q==0&&j&&!j.nextSibling){i["set"+l+"After"](j);return true}if(j=j?j.nextSibling:b.firstChild){if(q==0){i["set"+l+"Before"](j);return true}for(var o=[];;){for(;j&&!o.length;){r(j);j=j.nextSibling}var w=o.shift();if(!w)return false;var A=w.nodeValue.length;if(A>=q){i["set"+l](w,q);return true}q-=
A}}}var i=document.createRange();f=f||e;h(f.node,f.offset,"End")&&h(e.node,e.offset,"Start")&&d(i)}}})();function UndoHistory(g,p,k,m){this.container=g;this.maxDepth=p;this.commitDelay=k;this.editor=m;this.last=this.first=g={text:"",from:null,to:null};this.firstTouched=false;this.history=[];this.redoHistory=[];this.touched=[]}
UndoHistory.prototype={scheduleCommit:function(){var g=this;parent.clearTimeout(this.commitTimeout);this.commitTimeout=parent.setTimeout(function(){g.tryCommit()},this.commitDelay)},touch:function(g){this.setTouched(g);this.scheduleCommit()},undo:function(){this.commit();if(this.history.length){var g=this.history.pop();this.redoHistory.push(this.updateTo(g,"applyChain"));this.notifyEnvironment();return this.chainNode(g)}},redo:function(){this.commit();if(this.redoHistory.length){var g=this.redoHistory.pop();
this.addUndoLevel(this.updateTo(g,"applyChain"));this.notifyEnvironment();return this.chainNode(g)}},clear:function(){this.history=[];this.redoHistory=[]},historySize:function(){return{undo:this.history.length,redo:this.redoHistory.length}},push:function(g,p,k){for(var m=[],s=0;s<k.length;s++){var n=s==k.length-1?p:document.createElement("br");m.push({from:g,to:n,text:cleanText(k[s])});g=n}this.pushChains([m],g==null&&p==null);this.notifyEnvironment()},pushChains:function(g,p){this.commit(p);this.addUndoLevel(this.updateTo(g,
"applyChain"));this.redoHistory=[]},chainNode:function(g){for(var p=0;p<g.length;p++){var k=g[p][0];if(k=k&&(k.from||k.to))return k}},reset:function(){this.history=[];this.redoHistory=[]},textAfter:function(g){return this.after(g).text},nodeAfter:function(g){return this.after(g).to},nodeBefore:function(g){return this.before(g).from},tryCommit:function(){!window||!window.parent||!window.UndoHistory||(this.editor.highlightDirty()?this.commit(true):this.scheduleCommit())},commit:function(g){parent.clearTimeout(this.commitTimeout);
g||this.editor.highlightDirty(true);g=this.touchedChains();if(g.length){this.addUndoLevel(this.updateTo(g,"linkChain"));this.redoHistory=[];this.notifyEnvironment()}},updateTo:function(g,p){for(var k=[],m=[],s=0;s<g.length;s++){k.push(this.shadowChain(g[s]));m.push(this[p](g[s]))}p=="applyChain"&&this.notifyDirty(m);return k},notifyDirty:function(g){forEach(g,method(this.editor,"addDirtyNode"));this.editor.scheduleHighlight()},notifyEnvironment:function(){this.onChange&&this.onChange();window.frameElement&&
window.frameElement.CodeMirror.updateNumbers&&window.frameElement.CodeMirror.updateNumbers()},linkChain:function(g){for(var p=0;p<g.length;p++){var k=g[p];if(k.from)k.from.historyAfter=k;else this.first=k;if(k.to)k.to.historyBefore=k;else this.last=k}},after:function(g){return g?g.historyAfter:this.first},before:function(g){return g?g.historyBefore:this.last},setTouched:function(g){if(g){if(!g.historyTouched){this.touched.push(g);g.historyTouched=true}}else this.firstTouched=true},addUndoLevel:function(g){this.history.push(g);
this.history.length>this.maxDepth&&this.history.shift()},touchedChains:function(){function g(a,d){if(a)a.historyTemp=d;else s=d}function p(a){for(var d=[],c=a?a.nextSibling:m.container.firstChild;c&&(!isBR(c)||c.hackBR);c=c.nextSibling)!c.hackBR&&c.currentText&&d.push(c.currentText);return{from:a,to:c,text:cleanText(d.join(""))}}function k(a,d){for(var c=d+"Sibling",b=a[c];b&&!isBR(b);)b=b[c];return b}var m=this,s=null,n=[];m.firstTouched&&m.touched.push(null);forEach(m.touched,function(a){if(!(a&&
(a.parentNode!=m.container||a.hackBR))){if(a)a.historyTouched=false;else m.firstTouched=false;var d=p(a),c=m.after(a);if(!c||c.text!=d.text||c.to!=d.to){n.push(d);g(a,d)}}});var t=[];m.touched=[];forEach(n,function(a){if(a.from?a.from.historyTemp:s){for(var d=[],c=a.from,b=true;;){var e=c?c.historyTemp:s;if(!e)if(b)break;else e=p(c);d.unshift(e);g(c,null);if(!c)break;b=m.after(c);c=k(c,"previous")}c=a.to;for(b=m.before(a.from);;){if(!c)break;e=c?c.historyTemp:s;if(!e)if(b)break;else e=p(c);d.push(e);
g(c,null);b=m.before(c);c=k(c,"next")}t.push(d)}});return t},shadowChain:function(g){var p=[],k=this.after(g[0].from);for(g=g[g.length-1].to;;){p.push(k);k=k.to;if(!k||k==g)break;else k=k.historyAfter||this.before(g)}return p},applyChain:function(g){var p=select.cursorPos(this.container,false),k=this,m=g[0].from,s=g[g.length-1].to;(function(b,e){for(var f=b?b.nextSibling:k.container.firstChild;f!=e;){var h=f.nextSibling;removeElement(f);f=h}})(m,s);for(var n=0;n<g.length;n++){var t=g[n];n>0&&k.container.insertBefore(t.from,
s);var a=makePartSpan(fixSpaces(t.text));k.container.insertBefore(a,s);if(p&&p.node==t.from){a=0;var d=this.after(t.from);if(d&&n==g.length-1){for(var c=0;c<p.offset&&t.text.charAt(c)==d.text.charAt(c);c++);if(p.offset>c)a=t.text.length-d.text.length}select.setCursorPos(this.container,{node:t.from,offset:Math.max(0,p.offset+a)})}else p&&n==g.length-1&&p.node&&p.node.parentNode!=this.container&&select.setCursorPos(this.container,{node:t.from,offset:t.text.length})}this.linkChain(g);return m}};var internetExplorer=document.selection&&window.ActiveXObject&&/MSIE/.test(navigator.userAgent),webkit=/AppleWebKit/.test(navigator.userAgent),safari=/Apple Computer, Inc/.test(navigator.vendor),gecko=navigator.userAgent.match(/gecko\/(\d{8})/i);if(gecko)gecko=Number(gecko[1]);var mac=/Mac/.test(navigator.platform),brokenOpera=window.opera&&/Version\/10.[56]/.test(navigator.userAgent),slowWebkit=/AppleWebKit\/533/.test(navigator.userAgent);
function makeWhiteSpace(g){for(var p=[],k=true;g>0;g--){p.push(k||g==1?nbsp:" ");k^=true}return p.join("")}function fixSpaces(g){if(g.charAt(0)==" ")g=nbsp+g.slice(1);return g.replace(/\t/g,function(){return makeWhiteSpace(indentUnit)}).replace(/[ \u00a0]{2,}/g,function(p){return makeWhiteSpace(p.length)})}function cleanText(g){return g.replace(/\u00a0/g," ").replace(/\u200b/g,"")}
function makePartSpan(g){var p=g;if(g.nodeType==3)p=g.nodeValue;else g=document.createTextNode(p);var k=document.createElement("span");k.isPart=true;k.appendChild(g);k.currentText=p;return k}function alwaysZero(){return 0}var webkitLastLineHack=webkit?function(g){var p=g.lastChild;if(!p||!p.hackBR){p=document.createElement("br");p.hackBR=true;g.appendChild(p)}}:function(){};
function asEditorLines(g){var p=makeWhiteSpace(indentUnit);return map(g.replace(/\t/g,p).replace(/\u00a0/g," ").replace(/\r\n?/g,"\n").split("\n"),fixSpaces)}
var Editor=function(){function g(a,d){function c(f,h){if(f.nodeType==3){if((f.nodeValue=fixSpaces(f.nodeValue.replace(/[\r\u200b]/g,"").replace(/\n/g," "))).length)e=false;b.push(f)}else if(isBR(f)&&f.childNodes.length==0){e=true;b.push(f)}else{for(var i=f.firstChild;i;i=i.nextSibling)c(i);if(!e&&t.hasOwnProperty(f.nodeName.toUpperCase())){e=true;if(!d||!h)b.push(document.createElement("br"))}}}var b=[],e=true;c(a,true);return b}function p(a){function d(f){var h=f.parentNode,i=f.nextSibling;return function(j){h.insertBefore(j,
i)}}var c=[],b=null,e=true;return{next:function(){if(!a)throw StopIteration;var f=a;a=f.nextSibling;var h;if(f.isPart&&f.childNodes.length==1&&f.firstChild.nodeType==3){h=f.firstChild.nodeValue;f.dirty=f.dirty||h!=f.currentText;f.currentText=h;h=!/[\n\t\r]/.test(f.currentText)}else h=false;if(h){c.push(f);e=false;return f.currentText}else if(isBR(f)){e&&window.opera&&f.parentNode.insertBefore(makePartSpan(""),f);c.push(f);e=true;return"\n"}else{h=!f.nextSibling;b=d(f);removeElement(f);f=g(f,h);for(h=
0;h<f.length;h++){var i=f,j=h,q=f[h],l="\n";if(q.nodeType==3){select.snapshotChanged();q=makePartSpan(q);l=q.currentText;e=false}else{e&&window.opera&&b(makePartSpan(""));e=true}q.dirty=true;c.push(q);b(q);i[j]=l}return f.join("")}},nodes:c}}function k(a){for(;a&&!isBR(a);)a=a.previousSibling;return a}function m(a,d){if(a){if(isBR(a))a=a.nextSibling}else a=d.firstChild;for(;a&&!isBR(a);)a=a.nextSibling;return a}function s(a,d,c,b){function e(j){j=cleanText(a.history.textAfter(j));return b?j.toLowerCase():
j}this.editor=a;this.history=a.history;this.history.commit();this.valid=!!d;this.atOccurrence=false;if(b==undefined)b=typeof d=="string"&&d==d.toLowerCase();var f={node:null,offset:0},h=this;if(c&&typeof c=="object"&&typeof c.character=="number"){a.checkLine(c.line);c={node:c.line,offset:c.character};this.pos={from:c,to:c}}else this.pos=c?{from:select.cursorPos(a.container,true)||f,to:select.cursorPos(a.container,false)||f}:{from:f,to:f};if(typeof d!="string")this.matches=function(j,q,l){if(j){j=
e(q).slice(0,l);var r=j.match(d);for(l=0;r;){var o=j.indexOf(r[0]);l+=o;j=j.slice(o+1);if(o=j.match(d))r=o;else break}}else{j=e(q).slice(l);l=(r=j.match(d))&&l+j.indexOf(r[0])}if(r){h.currentMatch=r;return{from:{node:q,offset:l},to:{node:q,offset:l+r[0].length}}}};else{if(b)d=d.toLowerCase();var i=d.split("\n");this.matches=i.length==1?function(j,q,l){var r=e(q),o=d.length,w;if(j?l>=o&&(w=r.lastIndexOf(d,l-o))!=-1:(w=r.indexOf(d,l))!=-1)return{from:{node:q,offset:w},to:{node:q,offset:w+o}}}:function(j,
q,l){var r=j?i.length-1:0,o=i[r],w=e(q),A=j?w.indexOf(o)+o.length:w.lastIndexOf(o);if(!(j?A>=l||A!=o.length:A<=l||A!=w.length-o.length))for(l=q;;){if(j&&!l)break;l=j?this.history.nodeBefore(l):this.history.nodeAfter(l);if(!j&&!l)break;w=e(l);o=i[j?--r:++r];if(r>0&&r<i.length-1)if(w!=o)break;else continue;r=j?w.lastIndexOf(o):w.indexOf(o)+o.length;if(j?r!=w.length-o.length:r!=o.length)break;return{from:{node:j?l:q,offset:j?r:A},to:{node:j?q:l,offset:j?A:r}}}}}}function n(a){this.options=a;window.indentUnit=
a.indentUnit;var d=this.container=document.body;this.history=new UndoHistory(d,a.undoDepth,a.undoDelay,this);var c=this;if(!n.Parser)throw"No parser loaded.";a.parserConfig&&n.Parser.configure&&n.Parser.configure(a.parserConfig);!a.readOnly&&!internetExplorer&&select.setCursorPos(d,{node:null,offset:0});this.dirty=[];this.importCode(a.content||"");this.history.onChange=a.onChange;if(a.readOnly){if(!a.textWrapping)d.style.whiteSpace="nowrap"}else{if(a.continuousScanning!==false){this.scanner=this.documentScanner(a.passTime);
this.delayScanning()}var b=function(){if(document.body.contentEditable!=undefined&&internetExplorer)document.body.contentEditable="true";else document.designMode="on";if(internetExplorer&&a.height!="dynamic")document.body.style.minHeight=window.frameElement.clientHeight-2*document.body.offsetTop-5+"px";document.documentElement.style.borderWidth="0";if(!a.textWrapping)d.style.whiteSpace="nowrap"};try{b()}catch(e){var f=addEventHandler(document,"focus",function(){f();b()},true)}addEventHandler(document,
"keydown",method(this,"keyDown"));addEventHandler(document,"keypress",method(this,"keyPress"));addEventHandler(document,"keyup",method(this,"keyUp"));var h=function(){c.cursorActivity(false)};addEventHandler(internetExplorer?document.body:window,"mouseup",h);addEventHandler(document.body,"cut",h);gecko&&addEventHandler(window,"pagehide",function(){c.unloaded=true});addEventHandler(document.body,"paste",function(i){h();var j=null;try{var q=i.clipboardData||window.clipboardData;if(q)j=q.getData("Text")}catch(l){}if(j!==
null){i.stop();c.replaceSelection(j);select.scrollToCursor(c.container)}});this.options.autoMatchParens&&addEventHandler(document.body,"click",method(this,"scheduleParenHighlight"))}}var t={P:true,DIV:true,LI:true};s.prototype={findNext:function(){return this.find(false)},findPrevious:function(){return this.find(true)},find:function(a){function d(){var h={node:e,offset:f};c.pos={from:h,to:h};return c.atOccurrence=false}if(!this.valid)return false;var c=this,b=a?this.pos.from:this.pos.to,e=b.node,
f=b.offset;if(e&&!e.parentNode){e=null;f=0}for(;;){if(this.pos=this.matches(a,e,f))return this.atOccurrence=true;if(a){if(!e)return d();e=this.history.nodeBefore(e);f=this.history.textAfter(e).length}else{b=this.history.nodeAfter(e);if(!b){f=this.history.textAfter(e).length;return d()}e=b;f=0}}},select:function(){if(this.atOccurrence){select.setCursorPos(this.editor.container,this.pos.from,this.pos.to);select.scrollToCursor(this.editor.container)}},replace:function(a){if(this.atOccurrence){var d=
this.currentMatch;if(d)a=a.replace(/\\(\d)/,function(c,b){return d[b]});this.pos.to=this.editor.replaceRange(this.pos.from,this.pos.to,a);this.atOccurrence=false}},position:function(){if(this.atOccurrence)return{line:this.pos.from.node,character:this.pos.from.offset}}};n.prototype={importCode:function(a){var d=asEditorLines(a);if(!this.options.incrementalLoading||d.length<1E3){this.history.push(null,null,d);this.history.reset()}else{var c=0,b=this,e=function(){var f=d.slice(c,c+1E3);f.push("");b.history.push(b.history.nodeBefore(null),
null,f);b.history.reset();c+=1E3;c<d.length&&parent.setTimeout(e,1E3)};e()}},getCode:function(){if(!this.container.firstChild)return"";var a=[];select.markSelection();forEach(p(this.container.firstChild),method(a,"push"));select.selectMarked();webkit&&this.container.lastChild.hackBR&&a.pop();webkitLastLineHack(this.container);return cleanText(a.join(""))},checkLine:function(a){if(a===false||!(a==null||a.parentNode==this.container||a.hackBR))throw parent.CodeMirror.InvalidLineHandle;},cursorPosition:function(a){if(a==
null)a=true;return(a=select.cursorPos(this.container,a))?{line:a.node,character:a.offset}:{line:null,character:0}},firstLine:function(){return null},lastLine:function(){var a=this.container.lastChild;if(a)a=k(a);if(a&&a.hackBR)a=k(a.previousSibling);return a},nextLine:function(a){this.checkLine(a);a=m(a,this.container);return!a||a.hackBR?false:a},prevLine:function(a){this.checkLine(a);if(a==null)return false;return k(a.previousSibling)},visibleLineCount:function(){for(var a=this.container.firstChild;a&&
isBR(a);)a=a.nextSibling;if(!a)return false;return Math.floor((window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight)/a.offsetHeight)},selectLines:function(a,d,c,b){this.checkLine(a);a={node:a,offset:d};d=null;if(b!==undefined){this.checkLine(c);d={node:c,offset:b}}select.setCursorPos(this.container,a,d);select.scrollToCursor(this.container)},lineContent:function(a){var d=[];for(a=a?a.nextSibling:this.container.firstChild;a&&!isBR(a);a=a.nextSibling)d.push(nodeText(a));
return cleanText(d.join(""))},setLineContent:function(a,d){this.history.commit();this.replaceRange({node:a,offset:0},{node:a,offset:this.history.textAfter(a).length},d);this.addDirtyNode(a);this.scheduleHighlight()},removeLine:function(a){for(var d=a?a.nextSibling:this.container.firstChild;d;){var c=d.nextSibling;removeElement(d);if(isBR(d))break;d=c}this.addDirtyNode(a);this.scheduleHighlight()},insertIntoLine:function(a,d,c){var b=null;if(d=="end")b=m(a,this.container);else for(var e=a?a.nextSibling:
this.container.firstChild;e;e=e.nextSibling){if(d==0){b=e;break}var f=nodeText(e);if(f.length>d){b=e.nextSibling;c=f.slice(0,d)+c+f.slice(d);removeElement(e);break}d-=f.length}d=asEditorLines(c);for(c=0;c<d.length;c++){c>0&&this.container.insertBefore(document.createElement("BR"),b);this.container.insertBefore(makePartSpan(d[c]),b)}this.addDirtyNode(a);this.scheduleHighlight()},selectedText:function(){var a=this.history;a.commit();var d=select.cursorPos(this.container,true),c=select.cursorPos(this.container,
false);if(!d||!c)return"";if(d.node==c.node)return a.textAfter(d.node).slice(d.offset,c.offset);var b=[a.textAfter(d.node).slice(d.offset)];for(d=a.nodeAfter(d.node);d!=c.node;d=a.nodeAfter(d))b.push(a.textAfter(d));b.push(a.textAfter(c.node).slice(0,c.offset));return cleanText(b.join("\n"))},replaceSelection:function(a){this.history.commit();var d=select.cursorPos(this.container,true),c=select.cursorPos(this.container,false);if(d&&c){c=this.replaceRange(d,c,a);select.setCursorPos(this.container,
c);webkitLastLineHack(this.container)}},cursorCoords:function(a,d){function c(j,q){var l=-(document.body.scrollTop||document.documentElement.scrollTop||0),r=-(document.body.scrollLeft||document.documentElement.scrollLeft||0)+q;forEach([j,d?null:window.frameElement],function(o){for(;o;){r+=o.offsetLeft;l+=o.offsetTop;o=o.offsetParent}});return{x:r,y:l,yBot:l+j.offsetHeight}}function b(j,q){var l=document.createElement("SPAN");l.appendChild(document.createTextNode(j));try{return q(l)}finally{l.parentNode&&
l.parentNode.removeChild(l)}}var e=select.cursorPos(this.container,a);if(!e)return null;for(var f=e.offset,h=e.node,i=this;f;){h=h?h.nextSibling:this.container.firstChild;e=nodeText(h);if(f<e.length)return b(e.substr(0,f),function(j){j.style.position="absolute";j.style.visibility="hidden";j.className=h.className;i.container.appendChild(j);return c(h,j.offsetWidth)});f-=e.length}return h&&isSpan(h)?c(h,h.offsetWidth):h&&h.nextSibling&&isSpan(h.nextSibling)?c(h.nextSibling,0):b("\u200b",function(j){h?
h.parentNode.insertBefore(j,h.nextSibling):i.container.insertBefore(j,i.container.firstChild);return c(j,0)})},reroutePasteEvent:function(){if(!(this.capturingPaste||window.opera||gecko&&gecko>=20101026)){this.capturingPaste=true;var a=window.frameElement.CodeMirror.textareaHack,d=this.cursorCoords(true,true);a.style.top=d.y+"px";if(internetExplorer)if(d=select.getBookmark(this.container))this.selectionSnapshot=d;parent.focus();a.value="";a.focus();var c=this;parent.setTimeout(function(){c.capturingPaste=
false;window.focus();c.selectionSnapshot&&window.select.setBookmark(c.container,c.selectionSnapshot);var b=a.value;if(b){c.replaceSelection(b);select.scrollToCursor(c.container)}},10)}},replaceRange:function(a,d,c){c=asEditorLines(c);c[0]=this.history.textAfter(a.node).slice(0,a.offset)+c[0];var b=c[c.length-1];c[c.length-1]=b+this.history.textAfter(d.node).slice(d.offset);d=this.history.nodeAfter(d.node);this.history.push(a.node,d,c);return{node:this.history.nodeBefore(d),offset:b.length}},getSearchCursor:function(a,
d,c){return new s(this,a,d,c)},reindent:function(){this.container.firstChild&&this.indentRegion(null,this.container.lastChild)},reindentSelection:function(a){if(select.somethingSelected()){var d=select.selectionTopNode(this.container,true),c=select.selectionTopNode(this.container,false);d===false||c===false||this.indentRegion(d,c,a)}else this.indentAtCursor(a)},grabKeys:function(a,d){this.frozen=a;this.keyFilter=d},ungrabKeys:function(){this.frozen="leave"},setParser:function(a,d){n.Parser=window[a];
(d=d||this.options.parserConfig)&&n.Parser.configure&&n.Parser.configure(d);if(this.container.firstChild){forEach(this.container.childNodes,function(c){if(c.nodeType!=3)c.dirty=true});this.addDirtyNode(this.firstChild);this.scheduleHighlight()}},keyDown:function(a){if(this.frozen=="leave")this.keyFilter=this.frozen=null;if(this.frozen&&(!this.keyFilter||this.keyFilter(a.keyCode,a))){a.stop();this.frozen(a)}else{var d=a.keyCode;this.delayScanning();this.options.autoMatchParens&&this.scheduleParenHighlight();
if(d==13){if(a.ctrlKey&&!a.altKey)this.reparseBuffer();else{select.insertNewlineAtCursor();d=this.options.enterMode;if(d!="flat")this.indentAtCursor(d=="keep"?"keep":undefined);select.scrollToCursor(this.container)}a.stop()}else if(d==9&&this.options.tabMode!="default"&&!a.ctrlKey){this.handleTab(!a.shiftKey);a.stop()}else if(d==32&&a.shiftKey&&this.options.tabMode=="default"){this.handleTab(true);a.stop()}else if(d==36&&!a.shiftKey&&!a.ctrlKey)this.home()&&a.stop();else if(d==35&&!a.shiftKey&&!a.ctrlKey)this.end()&&
a.stop();else if(d==33&&!a.shiftKey&&!a.ctrlKey&&!gecko)this.pageUp()&&a.stop();else if(d==34&&!a.shiftKey&&!a.ctrlKey&&!gecko)this.pageDown()&&a.stop();else if((d==219||d==221)&&a.ctrlKey&&!a.altKey){this.highlightParens(a.shiftKey,true);a.stop()}else if(a.metaKey&&!a.shiftKey&&(d==37||d==39)){var c=select.selectionTopNode(this.container);if(!(c===false||!this.container.firstChild)){if(d==37)select.focusAfterNode(k(c),this.container);else{d=m(c,this.container);select.focusAfterNode(d?d.previousSibling:
this.container.lastChild,this.container)}a.stop()}}else if((a.ctrlKey||a.metaKey)&&!a.altKey)if(a.shiftKey&&d==90||d==89){select.scrollToNode(this.history.redo());a.stop()}else if(d==90||safari&&d==8){select.scrollToNode(this.history.undo());a.stop()}else if(d==83&&this.options.saveFunction){this.options.saveFunction();a.stop()}else d==86&&!mac&&this.reroutePasteEvent()}},keyPress:function(a){var d=this.options.electricChars&&n.Parser.electricChars,c=this;if(this.frozen&&(!this.keyFilter||this.keyFilter(a.keyCode||
a.code,a))||a.code==13||a.code==9&&this.options.tabMode!="default"||a.code==32&&a.shiftKey&&this.options.tabMode=="default")a.stop();else if(mac&&(a.ctrlKey||a.metaKey)&&a.character=="v")this.reroutePasteEvent();else if(d&&d.indexOf(a.character)!=-1)parent.setTimeout(function(){c.indentAtCursor(null)},0);else if(brokenOpera)if(a.code==8){var b=select.selectionTopNode(this.container);c=this;var e=b?b.nextSibling:this.container.firstChild;b!==false&&e&&isBR(e)&&parent.setTimeout(function(){select.selectionTopNode(c.container)==
e&&select.focusAfterNode(e.previousSibling,c.container)},20)}else{if(a.code==46){b=select.selectionTopNode(this.container);c=this;b&&isBR(b)&&parent.setTimeout(function(){select.selectionTopNode(c.container)!=b&&select.focusAfterNode(b,c.container)},20)}}else if(slowWebkit){e=(b=select.selectionTopNode(this.container))?b.nextSibling:this.container.firstChild;if(b&&e&&isBR(e)&&!isBR(b)){var f=document.createTextNode("\u200b");this.container.insertBefore(f,e);parent.setTimeout(function(){if(f.nodeValue==
"\u200b")removeElement(f);else f.nodeValue=f.nodeValue.replace("\u200b","")},20)}}webkit&&!this.options.textWrapping&&setTimeout(function(){var h=select.selectionTopNode(c.container,true);h&&h.nodeType==3&&h.previousSibling&&isBR(h.previousSibling)&&h.nextSibling&&isBR(h.nextSibling)&&h.parentNode.replaceChild(document.createElement("BR"),h.previousSibling)},50)},keyUp:function(a){this.cursorActivity(a.keyCode>=16&&a.keyCode<=18||a.keyCode>=33&&a.keyCode<=40)},indentLineAfter:function(a,d){function c(q){q=
q?q.nextSibling:b.container.firstChild;if(!q||!hasClass(q,"whitespace"))return null;return q}var b=this,e=c(a),f=0,h=e?e.currentText.length:0,i=e?e.nextSibling:a?a.nextSibling:this.container.firstChild;if(d=="keep"){if(a){var j=c(k(a.previousSibling));if(j)f=j.currentText.length}}else{j=a&&i&&i.currentText?i.currentText:"";if(d!=null&&this.options.tabMode=="shift")f=d?h+indentUnit:Math.max(0,h-indentUnit);else if(a)f=a.indentation(j,h,d,i);else if(n.Parser.firstIndentation)f=n.Parser.firstIndentation(j,
h,d,i)}h=f-h;if(h<0)if(f==0){if(i)select.snapshotMove(e.firstChild,i.firstChild||i,0);removeElement(e);e=null}else{select.snapshotMove(e.firstChild,e.firstChild,h,true);e.currentText=makeWhiteSpace(f);e.firstChild.nodeValue=e.currentText}else if(h>0)if(e){e.currentText=makeWhiteSpace(f);e.firstChild.nodeValue=e.currentText;select.snapshotMove(e.firstChild,e.firstChild,h,true)}else{e=makePartSpan(makeWhiteSpace(f));e.className="whitespace";a?insertAfter(e,a):this.container.insertBefore(e,this.container.firstChild);
select.snapshotMove(i&&(i.firstChild||i),e.firstChild,f,false,true)}else e&&select.snapshotMove(e.firstChild,e.firstChild,f,false);h!=0&&this.addDirtyNode(a)},highlightAtCursor:function(){var a=select.selectionTopNode(this.container,true),d=select.selectionTopNode(this.container,false);if(a===false||d===false)return false;select.markSelection();if(this.highlight(a,m(d,this.container),true,20)===false)return false;select.selectMarked();return true},handleTab:function(a){this.options.tabMode=="spaces"?
select.insertTabAtCursor():this.reindentSelection(a)},home:function(){var a=select.selectionTopNode(this.container,true),d=a;if(a===false||!(!a||a.isPart||isBR(a))||!this.container.firstChild)return false;for(;a&&!isBR(a);)a=a.previousSibling;var c=a?a.nextSibling:this.container.firstChild;c&&c!=d&&c.isPart&&hasClass(c,"whitespace")?select.focusAfterNode(c,this.container):select.focusAfterNode(a,this.container);select.scrollToCursor(this.container);return true},end:function(){var a=select.selectionTopNode(this.container,
true);if(a===false)return false;a=m(a,this.container);if(!a)return false;select.focusAfterNode(a.previousSibling,this.container);select.scrollToCursor(this.container);return true},pageUp:function(){var a=this.cursorPosition().line,d=this.visibleLineCount();if(a===false||d===false)return false;d-=2;for(var c=0;c<d;c++){a=this.prevLine(a);if(a===false)break}if(c==0)return false;select.setCursorPos(this.container,{node:a,offset:0});select.scrollToCursor(this.container);return true},pageDown:function(){var a=
this.cursorPosition().line,d=this.visibleLineCount();if(a===false||d===false)return false;d-=2;for(var c=0;c<d;c++){var b=this.nextLine(a);if(b===false)break;a=b}if(c==0)return false;select.setCursorPos(this.container,{node:a,offset:0});select.scrollToCursor(this.container);return true},scheduleParenHighlight:function(){this.parenEvent&&parent.clearTimeout(this.parenEvent);var a=this;this.parenEvent=parent.setTimeout(function(){a.highlightParens()},300)},highlightParens:function(a,d){function c(w,
A){if(w)if(i)if(i.call)i(w,A);else w.className+=" "+i[A?0:1];else{w.style.fontWeight="bold";w.style.color=A?"#8F8":"#F88"}}function b(w){if(w)if(i&&!i.call)removeClass(removeClass(w,i[0]),i[1]);else if(h.options.unmarkParen)h.options.unmarkParen(w);else{w.style.fontWeight="";w.style.color=""}}function e(w){if(w.currentText)return(w=w.currentText.match(/^[\s\u00a0]*([\(\)\[\]{}])[\s\u00a0]*$/))&&w[1]}function f(){for(var w=[],A,v=true,x=q;x;x=r?x.nextSibling:x.previousSibling)if(x.className==l&&isSpan(x)&&
(A=e(x))){if(/[\(\[\{]/.test(A)==r)w.push(A);else if(w.length){if(w.pop()!=matching[A])v=false}else v=false;if(!w.length)break}else if(x.dirty||!isSpan(x)&&!isBR(x))return{node:x,status:"dirty"};return{node:x,status:x&&v}}var h=this,i=this.options.markParen;if(typeof i=="string")i=[i,i];if(!d&&h.highlighted){b(h.highlighted[0]);b(h.highlighted[1])}if(!(!window||!window.parent||!window.select)){this.parenEvent&&parent.clearTimeout(this.parenEvent);this.parenEvent=null;var j,q=select.selectionTopNode(this.container,
true);if(q&&this.highlightAtCursor())if((q=select.selectionTopNode(this.container,true))&&((j=e(q))||(q=q.nextSibling)&&(j=e(q))))for(var l=q.className,r=/[\(\[\{]/.test(j);;){var o=f();if(o.status=="dirty"){this.highlight(o.node,m(o.node));o.node.dirty=false}else{c(q,o.status);c(o.node,o.status);if(d)parent.setTimeout(function(){b(q);b(o.node)},500);else h.highlighted=[q,o.node];a&&o.node&&select.focusAfterNode(o.node.previousSibling,this.container);break}}}},indentAtCursor:function(a){if(this.container.firstChild)if(this.highlightAtCursor()){var d=
select.selectionTopNode(this.container,false);if(d!==false){select.markSelection();this.indentLineAfter(k(d),a);select.selectMarked()}}},indentRegion:function(a,d,c){var b=a=k(a),e=a&&k(a.previousSibling);isBR(d)||(d=m(d,this.container));this.addDirtyNode(a);do{var f=m(b,this.container);b&&this.highlight(e,f,true);this.indentLineAfter(b,c);e=b;b=f}while(b!=d);select.setCursorPos(this.container,{node:a,offset:0},{node:d,offset:0})},cursorActivity:function(a){if(this.unloaded){window.document.designMode=
"off";window.document.designMode="on";this.unloaded=false}if(internetExplorer){this.container.createTextRange().execCommand("unlink");clearTimeout(this.saveSelectionSnapshot);var d=this;this.saveSelectionSnapshot=setTimeout(function(){var e=select.getBookmark(d.container);if(e)d.selectionSnapshot=e},200)}var c=this.options.onCursorActivity;if(!a||c){var b=select.selectionTopNode(this.container,false);if(!(b===false||!this.container.firstChild)){b=b||this.container.firstChild;c&&c(b);if(!a){this.scheduleHighlight();
this.addDirtyNode(b)}}}},reparseBuffer:function(){forEach(this.container.childNodes,function(a){a.dirty=true});this.container.firstChild&&this.addDirtyNode(this.container.firstChild)},addDirtyNode:function(a){if(a=a||this.container.firstChild){for(var d=0;d<this.dirty.length;d++)if(this.dirty[d]==a)return;if(a.nodeType!=3)a.dirty=true;this.dirty.push(a)}},allClean:function(){return!this.dirty.length},scheduleHighlight:function(){var a=this;parent.clearTimeout(this.highlightTimeout);this.highlightTimeout=
parent.setTimeout(function(){a.highlightDirty()},this.options.passDelay)},getDirtyNode:function(){for(;this.dirty.length>0;){var a=this.dirty.pop();try{for(;a&&a.parentNode!=this.container;)a=a.parentNode;if(a&&(a.dirty||a.nodeType==3))return a}catch(d){}}return null},highlightDirty:function(a){if(!window||!window.parent||!window.select)return false;this.options.readOnly||select.markSelection();for(var d,c=a?null:(new Date).getTime()+this.options.passTime;((new Date).getTime()<c||a)&&(d=this.getDirtyNode());){var b=
this.highlight(d,c);b&&b.node&&b.dirty&&this.addDirtyNode(b.node.nextSibling)}this.options.readOnly||select.selectMarked();d&&this.scheduleHighlight();return this.dirty.length==0},documentScanner:function(a){var d=this,c=null;return function(){if(!(!window||!window.parent||!window.select)){if(c&&c.parentNode!=d.container)c=null;select.markSelection();var b=d.highlight(c,(new Date).getTime()+a,true);select.selectMarked();b=b?b.node&&b.node.nextSibling:null;c=c==b?null:b;d.delayScanning()}}},delayScanning:function(){if(this.scanner){parent.clearTimeout(this.documentScan);
this.documentScan=parent.setTimeout(this.scanner,this.options.continuousScanning)}},highlight:function(a,d,c,b){function e(v){if(v){var x=v.oldNextSibling;if(o||x===undefined||v.nextSibling!=x)h.history.touch(v);v.oldNextSibling=v.nextSibling}else{x=h.container.oldFirstChild;if(o||x===undefined||h.container.firstChild!=x)h.history.touch(null);h.container.oldFirstChild=h.container.firstChild}}var f=this.container,h=this,i=this.options.activeTokens,j=typeof d=="number"?d:null;if(!f.firstChild)return false;
for(;a&&(!a.parserFromHere||a.dirty);){if(b!=null&&isBR(a)&&--b<0)return false;a=a.previousSibling}if(a&&!a.nextSibling)return false;var q=p(a?a.nextSibling:f.firstChild);b=stringStream(q);var l=a?a.parserFromHere(b):n.Parser.make(b),r={current:null,get:function(){if(!this.current)this.current=q.nodes.shift();return this.current},next:function(){this.current=null},remove:function(){f.removeChild(this.get());this.current=null},getNonEmpty:function(){for(var v=this.get();v&&isSpan(v)&&v.currentText==
"";)if(window.opera&&(v.previousSibling==null||isBR(v.previousSibling))&&(v.nextSibling==null||isBR(v.nextSibling))){this.next();v=this.get()}else{var x=v;this.remove();v=this.get();select.snapshotMove(x.firstChild,v&&(v.firstChild||v),0)}return v}},o=false,w=true,A=0;forEach(l,function(v){var x=r.getNonEmpty();if(v.value=="\n"){if(!isBR(x))throw"Parser out of sync. Expected BR.";if(x.dirty||!x.indentation)o=true;e(a);a=x;x.parserFromHere=l.copy();x.indentation=v.indentation||alwaysZero;x.dirty=false;
if(j==null&&x==d)throw StopIteration;if(j!=null&&(new Date).getTime()>=j||!o&&!w&&A>1&&!c)throw StopIteration;w=o;o=false;A=0;r.next()}else{if(!isSpan(x))throw"Parser out of sync. Expected SPAN.";if(x.dirty)o=true;A++;if(!x.reduced&&x.currentText==v.value&&x.className==v.style){i&&x.dirty&&i(x,v,h);x.dirty=false;r.next()}else{o=true;var H=makePartSpan(v.value);H.className=v.style;f.insertBefore(H,x);i&&i(H,v,h);v=v.value.length;for(var K=0;v>0;){x=r.get();var L=x.currentText.length;select.snapshotReplaceNode(x.firstChild,
H.firstChild,v,K);if(L>v){x=x;x.currentText=x.currentText.substring(v);x.reduced=true;v=0}else{v-=L;K+=L;r.remove()}}}}});e(a);webkitLastLineHack(this.container);return{node:r.getNonEmpty(),dirty:o}}};return n}();addEventHandler(window,"load",function(){var g=window.frameElement.CodeMirror;g.editor=new Editor(g.options);parent.setTimeout(method(g,"init"),0)});function tokenizer(g,p){function k(s){return s!="\n"&&/^[\s\u00a0]*$/.test(s)}var m={state:p,take:function(s){if(typeof s=="string")s={style:s,type:s};s.content=(s.content||"")+g.get();/\n$/.test(s.content)||g.nextWhile(k);s.value=s.content+g.get();return s},next:function(){if(!g.more())throw StopIteration;var s;if(g.equals("\n")){g.next();return this.take("whitespace")}if(g.applies(k))s="whitespace";else for(;!s;)s=this.state(g,function(n){m.state=n});return this.take(s)}};return m};var tokenizeJavaScript=function(){function g(a,d){for(var c=false;!a.endOfLine();){var b=a.next();if(b==d&&!c)return false;c=!c&&b=="\\"}return c}function p(a,d){return function(c,b){var e=a,f=k(a,d,c,function(i){e=i}),h=f.type=="operator"||f.type=="keyword c"||f.type.match(/^[\[{}\(,;:]$/);if(h!=d||e!=a)b(p(e,h));return f}}function k(a,d,c,b){function e(){c.nextWhileMatches(t);var q=c.get(),l=m.hasOwnProperty(q)&&m.propertyIsEnumerable(q)&&m[q];return l?{type:l.type,style:l.style,content:q}:{type:"variable",
style:"js-variable",content:q}}function f(q){var l="/*";for(q=q=="*";;){if(c.endOfLine())break;var r=c.next();if(r=="/"&&q){l=null;break}q=r=="*"}b(l);return{type:"comment",style:"js-comment"}}function h(){c.nextWhileMatches(s);return{type:"operator",style:"js-operator"}}function i(q){var l=g(c,q);b(l?q:null);return{type:"string",style:"js-string"}}if(a=='"'||a=="'")return i(a);var j=c.next();if(a=="/*")return f(j);else if(j=='"'||j=="'")return i(j);else if(/[\[\]{}\(\),;\:\.]/.test(j))return{type:j,
style:"js-punctuation"};else if(j=="0"&&(c.equals("x")||c.equals("X"))){c.next();c.nextWhileMatches(n);return{type:"number",style:"js-atom"}}else if(/[0-9]/.test(j)){c.nextWhileMatches(/[0-9]/);if(c.equals(".")){c.next();c.nextWhileMatches(/[0-9]/)}if(c.equals("e")||c.equals("E")){c.next();c.equals("-")&&c.next();c.nextWhileMatches(/[0-9]/)}return{type:"number",style:"js-atom"}}else if(j=="/")if(c.equals("*")){c.next();return f(j)}else if(c.equals("/")){g(c,null);return{type:"comment",style:"js-comment"}}else{if(d){g(c,
"/");c.nextWhileMatches(/[gimy]/);a={type:"regexp",style:"js-string"}}else a=h();return a}else return s.test(j)?h():e()}var m=function(){function a(h,i){return{type:h,style:"js-"+i}}var d=a("keyword a","keyword"),c=a("keyword b","keyword"),b=a("keyword c","keyword"),e=a("operator","keyword"),f=a("atom","atom");return{"if":d,"while":d,"with":d,"else":c,"do":c,"try":c,"finally":c,"return":b,"break":b,"continue":b,"new":b,"delete":b,"throw":b,"in":e,"typeof":e,"instanceof":e,"var":a("var","keyword"),
"function":a("function","keyword"),"catch":a("catch","keyword"),"for":a("for","keyword"),"switch":a("switch","keyword"),"case":a("case","keyword"),"default":a("default","keyword"),"true":f,"false":f,"null":f,undefined:f,NaN:f,Infinity:f}}(),s=/[+\-*&%=<>!?|]/,n=/[0-9A-Fa-f]/,t=/[\w\$_]/;return function(a,d){return tokenizer(a,d||p(false,true))}}();var JSParser=Editor.Parser=function(){function g(s,n,t,a,d,c){this.indented=s;this.column=n;this.type=t;if(a!=null)this.align=a;this.prev=d;this.info=c}function p(s){return function(n){var t=n&&n.charAt(0),a=s.type,d=t==a;return a=="vardef"?s.indented+4:a=="form"&&t=="{"?s.indented:a=="stat"||a=="form"?s.indented+indentUnit:s.info=="switch"&&!d?s.indented+(/^(?:case|default)\b/.test(n)?indentUnit:2*indentUnit):s.align?s.column-(d?1:0):s.indented+(d?0:indentUnit)}}var k={atom:true,number:true,variable:true,
string:true,regexp:true},m=false;return{make:function(s,n){function t(u){for(var B=u.length-1;B>=0;B--)y.push(u[B])}function a(){t(arguments);S=true}function d(){t(arguments);S=false}function c(){C={prev:C,vars:{"this":true,arguments:true}}}function b(){C=C.prev}function e(u){if(C){Q="js-variabledef";C.vars[u]=true}}function f(u,B){var P=function(){E=new g(O,I,u,null,E,B)};P.lex=true;return P}function h(){if(E.type==")")O=E.indented;E=E.prev}function i(u){return function(B){if(B==u)a();else u==";"?
d():a(arguments.callee)}}function j(){return d(l,j)}function q(){return d(r,q)}function l(u){if(u=="var")a(f("vardef"),K,i(";"),h);else if(u=="keyword a")a(f("form"),r,l,h);else if(u=="keyword b")a(f("form"),l,h);else if(u=="{")a(f("}"),H,h);else if(u==";")a();else if(u=="function")a(z);else if(u=="for")a(f("form"),i("("),f(")"),F,i(")"),h,l,h);else if(u=="variable")a(f("stat"),w);else if(u=="switch")a(f("form"),r,f("}","switch"),i("{"),H,h,h);else if(u=="case")a(r,i(":"));else if(u=="default")a(i(":"));
else u=="catch"?a(f("form"),c,i("("),M,i(")"),l,h,b):d(f("stat"),r,i(";"),h)}function r(u){if(k.hasOwnProperty(u))a(o);else if(u=="function")a(z);else if(u=="keyword c")a(r);else if(u=="(")a(f(")"),r,i(")"),h,o);else if(u=="operator")a(r);else if(u=="[")a(f("]"),x(r,"]"),h,o);else u=="{"?a(f("}"),x(v,"}"),h,o):a()}function o(u,B){if(u=="operator"&&/\+\+|--/.test(B))a(o);else if(u=="operator")a(r);else if(u==";")d();else if(u=="(")a(f(")"),x(r,")"),h,o);else if(u==".")a(A,o);else u=="["&&a(f("]"),
r,i("]"),h,o)}function w(u){u==":"?a(h,l):d(o,i(";"),h)}function A(u){if(u=="variable"){Q="js-property";a()}}function v(u){if(u=="variable")Q="js-property";k.hasOwnProperty(u)&&a(i(":"),r)}function x(u,B){function P(R){if(R==",")a(u,P);else R==B?a():a(i(B))}return function(R){R==B?a():d(u,P)}}function H(u){u=="}"?a():d(l,H)}function K(u,B){if(u=="variable"){e(B);a(L)}else a()}function L(u,B){if(B=="=")a(r,L);else u==","&&a(K)}function F(u){if(u=="var")a(K,G);else if(u==";")d(G);else u=="variable"?
a(N):d(G)}function N(u,B){B=="in"?a(r):a(o,G)}function G(u,B){if(u==";")a(D);else B=="in"?a(r):a(r,i(";"),D)}function D(u){u==")"?d():a(r)}function z(u,B){if(u=="variable"){e(B);a(z)}else u=="("&&a(c,x(M,")"),l,b)}function M(u,B){if(u=="variable"){e(B);a()}}var J=tokenizeJavaScript(s),y=[m?q:j],C=null,E=new g((n||0)-indentUnit,0,"block",false),I=0,O=0,S,Q,T={next:function(){for(;y[y.length-1].lex;)y.pop()();var u=J.next();if(u.type=="whitespace"&&I==0)O=u.value.length;I+=u.value.length;if(u.content==
"\n"){O=I=0;if(!("align"in E))E.align=false;u.indentation=p(E)}if(u.type=="whitespace"||u.type=="comment")return u;if(!("align"in E))E.align=true;for(;;){S=Q=false;y.pop()(u.type,u.content);if(S){if(Q)u.style=Q;else{var B;if(B=u.type=="variable")a:{for(B=C;B;){if(B.vars[u.content]){B=true;break a}B=B.prev}B=false}if(B)u.style="js-localvariable"}return u}}},copy:function(){var u=C,B=E,P=y.concat([]),R=J.state;return function(U){C=u;E=B;y=P.concat([]);I=O=0;J=tokenizeJavaScript(U,R);return T}}};h.lex=
true;return T},electricChars:"{}:",configure:function(s){if(s.json!=null)m=s.json}}}();var XMLParser=Editor.Parser=function(){var g={autoSelfClosers:{br:true,img:true,hr:true,link:true,input:true,meta:true,col:true,frame:true,base:true,area:true},doNotIndent:{pre:true,"!cdata":true}},p={autoSelfClosers:{},doNotIndent:{"!cdata":true}},k=g,m=false,s=function(){function n(c,b){var e=c.next();if(e=="<")if(c.equals("!")){c.next();if(c.equals("["))if(c.lookAhead("[CDATA[",true)){b(d("xml-cdata","]]\>"));return null}else return"xml-text";else if(c.lookAhead("--",true)){b(d("xml-comment","--\>"));
return null}else if(c.lookAhead("DOCTYPE",true)){c.nextWhileMatches(/[\w\._\-]/);b(d("xml-doctype",">"));return"xml-doctype"}else return"xml-text"}else if(c.equals("?")){c.next();c.nextWhileMatches(/[\w\._\-]/);b(d("xml-processing","?>"));return"xml-processing"}else{c.equals("/")&&c.next();b(t);return"xml-punctuation"}else if(e=="&"){for(;!c.endOfLine();)if(c.next()==";")break;return"xml-entity"}else{c.nextWhileMatches(/[^&<\n]/);return"xml-text"}}function t(c,b){var e=c.next();if(e==">"){b(n);return"xml-punctuation"}else if(/[?\/]/.test(e)&&
c.equals(">")){c.next();b(n);return"xml-punctuation"}else if(e=="=")return"xml-punctuation";else if(/[\'\"]/.test(e)){b(a(e));return null}else{c.nextWhileMatches(/[^\s\u00a0=<>\"\'\/?]/);return"xml-name"}}function a(c){return function(b,e){for(;!b.endOfLine();)if(b.next()==c){e(t);break}return"xml-attribute"}}function d(c,b){return function(e,f){for(;!e.endOfLine();){if(e.lookAhead(b,true)){f(n);break}e.next()}return c}}return function(c,b){return tokenizer(c,b||n)}}();return{make:function(n){function t(D){for(var z=
D.length-1;z>=0;z--)x.push(D[z])}function a(){t(arguments);N=true}function d(){t(arguments);N=false}function c(){v.style+=" xml-error"}function b(D){return function(z,M){if(M==D)a();else{c();a(arguments.callee)}}}function e(D,z){var M=k.doNotIndent.hasOwnProperty(D)||F&&F.noIndent;F={prev:F,name:D,indent:K,startOfLine:z,noIndent:M}}function f(D){return function(z,M){var J=D;if(J&&J.noIndent)return M;if(m&&/<!\[CDATA\[/.test(z))return 0;if(J&&/^<\//.test(z))J=J.prev;for(;J&&!J.startOfLine;)J=J.prev;
return J?J.indent+indentUnit:0}}function h(){return d(i,h)}function i(D,z){if(z=="<")a(j,r,l(H==1));else if(z=="</")a(q,b(">"));else{if(D=="xml-cdata"){if(!F||F.name!="!cdata")e("!cdata");if(/\]\]>$/.test(z))F=F.prev}else G.hasOwnProperty(D)||c();a()}}function j(D,z){if(D=="xml-name"){L=z.toLowerCase();v.style="xml-tagname";a()}else{L=null;d()}}function q(D,z){if(D=="xml-name"){v.style="xml-tagname";if(F&&z.toLowerCase()==F.name)F=F.prev;else c()}a()}function l(D){return function(z,M){if(M=="/>"||
M==">"&&k.autoSelfClosers.hasOwnProperty(L))a();else if(M==">"){e(L,D);a()}else{c();a(arguments.callee)}}}function r(D){if(D=="xml-name"){v.style="xml-attname";a(o,r)}else d()}function o(D,z){if(z=="=")a(w);else z==">"||z=="/>"?d(l):d()}function w(D){D=="xml-attribute"?a(w):d()}var A=s(n),v,x=[h],H=0,K=0,L=null,F=null,N,G={"xml-text":true,"xml-entity":true,"xml-comment":true,"xml-processing":true,"xml-doctype":true};return{indentation:function(){return K},next:function(){v=A.next();if(v.style=="whitespace"&&
H==0)K=v.value.length;else H++;if(v.content=="\n"){K=H=0;v.indentation=f(F)}if(v.style=="whitespace"||v.type=="xml-comment")return v;for(;;){N=false;x.pop()(v.style,v.content);if(N)return v}},copy:function(){var D=x.concat([]),z=A.state,M=F,J=this;return function(y){x=D.concat([]);H=K=0;F=M;A=s(y,z);return J}}}},electricChars:"/",configure:function(n){if(n.useHTMLKludges!=null)k=n.useHTMLKludges?g:p;if(n.alignCDATA)m=n.alignCDATA}}}();var CSSParser=Editor.Parser=function(){function g(k,m,s){return function(n){return!k||/^\}/.test(n)?s:m?s+indentUnit*2:s+indentUnit}}var p=function(){function k(t,a){var d=t.next();if(d=="@"){t.nextWhileMatches(/\w/);return"css-at"}else if(d=="/"&&t.equals("*")){a(m);return null}else if(d=="<"&&t.equals("!")){a(s);return null}else if(d=="=")return"css-compare";else if(t.equals("=")&&(d=="~"||d=="|")){t.next();return"css-compare"}else if(d=='"'||d=="'"){a(n(d));return null}else if(d=="#"){t.nextWhileMatches(/\w/);
return"css-hash"}else if(d=="!"){t.nextWhileMatches(/[ \t]/);t.nextWhileMatches(/\w/);return"css-important"}else if(/\d/.test(d)){t.nextWhileMatches(/[\w.%]/);return"css-unit"}else if(/[,.+>*\/]/.test(d))return"css-select-op";else if(/[;{}:\[\]]/.test(d))return"css-punctuation";else{t.nextWhileMatches(/[\w\\\-_]/);return"css-identifier"}}function m(t,a){for(var d=false;!t.endOfLine();){var c=t.next();if(d&&c=="/"){a(k);break}d=c=="*"}return"css-comment"}function s(t,a){for(var d=0;!t.endOfLine();){var c=
t.next();if(d>=2&&c==">"){a(k);break}d=c=="-"?d+1:0}return"css-comment"}function n(t){return function(a,d){for(var c=false;!a.endOfLine();){var b=a.next();if(b==t&&!c)break;c=!c&&b=="\\"}c||d(k);return"css-string"}}return function(t,a){return tokenizer(t,a||k)}}();return{make:function(k,m){m=m||0;var s=p(k),n=false,t=false,a=false,d={next:function(){var c=s.next(),b=c.style,e=c.content;if(b=="css-hash")b=c.style=t?"css-colorcode":"css-identifier";if(b=="css-identifier")if(t)c.style="css-value";else if(!n&&
!a)c.style="css-selector";if(e=="\n")c.indentation=g(n,t,m);if(e=="{"&&a=="@media")a=false;else if(e=="{")n=true;else if(e=="}")n=t=a=false;else if(e==";")t=a=false;else if(n&&b!="css-comment"&&b!="whitespace")t=true;else if(!n&&b=="css-at")a=e;return c},copy:function(){var c=n,b=t,e=s.state;return function(f){s=p(f,e);n=c;t=b;return d}}};return d},electricChars:"}"}}();var HTMLMixedParser=Editor.Parser=function(){function g(){var k=["XMLParser"],m;for(m in p)k.push(p[m]);for(var s in k)if(!window[k[s]])throw Error(k[s]+" parser must be loaded for HTML mixed mode to work.");XMLParser.configure({useHTMLKludges:true})}var p={script:"JSParser",style:"CSSParser"};return{make:function(k){function m(){var c=n.next();if(c.content=="<")a=true;else if(c.style=="xml-tagname"&&a===true)a=c.content.toLowerCase();else if(c.content==">"){if(p[a])d.next=s(window[p[a]],"</"+a);
a=false}return c}function s(c,b){var e=n.indentation();t=c.make(k,e+indentUnit);return function(){if(k.lookAhead(b,false,false,true)){t=null;d.next=m;return m()}var f=t.next(),h=f.value.lastIndexOf("<"),i=Math.min(f.value.length-h,b.length);if(h!=-1&&f.value.slice(h,h+i).toLowerCase()==b.slice(0,i)&&k.lookAhead(b.slice(i),false,false,true)){k.push(f.value.slice(h));f.value=f.value.slice(0,h)}if(f.indentation){var j=f.indentation;f.indentation=function(q){return q=="</"?e:j(q)}}return f}}g();var n=
XMLParser.make(k),t=null,a=false,d={next:m,copy:function(){var c=n.copy(),b=t&&t.copy(),e=d.next,f=a;return function(h){k=h;n=c(h);t=b&&b(h);d.next=e;a=f;return d}}};return d},electricChars:"{}/:",configure:function(k){if(k.triggers)p=k.triggers}}}();var DummyParser=Editor.Parser=function(){function g(p){for(;!p.endOfLine();)p.next();return"text"}return{make:function(p){function k(n){return function(){return n}}p=tokenizer(p,g);var m=0,s={next:function(){var n=p.next();if(n.type=="whitespace")if(n.value=="\n")n.indentation=k(m);else m=n.value.length;return n},copy:function(){var n=m;return function(t){m=n;p=tokenizer(t,g);return s}}};return s}}}();var LiquidParser=Editor.Parser=function(){var g={autoSelfClosers:{br:true,img:true,hr:true,link:true,input:true,meta:true,col:true,frame:true,base:true,area:true},doNotIndent:{pre:true,"!cdata":true}},p={autoSelfClosers:{},doNotIndent:{"!cdata":true}},k=g,m=false,s=/[\'\"]/,n=/[\w\_]/,t=/[\.\|\=\:]/,a={};["in"].forEach(function(c){a[c]=true});var d=function(){function c(l,r){var o=l.next();if(o=="<")if(l.equals("!")){l.next();if(l.equals("["))if(l.lookAhead("[CDATA[",true)){r(q("xml-cdata","]]\>"));
return null}else return"xml-text";else if(l.lookAhead("--",true)){r(q("xml-comment","--\>"));return null}else return"xml-text"}else if(l.equals("?")){l.next();l.nextWhileMatches(/[\w\._\-]/);r(q("xml-processing","?>"));return"xml-processing"}else{l.equals("/")&&l.next();r(b);return"xml-punctuation"}else if(o=="{"){if(l.equals("{")){l.next();r(e);return"liquid-punctuation"}if(l.equals("%")){l.next();r(f);return"liquid-punctuation"}else return"xml-text"}else if(o=="&"){for(;!l.endOfLine();)if(l.next()==
";")break;return"xml-entity"}else{l.nextWhileMatches(/[^{&<\n]/);return"xml-text"}}function b(l,r){var o=l.next();if(o==">"){r(c);return"xml-punctuation"}else if(/[?\/]/.test(o)&&l.equals(">")){l.next();r(c);return"xml-punctuation"}else if(o=="=")return"xml-punctuation";else if(/[\'\"]/.test(o)){r(j(o));return null}else{l.nextWhileMatches(/[^\s\u00a0=<>\"\'\/?]/);return"xml-name"}}function e(l,r){var o=l.next();if(o=="}")if(l.equals("}")){l.next();r(c);return"liquid-punctuation"}else{r(c);return"liquid-bad-punctuation"}else if(s.test(o)){r(i(o,
e));return null}else if(t.test(o))return"liquid-punctuation";return"liquid-text"}function f(l,r){l.nextWhileMatches(n);r(h);return"liquid-tag-name"}function h(l,r){var o=l.next();if(o=="%")if(l.equals("}")){l.next();r(c);return"liquid-punctuation"}else{r(c);return"liquid-bad-punctuation"}else if(s.test(o)){r(i(o,h));return null}else{if(t.test(o))o="liquid-punctuation";else{o=a;l.nextWhileMatches(n);var w=l.get();o=o&&o.propertyIsEnumerable(w)?{type:"string",style:"liquid-keyword",content:w}:{type:"string",
style:"liquid-text",content:w}}return o}}function i(l,r){return function(o,w){for(;!o.endOfLine();)if(o.next()==l){w(r);break}return"liquid-string"}}function j(l){return function(r,o){for(;!r.endOfLine();)if(r.next()==l){o(b);break}return"xml-attribute"}}function q(l,r){return function(o,w){for(;!o.endOfLine();){if(o.lookAhead(r,true)){w(c);break}o.next()}return l}}return function(l,r){return tokenizer(l,r||c)}}();return{make:function(c){function b(y){for(var C=y.length-1;C>=0;C--)K.push(y[C])}function e(){b(arguments);
D=true}function f(){b(arguments);D=false}function h(y){return function(C,E){if(E==y)e();else{z="xml-error";e(arguments.callee)}}}function i(y,C){var E=k.doNotIndent.hasOwnProperty(y)||G&&G.noIndent;G={prev:G,name:y,indent:F,startOfLine:C,noIndent:E}}function j(y){return function(C,E){var I=y;if(I&&I.noIndent)return E;if(m&&/<!\[CDATA\[/.test(C))return 0;if(I&&/^<\//.test(C))I=I.prev;for(;I&&!I.startOfLine;)I=I.prev;return I?I.indent+indentUnit:0}}function q(){return f(l,q)}function l(y,C){if(C=="<")e(r,
A,w(L==1));else if(C=="</")e(o,h(">"));else{if(y=="xml-cdata"){if(!G||G.name!="!cdata")i("!cdata");if(/\]\]>$/.test(C))G=G.prev}else M.hasOwnProperty(y)||J.hasOwnProperty(y)||(z="xml-error");e()}}function r(y,C){if(y=="xml-name"){N=C.toLowerCase();z="xml-tagname";e()}else{N=null;f()}}function o(y,C){if(y=="xml-name"&&G&&C.toLowerCase()==G.name){G=G.prev;z="xml-tagname"}else z="xml-error";e()}function w(y){return function(C,E){if(E=="/>"||E==">"&&k.autoSelfClosers.hasOwnProperty(N))e();else if(E==
">")i(N,y)||e();else{z="xml-error";e(arguments.callee)}}}function A(y){if(y=="xml-name"){z="xml-attname";e(v,A)}else f()}function v(y,C){if(C=="=")e(x);else C==">"||C=="/>"?f(w):f()}function x(y){y=="xml-attribute"?e(x):f()}var H=d(c),K=[q],L=0,F=0,N=null,G=null,D,z,M={"xml-text":true,"xml-entity":true,"xml-comment":true,"xml-processing":true},J={"liquid-punctuation":true,"liquid-bad-punctuation":true,"liquid-keyword":true,"liquid-tag-name":true,"liquid-variable":true,"liquid-text":true,"liquid-string":true};
return{indentation:function(){return F},next:function(){var y=H.next();if(y.style=="whitespace"&&L==0)F=y.value.length;else L++;if(y.content=="\n"){F=L=0;y.indentation=j(G)}if(y.style=="whitespace"||y.type=="xml-comment")return y;for(;;){D=z=false;K.pop()(y.style,y.content);if(D){if(z)y.style=z;return y}}},copy:function(){var y=K.concat([]),C=H.state,E=G,I=this;return function(O){K=y.concat([]);L=F=0;G=E;H=d(O,C);return I}}}},electricChars:"/",configure:function(c){if(c.useHTMLKludges!=null)k=c.useHTMLKludges?
g:p;if(c.alignCDATA)m=c.alignCDATA}}}();

File diff suppressed because it is too large Load Diff

View File

@ -41,7 +41,7 @@ var indentUnit = 2;
callback = function(line) {
for (var i = 0; i < line.length; i++)
node.appendChild(line[i]);
node.appendChild(document.createElement("BR"));
node.appendChild(document.createElement("br"));
};
}
@ -53,7 +53,7 @@ var indentUnit = 2;
line = [];
}
else {
var span = document.createElement("SPAN");
var span = document.createElement("span");
span.className = token.style;
span.appendChild(document.createTextNode(token.value));
line.push(span);

View File

@ -4,7 +4,7 @@
*/
function MirrorFrame(place, options) {
this.home = document.createElement("DIV");
this.home = document.createElement("div");
if (place.appendChild)
place.appendChild(this.home);
else
@ -12,7 +12,7 @@ function MirrorFrame(place, options) {
var self = this;
function makeButton(name, action) {
var button = document.createElement("INPUT");
var button = document.createElement("input");
button.type = "button";
button.value = name;
self.home.appendChild(button);
@ -36,7 +36,7 @@ MirrorFrame.prototype = {
var first = true;
do {
var cursor = this.mirror.getSearchCursor(text, first, true);
var cursor = this.mirror.getSearchCursor(text, first);
first = false;
while (cursor.findNext()) {
cursor.select();

View File

@ -112,28 +112,34 @@ var CSSParser = Editor.Parser = (function() {
function parseCSS(source, basecolumn) {
basecolumn = basecolumn || 0;
var tokens = tokenizeCSS(source);
var inBraces = false, inRule = false;
var inBraces = false, inRule = false, inDecl = false;;
var iter = {
next: function() {
var token = tokens.next(), style = token.style, content = token.content;
if (style == "css-identifier" && inRule)
token.style = "css-value";
if (style == "css-hash")
token.style = inRule ? "css-colorcode" : "css-identifier";
style = token.style = inRule ? "css-colorcode" : "css-identifier";
if (style == "css-identifier") {
if (inRule) token.style = "css-value";
else if (!inBraces && !inDecl) token.style = "css-selector";
}
if (content == "\n")
token.indentation = indentCSS(inBraces, inRule, basecolumn);
if (content == "{")
if (content == "{" && inDecl == "@media")
inDecl = false;
else if (content == "{")
inBraces = true;
else if (content == "}")
inBraces = inRule = false;
else if (inBraces && content == ";")
inRule = false;
inBraces = inRule = inDecl = false;
else if (content == ";")
inRule = inDecl = false;
else if (inBraces && style != "css-comment" && style != "whitespace")
inRule = true;
else if (!inBraces && style == "css-at")
inDecl = content;
return token;
},

View File

@ -1,9 +1,22 @@
var HTMLMixedParser = Editor.Parser = (function() {
if (!(CSSParser && JSParser && XMLParser))
throw new Error("CSS, JS, and XML parsers must be loaded for HTML mixed mode to work.");
XMLParser.configure({useHTMLKludges: true});
// tags that trigger seperate parsers
var triggers = {
"script": "JSParser",
"style": "CSSParser"
};
function checkDependencies() {
var parsers = ['XMLParser'];
for (var p in triggers) parsers.push(triggers[p]);
for (var i in parsers) {
if (!window[parsers[i]]) throw new Error(parsers[i] + " parser must be loaded for HTML mixed mode to work.");
}
XMLParser.configure({useHTMLKludges: true});
}
function parseMixed(stream) {
checkDependencies();
var htmlParser = XMLParser.make(stream), localParser = null, inTag = false;
var iter = {next: top, copy: copy};
@ -14,10 +27,10 @@ var HTMLMixedParser = Editor.Parser = (function() {
else if (token.style == "xml-tagname" && inTag === true)
inTag = token.content.toLowerCase();
else if (token.content == ">") {
if (inTag == "script")
iter.next = local(JSParser, "</script");
else if (inTag == "style")
iter.next = local(CSSParser, "</style");
if (triggers[inTag]) {
var parser = window[triggers[inTag]];
iter.next = local(parser, "</" + inTag);
}
inTag = false;
}
return token;
@ -47,7 +60,7 @@ var HTMLMixedParser = Editor.Parser = (function() {
return baseIndent;
else
return oldIndent(chars);
}
};
}
return token;
@ -69,6 +82,12 @@ var HTMLMixedParser = Editor.Parser = (function() {
return iter;
}
return {make: parseMixed, electricChars: "{}/:"};
return {
make: parseMixed,
electricChars: "{}/:",
configure: function(obj) {
if (obj.triggers) triggers = obj.triggers;
}
};
})();

View File

@ -60,7 +60,7 @@ var JSParser = Editor.Parser = (function() {
// semicolon. Actions at the end of the stack go first. It is
// initialized with an infinitely looping action that consumes
// whole statements.
var cc = [json ? singleExpr : statements];
var cc = [json ? expressions : statements];
// Context contains information about the current local scope, the
// variables defined in that, and the scopes above it.
var context = null;
@ -206,6 +206,8 @@ var JSParser = Editor.Parser = (function() {
}
// Pop off the current lexical context.
function poplex(){
if (lexical.type == ")")
indented = lexical.indented;
lexical = lexical.prev;
}
poplex.lex = true;
@ -218,6 +220,7 @@ var JSParser = Editor.Parser = (function() {
function expect(wanted){
return function expecting(type){
if (type == wanted) cont();
else if (wanted == ";") pass();
else cont(arguments.callee);
};
}
@ -226,8 +229,8 @@ var JSParser = Editor.Parser = (function() {
function statements(type){
return pass(statement, statements);
}
function singleExpr(type){
return pass(expression, statements);
function expressions(type){
return pass(expression, expressions);
}
// Dispatches various types of statements based on the type of the
// current token.
@ -236,6 +239,7 @@ var JSParser = Editor.Parser = (function() {
else if (type == "keyword a") cont(pushlex("form"), expression, statement, poplex);
else if (type == "keyword b") cont(pushlex("form"), statement, poplex);
else if (type == "{") cont(pushlex("}"), block, poplex);
else if (type == ";") cont();
else if (type == "function") cont(functiondef);
else if (type == "for") cont(pushlex("form"), expect("("), pushlex(")"), forspec1, expect(")"), poplex, statement, poplex);
else if (type == "variable") cont(pushlex("stat"), maybelabel);
@ -254,13 +258,16 @@ var JSParser = Editor.Parser = (function() {
else if (type == "operator") cont(expression);
else if (type == "[") cont(pushlex("]"), commasep(expression, "]"), poplex, maybeoperator);
else if (type == "{") cont(pushlex("}"), commasep(objprop, "}"), poplex, maybeoperator);
else cont();
}
// Called for places where operators, function calls, or
// subscripts are valid. Will skip on to the next action if none
// is found.
function maybeoperator(type){
if (type == "operator") cont(expression);
else if (type == "(") cont(pushlex(")"), expression, commasep(expression, ")"), poplex, maybeoperator);
function maybeoperator(type, value){
if (type == "operator" && /\+\+|--/.test(value)) cont(maybeoperator);
else if (type == "operator") cont(expression);
else if (type == ";") pass();
else if (type == "(") cont(pushlex(")"), commasep(expression, ")"), poplex, maybeoperator);
else if (type == ".") cont(property, maybeoperator);
else if (type == "[") cont(pushlex("]"), expression, expect("]"), poplex, maybeoperator);
}

View File

@ -6,7 +6,7 @@ var SparqlParser = Editor.Parser = (function() {
"isblank", "isliteral", "union", "a"]);
var keywords = wordRegexp(["base", "prefix", "select", "distinct", "reduced", "construct", "describe",
"ask", "from", "named", "where", "order", "limit", "offset", "filter", "optional",
"graph", "by", "asc", "desc", ]);
"graph", "by", "asc", "desc"]);
var operatorChars = /[*+\-<>=&|]/;
var tokenizeSparql = (function() {

View File

@ -38,6 +38,11 @@ var XMLParser = Editor.Parser = (function() {
setState(inBlock("xml-comment", "-->"));
return null;
}
else if (source.lookAhead("DOCTYPE", true)) {
source.nextWhileMatches(/[\w\._\-]/);
setState(inBlock("xml-doctype", ">"));
return "xml-doctype";
}
else {
return "xml-text";
}
@ -182,7 +187,7 @@ var XMLParser = Editor.Parser = (function() {
function base() {
return pass(element, base);
}
var harmlessTokens = {"xml-text": true, "xml-entity": true, "xml-comment": true, "xml-processing": true};
var harmlessTokens = {"xml-text": true, "xml-entity": true, "xml-comment": true, "xml-processing": true, "xml-doctype": true};
function element(style, content) {
if (content == "<") cont(tagname, attributes, endtag(tokenNr == 1));
else if (content == "</") cont(closetagname, expect(">"));

View File

@ -29,11 +29,10 @@ var select = {};
var fourSpaces = "\u00a0\u00a0\u00a0\u00a0";
select.scrollToNode = function(element) {
if (!element) return;
var doc = element.ownerDocument, body = doc.body,
win = (doc.defaultView || doc.parentWindow),
html = doc.documentElement,
select.scrollToNode = function(node, cursor) {
if (!node) return;
var element = node, body = document.body,
html = document.documentElement,
atEnd = !element.nextSibling || !element.nextSibling.nextSibling
|| !element.nextSibling.nextSibling.nextSibling;
// In Opera (and recent Webkit versions), BR elements *always*
@ -48,7 +47,14 @@ var select = {};
// offset, just scroll to the end.
if (compensateHack == 0) atEnd = false;
var y = compensateHack * (element ? element.offsetHeight : 0), x = 0, pos = element;
// WebKit has a bad habit of (sometimes) happily returning bogus
// offsets when the document has just been changed. This seems to
// always be 5/5, so we don't use those.
if (webkit && element && element.offsetTop == 5 && element.offsetLeft == 5)
return;
var y = compensateHack * (element ? element.offsetHeight : 0), x = 0,
width = (node ? node.offsetWidth : 0), pos = element;
while (pos && pos.offsetParent) {
y += pos.offsetTop;
// Don't count X offset for <br> nodes
@ -59,21 +65,29 @@ var select = {};
var scroll_x = body.scrollLeft || html.scrollLeft || 0,
scroll_y = body.scrollTop || html.scrollTop || 0,
screen_x = x - scroll_x, screen_y = y - scroll_y, scroll = false;
scroll = false, screen_width = window.innerWidth || html.clientWidth || 0;
if (screen_x < 0 || screen_x > (win.innerWidth || html.clientWidth || 0)) {
scroll_x = x;
scroll = true;
if (cursor || width < screen_width) {
if (cursor) {
var off = select.offsetInNode(node), size = nodeText(node).length;
if (size) x += width * (off / size);
}
var screen_x = x - scroll_x;
if (screen_x < 0 || screen_x > screen_width) {
scroll_x = x;
scroll = true;
}
}
if (screen_y < 0 || atEnd || screen_y > (win.innerHeight || html.clientHeight || 0) - 50) {
var screen_y = y - scroll_y;
if (screen_y < 0 || atEnd || screen_y > (window.innerHeight || html.clientHeight || 0) - 50) {
scroll_y = atEnd ? 1e6 : y;
scroll = true;
}
if (scroll) win.scrollTo(scroll_x, scroll_y);
if (scroll) window.scrollTo(scroll_x, scroll_y);
};
select.scrollToCursor = function(container) {
select.scrollToNode(select.selectionTopNode(container, true) || container.firstChild);
select.scrollToNode(select.selectionTopNode(container, true) || container.firstChild, true);
};
// Used to prevent restoring a selection when we do not need to.
@ -83,6 +97,21 @@ var select = {};
if (currentSelection) currentSelection.changed = true;
};
// Find the 'leaf' node (BR or text) after the given one.
function baseNodeAfter(node) {
var next = node.nextSibling;
if (next) {
while (next.firstChild) next = next.firstChild;
if (next.nodeType == 3 || isBR(next)) return next;
else return baseNodeAfter(next);
}
else {
var parent = node.parentNode;
while (parent && !parent.nextSibling) parent = parent.parentNode;
return parent && baseNodeAfter(parent);
}
}
// This is called by the code in editor.js whenever it is replacing
// a text node. The function sees whether the given oldNode is part
// of the current selection, and updates this selection if it is.
@ -107,6 +136,9 @@ var select = {};
point.offset += (offset || 0);
}
}
else if (select.ie_selection && point.offset == 0 && point.node == baseNodeAfter(from)) {
currentSelection.changed = true;
}
}
replace(currentSelection.start);
replace(currentSelection.end);
@ -130,8 +162,13 @@ var select = {};
// Most functions are defined in two ways, one for the IE selection
// model, one for the W3C one.
if (select.ie_selection) {
function selectionNode(win, start) {
var range = win.document.selection.createRange();
function selRange() {
var sel = document.selection;
return sel && (sel.createRange || sel.createTextRange)();
}
function selectionNode(start) {
var range = selRange();
range.collapse(start);
function nodeAfter(node) {
@ -149,7 +186,7 @@ var select = {};
}
var containing = range.parentElement();
if (!isAncestor(win.document.body, containing)) return null;
if (!isAncestor(document.body, containing)) return null;
if (!containing.firstChild) return nodeAtStartOf(containing);
var working = range.duplicate();
@ -176,25 +213,24 @@ var select = {};
return nodeAfter(containing);
}
select.markSelection = function(win) {
select.markSelection = function() {
currentSelection = null;
var sel = win.document.selection;
var sel = document.selection;
if (!sel) return;
var start = selectionNode(win, true),
end = selectionNode(win, false);
var start = selectionNode(true),
end = selectionNode(false);
if (!start || !end) return;
currentSelection = {start: start, end: end, window: win, changed: false};
currentSelection = {start: start, end: end, changed: false};
};
select.selectMarked = function() {
if (!currentSelection || !currentSelection.changed) return;
var win = currentSelection.window, doc = win.document;
function makeRange(point) {
var range = doc.body.createTextRange(),
var range = document.body.createTextRange(),
node = point.node;
if (!node) {
range.moveToElementText(currentSelection.window.document.body);
range.moveToElementText(document.body);
range.collapse(false);
}
else if (node.nodeType == 3) {
@ -218,14 +254,22 @@ var select = {};
start.select();
};
select.offsetInNode = function(node) {
var range = selRange();
if (!range) return 0;
var range2 = range.duplicate();
try {range2.moveToElementText(node);} catch(e){return 0;}
range.setEndPoint("StartToStart", range2);
return range.text.length;
};
// Get the top-level node that one end of the cursor is inside or
// after. Note that this returns false for 'no cursor', and null
// for 'start of document'.
select.selectionTopNode = function(container, start) {
var selection = container.ownerDocument.selection;
if (!selection) return false;
var range = selection.createRange(), range2 = range.duplicate();
var range = selRange();
if (!range) return false;
var range2 = range.duplicate();
range.collapse(start);
var around = range.parentElement();
if (around && isAncestor(container, around)) {
@ -272,6 +316,17 @@ var select = {};
else
end = middle - 1;
}
if (start == 0) {
var test1 = selRange(), test2 = test1.duplicate();
try {
test2.moveToElementText(container);
} catch(exception) {
return null;
}
if (test1.compareEndPoints("StartToStart", test2) == 0)
return null;
}
return container.childNodes[start] || null;
};
@ -279,21 +334,20 @@ var select = {};
// manually moving the cursor instead of restoring it to its old
// position.
select.focusAfterNode = function(node, container) {
var range = container.ownerDocument.body.createTextRange();
var range = document.body.createTextRange();
range.moveToElementText(node || container);
range.collapse(!node);
range.select();
};
select.somethingSelected = function(win) {
var sel = win.document.selection;
return sel && (sel.createRange().text != "");
select.somethingSelected = function() {
var range = selRange();
return range && (range.text != "");
};
function insertAtCursor(window, html) {
var selection = window.document.selection;
if (selection) {
var range = selection.createRange();
function insertAtCursor(html) {
var range = selRange();
if (range) {
range.pasteHTML(html);
range.collapse(false);
range.select();
@ -302,26 +356,26 @@ var select = {};
// Used to normalize the effect of the enter key, since browsers
// do widely different things when pressing enter in designMode.
select.insertNewlineAtCursor = function(window) {
insertAtCursor(window, "<br>");
select.insertNewlineAtCursor = function() {
insertAtCursor("<br>");
};
select.insertTabAtCursor = function(window) {
insertAtCursor(window, fourSpaces);
select.insertTabAtCursor = function() {
insertAtCursor(fourSpaces);
};
// Get the BR node at the start of the line on which the cursor
// currently is, and the offset into the line. Returns null as
// node if cursor is on first line.
select.cursorPos = function(container, start) {
var selection = container.ownerDocument.selection;
if (!selection) return null;
var range = selRange();
if (!range) return null;
var topNode = select.selectionTopNode(container, start);
while (topNode && !isBR(topNode))
topNode = topNode.previousSibling;
var range = selection.createRange(), range2 = range.duplicate();
var range2 = range.duplicate();
range.collapse(start);
if (topNode) {
range2.moveToElementText(topNode);
@ -340,7 +394,7 @@ var select = {};
select.setCursorPos = function(container, from, to) {
function rangeAt(pos) {
var range = container.ownerDocument.body.createTextRange();
var range = document.body.createTextRange();
if (!pos.node) {
range.moveToElementText(container);
range.collapse(true);
@ -373,42 +427,38 @@ var select = {};
}
// W3C model
else {
// Find the node right at the cursor, not one of its
// ancestors with a suitable offset. This goes down the DOM tree
// until a 'leaf' is reached (or is it *up* the DOM tree?).
function innerNode(node, offset) {
while (node.nodeType != 3 && !isBR(node)) {
var newNode = node.childNodes[offset] || node.nextSibling;
offset = 0;
while (!newNode && node.parentNode) {
node = node.parentNode;
newNode = node.nextSibling;
}
node = newNode;
if (!newNode) break;
}
return {node: node, offset: offset};
}
// Store start and end nodes, and offsets within these, and refer
// back to the selection object from those nodes, so that this
// object can be updated when the nodes are replaced before the
// selection is restored.
select.markSelection = function (win) {
var selection = win.getSelection();
select.markSelection = function () {
var selection = window.getSelection();
if (!selection || selection.rangeCount == 0)
return (currentSelection = null);
var range = selection.getRangeAt(0);
currentSelection = {
start: {node: range.startContainer, offset: range.startOffset},
end: {node: range.endContainer, offset: range.endOffset},
window: win,
start: innerNode(range.startContainer, range.startOffset),
end: innerNode(range.endContainer, range.endOffset),
changed: false
};
// We want the nodes right at the cursor, not one of their
// ancestors with a suitable offset. This goes down the DOM tree
// until a 'leaf' is reached (or is it *up* the DOM tree?).
function normalize(point){
while (point.node.nodeType != 3 && !isBR(point.node)) {
var newNode = point.node.childNodes[point.offset] || point.node.nextSibling;
point.offset = 0;
while (!newNode && point.node.parentNode) {
point.node = point.node.parentNode;
newNode = point.node.nextSibling;
}
point.node = newNode;
if (!newNode)
break;
}
}
normalize(currentSelection.start);
normalize(currentSelection.end);
};
select.selectMarked = function () {
@ -419,10 +469,15 @@ var select = {};
// this occurs is when a selection is deleted or overwitten. we
// check for that here.
function focusIssue() {
return cs.start.node == cs.end.node && cs.start.offset == 0 && cs.end.offset == 0;
if (cs.start.node == cs.end.node && cs.start.offset == cs.end.offset) {
var selection = window.getSelection();
if (!selection || selection.rangeCount == 0) return true;
var range = selection.getRangeAt(0), point = innerNode(range.startContainer, range.startOffset);
return cs.start.node != point.node || cs.start.offset != point.offset;
}
}
if (!cs || !(cs.changed || (webkit && focusIssue()))) return;
var win = cs.window, range = win.document.createRange();
var range = document.createRange();
function setPoint(point, which) {
if (point.node) {
@ -434,22 +489,23 @@ var select = {};
range["set" + which](point.node, point.offset);
}
else {
range.setStartAfter(win.document.body.lastChild || win.document.body);
range.setStartAfter(document.body.lastChild || document.body);
}
}
setPoint(cs.end, "End");
setPoint(cs.start, "Start");
selectRange(range, win);
selectRange(range);
};
// Helper for selecting a range object.
function selectRange(range, window) {
function selectRange(range) {
var selection = window.getSelection();
if (!selection) return;
selection.removeAllRanges();
selection.addRange(range);
}
function selectionRange(window) {
function selectionRange() {
var selection = window.getSelection();
if (!selection || selection.rangeCount == 0)
return false;
@ -460,7 +516,7 @@ var select = {};
// Finding the top-level node at the cursor in the W3C is, as you
// can see, quite an involved process.
select.selectionTopNode = function(container, start) {
var range = selectionRange(container.ownerDocument.defaultView);
var range = selectionRange();
if (!range) return false;
var node = start ? range.startContainer : range.endContainer;
@ -505,8 +561,7 @@ var select = {};
};
select.focusAfterNode = function(node, container) {
var win = container.ownerDocument.defaultView,
range = win.document.createRange();
var range = document.createRange();
range.setStartBefore(container.firstChild || container);
// In Opera, setting the end of a range at the end of a line
// (before a BR) will cause the cursor to appear on the next
@ -519,37 +574,59 @@ var select = {};
else
range.setEndBefore(container.firstChild || container);
range.collapse(false);
selectRange(range, win);
selectRange(range);
};
select.somethingSelected = function(win) {
var range = selectionRange(win);
select.somethingSelected = function() {
var range = selectionRange();
return range && !range.collapsed;
};
function insertNodeAtCursor(window, node) {
var range = selectionRange(window);
select.offsetInNode = function(node) {
var range = selectionRange();
if (!range) return 0;
range = range.cloneRange();
range.setStartBefore(node);
return range.toString().length;
};
select.insertNodeAtCursor = function(node) {
var range = selectionRange();
if (!range) return;
range.deleteContents();
range.insertNode(node);
webkitLastLineHack(window.document.body);
range = window.document.createRange();
webkitLastLineHack(document.body);
// work around weirdness where Opera will magically insert a new
// BR node when a BR node inside a span is moved around. makes
// sure the BR ends up outside of spans.
if (window.opera && isBR(node) && isSpan(node.parentNode)) {
var next = node.nextSibling, p = node.parentNode, outer = p.parentNode;
outer.insertBefore(node, p.nextSibling);
var textAfter = "";
for (; next && next.nodeType == 3; next = next.nextSibling) {
textAfter += next.nodeValue;
removeElement(next);
}
outer.insertBefore(makePartSpan(textAfter, document), node.nextSibling);
}
range = document.createRange();
range.selectNode(node);
range.collapse(false);
selectRange(range, window);
selectRange(range);
}
select.insertNewlineAtCursor = function(window) {
insertNodeAtCursor(window, window.document.createElement("BR"));
select.insertNewlineAtCursor = function() {
select.insertNodeAtCursor(document.createElement("BR"));
};
select.insertTabAtCursor = function(window) {
insertNodeAtCursor(window, window.document.createTextNode(fourSpaces));
select.insertTabAtCursor = function() {
select.insertNodeAtCursor(document.createTextNode(fourSpaces));
};
select.cursorPos = function(container, start) {
var range = selectionRange(window);
var range = selectionRange();
if (!range) return;
var topNode = select.selectionTopNode(container, start);
@ -562,12 +639,13 @@ var select = {};
range.setStartAfter(topNode);
else
range.setStartBefore(container);
return {node: topNode, offset: range.toString().length};
var text = range.toString();
return {node: topNode, offset: text.length};
};
select.setCursorPos = function(container, from, to) {
var win = container.ownerDocument.defaultView,
range = win.document.createRange();
var range = document.createRange();
function setPoint(node, offset, side) {
if (offset == 0 && node && !node.nextSibling) {
@ -613,7 +691,7 @@ var select = {};
to = to || from;
if (setPoint(to.node, to.offset, "End") && setPoint(from.node, from.offset, "Start"))
selectRange(range, win);
selectRange(range);
};
}
})();

View File

@ -39,11 +39,13 @@ var stringStream = function(source){
}
return {
// peek: -> character
// Return the next character in the stream.
peek: function() {
if (!ensureChars()) return null;
return current.charAt(pos);
},
// next: -> character
// Get the next character, throw StopIteration if at end, check
// for unused content.
next: function() {
@ -55,6 +57,7 @@ var stringStream = function(source){
}
return current.charAt(pos++);
},
// get(): -> string
// Return the characters iterated over since the last call to
// .get().
get: function() {
@ -89,7 +92,7 @@ var stringStream = function(source){
else if (str.slice(0, left) == cased(current.slice(pos))) {
accum += current; current = "";
try {current = source.next();}
catch (e) {break;}
catch (e) {if (e != StopIteration) throw e; break;}
pos = 0;
str = str.slice(left);
}
@ -106,8 +109,24 @@ var stringStream = function(source){
return found;
},
// Wont't match past end of line.
lookAheadRegex: function(regex, consume) {
if (regex.source.charAt(0) != "^")
throw new Error("Regexps passed to lookAheadRegex must start with ^");
// Fetch the rest of the line
while (current.indexOf("\n", pos) == -1) {
try {current += source.next();}
catch (e) {if (e != StopIteration) throw e; break;}
}
var matched = current.slice(pos).match(regex);
if (matched && consume) pos += matched[0].length;
return matched;
},
// Utils built on top of the above
// more: -> boolean
// Produce true if the stream isn't empty.
more: function() {
return this.peek() !== null;
},

View File

@ -101,7 +101,7 @@ var tokenizeJavaScript = (function() {
}
function readRegexp() {
nextUntilUnescaped(source, "/");
source.nextWhileMatches(/[gi]/);
source.nextWhileMatches(/[gimy]/); // 'y' is "sticky" option in Mozilla
return {type: "regexp", style: "js-string"};
}
// Mutli-line comments are tricky. We want to return the newlines

View File

@ -9,7 +9,7 @@
* complexity and hackery.
*
* In short, the editor 'touches' BR elements as it parses them, and
* the History stores these. When nothing is touched in commitDelay
* the UndoHistory stores these. When nothing is touched in commitDelay
* milliseconds, the changes are committed: It goes over all touched
* nodes, throws out the ones that did not change since last commit or
* are no longer in the document, and assembles the rest into zero or
@ -26,10 +26,10 @@
// delay (of no input) after which it commits a set of changes, and,
// unfortunately, the 'parent' window -- a window that is not in
// designMode, and on which setTimeout works in every browser.
function History(container, maxDepth, commitDelay, editor) {
function UndoHistory(container, maxDepth, commitDelay, editor) {
this.container = container;
this.maxDepth = maxDepth; this.commitDelay = commitDelay;
this.editor = editor; this.parent = editor.parent;
this.editor = editor;
// This line object represents the initial, empty editor.
var initial = {text: "", from: null, to: null};
// As the borders between lines are represented by BR elements, the
@ -47,13 +47,13 @@ function History(container, maxDepth, commitDelay, editor) {
this.history = []; this.redoHistory = []; this.touched = [];
}
History.prototype = {
UndoHistory.prototype = {
// Schedule a commit (if no other touches come in for commitDelay
// milliseconds).
scheduleCommit: function() {
var self = this;
this.parent.clearTimeout(this.commitTimeout);
this.commitTimeout = this.parent.setTimeout(function(){self.tryCommit();}, this.commitDelay);
parent.clearTimeout(this.commitTimeout);
this.commitTimeout = parent.setTimeout(function(){self.tryCommit();}, this.commitDelay);
},
// Mark a node as touched. Null is a valid argument.
@ -103,7 +103,7 @@ History.prototype = {
push: function(from, to, lines) {
var chain = [];
for (var i = 0; i < lines.length; i++) {
var end = (i == lines.length - 1) ? to : this.container.ownerDocument.createElement("BR");
var end = (i == lines.length - 1) ? to : document.createElement("br");
chain.push({from: from, to: end, text: cleanText(lines[i])});
from = end;
}
@ -145,7 +145,7 @@ History.prototype = {
// Commit unless there are pending dirty nodes.
tryCommit: function() {
if (!window.History) return; // Stop when frame has been unloaded
if (!window || !window.parent || !window.UndoHistory) return; // Stop when frame has been unloaded
if (this.editor.highlightDirty()) this.commit(true);
else this.scheduleCommit();
},
@ -153,7 +153,7 @@ History.prototype = {
// Check whether the touched nodes hold any changes, if so, commit
// them.
commit: function(doNotHighlight) {
this.parent.clearTimeout(this.commitTimeout);
parent.clearTimeout(this.commitTimeout);
// Make sure there are no pending dirty nodes.
if (!doNotHighlight) this.editor.highlightDirty(true);
// Build set of chains.
@ -192,10 +192,10 @@ History.prototype = {
},
notifyEnvironment: function() {
if (this.onChange) this.onChange();
// Used by the line-wrapping line-numbering code.
if (window.frameElement && window.frameElement.CodeMirror.updateNumbers)
window.frameElement.CodeMirror.updateNumbers();
if (this.onChange) this.onChange();
},
// Link a chain into the DOM nodes (or the first/last links for null
@ -257,8 +257,8 @@ History.prototype = {
function buildLine(node) {
var text = [];
for (var cur = node ? node.nextSibling : self.container.firstChild;
cur && !isBR(cur); cur = cur.nextSibling)
if (cur.currentText) text.push(cur.currentText);
cur && (!isBR(cur) || cur.hackBR); cur = cur.nextSibling)
if (!cur.hackBR && cur.currentText) text.push(cur.currentText);
return {from: node, to: cur, text: cleanText(text.join(""))};
}
@ -267,7 +267,7 @@ History.prototype = {
var lines = [];
if (self.firstTouched) self.touched.push(null);
forEach(self.touched, function(node) {
if (node && node.parentNode != self.container) return;
if (node && (node.parentNode != self.container || node.hackBR)) return;
if (node) node.historyTouched = false;
else self.firstTouched = false;
@ -380,7 +380,7 @@ History.prototype = {
self.container.insertBefore(line.from, end);
// Add the text.
var node = makePartSpan(fixSpaces(line.text), this.container.ownerDocument);
var node = makePartSpan(fixSpaces(line.text));
self.container.insertBefore(node, end);
// See if the cursor was on this line. Put it back, adjusting
// for changed line length, if it was.
@ -391,7 +391,7 @@ History.prototype = {
// Only adjust if the cursor is after the unchanged part of
// the line.
for (var match = 0; match < cursor.offset &&
line.text.charAt(match) == prev.text.charAt(match); match++);
line.text.charAt(match) == prev.text.charAt(match); match++){}
if (cursor.offset > match)
cursordiff = line.text.length - prev.text.length;
}

View File

@ -34,12 +34,15 @@ function matcher(regexp){
return function(value){return regexp.test(value);};
}
// Test whether a DOM node has a certain CSS class. Much faster than
// the MochiKit equivalent, for some reason.
function hasClass(element, className){
// Test whether a DOM node has a certain CSS class.
function hasClass(element, className) {
var classes = element.className;
return classes && new RegExp("(^| )" + className + "($| )").test(classes);
}
function removeClass(element, className) {
element.className = element.className.replace(new RegExp(" " + className + "\\b", "g"), "");
return element;
}
// Insert a DOM node after another node.
function insertAfter(newNode, oldNode) {

View File

@ -1,55 +1,52 @@
// Save -> Command S (need a form)
// Save -> Command OR CTRL S/s (need a form)
jQuery.fn.saveWithShortcut = function() {
var resetFormErrors = function(form) {
jQuery('div.form-errors').remove();
jQuery('div.formError').remove();
jQuery('p.inline-errors').remove();
form.find('li.error').removeClass('error');
}
var updateFromCodeMirror = function() {
if (typeof CodeMirror == undefined)
return;
jQuery.each(CodeMirrorEditors, function() {
this.el.val(this.editor.getCode());
});
}
var save = function(form) {
$.post(form.attr('action'), form.serializeArray(), function(data) {
onSaveCallback(form, data)
}, 'json');
};
var onSaveCallback = function(form, data) {
resetFormErrors(form);
if (data.alert != undefined) {
$.growl('error', data.alert);
for (var field in data.errors) {
var error = data.errors[field];
var node = form.find('li:has(#' + data.model + '_' + field + ')');
node.addClass('error');
node.append("<p class='inline-errors'>" + error + "</p>");
}
form.find('li.error input').eq(0).focus();
} else {
$.growl('success', data.notice);
$.publish('form.saved.success', [data]);
}
};
return this.each(function() {
var form = jQuery(this);
$.cmd('S', function() {
updateFromCodeMirror();
save(form);
event.preventDefault();
return false;
});
});
var resetFormErrors = function(form) {
jQuery('div.form-errors').remove();
jQuery('div.formError').remove();
jQuery('p.inline-errors').remove();
form.find('li.error').removeClass('error');
}
var updateFromCodeMirror = function() {
if (typeof CodeMirror == undefined) return;
jQuery.each(CodeMirrorEditors, function() {
this.el.val(this.editor.getCode());
});
}
var save = function(form) {
$.post(form.attr('action'), form.serializeArray(), function(data) {
onSaveCallback(form, data)
}, 'json');
};
var onSaveCallback = function(form, data) {
resetFormErrors(form);
if (data.alert != undefined) {
$.growl('error', data.alert);
for (var field in data.errors) {
var error = data.errors[field];
var node = form.find('li:has(#' + data.model + '_' + field + ')');
node.addClass('error');
node.append("<p class='inline-errors'>" + error + "</p>");
}
form.find('li.error input').eq(0).focus();
} else {
$.growl('success', data.notice);
$.publish('form.saved.success', [data]);
}
};
return this.each(function() {
var form = jQuery(this);
$.cmd('S', function() {
updateFromCodeMirror();
save(form);
}, [], { ignoreCase: true });
});
};

View File

@ -24,10 +24,10 @@ $(document).ready(function() {
enableFileOrTextToggling();
$('code.stylesheet textarea').each(function() {
addCodeMirrorEditor(null, $(this), ["tokenizejavascript.js", "parsejavascript.js", "parsecss.js"]);
addCodeMirrorEditor(null, $(this), 'CSS');
});
$('code.javascript textarea').each(function() {
addCodeMirrorEditor(null, $(this), ["parsecss.js", "tokenizejavascript.js", "parsejavascript.js"]);
addCodeMirrorEditor(null, $(this), 'JS');
});
$('select#theme_asset_content_type').bind('change', function() {

View File

@ -11,7 +11,7 @@ html {
}
pre.code, .editbox {
color: #666666;
color: #666;
}
.editbox p {
@ -19,33 +19,37 @@ pre.code, .editbox {
}
span.css-at {
color: #770088;
color: #708;
}
span.css-unit {
color: #228811;
color: #281;
}
span.css-value {
color: #770088;
color: #708;
}
span.css-identifier {
color: black;
}
span.css-selector {
color: #11B;
}
span.css-important {
color: #0000FF;
color: #00F;
}
span.css-colorcode {
color: #004499;
color: #299;
}
span.css-comment {
color: #AA7700;
color: #A70;
}
span.css-string {
color: #AA2222;
color: #A22;
}

View File

@ -1,50 +1,158 @@
body {
margin: 0;
padding: 3em 6em;
color: black;
max-width: 50em;
font-family: Arial, sans-serif;
line-height: 1.5;
max-width: 64.3em;
margin: 3em auto;
padding: 0 1em;
}
body.droid {
font-family: Droid Sans, Arial, sans-serif;
}
h1 {
font-size: 22pt;
}
.underline {
border-bottom: 3px solid #C44;
letter-spacing: -3px;
font-size: 3.23em;
font-weight: bold;
margin: 0;
}
h2 {
font-size: 14pt;
font-size: 1.23em;
font-weight: bold;
margin: .5em 0;
letter-spacing: -1px;
}
h3 {
font-size: 12pt;
font-size: 1em;
font-weight: bold;
margin: .4em 0;
}
p.rel {
padding-left: 2em;
text-indent: -2em;
}
div.border {
border: 1px solid black;
padding: 3px;
}
code {
font-family: courier, monospace;
font-size: 90%;
color: #144;
pre {
font-family: Courier New, monospaced;
background-color: #eee;
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
border-radius: 6px;
padding: 1em;
}
pre.code {
margin: 1.1em 12px;
border: 1px solid #CCCCCC;
color: black;
padding: .4em;
font-family: courier, monospace;
margin: 0 1em;
}
.warn {
color: #C00;
.grey {
font-size: 2em;
padding: .5em 1em;
line-height: 1.2em;
margin-top: .5em;
position: relative;
}
img.logo {
position: absolute;
right: -25px;
bottom: 4px;
}
a:link, a:visited, .quasilink {
color: #df0019;
cursor: pointer;
text-decoration: none;
}
a:hover, .quasilink:hover {
color: #800004;
}
h1 a:link, h1 a:visited, h1 a:hover {
color: black;
}
ul {
margin: 0;
padding-left: 1.2em;
}
a.download {
color: white;
background-color: #df0019;
width: 100%;
display: block;
text-align: center;
font-size: 1.23em;
font-weight: bold;
text-decoration: none;
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
border-radius: 6px;
padding: .5em 0;
margin-bottom: 1em;
}
a.download:hover {
background-color: #bb0010;
}
.rel {
margin-bottom: 0;
}
.rel-note {
color: #777;
font-size: .9em;
margin-top: .1em;
}
.logo-braces {
color: #df0019;
position: relative;
top: -4px;
}
.blk {
float: left;
}
.left {
width: 37em;
padding-right: 6.53em;
padding-bottom: 1em;
}
.left1 {
width: 15.24em;
padding-right: 6.45em;
}
.left2 {
width: 15.24em;
}
.right {
width: 20.68em;
}
.leftbig {
width: 42.44em;
padding-right: 6.53em;
}
.rightsmall {
width: 15.24em;
}
.clear:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
.clear { display: inline-block; }
/* start commented backslash hack \*/
* html .clear { height: 1%; }
.clear { display: block; }
/* close commented backslash hack */