jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [4/9] jspwiki-site git commit: Automatic Site Publish by Buildbot
Date Sat, 01 Jul 2017 17:23:45 GMT
http://git-wip-us.apache.org/repos/asf/jspwiki-site/blob/64b43923/js/haddock-edit.js
----------------------------------------------------------------------
diff --git a/js/haddock-edit.js b/js/haddock-edit.js
new file mode 100644
index 0000000..3da3474
--- /dev/null
+++ b/js/haddock-edit.js
@@ -0,0 +1 @@
+Array.implement({hsv2rgb:function(){var e=this,t,n,r,i,s,o=e[0]/360,u=e[1]/100,a=e[2]/100;return u?(o=o>1?0:6*o,s=o|0,n=a*(1-u),r=a*(1-u*(o-s)),i=a+n-r,t=s==0?[a,i,n]:s==1?[r,a,n]:s==2?[n,a,i]:s==3?[n,r,a]:s==4?[i,n,a]:[a,n,r]):t=[a,a,a],t.map(function(e){return.5+e*255|0})},rgb2hsv:function(){var e=this,t=0,n=0,r=255,i=e[0]/r,s,o=e[1]/r,u,a=e[2]/r,f,l=[i,o,a].max(),c=l-[i,o,a].min();return c&&(n=c/l,r=c/2,s=((l-i)/6+r)/c,u=((l-o)/6+r)/c,f=((l-a)/6+r)/c,t=i==l?f-u:o==l?1/3+s-f:2/3+u-s,t<0&&(t+=1),t>1&&(t-=1)),[t*360,n*100,l*100]}});var Dialog=new Class({Implements:[Events,Options],options:{cssShow:"show",cssClass:"",styles:{},relativeTo:document.body},initialize:function(e){var t=this,n;this.setClass(".dialog",e),this.setOptions(e),e=t.options,n=t.element=e.dialog||t.build(e),n.getElements(".close").addEvent("click",t.hide.bind(t)),n.getStyle("position")=="absolute"&&e.draggable&&new Drag(n,{handle:(t.get(".caption")||n).setStyle("cursor","move")}),t[e.showNow?"show":"hide"]()},toEl
 ement:function(){return this.element},get:function(e){return this.element.getElement(e)},hasClass:function(e){return this.element.hasClass(e)},ifClass:function(e,t,n){var r=this.element;return r&&r.ifClass(e,t,n),this},setClass:function(e,t){t.cssClass=e+(t.cssClass||"")},destroy:function(){this.element.destroy()},show:function(){this.fireEvent("beforeOpen",this);if(!this.options.draggable||!this.hasPosition)this.setPosition(),this.hasPosition=!0;return this.element.addClass(this.options.cssShow),this.fireEvent("open",this)},hide:function(){return this.hasPosition&&(this.fireEvent("beforeClose",this).element.removeClass(this.options.cssShow),this.fireEvent("close",this)),this},isVisible:function(){return this.element.hasClass(this.options.cssShow)},toggle:function(){return this[this.isVisible()?"hide":"show"]()},action:function(e){this.fireEvent("action",e),this.options.autoClose&&this.hide()},build:function(e){var t=this.element=["div"+e.cssClass,{styles:e.styles},["a.close",{html:
 "&#215;"},"div.body"]].slick().inject(document.body);return e.relativeTo&&t.inject($(e.relativeTo),"before"),this.setBody(e.body),e.caption&&this.setCaption(e.caption),t},setBody:function(e){var t=this.get(".body")||this.element,n=typeOf(e);return t.empty(),n=="string"&&t.set("html",e),n=="element"&&t.adopt(e),n=="elements"&&t.adopt(e),this},setCaption:function(e){var t=this.get(".caption")||"div.caption".slick().inject(this.element,"top"),n=typeOf(e);return t.empty(),n=="string"&&t.set("html",e),n=="element"&&t.adopt(e),this},setValue:function(e){return console.log("DIALOG  "+e),this.setBody(e)},setPosition:function(e){var t=window,n,r,i,s,o=this.element;return e||(e=this.options.relativeTo),s=e&&"getCoordinates"in e?e:document.id(e),s?(s=s.getCoordinates(),r=s.left,i=s.bottom):(n=t.getScroll(),t=t.getSize(),s=o.getCoordinates(),r=n.x+t.x/2-s.width/2,i=n.y+t.y/2-s.height/2),o.setPosition({x:r,y:i}),this}});Dialog.Buttons=new Class({Extends:Dialog,options:{buttons:[],autoClose:!0},i
 nitialize:function(e){this.setClass(".buttons",e),this.parent(e),this.setButtons(this.options.buttons)},setButtons:function(e){var t=this,n=t.get(".btn-group")||"div.btn-group".slick().inject(t.element);return n.empty().adopt(e.map(function(e){return"a.btn.btn-default.btn-sm".slick({html:e.localize(),events:{click:t.action.bind(t,e)}})})),t}}),Dialog.Color=new Class({Extends:Dialog,options:{color:"#ffffff",resize:{x:[96,256]}},initialize:function(e){var t=this,n,r=e.showNow,i=t.setHSV.bind(this);this.setClass(".color",e),e.caption="span.color".slick(),e.body=["div.cursor","div.zone"].slick(),n=t.cursor=e.body[0],e.showNow=!1,t.parent(e),new Drag(n,{handle:n.getNext(),style:!1,snap:0,onStart:i,onDrag:i}),t.setValue(),r&&t.show()},setValue:function(e){return e=(e||this.options.color).hexToRgb(!0)||[255,255,255],this.hsv=e.rgb2hsv(),this.moveCursor()},setHSV:function(e,t){var n=this,r=n.get(".body").getCoordinates(),i=[t.page.x-r.left,t.page.y-r.top],s=r.width,o=s/2,u=o/2,a=i[0]-o,f=s-
 i[1]-o,l=Math.sqrt(Math.pow(a,2)+Math.pow(f,2)),c=Math.atan2(a,f)/(Math.PI*2);n.hsv=[c>0?c*360:c*360+360,l<u?l/u*100:100,l>=u?Math.max(0,1-(l-u)/u)*100:100],n.moveCursor(),n.fireEvent("drag",n.getHex())},getHex:function(){return this.hsv.hsv2rgb().rgbToHex()},action:function(){this.parent(this.getHex())},show:function(){return this.parent().moveCursor()},moveCursor:function(){var e=this,t=e.hsv,n=e.getHex(),r=e.get(".body").getSize().x/2,i=t[0]/360*Math.PI*2,s=(t[1]+(100-t[2]))/100*(r/2);return e.get(".color").set({html:n,styles:{color:(new Color(n)).invert().hex,background:n}}),e.cursor.setStyles({left:Math.abs(Math.sin(i)*s+r),top:Math.abs(Math.cos(i)*s-r)}),e}}),Dialog.Selection=new Class({Extends:Dialog,options:{cssClass:"dialog selection",match:"^=",autoClose:!0},initialize:function(e){var t=this;t.setClass(".selection",e),t.selected=e.selected||"",t.parent(e),t.element.addEvent("click:relay(.item)",function(e){e.stop(),t.action(this.get("title"))})},setBody:function(e){var t=t
 his,n=[];return e||(e=t.options.body),typeOf(e)=="string"&&(e=e.split("|")),typeOf(e)=="array"&&(e=e.associate(e)),typeOf(e)=="object"&&(Object.each(e,function(e,t){n.push(e==""?"li.divider":"li.item",{html:e,title:t})}),e=["ul",n].slick()),typeOf(e)=="element"&&t.parent(e).setValue(t.selected),t},setValue:function(e){var t=this,n="selected",r,i=".item[title"+t.options.match+e+"]";return r=t.get("."+n),r&&r.removeClass(n),r=t.get(i),r&&r.addClass(n),t[n]=e,t},getValue:function(){return this.selected},action:function(e){this.setValue(e).parent(e)}}),Dialog.Font=new Class({Extends:Dialog.Selection,options:{fonts:{"arial, helvetica, sans-serif":"Sans Serif","times new roman, serif":"Serif",monospace:"Fixed Width","arial black, sans-serif":"Wide","arial narrow, sans-serif":"Narrow",divider1:"","comic sans ms":"Comic Sans","courier new":"Courier New",garamond:"Garamond",georgia:"Georgia",helvetica:"Helvetica","HelveticaNeue-Light":"Helvetica Neue Light",impact:"Impact","times new roman":
 "Times New Roman",tahoma:"Tahoma","trebuchet ms":"Trebuchet",verdana:"Verdana"}},initialize:function(e){var t=this;t.setClass(".font",e),e.body=e.fonts||t.options.fonts,t.parent(e),t.element.getElements(".item").each(function(e){e.setStyle("font-family",e.get("title"))})}}),Dialog.Chars=new Class({Extends:Dialog.Selection,options:{chars:["lsquo|rsquo|ldquo|rdquo|lsaquo|rsaquo|laquo|raquo|apos|quot|sbquo|bdquo","ndash|mdash|sect|para|dagger|Dagger|amp|lt|gt|copy|reg|trade","rarr|rArr|bull|middot|deg|plusmn|brvbar|times|divide|frac14|frac12|frac34","hellip|micro|cent|pound|euro|iquest|iexcl|uml|acute|cedil|circ|tilde","Agrave|Aacute|Acirc|Atilde|Auml|Aring|AElig|Ccedil|Egrave|Eacute|Ecirc|Euml","Igrave|Iacute|Icirc|Iuml|ETH|Ntilde|Ograve|Oacute|Ocirc|Otilde|Ouml|Oslash","OElig|Scaron|Ugrave|Uacute|Ucirc|Uuml|Yacute|Yuml|THORN|szlig|agrave|aacute","acirc|atilde|auml|aring|aelig|ccedil|egrave|eacute|ecirc|euml|igrave|iacute","icirc|iuml|eth|ntilde|ograve|oacute|ocirc|otilde|ouml|oslash|
 oelig|scaron","ugrave|uacute|ucirc|uuml|yacute|yuml|thorn|ordf|ordm|alpha|Omega|infin","not|sup2|sup3|permil|larr|uarr|darr|harr|hArr|crarr|loz|diams"]},initialize:function(e){this.setClass(".chars",e),this.parent(e)},setBody:function(){var e=[];return this.options.chars.map(function(t){var n=[];t.split("|").each(function(e){n.push("td.item[title=&"+e+";]",{html:"&"+e+";"})}),e.push("tr",n)}),this.parent(["table",e].slick())}}),Dialog.Find=new Class({Extends:Dialog,Binds:["find","replace"],options:{draggable:!0,controls:{f:"[name=tbFIND]",r:"[name=tbREPLACE]",h:".tbHITS",re:"[name=tbREGEXP]",i:"[name=tbMatchCASE]",one:"[name=replace]",all:"[name=replaceall]",tsel:"[name=tbTEXTSEL]"},data:{selection:function(){},get:function(){},set:function(){}}},initialize:function(e){var t=this.setOptions(e),n=t.options.dialog,r;this.setClass(".find",e),r=t.controls=Object.map(t.options.controls,function(e){return n.getElement(e)}),t.parent(e),r.f.addEvents({keyup:t.find,focus:t.find}),n.addEvents
 ({"change:relay([type=checkbox])":function(){r.f.focus()},"click:relay(button)":t.replace})},show:function(){var e=this.controls,t=this.options.data.selection();e.tsel.ifClass(t=="","hidden"),e.tsel.value=t,this.parent(),e.f.focus()},find:function(){var e=this,t=e.controls,n=t.f.value,r,i,s="disabled";n!=""&&(r=e.buildRE(n),r instanceof RegExp&&(r=e.options.data.get().match(e.buildRE(n,!0)),r&&(r=r.length))),t.h&&(t.h.innerHTML=r||""),i=+r?"erase":"set",t.r[i](s,s),t.one[i](s,s),t.all[i](s,s),t.f.focus()},replace:function(e){var t=this,n=t.controls,r=n.r,i=n.f,s=t.options.data;s.set(s.get().replace(t.buildRE(i.value,e.target==n.all),r?r.value:"")),i.focus()},buildRE:function(e,t){var n=this.controls,r=n.re&&n.re.checked,i=t?"g":"",s=n.i&&n.i.checked?"":"i";try{return RegExp(r?e:e.escapeRegExp(),i+s+"m")}catch(o){return"<span title='"+o+"'>!#@</span>"}}});var Textarea=new Class({Implements:[Options,Events],initialize:function(e,t){var n=this,r=n.ta=document.id(e),i=function(e){consol
 e.log("hi"),n.fireEvent("change",e)};return n.setOptions(t),n.taShadow="div[style=position:absolute;visibility:hidden;overflow:auto]".slick().setStyles(r.getStyles("font-family0font-size0line-height0text-indent0padding-top0padding-right0padding-bottom0padding-left0border-left-width0border-right-width0border-left-style0border-right-style0white-space0word-wrap".split(0))),this},toElement:function(){return this.ta},focus:function(){this.ta.focus()},getValue:function(){return this.ta.value},setValue:function(e){return this.ta.value=e,this.setSelectionRange(0,0),this},slice:function(e,t){return this.ta.value.slice(e,t)},indexOf:function(e,t){return this.ta.value.indexOf(e,t)},getFromStart:function(){return this.slice(0,this.getSelectionRange().start)},getTillEnd:function(){return this.slice(this.getSelectionRange().end)},getSelection:function(){var e=this.getSelectionRange();return this.slice(e.start,e.end)},setSelectionRange:function(e,t){var n=this.ta,r,i,s;return t||(t=e),n.setSelecti
 onRange?n.setSelectionRange(e,t):(r=n.value,i=r.slice(e,t-e).replace(/\r/g,"").length,e=r.slice(0,e).replace(/\r/g,"").length,s=n.createTextRange(),s.collapse(!0),s.moveEnd("character",e+i),s.moveStart("character",e),s.select()),n.fireEvent("change"),this},getSelectionRange:function(){var e=this.ta,t=0,n=0,r,i,s,o;return e.selectionStart!=null?(t=e.selectionStart,n=e.selectionEnd):(r=document.selection.createRange(),r&&r.parentElement()==e&&(i=r.duplicate(),s=e.value,o=s.length-s.match(/[\n\r]*$/)[0].length,i.moveToElementText(e),i.setEndPoint("StartToEnd",r),n=o-i.text.length,i.setEndPoint("StartToStart",r),t=o-i.text.length)),{start:t,end:n,thin:t==n}},setSelection:function(){var e=Array.from(arguments).join("").replace(/\r/g,""),t=this.ta,n=t.scrollTop,r,i,s,o;return t.selectionStart!=null?(r=t.selectionStart,i=t.selectionEnd,s=t.value,t.value=s.slice(0,r)+e+s.substr(i),t.selectionStart=r,t.selectionEnd=r+e.length):(t.focus(),o=document.selection.createRange(),o.text=e,o.collapse
 (1),o.moveStart("character",-e.length),o.select()),t.focus(),t.scrollTop=n,t.fireEvent("change"),this},insertAfter:function(){var e=Array.from(arguments).join("");return this.setSelection(e).setSelectionRange(this.getSelectionRange().start+e.length)},isCaretAtStartOfLine:function(){var e=this.getSelectionRange().start;return e<1||this.ta.value.charAt(e-1).test(/[\n\r]/)},isCaretAtEndOfLine:function(){var e=this.getSelectionRange().end;return e==this.ta.value.length||this.slice(e-1,e+1).test(/[\n\r]/)},getCoordinates:function(e){var t=this.ta,n=this.taShadow.inject(t,"before"),r=t.value.replace(/[<>&]/g,"X"),i,s,o,u,a;return e==undefined&&(e=this.getSelectionRange().end),i=n.set({styles:{width:t.offsetWidth,height:t.getStyle("height")},html:r.slice(0,e)+"<i>A</i>"+r.slice(e+1)}).getElement("i"),s=t.offsetTop+i.offsetTop-t.scrollTop,o=t.offsetLeft+i.offsetLeft-t.scrollLeft,u=i.offsetWidth,a=i.offsetHeight,console.log(e,t.offsetTop,"top: "+s,t.offsetLeft,"left: "+o,"width: "+u,"height:
  "+a,"right: "+(o+u),"bottom: "+(s+a)),{top:s,left:o,width:u,height:a,right:o+u,bottom:s+a}}});!function(){function e(e){var t=e.btns,n="disabled";t.undo&&t.undo.ifClass(!e.undo[0],n),t.redo&&t.redo.ifClass(!e.redo[0],n)}function t(t,n){t=this[t],n=this[n],t[0]&&(n[n.length]=this.getState(),this.putState(t.pop())),e(this)}this.Undoable=new Class({initializeUndoable:function(n,r){var i=this,s=i.undo=[];i.redo=[],i.btns=n,e(i),r=r||40,i.addEvents({beforeChange:function(t){s[s.length]=t||i.getState(),i.redo=[],s[r]&&s.shift(),e(i)},undo:t.pass(["undo","redo"],i),redo:t.pass(["redo","undo"],i)})}})}();var Snipe=new Class({Implements:[Options,Events,Undoable],Binds:["sync","shortcut","keystroke","suggest","action"],options:{tab:"    ",snippets:{},directsnips:{},sectionCursor:"all",sectionParser:function(){return{}}},initialize:function(e,t){t=this.setOptions(t).options,this.initializeUndoable(t.undoBtns);var n=this,r=t.container||$(e).form,i=n.textarea=new Textarea(e);n.directsnips=new S
 nipe.Snips(i,t.directsnips),n.snippets=new Snipe.Snips(i,t.snippets),n.snippets.dialogs.find=[Dialog.Find,{data:{selection:function(){return i.getSelection()},get:function(){var t=i.getSelection();return t==""?e.value:t},set:function(t){var r=i.getSelectionRange();n.fireEvent("beforeChange"),r.thin?e.value=t:i.setSelection(t),n.fireEvent("change")}}}],n.commands=new Snipe.Commands(r,{onOpen:function(){e.focus()},onClose:function(){e.focus()},onAction:n.action,dialogs:n.snippets.dialogs,relativeTo:i}),n.reset(),e.addEvents({keydown:n.keystroke,keypress:n.keystroke,keyup:n.suggest.debounce(),click:n.suggest.debounce(),input:function(){n.fireEvent("change")}.debounce()}),r.addEvent("keydown",n.shortcut)},toElement:function(){return this.textarea.toElement()},get:function(e){return"value"==e?this.textarea.getValue():/mainarea|textarea/.test(e)?this[e]:/snippets|directsnips|autosuggest|tabcompletion|smartpairs/.test(e)?this.options[e]:null},set:function(e,t){return e=="value"?(this.texta
 rea.setValue(t),this.fireEvent("beforeChange"),this.textarea.focus()):/snippets|directsnips|autosuggest|tabcompletion|smartpairs/.test(e)&&(this.options[e]=t),this.fireEvent("change")},shortcut:function(e){var t,n;if(e.shift||e.control||e.meta||e.alt)t=(e.shift?"shift+":"")+(e.control?"control+":"")+(e.meta?"meta+":"")+(e.alt?"alt+":"")+e.key,console.log("shortcut ",t),n=this.snippets.keys[t],n&&(e.stop(),this.commands.action(n))},keystroke:function(e){if(e.type=="keydown"){if(e.key.length==1)return}else{if(!e.event.which)return;e.key=String.fromCharCode(e.code).toLowerCase()}var t=this,n=t.textarea,r=e.key,i=n.getSelectionRange();n.focus(),/up|down|esc/.test(r)?t.reset():/tab|enter|delete|backspace/.test(r)?t[r](e,n,i):t.smartPairs(e,n,i)},enter:function(e,t){this.reset();var n=t.getFromStart().match(/(?:^|\r?\n)([ \t]+)(.*)$/);!e.shift&&n&&n[2]!=""&&(e.stop(),t.insertAfter("\n"+n[1]))},backspace:function(e,t,n){if(n.thin&&n.start>0){var r=t.getValue().charAt(n.start-1),i=this.dire
 ctsnips.get(r);i&&i.snippet==t.getValue().charAt(n.start)&&t.setSelectionRange(n.start,n.start+1).setSelection("")}},"delete":function(e,t,n){var r=this.options.tab;n.thin&&!t.getTillEnd().indexOf(r)&&(e.stop(),t.setSelectionRange(n.start,n.start+r.length).setSelection(""))},tab:function(e,t,n){var r=this,i;e.stop();if(r.options.tabcompletion&&n.thin&&(i=r.snippets.match()))return t.setSelectionRange(n.start-i.length,n.start).setSelection(""),r.commands.action(i);r.tab2spaces(e,t,n)},tab2spaces:function(e,t,n){var r=this.options.tab,i=t.getSelection(),s=t.getFromStart(),o=t.isCaretAtStartOfLine();i.indexOf("\n")>-1?(o&&(i="\n"+i),e.shift?i=i.replace(RegExp("\n"+r,"g"),"\n"):i=i.replace(/\n/g,"\n"+r),t.setSelection(o?i.slice(1):i)):e.shift?s.test(r+"$")&&t.setSelectionRange(n.start-r.length,n.start).setSelection(""):t.setSelection(r).setSelectionRange(n.start+r.length)},hasContext:function(){return!!this.context.snip},setContext:function(e,t){this.context={snip:e,suggest:t}},reset:fu
 nction(){console.log("Snipe:reset",this.context),this.context=null,this.textarea.focus(),this.commands.close()},smartPairs:function(e,t,n){var r,i=e.key;this.options.smartpairs&&(r=this.directsnips.get(i))&&(e.stop(),t.setSelection(i,t.getSelection(),r.snippet).setSelectionRange(n.start+1,n.end+1))},suggest:function(){var e;if(this.options.autosuggest){if(e=this.snippets.matchSuggest())return console.log("Snipe.suggest ",e),this.setContext(null,e),this.commands.action(e.cmd,e.lback);this.reset()}},action:function(e){function f(e){return e.replace(/~\{/g,"{")}var t=this,n=Array.slice(arguments,1),r=t.snippets.get(e),i=t.textarea,s,o,u=r.suggest?n.join():r.snippet,a=r.suggest&&t.context&&t.context.suggest;console.log("Snipe:action ",e,"snippet=",u,"args=",n,"suggest=",a);if(!r)return;r.event?t.fireEvent(r.event,arguments):(t.fireEvent("beforeChange"),a&&(u=t.suggestAction(i,u,a.lback,a.match)),(o=u.match(/(^|[\S\s]*[^~])\{([^!\{\}][^\{\}]*)\}([\S\s]*)/))?t.injectXL(i,u,f(o[1]),o[2],f(
 o[3])):(s=i.getSelectionRange(),u=f(u),t.inject(i,u,s.start+(s.thin?u.length:0),s.thin?0:u.length))),t.reset(),t.fireEvent("change"),t.suggest.delay(1,t)},suggestAction:function(e,t,n,r){var i=e.getSelectionRange().start,s=r.length;return t.startsWith(n)?(t=t.slice(n.length),s-=n.length):i-=n.length,e.setSelectionRange(i,i+s),t},injectXL:function(e,t,n,r,i){var s=e.getSelectionRange(),o=s.start;s.thin||(r=e.getSelection(),console.log("injectXL: ",r,n,i),r.startsWith(n)&&r.endsWith(i)?(console.log("TOGGLE: pfx/sfx matched inside the selection",s.start,s.end),r=r.slice(n.length,-i.length),n=i=""):e.getFromStart().endsWith(n)&&e.getTillEnd().startsWith(i)&&(console.log("TOGGLE: pfx/sfx matched outside the selection",s.start,s.end),o-=n.length,e.setSelectionRange(o,s.end+i.length),n=i="")),this.inject(e,n+r+i,o+n.length,r.length)},inject:function(e,t,n,r){var i=e.getFromStart(),s=i.split(/\r?\n/).pop(),o=s.match(/^\s+/);console.log("inject: ",t,n,r),t.test(/^\n/)&&i.test(/(^|[\n\r]\s*)$
 /)&&(console.log("collapse leading \\n",t),t=t.slice(1),n--),t.test(/\n$/)&&e.getTillEnd().test(/^\s*[\n\r]/)&&(console.log("collapse trailing \\n",t),t=t.slice(0,-1),n--),o&&(t=t.replace(/\n/g,"\n"+o[0])),e.setSelection(t).setSelectionRange(n,n+r)},getState:function(){var e=this.textarea,t=e.toElement();return{value:t.get("value"),cursor:e.getSelectionRange(),scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}},putState:function(e){var t=this,n=t.textarea,r=n.toElement();t.reset(),r.value=e.value,r.scrollTop=e.scrollTop,r.scrollLeft=e.scrollLeft,n.setSelectionRange(e.cursor.start,e.cursor.end),t.fireEvent("change"),t.suggest()}});Snipe.Snips=new Class({Implements:Events,initialize:function(e,t){var n=this,r,i,s,o,u=navigator.platform.match(/mac/i)?"meta+":"control+";n.workarea=e,n.keys={},n.dialogs={},n.snips=t,n.suggestions={};for(r in t){i=Function.from(t[r])(e,r),typeOf(i)=="string"&&(i={snippet:i});if(s=i.key)s.contains("+")||(s=u+s),n.keys[s.toLowerCase()]=r;if(o=i.suggest)typeOf(o
 )=="string"&&(i.suggest={lback:RegExp(o+"$"),match:RegExp("^"+o)}),n.suggestions[r]=i;i[r]&&(n.dialogs[r]=i[r]),i.dialog&&(n.dialogs[r]=i.dialog),t[r]=i}},match:function(){var e,t=this.workarea.getFromStart();for(e in this.snips)if(t.endsWith(e))return e;return!1},matchSuggest:function(){var e,t,n,r,i,s,o=this.suggestions,u=this.workarea,a=u.getSelectionRange(),f=u.getFromStart();for(e in o){t=o[e];if(this.inScope(t,f)){s=t.suggest,s.lback?(n=f.match(s.lback),n&&(n=n.getLast(),r=u.slice(a.start-n.length).match(s.match),r&&(i={lback:n,match:r.getLast()}))):i=Function.from(s)(u,a,f);if(i)return i.cmd=e,i}}return!1},get:function(e){var t=this,n=t.snips[e];return n&&n.alias&&(n=t.snips[n.alias]),n&&t.inScope(n,t.workarea.getFromStart())?n:!1},inScope:function(e,t){function o(e,i){for(n in e){r=t.lastIndexOf(n);if(r>-1&&t.indexOf(e[n],r)==-1)return i}return!i}var n,r,i=e.scope,s=e.nscope;return i?typeOf(i)=="function"?i(this.textarea):o(i,!0):s?o(s):!0}}),Snipe.Commands=new Class({Implem
 ents:[Events,Options],options:{cmds:"data-cmd"},dlgs:{},btns:{},dialogs:{},initialize:function(e,t){var n=this.setOptions(t),r=n.options.cmds,i,s,o=t.dialogs||{};e.addEvent("click:relay(["+r+"])",function(e){var t=this.get(r),i=n.dlgs[t];i?i.toggle():n.action(t),this.match("input")||e.stop()}),e.getElements("["+r+"]").each(function(u){i=u.get(r),n.btns[i]=u;if(s=e.getElement(".dialog."+i))o[i]||(o[i]=[Dialog,{}]),t=o[i][1],t.dialog=s.inject(document.body),t.relativeTo=u}),n.addDialogs(o)},addDialogs:function(e){var t,n,r=this.dialogs;for(n in e)r[n]&&console.log("Snipe.Commands addDialogs() - warning: double registration of => "+n),t=r[n]=e[n],instanceOf(t,Dialog)&&this.attach(t,n)},attach:function(e,t){var n=this,r=function(e){n.fireEvent("action",[t,e])};return n.dlgs[t]=e.addEvents({open:n.openDialog.bind(n,t),close:n.closeDialog.bind(n,t),action:r,drag:r})},action:function(e,t){var n=this,r="active",i=n.btns[e],s;if(!i||!i.match(".disabled"))n.dialogs[e]?(s=n.dlgs[e]||n.createDi
 alog(e),t!=null&&s.setValue(t),s.show()):(i&&i.addClass(r),n.fireEvent("action",[e,t]),i&&i.removeClass(r))},createDialog:function(e){var t=Function.from(this.dialogs[e])();return typeOf(t)!="array"&&(t=[Dialog.Selection,{body:t}]),t[1].relativeTo||(t[1].relativeTo=this.options.relativeTo||document.body),t[1].autoClose=!1,this.attach(new t[0](t[1]),e)},openDialog:function(e){var t=this,n=t.activeDlg,r=t.dlgs[e],i=t.btns[e];n&&n!=r&&n.hide(),t.activeDlg=t.dlgs[e],i&&i.addClass("active"),t.fireEvent("open",e)},closeDialog:function(e){var t=this,n=t.btns[e];t.dlgs[e]==t.activeDlg&&(t.activeDlg=null),n&&n.removeClass("active"),t.fireEvent("close",e)},close:function(){var e=this.activeDlg;e&&e.hide()}}),Snipe.Sections=new Class({Implements:[Events],Binds:["show","update","action"],options:{all:"( all )".localize(),sections:".sections",startOfPage:"Start of Page".localize()},initialize:function(e,t){var n=this;n.snipe=e,n.main=t.main,n.parser=t.parser,t.menu&&(n.list=t.menu.addEvent("clic
 k:relay(a)",n.action)),n.parse(),n.action(location.search),n.menu(),e.addEvent("change",n.update)},parse:function(){this.sections=this.parser(this.main.value)},menu:function(){var e=[],t=this.list,n=this.options,r=this.current,i=this.sections,s=function(t,n){e.push("li"+(n==r?".active":""),["a.text-indent-"+t.depth+".section"+n,{html:t.title}])};t&&(s({depth:0,title:n.all},-2),i[0]&&(i[0].start>0&&s({depth:0,title:n.startOfPage},-1),e.push("li.divider"),i.each(s)),t.empty().adopt(e.slick()),t.getParent().ifClass(r>=-1,"section-selected"))},update:function(){var e=this,t=e.main,n=e.snipe.get("value"),r=t.value;n.slice(-1)!="\n"&&(n+="\n"),n!=r.slice(e.begin,e.end)&&(t.value=r.slice(0,e.begin)+n+r.slice(e.end),e.end=e.begin+n.length,e.parse()),e.menu()},action:function(e){var t=this,n=t.main.value,r=t.sections,i=0,s=n.length;return e&&(e.target&&(e=e.target.className),e=(e.match(/section=?(-?\d+)/)||[,-2])[1].toInt(),e==-1?s=r[0].start:e>=0&&r[e]&&(i=r[e].start,r[e+1]&&(s=r[e+1].start
 )),t.current=e),t.begin=i,t.end=s,t.snipe.set("value",n.slice(i,s)),!1}}),Wiki.DirectSnips={'"':'"',"(":")","[":"]","{":"}","'":{snippet:"'",scope:{"[{":"}]"}}},Wiki.Snips={find:{},undo:{event:"undo"},redo:{event:"redo"},wysiwyg:{event:"config"},smartpairs:{event:"config"},livepreview:{event:"config"},autosuggest:{event:"config"},tabcompletion:{event:"config"},previewcolumn:{event:"config"},br:{key:"shift+enter",snippet:"\\\\\n"},hr:"\n----\n",lorem:"This is just some sample. Don’t even bother reading it; you will just waste your time. Why do you keep reading? Do I have to use Lorem Ipsum to stop you? OK, here goes: Lorem ipsum dolor sit amet, consectetur adipi sicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Still reading? Gosh, you’re impossible. I’ll stop here to spare you.",Lorem:{alias:"lorem"},bold:{key:"b",snippet:"__{bold}__"},italic:{key:"i",snippet:"''{italic}''"},mono:{key:"m",snippet:"{{{monospaced text}}} "},sub:"%%sub {subscript tex
 t}/% ",sup:"%%sup {superscript text}/% ",strike:"%%strike {strikethrough text}/% ",quote:"\n%%quote\n{Quoted text}\n/%\n",dl:"\n;{term}:definition-text ",def:{alias:"dl"},pre:"\n{{{\n{some preformatted block}\n}}}\n",code:"\n%%prettify \n{{{\n{/* some code block */}\n}}}\n/%\n",table:"\n||{heading-1} ||heading-2\n|cell11     |cell12\n|cell21     |cell22\n",me:{alias:"sign"},sign:function(){var e=Wiki.UserName||"UserName";return"\n%%signature\n"+e+", "+(new Date).toISOString()+"\n/%\n"},now:{alias:"date"},date:function(){return(new Date).toISOString()+" "},tabs:{nScope:{"%%(":")","%%tabs":"/%"},snippet:"%%tabs\n!tab-1\ntab-1 content 1\n!tab-2\ntab-2 content \n/%\n "},img:"\n[{Image src='{img.jpg}' width='400px' height='300px' align='left' }]\n ",imgSrcDlg:{scope:{"[{Image":"}]"},suggest:{lback:"src='([^']*)'?$",match:"^([^']*)"},imgSrcDlg:Wiki.pageDialog("Image","/search/suggestions")},imgAlignDlg:{scope:{"[{Image":"}]"},suggest:"align='\\w+'",imgAlignDlg:"left|center|right"},font:{n
 Scope:{"%%(":")"},snippet:"%%(font-family:{font};) body /% "},fontDlg:{scope:{"%%(":")"},suggest:{lback:"font-family:([^;\\)\\n\\r]*)$",match:"^([^;\\)\\n\\r]*)"},fontDlg:[Dialog.Font,{}]},color:"%%(color:{#000000}; background:#ffffff;) ${some text} /%",colorDlg:{scope:{"%%(":")"},suggest:"B#(?:[0-9a-f]{3}){1,2}\b",colorDlg:[Dialog.Color,{}]},symbol:{alias:"chars"},chars:"&entity;",charsDlg:{suggest:{lback:/&\w*;?$/,match:/^&\w*;?/},dialog:[Dialog.Chars,{caption:"dialog.character.entities".localize()}]},icon:"%%icon-{!search} /%",iconDlg:{scope:{"%%":"/%"},suggest:"icon-\\S*",iconDlg:[Dialog.Selection,{cssClass:".dialog-horizontal.icons",body:function(e){var t={};return e.split(",").forEach(function(e){e="icon-"+e,t[e]="<div class='"+e+"'></div>"}),t}("search,user,home,refresh,repeat,bookmark,tint,plus,external-link,signin,signout,rss,wrench,filter,link,paper-clip,undo,euro,tag,star,star-o,heart,trash-o,ellipsis-v,pie-chart,location,info,warning,error,flash,smile,frown,meh,slimbox,p
 icture,columns")}]},textDlg:{scope:{"%%":" "},suggest:{lback:/(:?%%|\.)text-(\w*)$/,match:/^\w*/},textDlg:[Dialog.Selection,{cssClass:".dialog-horizontal.text-styles",body:{primary:"<span class='text-primary'>primary</span>",success:"<span class='text-success'>success</span>",info:"<span class='text-info'>info</span>",warning:"<span class='text-warning'>warning</span>",danger:"<span class='text-danger'>danger</span>",white:"<span class='text-white'>white</span>",black:"<span class='text-black'>black</span>",divider2:"",left:"<span class='icon-align-left'></span>",center:"<span class='icon-align-center'></span>",right:"<span class='icon-align-right'></span>",justify:"<span class='icon-align-justify'></span>",capitalize:"<span class='text-capitalize'>Aa</span>",lowercase:"<span class='text-lowercase'>aa</span>",uppercase:"<span class='text-uppercase'>AA</span>",smallcaps:"<span class='text-smallcaps'>Aa</span>"}}]},contextBG:{scope:{"%%":" "},suggest:{lback:/%%(\w*)$/,match:/^(default
 |success|info|warning|error)/},contextBG:[Dialog.Selection,{cssClass:".dialog-horizontal",body:{"default":"<span class='default'>default</span>",success:"<span class='success'>success</span>",info:"<span class='info'>info</span>",warning:"<span class='warning'>warning</span>",error:"<span class='error'>error</span>"}}]},bgColorDlg:{scope:{"%%":" "},suggest:{lback:/(:?%%|\.)bg-(\w*)$/,match:/^\w*/},bgColorDlg:[Dialog.Selection,{cssClass:".dialog-horizontal.bg-colors",body:{primary:"<span class='bg-primary' title='primary'>&para;</span>",success:"<span class='bg-success' titlte='success'>&para;</span>",info:"<span class='bg-info' title='info'>&para;</span>",warning:"<span class='bg-warning' title='warning'>&para;</span>",danger:"<span class='bg-danger' title='danger'>&para;</span>",aqua:"<span class='bg-aqua' title='aqua'>&para;</span>",blue:"<span class='bg-blue' title='blue'>&para;</span>",navy:"<span class='bg-navy' title='navy'>&para;</span>",teal:"<span class='bg-teal' title='tea
 l'>&para;</span>",green:"<span class='bg-green' title='green'>&para;</span>",olive:"<span class='bg-olive' title='olive'>&para;</span>",lime:"<span class='bg-lime' title='lime'>&para;</span>",yellow:"<span class='bg-yellow' title='yellow'>&para;</span>",orange:"<span class='bg-orange' title='orange'>&para;</span>",red:"<span class='bg-red' title='red'>&para;</span>",fuchsia:"<span class='bg-fuchsia' title='fuchsia'>&para;</span>",purple:"<span class='bg-purple' title='purple'>&para;</span>",maroon:"<span class='bg-maroon' title='maroon'>&para;</span>",white:"<span class='bg-white' title='white'>&para;</span>",silver:"<span class='bg-silver' title='silver'>&para;</span>",gray:"<span class='bg-gray' title='gray'>&para;</span>",black:"<span class='bg-black' title='black'>&para;</span>"}}]},bgDlg:{scope:{"%%bg.":" "},suggest:{lback:/(:%%bg\.|\.?)(\w*)$/,match:/^\w*/},bgDlg:[Dialog.Selection,{cssClass:".dialog-horizontal",body:{top:"&uarr;",right:"&rarr;",bottom:"&darr;",left:"&larr;",di
 vider1:"",contain:"Contain",cover:"Cover",fixed:"Fixed",divider2:"",dark:"Dark",light:"Light",kenburns:"Animated"}}]},labelDlg:{scope:{"%%":"/%"},suggest:{lback:/%%label-(\w*)$/,match:/^\w*/},labelDlg:[Dialog.Selection,{cssClass:".dialog-horizontal",body:{"default":"<span class='label label-default'>default</span>",primary:"<span class='label label-primary'>primary</span>",success:"<span class='label label-success'>success</span>",info:"<span class='label label-info'>info</span>",warning:"<span class='label label-warning'>warning</span>",danger:"<span class='label label-danger'>danger</span>"}}]},listDlg:{scope:{"%%list-":"/%"},suggest:{lback:"list-(?:[\\w-]+-)?(\\w*)$",match:"^\\w*"},listDlg:[Dialog.Selection,{cssClass:".dialog-horizontal",body:"nostyle|unstyled|hover|group"}]},tableDlg:{scope:{"%%table-":"/%"},suggest:{lback:"table-(?:[\\w-]+-)?(\\w*)$",match:"^\\w*"},tableDlg:[Dialog.Selection,{cssClass:".dialog-horizontal",body:"sort|filter|striped|bordered|hover|condensed|fit"}
 ]},cssDlg:{scope:{"%%":" "},suggest:{lback:"(:?%%|\\.)([\\da-zA-Z-_]*)$",match:"^[\\da-zA-Z-_]*"},cssDlg:[Dialog.Selection,{caption:"dialog.styles".localize(),cssClass:".dialog-filtered",body:{"(css:value;)":"any css definitions","bg-":"Background colors","text-{default}":"Text colors and other styles","default":"<span class='default'>Contextual boxes</span>","label-{default}":"<span class='label label-default'>Contextual labels</span>",badge:"Badges <span class='badge'>007</span>",collapse:"Collapsible lists <b class='bullet'></b>","list-{nostyle}":"List styles","table-{fit}":"Table styles","":"","add-css":"Add CSS",alert:"Alert Box","accordion\n!Tab1\n{body1}\n!Tab2\nbody2\n":"Accordion",category:"<span class='category-link'>Category Link</span>",carousel:"Carousel viewer",columns:"Multi-column layout",commentbox:"Comment Box",graphBar:"Graph Bars",lead:"<span class='lead-item'>LEAD text</span>","pills\n!Tab1\n{body1}\n!Tab2\nbody2\n":"Pills",prettify:"Prettify syntax highlighter"
 ,progress:"Progress Bars",quote:"<div class='quote-item'>Quoted paragraph</div>",scrollable:"Scrollable <span style='font-family:monospace; white-space:pre;'>preformatted</span> block","scrollable-image":"Scrollable Wide Images","under-construction":"<span class='under-construction small' style='display:inline-block;height:auto;margin-bottom:0'/>",slimbox:"Slimbox viewer <span class='icon-slimbox'></span>","tabs\n!Tab1\n{body1}\n!Tab2\nbody2\n":"Tabs",viewer:"Media viewer"}}]},link:{key:"l",wysiwyg:"createlink",snippet:"[description|{pagename or url}|link-attributes] "},linkPart3:{suggest:{lback:"\\[(?:[^\\|\\]]+\\|[^\\|\\]]+\\|)([^\\|\\[\\]\\n\\r]*)$",match:"^[^\\|\\]\\n\\r]*"},linkPart3:[Dialog.Selection,{caption:"dialog.link.attributes".localize(),body:{"link-attributes":"<i>no attributes</i>","class='viewer'":"Embedded Viewer","class='slimbox'":"Add a Slimbox Link <span class='icon-slimbox'/> ","class='slimbox-link'":"Change to Slimbox Link <span class='icon-slimbox'/> ",divider
 1:"","class='btn btn-primary'":"Button style (normal)","class='btn btn-xs btn-primary'":"Button style (small)",divider2:"","target='_blank'":"Open link in new tab"}}]},linkDlg:{suggest:{lback:/\[([^\|\[{\]\n\r]*)$/,match:/^([^\|\[{\]\n\r]*)(?:[\]\n\r])/},linkDlg:Wiki.pageDialog("Wiki Link","/search/suggestions")},linkPart2:{suggest:{lback:/\[(?:[^\|\]]+\|)([^\|\[{\]\n\r]*)$/,match:/^([^\|\[{\]\n\r]*)(?:[\]\|\n\r])/},linkPart2:Wiki.pageDialog("Wiki Link","/search/suggestions")},variableDlg:{scope:{"[{$":"}]"},suggest:"\\w+",variableDlg:"applicationname|baseurl|encoding|inlinedimages|interwikilinks|jspwikiversion|loginstatus|uptime|pagename|pageprovider|pageproviderdescription|page-styles|requestcontext|totalpages|username"},allow:{alias:"acl"},acl:"\n[{ALLOW {permission} principal }]\n",permission:{scope:{"[{ALLOW":"}]"},suggest:{lback:"ALLOW (\\w*)$",match:"^\\w+"},permission:[Dialog.Selection,{caption:"dialog.permission".localize(),cssClass:".dialog-horizontal",body:"view|edit|modi
 fy|comment|rename|upload|delete"}]},principal:{scope:{"[{ALLOW":"}]"},suggest:{lback:"ALLOW \\w+ (?:[\\w,]+,)?(\\w*)$",match:"^\\w*"},principal:[Dialog.Selection,{caption:"dialog.principal".localize(),onOpen:function(e){(new Request({url:Wiki.XHRPreview,data:{page:Wiki.PageName,wikimarkup:"[{Groups}]"},onSuccess:function(t){var n="Anonymous|Asserted|Authenticated|All";t=t.replace(/<[^>]+>/g,"").replace(/\s*,\s*/g,"|").trim(),t!=""&&(n=n+"||"+t),e.setBody(n)}})).send()}}]},toc:{nScope:{"[{":"}]"},snippet:"\n[~{TableOfContents }]\n"},tocParams:{scope:{"[{TableOfContents":"}]"},suggest:"\\s",tocParams:[Dialog.Selection,{caption:"dialog.toc.options".localize(),body:{" title='{Page contents}' ":"title"," numbered='true' ":"numbered"," prefix='{Chap. }' ":"chapter prefix"}}]},plugin:"\n[{{plugin} \n{=body}\n}]\n",pluginDlg:{suggest:{lback:"(^|[^\\[])\\[{(\\w*)(?:\\|\\])?$",match:"^([^\\[\\]\\n\\r]*)\\}\\]"},pluginDlg:[Dialog.Selection,{caption:"dialog.plugin".localize(),body:{"ALLOW {perm
 ission} principal ":"Page Access Rights <span class='icon-unlock-alt' />","SET {name}='value'":"Set a Wiki variable","${varname}":"Get a Wiki variable","If name='{value}' page='pagename' exists='true' contains='regexp'\n\nbody\n":"IF plugin","SET alias='{pagename}'":"Set Page Alias","SET page-styles='prettify-nonum table-condensed-fit'":"Set Page Styles","SET sidebar='off'":"Hide Sidebar","":"",Counter:"Insert a simple counter",PageViewPlugin:"Count Views of this page","CurrentTimePlugin format='yyyy mmm-dd'":"Insert Current Time",Denounce:"Denounce a link","Image src='{image.jpg}'":"Insert an Image <span class='icon-picture'></span>",IndexPlugin:"Index of all pages","InsertPage page='{pagename}'":"Insert another Page",ListLocksPlugin:"List page locks",RecentChangesPlugin:"Displays the recent changed pages","ReferringPagesPlugin page='{pagename}' separator=',' include='regexp' exclude='regexp'":"Incoming Links (referring pages)","ReferredPagesPlugin page='{pagename}' type='local|ext
 ernal|attachment' depth='1..8' include='regexp' exclude='regexp'":"Outgoing Links (referred pages)","Search query='{Janne}' max='10'":"Insert a Search query","TableOfContents ":"Table Of Contents ",UndefinedPagesPlugin:"List pages that are missing",UnusedPagesPlugin:"List pages that have been orphaned",WeblogArchivePlugin:"Displays a list of older weblog entries",WeblogEntryPlugin:"Makes a new weblog entry","WeblogPlugin page='{pagename}' startDate='300604' days='30' maxEntries='30' allowComments='false'":"Builds a weblog"}}]},lipstick:{key:"control+enter",snippet:"{format}",nscope:{"[":"]"},suggest:function(e,t){return t.thin?null:{lback:"",match:e.getSelection()}},lipstick:[Dialog.Selection,{cssClass:".dialog-horizontal",onBeforeOpen:function(e){var t={},n=e.options.relativeTo,r=n.getSelectionRange();n.isCaretAtStartOfLine()&&Object.append(t,{"\n{!!!}":"<span title='header'>H<span class='sub'>1</span></span>","\n{!!}":"<span title='title'>H<span class='sub'>2</span></span>","\n{!}
 ":"<span title='sub-title'>H<span class='sub'>3</span></span>","\n* {list item}":"<span class='icon-list-ul'/>","\n# {list-item}":"<span class='icon-list-ol'/>","divider-sol":""}),Object.append(t,{"__{bold}__":"<span style='font-family:serif;'><b>B</b></span>","''{italic}''":"<span style='font-family:serif;'><i>I</i></span>","{{{monospaced}}} ":"<tt title='inline monospaced'>&lt;&gt;</tt>","{{{{code}}}}":"<span title='code' class='small' style='font-family:monospace;'>code</span>",divider1:"","[{link}]":"<span class='icon-link' title='Insert a link'/>","[{Image src='{image.jpg}'}]":"<span class='icon-picture' title='Insert an image'/>","[{{plugin}}]":"<span class='icon-puzzle-piece' title='Insert a Plugin'></span>","%%style {body} /%":"<span style='font-family:monospace;' title='Add a Style'>%%</span>",divider2:"","%%(font-family:{font};) body /%":"<span title='Change the Font'><span style='font-family:serif;'>A</span><span style='font-family:sans-serif'>a</span></span>","&{entity};
 ":"<span style='font-family:cursive;' title='Insert a Special Character'>&amp;</span>","[{ALLOW {permission} principal }]":"<span class='icon-unlock-alt' title='Add a page ACL'></span>","\\\\\n":"<b title='Insert a New Line'>&para;</b>"}),n.isCaretAtStartOfLine()&&n.isCaretAtEndOfLine()&&n.slice(r.start,r.end-1).indexOf("\n")>-1&&Object.append(t,{"divider-code":"","\n{{{\n/* code block */\n{code block}\n}}}\n":"<span class='small' style='font-family:monospace;'>&lt;/&gt;</span>","\n%%prettify\n{{{\n{pretiffied code block}\n}}}/%\n":"<span class='small' style='font-family:monospace;color:green;'>&lt;/&gt;</span>","\n%%scrollable\n{{{\n{code block}\n}}}/%\n":"&darr;&uarr;"}),e.setBody(t)}}]}},!function(e){function n(e,t){e.onbeforeunload=function(){if(t.value!=t.defaultValue)return"edit.areyousure".localize()},t.form.addEvent("submit",function(){e.onbeforeunload=null})}function r(n,r,i){function f(){t=!1}function l(t){r.ifClass(!t,"loading"),t&&(e.update(),f())}var s=n.get("value").tr
 im(),o=s=="",u,a;if(!i.checked)r.cache&&(r.empty(),r.cache=null);else if(r.cache!=s){r.cache=s,r.ifClass(o,"empty");if(o){r.innerHTML="preview.zone".localize();return}e.Context=="comment"&&(u=$("authorname").value||e.UserName||"AnonymousCoward",a=$("link").value,a&&(u="[{0}|{1}]".xsubs(u,a)),s+="\n\n%%signature\n{0}, [\\{CurrentTimePlugin}]\n/%\n".xsubs(u)),t=!0,(new Request.HTML({url:e.XHRPreview,data:{page:e.PageName,wikimarkup:s},update:r,onRequest:l,onComplete:l.pass(!0),onError:f})).send()}}function i(e){var t=[],n="¤",r=e.replace(/\{\{\{([\s\S]*?)\}\}\}/g,function(e){return e.replace(/^!/mg," ")}).replace(/^([!]{1,3})/mg,n+"$1"+n).split(n),i=r.shift().length,s=r.length,o,u,a;for(o=0;o<s;o+=2)u=r[o].length,a=r[o+1].split(/[\r\n]/)[0].replace(/(^|[^~])(__|""|\{\{|\}\}|%%\([^\)]+\)|%%\S+\s|%%\([^\)]+\)|\/%)/g,"$1").replace(/~([^~])/g,"$1"),t[o/2]={title:a,start:i,depth:3-u},i+=u+r[o+1].length;return t}var t;e.add("textarea#editorarea",function(s){function f(e){return o.getElemen
 t(e)}var o=s.form,u,a;n(window,s);if(u=f("textarea.snipeable")){u=new Snipe(u,{container:o,undoBtns:{undo:f("[data-cmd=undo]"),redo:f("[data-cmd=redo]")},snippets:e.Snips,directsnips:e.DirectSnips}),e.configPrefs(o,function(e,t){u.set(e,t)});if(a=f(".ajaxpreview")){var l=!1;setInterval(function(){l&&!t&&(l=!1,r(u,a,f("[data-cmd=livepreview]")))},250),u.addEvent("change",function(){l=!0})}new Snipe.Sections(u,{main:s,menu:f(".sections > ul"),parser:i})}})}(Wiki)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jspwiki-site/blob/64b43923/js/haddock-wysiwyg.js
----------------------------------------------------------------------
diff --git a/js/haddock-wysiwyg.js b/js/haddock-wysiwyg.js
new file mode 100644
index 0000000..21176da
--- /dev/null
+++ b/js/haddock-wysiwyg.js
@@ -0,0 +1 @@
+(function(){var e=/^(H[1-6]|HR|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|SCRIPT|NOSCRIPT|STYLE)$/i,t=/^(https?|ftp|rmtp|mms):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i,n=/<(script|noscript|style)[\u0000-\uFFFF]*?<\/(script|noscript|style)>/g;this.MooEditable=new Class({Implements:[Events,Options],options:{toolbar:!0,cleanup:!0,paragraphise:!0,xhtml:!0,semantics:!0,actions:"bold italic underline strikethrough | insertunorderedlist insertorderedlist indent outdent | undo redo | createlink unlink | urlimage | toggleview",handleSubmit:!0,handleLabel:!0,disabled:!1,baseCSS:"html{ height: 100%; cursor: text; } body{ font-family: sans-serif; }",extraCSS:"",externalCSS:"",html:'<!DOCTYPE html><html><head><meta charset="UTF-8">{BASEHREF}<style>{BASECSS} {EXTRACSS}</style>{EXTERNALCSS}</head><body></body></html>',rootElement:"p",baseURL:"",dimensions:null},initialize:function(e,t){if(!("contentEditable"in document.body||"designMode"in d
 ocument))return;this.setOptions(t),this.textarea=document.id(e),this.textarea.store("MooEditable",this),this.actions=this.options.actions.clean().split(" "),this.keys={},this.dialogs={},this.protectedElements=[],this.actions.each(function(e){var t=MooEditable.Actions[e];if(!t)return;if(t.options){var n=t.options.shortcut;n&&(this.keys[n]=e)}t.dialogs&&Object.each(t.dialogs,function(t,n){t=t.attempt(this),t.name=e+":"+n,typeOf(this.dialogs[e])!="object"&&(this.dialogs[e]={}),this.dialogs[e][n]=t},this),t.events&&Object.each(t.events,function(e,t){this.addEvent(t,e)},this)}.bind(this)),this.render()},toElement:function(){return this.textarea},render:function(){var e=this,t=this.options.dimensions||this.textarea.getSize();this.container=new Element("div",{id:this.textarea.id?this.textarea.id+"-mooeditable-container":null,"class":"mooeditable-container",styles:{width:t.x}}),this.textarea.addClass("mooeditable-textarea").setStyle("height",t.y),this.iframe=new IFrame({"class":"mooeditable
 -iframe",frameBorder:0,src:'javascript:""',styles:{height:t.y}}),this.toolbar=new MooEditable.UI.Toolbar({onItemAction:function(){var t=Array.from(arguments),n=t[0];e.action(n.name,t)}}),this.attach.delay(1,this),this.options.handleLabel&&this.textarea.id&&$$('label[for="'+this.textarea.id+'"]').addEvent("click",function(t){if(e.mode!="iframe")return;t.preventDefault(),e.focus()}),this.options.handleSubmit&&(this.form=this.textarea.getParent("form"),this.form&&this.form.addEvent("submit",function(){e.mode=="iframe"&&e.saveContent()})),this.fireEvent("render",this)},attach:function(){var e=this;this.mode="iframe",this.editorDisabled=!1,this.container.wraps(this.textarea),this.textarea.setStyle("display","none"),this.iframe.setStyle("display","").inject(this.textarea,"before"),Object.each(this.dialogs,function(t,n){Object.each(t,function(t){document.id(t).inject(e.iframe,"before");var r;t.addEvents({open:function(){r=e.selection.getRange(),e.editorDisabled=!0,e.toolbar.disable(n),e.fi
 reEvent("dialogOpen",this)},close:function(){e.toolbar.enable(),e.editorDisabled=!1,e.focus(),r&&e.selection.setRange(r),e.fireEvent("dialogClose",this)}})})}),this.win=this.iframe.contentWindow,this.doc=this.win.document,Browser.firefox&&(this.doc.designMode="On");var t=this.options.html.substitute({BASECSS:this.options.baseCSS,EXTRACSS:this.options.extraCSS,EXTERNALCSS:this.options.externalCSS?'<link rel="stylesheet" type="text/css" media="screen" href="'+this.options.externalCSS+'" />':"",BASEHREF:this.options.baseURL?'<base href="'+this.options.baseURL+'" />':""});this.doc.open(),this.doc.write(t),this.doc.close(),Browser.ie?this.doc.body.contentEditable=!0:this.doc.designMode="On",Object.append(this.win,new Window),Object.append(this.doc,new Document);if(Browser.Element){var n=this.win.Element.prototype;for(var r in Element)r.test(/^[A-Z]|\$|prototype|mooEditable/)||(n[r]=Element.prototype[r])}else document.id(this.doc.body);this.setContent(this.textarea.get("value")),this.doc.
 addEvents({mouseup:this.editorMouseUp.bind(this),mousedown:this.editorMouseDown.bind(this),mouseover:this.editorMouseOver.bind(this),mouseout:this.editorMouseOut.bind(this),mouseenter:this.editorMouseEnter.bind(this),mouseleave:this.editorMouseLeave.bind(this),contextmenu:this.editorContextMenu.bind(this),click:this.editorClick.bind(this),dblclick:this.editorDoubleClick.bind(this),keypress:this.editorKeyPress.bind(this),keyup:this.editorKeyUp.bind(this),keydown:this.editorKeyDown.bind(this),focus:this.editorFocus.bind(this),blur:this.editorBlur.bind(this)}),this.win.addEvents({focus:this.editorFocus.bind(this),blur:this.editorBlur.bind(this)}),["cut","copy","paste"].each(function(t){e.doc.body.addListener(t,e["editor"+t.capitalize()].bind(e))}),this.textarea.addEvent("keypress",this.textarea.retrieve("mooeditable:textareaKeyListener",this.keyListener.bind(this))),Browser.firefox2&&this.doc.addEvent("focus",function(){e.win.fireEvent("focus").focus()}),this.doc.addEventListener&&this
 .doc.addEventListener("focus",function(){e.win.fireEvent("focus")},!0);if(!Browser.ie&&!Browser.opera){var i=function(){e.execute("styleWithCSS",!1,!1),e.doc.removeEvent("focus",i)};this.win.addEvent("focus",i)}return this.options.toolbar&&(document.id(this.toolbar).inject(this.container,"top"),this.toolbar.render(this.actions)),this.options.disabled&&this.disable(),this.selection=new MooEditable.Selection(this.win),this.oldContent=this.getContent(),this.fireEvent("attach",this),this},detach:function(){return this.saveContent(),this.textarea.setStyle("display","").removeClass("mooeditable-textarea").inject(this.container,"before"),this.textarea.removeEvent("keypress",this.textarea.retrieve("mooeditable:textareaKeyListener")),this.container.dispose(),this.fireEvent("detach",this),this},enable:function(){return this.editorDisabled=!1,this.toolbar.enable(),this},disable:function(){return this.editorDisabled=!0,this.toolbar.disable(),this},editorFocus:function(e){this.oldContent="",this
 .fireEvent("editorFocus",[e,this])},editorBlur:function(e){this.oldContent=this.saveContent().getContent(),this.fireEvent("editorBlur",[e,this])},editorMouseUp:function(e){if(this.editorDisabled){e.stop();return}this.options.toolbar&&this.checkStates(),this.fireEvent("editorMouseUp",[e,this])},editorMouseDown:function(e){if(this.editorDisabled){e.stop();return}this.fireEvent("editorMouseDown",[e,this])},editorMouseOver:function(e){if(this.editorDisabled){e.stop();return}this.fireEvent("editorMouseOver",[e,this])},editorMouseOut:function(e){if(this.editorDisabled){e.stop();return}this.fireEvent("editorMouseOut",[e,this])},editorMouseEnter:function(e){if(this.editorDisabled){e.stop();return}this.oldContent&&this.getContent()!=this.oldContent&&(this.focus(),this.fireEvent("editorPaste",[e,this])),this.fireEvent("editorMouseEnter",[e,this])},editorMouseLeave:function(e){if(this.editorDisabled){e.stop();return}this.fireEvent("editorMouseLeave",[e,this])},editorContextMenu:function(e){if(
 this.editorDisabled){e.stop();return}this.fireEvent("editorContextMenu",[e,this])},editorClick:function(e){if(Browser.safari||Browser.chrome){var t=e.target;Element.get(t,"tag")=="img"&&(this.options.baseURL&&t.getProperty("src").indexOf("http://")==-1&&t.setProperty("src",this.options.baseURL+t.getProperty("src")),this.selection.selectNode(t),this.checkStates())}this.fireEvent("editorClick",[e,this])},editorDoubleClick:function(e){this.fireEvent("editorDoubleClick",[e,this])},editorKeyPress:function(e){if(this.editorDisabled){e.stop();return}this.keyListener(e),this.fireEvent("editorKeyPress",[e,this])},editorKeyUp:function(e){if(this.editorDisabled){e.stop();return}var t=e.code;this.options.toolbar&&(/^enter|left|up|right|down|delete|backspace$/i.test(e.key)||t>=33&&t<=36||t==45||e.meta||e.control)&&(Browser.ie6?(clearTimeout(this.checkStatesDelay),this.checkStatesDelay=this.checkStates.delay(500,this)):this.checkStates()),this.fireEvent("editorKeyUp",[e,this])},editorKeyDown:func
 tion(t){if(this.editorDisabled){t.stop();return}if(t.key=="enter")if(this.options.paragraphise){if(t.shift&&(Browser.safari||Browser.chrome)){var n=this.selection,r=n.getRange(),i=this.doc.createElement("br");r.insertNode(i),r.setStartAfter(i),r.setEndAfter(i),n.setRange(r);if(n.getSelection().focusNode==i.previousSibling){var s=this.doc.createTextNode(" "),o=i.parentNode,u=i.nextSibling;u?o.insertBefore(s,u):o.appendChild(s),n.selectNode(s),n.collapse(1)}this.win.scrollTo(0,Element.getOffsets(n.getRange().startContainer).y),t.preventDefault()}else if(Browser.firefox||Browser.safari||Browser.chrome){var a=this.selection.getNode(),f=Element.getParents(a).include(a).some(function(t){return t.nodeName.test(e)});f||this.execute("insertparagraph")}}else if(Browser.ie){var r=this.selection.getRange(),a=this.selection.getNode();r&&a.get("tag")!="li"&&(this.selection.insertContent("<br>"),this.selection.collapse(!1)),t.preventDefault()}if(Browser.opera){var l=t.control||t.meta;l&&t.key=="x
 "?this.fireEvent("editorCut",[t,this]):l&&t.key=="c"?this.fireEvent("editorCopy",[t,this]):(l&&t.key=="v"||t.shift&&t.code==45)&&this.fireEvent("editorPaste",[t,this])}this.fireEvent("editorKeyDown",[t,this])},editorCut:function(e){if(this.editorDisabled){e.stop();return}this.fireEvent("editorCut",[e,this])},editorCopy:function(e){if(this.editorDisabled){e.stop();return}this.fireEvent("editorCopy",[e,this])},editorPaste:function(e){if(this.editorDisabled){e.stop();return}this.fireEvent("editorPaste",[e,this])},keyListener:function(e){var t=Browser.platform=="mac"?e.meta:e.control;if(!t||!this.keys[e.key])return;e.preventDefault();var n=this.toolbar.getItem(this.keys[e.key]);n.action(e)},focus:function(){return(this.mode=="iframe"?this.win:this.textarea).focus(),this.fireEvent("focus",this),this},action:function(e,t){var n=MooEditable.Actions[e];n.command&&typeOf(n.command)=="function"?n.command.apply(this,t):(this.focus(),this.execute(e,!1,t),this.mode=="iframe"&&this.checkStates())
 },execute:function(e,t,n){if(this.busy)return;return this.busy=!0,this.doc.execCommand(e,t,n),this.saveContent(),this.busy=!1,!1},toggleView:function(){return this.fireEvent("beforeToggleView",this),this.mode=="textarea"?(this.mode="iframe",this.iframe.setStyle("display",""),this.setContent(this.textarea.value),this.textarea.setStyle("display","none")):(this.saveContent(),this.mode="textarea",this.textarea.setStyle("display",""),this.iframe.setStyle("display","none")),this.fireEvent("toggleView",this),this.focus.delay(10,this),this},getContent:function(){var e=this.protectedElements,t=this.doc.body.get("html").replace(/<!-- mooeditable:protect:([0-9]+) -->/g,function(t,n){return e[n.toInt()]});return this.cleanup(this.ensureRootElement(t))},setContent:function(e){var t=this.protectedElements;return e=e.replace(n,function(e){return t.push(e),"<!-- mooeditable:protect:"+(t.length-1)+" -->"}),this.doc.body.set("html",this.ensureRootElement(e)),this},saveContent:function(){return this.m
 ode=="iframe"&&this.textarea.set("value",this.getContent()),this.fireEvent("change"),this},ensureRootElement:function(t){if(this.options.rootElement){var n=new Element("div",{html:t.trim()}),r=-1,i=!1,s="",o=n.childNodes.length;for(var u=0;u<o;u++){var a=n.childNodes[u],f=a.nodeName;!f.test(e)&&f!=="#comment"?f==="#text"?a.nodeValue.trim()&&(r<0&&(r=u),s+=a.nodeValue):(r<0&&(r=u),s+=(new Element("div")).adopt($(a).clone()).get("html")):i=!0,u==o-1&&(i=!0);if(r>=0&&i){var l=new Element(this.options.rootElement,{html:s});n.replaceChild(l,n.childNodes[r]);for(var c=r+1;c<u;c++)n.removeChild(n.childNodes[c]),o--,u--,c--;r=-1,i=!1,s=""}}t=n.get("html").replace(/\n\n/g,"")}return t},checkStates:function(){var t=this.selection.getNode();if(!t)return;if(typeOf(t)!="element")return;this.actions.each(function(n){var r=this.toolbar.getItem(n);if(!r)return;r.deactivate();var i=MooEditable.Actions[n].states;if(!i)return;if(typeOf(i)=="function"){i.attempt([document.id(t),r],this);return}try{if(t
 his.doc.queryCommandState(n)){r.activate();return}}catch(s){}if(i.tags){var o=t;do{var u=o.tagName.toLowerCase();if(i.tags.contains(u)){r.activate(u);break}}while((o=Element.getParent(o))!=null)}if(i.css){var o=t;do{var a=!1;for(var f in i.css){var l=i.css[f];o.style[f.camelCase()].contains(l)&&(r.activate(l),a=!0)}if(a||o.tagName.test(e))break}while((o=Element.getParent(o))!=null)}}.bind(this))},cleanup:function(e){if(!this.options.cleanup)return e.trim();do{var t=e;this.options.baseURL&&(e=e.replace('="'+this.options.baseURL,'="')),e=e.replace(/<br class\="webkit-block-placeholder">/gi,"<br />"),e=e.replace(/<span class="Apple-style-span">(.*)<\/span>/gi,"$1"),e=e.replace(/ class="Apple-style-span"/gi,""),e=e.replace(/<span style="">/gi,""),e=e.replace(/<p>\s*<br ?\/?>\s*<\/p>/gi,"<p> </p>"),e=e.replace(/<p>(&nbsp;|\s)*<\/p>/gi,"<p> </p>"),this.options.semantics||(e=e.replace(/\s*<br ?\/?>\s*<\/p>/gi,"</p>")),this.options.xhtml&&(e=e.replace(/<br>/gi,"<br />"));if(this.options.s
 emantics){Browser.ie&&(e=e.replace(/<li>\s*<div>(.+?)<\/div><\/li>/g,"<li>$1</li>"));if(Browser.safari||Browser.chrome)e=e.replace(/^([\w\s]+.*?)<div>/i,"<p>$1</p><div>"),e=e.replace(/<div>(.+?)<\/div>/ig,"<p>$1</p>");Browser.ie||(e=e.replace(/<p>[\s\n]*(<(?:ul|ol)>.*?<\/(?:ul|ol)>)(.*?)<\/p>/ig,"$1<p>$2</p>"),e=e.replace(/<\/(ol|ul)>\s*(?!<(?:p|ol|ul|img).*?>)((?:<[^>]*>)?\w.*)$/g,"</$1><p>$2</p>")),e=e.replace(/<br[^>]*><\/p>/g,"</p>"),e=e.replace(/<p>\s*(<img[^>]+>)\s*<\/p>/ig,"$1\n"),e=e.replace(/<p([^>]*)>(.*?)<\/p>(?!\n)/g,"<p$1>$2</p>\n"),e=e.replace(/<\/(ul|ol|p)>(?!\n)/g,"</$1>\n"),e=e.replace(/><li>/g,">\n	<li>"),e=e.replace(/([^\n])<\/(ol|ul)>/g,"$1\n</$2>"),e=e.replace(/([^\n])<img/ig,"$1\n<img"),e=e.replace(/^\s*$/g,"")}e=e.replace(/<br ?\/?>$/gi,""),e=e.replace(/^<br ?\/?>/gi,""),this.options.paragraphise&&(e=e.replace(/(h[1-6]|p|div|address|pre|li|ol|ul|blockquote|center|dl|dt|dd)><br ?\/?>/gi,"$1>")),e=e.replace(/<br ?\/?>\s*<\/(h1|h2|h3|h4|h5|h6|li|p)/gi,"</$1"),e=e
 .replace(/<span style="font-weight: bold;">(.*)<\/span>/gi,"<strong>$1</strong>"),e=e.replace(/<span style="font-style: italic;">(.*)<\/span>/gi,"<em>$1</em>"),e=e.replace(/<b\b[^>]*>(.*?)<\/b[^>]*>/gi,"<strong>$1</strong>"),e=e.replace(/<i\b[^>]*>(.*?)<\/i[^>]*>/gi,"<em>$1</em>"),e=e.replace(/<u\b[^>]*>(.*?)<\/u[^>]*>/gi,'<span style="text-decoration: underline;">$1</span>'),e=e.replace(/<strong><span style="font-weight: normal;">(.*)<\/span><\/strong>/gi,"$1"),e=e.replace(/<em><span style="font-weight: normal;">(.*)<\/span><\/em>/gi,"$1"),e=e.replace(/<span style="text-decoration: underline;"><span style="font-weight: normal;">(.*)<\/span><\/span>/gi,"$1"),e=e.replace(/<strong style="font-weight: normal;">(.*)<\/strong>/gi,"$1"),e=e.replace(/<em style="font-weight: normal;">(.*)<\/em>/gi,"$1"),e=e.replace(/<[^> ]*/g,function(e){return e.toLowerCase()}),e=e.replace(/<[^>]*>/g,function(e){return e=e.replace(/ [^=]+=/g,function(e){return e.toLowerCase()}),e}),e=e.replace(/<[^!][^>]*>
 /g,function(e){return e=e.replace(/( [^=]+=)([^"][^ >]*)/g,'$1"$2"'),e}),this.options.xhtml&&(e=e.replace(/<img([^>]+)(\s*[^\/])>(<\/img>)*/gi,"<img$1$2 />")),e=e.replace(/<p>(?:\s*)<p>/g,"<p>"),e=e.replace(/<\/p>\s*<\/p>/g,"</p>"),e=e.replace(/<pre[^>]*>.*?<\/pre>/gi,function(e){return e.replace(/<br ?\/?>/gi,"\n")}),e=e.trim()}while(e!=t);return e}}),MooEditable.Selection=new Class({initialize:function(e){this.win=e},getSelection:function(){return this.win.focus(),this.win.getSelection?this.win.getSelection():this.win.document.selection},getRange:function(){var e=this.getSelection();if(!e)return null;try{return e.rangeCount>0?e.getRangeAt(0):e.createRange?e.createRange():null}catch(t){return this.doc.body.createTextRange()}},setRange:function(e){if(e.select)Function.attempt(function(){e.select()});else{var t=this.getSelection();t.addRange&&(t.removeAllRanges(),t.addRange(e))}},selectNode:function(e,t){var n=this.getRange(),r=this.getSelection();return n.moveToElementText?Function.
 attempt(function(){n.moveToElementText(e),n.select()}):r.addRange?(t?n.selectNodeContents(e):n.selectNode(e),r.removeAllRanges(),r.addRange(n)):r.setBaseAndExtent(e,0,e,1),e},isCollapsed:function(){var e=this.getRange();return e.item?!1:e.boundingWidth==0||this.getSelection().isCollapsed},collapse:function(e){var t=this.getRange(),n=this.getSelection();t.select?(t.collapse(e),t.select()):e?n.collapseToStart():n.collapseToEnd()},getContent:function(){var e=this.getRange(),t=new Element("body");if(this.isCollapsed())return"";e.cloneContents?t.appendChild(e.cloneContents()):e.item!=undefined||e.htmlText!=undefined?t.set("html",e.item?e.item(0).outerHTML:e.htmlText):t.set("html",e.toString());var n=t.get("html");return n},getText:function(){var e=this.getRange(),t=this.getSelection();return this.isCollapsed()?"":e.text||(t.toString?t.toString():"")},getNode:function(){var e=this.getRange();if(!Browser.ie||Browser.version>=9){var t=null;if(e){t=e.commonAncestorContainer,e.collapsed||e.st
 artContainer==e.endContainer&&e.startOffset-e.endOffset<2&&e.startContainer.hasChildNodes()&&(t=e.startContainer.childNodes[e.startOffset]);while(typeOf(t)!="element")t=t.parentNode}return document.id(t)}return document.id(e.item?e.item(0):e.parentElement())},insertContent:function(e){if(Browser.ie){var t=this.getRange();if(t.pasteHTML)t.pasteHTML(e),t.collapse(!1),t.select();else if(t.insertNode){t.deleteContents();if(t.createContextualFragment)t.insertNode(t.createContextualFragment(e));else{var n=this.win.document,r=n.createDocumentFragment(),i=n.createElement("div");r.appendChild(i),i.outerHTML=e,t.insertNode(r)}}}else this.win.document.execCommand("insertHTML",!1,e)}});var r={};MooEditable.Locale={define:function(e,t){if(typeOf(window.Locale)!="null")return Locale.define("en-US","MooEditable",e,t);typeOf(e)=="object"?Object.merge(r,e):r[e]=t},get:function(e){return typeOf(window.Locale)!="null"?Locale.get("MooEditable."+e):e?r[e]:""}},MooEditable.Locale.define({ok:"OK",cancel:"
 Cancel",bold:"Bold",italic:"Italic",underline:"Underline",strikethrough:"Strikethrough",unorderedList:"Unordered List",orderedList:"Ordered List",indent:"Indent",outdent:"Outdent",undo:"Undo",redo:"Redo",removeHyperlink:"Remove Hyperlink",addHyperlink:"Add Hyperlink",selectTextHyperlink:"Please select the text you wish to hyperlink.",enterURL:"Enter URL",enterImageURL:"Enter image URL",addImage:"Add Image",toggleView:"Toggle View"}),MooEditable.UI={},MooEditable.UI.Toolbar=new Class({Implements:[Events,Options],options:{"class":""},initialize:function(e){this.setOptions(e),this.el=new Element("div",{"class":"mooeditable-ui-toolbar "+this.options["class"]}),this.items={},this.content=null},toElement:function(){return this.el},render:function(e){return this.content?this.el.adopt(this.content):this.content=e.map(function(e){return e=="|"?this.addSeparator():e=="/"?this.addLineSeparator():this.addItem(e)}.bind(this)),this},addItem:function(e){var t=this,n=MooEditable.Actions[e];if(!n)re
 turn;var r=n.type||"button",i=n.options||{},s=new(MooEditable.UI[r.camelCase().capitalize()])(Object.append(i,{name:e,"class":e+"-item toolbar-item",title:n.title,onAction:t.itemAction.bind(t)}));return this.items[e]=s,document.id(s).inject(this.el),s},getItem:function(e){return this.items[e]},addSeparator:function(){return(new Element("span.toolbar-separator")).inject(this.el)},addLineSeparator:function(){return(new Element("div.toolbar-line-separator")).inject(this.el)},itemAction:function(){this.fireEvent("itemAction",arguments)},disable:function(e){return Object.each(this.items,function(t){t.name==e?t.activate():t.deactivate().disable()}),this},enable:function(){return Object.each(this.items,function(e){e.enable()}),this},show:function(){return this.el.setStyle("display",""),this},hide:function(){return this.el.setStyle("display","none"),this}}),MooEditable.UI.Button=new Class({Implements:[Events,Options],options:{title:"",name:"",text:"Button","class":"",shortcut:"",mode:"icon"
 },initialize:function(e){this.setOptions(e),this.name=this.options.name,this.render()},toElement:function(){return this.el},render:function(){var e=this,t=Browser.platform=="mac"?"Cmd":"Ctrl",n=this.options.shortcut?" ( "+t+"+"+this.options.shortcut.toUpperCase()+" )":"",r=this.options.title||name,i=r+n;return this.el=new Element("button",{"class":"mooeditable-ui-button "+e.options["class"],title:i,html:'<span class="button-icon"></span><span class="button-text">'+r+"</span>",events:{click:e.click.bind(e),mousedown:function(e){e.preventDefault()}}}),this.options.mode!="icon"&&this.el.addClass("mooeditable-ui-button-"+this.options.mode),this.active=!1,this.disabled=!1,Browser.ie&&this.el.addEvents({mouseenter:function(e){this.addClass("hover")},mouseleave:function(e){this.removeClass("hover")}}),this},click:function(e){e.preventDefault();if(this.disabled)return;this.action(e)},action:function(){this.fireEvent("action",[this].concat(Array.from(arguments)))},enable:function(){this.acti
 ve&&this.el.removeClass("onActive");if(!this.disabled)return;return this.disabled=!1,this.el.removeClass("disabled").set({disabled:!1,opacity:1}),this},disable:function(){if(this.disabled)return;return this.disabled=!0,this.el.addClass("disabled").set({disabled:!0,opacity:.4}),this},activate:function(){if(this.disabled)return;return this.active=!0,this.el.addClass("onActive"),this},deactivate:function(){return this.active=!1,this.el.removeClass("onActive"),this}}),MooEditable.UI.Dialog=new Class({Implements:[Events,Options],options:{"class":"",contentClass:""},initialize:function(e,t){this.setOptions(t),this.html=e;var n=this;this.el=new Element("div",{"class":"mooeditable-ui-dialog "+n.options["class"],html:'<div class="dialog-content '+n.options.contentClass+'">'+e+"</div>",styles:{display:"none"},events:{click:n.click.bind(n)}})},toElement:function(){return this.el},click:function(){return this.fireEvent("click",arguments),this},open:function(){return this.el.setStyle("display","
 "),this.fireEvent("open",this),this},close:function(){return this.el.setStyle("display","none"),this.fireEvent("close",this),this}}),MooEditable.UI.AlertDialog=function(e){if(!e)return;var t=e+' <button class="dialog-ok-button">'+MooEditable.Locale.get("ok")+"</button>";return new MooEditable.UI.Dialog(t,{"class":"mooeditable-alert-dialog",onOpen:function(){var e=this.el.getElement(".dialog-ok-button");(function(){e.focus()}).delay(10)},onClick:function(e){e.preventDefault();if(e.target.tagName.toLowerCase()!="button")return;document.id(e.target).hasClass("dialog-ok-button")&&this.close()}})},MooEditable.UI.PromptDialog=function(e,t,n){if(!e)return;var r='<label class="dialog-label">'+e+' <input type="text" class="text dialog-input" value="'+t+'">'+'</label> <button class="dialog-button dialog-ok-button">'+MooEditable.Locale.get("ok")+"</button>"+'<button class="dialog-button dialog-cancel-button">'+MooEditable.Locale.get("cancel")+"</button>";return new MooEditable.UI.Dialog(r,{"cl
 ass":"mooeditable-prompt-dialog",onOpen:function(){var e=this.el.getElement(".dialog-input");(function(){e.focus(),e.select()}).delay(10)},onClick:function(e){e.preventDefault();if(e.target.tagName.toLowerCase()!="button")return;var r=document.id(e.target),i=this.el.getElement(".dialog-input");if(r.hasClass("dialog-cancel-button"))i.set("value",t),this.close();else if(r.hasClass("dialog-ok-button")){var s=i.get("value");i.set("value",t),this.close(),n&&n.attempt(s,this)}}})},MooEditable.Actions={bold:{title:MooEditable.Locale.get("bold"),options:{shortcut:"b"},states:{tags:["b","strong"],css:{"font-weight":"bold"}},events:{beforeToggleView:function(){if(Browser.firefox){var e=this.textarea.get("value"),t=e.replace(/<strong([^>]*)>/gi,"<b$1>").replace(/<\/strong>/gi,"</b>");e!=t&&this.textarea.set("value",t)}},attach:function(){if(Browser.firefox){var e=this.textarea.get("value"),t=e.replace(/<strong([^>]*)>/gi,"<b$1>").replace(/<\/strong>/gi,"</b>");e!=t&&(this.textarea.set("value",
 t),this.setContent(t))}}}},italic:{title:MooEditable.Locale.get("italic"),options:{shortcut:"i"},states:{tags:["i","em"],css:{"font-style":"italic"}},events:{beforeToggleView:function(){if(Browser.firefox){var e=this.textarea.get("value"),t=e.replace(/<embed([^>]*)>/gi,"<tmpembed$1>").replace(/<em([^>]*)>/gi,"<i$1>").replace(/<tmpembed([^>]*)>/gi,"<embed$1>").replace(/<\/em>/gi,"</i>");e!=t&&this.textarea.set("value",t)}},attach:function(){if(Browser.firefox){var e=this.textarea.get("value"),t=e.replace(/<embed([^>]*)>/gi,"<tmpembed$1>").replace(/<em([^>]*)>/gi,"<i$1>").replace(/<tmpembed([^>]*)>/gi,"<embed$1>").replace(/<\/em>/gi,"</i>");e!=t&&(this.textarea.set("value",t),this.setContent(t))}}}},underline:{title:MooEditable.Locale.get("underline"),options:{shortcut:"u"},states:{tags:["u"],css:{"text-decoration":"underline"}},events:{beforeToggleView:function(){if(Browser.firefox||Browser.ie){var e=this.textarea.get("value"),t=e.replace(/<span style="text-decoration: underline;"([^
 >]*)>/gi,"<u$1>").replace(/<\/span>/gi,"</u>");e!=t&&this.textarea.set("value",t)}},attach:function(){if(Browser.firefox||Browser.ie){var e=this.textarea.get("value"),t=e.replace(/<span style="text-decoration: underline;"([^>]*)>/gi,"<u$1>").replace(/<\/span>/gi,"</u>");e!=t&&(this.textarea.set("value",t),this.setContent(t))}}}},strikethrough:{title:MooEditable.Locale.get("strikethrough"),options:{shortcut:"s"},states:{tags:["s","strike"],css:{"text-decoration":"line-through"}}},insertunorderedlist:{title:MooEditable.Locale.get("unorderedList"),states:{tags:["ul"]}},insertorderedlist:{title:MooEditable.Locale.get("orderedList"),states:{tags:["ol"]}},indent:{title:MooEditable.Locale.get("indent"),states:{tags:["blockquote"]}},outdent:{title:MooEditable.Locale.get("outdent")},undo:{title:MooEditable.Locale.get("undo"),options:{shortcut:"z"}},redo:{title:MooEditable.Locale.get("redo"),options:{shortcut:"y"}},unlink:{title:MooEditable.Locale.get("removeHyperlink")},createlink:{title:Moo
 Editable.Locale.get("addHyperlink"),options:{shortcut:"l"},states:{tags:["a"]},dialogs:{alert:MooEditable.UI.AlertDialog.pass(MooEditable.Locale.get("selectTextHyperlink")),prompt:function(e){return MooEditable.UI.PromptDialog(MooEditable.Locale.get("enterURL"),"http://",function(t){e.execute("createlink",!1,t.trim())})}},command:function(){var e=this.selection,n=this.dialogs.createlink;if(e.isCollapsed()){var r=e.getNode();if(r.get("tag")=="a"&&r.get("href")){e.selectNode(r);var i=n.prompt;i.el.getElement(".dialog-input").set("value",r.get("href")),i.open()}else n.alert.open()}else{var s=e.getText(),i=n.prompt;t.test(s)&&i.el.getElement(".dialog-input").set("value",s),i.open()}}},urlimage:{title:MooEditable.Locale.get("addImage"),options:{shortcut:"m"},dialogs:{prompt:function(e){return MooEditable.UI.PromptDialog(MooEditable.Locale.get("enterImageURL"),"http://",function(t){e.execute("insertimage",!1,t.trim())})}},command:function(){this.dialogs.urlimage.prompt.open()}},toggleview
 :{title:MooEditable.Locale.get("toggleView"),command:function(){this.mode=="textarea"?this.toolbar.enable():this.toolbar.disable("toggleview"),this.toggleView()}}},MooEditable.Actions.Settings={},Element.Properties.mooeditable={get:function(){return this.retrieve("MooEditable")}},Element.implement({mooEditable:function(e){var t=this.get("mooeditable");return t||(t=new MooEditable(this,e)),t}})})(),MooEditable.UI.MenuList=new Class({Implements:[Events,Options],options:{title:"",name:"","class":"",list:[]},initialize:function(e){this.setOptions(e),this.name=this.options.name,this.render()},toElement:function(){return this.el},render:function(){var e=this,t="";return this.options.list.each(function(e){t+='<option value="{value}" style="{style}">{text}</option>'.substitute(e)}),this.el=new Element("select",{"class":e.options["class"],title:e.options.title,html:t,styles:{height:"21px"},events:{change:e.change.bind(e)}}),this.disabled=!1,Browser.ie&&this.el.addEvents({mouseenter:function(
 e){this.addClass("hover")},mouseleave:function(e){this.removeClass("hover")}}),this},change:function(e){e.preventDefault();if(this.disabled)return;var t=e.target.value;this.action(t)},action:function(){this.fireEvent("action",[this].concat(Array.from(arguments)))},enable:function(){if(!this.disabled)return;return this.disabled=!1,this.el.set("disabled",!1).removeClass("disabled").set({disabled:!1,opacity:1}),this},disable:function(){if(this.disabled)return;return this.disabled=!0,this.el.set("disabled",!0).addClass("disabled").set({disabled:!0,opacity:.4}),this},activate:function(e){if(this.disabled)return;var t=0;return e&&this.options.list.each(function(n,r){n.value==e&&(t=r)}),this.el.selectedIndex=t,this},deactivate:function(){return this.el.selectedIndex=0,this.el.removeClass("onActive"),this}}),MooEditable.Locale.define({blockFormatting:"Block Formatting",paragraph:"Paragraph",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",heading4:"Heading 4",alignLeft:"Align 
 Left",alignRight:"Align Right",alignCenter:"Align Center",alignJustify:"Align Justify",removeFormatting:"Remove Formatting",insertHorizontalRule:"Insert Horizontal Rule"}),Object.append(MooEditable.Actions,{formatBlock:{title:MooEditable.Locale.get("blockFormatting"),type:"menu-list",options:{list:[{text:MooEditable.Locale.get("paragraph"),value:"p"},{text:MooEditable.Locale.get("heading2"),value:"h2",style:"font-size:18px; font-weight:bold;"},{text:MooEditable.Locale.get("heading3"),value:"h3",style:"font-size:14px; font-weight:bold;"},{text:MooEditable.Locale.get("heading4"),value:"h4",style:"font-size:12px; font-weight:bold;"}]},states:{tags:["p","h1","h2","h3"]},command:function(e,t){var n="<"+t+">";this.focus(),this.execute("formatBlock",!1,n)}},justifyleft:{title:MooEditable.Locale.get("alignLeft"),states:{css:{"text-align":"left"}}},justifyright:{title:MooEditable.Locale.get("alignRight"),states:{css:{"text-align":"right"}}},justifycenter:{title:MooEditable.Locale.get("alignC
 enter"),states:{tags:["center"],css:{"text-align":"center"}}},justifyfull:{title:MooEditable.Locale.get("alignJustify"),states:{css:{"text-align":"justify"}}},removeformat:{title:MooEditable.Locale.get("removeFormatting")},insertHorizontalRule:{title:MooEditable.Locale.get("insertHorizontalRule"),states:{tags:["hr"]},command:function(){this.selection.insertContent("<hr>")}}})
\ No newline at end of file


Mime
View raw message