diff --git a/public/images/icons/cancel.png b/public/images/icons/cancel.png new file mode 100644 index 0000000..c149c2b Binary files /dev/null and b/public/images/icons/cancel.png differ diff --git a/public/images/icons/text_heading_1.png b/public/images/icons/text_heading_1.png new file mode 100644 index 0000000..9c122e9 Binary files /dev/null and b/public/images/icons/text_heading_1.png differ diff --git a/public/images/icons/text_heading_2.png b/public/images/icons/text_heading_2.png new file mode 100644 index 0000000..fbd8765 Binary files /dev/null and b/public/images/icons/text_heading_2.png differ diff --git a/public/images/icons/text_heading_3.png b/public/images/icons/text_heading_3.png new file mode 100644 index 0000000..c7836cf Binary files /dev/null and b/public/images/icons/text_heading_3.png differ diff --git a/public/images/icons/text_heading_4.png b/public/images/icons/text_heading_4.png new file mode 100644 index 0000000..4e929ea Binary files /dev/null and b/public/images/icons/text_heading_4.png differ diff --git a/public/images/icons/text_heading_5.png b/public/images/icons/text_heading_5.png new file mode 100644 index 0000000..30cabeb Binary files /dev/null and b/public/images/icons/text_heading_5.png differ diff --git a/public/images/icons/text_heading_6.png b/public/images/icons/text_heading_6.png new file mode 100644 index 0000000..058170a Binary files /dev/null and b/public/images/icons/text_heading_6.png differ diff --git a/public/javascripts/wysihat_engine_pack.js b/public/javascripts/wysihat_engine_pack.js index e0471a5..5d5c1f0 100644 --- a/public/javascripts/wysihat_engine_pack.js +++ b/public/javascripts/wysihat_engine_pack.js @@ -1 +1 @@ -var Facebox=Class.create({initialize:function(a){this.settings={loading_image:"/images/facebox/loading.gif",close_image:"/images/facebox/closelabel.gif",image_types:new RegExp("."+["png","jpg","jpeg","gif"].join("|")+"$","i"),inited:true,facebox_html:' '};if(a){Object.extend(this.settings,a)}$(document.body).insert({bottom:this.settings.facebox_html});this.preload=[new Image(),new Image()];this.preload[0].src=this.settings.close_image;this.preload[1].src=this.settings.loading_image;f=this;$$("#facebox .b:first, #facebox .bl, #facebox .br, #facebox .tl, #facebox .tr").each(function(b){f.preload.push(new Image());f.preload.slice(-1).src=b.getStyle("background-image").replace(/url\((.+)\)/,"$1")});this.facebox=$("facebox");this.keyPressListener=this.watchKeyPress.bindAsEventListener(this);this.watchClickEvents();fb=this;Event.observe($$("#facebox .close").first(),"click",function(b){Event.stop(b);fb.close()});Event.observe($$("#facebox .close_image").first(),"click",function(b){Event.stop(b);fb.close()})},watchKeyPress:function(a){if(a.keyCode==27||!Event.element(a).descendantOf(this.facebox)){this.close()}},watchClickEvents:function(b){var a=this;$$("a[rel=facebox]").each(function(d,c){Event.observe(d,"click",function(g){Event.stop(g);a.click_handler(d,g)})})},loading:function(){if($$("#facebox .loading").length==1){return true}contentWrapper=$$("#facebox .content").first();contentWrapper.childElements().each(function(c,b){c.remove()});contentWrapper.insert({bottom:'
'});var a=document.viewport.getScrollOffsets();this.facebox.setStyle({top:a.top+(document.viewport.getHeight()/10)+"px",left:document.viewport.getWidth()/2-(this.facebox.getWidth()/2)+"px"});Event.observe(document,"keypress",this.keyPressListener);Event.observe(document,"click",this.keyPressListener)},reveal:function(b,a){this.loading();load=$$("#facebox .loading").first();if(load){load.remove()}contentWrapper=$$("#facebox .content").first();if(a){contentWrapper.addClassName(a)}contentWrapper.update(b);$$("#facebox .body").first().childElements().each(function(d,c){d.show()});if(!this.facebox.visible()){new Effect.Appear(this.facebox,{duration:0.3})}this.facebox.setStyle({left:document.viewport.getWidth()/2-(this.facebox.getWidth()/2)+"px"});Event.observe(document,"keypress",this.keyPressListener);Event.observe(document,"click",this.keyPressListener)},close:function(){new Effect.Fade("facebox",{duration:0.3})},click_handler:function(c,i){this.loading();Event.stop(i);var k=c.rel.match(/facebox\[\.(\w+)\]/);if(k){k=k[1]}new Effect.Appear(this.facebox,{duration:0.3});if(c.href.match(/#/)){var a=window.location.href.split("#")[0];var j=c.href.replace(a+"#","");var l=$(j);var h=new Element(l.tagName);h.innerHTML=l.innerHTML;this.reveal(h,k)}else{if(c.href.match(this.settings.image_types)){var g=new Image();b=this;g.onload=function(){b.reveal('
',k)};g.src=c.href}else{var b=this;var a=c.href;new Ajax.Request(a,{method:"get",onFailure:function(d){b.reveal(d.responseText,k)},onSuccess:function(d){b.reveal(d.responseText,k)}})}}}});var facebox;document.observe("dom:loaded",function(){facebox=new Facebox()});var WysiHat={};WysiHat.Editor={attach:function(a,c,e){c=$H(c);a=$(a);a.hide();var b=c.get("model")||WysiHat.iFrame;var d=e;return b.create(a,function(h){var g=h.getDocument();var i=h.getWindow();h.load();Event.observe(i,"focus",function(j){h.focus()});Event.observe(i,"blur",function(j){h.blur()});h._observeEvents();if(Prototype.Browser.Gecko){h.execCommand("undo",false,null)}if(d){d(h)}h.focus()})},include:function(a){this.includedModules=this.includedModules||$A([]);this.includedModules.push(a)},extend:function(b){var a=this.includedModules||$A([]);a.each(function(c){Object.extend(b,c)})}};WysiHat.Commands=(function(){function l(){this.execCommand("bold",false,null)}function w(){return this.queryCommandState("bold")}function H(){this.execCommand("underline",false,null)}function x(){return this.queryCommandState("underline")}function t(){this.execCommand("italic",false,null)}function F(){return this.queryCommandState("italic")}function v(){this.execCommand("strikethrough",false,null)}function g(){this.execCommand("blockquote",false,null)}function q(I){this.execCommand("fontname",false,I)}function m(){var I=this.selection.getNode();return Element.getStyle(I,"fontFamily")}function u(I){this.execCommand("fontsize",false,I)}function c(){var I=this.selection.getNode();return r(Element.getStyle(I,"fontSize"))}function G(I){this.execCommand("forecolor",false,I)}function k(){var I=this.selection.getNode();return y(Element.getStyle(I,"color"))}function p(I){if(Prototype.Browser.Gecko){this.execCommand("hilitecolor",false,I)}else{this.execCommand("backcolor",false,I)}}function a(){var I=this.selection.getNode();return y(Element.getStyle(I,"backgroundColor"))}function E(I){this.execCommand("justify"+I)}function d(){var I=this.selection.getNode();return Element.getStyle(I,"textAlign")}function j(I){this.execCommand("createLink",false,I)}function i(){var I=this.selection.getNode();if(this.linkSelected()){this.selection.selectNode(I)}this.execCommand("unlink",false,null)}function C(){var I=this.selection.getNode();return I?I.tagName.toUpperCase()=="A":false}function o(){this.execCommand("insertorderedlist",false,null)}function n(){this.execCommand("insertunorderedlist",false,null)}function e(I){this.execCommand("insertImage",false,I)}function b(J){if(Prototype.Browser.IE){var I=this._selection.getRange();I.pasteHTML(J);I.collapse(false);I.select()}else{this.execCommand("insertHTML",false,J)}}function A(M,L,K){var I=this.getDocument();if(Prototype.Browser.IE){this.selection.restore()}var J=this.commands.get(M);if(J){J.bind(this)(K)}else{I.execCommand(M,L,K)}}function h(K){var I=this.getDocument();var J=this.queryCommands.get(K);if(J){return J.bind(this)()}else{return I.queryCommandState(K)}}var B=$w("xxx-small xx-small x-small small medium large x-large xx-large");var D=$w("9px 10px 13px 16px 18px 24px 32px 48px");if(Prototype.Browser.WebKit){B.shift();B.push("-webkit-xxx-large")}function r(J){var I=B.indexOf(J);if(I>=0){return I}I=D.indexOf(J);if(I>=0){return I}return parseInt(J)}function y(M){if(!M||M.match(/[0-9a-f]{6}/i)){return M}var J=M.toLowerCase().match(/^(rgba?|hsla?)\(([\s\.\-,%0-9]+)\)/);if(J){var P=J[2].split(/\s*,\s*/),K=P.length,V=J[1];if((V=="rgb"&&K==3)||(V=="rgba"&&K==4)){var I=P[0];if(I.charAt(I.length-1)=="%"){var Q=P.map(function(L){return parseFloat(L)*2.56});if(K==4){Q[3]=P[3]}return z(Q)}return z(P)}if((V=="hsl"&&K==3)||(V=="hsla"&&K==4)){var R=((parseFloat(P[0])%360)+360)%360/360,N=parseFloat(P[1])/100,O=parseFloat(P[2])/100,T=O<=0.5?O*(N+1):O+N-O*N,U=2*O-T,Q=[s(U,T,R+1/3)*256,s(U,T,R)*256,s(U,T,R-1/3)*256,1];if(K==4){Q[3]=P[3]}return z(Q)}}return null}function z(J){var I=J.slice(0,3).map(function(K){var L=parseInt(K).toString(16);return L.length<2?"0"+L:L});return"#"+I.join("")}function s(J,I,K){if(K<0){++K}if(K>1){--K}var L=6*K;if(L<1){return J+(I-J)*L}if(2*K<1){return I}if(3*K<2){return J+(I-J)*(2/3-K)*6}return J}return{boldSelection:l,boldSelected:w,underlineSelection:H,underlineSelected:x,italicSelection:t,italicSelected:F,strikethroughSelection:v,blockquoteSelection:g,fontSelection:q,fontSelected:m,fontSizeSelection:u,fontSizeSelected:c,colorSelection:G,colorSelected:k,backgroundColorSelection:p,backgroundColorSelected:a,alignSelection:E,alignSelected:d,linkSelection:j,unlinkSelection:i,linkSelected:C,insertOrderedList:o,insertUnorderedList:n,insertImage:e,insertHTML:b,execCommand:A,queryCommandState:h,commands:$H({}),queryCommands:$H({link:C})}})();WysiHat.Editor.include(WysiHat.Commands);WysiHat.Events=(function(){var a=["click","dblclick","mousedown","mouseup","mouseover","mousemove","mouseout","keypress","keydown","keyup"];function b(j,k){a.each(function(l){Event.observe(j,l,function(m){k.fire("wysihat:"+l)})})}function g(l,j,k){Event.observe(j,"keydown",function(m){if(m.keyCode==86){k.fire("wysihat:paste")}});Event.observe(l,"paste",function(m){k.fire("wysihat:paste")})}function c(k,j){Event.observe(k,"focus",function(l){j.fire("wysihat:focus")});Event.observe(k,"blur",function(l){j.fire("wysihat:blur")})}function i(j,k){Event.observe(j,"mouseup",function(m){var l=k.selection.getRange();if(!l.collapsed){k.fire("wysihat:select")}})}function e(j,k){var l=k.rawContent();Event.observe(j,"keyup",function(n){var m=k.rawContent();if(l!=m){k.fire("wysihat:change");l=m}})}function d(j,l){var m=l.selection.getRange();var k=function(o){var n=l.selection.getRange();if(m!=n){l.fire("wysihat:cursormove");m=n}};Event.observe(j,"keyup",k);Event.observe(j,"mouseup",k)}function h(){if(this._observers_setup){return}var j=this.getDocument();var k=this.getWindow();b(j,this);g(k,j,this);c(k,this);i(j,this);e(j,this);d(j,this);this._observers_setup=true}return{_observeEvents:h}})();WysiHat.Editor.include(WysiHat.Events);WysiHat.Persistence=(function(){function h(i){return i.formatHTMLOutput()}function a(i){return i.formatHTMLInput()}function e(){return this.outputFilter(this.rawContent())}function d(i){this.setRawContent(this.inputFilter(i))}function c(){this.textarea.value=this.content()}function g(){this.setContent(this.textarea.value)}function b(){this.selection.setBookmark();this.save();this.load();this.selection.moveToBookmark()}return{outputFilter:h,inputFilter:a,content:e,setContent:d,save:c,load:g,reload:b}})();WysiHat.Editor.include(WysiHat.Persistence);WysiHat.Window=(function(){function c(){return this.contentDocument||this.contentWindow.document}function b(){if(this.contentDocument&&this.contentDocument.defaultView){return this.contentDocument.defaultView}else{if(this.contentWindow.document){return this.contentWindow}else{return null}}}function a(){this.getWindow().focus();if(this.hasFocus){return}this.hasFocus=true}function d(){this.hasFocus=false}return{getDocument:c,getWindow:b,focus:a,blur:d}})();WysiHat.Editor.include(WysiHat.Window);WysiHat.iFrame={create:function(a,c){var b=new Element("iframe",{id:a.id+"_editor","class":"editor"});Object.extend(b,WysiHat.iFrame.Methods);WysiHat.Editor.extend(b);b.attach(a,c);a.insert({before:b});return b}};WysiHat.iFrame.Methods={attach:function(a,b){this.textarea=a;this.observe("load",function(){try{var c=this.getDocument()}catch(d){return}this.selection=new WysiHat.Selection(this);if(this.ready&&c.designMode=="on"){return}this.setStyle({});c.designMode="on";b(this);this.ready=true;this.fire("wysihat:ready")})},unattach:function(){this.remove()},whenReady:function(b){if(this.ready){b(this)}else{var a=this;a.observe("wysihat:ready",function(){b(a)})}return this},setStyle:function(e){var a=this.getDocument();var c=this;if(!this.ready){return setTimeout(function(){c.setStyle(e)},1)}if(Prototype.Browser.IE){var d=a.createStyleSheet();d.addRule("body","border: 0");d.addRule("p","margin: 0");$H(e).each(function(h){var g=h.first().underscore().dasherize()+": "+h.last();d.addRule("body",g)})}else{if(Prototype.Browser.Opera){var d=Element("style").update("p { margin: 0; }");var b=a.getElementsByTagName("head")[0];b.appendChild(d)}else{Element.setStyle(a.body,e)}}return this},getStyle:function(b){var a=this.getDocument();return Element.getStyle(a.body,b)},rawContent:function(){var a=this.getDocument();if(a.body){return a.body.innerHTML}else{return""}},setRawContent:function(b){var a=this.getDocument();if(a.body){a.body.innerHTML=b}}};WysiHat.Editable={create:function(a,c){var b=new Element("div",{id:a.id+"_editor","class":"editor",contenteditable:"true"});b.textarea=a;WysiHat.Editor.extend(b);Object.extend(b,WysiHat.Editable.Methods);c(b);a.insert({before:b});return b}};WysiHat.Editable.Methods={getDocument:function(){return document},getWindow:function(){return window},rawContent:function(){return this.innerHTML},setRawContent:function(a){this.innerHTML=a}};Object.extend(String.prototype,(function(){function a(){var k=String(this);k=k.tidyXHTML();if(Prototype.Browser.WebKit){k=k.replace(/(
)+/g,"\n");k=k.replace(/(<\/div>)+/g,"");k=k.replace(/

\s*<\/p>/g,"");k=k.replace(/
(\n)*/g,"\n")}else{if(Prototype.Browser.Gecko){k=k.replace(/

/g,"");k=k.replace(/<\/p>(\n)?/g,"\n");k=k.replace(/
(\n)*/g,"\n")}else{if(Prototype.Browser.IE||Prototype.Browser.Opera){k=k.replace(/

( | |\s)<\/p>/g,"

");k=k.replace(/
/g,"");k=k.replace(/

/g,"");k=k.replace(/ /g,"");k=k.replace(/<\/p>(\n)?/g,"\n");k=k.gsub(/^

/,"");k=k.gsub(/<\/p>$/,"")}}}k=k.gsub(//,"");k=k.gsub(/<\/b>/,"");k=k.gsub(//,"");k=k.gsub(/<\/i>/,"");k=k.replace(/\n\n+/g,"

\n\n

");k=k.gsub(/(([^\n])(\n))(?=([^\n]))/,"#{2}
\n");k="

"+k+"

";k=k.replace(/

\s*/g,"

");k=k.replace(/\s*<\/p>/g,"

");var e=Element("body");e.innerHTML=k;if(Prototype.Browser.WebKit||Prototype.Browser.Gecko){var j;do{j=false;e.select("span").each(function(i){if(i.hasClassName("Apple-style-span")){i.removeClassName("Apple-style-span");if(i.className==""){i.removeAttribute("class")}j=true}else{if(i.getStyle("fontWeight")=="bold"){i.setStyle({fontWeight:""});if(i.style.length==0){i.removeAttribute("style")}i.update(""+i.innerHTML+"");j=true}else{if(i.getStyle("fontStyle")=="italic"){i.setStyle({fontStyle:""});if(i.style.length==0){i.removeAttribute("style")}i.update(""+i.innerHTML+"");j=true}else{if(i.getStyle("textDecoration")=="underline"){i.setStyle({textDecoration:""});if(i.style.length==0){i.removeAttribute("style")}i.update(""+i.innerHTML+"");j=true}else{if(i.attributes.length==0){i.replace(i.innerHTML);j=true}}}}}})}while(j)}var h=$A(["BR","IMG"]);for(var d=0;d(\n)*/g,"
\n");k=k.replace(/<\/p>\n

/g,"

\n\n

");k=k.replace(/

\s*<\/p>/g,"");k=k.replace(/\s*$/g,"");return k}function b(){var e=String(this);var d=Element("body");d.innerHTML=e;if(Prototype.Browser.Gecko||Prototype.Browser.WebKit){d.select("strong").each(function(g){g.replace(''+g.innerHTML+"")});d.select("em").each(function(g){g.replace(''+g.innerHTML+"")});d.select("u").each(function(g){g.replace(''+g.innerHTML+"")})}if(Prototype.Browser.WebKit){d.select("span").each(function(g){if(g.getStyle("fontWeight")=="bold"){g.addClassName("Apple-style-span")}if(g.getStyle("fontStyle")=="italic"){g.addClassName("Apple-style-span")}if(g.getStyle("textDecoration")=="underline"){g.addClassName("Apple-style-span")}})}e=d.innerHTML;e=e.tidyXHTML();e=e.replace(/<\/p>(\n)*

/g,"\n\n");e=e.replace(/(\n)?(\n)?/g,"\n");e=e.replace(/^

/g,"");e=e.replace(/<\/p>$/g,"");if(Prototype.Browser.Gecko){e=e.replace(/\n/g,"
");e=e+"
"}else{if(Prototype.Browser.WebKit){e=e.replace(/\n/g,"

");e="
"+e+"
";e=e.replace(/
<\/div>/g,"

")}else{if(Prototype.Browser.IE||Prototype.Browser.Opera){e=e.replace(/\n/g,"

\n

");e="

"+e+"

";e=e.replace(/

<\/p>/g,"

 

");e=e.replace(/(

 <\/p>)+$/g,"")}}}return e}function c(){var d=String(this);d=d.gsub(/\r\n?/,"\n");d=d.gsub(/<([A-Z]+)([^>]*)>/,function(e){return"<"+e[1].toLowerCase()+e[2]+">"});d=d.gsub(/<\/([A-Z]+)>/,function(e){return""});d=d.replace(/
/g,"
");return d}return{formatHTMLOutput:a,formatHTMLInput:b,tidyXHTML:c}})());Object.extend(String.prototype,{sanitize:function(a){return Element("div").update(this).sanitize(a).innerHTML.tidyXHTML()}});Element.addMethods({sanitize:function(c,b){c=$(c);b=$H(b);var a=$A(b.get("tags")||[]);var d=$A(b.get("attributes")||[]);var e=Element(c.nodeName);$A(c.childNodes).each(function(i){if(i.nodeType==1){var g=$(i).sanitize(b).childNodes;if(a.include(i.nodeName.toLowerCase())){var h=Element(i.nodeName);d.each(function(j){if((value=i.readAttribute(j))){h.writeAttribute(j,value)}});e.appendChild(h);$A(g).each(function(j){h.appendChild(j)})}else{$A(g).each(function(j){e.appendChild(j)})}}else{if(i.nodeType==3){e.appendChild(i)}}});return e}});if(typeof Range=="undefined"){Range=function(a){this.ownerDocument=a;this.startContainer=this.ownerDocument.documentElement;this.startOffset=0;this.endContainer=this.ownerDocument.documentElement;this.endOffset=0;this.collapsed=true;this.commonAncestorContainer=this._commonAncestorContainer(this.startContainer,this.endContainer);this.detached=false;this.START_TO_START=0;this.START_TO_END=1;this.END_TO_END=2;this.END_TO_START=3};Range.CLONE_CONTENTS=0;Range.DELETE_CONTENTS=1;Range.EXTRACT_CONTENTS=2;if(!document.createRange){document.createRange=function(){return new Range(this)}}Object.extend(Range.prototype,(function(){function r(){return e(this,Range.CLONE_CONTENTS)}function x(){try{var z=new Range(this.ownerDocument);z.startContainer=this.startContainer;z.startOffset=this.startOffset;z.endContainer=this.endContainer;z.endOffset=this.endOffset;z.collapsed=this.collapsed;z.commonAncestorContainer=this.commonAncestorContainer;z.detached=this.detached;return z}catch(y){return null}}function b(y){if(y){this.endContainer=this.startContainer;this.endOffset=this.startOffset;this.collapsed=true}else{this.startContainer=this.endContainer;this.startOffset=this.endOffset;this.collapsed=true}}function a(z,E){try{var A,D,C,y;A=this.commonAncestorContainer;D=E.commonAncestorContainer;C=A;while(C.parentNode){C=C.parentNode}y=D;while(y.parentNode){y=y.parentNode}switch(z){case this.START_TO_START:return p(this,this.startContainer,this.startOffset,E.startContainer,E.startOffset);break;case this.START_TO_END:return p(this,this.startContainer,this.startOffset,E.endContainer,E.endOffset);break;case this.END_TO_END:return p(this,this.endContainer,this.endOffset,E.endContainer,E.endOffset);break;case this.END_TO_START:return p(this,this.endContainer,this.endOffset,E.startContainer,E.startOffset);break}}catch(B){}return null}function w(){try{e(this,Range.DELETE_CONTENTS)}catch(y){}}function v(){this.detached=true}function o(){try{return e(this,Range.EXTRACT_CONTENTS)}catch(y){return null}}function k(y){try{var C,z,B;switch(this.startContainer.nodeType){case Node.CDATA_SECTION_NODE:case Node.TEXT_NODE:z=this.startContainer.splitText(this.startOffset);this.startContainer.parentNode.insertBefore(y,z);break;default:if(this.startContainer.childNodes.length==0){B=null}else{B=this.startContainer.childNodes(this.startOffset)}this.startContainer.insertBefore(y,B)}}catch(A){}}function d(y){this.setStartBefore(y);this.setEndAfter(y)}function u(y){this.setStart(y,0);this.setEnd(y,y.childNodes.length)}function q(y,C){try{var z,B;this.startContainer=y;this.startOffset=C;z=this.endContainer;while(z.parentNode){z=z.parentNode}B=this.startContainer;while(B.parentNode){B=B.parentNode}if(B!=z){this.collapse(true)}else{if(p(this,this.startContainer,this.startOffset,this.endContainer,this.endOffset)>0){this.collapse(true)}}this.collapsed=t(this);this.commonAncestorContainer=s(this.startContainer,this.endContainer)}catch(A){}}function n(y){this.setStart(y.parentNode,h(y)+1)}function j(y){this.setStart(y.parentNode,h(y))}function i(y,A){try{this.endContainer=y;this.endOffset=A;endRootContainer=this.endContainer;while(endRootContainer.parentNode){endRootContainer=endRootContainer.parentNode}startRootContainer=this.startContainer;while(startRootContainer.parentNode){startRootContainer=startRootContainer.parentNode}if(startRootContainer!=endRootContainer){this.collapse(false)}else{if(p(this,this.startContainer,this.startOffset,this.endContainer,this.endOffset)>0){this.collapse(false)}}this.collapsed=t(this);this.commonAncestorContainer=s(this.startContainer,this.endContainer)}catch(z){}}function g(y){this.setEnd(y.parentNode,h(y)+1)}function l(y){this.setEnd(y.parentNode,h(y))}function m(z){try{var B,y;while(z.firstChild){z.removeChild(z.firstChild)}y=this.extractContents();this.insertNode(z);z.appendChild(y);this.selectNode(z)}catch(A){}}function p(D,B,E,z,C){var G,A,y,F,H;if(B==z){if(E==C){return 0}else{if(E"+l.get("label")+"");m.addClassName(l.get("name"));n.appendChild(m);return m}function k(m,l){if(l.handler){return l.handler}else{if(l.get("handler")){return l.get("handler")}else{return function(n){n.execCommand(m)}}}}function g(l,m){var n=this;l.observe("click",function(o){m(n.editor);n.editor.fire("wysihat:change");n.editor.fire("wysihat:cursormove");Event.stop(o)})}function c(m,l){if(l.query){return l.query}else{if(l.get("query")){return l.get("query")}else{return function(n){return n.queryCommandState(m)}}}}function h(n,m,o){var p=this;var l=false;p.editor.observe("wysihat:cursormove",function(q){var r=o(p.editor);if(r!=l){l=r;p.updateButtonState(n,m,r)}})}function b(m,l,n){if(n){m.addClassName("selected")}else{m.removeClassName("selected")}}return{initialize:e,createToolbarElement:a,addButtonSet:d,addButton:j,createButtonElement:i,buttonHandler:k,observeButtonClick:g,buttonStateHandler:c,observeStateChanges:h,updateButtonState:b}})());WysiHat.Toolbar.ButtonSets={};WysiHat.Toolbar.ButtonSets.Basic=$A([{label:"Bold"},{label:"Underline"},{label:"Italic"}]);var editors=[];var WysihatHelper={faceboxFile:function(){facebox.loading();new Effect.Appear($("facebox"),{duration:0.3});var b=facebox;var a="/wysihat_files/?editor="+this.id;new Ajax.Request(a,{method:"get",onFailure:function(c){b.reveal(c.responseText,null)},onSuccess:function(c){b.reveal(c.responseText,null)}})},faceboxLink:function(){if(this.linkSelected()){this.unlinkSelection()}else{facebox.loading();new Effect.Appear($("facebox"),{duration:0.3});iframe=this;facebox.reveal('',null);Event.observe("link_field","change",function(a){iframe.linkSelection($("link_field").value)})}},faceboxHTML:function(){facebox.loading();new Effect.Appear($("facebox"),{duration:0.3});iframe=this;facebox.reveal('",null);Event.observe("html_editor","change",function(a){iframe.contentWindow.document.body.innerHTML=$("html_editor").value})}};function wysiHatify(d,c){WysiHat.Editor.include(WysihatHelper);var a=WysiHat.Editor.attach(d);var b=new WysiHat.Toolbar(a);editors.push(a);$$("form").each(function(e){e.onsubmit=function(){editors.each(function(g){g.save()})}});c.each(function(e){switch(e.toLowerCase()){case"image":b.addButton({label:e.gsub("_","-").camelize().capitalize(),handler:function(g){return g.faceboxFile(g)}});break;case"link":b.addButton({label:e.gsub("_","-").camelize().capitalize(),handler:function(g){return g.faceboxLink(g)}});break;case"html":b.addButton({label:e.gsub("_","-").camelize().capitalize(),handler:function(g){return g.faceboxHTML(g)}});break;case"paste":b.addButton({label:e.gsub("_","-").camelize().capitalize(),handler:function(g){return g.faceboxPaste(g)}});break;default:b.addButton({label:e.gsub("_","-").camelize().capitalize()})}})}; \ No newline at end of file +var Facebox=Class.create({initialize:function(a){this.settings={loading_image:"/images/facebox/loading.gif",close_image:"/images/facebox/closelabel.gif",image_types:new RegExp("."+["png","jpg","jpeg","gif"].join("|")+"$","i"),inited:true,facebox_html:'

'};if(a){Object.extend(this.settings,a)}$(document.body).insert({bottom:this.settings.facebox_html});this.preload=[new Image(),new Image()];this.preload[0].src=this.settings.close_image;this.preload[1].src=this.settings.loading_image;f=this;$$("#facebox .b:first, #facebox .bl, #facebox .br, #facebox .tl, #facebox .tr").each(function(b){f.preload.push(new Image());f.preload.slice(-1).src=b.getStyle("background-image").replace(/url\((.+)\)/,"$1")});this.facebox=$("facebox");this.keyPressListener=this.watchKeyPress.bindAsEventListener(this);this.watchClickEvents();fb=this;Event.observe($$("#facebox .close").first(),"click",function(b){Event.stop(b);fb.close()});Event.observe($$("#facebox .close_image").first(),"click",function(b){Event.stop(b);fb.close()})},watchKeyPress:function(a){if(a.keyCode==27||!Event.element(a).descendantOf(this.facebox)){this.close()}},watchClickEvents:function(b){var a=this;$$("a[rel=facebox]").each(function(d,c){Event.observe(d,"click",function(g){Event.stop(g);a.click_handler(d,g)})})},loading:function(){if($$("#facebox .loading").length==1){return true}contentWrapper=$$("#facebox .content").first();contentWrapper.childElements().each(function(c,b){c.remove()});contentWrapper.insert({bottom:'
'});var a=document.viewport.getScrollOffsets();this.facebox.setStyle({top:a.top+(document.viewport.getHeight()/10)+"px",left:document.viewport.getWidth()/2-(this.facebox.getWidth()/2)+"px"});Event.observe(document,"keypress",this.keyPressListener);Event.observe(document,"click",this.keyPressListener)},reveal:function(b,a){this.loading();load=$$("#facebox .loading").first();if(load){load.remove()}contentWrapper=$$("#facebox .content").first();if(a){contentWrapper.addClassName(a)}contentWrapper.update(b);$$("#facebox .body").first().childElements().each(function(d,c){d.show()});if(!this.facebox.visible()){new Effect.Appear(this.facebox,{duration:0.3})}this.facebox.setStyle({left:document.viewport.getWidth()/2-(this.facebox.getWidth()/2)+"px"});Event.observe(document,"keypress",this.keyPressListener);Event.observe(document,"click",this.keyPressListener)},close:function(){new Effect.Fade("facebox",{duration:0.3})},click_handler:function(c,i){this.loading();Event.stop(i);var k=c.rel.match(/facebox\[\.(\w+)\]/);if(k){k=k[1]}new Effect.Appear(this.facebox,{duration:0.3});if(c.href.match(/#/)){var a=window.location.href.split("#")[0];var j=c.href.replace(a+"#","");var l=$(j);var h=new Element(l.tagName);h.innerHTML=l.innerHTML;this.reveal(h,k)}else{if(c.href.match(this.settings.image_types)){var g=new Image();b=this;g.onload=function(){b.reveal('
',k)};g.src=c.href}else{var b=this;var a=c.href;new Ajax.Request(a,{method:"get",onFailure:function(d){b.reveal(d.responseText,k)},onSuccess:function(d){b.reveal(d.responseText,k)}})}}}});var facebox;document.observe("dom:loaded",function(){facebox=new Facebox()});var WysiHat={};WysiHat.Editor={attach:function(a,c,e){c=$H(c);a=$(a);a.hide();var b=c.get("model")||WysiHat.iFrame;var d=e;return b.create(a,function(h){var g=h.getDocument();var i=h.getWindow();h.load();Event.observe(i,"focus",function(j){h.focus()});Event.observe(i,"blur",function(j){h.blur()});h._observeEvents();if(Prototype.Browser.Gecko){h.execCommand("undo",false,null)}if(d){d(h)}h.focus()})},include:function(a){this.includedModules=this.includedModules||$A([]);this.includedModules.push(a)},extend:function(b){var a=this.includedModules||$A([]);a.each(function(c){Object.extend(b,c)})}};WysiHat.Commands=(function(){function h(){this.execCommand("bold",false,null)}function r(){return this.queryCommandState("bold")}function z(){this.execCommand("underline",false,null)}function s(){return this.queryCommandState("underline")}function n(){this.execCommand("italic",false,null)}function x(){return this.queryCommandState("italic")}function q(){this.execCommand("strikethrough",false,null)}function d(){this.execCommand("blockquote",false,null)}function m(A){this.execCommand("fontname",false,A)}function p(A){this.execCommand("fontsize",false,A)}function y(A){this.execCommand("forecolor",false,A)}function l(A){if(Prototype.Browser.Gecko){this.execCommand("hilitecolor",false,A)}else{this.execCommand("backcolor",false,A)}}function w(A){this.execCommand("justify"+A)}function b(){var A=this.selection.getNode();return Element.getStyle(A,"textAlign")}function g(A){this.execCommand("createLink",false,A)}function i(){var A=this.selection.getNode();if(this.linkSelected()){this.selection.selectNode(A)}this.execCommand("unlink",false,null)}function v(){var A=this.selection.getNode();return A?A.tagName.toUpperCase()=="A":false}function o(A){this.execCommand("formatblock",false,A)}function k(){this.execCommand("insertorderedlist",false,null)}function j(){this.execCommand("insertunorderedlist",false,null)}function c(A){this.execCommand("insertImage",false,A)}function a(B){if(Prototype.Browser.IE){var A=this._selection.getRange();A.pasteHTML(B);A.collapse(false);A.select()}else{this.execCommand("insertHTML",false,B)}}function t(E,D,C){var A=this.getDocument();if(Prototype.Browser.IE){this.selection.restore()}var B=this.commands.get(E);if(B){B.bind(this)(C)}else{A.execCommand(E,D,C)}}function e(C){var A=this.getDocument();var B=this.queryCommands.get(C);if(B){return B.bind(this)()}else{return A.queryCommandState(C)}}function u(){var B=$H({});var A=this;A.styleSelectors.each(function(C){var D=A.selection.getNode();B.set(C.first(),Element.getStyle(D,C.last()))});return B}return{boldSelection:h,boldSelected:r,underlineSelection:z,underlineSelected:s,italicSelection:n,italicSelected:x,strikethroughSelection:q,blockquoteSelection:d,fontSelection:m,fontSizeSelection:p,colorSelection:y,backgroundColorSelection:l,alignSelection:w,alignSelected:b,linkSelection:g,unlinkSelection:i,linkSelected:v,formatblockSelection:o,insertOrderedList:k,insertUnorderedList:j,insertImage:c,insertHTML:a,execCommand:t,queryCommandState:e,getSelectedStyles:u,commands:$H({}),queryCommands:$H({link:v}),styleSelectors:$H({fontname:"fontFamily",fontsize:"fontSize",forecolor:"color",hilitecolor:"backgroundColor",backcolor:"backgroundColor"})}})();WysiHat.Editor.include(WysiHat.Commands);WysiHat.Events=(function(){var a=["click","dblclick","mousedown","mouseup","mouseover","mousemove","mouseout","keypress","keydown","keyup"];function b(j,k){a.each(function(l){Event.observe(j,l,function(m){k.fire("wysihat:"+l)})})}function g(l,j,k){Event.observe(j,"keydown",function(m){if(m.keyCode==86){k.fire("wysihat:paste")}});Event.observe(l,"paste",function(m){k.fire("wysihat:paste")})}function c(k,j){Event.observe(k,"focus",function(l){j.fire("wysihat:focus")});Event.observe(k,"blur",function(l){j.fire("wysihat:blur")})}function i(j,k){Event.observe(j,"mouseup",function(m){var l=k.selection.getRange();if(!l.collapsed){k.fire("wysihat:select")}})}function e(j,k){var l=k.rawContent();Event.observe(j,"keyup",function(n){var m=k.rawContent();if(l!=m){k.fire("wysihat:change");l=m}})}function d(j,l){var m=l.selection.getRange();var k=function(o){var n=l.selection.getRange();if(m!=n){l.fire("wysihat:cursormove");m=n}};Event.observe(j,"keyup",k);Event.observe(j,"mouseup",k)}function h(){if(this._observers_setup){return}var j=this.getDocument();var k=this.getWindow();b(j,this);g(k,j,this);c(k,this);i(j,this);e(j,this);d(j,this);this._observers_setup=true}return{_observeEvents:h}})();WysiHat.Editor.include(WysiHat.Events);WysiHat.Persistence=(function(){function h(i){return i.formatHTMLOutput()}function a(i){return i.formatHTMLInput()}function e(){return this.outputFilter(this.rawContent())}function d(i){this.setRawContent(this.inputFilter(i))}function c(){this.textarea.value=this.content()}function g(){this.setContent(this.textarea.value)}function b(){this.selection.setBookmark();this.save();this.load();this.selection.moveToBookmark()}return{outputFilter:h,inputFilter:a,content:e,setContent:d,save:c,load:g,reload:b}})();WysiHat.Editor.include(WysiHat.Persistence);WysiHat.Window=(function(){function c(){return this.contentDocument||this.contentWindow.document}function b(){if(this.contentDocument&&this.contentDocument.defaultView){return this.contentDocument.defaultView}else{if(this.contentWindow.document){return this.contentWindow}else{return null}}}function a(){this.getWindow().focus();if(this.hasFocus){return}this.hasFocus=true}function d(){this.hasFocus=false}return{getDocument:c,getWindow:b,focus:a,blur:d}})();WysiHat.Editor.include(WysiHat.Window);WysiHat.iFrame={create:function(a,c){var b=new Element("iframe",{id:a.id+"_editor","class":"editor"});Object.extend(b,WysiHat.iFrame.Methods);WysiHat.Editor.extend(b);b.attach(a,c);a.insert({before:b});return b}};WysiHat.iFrame.Methods={attach:function(a,b){this.textarea=a;this.observe("load",function(){try{var c=this.getDocument()}catch(d){return}this.selection=new WysiHat.Selection(this);if(this.ready&&c.designMode=="on"){return}this.setStyle({});c.designMode="on";b(this);this.ready=true;this.fire("wysihat:ready")})},unattach:function(){this.remove()},whenReady:function(b){if(this.ready){b(this)}else{var a=this;a.observe("wysihat:ready",function(){b(a)})}return this},setStyle:function(e){var a=this.getDocument();var c=this;if(!this.ready){return setTimeout(function(){c.setStyle(e)},1)}if(Prototype.Browser.IE){var d=a.createStyleSheet();d.addRule("body","border: 0");d.addRule("p","margin: 0");$H(e).each(function(h){var g=h.first().underscore().dasherize()+": "+h.last();d.addRule("body",g)})}else{if(Prototype.Browser.Opera){var d=Element("style").update("p { margin: 0; }");var b=a.getElementsByTagName("head")[0];b.appendChild(d)}else{Element.setStyle(a.body,e)}}return this},getStyle:function(b){var a=this.getDocument();return Element.getStyle(a.body,b)},rawContent:function(){var a=this.getDocument();if(a.body){return a.body.innerHTML}else{return""}},setRawContent:function(b){var a=this.getDocument();if(a.body){a.body.innerHTML=b}}};WysiHat.Editable={create:function(a,c){var b=new Element("div",{id:a.id+"_editor","class":"editor",contenteditable:"true"});b.textarea=a;WysiHat.Editor.extend(b);Object.extend(b,WysiHat.Editable.Methods);c(b);a.insert({before:b});return b}};WysiHat.Editable.Methods={getDocument:function(){return document},getWindow:function(){return window},rawContent:function(){return this.innerHTML},setRawContent:function(a){this.innerHTML=a}};Object.extend(String.prototype,(function(){function a(){var k=String(this);k=k.tidyXHTML();if(Prototype.Browser.WebKit){k=k.replace(/(
)+/g,"\n");k=k.replace(/(<\/div>)+/g,"");k=k.replace(/

\s*<\/p>/g,"");k=k.replace(/
(\n)*/g,"\n")}else{if(Prototype.Browser.Gecko){k=k.replace(/

/g,"");k=k.replace(/<\/p>(\n)?/g,"\n");k=k.replace(/
(\n)*/g,"\n")}else{if(Prototype.Browser.IE||Prototype.Browser.Opera){k=k.replace(/

( | |\s)<\/p>/g,"

");k=k.replace(/
/g,"");k=k.replace(/

/g,"");k=k.replace(/ /g,"");k=k.replace(/<\/p>(\n)?/g,"\n");k=k.gsub(/^

/,"");k=k.gsub(/<\/p>$/,"")}}}k=k.gsub(//,"");k=k.gsub(/<\/b>/,"");k=k.gsub(//,"");k=k.gsub(/<\/i>/,"");k=k.replace(/\n\n+/g,"

\n\n

");k=k.gsub(/(([^\n])(\n))(?=([^\n]))/,"#{2}
\n");k="

"+k+"

";k=k.replace(/

\s*/g,"

");k=k.replace(/\s*<\/p>/g,"

");var e=Element("body");e.innerHTML=k;if(Prototype.Browser.WebKit||Prototype.Browser.Gecko){var j;do{j=false;e.select("span").each(function(i){if(i.hasClassName("Apple-style-span")){i.removeClassName("Apple-style-span");if(i.className==""){i.removeAttribute("class")}j=true}else{if(i.getStyle("fontWeight")=="bold"){i.setStyle({fontWeight:""});if(i.style.length==0){i.removeAttribute("style")}i.update(""+i.innerHTML+"");j=true}else{if(i.getStyle("fontStyle")=="italic"){i.setStyle({fontStyle:""});if(i.style.length==0){i.removeAttribute("style")}i.update(""+i.innerHTML+"");j=true}else{if(i.getStyle("textDecoration")=="underline"){i.setStyle({textDecoration:""});if(i.style.length==0){i.removeAttribute("style")}i.update(""+i.innerHTML+"");j=true}else{if(i.attributes.length==0){i.replace(i.innerHTML);j=true}}}}}})}while(j)}var h=$A(["BR","IMG"]);for(var d=0;d(\n)*/g,"
\n");k=k.replace(/<\/p>\n

/g,"

\n\n

");k=k.replace(/

\s*<\/p>/g,"");k=k.replace(/\s*$/g,"");return k}function b(){var e=String(this);var d=Element("body");d.innerHTML=e;if(Prototype.Browser.Gecko||Prototype.Browser.WebKit){d.select("strong").each(function(g){g.replace(''+g.innerHTML+"")});d.select("em").each(function(g){g.replace(''+g.innerHTML+"")});d.select("u").each(function(g){g.replace(''+g.innerHTML+"")})}if(Prototype.Browser.WebKit){d.select("span").each(function(g){if(g.getStyle("fontWeight")=="bold"){g.addClassName("Apple-style-span")}if(g.getStyle("fontStyle")=="italic"){g.addClassName("Apple-style-span")}if(g.getStyle("textDecoration")=="underline"){g.addClassName("Apple-style-span")}})}e=d.innerHTML;e=e.tidyXHTML();e=e.replace(/<\/p>(\n)*

/g,"\n\n");e=e.replace(/(\n)?(\n)?/g,"\n");e=e.replace(/^

/g,"");e=e.replace(/<\/p>$/g,"");if(Prototype.Browser.Gecko){e=e.replace(/\n/g,"
");e=e+"
"}else{if(Prototype.Browser.WebKit){e=e.replace(/\n/g,"

");e="
"+e+"
";e=e.replace(/
<\/div>/g,"

")}else{if(Prototype.Browser.IE||Prototype.Browser.Opera){e=e.replace(/\n/g,"

\n

");e="

"+e+"

";e=e.replace(/

<\/p>/g,"

 

");e=e.replace(/(

 <\/p>)+$/g,"")}}}return e}function c(){var d=String(this);d=d.gsub(/\r\n?/,"\n");d=d.gsub(/<([A-Z]+)([^>]*)>/,function(e){return"<"+e[1].toLowerCase()+e[2]+">"});d=d.gsub(/<\/([A-Z]+)>/,function(e){return""});d=d.replace(/
/g,"
");return d}return{formatHTMLOutput:a,formatHTMLInput:b,tidyXHTML:c}})());Object.extend(String.prototype,{sanitize:function(a){return Element("div").update(this).sanitize(a).innerHTML.tidyXHTML()}});Element.addMethods({sanitize:function(c,b){c=$(c);b=$H(b);var a=$A(b.get("tags")||[]);var d=$A(b.get("attributes")||[]);var e=Element(c.nodeName);$A(c.childNodes).each(function(i){if(i.nodeType==1){var g=$(i).sanitize(b).childNodes;if(a.include(i.nodeName.toLowerCase())){var h=Element(i.nodeName);d.each(function(j){if((value=i.readAttribute(j))){h.writeAttribute(j,value)}});e.appendChild(h);$A(g).each(function(j){h.appendChild(j)})}else{$A(g).each(function(j){e.appendChild(j)})}}else{if(i.nodeType==3){e.appendChild(i)}}});return e}});if(typeof Range=="undefined"){Range=function(a){this.ownerDocument=a;this.startContainer=this.ownerDocument.documentElement;this.startOffset=0;this.endContainer=this.ownerDocument.documentElement;this.endOffset=0;this.collapsed=true;this.commonAncestorContainer=this._commonAncestorContainer(this.startContainer,this.endContainer);this.detached=false;this.START_TO_START=0;this.START_TO_END=1;this.END_TO_END=2;this.END_TO_START=3};Range.CLONE_CONTENTS=0;Range.DELETE_CONTENTS=1;Range.EXTRACT_CONTENTS=2;if(!document.createRange){document.createRange=function(){return new Range(this)}}Object.extend(Range.prototype,(function(){function r(){return e(this,Range.CLONE_CONTENTS)}function x(){try{var z=new Range(this.ownerDocument);z.startContainer=this.startContainer;z.startOffset=this.startOffset;z.endContainer=this.endContainer;z.endOffset=this.endOffset;z.collapsed=this.collapsed;z.commonAncestorContainer=this.commonAncestorContainer;z.detached=this.detached;return z}catch(y){return null}}function b(y){if(y){this.endContainer=this.startContainer;this.endOffset=this.startOffset;this.collapsed=true}else{this.startContainer=this.endContainer;this.startOffset=this.endOffset;this.collapsed=true}}function a(z,E){try{var A,D,C,y;A=this.commonAncestorContainer;D=E.commonAncestorContainer;C=A;while(C.parentNode){C=C.parentNode}y=D;while(y.parentNode){y=y.parentNode}switch(z){case this.START_TO_START:return p(this,this.startContainer,this.startOffset,E.startContainer,E.startOffset);break;case this.START_TO_END:return p(this,this.startContainer,this.startOffset,E.endContainer,E.endOffset);break;case this.END_TO_END:return p(this,this.endContainer,this.endOffset,E.endContainer,E.endOffset);break;case this.END_TO_START:return p(this,this.endContainer,this.endOffset,E.startContainer,E.startOffset);break}}catch(B){}return null}function w(){try{e(this,Range.DELETE_CONTENTS)}catch(y){}}function v(){this.detached=true}function o(){try{return e(this,Range.EXTRACT_CONTENTS)}catch(y){return null}}function k(y){try{var C,z,B;switch(this.startContainer.nodeType){case Node.CDATA_SECTION_NODE:case Node.TEXT_NODE:z=this.startContainer.splitText(this.startOffset);this.startContainer.parentNode.insertBefore(y,z);break;default:if(this.startContainer.childNodes.length==0){B=null}else{B=this.startContainer.childNodes(this.startOffset)}this.startContainer.insertBefore(y,B)}}catch(A){}}function d(y){this.setStartBefore(y);this.setEndAfter(y)}function u(y){this.setStart(y,0);this.setEnd(y,y.childNodes.length)}function q(y,C){try{var z,B;this.startContainer=y;this.startOffset=C;z=this.endContainer;while(z.parentNode){z=z.parentNode}B=this.startContainer;while(B.parentNode){B=B.parentNode}if(B!=z){this.collapse(true)}else{if(p(this,this.startContainer,this.startOffset,this.endContainer,this.endOffset)>0){this.collapse(true)}}this.collapsed=t(this);this.commonAncestorContainer=s(this.startContainer,this.endContainer)}catch(A){}}function n(y){this.setStart(y.parentNode,h(y)+1)}function j(y){this.setStart(y.parentNode,h(y))}function i(y,A){try{this.endContainer=y;this.endOffset=A;endRootContainer=this.endContainer;while(endRootContainer.parentNode){endRootContainer=endRootContainer.parentNode}startRootContainer=this.startContainer;while(startRootContainer.parentNode){startRootContainer=startRootContainer.parentNode}if(startRootContainer!=endRootContainer){this.collapse(false)}else{if(p(this,this.startContainer,this.startOffset,this.endContainer,this.endOffset)>0){this.collapse(false)}}this.collapsed=t(this);this.commonAncestorContainer=s(this.startContainer,this.endContainer)}catch(z){}}function g(y){this.setEnd(y.parentNode,h(y)+1)}function l(y){this.setEnd(y.parentNode,h(y))}function m(z){try{var B,y;while(z.firstChild){z.removeChild(z.firstChild)}y=this.extractContents();this.insertNode(z);z.appendChild(y);this.selectNode(z)}catch(A){}}function p(D,B,E,z,C){var G,A,y,F,H;if(B==z){if(E==C){return 0}else{if(E"+l.get("label")+"");m.addClassName(l.get("name"));n.appendChild(m);return m}function k(m,l){if(l.handler){return l.handler}else{if(l.get("handler")){return l.get("handler")}else{return function(n){n.execCommand(m)}}}}function g(l,m){var n=this;l.observe("click",function(o){m(n.editor);n.editor.fire("wysihat:change");n.editor.fire("wysihat:cursormove");Event.stop(o)})}function c(m,l){if(l.query){return l.query}else{if(l.get("query")){return l.get("query")}else{return function(n){return n.queryCommandState(m)}}}}function h(n,m,o){var p=this;var l=false;p.editor.observe("wysihat:cursormove",function(q){var r=o(p.editor);if(r!=l){l=r;p.updateButtonState(n,m,r)}})}function b(m,l,n){if(n){m.addClassName("selected")}else{m.removeClassName("selected")}}return{initialize:e,createToolbarElement:a,addButtonSet:d,addButton:j,createButtonElement:i,buttonHandler:k,observeButtonClick:g,buttonStateHandler:c,observeStateChanges:h,updateButtonState:b}})());WysiHat.Toolbar.ButtonSets={};WysiHat.Toolbar.ButtonSets.Basic=$A([{label:"Bold"},{label:"Underline"},{label:"Italic"}]);var editors=[];var WysihatHelper={faceboxFile:function(){facebox.loading();new Effect.Appear($("facebox"),{duration:0.3});var b=facebox;var a="/wysihat_files/?editor="+this.id;new Ajax.Request(a,{method:"get",onFailure:function(c){b.reveal(c.responseText,null)},onSuccess:function(c){b.reveal(c.responseText,null)}})},faceboxLink:function(){if(this.linkSelected()){this.unlinkSelection()}else{facebox.loading();new Effect.Appear($("facebox"),{duration:0.3});iframe=this;facebox.reveal('',null);Event.observe("link_field","change",function(a){iframe.linkSelection($("link_field").value)})}},faceboxHTML:function(){facebox.loading();new Effect.Appear($("facebox"),{duration:0.3});iframe=this;facebox.reveal('",null);Event.observe("html_editor","change",function(a){iframe.contentWindow.document.body.innerHTML=$("html_editor").value})}};function wysiHatify(d,c){WysiHat.Editor.include(WysihatHelper);var a=WysiHat.Editor.attach(d);var b=new WysiHat.Toolbar(a);editors.push(a);$$("form").each(function(e){e.onsubmit=function(){editors.each(function(g){g.save()})}});c.each(function(e){switch(e.toLowerCase()){case"image":b.addButton({label:e.gsub("_","-").camelize().capitalize(),handler:function(g){return g.faceboxFile(g)}});break;case"link":b.addButton({label:e.gsub("_","-").camelize().capitalize(),handler:function(g){return g.faceboxLink(g)}});break;case"html":b.addButton({label:e.gsub("_","-").camelize().capitalize(),handler:function(g){return g.faceboxHTML(g)}});break;case"paste":b.addButton({label:e.gsub("_","-").camelize().capitalize(),handler:function(g){return g.faceboxPaste(g)}});case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":case"p":b.addButton({label:e.gsub("_","-").camelize().capitalize(),handler:function(g){return g.formatblockSelection(e.toLowerCase())}});break;default:b.addButton({label:e.gsub("_","-").camelize().capitalize()})}})}; \ No newline at end of file diff --git a/public/stylesheets/wysihat.css b/public/stylesheets/wysihat.css index 4592682..c52b79d 100644 --- a/public/stylesheets/wysihat.css +++ b/public/stylesheets/wysihat.css @@ -37,6 +37,20 @@ div.editor_toolbar span { background-image: url('../images/icons/image.png'); } .editor_toolbar .html { background-image: url('../images/icons/page_code.png'); } +.editor_toolbar .h1 { + background-image: url('../images/icons/text_heading_1.png'); } +.editor_toolbar .h2 { + background-image: url('../images/icons/text_heading_2.png'); } +.editor_toolbar .h3 { + background-image: url('../images/icons/text_heading_3.png'); } +.editor_toolbar .h4 { + background-image: url('../images/icons/text_heading_4.png'); } +.editor_toolbar .h5 { + background-image: url('../images/icons/text_heading_5.png'); } +.editor_toolbar .h6 { + background-image: url('../images/icons/text_heading_6.png'); } +.editor_toolbar .p { + background-image: url('../images/icons/cancel.png'); } iframe.editor { border: 1px solid #999; diff --git a/vendor/gems/wysihat-engine-0.1.9/.gitignore b/vendor/gems/wysihat-engine-0.1.10/.gitignore similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/.gitignore rename to vendor/gems/wysihat-engine-0.1.10/.gitignore diff --git a/vendor/gems/wysihat-engine-0.1.9/.specification b/vendor/gems/wysihat-engine-0.1.10/.specification similarity index 88% rename from vendor/gems/wysihat-engine-0.1.9/.specification rename to vendor/gems/wysihat-engine-0.1.10/.specification index 8524609..981a144 100644 --- a/vendor/gems/wysihat-engine-0.1.9/.specification +++ b/vendor/gems/wysihat-engine-0.1.10/.specification @@ -1,7 +1,7 @@ --- !ruby/object:Gem::Specification name: wysihat-engine version: !ruby/object:Gem::Version - version: 0.1.9 + version: 0.1.10 platform: ruby authors: - Jeff Kreeftmeijer @@ -9,7 +9,7 @@ autorequire: bindir: bin cert_chain: [] -date: 2009-12-22 00:00:00 +01:00 +date: 2010-01-11 00:00:00 +01:00 default_executable: dependencies: - !ruby/object:Gem::Dependency @@ -67,6 +67,7 @@ files: - generators/wysihat/templates/images/facebox/tr.png - generators/wysihat/templates/images/icons/arrow_redo.png - generators/wysihat/templates/images/icons/arrow_undo.png +- generators/wysihat/templates/images/icons/cancel.png - generators/wysihat/templates/images/icons/exclamation.png - generators/wysihat/templates/images/icons/image.png - generators/wysihat/templates/images/icons/link.png @@ -75,6 +76,12 @@ files: - generators/wysihat/templates/images/icons/text_align_left.png - generators/wysihat/templates/images/icons/text_align_right.png - generators/wysihat/templates/images/icons/text_bold.png +- generators/wysihat/templates/images/icons/text_heading_1.png +- generators/wysihat/templates/images/icons/text_heading_2.png +- generators/wysihat/templates/images/icons/text_heading_3.png +- generators/wysihat/templates/images/icons/text_heading_4.png +- generators/wysihat/templates/images/icons/text_heading_5.png +- generators/wysihat/templates/images/icons/text_heading_6.png - generators/wysihat/templates/images/icons/text_italic.png - generators/wysihat/templates/images/icons/text_list_bullets.png - generators/wysihat/templates/images/icons/text_list_numbers.png diff --git a/vendor/gems/wysihat-engine-0.1.9/CHANGELOG b/vendor/gems/wysihat-engine-0.1.10/CHANGELOG similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/CHANGELOG rename to vendor/gems/wysihat-engine-0.1.10/CHANGELOG diff --git a/vendor/gems/wysihat-engine-0.1.9/MIT-LICENSE b/vendor/gems/wysihat-engine-0.1.10/MIT-LICENSE similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/MIT-LICENSE rename to vendor/gems/wysihat-engine-0.1.10/MIT-LICENSE diff --git a/vendor/gems/wysihat-engine-0.1.9/README.textile b/vendor/gems/wysihat-engine-0.1.10/README.textile similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/README.textile rename to vendor/gems/wysihat-engine-0.1.10/README.textile diff --git a/vendor/gems/wysihat-engine-0.1.9/Rakefile b/vendor/gems/wysihat-engine-0.1.10/Rakefile similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/Rakefile rename to vendor/gems/wysihat-engine-0.1.10/Rakefile diff --git a/vendor/gems/wysihat-engine-0.1.9/TODO b/vendor/gems/wysihat-engine-0.1.10/TODO similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/TODO rename to vendor/gems/wysihat-engine-0.1.10/TODO diff --git a/vendor/gems/wysihat-engine-0.1.10/VERSION b/vendor/gems/wysihat-engine-0.1.10/VERSION new file mode 100644 index 0000000..9767cc9 --- /dev/null +++ b/vendor/gems/wysihat-engine-0.1.10/VERSION @@ -0,0 +1 @@ +0.1.10 diff --git a/vendor/gems/wysihat-engine-0.1.9/app/controllers/wysihat_files_controller.rb b/vendor/gems/wysihat-engine-0.1.10/app/controllers/wysihat_files_controller.rb similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/app/controllers/wysihat_files_controller.rb rename to vendor/gems/wysihat-engine-0.1.10/app/controllers/wysihat_files_controller.rb diff --git a/vendor/gems/wysihat-engine-0.1.9/app/helpers/wysihat_files_helper.rb b/vendor/gems/wysihat-engine-0.1.10/app/helpers/wysihat_files_helper.rb similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/app/helpers/wysihat_files_helper.rb rename to vendor/gems/wysihat-engine-0.1.10/app/helpers/wysihat_files_helper.rb diff --git a/vendor/gems/wysihat-engine-0.1.9/app/models/wysihat_file.rb b/vendor/gems/wysihat-engine-0.1.10/app/models/wysihat_file.rb similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/app/models/wysihat_file.rb rename to vendor/gems/wysihat-engine-0.1.10/app/models/wysihat_file.rb diff --git a/vendor/gems/wysihat-engine-0.1.9/app/views/wysihat_files/_form.html.erb b/vendor/gems/wysihat-engine-0.1.10/app/views/wysihat_files/_form.html.erb similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/app/views/wysihat_files/_form.html.erb rename to vendor/gems/wysihat-engine-0.1.10/app/views/wysihat_files/_form.html.erb diff --git a/vendor/gems/wysihat-engine-0.1.9/app/views/wysihat_files/_wysihat_file.html.erb b/vendor/gems/wysihat-engine-0.1.10/app/views/wysihat_files/_wysihat_file.html.erb similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/app/views/wysihat_files/_wysihat_file.html.erb rename to vendor/gems/wysihat-engine-0.1.10/app/views/wysihat_files/_wysihat_file.html.erb diff --git a/vendor/gems/wysihat-engine-0.1.9/app/views/wysihat_files/index.html.erb b/vendor/gems/wysihat-engine-0.1.10/app/views/wysihat_files/index.html.erb similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/app/views/wysihat_files/index.html.erb rename to vendor/gems/wysihat-engine-0.1.10/app/views/wysihat_files/index.html.erb diff --git a/vendor/gems/wysihat-engine-0.1.9/app/views/wysihat_files/new.html.erb b/vendor/gems/wysihat-engine-0.1.10/app/views/wysihat_files/new.html.erb similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/app/views/wysihat_files/new.html.erb rename to vendor/gems/wysihat-engine-0.1.10/app/views/wysihat_files/new.html.erb diff --git a/vendor/gems/wysihat-engine-0.1.9/config/locales/en.yml b/vendor/gems/wysihat-engine-0.1.10/config/locales/en.yml similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/config/locales/en.yml rename to vendor/gems/wysihat-engine-0.1.10/config/locales/en.yml diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/css/facebox.css b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/css/facebox.css similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/css/facebox.css rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/css/facebox.css diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/css/wysihat.css b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/css/wysihat.css similarity index 72% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/css/wysihat.css rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/css/wysihat.css index 4592682..c52b79d 100644 --- a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/css/wysihat.css +++ b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/css/wysihat.css @@ -37,6 +37,20 @@ div.editor_toolbar span { background-image: url('../images/icons/image.png'); } .editor_toolbar .html { background-image: url('../images/icons/page_code.png'); } +.editor_toolbar .h1 { + background-image: url('../images/icons/text_heading_1.png'); } +.editor_toolbar .h2 { + background-image: url('../images/icons/text_heading_2.png'); } +.editor_toolbar .h3 { + background-image: url('../images/icons/text_heading_3.png'); } +.editor_toolbar .h4 { + background-image: url('../images/icons/text_heading_4.png'); } +.editor_toolbar .h5 { + background-image: url('../images/icons/text_heading_5.png'); } +.editor_toolbar .h6 { + background-image: url('../images/icons/text_heading_6.png'); } +.editor_toolbar .p { + background-image: url('../images/icons/cancel.png'); } iframe.editor { border: 1px solid #999; diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/facebox/b.png b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/facebox/b.png similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/facebox/b.png rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/facebox/b.png diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/facebox/bl.png b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/facebox/bl.png similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/facebox/bl.png rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/facebox/bl.png diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/facebox/br.png b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/facebox/br.png similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/facebox/br.png rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/facebox/br.png diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/facebox/closelabel.gif b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/facebox/closelabel.gif similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/facebox/closelabel.gif rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/facebox/closelabel.gif diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/facebox/loading.gif b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/facebox/loading.gif similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/facebox/loading.gif rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/facebox/loading.gif diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/facebox/tl.png b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/facebox/tl.png similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/facebox/tl.png rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/facebox/tl.png diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/facebox/tr.png b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/facebox/tr.png similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/facebox/tr.png rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/facebox/tr.png diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/arrow_redo.png b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/arrow_redo.png similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/arrow_redo.png rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/arrow_redo.png diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/arrow_undo.png b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/arrow_undo.png similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/arrow_undo.png rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/arrow_undo.png diff --git a/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/cancel.png b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/cancel.png new file mode 100755 index 0000000..c149c2b Binary files /dev/null and b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/cancel.png differ diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/exclamation.png b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/exclamation.png similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/exclamation.png rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/exclamation.png diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/image.png b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/image.png similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/image.png rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/image.png diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/link.png b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/link.png similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/link.png rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/link.png diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/page_code.png b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/page_code.png similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/page_code.png rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/page_code.png diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/text_align_center.png b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_align_center.png similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/text_align_center.png rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_align_center.png diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/text_align_left.png b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_align_left.png similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/text_align_left.png rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_align_left.png diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/text_align_right.png b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_align_right.png similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/text_align_right.png rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_align_right.png diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/text_bold.png b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_bold.png similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/text_bold.png rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_bold.png diff --git a/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_heading_1.png b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_heading_1.png new file mode 100755 index 0000000..9c122e9 Binary files /dev/null and b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_heading_1.png differ diff --git a/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_heading_2.png b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_heading_2.png new file mode 100755 index 0000000..fbd8765 Binary files /dev/null and b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_heading_2.png differ diff --git a/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_heading_3.png b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_heading_3.png new file mode 100755 index 0000000..c7836cf Binary files /dev/null and b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_heading_3.png differ diff --git a/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_heading_4.png b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_heading_4.png new file mode 100755 index 0000000..4e929ea Binary files /dev/null and b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_heading_4.png differ diff --git a/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_heading_5.png b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_heading_5.png new file mode 100755 index 0000000..30cabeb Binary files /dev/null and b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_heading_5.png differ diff --git a/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_heading_6.png b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_heading_6.png new file mode 100755 index 0000000..058170a Binary files /dev/null and b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_heading_6.png differ diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/text_italic.png b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_italic.png similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/text_italic.png rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_italic.png diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/text_list_bullets.png b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_list_bullets.png similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/text_list_bullets.png rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_list_bullets.png diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/text_list_numbers.png b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_list_numbers.png similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/text_list_numbers.png rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_list_numbers.png diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/text_strikethrough.png b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_strikethrough.png similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/text_strikethrough.png rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_strikethrough.png diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/text_underline.png b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_underline.png similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/images/icons/text_underline.png rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/images/icons/text_underline.png diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/javascripts/facebox.js b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/javascripts/facebox.js similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/javascripts/facebox.js rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/javascripts/facebox.js diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/javascripts/wysihat.js b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/javascripts/wysihat.js similarity index 94% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/javascripts/wysihat.js rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/javascripts/wysihat.js index 57410cc..6061f88 100755 --- a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/javascripts/wysihat.js +++ b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/javascripts/wysihat.js @@ -88,29 +88,14 @@ WysiHat.Commands = (function() { this.execCommand('fontname', false, font); } - function fontSelected() { - var node = this.selection.getNode(); - return Element.getStyle(node, 'fontFamily'); - } - function fontSizeSelection(fontSize) { this.execCommand('fontsize', false, fontSize); } - function fontSizeSelected() { - var node = this.selection.getNode(); - return standardizeFontSize(Element.getStyle(node, 'fontSize')); - } - function colorSelection(color) { this.execCommand('forecolor', false, color); } - function colorSelected() { - var node = this.selection.getNode(); - return standardizeColor(Element.getStyle(node, 'color')); - } - function backgroundColorSelection(color) { if(Prototype.Browser.Gecko) { this.execCommand('hilitecolor', false, color); @@ -119,11 +104,6 @@ WysiHat.Commands = (function() { } } - function backgroundColorSelected() { - var node = this.selection.getNode(); - return standardizeColor(Element.getStyle(node, 'backgroundColor')); - } - function alignSelection(alignment) { this.execCommand('justify' + alignment); } @@ -150,6 +130,10 @@ WysiHat.Commands = (function() { return node ? node.tagName.toUpperCase() == 'A' : false; } + function formatblockSelection(element){ + this.execCommand('formatblock', false, element); + } + function insertOrderedList() { this.execCommand('insertorderedlist', false, null); } @@ -178,7 +162,7 @@ WysiHat.Commands = (function() { if (Prototype.Browser.IE) this.selection.restore(); - var handler = this.commands.get(command) + var handler = this.commands.get(command); if (handler) handler.bind(this)(value); else @@ -188,77 +172,22 @@ WysiHat.Commands = (function() { function queryCommandState(state) { var document = this.getDocument(); - var handler = this.queryCommands.get(state) + var handler = this.queryCommands.get(state); if (handler) return handler.bind(this)(); else return document.queryCommandState(state); } - var fontSizeNames = $w('xxx-small xx-small x-small small medium large x-large xx-large'); - var fontSizePixels = $w('9px 10px 13px 16px 18px 24px 32px 48px'); - if (Prototype.Browser.WebKit) { - fontSizeNames.shift(); - fontSizeNames.push('-webkit-xxx-large'); - } - - function standardizeFontSize(fontSize) { - var newSize = fontSizeNames.indexOf(fontSize); - if (newSize >= 0) return newSize; - - newSize = fontSizePixels.indexOf(fontSize); - if (newSize >= 0) return newSize; - return parseInt(fontSize); - } - - function standardizeColor(color) { - if (!color || color.match(/[0-9a-f]{6}/i)) return color; - var m = color.toLowerCase().match(/^(rgba?|hsla?)\(([\s\.\-,%0-9]+)\)/); - if(m){ - var c = m[2].split(/\s*,\s*/), l = c.length, t = m[1]; - if((t == "rgb" && l == 3) || (t == "rgba" && l == 4)){ - var r = c[0]; - if(r.charAt(r.length - 1) == "%"){ - var a = c.map(function(x){ - return parseFloat(x) * 2.56; - }); - if(l == 4){ a[3] = c[3]; } - return _colorFromArray(a); - } - return _colorFromArray(c); - } - if((t == "hsl" && l == 3) || (t == "hsla" && l == 4)){ - var H = ((parseFloat(c[0]) % 360) + 360) % 360 / 360, - S = parseFloat(c[1]) / 100, - L = parseFloat(c[2]) / 100, - m2 = L <= 0.5 ? L * (S + 1) : L + S - L * S, - m1 = 2 * L - m2, - a = [_hue2rgb(m1, m2, H + 1 / 3) * 256, - _hue2rgb(m1, m2, H) * 256, _hue2rgb(m1, m2, H - 1 / 3) * 256, 1]; - if(l == 4){ a[3] = c[3]; } - return _colorFromArray(a); - } - } - return null; // dojo.Color - } - - function _colorFromArray(a) { - var arr = a.slice(0, 3).map(function(x){ - var s = parseInt(x).toString(16); - return s.length < 2 ? "0" + s : s; - }); - return "#" + arr.join(""); // String - } - - function _hue2rgb(m1, m2, h){ - if(h < 0){ ++h; } - if(h > 1){ --h; } - var h6 = 6 * h; - if(h6 < 1){ return m1 + (m2 - m1) * h6; } - if(2 * h < 1){ return m2; } - if(3 * h < 2){ return m1 + (m2 - m1) * (2 / 3 - h) * 6; } - return m1; - } + function getSelectedStyles() { + var styles = $H({}); + var editor = this; + editor.styleSelectors.each(function(style){ + var node = editor.selection.getNode(); + styles.set(style.first(), Element.getStyle(node, style.last())); + }); + return styles; + } return { boldSelection: boldSelection, @@ -270,29 +199,35 @@ WysiHat.Commands = (function() { strikethroughSelection: strikethroughSelection, blockquoteSelection: blockquoteSelection, fontSelection: fontSelection, - fontSelected: fontSelected, fontSizeSelection: fontSizeSelection, - fontSizeSelected: fontSizeSelected, colorSelection: colorSelection, - colorSelected: colorSelected, backgroundColorSelection: backgroundColorSelection, - backgroundColorSelected: backgroundColorSelected, alignSelection: alignSelection, alignSelected: alignSelected, linkSelection: linkSelection, unlinkSelection: unlinkSelection, linkSelected: linkSelected, + formatblockSelection: formatblockSelection, insertOrderedList: insertOrderedList, insertUnorderedList: insertUnorderedList, insertImage: insertImage, insertHTML: insertHTML, execCommand: execCommand, queryCommandState: queryCommandState, + getSelectedStyles: getSelectedStyles, commands: $H({}), queryCommands: $H({ link: linkSelected + }), + + styleSelectors: $H({ + fontname: 'fontFamily', + fontsize: 'fontSize', + forecolor: 'color', + hilitecolor: 'backgroundColor', + backcolor: 'backgroundColor' }) }; })(); @@ -864,7 +799,7 @@ if (typeof Range == 'undefined') { this.START_TO_END = 1; this.END_TO_END = 2; this.END_TO_START = 3; - } + }; Range.CLONE_CONTENTS = 0; Range.DELETE_CONTENTS = 1; @@ -1519,7 +1454,7 @@ if (!window.getSelection) { this.isCollapsed = true; this.rangeCount = 0; this.ranges = []; - } + }; Object.extend(SelectionImpl.prototype, (function() { function addRange(r) { @@ -1988,7 +1923,7 @@ WysiHat.Toolbar = Class.create((function() { this.observeButtonClick(button, handler); var handler = this.buttonStateHandler(name, options); - this.observeStateChanges(button, name, handler) + this.observeStateChanges(button, name, handler); } function createButtonElement(toolbar, options) { diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/javascripts/wysihat_engine.js b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/javascripts/wysihat_engine.js similarity index 90% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/javascripts/wysihat_engine.js rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/javascripts/wysihat_engine.js index 871c2b3..59280c6 100644 --- a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/javascripts/wysihat_engine.js +++ b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/javascripts/wysihat_engine.js @@ -75,6 +75,8 @@ function wysiHatify(tag_id, buttons){ break; case 'paste': toolbar.addButton({label : button.gsub('_','-').camelize().capitalize(), handler: function(editor) { return editor.faceboxPaste(editor); }}); + case 'h1': case 'h2': case 'h3': case 'h4': case 'h5': case 'h6': case 'p': + toolbar.addButton({label : button.gsub('_','-').camelize().capitalize(), handler: function(editor) { return editor.formatblockSelection(button.toLowerCase()); }}); break; default: toolbar.addButton({label : button.gsub('_','-').camelize().capitalize()}); diff --git a/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/javascripts/wysihat_engine_pack.js b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/javascripts/wysihat_engine_pack.js new file mode 100644 index 0000000..5d5c1f0 --- /dev/null +++ b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/javascripts/wysihat_engine_pack.js @@ -0,0 +1 @@ +var Facebox=Class.create({initialize:function(a){this.settings={loading_image:"/images/facebox/loading.gif",close_image:"/images/facebox/closelabel.gif",image_types:new RegExp("."+["png","jpg","jpeg","gif"].join("|")+"$","i"),inited:true,facebox_html:'

'};if(a){Object.extend(this.settings,a)}$(document.body).insert({bottom:this.settings.facebox_html});this.preload=[new Image(),new Image()];this.preload[0].src=this.settings.close_image;this.preload[1].src=this.settings.loading_image;f=this;$$("#facebox .b:first, #facebox .bl, #facebox .br, #facebox .tl, #facebox .tr").each(function(b){f.preload.push(new Image());f.preload.slice(-1).src=b.getStyle("background-image").replace(/url\((.+)\)/,"$1")});this.facebox=$("facebox");this.keyPressListener=this.watchKeyPress.bindAsEventListener(this);this.watchClickEvents();fb=this;Event.observe($$("#facebox .close").first(),"click",function(b){Event.stop(b);fb.close()});Event.observe($$("#facebox .close_image").first(),"click",function(b){Event.stop(b);fb.close()})},watchKeyPress:function(a){if(a.keyCode==27||!Event.element(a).descendantOf(this.facebox)){this.close()}},watchClickEvents:function(b){var a=this;$$("a[rel=facebox]").each(function(d,c){Event.observe(d,"click",function(g){Event.stop(g);a.click_handler(d,g)})})},loading:function(){if($$("#facebox .loading").length==1){return true}contentWrapper=$$("#facebox .content").first();contentWrapper.childElements().each(function(c,b){c.remove()});contentWrapper.insert({bottom:'
'});var a=document.viewport.getScrollOffsets();this.facebox.setStyle({top:a.top+(document.viewport.getHeight()/10)+"px",left:document.viewport.getWidth()/2-(this.facebox.getWidth()/2)+"px"});Event.observe(document,"keypress",this.keyPressListener);Event.observe(document,"click",this.keyPressListener)},reveal:function(b,a){this.loading();load=$$("#facebox .loading").first();if(load){load.remove()}contentWrapper=$$("#facebox .content").first();if(a){contentWrapper.addClassName(a)}contentWrapper.update(b);$$("#facebox .body").first().childElements().each(function(d,c){d.show()});if(!this.facebox.visible()){new Effect.Appear(this.facebox,{duration:0.3})}this.facebox.setStyle({left:document.viewport.getWidth()/2-(this.facebox.getWidth()/2)+"px"});Event.observe(document,"keypress",this.keyPressListener);Event.observe(document,"click",this.keyPressListener)},close:function(){new Effect.Fade("facebox",{duration:0.3})},click_handler:function(c,i){this.loading();Event.stop(i);var k=c.rel.match(/facebox\[\.(\w+)\]/);if(k){k=k[1]}new Effect.Appear(this.facebox,{duration:0.3});if(c.href.match(/#/)){var a=window.location.href.split("#")[0];var j=c.href.replace(a+"#","");var l=$(j);var h=new Element(l.tagName);h.innerHTML=l.innerHTML;this.reveal(h,k)}else{if(c.href.match(this.settings.image_types)){var g=new Image();b=this;g.onload=function(){b.reveal('
',k)};g.src=c.href}else{var b=this;var a=c.href;new Ajax.Request(a,{method:"get",onFailure:function(d){b.reveal(d.responseText,k)},onSuccess:function(d){b.reveal(d.responseText,k)}})}}}});var facebox;document.observe("dom:loaded",function(){facebox=new Facebox()});var WysiHat={};WysiHat.Editor={attach:function(a,c,e){c=$H(c);a=$(a);a.hide();var b=c.get("model")||WysiHat.iFrame;var d=e;return b.create(a,function(h){var g=h.getDocument();var i=h.getWindow();h.load();Event.observe(i,"focus",function(j){h.focus()});Event.observe(i,"blur",function(j){h.blur()});h._observeEvents();if(Prototype.Browser.Gecko){h.execCommand("undo",false,null)}if(d){d(h)}h.focus()})},include:function(a){this.includedModules=this.includedModules||$A([]);this.includedModules.push(a)},extend:function(b){var a=this.includedModules||$A([]);a.each(function(c){Object.extend(b,c)})}};WysiHat.Commands=(function(){function h(){this.execCommand("bold",false,null)}function r(){return this.queryCommandState("bold")}function z(){this.execCommand("underline",false,null)}function s(){return this.queryCommandState("underline")}function n(){this.execCommand("italic",false,null)}function x(){return this.queryCommandState("italic")}function q(){this.execCommand("strikethrough",false,null)}function d(){this.execCommand("blockquote",false,null)}function m(A){this.execCommand("fontname",false,A)}function p(A){this.execCommand("fontsize",false,A)}function y(A){this.execCommand("forecolor",false,A)}function l(A){if(Prototype.Browser.Gecko){this.execCommand("hilitecolor",false,A)}else{this.execCommand("backcolor",false,A)}}function w(A){this.execCommand("justify"+A)}function b(){var A=this.selection.getNode();return Element.getStyle(A,"textAlign")}function g(A){this.execCommand("createLink",false,A)}function i(){var A=this.selection.getNode();if(this.linkSelected()){this.selection.selectNode(A)}this.execCommand("unlink",false,null)}function v(){var A=this.selection.getNode();return A?A.tagName.toUpperCase()=="A":false}function o(A){this.execCommand("formatblock",false,A)}function k(){this.execCommand("insertorderedlist",false,null)}function j(){this.execCommand("insertunorderedlist",false,null)}function c(A){this.execCommand("insertImage",false,A)}function a(B){if(Prototype.Browser.IE){var A=this._selection.getRange();A.pasteHTML(B);A.collapse(false);A.select()}else{this.execCommand("insertHTML",false,B)}}function t(E,D,C){var A=this.getDocument();if(Prototype.Browser.IE){this.selection.restore()}var B=this.commands.get(E);if(B){B.bind(this)(C)}else{A.execCommand(E,D,C)}}function e(C){var A=this.getDocument();var B=this.queryCommands.get(C);if(B){return B.bind(this)()}else{return A.queryCommandState(C)}}function u(){var B=$H({});var A=this;A.styleSelectors.each(function(C){var D=A.selection.getNode();B.set(C.first(),Element.getStyle(D,C.last()))});return B}return{boldSelection:h,boldSelected:r,underlineSelection:z,underlineSelected:s,italicSelection:n,italicSelected:x,strikethroughSelection:q,blockquoteSelection:d,fontSelection:m,fontSizeSelection:p,colorSelection:y,backgroundColorSelection:l,alignSelection:w,alignSelected:b,linkSelection:g,unlinkSelection:i,linkSelected:v,formatblockSelection:o,insertOrderedList:k,insertUnorderedList:j,insertImage:c,insertHTML:a,execCommand:t,queryCommandState:e,getSelectedStyles:u,commands:$H({}),queryCommands:$H({link:v}),styleSelectors:$H({fontname:"fontFamily",fontsize:"fontSize",forecolor:"color",hilitecolor:"backgroundColor",backcolor:"backgroundColor"})}})();WysiHat.Editor.include(WysiHat.Commands);WysiHat.Events=(function(){var a=["click","dblclick","mousedown","mouseup","mouseover","mousemove","mouseout","keypress","keydown","keyup"];function b(j,k){a.each(function(l){Event.observe(j,l,function(m){k.fire("wysihat:"+l)})})}function g(l,j,k){Event.observe(j,"keydown",function(m){if(m.keyCode==86){k.fire("wysihat:paste")}});Event.observe(l,"paste",function(m){k.fire("wysihat:paste")})}function c(k,j){Event.observe(k,"focus",function(l){j.fire("wysihat:focus")});Event.observe(k,"blur",function(l){j.fire("wysihat:blur")})}function i(j,k){Event.observe(j,"mouseup",function(m){var l=k.selection.getRange();if(!l.collapsed){k.fire("wysihat:select")}})}function e(j,k){var l=k.rawContent();Event.observe(j,"keyup",function(n){var m=k.rawContent();if(l!=m){k.fire("wysihat:change");l=m}})}function d(j,l){var m=l.selection.getRange();var k=function(o){var n=l.selection.getRange();if(m!=n){l.fire("wysihat:cursormove");m=n}};Event.observe(j,"keyup",k);Event.observe(j,"mouseup",k)}function h(){if(this._observers_setup){return}var j=this.getDocument();var k=this.getWindow();b(j,this);g(k,j,this);c(k,this);i(j,this);e(j,this);d(j,this);this._observers_setup=true}return{_observeEvents:h}})();WysiHat.Editor.include(WysiHat.Events);WysiHat.Persistence=(function(){function h(i){return i.formatHTMLOutput()}function a(i){return i.formatHTMLInput()}function e(){return this.outputFilter(this.rawContent())}function d(i){this.setRawContent(this.inputFilter(i))}function c(){this.textarea.value=this.content()}function g(){this.setContent(this.textarea.value)}function b(){this.selection.setBookmark();this.save();this.load();this.selection.moveToBookmark()}return{outputFilter:h,inputFilter:a,content:e,setContent:d,save:c,load:g,reload:b}})();WysiHat.Editor.include(WysiHat.Persistence);WysiHat.Window=(function(){function c(){return this.contentDocument||this.contentWindow.document}function b(){if(this.contentDocument&&this.contentDocument.defaultView){return this.contentDocument.defaultView}else{if(this.contentWindow.document){return this.contentWindow}else{return null}}}function a(){this.getWindow().focus();if(this.hasFocus){return}this.hasFocus=true}function d(){this.hasFocus=false}return{getDocument:c,getWindow:b,focus:a,blur:d}})();WysiHat.Editor.include(WysiHat.Window);WysiHat.iFrame={create:function(a,c){var b=new Element("iframe",{id:a.id+"_editor","class":"editor"});Object.extend(b,WysiHat.iFrame.Methods);WysiHat.Editor.extend(b);b.attach(a,c);a.insert({before:b});return b}};WysiHat.iFrame.Methods={attach:function(a,b){this.textarea=a;this.observe("load",function(){try{var c=this.getDocument()}catch(d){return}this.selection=new WysiHat.Selection(this);if(this.ready&&c.designMode=="on"){return}this.setStyle({});c.designMode="on";b(this);this.ready=true;this.fire("wysihat:ready")})},unattach:function(){this.remove()},whenReady:function(b){if(this.ready){b(this)}else{var a=this;a.observe("wysihat:ready",function(){b(a)})}return this},setStyle:function(e){var a=this.getDocument();var c=this;if(!this.ready){return setTimeout(function(){c.setStyle(e)},1)}if(Prototype.Browser.IE){var d=a.createStyleSheet();d.addRule("body","border: 0");d.addRule("p","margin: 0");$H(e).each(function(h){var g=h.first().underscore().dasherize()+": "+h.last();d.addRule("body",g)})}else{if(Prototype.Browser.Opera){var d=Element("style").update("p { margin: 0; }");var b=a.getElementsByTagName("head")[0];b.appendChild(d)}else{Element.setStyle(a.body,e)}}return this},getStyle:function(b){var a=this.getDocument();return Element.getStyle(a.body,b)},rawContent:function(){var a=this.getDocument();if(a.body){return a.body.innerHTML}else{return""}},setRawContent:function(b){var a=this.getDocument();if(a.body){a.body.innerHTML=b}}};WysiHat.Editable={create:function(a,c){var b=new Element("div",{id:a.id+"_editor","class":"editor",contenteditable:"true"});b.textarea=a;WysiHat.Editor.extend(b);Object.extend(b,WysiHat.Editable.Methods);c(b);a.insert({before:b});return b}};WysiHat.Editable.Methods={getDocument:function(){return document},getWindow:function(){return window},rawContent:function(){return this.innerHTML},setRawContent:function(a){this.innerHTML=a}};Object.extend(String.prototype,(function(){function a(){var k=String(this);k=k.tidyXHTML();if(Prototype.Browser.WebKit){k=k.replace(/(
)+/g,"\n");k=k.replace(/(<\/div>)+/g,"");k=k.replace(/

\s*<\/p>/g,"");k=k.replace(/
(\n)*/g,"\n")}else{if(Prototype.Browser.Gecko){k=k.replace(/

/g,"");k=k.replace(/<\/p>(\n)?/g,"\n");k=k.replace(/
(\n)*/g,"\n")}else{if(Prototype.Browser.IE||Prototype.Browser.Opera){k=k.replace(/

( | |\s)<\/p>/g,"

");k=k.replace(/
/g,"");k=k.replace(/

/g,"");k=k.replace(/ /g,"");k=k.replace(/<\/p>(\n)?/g,"\n");k=k.gsub(/^

/,"");k=k.gsub(/<\/p>$/,"")}}}k=k.gsub(//,"");k=k.gsub(/<\/b>/,"");k=k.gsub(//,"");k=k.gsub(/<\/i>/,"");k=k.replace(/\n\n+/g,"

\n\n

");k=k.gsub(/(([^\n])(\n))(?=([^\n]))/,"#{2}
\n");k="

"+k+"

";k=k.replace(/

\s*/g,"

");k=k.replace(/\s*<\/p>/g,"

");var e=Element("body");e.innerHTML=k;if(Prototype.Browser.WebKit||Prototype.Browser.Gecko){var j;do{j=false;e.select("span").each(function(i){if(i.hasClassName("Apple-style-span")){i.removeClassName("Apple-style-span");if(i.className==""){i.removeAttribute("class")}j=true}else{if(i.getStyle("fontWeight")=="bold"){i.setStyle({fontWeight:""});if(i.style.length==0){i.removeAttribute("style")}i.update(""+i.innerHTML+"");j=true}else{if(i.getStyle("fontStyle")=="italic"){i.setStyle({fontStyle:""});if(i.style.length==0){i.removeAttribute("style")}i.update(""+i.innerHTML+"");j=true}else{if(i.getStyle("textDecoration")=="underline"){i.setStyle({textDecoration:""});if(i.style.length==0){i.removeAttribute("style")}i.update(""+i.innerHTML+"");j=true}else{if(i.attributes.length==0){i.replace(i.innerHTML);j=true}}}}}})}while(j)}var h=$A(["BR","IMG"]);for(var d=0;d(\n)*/g,"
\n");k=k.replace(/<\/p>\n

/g,"

\n\n

");k=k.replace(/

\s*<\/p>/g,"");k=k.replace(/\s*$/g,"");return k}function b(){var e=String(this);var d=Element("body");d.innerHTML=e;if(Prototype.Browser.Gecko||Prototype.Browser.WebKit){d.select("strong").each(function(g){g.replace(''+g.innerHTML+"")});d.select("em").each(function(g){g.replace(''+g.innerHTML+"")});d.select("u").each(function(g){g.replace(''+g.innerHTML+"")})}if(Prototype.Browser.WebKit){d.select("span").each(function(g){if(g.getStyle("fontWeight")=="bold"){g.addClassName("Apple-style-span")}if(g.getStyle("fontStyle")=="italic"){g.addClassName("Apple-style-span")}if(g.getStyle("textDecoration")=="underline"){g.addClassName("Apple-style-span")}})}e=d.innerHTML;e=e.tidyXHTML();e=e.replace(/<\/p>(\n)*

/g,"\n\n");e=e.replace(/(\n)?(\n)?/g,"\n");e=e.replace(/^

/g,"");e=e.replace(/<\/p>$/g,"");if(Prototype.Browser.Gecko){e=e.replace(/\n/g,"
");e=e+"
"}else{if(Prototype.Browser.WebKit){e=e.replace(/\n/g,"

");e="
"+e+"
";e=e.replace(/
<\/div>/g,"

")}else{if(Prototype.Browser.IE||Prototype.Browser.Opera){e=e.replace(/\n/g,"

\n

");e="

"+e+"

";e=e.replace(/

<\/p>/g,"

 

");e=e.replace(/(

 <\/p>)+$/g,"")}}}return e}function c(){var d=String(this);d=d.gsub(/\r\n?/,"\n");d=d.gsub(/<([A-Z]+)([^>]*)>/,function(e){return"<"+e[1].toLowerCase()+e[2]+">"});d=d.gsub(/<\/([A-Z]+)>/,function(e){return""});d=d.replace(/
/g,"
");return d}return{formatHTMLOutput:a,formatHTMLInput:b,tidyXHTML:c}})());Object.extend(String.prototype,{sanitize:function(a){return Element("div").update(this).sanitize(a).innerHTML.tidyXHTML()}});Element.addMethods({sanitize:function(c,b){c=$(c);b=$H(b);var a=$A(b.get("tags")||[]);var d=$A(b.get("attributes")||[]);var e=Element(c.nodeName);$A(c.childNodes).each(function(i){if(i.nodeType==1){var g=$(i).sanitize(b).childNodes;if(a.include(i.nodeName.toLowerCase())){var h=Element(i.nodeName);d.each(function(j){if((value=i.readAttribute(j))){h.writeAttribute(j,value)}});e.appendChild(h);$A(g).each(function(j){h.appendChild(j)})}else{$A(g).each(function(j){e.appendChild(j)})}}else{if(i.nodeType==3){e.appendChild(i)}}});return e}});if(typeof Range=="undefined"){Range=function(a){this.ownerDocument=a;this.startContainer=this.ownerDocument.documentElement;this.startOffset=0;this.endContainer=this.ownerDocument.documentElement;this.endOffset=0;this.collapsed=true;this.commonAncestorContainer=this._commonAncestorContainer(this.startContainer,this.endContainer);this.detached=false;this.START_TO_START=0;this.START_TO_END=1;this.END_TO_END=2;this.END_TO_START=3};Range.CLONE_CONTENTS=0;Range.DELETE_CONTENTS=1;Range.EXTRACT_CONTENTS=2;if(!document.createRange){document.createRange=function(){return new Range(this)}}Object.extend(Range.prototype,(function(){function r(){return e(this,Range.CLONE_CONTENTS)}function x(){try{var z=new Range(this.ownerDocument);z.startContainer=this.startContainer;z.startOffset=this.startOffset;z.endContainer=this.endContainer;z.endOffset=this.endOffset;z.collapsed=this.collapsed;z.commonAncestorContainer=this.commonAncestorContainer;z.detached=this.detached;return z}catch(y){return null}}function b(y){if(y){this.endContainer=this.startContainer;this.endOffset=this.startOffset;this.collapsed=true}else{this.startContainer=this.endContainer;this.startOffset=this.endOffset;this.collapsed=true}}function a(z,E){try{var A,D,C,y;A=this.commonAncestorContainer;D=E.commonAncestorContainer;C=A;while(C.parentNode){C=C.parentNode}y=D;while(y.parentNode){y=y.parentNode}switch(z){case this.START_TO_START:return p(this,this.startContainer,this.startOffset,E.startContainer,E.startOffset);break;case this.START_TO_END:return p(this,this.startContainer,this.startOffset,E.endContainer,E.endOffset);break;case this.END_TO_END:return p(this,this.endContainer,this.endOffset,E.endContainer,E.endOffset);break;case this.END_TO_START:return p(this,this.endContainer,this.endOffset,E.startContainer,E.startOffset);break}}catch(B){}return null}function w(){try{e(this,Range.DELETE_CONTENTS)}catch(y){}}function v(){this.detached=true}function o(){try{return e(this,Range.EXTRACT_CONTENTS)}catch(y){return null}}function k(y){try{var C,z,B;switch(this.startContainer.nodeType){case Node.CDATA_SECTION_NODE:case Node.TEXT_NODE:z=this.startContainer.splitText(this.startOffset);this.startContainer.parentNode.insertBefore(y,z);break;default:if(this.startContainer.childNodes.length==0){B=null}else{B=this.startContainer.childNodes(this.startOffset)}this.startContainer.insertBefore(y,B)}}catch(A){}}function d(y){this.setStartBefore(y);this.setEndAfter(y)}function u(y){this.setStart(y,0);this.setEnd(y,y.childNodes.length)}function q(y,C){try{var z,B;this.startContainer=y;this.startOffset=C;z=this.endContainer;while(z.parentNode){z=z.parentNode}B=this.startContainer;while(B.parentNode){B=B.parentNode}if(B!=z){this.collapse(true)}else{if(p(this,this.startContainer,this.startOffset,this.endContainer,this.endOffset)>0){this.collapse(true)}}this.collapsed=t(this);this.commonAncestorContainer=s(this.startContainer,this.endContainer)}catch(A){}}function n(y){this.setStart(y.parentNode,h(y)+1)}function j(y){this.setStart(y.parentNode,h(y))}function i(y,A){try{this.endContainer=y;this.endOffset=A;endRootContainer=this.endContainer;while(endRootContainer.parentNode){endRootContainer=endRootContainer.parentNode}startRootContainer=this.startContainer;while(startRootContainer.parentNode){startRootContainer=startRootContainer.parentNode}if(startRootContainer!=endRootContainer){this.collapse(false)}else{if(p(this,this.startContainer,this.startOffset,this.endContainer,this.endOffset)>0){this.collapse(false)}}this.collapsed=t(this);this.commonAncestorContainer=s(this.startContainer,this.endContainer)}catch(z){}}function g(y){this.setEnd(y.parentNode,h(y)+1)}function l(y){this.setEnd(y.parentNode,h(y))}function m(z){try{var B,y;while(z.firstChild){z.removeChild(z.firstChild)}y=this.extractContents();this.insertNode(z);z.appendChild(y);this.selectNode(z)}catch(A){}}function p(D,B,E,z,C){var G,A,y,F,H;if(B==z){if(E==C){return 0}else{if(E"+l.get("label")+"");m.addClassName(l.get("name"));n.appendChild(m);return m}function k(m,l){if(l.handler){return l.handler}else{if(l.get("handler")){return l.get("handler")}else{return function(n){n.execCommand(m)}}}}function g(l,m){var n=this;l.observe("click",function(o){m(n.editor);n.editor.fire("wysihat:change");n.editor.fire("wysihat:cursormove");Event.stop(o)})}function c(m,l){if(l.query){return l.query}else{if(l.get("query")){return l.get("query")}else{return function(n){return n.queryCommandState(m)}}}}function h(n,m,o){var p=this;var l=false;p.editor.observe("wysihat:cursormove",function(q){var r=o(p.editor);if(r!=l){l=r;p.updateButtonState(n,m,r)}})}function b(m,l,n){if(n){m.addClassName("selected")}else{m.removeClassName("selected")}}return{initialize:e,createToolbarElement:a,addButtonSet:d,addButton:j,createButtonElement:i,buttonHandler:k,observeButtonClick:g,buttonStateHandler:c,observeStateChanges:h,updateButtonState:b}})());WysiHat.Toolbar.ButtonSets={};WysiHat.Toolbar.ButtonSets.Basic=$A([{label:"Bold"},{label:"Underline"},{label:"Italic"}]);var editors=[];var WysihatHelper={faceboxFile:function(){facebox.loading();new Effect.Appear($("facebox"),{duration:0.3});var b=facebox;var a="/wysihat_files/?editor="+this.id;new Ajax.Request(a,{method:"get",onFailure:function(c){b.reveal(c.responseText,null)},onSuccess:function(c){b.reveal(c.responseText,null)}})},faceboxLink:function(){if(this.linkSelected()){this.unlinkSelection()}else{facebox.loading();new Effect.Appear($("facebox"),{duration:0.3});iframe=this;facebox.reveal('',null);Event.observe("link_field","change",function(a){iframe.linkSelection($("link_field").value)})}},faceboxHTML:function(){facebox.loading();new Effect.Appear($("facebox"),{duration:0.3});iframe=this;facebox.reveal('",null);Event.observe("html_editor","change",function(a){iframe.contentWindow.document.body.innerHTML=$("html_editor").value})}};function wysiHatify(d,c){WysiHat.Editor.include(WysihatHelper);var a=WysiHat.Editor.attach(d);var b=new WysiHat.Toolbar(a);editors.push(a);$$("form").each(function(e){e.onsubmit=function(){editors.each(function(g){g.save()})}});c.each(function(e){switch(e.toLowerCase()){case"image":b.addButton({label:e.gsub("_","-").camelize().capitalize(),handler:function(g){return g.faceboxFile(g)}});break;case"link":b.addButton({label:e.gsub("_","-").camelize().capitalize(),handler:function(g){return g.faceboxLink(g)}});break;case"html":b.addButton({label:e.gsub("_","-").camelize().capitalize(),handler:function(g){return g.faceboxHTML(g)}});break;case"paste":b.addButton({label:e.gsub("_","-").camelize().capitalize(),handler:function(g){return g.faceboxPaste(g)}});case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":case"p":b.addButton({label:e.gsub("_","-").camelize().capitalize(),handler:function(g){return g.formatblockSelection(e.toLowerCase())}});break;default:b.addButton({label:e.gsub("_","-").camelize().capitalize()})}})}; \ No newline at end of file diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/migrations/create_wysihat_files.rb b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/migrations/create_wysihat_files.rb similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/migrations/create_wysihat_files.rb rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/migrations/create_wysihat_files.rb diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/sass/facebox.sass b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/sass/facebox.sass similarity index 100% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/sass/facebox.sass rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/sass/facebox.sass diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/sass/wysihat.sass b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/sass/wysihat.sass similarity index 73% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/sass/wysihat.sass rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/sass/wysihat.sass index 36304f4..b1e20d2 100644 --- a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/sass/wysihat.sass +++ b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/templates/sass/wysihat.sass @@ -55,8 +55,29 @@ div.editor_toolbar .html background-image: url('../images/icons/page_code.png') - - + + .h1 + background-image: url('../images/icons/text_heading_1.png') + + .h2 + background-image: url('../images/icons/text_heading_2.png') + + .h3 + background-image: url('../images/icons/text_heading_3.png') + + .h4 + background-image: url('../images/icons/text_heading_4.png') + + .h5 + background-image: url('../images/icons/text_heading_5.png') + + .h6 + background-image: url('../images/icons/text_heading_6.png') + + .p + background-image: url('../images/icons/cancel.png') + + iframe.editor border: 1px solid #999 height: 400px diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/wysihat_generator.rb b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/wysihat_generator.rb similarity index 86% rename from vendor/gems/wysihat-engine-0.1.9/generators/wysihat/wysihat_generator.rb rename to vendor/gems/wysihat-engine-0.1.10/generators/wysihat/wysihat_generator.rb index 792afed..92fb890 100644 --- a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/wysihat_generator.rb +++ b/vendor/gems/wysihat-engine-0.1.10/generators/wysihat/wysihat_generator.rb @@ -55,6 +55,13 @@ def manifest m.file 'images/icons/text_list_numbers.png', 'public/images/icons/text_list_numbers.png' m.file 'images/icons/text_strikethrough.png', 'public/images/icons/text_strikethrough.png' m.file 'images/icons/text_underline.png', 'public/images/icons/text_underline.png' + m.file 'images/icons/text_heading_1.png', 'public/images/icons/text_heading_1.png' + m.file 'images/icons/text_heading_2.png', 'public/images/icons/text_heading_2.png' + m.file 'images/icons/text_heading_3.png', 'public/images/icons/text_heading_3.png' + m.file 'images/icons/text_heading_4.png', 'public/images/icons/text_heading_4.png' + m.file 'images/icons/text_heading_5.png', 'public/images/icons/text_heading_5.png' + m.file 'images/icons/text_heading_6.png', 'public/images/icons/text_heading_6.png' + m.file 'images/icons/cancel.png', 'public/images/icons/cancel.png' end m.migration_template 'migrations/create_wysihat_files.rb', diff --git a/vendor/gems/wysihat-engine-0.1.9/lib/wysihat-engine.rb b/vendor/gems/wysihat-engine-0.1.10/lib/wysihat-engine.rb similarity index 82% rename from vendor/gems/wysihat-engine-0.1.9/lib/wysihat-engine.rb rename to vendor/gems/wysihat-engine-0.1.10/lib/wysihat-engine.rb index 51a4e6f..695fe02 100755 --- a/vendor/gems/wysihat-engine-0.1.9/lib/wysihat-engine.rb +++ b/vendor/gems/wysihat-engine-0.1.10/lib/wysihat-engine.rb @@ -7,30 +7,30 @@ def wysihat_editor(object_name, method, options = {}) InstanceTag.new(object_name, method, self, options.delete(:object)).to_wysihat_editor_tag(options) end end - + class InstanceTag #:nodoc: def to_wysihat_editor_tag(options = {}) options = DEFAULT_TEXT_AREA_OPTIONS.merge(options.stringify_keys) add_default_name_and_id(options) - + size = options.delete("size") - options["cols"], options["rows"] = size.split("x") if size && size.respond_to?(:split) - + options["cols"], options["rows"] = size.split("x") if size && size.respond_to?(:split) + if options['buttons'] == nil || options['buttons'] == :all - buttons = [:bold, :italic, :underline, :strikethrough, :justify_left, :justify_center, :justify_right, :insert_ordered_list, :insert_unordered_list, :undo, :redo, :link, :html, :image] + buttons = [:bold, :italic, :underline, :h1, :h2, :h3, :p, :strikethrough, :justify_left, :justify_center, :justify_right, :insert_ordered_list, :insert_unordered_list, :undo, :redo, :link, :html, :image] else buttons = options['buttons'] end - + javascript = "Event.observe(window, 'load', function() {" << "wysiHatify('#{tag_id}', ['#{buttons.join('\', \'')}']);" << "});" - + content_tag(:script, javascript, :type => 'text/javascript') << content_tag(:textarea, html_escape(options.delete('value') || value_before_type_cast(object)), options.merge(:class => 'wysihat_editor')) end end - + class FormBuilder #:nodoc: def wysihat_editor(method, options = {}) @template.wysihat_editor(@object_name, method, options) diff --git a/vendor/gems/wysihat-engine-0.1.9/wysihat-engine.gemspec b/vendor/gems/wysihat-engine-0.1.10/wysihat-engine.gemspec similarity index 88% rename from vendor/gems/wysihat-engine-0.1.9/wysihat-engine.gemspec rename to vendor/gems/wysihat-engine-0.1.10/wysihat-engine.gemspec index e761400..eb141ec 100644 --- a/vendor/gems/wysihat-engine-0.1.9/wysihat-engine.gemspec +++ b/vendor/gems/wysihat-engine-0.1.10/wysihat-engine.gemspec @@ -5,11 +5,11 @@ Gem::Specification.new do |s| s.name = %q{wysihat-engine} - s.version = "0.1.9" + s.version = "0.1.10" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Jeff Kreeftmeijer"] - s.date = %q{2009-12-22} + s.date = %q{2010-01-11} s.description = %q{A Rails engine to help integrate the 37signals WysiHat rich text editor to your application.} s.email = %q{jeff@80beans.com} s.extra_rdoc_files = [ @@ -42,6 +42,7 @@ Gem::Specification.new do |s| "generators/wysihat/templates/images/facebox/tr.png", "generators/wysihat/templates/images/icons/arrow_redo.png", "generators/wysihat/templates/images/icons/arrow_undo.png", + "generators/wysihat/templates/images/icons/cancel.png", "generators/wysihat/templates/images/icons/exclamation.png", "generators/wysihat/templates/images/icons/image.png", "generators/wysihat/templates/images/icons/link.png", @@ -50,6 +51,12 @@ Gem::Specification.new do |s| "generators/wysihat/templates/images/icons/text_align_left.png", "generators/wysihat/templates/images/icons/text_align_right.png", "generators/wysihat/templates/images/icons/text_bold.png", + "generators/wysihat/templates/images/icons/text_heading_1.png", + "generators/wysihat/templates/images/icons/text_heading_2.png", + "generators/wysihat/templates/images/icons/text_heading_3.png", + "generators/wysihat/templates/images/icons/text_heading_4.png", + "generators/wysihat/templates/images/icons/text_heading_5.png", + "generators/wysihat/templates/images/icons/text_heading_6.png", "generators/wysihat/templates/images/icons/text_italic.png", "generators/wysihat/templates/images/icons/text_list_bullets.png", "generators/wysihat/templates/images/icons/text_list_numbers.png", diff --git a/vendor/gems/wysihat-engine-0.1.9/VERSION b/vendor/gems/wysihat-engine-0.1.9/VERSION deleted file mode 100644 index 1a03094..0000000 --- a/vendor/gems/wysihat-engine-0.1.9/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.1.9 diff --git a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/javascripts/wysihat_engine_pack.js b/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/javascripts/wysihat_engine_pack.js deleted file mode 100644 index e0471a5..0000000 --- a/vendor/gems/wysihat-engine-0.1.9/generators/wysihat/templates/javascripts/wysihat_engine_pack.js +++ /dev/null @@ -1 +0,0 @@ -var Facebox=Class.create({initialize:function(a){this.settings={loading_image:"/images/facebox/loading.gif",close_image:"/images/facebox/closelabel.gif",image_types:new RegExp("."+["png","jpg","jpeg","gif"].join("|")+"$","i"),inited:true,facebox_html:'

'};if(a){Object.extend(this.settings,a)}$(document.body).insert({bottom:this.settings.facebox_html});this.preload=[new Image(),new Image()];this.preload[0].src=this.settings.close_image;this.preload[1].src=this.settings.loading_image;f=this;$$("#facebox .b:first, #facebox .bl, #facebox .br, #facebox .tl, #facebox .tr").each(function(b){f.preload.push(new Image());f.preload.slice(-1).src=b.getStyle("background-image").replace(/url\((.+)\)/,"$1")});this.facebox=$("facebox");this.keyPressListener=this.watchKeyPress.bindAsEventListener(this);this.watchClickEvents();fb=this;Event.observe($$("#facebox .close").first(),"click",function(b){Event.stop(b);fb.close()});Event.observe($$("#facebox .close_image").first(),"click",function(b){Event.stop(b);fb.close()})},watchKeyPress:function(a){if(a.keyCode==27||!Event.element(a).descendantOf(this.facebox)){this.close()}},watchClickEvents:function(b){var a=this;$$("a[rel=facebox]").each(function(d,c){Event.observe(d,"click",function(g){Event.stop(g);a.click_handler(d,g)})})},loading:function(){if($$("#facebox .loading").length==1){return true}contentWrapper=$$("#facebox .content").first();contentWrapper.childElements().each(function(c,b){c.remove()});contentWrapper.insert({bottom:'
'});var a=document.viewport.getScrollOffsets();this.facebox.setStyle({top:a.top+(document.viewport.getHeight()/10)+"px",left:document.viewport.getWidth()/2-(this.facebox.getWidth()/2)+"px"});Event.observe(document,"keypress",this.keyPressListener);Event.observe(document,"click",this.keyPressListener)},reveal:function(b,a){this.loading();load=$$("#facebox .loading").first();if(load){load.remove()}contentWrapper=$$("#facebox .content").first();if(a){contentWrapper.addClassName(a)}contentWrapper.update(b);$$("#facebox .body").first().childElements().each(function(d,c){d.show()});if(!this.facebox.visible()){new Effect.Appear(this.facebox,{duration:0.3})}this.facebox.setStyle({left:document.viewport.getWidth()/2-(this.facebox.getWidth()/2)+"px"});Event.observe(document,"keypress",this.keyPressListener);Event.observe(document,"click",this.keyPressListener)},close:function(){new Effect.Fade("facebox",{duration:0.3})},click_handler:function(c,i){this.loading();Event.stop(i);var k=c.rel.match(/facebox\[\.(\w+)\]/);if(k){k=k[1]}new Effect.Appear(this.facebox,{duration:0.3});if(c.href.match(/#/)){var a=window.location.href.split("#")[0];var j=c.href.replace(a+"#","");var l=$(j);var h=new Element(l.tagName);h.innerHTML=l.innerHTML;this.reveal(h,k)}else{if(c.href.match(this.settings.image_types)){var g=new Image();b=this;g.onload=function(){b.reveal('
',k)};g.src=c.href}else{var b=this;var a=c.href;new Ajax.Request(a,{method:"get",onFailure:function(d){b.reveal(d.responseText,k)},onSuccess:function(d){b.reveal(d.responseText,k)}})}}}});var facebox;document.observe("dom:loaded",function(){facebox=new Facebox()});var WysiHat={};WysiHat.Editor={attach:function(a,c,e){c=$H(c);a=$(a);a.hide();var b=c.get("model")||WysiHat.iFrame;var d=e;return b.create(a,function(h){var g=h.getDocument();var i=h.getWindow();h.load();Event.observe(i,"focus",function(j){h.focus()});Event.observe(i,"blur",function(j){h.blur()});h._observeEvents();if(Prototype.Browser.Gecko){h.execCommand("undo",false,null)}if(d){d(h)}h.focus()})},include:function(a){this.includedModules=this.includedModules||$A([]);this.includedModules.push(a)},extend:function(b){var a=this.includedModules||$A([]);a.each(function(c){Object.extend(b,c)})}};WysiHat.Commands=(function(){function l(){this.execCommand("bold",false,null)}function w(){return this.queryCommandState("bold")}function H(){this.execCommand("underline",false,null)}function x(){return this.queryCommandState("underline")}function t(){this.execCommand("italic",false,null)}function F(){return this.queryCommandState("italic")}function v(){this.execCommand("strikethrough",false,null)}function g(){this.execCommand("blockquote",false,null)}function q(I){this.execCommand("fontname",false,I)}function m(){var I=this.selection.getNode();return Element.getStyle(I,"fontFamily")}function u(I){this.execCommand("fontsize",false,I)}function c(){var I=this.selection.getNode();return r(Element.getStyle(I,"fontSize"))}function G(I){this.execCommand("forecolor",false,I)}function k(){var I=this.selection.getNode();return y(Element.getStyle(I,"color"))}function p(I){if(Prototype.Browser.Gecko){this.execCommand("hilitecolor",false,I)}else{this.execCommand("backcolor",false,I)}}function a(){var I=this.selection.getNode();return y(Element.getStyle(I,"backgroundColor"))}function E(I){this.execCommand("justify"+I)}function d(){var I=this.selection.getNode();return Element.getStyle(I,"textAlign")}function j(I){this.execCommand("createLink",false,I)}function i(){var I=this.selection.getNode();if(this.linkSelected()){this.selection.selectNode(I)}this.execCommand("unlink",false,null)}function C(){var I=this.selection.getNode();return I?I.tagName.toUpperCase()=="A":false}function o(){this.execCommand("insertorderedlist",false,null)}function n(){this.execCommand("insertunorderedlist",false,null)}function e(I){this.execCommand("insertImage",false,I)}function b(J){if(Prototype.Browser.IE){var I=this._selection.getRange();I.pasteHTML(J);I.collapse(false);I.select()}else{this.execCommand("insertHTML",false,J)}}function A(M,L,K){var I=this.getDocument();if(Prototype.Browser.IE){this.selection.restore()}var J=this.commands.get(M);if(J){J.bind(this)(K)}else{I.execCommand(M,L,K)}}function h(K){var I=this.getDocument();var J=this.queryCommands.get(K);if(J){return J.bind(this)()}else{return I.queryCommandState(K)}}var B=$w("xxx-small xx-small x-small small medium large x-large xx-large");var D=$w("9px 10px 13px 16px 18px 24px 32px 48px");if(Prototype.Browser.WebKit){B.shift();B.push("-webkit-xxx-large")}function r(J){var I=B.indexOf(J);if(I>=0){return I}I=D.indexOf(J);if(I>=0){return I}return parseInt(J)}function y(M){if(!M||M.match(/[0-9a-f]{6}/i)){return M}var J=M.toLowerCase().match(/^(rgba?|hsla?)\(([\s\.\-,%0-9]+)\)/);if(J){var P=J[2].split(/\s*,\s*/),K=P.length,V=J[1];if((V=="rgb"&&K==3)||(V=="rgba"&&K==4)){var I=P[0];if(I.charAt(I.length-1)=="%"){var Q=P.map(function(L){return parseFloat(L)*2.56});if(K==4){Q[3]=P[3]}return z(Q)}return z(P)}if((V=="hsl"&&K==3)||(V=="hsla"&&K==4)){var R=((parseFloat(P[0])%360)+360)%360/360,N=parseFloat(P[1])/100,O=parseFloat(P[2])/100,T=O<=0.5?O*(N+1):O+N-O*N,U=2*O-T,Q=[s(U,T,R+1/3)*256,s(U,T,R)*256,s(U,T,R-1/3)*256,1];if(K==4){Q[3]=P[3]}return z(Q)}}return null}function z(J){var I=J.slice(0,3).map(function(K){var L=parseInt(K).toString(16);return L.length<2?"0"+L:L});return"#"+I.join("")}function s(J,I,K){if(K<0){++K}if(K>1){--K}var L=6*K;if(L<1){return J+(I-J)*L}if(2*K<1){return I}if(3*K<2){return J+(I-J)*(2/3-K)*6}return J}return{boldSelection:l,boldSelected:w,underlineSelection:H,underlineSelected:x,italicSelection:t,italicSelected:F,strikethroughSelection:v,blockquoteSelection:g,fontSelection:q,fontSelected:m,fontSizeSelection:u,fontSizeSelected:c,colorSelection:G,colorSelected:k,backgroundColorSelection:p,backgroundColorSelected:a,alignSelection:E,alignSelected:d,linkSelection:j,unlinkSelection:i,linkSelected:C,insertOrderedList:o,insertUnorderedList:n,insertImage:e,insertHTML:b,execCommand:A,queryCommandState:h,commands:$H({}),queryCommands:$H({link:C})}})();WysiHat.Editor.include(WysiHat.Commands);WysiHat.Events=(function(){var a=["click","dblclick","mousedown","mouseup","mouseover","mousemove","mouseout","keypress","keydown","keyup"];function b(j,k){a.each(function(l){Event.observe(j,l,function(m){k.fire("wysihat:"+l)})})}function g(l,j,k){Event.observe(j,"keydown",function(m){if(m.keyCode==86){k.fire("wysihat:paste")}});Event.observe(l,"paste",function(m){k.fire("wysihat:paste")})}function c(k,j){Event.observe(k,"focus",function(l){j.fire("wysihat:focus")});Event.observe(k,"blur",function(l){j.fire("wysihat:blur")})}function i(j,k){Event.observe(j,"mouseup",function(m){var l=k.selection.getRange();if(!l.collapsed){k.fire("wysihat:select")}})}function e(j,k){var l=k.rawContent();Event.observe(j,"keyup",function(n){var m=k.rawContent();if(l!=m){k.fire("wysihat:change");l=m}})}function d(j,l){var m=l.selection.getRange();var k=function(o){var n=l.selection.getRange();if(m!=n){l.fire("wysihat:cursormove");m=n}};Event.observe(j,"keyup",k);Event.observe(j,"mouseup",k)}function h(){if(this._observers_setup){return}var j=this.getDocument();var k=this.getWindow();b(j,this);g(k,j,this);c(k,this);i(j,this);e(j,this);d(j,this);this._observers_setup=true}return{_observeEvents:h}})();WysiHat.Editor.include(WysiHat.Events);WysiHat.Persistence=(function(){function h(i){return i.formatHTMLOutput()}function a(i){return i.formatHTMLInput()}function e(){return this.outputFilter(this.rawContent())}function d(i){this.setRawContent(this.inputFilter(i))}function c(){this.textarea.value=this.content()}function g(){this.setContent(this.textarea.value)}function b(){this.selection.setBookmark();this.save();this.load();this.selection.moveToBookmark()}return{outputFilter:h,inputFilter:a,content:e,setContent:d,save:c,load:g,reload:b}})();WysiHat.Editor.include(WysiHat.Persistence);WysiHat.Window=(function(){function c(){return this.contentDocument||this.contentWindow.document}function b(){if(this.contentDocument&&this.contentDocument.defaultView){return this.contentDocument.defaultView}else{if(this.contentWindow.document){return this.contentWindow}else{return null}}}function a(){this.getWindow().focus();if(this.hasFocus){return}this.hasFocus=true}function d(){this.hasFocus=false}return{getDocument:c,getWindow:b,focus:a,blur:d}})();WysiHat.Editor.include(WysiHat.Window);WysiHat.iFrame={create:function(a,c){var b=new Element("iframe",{id:a.id+"_editor","class":"editor"});Object.extend(b,WysiHat.iFrame.Methods);WysiHat.Editor.extend(b);b.attach(a,c);a.insert({before:b});return b}};WysiHat.iFrame.Methods={attach:function(a,b){this.textarea=a;this.observe("load",function(){try{var c=this.getDocument()}catch(d){return}this.selection=new WysiHat.Selection(this);if(this.ready&&c.designMode=="on"){return}this.setStyle({});c.designMode="on";b(this);this.ready=true;this.fire("wysihat:ready")})},unattach:function(){this.remove()},whenReady:function(b){if(this.ready){b(this)}else{var a=this;a.observe("wysihat:ready",function(){b(a)})}return this},setStyle:function(e){var a=this.getDocument();var c=this;if(!this.ready){return setTimeout(function(){c.setStyle(e)},1)}if(Prototype.Browser.IE){var d=a.createStyleSheet();d.addRule("body","border: 0");d.addRule("p","margin: 0");$H(e).each(function(h){var g=h.first().underscore().dasherize()+": "+h.last();d.addRule("body",g)})}else{if(Prototype.Browser.Opera){var d=Element("style").update("p { margin: 0; }");var b=a.getElementsByTagName("head")[0];b.appendChild(d)}else{Element.setStyle(a.body,e)}}return this},getStyle:function(b){var a=this.getDocument();return Element.getStyle(a.body,b)},rawContent:function(){var a=this.getDocument();if(a.body){return a.body.innerHTML}else{return""}},setRawContent:function(b){var a=this.getDocument();if(a.body){a.body.innerHTML=b}}};WysiHat.Editable={create:function(a,c){var b=new Element("div",{id:a.id+"_editor","class":"editor",contenteditable:"true"});b.textarea=a;WysiHat.Editor.extend(b);Object.extend(b,WysiHat.Editable.Methods);c(b);a.insert({before:b});return b}};WysiHat.Editable.Methods={getDocument:function(){return document},getWindow:function(){return window},rawContent:function(){return this.innerHTML},setRawContent:function(a){this.innerHTML=a}};Object.extend(String.prototype,(function(){function a(){var k=String(this);k=k.tidyXHTML();if(Prototype.Browser.WebKit){k=k.replace(/(
)+/g,"\n");k=k.replace(/(<\/div>)+/g,"");k=k.replace(/

\s*<\/p>/g,"");k=k.replace(/
(\n)*/g,"\n")}else{if(Prototype.Browser.Gecko){k=k.replace(/

/g,"");k=k.replace(/<\/p>(\n)?/g,"\n");k=k.replace(/
(\n)*/g,"\n")}else{if(Prototype.Browser.IE||Prototype.Browser.Opera){k=k.replace(/

( | |\s)<\/p>/g,"

");k=k.replace(/
/g,"");k=k.replace(/

/g,"");k=k.replace(/ /g,"");k=k.replace(/<\/p>(\n)?/g,"\n");k=k.gsub(/^

/,"");k=k.gsub(/<\/p>$/,"")}}}k=k.gsub(//,"");k=k.gsub(/<\/b>/,"");k=k.gsub(//,"");k=k.gsub(/<\/i>/,"");k=k.replace(/\n\n+/g,"

\n\n

");k=k.gsub(/(([^\n])(\n))(?=([^\n]))/,"#{2}
\n");k="

"+k+"

";k=k.replace(/

\s*/g,"

");k=k.replace(/\s*<\/p>/g,"

");var e=Element("body");e.innerHTML=k;if(Prototype.Browser.WebKit||Prototype.Browser.Gecko){var j;do{j=false;e.select("span").each(function(i){if(i.hasClassName("Apple-style-span")){i.removeClassName("Apple-style-span");if(i.className==""){i.removeAttribute("class")}j=true}else{if(i.getStyle("fontWeight")=="bold"){i.setStyle({fontWeight:""});if(i.style.length==0){i.removeAttribute("style")}i.update(""+i.innerHTML+"");j=true}else{if(i.getStyle("fontStyle")=="italic"){i.setStyle({fontStyle:""});if(i.style.length==0){i.removeAttribute("style")}i.update(""+i.innerHTML+"");j=true}else{if(i.getStyle("textDecoration")=="underline"){i.setStyle({textDecoration:""});if(i.style.length==0){i.removeAttribute("style")}i.update(""+i.innerHTML+"");j=true}else{if(i.attributes.length==0){i.replace(i.innerHTML);j=true}}}}}})}while(j)}var h=$A(["BR","IMG"]);for(var d=0;d(\n)*/g,"
\n");k=k.replace(/<\/p>\n

/g,"

\n\n

");k=k.replace(/

\s*<\/p>/g,"");k=k.replace(/\s*$/g,"");return k}function b(){var e=String(this);var d=Element("body");d.innerHTML=e;if(Prototype.Browser.Gecko||Prototype.Browser.WebKit){d.select("strong").each(function(g){g.replace(''+g.innerHTML+"")});d.select("em").each(function(g){g.replace(''+g.innerHTML+"")});d.select("u").each(function(g){g.replace(''+g.innerHTML+"")})}if(Prototype.Browser.WebKit){d.select("span").each(function(g){if(g.getStyle("fontWeight")=="bold"){g.addClassName("Apple-style-span")}if(g.getStyle("fontStyle")=="italic"){g.addClassName("Apple-style-span")}if(g.getStyle("textDecoration")=="underline"){g.addClassName("Apple-style-span")}})}e=d.innerHTML;e=e.tidyXHTML();e=e.replace(/<\/p>(\n)*

/g,"\n\n");e=e.replace(/(\n)?(\n)?/g,"\n");e=e.replace(/^

/g,"");e=e.replace(/<\/p>$/g,"");if(Prototype.Browser.Gecko){e=e.replace(/\n/g,"
");e=e+"
"}else{if(Prototype.Browser.WebKit){e=e.replace(/\n/g,"

");e="
"+e+"
";e=e.replace(/
<\/div>/g,"

")}else{if(Prototype.Browser.IE||Prototype.Browser.Opera){e=e.replace(/\n/g,"

\n

");e="

"+e+"

";e=e.replace(/

<\/p>/g,"

 

");e=e.replace(/(

 <\/p>)+$/g,"")}}}return e}function c(){var d=String(this);d=d.gsub(/\r\n?/,"\n");d=d.gsub(/<([A-Z]+)([^>]*)>/,function(e){return"<"+e[1].toLowerCase()+e[2]+">"});d=d.gsub(/<\/([A-Z]+)>/,function(e){return""});d=d.replace(/
/g,"
");return d}return{formatHTMLOutput:a,formatHTMLInput:b,tidyXHTML:c}})());Object.extend(String.prototype,{sanitize:function(a){return Element("div").update(this).sanitize(a).innerHTML.tidyXHTML()}});Element.addMethods({sanitize:function(c,b){c=$(c);b=$H(b);var a=$A(b.get("tags")||[]);var d=$A(b.get("attributes")||[]);var e=Element(c.nodeName);$A(c.childNodes).each(function(i){if(i.nodeType==1){var g=$(i).sanitize(b).childNodes;if(a.include(i.nodeName.toLowerCase())){var h=Element(i.nodeName);d.each(function(j){if((value=i.readAttribute(j))){h.writeAttribute(j,value)}});e.appendChild(h);$A(g).each(function(j){h.appendChild(j)})}else{$A(g).each(function(j){e.appendChild(j)})}}else{if(i.nodeType==3){e.appendChild(i)}}});return e}});if(typeof Range=="undefined"){Range=function(a){this.ownerDocument=a;this.startContainer=this.ownerDocument.documentElement;this.startOffset=0;this.endContainer=this.ownerDocument.documentElement;this.endOffset=0;this.collapsed=true;this.commonAncestorContainer=this._commonAncestorContainer(this.startContainer,this.endContainer);this.detached=false;this.START_TO_START=0;this.START_TO_END=1;this.END_TO_END=2;this.END_TO_START=3};Range.CLONE_CONTENTS=0;Range.DELETE_CONTENTS=1;Range.EXTRACT_CONTENTS=2;if(!document.createRange){document.createRange=function(){return new Range(this)}}Object.extend(Range.prototype,(function(){function r(){return e(this,Range.CLONE_CONTENTS)}function x(){try{var z=new Range(this.ownerDocument);z.startContainer=this.startContainer;z.startOffset=this.startOffset;z.endContainer=this.endContainer;z.endOffset=this.endOffset;z.collapsed=this.collapsed;z.commonAncestorContainer=this.commonAncestorContainer;z.detached=this.detached;return z}catch(y){return null}}function b(y){if(y){this.endContainer=this.startContainer;this.endOffset=this.startOffset;this.collapsed=true}else{this.startContainer=this.endContainer;this.startOffset=this.endOffset;this.collapsed=true}}function a(z,E){try{var A,D,C,y;A=this.commonAncestorContainer;D=E.commonAncestorContainer;C=A;while(C.parentNode){C=C.parentNode}y=D;while(y.parentNode){y=y.parentNode}switch(z){case this.START_TO_START:return p(this,this.startContainer,this.startOffset,E.startContainer,E.startOffset);break;case this.START_TO_END:return p(this,this.startContainer,this.startOffset,E.endContainer,E.endOffset);break;case this.END_TO_END:return p(this,this.endContainer,this.endOffset,E.endContainer,E.endOffset);break;case this.END_TO_START:return p(this,this.endContainer,this.endOffset,E.startContainer,E.startOffset);break}}catch(B){}return null}function w(){try{e(this,Range.DELETE_CONTENTS)}catch(y){}}function v(){this.detached=true}function o(){try{return e(this,Range.EXTRACT_CONTENTS)}catch(y){return null}}function k(y){try{var C,z,B;switch(this.startContainer.nodeType){case Node.CDATA_SECTION_NODE:case Node.TEXT_NODE:z=this.startContainer.splitText(this.startOffset);this.startContainer.parentNode.insertBefore(y,z);break;default:if(this.startContainer.childNodes.length==0){B=null}else{B=this.startContainer.childNodes(this.startOffset)}this.startContainer.insertBefore(y,B)}}catch(A){}}function d(y){this.setStartBefore(y);this.setEndAfter(y)}function u(y){this.setStart(y,0);this.setEnd(y,y.childNodes.length)}function q(y,C){try{var z,B;this.startContainer=y;this.startOffset=C;z=this.endContainer;while(z.parentNode){z=z.parentNode}B=this.startContainer;while(B.parentNode){B=B.parentNode}if(B!=z){this.collapse(true)}else{if(p(this,this.startContainer,this.startOffset,this.endContainer,this.endOffset)>0){this.collapse(true)}}this.collapsed=t(this);this.commonAncestorContainer=s(this.startContainer,this.endContainer)}catch(A){}}function n(y){this.setStart(y.parentNode,h(y)+1)}function j(y){this.setStart(y.parentNode,h(y))}function i(y,A){try{this.endContainer=y;this.endOffset=A;endRootContainer=this.endContainer;while(endRootContainer.parentNode){endRootContainer=endRootContainer.parentNode}startRootContainer=this.startContainer;while(startRootContainer.parentNode){startRootContainer=startRootContainer.parentNode}if(startRootContainer!=endRootContainer){this.collapse(false)}else{if(p(this,this.startContainer,this.startOffset,this.endContainer,this.endOffset)>0){this.collapse(false)}}this.collapsed=t(this);this.commonAncestorContainer=s(this.startContainer,this.endContainer)}catch(z){}}function g(y){this.setEnd(y.parentNode,h(y)+1)}function l(y){this.setEnd(y.parentNode,h(y))}function m(z){try{var B,y;while(z.firstChild){z.removeChild(z.firstChild)}y=this.extractContents();this.insertNode(z);z.appendChild(y);this.selectNode(z)}catch(A){}}function p(D,B,E,z,C){var G,A,y,F,H;if(B==z){if(E==C){return 0}else{if(E"+l.get("label")+"");m.addClassName(l.get("name"));n.appendChild(m);return m}function k(m,l){if(l.handler){return l.handler}else{if(l.get("handler")){return l.get("handler")}else{return function(n){n.execCommand(m)}}}}function g(l,m){var n=this;l.observe("click",function(o){m(n.editor);n.editor.fire("wysihat:change");n.editor.fire("wysihat:cursormove");Event.stop(o)})}function c(m,l){if(l.query){return l.query}else{if(l.get("query")){return l.get("query")}else{return function(n){return n.queryCommandState(m)}}}}function h(n,m,o){var p=this;var l=false;p.editor.observe("wysihat:cursormove",function(q){var r=o(p.editor);if(r!=l){l=r;p.updateButtonState(n,m,r)}})}function b(m,l,n){if(n){m.addClassName("selected")}else{m.removeClassName("selected")}}return{initialize:e,createToolbarElement:a,addButtonSet:d,addButton:j,createButtonElement:i,buttonHandler:k,observeButtonClick:g,buttonStateHandler:c,observeStateChanges:h,updateButtonState:b}})());WysiHat.Toolbar.ButtonSets={};WysiHat.Toolbar.ButtonSets.Basic=$A([{label:"Bold"},{label:"Underline"},{label:"Italic"}]);var editors=[];var WysihatHelper={faceboxFile:function(){facebox.loading();new Effect.Appear($("facebox"),{duration:0.3});var b=facebox;var a="/wysihat_files/?editor="+this.id;new Ajax.Request(a,{method:"get",onFailure:function(c){b.reveal(c.responseText,null)},onSuccess:function(c){b.reveal(c.responseText,null)}})},faceboxLink:function(){if(this.linkSelected()){this.unlinkSelection()}else{facebox.loading();new Effect.Appear($("facebox"),{duration:0.3});iframe=this;facebox.reveal('',null);Event.observe("link_field","change",function(a){iframe.linkSelection($("link_field").value)})}},faceboxHTML:function(){facebox.loading();new Effect.Appear($("facebox"),{duration:0.3});iframe=this;facebox.reveal('",null);Event.observe("html_editor","change",function(a){iframe.contentWindow.document.body.innerHTML=$("html_editor").value})}};function wysiHatify(d,c){WysiHat.Editor.include(WysihatHelper);var a=WysiHat.Editor.attach(d);var b=new WysiHat.Toolbar(a);editors.push(a);$$("form").each(function(e){e.onsubmit=function(){editors.each(function(g){g.save()})}});c.each(function(e){switch(e.toLowerCase()){case"image":b.addButton({label:e.gsub("_","-").camelize().capitalize(),handler:function(g){return g.faceboxFile(g)}});break;case"link":b.addButton({label:e.gsub("_","-").camelize().capitalize(),handler:function(g){return g.faceboxLink(g)}});break;case"html":b.addButton({label:e.gsub("_","-").camelize().capitalize(),handler:function(g){return g.faceboxHTML(g)}});break;case"paste":b.addButton({label:e.gsub("_","-").camelize().capitalize(),handler:function(g){return g.faceboxPaste(g)}});break;default:b.addButton({label:e.gsub("_","-").camelize().capitalize()})}})}; \ No newline at end of file