Vous êtes sur la page 1sur 19

/*

Redactor v8.2.6
Updated: April 6, 2013
http://redactorjs.com/
Copyright (c) 2009-2013, Imperavi Inc.
License: http://redactorjs.com/license/
Usage: $('#content').redactor();
*/
var rwindow,rdocument;if("undefined"===typeof RELANG)var RELANG={};
var RLANG={html:"HTML",video:"Insert Video",image:"Insert Image",table:"Table",l
ink:"Link",link_insert:"Insert link",unlink:"Unlink",formatting:"Formatting",par
agraph:"Paragraph",quote:"Quote",code:"Code",header1:"Header 1",header2:"Header
2",header3:"Header 3",header4:"Header 4",bold:"Bold",italic:"Italic",fontcolor:"
Font Color",backcolor:"Back Color",unorderedlist:"Unordered List",orderedlist:"O
rdered List",outdent:"Outdent",indent:"Indent",cancel:"Cancel",insert:"Insert",s
ave:"Save",_delete:"Delete",
insert_table:"Insert Table",insert_row_above:"Add Row Above",insert_row_below:"A
dd Row Below",insert_column_left:"Add Column Left",insert_column_right:"Add Colu
mn Right",delete_column:"Delete Column",delete_row:"Delete Row",delete_table:"De
lete Table",rows:"Rows",columns:"Columns",add_head:"Add Head",delete_head:"Delet
e Head",title:"Title",image_position:"Position",none:"None",left:"Left",right:"R
ight",image_web_link:"Image Web Link",text:"Text",mailto:"Email",web:"URL",video
_html_code:"Video Embed Code",
file:"Insert File",upload:"Upload",download:"Download",choose:"Choose",or_choose
:"Or choose",drop_file_here:"Drop file here",align_left:"Align text to the left"
,align_center:"Center text",align_right:"Align text to the right",align_justify:
"Justify text",horizontalrule:"Insert Horizontal Rule",deleted:"Deleted",anchor:
"Anchor",link_new_tab:"Open link in new tab",underline:"Underline",alignment:"Al
ignment"};
(function(b){jQuery.fn.redactor=function(a){return this.each(function(){var c=b(
this);c.data("redactor")||c.data("redactor",new l(this,a))})};var l=function(a,c
){this.$el=b(a);"undefined"!==typeof c&&"undefined"!==typeof c.lang&&"en"!==c.la
ng&&"undefined"!==typeof RELANG[c.lang]&&(RLANG=RELANG[c.lang]);this.opts=b.exte
nd({iframe:!1,css:!1,iframeBase:!1,lang:"en",direction:"ltr",callback:!1,keyupCa
llback:!1,keydownCallback:!1,execCommandCallback:!1,insertHtmlCallback:!1,pasteP
reventCallback:!1,pasteManipulateCallback:!1,
pasteCleanUpCallback:!1,modalCreateCallback:!1,modalLoadCallback:!1,execCommandH
andler:{},plugins:!1,cleanup:!0,focus:!1,tabindex:!1,autoresize:!0,minHeight:!1,
fixed:!1,fixedTop:0,fixedBox:!1,source:!0,shortcuts:!0,insertTab:!1,undoSize:30,
mobile:!0,air:!1,wym:!1,convertLinks:!0,convertDivs:!0,protocol:"http://",autosa
ve:!1,autosaveCallback:!1,interval:60,imageGetJson:!1,imageUpload:!1,imageUpload
Callback:!1,imageUploadErrorCallback:!1,fileUpload:!1,fileUploadCallback:!1,file
UploadErrorCallback:!1,
uploadCrossDomain:!1,uploadFields:!1,observeImages:!0,overlay:!0,allowedTags:"fo
rm input button select option datalist output textarea fieldset legend section h
eader hgroup aside footer article details nav progress time canvas code span div
label a br p b i del strike u font img video source track audio iframe object e
mbed param blockquote mark cite small ul ol li hr dl dt dd sup sub big pre code
figure figcaption strong em table tr td th tbody thead tfoot h1 h2 h3 h4 h5 h6".
split(" "),toolbarExternal:!1,
buttonsCustom:{},buttonsAdd:[],buttons:"html | formatting | bold italic deleted
| unorderedlist orderedlist outdent indent | image video file table link | fontc
olor backcolor | alignment | horizontalrule".split(" "),airButtons:"formatting |
bold italic deleted | unorderedlist orderedlist outdent indent | fontcolor back
color".split(" "),formattingTags:"p blockquote pre h1 h2 h3 h4".split(" "),activ
eButtons:"deleted italic bold underline unorderedlist orderedlist".split(" "),ac

tiveButtonsStates:{b:"bold",
strong:"bold",i:"italic",em:"italic",del:"deleted",strike:"deleted",s:"deleted",
ul:"unorderedlist",ol:"orderedlist",u:"underline"},activeButtonStateMap:{bold:"b
old",italic:"italic",underline:"underline",deleted:"strikethrough"},allowJustify
:!0,cleanupFontTags:!0,colors:"#ffffff #ff9999 #ffcc99 #ffff99 #ccff99 #99ff99 #
99ffcc #99ffff #99ccff #9999ff #cc99ff #ff99ff #ff99cc #bfbfbf #ff4d4d #ffa64d #
ffff4d #a6ff4d #4dff4d #4dffa6 #4dffff #4da6ff #4d4dff #a64dff #ff4dff #ff4da6 #
808080 #ff0000 #ff8000 #ffff00 #80ff00 #00ff00 #00ff80 #00ffff #0080ff #0000ff #
8000ff #ff00ff #ff0080 #404040 #b30000 #b35900 #b3b300 #59b300 #00b300 #00b359 #
00b3b3 #0059b3 #0000b3 #5900b3 #b300b3 #b30059 #000000 #660000 #663300 #666600 #
336600 #006600 #006633 #006666 #003366 #000066 #330066 #660066 #660033".split("
"),
colorWidth:247,emptyHtml:"<p>"+(this.browser("msie")?"":"<br />")+"</p>",buffer:
!1,visual:!0,modal_file:String()+'<div id="redactor_modal_content"><form id="red
actorUploadFileForm" method="post" action="" enctype="multipart/form-data"><labe
l>Name (optional)</label><input type="text" id="redactor_filename" class="redact
or_input" /><div style="margin-top: 7px;"><input type="file" id="redactor_file"
name="file" /></div></form><br></div>',modal_image_edit:String()+'<div id="redac
tor_modal_content"><label>'+
RLANG.title+'</label><input id="redactor_file_alt" class="redactor_input" /><lab
el>'+RLANG.link+'</label><input id="redactor_file_link" class="redactor_input" /
><label>'+RLANG.image_position+'</label><select id="redactor_form_image_align"><
option value="none">'+RLANG.none+'</option><option value="left">'+RLANG.left+'</
option><option value="right">'+RLANG.right+'</option></select></div><div id="red
actor_modal_footer"><a href="javascript:void(null);" id="redactor_image_delete_b
tn" class="redactor_modal_btn">'+
RLANG._delete+'</a>&nbsp;&nbsp;&nbsp;<a href="javascript:void(null);" class="red
actor_modal_btn redactor_btn_modal_close">'+RLANG.cancel+'</a><input type="butto
n" name="save" class="redactor_modal_btn" id="redactorSaveBtn" value="'+RLANG.sa
ve+'" /></div>',modal_image:String()+'<div id="redactor_modal_content"><div id="
redactor_tabs"><a href="javascript:void(null);" class="redactor_tabs_act">'+RLAN
G.upload+'</a><a href="javascript:void(null);">'+RLANG.choose+'</a><a href="java
script:void(null);">'+
RLANG.link+'</a></div><form id="redactorInsertImageForm" method="post" action=""
enctype="multipart/form-data"><div id="redactor_tab1" class="redactor_tab"><inp
ut type="file" id="redactor_file" name="file" /></div><div id="redactor_tab2" cl
ass="redactor_tab" style="display: none;"><div id="redactor_image_box"></div></d
iv></form><div id="redactor_tab3" class="redactor_tab" style="display: none;"><l
abel>'+RLANG.image_web_link+'</label><input type="text" name="redactor_file_link
" id="redactor_file_link" class="redactor_input" /></div></div><div id="redacto
r_modal_footer"><a href="javascript:void(null);" class="redactor_modal_btn redac
tor_btn_modal_close">'+
RLANG.cancel+'</a><input type="button" name="upload" class="redactor_modal_btn"
id="redactor_upload_btn" value="'+RLANG.insert+'" /></div>',modal_link:String()+
'<div id="redactor_modal_content"><form id="redactorInsertLinkForm" method="post
" action=""><div id="redactor_tabs"><a href="javascript:void(null);" class="reda
ctor_tabs_act">URL</a><a href="javascript:void(null);">Email</a><a href="javascr
ipt:void(null);">'+RLANG.anchor+'</a></div><input type="hidden" id="redactor_tab
_selected" value="1" /><div class="redactor_tab" id="redactor_tab1"><label>URL</
label><input type="text" id="redactor_link_url" class="redactor_input" /><label
>'+
RLANG.text+'</label><input type="text" class="redactor_input redactor_link_text"
id="redactor_link_url_text" /><label><input type="checkbox" id="redactor_link_b
lank"> '+RLANG.link_new_tab+'</label></div><div class="redactor_tab" id="redacto
r_tab2" style="display: none;"><label>Email</label><input type="text" id="redact
or_link_mailto" class="redactor_input" /><label>'+RLANG.text+'</label><input typ
e="text" class="redactor_input redactor_link_text" id="redactor_link_mailto_text
" /></div><div class="redactor_tab" id="redactor_tab3" style="display: none;"><l
abel>'+
RLANG.anchor+'</label><input type="text" class="redactor_input" id="redactor_lin

k_anchor" /><label>'+RLANG.text+'</label><input type="text" class="redactor_inp


ut redactor_link_text" id="redactor_link_anchor_text" /></div></form></div><div
id="redactor_modal_footer"><a href="javascript:void(null);" class="redactor_moda
l_btn redactor_btn_modal_close">'+RLANG.cancel+'</a><input type="button" class="
redactor_modal_btn" id="redactor_insert_link_btn" value="'+RLANG.insert+'" /></d
iv>',modal_table:String()+
'<div id="redactor_modal_content"><label>'+RLANG.rows+'</label><input type="text
" size="5" value="2" id="redactor_table_rows" /><label>'+RLANG.columns+'</label>
<input type="text" size="5" value="3" id="redactor_table_columns" /></div><div i
d="redactor_modal_footer"><a href="javascript:void(null);" class="redactor_modal
_btn redactor_btn_modal_close">'+RLANG.cancel+'</a><input type="button" name="up
load" class="redactor_modal_btn" id="redactor_insert_table_btn" value="'+RLANG.i
nsert+'" /></div>',modal_video:String()+
'<div id="redactor_modal_content"><form id="redactorInsertVideoForm"><label>'+RL
ANG.video_html_code+'</label><textarea id="redactor_insert_video_area" style="wi
dth: 99%; height: 160px;"></textarea></form></div><div id="redactor_modal_footer
"><a href="javascript:void(null);" class="redactor_modal_btn redactor_btn_modal_
close">'+RLANG.cancel+'</a><input type="button" class="redactor_modal_btn" id="r
edactor_insert_video_btn" value="'+RLANG.insert+'" /></div>',toolbar:{html:{titl
e:RLANG.html,func:"toggle"},
formatting:{title:RLANG.formatting,func:"show",dropdown:{p:{title:RLANG.paragrap
h,exec:"formatblock"},blockquote:{title:RLANG.quote,exec:"formatblock",className
:"redactor_format_blockquote"},pre:{title:RLANG.code,exec:"formatblock",classNam
e:"redactor_format_pre"},h1:{title:RLANG.header1,exec:"formatblock",className:"r
edactor_format_h1"},h2:{title:RLANG.header2,exec:"formatblock",className:"redact
or_format_h2"},h3:{title:RLANG.header3,exec:"formatblock",className:"redactor_fo
rmat_h3"},h4:{title:RLANG.header4,
exec:"formatblock",className:"redactor_format_h4"}}},bold:{title:RLANG.bold,exec
:"bold"},italic:{title:RLANG.italic,exec:"italic"},deleted:{title:RLANG.deleted,
exec:"strikethrough"},underline:{title:RLANG.underline,exec:"underline"},unorder
edlist:{title:"&bull; "+RLANG.unorderedlist,exec:"insertunorderedlist"},orderedl
ist:{title:"1. "+RLANG.orderedlist,exec:"insertorderedlist"},outdent:{title:"< "
+RLANG.outdent,exec:"outdent"},indent:{title:"> "+RLANG.indent,exec:"indent"},im
age:{title:RLANG.image,
func:"showImage"},video:{title:RLANG.video,func:"showVideo"},file:{title:RLANG.f
ile,func:"showFile"},table:{title:RLANG.table,func:"show",dropdown:{insert_table
:{title:RLANG.insert_table,func:"showTable"},separator_drop1:{name:"separator"},
insert_row_above:{title:RLANG.insert_row_above,func:"insertRowAbove"},insert_row
_below:{title:RLANG.insert_row_below,func:"insertRowBelow"},insert_column_left:{
title:RLANG.insert_column_left,func:"insertColumnLeft"},insert_column_right:{tit
le:RLANG.insert_column_right,
func:"insertColumnRight"},separator_drop2:{name:"separator"},add_head:{title:RLA
NG.add_head,func:"addHead"},delete_head:{title:RLANG.delete_head,func:"deleteHea
d"},separator_drop3:{name:"separator"},delete_column:{title:RLANG.delete_column,
func:"deleteColumn"},delete_row:{title:RLANG.delete_row,func:"deleteRow"},delete
_table:{title:RLANG.delete_table,func:"deleteTable"}}},link:{title:RLANG.link,fu
nc:"show",dropdown:{link:{title:RLANG.link_insert,func:"showLink"},unlink:{title
:RLANG.unlink,exec:"unlink"}}},
fontcolor:{title:RLANG.fontcolor,func:"show"},backcolor:{title:RLANG.backcolor,f
unc:"show"},alignment:{title:RLANG.alignment,func:"show",dropdown:{alignleft:{ti
tle:RLANG.align_left,exec:"JustifyLeft"},aligncenter:{title:RLANG.align_center,e
xec:"JustifyCenter"},alignright:{title:RLANG.align_right,exec:"JustifyRight"},ju
stify:{title:RLANG.align_justify,exec:"JustifyFull"}}},alignleft:{exec:"JustifyL
eft",title:RLANG.align_left},aligncenter:{exec:"JustifyCenter",title:RLANG.align
_center},alignright:{exec:"JustifyRight",
title:RLANG.align_right},justify:{exec:"JustifyFull",title:RLANG.align_justify},
horizontalrule:{exec:"inserthorizontalrule",title:RLANG.horizontalrule}}},c,this
.$el.data());this.dropdowns=[];this.deferredModal={};this.undoStack=[];this.redo
Stack=[];this.typingType=null;this.typingCount=0;this.init()};l.prototype={init:
function(){this.height=this.$el.css("height");this.width=this.$el.css("width");r

document=this.document=document;rwindow=this.window=window;if(!1===this.opts.mob
ile&&this.isMobile())return this.build(!0),
!1;this.opts.iframe&&(this.opts.autoresize=!1);if(this.opts.air)b.extend(this.op
ts.toolbar,this.opts.buttonsCustom),this.opts.buttons=this.opts.airButtons;else
if(!1!==this.opts.toolbar){if(!1===this.opts.source){var a=b.inArray("html",this
.opts.buttons);if(-1!=a){var c=this.opts.buttons[a+1];this.opts.buttons.splice(a
,1);"undefined"!==typeof c&&"|"===c&&this.opts.buttons.splice(a,1)}}b.extend(thi
s.opts.toolbar,this.opts.buttonsCustom);b.each(this.opts.buttonsAdd,b.proxy(func
tion(a,b){this.opts.buttons.push(b)},
this))}!1!==this.opts.toolbar&&(b.each(this.opts.toolbar.formatting.dropdown,b.p
roxy(function(a,c){"-1"==b.inArray(a,this.opts.formattingTags)&&delete this.opts
.toolbar.formatting.dropdown[a]},this)),this.opts.allowJustify||delete this.opts
.toolbar.alignment.dropdown.justify);this.build(!1,function(){this.enableAir();t
his.buildToolbar();this.pushUndoStack(!1);"object"===typeof this.opts.plugins&&b
.each(this.opts.plugins,b.proxy(function(a,c){"undefined"!==typeof RedactorPlugi
ns[c]&&(b.extend(this,
RedactorPlugins[c]),"undefined"!==typeof RedactorPlugins[c].init&&this.init())},
this));!1===this.opts.activeButtons||!1===this.opts.toolbar||this.isMobile(!0)||
(b.proxy(function(){this.observeFormatting()},this),this.$editor.click(b.proxy(f
unction(){this.observeFormatting()},this)).keyup(b.proxy(function(a){a=a.keyCode
||a.which;switch(a){case 17:case 91:case 92:case 93:case 224:return}this.observe
Formatting(a)},this)));this.$editor.bind("paste",b.proxy(function(a){this.pushUn
doStack();if(!1===this.opts.cleanup)return!0;
if(this.opts.pastePreventCallback){var c=new b.Event;this.opts.pastePreventCallb
ack(c,this,a);if(c.isDefaultPrevented())return!0}this.pasteRunning=!0;this.setBu
ffer();this.saveScroll=!0===this.opts.autoresize?this.document.body.scrollTop:th
is.$editor.scrollTop();var d=null,h;if(this.browser("msie")||this.isMobile(!0))t
his.$editor.css("height",this.$editor.height()+"px"),d=this.extractContent();els
e{var c=this.document.createTextNode("\u200b\u200b"),k=this.getFocus()[0],k=k?3=
=k.nodeType?b(k).parent().offset().top:
b(k).offset().top:0;this.$editor.find(".redactorPaste").removeClass("redactorPas
te");h=b("<div />",this.document).append(c).css({overflow:"hidden",width:"1px",h
eight:"1px",position:"absolute",left:"-1000px",top:k+"px"}).addClass("redactorPa
ste");this.$editor.append(h);this.setSelection(c,0,c,2)}setTimeout(b.proxy(funct
ion(){var c;if(h){var f=this.$editor.find("> .redactorPaste");f.each(function(a)
{0<a&&h.append(b(this).contents())});c=this.extractContent(h[0]);f.remove()}else
c=this.extractContent(),
this.$editor.css("height","").append(d);this.restoreSelection();this.opts.pasteM
anipulateCallback&&this.opts.pasteManipulateCallback(this,c,a);c=this.getFragmen
tHtml(c);this.pasteCleanUp(c);this.pasteRunning=!1},this),1)},this));this.keyup(
);this.keydown();this.$editor.keypress(b.proxy(function(a){a.stopPropagation();i
f(!a.ctrlKey&&!a.metaKey)this.onTyping("key")},this));this.$editor.mousedown(b.p
roxy(function(a){this.onTyping("move")},this));!1!==this.opts.autosave&&this.aut
oSave();setTimeout(b.proxy(function(){this.observeImages();
this.observeTables()},this),1);if(this.browser("mozilla")){this.$editor.click(b.
proxy(function(){this.saveSelection()},this));try{this.document.execCommand("ena
bleObjectResizing",!1,!1),this.document.execCommand("enableInlineTableEditing",!
1,!1)}catch(a){}}this.opts.focus&&setTimeout(b.proxy(function(){this.focus()},th
is),1);this.opts.fixed&&(this.observeScroll(),b(document).scroll(b.proxy(this.ob
serveScroll,this)));"function"===typeof this.opts.callback&&this.opts.callback(t
his);!1!==this.opts.toolbar&&
this.$toolbar.find("a").attr("tabindex","-1");if(this.browser("msie"))this.$edit
or.one("click",b.proxy(function(){this.focus()},this))})},shortcuts:function(a,c
){a.preventDefault();var d=!1;b.each(this.opts.activeButtonStateMap,function(a,b
){if(b==c)return d=a,!1});d&&(this.skipFormatObserveOnce=!0,this.toggleBtnActive
(d));this.execCommand(c,!1)},keyup:function(){this.$editor.keyup(b.proxy(functio
n(a){var b=a.keyCode||a.which;this.browser("mozilla")&&!this.pasteRunning&&this.
saveSelection();"function"===
typeof this.opts.keyupCallback&&this.opts.keyupCallback(this,a);if(8===b||46===b
)return this.observeImages(),this.formatEmpty(a);if(13===b&&!a.shiftKey&&!a.ctrl

Key&&!a.metaKey){if(this.browser("mozilla")){try{this.document.execCommand("unli
nk",!1,null)}catch(d){}var b=this.window.getSelection(),e=b.anchorNode;if(b.isCo
llapsed&&0==b.anchorOffset&&e&&"A"===e.tagName&&"<br>"==e.innerHTML){var f=e.par
entNode;b.selectAllChildren(e.parentNode);f.innerHTML="<br>"}}this.browser("webk
it")&&this.formatNewLine(a);
this.opts.convertLinks&&this.$editor.linkify()}this.syncCode()},this))},keydown:
function(){this.$editor.keydown(b.proxy(function(a){var c=a.keyCode||a.which;if(
c){var d=this.getParentNode(),e=this.getCurrentNode(),f=!1,g=(a.ctrlKey||a.metaK
ey)&&!a.altKey,h=!a.ctrlKey&&a.metaKey;if(d&&"PRE"===b(d).get(0).tagName||e&&"PR
E"===b(e).get(0).tagName)f=!0;"function"===typeof this.opts.keydownCallback&&thi
s.opts.keydownCallback(this,a);if(13==c)this.pushUndoStack();else if(8==c||46==c
)this.onTyping("delete");
else if(33<=c&&40>=c)this.onTyping("move");if(h&&this.opts.shortcuts){var k;if(t
his.window.getSelection&&(k=this.window.getSelection())&&k.modify)switch(d=a.shi
ftKey?"extend":"move",c){case 39:k.modify(d,"right","lineboundary");a.preventDef
ault();break;case 37:k.modify(d,"left","lineboundary"),a.preventDefault()}}g&&th
is.opts.shortcuts&&(90===c?a.shiftKey?this.shortcuts(a,"redo"):this.shortcuts(a,
"undo"):89==c?this.shortcuts(a,"redo"):77===c?this.shortcuts(a,"removeformat"):6
6===c?this.shortcuts(a,
"bold"):73===c?this.shortcuts(a,"italic"):85===c?this.shortcuts(a,"underline"):7
4===c?this.shortcuts(a,"insertunorderedlist"):75===c?this.shortcuts(a,"insertord
eredlist"):76===c?this.shortcuts(a,"superscript"):72===c&&this.shortcuts(a,"subs
cript"));g||90===c||(this.opts.buffer=!1);if(!0===f&&13===c)return a.preventDefa
ult(),a=b(e).parent().text(),this.insertNodeAtCaret(this.document.createTextNode
("\r\n")),-1==a.search(/\s$/)&&this.insertNodeAtCaret(this.document.createTextNo
de("\r\n")),this.syncCode(),
!1;if(this.opts.shortcuts&&!a.shiftKey&&9===c&&this.opts.insertTab)if(!1===f)thi
s.shortcuts(a,"indent");else return a.preventDefault(),this.insertNodeAtCaret(th
is.document.createTextNode("\t")),this.syncCode(),!1;else this.opts.shortcuts&&a
.shiftKey&&9===c&&this.opts.insertTab&&this.shortcuts(a,"outdent");if(this.brows
er("webkit")&&-1===navigator.userAgent.indexOf("Chrome"))return this.safariShift
KeyEnter(a,c)}},this))},build:function(a,c){if(!0!==a){var d=function(){var a=th
is.$content.contents(),
d=a.find("head");this.$editor=a.find("body").attr("contenteditable",!0).attr("di
r",this.opts.direction);rdocument=this.document=this.$editor[0].ownerDocument;rw
indow=this.window=this.document.defaultView||window;b(rdocument).on("touchend",f
unction(a){setTimeout(function(){rwindow.focus()},100)});!1!==this.opts.iframeBa
se&&d.append('<base href="'+this.opts.iframeBase+'" />');!1!==this.opts.css&&d.a
ppend('<link rel="stylesheet" href="'+this.opts.css+'" />');this.$editor.html(g)
;c&&(c.call(this),c=null)};
this.$box=b('<div class="redactor_box"></div>');this.opts.air&&(this.air=b('<div
class="redactor_air" style="display: none;"></div>'));this.$content=null;this.t
extareamode=!0;if("TEXTAREA"===this.$el.get(0).tagName){if(this.opts.iframe){var
e=this;this.$content=b('<iframe style="width: 100%;" frameborder="0"></iframe>'
).load(function(){d.call(e)})}else this.$content=this.$editor=b("<div></div>");v
ar f=this.$el.get(0).className.split(/\s+/);b.each(f,b.proxy(function(a,b){this.
$content.addClass("redactor_"+
b)},this))}else this.textareamode=!1,this.$content=this.$editor=this.$el,this.$e
l=b('<textarea name="'+this.$editor.attr("id")+'"></textarea>').css("height",thi
s.height);this.$editor&&this.$editor.addClass("redactor_editor").attr("contented
itable",!0).attr("dir",this.opts.direction);!1!==this.opts.tabindex&&this.$conte
nt.attr("tabindex",this.opts.tabindex);!1!==this.opts.minHeight&&this.$content.c
ss("min-height",this.opts.minHeight+"px");!0===this.opts.wym&&this.$content.addC
lass("redactor_editor_wym");
!1===this.opts.autoresize&&this.$content.css("height",this.height);this.$el.hide
();var g="";this.textareamode?(g=this.$el.val(),g=this.savePreCode(g),this.$box.
insertAfter(this.$el).append(this.$content).append(this.$el)):(g=this.$editor.ht
ml(),g=this.savePreCode(g),this.$box.insertAfter(this.$content).append(this.$el)
.append(this.$editor));g=this.paragraphy(g);this.$editor&&this.$editor.html(g);!
1===this.textareamode&&this.syncCode()}else"TEXTAREA"!==this.$el.get(0).tagName&

&(g=this.$el.val(),f=
b('<textarea name="'+this.$editor.attr("id")+'"></textarea>').css("height",this.
height).val(g),this.$el.hide(),this.$el.after(f));c&&this.$editor&&c.call(this)}
,enableAir:function(){if(!1===this.opts.air)return!1;this.air.hide();this.$edito
r.bind("textselect",b.proxy(function(a){this.showAir(a)},this));this.$editor.bin
d("textunselect",b.proxy(function(){this.air.hide()},this))},showAir:function(a)
{b(".redactor_air").hide();var c=this.air.innerWidth(),d=a.clientX;b(this.docume
nt).width()<d+c&&(d-=
c);a=a.clientY+b(document).scrollTop()+14;!0===this.opts.iframe&&(a+=this.$box.p
osition().top,d+=this.$box.position().left);this.air.css({left:d+"px",top:a+"px"
}).show()},pushUndoStack:function(a){var b=this.getState();this.undoStack.length
&&this.compareStates(this.undoStack[this.undoStack.length-1],b)||(void 0===a&&(a
=!0),this.undoStack.length==this.opts.undoSize&&this.undoStack.shift(),this.undo
Stack.push(b),this.redoStack=[],a&&this.resetTyping())},popUndoStack:function(){
var a=this.undoStack.pop(),
b;a&&(b=this.getState(),this.compareStates(a,b)||(this.redoStack.push(b),this.re
storeState(a)))},popRedoStack:function(){var a=this.redoStack.pop();a&&(this.und
oStack.push(this.getState()),this.restoreState(a))},restoreState:function(a){thi
s.$editor.html(a.html);this.focus();if(!this.oldIE()){if(a.origin){var b=functio
n(a){if(!a)return[null,null];for(var b=d.$editor.get(0),c=0,e=0;e<a.length;e++)s
witch(a[e][0]){case "node":b=b.childNodes[a[e][1]];break;case "text":c=a[e][1]}r
eturn[b,c]},d=this,e=
b(a.origin);a=b(a.focus);this.setSelection(e[0],e[1],a[0],a[1]);this.focus()}els
e this.selectLast();this.resetTyping()}},getState:function(){function a(a){var b
=[],c=e.$editor.get(0);3==a[0].nodeType&&b.unshift(["text",a[1]]);for(var d=a[0]
,m;d&&d!=c;){a=0;for(m=d;m=m.previousSibling;)a++;b.unshift(["node",a]);d=d.pare
ntNode}return b}var b=this.getOrigin(),d=this.getFocus(),e=this;return{html:this
.$editor.html(),origin:b?a(b):null,focus:d?a(d):null}},compareStates:function(a,
b){if(a.html!=b.html)return!1;
if(!a.origin&&!a.focus)return!0;if(!a.origin&&b.origin||a.origin&&!b.origin||a.o
rigin.length!=b.origin.length||!a.focus&&b.focus||a.focus&&!b.focus||a.focus.len
gth!=b.focus.length)return!1;var d=function(a,b){for(var c=0;c<a.length;c++)if(a
[c][0]!=b[c][0]||a[c][1]!=b[c][1])return!1;return!0};return a.origin&&!d(a.origi
n,b.origin)||a.focus&&!d(a.focus,b.focus)?!1:!0},onTyping:function(a){var b=this
;this.typingType&&this.typingType!=a&&0<this.typingCount&&("move"!=a&&b.pushUndo
Stack(!1),this.typingCount=
0);this.typingType=a;this.typingCount++;25<this.typingCount&&"move"!=this.typing
Type&&(setTimeout(function(){b.pushUndoStack(!1)},0),this.typingCount=0)},resetT
yping:function(){this.typingType=null;this.typingCount=0},syncCode:function(){th
is.$el.val(this.$editor.html())},focus:function(a){var c=this.getFocus(),d=this.
getOrigin();a?(c&&c[0]==d[0]&&c[1]==d[1]&&b(c[0]).is("body, .redactor_editor")&&
(c=null),c||this.selectLast()):(!c||!d||c[0]==d[0]&&0==c[1]&&0==d[1]&&b(c[0]).is
("body, .redactor_editor"))&&
(a=this.$editor[0].firstChild)&&"BR"!==a.tagName&&"IMG"!==a.tagName&&this.setSel
ection(a,0,a,0);this.opts.iframe&&this.$editor[0]&&(a=this.$editor[0].ownerDocum
ent)&&(a.defaultView||a.parentWindow).focus();this.$editor.focus()},setCode:func
tion(a,b){b="undefined"==typeof b?!0:b;a=this.stripTags(a);this.$editor.html(a);
b&&this.focus();this.syncCode()},getCode:function(){var a="",a=this.opts.visual?
this.$editor.html():this.$el.val();return this.stripTags(a)},insertHtml:function
(a,b){this.focus();this.pasteHtmlAtCaret(a,
b);this.observeImages();this.syncCode()},pasteHtmlAtCaret:function(a,c){c||this.
pushUndoStack();var d=!1,e,f;if(this.document.getSelection){if(e=this.window.get
Selection(),e.getRangeAt&&e.rangeCount){d=this.analyzeSelection();d.isCollapsed|
|b(d.selectedEls).filter("body").length||(d.selectPartials(),f=d.bookmarkSelecti
on(),b(d.selectedEls).remove(),f[0].after("\u200b\u200b"),d.restoreBookmark());d
=[];f=e.getRangeAt(0);f.deleteContents();"BODY"==f.startContainer.tagName&&(a.ma
tch(/<(p|div|h\d|ul|ol|blockquote|pre)(\s|\/|>)/i)||
(a="<p>"+a+"</p>"));if(a.match(/<(p|div|h\d|ul|ol|blockquote|pre)(\s|\/|>)/i)){v
ar g=b(f.startContainer).closest("p, div, h1, h2, h3, h4, h5, h6, ul, ol, blockq
uote, pre");if(g.length){var h=f.cloneRange();h.setEnd(g[0],g[0].childNodes.leng

th);var k=this.document.createElement("div");k.appendChild(h.cloneContents());if
(""===b.trim(k.innerHTML)||k.innerHTML.match(/^<br\s*\/?>$/i))f.setStartAfter(g[
0]),f.setEndAfter(g[0]),h=b.trim(g.html()),(""===h||h.match(/^<br\s*\/?>$/i))&&g
.remove()}}g=this.document.createElement("div");
g.innerHTML=a;for(var h=this.document.createDocumentFragment(),m;k=g.firstChild;
)m=h.appendChild(k),d.push(m);f.insertNode(h);m&&(f=f.cloneRange(),1==m.nodeType
&&m.childNodes.length?(m=m.childNodes[m.childNodes.length-1],"BR"==m.tagName?m.p
reviousSibling?f.setStartAfter(m.previousSibling):f.setStartBefore(m):f.setStart
After(m)):f.setStartAfter(m),f.collapse(!0),e.removeAllRanges(),e.addRange(f))}}
else this.document.selection&&"Control"!=this.document.selection.type&&this.docu
ment.selection.createRange().pasteHTML(a);
this.opts.insertHtmlCallback&&this.opts.insertHtmlCallback(d,this)},destroy:func
tion(){var a=this.getCode();this.textareamode?(this.$box.after(this.$el),this.$b
ox.remove(),this.$el.height(this.height).val(a).show()):(this.$box.after(this.$e
ditor),this.$box.remove(),this.$editor.removeClass("redactor_editor").removeClas
s("redactor_editor_wym").attr("contenteditable",!1).html(a).show());this.opts.to
olbarExternal&&b(this.opts.toolbarExternal).empty();b(".redactor_air").remove();
for(a=0;a<this.dropdowns.length;a++)this.dropdowns[a].remove(),
delete this.dropdowns[a];this.undoStack=[];this.redoStack=[];!1!==this.opts.auto
save&&clearInterval(this.autosaveInterval)},observeFormatting:function(a){if(thi
s.skipFormatObserveOnce)this.skipFormatObserveOnce=!1;else{var c=this.getCurrent
Node(),d=b(c),e=this.$editor.get(0);this.inactiveAllButtons();b.each(this.opts.a
ctiveButtonsStates,b.proxy(function(a,b){0!=d.closest(a,e).length&&this.setBtnAc
tive(b)},this));if(a&&13==a){var f=this;b.each(this.opts.activeButtonStateMap,fu
nction(a,b){try{f.document.queryCommandState(b)?
f.setBtnActive(a):f.setBtnInactive(a)}catch(c){}})}a=d.closest("p div h1 h2 h3 h
4 h5 h6 blockquote td".split(" "));if("undefined"!==typeof a[0]&&"undefined"!==t
ypeof a[0].elem&&0!=b(a[0].elem).size())switch(b(a[0].elem).css("text-align")){c
ase "right":this.setBtnActive("alignright");break;case "center":this.setBtnActiv
e("aligncenter");break;case "justify":this.setBtnActive("justify");break;default
:this.setBtnActive("alignleft")}}},observeImages:function(){if(!1===this.opts.ob
serveImages)return!1;
this.$editor.find("img").each(b.proxy(function(a,c){this.browser("msie")&&b(c).a
ttr("unselectable","on");this.resizeImage(c)},this))},observeTables:function(){t
his.$editor.find("table").click(b.proxy(this.tableObserver,this))},observeScroll
:function(){var a=b(this.document).scrollTop(),c=this.$box.offset().top,d=0;a>c?
(a="100%",this.opts.fixedBox&&(d=this.$box.offset().left,a=this.$box.innerWidth(
)),this.fixed=!0,this.$toolbar.css({position:"fixed",width:a,zIndex:1005,top:thi
s.opts.fixedTop+"px",
left:d})):(this.fixed=!1,this.$toolbar.css({position:"relative",width:"auto",zIn
dex:1,top:0,left:d}))},setBuffer:function(){this.saveSelection();this.opts.buffe
r=this.$editor.html()},getBuffer:function(){if(!1===this.opts.buffer)return!1;th
is.$editor.html(this.opts.buffer);this.browser("msie")||this.restoreSelection();
this.opts.buffer=!1},execCommand:function(a,c,d){if(0==this.opts.visual)return t
his.$el.focus(),!1;"undefined"==typeof d&&(d=!0);d&&"undo"!=a&&"redo"!=a&&this.p
ushUndoStack();try{var e;
if("inserthtml"===a)this.focus(),this.pasteHtmlAtCaret(c,!0),this.observeImages(
);else if("removeformat"===a)this.removeSelectedFormatting("b, strong, i, em, u,
s, span, strike, font",!0);else if("unlink"===a)this.removeSelectedFormatting("
a",!1);else if("JustifyLeft"===a||"JustifyCenter"===a||"JustifyRight"===a||"Just
ifyFull"===a){var f=this.getOrigin(),g=this.getFocus();if(!g||!1===this.opts.ifr
ame&&0==b(g[0]).closest(".redactor_editor").size())return!1;var h;g[0]==f[0]&&(h
=b(g[0]).closest("p, div, h1, h2, h3, h4, h5, h6, blockquote, td, li",
this.$editor.get(0)));h&&h.length?(c=!1,"JustifyCenter"===a?c="center":"JustifyL
eft"===a?c="left":"JustifyRight"===a?c="right":"JustifyFull"===a&&(c="justify"),
c&&c==("rtl"==this.opts.direction.toLowerCase()?"right":"left")&&(c=!1),!1===c?h
.css("text-align","").removeAttr("align"):h.css("text-align",c).removeAttr("alig
n"),this.focus()):this.execRun(a,c)}else if("formatblock"===a&&"blockquote"===c)
if(e=this.getCurrentNode(),"BLOCKQUOTE"===b(e).get(0).tagName)if(this.browser("m
sie")){var k=b("<p>"+

b(e).html()+"</p>");b(e).replaceWith(k)}else this.execRun(a,"p");else if("P"===b


(e).get(0).tagName){var m=b(e).parent();"BLOCKQUOTE"===b(m).get(0).tagName?(k=b(
"<p>"+b(e).html()+"</p>"),b(m).replaceWith(k),this.setSelection(k[0],0,k[0],0)):
this.browser("msie")?(k=b("<blockquote>"+b(e).html()+"</blockquote>"),b(e).repla
ceWith(k)):this.execRun(a,c)}else this.execRun(a,c);else"formatblock"!==a||"pre"
!==c&&"p"!==c?"undo"==a?this.popUndoStack():"redo"==a?this.popRedoStack():this.o
pts.execCommandHandler[a]?
this.opts.execCommandHandler[a].call(this,a,c,this):("inserthorizontalrule"===a&
&this.browser("msie")&&this.focus(),"formatblock"===a&&this.browser("mozilla")&&
this.focus(),this.execRun(a,c)):(e=this.getParentNode(),"PRE"===b(e).get(0).tagN
ame?b(e).replaceWith("<p>"+this.encodeEntities(b(e).text())+"</p>"):this.execRun
(a,c));"inserthorizontalrule"===a&&this.$editor.find("hr").removeAttr("id");this
.syncCode();this.oldIE()&&this.focus();"function"===typeof this.opts.execCommand
Callback&&this.opts.execCommandCallback(this,
a);this.opts.air&&this.air.hide()}catch(l){}},execRun:function(a,b){"formatblock
"===a&&this.browser("msie")&&(b="<"+b+">");this.document.execCommand(a,!1,b)},fo
rmatNewLine:function(a){var c=this.getParentNode();a="DIV"===c.nodeName&&(0==thi
s.opts.iframe&&c.className.match(/(\s|^)redactor_editor(\s|$)/)||1==this.opts.if
rame&&"BODY"==c.tagName);c="P"===c.nodeName;if(a||c)if(a=this.getCurrentNode(),c
=a.innerHTML||"",c=""===c||"<br>"==c,"DIV"===a.tagName){if("P"===a.parentNode.ta
gName){for(var d=a.parentNode;d.parentNode&&
"P"===d.parentNode.tagName;)d=d.parentNode;d.parentNode.insertBefore(a,d.nextSib
ling);this.setSelection(a,0,a,0)}c&&(a=b(a),c=b("<p>").append(a.clone().get(0).c
hildNodes),a.replaceWith(c),c.html("<br />"),this.setSelection(c[0],0,c[0],0))}e
lse"P"!==a.tagName||c||(a.parentNode.insertBefore(this.document.createElement("p
"),a),this.setSelection(a,0,a,0))},safariShiftKeyEnter:function(a,c){return a.sh
iftKey&&13===c?(a.preventDefault(),this.insertNodeAtCaret(b("<span><br /></span>
").get(0)),this.syncCode(),
!1):!0},formatEmpty:function(a){var c=b.trim(this.$editor.html()),c=c.replace(/<
br\s?\/?>/i,""),d=c.replace(/<p>\s?<\/p>/gi,"");if(""===c||""===d)return a&&a.pr
eventDefault(),a=b(this.opts.emptyHtml).get(0),this.$editor.html(a),this.setSele
ction(a,0,a,0),this.syncCode(),!1;this.syncCode()},paragraphy:function(a){a=b.tr
im(a);if(""===a||"<p></p>"===a||"<p><br></p>"===a)return this.opts.emptyHtml;thi
s.opts.convertDivs&&(a=a.replace(/<div(.*?)>([\w\W]*?)<\/div>/gi,"<p>$2</p>"));v
ar c=function(a,b,c){return a.replace(new RegExp(b,
"g"),c)},d=function(b,d){return c(a,b,d)};a+="\n";d("<br />\\s*<br />","\n\n");d
("(<(table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre
|select|form|blockquote|address|math|style|script|object|input|param|p|h[1-6])[^
>]*>)","\n$1");d("(</(table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|d
d|dt|ul|ol|li|pre|select|form|blockquote|address|math|style|script|object|input|
param|p|h[1-6])>)","$1\n\n");d("\r\n|\r","\n");d("\n\n+","\n\n");d("\n?((.|\n)+?
)$","<p>$1</p>\n");d("<p>\\s*?</p>",
"");d("<p>(<div[^>]*>\\s*)","$1<p>");d("<p>([^<]+)\\s*?(</(div|address|form)[^>]
*>)","<p>$1</p>$2");d("<p>\\s*(</?(table|thead|tfoot|caption|colgroup|tbody|tr|t
d|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|style|script|
object|input|param|p|h[1-6])[^>]*>)\\s*</p>","$1");d("<p>(<li.+?)</p>","$1");d("
<p>\\s*(</?(table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol
|li|pre|select|form|blockquote|address|math|style|script|object|input|param|p|h[
1-6])[^>]*>)","$1");d("(</?(table|thead|tfoot|caption|colgroup|tbody|tr|td|th|di
v|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|style|script|object|
input|param|p|h[1-6])[^>]*>)\\s*</p>",
"$1");d("(</?(table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|
ol|li|pre|select|form|blockquote|address|math|style|script|object|input|param|p|
h[1-6])[^>]*>)\\s*<br />","$1");d("<br />(\\s*</?(p|li|div|dl|dd|dt|th|pre|td|ul
|ol)[^>]*>)","$1");-1!=a.indexOf("<pre")&&d("(<pre(.|\n)*?>)((.|\n)*?)</pre>",fu
nction(a,b,d,h){return c(b,"\\\\(['\"\\\\])","$1")+c(c(c(h,"<p>","\n"),"</p>|<br
/>",""),"\\\\(['\"\\\\])","$1")+"</pre>"});return d("\n</p>$","</p>")},stripTag
s:function(a){var c=this.opts.allowedTags;
return a.replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,function(a,e){return"-1"<b.inA
rray(e.toLowerCase(),c)?a:""})},removeSelectedFormatting:function(a,c){var d=thi

s.analyzeSelection(),e;if(c){if(d.isCollapsed)return;d.selectPartials();e=d.sele
ctedEls}else e=d.selectedEls,e.push(d.origin[0]),d.focus[0]!=d.origin[0]&&e.push
(d.focus[0]);d.bookmarkSelection();var f=function(){b(this).after(this.childNode
s);b(this).remove()},g=this.$editor;b(e).each(function(){for(var d=b(this),e=d.p
arent().closest(a,g),
m=0;e.length;){m++;if(1E3<m){console.error("infinite loop when removing formatti
ng");break}var l=e[0];if(1!=l.childNodes.length&&c){var s=d.parentsUntil(e);if(s
.length){for(var z=b(this),p,t=b('<span class="__bogus" />');this.nextSibling;)p
||(p=t),p.append(this.nextSibling);s.each(function(){for(p&&(p=b(this.cloneNode(
!1)).append(p));this.nextSibling;)p||(p=t),p.append(this.nextSibling);z=b(this.c
loneNode(!1)).append(z)});p&&(p.is(t)?e.after(b(l.cloneNode(!1)).append(p[0].chi
ldNodes)):(f.call(t[0]),
e.after(b(l.cloneNode(!1)).append(p))));e.after(z)}else if(this.previousSibling)
if(this.nextSibling){for(e=b(l.cloneNode(!1));this.nextSibling;)e.append(this.ne
xtSibling);b(l).after(e).after(this)}else b(l).after(this);else b(l).before(this
)}else f.call(l);e=d.parent().closest(a,g)}d.find(a).each(f);d.is(a)&&f.call(thi
s)});d.restoreBookmark();this.observeFormatting()},savePreCode:function(a){var c
=a.match(/<pre(.*?)>([\w\W]*?)<\/pre>/gi);null!==c&&b.each(c,b.proxy(function(b,
c){var f=c.match(/<pre(.*?)>([\w\W]*?)<\/pre>/i);
f[2]=this.encodeEntities(f[2]);a=a.replace(c,"<pre"+f[1]+">"+f[2]+"</pre>")},thi
s));return a},encodeEntities:function(a){a=String(a).replace(/&amp;/g,"&").repla
ce(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"');return String(a).rep
lace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot
;")},cleanupPre:function(a){a=a.replace(/<br>/gi,"\n");a=a.replace(/<\/p>/gi,"\n
");a=a.replace(/<\/div>/gi,"\n");var b=this.document.createElement("div");b.inne
rHTML=a;return b.textContent||
b.innerText},pasteCleanUp:function(a){var c=this.getParentNode();if(b(c).get(0)&
&"PRE"===b(c).get(0).tagName)return a=this.cleanupPre(a),this.pasteCleanUpInsert
(a),!0;c=new b.Event;this.opts.pasteCleanUpCallback&&(a=this.opts.pasteCleanUpCa
llback(c,this,a));c.isDefaultPrevented()||(a=a.replace(/\x3c!--[\s\S]*?--\x3e|<\
?(?:php)?[\s\S]*?\?>/gi,""),a=a.replace(/(&nbsp;){2,}/gi,"&nbsp;"),a=a.replace(/
<b\sid="internal-source-marker(.*?)">([\w\W]*?)<\/b>/gi,"$2"),a=this.stripTags(a
),a=a.replace(/\[/g,"&#91;"),
a=a.replace(/\]/g,"&#93;"),a=a.replace(/<td><\/td>/gi,"[td]"),a=a.replace(/<td>&
nbsp;<\/td>/gi,"[td]"),a=a.replace(/<td><br><\/td>/gi,"[td]"),a=a.replace(/<a(.*
?)href="(.*?)"(.*?)>([\w\W]*?)<\/a>/gi,'[a href="$2"]$4[/a]'),a=a.replace(/<ifra
me(.*?)>([\w\W]*?)<\/iframe>/gi,"[iframe$1]$2[/iframe]"),a=a.replace(/<video(.*?
)>([\w\W]*?)<\/video>/gi,"[video$1]$2[/video]"),a=a.replace(/<audio(.*?)>([\w\W]
*?)<\/audio>/gi,"[audio$1]$2[/audio]"),a=a.replace(/<embed(.*?)>([\w\W]*?)<\/emb
ed>/gi,"[embed$1]$2[/embed]"),
a=a.replace(/<object(.*?)>([\w\W]*?)<\/object>/gi,"[object$1]$2[/object]"),a=a.r
eplace(/<param(.*?)>/gi,"[param$1]"),a=a.replace(/<img(.*?)style="(.*?)"(.*?)>/g
i,"[img$1$3]"),a=a.replace(/<(\w+)([\w\W]*?)>/gi,"<$1>"),a=a.replace(/<[^\/>][^>
]*>(\s*|\t*|\n*|&nbsp;|<br>)<\/[^>]+>/gi,""),a=a.replace(/<[^\/>][^>]*>(\s*|\t*|
\n*|&nbsp;|<br>)<\/[^>]+>/gi,""),a=a.replace(/\[td\]/gi,"<td>&nbsp;</td>"),a=a.r
eplace(/\[a href="(.*?)"\]([\w\W]*?)\[\/a\]/gi,'<a href="$1">$2</a>'),a=a.replac
e(/\[iframe(.*?)\]([\w\W]*?)\[\/iframe\]/gi,
"<iframe$1>$2</iframe>"),a=a.replace(/\[video(.*?)\]([\w\W]*?)\[\/video\]/gi,"<v
ideo$1>$2</video>"),a=a.replace(/\[audio(.*?)\]([\w\W]*?)\[\/audio\]/gi,"<audio$
1>$2</audio>"),a=a.replace(/\[embed(.*?)\]([\w\W]*?)\[\/embed\]/gi,"<embed$1>$2<
/embed>"),a=a.replace(/\[object(.*?)\]([\w\W]*?)\[\/object\]/gi,"<object$1>$2</o
bject>"),a=a.replace(/\[param(.*?)\]/gi,"<param$1>"),a=a.replace(/\[img(.*?)\]/g
i,"<img$1>"),a=a.replace(/&#91;paste:([a-zA-Z0-9]+)(.*?)&#93;([\w\W]*?)&#91;\/pa
ste:\1&#93;/gi,"<$1$2>$3</$1>"),
a=a.replace(/&#91;/g,"["),a=a.replace(/&#93;/g,"]"),this.opts.convertDivs&&(a=a.
replace(/<div(.*?)>([\w\W]*?)<\/div>/gi,"<p>$2</p>")),a=a.replace(/<span>([\w\W]
*?)<\/span>/gi,"$1"),a=a.replace(/\n{3,}/gi,"\n"),a=a.replace(/<p><p>/gi,"<p>"),
a=a.replace(/<\/p><\/p>/gi,"</p>"),this.browser("mozilla")&&(a=a.replace(/<br>$/
gi,"")));this.pasteCleanUpInsert(a)},pasteCleanUpInsert:function(a){this.execCom
mand("inserthtml",a);!0===this.opts.autoresize?b(this.document.body).scrollTop(t

his.saveScroll):this.$editor.scrollTop(this.saveScroll)},
formattingRemove:function(a){var c=[],d=a.match(/<pre(.*?)>([\w\W]*?)<\/pre>/gi)
;null!==d&&b.each(d,function(b,d){a=a.replace(d,"prebuffer_"+b);c.push(d)});a=a.
replace(/\s{2,}/g," ");a=a.replace(/\n/g," ");a=a.replace(/[\t]*/g,"");a=a.repla
ce(/\n\s*\n/g,"\n");a=a.replace(/^[\s\n]*/g,"");a=a.replace(/[\s\n]*$/g,"");a=a.
replace(/>\s+</g,"><");c&&(b.each(c,function(b,c){a=a.replace("prebuffer_"+b,c)}
),c=[]);return a},formattingIndenting:function(a){a=a.replace(/<li/g,"\t<li");a=
a.replace(/<tr/g,"\t<tr");
a=a.replace(/<td/g,"\t\t<td");return a=a.replace(/<\/tr>/g,"\t</tr>")},formattin
gEmptyTags:function(a){var b="<pre></pre> <blockquote>\\s*</blockquote> <em>\\s*
</em> <ul></ul> <ol></ol> <li></li> <table></table> <tr></tr> <span>\\s*<span> <
span>&nbsp;<span> <b>\\s*</b> <b>&nbsp;</b>".split(" ");this.browser("msie")&&(b
.push("<p>\\s*</p>"),b.push("<p>&nbsp;</p>"),b.push("<p>&#8203;</p>"),b.push("<d
iv>\\s*</div>"));for(var d=0;d<b.length;++d)a=a.replace(new RegExp(b[d],"gi"),""
);return a},formattingAddBefore:function(a){for(var b=
"<p <form </ul> </ol> <fieldset <legend <object <embed <select <option <input <t
extarea <pre <blockquote <ul <ol <li <dl <dt <dd <table <thead <tbody <caption <
/caption> <th <tr <td <figure".split(" "),d=0;d<b.length;++d){var e=b[d];a=a.rep
lace(new RegExp(e,"gi"),"\r\n"+e)}return a},formattingAddAfter:function(a){for(v
ar b="</p>;</div>;</h1>;</h2>;</h3>;</h4>;</h5>;</h6>;<br>;<br />;</dl>;</dt>;</
dd>;</form>;</blockquote>;</pre>;</legend>;</fieldset>;</object>;</embed>;</text
area>;</select>;</option>;</table>;</thead>;</tbody>;</tr>;</td>;</th>;</figure>
".split(";"),
d=0;d<b.length;++d){var e=b[d];a=a.replace(new RegExp(e,"gi"),e+"\r\n")}return a
},formatting:function(a){a=this.formattingRemove(a);a=this.formattingEmptyTags(a
);a=this.formattingAddBefore(a);a=this.formattingAddAfter(a);return a=this.forma
ttingIndenting(a)},toggle:function(){var a;if(this.opts.visual){var b=this.$edit
or.innerHeight();this.$editor.hide();this.$content.hide();a=this.$editor.html();
this.$el.height(b).val(a).show().focus();this.setBtnActive("html");this.opts.vis
ual=!1}else this.$el.hide(),
a=this.$el.val(),this.$editor.html(a).show(),this.$content.show(),""===this.$edi
tor.html()&&this.setCode(this.opts.emptyHtml,!1),this.focus(),this.setBtnInactiv
e("html"),this.opts.visual=!0,this.observeImages(),this.observeTables()},autoSav
e:function(){this.autosaveInterval=setInterval(b.proxy(function(){b.ajax({url:th
is.opts.autosave,type:"post",data:this.$el.attr("name")+"="+escape(encodeURIComp
onent(this.getCode())),success:b.proxy(function(a){"function"===typeof this.opts
.autosaveCallback&&this.opts.autosaveCallback(a,
this)},this)})},this),1E3*this.opts.interval)},buildToolbar:function(){if(!1===t
his.opts.toolbar)return!1;this.$toolbar=b("<ul>").addClass("redactor_toolbar");t
his.opts.air?(b(this.air).append(this.$toolbar),b("body").append(this.air)):!1==
=this.opts.toolbarExternal?this.$box.prepend(this.$toolbar):b(this.opts.toolbarE
xternal).html(this.$toolbar);var a=this,c=function(c,d){if("|"!==d&&"undefined"!
==typeof a.opts.toolbar[d]){var g=a.opts.toolbar[d];if(!1===a.opts.fileUpload&&"
file"===d)return;c.append(b('<li class="redactor_btn_container_'+
d+'">').append(a.buildButton(d,g)))}"|"===d&&c.append(b('<li class="redactor_sep
arator"></li>'))},d=this.$toolbar;b.each(this.opts.buttons,function(a,f){if(b.is
Array(f)){var g=b("<ul />");b.each(f,function(a,b){c(g,b)});d.append(b('<li clas
s="redactor_btn_group" />').append(g))}else c(d,f)})},buildButton:function(a,c){
var d=b('<a href="javascript:void(null);" title="'+c.title+'" class="redactor_bt
n_'+a+'"></a>');d.attr({unselectable:"on",tabindex:-1}).on("dragstart",function(
a){a.preventDefault()});
"undefined"===typeof c.func?d.click(b.proxy(function(){-1!=b.inArray(a,this.opts
.activeButtons)&&this.toggleBtnActive(a);(this.browser("mozilla")||this.opts.ifr
ame)&&this.focus();this.execCommand(c.exec,a)},this)):"show"!==c.func&&d.click(b
.proxy(function(a){this[c.func](a)},this));"undefined"!==typeof c.callback&&!1!=
=c.callback&&d.click(b.proxy(function(b){c.callback(this,b,a)},this));if("backco
lor"===a||"fontcolor"===a||"undefined"!==typeof c.dropdown){var e=b('<div class=
"redactor_dropdown" style="display: none;">'),
e="backcolor"===a||"fontcolor"===a?this.buildColorPicker(e,a):this.buildDropdown
(e,c.dropdown);this.dropdowns.push(e.appendTo(b(document.body)));this.hdlShowDro

pDown=b.proxy(function(b){this.showDropDown(b,e,a,c)},this);d.click(this.hdlShow
DropDown)}return d},buildDropdown:function(a,c){b.each(c,b.proxy(function(c,e){"
undefined"===typeof e.className&&(e.className="");var f;"undefined"!==typeof e.n
ame&&"separator"===e.name?f=b('<a class="redactor_separator_drop" unselectable="
on">'):(f=b('<a href="javascript:void(null);" unselectable="on" class="'+
e.className+'" style="'+(e.style||"")+'">'+e.title+"</a>"),"function"===typeof e
.callback?b(f).click(b.proxy(function(a){e.callback(this,a,c)},this)):"undefined
"===typeof e.func?b(f).click(b.proxy(function(){this.execCommand(e.exec,c);this.
focus()},this)):b(f).click(b.proxy(function(a){this[e.func](a)},this)));b(a).app
end(f)},this));return a},buildColorPicker:function(a,c){var d;d="backcolor"===c?
this.browser("msie")?"BackColor":"hilitecolor":"forecolor";b(a).width(this.opts.
colorWidth);for(var e=
this.opts.colors.length,f=0;f<e;++f){var g=this.opts.colors[f],g=b('<a rel="'+g+
'" href="javascript:void(null);" class="redactor_color_link" unselectable="on"><
/a>').css({backgroundColor:g});b(a).append(g);var h=this;b(g).click(function(){v
ar a=b(this).attr("rel");h.execCommand(d,a);if("forecolor"===d)if(h.opts.cleanup
FontTags)h.$editor.find("font").filter(function(){return b(this).attr("color")==
a}).replaceWith(function(){var a=b('<span style="color: '+b(this).attr("color")+
';">'+b(this).html()+
"</span>");a.find("[style]").css("color","");return a});else{var c=b(h.analyzeSe
lection().selectedEls);c.find("[style]").css("color","");c.filter("[style]").css
("color","")}h.browser("msie")&&"BackColor"===d&&h.$editor.find("font").replaceW
ith(function(){return b('<span style="'+b(this).attr("style")+'">'+b(this).html(
)+"</span>")});h.focus()})}e=b('<a href="javascript:void(null);" class="redactor
_color_none" unselectable="on"></a>').html(RLANG.none);"backcolor"===c?e.click(b
.proxy(this.setBackgroundNone,
this)):e.click(b.proxy(this.setColorNone,this));b(a).append(e);return a},setBack
groundNone:function(){b(this.getCurrentNode()).parentsUntil(".redactor_editor, b
ody").each(function(){var a=b(this);if(a.style.backgroundColor)return a.css("bac
kground-color","transparent"),!1});this.syncCode();this.focus()},setColorNone:fu
nction(){b(this.getCurrentNode()).parentsUntil(".redactor_editor, body").addBack
().each(function(){var a=b(this);if(this.attributes.color||this.style.color)retu
rn a.removeAttr("color").css("color",
""),!1});this.syncCode();this.focus()},showDropDown:function(a,c,d,e){var f=this
.getBtn(d);if(f.hasClass("dropact"))this.hideAllDropDown();else{this.hideAllDrop
Down();this.setBtnActive(d);f.addClass("dropact");var g=f.offset(),h=g.left,k=b(
window).width(),m=b(c).outerWidth();e.dropdownOnShow&&e.dropdownOnShow(this,a,c,
d);h+m>k&&(h=Math.max(h-m+this.getBtn(d).outerWidth(),0));this.opts.air?(e=this.
air.offset().top,b(c).css({position:"absolute",left:h+"px",top:e+30+"px"}).show(
)):this.opts.fixed&&this.fixed?
b(c).css({position:"fixed",left:h+"px",top:"30px"}).show():(e=g.top+f.outerHeigh
t(),b(c).css({position:"absolute",left:h+"px",top:e+"px"}).show())}h=b.proxy(fun
ction(a){this.hideDropDown(a,c,d)},this);b(document).one("click",h);this.$editor
.one("click",h);this.$content.one("click",h);a.stopPropagation()},hideAllDropDow
n:function(){this.$toolbar.find("a.dropact").removeClass("redactor_act").removeC
lass("dropact");b(".redactor_dropdown").hide()},hideDropDown:function(a,c,d){b(a
.target).hasClass("dropact")||
(b(c).removeClass("dropact"),this.showedDropDown=!1,this.hideAllDropDown())},get
Btn:function(a){return!1===this.opts.toolbar?!1:b(this.$toolbar.find("a.redactor
_btn_"+a))},toggleBtnActive:function(a){0==this.opts.activeButtons||!1===this.op
ts.toolbar||this.isMobile(!0)||this.getBtn(a).toggleClass("redactor_act")},setBt
nActive:function(a){0==this.opts.activeButtons||!1===this.opts.toolbar||this.isM
obile(!0)||this.getBtn(a).addClass("redactor_act")},setBtnInactive:function(a){0
==this.opts.activeButtons||
!1===this.opts.toolbar||this.isMobile(!0)||this.getBtn(a).removeClass("redactor_
act")},inactiveAllButtons:function(){b.each(this.opts.activeButtons,b.proxy(func
tion(a,b){this.setBtnInactive(b)},this))},changeBtnIcon:function(a,b){this.getBt
n(a).addClass("redactor_btn_"+b)},removeBtnIcon:function(a,b){this.getBtn(a).rem
oveClass("redactor_btn_"+b)},addBtnSeparator:function(){this.$toolbar.append(b('
<li class="redactor_separator"></li>'))},addBtnSeparatorAfter:function(a){this.g

etBtn(a).parent().after(b('<li class="redactor_separator"></li>'))},
addBtnSeparatorBefore:function(a){this.getBtn(a).parent().before(b('<li class="r
edactor_separator"></li>'))},removeBtnSeparatorAfter:function(a){this.getBtn(a).
parent().next().remove()},removeBtnSeparatorBefore:function(a){this.getBtn(a).pa
rent().prev().remove()},setBtnRight:function(a){if(!1===this.opts.toolbar)return
!1;this.getBtn(a).parent().addClass("redactor_btn_right")},setBtnLeft:function(a
){if(!1===this.opts.toolbar)return!1;this.getBtn(a).parent().removeClass("redact
or_btn_right")},addBtn:function(a,
c,d,e){if(!1===this.opts.toolbar)return!1;a=this.buildButton(a,{title:c,callback
:d,dropdown:e});this.$toolbar.append(b("<li>").append(a))},addBtnFirst:function(
a,c,d,e){if(!1===this.opts.toolbar)return!1;a=this.buildButton(a,{title:c,callba
ck:d,dropdown:e});this.$toolbar.prepend(b("<li>").append(a))},addBtnAfter:functi
on(a,c,d,e,f){if(!1===this.opts.toolbar)return!1;c=this.buildButton(c,{title:d,c
allback:e,dropdown:f});this.getBtn(a).parent().after(b("<li>").append(c))},addBt
nBefore:function(a,c,
d,e,f){if(!1===this.opts.toolbar)return!1;c=this.buildButton(c,{title:d,callback
:e,dropdown:f});this.getBtn(a).parent().before(b("<li>").append(c))},removeBtn:f
unction(a,b){var d=this.getBtn(a);!0===b&&d.parent().next().remove();d.parent().
removeClass("redactor_btn_right");d.remove()},getFragmentHtml:function(a){a=a.cl
oneNode(!0);var b=this.document.createElement("div");b.appendChild(a);return b.i
nnerHTML},extractContent:function(a){a=a||this.$editor.get(0);for(var b=this.doc
ument.createDocumentFragment(),
d;d=a.firstChild;)b.appendChild(d);return b},saveSelection:function(){this.focus
();this.savedSel=this.getOrigin();this.savedSelObj=this.getFocus()},restoreSelec
tion:function(){"undefined"!==typeof this.savedSel&&null!==this.savedSel&&null!=
=this.savedSelObj?!1===this.opts.iframe&&0==b(this.savedSel[0]).closest(".redact
or_editor").size()?this.focus():(this.browser("opera")&&this.focus(),this.setSel
ection(this.savedSel[0],this.savedSel[1],this.savedSelObj[0],this.savedSelObj[1]
),this.browser("mozilla")&&
this.focus()):this.focus()},getSelection:function(){var a=this.document;return t
his.window.getSelection?this.window.getSelection():a.getSelection?a.getSelection
():a.selection.createRange()},hasSelection:function(){if(this.oldIE()){var a=thi
s.$editor.get(0),b;return a&&a.document&&a.document.selection?(b=a.document.sele
ction.createRange())&&b.parentElement().document===a.document:!1}return(a=this.g
etSelection())&&null!=a.focusNode&&null!=a.anchorNode},getOrigin:function(){if(t
his.oldIE()){var a=this.$editor.get(0),
b;if(!this.hasSelection())return null;a.focus();b=a.document.selection.createRan
ge();return this._getBoundary(a.document,b,!0)}return(a=this.getSelection())&&nu
ll!=a.anchorNode?[a.anchorNode,a.anchorOffset]:null},getFocus:function(){if(this
.oldIE()){var a=this.$editor.get(0),b;if(!this.hasSelection())return null;a.focu
s();b=a.document.selection.createRange();return this._getBoundary(a.document,b,!
1)}return(a=this.getSelection())&&null!=a.focusNode?[a.focusNode,a.focusOffset]:
null},setSelection:function(a,
b,d,e){null==d&&(d=a);null==e&&(e=b);if(this.oldIE()){var f=this.$editor.get(0),
g=f.document.body.createTextRange();this._moveBoundary(f.document,g,!1,d,e);this
._moveBoundary(f.document,g,!0,a,b);return g.select()}if(f=this.getSelection())i
f(f.collapse&&f.extend)f.collapse(a,b),f.extend(d,e);else{g=this.document.create
Range();g.setStart(a,b);g.setEnd(d,e);g.collapsed&&(a!=d||a==d&&b!=e)&&(g.setSta
rt(d,e),g.setEnd(a,b));try{f.removeAllRanges()}catch(h){}f.addRange(g)}},selectL
ast:function(a){a||(a=
this.$editor);if(a=b(a).get(0)){var c=a.lastChild;if(c){for(;c.lastChild;)c=c.la
stChild;3==c.nodeType?this.setSelection(c,c.nodeValue.length,c,c.nodeValue.lengt
h):"BR"===c.tagName||"IMG"===c.tagName?(a=c.parentNode,this.setSelection(a,a.len
gth-1,a,a.length-1)):this.setSelection(c,0,c,0)}else this.setSelection(a,0,a,0)}
},selectFirst:function(a){a||(a=this.$editor);if(a=b(a).get(0)){var c=a.firstChi
ld;c&&"BR"!==c.tagName&&"IMG"!==c.tagName?this.setSelection(c,0,c,0):this.setSel
ection(a,0,a,0)}},getCurrentNode:function(){if("undefined"!==
typeof this.window.getSelection){var a=this.getSelectedNode();return a?a.parentN
ode:!1}if("undefined"!==typeof this.document.selection)return this.getSelection(
).parentElement()},getParentNode:function(){return b(this.getCurrentNode()).pare

nt()[0]},getSelectedNode:function(){if(this.oldIE())return this.getSelection().p
arentElement();if("undefined"!==typeof this.window.getSelection){var a=this.wind
ow.getSelection();return a&&0<a.rangeCount?this.getSelection().getRangeAt(0).com
monAncestorContainer:
!1}if("undefined"!==typeof this.document.selection)return this.getSelection()},_
getBoundary:function(a,b,d){var e,f,g=!1;a=a.createElement("a");e=b.duplicate();
e.collapse(d);for(f=e.parentElement();f.insertBefore(a,g?a.previousSibling:null)
,g=!0,e.moveToElementText(a),0<e.compareEndPoints(d?"StartToStart":"StartToEnd",
b)&&null!=a.previousSibling;);-1===e.compareEndPoints(d?"StartToStart":"StartToE
nd",b)&&a.nextSibling?(e.setEndPoint(d?"EndToStart":"EndToEnd",b),b=a.nextSiblin
g,d=e.text.length):(b=
a.parentNode,d=this._getChildIndex(a));a.parentNode.removeChild(a);return[b,d]},
_moveBoundary:function(a,b,d,e,f){var g,h,k;k=0;g=this._isText(e)?e:e.childNodes
[f];h=this._isText(e)?e.parentNode:e;this._isText(e)&&(k=f);e=a.createElement("a
");h.insertBefore(e,g||null);a=a.body.createTextRange();a.moveToElementText(e);e
.parentNode.removeChild(e);b.setEndPoint(d?"StartToStart":"EndToEnd",a);return b
[d?"moveStart":"moveEnd"]("character",k)},_isText:function(a){return null!=a?3==
a.nodeType:!1},_getChildIndex:function(a){for(var b=
0;a=a.previousSibling;)b++;return b},insertNodeAfterCaret:function(a){this.saveS
election();this.insertNodeAtCaret(a);this.restoreSelection()},insertNodeAtCaret:
function(a){if(this.window.getSelection){var b=this.getSelection();if(b.rangeCou
nt){var d=b.getRangeAt(0);d.collapse(!1);d.insertNode(a);d=d.cloneRange();d.sele
ctNodeContents(a);d.collapse(!1);b.removeAllRanges();b.addRange(d)}}else this.do
cument.selection&&(b=1===a.nodeType?a.outerHTML:a.data,d="marker_"+(""+Math.rand
om()).slice(2),b+='<span id="'+
d+'"></span>',a=this.getSelection(),a.collapse(!1),a.pasteHTML(b),b=this.documen
t.getElementById(d),a.moveToElementText(b),a.select(),b.parentNode.removeChild(b
))},getSelectedHtml:function(){var a="";if(this.window.getSelection){var b=this.
window.getSelection();if(b.rangeCount){for(var a=this.document.createElement("di
v"),d=0,e=b.rangeCount;d<e;++d)a.appendChild(b.getRangeAt(d).cloneContents());a=
a.innerHTML}}else this.document.selection&&"Text"===this.document.selection.type
&&(a=this.document.selection.createRange().htmlText);
return a},analyzeSelection:function(){var a=this.getOrigin(),c=this.getFocus(),d
=c[0]==a[0]&&c[1]==a[1];b(a[0]).is(".redactor_editor, body")&&(a[0]=a[0].childNo
des[a[1]],a[1]=0);b(c[0]).is(".redactor_editor, body")&&(c[0]=c[0].childNodes[c[
1]?c[1]-1:0],c[1]=3==c[0].nodeType?c[0].nodeValue.length:c[0].childNodes.length)
;var e=b(a[0]).parentsUntil(".redactor_editor, body, html"),f=b(c[0]).parentsUnt
il(".redactor_editor, body, html"),g,h,k;f.each(function(a){var c=this;e.each(fu
nction(a){if(this===c)return g=
b(this),k=a,!1});if(g)return h=a,!1});g||(g=this.$editor,k=e.length,h=f.length);
var m=0<k?e.get(k-1):a[0],l=0<h?f.get(h-1):c[0],s=[],z=!1,p=function(){var b;b=a
;a=c;c=b;b=e;e=f;f=b;b=k;k=h;h=b;b=m;m=l;l=b};if(c[0]==a[0])a[1]>c[1]&&p();else
for(var t=function(a,b){var c=[],d;for(1==a.nodeType&&c.push([a,b]);a&&a!=g[0];)
{b=0;for(d=a;d=d.previousSibling;)b++;c.push([a.parentNode,b]);a=a.parentNode}re
turn c.reverse()},B=t(a[0],a[1]),t=t(c[0],c[1]),u=0;B[u]&&t[u];u++)if(B[u][0]!=t
[u][0]){console.error("unexpected difference in selection path roots");
break}else if(B[u][1]<t[u][1])break;else if(B[u][1]>t[u][1]){p();break}var A=fun
ction(a){for(;1==a.parentNode.childNodes.length;)a=a.parentNode;return a};b.each
(g.get(0).childNodes,function(a){if(this==l)return!1;this==m?z=!0:z&&s.push(A(th
is))});a[0].parentNode!=c[0].parentNode&&(p=function(a,c,d,e){var f=b(e).parents
Until(".redactor_editor, body, html").toArray();f.push(e);f.push(c);for(e=!1;a&&
!b(a).is(f);){for(;a[d];){c=a[d];if(b(c).is(f)){e=!0;break}s.push(A(c));a=c}if(e
)break;a=a.parentNode}},
k&&h&&(p(a[0],m,"nextSibling",c[0]),p(c[0],l,"previousSibling",a[0])));var n,v=n
ull,q,y=null;if(a[0]==c[0])3==a[0].nodeType?0==a[1]&&c[1]>=a[0].nodeValue.length
?(n=q=A(a[0]),s.push(n)):(n=a[0],v=a[1],q=c[0],y=c[1]):0==a[1]&&a[0].childNodes.
length==c[1]?(n=q=A(a[0]),s.push(n)):0==a[1]&&0==c[1]?(a[0].insertBefore(a[0].ow
nerDocument.createTextNode(""),a[0].firstChild),n=q=a[0].childNodes[0],s.push(n)
):(b.each(a[0].childNodes,function(b){if(b>=c[1])return!1;b>=a[1]&&s.push(this)}
),a[0].childNodes[a[1]]||

(p=a[0].ownerDocument.createTextNode(""),a[0].appendChild(p),s.push(p),c[1]++),n
=a[0].childNodes[a[1]],q=c[0].childNodes[c[1]?c[1]-1:0]);else{if(3==a[0].nodeTyp
e)0<a[1]?(n=a[0],v=a[1]):(n=A(a[0]),s.push(n));else{var D=f.toArray();D.push(c[0
]);b.each(a[0].childNodes,function(c){if(b(this).is(D))return!1;c>=a[1]&&s.push(
this)});n=a[0].childNodes[a[1]];n||(n=a[0].nextSibling)}if(3==c[0].nodeType)c[1]
<c[0].nodeValue.length?(q=c[0],y=c[1]):(q=A(c[0]),s.push(q));else{var E=e.toArra
y(),F=!1;E.push(a[0]);
b.each(c[0].childNodes,function(a){b(this).is(E)?F=!0:F&&a<c[1]&&s.push(this)});
q=c[0].childNodes[c[1]-1];q||(q=c[0].previousSibling)}}var r={origin:a,focus:c,$
commonAncestor:g,isCollapsed:d,selectedEls:s},C=this,w,x;r.selectPartials=functi
on(a){n==q&&null!==v?(n=q=C.splitTextNode(n,a,v,y),y=v=null,r.selectedEls.push(n
)):(null!==v&&(n=C.splitTextNode(n,a,v),v=null,r.selectedEls.push(n)),null!==y&&
(q=C.splitTextNode(q,a,0,y),y=null,r.selectedEls.push(q)));return r};r.bookmarkS
election=function(){r.selectPartials();
r.removeBookmarks();var a=function(a){for(var b=[],c=!1,d=0;d<r.selectedEls.leng
th;d++)r.selectedEls[d]==a?c=!0:b.push(r.selectedEls[d]);if(c){for(a=a.firstChil
d;a;)b.push(a),a=a.nextSibling;r.selectedEls=b}};w=b('<ins class="start"></ins>'
);b(n).is(".redactor_editor, body, li")?(a(n),w.prependTo(n)):w.insertBefore(n);
x=b('<ins class="end"></ins>');b(q).is(".redactor_editor, body, li")?(a(q),x.app
endTo(q)):x.insertAfter(q);return[w,x]};r.restoreBookmark=function(){w&&x&&C.set
Selection(w.get(0),0,
x.get(0),0);r.removeBookmarks()};r.removeBookmarks=function(){w&&w.remove();x&&x
.remove()};return r},splitTextNode:function(a,c,d,e){var f=a.nodeValue;if("undef
ined"==typeof e||null===e)e=f.length;d=d||0;if(d>e){var g=d;d=e;e=g}g=f.substr(0
,d);d=f.substr(d,e-d);e=f.substr(e);c=c?b(c).text(d):b(a.ownerDocument.createTex
tNode(d));if(g.length&&e.length)a.nodeValue=g,c=c.insertAfter(a),c.after(a.owner
Document.createTextNode(e));else if(g.length)a.nodeValue=g,c=c.insertAfter(a);el
se if(e.length)a.nodeValue=
e,c=c.insertBefore(a);else return a;return c.get(0)},resizeImage:function(a){var
c=!1,d=!1,e,f=b(a).width()/b(a).height();b(a).off("hover mousedown mouseup clic
k mousemove");b(a).hover(function(){b(a).css("cursor","nw-resize")},function(){b
(a).css("cursor","");c=!1});b(a).mousedown(function(g){g.preventDefault();f=b(a)
.width()/b(a).height();d=c=!0;Math.round(g.pageX-b(a).eq(0).offset().left);e=Mat
h.round(g.pageY-b(a).eq(0).offset().top)});b(a).mouseup(b.proxy(function(d){c=!1
;b(a).css("cursor","");
this.syncCode()},this));b(a).click(b.proxy(function(a){d&&this.imageEdit(a)},thi
s));b(a).mousemove(function(g){if(c){d=!1;Math.round(g.pageX-b(this).eq(0).offse
t().left);var h=Math.round(g.pageY-b(this).eq(0).offset().top)-e,k=b(a).height()
,h=parseInt(k,10)+h,k=h*f;10<k&&b(a).width(k);10<h&&b(a).height(h);Math.round(g.
pageX-b(this).eq(0).offset().left);e=Math.round(g.pageY-b(this).eq(0).offset().t
op)}})},showTable:function(){this.saveSelection();this.modalInit(RLANG.table,thi
s.opts.modal_table,300,
b.proxy(function(){b("#redactor_insert_table_btn").click(b.proxy(this.insertTabl
e,this));setTimeout(function(){b("#redactor_table_rows").focus()},200)},this))},
insertTable:function(){for(var a=b("#redactor_table_rows").val(),c=b("#redactor_
table_columns").val(),d=b("<div></div>"),e=Math.floor(99999*Math.random()),e=b('
<table id="table'+e+'"><tbody></tbody></table>'),f=0;f<a;f++){for(var g=b("<tr><
/tr>"),h=0;h<c;h++){var k=b("<td><br></td>");b(g).append(k)}b(e).append(g)}b(d).
append(e);a=b(d).html()+
"<p></p>";this.restoreSelection();this.execCommand("inserthtml",a);this.modalClo
se();this.observeTables()},tableObserver:function(a){this.$table=b(a.target).clo
sest("table");this.$table_tr=this.$table.find("tr");this.$table_td=this.$table.f
ind("td");this.$tbody=b(a.target).closest("tbody");this.$thead=b(this.$table).fi
nd("thead");this.$current_td=b(a.target);this.$current_tr=b(a.target).closest("t
r")},deleteTable:function(){b(this.$table).remove();this.$table=!1;this.syncCode
()},deleteRow:function(){b(this.$current_tr).remove();
this.syncCode()},deleteColumn:function(){var a=b(this.$current_td).get(0).cellIn
dex;b(this.$table).find("tr").each(function(){b(this).find("td").eq(a).remove()}
);this.syncCode()},addHead:function(){if(0!==b(this.$table).find("thead").size()
)this.deleteHead();else{var a=b(this.$table).find("tr").first().clone();a.find("

td").html("&nbsp;");this.$thead=b("<thead></thead>");this.$thead.append(a);b(thi
s.$table).prepend(this.$thead);this.syncCode()}},deleteHead:function(){b(this.$t
head).remove();this.$thead=
!1;this.syncCode()},insertRowAbove:function(){this.insertRow("before")},insertRo
wBelow:function(){this.insertRow("after")},insertColumnLeft:function(){this.inse
rtColumn("before")},insertColumnRight:function(){this.insertColumn("after")},ins
ertRow:function(a){var c=b(this.$current_tr).clone();c.find("td").html("&nbsp;")
;"after"===a?b(this.$current_tr).after(c):b(this.$current_tr).before(c);this.syn
cCode()},insertColumn:function(a){var c=0;this.$current_tr.find("td").each(b.pro
xy(function(a,e){b(e)[0]===
this.$current_td[0]&&(c=a)},this));this.$table_tr.each(function(d,e){var f=b(e).
find("td").eq(c),g=f.clone();g.html("&nbsp;");"after"===a?b(f).after(g):b(f).bef
ore(g)});this.syncCode()},showVideo:function(){this.saveSelection();this.modalIn
it(RLANG.video,this.opts.modal_video,600,b.proxy(function(){b("#redactor_insert_
video_btn").click(b.proxy(this.insertVideo,this));setTimeout(function(){b("#reda
ctor_insert_video_area").focus()},200)},this))},insertVideo:function(){var a=b("
#redactor_insert_video_area").val(),
a=this.stripTags(a);this.restoreSelection();this.execCommand("inserthtml",a);thi
s.modalClose()},imageEdit:function(a){var c=b(a.target),d=c.parent();a=b.proxy(f
unction(){b("#redactor_file_alt").val(c.attr("alt"));b("#redactor_image_edit_src
").attr("href",c.attr("src"));b("#redactor_form_image_align").val(c.css("float")
);"A"===b(d).get(0).tagName&&b("#redactor_file_link").val(b(d).attr("href"));b("
#redactor_image_delete_btn").click(b.proxy(function(){this.imageDelete(c)},this)
);b("#redactorSaveBtn").click(b.proxy(function(){this.imageSave(c)},
this))},this);this.modalInit(RLANG.image,this.opts.modal_image_edit,380,a)},imag
eDelete:function(a){var c=b(a).parent();0!=c.size()&&"A"==c[0].tagName?c.remove(
):b(a).remove();this.modalClose();this.syncCode()},imageSave:function(a){var c=b
(a).parent();b(a).attr("alt",b("#redactor_file_alt").val());var d=b("#redactor_f
orm_image_align").val();"left"===d?b(a).css({"float":"left",margin:"0 10px 10px
0"}):"right"===d?b(a).css({"float":"right",margin:"0 0 10px 10px"}):b(a).css({"f
loat":"none",margin:"0"});
d=b.trim(b("#redactor_file_link").val());""!==d?"A"!==b(c).get(0).tagName?b(a).r
eplaceWith('<a href="'+d+'">'+this.outerHTML(a)+"</a>"):b(c).attr("href",d):"A"=
==b(c).get(0).tagName&&b(c).replaceWith(this.outerHTML(a));this.modalClose();thi
s.observeImages();this.syncCode()},showImage:function(){this.saveSelection();var
a=b.proxy(function(){!1!==this.opts.imageGetJson?b.getJSON(this.opts.imageGetJs
on,b.proxy(function(a){var c={},f=0;b.each(a,b.proxy(function(a,b){"undefined"!=
=typeof b.folder&&(f++,
c[b.folder]=f)},this));var g=!1;b.each(a,b.proxy(function(a,d){var f="";"undefin
ed"!==typeof d.title&&(f=d.title);var h=0;b.isEmptyObject(c)||"undefined"===type
of d.folder||(h=c[d.folder],!1===g&&(g=".redactorfolder"+h));f=b('<img src="'+d.
thumb+'" class="redactorfolder redactorfolder'+h+'" rel="'+d.image+'" title="'+f
+'" />');b("#redactor_image_box").append(f);b(f).click(b.proxy(this.imageSetThum
b,this))},this));if(!b.isEmptyObject(c)){b(".redactorfolder").hide();b(g).show()
;var h=b('<select id="redactor_image_box_select">');
b.each(c,function(a,c){h.append(b('<option value="'+c+'">'+a+"</option>"))});b("
#redactor_image_box").before(h);h.change(function(a){b(".redactorfolder").hide()
;b(".redactorfolder"+b(a.target).val()).show()})}},this)):b("#redactor_tabs a").
eq(1).remove();if(!1!==this.opts.imageUpload)!1===this.opts.uploadCrossDomain&&!
1===this.isMobile()&&0!==b("#redactor_file").size()&&b("#redactor_file").dragupl
oad({url:this.opts.imageUpload,uploadFields:this.opts.uploadFields,success:b.pro
xy(this.imageUploadCallback,
this),error:b.proxy(this.opts.imageUploadErrorCallback,this)}),this.uploadInit("
redactor_file",{auto:!0,url:this.opts.imageUpload,success:b.proxy(this.imageUplo
adCallback,this),error:b.proxy(this.opts.imageUploadErrorCallback,this)});else i
f(b(".redactor_tab").hide(),!1===this.opts.imageGetJson)b("#redactor_tabs").remo
ve(),b("#redactor_tab3").show();else{var a=b("#redactor_tabs a");a.eq(0).remove(
);a.eq(1).addClass("redactor_tabs_act");b("#redactor_tab2").show()}b("#redactor_
upload_btn").click(b.proxy(this.imageUploadCallbackLink,
this));!1===this.opts.imageUpload&&!1===this.opts.imageGetJson&&setTimeout(funct

ion(){b("#redactor_file_link").focus()},200)},this);this.modalInit(RLANG.image,t
his.opts.modal_image,600,a)},imageSetThumb:function(a){this._imageSet('<img src=
"'+b(a.target).attr("rel")+'" alt="'+b(a.target).attr("title")+'" />&nbsp;',!0)}
,imageUploadCallbackLink:function(){if(""!==b("#redactor_file_link").val()){var
a='<img src="'+b("#redactor_file_link").val()+'" />&nbsp;';this._imageSet(a,!0)}
else this.modalClose()},
imageUploadCallback:function(a){this._imageSet(a)},_imageSet:function(a,b){this.
restoreSelection();if(!1!==a){var d="",d=!0!==b?'<p><img src="'+a.filelink+'" />
</p>':a;this.execCommand("inserthtml",d);!0!==b&&"function"===typeof this.opts.i
mageUploadCallback&&this.opts.imageUploadCallback(this,a)}this.modalClose();this
.observeImages()},showLink:function(){this.saveSelection();var a=b.proxy(functio
n(){this.insert_link_node=!1;var a=this.getSelection(),d="",e="",f="";this.brows
er("msie")?(e=this.getParentNode(),
"A"===e.nodeName?(this.insert_link_node=b(e),e=this.insert_link_node.text(),d=th
is.insert_link_node.attr("href"),f=this.insert_link_node.attr("target")):e=this.
oldIE()?a.text:a.toString()):a&&a.anchorNode&&"A"===a.anchorNode.parentNode.tagN
ame?(d=a.anchorNode.parentNode.href,e=a.anchorNode.parentNode.text,f=a.anchorNod
e.parentNode.target,""===a.toString()&&(this.insert_link_node=a.anchorNode.paren
tNode)):e=a.toString();b("#redactor_link_url_text").val(e);a=self.location.href.
replace(/\/$/i,"");a=
d.replace(a,"");0===d.search("mailto:")?(this.setModalTab(2),b("#redactor_tab_se
lected").val(2),b("#redactor_link_mailto").val(d.replace("mailto:",""))):0===a.s
earch(/^#/gi)?(this.setModalTab(3),b("#redactor_tab_selected").val(3),b("#redact
or_link_anchor").val(a.replace(/^#/gi,""))):b("#redactor_link_url").val(a);"_bla
nk"===f&&b("#redactor_link_blank").attr("checked",!0);b("#redactor_insert_link_b
tn").click(b.proxy(this.insertLink,this));setTimeout(function(){b("#redactor_lin
k_url").focus()},200)},
this);this.modalInit(RLANG.link,this.opts.modal_link,600,a)},insertLink:function
(){var a=b("#redactor_tab_selected").val(),c="",d="",e="",f="";"1"===a?(c=b("#re
dactor_link_url").val(),d=b("#redactor_link_url_text").val(),d.length||(d=c),b("
#redactor_link_blank").prop("checked")&&(e=' target="_blank"',f="_blank"),c.leng
th&&!c.match(/^(\w+:)|\//)&&(c=this.opts.protocol+c)):"2"===a?(c="mailto:"+b("#r
edactor_link_mailto").val(),d=b("#redactor_link_mailto_text").val(),d.length||(d
=b("#redactor_link_mailto").val())):
"3"===a&&(c="#"+b("#redactor_link_anchor").val(),d=b("#redactor_link_anchor_text
").val());this._insertLink('<a href="'+c+'"'+e+">"+d+"</a>",b.trim(d),c,f)},_ins
ertLink:function(a,c,d,e){this.focus();this.restoreSelection();""!==c&&""!==d&&(
this.insert_link_node?(b(this.insert_link_node).text(c),b(this.insert_link_node)
.attr("href",d),""!==e?b(this.insert_link_node).attr("target",e):b(this.insert_l
ink_node).removeAttr("target"),this.syncCode()):this.execCommand("inserthtml",a)
);this.modalClose()},
showFile:function(){this.saveSelection();var a=b.proxy(function(){var a=this.get
Selection(),d="",d=this.oldIE()?a.text:a.toString();b("#redactor_filename").val(
d);!1===this.opts.uploadCrossDomain&&!1===this.isMobile()&&b("#redactor_file").d
ragupload({url:this.opts.fileUpload,uploadFields:this.opts.uploadFields,success:
b.proxy(this.fileUploadCallback,this),error:b.proxy(this.opts.fileUploadErrorCal
lback,this)});this.uploadInit("redactor_file",{auto:!0,url:this.opts.fileUpload,
success:b.proxy(this.fileUploadCallback,
this),error:b.proxy(this.opts.fileUploadErrorCallback,this)})},this);this.modalI
nit(RLANG.file,this.opts.modal_file,600,a)},fileUploadCallback:function(a){this.
restoreSelection();if(!1!==a){var c=b("#redactor_filename").val();""===c&&(c=a.f
ilename);c='<a href="'+a.filelink+'">'+c+"</a>";this.browser("webkit")&&this.win
dow.chrome&&(c+="&nbsp;");this.execCommand("inserthtml",c);"function"===typeof t
his.opts.fileUploadCallback&&this.opts.fileUploadCallback(this,a)}this.modalClos
e()},modalDeferredInit:function(a,
c,d,e){if(this.deferredModal[c])this.modalInit(a,this.deferredModal[c],d,e);else
if(this.opts.modalLoadCallback)this.opts.modalLoadCallback(this,a,c,d,e);else{v
ar f=this;b.ajax(c).done(function(b){f.deferredModal[c]=b;f.modalInit(a,f.deferr
edModal[c],d,e)})}},modalInit:function(a,c,d,e){if("object"===typeof c&&c.url)th
is.modalDeferredInit(a,c.url,d,e);else{this.saveSelection();this.restoreAndClose

||(this.restoreAndClose=b.proxy(function(){this.restoreSelection();this.modalClo
se();return!1},this));
d=Math.min(d,b(window).width());0===b("#redactor_modal_overlay").size()&&(this.o
verlay=b('<div id="redactor_modal_overlay" style="display: none;"></div>'),b("bo
dy").append(this.overlay));this.opts.overlay&&(b("#redactor_modal_overlay").show
(),b("#redactor_modal_overlay").click(this.restoreAndClose));0===b("#redactor_mo
dal").size()&&(this.modal=b('<div id="redactor_modal" style="display: none;"><di
v id="redactor_modal_close">&times;</div><div id="redactor_modal_header"></div><
div id="redactor_modal_inner"></div></div>'),
b("body").append(this.modal),this.opts.modalCreateCallback&&(this.modal=this.opt
s.modalCreateCallback(this,this.modal)));b("#redactor_modal_close").click(this.r
estoreAndClose);this.hdlModalClose=b.proxy(function(a){if(27===a.keyCode)return
this.restoreSelection(),this.modalClose(),!1},this);b(document).keyup(this.hdlMo
dalClose);this.$editor.keyup(this.hdlModalClose);0==c.indexOf("#")?b("#redactor_
modal_inner").empty().append(b(c).html()):b("#redactor_modal_inner").empty().app
end(c);b("#redactor_modal_header").html(a);
"undefined"!==typeof b.fn.draggable&&(b("#redactor_modal").draggable({handle:"#r
edactor_modal_header"}),b("#redactor_modal_header").css("cursor","move"));if(0!=
=b("#redactor_tabs").size()){var f=this;b("#redactor_tabs a").each(function(a,c)
{a++;b(c).click(function(){b("#redactor_tabs a").removeClass("redactor_tabs_act"
);b(this).addClass("redactor_tabs_act");b(".redactor_tab").hide();b("#redactor_t
ab"+a).show();b("#redactor_tab_selected").val(a);if(!1===f.isMobile()){var c=b("
#redactor_modal").outerHeight();
b("#redactor_modal").css("margin-top","-"+(c+10)/2+"px")}})})}b("#redactor_modal
.redactor_btn_modal_close").click(this.restoreAndClose);!1===this.isMobile()?(b
("#redactor_modal").css({position:"fixed",top:"-2000px",left:"50%",width:d+"px",
marginLeft:"-"+d/2+"px"}).show(),this.modalSaveBodyOveflow=b(document.body).css(
"overflow")):b("#redactor_modal").css({position:"fixed",width:"100%",height:"100
%",top:"0",left:"0",margin:"0",minHeight:"300px"}).show();"function"===typeof e&
&e();!1===this.isMobile()&&
setTimeout(function(){var a=b("#redactor_modal").outerHeight();b("#redactor_moda
l").css({top:"50%",height:"auto",minHeight:"auto",marginTop:"-"+(a+10)/2+"px"})}
,20)}},modalClose:function(){b("#redactor_modal_close").unbind("click",this.rest
oreAndClose);b("#redactor_modal").fadeOut("fast",b.proxy(function(){b("#redactor
_modal_inner").html("");this.opts.overlay&&(b("#redactor_modal_overlay").hide(),
b("#redactor_modal_overlay").unbind("click",this.restoreAndClose));b(document).u
nbind("keyup",this.hdlModalClose);
this.$editor.unbind("keyup",this.hdlModalClose)},this));!1===this.isMobile()&&b(
document.body).css("overflow",this.modalSaveBodyOveflow?this.modalSaveBodyOveflo
w:"visible");this.focus();return!1},setModalTab:function(a){b(".redactor_tab").h
ide();var c=b("#redactor_tabs a");c.removeClass("redactor_tabs_act");c.eq(a-1).a
ddClass("redactor_tabs_act");b("#redactor_tab"+a).show()},uploadInit:function(a,
c){this.uploadOptions={url:!1,success:!1,error:!1,start:!1,trigger:!1,auto:!1,in
put:!1};b.extend(this.uploadOptions,
c);0!==b("#"+a).size()&&"INPUT"===b("#"+a).get(0).tagName?(this.uploadOptions.in
put=b("#"+a),this.element=b(b("#"+a).get(0).form)):this.element=b("#"+a);this.el
ement_action=this.element.attr("action");this.uploadOptions.auto?b(this.uploadOp
tions.input).change(b.proxy(function(){this.element.submit(function(a){return!1}
);this.uploadSubmit()},this)):this.uploadOptions.trigger&&b("#"+this.uploadOptio
ns.trigger).click(b.proxy(this.uploadSubmit,this))},uploadSubmit:function(){this
.uploadForm(this.element,
this.uploadFrame())},uploadFrame:function(){this.id="f"+Math.floor(99999*Math.ra
ndom());var a=this.document.createElement("div");a.innerHTML='<iframe style="dis
play:none" id="'+this.id+'" name="'+this.id+'"></iframe>';b(a).appendTo("body");
this.uploadOptions.start&&this.uploadOptions.start();b("#"+this.id).load(b.proxy
(this.uploadLoaded,this));return this.id},uploadForm:function(a,c){if(this.uploa
dOptions.input){var d="redactorUploadForm"+this.id,e="redactorUploadFile"+this.i
d;this.form=b('<form action="'+
this.uploadOptions.url+'" method="POST" target="'+c+'" name="'+d+'" id="'+d+'" e
nctype="multipart/form-data"></form>');!1!==this.opts.uploadFields&&"object"===t

ypeof this.opts.uploadFields&&b.each(this.opts.uploadFields,b.proxy(function(a,c
){0===c.toString().indexOf("#")&&(c=b(c).val());var d=b("<input/>",{type:"hidden
",name:a,value:c});b(this.form).append(d)},this));var d=this.uploadOptions.input
,f=b(d).clone();b(d).attr("id",e);b(d).before(f);b(d).appendTo(this.form);b(this
.form).css("position",
"absolute");b(this.form).css("top","-2000px");b(this.form).css("left","-2000px")
;b(this.form).appendTo("body");this.form.submit()}else a.attr("target",c),a.attr
("method","POST"),a.attr("enctype","multipart/form-data"),a.attr("action",this.u
ploadOptions.url),this.element.submit()},uploadLoaded:function(){var a=b("#"+thi
s.id)[0],a=a.contentDocument?a.contentDocument:a.contentWindow?a.contentWindow.d
ocument:window.frames[this.id].document;this.uploadOptions.success&&("undefined"
!==typeof a?(a=a.body.innerHTML.match(/\{(.|\n)*\}/)[0],
a=b.parseJSON(a),"undefined"==typeof a.error?this.uploadOptions.success(a):(this
.uploadOptions.error(this,a),this.modalClose())):(alert("Upload failed!"),this.m
odalClose()));this.element.attr("action",this.element_action);this.element.attr(
"target","")},browser:function(a){var b=navigator.userAgent.toLowerCase(),b=/(ch
rome)[ \/]([\w.]+)/.exec(b)||/(webkit)[ \/]([\w.]+)/.exec(b)||/(opera)(?:.*versi
on|)[ \/]([\w.]+)/.exec(b)||/(msie) ([\w.]+)/.exec(b)||/(trident).*rv:([\w.]+)/.
exec(b)||0>b.indexOf("compatible")&&
/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(b)||[];return"version"==a?b[2]:"webkit"==a?
"chrome"==b[1]||"webkit"==b[1]:"msie"==a?"msie"==b[1]||"trident"==b[1]:b[1]==a},
oldIE:function(){return this.browser("msie")&&9>parseInt(this.browser("version")
,10)?!0:!1},outerHTML:function(a){return b("<p>").append(b(a).eq(0).clone()).htm
l()},normalize:function(a){return parseInt(a.replace("px",""),10)},isMobile:func
tion(a){return!0===a&&/(iPhone|iPod|iPad|BlackBerry|Android)/.test(navigator.use
rAgent)?!0:/(iPhone|iPod|BlackBerry|Android)/.test(navigator.userAgent)?
!0:!1}};b.fn.getObject=function(){return this.data("redactor")};b.fn.getEditor=f
unction(){return this.data("redactor").$editor};b.fn.getCode=function(){return b
.trim(this.data("redactor").getCode())};b.fn.getText=function(){return this.data
("redactor").$editor.text()};b.fn.getSelected=function(){return this.data("redac
tor").getSelectedHtml()};b.fn.setCode=function(a,b){this.data("redactor").setCod
e(a,b)};b.fn.insertHtml=function(a){this.data("redactor").insertHtml(a)};b.fn.de
stroyEditor=function(){this.each(function(){"undefined"!=
typeof b(this).data("redactor")&&(b(this).data("redactor").destroy(),b(this).rem
oveData("redactor"))})};b.fn.setFocus=function(a){this.data("redactor").focus(a)
};b.fn.execCommand=function(a,b){this.data("redactor").execCommand(a,b)}})(jQuer
y);
(function(b){function l(a,c){this.opts=b.extend({url:!1,success:!1,error:!1,prev
iew:!1,uploadFields:!1,text:RLANG.drop_file_here,atext:RLANG.or_choose},c);this.
$el=b(a)}b.fn.dragupload=function(a){return this.each(function(){(new l(this,a))
.init()})};l.prototype={init:function(){if(-1===navigator.userAgent.search("MSIE
")){this.droparea=b('<div class="redactor_droparea"></div>');this.dropareabox=b(
'<div class="redactor_dropareabox">'+this.opts.text+"</div>");this.dropalternati
ve=b('<div class="redactor_dropalternative">'+
this.opts.atext+"</div>");this.droparea.append(this.dropareabox);this.$el.before
(this.droparea);this.$el.before(this.dropalternative);this.dropareabox.bind("dra
gover",b.proxy(function(){return this.ondrag()},this));this.dropareabox.bind("dr
agleave",b.proxy(function(){return this.ondragleave()},this));var a=b.proxy(func
tion(a){a=parseInt(a.loaded/a.total*100,10);this.dropareabox.text("Loading "+a+"
%")},this),c=jQuery.ajaxSettings.xhr();c.upload&&c.upload.addEventListener("prog
ress",a,!1);var d=function(){return c};
this.dropareabox.get(0).ondrop=b.proxy(function(a){a.preventDefault();this.dropa
reabox.removeClass("hover").addClass("drop");a=a.dataTransfer.files[0];var c=new
FormData;!1!==this.opts.uploadFields&&"object"===typeof this.opts.uploadFields&
&b.each(this.opts.uploadFields,b.proxy(function(a,d){0===d.toString().indexOf("#
")&&(d=b(d).val());c.append(a,d)},this));c.append("file",a);b.ajax({url:this.opt
s.url,dataType:"html",data:c,xhr:d,cache:!1,contentType:!1,processData:!1,type:"
POST",success:b.proxy(function(a){a=
b.parseJSON(a);"undefined"==typeof a.error?this.opts.success(a):(this.opts.error
(this,a),this.opts.success(!1))},this)})},this)}},ondrag:function(){this.dropare

abox.addClass("hover");return!1},ondragleave:function(){this.dropareabox.removeC
lass("hover");return!1}}})(jQuery);
(function(b){var l=/(^|&lt;|\s)(www\..+?\..+?)(\s|&gt;|$|\[|\])/g,a=/(^|&lt;|\s)
(((https?|ftp):\/\/|mailto:).+?)(\s|&gt;|$|\[|\])/g,c=function(){for(var d=this.
childNodes,e=d.length;e--;){var f=d[e];if(3===f.nodeType){var g=f.nodeValue;g&&(
g=g.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(l,'$
1<a href="http://$2">$2</a>$3').replace(a,'$1<a href="$2">$2</a>$5'),g!=f.nodeVa
lue&&b(f).after(g).remove())}else 1!==f.nodeType||/^(a|button|textarea)$/i.test(
f.tagName)||c.call(f)}};
b.fn.linkify=function(){this.each(c)}})(jQuery);
(function(b){b.event.special.textselect={setup:function(l,a){b(this).data("texts
elected",!1);b(this).data("ttt",l);b(this).on("mouseup",b.event.special.textsele
ct.handler)},teardown:function(l){b(this).off("mouseup",b.event.special.textsele
ct.handler)},handler:function(l){var a=b(this).data("ttt"),a=b.event.special.tex
tselect.getSelectedText(a).toString();""!=a&&(b(this).data("textselected",!0),l.
type="textselect",l.text=a,b.event.dispatch.apply(this,arguments))},getSelectedT
ext:function(b){b="";
rwindow.getSelection?b=rwindow.getSelection():rdocument.getSelection?b=rdocument
.getSelection():rdocument.selection&&(b=rdocument.selection.createRange().text);
return b}};b.event.special.textunselect={setup:function(l,a){b(this).data("rttt"
,l);b(this).data("textselected",!1);b(this).on("mouseup",b.event.special.textuns
elect.handler);b(this).on("keyup",b.event.special.textunselect.handlerKey)},tear
down:function(l){b(this).unbind("mouseup",b.event.special.textunselect.handler)}
,handler:function(l){if(b(this).data("textselected")){var a=
b(this).data("rttt");""==b.event.special.textselect.getSelectedText(a).toString(
)&&(b(this).data("textselected",!1),l.type="textunselect",b.event.dispatch.apply
(this,arguments))}},handlerKey:function(l){if(b(this).data("textselected")){var
a=b(this).data("rttt"),a=b.event.special.textselect.getSelectedText(a).toString(
);if(l.keyCode=27,""==a)b(this).data("textselected",!1),l.type="textunselect",b.
event.dispatch.apply(this,arguments)}}}})(jQuery);

Vous aimerez peut-être aussi