Mercurial > public > sg101
diff media/js/markitup/jquery.markitup.pack.js @ 199:217119c87a06
Fix #72: update to 1.1.7 of the MarkItUp! editor.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 11 Apr 2010 18:56:30 +0000 |
parents | afb65fa947f1 |
children | a61b1c598001 |
line wrap: on
line diff
--- a/media/js/markitup/jquery.markitup.pack.js Sun Apr 11 17:58:09 2010 +0000 +++ b/media/js/markitup/jquery.markitup.pack.js Sun Apr 11 18:56:30 2010 +0000 @@ -1,9 +1,9 @@ // ---------------------------------------------------------------------------- // markItUp! Universal MarkUp Engine, JQuery plugin -// v 1.1.6.1 +// v 1.1.7 // Dual licensed under the MIT and GPL licenses. // ---------------------------------------------------------------------------- // Copyright (C) 2007-2010 Jay Salvat // http://markitup.jaysalvat.com/ // ---------------------------------------------------------------------------- -(function($){$.fn.markItUp=function(settings,extraSettings){var options,ctrlKey,shiftKey,altKey;ctrlKey=shiftKey=altKey=false;options={id:'',nameSpace:'',root:'',previewInWindow:'',previewAutoRefresh:true,previewPosition:'after',previewTemplatePath:'~/templates/preview.html',previewParserPath:'',previewParserVar:'data',resizeHandle:true,beforeInsert:'',afterInsert:'',onEnter:{},onShiftEnter:{},onCtrlEnter:{},onTab:{},markupSet:[{}]};$.extend(options,settings,extraSettings);if(!options.root){$('script').each(function(a,tag){miuScript=$(tag).get(0).src.match(/(.*)jquery\.markitup(\.pack)?\.js$/);if(miuScript!==null){options.root=miuScript[1]}})}return this.each(function(){var $$,textarea,levels,scrollPosition,caretPosition,caretOffset,clicked,hash,header,footer,previewWindow,template,iFrame,abort;$$=$(this);textarea=this;levels=[];abort=false;scrollPosition=caretPosition=0;caretOffset=-1;options.previewParserPath=localize(options.previewParserPath);options.previewTemplatePath=localize(options.previewTemplatePath);function localize(data,inText){if(inText){return data.replace(/("|')~\//g,"$1"+options.root)}return data.replace(/^~\//,options.root)}function init(){id='';nameSpace='';if(options.id){id='id="'+options.id+'"'}else if($$.attr("id")){id='id="markItUp'+($$.attr("id").substr(0,1).toUpperCase())+($$.attr("id").substr(1))+'"'}if(options.nameSpace){nameSpace='class="'+options.nameSpace+'"'}$$.wrap('<div '+nameSpace+'></div>');$$.wrap('<div '+id+' class="markItUp"></div>');$$.wrap('<div class="markItUpContainer"></div>');$$.addClass("markItUpEditor");header=$('<div class="markItUpHeader"></div>').insertBefore($$);$(dropMenus(options.markupSet)).appendTo(header);footer=$('<div class="markItUpFooter"></div>').insertAfter($$);if(options.resizeHandle===true&&$.browser.safari!==true){resizeHandle=$('<div class="markItUpResizeHandle"></div>').insertAfter($$).bind("mousedown",function(e){var h=$$.height(),y=e.clientY,mouseMove,mouseUp;mouseMove=function(e){$$.css("height",Math.max(20,e.clientY+h-y)+"px");return false};mouseUp=function(e){$("html").unbind("mousemove",mouseMove).unbind("mouseup",mouseUp);return false};$("html").bind("mousemove",mouseMove).bind("mouseup",mouseUp)});footer.append(resizeHandle)}$$.keydown(keyPressed).keyup(keyPressed);$$.bind("insertion",function(e,settings){if(settings.target!==false){get()}if(textarea===$.markItUp.focused){markup(settings)}});$$.focus(function(){$.markItUp.focused=this})}function dropMenus(markupSet){var ul=$('<ul></ul>'),i=0;$('li:hover > ul',ul).css('display','block');$.each(markupSet,function(){var button=this,t='',title,li,j;title=(button.key)?(button.name||'')+' [Ctrl+'+button.key+']':(button.name||'');key=(button.key)?'accesskey="'+button.key+'"':'';if(button.separator){li=$('<li class="markItUpSeparator">'+(button.separator||'')+'</li>').appendTo(ul)}else{i++;for(j=levels.length-1;j>=0;j--){t+=levels[j]+"-"}li=$('<li class="markItUpButton markItUpButton'+t+(i)+' '+(button.className||'')+'"><a href="" '+key+' title="'+title+'">'+(button.name||'')+'</a></li>').bind("contextmenu",function(){return false}).click(function(){return false}).mouseup(function(){if(button.call){eval(button.call)()}markup(button);return false}).hover(function(){$('> ul',this).show();$(document).one('click',function(){$('ul ul',header).hide()})},function(){$('> ul',this).hide()}).appendTo(ul);if(button.dropMenu){levels.push(i);$(li).addClass('markItUpDropMenu').append(dropMenus(button.dropMenu))}}});levels.pop();return ul}function magicMarkups(string){if(string){string=string.toString();string=string.replace(/\(\!\(([\s\S]*?)\)\!\)/g,function(x,a){var b=a.split('|!|');if(altKey===true){return(b[1]!==undefined)?b[1]:b[0]}else{return(b[1]===undefined)?"":b[0]}});string=string.replace(/\[\!\[([\s\S]*?)\]\!\]/g,function(x,a){var b=a.split(':!:');if(abort===true){return false}value=prompt(b[0],(b[1])?b[1]:'');if(value===null){abort=true}return value});return string}return""}function prepare(action){if($.isFunction(action)){action=action(hash)}return magicMarkups(action)}function build(string){openWith=prepare(clicked.openWith);placeHolder=prepare(clicked.placeHolder);replaceWith=prepare(clicked.replaceWith);closeWith=prepare(clicked.closeWith);if(replaceWith!==""){block=openWith+replaceWith+closeWith}else if(selection===''&&placeHolder!==''){block=openWith+placeHolder+closeWith}else{block=openWith+(string||selection)+closeWith}return{block:block,openWith:openWith,replaceWith:replaceWith,placeHolder:placeHolder,closeWith:closeWith}}function markup(button){var len,j,n,i;hash=clicked=button;get();$.extend(hash,{line:"",root:options.root,textarea:textarea,selection:(selection||''),caretPosition:caretPosition,ctrlKey:ctrlKey,shiftKey:shiftKey,altKey:altKey});prepare(options.beforeInsert);prepare(clicked.beforeInsert);if(ctrlKey===true&&shiftKey===true){prepare(clicked.beforeMultiInsert)}$.extend(hash,{line:1});if(ctrlKey===true&&shiftKey===true){lines=selection.split(/\r?\n/);for(j=0,n=lines.length,i=0;i<n;i++){if($.trim(lines[i])!==''){$.extend(hash,{line:++j,selection:lines[i]});lines[i]=build(lines[i]).block}else{lines[i]=""}}string={block:lines.join('\n')};start=caretPosition;len=string.block.length+(($.browser.opera)?n:0)}else if(ctrlKey===true){string=build(selection);start=caretPosition+string.openWith.length;len=string.block.length-string.openWith.length-string.closeWith.length;len-=fixIeBug(string.block)}else if(shiftKey===true){string=build(selection);start=caretPosition;len=string.block.length;len-=fixIeBug(string.block)}else{string=build(selection);start=caretPosition+string.block.length;len=0;start-=fixIeBug(string.block)}if((selection===''&&string.replaceWith==='')){caretOffset+=fixOperaBug(string.block);start=caretPosition+string.openWith.length;len=string.block.length-string.openWith.length-string.closeWith.length;caretOffset=$$.val().substring(caretPosition,$$.val().length).length;caretOffset-=fixOperaBug($$.val().substring(0,caretPosition))}$.extend(hash,{caretPosition:caretPosition,scrollPosition:scrollPosition});if(string.block!==selection&&abort===false){insert(string.block);set(start,len)}else{caretOffset=-1}get();$.extend(hash,{line:'',selection:selection});if(ctrlKey===true&&shiftKey===true){prepare(clicked.afterMultiInsert)}prepare(clicked.afterInsert);prepare(options.afterInsert);if(previewWindow&&options.previewAutoRefresh){refreshPreview()}shiftKey=altKey=ctrlKey=abort=false}function fixOperaBug(string){if($.browser.opera){return string.length-string.replace(/\n*/g,'').length}return 0}function fixIeBug(string){if($.browser.msie){return string.length-string.replace(/\r*/g,'').length}return 0}function insert(block){if(document.selection){var newSelection=document.selection.createRange();newSelection.text=block}else{$$.val($$.val().substring(0,caretPosition)+block+$$.val().substring(caretPosition+selection.length,$$.val().length))}}function set(start,len){if(textarea.createTextRange){if($.browser.opera&&$.browser.version>=9.5&&len==0){return false}range=textarea.createTextRange();range.collapse(true);range.moveStart('character',start);range.moveEnd('character',len);range.select()}else if(textarea.setSelectionRange){textarea.setSelectionRange(start,start+len)}textarea.scrollTop=scrollPosition;textarea.focus()}function get(){textarea.focus();scrollPosition=textarea.scrollTop;if(document.selection){selection=document.selection.createRange().text;if($.browser.msie){var range=document.selection.createRange(),rangeCopy=range.duplicate();rangeCopy.moveToElementText(textarea);caretPosition=-1;while(rangeCopy.inRange(range)){rangeCopy.moveStart('character');caretPosition++}}else{caretPosition=textarea.selectionStart}}else{caretPosition=textarea.selectionStart;selection=$$.val().substring(caretPosition,textarea.selectionEnd)}return selection}function preview(){if(!previewWindow||previewWindow.closed){if(options.previewInWindow){previewWindow=window.open('','preview',options.previewInWindow)}else{iFrame=$('<iframe class="markItUpPreviewFrame"></iframe>');if(options.previewPosition=='after'){iFrame.insertAfter(footer)}else{iFrame.insertBefore(header)}previewWindow=iFrame[iFrame.length-1].contentWindow||frame[iFrame.length-1]}}else if(altKey===true){if(iFrame){iFrame.remove()}else{previewWindow.close()}previewWindow=iFrame=false}if(!options.previewAutoRefresh){refreshPreview()}}function refreshPreview(){renderPreview()}function renderPreview(){var phtml;if(options.previewParserPath!==''){$.ajax({type:'POST',url:options.previewParserPath,data:options.previewParserVar+'='+encodeURIComponent($$.val()),success:function(data){writeInPreview(localize(data,1))}})}else{if(!template){$.ajax({url:options.previewTemplatePath,success:function(data){writeInPreview(localize(data,1).replace(/<!-- content -->/g,$$.val()))}})}}return false}function writeInPreview(data){if(previewWindow.document){try{sp=previewWindow.document.documentElement.scrollTop}catch(e){sp=0}var h="test";previewWindow.document.open();previewWindow.document.write(data);previewWindow.document.close();previewWindow.document.documentElement.scrollTop=sp}if(options.previewInWindow){previewWindow.focus()}}function keyPressed(e){shiftKey=e.shiftKey;altKey=e.altKey;ctrlKey=(!(e.altKey&&e.ctrlKey))?e.ctrlKey:false;if(e.type==='keydown'){if(ctrlKey===true){li=$("a[accesskey="+String.fromCharCode(e.keyCode)+"]",header).parent('li');if(li.length!==0){ctrlKey=false;li.triggerHandler('mouseup');return false}}if(e.keyCode===13||e.keyCode===10){if(ctrlKey===true){ctrlKey=false;markup(options.onCtrlEnter);return options.onCtrlEnter.keepDefault}else if(shiftKey===true){shiftKey=false;markup(options.onShiftEnter);return options.onShiftEnter.keepDefault}else{markup(options.onEnter);return options.onEnter.keepDefault}}if(e.keyCode===9){if(shiftKey==true||ctrlKey==true||altKey==true){return false}if(caretOffset!==-1){get();caretOffset=$$.val().length-caretOffset;set(caretOffset,0);caretOffset=-1;return false}else{markup(options.onTab);return options.onTab.keepDefault}}}}init()})};$.fn.markItUpRemove=function(){return this.each(function(){$$=$(this).unbind().removeClass('markItUpEditor');$$.parent('div').parent('div.markItUp').parent('div').replaceWith($$)})};$.markItUp=function(settings){var options={target:false};$.extend(options,settings);if(options.target){return $(options.target).each(function(){$(this).focus();$(this).trigger('insertion',[options])})}else{$('textarea').trigger('insertion',[options])}}})(jQuery); \ No newline at end of file +eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(3($){$.23.T=3(f,g){B k,v,A,F;v=A=F=l;k={D:\'\',12:\'\',U:\'\',1j:\'\',1y:7,24:\'25\',1k:\'~/2R/1z.1A\',1b:\'\',26:\'27\',1l:7,1B:\'\',1C:\'\',1D:{},1E:{},1F:{},1G:{},28:[{}]};$.V(k,f,g);2(!k.U){$(\'2S\').1c(3(a,b){1H=$(b).14(0).2T.2U(/(.*)2V\\.2W(\\.2X)?\\.2Y$/);2(1H!==29){k.U=1H[1]}})}4 G.1c(3(){B d,u,15,16,p,H,L,P,17,1m,w,2a,M,18;d=$(G);u=G;15=[];18=l;16=p=0;H=-1;k.1b=1d(k.1b);k.1k=1d(k.1k);3 1d(a,b){2(b){4 a.W(/("|\')~\\//g,"$1"+k.U)}4 a.W(/^~\\//,k.U)}3 2b(){D=\'\';12=\'\';2(k.D){D=\'D="\'+k.D+\'"\'}8 2(d.1I("D")){D=\'D="T\'+(d.1I("D").2c(0,1).2Z())+(d.1I("D").2c(1))+\'"\'}2(k.12){12=\'N="\'+k.12+\'"\'}d.1J(\'<z \'+12+\'></z>\');d.1J(\'<z \'+D+\' N="T"></z>\');d.1J(\'<z N="30"></z>\');d.2d("2e");17=$(\'<z N="31"></z>\').2f(d);$(1K(k.28)).1L(17);1m=$(\'<z N="32"></z>\').1M(d);2(k.1l===7&&$.X.33!==7){1l=$(\'<z N="34"></z>\').1M(d).1e("1N",3(e){B h=d.2g(),y=e.2h,1n,1o;1n=3(e){d.2i("2g",35.36(20,e.2h+h-y)+"37");4 l};1o=3(e){$("1A").1O("2j",1n).1O("2k",1o);4 l};$("1A").1e("2j",1n).1e("2k",1o)});1m.2l(1l)}d.2m(1P).38(1P);d.1e("1Q",3(e,a){2(a.1p!==l){14()}2(u===$.T.2n){Y(a)}});d.1f(3(){$.T.2n=G})}3 1K(b){B c=$(\'<Z></Z>\'),i=0;$(\'C:2o > Z\',c).2i(\'39\',\'q\');$.1c(b,3(){B a=G,t=\'\',1q,C,j;1q=(a.19)?(a.1R||\'\')+\' [3a+\'+a.19+\']\':(a.1R||\'\');19=(a.19)?\'2p="\'+a.19+\'"\':\'\';2(a.2q){C=$(\'<C N="3b">\'+(a.2q||\'\')+\'</C>\').1L(c)}8{i++;2r(j=15.6-1;j>=0;j--){t+=15[j]+"-"}C=$(\'<C N="2s 2s\'+t+(i)+\' \'+(a.3c||\'\')+\'"><a 3d="" \'+19+\' 1q="\'+1q+\'">\'+(a.1R||\'\')+\'</a></C>\').1e("3e",3(){4 l}).2t(3(){4 l}).1N(3(){2(a.2u){3f(a.2u)()}2v(3(){Y(a)},1);4 l}).2o(3(){$(\'> Z\',G).3g();$(E).3h(\'2t\',3(){$(\'Z Z\',17).2w()})},3(){$(\'> Z\',G).2w()}).1L(c);2(a.2x){15.3i(i);$(C).2d(\'3j\').2l(1K(a.2x))}}});15.3k();4 c}3 2y(c){2(c){c=c.3l();c=c.W(/\\(\\!\\(([\\s\\S]*?)\\)\\!\\)/g,3(x,a){B b=a.1S(\'|!|\');2(F===7){4(b[1]!==2z)?b[1]:b[0]}8{4(b[1]===2z)?"":b[0]}});c=c.W(/\\[\\!\\[([\\s\\S]*?)\\]\\!\\]/g,3(x,a){B b=a.1S(\':!:\');2(18===7){4 l}1T=3m(b[0],(b[1])?b[1]:\'\');2(1T===29){18=7}4 1T});4 c}4""}3 I(a){2($.3n(a)){a=a(P)}4 2y(a)}3 1g(a){J=I(L.J);1a=I(L.1a);Q=I(L.Q);O=I(L.O);2(Q!==""){q=J+Q+O}8 2(m===\'\'&&1a!==\'\'){q=J+1a+O}8{q=J+(a||m)+O}4{q:q,J:J,Q:Q,1a:1a,O:O}}3 Y(a){B b,j,n,i;P=L=a;14();$.V(P,{1r:"",U:k.U,u:u,m:(m||\'\'),p:p,v:v,A:A,F:F});I(k.1B);I(L.1B);2(v===7&&A===7){I(L.3o)}$.V(P,{1r:1});2(v===7&&A===7){R=m.1S(/\\r?\\n/);2r(j=0,n=R.6,i=0;i<n;i++){2($.3p(R[i])!==\'\'){$.V(P,{1r:++j,m:R[i]});R[i]=1g(R[i]).q}8{R[i]=""}}o={q:R.3q(\'\\n\')};11=p;b=o.q.6+(($.X.1U)?n:0)}8 2(v===7){o=1g(m);11=p+o.J.6;b=o.q.6-o.J.6-o.O.6;b-=1s(o.q)}8 2(A===7){o=1g(m);11=p;b=o.q.6;b-=1s(o.q)}8{o=1g(m);11=p+o.q.6;b=0;11-=1s(o.q)}2((m===\'\'&&o.Q===\'\')){H+=1V(o.q);11=p+o.J.6;b=o.q.6-o.J.6-o.O.6;H=d.K().1h(p,d.K().6).6;H-=1V(d.K().1h(0,p))}$.V(P,{p:p,16:16});2(o.q!==m&&18===l){2A(o.q);1W(11,b)}8{H=-1}14();$.V(P,{1r:\'\',m:m});2(v===7&&A===7){I(L.3r)}I(L.1C);I(k.1C);2(w&&k.1y){1X()}A=F=v=18=l}3 1V(a){2($.X.1U){4 a.6-a.W(/\\n*/g,\'\').6}4 0}3 1s(a){2($.X.2B){4 a.6-a.W(/\\r*/g,\'\').6}4 0}3 2A(a){2(E.m){B b=E.m.1Y();b.2C=a}8{d.K(d.K().1h(0,p)+a+d.K().1h(p+m.6,d.K().6))}}3 1W(a,b){2(u.2D){2($.X.1U&&$.X.3s>=9.5&&b==0){4 l}1i=u.2D();1i.3t(7);1i.2E(\'1Z\',a);1i.3u(\'1Z\',b);1i.3v()}8 2(u.2F){u.2F(a,a+b)}u.1t=16;u.1f()}3 14(){u.1f();16=u.1t;2(E.m){m=E.m.1Y().2C;2($.X.2B){B a=E.m.1Y(),1u=a.3w();1u.3x(u);p=-1;3y(1u.3z(a)){1u.2E(\'1Z\');p++}}8{p=u.2G}}8{p=u.2G;m=d.K().1h(p,u.3A)}4 m}3 1z(){2(!w||w.3B){2(k.1j){w=3C.2H(\'\',\'1z\',k.1j)}8{M=$(\'<2I N="3D"></2I>\');2(k.24==\'25\'){M.1M(1m)}8{M.2f(17)}w=M[M.6-1].3E||3F[M.6-1]}}8 2(F===7){2(M){M.3G()}8{w.2J()}w=M=l}2(!k.1y){1X()}}3 1X(){2K()}3 2K(){B b;2(k.1b!==\'\'){$.2L({2M:\'3H\',2N:k.1b,27:k.26+\'=\'+3I(d.K()),2O:3(a){21(1d(a,1))}})}8{2(!2a){$.2L({2N:k.1k,2O:3(a){21(1d(a,1).W(/<!-- 3J -->/g,d.K()))}})}}4 l}3 21(a){2(w.E){3K{22=w.E.2P.1t}3L(e){22=0}w.E.2H();w.E.3M(a);w.E.2J();w.E.2P.1t=22}2(k.1j){w.1f()}}3 1P(e){A=e.A;F=e.F;v=(!(e.F&&e.v))?e.v:l;2(e.2M===\'2m\'){2(v===7){C=$("a[2p="+3N.3O(e.1v)+"]",17).1w(\'C\');2(C.6!==0){v=l;2v(3(){C.3P(\'1N\')},1);4 l}}2(e.1v===13||e.1v===10){2(v===7){v=l;Y(k.1F);4 k.1F.1x}8 2(A===7){A=l;Y(k.1E);4 k.1E.1x}8{Y(k.1D);4 k.1D.1x}}2(e.1v===9){2(A==7||v==7||F==7){4 l}2(H!==-1){14();H=d.K().6-H;1W(H,0);H=-1;4 l}8{Y(k.1G);4 k.1G.1x}}}}2b()})};$.23.3Q=3(){4 G.1c(3(){B a=$(G).1O().3R(\'2e\');a.1w(\'z\').1w(\'z.T\').1w(\'z\').Q(a)})};$.T=3(a){B b={1p:l};$.V(b,a);2(b.1p){4 $(b.1p).1c(3(){$(G).1f();$(G).2Q(\'1Q\',[b])})}8{$(\'u\').2Q(\'1Q\',[b])}}})(3S);',62,241,'||if|function|return||length|true|else|||||||||||||false|selection||string|caretPosition|block||||textarea|ctrlKey|previewWindow|||div|shiftKey|var|li|id|document|altKey|this|caretOffset|prepare|openWith|val|clicked|iFrame|class|closeWith|hash|replaceWith|lines||markItUp|root|extend|replace|browser|markup|ul||start|nameSpace||get|levels|scrollPosition|header|abort|key|placeHolder|previewParserPath|each|localize|bind|focus|build|substring|range|previewInWindow|previewTemplatePath|resizeHandle|footer|mouseMove|mouseUp|target|title|line|fixIeBug|scrollTop|rangeCopy|keyCode|parent|keepDefault|previewAutoRefresh|preview|html|beforeInsert|afterInsert|onEnter|onShiftEnter|onCtrlEnter|onTab|miuScript|attr|wrap|dropMenus|appendTo|insertAfter|mousedown|unbind|keyPressed|insertion|name|split|value|opera|fixOperaBug|set|refreshPreview|createRange|character||writeInPreview|sp|fn|previewPosition|after|previewParserVar|data|markupSet|null|template|init|substr|addClass|markItUpEditor|insertBefore|height|clientY|css|mousemove|mouseup|append|keydown|focused|hover|accesskey|separator|for|markItUpButton|click|call|setTimeout|hide|dropMenu|magicMarkups|undefined|insert|msie|text|createTextRange|moveStart|setSelectionRange|selectionStart|open|iframe|close|renderPreview|ajax|type|url|success|documentElement|trigger|templates|script|src|match|jquery|markitup|pack|js|toUpperCase|markItUpContainer|markItUpHeader|markItUpFooter|safari|markItUpResizeHandle|Math|max|px|keyup|display|Ctrl|markItUpSeparator|className|href|contextmenu|eval|show|one|push|markItUpDropMenu|pop|toString|prompt|isFunction|beforeMultiInsert|trim|join|afterMultiInsert|version|collapse|moveEnd|select|duplicate|moveToElementText|while|inRange|selectionEnd|closed|window|markItUpPreviewFrame|contentWindow|frame|remove|POST|encodeURIComponent|content|try|catch|write|String|fromCharCode|triggerHandler|markItUpRemove|removeClass|jQuery'.split('|'),0,{})) \ No newline at end of file