!function(t){"use strict";var e=function(e,n){var i=["autofocus","savable","hideable","width","height","resize","iconlibrary","language","footer","fullscreen","hiddenButtons","disabledButtons"];t.each(i,function(i,a){"undefined"!=typeof t(e).data(a)&&(n="object"==typeof n?n:{},n[a]=t(e).data(a))}),this.$ns="bootstrap-markdown",this.$element=t(e),this.$editable={el:null,type:null,attrKeys:[],attrValues:[],content:null},this.$options=t.extend(!0,{},t.fn.markdown.defaults,n,this.$element.data("options")),this.$oldContent=null,this.$isPreview=!1,this.$isFullscreen=!1,this.$editor=null,this.$textarea=null,this.$handler=[],this.$callback=[],this.$nextTab=[],this.showEditor()};e.prototype={constructor:e,__alterButtons:function(e,n){var i=this.$handler,a="all"==e,s=this;t.each(i,function(t,i){var o=!0;o=a?!1:i.indexOf(e)<0,o===!1&&n(s.$editor.find('button[data-handler="'+i+'"]'))})},__buildButtons:function(e,n){var i,a=this.$ns,s=this.$handler,o=this.$callback;for(i=0;i",{"class":"btn-group"});for(c=0;c"),u.text(" "+this.__localize(m)).addClass("btn-default btn-sm").addClass(b),b.match(/btn\-(primary|success|info|warning|danger|link)/)&&u.removeClass("btn-default"),u.attr({type:"button",title:this.__localize(p.title)+w,tabindex:y,"data-provider":a,"data-handler":g,"data-hotkey":k}),p.toggle===!0&&u.attr("data-toggle","button"),f=t(""),f.addClass(v),f.prependTo(u),d.append(u),s.push(g),o.push(p.callback)}n.append(d)}}return n},__setListener:function(){var e="undefined"!=typeof this.$textarea.attr("rows"),n=this.$textarea.val().split("\n").length>5?this.$textarea.val().split("\n").length:"5",i=e?this.$textarea.attr("rows"):n;this.$textarea.attr("rows",i),this.$options.resize&&this.$textarea.css("resize",this.$options.resize),this.$textarea.on("focus",t.proxy(this.focus,this)).on("keypress",t.proxy(this.keypress,this)).on("keyup",t.proxy(this.keyup,this)).on("change",t.proxy(this.change,this)).on("select",t.proxy(this.select,this)),this.eventSupported("keydown")&&this.$textarea.on("keydown",t.proxy(this.keydown,this)),this.$textarea.data("markdown",this)},__handle:function(e){var n=t(e.currentTarget),i=this.$handler,a=this.$callback,s=n.attr("data-handler"),o=i.indexOf(s),r=a[o];t(e.currentTarget).focus(),r(this),this.change(this),s.indexOf("cmdSave")<0&&this.$textarea.focus(),e.preventDefault()},__localize:function(e){var n=t.fn.markdown.messages,i=this.$options.language;return"undefined"!=typeof n&&"undefined"!=typeof n[i]&&"undefined"!=typeof n[i][e]?n[i][e]:e},__getIcon:function(t){return"object"==typeof t?t[this.$options.iconlibrary]:t},setFullscreen:function(e){var n=this.$editor,i=this.$textarea;e===!0?(n.addClass("md-fullscreen-mode"),t("body").addClass("md-nooverflow"),this.$options.onFullscreen(this)):(n.removeClass("md-fullscreen-mode"),t("body").removeClass("md-nooverflow"),1==this.$isPreview&&this.hidePreview().showPreview()),this.$isFullscreen=e,i.focus()},showEditor:function(){var e,n=this,i=this.$ns,a=this.$element,s=(a.css("height"),a.css("width"),this.$editable),o=this.$handler,r=this.$callback,l=this.$options,c=t("
",{"class":"md-editor",click:function(){n.focus()}});if(null===this.$editor){var h=t("
",{"class":"md-header btn-toolbar"}),d=[];if(l.buttons.length>0&&(d=d.concat(l.buttons[0])),l.additionalButtons.length>0&&(d=d.concat(l.additionalButtons[0])),l.reorderButtonGroups.length>0&&(d=d.filter(function(t){return l.reorderButtonGroups.indexOf(t.name)>-1}).sort(function(t,e){return l.reorderButtonGroups.indexOf(t.name)l.reorderButtonGroups.indexOf(e.name)?1:0})),d.length>0&&(h=this.__buildButtons([d],h)),l.fullscreen.enable&&h.append('
').on("click",".md-control-fullscreen",function(t){t.preventDefault(),n.setFullscreen(!0)}),c.append(h),a.is("textarea"))a.before(c),e=a,e.addClass("md-input"),c.append(e);else{var u="function"==typeof toMarkdown?toMarkdown(a.html()):a.html(),f=t.trim(u);e=t("