Index: extensions/bbcode_bar/bbcode_bar.inc.php
===================================================================
--- extensions/bbcode_bar/bbcode_bar.inc.php	(revision 23202)
+++ extensions/bbcode_bar/bbcode_bar.inc.php	(revision 23203)
@@ -64,5 +64,5 @@
   if (isset($pwg_loaded_plugins['SmiliesSupport'])) 
   {
-    set_smiliessupport($prefilter);
+    set_smiliessupport($prefilter, $textarea_id);
   }  
 }
Index: extensions/bbcode_bar/template/bbcode_bar.tpl
===================================================================
--- extensions/bbcode_bar/template/bbcode_bar.tpl	(revision 23202)
+++ extensions/bbcode_bar/template/bbcode_bar.tpl	(revision 23203)
@@ -23,10 +23,10 @@
     {if $BBC.ul}{counter}{ldelim}name:'{'Unordered list : [ul][li]element[/li][/ul]'|@translate}', openWith:'[ul]\n', closeWith:'\n[/ul]', className:'markItUpListUL'},{/if}
     {if $BBC.ol}{counter}{ldelim}name:'{'Ordered list : [ol][li]element[/li][/ol]'|@translate}', openWith:'[ol]\n', closeWith:'\n[/ol]', className:'markItUpListOL'},{/if}
-    {if $BBC.ul OR $BBC.ol}{counter}{ldelim}name:'{'List element : [li]element[/li]'|@translate}', openWith:'[li]', closeWith:'[/li]', className:'markItUpListLI'},{/if}
+    {if $BBC.ul OR $BBC.ol}{counter}{ldelim}name:'{'List element : [li]element[/li]'|@translate}', multiline:true, openWith:'[li]', closeWith:'[/li]', className:'markItUpListLI'},{/if}
     
     {if $SEP[2]}{counter}{ldelim}separator:'|' },{/if}
     
-    {if $BBC.img}{counter}{ldelim}name:'{'Picture : [img]picture[/img]'|@translate}', key:'P', replaceWith:'[img][![Url]!][/img]', className:'markItUpPicture'},{/if}
-    {if $BBC.url}{counter}{ldelim}name:'{'URL : [url=URL]Title[/url]'|@translate}', key:'L', openWith:'[url=[![Url]!]]', closeWith:'[/url]', className:'markItUpLink'},{/if}
+    {if $BBC.img}{counter}{ldelim}name:'{'Picture : [img]picture[/img]'|@translate}', key:'P', replaceWith:'[img][![Source:!:http://]!][/img]', className:'markItUpPicture'},{/if}
+    {if $BBC.url}{counter}{ldelim}name:'{'URL : [url=URL]Title[/url]'|@translate}', key:'L', openWith:'[url=[![Url:!:http://]!]]', closeWith:'[/url]', className:'markItUpLink'},{/if}
     {if $BBC.email}{counter}{ldelim}name:'{'E-mail : [email]Email[/email]'|@translate}', key:'M', replaceWith:'[email][![Mail]!][/email]', className:'markItUpMail'},{/if}
     
@@ -64,7 +64,6 @@
 };{/strip}
 
-jQuery(document).ready(function() {ldelim}
-  jQuery('#{$BBCODE_ID}').markItUp(BBCodeBar);
-  jQuery('.markItUpHeader>ul').css('width', {$bbc_counter}*22);
-});
+
+jQuery('#{$BBCODE_ID}').markItUp(BBCodeBar);
+jQuery('.markItUpHeader>ul').css('width', {$bbc_counter}*22);
 {/footer_script}
Index: extensions/bbcode_bar/template/markitup/jquery.markitup.js
===================================================================
--- extensions/bbcode_bar/template/markitup/jquery.markitup.js	(revision 23202)
+++ extensions/bbcode_bar/template/markitup/jquery.markitup.js	(revision 23203)
@@ -4,57 +4,6 @@
 // Dual licensed under the MIT and GPL licenses.
 // ----------------------------------------------------------------------------
