!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&module.exports?module.exports=function(b,c){return void 0===c&&(c="undefined"!=typeof window?require("jquery"):require("jquery")(b)),a(c),c}:a(jQuery)}(function(a){var b=function(c,d){this.id=++a.FE.ID,this.opts=a.extend(!0,{},a.extend({},b.DEFAULTS,"object"==typeof d&&d));var e=JSON.stringify(this.opts);a.FE.OPTS_MAPPING[e]=a.FE.OPTS_MAPPING[e]||this.id,this.sid=a.FE.OPTS_MAPPING[e],a.FE.SHARED[this.sid]=a.FE.SHARED[this.sid]||{},this.shared=a.FE.SHARED[this.sid],this.shared.count=(this.shared.count||0)+1,this.$oel=a(c),this.$oel.data("froala.editor",this),this.o_doc=c.ownerDocument,this.o_win="defaultView"in this.o_doc?this.o_doc.defaultView:this.o_doc.parentWindow;var f=a(this.o_win).scrollTop();this.$oel.on("froala.doInit",a.proxy(function(){this.$oel.off("froala.doInit"),this.doc=this.$el.get(0).ownerDocument,this.win="defaultView"in this.doc?this.doc.defaultView:this.doc.parentWindow,this.$doc=a(this.doc),this.$win=a(this.win),this.opts.pluginsEnabled||(this.opts.pluginsEnabled=Object.keys(a.FE.PLUGINS)),this.opts.initOnClick?(this.load(a.FE.MODULES),this.$el.on("touchstart.init",function(){a(this).data("touched",!0)}),this.$el.on("touchmove.init",function(){a(this).removeData("touched")}),this.$el.on("mousedown.init touchend.init dragenter.init focus.init",a.proxy(function(b){if("touchend"==b.type&&!this.$el.data("touched"))return!0;if(1===b.which||!b.which){this.$el.off("mousedown.init touchstart.init touchmove.init touchend.init dragenter.init focus.init"),this.load(a.FE.MODULES),this.load(a.FE.PLUGINS);var c=b.originalEvent&&b.originalEvent.originalTarget;c&&"IMG"==c.tagName&&a(c).trigger("mousedown"),"undefined"==typeof this.ul&&this.destroy(),"touchend"==b.type&&this.image&&b.originalEvent&&b.originalEvent.target&&a(b.originalEvent.target).is("img")&&setTimeout(a.proxy(function(){this.image.edit(a(b.originalEvent.target))},this),100),this.ready=!0,this.events.trigger("initialized")}},this))):(this.load(a.FE.MODULES),this.load(a.FE.PLUGINS),a(this.o_win).scrollTop(f),"undefined"==typeof this.ul&&this.destroy(),this.ready=!0,this.events.trigger("initialized"))},this)),this._init()};b.DEFAULTS={initOnClick:!1,pluginsEnabled:null},b.MODULES={},b.PLUGINS={},b.VERSION="2.4.2",b.INSTANCES=[],b.OPTS_MAPPING={},b.SHARED={},b.ID=0,b.prototype._init=function(){var b=this.$oel.prop("tagName"),c=a.proxy(function(){"TEXTAREA"!=b&&(this._original_html=this._original_html||this.$oel.html()),this.$box=this.$box||this.$oel,this.opts.fullPage&&(this.opts.iframe=!0),this.opts.iframe?(this.$iframe=a(''},{test_regex:/^.*(vimeo\.com\/)((channels\/[A-z]+\/)|(groups\/[A-z]+\/videos\/))?([0-9]+)/,url_regex:/(?:https?:\/\/)?(?:www\.)?(?:vimeo\.com)\/(?:channels\/[A-z]+\/|groups\/[A-z]+\/videos\/)?(.+)/g,url_text:'//player.vimeo.com/video/$1',html:''},{test_regex:/^.+(dailymotion.com|dai.ly)\/(video|hub)?\/?([^_]+)[^#]*(#video=([^_&]+))?/,url_regex:/(?:https?:\/\/)?(?:www\.)?(?:dailymotion\.com|dai\.ly)\/(?:video|hub)?\/?(.+)/g,url_text:'//www.dailymotion.com/embed/video/$1',html:''},{test_regex:/^.+(screen.yahoo.com)\/[^_&]+/,url_regex:'',url_text:'',html:''},{test_regex:/^.+(rutube.ru)\/[^_&]+/,url_regex:/(?:https?:\/\/)?(?:www\.)?(?:rutube\.ru)\/(?:video)?\/?(.+)/g,url_text:'//rutube.ru/play/embed/$1',html:''}];$.FE.VIDEO_EMBED_REGEX=/^\W*((<\/iframe>)|())\W*$/i;$.FE.PLUGINS.video=function(editor){var $overlay;var $handler;var $video_resizer;var $current_video;function _refreshInsertPopup(){var $popup=editor.popups.get('video.insert');var $url_input=$popup.find('.fr-video-by-url-layer input');$url_input.val('').trigger('change');var $embed_area=$popup.find('.fr-video-embed-layer textarea');$embed_area.val('').trigger('change');} function showInsertPopup(){var $btn=editor.$tb.find('.fr-command[data-cmd="insertVideo"]');var $popup=editor.popups.get('video.insert');if(!$popup)$popup=_initInsertPopup();if(!$popup.hasClass('fr-active')){editor.popups.refresh('video.insert');editor.popups.setContainer('video.insert',editor.$tb);var left=$btn.offset().left+$btn.outerWidth()/2;var top=$btn.offset().top+(editor.opts.toolbarBottom?10:$btn.outerHeight()-10);editor.popups.show('video.insert',left,top,$btn.outerHeight());}} function _showEditPopup(){var $popup=editor.popups.get('video.edit');if(!$popup)$popup=_initEditPopup();editor.popups.setContainer('video.edit',$(editor.opts.scrollableContainer));editor.popups.refresh('video.edit');var $video_obj=$current_video.find('iframe, embed, video');var left=$video_obj.offset().left+$video_obj.outerWidth()/2;var top=$video_obj.offset().top+$video_obj.outerHeight();editor.popups.show('video.edit',left,top,$video_obj.outerHeight());} function _initInsertPopup(delayed){if(delayed){editor.popups.onRefresh('video.insert',_refreshInsertPopup);return true;} var video_buttons='';if(editor.opts.videoInsertButtons.length>1){video_buttons='
'+editor.button.buildList(editor.opts.videoInsertButtons)+'
';} var by_url_layer='';if(editor.opts.videoInsertButtons.indexOf('videoByURL')>=0){by_url_layer='
'} var embed_layer='';if(editor.opts.videoInsertButtons.indexOf('videoEmbed')>=0){embed_layer='
'} var template={buttons:video_buttons,by_url_layer:by_url_layer,embed_layer:embed_layer} var $popup=editor.popups.create('video.insert',template);return $popup;} function showLayer(name){var $popup=editor.popups.get('video.insert');var left;var top;if(!$current_video&&!editor.opts.toolbarInline){var $btn=editor.$tb.find('.fr-command[data-cmd="insertVideo"]');left=$btn.offset().left+$btn.outerWidth()/2;top=$btn.offset().top+(editor.opts.toolbarBottom?10:$btn.outerHeight()-10);} if(editor.opts.toolbarInline){top=$popup.offset().top-editor.helpers.getPX($popup.css('margin-top'));if($popup.hasClass('fr-above')){top+=$popup.outerHeight();}} $popup.find('.fr-layer').removeClass('fr-active');$popup.find('.fr-'+name+'-layer').addClass('fr-active');editor.popups.show('video.insert',left,top,0);} function refreshByURLButton($btn){var $popup=editor.popups.get('video.insert');if($popup.find('.fr-video-by-url-layer').hasClass('fr-active')){$btn.addClass('fr-active');}} function refreshEmbedButton($btn){var $popup=editor.popups.get('video.insert');if($popup.find('.fr-video-embed-layer').hasClass('fr-active')){$btn.addClass('fr-active');}} function insert(embedded_code){editor.events.focus(true);editor.selection.restore();editor.html.insert(''+embedded_code+'',false,editor.opts.videoSplitHTML);editor.popups.hide('video.insert');var $video=editor.$el.find('.fr-jiv');$video.removeClass('fr-jiv');$video.toggleClass('fr-draggable',editor.opts.videoMove);editor.events.trigger('video.inserted',[$video]);} function insertByURL(link){if(typeof link=='undefined'){var $popup=editor.popups.get('video.insert');link=$popup.find('.fr-video-by-url-layer input[type="text"]').val()||'';} var video=null;if(editor.helpers.isURL(link)){for(var i=0;i<$.FE.VIDEO_PROVIDERS.length;i++){var vp=$.FE.VIDEO_PROVIDERS[i];if(vp.test_regex.test(link)){video=link.replace(vp.url_regex,vp.url_text);video=vp.html.replace(/\{url\}/,video);break;}}} if(video){insert(video);} else{editor.events.trigger('video.linkError',[link]);}} function insertEmbed(code){if(typeof code=='undefined'){var $popup=editor.popups.get('video.insert');code=$popup.find('.fr-video-embed-layer textarea').val()||'';} if(code.length===0||!$.FE.VIDEO_EMBED_REGEX.test(code)){editor.events.trigger('video.codeError',[code]);} else{insert(code);}} function _handlerMousedown(e){if(!editor.core.sameInstance($video_resizer))return true;e.preventDefault();e.stopPropagation();var c_x=e.pageX||(e.originalEvent.touches?e.originalEvent.touches[0].pageX:null);var c_y=e.pageY||(e.originalEvent.touches?e.originalEvent.touches[0].pageY:null);if(!c_x||!c_y){return false;} if(!editor.undo.canDo())editor.undo.saveStep();$handler=$(this);$handler.data('start-x',c_x);$handler.data('start-y',c_y);$overlay.show();editor.popups.hideAll();_unmarkExit();} function _handlerMousemove(e){if(!editor.core.sameInstance($video_resizer))return true;if($handler){e.preventDefault() var c_x=e.pageX||(e.originalEvent.touches?e.originalEvent.touches[0].pageX:null);var c_y=e.pageY||(e.originalEvent.touches?e.originalEvent.touches[0].pageY:null);if(!c_x||!c_y){return false;} var s_x=$handler.data('start-x');var s_y=$handler.data('start-y');$handler.data('start-x',c_x);$handler.data('start-y',c_y);var diff_x=c_x-s_x;var diff_y=c_y-s_y;var $video_obj=$current_video.find('iframe, embed, video');var width=$video_obj.width();var height=$video_obj.height();if($handler.hasClass('fr-hnw')||$handler.hasClass('fr-hsw')){diff_x=0-diff_x;} if($handler.hasClass('fr-hnw')||$handler.hasClass('fr-hne')){diff_y=0-diff_y;} $video_obj.css('width',width+diff_x);$video_obj.css('height',height+diff_y);$video_obj.removeAttr('width');$video_obj.removeAttr('height');_repositionResizer();}} function _handlerMouseup(e){if(!editor.core.sameInstance($video_resizer))return true;if($handler&&$current_video){if(e)e.stopPropagation();$handler=null;$overlay.hide();_repositionResizer();_showEditPopup();editor.undo.saveStep();}} function _getHandler(pos){return'
';} function _initResizer(){var doc;if(!editor.shared.$video_resizer){editor.shared.$video_resizer=$('
');$video_resizer=editor.shared.$video_resizer;editor.events.$on($video_resizer,'mousedown',function(e){e.stopPropagation();},true);if(editor.opts.videoResize){$video_resizer.append(_getHandler('nw')+_getHandler('ne')+_getHandler('sw')+_getHandler('se'));editor.shared.$vid_overlay=$('
');$overlay=editor.shared.$vid_overlay;doc=$video_resizer.get(0).ownerDocument;$(doc).find('body').append($overlay);}}else{$video_resizer=editor.shared.$video_resizer;$overlay=editor.shared.$vid_overlay;editor.events.on('destroy',function(){$video_resizer.removeClass('fr-active').appendTo($('body'));},true);} editor.events.on('shared.destroy',function(){$video_resizer.html('').removeData().remove();$video_resizer=null;if(editor.opts.videoResize){$overlay.remove();$overlay=null;}},true);if(!editor.helpers.isMobile()){editor.events.$on($(editor.o_win),'resize.video',function(){_exitEdit(true);});} if(editor.opts.videoResize){doc=$video_resizer.get(0).ownerDocument;editor.events.$on($video_resizer,editor._mousedown,'.fr-handler',_handlerMousedown);editor.events.$on($(doc),editor._mousemove,_handlerMousemove);editor.events.$on($(doc.defaultView||doc.parentWindow),editor._mouseup,_handlerMouseup);editor.events.$on($overlay,'mouseleave',_handlerMouseup);}} function _repositionResizer(){if(!$video_resizer)_initResizer();(editor.$wp||$(editor.opts.scrollableContainer)).append($video_resizer);$video_resizer.data('instance',editor);var $video_obj=$current_video.find('iframe, embed, video');$video_resizer.css('top',(editor.opts.iframe?$video_obj.offset().top-1:$video_obj.offset().top-editor.$wp.offset().top-1)+editor.$wp.scrollTop()).css('left',(editor.opts.iframe?$video_obj.offset().left-1:$video_obj.offset().left-editor.$wp.offset().left-1)+editor.$wp.scrollLeft()).css('width',$video_obj.outerWidth()).css('height',$video_obj.height()).addClass('fr-active')} var touchScroll;function _edit(e){if(e&&e.type=='touchend'&&touchScroll){return true;} e.preventDefault();e.stopPropagation();if(editor.edit.isDisabled()){return false;} for(var i=0;i<$.FE.INSTANCES.length;i++){if($.FE.INSTANCES[i]!=editor){$.FE.INSTANCES[i].events.trigger('video.hideResizer');}} editor.toolbar.disable();if(editor.helpers.isMobile()){editor.events.disableBlur();editor.$el.blur();editor.events.enableBlur();} $current_video=$(this);$(this).addClass('fr-active');if(editor.opts.iframe){editor.size.syncIframe();} _repositionResizer();_showEditPopup();editor.selection.clear();editor.button.bulkRefresh();editor.events.trigger('image.hideResizer');} function _exitEdit(force_exit){if($current_video&&(_canExit()||force_exit===true)){$video_resizer.removeClass('fr-active');editor.toolbar.enable();$current_video.removeClass('fr-active');$current_video=null;_unmarkExit();}} editor.shared.vid_exit_flag=false;function _markExit(){editor.shared.vid_exit_flag=true;} function _unmarkExit(){editor.shared.vid_exit_flag=false;} function _canExit(){return editor.shared.vid_exit_flag;} function _initEvents(){editor.events.on('mousedown window.mousedown',_markExit);editor.events.on('window.touchmove',_unmarkExit);editor.events.on('mouseup window.mouseup',_exitEdit);editor.events.on('commands.mousedown',function($btn){if($btn.parents('.fr-toolbar').length>0){_exitEdit();}});editor.events.on('blur video.hideResizer commands.undo commands.redo element.dropped',function(){_exitEdit(true);});} function _initEditPopup(){var video_buttons='';if(editor.opts.videoEditButtons.length>=1){video_buttons+='
';video_buttons+=editor.button.buildList(editor.opts.videoEditButtons);video_buttons+='
';} var template={buttons:video_buttons} var $popup=editor.popups.create('video.edit',template);editor.events.$on(editor.$wp,'scroll.video-edit',function(){if($current_video&&editor.popups.isVisible('video.edit')){_showEditPopup();}});return $popup;} function _refreshSizePopup(){if($current_video){var $popup=editor.popups.get('video.size');var $video_obj=$current_video.find('iframe, embed, video') $popup.find('input[name="width"]').val($video_obj.get(0).style.width||$video_obj.attr('width')).trigger('change');$popup.find('input[name="height"]').val($video_obj.get(0).style.height||$video_obj.attr('height')).trigger('change');}} function showSizePopup(){var $popup=editor.popups.get('video.size');if(!$popup)$popup=_initSizePopup();editor.popups.refresh('video.size');editor.popups.setContainer('video.size',$(editor.opts.scrollableContainer));var $video_obj=$current_video.find('iframe, embed, video') var left=$video_obj.offset().left+$video_obj.width()/2;var top=$video_obj.offset().top+$video_obj.height();editor.popups.show('video.size',left,top,$video_obj.height());} function _initSizePopup(delayed){if(delayed){editor.popups.onRefresh('video.size',_refreshSizePopup);return true;} var video_buttons='';video_buttons='
'+editor.button.buildList(editor.opts.videoSizeButtons)+'
';var size_layer='';size_layer='
';var template={buttons:video_buttons,size_layer:size_layer} var $popup=editor.popups.create('video.size',template);editor.events.$on(editor.$wp,'scroll',function(){if($current_video&&editor.popups.isVisible('video.size')){showSizePopup();}});return $popup;} function align(val){$current_video.removeClass('fr-fvr fr-fvl');if(val=='left'){$current_video.addClass('fr-fvl');} else if(val=='right'){$current_video.addClass('fr-fvr');} _repositionResizer();_showEditPopup();} function refreshAlign($btn){if(!$current_video)return false;if($current_video.hasClass('fr-fvl')){$btn.find('> *:first').replaceWith(editor.icon.create('align-left'));} else if($current_video.hasClass('fr-fvr')){$btn.find('> *:first').replaceWith(editor.icon.create('align-right'));} else{$btn.find('> *:first').replaceWith(editor.icon.create('align-justify'));}} function refreshAlignOnShow($btn,$dropdown){var alignment='justify';if($current_video.hasClass('fr-fvl')){alignment='left';} else if($current_video.hasClass('fr-fvr')){alignment='right';} $dropdown.find('.fr-command[data-param1="'+alignment+'"]').addClass('fr-active');} function display(val){$current_video.removeClass('fr-dvi fr-dvb');if(val=='inline'){$current_video.addClass('fr-dvi');} else if(val=='block'){$current_video.addClass('fr-dvb');} _repositionResizer();_showEditPopup();} function refreshDisplayOnShow($btn,$dropdown){var d='block';if($current_video.hasClass('fr-dvi')){d='inline';} $dropdown.find('.fr-command[data-param1="'+d+'"]').addClass('fr-active');} function remove(){if($current_video){if(editor.events.trigger('video.beforeRemove',[$current_video])!==false){var $video=$current_video;editor.popups.hideAll();_exitEdit(true);editor.selection.setBefore($video.get(0))||editor.selection.setAfter($video.get(0));$video.remove();editor.selection.restore();editor.html.fillEmptyBlocks();editor.events.trigger('video.removed',[$video]);}}} function _convertStyleToClasses($video){if(!$video.hasClass('fr-dvi')&&!$video.hasClass('fr-dvb')){var flt=$video.css('float');$video.css('float','none');if($video.css('display')=='block'){$video.css('float',flt);if(parseInt($video.css('margin-left'),10)===0&&($video.attr('style')||'').indexOf('margin-right: auto')>=0){$video.addClass('fr-fvl');} else if(parseInt($video.css('margin-right'),10)===0&&($video.attr('style')||'').indexOf('margin-left: auto')>=0){$video.addClass('fr-fvr');} $video.addClass('fr-dvb');} else{$video.css('float',flt);if($video.css('float')=='left'){$video.addClass('fr-fvl');} else if($video.css('float')=='right'){$video.addClass('fr-fvr');} $video.addClass('fr-dvi');} $video.css('margin','');$video.css('float','');$video.css('display','');$video.css('z-index','');$video.css('position','');$video.css('overflow','');$video.css('vertical-align','');} if(!editor.opts.videoTextNear){$video.removeClass('fr-dvi').addClass('fr-dvb');}} function _refreshVideoList(){editor.$el.find('video').filter(function(){return $(this).parents('span.fr-video').length===0;}).wrap('');editor.$el.find('embed, iframe').filter(function(){if(editor.browser.safari&&this.getAttribute('src')){this.setAttribute('src',this.src);} if($(this).parents('span.fr-video').length>0)return false;var link=$(this).attr('src');for(var i=0;i<$.FE.VIDEO_PROVIDERS.length;i++){var vp=$.FE.VIDEO_PROVIDERS[i];if(vp.test_regex.test(link)){return true;}} return false;}).map(function(){return $(this).parents('object').length===0?this:$(this).parents('object').get(0);}).wrap('');var videos=editor.$el.find('span.fr-video');for(var i=0;i'+this.icon.create('align-'+val)+'';}} c+='';return c;},callback:function(cmd,val){this.video.align(val);},refresh:function($btn){this.video.refreshAlign($btn);},refreshOnShow:function($btn,$dropdown){this.video.refreshAlignOnShow($btn,$dropdown);}}) $.FE.DefineIcon('videoRemove',{NAME:'trash'}) $.FE.Command('videoRemove',{title:'Remove',callback:function(){this.video.remove();}}) $.FE.DefineIcon('videoSize',{NAME:'arrows-alt'}) $.FE.Command('videoSize',{undo:false,focus:false,title:'Change Size',callback:function(){this.video.showSizePopup();}});$.FE.DefineIcon('videoBack',{NAME:'arrow-left'});$.FE.Command('videoBack',{title:'Back',undo:false,focus:false,back:true,callback:function(){this.video.back();},refresh:function($btn){var $current_video=this.video.get();if(!$current_video&&!this.opts.toolbarInline){$btn.addClass('fr-hidden');$btn.next('.fr-separator').addClass('fr-hidden');} else{$btn.removeClass('fr-hidden');$btn.next('.fr-separator').removeClass('fr-hidden');}}});$.FE.Command('videoSetSize',{undo:true,focus:false,callback:function(){this.video.setSize();}})}));(function(factory){if(typeof define==='function'&&define.amd){define(['jquery'],factory);}else if(typeof module==='object'&&module.exports){module.exports=function(root,jQuery){if(jQuery===undefined){if(typeof window!=='undefined'){jQuery=require('jquery');} else{jQuery=require('jquery')(root);}} factory(jQuery);return jQuery;};}else{factory(jQuery);}}(function($){'use strict';$.extend($.FE.POPUP_TEMPLATES,{'audio.insert':'[_BUTTONS_][_BY_URL_LAYER_][_EMBED_LAYER_]','audio.edit':'[_BUTTONS_]','audio.size':'[_BUTTONS_][_SIZE_LAYER_]'}) $.extend($.FE.DEFAULTS,{audioInsertButtons:['audioBack','|','audioByURL','audioEmbed'],audioEditButtons:['audioDisplay','audioAlign','audioSize','audioRemove'],audioResize:true,audioSizeButtons:['audioBack','|'],audioSplitHTML:false,audioTextNear:true,audioDefaultAlign:'center',audioDefaultDisplay:'block',audioMove:true});$.FE.VIDEO_PROVIDERS=[];$.FE.VIDEO_EMBED_REGEX=/^\W*((<\/iframe>)|())\W*$/i;$.FE.PLUGINS.audio=function(editor){var $overlay;var $handler;var $audio_resizer;var $current_audio;function _refreshInsertPopup(){var $popup=editor.popups.get('audio.insert');var $url_input=$popup.find('.fr-audio-by-url-layer input');$url_input.val('').trigger('change');var $embed_area=$popup.find('.fr-audio-embed-layer textarea');$embed_area.val('').trigger('change');} function showInsertPopup(){var $btn=editor.$tb.find('.fr-command[data-cmd="insertAudio"]');var $popup=editor.popups.get('audio.insert');if(!$popup)$popup=_initInsertPopup();if(!$popup.hasClass('fr-active')){editor.popups.refresh('audio.insert');editor.popups.setContainer('audio.insert',editor.$tb);var left=$btn.offset().left+$btn.outerWidth()/2;var top=$btn.offset().top+(editor.opts.toolbarBottom?10:$btn.outerHeight()-10);editor.popups.show('audio.insert',left,top,$btn.outerHeight());}} function _showEditPopup(){var $popup=editor.popups.get('audio.edit');if(!$popup)$popup=_initEditPopup();editor.popups.setContainer('audio.edit',$(editor.opts.scrollableContainer));editor.popups.refresh('audio.edit');var $audio_obj=$current_audio.find('iframe, embed, audio');var left=$audio_obj.offset().left+$audio_obj.outerWidth()/2;var top=$audio_obj.offset().top+$audio_obj.outerHeight();editor.popups.show('audio.edit',left,top,$audio_obj.outerHeight());} function _initInsertPopup(delayed){if(delayed){editor.popups.onRefresh('audio.insert',_refreshInsertPopup);return true;} var audio_buttons='';if(editor.opts.audioInsertButtons.length>1){audio_buttons='
'+editor.button.buildList(editor.opts.audioInsertButtons)+'
';} var by_url_layer='';if(editor.opts.audioInsertButtons.indexOf('audioByURL')>=0){by_url_layer='
'} var embed_layer='';if(editor.opts.audioInsertButtons.indexOf('audioEmbed')>=0){embed_layer='
'} var template={buttons:audio_buttons,by_url_layer:by_url_layer,embed_layer:embed_layer} var $popup=editor.popups.create('audio.insert',template);return $popup;} function showLayer(name){var $popup=editor.popups.get('audio.insert');var left;var top;if(!$current_audio&&!editor.opts.toolbarInline){var $btn=editor.$tb.find('.fr-command[data-cmd="insertAudio"]');left=$btn.offset().left+$btn.outerWidth()/2;top=$btn.offset().top+(editor.opts.toolbarBottom?10:$btn.outerHeight()-10);} if(editor.opts.toolbarInline){top=$popup.offset().top-editor.helpers.getPX($popup.css('margin-top'));if($popup.hasClass('fr-above')){top+=$popup.outerHeight();}} $popup.find('.fr-layer').removeClass('fr-active');$popup.find('.fr-'+name+'-layer').addClass('fr-active');editor.popups.show('audio.insert',left,top,0);} function refreshByURLButton($btn){var $popup=editor.popups.get('audio.insert');if($popup.find('.fr-audio-by-url-layer').hasClass('fr-active')){$btn.addClass('fr-active');}} function refreshEmbedButton($btn){var $popup=editor.popups.get('audio.insert');if($popup.find('.fr-audio-embed-layer').hasClass('fr-active')){$btn.addClass('fr-active');}} function insert(embedded_code){editor.events.focus(true);editor.selection.restore();editor.html.insert(''+embedded_code+'',false,editor.opts.audioSplitHTML);editor.popups.hide('audio.insert');var $audio=editor.$el.find('.fr-jiv');$audio.removeClass('fr-jiv');$audio.toggleClass('fr-draggable',editor.opts.audioMove);editor.events.trigger('audio.inserted',[$audio]);} function insertByURL(link){if(typeof link=='undefined'){var $popup=editor.popups.get('audio.insert');link=$popup.find('.fr-audio-by-url-layer input[type="text"]').val()||'';} var audio=null;if(editor.helpers.isURL(link)){for(var i=0;i<$.FE.VIDEO_PROVIDERS.length;i++){var vp=$.FE.VIDEO_PROVIDERS[i];if(vp.test_regex.test(link)){audio=link.replace(vp.url_regex,vp.url_text);audio=vp.html.replace(/\{url\}/,audio);break;}}} if(audio){insert(audio);} else{editor.events.trigger('audio.linkError',[link]);}} function insertEmbed(code){if(typeof code=='undefined'){var $popup=editor.popups.get('audio.insert');code=$popup.find('.fr-audio-embed-layer textarea').val()||'';} if(code.length===0||!$.FE.VIDEO_EMBED_REGEX.test(code)){editor.events.trigger('audio.codeError',[code]);} else{insert(code);}} function _handlerMousedown(e){if(!editor.core.sameInstance($audio_resizer))return true;e.preventDefault();e.stopPropagation();var c_x=e.pageX||(e.originalEvent.touches?e.originalEvent.touches[0].pageX:null);var c_y=e.pageY||(e.originalEvent.touches?e.originalEvent.touches[0].pageY:null);if(!c_x||!c_y){return false;} if(!editor.undo.canDo())editor.undo.saveStep();$handler=$(this);$handler.data('start-x',c_x);$handler.data('start-y',c_y);$overlay.show();editor.popups.hideAll();_unmarkExit();} function _handlerMousemove(e){if(!editor.core.sameInstance($audio_resizer))return true;if($handler){e.preventDefault() var c_x=e.pageX||(e.originalEvent.touches?e.originalEvent.touches[0].pageX:null);var c_y=e.pageY||(e.originalEvent.touches?e.originalEvent.touches[0].pageY:null);if(!c_x||!c_y){return false;} var s_x=$handler.data('start-x');var s_y=$handler.data('start-y');$handler.data('start-x',c_x);$handler.data('start-y',c_y);var diff_x=c_x-s_x;var diff_y=c_y-s_y;var $audio_obj=$current_audio.find('iframe, embed, audio');var width=$audio_obj.width();var height=$audio_obj.height();if($handler.hasClass('fr-hnw')||$handler.hasClass('fr-hsw')){diff_x=0-diff_x;} if($handler.hasClass('fr-hnw')||$handler.hasClass('fr-hne')){diff_y=0-diff_y;} $audio_obj.css('width',width+diff_x);$audio_obj.css('height',height+diff_y);$audio_obj.removeAttr('width');$audio_obj.removeAttr('height');_repositionResizer();}} function _handlerMouseup(e){if(!editor.core.sameInstance($audio_resizer))return true;if($handler&&$current_audio){if(e)e.stopPropagation();$handler=null;$overlay.hide();_repositionResizer();_showEditPopup();editor.undo.saveStep();}} function _getHandler(pos){return'
';} function _initResizer(){var doc;if(!editor.shared.$audio_resizer){editor.shared.$audio_resizer=$('
');$audio_resizer=editor.shared.$audio_resizer;editor.events.$on($audio_resizer,'mousedown',function(e){e.stopPropagation();},true);if(editor.opts.audioResize){$audio_resizer.append(_getHandler('nw')+_getHandler('ne')+_getHandler('sw')+_getHandler('se'));editor.shared.$audio_overlay=$('
');$overlay=editor.shared.$audio_overlay;doc=$audio_resizer.get(0).ownerDocument;$(doc).find('body').append($overlay);}}else{$audio_resizer=editor.shared.$audio_resizer;$overlay=editor.shared.$audio_overlay;editor.events.on('destroy',function(){$audio_resizer.removeClass('fr-active').appendTo($('body'));},true);} editor.events.on('shared.destroy',function(){$audio_resizer.html('').removeData().remove();$audio_resizer=null;if(editor.opts.audioResize){$overlay.remove();$overlay=null;}},true);if(!editor.helpers.isMobile()){editor.events.$on($(editor.o_win),'resize.audio',function(){_exitEdit(true);});} if(editor.opts.audioResize){doc=$audio_resizer.get(0).ownerDocument;editor.events.$on($audio_resizer,editor._mousedown,'.fr-handler',_handlerMousedown);editor.events.$on($(doc),editor._mousemove,_handlerMousemove);editor.events.$on($(doc.defaultView||doc.parentWindow),editor._mouseup,_handlerMouseup);editor.events.$on($overlay,'mouseleave',_handlerMouseup);}} function _repositionResizer(){if(!$audio_resizer)_initResizer();(editor.$wp||$(editor.opts.scrollableContainer)).append($audio_resizer);$audio_resizer.data('instance',editor);var $audio_obj=$current_audio.find('iframe, embed, audio');$audio_resizer.css('top',(editor.opts.iframe?$audio_obj.offset().top-1:$audio_obj.offset().top-editor.$wp.offset().top-1)+editor.$wp.scrollTop()).css('left',(editor.opts.iframe?$audio_obj.offset().left-1:$audio_obj.offset().left-editor.$wp.offset().left-1)+editor.$wp.scrollLeft()).css('width',$audio_obj.outerWidth()).css('height',$audio_obj.height()).addClass('fr-active')} var touchScroll;function _edit(e){if(e&&e.type=='touchend'&&touchScroll){return true;} e.preventDefault();e.stopPropagation();if(editor.edit.isDisabled()){return false;} for(var i=0;i<$.FE.INSTANCES.length;i++){if($.FE.INSTANCES[i]!=editor){$.FE.INSTANCES[i].events.trigger('audio.hideResizer');}} editor.toolbar.disable();if(editor.helpers.isMobile()){editor.events.disableBlur();editor.$el.blur();editor.events.enableBlur();} $current_audio=$(this);$(this).addClass('fr-active');if(editor.opts.iframe){editor.size.syncIframe();} _repositionResizer();_showEditPopup();editor.selection.clear();editor.button.bulkRefresh();editor.events.trigger('image.hideResizer');} function _exitEdit(force_exit){if($current_audio&&(_canExit()||force_exit===true)){$audio_resizer.removeClass('fr-active');editor.toolbar.enable();$current_audio.removeClass('fr-active');$current_audio=null;_unmarkExit();}} editor.shared.audio_exit_flag=false;function _markExit(){editor.shared.audio_exit_flag=true;} function _unmarkExit(){editor.shared.audio_exit_flag=false;} function _canExit(){return editor.shared.audio_exit_flag;} function _initEvents(){editor.events.on('mousedown window.mousedown',_markExit);editor.events.on('window.touchmove',_unmarkExit);editor.events.on('mouseup window.mouseup',_exitEdit);editor.events.on('commands.mousedown',function($btn){if($btn.parents('.fr-toolbar').length>0){_exitEdit();}});editor.events.on('blur audio.hideResizer commands.undo commands.redo element.dropped',function(){_exitEdit(true);});} function _initEditPopup(){var audio_buttons='';if(editor.opts.audioEditButtons.length>=1){audio_buttons+='
';audio_buttons+=editor.button.buildList(editor.opts.audioEditButtons);audio_buttons+='
';} var template={buttons:audio_buttons} var $popup=editor.popups.create('audio.edit',template);editor.events.$on(editor.$wp,'scroll.audio-edit',function(){if($current_audio&&editor.popups.isVisible('audio.edit')){_showEditPopup();}});return $popup;} function _refreshSizePopup(){if($current_audio){var $popup=editor.popups.get('audio.size');var $audio_obj=$current_audio.find('iframe, embed, audio') $popup.find('input[name="width"]').val($audio_obj.get(0).style.width||$audio_obj.attr('width')).trigger('change');$popup.find('input[name="height"]').val($audio_obj.get(0).style.height||$audio_obj.attr('height')).trigger('change');}} function showSizePopup(){var $popup=editor.popups.get('audio.size');if(!$popup)$popup=_initSizePopup();editor.popups.refresh('audio.size');editor.popups.setContainer('audio.size',$(editor.opts.scrollableContainer));var $audio_obj=$current_audio.find('iframe, embed, audio') var left=$audio_obj.offset().left+$audio_obj.width()/2;var top=$audio_obj.offset().top+$audio_obj.height();editor.popups.show('audio.size',left,top,$audio_obj.height());} function _initSizePopup(delayed){if(delayed){editor.popups.onRefresh('audio.size',_refreshSizePopup);return true;} var audio_buttons='';audio_buttons='
'+editor.button.buildList(editor.opts.audioSizeButtons)+'
';var size_layer='';size_layer='
';var template={buttons:audio_buttons,size_layer:size_layer} var $popup=editor.popups.create('audio.size',template);editor.events.$on(editor.$wp,'scroll',function(){if($current_audio&&editor.popups.isVisible('audio.size')){showSizePopup();}});return $popup;} function align(val){$current_audio.removeClass('fr-fvr fr-fvl');if(val=='left'){$current_audio.addClass('fr-fvl');} else if(val=='right'){$current_audio.addClass('fr-fvr');} _repositionResizer();_showEditPopup();} function refreshAlign($btn){if(!$current_audio)return false;if($current_audio.hasClass('fr-fvl')){$btn.find('> *:first').replaceWith(editor.icon.create('align-left'));} else if($current_audio.hasClass('fr-fvr')){$btn.find('> *:first').replaceWith(editor.icon.create('align-right'));} else{$btn.find('> *:first').replaceWith(editor.icon.create('align-justify'));}} function refreshAlignOnShow($btn,$dropdown){var alignment='justify';if($current_audio.hasClass('fr-fvl')){alignment='left';} else if($current_audio.hasClass('fr-fvr')){alignment='right';} $dropdown.find('.fr-command[data-param1="'+alignment+'"]').addClass('fr-active');} function display(val){$current_audio.removeClass('fr-dvi fr-dvb');if(val=='inline'){$current_audio.addClass('fr-dvi');} else if(val=='block'){$current_audio.addClass('fr-dvb');} _repositionResizer();_showEditPopup();} function refreshDisplayOnShow($btn,$dropdown){var d='block';if($current_audio.hasClass('fr-dvi')){d='inline';} $dropdown.find('.fr-command[data-param1="'+d+'"]').addClass('fr-active');} function remove(){if($current_audio){if(editor.events.trigger('audio.beforeRemove',[$current_audio])!==false){var $audio=$current_audio;editor.popups.hideAll();_exitEdit(true);editor.selection.setBefore($audio.get(0))||editor.selection.setAfter($audio.get(0));$audio.remove();editor.selection.restore();editor.html.fillEmptyBlocks();editor.events.trigger('audio.removed',[$audio]);}}} function _convertStyleToClasses($audio){if(!$audio.hasClass('fr-dvi')&&!$audio.hasClass('fr-dvb')){var flt=$audio.css('float');$audio.css('float','none');if($audio.css('display')=='block'){$audio.css('float',flt);if(parseInt($audio.css('margin-left'),10)===0&&($audio.attr('style')||'').indexOf('margin-right: auto')>=0){$audio.addClass('fr-fvl');} else if(parseInt($audio.css('margin-right'),10)===0&&($audio.attr('style')||'').indexOf('margin-left: auto')>=0){$audio.addClass('fr-fvr');} $audio.addClass('fr-dvb');} else{$audio.css('float',flt);if($audio.css('float')=='left'){$audio.addClass('fr-fvl');} else if($audio.css('float')=='right'){$audio.addClass('fr-fvr');} $audio.addClass('fr-dvi');} $audio.css('margin','');$audio.css('float','');$audio.css('display','');$audio.css('z-index','');$audio.css('position','');$audio.css('overflow','');$audio.css('vertical-align','');} if(!editor.opts.audioTextNear){$audio.removeClass('fr-dvi').addClass('fr-dvb');}} function _refreshAudioList(){editor.$el.find('audio').filter(function(){return $(this).parents('span.fr-video').length===0;}).wrap('');editor.$el.find('embed, iframe').filter(function(){if(editor.browser.safari&&this.getAttribute('src')){this.setAttribute('src',this.src);} if($(this).parents('span.fr-video').length>0)return false;var link=$(this).attr('src');for(var i=0;i<$.FE.VIDEO_PROVIDERS.length;i++){var vp=$.FE.VIDEO_PROVIDERS[i];if(vp.test_regex.test(link)){return true;}} return false;}).map(function(){return $(this).parents('object').length===0?this:$(this).parents('object').get(0);}).wrap('');var audios=editor.$el.find('span.fr-video');for(var i=0;i'+this.icon.create('align-'+val)+'';}} c+='';return c;},callback:function(cmd,val){this.audio.align(val);},refresh:function($btn){this.audio.refreshAlign($btn);},refreshOnShow:function($btn,$dropdown){this.audio.refreshAlignOnShow($btn,$dropdown);}}) $.FE.DefineIcon('audioRemove',{NAME:'trash'}) $.FE.Command('audioRemove',{title:'Remove',callback:function(){this.audio.remove();}}) $.FE.DefineIcon('audioSize',{NAME:'arrows-alt'}) $.FE.Command('audioSize',{undo:false,focus:false,title:'Change Size',callback:function(){this.audio.showSizePopup();}});$.FE.DefineIcon('audioBack',{NAME:'arrow-left'});$.FE.Command('audioBack',{title:'Back',undo:false,focus:false,back:true,callback:function(){this.audio.back();},refresh:function($btn){var $current_audio=this.audio.get();if(!$current_audio&&!this.opts.toolbarInline){$btn.addClass('fr-hidden');$btn.next('.fr-separator').addClass('fr-hidden');} else{$btn.removeClass('fr-hidden');$btn.next('.fr-separator').removeClass('fr-hidden');}}});$.FE.Command('audioSetSize',{undo:true,focus:false,callback:function(){this.audio.setSize();}})}));!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&module.exports?module.exports=function(b,c){return void 0===c&&(c="undefined"!=typeof window?require("jquery"):require("jquery")(b)),a(c),c}:a(jQuery)}(function(a){a.FE.PLUGINS.quote=function(b){function c(a){for(;a.parentNode&&a.parentNode!=b.el;)a=a.parentNode;return a}function d(){var d,e=b.selection.blocks();for(d=0;d");for(f.insertBefore(e[0]),d=0;d span").text(d)}}return{apply:c,refreshOnShow:d,refresh:e}},a.FE.Command("fontSize",{type:"dropdown",title:"Font Size",displaySelection:function(a){return a.opts.fontSizeSelection},displaySelectionWidth:30,defaultSelection:function(a){return a.opts.fontSizeDefaultSelection},html:function(){for(var a='"},callback:function(a,b){this.fontSize.apply(b)},refresh:function(a){this.fontSize.refresh(a)},refreshOnShow:function(a,b){this.fontSize.refreshOnShow(a,b)},plugin:"fontSize"}),a.FE.DefineIcon("fontSize",{NAME:"text-height"})});!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&module.exports?module.exports=function(b,c){return void 0===c&&(c="undefined"!=typeof window?require("jquery"):require("jquery")(b)),a(c),c}:a(jQuery)}(function(a){a.extend(a.FE.DEFAULTS,{fontFamily:{"Arial,Helvetica,sans-serif":"Arial","Georgia,serif":"Georgia","Impact,Charcoal,sans-serif":"Impact","Tahoma,Geneva,sans-serif":"Tahoma","Times New Roman,Times,serif":"Times New Roman","Verdana,Geneva,sans-serif":"Verdana"},fontFamilySelection:!1,fontFamilyDefaultSelection:"Font Family"}),a.FE.PLUGINS.fontFamily=function(b){function c(a){b.format.applyStyle("font-family",a)}function d(a,b){b.find(".fr-command.fr-active").removeClass("fr-active").attr("aria-selected",!1),b.find('.fr-command[data-param1="'+g()+'"]').addClass("fr-active").attr("aria-selected",!0);var c=b.find(".fr-dropdown-list"),d=b.find(".fr-active").parent();d.length?c.parent().scrollTop(d.offset().top-c.offset().top-(c.parent().outerHeight()/2-d.outerHeight()/2)):c.parent().scrollTop(0)}function e(b){var c=b.replace(/(sans-serif|serif|monospace|cursive|fantasy)/gi,"").replace(/"|'| /g,"").split(",");return a.grep(c,function(a){return a.length>0})}function f(a,b){for(var c=0;c span").text(b.opts.fontFamily[g()]||d[0]||b.opts.fontFamilyDefaultSelection)}}return{apply:c,refreshOnShow:d,refresh:h}},a.FE.Command("fontFamily",{type:"dropdown",displaySelection:function(a){return a.opts.fontFamilySelection},defaultSelection:function(a){return a.opts.fontFamilyDefaultSelection},displaySelectionWidth:120,html:function(){var a='"},title:"Font Family",callback:function(a,b){this.fontFamily.apply(b)},refresh:function(a){this.fontFamily.refresh(a)},refreshOnShow:function(a,b){this.fontFamily.refreshOnShow(a,b)},plugin:"fontFamily"}),a.FE.DefineIcon("fontFamily",{NAME:"font"})});!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&module.exports?module.exports=function(b,c){return void 0===c&&(c="undefined"!=typeof window?require("jquery"):require("jquery")(b)),a(c),c}:a(jQuery)}(function(a){a.extend(a.FE.POPUP_TEMPLATES,{emoticons:"[_BUTTONS_][_EMOTICONS_]"}),a.extend(a.FE.DEFAULTS,{emoticonsStep:8,emoticonsSet:[{code:"1f600",desc:"Grinning face"},{code:"1f601",desc:"Grinning face with smiling eyes"},{code:"1f602",desc:"Face with tears of joy"},{code:"1f603",desc:"Smiling face with open mouth"},{code:"1f604",desc:"Smiling face with open mouth and smiling eyes"},{code:"1f605",desc:"Smiling face with open mouth and cold sweat"},{code:"1f606",desc:"Smiling face with open mouth and tightly-closed eyes"},{code:"1f607",desc:"Smiling face with halo"},{code:"1f608",desc:"Smiling face with horns"},{code:"1f609",desc:"Winking face"},{code:"1f60a",desc:"Smiling face with smiling eyes"},{code:"1f60b",desc:"Face savoring delicious food"},{code:"1f60c",desc:"Relieved face"},{code:"1f60d",desc:"Smiling face with heart-shaped eyes"},{code:"1f60e",desc:"Smiling face with sunglasses"},{code:"1f60f",desc:"Smirking face"},{code:"1f610",desc:"Neutral face"},{code:"1f611",desc:"Expressionless face"},{code:"1f612",desc:"Unamused face"},{code:"1f613",desc:"Face with cold sweat"},{code:"1f614",desc:"Pensive face"},{code:"1f615",desc:"Confused face"},{code:"1f616",desc:"Confounded face"},{code:"1f617",desc:"Kissing face"},{code:"1f618",desc:"Face throwing a kiss"},{code:"1f619",desc:"Kissing face with smiling eyes"},{code:"1f61a",desc:"Kissing face with closed eyes"},{code:"1f61b",desc:"Face with stuck out tongue"},{code:"1f61c",desc:"Face with stuck out tongue and winking eye"},{code:"1f61d",desc:"Face with stuck out tongue and tightly-closed eyes"},{code:"1f61e",desc:"Disappointed face"},{code:"1f61f",desc:"Worried face"},{code:"1f620",desc:"Angry face"},{code:"1f621",desc:"Pouting face"},{code:"1f622",desc:"Crying face"},{code:"1f623",desc:"Persevering face"},{code:"1f624",desc:"Face with look of triumph"},{code:"1f625",desc:"Disappointed but relieved face"},{code:"1f626",desc:"Frowning face with open mouth"},{code:"1f627",desc:"Anguished face"},{code:"1f628",desc:"Fearful face"},{code:"1f629",desc:"Weary face"},{code:"1f62a",desc:"Sleepy face"},{code:"1f62b",desc:"Tired face"},{code:"1f62c",desc:"Grimacing face"},{code:"1f62d",desc:"Loudly crying face"},{code:"1f62e",desc:"Face with open mouth"},{code:"1f62f",desc:"Hushed face"},{code:"1f630",desc:"Face with open mouth and cold sweat"},{code:"1f631",desc:"Face screaming in fear"},{code:"1f632",desc:"Astonished face"},{code:"1f633",desc:"Flushed face"},{code:"1f634",desc:"Sleeping face"},{code:"1f635",desc:"Dizzy face"},{code:"1f636",desc:"Face without mouth"},{code:"1f637",desc:"Face with medical mask"}],emoticonsButtons:["emoticonsBack","|"],emoticonsUseImage:!0}),a.FE.PLUGINS.emoticons=function(b){function c(){var a=b.$tb.find('.fr-command[data-cmd="emoticons"]'),c=b.popups.get("emoticons");if(c||(c=e()),!c.hasClass("fr-active")){b.popups.refresh("emoticons"),b.popups.setContainer("emoticons",b.$tb);var d=a.offset().left+a.outerWidth()/2,f=a.offset().top+(b.opts.toolbarBottom?10:a.outerHeight()-10);b.popups.show("emoticons",d,f,a.outerHeight())}}function d(){b.popups.hide("emoticons")}function e(){var a="";b.opts.toolbarInline&&b.opts.emoticonsButtons.length>0&&(a='
'+b.button.buildList(b.opts.emoticonsButtons)+"
");var c={buttons:a,emoticons:f()},d=b.popups.create("emoticons",c);return b.tooltip.bind(d,".fr-emoticon"),g(d),d}function f(){for(var a='
',c=0;c"),a+=''+(b.opts.emoticonsUseImage?'':"&#x"+b.opts.emoticonsSet[c].code+";")+''+b.language.translate(b.opts.emoticonsSet[c].desc)+"   ";return b.opts.emoticonsUseImage&&(a+='

Emoji free by Emoji One

'),a+="
"}function g(c){b.events.on("popup.tab",function(d){var e=a(d.currentTarget);if(!b.popups.isVisible("emoticons")||!e.is("span, a"))return!0;var f,g,h,i=d.which;if(a.FE.KEYCODE.TAB==i){if(e.is("span.fr-emoticon")&&d.shiftKey||e.is("a")&&!d.shiftKey){var j=c.find(".fr-buttons");f=!b.accessibility.focusToolbar(j,!!d.shiftKey)}if(f!==!1){var k=c.find("span.fr-emoticon:focus:first, span.fr-emoticon:visible:first, a");e.is("span.fr-emoticon")&&(k=k.not("span.fr-emoticon:not(:focus)")),g=k.index(e),g=d.shiftKey?((g-1)%k.length+k.length)%k.length:(g+1)%k.length,h=k.get(g),b.events.disableBlur(),h.focus(),f=!1}}else if(a.FE.KEYCODE.ARROW_UP==i||a.FE.KEYCODE.ARROW_DOWN==i||a.FE.KEYCODE.ARROW_LEFT==i||a.FE.KEYCODE.ARROW_RIGHT==i){if(e.is("span.fr-emoticon")){var l=e.parent().find("span.fr-emoticon");g=l.index(e);var m=b.opts.emoticonsStep,n=Math.floor(l.length/m),o=g%m,p=Math.floor(g/m),q=p*m+o,r=n*m;a.FE.KEYCODE.ARROW_UP==i?q=((q-m)%r+r)%r:a.FE.KEYCODE.ARROW_DOWN==i?q=(q+m)%r:a.FE.KEYCODE.ARROW_LEFT==i?q=((q-1)%r+r)%r:a.FE.KEYCODE.ARROW_RIGHT==i&&(q=(q+1)%r),h=a(l.get(q)),b.events.disableBlur(),h.focus(),f=!1}}else a.FE.KEYCODE.ENTER==i&&(e.is("a")?e[0].click():b.button.exec(e),f=!1);return f===!1&&(d.preventDefault(),d.stopPropagation()),f},!0)}function h(c,d){b.html.insert('"+(d?" ":c)+" "+a.FE.MARKERS,!0)}function i(){b.popups.hide("emoticons"),b.toolbar.showInline()}function j(){var c=function(){for(var a=b.el.querySelectorAll(".fr-emoticon:not(.fr-deletable)"),c=0;c0&&d.startOffset>0){var f=e.childNodes[d.startOffset-1];if(b.node.hasClass(f,"fr-emoticon"))return f}return!1};b.events.on("keydown",function(c){if(b.keys.isCharacter(c.which)&&b.selection.inEditor()){var e=b.selection.ranges(0),f=d();f&&(0===e.startOffset&&b.selection.element()===f?a(f).before(a.FE.MARKERS+a.FE.INVISIBLE_SPACE):a(f).after(a.FE.INVISIBLE_SPACE+a.FE.MARKERS),b.selection.restore())}}),b.events.on("keyup",function(c){for(var e=b.el.querySelectorAll(".fr-emoticon"),f=0;f=a.FE.KEYCODE.ARROW_LEFT&&c.which<=a.FE.KEYCODE.ARROW_DOWN)){var g=d();b.node.hasClass(g,"fr-emoticon-img")&&(a(g).append(a.FE.MARKERS),b.selection.restore())}})}return{_init:j,insert:h,showEmoticonsPopup:c,hideEmoticonsPopup:d,back:i}},a.FE.DefineIcon("emoticons",{NAME:"smile-o"}),a.FE.Command("emoticons",{title:"Emoticons",undo:!1,focus:!0,refreshOnCallback:!1,popup:!0,callback:function(){this.popups.isVisible("emoticons")?(this.$el.find(".fr-marker").length&&(this.events.disableBlur(),this.selection.restore()),this.popups.hide("emoticons")):this.emoticons.showEmoticonsPopup()},plugin:"emoticons"}),a.FE.Command("insertEmoticon",{callback:function(a,b){this.emoticons.insert("&#x"+b+";",this.opts.emoticonsUseImage?"https://cdnjs.cloudflare.com/ajax/libs/emojione/2.0.1/assets/svg/"+b+".svg":null),this.emoticons.hideEmoticonsPopup()}}),a.FE.DefineIcon("emoticonsBack",{NAME:"arrow-left"}),a.FE.Command("emoticonsBack",{title:"Back",undo:!1,focus:!1,back:!0,refreshAfterCallback:!1,callback:function(){this.emoticons.back()}})});!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&module.exports?module.exports=function(b,c){return void 0===c&&(c="undefined"!=typeof window?require("jquery"):require("jquery")(b)),a(c),c}:a(jQuery)}(function(a){a.extend(a.FE.POPUP_TEMPLATES,{"colors.picker":"[_BUTTONS_][_TEXT_COLORS_][_BACKGROUND_COLORS_]"}),a.extend(a.FE.DEFAULTS,{colorsText:["#61BD6D","#1ABC9C","#54ACD2","#2C82C9","#9365B8","#475577","#CCCCCC","#41A85F","#00A885","#3D8EB9","#2969B0","#553982","#28324E","#000000","#F7DA64","#FBA026","#EB6B56","#E25041","#A38F84","#EFEFEF","#FFFFFF","#FAC51C","#F37934","#D14841","#B8312F","#7C706B","#D1D5D8","REMOVE"],colorsBackground:["#61BD6D","#1ABC9C","#54ACD2","#2C82C9","#9365B8","#475577","#CCCCCC","#41A85F","#00A885","#3D8EB9","#2969B0","#553982","#28324E","#000000","#F7DA64","#FBA026","#EB6B56","#E25041","#A38F84","#EFEFEF","#FFFFFF","#FAC51C","#F37934","#D14841","#B8312F","#7C706B","#D1D5D8","REMOVE"],colorsStep:7,colorsDefaultTab:"text",colorsButtons:["colorsBack","|","-"]}),a.FE.PLUGINS.colors=function(b){function c(){var a=b.$tb.find('.fr-command[data-cmd="color"]'),c=b.popups.get("colors.picker");if(c||(c=e()),!c.hasClass("fr-active"))if(b.popups.setContainer("colors.picker",b.$tb),i(c.find(".fr-selected-tab").attr("data-param1")),a.is(":visible")){var d=a.offset().left+a.outerWidth()/2,f=a.offset().top+(b.opts.toolbarBottom?10:a.outerHeight()-10);b.popups.show("colors.picker",d,f,a.outerHeight())}else b.position.forSelection(c),b.popups.show("colors.picker")}function d(){b.popups.hide("colors.picker")}function e(){var a='
';b.opts.toolbarInline&&b.opts.colorsButtons.length>0&&(a+=b.button.buildList(b.opts.colorsButtons)),a+=f()+"
";var c={buttons:a,text_colors:g("text"),background_colors:g("background")},d=b.popups.create("colors.picker",c);return h(d),d}function f(){var a='
';return a+=''+b.language.translate("Text")+"",a+=''+b.language.translate("Background")+"",a+"
"}function g(a){for(var c="text"==a?b.opts.colorsText:b.opts.colorsBackground,d='
',e=0;e"),d+="REMOVE"!=c[e]?''+b.language.translate("Color")+" "+c[e]+"   ":''+b.icon.create("remove")+''+b.language.translate("Clear Formatting")+"";return d+"
"}function h(c){b.events.on("popup.tab",function(d){var e=a(d.currentTarget);if(!b.popups.isVisible("colors.picker")||!e.is("span"))return!0;var f=d.which,g=!0;if(a.FE.KEYCODE.TAB==f){var h=c.find(".fr-buttons");g=!b.accessibility.focusToolbar(h,!!d.shiftKey)}else if(a.FE.KEYCODE.ARROW_UP==f||a.FE.KEYCODE.ARROW_DOWN==f||a.FE.KEYCODE.ARROW_LEFT==f||a.FE.KEYCODE.ARROW_RIGHT==f){if(e.is("span.fr-select-color")){var i=e.parent().find("span.fr-select-color"),j=i.index(e),k=b.opts.colorsStep,l=Math.floor(i.length/k),m=j%k,n=Math.floor(j/k),o=n*k+m,p=l*k;a.FE.KEYCODE.ARROW_UP==f?o=((o-k)%p+p)%p:a.FE.KEYCODE.ARROW_DOWN==f?o=(o+k)%p:a.FE.KEYCODE.ARROW_LEFT==f?o=((o-1)%p+p)%p:a.FE.KEYCODE.ARROW_RIGHT==f&&(o=(o+1)%p);var q=a(i.get(o));b.events.disableBlur(),q.focus(),g=!1}}else a.FE.KEYCODE.ENTER==f&&(b.button.exec(e),g=!1);return g===!1&&(d.preventDefault(),d.stopPropagation()),g},!0)}function i(c){var d,e=b.popups.get("colors.picker"),f=a(b.selection.element());d="background"==c?"background-color":"color";var g=e.find(".fr-"+c+"-color .fr-select-color");for(g.find(".fr-selected-color").remove(),g.removeClass("fr-active-item"),g.not('[data-param1="REMOVE"]').attr("aria-selected",!1);f.get(0)!=b.el;){if("transparent"!=f.css(d)&&"rgba(0, 0, 0, 0)"!=f.css(d)){var h=e.find(".fr-"+c+'-color .fr-select-color[data-param1="'+b.helpers.RGBToHex(f.css(d))+'"]');h.append(''),h.addClass("fr-active-item").attr("aria-selected",!0);break}f=f.parent()}}function j(a,c){a.hasClass("fr-selected-tab")||(a.siblings().removeClass("fr-selected-tab").attr("aria-pressed",!1),a.addClass("fr-selected-tab").attr("aria-pressed",!0),a.parents(".fr-popup").find(".fr-color-set").removeClass("fr-selected-set"),a.parents(".fr-popup").find(".fr-color-set.fr-"+c+"-color").addClass("fr-selected-set"),i(c)),b.accessibility.focusPopup(a.parents(".fr-popup"))}function k(a){"REMOVE"!=a?b.format.applyStyle("background-color",b.helpers.HEXtoRGB(a)):b.format.removeStyle("background-color"),d()}function l(a){"REMOVE"!=a?b.format.applyStyle("color",b.helpers.HEXtoRGB(a)):b.format.removeStyle("color"),d()}function m(){b.popups.hide("colors.picker"),b.toolbar.showInline()}return{showColorsPopup:c,hideColorsPopup:d,changeSet:j,background:k,text:l,back:m}},a.FE.DefineIcon("colors",{NAME:"tint"}),a.FE.Command("color",{title:"Colors",undo:!1,focus:!0,refreshOnCallback:!1,popup:!0,callback:function(){this.popups.isVisible("colors.picker")?(this.$el.find(".fr-marker").length&&(this.events.disableBlur(),this.selection.restore()),this.popups.hide("colors.picker")):this.colors.showColorsPopup()},plugin:"colors"}),a.FE.Command("textColor",{undo:!0,callback:function(a,b){this.colors.text(b)}}),a.FE.Command("backgroundColor",{undo:!0,callback:function(a,b){this.colors.background(b)}}),a.FE.Command("colorChangeSet",{undo:!1,focus:!1,callback:function(a,b){var c=this.popups.get("colors.picker").find('.fr-command[data-cmd="'+a+'"][data-param1="'+b+'"]');this.colors.changeSet(c,b)}}),a.FE.DefineIcon("colorsBack",{NAME:"arrow-left"}),a.FE.Command("colorsBack",{title:"Back",undo:!1,focus:!1,back:!0,refreshAfterCallback:!1,callback:function(){this.colors.back()}}),a.FE.DefineIcon("remove",{NAME:"eraser"})});!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&module.exports?module.exports=function(b,c){return void 0===c&&(c="undefined"!=typeof window?require("jquery"):require("jquery")(b)),a(c),c}:a(jQuery)}(function(a){a.extend(a.FE.DEFAULTS,{}),a.FE.URLRegEx=/(\s|^|>)((http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,3})?(:\d*)?(\/[^\s<]*)?)(\s|$|<)/gi,a.FE.PLUGINS.url=function(b){function c(a){for(;a.parentNode;)if(a=a.parentNode,["A","BUTTON","TEXTAREA"].indexOf(a.tagName)>=0)return!0;return!1}function d(){for(var d=b.doc.createTreeWalker(b.el,NodeFilter.SHOW_TEXT,b.node.filter(function(b){return a.FE.URLRegEx.test(b.textContent.replace(/ /gi,""))&&!c(b)}),!1);d.nextNode();){var e=d.currentNode,f=null;b.opts.linkAlwaysNoFollow&&(f="nofollow"),b.opts.linkAlwaysBlank&&(f?f+=" noopener noreferrer":f="noopener noreferrer"),a(e).before(e.textContent.replace(a.FE.URLRegEx,"$1$2$7')),e.parentNode.removeChild(e)}}function e(){b.events.on("paste.afterCleanup",function(c){if(a.FE.URLRegEx.test(c))return c.replace(a.FE.URLRegEx,"$1$2$7')}),b.events.on("keyup",function(c){var e=c.which;e!=a.FE.KEYCODE.ENTER&&e!=a.FE.KEYCODE.SPACE||d(b.node.contents(b.el))}),b.events.on("keydown",function(c){var d=c.which;if(d==a.FE.KEYCODE.ENTER){var e=b.selection.element();if(("A"==e.tagName||a(e).parents("a").length)&&b.selection.info(e).atEnd)return c.stopImmediatePropagation(),"A"!==e.tagName&&(e=a(e).parents("a")[0]),a(e).after(" "+a.FE.MARKERS),b.selection.restore(),!1}})}return{_init:e}}});!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&module.exports?module.exports=function(b,c){return void 0===c&&(c="undefined"!=typeof window?require("jquery"):require("jquery")(b)),a(c),c}:a(jQuery)}(function(a){a.extend(a.FE.DEFAULTS,{lineBreakerTags:["table","hr","form","dl","span.fr-video"],lineBreakerOffset:15,lineBreakerHorizontalOffset:10}),a.FE.PLUGINS.lineBreaker=function(b){function c(a,c){var d,e,f,g,h,i,j,k;if(null==a)g=c.parent(),h=g.offset().top,j=c.offset().top,d=j-Math.min((j-h)/2,b.opts.lineBreakerOffset),f=g.outerWidth(),e=g.offset().left;else if(null==c)g=a.parent(),i=g.offset().top+g.outerHeight(),k=a.offset().top+a.outerHeight(),d=k+Math.min((i-k)/2,b.opts.lineBreakerOffset),f=g.outerWidth(),e=g.offset().left;else{g=a.parent();var l=a.offset().top+a.height(),m=c.offset().top;if(l>m)return!1;d=(l+m)/2,f=g.outerWidth(),e=g.offset().left}b.opts.iframe&&(e+=b.$iframe.offset().left-b.helpers.scrollLeft(),d+=b.$iframe.offset().top-b.helpers.scrollTop()),b.$box.append(q),q.css("top",d-b.win.pageYOffset),q.css("left",e-b.win.pageXOffset),q.css("width",f),q.data("tag1",a),q.data("tag2",c),q.addClass("fr-visible").data("instance",b)}function d(a,d){var f,g,h=a.offset().top,i=a.offset().top+a.outerHeight();if(Math.abs(i-d)<=b.opts.lineBreakerOffset||Math.abs(d-h)<=b.opts.lineBreakerOffset)if(Math.abs(i-d)0)return c=d.parents(b.opts.lineBreakerTags.(",")).get(0),a(c)}return null}function f(c,d){var e=b.doc.elementFromPoint(c,d);return e&&!a(e).closest(".fr-line-breaker").length&&!b.node.isElement(e)&&e!=b.$wp.get(0)&&a(e).closest(b.$wp).length?e:null}function g(a,c,d){for(var e=d,g=null;e<=b.opts.lineBreakerOffset&&!g;)g=f(a,c-e),g||(g=f(a,c+e)),e+=d;return g}function h(a,c,d){for(var e=null;!e&&a>b.$box.offset().left&&a"+a.FE.MARKERS+"
"):e.before(a.FE.MARKERS+"
"):f&&"TD"!=d.parent().get(0).tagName&&0===d.parents(f).length?d.after("<"+f+">"+a.FE.MARKERS+"
"):d.after(a.FE.MARKERS+"
"),b.selection.restore()}function o(){b.shared.$line_breaker||(b.shared.$line_breaker=a('
')),q=b.shared.$line_breaker,b.events.on("shared.destroy",function(){q.html("").removeData().remove(),q=null},!0),b.events.on("destroy",function(){q.removeData("instance").removeClass("fr-visible").appendTo("body"),clearTimeout(s)},!0),b.events.$on(q,"mousemove",function(a){a.stopPropagation()},!0),b.events.$on(q,"mousedown","a",function(a){a.stopPropagation()},!0),b.events.$on(q,"click","a",n,!0)}function p(){return!!b.$wp&&(o(),r=!1,b.events.$on(b.$win,"mousemove",j),b.events.$on(a(b.win),"scroll",k),b.events.on("popups.show.table.edit",k),b.events.on("commands.after",k),b.events.$on(a(b.win),"mousedown",l),void b.events.$on(a(b.win),"mouseup",m))}var q,r,s;return{_init:p}}});!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&module.exports?module.exports=function(b,c){return void 0===c&&(c="undefined"!=typeof window?require("jquery"):require("jquery")(b)),a(c),c}:a(jQuery)}(function(a){a.extend(a.FE.DEFAULTS,{entities:""'¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿŒœŠšŸƒˆ˜ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϑϒϖ   ‌‍‎‏–—‘’‚“”„†‡•…‰′″‹›‾⁄€ℑ℘ℜ™ℵ←↑→↓↔↵⇐⇑⇒⇓⇔∀∂∃∅∇∈∉∋∏∑−∗√∝∞∠∧∨∩∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅⌈⌉⌊⌋⟨⟩◊♠♣♥♦"}),a.FE.PLUGINS.entities=function(b){function c(a){var b=a.textContent;if(b.match(g)){for(var c="",d=0;d=0)return!0;for(var e=b.node.contents(a),f=0;f").html(b.opts.entities).text(),d=b.opts.entities.split(";");h={},g="";for(var f=0;f0;)g++,h=b.doc.elementFromPoint(c.originalEvent.pageX-b.win.pageXOffset,c.originalEvent.pageY-b.win.pageYOffset-g);(!d(h)||n&&0===b.$el.find(h).length&&h!=n.get(0))&&(h=null);for(var i=0,j=f;!d(j)&&j==f&&c.originalEvent.pageY-b.win.pageYOffset+i=0&&(f=a(f).parents("table").get(0)),f&&["LI"].indexOf(f.tagName)>=0&&(f=a(f).parents("UL, OL").get(0)),f&&!a(f).hasClass("fr-drag-helper")){n||(a.FE.$draggable_helper||(a.FE.$draggable_helper=a('
')),n=a.FE.$draggable_helper,b.events.on("shared.destroy",function(){n.html("").removeData().remove(),n=null},!0));var k,l=c.originalEvent.pageY;k=l0&&(o=parseFloat(m.prev().css("margin-bottom"))||0),o=Math.max(o,parseFloat(m.css("margin-top"))||0),e(m.offset().top-o/2-b.$box.offset().top,m.offset().left-b.win.pageXOffset-b.$box.offset().left,m.width()),n.data("fr-position","before"))):"after"==n.data("fr-position")&&m.is(n.data("fr-tag"))||(o=parseFloat(m.css("margin-bottom"))||0,e(m.offset().top+a(f).height()+o/2-b.$box.offset().top,m.offset().left-b.win.pageXOffset-b.$box.offset().left,m.width()),n.data("fr-position","after")),n.data("fr-tag",m),n.addClass("fr-visible"),n.appendTo(b.$box)}else n&&b.$box.find(n).length>0&&n.removeClass("fr-visible")}function g(a){a.originalEvent.dataTransfer.dropEffect="move",b.opts.dragInline?j()||!b.browser.msie&&!b.browser.edge||a.preventDefault():(a.preventDefault(),f(a))}function h(a){a.originalEvent.dataTransfer.dropEffect="move",b.opts.dragInline||a.preventDefault()}function i(a){b.$el.attr("contenteditable",!0);var c=b.$el.find(".fr-dragging");n&&n.hasClass("fr-visible")&&b.$box.find(n).length?k(a):c.length&&(a.preventDefault(),a.stopPropagation()),n&&b.$box.find(n).length&&n.removeClass("fr-visible"),c.removeClass("fr-dragging")}function j(){for(var b=null,c=0;c'),n.removeClass("fr-visible");else{var g=b.markers.insertAtPoint(c.originalEvent);if(g===!1)return!1}d.removeClass("fr-dragging");var h=d;if(d.parent().is("A")&&(h=d.parent()),b.core.isEmpty())b.events.focus();else{var i=b.$el.find(".fr-marker");i.replaceWith(a.FE.MARKERS),b.selection.restore()}if(e==b||b.undo.canDo()||b.undo.saveStep(),b.core.isEmpty())b.$el.html(h);else{var j=b.markers.insert();a(j).replaceWith(h),d.after(a.FE.MARKERS),b.selection.restore()}return b.popups.hideAll(),b.selection.save(),b.$el.find(b.html.emptyBlockTagsQuery()).not("TD, TH, LI, .fr-inner").remove(),b.html.wrap(),b.html.fillEmptyBlocks(),b.selection.restore(),b.undo.saveStep(),b.opts.iframe&&b.size.syncIframe(),e!=b&&(e.popups.hideAll(),e.$el.find(e.html.emptyBlockTagsQuery()).not("TD, TH, LI, .fr-inner").remove(),e.html.wrap(),e.html.fillEmptyBlocks(),e.undo.saveStep(),e.events.trigger("element.dropped"),e.opts.iframe&&e.size.syncIframe()),b.events.trigger("element.dropped",[h]),!1}}function l(a){if(a&&"DIV"==a.tagName&&b.node.hasClass(a,"fr-drag-helper"))a.parentNode.removeChild(a);else if(a&&a.nodeType==Node.ELEMENT_NODE)for(var c=a.querySelectorAll("div.fr-drag-helper"),d=0;d=this.wrap_line_length?(this.print_newline(!1,a),this.print_indentation(a)):(this.line_char_count++,a.push(" "))},this.get_content=function(){for(var a="",b=[];"<"!=this.input.charAt(this.pos);){if(this.pos>=this.input.length)return b.length?b.(""):["","TK_EOF"];if(this.traverse_whitespace())this.space_or_wrap(b);else{if(q){var c=this.input.substr(this.pos,3);if("{{#"==c||"{{/"==c)break;if("{{!"==c)return[this.get_tag(),"TK_TAG_HANDLEBARS_COMMENT"];if("{{"==this.input.substr(this.pos,2)&&"{{else}}"==this.get_tag(!0))break}a=this.input.charAt(this.pos),this.pos++,this.line_char_count++,b.push(a)}}return b.length?b.(""):""},this.get_contents_to=function(a){if(this.pos==this.input.length)return["","TK_EOF"];var b="",c=new RegExp("","igm");c.lastIndex=this.pos;var d=c.exec(this.input),e=d?d.index:this.input.length;return this.pos=this.input.length)return a&&(this.pos=j,this.line_char_count=l),f.length?f.(""):["","TK_EOF"];if(e=this.input.charAt(this.pos),this.pos++,this.Utils.in_array(e,this.Utils.whitespace))h=!0;else{if("'"!=e&&'"'!=e||(e+=this.get_unformatted(e),h=!0),"="==e&&(h=!1),f.length&&"="!=f[f.length-1]&&">"!=e&&h){if(this.space_or_wrap(f),h=!1,!i&&"force"==r&&"/"!=e){this.print_newline(!0,f),this.print_indentation(f);for(var m=0;m=2&&"{"==f[f.length-1]&&"{"==f[f.length-2]&&(b="#"==e||"/"==e||"!"==e?this.pos-3:this.pos-2,d="{"),this.line_char_count++,f.push(e),f[1]&&("!"==f[1]||"?"==f[1]||"%"==f[1])){f=[this.get_comment(b)];break}if(q&&f[1]&&"{"==f[1]&&f[2]&&"!"==f[2]){f=[this.get_comment(b)];break}if(q&&"{"==d&&f.length>2&&"}"==f[f.length-2]&&"}"==f[f.length-1])break}}while(">"!=e);var p,t,u=f.("");p=u.indexOf(" ")!=-1?u.indexOf(" "):"{"==u[0]?u.indexOf("}"):u.indexOf(">"),t="<"!=u[0]&&q?"#"==u[2]?3:2:1;var v=u.substring(t,p).toLowerCase();return"/"==u.charAt(u.length-2)||this.Utils.in_array(v,this.Utils.single_token)?a||(this.tag_type="SINGLE"):q&&"{"==u[0]&&"else"==v?a||(this.indent_to_tag("if"),this.tag_type="HANDLEBARS_ELSE",this.indent_content=!0,this.traverse_whitespace()):this.is_unformatted(v,n)?(g=this.get_unformatted("",u),f.push(g),c=this.pos-1,this.tag_type="SINGLE"):"script"==v&&(u.search("type")==-1||u.search("type")>-1&&u.search(/\b(text|application)\/(x-)?(javascript|ecmascript|jscript|livescript)/)>-1)?a||(this.record_tag(v),this.tag_type="SCRIPT"):"style"==v&&(u.search("type")==-1||u.search("type")>-1&&u.search("text/css")>-1)?a||(this.record_tag(v),this.tag_type="STYLE"):"!"==v.charAt(0)?a||(this.tag_type="SINGLE",this.traverse_whitespace()):a||("/"==v.charAt(0)?(this.retrieve_tag(v.substring(1)),this.tag_type="END"):(this.record_tag(v),"html"!=v.toLowerCase()&&(this.indent_content=!0),this.tag_type="START"),this.traverse_whitespace()&&this.space_or_wrap(f),this.Utils.in_array(v,this.Utils.extra_liners)&&(this.print_newline(!1,this.output),this.output.length&&"\n"!=this.output[this.output.length-2]&&this.print_newline(!0,this.output))),a&&(this.pos=j,this.line_char_count=l),f.("")},this.get_comment=function(a){var b="",c=">",d=!1;this.pos=a;var e=this.input.charAt(this.pos);for(this.pos++;this.pos<=this.input.length&&(b+=e,b[b.length-1]!=c[c.length-1]||b.indexOf(c)==-1);)!d&&b.length<10&&(0===b.indexOf("",d=!0):0===b.indexOf("",d=!0):0===b.indexOf("",d=!0):0===b.indexOf("",d=!0):0===b.indexOf("{{!")?(c="}}",d=!0):0===b.indexOf("",d=!0):0===b.indexOf("<%")&&(c="%>",d=!0)),e=this.input.charAt(this.pos),this.pos++;return b},this.get_unformatted=function(a,b){if(b&&b.toLowerCase().indexOf(a)!=-1)return"";var c="",d="",e=0,f=!0;do{if(this.pos>=this.input.length)return d;if(c=this.input.charAt(this.pos),this.pos++,this.Utils.in_array(c,this.Utils.whitespace)){if(!f){this.line_char_count--;continue}if("\n"==c||"\r"==c){d+="\n",this.line_char_count=0;continue}}d+=c,this.line_char_count++,f=!0,q&&"{"==c&&d.length&&"{"==d[d.length-2]&&(d+=this.get_unformatted("}}"),e=d.length)}while(d.toLowerCase().indexOf(a,e)==-1);return d},this.get_token=function(){var a;if("TK_TAG_SCRIPT"==this.last_token||"TK_TAG_STYLE"==this.last_token){var b=this.last_token.substr(7);return a=this.get_contents_to(b),"string"!=typeof a?a:[a,"TK_"+b]}if("CONTENT"==this.current_mode)return a=this.get_content(),"string"!=typeof a?a:[a,"TK_CONTENT"];if("TAG"==this.current_mode){if(a=this.get_tag(),"string"!=typeof a)return a;var c="TK_TAG_"+this.tag_type;return[a,c]}},this.get_full_indent=function(a){return a=this.indent_level+a||0,a<1?"":new Array(a+1).(this.indent_string)},this.is_unformatted=function(a,b){if(!this.Utils.in_array(a,b))return!1;if("a"!=a.toLowerCase()||!this.Utils.in_array("a",b))return!0;var c=this.get_tag(!0),d=(c||"").match(/^\s*<\s*\/?([a-z]*)\s*[^>]*>\s*$/);return!(d&&!this.Utils.in_array(d,b))},this.printer=function(a,b,c,f,g){this.input=a||"",this.output=[],this.indent_character=b,this.indent_string="",this.indent_size=c,this.brace_style=g,this.indent_level=0,this.wrap_line_length=f,this.line_char_count=0;for(var h=0;h0&&(a=e(a)),a&&""!==a&&(a.length>1&&"\n"==a[a.length-1]?(this.output.push(a.slice(0,-1)),this.print_newline(!1,this.output)):this.output.push(a));for(var b=0;b0,this.output);this.newlines=0},this.indent=function(){this.indent_level++},this.unindent=function(){this.indent_level>0&&this.indent_level--}},this}var h,i,j,k,l,m,n,o,p,q,r,s,t,u;for(c=c||{},void 0!==c.wrap_line_length&&0!==parseInt(c.wrap_line_length,10)||void 0===c.max_char||0===parseInt(c.max_char,10)||(c.wrap_line_length=c.max_char),i=void 0!==c.indent_inner_html&&c.indent_inner_html,j=void 0===c.indent_size?4:parseInt(c.indent_size,10),k=void 0===c.indent_char?" ":c.indent_char,m=void 0===c.brace_style?"collapse":c.brace_style,l=0===parseInt(c.wrap_line_length,10)?32786:parseInt(c.wrap_line_length||250,10),n=c.unformatted||["a","span","img","bdo","em","strong","dfn","code","samp","kbd","var","cite","abbr","acronym","q","sub","sup","tt","i","b","big","small","u","s","strike","font","ins","del","address","pre"],o=void 0===c.preserve_newlines||c.preserve_newlines,p=o?isNaN(parseInt(c.max_preserve_newlines,10))?32786:parseInt(c.max_preserve_newlines,10):0,q=void 0!==c.indent_handlebars&&c.indent_handlebars,r=void 0===c.wrap_attributes?"auto":c.wrap_attributes,s=void 0===c.wrap_attributes_indent_size?j:parseInt(c.wrap_attributes_indent_size,10)||j,t=void 0!==c.end_with_newline&&c.end_with_newline,u=Array.isArray(c.extra_liners)?c.extra_liners.concat():"string"==typeof c.extra_liners?c.extra_liners.split(","):"head,body,/html".split(","),c.indent_with_tabs&&(k="\t",j=1),h=new g,h.printer(a,k,j,l,m);;){var v=h.get_token();if(h.token_text=v[0],h.token_type=v[1],"TK_EOF"==h.token_type)break;switch(h.token_type){case"TK_TAG_START":h.print_newline(!1,h.output),h.print_token(h.token_text),h.indent_content&&(h.indent(),h.indent_content=!1),h.current_mode="CONTENT";break;case"TK_TAG_STYLE":case"TK_TAG_SCRIPT":h.print_newline(!1,h.output),h.print_token(h.token_text),h.current_mode="CONTENT";break;case"TK_TAG_END":if("TK_CONTENT"==h.last_token&&""===h.last_text){var w=h.token_text.match(/\w+/)[0],x=null;h.output.length&&(x=h.output[h.output.length-1].match(/(?:<|{{#)\s*(\w+)/)),(null==x||x[1]!=w&&!h.Utils.in_array(x[1],n))&&h.print_newline(!1,h.output)}h.print_token(h.token_text),h.current_mode="CONTENT";break;case"TK_TAG_SINGLE":var y=h.token_text.match(/^\s*<([a-z-]+)/i);y&&h.Utils.in_array(y[1],n)||h.print_newline(!1,h.output),h.print_token(h.token_text),h.current_mode="CONTENT";break;case"TK_TAG_HANDLEBARS_ELSE":h.print_token(h.token_text),h.indent_content&&(h.indent(),h.indent_content=!1),h.current_mode="CONTENT";break;case"TK_TAG_HANDLEBARS_COMMENT":h.print_token(h.token_text),h.current_mode="TAG";break;case"TK_CONTENT":h.print_token(h.token_text),h.current_mode="TAG";break;case"TK_STYLE":case"TK_SCRIPT":if(""!==h.token_text){h.print_newline(!1,h.output);var z,A=h.token_text,B=1;"TK_SCRIPT"==h.token_type?z="function"==typeof f&&f:"TK_STYLE"==h.token_type&&(z="function"==typeof b&&b),"keep"==c.indent_scripts?B=0:"separate"==c.indent_scripts&&(B=-h.indent_level);var C=h.get_full_indent(B);if(z)A=z(A.replace(/^\s*/,C),c);else{var D=A.match(/^\s*/)[0],E=D.match(/[^\n\r]*$/)[0].split(h.indent_string).length-1,F=h.get_full_indent(B-E);A=A.replace(/^\s*/,C).replace(/\r\n|\r|\n/g,"\n"+F).replace(/\s+$/,"")}A&&(h.print_token_raw(A),h.print_newline(!0,h.output))}h.current_mode="TAG";break;default:""!==h.token_text&&h.print_token(h.token_text)}h.last_token=h.token_type,h.last_text=h.token_text}var G=h.output.("").replace(/[\r\n\t ]+$/,"");return t&&(G+="\n"),G}function b(a,b){function c(){return v=a.charAt(++x),v||""}function d(b){var d="",e=x;return b&&g(),d=a.charAt(x+1)||"",x=e-1,c(),d}function e(b){for(var d=x;c();)if("\\"===v)c();else{if(b.indexOf(v)!==-1)break;if("\n"===v)break}return a.substring(d,x+1)}function f(a){var b=x,d=e(a);return x=b-1,c(),d}function g(){for(var a="";w.test(d());)c(),a+=v;return a}function h(){var a="";for(v&&w.test(v)&&(a=v);w.test(c());)a+=v;return a}function i(b){var e=x;for(b="/"===d(),c();c();){if(!b&&"*"===v&&"/"===d()){c();break}if(b&&"\n"===v)return a.substring(e,x)}return a.substring(e,x)+v}function j(b){return a.substring(x-b.length,x).toLowerCase()===b}function k(){for(var b=0,c=x+1;cC):F=B>=C):"}"===v?(m(),D["}"](v),F=!1,G=!1,C&&C--,t&&0===B&&D.newLine(!0)):":"===v?(g(),!F&&!H||j("&")||k()?":"===d()?(c(),E.push("::")):E.push(":"):(G=!0,E.push(":"),D.singleSpace())):'"'===v||"'"===v?(D.preserveSingleSpace(),E.push(e(v))):";"===v?(G=!1,E.push(v),D.newLine()):"("===v?j("url")?(E.push(v),g(),c()&&(")"!==v&&'"'!==v&&"'"!==v?E.push(e(")")):x--)):(y++,D.preserveSingleSpace(),E.push(v),g()):")"===v?(E.push(v),y--):","===v?(E.push(v),g(),r&&!G&&y<1?D.newLine():D.singleSpace()):"]"===v?E.push(v):"["===v?(D.preserveSingleSpace(),E.push(v)):"="===v?(g(),v="=",E.push(v)):(D.preserveSingleSpace(),E.push(v))}var P="";return z&&(P+=z),P+=E.("").replace(/[\r\n\t ]+$/,""),s&&(P+="\n"),"\n"!=u&&(P=P.replace(/[\n]/g,u)),P}function c(a,b){for(var c=0;cc&&(c=a.line_indent_level));var d={mode:b,parent:a,last_text:a?a.last_text:"",last_word:a?a.last_word:"",declaration_statement:!1,declaration_assignment:!1,multiline_frame:!1,if_block:!1,else_block:!1,do_block:!1,do_while:!1,in_case_statement:!1,in_case:!1,case_body:!1,indentation_level:c,line_indent_level:a?a.line_indent_level:c,start_line_index:R.get_line_number(),ternary_depth:0};return d}function g(a){var b=a.newlines,c=ba.keep_array_indentation&&t(Y.mode);if(c)for(d=0;d0);else if(ba.max_preserve_newlines&&b>ba.max_preserve_newlines&&(b=ba.max_preserve_newlines),ba.preserve_newlines&&a.newlines>1){n();for(var d=1;d=ba.wrap_line_length&&n(!1,!0)}}function n(a,b){if(!b&&";"!==Y.last_text&&","!==Y.last_text&&"="!==Y.last_text&&"TK_OPERATOR"!==V)for(;Y.mode===l.Statement&&!Y.if_block&&!Y.do_block;)v();R.add_new_line(a)&&(Y.multiline_frame=!0)}function o(){R.just_added_newline()&&(ba.keep_array_indentation&&t(Y.mode)&&U.wanted_newline?(R.current_line.push(U.whitespace_before),R.space_before_token=!1):R.set_indent(Y.indentation_level)&&(Y.line_indent_level=Y.indentation_level))}function p(a){return R.raw?void R.add_raw_token(U):(ba.comma_first&&"TK_COMMA"===V&&R.just_added_newline()&&","===R.previous_line.last()&&(R.previous_line.pop(),o(),R.add_token(","),R.space_before_token=!0),a=a||U.text,o(),void R.add_token(a))}function q(){Y.indentation_level+=1}function r(){Y.indentation_level>0&&(!Y.parent||Y.indentation_level>Y.parent.indentation_level)&&(Y.indentation_level-=1)}function s(a){Y?($.push(Y),Z=Y):Z=f(null,a),Y=f(Z,a)}function t(a){return a===l.ArrayLiteral}function u(a){return c(a,[l.Expression,l.ForInitializer,l.Conditional])}function v(){$.length>0&&(Z=Y,Y=$.pop(),Z.mode===l.Statement&&R.remove_redundant_indentation(Z))}function w(){return Y.parent.mode===l.ObjectLiteral&&Y.mode===l.Statement&&(":"===Y.last_text&&0===Y.ternary_depth||"TK_RESERVED"===V&&c(Y.last_text,["get","set"]))}function x(){return!!("TK_RESERVED"===V&&c(Y.last_text,["var","let","const"])&&"TK_WORD"===U.type||"TK_RESERVED"===V&&"do"===Y.last_text||"TK_RESERVED"===V&&"return"===Y.last_text&&!U.wanted_newline||"TK_RESERVED"===V&&"else"===Y.last_text&&("TK_RESERVED"!==U.type||"if"!==U.text)||"TK_END_EXPR"===V&&(Z.mode===l.ForInitializer||Z.mode===l.Conditional)||"TK_WORD"===V&&Y.mode===l.BlockStatement&&!Y.in_case&&"--"!==U.text&&"++"!==U.text&&"function"!==W&&"TK_WORD"!==U.type&&"TK_RESERVED"!==U.type||Y.mode===l.ObjectLiteral&&(":"===Y.last_text&&0===Y.ternary_depth||"TK_RESERVED"===V&&c(Y.last_text,["get","set"])))&&(s(l.Statement),q(),"TK_RESERVED"===V&&c(Y.last_text,["var","let","const"])&&"TK_WORD"===U.type&&(Y.declaration_statement=!0),w()||m("TK_RESERVED"===U.type&&c(U.text,["do","for","if","while"])),!0)}function y(a,b){for(var c=0;c=ca.length?null:ca[b]}function C(){x();var a=l.Expression;if("["===U.text){if("TK_WORD"===V||")"===Y.last_text)return"TK_RESERVED"===V&&c(Y.last_text,T.line_starters)&&(R.space_before_token=!0),s(a),p(),q(),void(ba.space_in_paren&&(R.space_before_token=!0));a=l.ArrayLiteral,t(Y.mode)&&("["!==Y.last_text&&(","!==Y.last_text||"]"!==W&&"}"!==W)||ba.keep_array_indentation||n())}else"TK_RESERVED"===V&&"for"===Y.last_text?a=l.ForInitializer:"TK_RESERVED"===V&&c(Y.last_text,["if","while"])&&(a=l.Conditional);";"===Y.last_text||"TK_START_BLOCK"===V?n():"TK_END_EXPR"===V||"TK_START_EXPR"===V||"TK_END_BLOCK"===V||"."===Y.last_text?m(U.wanted_newline):"TK_RESERVED"===V&&"("===U.text||"TK_WORD"===V||"TK_OPERATOR"===V?"TK_RESERVED"===V&&("function"===Y.last_word||"typeof"===Y.last_word)||"*"===Y.last_text&&"function"===W?ba.space_after_anon_function&&(R.space_before_token=!0):"TK_RESERVED"!==V||!c(Y.last_text,T.line_starters)&&"catch"!==Y.last_text||ba.space_before_conditional&&(R.space_before_token=!0):R.space_before_token=!0,"("===U.text&&"TK_RESERVED"===V&&"await"===Y.last_word&&(R.space_before_token=!0),"("===U.text&&("TK_EQUALS"!==V&&"TK_OPERATOR"!==V||w()||m()),s(a),p(),ba.space_in_paren&&(R.space_before_token=!0),q()}function D(){for(;Y.mode===l.Statement;)v();Y.multiline_frame&&m("]"===U.text&&t(Y.mode)&&!ba.keep_array_indentation),ba.space_in_paren&&("TK_START_EXPR"!==V||ba.space_in_empty_paren?R.space_before_token=!0:(R.trim(),R.space_before_token=!1)),"]"===U.text&&ba.keep_array_indentation?(p(),v()):(v(),p()),R.remove_redundant_indentation(Z),Y.do_while&&Z.mode===l.Conditional&&(Z.mode=l.Expression,Y.do_block=!1,Y.do_while=!1)}function E(){var a=B(1),b=B(2);s(b&&(":"===b.text&&c(a.type,["TK_STRING","TK_WORD","TK_RESERVED"])||c(a.text,["get","set"])&&c(b.type,["TK_WORD","TK_RESERVED"]))?c(W,["class","interface"])?l.BlockStatement:l.ObjectLiteral:l.BlockStatement);var d=!a.comments_before.length&&"}"===a.text,e=d&&"function"===Y.last_word&&"TK_END_EXPR"===V;"expand"===ba.brace_style||"none"===ba.brace_style&&U.wanted_newline?"TK_OPERATOR"!==V&&(e||"TK_EQUALS"===V||"TK_RESERVED"===V&&A(Y.last_text)&&"else"!==Y.last_text)?R.space_before_token=!0:n(!1,!0):"TK_OPERATOR"!==V&&"TK_START_EXPR"!==V?"TK_START_BLOCK"===V?n():R.space_before_token=!0:t(Z.mode)&&","===Y.last_text&&("}"===W?R.space_before_token=!0:n()),p(),q()}function F(){for(;Y.mode===l.Statement;)v();var a="TK_START_BLOCK"===V;"expand"===ba.brace_style?a||n():a||(t(Y.mode)&&ba.keep_array_indentation?(ba.keep_array_indentation=!1,n(),ba.keep_array_indentation=!0):n()),v(),p()}function G(){if("TK_RESERVED"===U.type&&Y.mode!==l.ObjectLiteral&&c(U.text,["set","get"])&&(U.type="TK_WORD"),"TK_RESERVED"===U.type&&Y.mode===l.ObjectLiteral){var a=B(1);":"==a.text&&(U.type="TK_WORD")}if(x()||!U.wanted_newline||u(Y.mode)||"TK_OPERATOR"===V&&"--"!==Y.last_text&&"++"!==Y.last_text||"TK_EQUALS"===V||!ba.preserve_newlines&&"TK_RESERVED"===V&&c(Y.last_text,["var","let","const","set","get"])||n(),Y.do_block&&!Y.do_while){if("TK_RESERVED"===U.type&&"while"===U.text)return R.space_before_token=!0,p(),R.space_before_token=!0,void(Y.do_while=!0);n(),Y.do_block=!1}if(Y.if_block)if(Y.else_block||"TK_RESERVED"!==U.type||"else"!==U.text){for(;Y.mode===l.Statement;)v();Y.if_block=!1,Y.else_block=!1}else Y.else_block=!0;if("TK_RESERVED"===U.type&&("case"===U.text||"default"===U.text&&Y.in_case_statement))return n(),(Y.case_body||ba.jslint_happy)&&(r(),Y.case_body=!1),p(),Y.in_case=!0,void(Y.in_case_statement=!0);if("TK_RESERVED"===U.type&&"function"===U.text&&((c(Y.last_text,["}",";"])||R.just_added_newline()&&!c(Y.last_text,["[","{",":","=",","]))&&(R.just_added_blankline()||U.comments_before.length||(n(),n(!0))),"TK_RESERVED"===V||"TK_WORD"===V?"TK_RESERVED"===V&&c(Y.last_text,["get","set","new","return","export","async"])?R.space_before_token=!0:"TK_RESERVED"===V&&"default"===Y.last_text&&"export"===W?R.space_before_token=!0:n():"TK_OPERATOR"===V||"="===Y.last_text?R.space_before_token=!0:(Y.multiline_frame||!u(Y.mode)&&!t(Y.mode))&&n()),"TK_COMMA"!==V&&"TK_START_EXPR"!==V&&"TK_EQUALS"!==V&&"TK_OPERATOR"!==V||w()||m(),"TK_RESERVED"===U.type&&c(U.text,["function","get","set"]))return p(),void(Y.last_word=U.text);if(_="NONE","TK_END_BLOCK"===V?"TK_RESERVED"===U.type&&c(U.text,["else","catch","finally"])?"expand"===ba.brace_style||"end-expand"===ba.brace_style||"none"===ba.brace_style&&U.wanted_newline?_="NEWLINE":(_="SPACE",R.space_before_token=!0):_="NEWLINE":"TK_SEMICOLON"===V&&Y.mode===l.BlockStatement?_="NEWLINE":"TK_SEMICOLON"===V&&u(Y.mode)?_="SPACE":"TK_STRING"===V?_="NEWLINE":"TK_RESERVED"===V||"TK_WORD"===V||"*"===Y.last_text&&"function"===W?_="SPACE":"TK_START_BLOCK"===V?_="NEWLINE":"TK_END_EXPR"===V&&(R.space_before_token=!0,_="NEWLINE"),"TK_RESERVED"===U.type&&c(U.text,T.line_starters)&&")"!==Y.last_text&&(_="else"===Y.last_text||"export"===Y.last_text?"SPACE":"NEWLINE"),"TK_RESERVED"===U.type&&c(U.text,["else","catch","finally"]))if("TK_END_BLOCK"!==V||"expand"===ba.brace_style||"end-expand"===ba.brace_style||"none"===ba.brace_style&&U.wanted_newline)n();else{R.trim(!0);var b=R.current_line;"}"!==b.last()&&n(),R.space_before_token=!0}else"NEWLINE"===_?"TK_RESERVED"===V&&A(Y.last_text)?R.space_before_token=!0:"TK_END_EXPR"!==V?"TK_START_EXPR"===V&&"TK_RESERVED"===U.type&&c(U.text,["var","let","const"])||":"===Y.last_text||("TK_RESERVED"===U.type&&"if"===U.text&&"else"===Y.last_text?R.space_before_token=!0:n()):"TK_RESERVED"===U.type&&c(U.text,T.line_starters)&&")"!==Y.last_text&&n():Y.multiline_frame&&t(Y.mode)&&","===Y.last_text&&"}"===W?n():"SPACE"===_&&(R.space_before_token=!0);p(),Y.last_word=U.text,"TK_RESERVED"===U.type&&"do"===U.text&&(Y.do_block=!0),"TK_RESERVED"===U.type&&"if"===U.text&&(Y.if_block=!0)}function H(){for(x()&&(R.space_before_token=!1);Y.mode===l.Statement&&!Y.if_block&&!Y.do_block;)v();p()}function I(){x()?R.space_before_token=!0:"TK_RESERVED"===V||"TK_WORD"===V?R.space_before_token=!0:"TK_COMMA"===V||"TK_START_EXPR"===V||"TK_EQUALS"===V||"TK_OPERATOR"===V?w()||m():n(),p()}function J(){x(),Y.declaration_statement&&(Y.declaration_assignment=!0),R.space_before_token=!0,p(),R.space_before_token=!0}function K(){return Y.declaration_statement?(u(Y.parent.mode)&&(Y.declaration_assignment=!1),p(),void(Y.declaration_assignment?(Y.declaration_assignment=!1,n(!1,!0)):(R.space_before_token=!0,ba.comma_first&&m()))):(p(),void(Y.mode===l.ObjectLiteral||Y.mode===l.Statement&&Y.parent.mode===l.ObjectLiteral?(Y.mode===l.Statement&&v(),n()):(R.space_before_token=!0,ba.comma_first&&m())))}function L(){if(x(),"TK_RESERVED"===V&&A(Y.last_text))return R.space_before_token=!0,void p();if("*"===U.text&&"TK_DOT"===V)return void p();if(":"===U.text&&Y.in_case)return Y.case_body=!0,q(),p(),n(),void(Y.in_case=!1);if("::"===U.text)return void p();"TK_OPERATOR"===V&&m();var a=!0,b=!0;c(U.text,["--","++","!","~"])||c(U.text,["-","+"])&&(c(V,["TK_START_BLOCK","TK_START_EXPR","TK_EQUALS","TK_OPERATOR"])||c(Y.last_text,T.line_starters)||","===Y.last_text)?(a=!1,b=!1,!U.wanted_newline||"--"!==U.text&&"++"!==U.text||n(!1,!0),";"===Y.last_text&&u(Y.mode)&&(a=!0),"TK_RESERVED"===V?a=!0:"TK_END_EXPR"===V?a=!("]"===Y.last_text&&("--"===U.text||"++"===U.text)):"TK_OPERATOR"===V&&(a=c(U.text,["--","-","++","+"])&&c(Y.last_text,["--","-","++","+"]),c(U.text,["+","-"])&&c(Y.last_text,["--","++"])&&(b=!0)),Y.mode!==l.BlockStatement&&Y.mode!==l.Statement||"{"!==Y.last_text&&";"!==Y.last_text||n()):":"===U.text?0===Y.ternary_depth?a=!1:Y.ternary_depth-=1:"?"===U.text?Y.ternary_depth+=1:"*"===U.text&&"TK_RESERVED"===V&&"function"===Y.last_text&&(a=!1,b=!1),R.space_before_token=R.space_before_token||a,p(),R.space_before_token=b}function M(){if(R.raw)return R.add_raw_token(U),void(U.directives&&"end"===U.directives.preserve&&(ba.test_output_raw||(R.raw=!1)));if(U.directives)return n(!1,!0),p(),"start"===U.directives.preserve&&(R.raw=!0),void n(!1,!0);if(!k.newline.test(U.text)&&!U.wanted_newline)return R.space_before_token=!0,p(),void(R.space_before_token=!0);var a,b=h(U.text),c=!1,d=!1,f=U.whitespace_before,g=f.length;for(n(!1,!0),b.length>1&&(y(b.slice(1),"*")?c=!0:z(b.slice(1),f)&&(d=!0)),p(b[0]),a=1;ag?p(b[a].substring(g)):R.add_token(b[a]);n(!1,!0)}function N(){U.wanted_newline?n(!1,!0):R.trim(!0),R.space_before_token=!0,p(),n(!1,!0)}function O(){x(),"TK_RESERVED"===V&&A(Y.last_text)?R.space_before_token=!0:m(")"===Y.last_text&&ba.break_chained_methods),p()}function P(){p(),"\n"===U.text[U.text.length-1]&&n()}function Q(){for(;Y.mode===l.Statement;)v()}var R,S,T,U,V,W,X,Y,Z,$,_,aa,ba,ca=[],da="";for(aa={TK_START_EXPR:C,TK_END_EXPR:D,TK_START_BLOCK:E,TK_END_BLOCK:F,TK_WORD:G,TK_RESERVED:G,TK_SEMICOLON:H,TK_STRING:I,TK_EQUALS:J,TK_OPERATOR:L,TK_COMMA:K,TK_BLOCK_COMMENT:M,TK_COMMENT:N,TK_DOT:O,TK_UNKNOWN:P,TK_EOF:Q},b=b?b:{},ba={},void 0!==b.braces_on_own_line&&(ba.brace_style=b.braces_on_own_line?"expand":"collapse"),ba.brace_style=b.brace_style?b.brace_style:ba.brace_style?ba.brace_style:"collapse","expand-strict"===ba.brace_style&&(ba.brace_style="expand"),ba.indent_size=b.indent_size?parseInt(b.indent_size,10):4,ba.indent_char=b.indent_char?b.indent_char:" ",ba.eol=b.eol?b.eol:"\n",ba.preserve_newlines=void 0===b.preserve_newlines||b.preserve_newlines,ba.break_chained_methods=void 0!==b.break_chained_methods&&b.break_chained_methods,ba.max_preserve_newlines=void 0===b.max_preserve_newlines?0:parseInt(b.max_preserve_newlines,10),ba.space_in_paren=void 0!==b.space_in_paren&&b.space_in_paren,ba.space_in_empty_paren=void 0!==b.space_in_empty_paren&&b.space_in_empty_paren,ba.jslint_happy=void 0!==b.jslint_happy&&b.jslint_happy,ba.space_after_anon_function=void 0!==b.space_after_anon_function&&b.space_after_anon_function,ba.keep_array_indentation=void 0!==b.keep_array_indentation&&b.keep_array_indentation,ba.space_before_conditional=void 0===b.space_before_conditional||b.space_before_conditional,ba.unescape_strings=void 0!==b.unescape_strings&&b.unescape_strings,ba.wrap_line_length=void 0===b.wrap_line_length?0:parseInt(b.wrap_line_length,10),ba.e4x=void 0!==b.e4x&&b.e4x,ba.end_with_newline=void 0!==b.end_with_newline&&b.end_with_newline,ba.comma_first=void 0!==b.comma_first&&b.comma_first,ba.test_output_raw=void 0!==b.test_output_raw&&b.test_output_raw,ba.jslint_happy&&(ba.space_after_anon_function=!0),b.indent_with_tabs&&(ba.indent_char="\t",ba.indent_size=1),ba.eol=ba.eol.replace(/\\r/,"\r").replace(/\\n/,"\n"),X="";ba.indent_size>0;)X+=ba.indent_char,ba.indent_size-=1;var ea=0;if(a&&a.length){for(;" "===a.charAt(ea)||"\t"===a.charAt(ea);)da+=a.charAt(ea),ea+=1;a=a.substring(ea)}V="TK_START_BLOCK",W="",R=new i(X,da),R.raw=ba.test_output_raw,$=[],s(l.BlockStatement),this.beautify=function(){var b,c;for(T=new j(a,ba,X),ca=T.tokenize(),S=0;b=B();){for(var d=0;d0&&(c-=1,b-=a.indent_length)},this.trim=function(){for(;" "===this.last();){d.pop();b-=1}e=0===d.length},this.toString=function(){var b="";return this._empty||(c>=0&&(b=a.indent_cache[c]),b+=d.("")),b}}function i(a,b){b=b||"",this.indent_cache=[b],this.baseIndentLength=b.length,this.indent_length=a.length,this.raw=!1;var c=[];this.baseIndentString=b,this.indent_string=a,this.previous_line=null,this.current_line=null,this.space_before_token=!1,this.add_outputline=function(){this.previous_line=this.current_line,this.current_line=new h(this),c.push(this.current_line)},this.add_outputline(),this.get_line_number=function(){return c.length},this.add_new_line=function(a){return(1!==this.get_line_number()||!this.just_added_newline())&&(!(!a&&this.just_added_newline())&&(this.raw||this.add_outputline(),!0))},this.get_code=function(){var a=c.("\n").replace(/[\r\n\t ]+$/,"");return a},this.set_indent=function(a){if(c.length>1){for(;a>=this.indent_cache.length;)this.indent_cache.push(this.indent_cache[this.indent_cache.length-1]+this.indent_string);return this.current_line.set_indent(a),!0}return this.current_line.set_indent(0),!1},this.add_raw_token=function(a){for(var b=0;b1&&this.current_line.is_empty();)c.pop(),this.current_line=c[c.length-1],this.current_line.trim();this.previous_line=c.length>1?c[c.length-2]:null},this.just_added_newline=function(){return this.current_line.is_empty()},this.just_added_blankline=function(){if(this.just_added_newline()){if(1===c.length)return!0;var a=c[c.length-2];return a.is_empty()}return!1}}function j(a,b,e){function f(a){if(!a.match(y))return null;var b={};z.lastIndex=0;for(var c=z.exec(a);c;)b[c[1]]=c[2],c=z.exec(a);return b}function g(){var e,g=[];if(p=0,q="",t>=u)return["","TK_EOF"];var y;y=s.length?s[s.length-1]:new m("TK_START_BLOCK","{");var z=a.charAt(t);for(t+=1;c(z,i);){if(k.newline.test(z)?"\n"===z&&"\r"===a.charAt(t-2)||(p+=1,g=[]):g.push(z),t>=u)return["","TK_EOF"];z=a.charAt(t),t+=1}if(g.length&&(q=g.("")),j.test(z)){var C=!0,D=!0,E=j;for("0"===z&&t/))&&("TK_RESERVED"===y.type&&c(y.text,["return","case","throw","else","do","typeof","yield"])||"TK_END_EXPR"===y.type&&")"===y.text&&y.parent&&"TK_RESERVED"===y.parent.type&&c(y.parent.text,["if","while","for"])||c(y.type,["TK_COMMENT","TK_START_EXPR","TK_START_BLOCK","TK_END_BLOCK","TK_OPERATOR","TK_EQUALS","TK_EOF","TK_SEMICOLON","TK_COMMA"]))){var I=z,J=!1,K=!1;if(e=z,"/"===I)for(var L=!1;t/g,N=a.slice(t-1),O=M.exec(N);if(O&&0===O.index){for(var P=O[2],Q=0;O;){var R=!!O[1],S=O[2],T=!!O[O.length-1]||"![CDATA["===S.slice(0,8);if(S!==P||T||(R?--Q:++Q),Q<=0)break;O=M.exec(N)}var U=O?O.index+O[0].length:N.length;return N=N.slice(0,U),t+=U-1,N=N.replace(k.lineBreak,"\n"),[N,"TK_STRING"]}}else for(;t"===a.substring(t-1,t+2))return r=!1,t+=2,["-->","TK_COMMENT"];if("."===z)return[z,"TK_DOT"];if(c(z,o)){for(;t=u)););return","===z?[z,"TK_COMMA"]:"="===z?[z,"TK_EQUALS"]:[z,"TK_OPERATOR"]}return[z,"TK_UNKNOWN"]}function h(a){for(var b,c=!1,d="",e=0,f="",g=0;c||e=0&&g<32){d+="x"===b?"\\x"+f:"\\u"+f;continue}if(34===g||39===g||92===g)d+="\\"+String.fromCharCode(g);else{if("x"===b&&g>126&&g<=255)return a;d+=String.fromCharCode(g)}}else"\\"===b?c=!0:d+=b;return d}var i="\n\r\t ".split(""),j=/[0-9]/,l=/[01234567]/,n=/[0123456789abcdefABCDEF]/,o="+ - * / % & ++ -- = += -= *= /= %= == === != !== > < >= <= >> << >>> >>>= >>= <<= && &= | || ! ~ , : ? ^ ^= |= :: =>".split(" ");this.line_starters="continue,try,throw,return,var,let,const,if,switch,case,default,for,while,break,function,import,export".split(",");var p,q,r,s,t,u,v=this.line_starters.concat(["do","in","else","get","set","new","catch","finally","typeof","yield","async","await"]),w=/([\s\S]*?)((?:\*\/)|$)/g,x=/([^\n\r\u2028\u2029]*)/g,y=/\/\* beautify( \w+[:]\w+)+ \*\//g,z=/ (\w+)[:](\w+)/g,A=/([\s\S]*?)((?:\/\*\sbeautify\signore:end\s\*\/)|$)/g,B=/((<\?php|<\?=)[\s\S]*?\?>)|(<%[\s\S]*?%>)/g;this.tokenize=function(){u=a.length,t=0,r=!1,s=[];for(var b,c,d,e=null,f=[],h=[];!c||"TK_EOF"!==c.type;){for(d=g(),b=new m(d[1],d[0],p,q);"TK_COMMENT"===b.type||"TK_BLOCK_COMMENT"===b.type||"TK_UNKNOWN"===b.type;)"TK_BLOCK_COMMENT"===b.type&&(b.directives=d[2]),h.push(b),d=g(),b=new m(d[1],d[0],p,q);h.length&&(b.comments_before=h,h=[]),"TK_START_BLOCK"===b.type||"TK_START_EXPR"===b.type?(b.parent=c,f.push(e),e=b):("TK_END_BLOCK"===b.type||"TK_END_EXPR"===b.type)&&e&&("]"===b.text&&"["===e.text||")"===b.text&&"("===e.text||"}"===b.text&&"{"===e.text)&&(b.parent=e.parent,e=f.pop()),s.push(b),c=b}return s}}var k={};!function(a){var b="\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc",c="\u0300-\u036f\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u0620-\u0649\u0672-\u06d3\u06e7-\u06e8\u06fb-\u06fc\u0730-\u074a\u0800-\u0814\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0840-\u0857\u08e4-\u08fe\u0900-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962-\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09d7\u09df-\u09e0\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5f-\u0b60\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2-\u0ce3\u0ce6-\u0cef\u0d02\u0d03\u0d46-\u0d48\u0d57\u0d62-\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e34-\u0e3a\u0e40-\u0e45\u0e50-\u0e59\u0eb4-\u0eb9\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f41-\u0f47\u0f71-\u0f84\u0f86-\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1029\u1040-\u1049\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u170e-\u1710\u1720-\u1730\u1740-\u1750\u1772\u1773\u1780-\u17b2\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1920-\u192b\u1930-\u193b\u1951-\u196d\u19b0-\u19c0\u19c8-\u19c9\u19d0-\u19d9\u1a00-\u1a15\u1a20-\u1a53\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1b46-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1bb0-\u1bb9\u1be6-\u1bf3\u1c00-\u1c22\u1c40-\u1c49\u1c5b-\u1c7d\u1cd0-\u1cd2\u1d00-\u1dbe\u1e01-\u1f15\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2d81-\u2d96\u2de0-\u2dff\u3021-\u3028\u3099\u309a\ua640-\ua66d\ua674-\ua67d\ua69f\ua6f0-\ua6f1\ua7f8-\ua800\ua806\ua80b\ua823-\ua827\ua880-\ua881\ua8b4-\ua8c4\ua8d0-\ua8d9\ua8f3-\ua8f7\ua900-\ua909\ua926-\ua92d\ua930-\ua945\ua980-\ua983\ua9b3-\ua9c0\uaa00-\uaa27\uaa40-\uaa41\uaa4c-\uaa4d\uaa50-\uaa59\uaa7b\uaae0-\uaae9\uaaf2-\uaaf3\uabc0-\uabe1\uabec\uabed\uabf0-\uabf9\ufb20-\ufb28\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f",d=new RegExp("["+b+"]"),e=new RegExp("["+b+c+"]");a.newline=/[\n\r\u2028\u2029]/,a.lineBreak=new RegExp("\r\n|"+a.newline.source),a.allLineBreaks=new RegExp(a.lineBreak.source,"g"),a.isIdentifierStart=function(a){return a<65?36===a||64===a:a<91||(a<97?95===a:a<123||a>=170&&d.test(String.fromCharCode(a)))},a.isIdentifierChar=function(a){return a<48?36===a:a<58||!(a<65)&&(a<91||(a<97?95===a:a<123||a>=170&&e.test(String.fromCharCode(a))))}}(k);var l={BlockStatement:"BlockStatement",Statement:"Statement",ObjectLiteral:"ObjectLiteral",ArrayLiteral:"ArrayLiteral",ForInitializer:"ForInitializer",Conditional:"Conditional",Expression:"Expression"},m=function(a,b,c,d,e,f){this.type=a,this.text=b,this.comments_before=[],this.newlines=c||0,this.wanted_newline=c>0,this.whitespace_before=d||"",this.parent=null,this.directives=null};return{run:a}}});(function($){$.FroalaEditor.PLUGINS.mediaManager=function(editor){function onInsertFile(){new $.oc.mediaManager.popup({alias:'ocmediamanager',cropAndInsertButton:false,onInsert:function(items){if(!items.length){$.oc.alert($.oc.lang.get('mediamanager.invalid_file_empty_insert')) return} if(items.length>1){$.oc.alert($.oc.lang.get('mediamanager.invalid_file_single_insert')) return} var link,text=editor.selection.text(),textIsEmpty=$.trim(text)==='' for(var i=0,len=items.length;i'+text+'');var $file=editor.$el.find('#fr-inserted-file');$file.removeAttr('id');editor.undo.saveStep() this.hide()}})} function onInsertImage(){var $currentImage=editor.image.get() new $.oc.mediaManager.popup({alias:'ocmediamanager',cropAndInsertButton:true,onInsert:function(items){if(!items.length){$.oc.alert($.oc.lang.get('mediamanager.invalid_image_empty_insert')) return} var imagesInserted=0 for(var i=0,len=items.length;i1){$.oc.alert($.oc.lang.get('mediamanager.invalid_file_single_insert')) return} var item=items[0] if(item.documentType!=='video'){$.oc.alert($.oc.lang.get('mediamanager.invalid_video_invalid_insert','The file "'+item.title+'" is not a video.')) return} var $richEditorNode=editor.$el.closest('[data-control="richeditor"]') $richEditorNode.richEditor('insertVideo',item.publicUrl,item.title) this.hide()}})} function onInsertAudio(){new $.oc.mediaManager.popup({alias:'ocmediamanager',cropAndInsertButton:false,onInsert:function(items){if(!items.length){$.oc.alert($.oc.lang.get('mediamanager.invalid_audio_empty_insert')) return} if(items.length>1){$.oc.alert($.oc.lang.get('mediamanager.invalid_file_single_insert')) return} var item=items[0] if(item.documentType!=='audio'){$.oc.alert($.oc.lang.get('mediamanager.invalid_audio_invalid_insert','The file "'+item.title+'" is not an audio file.')) return} var $richEditorNode=editor.$el.closest('[data-control="richeditor"]') $richEditorNode.richEditor('insertAudio',item.publicUrl,item.title) this.hide()}})} function _insertVideoFallback(link){var $richEditorNode=editor.$el.closest('[data-control="richeditor"]') var title=link.substring(link.lastIndexOf('/')+1) $richEditorNode.richEditor('insertVideo',link,title) editor.popups.hide('video.insert')} function _insertAudioFallback(link){var $richEditorNode=editor.$el.closest('[data-control="richeditor"]') var title=link.substring(link.lastIndexOf('/')+1) $richEditorNode.richEditor('insertAudio',link,title) editor.popups.hide('audio.insert')} function _init(){editor.events.on('destroy',_destroy,true) editor.events.on('video.linkError',_insertVideoFallback) editor.events.on('audio.linkError',_insertAudioFallback)} function _destroy(){} return{_init:_init,insertFile:onInsertFile,insertImage:onInsertImage,insertVideo:onInsertVideo,insertAudio:onInsertAudio}} if(!$.FE.PLUGINS.link||!$.FE.PLUGINS.file||!$.FE.PLUGINS.image||!$.FE.PLUGINS.video){throw new Error('Media manager plugin requires link, file, image and video plugin.');} $.FE.DEFAULTS.imageInsertButtons.push('mmImageManager');$.FE.Command('mmImageManager',{title:'Browse',undo:false,focus:false,callback:function(){this.mediaManager.insertImage();},plugin:'mediaManager'}) $.FE.DefineIcon('mmImageManager',{NAME:'folder'});$.FE.DEFAULTS.fileInsertButtons.push('mmFileManager');$.FE.Command('mmFileManager',{title:'Browse',undo:false,focus:false,callback:function(){this.mediaManager.insertFile();},plugin:'mediaManager'}) $.FE.DefineIcon('mmFileManager',{NAME:'folder'});$.FE.DEFAULTS.videoInsertButtons.push('mmVideoManager');$.FE.Command('mmVideoManager',{title:'Browse',undo:false,focus:false,callback:function(){this.mediaManager.insertVideo();},plugin:'mediaManager'}) $.FE.DefineIcon('mmVideoManager',{NAME:'folder'});$.FE.DEFAULTS.audioInsertButtons.push('mmAudioManager');$.FE.Command('mmAudioManager',{title:'Browse',undo:false,focus:false,callback:function(){this.mediaManager.insertAudio();},plugin:'mediaManager'}) $.FE.DefineIcon('mmAudioManager',{NAME:'folder'});})(jQuery);var richeditorPageLinksPlugin function richeditorPageLinksSelectPage($form){richeditorPageLinksPlugin.setLinkValueFromPopup($form)} $.FroalaEditor.DEFAULTS=$.extend($.FroalaEditor.DEFAULTS,{pageLinksHandler:'onLoadPageLinksForm'});$.FroalaEditor.DEFAULTS.key='HHMDUGENKACTMXQL==';(function($){$.FroalaEditor.PLUGINS.pageLinks=function(editor){function setLinkValueFromPopup($form){var $select=$('select[name=pagelink]',$form) var link={text:$('option:selected',$select).text().trim(),href:$select.val()} setTimeout(function(){editor.popups.show('link.insert') setLinkValue(link)},300)} function setLinkValue(link){var $popup=editor.popups.get('link.insert');var text_inputs=$popup.find('input.fr-link-attr[type="text"]');var check_inputs=$popup.find('input.fr-link-attr[type="checkbox"]');var $input;var i;for(i=0;i').append($el.clone()).remove().html() editor.events.focus(true) editor.selection.restore() editor.html.insert(html) editor.html.cleanEmptyTags() $('figure',editor.$el).each(function(){var $this=$(this),$parent=$this.parent('p'),$next=$this.next('p') if(!!$parent.length){$this.insertAfter($parent)} if(!!$next.length&&$.trim($next.text()).length==0){$next.remove()}}) editor.undo.saveStep()} function _makeUiBlockElement(){var $node=$('
 
') $node.get(0).contentEditable=false return $node} function insertVideo(url,text){var $node=_makeUiBlockElement() $node.attr('data-video',url) $node.attr('data-label',text) insertElement($node)} function insertAudio(url,text){var $node=_makeUiBlockElement() $node.attr('data-audio',url) $node.attr('data-label',text) insertElement($node)} function _initUiBlocks(){$('[data-video], [data-audio]',editor.$el).each(function(){$(this).addClass('fr-draggable').attr({'data-ui-block':'true','draggable':'true','tabindex':'0'}).html(' ') this.contentEditable=false})} function _handleUiBlocksKeydown(ev){if(ev.which==40||ev.which==38||ev.which==8||ev.which==46){var $block=$(editor.selection.element()) if($block.is('br')){$block=$block.parent()} if(!!$block.length){switch(ev.which){case 38:_handleUiBlockCaretIn($block.prev()) break case 40:_handleUiBlockCaretIn($block.next()) break case 46:_handleUiBlockCaretClearEmpty($block.next(),$block) break case 8:_handleUiBlockCaretClearEmpty($block.prev(),$block) break}}}} function _handleUiBlockCaretClearEmpty($block,$p){if($block.attr('data-ui-block')!==undefined&&$.trim($p.text()).length==0){$p.remove() _handleUiBlockCaretIn($block) editor.undo.saveStep()}} function _handleUiBlockCaretIn($block){if($block.attr('data-ui-block')!==undefined){$block.focus() editor.selection.clear() return true} return false} function _uiBlockKeyDown(ev,block){if(ev.which==40||ev.which==38||ev.which==13||ev.which==8||ev.which==46){switch(ev.which){case 40:_focusUiBlockOrText($(block).next(),true) break case 38:_focusUiBlockOrText($(block).prev(),false) break case 13:var $paragraph=$('


') $paragraph.insertAfter(block) editor.selection.setAfter(block) editor.selection.restore() editor.undo.saveStep() break case 8:case 46:var $nextFocus=$(block).next(),gotoStart=true if($nextFocus.length==0){$nextFocus=$(block).prev() gotoStart=false} _focusUiBlockOrText($nextFocus,gotoStart) $(block).remove() editor.undo.saveStep() break} ev.preventDefault()}} function _focusUiBlockOrText($block,gotoStart){if(!!$block.length){if(!_handleUiBlockCaretIn($block)){if(gotoStart){editor.selection.setAtStart($block.get(0)) editor.selection.restore()} else{editor.selection.setAtEnd($block.get(0)) editor.selection.restore()}}}} function _onKeydown(ev){_handleUiBlocksKeydown(ev) if(ev.isDefaultPrevented()){return false}} function _onFigureKeydown(ev){if(ev.target&&$(ev.target).attr('data-ui-block')!==undefined){_uiBlockKeyDown(ev,ev.target)} if(ev.isDefaultPrevented()){return false}} function _onSync(html){var $domTree=$('
'+html+'
') $domTree.find('[data-video], [data-audio]').each(function(){$(this).removeAttr('contenteditable data-ui-block tabindex draggable').removeClass('fr-draggable fr-dragging')}) return $domTree.html()} function _init(){editor.events.on('initialized',_initUiBlocks) editor.events.on('html.set',_initUiBlocks) editor.events.on('html.get',_onSync) editor.events.on('keydown',_onKeydown) editor.events.on('destroy',_destroy,true) editor.$el.on('keydown','figure',_onFigureKeydown)} function _destroy(){editor.$el.off('keydown','figure',_onFigureKeydown)} return{_init:_init,insert:insertElement,insertVideo:insertVideo,insertAudio:insertAudio}}})(jQuery);+function($){"use strict";var Base=$.oc.foundation.base,BaseProto=Base.prototype var RichEditor=function(element,options){this.options=options this.$el=$(element) this.$textarea=this.$el.find('>textarea:first') this.$form=this.$el.closest('form') this.editor=null $.oc.foundation.controlUtils.markDisposable(element) Base.call(this) this.init()} RichEditor.prototype=Object.create(BaseProto) RichEditor.prototype.constructor=RichEditor RichEditor.DEFAULTS={linksHandler:null,Handler:null,stylesheet:null,fullpage:false,editorLang:'en',useMediaManager:false,toolbarButtons:null,allowEmptyTags:null,allowTags:null,allowAttributes:null,noWrapTags:null,removeTags:null,lineBreakerTags:null,imageStyles:null,linkStyles:null,paragraphStyles:null,paragraphFormat:null,tableStyles:null,tableCellStyles:null,aceVendorPath:'/',readOnly:false} RichEditor.prototype.init=function(){var self=this;this.$el.one('dispose-control',this.proxy(this.dispose)) if(!this.$textarea.attr('id')){this.$textarea.attr('id','element-'+Math.random().toString(36).substring(7))} this.initFroala()} RichEditor.prototype.initFroala=function(){var froalaOptions={editorClass:'control-richeditor',language:this.options.editorLang,fullPage:this.options.fullpage,pageLinksHandler:this.options.linksHandler,aceEditorVendorPath:this.options.aceVendorPath,toolbarSticky:false} if(this.options.toolbarButtons){froalaOptions.toolbarButtons=this.options.toolbarButtons.split(',')} else{froalaOptions.toolbarButtons=$.oc.richEditorButtons} froalaOptions.imageStyles=this.options.imageStyles?this.options.imageStyles:{'oc-img-rounded':'Rounded','oc-img-bordered':'Bordered'} froalaOptions.linkStyles=this.options.linkStyles?this.options.linkStyles:{'oc-link-green':'Green','oc-link-strong':'Thick'} froalaOptions.paragraphStyles=this.options.paragraphStyles?this.options.paragraphStyles:{'oc-text-gray':'Gray','oc-text-bordered':'Bordered','oc-text-spaced':'Spaced','oc-text-uppercase':'Uppercase'} froalaOptions.tableStyles=this.options.tableStyles?this.options.tableStyles:{'oc-dashed-borders':'Dashed Borders','oc-alternate-rows':'Alternate Rows'} froalaOptions.tableCellStyles=this.options.tableCellStyles?this.options.tableCellStyles:{'oc-cell-highlighted':'Highlighted','oc-cell-thick-border':'Thick'} froalaOptions.toolbarButtonsMD=froalaOptions.toolbarButtons froalaOptions.toolbarButtonsSM=froalaOptions.toolbarButtons froalaOptions.toolbarButtonsXS=froalaOptions.toolbarButtons if(this.options.htmlAllowedEmptyTags){froalaOptions.allowEmptyTags=this.options.htmlAllowedEmptyTags.split(/[\s,]+/)} if(this.options.allowTags){froalaOptions.htmlAllowedTags=this.options.allowTags.split(/[\s,]+/)} froalaOptions.htmlAllowedAttrs=this.options.allowAttributes?this.options.allowAttributes.split(/[\s,]+/):['accept','accept-charset','accesskey','action','align','allowfullscreen','allowtransparency','alt','aria-.*','async','autocomplete','autofocus','autoplay','autosave','background','bgcolor','border','charset','cellpadding','cellspacing','checked','cite','class','color','cols','colspan','content','contenteditable','contextmenu','controls','coords','data','data-.*','datetime','default','defer','dir','dirname','disabled','','draggable','dropzone','enctype','for','form','formaction','frameborder','headers','height','hidden','high','href','hreflang','http-equiv','icon','id','ismap','itemprop','keytype','kind','label','lang','language','list','loop','low','max','maxlength','media','method','min','mozallowfullscreen','multiple','muted','name','novalidate','open','optimum','pattern','ping','placeholder','playsinline','poster','preload','pubdate','radiogroup','readonly','rel','required','reversed','rows','rowspan','sandbox','scope','scoped','scrolling','seamless','selected','shape','size','sizes','span','src','srcdoc','srclang','srcset','start','step','summary','spellcheck','style','tabindex','target','title','type','translate','usemap','value','valign','webkitallowfullscreen','width','wrap'] froalaOptions.htmlDoNotWrapTags=this.options.noWrapTags?this.options.noWrapTags.split(/[\s,]+/):['figure','script','style'] if(this.options.removeTags){froalaOptions.htmlRemoveTags=this.options.removeTags.split(/[\s,]+/)} froalaOptions.lineBreakerTags=this.options.lineBreakerTags?this.options.lineBreakerTags.split(/[\s,]+/):['figure,table,hr,iframe,form,dl'] froalaOptions.shortcutsEnabled=['show','bold','italic','underline','indent','outdent','undo','redo'] froalaOptions.imageURL=froalaOptions.fileURL=window.location froalaOptions.imageParam=froalaOptions.fileParam='file_data' froalaOptions.imageParams=froalaOptions.fileParams={X_OCTOBER_MEDIA_MANAGER_QUICK_:1} var placeholder=this.$textarea.attr('placeholder') froalaOptions.placeholderText=placeholder?placeholder:'' froalaOptions.height=this.$el.hasClass('stretch')?Infinity:$('.height-indicator',this.$el).height() $.FroalaEditor.ICON_TEMPLATES={font_awesome:'',text:'[NAME]',image:'[ALT]'} this.$textarea.on('froalaEditor.initialized',this.proxy(this.build)) this.$textarea.on('froalaEditor.contentChanged',this.proxy(this.onChange)) this.$textarea.on('froalaEditor.keydown',this.proxy(this.onKeydown)) this.$textarea.on('froalaEditor.html.get',this.proxy(this.onSyncContent)) this.$textarea.on('froalaEditor.html.set',this.proxy(this.onSetContent)) this.$form.on('oc.beforeRequest',this.proxy(this.onFormBeforeRequest)) this.$textarea.froalaEditor(froalaOptions) this.editor=this.$textarea.data('froala.editor') if(this.options.readOnly){this.editor.edit.off()} this.$el.on('keydown','.fr-view figure',this.proxy(this.onFigureKeydown))} RichEditor.prototype.dispose=function(){this.unHandlers() this.$textarea.froalaEditor('destroy') this.$el.removeData('oc.richEditor') this.options=null this.$el=null this.$textarea=null this.$form=null this.editor=null BaseProto.dispose.call(this)} RichEditor.prototype.unHandlers=function(){this.$el.off('keydown','.fr-view figure',this.proxy(this.onFigureKeydown)) this.$textarea.off('froalaEditor.initialized',this.proxy(this.build)) this.$textarea.off('froalaEditor.contentChanged',this.proxy(this.onChange)) this.$textarea.off('froalaEditor.keydown',this.proxy(this.onKeydown)) this.$textarea.off('froalaEditor.html.get',this.proxy(this.onSyncContent)) this.$textarea.off('froalaEditor.html.set',this.proxy(this.onSetContent)) this.$form.off('oc.beforeRequest',this.proxy(this.onFormBeforeRequest)) $(window).off('resize',this.proxy(this.updateLayout)) $(window).off('oc.updateUi',this.proxy(this.updateLayout)) this.$el.off('dispose-control',this.proxy(this.dispose))} RichEditor.prototype.build=function(event,editor){this.updateLayout() $(window).on('resize',this.proxy(this.updateLayout)) $(window).on('oc.updateUi',this.proxy(this.updateLayout)) this.$textarea.trigger('init.oc.richeditor',[this])} RichEditor.prototype.isCodeViewActive=function(){return this.editor&&this.editor.codeView&&this.editor.codeView.isActive()} RichEditor.prototype.getElement=function(){return this.$el} RichEditor.prototype.getEditor=function(){return this.editor} RichEditor.prototype.getTextarea=function(){return this.$textarea} RichEditor.prototype.getContent=function(){return this.editor.html.get()} RichEditor.prototype.setContent=function(html){this.editor.html.set(html)} RichEditor.prototype.syncContent=function(){this.editor.events.trigger('contentChanged')} RichEditor.prototype.updateLayout=function(){var $editor=$('.fr-wrapper',this.$el),$codeEditor=$('.fr-code',this.$el),$toolbar=$('.fr-toolbar',this.$el),$box=$('.fr-box',this.$el) if(!$editor.length){return} if(this.$el.hasClass('stretch')&&!$box.hasClass('fr-fullscreen')){var height=$toolbar.outerHeight(true) $editor.css('top',height+1) $codeEditor.css('top',height)} else{$editor.css('top','') $codeEditor.css('top','')}} RichEditor.prototype.insertHtml=function(html){this.editor.html.insert(html) this.editor.selection.restore()} RichEditor.prototype.insertElement=function($el){this.insertHtml($('
').append($el.clone()).remove().html())} RichEditor.prototype.insertUiBlock=function($node){this.$textarea.froalaEditor('figures.insert',$node)} RichEditor.prototype.insertVideo=function(url,title){this.$textarea.froalaEditor('figures.insertVideo',url,title)} RichEditor.prototype.insertAudio=function(url,title){this.$textarea.froalaEditor('figures.insertAudio',url,title)} RichEditor.prototype.onSetContent=function(ev,editor){this.$textarea.trigger('setContent.oc.richeditor',[this])} RichEditor.prototype.onSyncContent=function(ev,editor,html){if(editor.codeBeautifier){html=editor.codeBeautifier.run(html,editor.opts.codeBeautifierOptions)} var container={html:html} this.$textarea.trigger('syncContent.oc.richeditor',[this,container]) return container.html} RichEditor.prototype.onFocus=function(){this.$el.addClass('editor-focus')} RichEditor.prototype.onBlur=function(){this.$el.removeClass('editor-focus')} RichEditor.prototype.onFigureKeydown=function(ev){this.$textarea.trigger('figureKeydown.oc.richeditor',[ev,this])} RichEditor.prototype.onKeydown=function(ev,editor,keyEv){this.$textarea.trigger('keydown.oc.richeditor',[keyEv,this]) if(ev.isDefaultPrevented()){return false}} RichEditor.prototype.onChange=function(ev){this.$form.trigger('change')} RichEditor.prototype.onFormBeforeRequest=function(ev){if(!this.editor){return} if(this.isCodeViewActive()){this.editor.html.set(this.editor.codeView.get())} this.$textarea.val(this.editor.html.get())} var old=$.fn.richEditor $.fn.richEditor=function(option){var args=Array.prototype.slice.call(arguments,1),result this.each(function(){var $this=$(this) var data=$this.data('oc.richEditor') var options=$.extend({},RichEditor.DEFAULTS,$this.data(),typeof option=='object'&&option) if(!data)$this.data('oc.richEditor',(data=new RichEditor(this,options))) if(typeof option=='string')result=data[option].apply(data,args) if(typeof result!='undefined')return false}) return result?result:this} $.fn.richEditor.Constructor=RichEditor $.fn.richEditor.noConflict=function(){$.fn.richEditor=old return this} $(document).render(function(){$('[data-control="richeditor"]').richEditor()}) if($.oc===undefined) $.oc={} $.oc.richEditorButtons=['paragraphFormat','paragraphStyle','quote','bold','italic','align','formatOL','formatUL','insertTable','insertLink','insertImage','insertVideo','insertAudio','insertFile','insertHR','fullscreen','html']}(window.jQuery); /* * Rich text editor form field control (WYSIWYG) * * Data attributes: * - data-control="richeditor" - enables the rich editor plugin * * JavaScript API: * $('textarea').richEditor() * * Dependancies: * - Froala Editor (froala_editor.js) */ +function ($) { "use strict"; var Base = $.oc.foundation.base, BaseProto = Base.prototype // RICHEDITOR CLASS DEFINITION // ============================ var RichEditor = function(element, options) { this.options = options this.$el = $(element) this.$textarea = this.$el.find('>textarea:first') this.$form = this.$el.closest('form') this.editor = null $.oc.foundation.controlUtils.markDisposable(element) Base.call(this) this.init() } RichEditor.prototype = Object.create(BaseProto) RichEditor.prototype.constructor = RichEditor RichEditor.DEFAULTS = { linksHandler: null, stylesheet: null, fullpage: false, editorLang: 'en', toolbarButtons: null, allowEmptyTags: null, allowTags: null, allowAttributes: null, noWrapTags: null, removeTags: null, lineBreakerTags: null, imageStyles: null, linkStyles: null, paragraphStyles: null, tableStyles: null, tableCellStyles: null, aceVendorPath: '/', readOnly: false } RichEditor.prototype.init = function() { var self = this; this.$el.one('dispose-control', this.proxy(this.dispose)) /* * Textarea must have an identifier */ if (!this.$textarea.attr('id')) { this.$textarea.attr('id', 'element-' + Math.random().toString(36).substring(7)) } /* * Initialize Froala editor */ this.initFroala() } RichEditor.prototype.initFroala = function() { var froalaOptions = { editorClass: 'control-richeditor', language: this.options.editorLang, fullPage: this.options.fullpage, pageLinksHandler: this.options.linksHandler, aceEditorVendorPath: this.options.aceVendorPath, toolbarSticky: false } if (this.options.toolbarButtons) { froalaOptions.toolbarButtons = this.options.toolbarButtons.split(',') } else { froalaOptions.toolbarButtons = $.oc.richEditorButtons } froalaOptions.imageStyles = this.options.imageStyles ? this.options.imageStyles : { 'oc-img-rounded': 'Rounded', 'oc-img-bordered': 'Bordered' } froalaOptions.linkStyles = this.options.linkStyles ? this.options.linkStyles : { 'oc-link-green': 'Green', 'oc-link-strong': 'Thick' } froalaOptions.paragraphStyles = this.options.paragraphStyles ? this.options.paragraphStyles : { 'oc-text-gray': 'Gray', 'oc-text-bordered': 'Bordered', 'oc-text-spaced': 'Spaced', 'oc-text-uppercase': 'Uppercase' } froalaOptions.tableStyles = this.options.tableStyles ? this.options.tableStyles : { 'oc-dashed-borders': 'Dashed Borders', 'oc-alternate-rows': 'Alternate Rows' } froalaOptions.tableCellStyles = this.options.tableCellStyles ? this.options.tableCellStyles : { 'oc-cell-highlighted': 'Highlighted', 'oc-cell-thick-border': 'Thick' } froalaOptions.toolbarButtonsMD = froalaOptions.toolbarButtons froalaOptions.toolbarButtonsSM = froalaOptions.toolbarButtons froalaOptions.toolbarButtonsXS = froalaOptions.toolbarButtons if (this.options.htmlAllowedEmptyTags) { froalaOptions.allowEmptyTags = this.options.htmlAllowedEmptyTags.split(/[\s,]+/) } if (this.options.allowTags) { froalaOptions.htmlAllowedTags = this.options.allowTags.split(/[\s,]+/) } froalaOptions.htmlAllowedAttrs = this.options.allowAttributes ? this.options.allowAttributes.split(/[\s,]+/) : ['accept', 'accept-charset', 'accesskey', 'action', 'align', 'allowfullscreen', 'allowtransparency', 'alt', 'aria-.*', 'async', 'autocomplete', 'autofocus', 'autoplay', 'autosave', 'background', 'bgcolor', 'border', 'charset', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'color', 'cols', 'colspan', 'content', 'contenteditable', 'contextmenu', 'controls', 'coords', 'data', 'data-.*', 'datetime', 'default', 'defer', 'dir', 'dirname', 'disabled', '', 'draggable', 'dropzone', 'enctype', 'for', 'form', 'formaction', 'frameborder', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'http-equiv', 'icon', 'id', 'ismap', 'itemprop', 'keytype', 'kind', 'label', 'lang', 'language', 'list', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'mozallowfullscreen', 'multiple', 'muted', 'name', 'novalidate', 'open', 'optimum', 'pattern', 'ping', 'placeholder', 'playsinline', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'reversed', 'rows', 'rowspan', 'sandbox', 'scope', 'scoped', 'scrolling', 'seamless', 'selected', 'shape', 'size', 'sizes', 'span', 'src', 'srcdoc', 'srclang', 'srcset', 'start', 'step', 'summary', 'spellcheck', 'style', 'tabindex', 'target', 'title', 'type', 'translate', 'usemap', 'value', 'valign', 'webkitallowfullscreen', 'width', 'wrap'] froalaOptions.htmlDoNotWrapTags = this.options.noWrapTags ? this.options.noWrapTags.split(/[\s,]+/) : ['figure', 'script', 'style'] if (this.options.removeTags) { froalaOptions.htmlRemoveTags = this.options.removeTags.split(/[\s,]+/) } froalaOptions.lineBreakerTags = this.options.lineBreakerTags ? this.options.lineBreakerTags.split(/[\s,]+/) : ['figure, table, hr, iframe, form, dl'] froalaOptions.shortcutsEnabled = ['show', 'bold', 'italic', 'underline', 'indent', 'outdent', 'undo', 'redo'] // File froalaOptions.imageURL = froalaOptions.fileURL = window.location froalaOptions.imageParam = froalaOptions.fileParam = 'file_data' froalaOptions.imageParams = froalaOptions.fileParams = { X_OCTOBER_MEDIA_MANAGER_QUICK_: 1 } var placeholder = this.$textarea.attr('placeholder') froalaOptions.placeholderText = placeholder ? placeholder : '' froalaOptions.height = this.$el.hasClass('stretch') ? Infinity : $('.height-indicator', this.$el).height() $.FroalaEditor.ICON_TEMPLATES = { font_awesome: '', text: '[NAME]', image: '[ALT]' } this.$textarea.on('froalaEditor.initialized', this.proxy(this.build)) this.$textarea.on('froalaEditor.contentChanged', this.proxy(this.onChange)) this.$textarea.on('froalaEditor.html.get', this.proxy(this.onSyncContent)) this.$textarea.on('froalaEditor.html.set', this.proxy(this.onSetContent)) this.$form.on('oc.beforeRequest', this.proxy(this.onFormBeforeRequest)) this.$textarea.froalaEditor(froalaOptions) this.editor = this.$textarea.data('froala.editor') if (this.options.readOnly) { this.editor.edit.off() } this.$el.on('keydown', '.fr-view figure', this.proxy(this.onFigureKeydown)) } RichEditor.prototype.dispose = function() { this.unHandlers() this.$textarea.froalaEditor('destroy') this.$el.removeData('oc.richEditor') this.options = null this.$el = null this.$textarea = null this.$form = null this.editor = null BaseProto.dispose.call(this) } RichEditor.prototype.unHandlers = function() { this.$el.off('keydown', '.fr-view figure', this.proxy(this.onFigureKeydown)) this.$textarea.off('froalaEditor.initialized', this.proxy(this.build)) this.$textarea.off('froalaEditor.contentChanged', this.proxy(this.onChange)) this.$textarea.off('froalaEditor.html.get', this.proxy(this.onSyncContent)) this.$textarea.off('froalaEditor.html.set', this.proxy(this.onSetContent)) this.$form.off('oc.beforeRequest', this.proxy(this.onFormBeforeRequest)) $(window).off('resize', this.proxy(this.updateLayout)) $(window).off('oc.updateUi', this.proxy(this.updateLayout)) this.$el.off('dispose-control', this.proxy(this.dispose)) } RichEditor.prototype.build = function(event, editor) { this.updateLayout() $(window).on('resize', this.proxy(this.updateLayout)) $(window).on('oc.updateUi', this.proxy(this.updateLayout)) // Bind the keydown listener here to ensure it gets handled before the Froala handlers editor.events.on('keydown', this.proxy(this.onKeydown), true) this.$textarea.trigger('init.oc.richeditor', [this]) } RichEditor.prototype.isCodeViewActive = function() { return this.editor && this.editor.codeView && this.editor.codeView.isActive() } RichEditor.prototype.getElement = function() { return this.$el } RichEditor.prototype.getEditor = function() { return this.editor } RichEditor.prototype.getTextarea = function() { return this.$textarea } RichEditor.prototype.getContent = function() { return this.editor.html.get() } RichEditor.prototype.setContent = function(html) { this.editor.html.set(html) } RichEditor.prototype.syncContent = function() { this.editor.events.trigger('contentChanged') } RichEditor.prototype.updateLayout = function() { var $editor = $('.fr-wrapper', this.$el), $codeEditor = $('.fr-code', this.$el), $toolbar = $('.fr-toolbar', this.$el), $box = $('.fr-box', this.$el) if (!$editor.length) { return } if (this.$el.hasClass('stretch') && !$box.hasClass('fr-fullscreen')) { var height = $toolbar.outerHeight(true) $editor.css('top', height+1) $codeEditor.css('top', height) } else { $editor.css('top', '') $codeEditor.css('top', '') } } RichEditor.prototype.insertHtml = function(html) { this.editor.html.insert(html) this.editor.selection.restore() } RichEditor.prototype.insertElement = function($el) { this.insertHtml($('
').append($el.clone()).remove().html()) } /* * Inserts non-editable block (used for snippets, audio and video) */ RichEditor.prototype.insertUiBlock = function($node) { this.$textarea.froalaEditor('figures.insert', $node) } RichEditor.prototype.insertVideo = function(url, title) { this.$textarea.froalaEditor('figures.insertVideo', url, title) } RichEditor.prototype.insertAudio = function(url, title) { this.$textarea.froalaEditor('figures.insertAudio', url, title) } // EVENT HANDLERS // ============================ RichEditor.prototype.onSetContent = function(ev, editor) { this.$textarea.trigger('setContent.oc.richeditor', [this]) } RichEditor.prototype.onSyncContent = function(ev, editor, html) { // Beautify HTML. if (editor.codeBeautifier) { html = editor.codeBeautifier.run(html, editor.opts.codeBeautifierOptions) } var container = { html: html } this.$textarea.trigger('syncContent.oc.richeditor', [this, container]) return container.html } RichEditor.prototype.onFocus = function() { this.$el.addClass('editor-focus') } RichEditor.prototype.onBlur = function() { this.$el.removeClass('editor-focus') } RichEditor.prototype.onFigureKeydown = function(ev) { this.$textarea.trigger('figureKeydown.oc.richeditor', [ev, this]) } RichEditor.prototype.onKeydown = function(ev, editor, keyEv) { this.$textarea.trigger('keydown.oc.richeditor', [keyEv, this]) if (ev.isDefaultPrevented()) { return false } } RichEditor.prototype.onChange = function(ev) { this.$form.trigger('change') } /* * Instantly synchronizes HTML content. * The onSyncContent() method (above) is involved into this call, * so the resulting HTML is (optionally) beautified. */ RichEditor.prototype.onFormBeforeRequest = function(ev) { if (!this.editor) { return } if (this.isCodeViewActive()) { this.editor.html.set(this.editor.codeView.get()) } this.$textarea.val(this.editor.html.get()) } // RICHEDITOR PLUGIN DEFINITION // ============================ var old = $.fn.richEditor $.fn.richEditor = function (option) { var args = Array.prototype.slice.call(arguments, 1), result this.each(function () { var $this = $(this) var data = $this.data('oc.richEditor') var options = $.extend({}, RichEditor.DEFAULTS, $this.data(), typeof option == 'object' && option) if (!data) $this.data('oc.richEditor', (data = new RichEditor(this, options))) if (typeof option == 'string') result = data[option].apply(data, args) if (typeof result != 'undefined') return false }) return result ? result : this } $.fn.richEditor.Constructor = RichEditor // RICHEDITOR NO CONFLICT // ================= $.fn.richEditor.noConflict = function() { $.fn.richEditor = old return this } // RICHEDITOR DATA-API // =============== $(document).render(function() { $('[data-control="richeditor"]').richEditor() }) // BUTTON DEFINITIONS // ================= if ($.oc === undefined) $.oc = {} $.oc.richEditorButtons = [ 'paragraphFormat', 'paragraphStyle', 'quote', 'bold', 'italic', 'align', 'formatOL', 'formatUL', 'insertTable', 'insertLink', 'insertImage', 'insertVideo', 'insertAudio', 'insertFile', 'insertHR', 'fullscreen', 'html' ] }(window.jQuery);