/* =================================================== * bootstrap-markdown.js v2.3.1 * http://github.com/toopay/bootstrap-markdown * =================================================== * Copyright 2013 Taufan Aditya * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ========================================================== */ !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.$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(t,s){var v,x=this.$ns,h=this.$handler,k=this.$callback;for(v=0;v",{"class":"btn-group"});for(o=0;o '+f+"");h.push(u);k.push(g.callback)}s.append(r)}}return s},__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);this.$textarea.css("resize","none");this.$textarea.on("focus",e.proxy(this.focus,this)).on("keypress",e.proxy(this.keypress,this)).on("keyup",e.proxy(this.keyup,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);if(g.indexOf("cmdSave")<0){this.$textarea.focus()}j.preventDefault()},showEditor:function(){var r=this,q,o=this.$ns,f=this.$element,p=f.css("height"),h=f.css("width"),j=this.$editable,t=this.$handler,s=this.$callback,u=this.$options,l=e("
",{"class":"md-editor",click:function(){r.focus()}});if(this.$editor==null){var g=e("
",{"class":"md-header btn-toolbar"});if(u.buttons.length>0){g=this.__buildButtons(u.buttons,g)}if(u.additionalButtons.length>0){g=this.__buildButtons(u.additionalButtons,g)}l.append(g);if(f.is("textarea")){f.before(l);q=f;q.addClass("md-input");l.append(q)}else{var m=(typeof toMarkdown=="function")?toMarkdown(f.html()):f.html(),n=e.trim(m);q=e("