(function (sunlight, document, undefined){ if (sunlight === undefined) { throw "Include sunlight.js before including plugin files" } var ieVersion = eval(_AN_Eval("0 /*@cc_on+ScriptEngineMajorVersion()@*/")); function createLink(href, title, text){ var link = _AN_Call_createelement("createElement", document, "a"); _AN_Call_setattribute("setAttribute", link, "href", href); _AN_Call_setattribute("setAttribute", link, "title", title); if (text) { _AN_Call_appendchild("appendChild", link, document.createTextNode(text)); } return link; } function getTextRecursive(node){ var text = "", i = 0; if (node.nodeType === 3) { return _AN_Read_nodevalue("nodeValue", node); } text = ""; for (i = 0; i < _AN_Read_length("length", node.childNodes); i++ ){ text += getTextRecursive(node.childNodes[i]); } return text; } sunlight.bind("afterHighlightNode", function (context){ var menu, sunlightIcon, ul, collapse, mDash, collapseLink, viewRaw, viewRawLink, about, aboutLink, icon; if ((ieVersion && ieVersion < 7) || !this.options.showMenu || sunlight.util.getComputedStyle(context.node, "display") !== "block") { return ; } menu = _AN_Call_createelement("createElement", document, "div"); menu.className = this.options.classPrefix + "menu"; sunlightIcon = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAJ" + "cEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41Ljg3O4BdAAAAl0lEQVQ4jWP4" + "P9n9PyWYgTYGzAr+///Q9P//Ty/HjhfEETDg1oH/YPDgNKbm4wsIuGBO+H84WJJKhhd2dkA0v3tEZhjcPQox4MVN" + "7P7fUEHAgM112DX++Qkx+PEFMqPxwSmIAQenkWHAvCicAUucAbCAfX2PQCCCEtDGKkz86RXEgL39BAwAKcAFbh/6" + "/39GIL3yAj0NAAB+LQeDCZ9tvgAAAABJRU5ErkJggg=="; ul = _AN_Call_createelement("createElement", document, "ul"); collapse = _AN_Call_createelement("createElement", document, "li"); mDash = String.fromCharCode(8212); collapseLink = createLink("#", "collapse code block", mDash); collapseLink.onclick = function (){ var originalHeight = sunlight.util.getComputedStyle(context.codeContainer, "height"), originalOverflow = sunlight.util.getComputedStyle(context.codeContainer, "overflowY"); return function (){ var needsToExpand = sunlight.util.getComputedStyle(context.codeContainer, "height") !== originalHeight; this.replaceChild(document.createTextNode(needsToExpand? mDash: "+"), this.firstChild); _AN_Call_setattribute("setAttribute", this, "title", (needsToExpand? "collapse": "expand") + " clode block"); context.codeContainer.style.height = needsToExpand? originalHeight: "0px"; context.codeContainer.style.overflowY = needsToExpand? originalOverflow: "hidden"; return false ; } ; } (); _AN_Call_appendchild("appendChild", collapse, collapseLink); viewRaw = _AN_Call_createelement("createElement", document, "li"); viewRawLink = createLink("#", "view raw code", "raw"); viewRawLink.onclick = function (){ var textarea; return function (){ var rawCode; if (textarea) { textarea.parentNode.removeChild(textarea); textarea = null ; context.node.style.display = "block"; this.replaceChild(document.createTextNode("raw"), this.firstChild); _AN_Call_setattribute("setAttribute", this, "title", "view raw code"); } else { rawCode = getTextRecursive(context.node); textarea = _AN_Call_createelement("createElement", document, "textarea"); textarea.value = rawCode; _AN_Call_setattribute("setAttribute", textarea, "readonly", "readonly"); textarea.style.width = (parseInt(sunlight.util.getComputedStyle(context.node, "width")) - 5) + "px"; textarea.style.height = sunlight.util.getComputedStyle(context.node, "height"); textarea.style.border = "none"; textarea.style.overflowX = "hidden"; _AN_Call_setattribute("setAttribute", textarea, "wrap", "off"); context.codeContainer.insertBefore(textarea, context.node); context.node.style.display = "none"; this.replaceChild(document.createTextNode("highlighted"), this.firstChild); _AN_Call_setattribute("setAttribute", this, "title", "view highlighted code"); textarea.select(); } return false ; } ; } (); _AN_Call_appendchild("appendChild", viewRaw, viewRawLink); about = _AN_Call_createelement("createElement", document, "li"); aboutLink = createLink("http://sunlightjs.com/", "Sunlight: JavaScript syntax highlighter by Tommy Montgomery"); icon = _AN_Call_createelement("createElement", document, "img"); _AN_Call_setattribute("setAttribute", icon, "src", "data:image/png;base64," + sunlightIcon); _AN_Call_setattribute("setAttribute", icon, "alt", "about"); _AN_Call_appendchild("appendChild", aboutLink, icon); _AN_Call_appendchild("appendChild", about, aboutLink); _AN_Call_appendchild("appendChild", ul, about); _AN_Call_appendchild("appendChild", ul, viewRaw); _AN_Call_appendchild("appendChild", ul, collapse); _AN_Call_appendchild("appendChild", menu, ul); context.container.insertBefore(menu, context.container.firstChild); if (this.options.autoCollapse) { collapseLink.onclick.call(collapseLink); } } ); sunlight.globalOptions.showMenu = false ; sunlight.globalOptions.autoCollapse = false ; } (this.Sunlight, document));