(function(k){var g=CKEDITOR.tools.trim,f={},h=function(b,a){var c=b.video.$;c.onloadedmetadata=c.onerror=null;var d=g(b.getValueOf("info","src"));if(!d.length)return!1;if(void 0!==f[d])return f[d];c.onloadedmetadata=c.onerror=function(){c.onloadedmetadata=c.onerror=null;var b=c.videoWidth,e=c.videoHeight;f[d]=b&&e?{width:b,height:e}:!1;a()};c.src=d},e=function(b){var a=h(b,function(){e(b)}),c=b.video;a?(b.commitContent(c),a=(100*a.height/a.width).toFixed(5)+"%",c.setStyle("display","block").getParent().getParent().setStyle("padding-top",
a)):c.setStyle("display","none")};CKEDITOR.dialog.add("video",function(b){return{title:b.lang.video.title,minWidth:400,minHeight:300,contents:[{id:"info",label:b.lang.common.generalTab,elements:[{id:"src",type:"text",label:b.lang.common.url,required:!0,onChange:function(){e(this.getDialog())},validate:CKEDITOR.dialog.validate.notEmpty(b.lang.video.emptySrc),setup:function(a){this.setValue(a&&a.getAttribute("src")||"")},commit:function(a){a.setAttribute("src",g(this.getValue()))}},{id:"browse",type:"button",
filebrowser:"info:src",hidden:!0,label:b.lang.common.browseServer},{id:"controls",type:"checkbox",label:b.lang.video.controls,"default":!0,onChange:function(){var a=this.getDialog();this.getValue()||a.getContentElement("info","muted_looping_autoplay").setValue(!0,!0);e(a)},setup:function(a){this.setValue(!(!a||!a.hasAttribute("controls")))},commit:function(a){this.getValue()?a.setAttribute("controls","controls"):a.removeAttribute("controls")}},{id:"muted_looping_autoplay",type:"checkbox",label:b.lang.video.mutedLoopingAutoplay,
onChange:function(){var a=this.getDialog();this.getValue()||a.getContentElement("info","controls").setValue(!0,!0);e(a)},setup:function(a){this.setValue(!(!a||!a.hasAttribute("autoplay")))},commit:function(a){this.getValue()?a.setAttributes({autoplay:"autoplay",loop:"loop",muted:"muted"}):a.removeAttributes(["autoplay","loop","muted"])}},{id:"preview",type:"html",html:"\x3clabel\x3e"+b.lang.video.preview+'\x3c/label\x3e\x3cdiv class\x3d"cke_dialog_ui_labeled_content" style\x3d"position:relative;background-color:#f8f8f8;border:1px solid #d1d1d1;"\x3e\x3cdiv style\x3d"height:0;padding-top:56.25%"\x3e\x3cdiv style\x3d"position:absolute;bottom:0;left:0;right:0;top:0;"\x3e\x3cvideo preload\x3d"metadata" style\x3d"width:100%;height:100%;display:none;"\x3e\x3c/video\x3e\x3c/div\x3e\x3c/div\x3e\x3c/div\x3e'}]}],
onLoad:function(){this.video=this.getContentElement("info","preview").getElement().getNext().getFirst().getFirst().getFirst();this.video.$.addEventListener("loadedmetadata",function(a){a=a.target;a.muted=a.hasAttribute("muted")},!1)},onShow:function(){var a=this.getSelectedElement();a&&"video"==a.data("cke-real-element-type")&&(a=b.restoreRealElement(a),this.setupContent(a),e(this))},onOk:function(){var a=this,c=h(a,function(){a.definition.onOk.apply(a)});if(c){var d=CKEDITOR.dom.element.createFromHtml("\x3ccke:video\x3e\x3c/cke:video\x3e",
b.document);d.setAttributes({preload:"metadata",width:c.width,height:c.height});a.commitContent(d);d=b.createFakeElement(d,"cke-video","video",!1);d.$.src=CKEDITOR.tools.createImageData(c);b.insertElement(d);a.hide()}else return!1===c&&alert(b.lang.video.invalidSrc),!1},onHide:function(){var a=this.video.setStyle("display","none").$;a.onloadedmetadata=a.onerror=null;a.src=""}}})})();