Mercurial > eldonilo > barbecue
diff index.xhtml @ 1:eb3679d92996
put JS and CSS code in separated files
author | Sonny Piers <sonny.piers@gmail.com> |
---|---|
date | Sun, 18 Dec 2011 19:49:32 +0100 |
parents | 891d16fda2e2 |
children | 683f56999fb3 |
line wrap: on
line diff
--- a/index.xhtml +++ b/index.xhtml @@ -2,198 +2,10 @@ <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> + <title> barbecue </title> <meta charset="UTF-8" /> - <title> contentEditable </title> - <script type="text/javascript">//<![CDATA[ - var - gActiveEditor = null, // active editing host - gCommandDump = null; // command dump field - function ExecCommand(toolbarElement) { - var argVal, argStr, - type = toolbarElement.getAttribute("type"), - command = toolbarElement.getAttribute("data-command"); - switch (type) { // get the execCommand argument according to the button type - case "button": // toolbar button: no argument - argVal = argStr = false; - break; - case "checkbox": // styleWithCSS: boolean argument - argVal = argStr = "" + toolbarElement.checked + ""; - break; - default: // <select> menu: string argument - if (!toolbarElement.selectedIndex) return; - argVal = toolbarElement.value; - argStr = "'" + argVal.replace("<", "<").replace(">", ">") + "'"; - toolbarElement.selectedIndex = 0; // reset drop-down list - } - document.execCommand(command, false, argVal); // send requested action - if (gActiveEditor) gActiveEditor.focus(); // re-focus the editable element - gCommandDump.innerHTML = "document.execCommand('" + command + "', false, '" + argStr + "');"; - } - window.addEventListener("DOMContentLoaded", function() { - var i, - buttons = document.querySelectorAll("*[data-command]"), - editors = document.querySelectorAll("*[contenteditable]"); - for (i = 0; i < buttons.length; i++) { - buttons[i].onclick = function() { ExecCommand(this); }; - buttons[i].onchange = function() { ExecCommand(this); }; - } - for (i = 0; i < editors.length; i++) - editors[i].onfocus = function() { gActiveEditor = this; }; - gCommandDump = document.querySelector("#execCommand"); - ExecCommand(document.querySelector("#useCSS")); - }, false); - //]]></script> - <style type="text/css"> - html { - background: #111; - color: #eee; - font-family: sans-serif; - font-size: 12px; - } - body { - margin: 1em auto; - padding: 5px 20px; - width: 600px; - background: #eee; - color: #111; - border: 2px solid #eee; - overflow: auto; - } - *[contenteditable] { - margin: 1em 0; - padding: 10px; - background: #fff; - color: #111; - border: 1px solid #ddd; - outline: none; - resize: both; - } - #execCommand { - padding-left: 5em; - min-height: 1em; - line-height: 1em; - color: #555; - } - footer { - border-top: 1px solid #ccc; - } - #toolbar { - border-bottom: 1px solid #ccc; - } - #toolbar dt { - float: left; - clear: both; - width: 5em; - line-height: 24px; - } - #toolbar dd { - line-height: 24px; - } - #toolbar input { - /* toolbar images taken from CKEditor */ - background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAUPCAMAAACIlZC6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAMAUExURQAAAB5DQ///AANNxxU+PpiYmPeRKwMwMFPsYh0fojMzMw04OKQKABk3LLAOABwipq/V89jY2SgroVRXqSczrvGxU5WxHyVGRvz8/P9nAe3XW+yUJNQ6ARxCQstVBpWYyLkWAARY9FGP7Pt9DscmAmmd7uDcr2turz9Cpd53CHHI6YWIvN/e7A+bA42ANXuq8WdeNHGVDvfHCydFxRE7O/GRHP8AAJHU7vDw8tK5nxg/QPz//09xBgQYhu/oyMKBcNpoDaOkpPdeK4okAE9lx+LHwhY+Phhp7s/n5rrLeBJOzy5KSlTuYNx2GPCKV09SQ7uveB9l3LpXROrq7Q1Fy/f397/b2aeorMBIOAAzzP79Avz8A+iHGAY4x7rA3VHsXpC49OLg6gUyMv/+AefZ1DVNTIiIiPj7+jNMTAEhXUTdU/LuDObm5t3YEqusrP7+Avf153h4d8ubgPaPFjFKTylIRfaiNh1BR+biEzFMSCFERHJycpqamnqtZxk+Tvj18w4VnfDl4rdqUnd4cQAgqDxKQAIsvwIlT62toT5QUAA5OaenrPDuEQgzsA4qYCJCRKGhnvz7BAc3vxQ9PQpD0BQ8QDmB7a2trSRFRUBRUf///x0eoODg4JeXlwxxtrS2tvmbI3QxDf6RB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uunAj1hwAAYHzv3l80Nu/pH+9f9Sta7Yd7+xtP9Y+Pj/fzlo3vbd7z4fj4uGjqpxfGL4yPX/glc1/baQQHT548EDSCr3DJa7tf3b17924AgP8bADsP4s1ClpYJAAAAAElFTkSuQmCC); - height: 20px; - width: 20px; - } - #toolbar *[disabled] { - opacity: 0.5; - } - #toolbar *[data-command="increaseFontSize"], - #toolbar *[data-command="decreaseFontSize"] { - background-image: none; - } - #toolbar *[type="checkbox"] { - margin: 0; - padding: 0; - vertical-align: middle; - background-image: none; - } - *[data-command="cut"] { background-position: 0 -96px; } - *[data-command="copy"] { background-position: 0 -112px; } - *[data-command="paste"] { background-position: 0 -128px; } - *[data-command="undo"] { background-position: 0 -208px; } - *[data-command="redo"] { background-position: 0 -224px; } - *[data-command="bold"] { background-position: 0 -304px; } - *[data-command="italic"] { background-position: 0 -320px; } - *[data-command="underline"] { background-position: 0 -336px; } - *[data-command="strikeThrough"] { background-position: 0 -352px; } - *[data-command="subscript"] { background-position: 0 -368px; } - *[data-command="superscript"] { background-position: 0 -384px; } - *[data-command="insertOrderedList"] { background-position: 0 -400px; } - *[data-command="insertUnorderedList"] { background-position: 0 -416px; } - *[data-command="outdent"] { background-position: 0 -432px; } - *[data-command="indent"] { background-position: 0 -448px; } - *[data-command="justifyLeft"] { background-position: 0 -464px; } - *[data-command="justifyCenter"] { background-position: 0 -480px; } - *[data-command="justifyRight"] { background-position: 0 -496px; } - *[data-command="justifyFull"] { background-position: 0 -512px; } - </style> - <!-- - - Mutation Events: - - https://developer.mozilla.org/en/XUL/Events#Mutation_DOM_events - --> - <script type="text/javascript">//<![CDATA[ - var gBreadCrumb = null; - function updateBreadCrumb(node, action) { - if (!gBreadCrumb || !node || (node == document.body)) return; - var - body = document.body, - text = node.nodeName, - tmp = node.parentNode; - while (tmp && tmp != body) { - text = tmp.nodeName + " > " + text; - tmp = tmp.parentNode; - } - text = action + ": " + text; - gBreadCrumb.innerHTML = text; - console.log(text); - } - - // retrieve the startContainer of the current selection - var gLastFocusNode = null; - function getSelectionStart() { - var node = document.getSelection().anchorNode; - return (node.nodeName == "#text" ? node.parentNode : node); - } - function onCaretMove(event, action) { - var selection = document.getSelection(); - var node = selection.isCollapsed ? selection.focusNode - : selection.getRangeAt(0).commonAncestorContainer; - if (node != gLastFocusNode) { - updateBreadCrumb(node, action); - gLastFocusNode = node; - } - } - - window.addEventListener("DOMContentLoaded", function() { - gBreadCrumb = document.querySelector("#breadcrumb"); - - function onAttrModified(event) { updateBreadCrumb(event.target, "keypress"); } - function onNodeInserted(event) { updateBreadCrumb(event.target, "inserted"); } - function onNodeRemoved(event) { updateBreadCrumb(event.target, "removed "); } - - function onKeyUp(event) { onCaretMove(event, "keyup"); } - function onClick(event) { onCaretMove(event, "click"); } - - // listening to mutation events on 'document' freezes Firefox :-/ - var i, editors = document.querySelectorAll("*[contenteditable]"); - for (i = 0; i < editors.length; i++) { - // mutation events -- do we really need them? - editors[i].addEventListener("DOMAttrModified", onAttrModified, false); - editors[i].addEventListener("DOMNodeInserted", onNodeInserted, false); - editors[i].addEventListener("DOMNodeRemoved", onNodeRemoved, false); - // caret movements - //editors[i].addEventListener("textinput", onKeyUp, false); - editors[i].addEventListener("keyup", onKeyUp, false); - editors[i].addEventListener("mouseup", onClick, false); - } - }, false); - //]]></script> - <style type="text/css"> - .attrModified { border: 1px dashed red; } - .nodeModified { border: 1px dashed navy; } - .nodeInserted { border: 1px dotted brown; } - </style> + <link type="text/css" href="style.css" rel="stylesheet" /> + <script type="text/javascript" src="script.js"/> </head> <body> <form id="toolbar">