EVOLUTION-MANAGER
Edit File: bootstrap-markdown.min.js
!function(e){var c=function(g,f){this.$ns="bootstrap-markdown";this.$element=e(g);this.$editable={el:null,type:null,attrKeys:[],attrValues:[],content:null};this.$options=e.extend(true,{},e.fn.markdown.defaults,f,this.$element.data(),this.$element.data("options"));this.$oldContent=null;this.$isPreview=false;this.$editor=null;this.$textarea=null;this.$handler=[];this.$callback=[];this.$nextTab=[];this.showEditor()};c.prototype={constructor:c,__alterButtons:function(h,g){var i=this.$handler,f=(h=="all"),j=this;e.each(i,function(m,l){var n=true;if(f){n=false}else{n=l.indexOf(h)<0}if(n==false){g(j.$editor.find('button[data-handler="'+l+'"]'))}})},__buildButtons:function(v,u){var x,B=this.$ns,h=this.$handler,k=this.$callback;for(x=0;x<v.length;x++){var q,l=v[x];for(q=0;q<l.length;q++){var o,A=l[q].data,t=e("<div/>",{"class":"btn-group"});for(o=0;o<A.length;o++){var g=A[o],r="",w=B+"-"+g.name,n=g.icon instanceof Object?g.icon[this.$options.iconlibrary]:g.icon,f=g.btnText?g.btnText:"",m=g.btnClass?g.btnClass:"btn",j=g.tabIndex?g.tabIndex:"-1",s=typeof g.hotkey!=="undefined"?g.hotkey:"",p=typeof jQuery.hotkeys!=="undefined"&&s!==""?" ("+s+")":"";if(g.toggle==true){r=' data-toggle="button"'}t.append('<button type="button" class="'+m+' btn-default btn-sm" title="'+this.__localize(g.title)+p+'" tabindex="'+j+'" data-provider="'+B+'" data-handler="'+w+'" data-hotkey="'+s+'"'+r+'><span class="'+n+'"></span> '+this.__localize(f)+"</button>");h.push(w);k.push(g.callback)}u.append(t)}}return u},__setListener:function(){var g=typeof this.$textarea.attr("rows")!="undefined",f=this.$textarea.val().split("\n").length>5?this.$textarea.val().split("\n").length:"5",h=g?this.$textarea.attr("rows"):f;this.$textarea.attr("rows",h);if(this.$options.resize){this.$textarea.css("resize",this.$options.resize)}this.$textarea.on("focus",e.proxy(this.focus,this)).on("keypress",e.proxy(this.keypress,this)).on("keyup",e.proxy(this.keyup,this)).on("change",e.proxy(this.change,this));if(this.eventSupported("keydown")){this.$textarea.on("keydown",e.proxy(this.keydown,this))}this.$textarea.data("markdown",this)},__handle:function(j){var i=e(j.currentTarget),h=this.$handler,l=this.$callback,g=i.attr("data-handler"),k=h.indexOf(g),f=l[k];e(j.currentTarget).focus();f(this);this.change(this);if(g.indexOf("cmdSave")<0){this.$textarea.focus()}j.preventDefault()},__localize:function(f){var g=e.fn.markdown.messages,h=this.$options.language;if(typeof g!=="undefined"&&typeof g[h]!=="undefined"&&typeof g[h][f]!=="undefined"){return g[h][f]}return f},showEditor:function(){var w=this,r,y=this.$ns,q=this.$element,f=q.css("height"),x=q.css("width"),u=this.$editable,k=this.$handler,o=this.$callback,m=this.$options,n=e("<div/>",{"class":"md-editor",click:function(){w.focus()}});if(this.$editor==null){var l=e("<div/>",{"class":"md-header btn-toolbar"});var g=[];if(m.buttons.length>0){g=g.concat(m.buttons[0])}if(m.additionalButtons.length>0){g=g.concat(m.additionalButtons[0])}if(m.reorderButtonGroups.length>0){g=g.filter(function(z){return m.reorderButtonGroups.indexOf(z.name)>-1}).sort(function(A,z){if(m.reorderButtonGroups.indexOf(A.name)<m.reorderButtonGroups.indexOf(z.name)){return -1}if(m.reorderButtonGroups.indexOf(A.name)>m.reorderButtonGroups.indexOf(z.name)){return 1}return 0})}if(g.length>0){l=this.__buildButtons([g],l)}n.append(l);if(q.is("textarea")){q.before(n);r=q;r.addClass("md-input");n.append(r)}else{var h=(typeof toMarkdown=="function")?toMarkdown(q.html()):q.html(),v=e.trim(h);r=e("<textarea/>",{"class":"md-input",val:v});n.append(r);u.el=q;u.type=q.prop("tagName").toLowerCase();u.content=q.html();e(q[0].attributes).each(function(){u.attrKeys.push(this.nodeName);u.attrValues.push(this.nodeValue)});q.replaceWith(n)}var i=e("<div/>",{"class":"md-footer"}),p=false,t="";if(m.savable){p=true;var j="cmdSave";k.push(j);o.push(m.onSave);i.append('<button class="btn btn-success" data-provider="'+y+'" data-handler="'+j+'"><i class="icon icon-white icon-ok"></i> '+this.__localize("Save")+"</button>")}t=typeof m.footer==="function"?m.footer(this):m.footer;if(e.trim(t)!==""){p=true;i.append(t)}if(p){n.append(i)}if(m.width&&m.width!=="inherit"){if(jQuery.isNumeric(m.width)){n.css("display","table");r.css("width",m.width+"px")}else{n.addClass(m.width)}}if(m.height&&m.height!=="inherit"){if(jQuery.isNumeric(m.height)){var s=m.height;if(l){s=Math.max(0,s-l.outerHeight())}if(i){s=Math.max(0,s-i.outerHeight())}r.css("height",s+"px")}else{n.addClass(m.height)}}this.$editor=n;this.$textarea=r;this.$editable=u;this.$oldContent=this.getContent();this.__setListener();this.$editor.attr("id",(new Date).getTime());this.$editor.on("click",'[data-provider="bootstrap-markdown"]',e.proxy(this.__handle,this));if(this.$element.is(":disabled")||this.$element.is("[readonly]")){this.disableButtons("all")}if(this.eventSupported("keydown")&&typeof jQuery.hotkeys==="object"){l.find('[data-provider="bootstrap-markdown"]').each(function(){var A=e(this),z=A.attr("data-hotkey");if(z.toLowerCase()!==""){r.bind("keydown",z,function(){A.trigger("click");return false})}})}}else{this.$editor.show()}if(m.autofocus){this.$textarea.focus();this.$editor.addClass("active")}if(m.initialstate==="preview"){this.showPreview()}this.hideButtons(m.hiddenButtons);this.disableButtons(m.disabledButtons);m.onShow(this);return this},parseContent:function(){var g,f=this.$options.onPreview(this);if(typeof f=="string"){g=f}else{var h=this.$textarea.val();if(typeof markdown=="object"){g=markdown.toHTML(h)}else{if(typeof marked=="function"){g=marked(h)}else{g=h}}}return g},showPreview:function(){var h=this.$options,f=this.$textarea,j=f.next(),g=e("<div/>",{"class":"md-preview","data-provider":"markdown-preview"}),i;this.$isPreview=true;this.disableButtons("all").enableButtons("cmdPreview");i=this.parseContent();g.html(i);if(j&&j.attr("class")=="md-footer"){g.insertBefore(j)}else{f.parent().append(g)}g.css({width:f.outerWidth()+"px",height:f.outerHeight()+"px"});if(this.$options.resize){g.css("resize",this.$options.resize)}f.hide();g.data("markdown",this);return this},hidePreview:function(){this.$isPreview=false;var f=this.$editor.find('div[data-provider="markdown-preview"]');f.remove();this.enableButtons("all");this.$textarea.show();this.__setListener();return this},isDirty:function(){return this.$oldContent!=this.getContent()},getContent:function(){return this.$textarea.val()},setContent:function(f){this.$textarea.val(f);return this},findSelection:function(g){var j=this.getContent(),i;if(i=j.indexOf(g),i>=0&&g.length>0){var f=this.getSelection(),h;this.setSelection(i,i+g.length);h=this.getSelection();this.setSelection(f.start,f.end);return h}else{return null}},getSelection:function(){var f=this.$textarea[0];return(("selectionStart" in f&&function(){var g=f.selectionEnd-f.selectionStart;return{start:f.selectionStart,end:f.selectionEnd,length:g,text:f.value.substr(f.selectionStart,g)}})||function(){return null})()},setSelection:function(h,f){var g=this.$textarea[0];return(("selectionStart" in g&&function(){g.selectionStart=h;g.selectionEnd=f;return})||function(){return null})()},replaceSelection:function(g){var f=this.$textarea[0];return(("selectionStart" in f&&function(){f.value=f.value.substr(0,f.selectionStart)+g+f.value.substr(f.selectionEnd,f.value.length);f.selectionStart=f.value.length;return this})||function(){f.value+=g;return jQuery(f)})()},getNextTab:function(){if(this.$nextTab.length==0){return null}else{var f,g=this.$nextTab.shift();if(typeof g=="function"){f=g()}else{if(typeof g=="object"&&g.length>0){f=g}}return f}},setNextTab:function(i,g){if(typeof i=="string"){var h=this;this.$nextTab.push(function(){return h.findSelection(i)})}else{if(typeof i=="numeric"&&typeof g=="numeric"){var f=this.getSelection();this.setSelection(i,g);this.$nextTab.push(this.getSelection());this.setSelection(f.start,f.end)}}return},__parseButtonNameParam:function(f){var g=[];if(typeof f=="string"){g.push(f)}else{g=f}return g},enableButtons:function(f){var h=this.__parseButtonNameParam(f),g=this;e.each(h,function(k,j){g.__alterButtons(h[k],function(i){i.removeAttr("disabled")})});return this},disableButtons:function(f){var h=this.__parseButtonNameParam(f),g=this;e.each(h,function(k,j){g.__alterButtons(h[k],function(i){i.attr("disabled","disabled")})});return this},hideButtons:function(f){var h=this.__parseButtonNameParam(f),g=this;e.each(h,function(k,j){g.__alterButtons(h[k],function(i){i.addClass("hidden")})});return this},showButtons:function(f){var h=this.__parseButtonNameParam(f),g=this;e.each(h,function(k,j){g.__alterButtons(h[k],function(i){i.removeClass("hidden")})});return this},eventSupported:function(f){var g=f in this.$element;if(!g){this.$element.setAttribute(f,"return;");g=typeof this.$element[f]==="function"}return g},keyup:function(i){var g=false;switch(i.keyCode){case 40:case 38:case 16:case 17:case 18:break;case 9:var f;if(f=this.getNextTab(),f!=null){var h=this;setTimeout(function(){h.setSelection(f.start,f.end)},500);g=true}else{var j=this.getSelection();if(j.start==j.end&&j.end==this.getContent().length){g=false}else{this.setSelection(this.getContent().length,this.getContent().length);g=true}}break;case 13:case 27:g=false;break;default:g=false}if(g){i.stopPropagation();i.preventDefault()}this.$options.onChange(this)},change:function(f){this.$options.onChange(this);return this},focus:function(i){var f=this.$options,h=f.hideable,g=this.$editor;g.addClass("active");e(document).find(".md-editor").each(function(){if(e(this).attr("id")!=g.attr("id")){var j;if(j=e(this).find("textarea").data("markdown"),j==null){j=e(this).find('div[data-provider="markdown-preview"]').data("markdown")}if(j){j.blur()}}});f.onFocus(this);return this},blur:function(m){var g=this.$options,l=g.hideable,j=this.$editor,h=this.$editable;if(j.hasClass("active")||this.$element.parent().length==0){j.removeClass("active");if(l){if(h.el!=null){var f=e("<"+h.type+"/>"),k=this.getContent(),i=(typeof markdown=="object")?markdown.toHTML(k):k;e(h.attrKeys).each(function(o,n){f.attr(h.attrKeys[o],h.attrValues[o])});f.html(i);j.replaceWith(f)}else{j.hide()}}g.onBlur(this)}return this}};var a=e.fn.markdown;e.fn.markdown=function(f){return this.each(function(){var i=e(this),h=i.data("markdown"),g=typeof f=="object"&&f;if(!h){i.data("markdown",(h=new c(this,g)))}})};e.fn.markdown.messages={};e.fn.markdown.defaults={autofocus:false,hideable:false,savable:false,width:"inherit",height:"inherit",resize:"none",iconlibrary:"glyph",language:"en",initialstate:"editor",buttons:[[{name:"groupFont",data:[{name:"cmdBold",hotkey:"Ctrl+B",title:"Bold",icon:{glyph:"glyphicon glyphicon-bold",fa:"fa fa-bold","fa-3":"icon-bold"},callback:function(i){var f,j,g=i.getSelection(),h=i.getContent();if(g.length==0){f=i.__localize("strong text")}else{f=g.text}if(h.substr(g.start-2,2)=="**"&&h.substr(g.end,2)=="**"){i.setSelection(g.start-2,g.end+2);i.replaceSelection(f);j=g.start-2}else{i.replaceSelection("**"+f+"**");j=g.start+2}i.setSelection(j,j+f.length)}},{name:"cmdItalic",title:"Italic",hotkey:"Ctrl+I",icon:{glyph:"glyphicon glyphicon-italic",fa:"fa fa-italic","fa-3":"icon-italic"},callback:function(i){var f,j,g=i.getSelection(),h=i.getContent();if(g.length==0){f=i.__localize("emphasized text")}else{f=g.text}if(h.substr(g.start-1,1)=="*"&&h.substr(g.end,1)=="*"){i.setSelection(g.start-1,g.end+1);i.replaceSelection(f);j=g.start-1}else{i.replaceSelection("*"+f+"*");j=g.start+1}i.setSelection(j,j+f.length)}},{name:"cmdHeading",title:"Heading",hotkey:"Ctrl+H",icon:{glyph:"glyphicon glyphicon-header",fa:"fa fa-font","fa-3":"icon-font"},callback:function(i){var f,k,g=i.getSelection(),h=i.getContent(),j,l;if(g.length==0){f=i.__localize("heading text")}else{f=g.text+"\n"}if((j=4,h.substr(g.start-j,j)=="### ")||(j=3,h.substr(g.start-j,j)=="###")){i.setSelection(g.start-j,g.end);i.replaceSelection(f);k=g.start-j}else{if(g.start>0&&(l=h.substr(g.start-1,1),!!l&&l!="\n")){i.replaceSelection("\n\n### "+f);k=g.start+6}else{i.replaceSelection("### "+f);k=g.start+4}}i.setSelection(k,k+f.length)}}]},{name:"groupLink",data:[{name:"cmdUrl",title:"URL/Link",hotkey:"Ctrl+L",icon:{glyph:"glyphicon glyphicon-link",fa:"fa fa-link","fa-3":"icon-link"},callback:function(j){var f,k,g=j.getSelection(),i=j.getContent(),h;if(g.length==0){f=j.__localize("enter link description here")}else{f=g.text}h=prompt(j.__localize("Insert Hyperlink"),"http://");if(h!=null&&h!=""&&h!="http://"){j.replaceSelection("["+f+"]("+h+")");k=g.start+1;j.setSelection(k,k+f.length)}}},{name:"cmdImage",title:"Image",hotkey:"Ctrl+G",icon:{glyph:"glyphicon glyphicon-picture",fa:"fa fa-picture-o","fa-3":"icon-picture"},callback:function(j){var f,k,g=j.getSelection(),i=j.getContent(),h;if(g.length==0){f=j.__localize("enter image description here")}else{f=g.text}h=prompt(j.__localize("Insert Image Hyperlink"),"http://");if(h!=null){j.replaceSelection("+'")');k=g.start+2;j.setNextTab(j.__localize("enter image title here"));j.setSelection(k,k+f.length)}}}]},{name:"groupMisc",data:[{name:"cmdList",hotkey:"Ctrl+U",title:"Unordered List",icon:{glyph:"glyphicon glyphicon-list",fa:"fa fa-list","fa-3":"icon-list-ul"},callback:function(j){var f,k,g=j.getSelection(),h=j.getContent();if(g.length==0){f=j.__localize("list text here");j.replaceSelection("- "+f);k=g.start+2}else{if(g.text.indexOf("\n")<0){f=g.text;j.replaceSelection("- "+f);k=g.start+2}else{var i=[];i=g.text.split("\n");f=i[0];e.each(i,function(m,l){i[m]="- "+l});j.replaceSelection("\n\n"+i.join("\n"));k=g.start+4}}j.setSelection(k,k+f.length)}},{name:"cmdListO",hotkey:"Ctrl+O",title:"Ordered List",icon:{glyph:"glyphicon glyphicon-th-list",fa:"fa fa-list-ol","fa-3":"icon-list-ol"},callback:function(j){var f,k,g=j.getSelection(),h=j.getContent();if(g.length==0){f=j.__localize("list text here");j.replaceSelection("1. "+f);k=g.start+3}else{if(g.text.indexOf("\n")<0){f=g.text;j.replaceSelection("1. "+f);k=g.start+3}else{var i=[];i=g.text.split("\n");f=i[0];e.each(i,function(m,l){i[m]="1. "+l});j.replaceSelection("\n\n"+i.join("\n"));k=g.start+5}}j.setSelection(k,k+f.length)}},{name:"cmdCode",hotkey:"Ctrl+K",title:"Code",icon:{glyph:"glyphicon glyphicon-asterisk",fa:"fa fa-code","fa-3":"icon-code"},callback:function(i){var f,j,g=i.getSelection(),h=i.getContent();if(g.length==0){f=i.__localize("code text here")}else{f=g.text}if(h.substr(g.start-1,1)=="`"&&h.substr(g.end,1)=="`"){i.setSelection(g.start-1,g.end+1);i.replaceSelection(f);j=g.start-1}else{i.replaceSelection("`"+f+"`");j=g.start+1}i.setSelection(j,j+f.length)}},{name:"cmdQuote",hotkey:"Ctrl+Q",title:"Quote",icon:{glyph:"glyphicon glyphicon-comment",fa:"fa fa-quote-left","fa-3":"icon-quote-left"},callback:function(j){var f,k,g=j.getSelection(),h=j.getContent();if(g.length==0){f=j.__localize("quote here");j.replaceSelection("> "+f);k=g.start+2}else{if(g.text.indexOf("\n")<0){f=g.text;j.replaceSelection("> "+f);k=g.start+2}else{var i=[];i=g.text.split("\n");f=i[0];e.each(i,function(m,l){i[m]="> "+l});j.replaceSelection("\n\n"+i.join("\n"));k=g.start+4}}j.setSelection(k,k+f.length)}}]},{name:"groupUtil",data:[{name:"cmdPreview",toggle:true,hotkey:"Ctrl+P",title:"Preview",btnText:"Preview",btnClass:"btn btn-primary btn-sm",icon:{glyph:"glyphicon glyphicon-search",fa:"fa fa-search","fa-3":"icon-search"},callback:function(h){var f=h.$isPreview,g;if(f==false){h.showPreview()}else{h.hidePreview()}}}]}]],additionalButtons:[],reorderButtonGroups:[],hiddenButtons:[],disabledButtons:[],footer:"",onShow:function(f){},onPreview:function(f){},onSave:function(f){},onBlur:function(f){},onFocus:function(f){},onChange:function(f){}};e.fn.markdown.Constructor=c;e.fn.markdown.noConflict=function(){e.fn.markdown=a;return this};var d=function(f){var g=f;if(g.data("markdown")){g.data("markdown").showEditor();return}g.markdown()};var b=function(h){var i=false,g,f=e(h.currentTarget);if((h.type=="focusin"||h.type=="click")&&f.length==1&&typeof f[0]=="object"){g=f[0].activeElement;if(!e(g).data("markdown")){if(typeof e(g).parent().parent().parent().attr("class")=="undefined"||e(g).parent().parent().parent().attr("class").indexOf("md-editor")<0){if(typeof e(g).parent().parent().attr("class")=="undefined"||e(g).parent().parent().attr("class").indexOf("md-editor")<0){i=true}}else{i=false}}if(i){e(document).find(".md-editor").each(function(){var k=e(g).parent();if(e(this).attr("id")!=k.attr("id")){var j;if(j=e(this).find("textarea").data("markdown"),j==null){j=e(this).find('div[data-provider="markdown-preview"]').data("markdown")}if(j){j.blur()}}})}h.stopPropagation()}};e(document).on("click.markdown.data-api",'[data-provide="markdown-editable"]',function(f){d(e(this));f.preventDefault()}).on("click",function(f){b(f)}).on("focusin",function(f){b(f)}).ready(function(){e('textarea[data-provide="markdown"]').each(function(){d(e(this))})})}(window.jQuery);