Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update joined files

  • Loading branch information...
commit e21b19a808aa0f5e6be61a92b0e7b98c2722fa72 1 parent 6098abd
@johnny authored
Showing with 15 additions and 14 deletions.
  1. +9 −9 public/javascripts/joined-min.js
  2. +6 −5 public/javascripts/joined.js
View
18 public/javascripts/joined-min.js
@@ -14,15 +14,15 @@ ME.dialog=function(k){function d(d,l){fields=d.find(":input");d.dialog({autoOpen
h+"-dialog");l=l(j);e=l.length;submit=function(){var a=[],c;for(c=0;c<e;c++)a[c]=l[c].val();b.submit.apply(this,a);j.dialog("close")};g=d(j,{Ok:submit,Update:submit,Remove:function(){b.remove();j.dialog("close")},Cancel:function(){j.dialog("close")}});this[h]=function(a){g.selectButtons(a);return g};return this[h](m)}}var b;return{link:o("link",function(b){return[b.find("input.title"),$uri=b.find("input.uri"),b.find("select.uri").change(function(){$uri.val(k(this).val())})]}),insertImage:o("insertImage",
function(b){return[b.find("input.imageUri"),b.find("input.title"),b.find("input.uri")]})}}(jQuery);$(document).ready(function(){$("textarea.markup").initMarkupEditor({})});
ME.addMode("textile",function(){function k(a,c){var f=a.editor.currentMode,b=f.getParagraphs(),e=b.length;for(i=0;i<e;i++)b[i]=c(b[i]);f.setParagraphs(b)}function d(a,c){k(a,function(a){var b,e,d=[];if(/^\w+\([^)]+\)\./.test(a)){b=jQuery.trim(a.slice(a.indexOf("(")+1,a.indexOf(")"))).split(/\s+/);e=b.length;for(i=0;i<e;i++)b[i]!="right"&&b[i]!="left"&&b[i]!="center"&&d.push(b[i]);d.push(c);return a.replace(/^(\w+)[^.]+.\s+/,"$1("+d.join(" ")+"). ")}else return/^\w+\./.test(a)?a.replace(/^(\w+)\.\s*/,
-"$1("+c+"). "):"p("+c+"). "+a})}function o(a,c){match=c.exec(b);if(c.lastIndex!==0){for(;c.lastIndex<h;)match=c.exec(b);a.selectionStart=c.lastIndex-match[0].length;a.selectionEnd=c.lastIndex;return match}}var b,h,l,m,g,e={},j=jQuery;regexpes={"*":/^(\w+\. )?\s*\*(.*)\*/};return{name:"Textile Mode",buttons:{"default":{clicked:function(a,c){var b=a.getSelection(!0).split("\n"),e=b.length,d,n;for(d=0;d<e;d++)n=b[d],/^\s*$/.test(n)||(/ on$/.test(c.className)?(n=(match=n.match(/^(\w+\. )?\s*\*/))?(match[1]||
-"")+n.slice(match[0].length):"*"+a.extendLeftSelection(/[ .]+/)+n,(match=n.match(/\*([\.]*)$/))?n=n.slice(0,-match[0].length)+(match[1]||""):n+=a.extendRightSelection(/ +/)+"*"):n=j.trim(n.replace(/^(\w+\. )?\s*(.*)/,"$1"+this.delimiter+"$2"))+this.delimiter,b[d]=n);a.replaceSelection(b.join("\n"))}},bold:{delimiter:"*"},italic:{delimiter:"_"},alignLeft:{clicked:function(a){d(a,"left")}},alignRight:{clicked:function(a){d(a,"right")}},alignCenter:{clicked:function(a){d(a,"center")}},link:{clicked:function(a,
-c){var b,d,j,n;/ on$/.test(c.className)?(b=ME.dialog.link(["Update","Remove","Cancel"]),j=e.a.attributes.href,n=o(a,RegExp('"([^"]*)":'+j,"g")),d=n[1],b.val("input.uri",j)):(b=ME.dialog.link(["Ok","Cancel"]),d=a.getSelection());/^\s*$/.test(d)||b.val(".title",d);b.dialog("open",{submit:function(c,b){a.replaceSelection('"'+c+'":'+b)},remove:function(){a.replaceSelection(n[1])},close:function(){a.editor.currentMode.updatePreview();a.editor.checkState()}})}},insertImage:{clicked:function(a,c){var b,
-d,j;if(/ on$/.test(c.className)){b=ME.dialog.insertImage(["Update","Remove","Cancel"]);j=e.img.attributes.src;o(a,RegExp("!"+j+"(\\([^\\)]*\\))?!(:[^ \n]*)?","g"));if(e.a)d=e.a.attributes.href;b.val("input.uri",d);b.val("input.imageUri",j);b.val("input.title",e.img.attributes.title)}else b=ME.dialog.insertImage(["Ok","Cancel"]),a.getSelection();b.dialog("open",{submit:function(c,b,e){b&&!/^\s*$/.test(b)&&(c=c+"("+b+")");c="!"+c+"!";e&&!/^\s*$/.test(e)&&(c=c+":"+e);a.replaceSelection(c)},remove:function(){a.replaceSelection("")},
-close:function(){a.editor.currentMode.updatePreview();a.editor.checkState()}})}}},selects:{formatBlock:{clicked:function(a,c){k(a,function(a){return/^\w+(\([\w ]+\))?\./.test(a)?a.replace(/^\w+(\([\w ]+\))?\.\s+/,c.value+"$1. "):c.value+". "+a})}}},updatePreview:function(){this.htmlDiv.html(textileCompiler.compile(this.textArea.val()))},toText:function(a){a||(a=this.htmlDiv.html());a=a.replace(/\s*<(h[1-4])>((.|[\r\n])*?)<\/\1>\s*/gi,"\n\n$1. $2\n\n");a=a.replace(/\s*<(p)>((.|[\r\n])*?)<\/\1>\s*/gi,
-"\n\n$2\n\n");a=a.replace(/\s*<(p|h[1-4]).*class=\"([^\"]+)\">((.|[\r\n])*?)<\/\1>\s*/gi,"\n\n$1($2). $3\n\n");a=a.replace(/<br ?\/?>\s*/gi,"\n");a=a.replace(/<(?:b|strong)>((.|[\r\n])*?)<\/(?:b|strong)>/gi,"*$1*");a=a.replace(/<(?:i|em)>((.|[\r\n])*?)<\/(?:i|em)>/gi,"_$1_");a=a.replace(/<(?:strike|del)>((.|[\r\n])*?)<\/(?:strike|del)>/gi,"-$1-");a=a.replace(/<(?:u|ins)>((.|[\r\n])*?)<\/(?:u|ins)>/gi,"+$1+");a=a.replace(/<img[^>]*>/gi,function(a){var b=j(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,e){return/^\s*![^!]+!\s*$/.test(e)?j.trim(e)+":"+b:'"'+e+'":'+b});a=a.replace(/\s*<code[^>]*>((.|[\r\n])*?)<\/code>\s*/gi," @$1@ ");a=a.replace(/(\r\n|\n){3,}/g,"\n\n");return a=a.replace(/^[\r\n]+|[\r\n]+$/g,"")},getStates:function(){var a=this.getExtendedSelection();trace=textileCompiler.trace(a,h-l,selectionEnd-l);return this.buildStateObject(trace,e={})},getExtendedSelection:function(){var a;
-a=0;h=this.textArea[0].selectionStart;selectionEnd=this.textArea[0].selectionEnd;b=this.textArea.val();l=0;for(m=-1;(a=b.indexOf("\n\n",a)+2)!==1;)if(h>a)l=a;else if(selectionEnd<a){m=a-2;break}a=m===-1?b.slice(l):b.slice(l,m);g=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(b.slice(0,l)+a):this.textArea.val(b.slice(0,l)+a+b.slice(m));this.moveCaret(a.length-g)},moveCaret:function(a){console.log("Moving caret: "+
-a);Math.abs(h-l)>Math.abs(a)?h+=a:h=l;this.textArea.focus();this.textArea[0].setSelectionRange(h,h)}}});
+"$1("+c+"). "):"p("+c+"). "+a})}function o(a,c){match=c.exec(b);if(c.lastIndex!==0){for(;c.lastIndex<h;)match=c.exec(b);a.selectionStart=c.lastIndex-match[0].length;a.selectionEnd=c.lastIndex;return match}}var b,h,l,m,g,e={},j=jQuery;regexpes={"*":[/^(\w+\. )?\s*\*/,/\*([\.]*)$/],_:[/^(\w+\. )?\s*_/,/_([\.]*)$/]};return{name:"Textile Mode",buttons:{"default":{clicked:function(a,c){var b=a.getSelection(!0).split("\n"),e=b.length,d,n;for(d=0;d<e;d++)n=b[d],/^\s*$/.test(n)||(/ on$/.test(c.className)?
+(n=(match=n.match(regexpes[this.delimiter][0]))?(match[1]||"")+n.slice(match[0].length):this.delimiter+a.extendLeftSelection(/[ .]+/)+n,(match=n.match(regexpes[this.delimiter][1]))?n=n.slice(0,-match[0].length)+(match[1]||""):n+=a.extendRightSelection(/ +/)+this.delimiter):n=j.trim(n.replace(/^(\w+\. )?\s*(.*)/,"$1"+this.delimiter+"$2"))+this.delimiter,b[d]=n);a.replaceSelection(b.join("\n"))}},bold:{delimiter:"*"},italic:{delimiter:"_"},alignLeft:{clicked:function(a){d(a,"left")}},alignRight:{clicked:function(a){d(a,
+"right")}},alignCenter:{clicked:function(a){d(a,"center")}},link:{clicked:function(a,c){var b,d,j,n;/ on$/.test(c.className)?(b=ME.dialog.link(["Update","Remove","Cancel"]),j=e.a.attributes.href,n=o(a,RegExp('"([^"]*)":'+j,"g")),d=n[1],b.val("input.uri",j)):(b=ME.dialog.link(["Ok","Cancel"]),d=a.getSelection());/^\s*$/.test(d)||b.val(".title",d);b.dialog("open",{submit:function(c,b){a.replaceSelection('"'+c+'":'+b)},remove:function(){a.replaceSelection(n[1])},close:function(){a.editor.currentMode.updatePreview();
+a.editor.checkState()}})}},insertImage:{clicked:function(a,c){var b,d,j;if(/ on$/.test(c.className)){b=ME.dialog.insertImage(["Update","Remove","Cancel"]);j=e.img.attributes.src;o(a,RegExp("!"+j+"(\\([^\\)]*\\))?!(:[^ \n]*)?","g"));if(e.a)d=e.a.attributes.href;b.val("input.uri",d);b.val("input.imageUri",j);b.val("input.title",e.img.attributes.title)}else b=ME.dialog.insertImage(["Ok","Cancel"]),a.getSelection();b.dialog("open",{submit:function(c,b,e){b&&!/^\s*$/.test(b)&&(c=c+"("+b+")");c="!"+c+"!";
+e&&!/^\s*$/.test(e)&&(c=c+":"+e);a.replaceSelection(c)},remove:function(){a.replaceSelection("")},close:function(){a.editor.currentMode.updatePreview();a.editor.checkState()}})}}},selects:{formatBlock:{clicked:function(a,c){k(a,function(a){return/^\w+(\([\w ]+\))?\./.test(a)?a.replace(/^\w+(\([\w ]+\))?\.\s+/,c.value+"$1. "):c.value+". "+a})}}},updatePreview:function(){this.htmlDiv.html(textileCompiler.compile(this.textArea.val()))},toText:function(a){a||(a=this.htmlDiv.html());a=a.replace(/\s*<(h[1-4])>((.|[\r\n])*?)<\/\1>\s*/gi,
+"\n\n$1. $2\n\n");a=a.replace(/\s*<(p)>((.|[\r\n])*?)<\/\1>\s*/gi,"\n\n$2\n\n");a=a.replace(/\s*<(p|h[1-4]).*class=\"([^\"]+)\">((.|[\r\n])*?)<\/\1>\s*/gi,"\n\n$1($2). $3\n\n");a=a.replace(/<br ?\/?>\s*/gi,"\n");a=a.replace(/<(?:b|strong)>((.|[\r\n])*?)<\/(?:b|strong)>/gi,"*$1*");a=a.replace(/<(?:i|em)>((.|[\r\n])*?)<\/(?:i|em)>/gi,"_$1_");a=a.replace(/<(?:strike|del)>((.|[\r\n])*?)<\/(?:strike|del)>/gi,"-$1-");a=a.replace(/<(?:u|ins)>((.|[\r\n])*?)<\/(?:u|ins)>/gi,"+$1+");a=a.replace(/<img[^>]*>/gi,
+function(a){var b=j(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,e){return/^\s*![^!]+!\s*$/.test(e)?j.trim(e)+":"+b:'"'+e+'":'+b});a=a.replace(/\s*<code[^>]*>((.|[\r\n])*?)<\/code>\s*/gi," @$1@ ");a=a.replace(/(\r\n|\n){3,}/g,"\n\n");return a=a.replace(/^[\r\n]+|[\r\n]+$/g,"")},getStates:function(){var a=this.getExtendedSelection();trace=textileCompiler.trace(a,h-l,selectionEnd-l);return this.buildStateObject(trace,
+e={})},getExtendedSelection:function(){var a;a=0;h=this.textArea[0].selectionStart;selectionEnd=this.textArea[0].selectionEnd;b=this.textArea.val();l=0;for(m=-1;(a=b.indexOf("\n\n",a)+2)!==1;)if(h>a)l=a;else if(selectionEnd<a){m=a-2;break}a=m===-1?b.slice(l):b.slice(l,m);g=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(b.slice(0,l)+a):this.textArea.val(b.slice(0,l)+a+b.slice(m));this.moveCaret(a.length-
+g)},moveCaret:function(a){console.log("Moving caret: "+a);Math.abs(h-l)>Math.abs(a)?h+=a:h=l;this.textArea.focus();this.textArea[0].setSelectionRange(h,h)}}});
textileCompiler=function(){function k(b){b=b.exec(o);var h,l;if(b)return h=/^\s*/.exec(b[0])[0].length,l=b[0].length,h&&d.advancePointer(h),l-h&&d.advancePointer(l-h),o=o.slice(l),b||!0}var d=function(){function b(a,b){var c=["class"],e;definableAttributes[a]&&(c=c.concat(definableAttributes[a]));for(e=c.length;e--;)b(c[e])}function d(a){var c=!0,f=j==-1,g,h,l;if(f)g=e[0];else{h=j+1;for(l=e.length;h<l;h++)if(e[h].tag===a.tag){g=e[h];e[h]=e[j+1];e[j+1]=g;break}}g&&g.attributes&&b(g.tag,function(b){g.attributes[b]!==
a.attributes[b]&&(c=!1,delete g.attributes[b])});return g&&(f||c)}function l(a){var b="";for(attr in a.attributes)a.attributes.hasOwnProperty(attr)&&(b+=" "+attr+'="'+a.attributes[attr]+'"');return"<"+a.tag+b+">"}function k(a){var b;for(b=g.length;b--;)if(g[b].tag===a)return b}var g,e,j,a,c,f,o,r,n,p,q=!1;definableAttributes={img:["title","src"],a:["href"]};return{init:function(){g=[{content:""}]},initTrace:function(a,b){e=[];n=void 0;f=0;o=a;r=b},finalizeTrace:function(){n&&(n=p=!1)},advancePointer:function(b){f+=
b;if(n===void 0&&f>o){b=g.length;var c;a=n=!0;for(c=1;c<b;c++)e[c-1]={tag:g[c].tag,attributes:g[c].attributes};j=e.length-1}p?n=p=!1:n&&f>r&&(p=!0)},pushTag:function(b,c){var f={tag:b,attributes:c||{},content:""};g.push(f);n&&(a?(e[j+1]={tag:f.tag,attributes:f.attributes},j+=1):e[j+1]&&(d(f)?j+=1:q=!0))},closeTag:function(b){var d;b?(d=k(b),b=g.splice(d,1)[0]):b=g.pop();n&&(a=!1,q&&(e=e.slice(0,j+1),q=!1),e[j].tag===b.tag&&(j-=1),c=!0);this.pushString(l(b)+b.content,g[d-1]);this.pushString("</"+b.tag+
View
11 public/javascripts/joined.js
@@ -567,7 +567,8 @@ ME.addMode("textile", function() {
}
regexpes = {
- "*": /^(\w+\. )?\s*\*(.*)\*/
+ "*": [/^(\w+\. )?\s*\*/, /\*([\.]*)$/],
+ "_": [/^(\w+\. )?\s*_/, /_([\.]*)$/]
};
return {
name: "Textile Mode",
@@ -586,20 +587,20 @@ ME.addMode("textile", function() {
if(/ on$/.test(target.className)){
// first handle the left part
- match = currentLine.match(/^(\w+\. )?\s*\*/);
+ match = currentLine.match(regexpes[this.delimiter][0]);
if(match){
currentLine = (match[1] || "") + currentLine.slice(match[0].length);
} else {
// place delimiter left and extend selection
- currentLine = "*" + toolbar.extendLeftSelection(/[ .]+/) + currentLine;
+ currentLine = this.delimiter + toolbar.extendLeftSelection(/[ .]+/) + currentLine;
}
// Then handle the right
- match = currentLine.match(/\*([\.]*)$/);
+ match = currentLine.match(regexpes[this.delimiter][1]);
if(match){
currentLine = currentLine.slice(0, - match[0].length) + (match[1] || "");
} else {
- currentLine += toolbar.extendRightSelection(/ +/) + "*";
+ currentLine += toolbar.extendRightSelection(/ +/) + this.delimiter;
}
} else {
Please sign in to comment.
Something went wrong with that request. Please try again.