Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

update joined files

  • Loading branch information...
commit fcdbd07a68f38330695e482196dfb7f6dcce39cc 1 parent 023fb14
Jonas von Andrian authored December 07, 2011
146  source/javascripts/joined-min.js
... ...
@@ -1,65 +1,81 @@
1  
-(function(g){var d,k;k={check:function(){var h=!0;this.find(d.errorElement+"."+d.errorClass).remove();this.find(":input."+d.inputErrorClass).removeClass(d.inputErrorClass);this.find(":input.required").each(function(){var r=g(this),k=g.trim(r.val()),t=r.siblings("label").text().replace(d.removeLabelChar,""),n="";if(k==="")n=hasLabelPlaceholder?n=d.errorText.replace("{label}",t):n=d.errorText,h=!1;else if(r.hasClass("email")&&!/^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/.test(k))n=
2  
-hasLabelPlaceholder?n=d.emailErrorText.replace("{label}",t):n=d.emailErrorText,h=!1;n!==""&&r.parent().addClass(d.errorClass)});return h},reset:function(){return this.find(":input.required").each(function(){g(this).parent().removeClass(d.errorClass)})}};g.fn.isValid=function(h){k[h]||(h="check");return k[h].apply(this,Array.prototype.slice.call(arguments,1))};g.fn.isValid.init=function(h){d=g.extend({},g.fn.isValid.defaults,h);hasLabelPlaceholder=d.errorText.indexOf("{label}")>-1};g.fn.isValid.defaults=
3  
-{errorClass:"error",errorText:"{label} is a required field.",emailErrorText:"Please enter a valid {label}",errorElement:"strong",removeLabelChar:"*"}})(jQuery);
4  
-(function(g){function d(a){g.extend(this,a);this.prototype=d.prototype}function k(a,c){this.name=a;if(c)this.clicked=c,s.push(a)}function h(a,c,f){k.apply(this,[a,f]);this.options=c||[]}function r(){var a,c,f;if(!q){a=0;for(c=p.length;a<c;a++)(f=m[p[a]])&&(q+=f.getButton())}return q}function u(a){var c=g('<div class="toolbar"></div>'),f=this;this.textArea=a.textArea;this.htmlDiv=a.htmlDiv;this.editor=a;this.div=c;c.html(r());c.mouseup(function(e){e=e.target;if(!/(select|option)/i.test(e.nodeName)){if(/span/i.test(e.nodeName))e=
5  
-e.parentNode;if(e.disabled)return a.is("wysiwyg")?a.htmlDiv.focus():a.textArea.focus(),!1;var b=e.className;b=b.split(" ")[0];f.runAction(b,e);a.checkState()}}).change(function(e){e=e.target;f.runAction(e.className,e);return!1}).click(function(){return!1});a.container.prepend(c)}function t(a,c){function f(b,c){b.keydown(function(b){if(c||e.is("wysiwyg"))return e.currentMode.pressed(b.keyCode)}).keyup(function(b){if(c||e.is("wysiwyg"))return e.currentMode.released(b.keyCode)}).mouseup(function(){if(c||
6  
-e.is("wysiwyg"))return e.currentMode.clicked()})}var e=this,b=0;this.loadedModes={};this.setDataType(a.attr("class"));this.settings=c;if(this.dataType)this.textArea=a.bind("mouseup keyup",function(){e.checkState();clearTimeout(b);b=setTimeout(function(){e.currentMode.updatePreview()},1E3)}),f(a,!0),this.htmlDiv=g('<div class="preview"></div>').bind("mouseup keyup",function(){e.is("wysiwyg")&&e.checkState()}),f(this.htmlDiv),this.container=a.wrap('<div class="markupEditor"></div>').parent().append(e.htmlDiv),
7  
-a.wrap('<div class="textarea">'),this.toolbar=new u(this)}function n(a,c){var f;f={};g.extend(f,j,c);f=new t(a,f);f.currentMode=f.getDataMode();if(a.hasClass("wysiwyg"))f.currentMode.activate(),f.currentMode=f.getMode("wysiwyg");f.currentMode.activate();f.checkState();return f}var j={},l={},m={},q="",p=["bold","italic","alignLeft","alignCenter","alignRight","unorderedList","orderedList","link","insertImage","save","wysiwyg","changeDataMode","formatBlock"],s=[];d.prototype={load:function(a){this.editor=
8  
-a;this.htmlDiv=a.htmlDiv;this.textArea=a.textArea;console.log("loaded Mode "+this.name)},pressed:function(a){if(a===16)this.holdShift=!0;if(ME.util.isNeutralKey(a))this.holdNeutralKey=!0},released:function(a){if(a===16)this.holdShift=!1;if(ME.util.isNeutralKey(a))this.holdNeutralKey=!1},clicked:g.noop,activate:function(){this.htmlDiv.is(":empty")?this.updatePreview():this.updateTextArea();this.editor.toolbar.loadModeToolbar();this.afterActivation()},updatePreview:function(){console.log("updating preview in Mode "+
9  
-this.name);this.htmlDiv.html(this.toHTML()||"<p>&nbsp;</p>")},updateTextArea:function(){console.log("updating TA in Mode "+this.name);this.textArea.val(this.toText())},afterActivation:function(){this.textArea.parent().show().find(":first-child").focus()[0].setSelectionRange(0,0);this.htmlDiv.attr("contentEditable",!1)},getStates:function(){var a=this.getSelectionStates();this.id==="wysiwyg"?a.wysiwyg=!0:a.changeDataMode=this.id;return a},getSelectionStates:function(){return{}},buildStateObject:function(a,
10  
-c){for(var f,e=a.length,b={};e--;)switch(f=a[e],f.tag?f.tag:f.nodeName.toLowerCase()){case "a":c.a=f;b.link=!0;break;case "img":c.img=f;b.insertImage=!0;break;case "i":b.italic=!0;break;case "b":b.bold=!0;break;case "ol":b.orderedList=!0;b.unorderedList=!1;b.formatBlock="disable";b.alignLeft="disable";b.alignRight="disable";b.alignCenter="disable";c.list=f;break;case "ul":b.orderedList=!1;b.unorderedList=!0;b.formatBlock="disable";b.alignLeft="disable";b.alignRight="disable";b.alignCenter="disable";
11  
-c.list=f;break;case "li":break;default:b.formatBlock=f.tag?f.tag:f.nodeName.toLowerCase(),c.block=f}return b},getSelection:function(a){var c=this.textArea,f=c.val(),e;c.focus();this.scrollPosition=c.scrollTop;this.selectionStart=c[0].selectionStart;this.selectionEnd=c[0].selectionEnd;f[this.selectionEnd-1]==="\n"&&(this.selectionEnd-=1);if(a){c=Math.max(f.lastIndexOf(a,this.selectionStart),f.lastIndexOf("\n",this.selectionStart));this.selectionStart=c!==-1?c+1:0;c=f.indexOf("\n",this.selectionEnd);
12  
-e=c===-1?f.slice(this.selectionStart):f.slice(this.selectionStart,c);c=0;do c=e.indexOf(a,c+1);while(c!==-1&&this.selectionEnd>this.selectionStart+c);if(c===-1)c=e.length;this.selectionEnd=this.selectionStart+c}return this.selection=f.slice(this.selectionStart,this.selectionEnd)},replaceSelection:function(a,c){var f=this.textArea,e=this.selectionStart,b=this.selectionStart+a.length;f.val(f.val().slice(0,this.selectionStart)+a+f.val().slice(this.selectionEnd,f.val().length));c===!0?b=e:c===!1&&(e=
13  
-b);f[0].setSelectionRange(e,b);f.focus()},extendRightSelection:function(a){var c;a=RegExp(a.source,"g");a.lastIndex=this.selectionEnd;if((c=a.exec(this.textArea.val()))&&a.lastIndex==this.selectionEnd+c[0].length)return this.selectionEnd+=c[0].length,c[0]},extendLeftSelection:function(a){var c=this.textArea.val().slice(0,this.selectionStart);a=RegExp(a.source+"$");if(a=a.exec(c))return this.selectionStart-=a[0].length,a[0]}};k.prototype={getButton:function(){return'<a href="#" class="'+this.name+
14  
-'" ><span>'+this.name+"</span></a>"}};h.prototype={getButton:function(){var a='<select class="'+this.name+'">',c=this.options.length,f;a.className=this.name;for(f=0;f<c;f+=1)a+='<option value="'+this.options[f][0]+'">'+this.options[f][1]+"</option>";return a+"</select>"}};u.prototype={loadModeToolbar:function(){var a=this.editor.currentMode.supportedItems,c=this.editor.settings.save,f=this.visibleItems,e=[];this.div.children().each(function(){var b=this.className;a.indexOf(b)!=-1&&(b!=="save"||c)?
15  
-((!f||f.indexOf(b)==-1)&&g(this).show(),e.push(b)):(!f||f.indexOf(b)!=-1)&&g(this).hide()});this.visibleItems=e},runAction:function(a,c){var f=m[a],e=this.editor,b=e.currentMode;(f[b.id]||f).clicked(e,b,c);a!="changeMode"&&!e.is("wysiwyg")&&b.updatePreview()},setActive:function(a){a&&this.div.children().each(function(){var c=this.className.split(" ")[0];if(a[c]=="disable")this.disabled=!0,this.className=c+" disabled";else if(this.disabled=!1,this.className=c,a[c]===!0)this.className=c+" on";else if(a[c])this.value=
16  
-a[c]})}};t.prototype={changeMode:function(a){a=this.getMode(a);this.commit();this.currentMode=a;a.activate()},changeDataMode:function(a){var c=this.is("wysiwyg");if(!a||a===this.currentMode.id)return!1;this.changeMode(a);c&&this.changeMode("wysywyg")},getDataMode:function(){return this.getMode(this.dataType)},getMode:function(a){if(this.loadedModes[a])return this.loadedModes[a];else if(l[a])return this.loadedModes[a]=l[a](this),this.loadedModes[a];else console.log("Mode "+a+" is not defined")},setDataType:function(a){var c,
17  
-f=a.split(/\s+/);for(a=0;a<f.length;a+=1)if(c=f[a],c!=="wysiwyg"&&l[c])this.dataType=c},commit:function(){this.is("wysiwyg")?this.getMode(this.dataType).updateTextArea():this.currentMode.updatePreview()},is:function(a){return this.currentMode.id===a},checkState:function(){this.toolbar.setActive(this.currentMode.getStates())}};ME={addMode:function(a,c){var f=c(),e=f.items,b,o=s.slice();f.id=a;if(e)for(item in e)e.hasOwnProperty(item)&&item!=="default"&&(o.push(item),m[item]||(b=e[item].options?h:k,
18  
-m[item]=new b(item)),m[item][a]=g.extend({name:item},e["default"],e[item]));a!=="wysiwyg"&&m.changeDataMode.options.push([a,f.name]);f.supportedItems=o;l[a]=function(b){var e=new d(f);e.load(b);return e};return f},options:{},setOptions:function(a){this.options=a}};g.fn.initMarkupEditor=function(a){ME.settings=a;this.each(function(c,f){var e=g(f);if(e.is("textarea"))n(e,a);else{e.css("min-height",e.height());var b;b=g('<textarea class="'+e[0].className+'">').prependTo(e);b=n(b,a);b.htmlDiv.append(b.container.nextAll());
19  
-b.currentMode.updateTextArea();b.changeMode("wysiwyg");b.checkState();e.append(b.container)}});return this};m.changeDataMode=new h("changeDataMode",[],function(a,c,f){a.changeDataMode(f.value)});m.formatBlock=new h("formatBlock",[["p","Paragraph"],["h1","Heading 1"],["h2","Heading 2"],["h3","Heading 3"]]);m.save=new k("save",function(a){a.commit();a.settings.save(a)});m.wysiwyg=new k("wysiwyg",function(a){a.is("wysiwyg")?a.changeMode(a.dataType):a.changeMode("wysiwyg")});return ME})(jQuery);
20  
-(function(g){neutralKeys="9.16.17.18.20.27.33.34.35.36.37.38.39.40.45.91.93.93";g.util={isNeutralKey:function(d){return neutralKeys.indexOf(""+d)!=-1},isRemovalKey:function(d){return d==46||d==8}}})(ME);
21  
-(function(g,d){var k=d.util.isNeutralKey,h=d.util.isRemovalKey;g.fn.enhanceTextfield=function(d){d=d||{};return this.each(function(){function u(){j.css("color","grey").data("hasPrompt",!0).val(d.prompt)}function t(){j.css("color",q).data("hasPrompt",!1).val("")}function n(){j.val()&&j.val()!==d.prompt?(j.css("color",q),l.show()):(u(),l.hide(),m=!1)}var j=g(this),l,m,q=j.css("color");j.is("input")&&(l=g("<span>x</span>").click(function(){t();j.focus();l.hide();m=!1}),$p=j.wrap('<span class="clearButton">').focus(function(){!m&&
22  
-j.val()===d.prompt&&t();j.parent().addClass("focus")}).focusout(function(){!m&&!j.val()&&u();j.parent().removeClass("focus")}).keydown(function(g){!k(g.which)&&(!m||h(g.which))&&j.val()===d.prompt&&t()}).keyup(function(d){!m&&!k(d.which)&&!h(d.which)&&(m=!0,n())}).bind("blur change",function(){n()}).submit(function(){j.val()===d.prompt&&t()}).parent().append(l),j.hasClass("ui-corner-left")?$p.addClass("ui-corner-left"):$p.addClass("ui-corner-all"))})}})(jQuery,ME);
23  
-(function(g,d){g.fn.required=function(d){return this.each(function(){d?g(this).addClass("required"):g(this).removeClass("required")})};g.widget("ui.combobox",{_create:function(){var k=this.element,h=this.options.key,r=g.ui.autocomplete.escapeRegex;k.autocomplete({delay:0,minLength:0,source:function(g,k){var n=RegExp(r(g.term),"i"),j=d.options[h]||[],l=j.length,m=[],q,p;if(g.term)for(p=0;p<l;p++)q=j[p],n.test(q)&&m.push({label:q.replace(RegExp("(?![^&;]+;)(?!<[^<>]*)("+r(g.term)+")(?![^<>]*>)(?![^&;]+;)",
24  
-"gi"),"<strong>$1</strong>"),value:q});else m=j;k(m)},focus:function(d,h){k.val(h.item.value).change()}}).addClass("ui-corner-left");k.data("autocomplete")._renderItem=function(d,h){return g("<li></li>").data("item.autocomplete",h).append("<a>"+h.label+"</a>").appendTo(d)};this.button=g("<button type='button'>&nbsp;</button>").attr("tabIndex",-1).attr("title","Show All Items").insertAfter(k).button({icons:{primary:"ui-icon-triangle-1-s"},text:!1}).removeClass("ui-corner-all").addClass("ui-corner-right ui-button-icon").click(function(){k.autocomplete("widget").is(":visible")?
25  
-k.autocomplete("close"):(k.data("hasPrompt")&&k.val(""),k.autocomplete("search",""),k.focus())})},destroy:function(){this.button.remove();g.Widget.prototype.destroy.call(this)}})})(jQuery,ME);
26  
-(function(g){function d(d,g,k){var j=g.length,l=d.find(":first-child");d.dialog({autoOpen:!1,width:600,close:function(){h.close&&h.close();for(i=0;i<j;i++)g[i].val("").removeAttr("checked").removeAttr("selected")},open:function(){for(i=0;i<j;i++)g[i].change();g[0][0].setSelectionRange(0,0);l.isValid("reset")}});return{dialog:function(g,j){j&&(h=j);d.dialog(g)},find:function(h){return d.find(h)},selectButtons:function(h){for(var g={},j=h.length;j--;)g[h[j]]=k[h[j]];d.dialog("option","buttons",g)},
27  
-val:function(d,h){this.find(d).val(h)}}}function k(k,t){var n,j,l,m,q,p,s,a=t.length,c=[];n=g('<div id="'+k+'-dialog" title="'+r[k+"Title"]+'"><form>');var f=n.find(":first-child");for(l=0;l<a;l++){m=t[l][0];q=t[l][1];f.append('<label for="'+m+'">'+r[m]+"</label>");c[l]=g('<input type="text" class="'+m+'" name="'+m+'">').appendTo(f);if(q)for(p in q)q.hasOwnProperty(p)&&(s=q[p],c[l][p](s));c[l].enhanceTextfield({prompt:r[m+"Prompt"]})}submit=function(){var e=[],b;for(b=0;b<a;b++)e[b]=c[b].submit().val();
28  
-f.isValid()&&(h.submit.apply(this,e),n.dialog("close"))};j=d(n,c,{Create:submit,Update:submit,Remove:function(){h.remove();n.dialog("close")},Cancel:function(){n.dialog("close")}});return function(e){j.selectButtons(e);return j}}var h;g.fn.isValid.init();var r={linkTitle:"Link",insertImageTitle:"Image",uri:"Link",uriPrompt:"Enter or select link",title:"Title",titlePrompt:"Enter title",imageUri:"Image Source"};ME.dialog={link:k("link",[["title",{required:!0}],["uri",{combobox:{key:"uri"},required:!0}]]),
29  
-insertImage:k("insertImage",[["imageUri",{combobox:{key:"imageUri"},required:!0}],["title"],["uri",{combobox:{key:"uri"}}]])}})(jQuery);
30  
-ME.addMode("textile",function(){function g(c,a){var e=c.getParagraphs(),b=e.length;for(i=0;i<b;i++)e[i]=a(e[i]);c.setParagraphs(e)}function d(c,a){var e=c.length,b,o,v;for(b=0;b<e;b++)o=c[b],/^\s*$/.test(o)||(o=o.match(/^((?:\w+\. )?(?: *[\*#] )?)\s*(.*)/),v=o[1],o=o[2],a(b,v,o))}function k(c,a,e){var b=c.getSelection(a).split("\n");d(b,function(c,a,f){b[c]=e(a,f)});c.replaceSelection(b.join("\n"))}function h(c){var a=c.getSelection("\n").split("\n").slice(0,1);c.selectionEnd=c.selectionStart+a[0].length;
31  
-d(a,function(e,b,o){c.selectionStart+=b.length;a[e]=o});return a[0]}function r(c,a){g(c,function(e){var b,c,d=[];if(/^\w+\([^)]+\)\./.test(e)){b=jQuery.trim(e.slice(e.indexOf("(")+1,e.indexOf(")"))).split(/\s+/);c=b.length;for(i=0;i<c;i++)b[i]!="right"&&b[i]!="left"&&b[i]!="center"&&d.push(b[i]);d.push(a);return e.replace(/^(\w+)[^.]+.\s+/,"$1("+d.join(" ")+"). ")}else return/^\w+\./.test(e)?e.replace(/^(\w+)\.\s*/,"$1("+a+"). "):"p("+a+"). "+e})}function u(c,a){var e=a.exec(n);if(a.lastIndex!==0){for(;a.lastIndex<
32  
-j;)e=a.exec(n);c.selectionStart=a.lastIndex-e[0].length;c.selectionEnd=a.lastIndex;return e}}function t(c,a,e){k(c,"\n",function(b,c){/ on$/.test(a.className)||(c=e+" "+c);return c})}var n,j,l,m,q,p={},s=jQuery,a={ul:"*",ol:"#"};regexpes={"*":[/^(\w+\. )?\s*\*/,/\*([\.]*)$/],_:[/^(\w+\. )?\s*_/,/_([\.]*)$/]};return{name:"Textile Mode",items:{"default":{clicked:function(c,a,e){var b,o=this;k(a," ",function(c,d){/ on$/.test(e.className)?(d=(b=d.match(regexpes[o.delimiter][0]))?(b[1]||"")+d.slice(b[0].length):
33  
-o.delimiter+a.extendLeftSelection(/[ .]+/)+d,(b=d.match(regexpes[o.delimiter][1]))?d=d.slice(0,-b[0].length)+(b[1]||""):d+=a.extendRightSelection(/ +/)+o.delimiter):d=s.trim(o.delimiter+d)+o.delimiter;return c+d})}},bold:{delimiter:"*"},italic:{delimiter:"_"},alignLeft:{clicked:function(c,a){r(a,"left")}},alignRight:{clicked:function(c,a){r(a,"right")}},alignCenter:{clicked:function(c,a){r(a,"center")}},unorderedList:{clicked:function(c,a,e){t(a,e,"*")}},orderedList:{clicked:function(c,a,e){t(a,e,
34  
-"#")}},link:{clicked:function(a,d,e){var b,o,v;/ on$/.test(e.className)?(e=ME.dialog.link(["Update","Remove","Cancel"]),o=p.a.attributes.href,v=u(d,RegExp('"([^"]*)":'+o,"g")),b=v[1],e.val("input.uri",o)):(e=ME.dialog.link(["Create","Cancel"]),b=h(d));/^\s*$/.test(b)||e.val(".title",b);e.dialog("open",{submit:function(b,e){d.replaceSelection('"'+b+'":'+e)},remove:function(){d.replaceSelection(v[1])},close:function(){d.updatePreview();a.checkState()}})}},insertImage:{clicked:function(a,d,e){var b,
35  
-o;if(/ on$/.test(e.className)){e=ME.dialog.insertImage(["Update","Remove","Cancel"]);o=p.img.attributes.src;u(d,RegExp("!"+o+"(\\([^\\)]*\\))?!(:[^ \n]*)?","g"));if(p.a)b=p.a.attributes.href;e.val("input.uri",b);e.val("input.imageUri",o);e.val("input.title",p.img.attributes.title)}else e=ME.dialog.insertImage(["Create","Cancel"]),h(d);e.dialog("open",{submit:function(b,e,a){e&&!/^\s*$/.test(e)&&(b=b+"("+e+")");b="!"+b+"!";a&&!/^\s*$/.test(a)&&(b=b+":"+a);d.replaceSelection(b)},remove:function(){d.replaceSelection("")},
36  
-close:function(){d.updatePreview();a.checkState()}})}},formatBlock:{clicked:function(a,d,e){g(d,function(b){return/^\w+(\([\w ]+\))?\./.test(b)?b.replace(/^\w+(\([\w ]+\))?\.\s+/,e.value+"$1. "):/^[\*#] /.test(b)?b:e.value+". "+b})}}},updatePreview:function(){this.htmlDiv.html(textileCompiler.compile(this.textArea.val()))},toText:function(a){function d(a,b){var c,f,h={b:[/<(?:b|strong)>((.|[\r\n])*?)<\/(?:b|strong)>/gi,"*"],i:[/<(?:i|em)>((.|[\r\n])*?)<\/(?:i|em)>/gi,"_"],del:[/<(?:strike|del)>((.|[\r\n])*?)<\/(?:strike|del)>/gi,
37  
-"-"],u:[/<(?:u|ins)>((.|[\r\n])*?)<\/(?:u|ins)>/gi,"+"]};for(c=a.length;c;c--)f=h[a[c-1]],b(f[0],f[1])}a||(a=this.htmlDiv.html());a=a.replace(/\s*<(ul|ol)>((.|[\r\n])*?)<\/\1>\s*/gi,function(a,b,c){a=b=="ul"?"*":"#";d(["b","i","u","del"],function(a,b){c=c.replace(a,b+"$1"+b)});return c.replace(/\s*<li>((.|[\r\n])*?)<\/li>\s*/gi,a+" $1\n")+"\n"});a=a.replace(/ *<(p|h[1-4])([^>]*)>((.|[\r\n])*?)<\/\1>\s*/gi,function(a,b,c,h){a="";(c=c.match(/class=\"([^"]*)/))?a=b+"("+c[1]+"). ":b!="p"&&(a=b+". ");
38  
-d(["b","i","u","del"],function(a,b){h=h.replace(a,function(a,e){return b+e.replace(/<br ?\/?>\s*/gi,b+"\n"+b)+b})});return a+h.replace(/<br ?\/?>\s*/gi,"\n")+"\n\n"});a=a.replace(/<img[^>]*>/gi,function(a){var b=s(a);a=b.attr("src");(b=b.attr("title"))&&!/^\s*$/.test(b)&&(a=a+"("+b+")");return"!"+a+"!"});a=a.replace(/<a href="([^\"]*)">((.|[\r\n])*?)<\/a>/gi,function(a,b,c){return/^\s*![^!]+!\s*$/.test(c)?s.trim(c)+":"+b:'"'+c+'":'+b});a=a.replace(/\s*<code[^>]*>((.|[\r\n])*?)<\/code>\s*/gi," @$1@ ");
39  
-a=a.replace(/(\r\n|\n){3,}/g,"\n\n");a=a.replace(/&nbsp;/g," ");return a=a.replace(/^[\r\n]+|[\r\n]+$/g,"")},getSelectionStates:function(){var a=this.getExtendedSelection();trace=textileCompiler.trace(a,j-l,selectionEnd-l);return this.buildStateObject(trace,p={})},getExtendedSelection:function(){var a;a=0;j=this.textArea[0].selectionStart;selectionEnd=this.textArea[0].selectionEnd;n=this.textArea.val();l=0;for(m=-1;(a=n.indexOf("\n\n",a)+2)!==1;)if(j>a)l=a;else if(selectionEnd<a){m=a-2;break}a=m===
40  
--1?n.slice(l):n.slice(l,m);q=a.length;return a},getParagraphs:function(){return this.getExtendedSelection().split(/\n\n+/)},setParagraphs:function(a){a=a.join("\n\n");m===-1?this.textArea.val(n.slice(0,l)+a):this.textArea.val(n.slice(0,l)+a+n.slice(m));this.moveCaret(a.length-q)},moveCaret:function(a){Math.abs(j-l)>Math.abs(a)?j+=a:j=l;this.textArea.focus();this.textArea[0].setSelectionRange(j,j)},pressed:function(c){switch(c){case 13:var d;if((c=p.list)&&/(u|o)l/i.test(c.tag))this.getSelection(),
41  
-d=this.holdShift?" <br> ":"\n"+a[c.tag]+" ",this.replaceSelection(d,!1),d=!1;return d;default:this.prototype.pressed.apply(this,[c])}}}});
42  
-(function(){function g(h){h=h.exec(k);var g,u;if(h)return g=/^\s*/.exec(h[0])[0].length,u=h[0].length,g&&d.advancePointer(g,!0),u-g&&d.advancePointer(u-g),k=k.slice(u),h||!0}var d=function(){function d(a,b){var e=["class"],c;w[a]&&(e=e.concat(w[a]));for(c=e.length;c--;)b(e[c])}function g(a){var b=!0,e=m==-1,c,o,f;if(e)/(o|u)l/.test(l[0].tag)?(/(o|u)l/.test(a.tag)&&a.tag!=l[0].tag&&(a={tag:"p"}),c=l[0]=a):c=l[0];else{o=m+1;for(f=l.length;o<f;o++)if(l[o].tag===a.tag){c=l[o];l[o]=l[m+1];l[m+1]=c;break}}c&&
43  
-c.attributes&&d(c.tag,function(e){c.attributes[e]!==a.attributes[e]&&(b=!1,delete c.attributes[e])});return c&&(e||b)}function k(a){this.tag=a.tag;this.attributes=a.attributes}function t(a){var b="";for(attr in a.attributes)a.attributes.hasOwnProperty(attr)&&(b+=" "+attr+'="'+a.attributes[attr]+'"');return"<"+a.tag+b+">"}function n(a){var b;for(b=j.length;b--;)if(j[b].tag===a)return b}var j,l,m,q,p,s,a,c,f,e,b=!1,o,v=["li"],w={img:["title","src"],a:["href"]};return{init:function(){j=[{content:""}]},
44  
-initTrace:function(b,e,d){l=[];f=void 0;s=0;a=b;c=e;o=d},finalizeTrace:function(){f&&(f=e=!1)},advancePointer:function(b,d){s+=b;if(f===void 0&&(s>a||s==o)){var h=j.length,g,w=0;q=f=!0;for(g=1;g<h;g++)v.indexOf(j[g].tag)==-1?l[g-1-w]=new k(j[g]):w+=1;m=l.length-1}f&&s>c&&(e||d?f=e=!1:e=!0)},pushTag:function(a,e){var c={tag:a,attributes:e||{},content:""};j.push(c);f&&v.indexOf(a)==-1&&(q?(l[m+1]=new k(c),m+=1):l[m+1]&&(g(c)?m+=1:b=!0))},closeTag:function(a){var e,c;a?(c=n(a),e=j.splice(c,1)[0]):e=
45  
-j.pop();f&&v.indexOf(a)==-1&&(q=!1,b&&(l=l.slice(0,m+1),b=!1),l[m].tag===e.tag&&(m-=1),p=!0);this.pushString(t(e)+e.content,j[c-1]);this.pushString("</"+e.tag+">");p=!1},popLineEnd:function(){for(var a=!1,b={b:"*",i:"_"},e;"a,i,b,li".indexOf(j[j.length-1].tag)!=-1;)"li"===j[j.length-1].tag?(this.closeTag(),a=!0):(e=j.pop(),this.pushString(b[e.tag]+e.content));return a},popParagraphEnd:function(){for(;j.length>1;)this.closeTag()},pushString:function(a,b){b||(b=j[j.length-1]);b.content+=a;/^([ ]+|<br\/>)?$/.test(a)||
46  
-(q&&(q=!1),f&&!p&&l[m+1]&&(l=l.slice(0,m+1)))},isOpen:function(a){return typeof n(a)==="number"},blockTagIsOpen:function(){return!!j[1]},closeBlockTag:function(){for(;j[1];)this.closeTag()},getTrace:function(){return l},toHtml:function(){return j[0].content}}}(),k;textileCompiler={compile:function(h){d.init();for(k=h;!/^\s*$/.test(k);){if(h=g(/^\s*(h\d|p|bq)(\(([^#\)]*)(#[^\)]+)?\))?\. /)){var r={};h[3]&&(r["class"]=h[3]);if(h[4])r.id=h[4];d.pushTag(h[1],r)}for(;!g(/^\n/)&&!/^\s*$/.test(k);){h=void 0;
47  
-if(g(/^ *\* /))d.isOpen("ul")||(d.closeBlockTag(),d.pushTag("ul")),d.pushTag("li");else if(g(/^ *# /))d.isOpen("ol")||(d.closeBlockTag(),d.pushTag("ol")),d.pushTag("li");else{for(;d.isOpen("ul")||d.isOpen("ol");)d.closeTag();d.blockTagIsOpen()||d.pushTag("p")}h=g(/^ */);d.pushString(h[0]);for(h=h=void 0;;)if(g(/^_(?=[^ \n]+)/))d.isOpen("i")?d.pushString("_"):d.pushTag("i");else if(g(/^\*(?=[^ \n]+)/))d.isOpen("b")?d.pushString("*"):d.pushTag("b");else if(h=g(/^([^ \n]+)_( +|(?=\n|$))/))d.isOpen("i")?
48  
-(d.pushString(h[1]),d.closeTag("i"),d.pushString(h[2])):d.pushString(h[1]+"_"+h[2]);else if(h=g(/^([^ \n]+)\*( +|(?=\n|$))/))d.isOpen("b")?(d.pushString(h[1]),d.closeTag("b"),d.pushString(h[2])):d.pushString(h[1]+"*"+h[2]);else if(h=g(/^( *)"([^"]*)":([^ \n]+)/))d.pushString(h[1]),d.pushTag("a",{href:h[3]}),d.pushString(h[2]),d.closeTag();else if(h=g(/^( *)!([^!\(]+)(\(([^\)]*)\))?!(:([^ \n]+))?/)){d.pushString(h[1]);h[6]&&d.pushTag("a",{href:h[6]});r={src:h[2]};if(h[4])r.title=h[4];d.pushTag("img",
49  
-r);d.closeTag();h[6]&&d.closeTag()}else if(h=g(/^([^ \n]+)/))d.pushString(h[1]);else if(h=g(/^( +)/))d.pushString(h[1]);else{g(/^\n/);h=d.popLineEnd();!h&&!/^\s*(\n|$|[\*#] )/.test(k)&&d.pushString("<br/>");break}}d.popParagraphEnd()}return d.toHtml()},trace:function(h,g,k){d.initTrace(g,k,h.length);this.compile(h);d.finalizeTrace();return d.getTrace()}}})();
50  
-ME.addMode("wysiwyg",function(){function g(a){return a.parent().is(".preview")?a:a.parentsUntil(".preview").last()}function d(){var a,b,d=-1;a=g(jQuery(c.getRangeAt(0).startContainer));b=g(jQuery(c.getRangeAt(0).endContainer))[0];return a[0]!==b?a.nextAll().filter(function(a){this==b&&(d=a);if(d===-1||d===a)return!0}).add(a):a}function k(a){d().removeClass("left").removeClass("right").removeClass("center").addClass(a)}function h(a,b){var d=a[0],h;a.length>1?(h=a[a.length-1],f.setStart(d,0),f.setEnd(h,
51  
-h.childNodes.length)):f.selectNodeContents(d);b!==void 0&&f.collapse(b);c.removeAllRanges();c.addRange(f)}function r(e,b,c,d){/ on$/.test(c.className)?u(e,b):(c=b.getSelection("br"),d=a("<"+d+">"),n(d,c.firstChild),j(b.leftBorder,d),j(b.rightBorder,d),b.replaceSelection(e,d))}function u(e,b){contents=b.getSelection("li");lines=[];l(lines,contents.firstChild);$p=a("<p>").html(lines.join("<br>"));b.replaceSelection(e,$p)}function t(a,b,c){this.nextProperty=c;this.ancestors=a.parentsUntil(".preview");
52  
-this.block=this.ancestors[this.ancestors.length-1]||a[0];for(this.borderNode=this.ancestors[this.ancestors.length-2]||a[0];this.borderNode;){this.node=this.borderNode;if(!b||this.borderNode.nodeName.toLowerCase()===b)break;this.borderNode=this.borderNode[c]}this.safeBlock=this.borderNode?this.block:this.block[c]}function n(e,b){function c(){/^\s*$/.test(d.textContent)||e.append(d);d=document.createElement("li")}for(var d=document.createElement("li"),h;b!==null;)h=b.nextSibling,/br/i.test(b.nodeName)?
53  
-c():/(p|h\d)/i.test(b.nodeName)?(c(),n(e,b.firstChild)):/(o|u)l/i.test(b.nodeName)?(c(),a(b).children().appendTo(e)):/li/i.test(b.nodeName)?(c(),e.append(b)):d.appendChild(b),b=h;c()}function j(e,b){var c;if(e.safeBlock&&/ul/i.test(e.safeBlock.nodeName))next=e.safeBlock[e.nextProperty],c=a(e.safeBlock).remove().children(),e.nextProperty==="previousSibling"?c.prependTo(b):c.appendTo(b),e.safeBlock=next}function l(a,b){for(;b;)/(o|u)l/i.test(b.nodeName)?l(a,b.firstChild):/li/i.test(b.nodeName)&&a.push(b.innerHTML),
54  
-b=b.nextSibling}function m(a){function b(a,b){for(;!f[a];)f=f.parentNode;if((f=f[a])&&!/br|h\d|p/i.test(f.nodeName))return h([f],b),!1}var d=c.getRangeAt(0),f,g;if(d.collapsed&&(f=d.startContainer,f.nodeType==3))if(g=f.nodeValue,d.startOffset+a===0&&/^ /.test(g))return b("previousSibling",!1);else if(d.startOffset+a===f.length&&/ $/.test(g))return b("nextSibling",!0)}function q(e,b){if(p(b,46)===!1)return!1;if(!a.browser.webkit)return!0;var d,f=s.block;d=s.list;f=(d||f).nextSibling;var h=c.getRangeAt(0),
55  
-g=h.startContainer;if(!h.collapsed||!f||h.startOffset!==g.length)return!0;for(;g.parentNode!==b[0];){if(g.nextSibling)return!0;g=g.parentNode}if(d)g=g.lastChild;if(/(u|o)l/i.test(f.nodeName))f=f.firstChild;f=a(f);d=f.contents();a(g).append(d);f.remove();return!1}function p(e,b,d){var f=c.getRangeAt(0);if(!a.browser.mozilla||d||f.collapsed||ME.util.isNeutralKey(b))return!0;d=f.extractContents();if(e.is(":empty")||/^ *$/.test(e.text()))return d=document.createElement(d.childNodes[0].nodeName),e.html(d),
56  
-h([d]),/^8|13|46$/.test(""+b)?!1:!0}var s={},a=jQuery,c=getSelection(),f=document.createRange();return{name:"Preview Mode",items:{"default":{clicked:function(){document.execCommand(this.name,!1,null)}},bold:{tag:"b"},italic:{tag:"i"},alignLeft:{clicked:function(){k("left")}},alignRight:{clicked:function(){k("right")}},alignCenter:{clicked:function(){k("center")}},unorderedList:{clicked:function(a,b,c){r(a,b,c,"ul")}},orderedList:{clicked:function(a,b,c){r(a,b,c,"ol")}},link:{clicked:function(e,b,
57  
-d){var f,h,g=c.getRangeAt(0);b={remove:function(){var a=f.text();f.replaceWith(a)},close:function(){e.htmlDiv.focus();e.checkState()}};/ on$/.test(d.className)?(f=a(s.a),d=ME.dialog.link(["Update","Remove","Cancel"]),b.submit=function(a,b){f.attr("href",b).text(a);g.selectNodeContents(f[0]);c.removeAllRanges();c.addRange(g)},h=f.text(),d.val("input.uri",f.attr("href"))):(d=ME.dialog.link(["Create","Cancel"]),b.submit=function(b,e){var d=a('<a href="'+e+'">'+b+"</a>")[0];g.deleteContents();g.insertNode(d);
58  
-g.selectNodeContents(d);c.removeAllRanges();c.addRange(g)},h=g.toString());/^\s*$/.test(h)||d.val(".title",h);d.dialog("open",b)}},insertImage:{clicked:function(c,b,d){var f=window.getSelection(),h=f.getRangeAt(0);/ on$/.test(d.className)?(b=ME.dialog.insertImage(["Update","Remove","Cancel"]),s.a&&(d=a(s.a),b.val("input.uri",d.attr("href")),h.selectNode(s.a)),imageNode=a(s.img),b.val("input.imageUri",imageNode.attr("src")),b.val("input.title",imageNode.attr("title"))):b=ME.dialog.insertImage(["Create",
59  
-"Cancel"]);b.dialog("open",{submit:function(b,c,d){var e=b=a('<img src="'+b+'"/>');/^\s*$/.test(c)||b.attr({alt:c,title:c});/^\s*$/.test(d)||(e=a('<a href="'+d+'"/>').append(b));h.deleteContents();h.insertNode(e[0]);h.selectNode(b[0]);f.removeAllRanges();f.addRange(h)},remove:function(){imageNode.remove()},close:function(){c.htmlDiv.focus();c.checkState()}})}},formatBlock:{clicked:function(c,b,f){var g,j=[],l;d().replaceWith(function(){l=/(u|o)l/i.test(this.nodeName)?this.nodeName:f.value;g=a("<"+
60  
-l+">").addClass(this.className).append(this.childNodes);j.push(g[0]);return g});h(j)}}},getSelection:function(d){var b=c.getRangeAt(0);this.collapsed=b.collapsed;this.leftBorder=new t(jQuery(c.getRangeAt(0).startContainer),d,"previousSibling");this.rightBorder=new t(jQuery(c.getRangeAt(0).endContainer),d,"nextSibling");b.setStartBefore(this.leftBorder.node);b.setEndAfter(this.rightBorder.node);this.rightBorder.borderNode&&a(this.rightBorder.borderNode).nextAll().appendTo("<"+this.rightBorder.block.nodeName+
61  
-">").parent().insertAfter(this.rightBorder.block);return b.extractContents()},replaceSelection:function(c,b){this.leftBorder.safeBlock?b.insertAfter(this.leftBorder.safeBlock):c.htmlDiv.prepend(b);this.collapsed?h(b,!0):h(b);/^\s*$/.test(this.leftBorder.block.textContent)&&a(this.leftBorder.block).remove();/^\s*$/.test(this.rightBorder.block.textContent)&&a(this.rightBorder.block).remove()},afterActivation:function(){this.textArea.parent().hide();this.htmlDiv.attr("contentEditable",!0);a.browser.mozilla&&
62  
-document.execCommand("styleWithCSS",null,!1)},getSelectionStates:function(){function d(a,b){if(b){var c=b.nodeName,e=a[0].nodeName;c!="#text"&&e!="#text"&&e!=c&&(a=a.find(b.nodeName.toLowerCase()))}return a.parentsUntil(".preview").add(a)}if(!a(document.activeElement).is(".preview"))return{};var b=[],f;f=c.getRangeAt(0).cloneContents().firstChild;b=d(jQuery(c.getRangeAt(0).startContainer),f);f=d(jQuery(c.getRangeAt(0).endContainer),f);/(u|o)l/i.test(b[0].nodeName)&&b[0].nodeName!==f[0].nodeName&&
63  
-(b=b.toArray(),b[0]=a("<p>")[0]);return this.buildStateObject(b,s={})},clicked:function(){m(0)},pressed:function(d){this.prototype.pressed.apply(this,[d]);switch(d){case 13:var b;var f=this.htmlDiv;if(p(f,13)===!1)b=!1;else{d=!0;var g,j,l,k=s.block;if(/h[1-5]/i.test(k.nodeName)){j=c.getRangeAt(0);for(g=l=j.endContainer;g.parentNode!==f[0];){if(g.nextSibling){d=!1;break}g=g.parentNode}d&&j.endOffset===l.textContent.length&&(g=a("<p>").insertAfter(k),h(g),b=!1)}}return b;case 8:a:if(b=this.htmlDiv,
64  
-d=this.editor,p(b,8)===!1)f=!1;else{g=!0;l=s.block;j=s.list;l=(j||l).previousSibling;var n=c.getRangeAt(0);k=n.startContainer;if(!n.collapsed||!l||n.startOffset!==0)f=!0;else{for(;k.parentNode!==b[0];){if(k.previousSibling){g=!1;if(/li/i.test(k.nodeName))f=!0;else{f=!0;break a}break}k=k.parentNode}if(g){if(j)k=k.firstChild;k=a(k);f=k.contents();a(l).append(f);k.remove();h([f[0]],!0)}else j&&f&&u(d,this);f=!1}}return f;case 46:return q(this,this.htmlDiv,this.editor);case 37:return m(-1);case 39:return m(1);
65  
-default:return p(this.htmlDiv,d,this.holdNeutralKey)}},toText:function(){return this.editor.getDataMode().toText()},toHTML:function(){return this.htmlDiv.html()}}});
  1
+(function(){var g={};ME={addMode:function(e,c){c.id=e;c.supportedItems=ME.Toolbar.getSupportedItems(e,c.name,c.items);return g[e]=new ME.Mode(c)},hasMode:function(e){return!!g[e]},getMode:function(e){var c=g[e];return c?c:this.addMode(e,{name:e},true)},options:{},setOptions:function(e){this.options=e}}})(jQuery);(function(){var g={};ME.t10n=function(e){return g[e]};ME.t10n.load=function(e){g=e}})();
  2
+ME.t10n.load({noticeTitle:"Notice",noticeMissingToHTML:"The old mode could not convert to HTML. You will have to convert the markup manually.",noticeMissingToText:"This mode can not convert HTML to your markup. You will have to convert the markup manually",noticeMissingDatamode:"Datamode not found. Please specify a valid datamode",linkTitle:"Link",insertImageTitle:"Image",uri:"Link",uriPrompt:"Enter or select link",title:"Title",titlePrompt:"Enter title",imageUri:"Image Source",p:"Paragraph",h1:"Heading 1",
  3
+h2:"Heading 2",h3:"Heading 3",bold:"Bold",italic:"Italic",alignLeft:"align left",alignCenter:"align center",alignRight:"align right",unorderedList:"unordered list",orderedList:"ordered list",link:"link",insertImage:"image",save:"save",wysiwyg:"edit preview directly",close:"close",changeDataMode:"change the markup format",formatBlock:"change paragraph format",errorText:"{label} is a required field.",emailErrorText:"Please enter a valid {label}"});
  4
+(function(g,e){function c(f){this.$form=f;this.inputs=f.find(":input.required")}function a(f,a,b){var j=f.data(b);j||(j=new a(f),f.data(b,j));return j}function d(f){this.$element=f;this.$tip=g('<div class="error-tip"></div>').html('<div class="arrow"></div><div class="inner"></div>').prependTo(document.body)}var k;c.prototype={check:function(){var f=true;this.reset(true);this.inputs.each(function(){var a=g(this),b=g.trim(a.val()),j=a.parent().prev().text(),h;b===""?(h=e("errorText")||k.errorText,
  5
+f=false):a.hasClass("email")&&!/^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/.test(b)&&(h=e("emailErrorText")||k.emailErrorText,f=false);h&&(h=h.replace("{label}",j),a.parent().addClass(k.errorClass).error("show",h))});return f},reset:function(f){return this.inputs.each(function(){g(this).parent().removeClass(k.errorClass).error("hide",f)})}};g.fn.isValid=function(f,d){var b=true;this.each(function(){var j=a(g(this),c,"isValid");j[f]||(f="check");b=j[f](d)?b:false});return b};
  6
+g.fn.isValid.init=function(f){k=g.extend({},g.fn.isValid.defaults,f)};g.fn.isValid.defaults={errorClass:"error",errorText:"{label} is a required field.",emailErrorText:"Please enter a valid {label}"};d.prototype={opacity:0.8,show:function(f){var a=this.$tip;this.hidden=false;a.find(".inner").text(f);a.css({top:0,left:0,visibility:"hidden",display:"block"});f=g.extend({},this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight});a.css({top:f.top+f.height/2-a[0].offsetHeight/
  7
+2,left:f.left+f.width});a.stop().css({opacity:0,display:"block",visibility:"visible"}).animate({opacity:this.opacity})},hide:function(a){var c=this;if(!this.hidden)a?this.$tip.stop().fadeOut(function(){c.hidden=true}):(this.$tip.hide(),this.hidden=true)}};g.fn.error=function(f,c){return this.each(function(){a(g(this),d,"error")[f](c)})}})(jQuery,ME.t10n);
  8
+(function(g){neutralKeys="9.16.17.18.20.27.33.34.35.36.37.38.39.40.45.91.93.93";g.util={isNeutralKey:function(e){return neutralKeys.indexOf(""+e)!=-1},isRemovalKey:function(e){return e==46||e==8}}})(ME);
  9
+(function(g,e){var c=e.util.isNeutralKey,a=e.util.isRemovalKey;g.fn.enhanceTextfield=function(d){d=d||{};return this.each(function(){function e(){b.css("color","grey").data("hasPrompt",true).val(d.prompt)}function f(){b.css("color",q).data("hasPrompt",false).val("")}function m(){b.val()&&b.val()!==d.prompt?(b.css("color",q),j.show()):(e(),j.hide(),h=false)}var b=g(this),j,h,q=b.css("color");b.is("input")&&(j=g("<span>x</span>").click(function(){f();b.focus();j.hide();h=false}),$p=b.wrap('<span class="clearButton">').focus(function(){!h&&
  10
+b.val()===d.prompt&&f();b.parent().addClass("focus")}).focusout(function(){!h&&!b.val()&&e();b.parent().removeClass("focus")}).keydown(function(p){!c(p.which)&&(!h||a(p.which))&&b.val()===d.prompt&&f()}).keyup(function(b){!h&&!c(b.which)&&!a(b.which)&&(h=true,m())}).bind("blur change",function(){m()}).submit(function(){b.val()===d.prompt&&f()}).parent().append(j),$p.addClass("ui-corner-all"))})}})(jQuery,ME);
  11
+(function(g,e){g.fn.required=function(c){return this.each(function(){c?g(this).addClass("required"):g(this).removeClass("required")})};g.widget("ui.combobox",{_create:function(){var c=this.element,a=this.options.key,d=g.ui.autocomplete.escapeRegex;c.autocomplete({delay:0,minLength:0,source:function(c,f){var m=RegExp(d(c.term),"i"),b=e.options[a]||[],j=b.length,h=[],q,p;if(c.term)for(p=0;p<j;p++)q=b[p],m.test(q)&&h.push({label:q.replace(RegExp("(?![^&;]+;)(?!<[^<>]*)("+d(c.term)+")(?![^<>]*>)(?![^&;]+;)",
  12
+"gi"),"<strong>$1</strong>"),value:q});else h=b;f(h)},focus:function(a,f){c.val(f.item.value).change()}}).addClass("ui-corner-right short");c.data("autocomplete")._renderItem=function(a,f){return g("<li></li>").data("item.autocomplete",f).append("<a>"+f.label+"</a>").appendTo(a)};this.button=g("<button type='button'>&nbsp;</button>").attr("tabIndex",-1).attr("title","Show All Items").button({icons:{primary:"ui-icon-triangle-1-s"},text:false}).addClass("ui-corner-right ui-button-icon").click(function(){c.autocomplete("widget").is(":visible")?
  13
+c.autocomplete("close"):(c.data("hasPrompt")&&c.val(""),c.autocomplete("search",""),c.focus())}).appendTo(c.parent())},destroy:function(){this.button.remove();g.Widget.prototype.destroy.call(this)}})})(jQuery,ME);
  14
+(function(g,e){function c(b,a,h){this.dialogNode=b;this.availableButtons=a;this.textNode=h}function a(b){var a=b.append("<p>");b.dialog({autoOpen:false,width:600,modal:true,close:function(){m&&m.close&&m.close()}});return new c(b,{Ok:function(){m&&m.submit&&m.submit();b.dialog("close")},Cancel:function(){m&&m.cancel&&m.cancel();b.dialog("close")}},a)}function d(b,a){var h=a.length,f=b.append("<form>"),p=k(f,a);submit=function(){var a=[],c;for(c=0;c<h;c++)a[c]=p[c].submit().val();f.isValid()&&(m.submit.apply(this,
  15
+a),b.dialog("close"))};b.dialog({autoOpen:false,width:600,modal:true,close:function(){f.isValid("reset");m.close&&m.close();for(i=0;i<h;i++)p[i].val("").removeAttr("checked").removeAttr("selected")},open:function(){for(i=0;i<h;i++)p[i].change();p[0][0].setSelectionRange(0,0)}});return new c(b,{Create:submit,Update:submit,Remove:function(){m.remove();b.dialog("close")},Cancel:function(){b.dialog("close")}})}function k(b,a){var h,f,p,c,d=[],k=a.length;for(c=0;c<k;c++)if(f=a[c][0],h=a[c][1],b.append('<label for="'+
  16
+f+'">'+e(f)+"</label>"),d[c]=g('<input type="text" class="'+f+'" name="'+f+'">').appendTo(b),d[c].enhanceTextfield({prompt:e(f+"Prompt")}),h)for(p in h)h.hasOwnProperty(p)&&(f=h[p],d[c][p](f));return d}function f(b,f){var h,c;h=g('<div id="'+b+'-dialog" title="'+e(b+"Title")+'">');c=f?d(h,f):a(h);return function(b,h){c.selectButtons(b);c.setText(h);return c}}var m;g.fn.isValid.init();c.prototype={dialog:function(b,a){a&&(m=a);this.dialogNode.dialog(b)},find:function(b){return this.dialogNode.find(b)},
  17
+selectButtons:function(b){for(var a={},h=b.length;h--;)a[b[h]]=this.availableButtons[b[h]];this.dialogNode.dialog("option","buttons",a)},setText:function(b){this.textNode&&this.textNode.html(b)},val:function(b,a){this.find(b).val(a)}};ME.dialog={link:f("link",[["title",{required:true}],["uri",{combobox:{key:"uri"},required:true}]]),insertImage:f("insertImage",[["imageUri",{combobox:{key:"imageUri"},required:true}],["title"],["uri",{combobox:{key:"uri"}}]]),notice:f("notice")}})(jQuery,ME.t10n);
  18
+(function(g){function e(a,c){if(ME.Editor.extractDataType(a,c))return true;else ME.dialog.notice(["Ok"],ME.t10n("noticeMissingDatamode")).dialog("open")}function c(c,d){if(e(c[0].className)){var b,j,h=g('<textarea class="'+c[0].className+'">');c.css("min-height",c.height());c.before(h);d=d||{};d.preview=c;b=a(h,d);(j=c.attr("src"))?g.get(j,{},function(a){h.val(a);b.checkState();b.currentMode.updatePreview(b)}):(b.currentMode.updateTextArea(b),b.changeMode("wysiwyg"))}}function a(a,c){if(e(a[0].className)){var b,
  19
+j={};g.extend(j,d,c);b=new ME.Editor(a,j);b.currentMode=b.getDataMode();a.hasClass("wysiwyg")?b.changeMode("wysiwyg"):b.currentMode.activate(b,function(){b.currentMode.afterActivation(b)});return b}}var d={},k={init:function(f){ME.settings=f;return this.each(function(d,b){var j=g(b);j.is("textarea")?a(j,f):c(j,f)})},close:function(){},prepare:function(a){return this.one("click",function(){g(this).markupEditor(a)})}};g.fn.markupEditor=function(a){var c=Array.prototype.slice.call(arguments,1);typeof a===
  20
+"object"&&c.push(a);k[a]||(a="init");return k[a].apply(this,c)}})(jQuery);
  21
+(function(g){ME.Mode=function c(a){g.extend(this,a);this.prototype=c.prototype};ME.Mode.prototype={pressed:function(c,a){if(a===16)ME.holdShift=true;if(ME.util.isNeutralKey(a))ME.holdNeutralKey=true},released:function(c,a){if(a===16)ME.holdShift=false;if(ME.util.isNeutralKey(a))ME.holdNeutralKey=false},clicked:g.noop,activate:function(c,a){c.preview.is(":empty")?this.updatePreview(c,a):this.updateTextArea(c,a);c.toolbar.loadModeToolbar(c)},updatePreview:function(c,a){var d;this.toHTML?(d=this.toHTML(c,
  22
+a),d!==void 0&&(c.preview.html(d||"<p>&nbsp;</p>"),a&&a())):a&&a()},updateTextArea:function(c,a){var d;this.toText&&(!c.oldMode||c.oldMode.toHTML)?(d=this.toText(c,a),d!==void 0&&(c.textArea.val(d),a&&a())):a&&a()},afterActivation:function(c){var a=c.preview;c.textArea.parent().show().find(":first-child").focus()[0].setSelectionRange(0,0);c.dataType=this.id;a.attr("contentEditable",false);this.toHTML?a.show():a.hide()},getStates:function(c){var a=this.getSelectionStates(c);this.id==="wysiwyg"?(a.wysiwyg=
  23
+true,a.changeDataMode=c.dataType):a.changeDataMode=this.id;return a},getSelectionStates:function(){return{}},buildStateObject:function(c,a){for(var d,k=c.length,f={};k--;)switch(d=c[k],d.tag?d.tag:d.nodeName.toLowerCase()){case "a":a.a=d;f.link=true;break;case "img":a.img=d;f.insertImage=true;break;case "i":f.italic=true;break;case "b":f.bold=true;break;case "ol":f.orderedList=true;f.unorderedList=false;f.formatBlock="disable";f.alignLeft="disable";f.alignRight="disable";f.alignCenter="disable";a.list=
  24
+d;break;case "ul":f.orderedList=false;f.unorderedList=true;f.formatBlock="disable";f.alignLeft="disable";f.alignRight="disable";f.alignCenter="disable";a.list=d;break;case "li":break;default:f.formatBlock=d.tag?d.tag:d.nodeName.toLowerCase(),a.block=d}return f},atBeginningOfLine:function(c){return c.textArea.val()[c.selectionStart-1]==="\n"},getSelection:function(c,a){var d,k,f,g,b,j;b=c.textArea;var h=b.val();b.focus();c.initSelectionProperties(h);b=c.selectionEnd;j=c.selectionStart;if(a){k=a.indexOf("\n")===
  25
+-1?"\n":"\n\n";f=k.length;d=j-k.length;d=Math.max(h.lastIndexOf(a,d),h.lastIndexOf(k,d));g=d!==-1?d+f:0;d=h.indexOf(k,b);k=d===-1?h.slice(g):h.slice(g,d);d=0;do d=k.indexOf(a,d+f);while(d!==-1&&b>g+d);if(d===-1)d=k.length;f=g+d}c.boundaryStart=a?g:j;c.boundaryEnd=a?f:b;c.boundaryDistance=a?d:j-b;return h.slice(c.boundaryStart,c.boundaryEnd)},extendSelection:function(c,a){var d=this.getSelection(c,a);c.setSelectionRange(c.boundaryStart,c.boundaryEnd);return d},replaceSelection:function(c,a,d){var k=
  26
+c.textArea,f=c.selectionStart,g=c.selectionStart+a.length;k.val(k.val().slice(0,c.selectionStart)+a+k.val().slice(c.selectionEnd,k.val().length));d===true?g=f:d===false&&(f=g);c.setSelectionRange(f,g);k.focus()},extendRightSelection:function(c,a){var d,a=RegExp(a.source,"g");a.lastIndex=c.selectionEnd;if((d=a.exec(c.textArea.val()))&&a.lastIndex==c.selectionEnd+d[0].length)return c.selectionEnd+=d[0].length,d[0]},extendLeftSelection:function(c,a){var d;d=c.textArea.val().slice(0,c.selectionStart);
  27
+a=RegExp(a.source+"$");if(d=a.exec(d))return c.selectionStart-=d[0].length,d[0]}}})(jQuery);
  28
+(function(g,e){function c(){var b,a,h;if(!k)for(b=0,a=m.length;b<a;b++)(h=d[m[b]])&&(k+=h.getButton());return k}function a(b,a,h){var c=a.find(".changeDataMode");c.html(b.find("option").clone()).change(function(){var h=g(this).val();b.val()!==h&&b.val(h).change()});a=b.data("editorIDs")||[];a[0]||b.hide().change(function(){var b=g(this).val();c.val()!==b&&c.val(b).change()});a.push(h);b.data("editorIDs",a)}var d={},k="",f=[],m="bold,italic,alignLeft,alignCenter,alignRight,unorderedList,orderedList,link,insertImage,save,wysiwyg,close,changeDataMode,formatBlock".split(",");
  29
+ME.ToolbarButton=function(b,a,h){this.name=b;this.isAvailable=h;if(a)this.clicked=a,f.push(b)};ME.ToolbarButton.prototype={getButton:function(){return'<a href="#" class="'+this.name+'" title="'+e(this.name)+'"><span>'+this.name+"</span></a>"}};ME.ToolbarSelect=function(b,a,h,c){ME.ToolbarButton.apply(this,[b,h,c]);this.options=a||[]};ME.ToolbarSelect.prototype={getButton:function(){var b='<select class="'+this.name+'" title="'+e(this.name)+'">',a=this.options.length,h;b.className=this.name;for(h=
  30
+0;h<a;h+=1)b+='<option value="'+this.options[h][0]+'">'+this.options[h][1]+"</option>";return b+"</select>"}};ME.Toolbar=function(b){var f=g('<div class="toolbar"></div>'),h=this,d=b.settings.select;this.div=f;f.html(c());d&&d[0]&&a(d,f,b.id);f.mouseup(function(a){target=a.target;if(/(a|span)/i.test(target.nodeName)){if(/span/i.test(target.nodeName))target=target.parentNode;if(target.disabled)return b.is("wysiwyg")?b.preview.focus():b.textArea.focus(),false;a=target.className;a=a.split(" ")[0];h.runAction(b,
  31
+a,target)}}).change(function(a){a=a.target;h.runAction(b,a.className,a);return false}).click(function(){return false})};ME.Toolbar.getSupportedItems=function(b,a,h){var c,p=f.slice();if(h)for(item in h)h.hasOwnProperty(item)&&item!=="default"&&(p.push(item),d[item]||(c=h[item].options?ME.ToolbarSelect:ME.ToolbarButton,d[item]=new c(item)),d[item][b]=g.extend({name:item},h["default"],h[item]));b!=="wysiwyg"&&d.changeDataMode.options.push([b,a]);return p};ME.Toolbar.prototype={loadModeToolbar:function(b){var a=
  32
+b.currentMode.supportedItems,h=this.visibleItems,c=[];this.div.children().each(function(){var f=this.className.split(" ")[0],e=d[f].isAvailable;a.indexOf(f)!=-1&&(!e||e(b))?((!h||h.indexOf(f)==-1)&&g(this).show(),c.push(f)):(!h||h.indexOf(f)!=-1)&&g(this).hide()});this.visibleItems=c},runAction:function(b,a,h){var a=d[a],c=b.currentMode;b.is("wysiwyg")&&b.preview.focus();(a[c.id]||a).clicked(b,h)||(b.checkState(),b.is("wysiwyg")||c.updatePreview(b))},setActive:function(b){b&&this.div.children().each(function(){var a=
  33
+this.className.split(" ")[0];if(b[a]=="disable")this.disabled=true,this.className=a+" disabled";else if(this.disabled=false,this.className=a,b[a]===true)this.className=a+" on";else if(b[a])this.value=b[a]})}};d.changeDataMode=new ME.ToolbarSelect("changeDataMode",[],function(b,a){b.changeDataMode(a.value);return true},function(b){return b.toolbar.div.find(".changeDataMode option").length>1});d.formatBlock=new ME.ToolbarSelect("formatBlock",[["p",e("p")],["h1",e("h1")],["h2",e("h2")],["h3",e("h3")]]);
  34
+d.save=new ME.ToolbarButton("save",function(b){b.synchronize();b.settings.save(b);return true},function(b){return b.settings.save});d.wysiwyg=new ME.ToolbarButton("wysiwyg",function(b){b.is("wysiwyg")?b.changeMode(b.dataType):b.changeMode("wysiwyg");return true},function(b){b=b.currentMode;return b.toHTML&&b.toText});d.close=new ME.ToolbarButton("close",function(b){b.close()},function(b){b=b.settings;return b.preview||b.closable})})(jQuery,ME.t10n);
  35
+(function(g,e){var c,a=[],d=0;ME.Editor=function(c,f){function e(a,h){a.keydown(function(a){if(h||b.is("wysiwyg"))return b.currentMode.pressed(b,a.keyCode)}).keyup(function(a){if(h||b.is("wysiwyg"))return b.currentMode.released(b,a.keyCode)}).mouseup(function(){if(h||b.is("wysiwyg"))return b.focus(),b.currentMode.clicked(b)})}var b=this,j=0,h=f.preview;a[d]=b;b.id=d;d++;this.setDataType(c.attr("class"));this.settings=f;if(this.dataType)this.textArea=c.bind("mouseup keyup",function(){b.checkState();
  36
+clearTimeout(j);j=setTimeout(function(){b.currentMode.updatePreview(b)},1E3)}),e(c,true),h?h.addClass("preview"):h=g('<div class="preview">'),this.preview=h.bind("mouseup keyup",function(){b.is("wysiwyg")&&b.checkState()}),e(this.preview),this.overlay=g('<div class="overlay"><div class="background"></div><div class="spinner"></div></div>'),this.toolbar=new ME.Toolbar(this),this.container=c.wrap('<div class="markupEditor">').parent().append(b.preview).append(this.overlay).prepend(this.toolbar.div),
  37
+c.wrap('<div class="textarea">')};ME.Editor.extractDataType=function(a){for(var c,d=a.split(/\s+/),a=0;a<d.length;a+=1)if(c=d[a],c!=="wysiwyg"&&ME.hasMode(c))return c};ME.Editor.prototype={changeMode:function(a,c){var d=this,b=ME.getMode(a),e=d.currentMode;this.warnIfNecessary(e,b,function(){d.beginModeChange();d.synchronize(function(){d.oldMode=e;d.currentMode=b;b.activate(d,function(){b.afterActivation(d);d.checkState();delete d.oldMode;d.finalizeModeChange(c)})})},c)},changeDataMode:function(a,
  38
+c){var d=this.is("wysiwyg"),b=ME.getMode(a);if(!a||a===this.currentMode.id)return false;d&&b.toText?(this.dataType=a,this.checkState(),this.syncEditors(c)):this.changeMode(a)},warnIfNecessary:function(a,c,d,b){var g=this;b||c.toText&&a.toHTML?d():(text=c.toText?"noticeMissingToHTML":"noticeMissingToText",dialogProxy=ME.dialog.notice(["Ok","Cancel"],e(text)),dialogProxy.dialog("open",{submit:function(){d&&d()},cancel:function(){g.toolbar.div.find(".changeDataMode").val(a.id)}}))},beginModeChange:function(){this.overlay.show()},
  39
+syncEditors:function(c){var d,e;e=this.settings.select;var b=this.currentMode.id;if(e&&!c){e=e.data("editorIDs")||[];for(c=e.length;--c>=0;)d=e[c],d!==this.id&&(d=a[d],b!==d.currentMode.id?d.changeMode(b,true):d.changeDataMode(this.dataType,true))}},finalizeModeChange:function(a){this.overlay.hide();this.syncEditors(a)},getDataMode:function(){return ME.getMode(this.dataType)},setDataType:function(a){this.dataType=ME.Editor.extractDataType(a)},initSelectionProperties:function(a){var c=this.textArea;
  40
+this.scrollPosition=c.scrollTop;this.selectionStart=c[0].selectionStart;c=c[0].selectionEnd;c!=this.selectionStart&&a[c-1]==="\n"&&(c-=1);this.selectionEnd=c},setSelectionRange:function(a,c){this.textArea[0].setSelectionRange(a,c);this.selectionStart=a;this.selectionEnd=c},synchronize:function(a){this.is("wysiwyg")?this.currentMode.updateTextArea(this,a):this.currentMode.updatePreview(this,a)},is:function(a){return this.currentMode.id===a},checkState:function(){this.toolbar.setActive(this.currentMode.getStates(this))},
  41
+focus:function(){c&&a[c].blur();c=this.id},blur:function(){},close:function(){var a=this.settings.preview||this.textArea;this.synchronize();this.container.replaceWith(a);a.removeClass("preview").unbind().attr("contentEditable",false).show().markupEditor("prepare",this.settings)}}})(jQuery,ME.t10n);
  42
+(function(){function g(a,c){var d,e=b.getParagraphs(a),f=e.length;for(d=0;d<f;d++)e[d]=c(e[d]);b.setParagraphs(a,e)}function e(a,b){var c=a.length,d,e,f;for(d=0;d<c;d++)e=a[d],/^\s*$/.test(e)||(e=e.match(/^((?:\w+\. )?(?: *[\*#] )?)\s*(.*)/),f=e[1],e=e[2],b(d,f,e))}function c(a,c,d){var f=b.extendSelection(a,c).split("\n");e(f,function(a,b,c){f[a]=d(b,c)});b.replaceSelection(a,f.join("\n"))}function a(a,c){var d=b.extendSelection(a,c).split("\n").slice(0,1);a.selectionEnd=a.selectionStart+d[0].length;
  43
+e(d,function(b,c,e){a.setSelectionRange(a.selectionStart+c.length,a.selectionEnd);d[b]=e});return d[0]}function d(a,b){g(a,function(a){var c,h,d=[];if(/^\w+\([^)]+\)\./.test(a)){c=jQuery.trim(a.slice(a.indexOf("(")+1,a.indexOf(")"))).split(/\s+/);h=c.length;for(i=0;i<h;i++)c[i]!="right"&&c[i]!="left"&&c[i]!="center"&&d.push(c[i]);d.push(b);return a.replace(/^(\w+)[^.]+.\s+/,"$1("+d.join(" ")+"). ")}else return/^\w+\./.test(a)?a.replace(/^(\w+)\.\s*/,"$1("+b+"). "):"p("+b+"). "+a})}function k(a,b){var c=
  44
+a.textArea.val(),d=b.exec(c);if(b.lastIndex!==0){for(;b.lastIndex<a.selectionStart;)d=b.exec(c);a.setSelectionRange(b.lastIndex-d[0].length,b.lastIndex);return d}}function f(a,b,d){c(a,"\n",function(a,c){/ on$/.test(b.className)||(c=d+" "+c);return c})}var m=jQuery,b,j={ul:"*",ol:"#"};b=ME.addMode("textile",{name:"Textile Mode",items:{"default":{clicked:function(a,d){var e,f=this;c(a," ",function(c,g){var h;/ on$/.test(d.className)?(h=(e=g.match(f.leftRegExp))?(e[1]||"")+g.slice(e[0].length):f.delimiter+
  45
+b.extendLeftSelection(a,/[ .]+/)+g,g=h,(e=g.match(f.rightRegExp))?g=g.slice(0,-e[0].length)+(e[1]||""):g+=b.extendRightSelection(a,/ +/)+f.delimiter):g=m.trim(f.delimiter+g)+f.delimiter;return c+g})}},bold:{delimiter:"*",leftRegExp:/^(\w+\. )?\s*\*/,rightRegExp:/\*([\.]*)$/},italic:{delimiter:"_",leftRegExp:/^(\w+\. )?\s*_/,rightRegExp:/_([\.]*)$/},alignLeft:{clicked:function(a){d(a,"left")}},alignRight:{clicked:function(a){d(a,"right")}},alignCenter:{clicked:function(a){d(a,"center")}},unorderedList:{clicked:function(a,
  46
+b){f(a,b,"*")}},orderedList:{clicked:function(a,b){f(a,b,"#")}},link:{clicked:function(c,d){var e,f,g,l;/ on$/.test(d.className)?(e=ME.dialog.link(["Update","Remove","Cancel"]),g=c.currentNodes.a.attributes.href,l=k(c,RegExp('"([^"]*)":'+g,"g")),f=l[1],e.val("input.uri",g)):(e=ME.dialog.link(["Create","Cancel"]),f=a(c," "));/^\s*$/.test(f)||e.val(".title",f);e.dialog("open",{submit:function(a,d){b.replaceSelection(c,'"'+a+'":'+d)},remove:function(){b.replaceSelection(c,l[1])},close:function(){b.updatePreview(c);
  47
+c.checkState()}})}},insertImage:{clicked:function(c,d){var e,f,g;if(/ on$/.test(d.className)){e=ME.dialog.insertImage(["Update","Remove","Cancel"]);g=c.currentNodes.img.attributes.src;k(c,RegExp("!"+g+"(\\([^\\)]*\\))?!(:[^ \n]*)?","g"));if(c.currentNodes.a)f=c.currentNodes.a.attributes.href;e.val("input.uri",f);e.val("input.imageUri",g);e.val("input.title",c.currentNodes.img.attributes.title)}else e=ME.dialog.insertImage(["Create","Cancel"]),a(c," ");e.dialog("open",{submit:function(a,d,e){d&&!/^\s*$/.test(d)&&
  48
+(a=a+"("+d+")");a="!"+a+"!";e&&!/^\s*$/.test(e)&&(a=a+":"+e);b.replaceSelection(c,a)},remove:function(){b.replaceSelection(c,"")},close:function(){b.updatePreview(c);c.checkState()}})}},formatBlock:{clicked:function(a,b){g(a,function(a){return/^\w+(\([\w ]+\))?\./.test(a)?a.replace(/^\w+(\([\w ]+\))?\.\s+/,b.value+"$1. "):/^[\*#] /.test(a)?a:b.value+". "+a})}}},toHTML:function(a){return textileCompiler.compile(a.textArea.val())},toText:function(a){function b(a,c){var d,e,h={b:[/(\s*)<(?:b|strong)>((?:.|[\r\n])*?)<\/(?:b|strong)>(\s*)/gi,
  49
+"*"],i:[/(\s*)<(?:i|em)>((?:.|[\r\n])*?)<\/(?:i|em)>(\s*)/gi,"_"],del:[/(\s*)<(?:strike|del)>((?:.|[\r\n])*?)<\/(?:strike|del)>(\s*)/gi,"-"],u:[/(\s*)<(?:u|ins)>((?:.|[\r\n])*?)<\/(?:u|ins)>(\s*)/gi,"+"]};for(d=a.length;d;d--)e=h[a[d-1]],c(e[0],e[1])}a=a.preview.html();a=a.replace(/\s*<(ul|ol)>((.|[\r\n])*?)<\/\1>\s*/gi,function(a,c,d){a=c=="ul"?"*":"#";b(["b","i","u","del"],function(a,b){d=d.replace(a,function(a,c,d,e){return(c?" ":"")+b+d+b+(e?" ":"")})});return d.replace(/\s*<li>((.|[\r\n])*?)<\/li>\s*/gi,
  50
+a+" $1\n")+"\n"});a=a.replace(/ *<(p|h[1-4])([^>]*)>((.|[\r\n])*?)<\/\1>\s*/gi,function(a,c,d,e){a="";(d=d.match(/class=\"([^"]*)/))?a=c+"("+d[1]+"). ":c!="p"&&(a=c+". ");b(["b","i","u","del"],function(a,c){e=e.replace(a,function(a,b,d,e){return(b?" ":"")+c+d.replace(/<br ?\/?>\s*/gi,c+"\n"+c)+c+(e?" ":"")})});return a+e.replace(/<br ?\/?>\s*/gi,"\n")+"\n\n"});a=a.replace(/\s*<img[^>]*>\s*/gi,function(a){var c=m(a),a=c.attr("src");(c=c.attr("title"))&&!/^\s*$/.test(c)&&(a=a+"("+c+")");return"!"+a+
  51
+"!"});a=a.replace(/(\s*)<a href="([^\"]*)">((?:.|[\r\n])*?)<\/a>(\s*)/gi,function(a,c,b,d,e){a=c?" ":"";a+=/^\s*![^!]+!\s*$/.test(d)?m.trim(d)+":":'"'+d+'":';a+=b;e&&(a+=" ");return a});a=a.replace(/\s*<code[^>]*>((.|[\r\n])*?)<\/code>\s*/gi," @$1@ ");a=a.replace(/(\r\n|\n){3,}/g,"\n\n");a=a.replace(/&nbsp;/g," ");return a=a.replace(/^[\r\n]+|[\r\n]+$/g,"")},getSelectionStates:function(a){var c=this.getSelection(a,"\n\n");return this.buildStateObject(textileCompiler.trace(c,a.selectionStart-a.boundaryStart,
  52
+a.selectionEnd-a.boundaryStart),a.currentNodes={})},getParagraphs:function(a){return this.getSelection(a,"\n\n").split(/\n\n+/)},setParagraphs:function(a,c){var b=a.textArea.val(),c=c.join("\n\n");a.boundaryStart===-1?a.textArea.val(b.slice(0,a.boundaryStart)+c):a.textArea.val(b.slice(0,a.boundaryStart)+c+b.slice(a.boundaryEnd));this.moveCaret(a,c.length-a.boundaryDistance)},moveCaret:function(a,c){var b=a.selectionStart,d=a.startOfParagraphs;Math.abs(b-d)>Math.abs(c)?b+=c:b=d;a.textArea.focus();
  53
+a.setSelectionRange(b,b)},pressed:function(a,c){switch(c){case 13:var d;var e=a.currentNodes.list;e&&/(u|o)l/i.test(e.tag)&&!b.atBeginningOfLine(a)&&(b.getSelection(a),d=ME.holdShift?" <br> ":"\n"+j[e.tag]+" ",b.replaceSelection(a,d,false),d=false);return d;default:this.prototype.pressed.apply(this,[a,c])}}})})();
  54
+(function(){function g(a){var a=a.exec(c),d,g;if(a)return d=/^\s*/.exec(a[0])[0].length,g=a[0].length,d&&e.advancePointer(d,true),g-d&&e.advancePointer(g-d),c=c.slice(g),a||true}var e=function(){function a(a,c){var b=["class"],d;y[a]&&(b=b.concat(y[a]));for(d=b.length;d--;)c(b[d])}function c(b){var d=true,e=h==-1,f,t,v;if(e)/(o|u)l/.test(j[0].tag)?(/(o|u)l/.test(b.tag)&&b.tag!=j[0].tag&&(b={tag:"p"}),f=j[0]=b):f=j[0];else for(t=h+1,v=j.length;t<v;t++)if(j[t].tag===b.tag){f=j[t];j[t]=j[h+1];j[h+1]=
  55
+f;break}f&&f.attributes&&a(f.tag,function(a){f.attributes[a]!==b.attributes[a]&&(d=false,delete f.attributes[a])});return f&&(e||d)}function e(a){this.tag=a.tag;this.attributes=a.attributes}function f(a){var c="";for(attr in a.attributes)a.attributes.hasOwnProperty(attr)&&(c+=" "+attr+'="'+a.attributes[attr]+'"');return"<"+a.tag+c+">"}function g(a){var c;for(c=b.length;c--;)if(b[c].tag===a)return c}var b,j,h,q,p,u,r,l,n,s,t=false,x,v=["li"],y={img:["title","src"],a:["href"]},z={i:"_",b:"*"};return{init:function(){b=
  56
+[{content:""}]},initTrace:function(a,c,b){j=[];n=void 0;u=0;r=a;l=c;x=b},finalizeTrace:function(){n&&(n=s=false);j[0]||(j[0]={tag:"p"})},advancePointer:function(a,c){u+=a;if(n===void 0&&(u>r||u==x)){var d=b.length,f,t=0;q=n=true;for(f=1;f<d;f++)v.indexOf(b[f].tag)==-1?j[f-1-t]=new e(b[f]):t+=1;h=j.length-1}n&&u>l&&(s||c?n=s=false:s=true)},pushTag:function(a,f){var g={tag:a,attributes:f||{},content:""};b.push(g);n&&v.indexOf(a)==-1&&(q?(j[h+1]=new e(g),h+=1):j[h+1]&&(c(g)?h+=1:t=true))},pushTagUnlessOpen:function(a){this.isOpen(a)?
  57
+this.pushString(z[a]):this.pushTag(a)},closeTag:function(a){var c,d;a?(d=g(a),c=b.splice(d,1)[0]):c=b.pop();n&&v.indexOf(a)==-1&&(q=false,t&&(j=j.slice(0,h+1),t=false),j[h].tag===c.tag&&(h-=1),p=true);this.pushString(f(c)+c.content,b[d-1]);this.pushString("</"+c.tag+">");p=false},closeTagIfOpen:function(a,c,b){c=c||"";b=b||"";this.isOpen(a)?(this.pushString(c),this.closeTag(a),this.pushString(b)):this.pushString(c+z[a]+b)},popLineEnd:function(){for(var a=false,c={b:"*",i:"_"},d;"a,i,b,li".indexOf(b[b.length-
  58
+1].tag)!=-1;)"li"===b[b.length-1].tag?(this.closeTag(),a=true):(d=b.pop(),this.pushString(c[d.tag]+d.content));return a},popParagraphEnd:function(){for(;b.length>1;)this.closeTag()},pushString:function(a,c){c||(c=b[b.length-1]);c.content+=a;/^([ ]+|<br\/>)?$/.test(a)||(q&&(q=false),n&&!p&&j[h+1]&&(j=j.slice(0,h+1)))},isOpen:function(a){return typeof g(a)==="number"},blockTagIsOpen:function(){return!!b[1]},closeBlockTag:function(){for(;b[1];)this.closeTag()},getTrace:function(){return j},toHtml:function(){return b[0].content}}}(),
  59
+c;textileCompiler={compile:function(a){e.init();for(c=a;!/^\s*$/.test(c);){if(a=g(/^\s*(h\d|p|bq)(\(([^#\)]*)(#[^\)]+)?\))?\. /)){var d={};a[3]&&(d["class"]=a[3]);if(a[4])d.id=a[4];e.pushTag(a[1],d)}for(;!g(/^\n/)&&!/^\s*$/.test(c);){a=void 0;if(g(/^ *\* /))e.isOpen("ul")||(e.closeBlockTag(),e.pushTag("ul")),e.pushTag("li");else if(g(/^ *# /))e.isOpen("ol")||(e.closeBlockTag(),e.pushTag("ol")),e.pushTag("li");else{for(;e.isOpen("ul")||e.isOpen("ol");)e.closeTag();e.blockTagIsOpen()||e.pushTag("p")}a=
  60
+g(/^ */);e.pushString(a[0]);for(a=a=void 0;;)if(g(/^_(?=[^ \n]+)/))e.pushTagUnlessOpen("i");else if(g(/^\*(?=[^ \n]+)/))e.pushTagUnlessOpen("b");else if(a=g(/^([^ \n"\*]+)_([\*]*)( +|(?=\n|$))/))e.closeTagIfOpen("i",a[1]),a[2]&&e.closeTagIfOpen("b"),e.pushString(a[3]);else if(a=g(/^([^ \n"_]+)\*([_]*)( +|(?=\n|$))/))e.closeTagIfOpen("b",a[1]),a[2]&&e.closeTagIfOpen("i"),e.pushString(a[3]);else if(a=g(/^( *)"([^"]*)":([^ \n]+)/))e.pushString(a[1]),e.pushTag("a",{href:a[3]}),e.pushString(a[2]),e.closeTag();
  61
+else if(a=g(/^( *)!([^!\(]+)(\(([^\)]*)\))?!(:([^ \n]+))?/)){e.pushString(a[1]);a[6]&&e.pushTag("a",{href:a[6]});d={src:a[2]};if(a[4])d.title=a[4];e.pushTag("img",d);e.closeTag();a[6]&&e.closeTag()}else if(a=g(/^([^ \n]+)/))e.pushString(a[1]);else if(a=g(/^( +)/))e.pushString(a[1]);else{g(/^\n/);(a=e.popLineEnd())?(e.isOpen("ul")&&!/^ *\*+/.test(c)||e.isOpen("ol")&&!/^ *#+/.test(c))&&e.closeTag():/^ *(\||[\*#] )/.test(c)?e.closeTag():/^ *(\n|$|[\*#] )/.test(c)||e.pushString("<br/>");break}}e.popParagraphEnd()}return e.toHtml()},
  62
+trace:function(a,c,g){e.initTrace(c,g,a.length);this.compile(a);e.finalizeTrace();return e.getTrace()}}})();
  63
+(function(){function g(a,c){var b,d,e,f=l();b=r.getSelection(a);if(!/h\d|p|(o|u)l/i.test(b.childNodes[0].nodeName))b=b.firstChild;b=b.childNodes;e=b.length;for(d=0;d<e;d++)f=f.add(c(b[d]));r.replaceSelection(a,f)}function e(a,c){g(a,function(a){return l(a).removeClass("left").removeClass("right").removeClass("center").addClass(c)})}function c(a,c){var b=a[0],d;a.length>1?(d=a[a.length-1],s.setStart(b,0),s.setEnd(d,d.childNodes.length)):s.selectNodeContents(b);c!==void 0&&s.collapse(c);n.removeAllRanges();
  64
+n.addRange(s)}function a(a,c,b){/ on$/.test(c.className)?d(a):(c=r.getSelection(a,"br"),b=l("<"+b+">"),f(b,c.firstChild),m(a.leftBorder,b),m(a.rightBorder,b),r.replaceSelection(a,b))}function d(a){contents=r.getSelection(a,"li");lines=[];b(lines,contents.firstChild);$p=l("<p>").html(lines.join("<br>"));r.replaceSelection(a,$p)}function k(a,c,b){this.nextProperty=b;a.is(".preview")&&(a=b==="nextSibling"?l(a[0].lastChild):l(a[0].firstChild));this.ancestors=a.parentsUntil(".preview");this.block=this.ancestors[this.ancestors.length-
  65
+1]||a[0];for(this.borderNode=this.ancestors[this.ancestors.length-(c?2:1)]||a[0];this.borderNode;){this.node=this.borderNode;if(this.borderNode.nodeName.toLowerCase()===c)break;else if(/preview/.test(this.node.parentNode.className)){this.borderNode=null;break}this.borderNode=this.borderNode[b]}this.safeBlock=this.borderNode?this.block:this.block[b]}function f(a,c){function b(){/^\s*$/.test(d.textContent)||a.append(d);d=document.createElement("li")}for(var d=document.createElement("li"),e;c!==null;)e=
  66
+c.nextSibling,/br/i.test(c.nodeName)?b():/(p|h\d)/i.test(c.nodeName)?(b(),f(a,c.firstChild)):/(o|u)l/i.test(c.nodeName)?(b(),l(c).children().appendTo(a)):/li/i.test(c.nodeName)?(b(),a.append(c)):d.appendChild(c),c=e;b()}function m(a,c){var b;if(a.safeBlock&&a.safeBlock.nodeName===c[0].nodeName)next=a.safeBlock[a.nextProperty],b=l(a.safeBlock).remove().children(),a.nextProperty==="previousSibling"?b.prependTo(c):b.appendTo(c),a.safeBlock=next}function b(a,c){for(;c;)/(o|u)l/i.test(c.nodeName)?b(a,
  67
+c.firstChild):/li/i.test(c.nodeName)&&a.push(c.innerHTML),c=c.nextSibling}function j(a){function b(a,e){for(;!d[a];)d=d.parentNode;if((d=d[a])&&!/br|h\d|p/i.test(d.nodeName))return g?c([d],e):(e&&f.setStartBefore(d.firstChild),n.removeAllRanges(),n.addRange(f)),false}var d,e,f=n.getRangeAt(0),g=f.collapsed;d=f.startContainer;if(d.nodeType==3)if(e=d.nodeValue,f.startOffset+a===0&&/^ /.test(e))return b("previousSibling",false);else if(f.startOffset+a===d.length&&/ $/.test(e))return b("nextSibling",
  68
+true)}function h(a,b){if(p(b,8)===false)return false;var e,f,g,h,j,k=true,o=a.currentNodes.block,m=a.currentNodes.list;g=(m||o).previousSibling;var q=(m||o).nextSibling;h=n.getRangeAt(0);o=h.startContainer;if(!h.collapsed||!g||h.startOffset!==0)return true;for(;o.parentNode!==b[0];){if(o.previousSibling){k=false;if(/li/i.test(o.nodeName))e=true;else if(m&&/br/i.test(o.previousSibling.nodeName))f=true;else return true;break}o=o.parentNode}h=/(u|o)l/i.test(g.nodeName);j=/(u|o)l/i.test(q.nodeName);if(k){if(m)o=
  69
+o.firstChild;if(h)g=g.lastChild;o=l(o);e=o.contents();l(g).append(e);o.remove();c([e[0]],true);h&&j&&l(g).parent().append(l(q).detach().contents())}else if(f)o.parentNode.removeChild(o.previousSibling),o=l(o),e=o.nextAll(),f=o.parent("li"),g=l("<li>").append(o,e),f.after(g),c(g,true),d(a);else if(e){g=o.previousSibling;e=l(o).detach().contents();o=g;for(f=o.lastChild;f&&(/br/i.test(f.nodeName)||f.nodeType===3&&/^ *$/.test(f.textContent));)o.removeChild(f),f=o.lastChild;if(!e[0]||/br/i.test(e[0].nodeName))e[0]=
  70
+document.createTextNode("\u00a0");l(g).append("<br>",e);e[0]?c(e,true):c([g],false)}return false}function q(a,c){if(p(c,46)===false)return false;if(!l.browser.webkit)return true;var b,d,e=a.currentNodes.block;b=a.currentNodes.list;e=(b||e).nextSibling;d=n.getRangeAt(0);var f=d.startContainer;if(!d.collapsed||!e||d.startOffset!==f.length)return true;for(;f.parentNode!==c[0];){if(f.nextSibling)return true;f=f.parentNode}d=/(u|o)l/i.test(e.nodeName);if(!d||!b){if(b)f=f.lastChild;if(d)e=e.firstChild}e=
  71
+l(e);b=e.contents();l(f).append(b);e.remove();return false}function p(a,b,d){var e=n.getRangeAt(0);if(!l.browser.mozilla||d||e.collapsed||ME.util.isNeutralKey(b))return true;d=e.extractContents();if(a.is(":empty")||/^ *$/.test(a.text()))return d=document.createElement(d.childNodes[0].nodeName),a.html(d),c([d]),/^8|13|46$/.test(""+b)?false:true}function u(){var a,c,b=n.getRangeAt(0),d=b.startContainer,e=b.startOffset,f=b.endContainer,g=b.endOffset;if(d.nodeType==3)c=true,a=d.nodeValue,b.setStart(d,
  72
+a.lastIndexOf(" ",e)+1);if(f.nodeType==3){c=true;a=f.nodeValue;g=a.indexOf(" ",g-1);if(g===-1)g=a.length;b.setEnd(f,g)}c&&(n.removeAllRanges(),n.addRange(b))}var r,l=jQuery,n=getSelection(),s=document.createRange();r=ME.addMode("wysiwyg",{name:"Preview Mode",items:{"default":{clicked:function(){u();document.execCommand(this.name,false,null)}},bold:{tag:"b"},italic:{tag:"i"},alignLeft:{clicked:function(a){e(a,"left")}},alignRight:{clicked:function(a){e(a,"right")}},alignCenter:{clicked:function(a){e(a,
  73
+"center")}},unorderedList:{clicked:function(c,b){a(c,b,"ul")}},orderedList:{clicked:function(c,b){a(c,b,"ol")}},link:{clicked:function(a,c){u();var b,d,e,f=n.getRangeAt(0),g={remove:function(){var a=d.text();d.replaceWith(a)},close:function(){a.preview.focus();a.checkState()}};/ on$/.test(c.className)?(d=l(a.currentNodes.a),b=ME.dialog.link(["Update","Remove","Cancel"]),g.submit=function(a,c){d.attr("href",c).text(a);f.selectNodeContents(d[0]);n.removeAllRanges();n.addRange(f)},e=d.text(),b.val("input.uri",
  74
+d.attr("href"))):(b=ME.dialog.link(["Create","Cancel"]),g.submit=function(a,c){var b=l('<a href="'+c+'">'+a+"</a>")[0];f.deleteContents();f.insertNode(b);f.selectNodeContents(b);n.removeAllRanges();n.addRange(f)},e=f.toString());/^\s*$/.test(e)||b.val(".title",e);b.dialog("open",g)}},insertImage:{clicked:function(a,c){var b,d,e=window.getSelection(),f=e.getRangeAt(0);/ on$/.test(c.className)?(b=ME.dialog.insertImage(["Update","Remove","Cancel"]),a.currentNodes.a&&(d=l(a.currentNodes.a),b.val("input.uri",
  75
+d.attr("href")),f.selectNode(a.currentNodes.a)),imageNode=l(a.currentNodes.img),b.val("input.imageUri",imageNode.attr("src")),b.val("input.title",imageNode.attr("title"))):b=ME.dialog.insertImage(["Create","Cancel"]);b.dialog("open",{submit:function(a,c,b){var d=a=l('<img src="'+a+'"/>');/^\s*$/.test(c)||a.attr({alt:c,title:c});/^\s*$/.test(b)||(d=l('<a href="'+b+'"/>').append(a));f.deleteContents();f.insertNode(d[0]);f.selectNode(a[0]);e.removeAllRanges();e.addRange(f)},remove:function(){imageNode.remove()},
  76
+close:function(){a.preview.focus();a.checkState()}})}},formatBlock:{clicked:function(a,c){g(a,function(a){/(u|o)l/i.test(a.nodeName)||(a=l("<"+c.value+">").addClass(a.className).append(a.childNodes));return a})}}},getSelection:function(a,c){var b=n.getRangeAt(0),d=jQuery(n.getRangeAt(0).startContainer),e=jQuery(n.getRangeAt(0).endContainer);a.collapsed=b.collapsed;d.is(".preview")&&(d=l(d[0].firstChild));e.is(".preview")&&(e=a.collapsed?d:l(e[0].lastChild));a.leftBorder=new k(d,c,"previousSibling");
  77
+a.rightBorder=new k(e,c,"nextSibling");b.setStartBefore(a.leftBorder.node);b.setEndAfter(a.rightBorder.node);a.rightBorder.borderNode&&l(a.rightBorder.borderNode).nextAll().appendTo("<"+a.rightBorder.block.nodeName+">").parent().insertAfter(a.rightBorder.block);return b.extractContents()},replaceSelection:function(a,b){a.leftBorder.safeBlock?b.insertAfter(a.leftBorder.safeBlock):a.preview.prepend(b);a.collapsed?c(b,true):c(b);/^\s*$/.test(a.leftBorder.block.textContent)&&l(a.leftBorder.block).remove();
  78
+/^\s*$/.test(a.rightBorder.block.textContent)&&l(a.rightBorder.block).remove()},afterActivation:function(a){a.textArea.parent().hide();a.preview.attr("contentEditable",true);l.browser.mozilla&&document.execCommand("styleWithCSS",null,false)},getSelectionStates:function(a){function c(a,b){if(b){var d=b.nodeName,e=a[0].nodeName;d!="#text"&&e!="#text"&&e!=d&&(a=a.find(b.nodeName.toLowerCase()))}return a.parentsUntil(".preview").add(a)}if(!l(document.activeElement).is(".preview"))return{};j(0);var b=
  79
+[],d;d=n.getRangeAt(0).cloneContents();b=c(jQuery(n.getRangeAt(0).startContainer),d.firstChild);d=c(jQuery(n.getRangeAt(0).endContainer),d.lastChild);/(u|o)l/i.test(b[0].nodeName)&&b[0].nodeName!==d[0].nodeName&&(b=b.toArray(),b[0]=l("<p>")[0]);return this.buildStateObject(b,a.currentNodes={})},clicked:function(){j(0)},pressed:function(a,b){this.prototype.pressed.apply(this,[a,b]);switch(b){case 13:var e;a:{var f=a.preview;if(p(f,13)===false)e=false;else{var g,k,m,r,o,s=true,u=a.currentNodes.block,
  80
+w=a.currentNodes.list,A=/h[1-5]/i.test((w||u).nodeName);if(A||w){k=n.getRangeAt(0);for(g=m=k.endContainer;g.parentNode!==f[0];){/li/i.test(g.nodeName)&&(o=g);if(g.nextSibling){s=false;break}g=g.parentNode}if(s)A&&k.endOffset===m.textContent.length?r=true:w&&!l(o).text()&&(l(o).remove(),r=true);else if(o&&!l(o).text()){d(a);e=false;break a}r&&(g=l("<p>").insertAfter(w||u),c(g),e=false)}}}return e;case 8:return h(a,a.preview);case 46:return q(a,a.preview);case 37:return j(-1);case 39:return j(1);default:return p(a.preview,
  81
+b,ME.holdNeutralKey)}},toText:function(a,b){return a.getDataMode().toText(a,b)},toHTML:function(a){return a.preview.html()}})})();ME.addMode("haml",function(){var g=jQuery;return{name:"Haml Mode",toHTML:function(e,c){g.get("/api/markup/to_html",{type:"haml",content:e.textArea.val()},function(a){e.preview.html(a);c&&c()})},toText:function(e,c){g.get("/api/markup/from_html",{type:"haml",content:e.preview.html()},function(a){e.textArea.val(a);c&&c()})}}}());
3,451  source/javascripts/joined.js
1809 additions, 1642 deletions not shown

0 notes on commit fcdbd07

Please sign in to comment.
Something went wrong with that request. Please try again.