天津投入产出系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
13 KiB

/* ===================================================
* 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<t.length;v++){var p,l=t[v];for(p=0;p<l.length;p++){var o,w=l[p].data,r=e("<div/>",{"class":"btn-group"});for(o=0;o<w.length;o++){var g=w[o],q="",u=x+"-"+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";if(g.toggle==true){q=' data-toggle="button"'}r.append('<button type="button" class="'+m+' btn-default btn-sm" title="'+g.title+'" tabindex="'+j+'" data-provider="'+x+'" data-handler="'+u+'"'+q+'><span class="'+n+'"></span> '+f+"</button>");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("<div/>",{"class":"md-editor",click:function(){r.focus()}});if(this.$editor==null){var g=e("<div/>",{"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("<textarea/>",{"class":"md-input",val:n});l.append(q);j.el=f;j.type=f.prop("tagName").toLowerCase();j.content=f.html();e(f[0].attributes).each(function(){j.attrKeys.push(this.nodeName);j.attrValues.push(this.nodeValue)});f.replaceWith(l)}if(u.savable){var k=e("<div/>",{"class":"md-footer"}),i="cmdSave";t.push(i);s.push(u.onSave);k.append('<button class="btn btn-success" data-provider="'+o+'" data-handler="'+i+'"><i class="icon icon-white icon-ok"></i> Save</button>');l.append(k)}e.each(["height","width"],function(w,v){if(u[v]!="inherit"){if(jQuery.isNumeric(u[v])){l.css(v,u[v]+"px")}else{l.addClass(u[v])}}});this.$editor=l;this.$textarea=q;this.$editable=j;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))}else{this.$editor.show()}if(u.autofocus){this.$textarea.focus();this.$editor.addClass("active")}u.onShow(this);return this},showPreview:function(){var h=this.$options,i=h.onPreview(this),f=this.$textarea,k=f.next(),g=e("<div/>",{"class":"md-preview","data-provider":"markdown-preview"}),j;this.$isPreview=true;this.disableButtons("all").enableButtons("cmdPreview");if(typeof i=="string"){j=i}else{var l=f.val();if(typeof markdown=="object"){j=markdown.toHTML(l)}else{if(typeof marked=="function"){j=marked(l)}else{j=l}}}g.html(j);if(k&&k.attr("class")=="md-footer"){g.insertB