-// Copyright (C) 2007-2010 Jay Salvat
+// Copyright (C) 2007-2012 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;}).bind("focusin",function(){$$.focus();}).mousedown(function(){if(button.call){eval(button.call)();}
-setTimeout(function(){markup(button)},1);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){var openWith=prepare(clicked.openWith);var placeHolder=prepare(clicked.placeHolder);var replaceWith=prepare(clicked.replaceWith);var closeWith=prepare(clicked.closeWith);if(replaceWith!==""){block=openWith+replaceWith+closeWith;}else if(selection===''&&placeHolder!==''){block=openWith+placeHolder+closeWith;}else{string=string||selection;if(string.match(/ $/)){block=openWith+string.replace(/ $/,'')+closeWith+' ';}else{block=openWith+string+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-1:0);}else if(ctrlKey===true){string=build(selection);start=caretPosition+string.openWith.length;len=string.block.length-string.openWith.length-string.closeWith.length;len=len-(string.block.match(/ $/)?1:0);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{textarea.value=textarea.value.substring(0,caretPosition)+block+textarea.value.substring(caretPosition+selection.length,textarea.value.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;if($.browser.msie){var range=selection.createRange();var stored_range=range.duplicate();stored_range.moveToElementText(textarea);stored_range.setEndPoint('EndToEnd',range);var s=stored_range.text.length-range.text.length;caretPosition=s-(textarea.value.substr(0,s).length-textarea.value.substr(0,s).replace(/\r/g,'').length);selection=range.text;}else{caretPosition=textarea.selectionStart;}}else{caretPosition=textarea.selectionStart;selection=textarea.value.substring(caretPosition,textarea.selectionEnd);}
-return selection;}
-function preview(){if(!previewWindow||previewWindow.closed){if(options.previewInWindow){previewWindow=window.open('','preview',options.previewInWindow);$(window).unload(function(){previewWindow.close();});}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();}
-if(options.previewInWindow){previewWindow.focus();}}
-function refreshPreview(){renderPreview();}
-function renderPreview(){var phtml;if(options.previewParserPath!==''){$.ajax({type:'POST',dataType:'text',global:false,url:options.previewParserPath,data:options.previewParserVar+'='+encodeURIComponent($$.val()),success:function(data){writeInPreview(localize(data,1));}});}else{if(!template){$.ajax({url:options.previewTemplatePath,dataType:'text',global:false,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;}
-previewWindow.document.open();previewWindow.document.write(data);previewWindow.document.close();previewWindow.document.documentElement.scrollTop=sp;}}
-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;setTimeout(function(){li.triggerHandler('mousedown');},1);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(){var $$=$(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);
+(function($){$.fn.markItUp=function(settings,extraSettings){var method,params,options,ctrlKey,shiftKey,altKey;ctrlKey=shiftKey=altKey=false;if(typeof settings=="string"){method=settings;params=extraSettings}options={id:"",nameSpace:"",root:"",previewHandler:false,previewInWindow:"",previewInElement:"",previewAutoRefresh:true,previewPosition:"after",previewTemplatePath:"~/templates/preview.html",previewParser:false,previewParserPath:"",previewParserVar:"data",resizeHandle:true,beforeInsert:"",afterInsert:"",onEnter:{},onShiftEnter:{},onCtrlEnter:{},onTab:{},markupSet:[{}]};$.extend(options,settings,extraSettings);if(!options.root){$("script").each(function(e,t){miuScript=$(t).get(0).src.match(/(.*)jquery\.markitup(\.pack)?\.js$/);if(miuScript!==null){options.root=miuScript[1]}})}var uaMatch=function(e){e=e.toLowerCase();var t=/(chrome)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[];return{browser:t[1]||"",version:t[2]||"0"}};var matched=uaMatch(navigator.userAgent);var browser={};if(matched.browser){browser[matched.browser]=true;browser.version=matched.version}if(browser.chrome){browser.webkit=true}else if(browser.webkit){browser.safari=true}return this.each(function(){function localize(e,t){if(t){return e.replace(/("|')~\//g,"$1"+options.root)}return e.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.markItUp",function(e){var t=$$.height(),n=e.clientY,r,i;r=function(e){$$.css("height",Math.max(20,e.clientY+t-n)+"px");return false};i=function(e){$("html").unbind("mousemove.markItUp",r).unbind("mouseup.markItUp",i);return false};$("html").bind("mousemove.markItUp",r).bind("mouseup.markItUp",i)});footer.append(resizeHandle)}$$.bind("keydown.markItUp",keyPressed).bind("keyup",keyPressed);$$.bind("insertion.markItUp",function(e,t){if(t.target!==false){get()}if(textarea===$.markItUp.focused){markup(t)}});$$.bind("focus.markItUp",function(){$.markItUp.focused=this});if(options.previewInElement){refreshPreview()}}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.markItUp",function(){return false}).bind("click.markItUp",function(e){e.preventDefault()}).bind("focusin.markItUp",function(){$$.focus()}).bind("mouseup",function(){if(button.call){eval(button.call)()}setTimeout(function(){markup(button)},1);return false}).bind("mouseenter.markItUp",function(){$("> ul",this).show();$(document).one("click",function(){$("ul ul",header).hide()})}).bind("mouseleave.markItUp",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(e){if(e){e=e.toString();e=e.replace(/\(\!\(([\s\S]*?)\)\!\)/g,function(e,t){var n=t.split("|!|");if(altKey===true){return n[1]!==undefined?n[1]:n[0]}else{return n[1]===undefined?"":n[0]}});e=e.replace(/\[\!\[([\s\S]*?)\]\!\]/g,function(e,t){var n=t.split(":!:");if(abort===true){return false}value=prompt(n[0],n[1]?n[1]:"");if(value===null){abort=true}return value});return e}return""}function prepare(e){if($.isFunction(e)){e=e(hash)}return magicMarkups(e)}function build(e){var t=prepare(clicked.openWith);var n=prepare(clicked.placeHolder);var r=prepare(clicked.replaceWith);var i=prepare(clicked.closeWith);var s=prepare(clicked.openBlockWith);var o=prepare(clicked.closeBlockWith);var u=clicked.multiline;if(r!==""){block=t+r+i}else if(selection===""&&n!==""){block=t+n+i}else{e=e||selection;var a=[e],f=[];if(u===true){a=e.split(/\r?\n/)}for(var l=0;l<a.length;l++){line=a[l];var c;if(c=line.match(/ *$/)){f.push(t+line.replace(/ *$/g,"")+i+c)}else{f.push(t+line+i)}}block=f.join("\n")}block=s+block+o;return{block:block,openBlockWith:s,openWith:t,replaceWith:r,placeHolder:n,closeWith:i,closeBlockWith:o}}function markup(e){var t,n,r,i;hash=clicked=e;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||e.multiline===true){prepare(clicked.beforeMultiInsert)}$.extend(hash,{line:1});if(ctrlKey===true&&shiftKey===true){lines=selection.split(/\r?\n/);for(n=0,r=lines.length,i=0;i<r;i++){if($.trim(lines[i])!==""){$.extend(hash,{line:++n,selection:lines[i]});lines[i]=build(lines[i]).block}else{lines[i]=""}}string={block:lines.join("\n")};start=caretPosition;t=string.block.length+(browser.opera?r-1:0)}else if(ctrlKey===true){string=build(selection);start=caretPosition+string.openWith.length;t=string.block.length-string.openWith.length-string.closeWith.length;t=t-(string.block.match(/ $/)?1:0);t-=fixIeBug(string.block)}else if(shiftKey===true){string=build(selection);start=caretPosition;t=string.block.length;t-=fixIeBug(string.block)}else{string=build(selection);start=caretPosition+string.block.length;t=0;start-=fixIeBug(string.block)}if(selection===""&&string.replaceWith===""){caretOffset+=fixOperaBug(string.block);start=caretPosition+string.openBlockWith.length+string.openWith.length;t=string.block.length-string.openBlockWith.length-string.openWith.length-string.closeWith.length-string.closeBlockWith.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,t)}else{caretOffset=-1}get();$.extend(hash,{line:"",selection:selection});if(ctrlKey===true&&shiftKey===true||e.multiline===true){prepare(clicked.afterMultiInsert)}prepare(clicked.afterInsert);prepare(options.afterInsert);if(previewWindow&&options.previewAutoRefresh){refreshPreview()}shiftKey=altKey=ctrlKey=abort=false}function fixOperaBug(e){if(browser.opera){return e.length-e.replace(/\n*/g,"").length}return 0}function fixIeBug(e){if(browser.msie){return e.length-e.replace(/\r*/g,"").length}return 0}function insert(e){if(document.selection){var t=document.selection.createRange();t.text=e}else{textarea.value=textarea.value.substring(0,caretPosition)+e+textarea.value.substring(caretPosition+selection.length,textarea.value.length)}}function set(e,t){if(textarea.createTextRange){if(browser.opera&&browser.version>=9.5&&t==0){return false}range=textarea.createTextRange();range.collapse(true);range.moveStart("character",e);range.moveEnd("character",t);range.select()}else if(textarea.setSelectionRange){textarea.setSelectionRange(e,e+t)}textarea.scrollTop=scrollPosition;textarea.focus()}function get(){textarea.focus();scrollPosition=textarea.scrollTop;if(document.selection){selection=document.selection.createRange().text;if(browser.msie){var e=document.selection.createRange(),t=e.duplicate();t.moveToElementText(textarea);caretPosition=-1;while(t.inRange(e)){t.moveStart("character");caretPosition++}}else{caretPosition=textarea.selectionStart}}else{caretPosition=textarea.selectionStart;selection=textarea.value.substring(caretPosition,textarea.selectionEnd)}return selection}function preview(){if(typeof options.previewHandler==="function"){previewWindow=true}else if(options.previewInElement){previewWindow=$(options.previewInElement)}else if(!previewWindow||previewWindow.closed){if(options.previewInWindow){previewWindow=window.open("","preview",options.previewInWindow);$(window).unload(function(){previewWindow.close()})}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()}if(options.previewInWindow){previewWindow.focus()}}function refreshPreview(){renderPreview()}function renderPreview(){var e;if(options.previewHandler&&typeof options.previewHandler==="function"){options.previewHandler($$.val())}else if(options.previewParser&&typeof options.previewParser==="function"){var t=options.previewParser($$.val());writeInPreview(localize(t,1))}else if(options.previewParserPath!==""){$.ajax({type:"POST",dataType:"text",global:false,url:options.previewParserPath,data:options.previewParserVar+"="+encodeURIComponent($$.val()),success:function(e){writeInPreview(localize(e,1))}})}else{if(!template){$.ajax({url:options.previewTemplatePath,dataType:"text",global:false,success:function(e){writeInPreview(localize(e,1).replace(/<!-- content -->/g,$$.val()))}})}}return false}function writeInPreview(e){if(options.previewInElement){$(options.previewInElement).html(e)}else if(previewWindow&&previewWindow.document){try{sp=previewWindow.document.documentElement.scrollTop}catch(t){sp=0}previewWindow.document.open();previewWindow.document.write(e);previewWindow.document.close();previewWindow.document.documentElement.scrollTop=sp}}function keyPressed(e){shiftKey=e.shiftKey;altKey=e.altKey;ctrlKey=!(e.altKey&&e.ctrlKey)?e.ctrlKey||e.metaKey:false;if(e.type==="keydown"){if(ctrlKey===true){li=$('a[accesskey="'+(e.keyCode==13?"\\n":String.fromCharCode(e.keyCode))+'"]',header).parent("li");if(li.length!==0){ctrlKey=false;setTimeout(function(){li.triggerHandler("mouseup")},1);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}}}}function remove(){$$.unbind(".markItUp").removeClass("markItUpEditor");$$.parent("div").parent("div.markItUp").parent("div").replaceWith($$);$$.data("markItUp",null)}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);if(method){switch(method){case"remove":remove();break;case"insert":markup(params);break;default:$.error("Method "+method+" does not exist on jQuery.markItUp")}return}init()})};$.fn.markItUpRemove=function(){return this.each(function(){$(this).markItUp("remove")})};$.markItUp=function(e){var t={target:false};$.extend(t,e);if(t.target){return $(t.target).each(function(){$(this).focus();$(this).trigger("insertion",[t])})}else{$("textarea").trigger("insertion",[t])}}})(jQuery)
