!function(){var e={},t=function(t){for(var n=e[t],i=n.deps,o=n.defn,a=i.length,s=new Array(a),l=0;l"}else"application/x-shockwave-flash"===c.source1mime?(l+='',c.poster&&(l+=''),l+=""):c.source1mime.indexOf("audio")!==-1?a.settings.audio_template_callback?l=a.settings.audio_template_callback(c):l+='":"script"===c.type?l+='':l=a.settings.video_template_callback?a.settings.video_template_callback(c):'"}return l};return{dataToHtml:a}}),s("h",tinymce.util.Promise),a("b",["g","h"],function(e,t){var n=function(e,n,r){var i={};return new t(function(t,o){var a=function(r){return r.html&&(i[e.source1]=r),t({url:e.source1,html:r.html?r.html:n(e)})};i[e.source1]?a(i[e.source1]):r({url:e.source1},a,o)})},r=function(e,n){return new t(function(t){t({html:n(e),url:e.source1})})},i=function(t){return function(n){return e.dataToHtml(t,n)}},o=function(e,t){var o=e.settings.media_url_resolver;return o?n(t,i(e),o):r(t,i(e))};return{getEmbedHtml:o}}),s("d",tinymce.Env),a("2",["6","7","4","b","c","d"],function(e,t,n,r,i,o){var a=o.ie&&o.ie<=8?"onChange":"onInput",s=function(e){return function(t){var n=t&&t.msg?"Media embed handler error: "+t.msg:"Media embed handler threw unknown error.";e.notificationManager.open({type:"error",text:n})}},l=function(e){var n=e.selection.getNode(),r=n.getAttribute("data-ephox-embed-iri");return r?{source1:r,"data-ephox-embed-iri":r}:n.getAttribute("data-mce-object")?t.htmlToData(e.settings.media_scripts,e.serializer.serialize(n,{selection:!0})):{}},c=function(e){var t=e.selection.getNode();if(t.getAttribute("data-mce-object"))return e.selection.getContent()},u=function(e,n){return function(r){var o=r.html;e.find("#embed").value(o);var a=i.extend(t.htmlToData(n.settings.media_scripts,o),{source1:r.url});e.fromJSON(a),h(e)}},d=function(e,t){var n,r,i=e.dom.select("img[data-mce-object]");for(n=0;n=0;r--)t[n]===i[r]&&i.splice(r,1);e.selection.select(i[0])},f=function(e){return function(){var t=this.toJSON();r.getEmbedHtml(e,t).then(function(n){var r=e.dom.select("img[data-mce-object]"),i=t.embed?t.embed:n.html;e.insertContent(i),d(e,r),e.nodeChanged()}).catch(s(e))}},h=function(e){var t=e.find("#width")[0],n=e.find("#height")[0];t&&n&&(t.state.set("oldVal",t.value()),n.state.set("oldVal",n.value()))},p=function(e,t){i.each(t,function(t,n){e.find("#"+n).value(t)})},m=function(e){var o,d,m=[{name:"source1",type:"filepicker",filetype:"media",size:40,autofocus:!0,label:"Source",onpaste:function(){setTimeout(function(){r.getEmbedHtml(e,o.toJSON()).then(u(o,e)).catch(s(e))},1)},onchange:function(t){r.getEmbedHtml(e,o.toJSON()).then(u(o,e)).catch(s(e)),p(o,t.meta)},onbeforecall:function(e){e.meta=o.toJSON()}}],g=function(e){var t=o.find("#width")[0],r=o.find("#height")[0],i=t.state.get("oldVal"),a=r.state.get("oldVal"),s=t.value(),l=r.value();o.find("#constrain")[0].checked()&&i&&a&&s&&l&&(e.control.name()===t.name()?(l=Math.round(s/i*l),isNaN(l)||r.value(l)):(s=Math.round(l/a*s),isNaN(s)||t.value(s))),d=o.toJSON(),o.find("#embed").value(n.updateHtml(d.embed,d)),h(o)};e.settings.media_alt_source!==!1&&m.push({name:"source2",type:"filepicker",filetype:"media",size:40,label:"Alternative source"}),e.settings.media_poster!==!1&&m.push({name:"poster",type:"filepicker",filetype:"image",size:40,label:"Poster"}),e.settings.media_dimensions!==!1&&m.push({type:"container",label:"Dimensions",layout:"flex",align:"center",spacing:5,items:[{name:"width",type:"textbox",maxLength:5,size:3,onchange:g,ariaLabel:"Width"},{type:"label",text:"x"},{name:"height",type:"textbox",maxLength:5,size:3,onchange:g,ariaLabel:"Height"},{name:"constrain",type:"checkbox",checked:!0,text:"Constrain proportions"}]}),d=l(e);var v={id:"mcemediasource",type:"textbox",flex:1,name:"embed",value:c(e),multiline:!0,label:"Source"},y=function(){d=i.extend({},t.htmlToData(e.settings.media_scripts,this.value())),this.parent().parent().fromJSON(d)};v[a]=y,o=e.windowManager.open({title:"Insert/edit video",data:d,bodyType:"tabpanel",body:[{title:"General",type:"form",items:m},{title:"Embed",type:"container",layout:"flex",direction:"column",align:"stretch",padding:10,spacing:10,items:[{type:"label",text:"Paste your embed code below:",forId:"mcemediasource"},v]}],onSubmit:f(e)}),h(o)};return{showDialog:m}}),a("3",["c","8","9","a"],function(e,t,n,r){var i=function(e,i){if(e.settings.media_filter_html===!1)return i;var o,a=new t;return new n({validate:!1,allow_conditional_comments:!1,special:"script,noscript",comment:function(e){a.comment(e)},cdata:function(e){a.cdata(e)},text:function(e,t){a.text(e,t)},start:function(t,n,r){if(o=!0,"script"!==t&&"noscript"!==t){for(var i=0;i]*>","gi")});var r=e.schema.getBoolAttrs();tinymce.each("webkitallowfullscreen mozallowfullscreen allowfullscreen".split(" "),function(e){r[e]={}}),e.parser.addNodeFilter("iframe,video,audio,object,embed,script",i.placeHolderConverter(e)),e.serializer.addAttributeFilter("data-mce-object",function(t,r){for(var i,o,a,s,l,c,u,d,f=t.length;f--;)if(i=t[f],i.parent){for(u=i.attr(r),o=new tinymce.html.Node(u,1),"audio"!==u&&"script"!==u&&(d=i.attr("class"),d&&d.indexOf("mce-preview-object")!==-1?o.attr({width:i.firstChild.attr("width"),height:i.firstChild.attr("height")}):o.attr({width:i.attr("width"),height:i.attr("height")})),o.attr({style:i.attr("style")}),s=i.attributes,a=s.length;a--;){var h=s[a].name;0===h.indexOf("data-mce-p-")&&o.attr(h.substr(11),s[a].value)}"script"===u&&o.attr("type","text/javascript"),l=i.attr("data-mce-html"),l&&(c=new tinymce.html.Node("#text",3),c.raw=!0,c.value=n.sanitize(e,unescape(l)),o.append(c)),i.replace(o)}})}),e.on("click keyup",function(){var t=e.selection.getNode();t&&e.dom.hasClass(t,"mce-preview-object")&&e.dom.getAttrib(t,"data-mce-selected")&&t.setAttribute("data-mce-selected","2")}),e.on("ObjectSelected",function(e){var t=e.target.getAttribute("data-mce-object");"audio"!==t&&"script"!==t||e.preventDefault()}),e.on("objectResized",function(e){var t,n=e.target;n.getAttribute("data-mce-object")&&(t=n.getAttribute("data-mce-html"),t&&(t=unescape(t),n.setAttribute("data-mce-html",escape(r.updateHtml(t,{width:e.width,height:e.height})))))}),this.showDialog=function(){t.showDialog(e)},e.addButton("media",{tooltip:"Insert/edit video",onclick:this.showDialog,stateSelector:["img[data-mce-object]","span[data-mce-object]","div[data-ephox-embed-iri]"]}),e.addMenuItem("media",{icon:"media",text:"Media",onclick:this.showDialog,context:"insert",prependToContext:!0}),e.on("setContent",function(){e.$("span.mce-preview-object").each(function(t,n){var r=e.$(n);0===r.find("span.mce-shim",n).length&&r.append('')})}),e.addCommand("mceMedia",this.showDialog)};return e.add("media",o),function(){}}),r("0")()}();