/* * Copyright © 2018 Regular Labs - All Rights Reserved * License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ var RegularLabsModalsPopup=null;(function($){"use strict";RegularLabsModalsPopup={init:function(){$('ul.nav-tabs > li > a').on('shown.bs.tab',function(){$('#type').val($(this)[0].hash.replace('#tab-','')).trigger('change');});var selection=this.getSelection();if(selection){$('input[name="text"]').val(selection);} $('.reglab-overlay').css('cursor','').fadeOut();},insertText:function(){var tag=this.getTag();if(!tag){return false;} window.parent.Joomla.editors.instances[modals_editorname].replaceSelection(tag);return true;},getSelection:function(){var editor_textarea=window.parent.document.getElementById(modals_editorname);if(!editor_textarea){return false;} var iframes=editor_textarea.parentNode.getElementsByTagName('iframe');if(!iframes.length){return false;} var editor_frame=iframes[0];var contentWindow=editor_frame.contentWindow;if(typeof contentWindow.getSelection!=='undefined'){var sel=contentWindow.getSelection();if(sel.rangeCount){var container=contentWindow.document.createElement("div");for(var i=0,len=sel.rangeCount;i