3
0
Fork 0
This repository has been archived on 2024-11-14. You can view files and clone it, but cannot push or open issues or pull requests.
ThemeParkPlus-Panel/public/assets/js/jquery.wysibb.min.js

5 lines
62 KiB
JavaScript
Raw Permalink Normal View History

2021-06-27 19:01:43 +00:00
/*! WysiBB v1.5.1 2014-03-26
Author: Vadim Dobroskok
*/
"undefined"==typeof WBBLANG&&(WBBLANG={}),WBBLANG.en=CURLANG={bold:"Bold",italic:"Italic",underline:"Underline",strike:"Strike",link:"Link",img:"Insert image",sup:"Superscript",sub:"Subscript",justifyleft:"Align left",justifycenter:"Align center",justifyright:"Align right",table:"Insert table",bullist:"• Unordered list",numlist:"1. Ordered list",quote:"Quote",offtop:"Offtop",code:"Code",spoiler:"Spoiler",fontcolor:"Font color",fontsize:"Font size",fontfamily:"Font family",fs_verysmall:"Very small",fs_small:"Small",fs_normal:"Normal",fs_big:"Big",fs_verybig:"Very big",smilebox:"Insert emoticon",video:"Insert YouTube",removeFormat:"Remove Format",modal_link_title:"Insert link",modal_link_text:"Display text",modal_link_url:"URL",modal_email_text:"Display email",modal_email_url:"Email",modal_link_tab1:"Insert URL",modal_img_title:"Insert image",modal_img_tab1:"Insert URL",modal_img_tab2:"Upload image",modal_imgsrc_text:"Enter image URL",modal_img_btn:"Choose file",add_attach:"Add Attachment",modal_video_text:"Enter the URL of the video",close:"Close",save:"Save",cancel:"Cancel",remove:"Delete",validation_err:"The entered data is invalid",error_onupload:"Error during file upload",fileupload_text1:"Drop file here",fileupload_text2:"or",loading:"Loading",auto:"Auto",views:"Views",downloads:"Downloads",sm1:"Smile",sm2:"Laughter",sm3:"Wink",sm4:"Thank you",sm5:"Scold",sm6:"Shock",sm7:"Angry",sm8:"Pain",sm9:"Sick"},wbbdebug=!0,function(a){"use strict";a.wysibb=function(b,c){a(b).data("wbb",this),c&&c.deflang&&"undefined"!=typeof WBBLANG[c.deflang]&&(CURLANG=WBBLANG[c.deflang]),c&&c.lang&&"undefined"!=typeof WBBLANG[c.lang]&&(CURLANG=WBBLANG[c.lang]),this.txtArea=b,this.$txtArea=a(b);this.$txtArea.attr("id")||this.setUID(this.txtArea);this.options={bbmode:!1,onlyBBmode:!1,themeName:"default",bodyClass:"",lang:"ru",tabInsert:!0,imgupload:!1,img_uploadurl:"/iupload.php",img_maxwidth:800,img_maxheight:800,hotkeys:!0,showHotkeys:!0,autoresize:!0,resize_maxheight:800,loadPageStyles:!0,traceTextarea:!0,smileConversion:!0,buttons:"bold,italic,underline,strike,sup,sub,|,img,video,link,|,bullist,numlist,|,fontcolor,fontsize,fontfamily,|,justifyleft,justifycenter,justifyright,|,quote,code,table,removeFormat",allButtons:{bold:{title:CURLANG.bold,buttonHTML:'<span class="fonticon ve-tlb-bold1"></span>',excmd:"bold",hotkey:"ctrl+b",transform:{"<b>{SELTEXT}</b>":"[b]{SELTEXT}[/b]","<strong>{SELTEXT}</strong>":"[b]{SELTEXT}[/b]"}},italic:{title:CURLANG.italic,buttonHTML:'<span class="fonticon ve-tlb-italic1"></span>',excmd:"italic",hotkey:"ctrl+i",transform:{"<i>{SELTEXT}</i>":"[i]{SELTEXT}[/i]","<em>{SELTEXT}</em>":"[i]{SELTEXT}[/i]"}},underline:{title:CURLANG.underline,buttonHTML:'<span class="fonticon ve-tlb-underline1"></span>',excmd:"underline",hotkey:"ctrl+u",transform:{"<u>{SELTEXT}</u>":"[u]{SELTEXT}[/u]"}},strike:{title:CURLANG.strike,buttonHTML:'<span class="fonticon fi-stroke1 ve-tlb-strike1"></span>',excmd:"strikeThrough",transform:{"<strike>{SELTEXT}</strike>":"[s]{SELTEXT}[/s]","<s>{SELTEXT}</s>":"[s]{SELTEXT}[/s]"}},sup:{title:CURLANG.sup,buttonHTML:'<span class="fonticon ve-tlb-sup1"></span>',excmd:"superscript",transform:{"<sup>{SELTEXT}</sup>":"[sup]{SELTEXT}[/sup]"}},sub:{title:CURLANG.sub,buttonHTML:'<span class="fonticon ve-tlb-sub1"></span>',excmd:"subscript",transform:{"<sub>{SELTEXT}</sub>":"[sub]{SELTEXT}[/sub]"}},link:{title:CURLANG.link,buttonHTML:'<span class="fonticon ve-tlb-link1"></span>',hotkey:"ctrl+shift+2",modal:{title:CURLANG.modal_link_title,width:"500px",tabs:[{input:[{param:"SELTEXT",title:CURLANG.modal_link_text,type:"div"},{param:"URL",title:CURLANG.modal_link_url,validation:"^http(s)?://"}]}]},transform:{'<a href="{URL}">{SELTEXT}</a>':"[url={URL}]{SELTEXT}[/url]",'<a href="{URL}">{URL}</a>':"[url]{URL}[/url]"}},img:{title:CURLANG.img,buttonHTML:'<span class="fonticon ve-tlb-img1"></span>',hotkey:"ctrl+shift+1",addWrap:!0,modal:{title:CURLANG.modal_img_title,width:"600px",tabs:[{title:CURLANG.modal_img_tab1,input:[{param:"SRC",title:CURLANG.modal_imgsrc_text,validation:"^http(s)
return!1}{var l=this.getRange(),m=this.getSelectText();this.getSelectNode()}m=""==m?"":this.clearFromSubInsert(m,b);var n=this.elFromString(m),o=window.getSelection?l.cloneRange():this.body.createTextRange(),p=window.getSelection?l.cloneRange():this.body.createTextRange();if(window.getSelection){this.insertAtCursor('<span id="wbbdivide"></span>');var q=i.find("span#wbbdivide").get(0);o.setStart(h.firstChild,0),o.setEndBefore(q),p.setStartAfter(q),p.setEndAfter(h.lastChild)}else o.moveToElementText(h),p.moveToElementText(h),o.setEndPoint("EndToStart",l),p.setEndPoint("StartToEnd",l);var r=this.getSelectText(!1,o),s=this.getSelectText(!1,p);if(""!=s){var t=i.clone().html(s);i.after(t)}return c!==!0&&i.after(n),window.getSelection?(i.html(r),c!==!0&&this.selectNode(n)):i.replaceWith(r),!1},this))}},execNativeCommand:function(b,c){if(this.body.focus(),"insertHTML"!=b||window.getSelection)if("insertHTML"==b){var d=this.getSelection(),e=this.elFromString(c),f=this.lastRange?this.lastRange:this.getRange();f.deleteContents(),f.insertNode(e),f.collapse(!1),d.removeAllRanges(),d.addRange(f)}else"undefined"==typeof c&&(c=!1),this.lastRange&&(a.log("Last range select"),this.selectLastRange()),document.execCommand(b,!1,c);else{var g=this.lastRange?this.lastRange:document.selection.createRange();g.pasteHTML(c);var h=a("<div>").html(c).text(),i=h.indexOf("");i>-1&&(g.moveStart("character",-1*(h.length-i)),g.select()),this.lastRange=!1}},getCodeByCommand:function(a,b){return this.options.bbmode?this.getBBCodeByCommand(a,b):this.getHTMLByCommand(a,b)},getBBCodeByCommand:function(b,c){if(!this.options.allButtons[b])return"";"undefined"==typeof c&&(c={}),c=this.keysToLower(c),c.seltext||(c.seltext=this.getSelectText(!0));var d=this.options.allButtons[b].bbcode;d=d.replace(/\{(.*?)(\[.*?\])*\}/g,function(a,b,d){if(d){var e;if(d&&(e=new RegExp(d+"+","i")),"undefined"!=typeof c[b.toLowerCase()]&&null===c[b.toLowerCase()].toString().match(e))return""}return"undefined"==typeof c[b.toLowerCase()]?"":c[b.toLowerCase()]});var e=null,f=0;if(this.options.allButtons[b].transform){var g=[];a.each(this.options.allButtons[b].transform,function(a,b){g.push(b)}),g=this.sortArray(g,-1),a.each(g,function(a,b){var d=!0,g=0,h={};b=b.replace(/\{(.*?)(\[.*?\])*\}/g,function(a,b,e){var f;return b=b.toLowerCase(),e&&(f=new RegExp(e+"+","i")),("undefined"==typeof c[b.toLowerCase()]||e&&null===c[b.toLowerCase()].toString().match(f))&&(d=!1),"undefined"==typeof c[b]||h[b]||(h[b]=1,g++),"undefined"==typeof c[b.toLowerCase()]?"":c[b.toLowerCase()]}),d&&g>f&&(e=b,f=g)})}return e||d},getHTMLByCommand:function(b,c){if(!this.options.allButtons[b])return"";c=this.keysToLower(c),"undefined"==typeof c&&(c={}),c.seltext||(c.seltext=this.getSelectText(!1),""==c.seltext?c.seltext="":(c.seltext=this.clearFromSubInsert(c.seltext,b),this.options.allButtons[b].onlyClearText===!0&&(c.seltext=this.toBB(c.seltext).replace(/\</g,"&lt;").replace(/\n/g,"<br/>").replace(/\s{3}/g,'<span class="wbbtab"></span>'))));var d="";this.seltextID="wbbid_"+ ++this.lastid,"link"!=b&&"img"!=b?c.seltext='<span id="'+this.seltextID+'">'+c.seltext+"</span>":d='<span id="'+this.seltextID+'"></span>';var e=this.options.allButtons[b].html;e=e.replace(/\{(.*?)(\[.*?\])*\}/g,function(a,b,d){if(d){var e=new RegExp(d+"+","i");if("undefined"!=typeof c[b.toLowerCase()]&&null===c[b.toLowerCase()].toString().match(e))return""}return"undefined"==typeof c[b.toLowerCase()]?"":c[b.toLowerCase()]});var f=null,g=0;if(this.options.allButtons[b].transform){var h=[];a.each(this.options.allButtons[b].transform,function(a){h.push(a)}),h=this.sortArray(h,-1),a.each(h,function(a,b){var d=!0,e=0,h={};b=b.replace(/\{(.*?)(\[.*?\])*\}/g,function(a,b,f){var g;return b=b.toLowerCase(),f&&(g=new RegExp(f+"+","i")),("undefined"==typeof c[b]||f&&null===c[b].toString().match(g))&&(d=!1),"undefined"==typeof c[b]||h[b]||(h[b]=1,e++),"undefined"==typeof c[b]?"":c[b]}),d&&e>g&&(f=b,g=e)})}return(f||e)+d},getSelection:function(){return window.getSelection?window.getSelection():document.selection?(this.options.bbmode,document.sel