app/assets/javascripts/plugins/video.min.js in wysiwyg-rails-1.2.8 vs app/assets/javascripts/plugins/video.min.js in wysiwyg-rails-2.0.0.pre.rc.3

- old
+ new

@@ -1,6 +1,6 @@ /*! - * froala_editor v1.2.8 (https://www.froala.com/wysiwyg-editor) - * License https://www.froala.com/wysiwyg-editor/terms + * froala_editor v2.0.0-rc.3 (https://www.froala.com/wysiwyg-editor/v2.0) + * License http://editor.froala.com/license * Copyright 2014-2015 Froala Labs */ -!function(a){a.Editable.DEFAULTS=a.extend(a.Editable.DEFAULTS,{videoAllowedAttrs:["src","width","height","frameborder","allowfullscreen","webkitallowfullscreen","mozallowfullscreen","href","target","id","controls","value","name"],videoAllowedTags:["iframe","object","param","video","source","embed"],defaultVideoAlignment:"center",textNearVideo:!0}),a.Editable.VIDEO_PROVIDERS=[{test_regex:/^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/,url_regex:/(?:https?:\/\/)?(?:www\.)?(?:m\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=|embed\/)?(.+)/g,url_text:"//www.youtube.com/embed/$1",html:'<iframe width="640" height="360" src="{url}" frameborder="0" allowfullscreen></iframe>'},{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:'<iframe width="640" height="360" src="{url}" frameborder="0" allowfullscreen></iframe>'},{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:'<iframe width="640" height="360" src="{url}" frameborder="0" allowfullscreen></iframe>'},{test_regex:/^.+(screen.yahoo.com)\/(videos-for-you|popular)?\/[^_&]+/,url_regex:"",url_text:"",html:'<iframe width="640" height="360" src="{url}?format=embed" frameborder="0" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true" allowtransparency="true"></iframe>'}],a.Editable.video_commands={floatVideoLeft:{title:"Float Left",icon:{type:"font",value:"fa fa-align-left"}},floatVideoNone:{title:"Float None",icon:{type:"font",value:"fa fa-align-justify"}},floatVideoRight:{title:"Float Right",icon:{type:"font",value:"fa fa-align-right"}},removeVideo:{title:"Remove Video",icon:{type:"font",value:"fa fa-trash-o"}}},a.Editable.DEFAULTS=a.extend(a.Editable.DEFAULTS,{videoButtons:["floatVideoLeft","floatVideoNone","floatVideoRight","removeVideo"]}),a.Editable.commands=a.extend(a.Editable.commands,{insertVideo:{title:"Insert Video",icon:"fa fa-video-camera",callback:function(){this.insertVideo()},undo:!1}}),a.Editable.prototype.insertVideo=function(){this.options.inlineMode||(this.closeImageMode(),this.imageMode=!1,this.positionPopup("insertVideo")),this.selectionInEditor()&&this.saveSelection(),this.showInsertVideo(),this.$video_wrapper.find("textarea").val("")},a.Editable.prototype.insertVideoHTML=function(){var a='<div class="froala-popup froala-video-popup" style="display: none;"><h4><span data-text="true">Insert Video</span><i title="Cancel" class="fa fa-times" id="f-video-close-'+this._id+'"></i></h4><div class="f-popup-line"><textarea placeholder="Embedded code" id="f-video-textarea-'+this._id+'"></textarea></div><p class="or"><span data-text="true">or</span></p><div class="f-popup-line"><input type="text" placeholder="http://youtube.com/" id="f-video-input-'+this._id+'"/><button data-text="true" class="f-ok f-submit fr-p-bttn" id="f-video-ok-'+this._id+'">OK</button></div></div>';return a},a.Editable.prototype.buildInsertVideo=function(){this.$video_wrapper=a(this.insertVideoHTML()),this.$popup_editor.append(this.$video_wrapper),this.addListener("hidePopups",this.hideVideoWrapper),this.$video_wrapper.on("mouseup touchend",a.proxy(function(a){this.isResizing()||a.stopPropagation()},this)),this.$video_wrapper.on("mouseup keydown","input#f-video-input-"+this._id+", textarea#f-video-textarea-"+this._id,a.proxy(function(a){a.stopPropagation()},this));var b=this;this.$video_wrapper.on("change","input#f-video-input-"+this._id+", textarea#f-video-textarea-"+this._id,function(){"INPUT"==this.tagName?b.$video_wrapper.find("textarea#f-video-textarea-"+b._id).val(""):"TEXTAREA"==this.tagName&&b.$video_wrapper.find("input#f-video-input-"+b._id).val("")}),this.$video_wrapper.on("click","button#f-video-ok-"+this._id,a.proxy(function(){var a=this.$video_wrapper.find("input#f-video-input-"+this._id),b=this.$video_wrapper.find("textarea#f-video-textarea-"+this._id);""!==a.val()?this.writeVideo(a.val(),!1):""!==b.val()&&this.writeVideo(b.val(),!0)},this)),this.$video_wrapper.on(this.mouseup,"i#f-video-close-"+this._id,a.proxy(function(){this.$bttn_wrapper.show(),this.hideVideoWrapper(),this.options.inlineMode&&!this.imageMode&&0===this.options.buttons.length&&this.hide(),this.restoreSelection(),this.focus(),this.options.inlineMode||this.hide()},this)),this.$video_wrapper.on("click",function(a){a.stopPropagation()}),this.$video_wrapper.on("click","*",function(a){a.stopPropagation()}),this.$window.on("keydown."+this._id,a.proxy(function(b){if(this.$element.find(".f-video-editor.active").length>0){var c=b.which;if(46==c||8==c)return b.stopPropagation(),b.preventDefault(),setTimeout(a.proxy(function(){this.removeVideo()},this),0),!1}},this))},a.Editable.prototype.destroyVideo=function(){this.$video_wrapper.html("").removeData().remove()},a.Editable.prototype.initVideo=function(){this.buildInsertVideo(),this.addVideoControls(),this.addListener("destroy",this.destroyVideo)},a.Editable.initializers.push(a.Editable.prototype.initVideo),a.Editable.prototype.hideVideoEditorPopup=function(){this.$video_editor&&(this.$video_editor.hide(),a("span.f-video-editor").removeClass("active"),this.$element.removeClass("f-non-selectable"),this.editableDisabled||this.isHTML||this.$element.attr("contenteditable",!0))},a.Editable.prototype.showVideoEditorPopup=function(){this.hidePopups(),this.$video_editor&&this.$video_editor.show(),this.$element.removeAttr("contenteditable")},a.Editable.prototype.addVideoControlsHTML=function(){this.$video_editor=a('<div class="froala-popup froala-video-editor-popup" style="display: none">');for(var b=a('<div class="f-popup-line">').appendTo(this.$video_editor),c=0;c<this.options.videoButtons.length;c++){var d=this.options.videoButtons[c];if(void 0!==a.Editable.video_commands[d]){var e=a.Editable.video_commands[d],f='<button class="fr-bttn" data-callback="'+d+'" data-cmd="'+d+'" title="'+e.title+'">';f+=void 0!==this.options.icons[d]?this.prepareIcon(this.options.icons[d],e.title):this.prepareIcon(e.icon,e.title),f+="</button>",b.append(f)}}this.addListener("hidePopups",this.hideVideoEditorPopup),this.$popup_editor.append(this.$video_editor),this.bindCommandEvents(this.$video_editor)},a.Editable.prototype.floatVideoLeft=function(){a("span.f-video-editor.active").attr("class","f-video-editor active fr-fvl"),this.triggerEvent("videoFloatedLeft"),a("span.f-video-editor.active").click()},a.Editable.prototype.floatVideoRight=function(){a("span.f-video-editor.active").attr("class","f-video-editor active fr-fvr"),this.triggerEvent("videoFloatedRight"),a("span.f-video-editor.active").click()},a.Editable.prototype.floatVideoNone=function(){a("span.f-video-editor.active").attr("class","f-video-editor active fr-fvn"),this.triggerEvent("videoFloatedNone"),a("span.f-video-editor.active").click()},a.Editable.prototype.removeVideo=function(){a("span.f-video-editor.active").remove(),this.hide(),this.triggerEvent("videoRemoved"),this.focus()},a.Editable.prototype.refreshVideo=function(){this.$element.find("iframe, object").each(function(b,c){for(var d=a(c),e=0;e<a.Editable.VIDEO_PROVIDERS.length;e++){var f=a.Editable.VIDEO_PROVIDERS[e];if(f.test_regex.test(d.attr("src"))){0===d.parents(".f-video-editor").length&&d.wrap('<span class="f-video-editor fr-fvn" data-fr-verified="true" contenteditable="false">');break}}}),this.browser.msie&&this.$element.find(".f-video-editor").each(function(){this.oncontrolselect=function(){return!1}}),this.options.textNearVideo||this.$element.find(".f-video-editor").attr("contenteditable",!1).addClass("fr-tnv")},a.Editable.prototype.addVideoControls=function(){this.addVideoControlsHTML(),this.addListener("sync",this.refreshVideo),this.$element.on("mousedown","span.f-video-editor",a.proxy(function(a){a.stopPropagation()},this)),this.$element.on("click touchend","span.f-video-editor",a.proxy(function(b){if(this.isDisabled)return!1;b.preventDefault(),b.stopPropagation();var c=b.currentTarget;this.clearSelection(),this.showVideoEditorPopup(),this.showByCoordinates(a(c).offset().left+a(c).width()/2,a(c).offset().top+a(c).height()+3),a(c).addClass("active"),this.refreshVideoButtons(c)},this))},a.Editable.prototype.refreshVideoButtons=function(b){var c=a(b).attr("class");this.$video_editor.find("[data-cmd]").removeClass("active"),c.indexOf("fr-fvl")>=0?this.$video_editor.find('[data-cmd="floatVideoLeft"]').addClass("active"):c.indexOf("fr-fvr")>=0?this.$video_editor.find('[data-cmd="floatVideoRight"]').addClass("active"):this.$video_editor.find('[data-cmd="floatVideoNone"]').addClass("active")},a.Editable.prototype.writeVideo=function(b,c){var d=null;if(c)d=this.clean(b,!0,!1,this.options.videoAllowedTags,this.options.videoAllowedAttrs);else for(var e=0;e<a.Editable.VIDEO_PROVIDERS.length;e++){var f=a.Editable.VIDEO_PROVIDERS[e];if(f.test_regex.test(b)){b=b.replace(f.url_regex,f.url_text),d=f.html.replace(/\{url\}/,b);break}}if(d){this.restoreSelection(),this.$element.focus();var g="fr-fvn";"left"==this.options.defaultVideoAlignment&&(g="fr-fvl"),"right"==this.options.defaultVideoAlignment&&(g="fr-fvr"),this.textNearVideo||(g+=" fr-tnv");try{this.insertHTML('<span contenteditable="false" class="f-video-editor '+g+'" data-fr-verified="true">'+d+"</span>")}catch(h){}this.$bttn_wrapper.show(),this.hideVideoWrapper(),this.hide(),this.triggerEvent("videoInserted",[d])}else this.triggerEvent("videoError")},a.Editable.prototype.showVideoWrapper=function(){this.$video_wrapper&&(this.$video_wrapper.show(),this.$video_wrapper.find(".f-popup-line input").val(""))},a.Editable.prototype.hideVideoWrapper=function(){this.$video_wrapper&&(this.$video_wrapper.hide(),this.$video_wrapper.find("input").blur())},a.Editable.prototype.showInsertVideo=function(){this.hidePopups(),this.showVideoWrapper()}}(jQuery); +!function(a){"use strict";a.extend(a.FroalaEditor.POPUP_TEMPLATES,{"video.insert":"[_BUTTONS_][_BY_URL_LAYER_][_EMBED_LAYER_]","video.edit":"[_BUTTONS_]","video.size":"[_BUTTONS_][_SIZE_LAYER_]"}),a.extend(a.FroalaEditor.DEFAULTS,{videoInsertButtons:["videoBack","|","videoByURL","videoEmbed"],videoEditButtons:["videoDisplay","videoAlign","videoSize","videoRemove"],videoResize:!0,videoSizeButtons:["videoBack","|"],videoTextNear:!0,videoDefaultAlign:"center",videoDefaultDisplay:"block",videoIframeStyle:'.fr-video{text-align:center;position:relative}.fr-video:after{position:absolute;content:"";z-index:1;top:0;left:0;right:0;bottom:0;cursor:pointer}.fr-video.fr-active>*{z-index:2;position:relative}.fr-video.fr-dvb{display:block;clear:both}.fr-video.fr-dvb.fr-fvl{text-align:left}.fr-video.fr-dvb.fr-fvr{text-align:right}.fr-video.fr-dvi{display:inline-block}.fr-video.fr-dvi.fr-fvl{float:left}.fr-video.fr-dvi.fr-fvr{float:right}'}),a.FroalaEditor.VIDEO_PROVIDERS=[{test_regex:/^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/,url_regex:/(?:https?:\/\/)?(?:www\.)?(?:m\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=|embed\/)?([0-9a-zA-Z_\-]+)(.+)?/g,url_text:"//www.youtube.com/embed/$1",html:'<iframe width="640" height="360" src="{url}" frameborder="0" allowfullscreen></iframe>'},{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:'<iframe width="640" height="360" src="{url}" frameborder="0" allowfullscreen></iframe>'},{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:'<iframe width="640" height="360" src="{url}" frameborder="0" allowfullscreen></iframe>'},{test_regex:/^.+(screen.yahoo.com)\/(videos-for-you|popular)?\/[^_&]+/,url_regex:"",url_text:"",html:'<iframe width="640" height="360" src="{url}?format=embed" frameborder="0" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true" allowtransparency="true"></iframe>'}],a.FroalaEditor.PLUGINS.video=function(b){function c(){var a=b.popups.get("video.insert"),c=a.find(".fr-video-by-url-layer input");c.val("").trigger("change");var d=a.find(".fr-video-embed-layer textarea");d.val("").trigger("change")}function d(){var a=b.$tb.find('.fr-command[data-cmd="insertVideo"]'),c=b.popups.get("video.insert");if(c||(c=f()),!c.hasClass("fr-active")){b.popups.refresh("video.insert"),b.popups.setContainer("video.insert",b.$tb),b.core.hasFocus()&&b.selection.save();var d=a.offset().left+a.outerWidth()/2,e=a.offset().top+(b.opts.toolbarBottom?10:a.outerHeight()-10);b.popups.show("video.insert",d,e,a.outerHeight())}}function e(){var c=b.popups.get("video.edit");c||(c=y()),b.popups.setContainer("video.edit",a(b.opts.scrollableContainer)),b.popups.refresh("video.edit");var d=U.find("iframe, embed, video"),e=d.offset().left+d.outerWidth()/2,f=d.offset().top+d.outerHeight();b.popups.show("video.edit",e,f,d.outerHeight())}function f(){var a="";b.opts.videoInsertButtons.length>1&&(a='<div class="fr-buttons">'+b.button.buildList(b.opts.videoInsertButtons)+"</div>");var d="";b.opts.videoInsertButtons.indexOf("videoByURL")>=0&&(d='<div class="fr-video-by-url-layer fr-layer fr-active" id="fr-video-by-url-layer-'+b.id+'"><div class="fr-input-line"><input type="text" placeholder="http://" tabIndex="1"></div><div class="fr-action-buttons"><button type="button" class="fr-command fr-submit" data-cmd="videoInsertByURL" tabIndex="2">'+b.language.translate("Insert")+"</button></div></div>");var e="";b.opts.videoInsertButtons.indexOf("videoEmbed")>=0&&(e='<div class="fr-video-embed-layer fr-layer" id="fr-video-embed-layer-'+b.id+'"><div class="fr-input-line"><textarea type="text" placeholder="'+b.language.translate("Embedded Code")+'" tabIndex="1" rows="5"></textarea></div><div class="fr-action-buttons"><button type="button" class="fr-command fr-submit" data-cmd="videoInsertEmbed" tabIndex="2">'+b.language.translate("Insert")+"</button></div></div>");var f={buttons:a,by_url_layer:d,embed_layer:e},g=b.popups.create("video.insert",f);return b.popups.onRefresh("video.insert",c),b.popups.onHide("video.insert",j),g}function g(a){var c,d,e=b.popups.get("video.insert");if(!U&&!b.opts.toolbarInline){var f=b.$tb.find('.fr-command[data-cmd="insertVideo"]');c=f.offset().left+f.outerWidth()/2,d=f.offset().top+(b.opts.toolbarBottom?10:f.outerHeight()-10)}b.opts.toolbarInline&&(d=e.offset().top-b.helpers.getPX(e.css("margin-top")),e.hasClass("fr-above")&&(d+=e.outerHeight())),e.find(".fr-layer").removeClass("fr-active"),e.find(".fr-"+a+"-layer").addClass("fr-active"),b.popups.show("video.insert",c,d,0)}function h(a){var c=b.popups.get("video.insert");c.find(".fr-video-by-url-layer").hasClass("fr-active")&&a.addClass("fr-active")}function i(a){var c=b.popups.get("video.insert");c.find(".fr-video-embed-layer").hasClass("fr-active")&&a.addClass("fr-active")}function j(){!U&&b.$el.find(".fr-marker").length&&(b.events.focus(),b.selection.restore())}function k(a){b.events.focus(!0),b.selection.restore(),b.html.insert('<span class="fr-jiv fr-video fr-dv'+b.opts.videoDefaultDisplay[0]+("center"!=b.opts.videoDefaultAlign?" fr-fv"+b.opts.videoDefaultAlign[0]:"")+'">'+a+"<span>"),b.popups.hide("video.insert");var c=b.$el.find(".fr-jiv");c.removeClass("fr-jiv"),b.events.trigger("video.inserted",[c])}function l(c){if("undefined"==typeof c){var d=b.popups.get("video.insert");c=d.find('.fr-video-by-url-layer input[type="text"]').val()||""}for(var e=null,f=0;f<a.FroalaEditor.VIDEO_PROVIDERS.length;f++){var g=a.FroalaEditor.VIDEO_PROVIDERS[f];if(g.test_regex.test(c)){e=c.replace(g.url_regex,g.url_text),e=g.html.replace(/\{url\}/,e);break}}e?k(e):b.events.trigger("video.linkError",[c])}function m(a){if("undefined"==typeof a){var c=b.popups.get("video.insert");a=c.find(".fr-video-embed-layer textarea").val()||""}0===a.length?b.events.trigger("video.codeError",[a]):k(a)}function n(c){c.preventDefault(),c.stopPropagation();var d=c.pageX||(c.originalEvent.touches?c.originalEvent.touches[0].pageX:null),e=c.pageY||(c.originalEvent.touches?c.originalEvent.touches[0].pageY:null);return d&&e?(S=a(this),S.data("start-x",d),S.data("start-y",e),R.show(),void b.popups.hideAll()):!1}function o(a){if(S){a.preventDefault();var b=a.pageX||(a.originalEvent.touches?a.originalEvent.touches[0].pageX:null),c=a.pageY||(a.originalEvent.touches?a.originalEvent.touches[0].pageY:null);if(!b||!c)return!1;var d=S.data("start-x"),e=S.data("start-y");S.data("start-x",b),S.data("start-y",c);var f=b-d,g=c-e,h=U.find("iframe, embed, video"),i=h.width(),j=h.height();(S.hasClass("fr-hnw")||S.hasClass("fr-hsw"))&&(f=0-f),(S.hasClass("fr-hnw")||S.hasClass("fr-hne"))&&(g=0-g),h.css("width",i+f),h.css("height",j+g),h.removeAttr("width"),h.removeAttr("height"),s()}}function p(a){S&&(a&&a.preventDefault(),S=null,R.hide(),s(),e())}function q(a){return'<div class="fr-handler fr-h'+a+'"></div>'}function r(){if(T=a('<div class="fr-video-resizer"></div>'),b.$wp.append(T),a(b.original_window).on("resize.video"+b.id,u),b.events.on("destroy",function(){T.html("").removeData().remove(),a(b.original_window).off("resize.video"+b.id)},!0),b.opts.videoResize){T.append(q("nw")+q("ne")+q("sw")+q("se"));var c=T.get(0).ownerDocument;T.on(b._mousedown+".vidresize"+b.id,".fr-handler",n),a(c).on(b._mousemove+".vidresize"+b.id,o),a(c.defaultView||c.parentWindow).on(b._mouseup+".vidresize"+b.id,p),R=a('<div class="fr-video-overlay"></div>'),a(c).find("body").append(R),R.on("mouseleave",p),b.events.on("destroy",function(){T.off(b._mousedown+".vidresize"+b.id),a(c).off(b._mousemove+".vidresize"+b.id),a(c.defaultView||c.parentWindow).off(b._mouseup+".vidresize"+b.id),R.off("mouseleave").remove()},!0)}}function s(){T||r();var a=U.find("iframe, embed, video");T.css("top",(b.opts.iframe?a.offset().top-1:a.offset().top-b.$wp.offset().top-1)+b.$wp.scrollTop()).css("left",(b.opts.iframe?a.offset().left-1:a.offset().left-b.$wp.offset().left-1)+b.$wp.scrollLeft()).css("width",a.outerWidth()).css("height",a.height()).addClass("fr-active")}function t(c){return c.preventDefault(),c.stopPropagation(),b.edit.isDisabled()?!1:(c.stopPropagation(),b.toolbar.disable(),b.helpers.isMobile()&&(b.events.disableBlur(),b.$el.blur(),b.events.enableBlur()),U=a(this),a(this).addClass("fr-active"),b.opts.iframe&&b.height.syncIframe(),s(),e(),b.selection.clear(),b.button.bulkRefresh(),void b.events.trigger("image.hideResizer"))}function u(a){a===!0&&(V=!0),U&&V&&(T.removeClass("fr-active"),b.toolbar.enable(),U.removeClass("fr-active"),U=null),V=!1}function v(){V=!0}function w(){V=!1}function x(){b.events.on("mousedown",v),b.events.on("window.mousedown",v),b.events.on("window.touchmove",w),b.events.on("mouseup",u),b.events.on("window.mouseup",u),b.events.on("commands.mousedown",function(a){a.parents(".fr-toolbar").length>0&&u()}),b.events.on("video.hideResizer",u)}function y(){var a="";b.opts.videoEditButtons.length>1&&(a+='<div class="fr-buttons">',a+=b.button.buildList(b.opts.videoEditButtons),a+="</div>");var c={buttons:a},d=b.popups.create("video.edit",c);return b.$wp.on("scroll.video-edit",function(){U&&b.popups.isVisible("video.edit")&&e()}),b.events.on("destroy",function(){b.$wp.off("scroll.video-edit")}),d}function z(){if(U){var a=b.popups.get("video.size"),c=U.find("iframe, embed, video");a.find('input[name="width"]').val(c.get(0).style.width||c.attr("width")).trigger("change"),a.find('input[name="height"]').val(c.get(0).style.height||c.attr("height")).trigger("change")}}function A(){var c=b.popups.get("video.size");c||(c=B()),b.popups.refresh("video.size"),b.popups.setContainer("video.size",a(b.opts.scrollableContainer));var d=U.find("iframe, embed, video"),e=d.offset().left+d.width()/2,f=d.offset().top+d.height();b.popups.show("video.size",e,f,d.height())}function B(){var a="";a='<div class="fr-buttons">'+b.button.buildList(b.opts.videoSizeButtons)+"</div>";var c="";c='<div class="fr-video-size-layer fr-layer fr-active" id="fr-video-size-layer-'+b.id+'"><div class="fr-video-group"><div class="fr-input-line"><input type="text" name="width" placeholder="'+b.language.translate("Width")+'" tabIndex="1"></div><div class="fr-input-line"><input type="text" name="height" placeholder="'+b.language.translate("Height")+'" tabIndex="1"></div></div><div class="fr-action-buttons"><button type="button" class="fr-command fr-submit" data-cmd="videoSetSize" tabIndex="2">'+b.language.translate("Update")+"</button></div></div>";var d={buttons:a,size_layer:c},e=b.popups.create("video.size",d);return b.popups.onRefresh("video.size",z),b.$wp.on("scroll.video-size",function(){U&&b.popups.isVisible("video.size")&&A()}),b.events.on("destroy",function(){b.$wp.off("scroll.video-size")}),e}function C(a){U.removeClass("fr-fvr fr-fvl"),"left"==a?U.addClass("fr-fvl"):"right"==a&&U.addClass("fr-fvr"),s(),e()}function D(a){U.hasClass("fr-fvl")?a.find("> i").attr("class","fa fa-align-left"):U.hasClass("fr-fvr")?a.find("> i").attr("class","fa fa-align-right"):a.find("> i").attr("class","fa fa-align-justify")}function E(a,b){var c="justify";U.hasClass("fr-fvl")?c="left":U.hasClass("fr-fvr")&&(c="right"),b.find('.fr-command[data-param1="'+c+'"]').addClass("fr-active")}function F(a){U.removeClass("fr-dvi fr-dvb"),"inline"==a?U.addClass("fr-dvi"):"block"==a&&U.addClass("fr-dvb"),s(),e()}function G(a,b){var c="block";U.hasClass("fr-dvi")&&(c="inline"),b.find('.fr-command[data-param1="'+c+'"]').addClass("fr-active")}function H(){if(U&&b.events.trigger("video.beforeRemove",[U])!==!1){var a=U;b.popups.hideAll(),u(!0),b.selection.setBefore(a.get(0))||b.selection.setAfter(a.get(0)),a.remove(),b.selection.restore(),b.html.fillEmptyBlocks(!0),b.events.trigger("video.removed",[a])}}function I(a){if(!a.hasClass("fr-dvi")&&!a.hasClass("fr-dvb")){var c=a.css("float");a.css("float","none"),"block"==a.css("display")?(a.css("float",c),0===parseInt(a.css("margin-left"),10)&&(a.attr("style")||"").indexOf("margin-right: auto")>=0?a.addClass("fr-fvl"):0===parseInt(a.css("margin-right"),10)&&(a.attr("style")||"").indexOf("margin-left: auto")>=0&&a.addClass("fr-fvr"),a.addClass("fr-dvb")):(a.css("float",c),"left"==a.css("float")?a.addClass("fr-fvl"):"right"==a.css("float")&&a.addClass("fr-fvr"),a.addClass("fr-dvi")),a.css("margin",""),a.css("float",""),a.css("display",""),a.css("z-index",""),a.css("position",""),a.css("overflow",""),a.css("vertical-align","")}b.opts.videoTextNear||a.removeClass("fr-dvi").addClass("fr-dvb")}function J(b){var c={"z-index":1,position:"relative",overflow:"auto"};b.hasClass("fr-dvb")?(a.extend(c,{"vertical-align":"top",display:"block"}),b.hasClass("fr-fvr")?a.extend(c,{"float":"none","margin-right":"0","margin-left":"auto"}):b.hasClass("fr-fvl")?a.extend(c,{"float":"none","margin-left":"0","margin-right":"auto"}):a.extend(c,{"float":"none",margin:"auto"})):(a.extend(c,{display:"inline-block"}),b.hasClass("fr-fvr")?a.extend(c,{"float":"right"}):b.hasClass("fr-fvl")?a.extend(c,{"float":"left"}):a.extend(c,{"float":"none"})),b.removeClass("fr-dvb fr-dvi fr-fvr fr-fvl fr-fvn"),""===b.attr("class")&&b.removeAttr("class"),b.css(c)}function K(){b.$el.find("video").filter(function(){return 0===a(this).parents("span.fr-video").length}).wrap('<span class="fr-video"></span>'),b.$el.find("embed, iframe").filter(function(){if(a(this).parents("span.fr-video").length>0)return!1;for(var b=a(this).attr("src"),c=0;c<a.FroalaEditor.VIDEO_PROVIDERS.length;c++){var d=a.FroalaEditor.VIDEO_PROVIDERS[c];if(d.test_regex.test(b))return!0}return!1}).map(function(){return 0===a(this).parents("object").length?this:a(this).parents("object").get(0)}).wrap('<span class="fr-video"></span>');for(var c=b.$el.find("span.fr-video"),d=0;d<c.length;d++)I(a(c[d]))}function L(){b.$el.find("span.fr-video").each(function(){J(a(this))})}function M(){b.$el.find("span.fr-video").each(function(){I(a(this))})}function N(){x(),b.events.on("html.set",K),K(),b.opts.useClasses||(b.events.on("html.beforeGet",L),b.events.on("html.afterGet",M)),b.opts.iframe&&(b.events.on("html.set",function(){b.core.injectStyle(b.opts.videoIframeStyle)}),b.core.injectStyle(b.opts.videoIframeStyle)),b.$el.on("mousedown","span.fr-video",function(a){a.stopPropagation()}),b.$el.on("click touchstart","span.fr-video",t),b.events.on("keydown",function(c){var d=c.which;return!U||d!=a.FroalaEditor.KEYCODE.BACKSPACE&&d!=a.FroalaEditor.KEYCODE.DELETE?U&&d==a.FroalaEditor.KEYCODE.ESC?(u(!0),c.preventDefault(),!1):U&&!b.keys.ctrlKey(c)?(c.preventDefault(),!1):void 0:(c.preventDefault(),H(),!1)},!0),b.events.on("keydown",function(){b.$el.find("span.fr-video:empty").remove()})}function O(){U?U.trigger("click"):(b.popups.hide("video.insert"),b.toolbar.showInline())}function P(a,c){if(U){var d=b.popups.get("video.size"),e=U.find("iframe, embed, video");e.css("width",a||d.find('input[name="width"]').val()),e.css("height",c||d.find('input[name="height"]').val()),e.get(0).style.width&&e.removeAttr("width"),e.get(0).style.height&&e.removeAttr("height"),d.find("input").blur(),setTimeout(function(){U.trigger("click")},b.helpers.isAndroid()?50:0)}}function Q(){return U}var R,S,T,U,V=!1;return{_init:N,showInsertPopup:d,showLayer:g,refreshByURLButton:h,refreshEmbedButton:i,insertByURL:l,insertEmbed:m,insert:k,align:C,refreshAlign:D,refreshAlignOnShow:E,display:F,refreshDisplayOnShow:G,remove:H,showSizePopup:A,back:O,setSize:P,get:Q}},a.FroalaEditor.RegisterCommand("insertVideo",{title:"Insert Video",undo:!1,focus:!1,refreshAfterCallback:!1,popup:!0,callback:function(){this.popups.isVisible("video.insert")?this.popups.hide("video.insert"):this.video.showInsertPopup()}}),a.FroalaEditor.DefineIcon("insertVideo",{NAME:"video-camera"}),a.FroalaEditor.DefineIcon("videoByURL",{NAME:"link"}),a.FroalaEditor.RegisterCommand("videoByURL",{title:"By URL",undo:!1,focus:!1,callback:function(){this.video.showLayer("video-by-url")},refresh:function(a){this.video.refreshByURLButton(a)}}),a.FroalaEditor.DefineIcon("videoEmbed",{NAME:"code"}),a.FroalaEditor.RegisterCommand("videoEmbed",{title:"Embedded Code",undo:!1,focus:!1,callback:function(){this.video.showLayer("video-embed")},refresh:function(a){this.video.refreshEmbedButton(a)}}),a.FroalaEditor.RegisterCommand("videoInsertByURL",{undo:!0,focus:!0,callback:function(){this.video.insertByURL()}}),a.FroalaEditor.RegisterCommand("videoInsertEmbed",{undo:!0,focus:!0,callback:function(){this.video.insertEmbed()}}),a.FroalaEditor.DefineIcon("videoDisplay",{NAME:"star"}),a.FroalaEditor.RegisterCommand("videoDisplay",{title:"Display",type:"dropdown",options:{inline:"Inline",block:"Break Text"},callback:function(a,b){this.video.display(b)},refresh:function(a){this.opts.videoTextNear||a.addClass("fr-hidden")},refreshOnShow:function(a,b){this.video.refreshDisplayOnShow(a,b)}}),a.FroalaEditor.DefineIcon("videoAlign",{NAME:"align-center"}),a.FroalaEditor.RegisterCommand("videoAlign",{type:"dropdown",title:"Align",options:{left:"Align Left",justify:"None",right:"Align Right"},html:function(){var b='<ul class="fr-dropdown-list">',c=a.FroalaEditor.COMMANDS.videoAlign.options;for(var d in c)b+='<li><a class="fr-command" data-cmd="videoAlign" data-param1="'+d+'" title="'+this.language.translate(c[d])+'"><i class="fa fa-align-'+d+'"></i></a></li>';return b+="</ul>"},callback:function(a,b){this.video.align(b)},refresh:function(a){this.video.refreshAlign(a)},refreshOnShow:function(a,b){this.video.refreshAlignOnShow(a,b)}}),a.FroalaEditor.DefineIcon("videoRemove",{NAME:"trash"}),a.FroalaEditor.RegisterCommand("videoRemove",{title:"Remove",callback:function(){this.video.remove()}}),a.FroalaEditor.DefineIcon("videoSize",{NAME:"arrows-alt"}),a.FroalaEditor.RegisterCommand("videoSize",{undo:!1,focus:!1,title:"Change Size",callback:function(){this.video.showSizePopup()}}),a.FroalaEditor.DefineIcon("videoBack",{NAME:"arrow-left"}),a.FroalaEditor.RegisterCommand("videoBack",{title:"Back",undo:!1,focus:!1,back:!0,callback:function(){this.video.back()},refresh:function(a){var b=this.video.get();b||this.opts.toolbarInline?(a.removeClass("fr-hidden"),a.next(".fr-separator").removeClass("fr-hidden")):(a.addClass("fr-hidden"),a.next(".fr-separator").addClass("fr-hidden"))}}),a.FroalaEditor.RegisterCommand("videoSetSize",{undo:!0,focus:!1,callback:function(){this.video.setSize()}})}(jQuery); \ No newline at end of file