MINI
C:
/
siak
/
Siak71
/
bootstrap
/
v5
/
assets
/
plugins
/
bootstrap-markdown
/
js
/
Upload File:
files >> C:/siak/Siak71/bootstrap/v5/assets/plugins/bootstrap-markdown/js/bootstrap-markdown.min.js
!function(t){"use strict";var e=function(e,n){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.$oldContent=null,this.$isPreview=!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,r=this;t.each(i,function(t,i){var s=!0;s=a?!1:i.indexOf(e)<0,0==s&&n(r.$editor.find('button[data-handler="'+i+'"]'))})},__buildButtons:function(e,n){var i,a=this.$ns,r=this.$handler,s=this.$callback;for(i=0;i<e.length;i++){var o,l=e[i];for(o=0;o<l.length;o++){var c,h=l[o].data,d=t("<div/>",{"class":"btn-group"});for(c=0;c<h.length;c++){var u=h[c],p="",f=a+"-"+u.name,v=u.btnText?u.btnText:"",g=u.btnClass?u.btnClass:"btn",m=u.tabIndex?u.tabIndex:"-1";1==u.toggle&&(p=' data-toggle="button"'),d.append('<button class="'+g+' btn-default btn-sm" title="'+u.title+'" tabindex="'+m+'" data-provider="'+a+'" data-handler="'+f+'"'+p+'><span class="'+u.icon+'"></span> '+v+"</button>"),r.push(f),s.push(u.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.$textarea.css("resize","none"),this.$textarea.on("focus",t.proxy(this.focus,this)).on("keypress",t.proxy(this.keypress,this)).on("keyup",t.proxy(this.keyup,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,r=n.attr("data-handler"),s=i.indexOf(r),o=a[s];t(e.currentTarget).focus(),o(this),r.indexOf("cmdSave")<0&&this.$textarea.focus(),e.preventDefault()},showEditor:function(){var e,n=this,i=this.$ns,a=this.$element,r=(a.css("height"),a.css("width"),this.$editable),s=this.$handler,o=this.$callback,l=this.$options,c=t("<div/>",{"class":"md-editor",click:function(){n.focus()}});if(null==this.$editor){var h=t("<div/>",{"class":"md-header btn-toolbar"});if(l.buttons.length>0&&(h=this.__buildButtons(l.buttons,h)),l.additionalButtons.length>0&&(h=this.__buildButtons(l.additionalButtons,h)),c.append(h),a.is("textarea"))a.before(c),e=a,e.addClass("md-input"),c.append(e);else{var d="function"==typeof toMarkdown?toMarkdown(a.html()):a.html(),u=t.trim(d);e=t("<textarea/>",{"class":"md-input",val:u}),c.append(e),r.el=a,r.type=a.prop("tagName").toLowerCase(),r.content=a.html(),t(a[0].attributes).each(function(){r.attrKeys.push(this.nodeName),r.attrValues.push(this.nodeValue)}),a.replaceWith(c)}if(l.savable){var p=t("<div/>",{"class":"md-footer"}),f="cmdSave";s.push(f),o.push(l.onSave),p.append('<button class="btn btn-success" data-provider="'+i+'" data-handler="'+f+'"><i class="icon icon-white icon-ok"></i> Save</button>'),c.append(p)}t.each(["height","width"],function(t,e){"inherit"!=l[e]&&(jQuery.isNumeric(l[e])?c.css(e,l[e]+"px"):c.addClass(l[e]))}),this.$editor=c,this.$textarea=e,this.$editable=r,this.$oldContent=this.getContent(),this.__setListener(),this.$editor.attr("id",(new Date).getTime()),this.$editor.on("click",'[data-provider="bootstrap-markdown"]',t.proxy(this.__handle,this))}else this.$editor.show();return l.autofocus&&(this.$textarea.focus(),this.$editor.addClass("active")),l.onShow(this),this},showPreview:function(){var e,n=this.$options,i=n.onPreview(this),a=this.$textarea,r=a.next(),s=t("<div/>",{"class":"md-preview","data-provider":"markdown-preview"});return this.$isPreview=!0,this.disableButtons("all").enableButtons("cmdPreview"),e="string"==typeof i?i:"object"==typeof markdown?markdown.toHTML(a.val()):a.val(),s.html(e),r&&"md-footer"==r.attr("class")?s.insertBefore(r):a.parent().append(s),a.hide(),s.data("markdown",this),this},hidePreview:function(){this.$isPreview=!1;var t=this.$editor.find('div[data-provider="markdown-preview"]');return t.remove(),this.enableButtons("all"),this.$textarea.show(),this.__setListener(),this},isDirty:function(){return this.$oldContent!=this.getContent()},getContent:function(){return this.$textarea.val()},setContent:function(t){return this.$textarea.val(t),this},findSelection:function(t){var e,n=this.getContent();if(e=n.indexOf(t),e>=0&&t.length>0){var i,a=this.getSelection();return this.setSelection(e,e+t.length),i=this.getSelection(),this.setSelection(a.start,a.end),i}return null},getSelection:function(){var t=this.$textarea[0];return("selectionStart"in t&&function(){var e=t.selectionEnd-t.selectionStart;return{start:t.selectionStart,end:t.selectionEnd,length:e,text:t.value.substr(t.selectionStart,e)}}||function(){return null})()},setSelection:function(t,e){var n=this.$textarea[0];return("selectionStart"in n&&function(){n.selectionStart=t,n.selectionEnd=e}||function(){return null})()},replaceSelection:function(t){var e=this.$textarea[0];return("selectionStart"in e&&function(){return e.value=e.value.substr(0,e.selectionStart)+t+e.value.substr(e.selectionEnd,e.value.length),e.selectionStart=e.value.length,this}||function(){return e.value+=t,jQuery(e)})()},getNextTab:function(){if(0==this.$nextTab.length)return null;var t,e=this.$nextTab.shift();return"function"==typeof e?t=e():"object"==typeof e&&e.length>0&&(t=e),t},setNextTab:function(t,e){if("string"==typeof t){var n=this;this.$nextTab.push(function(){return n.findSelection(t)})}else if("numeric"==typeof t&&"numeric"==typeof e){var i=this.getSelection();this.setSelection(t,e),this.$nextTab.push(this.getSelection()),this.setSelection(i.start,i.end)}},enableButtons:function(t){var e=function(t){t.removeAttr("disabled")};return this.__alterButtons(t,e),this},disableButtons:function(t){var e=function(t){t.attr("disabled","disabled")};return this.__alterButtons(t,e),this},eventSupported:function(t){var e=t in this.$element;return e||(this.$element.setAttribute(t,"return;"),e="function"==typeof this.$element[t]),e},keydown:function(e){this.suppressKeyPressRepeat=~t.inArray(e.keyCode,[40,38,9,13,27]),this.keyup(e)},keypress:function(t){this.suppressKeyPressRepeat||this.keyup(t)},keyup:function(t){var e=!1;switch(t.keyCode){case 40:case 38:case 16:case 17:case 18:break;case 9:var n;if(n=this.getNextTab(),null!=n){var i=this;setTimeout(function(){i.setSelection(n.start,n.end)},500),e=!0}else{var a=this.getSelection();a.start==a.end&&a.end==this.getContent().length?e=!1:(this.setSelection(this.getContent().length,this.getContent().length),e=!0)}break;case 13:case 27:e=!1;break;default:e=!1}e&&(t.stopPropagation(),t.preventDefault())},focus:function(){var e=this.$options,n=(e.hideable,this.$editor);return n.addClass("active"),t(document).find(".md-editor").each(function(){if(t(this).attr("id")!=n.attr("id")){var e;e=t(this).find("textarea").data("markdown"),null==e&&(e=t(this).find('div[data-provider="markdown-preview"]').data("markdown")),e&&e.blur()}}),e.onFocus(this),this},blur:function(){var e=this.$options,n=e.hideable,i=this.$editor,a=this.$editable;if(i.hasClass("active")||0==this.$element.parent().length){if(i.removeClass("active"),n)if(null!=a.el){var r=t("<"+a.type+"/>"),s=this.getContent(),o="object"==typeof markdown?markdown.toHTML(s):s;t(a.attrKeys).each(function(t){r.attr(a.attrKeys[t],a.attrValues[t])}),r.html(o),i.replaceWith(r)}else i.hide();e.onBlur(this)}return this}};var n=t.fn.markdown;t.fn.markdown=function(n){return this.each(function(){var i=t(this),a=i.data("markdown"),r="object"==typeof n&&n;a||i.data("markdown",a=new e(this,r))})},t.fn.markdown.defaults={autofocus:!1,hideable:!1,savable:!1,width:"inherit",height:"inherit",buttons:[[{name:"groupFont",data:[{name:"cmdBold",title:"Bold",icon:"glyphicon glyphicon-bold",callback:function(t){var e,n,i=t.getSelection(),a=t.getContent();e=0==i.length?"strong text":i.text,"**"==a.substr(i.start-2,2)&&"**"==a.substr(i.end,2)?(t.setSelection(i.start-2,i.end+2),t.replaceSelection(e),n=i.start-2):(t.replaceSelection("**"+e+"**"),n=i.start+2),t.setSelection(n,n+e.length)}},{name:"cmdItalic",title:"Italic",icon:"glyphicon glyphicon-italic",callback:function(t){var e,n,i=t.getSelection(),a=t.getContent();e=0==i.length?"emphasized text":i.text,"*"==a.substr(i.start-1,1)&&"*"==a.substr(i.end,1)?(t.setSelection(i.start-1,i.end+1),t.replaceSelection(e),n=i.start-1):(t.replaceSelection("*"+e+"*"),n=i.start+1),t.setSelection(n,n+e.length)}},{name:"cmdHeading",title:"Heading",icon:"glyphicon glyphicon-header",callback:function(t){var e,n,i,a,r=t.getSelection(),s=t.getContent();e=0==r.length?"heading text":r.text+"\n",i=4,"### "==s.substr(r.start-i,i)||(i=3,"###"==s.substr(r.start-i,i))?(t.setSelection(r.start-i,r.end),t.replaceSelection(e),n=r.start-i):r.start>0&&(a=s.substr(r.start-1,1),!!a&&"\n"!=a)?(t.replaceSelection("\n\n### "+e),n=r.start+6):(t.replaceSelection("### "+e),n=r.start+4),t.setSelection(n,n+e.length)}}]},{name:"groupLink",data:[{name:"cmdUrl",title:"URL/Link",icon:"glyphicon glyphicon-globe",callback:function(t){{var e,n,i,a=t.getSelection();t.getContent()}e=0==a.length?"enter link description here":a.text,i=prompt("Insert Hyperlink","http://"),null!=i&&""!=i&&"http://"!=i&&(t.replaceSelection("["+e+"]("+i+")"),n=a.start+1,t.setSelection(n,n+e.length))}},{name:"cmdImage",title:"Image",icon:"glyphicon glyphicon-picture",callback:function(t){{var e,n,i,a=t.getSelection();t.getContent()}e=0==a.length?"enter image description here":a.text,i=prompt("Insert Image Hyperlink","http://"),null!=i&&(t.replaceSelection("'),n=a.start+2,t.setNextTab("enter image title here"),t.setSelection(n,n+e.length))}}]},{name:"groupMisc",data:[{name:"cmdList",title:"List",icon:"glyphicon glyphicon-list",callback:function(e){{var n,i,a=e.getSelection();e.getContent()}if(0==a.length)n="list text here",e.replaceSelection("- "+n),i=a.start+2;else if(a.text.indexOf("\n")<0)n=a.text,e.replaceSelection("- "+n),i=a.start+2;else{var r=[];r=a.text.split("\n"),n=r[0],t.each(r,function(t,e){r[t]="- "+e}),e.replaceSelection("\n\n"+r.join("\n")),i=a.start+4}e.setSelection(i,i+n.length)}}]},{name:"groupUtil",data:[{name:"cmdPreview",toggle:!0,title:"Preview",btnText:"Preview",btnClass:"btn btn-primary btn-sm",icon:"glyphicon glyphicon-search",callback:function(t){var e=t.$isPreview;0==e?t.showPreview():t.hidePreview()}}]}]],additionalButtons:[],onShow:function(){},onPreview:function(){},onSave:function(){},onBlur:function(){},onFocus:function(){}},t.fn.markdown.Constructor=e,t.fn.markdown.noConflict=function(){return t.fn.markdown=n,this};var i=function(t){var e=t;return e.data("markdown")?void e.data("markdown").showEditor():void e.markdown(e.data())},a=function(e){var n,i=!1,a=t(e.currentTarget);"focusin"!=e.type&&"click"!=e.type||1!=a.length||"object"!=typeof a[0]||(n=a[0].activeElement,t(n).data("markdown")||("undefined"==typeof t(n).parent().parent().parent().attr("class")||t(n).parent().parent().parent().attr("class").indexOf("md-editor")<0?("undefined"==typeof t(n).parent().parent().attr("class")||t(n).parent().parent().attr("class").indexOf("md-editor")<0)&&(i=!0):i=!1),i&&t(document).find(".md-editor").each(function(){var e=t(n).parent();if(t(this).attr("id")!=e.attr("id")){var i;i=t(this).find("textarea").data("markdown"),null==i&&(i=t(this).find('div[data-provider="markdown-preview"]').data("markdown")),i&&i.blur()}}),e.stopPropagation())};t(document).on("click.markdown.data-api",'[data-provide="markdown-editable"]',function(e){i(t(this)),e.preventDefault()}).on("click",function(t){a(t)}).on("focusin",function(t){a(t)}).ready(function(){t('textarea[data-provide="markdown"]').each(function(){i(t(this))})})}(window.jQuery);
Copyright ©2021 || Defacer Indonesia