var CodeMirrorConfig=window.CodeMirrorConfig||{};var CodeMirror=(function(){function setDefaults(object,defaults){for(var option in defaults){if(!object.hasOwnProperty(option))
object[option]=defaults[option];}}
function forEach(array,action){for(var i=0;i<array.length;i++)
action(array[i]);}
setDefaults(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,onChange:null,undoDepth:50,undoDelay:800,disableSpellcheck:true,textWrapping:true,readOnly:false,width:"",height:"300px",autoMatchParens:false,parserConfig:null,tabMode:"indent",reindentOnLoad:false,activeTokens:null,cursorActivity:null,lineNumbers:false,indentUnit:2,domain:null});function addLineNumberDiv(container){var nums=document.createElement("DIV"),scroller=document.createElement("DIV");nums.style.position="absolute";nums.style.height="100%";if(nums.style.setExpression){try{nums.style.setExpression("height","this.previousSibling.offsetHeight + 'px'");}
catch(e){}}
nums.style.top="0px";nums.style.overflow="hidden";container.appendChild(nums);scroller.className="CodeMirror-line-numbers";nums.appendChild(scroller);return nums;}
function frameHTML(options){if(typeof options.parserfile=="string")
options.parserfile=[options.parserfile];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>"];html.push("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=EmulateIE7\"/>");forEach(options.stylesheet,function(file){html.push("<link rel=\"stylesheet\" type=\"text/css\" href=\""+file+"\"/>");});forEach(options.basefiles.concat(options.parserfile),function(file){html.push("<script type=\"text/javascript\" src=\""+options.path+file+"\"><"+"/script>");});html.push("</head><body style=\"border-width: 0;\" class=\"editbox\" spellcheck=\""+
(options.disableSpellcheck?"false":"true")+"\"></body></html>");return html.join("");}
var internetExplorer=document.selection&&window.ActiveXObject&&/MSIE/.test(navigator.userAgent);function CodeMirror(place,options){if(options.dumbTabs)options.tabMode="spaces";else if(options.normalTab)options.tabMode="default";this.options=options=options||{};setDefaults(options,CodeMirrorConfig);var frame=this.frame=document.createElement("IFRAME");if(options.iframeClass)frame.className=options.iframeClass;frame.frameBorder=0;frame.style.border="0";frame.style.width='100%';frame.style.height='100%';frame.style.display="block";var div=this.wrapping=document.createElement("DIV");div.style.position="relative";div.className="CodeMirror-wrapping";div.style.width=options.width;div.style.height=options.height;var teHack=this.textareaHack=document.createElement("TEXTAREA");div.appendChild(teHack);teHack.style.position="absolute";teHack.style.left="-10000px";teHack.style.width="10px";frame.CodeMirror=this;if(options.domain&&internetExplorer){this.html=frameHTML(options);frame.src="javascript:(function(){document.open();"+
(options.domain?"document.domain=\""+options.domain+"\";":"")+"document.write(window.frameElement.CodeMirror.html);document.close();})()";}
else{frame.src="javascript:false";}
if(place.appendChild)place.appendChild(div);else place(div);div.appendChild(frame);if(options.lineNumbers)this.lineNumbers=addLineNumberDiv(div);this.win=frame.contentWindow;if(!options.domain||!internetExplorer){this.win.document.open();this.win.document.write(frameHTML(options));this.win.document.close();}}
CodeMirror.prototype={init:function(){if(this.options.initCallback)this.options.initCallback(this);if(this.options.lineNumbers)this.activateLineNumbers();if(this.options.reindentOnLoad)this.reindent();},getCode:function(){return this.editor.getCode();},setCode:function(code){this.editor.importCode(code);},selection:function(){this.focusIfIE();return this.editor.selectedText();},reindent:function(){this.editor.reindent();},reindentSelection:function(){this.focusIfIE();this.editor.reindentSelection(null);},focusIfIE:function(){if(this.win.select.ie_selection)this.focus();},focus:function(){this.win.focus();if(this.editor.selectionSnapshot)
this.win.select.setBookmark(this.win.document.body,this.editor.selectionSnapshot);},replaceSelection:function(text){this.focus();this.editor.replaceSelection(text);return true;},replaceChars:function(text,start,end){this.editor.replaceChars(text,start,end);},getSearchCursor:function(string,fromCursor,caseFold){return this.editor.getSearchCursor(string,fromCursor,caseFold);},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(callback,filter){this.editor.grabKeys(callback,filter);},ungrabKeys:function(){this.editor.ungrabKeys();},setParser:function(name){this.editor.setParser(name);},setSpellcheck:function(on){this.win.document.body.spellcheck=on;},setStylesheet:function(names){if(typeof names==="string")names=[names];var activeStylesheets={};var matchedNames={};var links=this.win.document.getElementsByTagName("link");for(var x=0,link;link=links[x];x++){if(link.rel.indexOf("stylesheet")!==-1){for(var y=0;y<names.length;y++){var name=names[y];if(link.href.substring(link.href.length-name.length)===name){activeStylesheets[link.href]=true;matchedNames[name]=true;}}}}
for(var x=0,link;link=links[x];x++){if(link.rel.indexOf("stylesheet")!==-1){link.disabled=!(link.href in activeStylesheets);}}
for(var y=0;y<names.length;y++){var name=names[y];if(!(name in matchedNames)){var link=this.win.document.createElement("link");link.rel="stylesheet";link.type="text/css";link.href=name;this.win.document.getElementsByTagName('head')[0].appendChild(link);}}},setTextWrapping:function(on){if(on==this.options.textWrapping)return;this.win.document.body.style.whiteSpace=on?"":"nowrap";this.options.textWrapping=on;if(this.lineNumbers){this.setLineNumbers(false);this.setLineNumbers(true);}},setIndentUnit:function(unit){this.win.indentUnit=unit;},setUndoDepth:function(depth){this.editor.history.maxDepth=depth;},setTabMode:function(mode){this.options.tabMode=mode;},setLineNumbers:function(on){if(on&&!this.lineNumbers){this.lineNumbers=addLineNumberDiv(this.wrapping);this.activateLineNumbers();}
else if(!on&&this.lineNumbers){this.wrapping.removeChild(this.lineNumbers);this.wrapping.style.marginLeft="";this.lineNumbers=null;}},cursorPosition:function(start){this.focusIfIE();return this.editor.cursorPosition(start);},firstLine:function(){return this.editor.firstLine();},lastLine:function(){return this.editor.lastLine();},nextLine:function(line){return this.editor.nextLine(line);},prevLine:function(line){return this.editor.prevLine(line);},lineContent:function(line){return this.editor.lineContent(line);},setLineContent:function(line,content){this.editor.setLineContent(line,content);},removeLine:function(line){this.editor.removeLine(line);},insertIntoLine:function(line,position,content){this.editor.insertIntoLine(line,position,content);},selectLines:function(startLine,startOffset,endLine,endOffset){this.win.focus();this.editor.selectLines(startLine,startOffset,endLine,endOffset);},nthLine:function(n){var line=this.firstLine();for(;n>1&&line!==false;n--)
line=this.nextLine(line);return line;},lineNumber:function(line){var num=0;while(line!==false){num++;line=this.prevLine(line);}
return num;},jumpToLine:function(line){if(typeof line=="number")line=this.nthLine(line);this.selectLines(line,0);this.win.focus();},currentLine:function(){return this.lineNumber(this.cursorLine());},cursorLine:function(){return this.cursorPosition().line;},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;function sizeBar(){if(frame.offsetWidth==0)return;for(var root=frame;root.parentNode;root=root.parentNode);if(!nums.parentNode||root!=document||!win.Editor){try{clear();}catch(e){}
clearInterval(sizeInterval);return;}
if(nums.offsetWidth!=barWidth){barWidth=nums.offsetWidth;nums.style.left="-"+(frame.parentNode.style.marginLeft=barWidth+"px");}}
function doScroll(){nums.scrollTop=body.scrollTop||doc.documentElement.scrollTop||0;}
var clear=function(){};sizeBar();var sizeInterval=setInterval(sizeBar,500);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;}}
doScroll();}
var onScroll=win.addEventHandler(win,"scroll",update,true),onResize=win.addEventHandler(win,"resize",update,true);clear=function(){onScroll();onResize();if(pending)clearTimeout(pending);};update();}
function wrapping(){var node,lineNum,next,pos;function addNum(n){if(!lineNum)lineNum=scroller.appendChild(document.createElement("DIV"));lineNum.innerHTML=n;pos=lineNum.offsetHeight+lineNum.offsetTop;lineNum=lineNum.nextSibling;}
function work(){if(!scroller.parentNode||scroller.parentNode!=self.lineNumbers)return;var endTime=new Date().getTime()+self.options.lineNumberTime;while(node){addNum(next++);for(;node&&!win.isBR(node);node=node.nextSibling){var bott=node.offsetTop+node.offsetHeight;while(scroller.offsetHeight&&bott-3>pos)addNum("&nbsp;");}
if(node)node=node.nextSibling;if(new Date().getTime()>endTime){pending=setTimeout(work,self.options.lineNumberDelay);return;}}
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++);doScroll();}
function start(){doScroll();node=body.firstChild;lineNum=scroller.firstChild;pos=0;next=1;work();}
start();var pending=null;function update(){if(pending)clearTimeout(pending);if(self.editor.allClean())start();else pending=setTimeout(update,200);}
self.updateNumbers=update;var onScroll=win.addEventHandler(win,"scroll",doScroll,true),onResize=win.addEventHandler(win,"resize",update,true);clear=function(){if(pending)clearTimeout(pending);if(self.updateNumbers==update)self.updateNumbers=null;onScroll();onResize();};}
(this.options.textWrapping?wrapping:nonWrapping)();}};CodeMirror.InvalidLineHandle={toString:function(){return"CodeMirror.InvalidLineHandle";}};CodeMirror.replace=function(element){if(typeof element=="string")
element=document.getElementById(element);return function(newElement){element.parentNode.replaceChild(newElement,element);};};CodeMirror.fromTextArea=function(area,options){if(typeof area=="string")
area=document.getElementById(area);options=options||{};if(area.style.width&&options.width==null)
options.width=area.style.width;if(area.style.height&&options.height==null)
options.height=area.style.height;if(options.content==null)options.content=area.value;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);}
function insert(frame){if(area.nextSibling)
area.parentNode.insertBefore(frame,area.nextSibling);else
area.parentNode.appendChild(frame);}
area.style.display="none";var mirror=new CodeMirror(insert,options);return mirror;};CodeMirror.isProbablySupported=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+)?)\./)))
return Number(match[1])>=3;else if(document.selection&&window.ActiveXObject&&(match=navigator.userAgent.match(/MSIE (\d+(?:\.\d*)?)\b/)))
return Number(match[1])>=6;else if(match=navigator.userAgent.match(/gecko\/(\d{8})/i))
return Number(match[1])>=20050901;else if(match=navigator.userAgent.match(/AppleWebKit\/(\d+)/))
return Number(match[1])>=525;else
return null;};return CodeMirror;})();$j(function($){$(document).ready(function(){var config_liquid={height:"500px",parserfile:["parsexml.js","parsecss.js","tokenizejavascript.js","parsejavascript.js","parsehtmlmixed.js"],stylesheet:["/javascripts/CodeMirror-0.67/css/xmlcolors.css","/javascripts/CodeMirror-0.67/css/jscolors.css","/javascripts/CodeMirror-0.67/css/csscolors.css"],path:"/javascripts/CodeMirror-0.67/js/",lineNumbers:true};$('textarea.tinymce_liquid').each(function(i){var editor=CodeMirror.fromTextArea(this.id,config_liquid);ldo=$(this).metadata().liquidictionaryOptions;if(ldo.length>0){var sel=$('<select><option>Insert Tag...</option></select>').change(function(){editor.replaceSelection('{{ '+sel.val()+' }}');sel[0].selectedIndex=0;});$.each(ldo,function(i,pair){sel.append($("<option></option>").attr("value",pair[1]).text(pair[0]));});$(this).closest('div').before(sel);}});});});