File: D:/HostingSpaces/SBogers10/kms.komma.pro/wwwroot/lib/editor/trumbowyg.min.js
$.trumbowyg={langs:{en:{viewHTML:"View HTML",formatting:"Formatting",p:"Paragraph",blockquote:"Quote",code:"Code",header:"Header",bold:"Bold",italic:"Italic",strikethrough:"Stroke",underline:"Underline",strong:"Strong",em:"Emphasis",del:"Deleted",unorderedList:"Unordered list",orderedList:"Ordered list",insertImage:"Insert Image",insertVideo:"Insert Video",link:"Link",createLink:"Insert link",unlink:"Remove link",justifyLeft:"Align Left",justifyCenter:"Align Center",justifyRight:"Align Right",justifyFull:"Align Justify",horizontalRule:"Insert horizontal rule",fullscreen:"fullscreen",close:"Close",submit:"Confirm",reset:"Cancel",invalidUrl:"Invalid URL",required:"Required",description:"Description",title:"Title",text:"Text"}},opts:{},btnsGrps:{design:["bold","italic","underline","strikethrough"],semantic:["strong","em","del"],justify:["justifyLeft","justifyCenter","justifyRight","justifyFull"],lists:["unorderedList","orderedList"]}},function(t){t.fn.trumbowyg=function(i,s){if(t.isObject(i)||null==i)return this.each(function(){t(this).data("trumbowyg")||t(this).data("trumbowyg",new e(this,i))});if(1==this.length)try{var n=t(this).data("trumbowyg");switch(i){case"openModal":return n.openModal(s.title,s.content);case"closeModal":return n.closeModal();case"openModalInsert":return n.openModalInsert(s.title,s.fields,s.callback);case"saveSelection":return n.saveSelection();case"getSelection":return n.selection;case"getSelectedText":return n.selection+"";case"restoreSelection":return n.restoreSelection();case"destroy":return n.destroy();case"lang":return n.lang;case"duration":return n.o.duration;case"html":return n.html(s)}}catch(o){}return!1};var e=function(e,i){this.$e=t(e),this.$creator=t(e),i=t.extend(!0,{},i,t.trumbowyg.opts),this.lang="undefined"==typeof i.lang||"undefined"==typeof t.trumbowyg.langs[i.lang]?t.trumbowyg.langs.en:t.extend(!0,{},t.trumbowyg.langs.en,t.trumbowyg.langs[i.lang]),this.o=t.extend(!0,{lang:"en",dir:"ltr",duration:200,mobile:!1,tablet:!0,closable:!1,fullscreenable:!0,fixedBtnPane:!1,fixedFullWidth:!1,semantic:!1,resetCss:!1,autogrow:!1,prefix:"trumbowyg-",convertLink:!0,btns:["viewHTML","|","formatting","|",t.trumbowyg.btnsGrps.design,"|","link","|","insertImage","|",t.trumbowyg.btnsGrps.justify,"|",t.trumbowyg.btnsGrps.lists,"|","horizontalRule"],btnsAdd:[],btnsDef:{viewHTML:{func:"toggle"},p:{func:"formatBlock"},blockquote:{func:"formatBlock"},h1:{func:"formatBlock",title:this.lang.header+" 1"},h2:{func:"formatBlock",title:this.lang.header+" 2"},h3:{func:"formatBlock",title:this.lang.header+" 3"},h4:{func:"formatBlock",title:this.lang.header+" 4"},bold:{},italic:{},underline:{},strikethrough:{},strong:{func:"bold"},em:{func:"italic"},del:{func:"strikethrough"},createLink:{},unlink:{},insertImage:{},justifyLeft:{},justifyCenter:{},justifyRight:{},justifyFull:{},unorderedList:{func:"insertUnorderedList"},orderedList:{func:"insertOrderedList"},horizontalRule:{func:"insertHorizontalRule"},formatting:{dropdown:["p","blockquote","h1","h2","h3","h4"]},link:{dropdown:["createLink","unlink"]}}},i),this.o.semantic&&!i.btns?this.o.btns=["viewHTML","|","formatting","|",t.trumbowyg.btnsGrps.semantic,"|","link","|","insertImage","|",t.trumbowyg.btnsGrps.justify,"|",t.trumbowyg.btnsGrps.lists,"|","horizontalRule"]:i&&i.btns&&(this.o.btns=i.btns),this.init()};e.prototype={init:function(){return this.height=this.$e.css("height"),this.isEnabled()?(this.buildEditor(!0),void 0):(this.buildEditor(),this.buildBtnPane(),this.fixedBtnPaneEvents(),this.buildOverlay(),void 0)},buildEditor:function(e){if(e!==!0){this.$box=t("<div/>",{"class":this.o.prefix+"box "+this.o.prefix+this.o.lang+" trumbowyg"}),this.isTextarea=!0,this.$e.is("textarea")?this.$editor=t("<div/>"):(this.$editor=this.$e,this.$e=this.buildTextarea().val(this.$e.val()),this.isTextarea=!1),this.$e.hide().addClass(this.o.prefix+"textarea");var i="";this.isTextarea?(i=this.$e.val(),this.$box.insertAfter(this.$e).append(this.$editor).append(this.$e)):(i=this.$editor.html(),this.$box.insertAfter(this.$editor).append(this.$e).append(this.$editor),this.syncCode()),this.$editor.addClass(this.o.prefix+"editor").attr("contenteditable",!0).attr("dir",this.o.dir).html(i),this.o.resetCss&&this.$editor.addClass(this.o.prefix+"reset-css"),this.o.autogrow||(this.$editor.css({height:this.height,overflow:"auto"}),this.$e.css({height:this.height,overflow:"auto"})),this.o.semantic&&(this.$editor.html(this.$editor.html().replace("<br>","</p><p>").replace("&nsbp;","")),this.semanticCode());var s=this;this.$editor.on("dblclick","img",function(){var e=t(this);return s.openModalInsert(s.lang.insertImage,{url:{label:"URL",value:e.attr("src"),required:!0},alt:{label:"description",value:e.attr("alt")}},function(t){e.attr("src",t.url),e.attr("alt",t.alt)}),!1}).on("keyup",function(){s.semanticCode()}).on("blur",function(){s.syncCode()})}else if(!this.$e.is("textarea")){var n=this.buildTextarea().val(this.$e.val());this.$e.hide().after(n)}},buildTextarea:function(){return t('<textarea name="'+this.$e.attr("id")+'"></textarea>',{height:this.height})},buildBtnPane:function(){var e=this;if(e.o.btns!==!1){var i=e.o.prefix;e.$btnPane=t("<ul/>",{"class":i+"button-pane"}),t.each(e.o.btns.concat(e.o.btnsAdd),t.proxy(function(s,n){try{var o=n.split("btnGrp-");void 0!=o[1]&&(n=t.trumbowyg.btnsGrps[o[1]])}catch(r){}t.isArray(n)||(n=[n]),t.each(n,t.proxy(function(s,n){try{var o=t("<li/>");"|"==n?o.addClass(i+"separator"):("viewHTML"==n&&o.addClass(i+"not-disable"),o.append(e.buildBtn(n))),e.$btnPane.append(o)}catch(r){}},e))},e));var s=t("<li/>",{"class":i+"not-disable "+i+"buttons-right"});e.o.fullscreenable&&s.append(e.buildRightBtn("fullscreen").on("click",t.proxy(function(){var s=i+"fullscreen";e.$box.toggleClass(s),e.$box.hasClass(s)?(t("body").css("overflow","hidden"),e.$box.css({position:"fixed",top:0,left:0,width:"100%",height:"100%",margin:0,padding:0,zIndex:10}),t([e.$editor,e.$e]).each(function(){t(this).css({height:"100%",overflow:"auto"})}),e.$btnPane.css("width","100%")):(t("body").css("overflow","auto"),e.$box.removeAttr("style"),e.o.autogrow||(h=e.height,t([e.$editor,e.$e]).each(function(){t(e).css("height",h)}))),t(window).trigger("scroll")},e))),e.o.closable&&s.append(e.buildRightBtn("close").on("click",t.proxy(function(){var s=i+"fullscreen";e.$box.hasClass(s)&&t("body").css("overflow","auto"),e.destroy()},e))),s.not(":empty")&&e.$btnPane.append(s),e.$box.prepend(e.$btnPane)}},buildBtn:function(e){var i=this.o.prefix,s=this.o.btnsDef[e],n=this,o=t("<a/>",{href:"javascript:void(null);","class":i+e+"-button"+(s.ico?" "+i+s.ico+"-button":""),text:s.text||s.title||this.lang[e]||e.charAt(0).toUpperCase()+e.slice(1),title:s.title||s.text||this.lang[e]||e.charAt(0).toUpperCase()+e.slice(1),mousedown:function(o){return(!s.dropdown||n.$box.find("."+e+"-"+i+"dropdown").is(":hidden"))&&t("body").trigger("mousedown"),n.$btnPane.hasClass(i+"disable")&&!t(this).parent().hasClass(i+"not-disable")?!1:(n.execCommand((s.dropdown?"dropdown":!1)||s.func||e,s.param||e),o.stopPropagation(),o.preventDefault(),!1)}});if(s.dropdown){o.addClass(i+"open-dropdown");var r=i+"dropdown",a=t("<div/>",{"class":e+"-"+r+" "+r+" "+i+"fixed-top"});a.data("visible",!1);for(var l=0,h=s.dropdown.length;h>l;l++)n.o.btnsDef[s.dropdown[l]]&&a.append(n.buildSubBtn(s.dropdown[l]));this.$box.append(a.hide())}return o},buildSubBtn:function(e){var i=this.o.btnsDef[e];return t("<a/>",{href:"javascript:void(null);",text:i.text||i.title||this.lang[e]||e,mousedown:t.proxy(function(s){return t("body").trigger("mousedown"),this.execCommand(i.func||e,i.param||e),s.stopPropagation(),s.preventDefault(),!1},this)})},buildRightBtn:function(e){return t("<a/>",{href:"javascript:void(null);","class":this.o.prefix+e+"-button",title:this.lang[e],text:this.lang[e]})},buildOverlay:function(){return this.$overlay=t("<div/>",{"class":this.o.prefix+"overlay"}).css({top:this.$btnPane.outerHeight(),height:parseInt(this.$editor.outerHeight())+1+"px"}).appendTo(this.$box)},showOverlay:function(){t(window).trigger("scroll"),this.$overlay.fadeIn(this.o.duration),this.$box.addClass(this.o.prefix+"box-blur")},hideOverlay:function(){this.$overlay.fadeOut(this.o.duration/4),this.$box.removeClass(this.o.prefix+"box-blur")},fixedBtnPaneEvents:function(){this.o.fixedBtnPane&&(this.isFixed=!1,t(window).on("scroll",t.proxy(function(){if(this.$box){this.syncCode();var e=t(window).scrollTop(),i=this.$box.offset().top+1,s=e-i>0&&e-i-parseInt(this.height)<0;s?(this.isFixed||(this.isFixed=!0,this.$btnPane.css({position:"fixed",top:0,left:this.o.fixedFullWidth?"0":"auto",width:this.o.fixedFullWidth?"100%":parseInt(this.$box.css("width"))-1+"px",zIndex:7}),this.$editor.css({marginTop:this.$btnPane.css("height")}),this.$e.css({marginTop:this.$btnPane.css("height")})),t("."+this.o.prefix+"fixed-top",this.$box).css({position:this.o.fixedFullWidth?"fixed":"absolute",top:this.o.fixedFullWidth?this.$btnPane.outerHeight():parseInt(this.$btnPane.outerHeight())+(e-i)+"px",zIndex:15})):this.isFixed&&(this.isFixed=!1,this.$btnPane.css({position:"relative"}),this.$editor.css({marginTop:0}),this.$e.css({marginTop:0}),t("."+this.o.prefix+"fixed-top",this.$box).css({position:"absolute",top:this.$btnPane.outerHeight()}))}},this)))},destroy:function(){var t=this.html();this.isTextarea?this.$box.after(this.$e.css({height:this.height}).val(t).removeClass(this.o.prefix+"textarea").show()):this.$box.after(this.$editor.css({height:this.height}).removeClass(this.o.prefix+"editor").attr("contenteditable",!1).html(t).show()),this.$box.remove(),this.$creator.removeData("trumbowyg")},toggle:function(){this.semanticCode(),this.$editor.toggle(),this.$e.toggle(),this.$btnPane.toggleClass(this.o.prefix+"disable"),this.$btnPane.find("."+this.o.prefix+"viewHTML-button").toggleClass(this.o.prefix+"active")},dropdown:function(e){var i=this.o.prefix,s=this.$box.find("."+e+"-"+i+"dropdown"),n=this.$btnPane.find("."+i+e+"-button");s.is(":hidden")?(n.addClass(this.o.prefix+"active"),s.css({position:"absolute",top:this.$btnPane.outerHeight(),left:this.o.fixedFullWidth&&this.isFixed?n.offset().left+"px":n.offset().left-this.$btnPane.offset().left+"px"}).show(),t(window).trigger("scroll"),t("body").on("mousedown",t.proxy(function(){t("."+i+"dropdown").hide(),t("."+i+"active").removeClass(i+"active"),t("body").off("mousedown")},this))):t("body").trigger("mousedown")},html:function(t){return t?(this.$e.val(t),this.syncCode(!0),tbw):this.$e.val()},syncCode:function(t){!t&&this.$editor.is(":visible")?this.$e.val(this.$editor.html()):this.$editor.html(this.$e.val()),this.o.autogrow&&(this.height=this.$editor.css("height"),this.$e.css({height:this.height}))},semanticCode:function(e){this.syncCode(e),this.o.semantic&&(this.semanticTag("b","strong"),this.semanticTag("i","em"),this.semanticTag("strike","del"),this.$editor.contents().filter(function(){return 3===this.nodeType&&t.trim(this.nodeValue).length>0}).wrap("<p></p>").end().filter("br").remove(),this.$e.val(this.$editor.html()))},semanticTag:function(e,i){t(e,this.$editor).each(function(){t(this).replaceWith(function(){return"<"+i+">"+t(this).html()+"</"+i+">"})})},createLink:function(){var t=this;this.saveSelection(),this.openModalInsert(this.lang.createLink,{url:{label:"URL",value:"http://",required:!0},title:{label:this.lang.title,value:this.selection},text:{label:this.lang.text,value:this.selection}},function(e){return t.execCommand("createLink",e.url),!0})},insertImage:function(){var t=this;this.saveSelection(),this.openModalInsert(this.lang.insertImage,{url:{label:"URL",value:"http://",required:!0},alt:{label:"description",value:this.selection}},function(e){return t.execCommand("insertImage",e.url),!0})},execCommand:function(t,e){"dropdown"!=t&&this.$editor.focus();try{this[t](e)}catch(i){try{t(e,this)}catch(i){this.$editor.focus(),"insertHorizontalRule"==t&&(e=null),document.execCommand(t,!1,e)}}this.syncCode()},formatBlock:function(e){t.browser.msie&&(e="<"+e+">"),document.execCommand("formatBlock",!1,e)},openModal:function(e,i){var s=this.o.prefix;if(t("."+s+"modal-box",this.$box).size()>0)return!1;this.saveSelection(),this.showOverlay(),this.$btnPane.addClass(s+"disable"),t("."+s+"not-disable",this.$btnPane).not("."+s+"buttons-right").removeClass(s+"not-disable").addClass(s+"not-disable-old");var n=t("<div/>",{"class":s+"modal "+s+"fixed-top"}).css({top:parseInt(this.$btnPane.css("height"))+1+"px"}).appendTo(this.$box);this.$overlay.one("click",function(t){t.preventDefault(),n.trigger(s+"cancel")}),$e=this.$editor,$form=t("<form/>",{action:"javascript:void(null);",html:i}).on("submit",function(t){t.preventDefault(),n.trigger(s+"confirm")}).on("reset",function(t){t.preventDefault(),n.trigger(s+"cancel")});var o=t("<div/>",{"class":s+"modal-box",html:$form}).css({top:"-"+parseInt(this.$btnPane.outerHeight())+"px",opacity:0}).appendTo(n).animate({top:0,opacity:1},this.o.duration/2);return t("<span/>",{text:e,"class":s+"modal-title"}).prependTo(o),o.find("input:first").focus(),this.buildModalBtn("submit",o),this.buildModalBtn("reset",o),t("body").trigger("scroll"),n},buildModalBtn:function(e,i){return t("<input/>",{"class":this.o.prefix+"modal-button "+this.o.prefix+"modal-"+e,value:this.lang[e]||e,type:e}).appendTo(i.find("form"))},closeModal:function(){var e=this.o.prefix;this.$btnPane.removeClass(e+"disable"),this.$overlay.off(),t("."+this.o.prefix+"not-disable-old",this.$btnPane).removeClass(e+"not-disable-old").addClass(e+"not-disable");var i=this,s=t("."+e+"modal-box",this.$box);s.animate({top:"-"+s.css("height")},this.o.duration/2,function(){t(this).parent().remove(),i.hideOverlay()})},openModalInsert:function(e,i,s){var n="",o=this.o.prefix;for(f in i){var r=i[f];label=void 0==r.label?this.lang[f]?this.lang[f]:f.charAt(0).toUpperCase()+f.slice(1):this.lang[r.label]?this.lang[r.label]:r.label,void 0==r.name&&(r.name=f),r.pattern||"url"!=f||(r.pattern=/^(http|https):\/\/([\w~#!:.?+=&%@!\-\/]+)$/,r.patternError=this.lang.invalidUrl),n+='<label><input type="'+(r.type||"text")+'" name="'+r.name+'" value="'+(r.value||"")+'"><span class="'+o+'input-infos"><span>'+label+"</span></span></label>"}var a=this.openModal(e,n),l=this;return a.on(o+"confirm",function(){var e=t(this).find("form"),n=!0,r={};for(f in i){var h=t('input[name="'+f+'"]',e);r[f]=h.val(),!i[f].required||null!=r[f]&&void 0!=r[f]&&""!=t.trim(r[f])?i[f].pattern&&!i[f].pattern.test(r[f])&&(n=!1,l.addErrorOnModalField(h,i[f].patternError)):(n=!1,l.addErrorOnModalField(h,l.lang.required))}n&&(l.restoreSelection(),s(r,i)&&(l.syncCode(),l.closeModal(),a.off(o+"confirm")))}).one(o+"cancel",function(){a.off(o+"confirm"),l.closeModal(),l.restoreSelection()}),a},addErrorOnModalField:function(t,e){var i=t.parent(),s=this.o.prefix;i.addClass(s+"input-error"),t.on("change keyup",function(){i.removeClass(s+"input-error")}),i.find("input+span").append('<span class="'+s+'msg-error">'+e+"</span>")},saveSelection:function(){if(this.selection=null,window.getSelection){var t=window.getSelection();t.getRangeAt&&t.rangeCount&&(this.selection=t.getRangeAt(0))}else document.selection&&document.selection.createRange&&(this.selection=document.selection.createRange())},restoreSelection:function(){if(range=this.selection)if(window.getSelection){var t=window.getSelection();t.removeAllRanges(),t.addRange(range)}else document.selection&&range.select&&range.select()},isEnabled:function(){var t="iPhone|iPod|Android|BlackBerry|WindowssPhone|ZuneWP7",e=new RegExp("(iPad|webOS)"),i=new RegExp("("+t+")");return this.o.tablet===!0&&e.test(navigator.userAgent)||this.o.mobile===!0&&i.test(navigator.userAgent)}};var i=Object.prototype.toString,s=Object.prototype.hasOwnProperty;t.isObject=function(t){if("[object Object]"!==i.call(t))return!1;var e;for(e in t);return!e||s.call(t,e)},t.isString=function(t){return"string"==typeof t}}(jQuery);