Current Directory: /home/astoriaah/www/components/com_jce/editor/libraries/pro/js/editor
Viewing File: /home/astoriaah/www/components/com_jce/editor/libraries/pro/js/editor/text.min.js
/* jce - 2.9.24 | 2022-05-27 | https://www.joomlacontenteditor.net | Copyright (C) 2006 - 2022 Ryan Demmer. All rights reserved | GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html */
!function($){$.fn.codemirror=function(options){return this.each(function(){if("undefined"==typeof CodeMirror)throw"CodeMirror is not loaded!";"codemirror"==options.theme&&(options.theme="default");var settings={mode:"text/html",theme:options.theme,indentWithTabs:!0,smartIndent:!0,tabMode:"indent",styleActiveLine:!0,highlightSelectionMatches:!!options.selection_match,autoCloseTags:!!options.tag_closing,foldGutter:!0,gutters:["CodeMirror-linenumbers","CodeMirror-foldgutter"],widget:"..."};cm=CodeMirror($(this).get(0),settings),cm.activeLine=0,$(this).on("codemirror:wrap",function(evt,state){cm.setOption("lineWrapping",state);try{cm.focus()}catch(e){}}),options.font_size&&(/px/.test(options.font_size)||(options.font_size+="px"),cm.getWrapperElement().style.fontSize=options.font_size),$(this).on("codemirror:linenumbers",function(evt,state){cm.setOption("lineNumbers",state);try{cm.focus()}catch(e){}}),$(this).on("codemirror:highlight",function(evt,state){var c=cm.getCursor();state?cm.setOption("mode","text/html"):cm.setOption("mode","text/plain"),cm.setCursor(c);try{cm.focus()}catch(e){}}),$(this).on("codemirror:resize",function(evt,w,h){cm.setSize(w||null,h)}),$(this).on("codemirror:setcontent",function(evt,value){""===value&&(value=" "),cm.setValue(value);try{cm.focus()}catch(e){}}),$(this).on("codemirror:insertcontent",function(value){return cm.replaceSelection(value)}),$(this).on("codemirror:getcontent",function(){var value=cm.getValue();return value=value.replace(/^\s*|\s*$/g,"")}),cm.getSearchState=function(){function SearchState(){this.posFrom=this.posTo=this.query=null,this.marked=[]}return cm.state.search||(cm.state.search=new SearchState)},cm.clearSearch=function(){cm.operation(function(){var state=cm.getSearchState(cm);if(state.query){state.query=null;for(var i=0;i<state.marked.length;++i)state.marked[i].clear();state.marked.length=0,cm.removeOverlay(state.overlay)}})},$(this).on("codemirror:clearsearch",cm.clearSearch),$(this).on("codemirror:search",function(evt,query,rev,re){function searchOverlay(query){return"string"==typeof query?{token:function(stream){return stream.match(query)?"searching":(stream.next(),void(stream.skipTo(query.charAt(0))||stream.skipToEnd()))}}:{token:function(stream){if(stream.match(query))return"searching";for(;!stream.eol()&&(stream.next(),!stream.match(query,!1)););}}}function getSearchCursor(cm,query,pos){return cm.getSearchCursor(query,pos,"string"==typeof query&&query==query.toLowerCase())}function doSearch(cm,rev,query){var state=cm.getSearchState(cm);return state.query?findNext(cm,rev):void(query&&(state.query=query,cm.removeOverlay(state.overlay),state.overlay=searchOverlay(state.query),cm.addOverlay(state.overlay),state.posFrom=state.posTo=cm.getCursor(),findNext(cm,rev)))}function findNext(cm,rev){cm.operation(function(){var state=cm.getSearchState(),cursor=getSearchCursor(cm,state.query,rev?state.posFrom:state.posTo);(cursor.find(rev)||(cursor=getSearchCursor(cm,state.query,rev?CodeMirror.Pos(cm.lastLine()):CodeMirror.Pos(cm.firstLine(),0)),cursor.find(rev)))&&(cm.setSelection(cursor.pos.from,cursor.pos.to),state.posFrom=cursor.pos.from,state.posTo=cursor.pos.to,cm.scrollIntoView(cursor.pos.from))})}re&&(query=new RegExp(query));var state=cm.getSearchState(cm);state.query!==query&&cm.clearSearch(),doSearch(cm,rev,query)}),$(this).on("codemirror:replace",function(evt,query,text,all,re){function getSearchCursor(cm,query,pos){return cm.getSearchCursor(query,pos,"string"==typeof query&&query==query.toLowerCase())}function advance(){var match,start=cursor.pos.from;return(match=cursor.findNext())||(cursor=cm.getSearchCursor(query),start&&(match=cursor.findNext())&&(cursor.pos.from.line!=start.line||cursor.pos.from.ch!=start.ch))?(cm.setSelection(cursor.pos.from,cursor.pos.to),doReplace(match),cm.setCursor(cursor.pos.to),cm.scrollIntoView(cursor.pos.to),void cm.focus()):(cm.focus(),!1)}function doReplace(match){cursor.replace("string"==typeof query?text:text.replace(/\$(\d)/,function(w,i){return match[i]}))}if(re&&(query=new RegExp(query)),all)for(var cursor=getSearchCursor(cm,query);cursor.findNext();)if("string"!=typeof query){var match=cm.getRange(cursor.from(),cursor.to()).match(query);if(!match)return;cursor.replace(text.replace(/\$(\d)/g,function(w,i){return match[i]}))}else cursor.replace(text);else{cm.clearSearch();var cursor=getSearchCursor(cm,query,cm.getCursor());advance()}}),cm.format=function(){function getSelectedRange(){return{from:cm.getCursor(!0),to:cm.getCursor(!1)}}CodeMirror.commands.selectAll(cm);var range=getSelectedRange();cm.autoFormatRange(range.from,range.to)},cm.setCursorPos=function(pos){cm.setCursor({line:pos,ch:0},{scroll:!1});var doc=cm.getDoc(),cursor=doc.getCursor(),line=doc.getLine(cursor.line);cm.setCursor({line:pos,ch:line.length},{scroll:!0}),cm.activeLine=pos},cm.getCursorPos=function(){return cm.getCursor().line||cm.activeLine||1},cm.on("mousedown",function(){window.setTimeout(function(){cm.activeLine=cm.getCursor().line},10)}),cm.on("keyup",function(){window.setTimeout(function(){cm.activeLine=cm.getCursor().line},10)}),cm.refresh(),cm.isActive=!0})}}(jQuery),function($){var CodeEditor={options:{format:!0,width:"100%",height:"100%",theme:"codemirror",font_size:"",fullscreen:!1,editor:{},format_options:{},linenumbers:!0,wrap:!0,onsave:function(){}},init:function(options){function loadContent(content){self.options.format&&content&&(content=self.formatHTML(content)),self._load(content)}var self=this;$.extend(this.options,options),this.src=tinyMCEPopup.getWindowArg("url");var content=tinyMCEPopup.getWindowArg("content")||" ";$(document).ready(function(){self._createToolbar(),$(".source-editor-container").codemirror(self.options),loadContent(content),self.src&&$.ajax({url:self.src+"?"+$.now(),dataType:"text"}).done(function(content){loadContent(content)}).fail(function(e,status,txt){"abort"!==status&&Wf.Modal.alert(status)}),$("button.save").on("click",function(e){self.save(),e.preventDefault()})})},formatHTML:function(html,options){if(this.src&&/\.json$/i.test(this.src)){try{html=JSON.stringify(JSON.parse(html),null,"\t")}catch(e){}return html}return options=$.extend({indent_size:1,indent_char:"\t",max_char:0,wrap_line_length:0,inline:["a","abbr","b","bdi","bdo","br","cite","code","data","del","dfn","em","i","img","ins","kbd","keygen","map","mark","math","meter","noscript","output","progress","q","ruby","s","samp","small","span","strong","sub","sup","time","u","var","wbr","text","acronym","big","strike","tt"]},this.options.format_options),"undefined"!=typeof html_beautify?html_beautify(html,options):html},_createToolbar:function(){var opt=this.options,$elm=$(".source-editor-container");$(".source-editor .uk-navbar button").click(function(e){e.preventDefault();var action=$(this).data("action");if("search"==action||"search-previous"==action){var f=$("#source_search_value").val(),prev=!("search-previous"!=action);return $elm.trigger("codemirror:search",[f,prev,$('button[data-action="regex"]').hasClass("uk-active")])}if("replace"==action||"replace-all"==action){var f=$("#source_search_value").val(),r=$("#source_replace_value").val(),all=!("replace-all"!=action);return $elm.trigger("codemirror:replace",[f,r,all,$('button[data-action="regex"]').hasClass("uk-active")])}$(this).hasClass("uk-button-checkbox")&&$(this).toggleClass("uk-active"),$elm.trigger("codemirror:"+action,$(this).hasClass("uk-active"))}).filter(".uk-button-checkbox").each(function(){var action=$(this).data("action");opt[action]&&$(this).addClass("uk-active")}),$("#source_search_value").change(function(){""===this.value&&$elm.trigger("codemirror:clearsearch")})},setButtonState:function(button,state){$('.source-editor .uk-navbar button[data-action="'+button+'"]').toggleClass("uk-active",state)},_load:function(content){var self=this;$(".source-editor-container").on("codemirror:format",function(){var html=$(this).triggerHandler("codemirror:getcontent");self.setContent(html,!0)}),this._loaded(content)},_loaded:function(content){this.setContent(content),$(".source-editor-container").trigger("codemirror:wrap",!!this.options.wrap),$(".source-editor-container").trigger("codemirror:linenumbers",!!this.options.linenumbers),$(".source-editor-container").trigger("codemirror:focus")},setContent:function(value,format){format&&(value=this.formatHTML(value)),$(".source-editor-container").trigger("codemirror:setcontent",value)},getContent:function(){return $(".source-editor-container").triggerHandler("codemirror:getcontent")},resize:function(w,h,init){h-=$(".uk-navbar").outerHeight(),$(".source-editor-container").css({width:w,height:h})},undo:function(){this.editor.undo(),this.focus()},redo:function(){this.editor.redo(),this.focus()},indent:function(){},getContainer:function(){return this.container||null},format:function(){var html=this.getContent();html=this._format(html),this.setContent(html)},setActive:function(state){this.editor.isActive=!!state},_setLoader:function(){$('<div class="loading" />').appendTo("body")},_removeLoader:function(){$("div.loading","body").remove()},save:function(){var self=this,src=tinyMCEPopup.getWindowArg("src"),content=this.getContent(),name="",ext="html";src&&(name=Wf.String.basename(src),name=Wf.String.stripExt(name),ext=Wf.String.getExt(src)),self._setLoader();var options=FileBrowser.options;Wf.Modal.prompt(tinyMCEPopup.getLang("dlg.save_file","Save File"),function(name){name=Wf.String.safe(name,options.websafe_mode,options.websafe_spaces,options.websafe_textcase);var saveResolve=tinyMCEPopup.getWindowArg("save");if("function"==typeof saveResolve)return void saveResolve(name,content).finally(function(){self._removeLoader()});var file=name+"."+ext||Wf.String.basename(src);Wf.JSON.request("saveTextFile",{json:[src,file],data:content},function(o){self.options.onsave.apply(self.options.scope||self,[src]),self._removeLoader()})},{text:tinyMCEPopup.getLang("dlg.name","Name"),value:name,open:function(e){$(".uk-modal-footer .uk-text",e.target).text(tinyMCEPopup.getLang("dlg.save","Save")),$("#dialog-prompt-input").parent().addClass("uk-form-icon uk-form-icon-flip").append('<span class="uk-text-muted uk-icon-none">.'+ext+"</span>")},validate:function(value){return!!value&&Wf.String.safe(value,options.websafe_mode,options.websafe_spaces,options.websafe_textcase)}})}};window.CodeEditor=CodeEditor}(jQuery);