agenda-libre-ruby/public/assets/tinymce/plugins/media/plugin.js

1 line
15 KiB
JavaScript

!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<a;++l)s[l]=r(i[l]);var c=o.apply(null,s);if(void 0===c)throw"module ["+t+"] returned undefined";n.instance=c},n=function(t,n,r){if("string"!=typeof t)throw"module id must be a string";if(void 0===n)throw"no dependencies for "+t;if(void 0===r)throw"no definition function for "+t;e[t]={deps:n,defn:r,instance:void 0}},r=function(n){var r=e[n];if(void 0===r)throw"module ["+n+"] was undefined";return void 0===r.instance&&t(n),r.instance},i=function(e,t){for(var n=e.length,i=new Array(n),o=0;o<n;++o)i.push(r(e[o]));t.apply(null,t)},o={};o.bolt={module:{api:{define:n,require:i,demand:r}}};var a=n,s=function(e,t){a(e,[],function(){return t})};s("1",tinymce.PluginManager),s("6",tinymce.util.Delay),s("c",tinymce.util.Tools),s("9",tinymce.html.SaxParser),s("a",tinymce.html.Schema),a("e",[],function(){var e=function(e,t){if(e)for(var n=0;n<e.length;n++)if(t.indexOf(e[n].filter)!==-1)return e[n]};return{getVideoScriptMatch:e}}),a("7",["c","9","a","e"],function(e,t,n,r){var i=function(n,i){var o={};return new t({validate:!1,allow_conditional_comments:!0,special:"script,noscript",start:function(t,i){o.source1||"param"!==t||(o.source1=i.map.movie);var a=i.map["data-ephox-embed-iri"];if(a&&(o.type="ephox-embed-iri",o.source1=a),"iframe"!==t&&"object"!==t&&"embed"!==t&&"video"!==t&&"audio"!==t||(o.type||(o.type=t),o=e.extend(i.map,o)),"script"===t){var s=r.getVideoScriptMatch(n,i.map.src);if(!s)return;o={type:"script",source1:i.map.src,width:s.width,height:s.height}}"source"===t&&(o.source1?o.source2||(o.source2=i.map.src):o.source1=i.map.src),"img"!==t||o.poster||(o.poster=i.map.src)}}).parse(i),o.source1=o.source1||o.src||o.data,o.source2=o.source2||"",o.poster=o.poster||"","ephox-embed-iri"===o.type?e.extend({},{type:o.type,source1:o.source1,source2:"",poster:"",width:o.width,height:o.height}):o};return{htmlToData:i}}),s("8",tinymce.html.Writer),a("4",["8","9","a"],function(e,t,n){var r=function(e,t){var n,r,i,o;for(n in t)if(i=""+t[n],e.map[n])for(r=e.length;r--;)o=e[r],o.name===n&&(i?(e.map[n]=i,o.value=i):(delete e.map[n],e.splice(r,1)));else i&&(e.push({name:n,value:i}),e.map[n]=i)},i=function(i,o,a){var s,l=new e,c=0;return new t({validate:!1,allow_conditional_comments:!0,special:"script,noscript",comment:function(e){l.comment(e)},cdata:function(e){l.cdata(e)},text:function(e,t){l.text(e,t)},start:function(e,t,n){switch(e){case"video":case"object":case"embed":case"img":case"iframe":r(t,{width:o.width,height:o.height})}if(a)switch(e){case"video":r(t,{poster:o.poster,src:""}),o.source2&&r(t,{src:""});break;case"iframe":r(t,{src:o.source1});break;case"source":if(c++,c<=2&&(r(t,{src:o["source"+c],type:o["source"+c+"mime"]}),!o["source"+c]))return;break;case"img":if(!o.poster)return;s=!0}l.start(e,t,n)},end:function(e){if("video"===e&&a)for(var t=1;t<=2;t++)if(o["source"+t]){var n=[];n.map={},c<t&&(r(n,{src:o["source"+t],type:o["source"+t+"mime"]}),l.start("source",n,!0))}if(o.poster&&"object"===e&&a&&!s){var i=[];i.map={},r(i,{src:o.poster,width:o.width,height:o.height}),l.start("img",i,!0)}l.end(e)}},new n({})).parse(i),l.getContent()};return{updateHtml:i}}),a("i",[],function(){var e=function(e){var t={mp3:"audio/mpeg",wav:"audio/wav",mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",swf:"application/x-shockwave-flash"},n=e.toLowerCase().split(".").pop(),r=t[n];return r?r:""};return{guess:e}}),a("j",[],function(){var e=[{regex:/youtu\.be\/([\w\-.]+)/,type:"iframe",w:560,h:314,url:"//www.youtube.com/embed/$1",allowFullscreen:!0},{regex:/youtube\.com(.+)v=([^&]+)/,type:"iframe",w:560,h:314,url:"//www.youtube.com/embed/$2",allowFullscreen:!0},{regex:/youtube.com\/embed\/([a-z0-9\-_]+(?:\?.+)?)/i,type:"iframe",w:560,h:314,url:"//www.youtube.com/embed/$1",allowFullscreen:!0},{regex:/vimeo\.com\/([0-9]+)/,type:"iframe",w:425,h:350,url:"//player.vimeo.com/video/$1?title=0&byline=0&portrait=0&color=8dc7dc",allowfullscreen:!0},{regex:/vimeo\.com\/(.*)\/([0-9]+)/,type:"iframe",w:425,h:350,url:"//player.vimeo.com/video/$2?title=0&amp;byline=0",allowfullscreen:!0},{regex:/maps\.google\.([a-z]{2,3})\/maps\/(.+)msid=(.+)/,type:"iframe",w:425,h:350,url:'//maps.google.com/maps/ms?msid=$2&output=embed"',allowFullscreen:!1},{regex:/dailymotion\.com\/video\/([^_]+)/,type:"iframe",w:480,h:270,url:"//www.dailymotion.com/embed/video/$1",allowFullscreen:!0}];return{urlPatterns:e}}),a("g",["i","7","j","e","4","c"],function(e,t,n,r,i,o){var a=function(a,s){var l="",c=o.extend({},s);if(!c.source1&&(o.extend(c,t.htmlToData(a.settings.media_scripts,c.embed)),!c.source1))return"";if(c.source2||(c.source2=""),c.poster||(c.poster=""),c.source1=a.convertURL(c.source1,"source"),c.source2=a.convertURL(c.source2,"source"),c.source1mime=e.guess(c.source1),c.source2mime=e.guess(c.source2),c.poster=a.convertURL(c.poster,"poster"),o.each(n.urlPatterns,function(e){var t,n,r=e.regex.exec(c.source1);if(r){for(n=e.url,t=0;r[t];t++)n=n.replace("$"+t,function(){return r[t]});c.source1=n,c.type=e.type,c.allowFullscreen=e.allowFullscreen,c.width=c.width||e.w,c.height=c.height||e.h}}),c.embed)l=i.updateHtml(c.embed,c,!0);else{var u=r.getVideoScriptMatch(a.settings.media_scripts,c.source1);if(u&&(c.type="script",c.width=u.width,c.height=u.height),c.width=c.width||300,c.height=c.height||150,o.each(c,function(e,t){c[t]=a.dom.encode(e)}),"iframe"===c.type){var d=c.allowFullscreen?' allowFullscreen="1"':"";l+='<iframe src="'+c.source1+'" width="'+c.width+'" height="'+c.height+'"'+d+"></iframe>"}else"application/x-shockwave-flash"===c.source1mime?(l+='<object data="'+c.source1+'" width="'+c.width+'" height="'+c.height+'" type="application/x-shockwave-flash">',c.poster&&(l+='<img src="'+c.poster+'" width="'+c.width+'" height="'+c.height+'" />'),l+="</object>"):c.source1mime.indexOf("audio")!==-1?a.settings.audio_template_callback?l=a.settings.audio_template_callback(c):l+='<audio controls="controls" src="'+c.source1+'">'+(c.source2?'\n<source src="'+c.source2+'"'+(c.source2mime?' type="'+c.source2mime+'"':"")+" />\n":"")+"</audio>":"script"===c.type?l+='<script src="'+c.source1+'"></script>':l=a.settings.video_template_callback?a.settings.video_template_callback(c):'<video width="'+c.width+'" height="'+c.height+'"'+(c.poster?' poster="'+c.poster+'"':"")+' controls="controls">\n<source src="'+c.source1+'"'+(c.source1mime?' type="'+c.source1mime+'"':"")+" />\n"+(c.source2?'<source src="'+c.source2+'"'+(c.source2mime?' type="'+c.source2mime+'"':"")+" />\n":"")+"</video>"}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<t.length;n++)for(r=i.length-1;r>=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<n.length;i++){if(0===n[i].name.indexOf("on"))return;"style"===n[i].name&&(n[i].value=e.dom.serializeStyle(e.dom.parseStyle(n[i].value),t))}a.start(t,n,r),o=!1}},end:function(e){o||a.end(e)}},new r({})).parse(i),a.getContent()};return{sanitize:i}}),s("f",tinymce.html.Node),a("5",["3","e","f","d"],function(e,t,n,r){var i=function(e,t){var i,o=t.name;return i=new n("img",1),i.shortEnded=!0,a(e,t,i),i.attr({width:t.attr("width")||"300",height:t.attr("height")||("audio"===o?"30":"150"),style:t.attr("style"),src:r.transparentSrc,"data-mce-object":o,class:"mce-object mce-object-"+o}),i},o=function(e,t){var r,i,o,s=t.name;return r=new n("span",1),r.attr({contentEditable:"false",style:t.attr("style"),"data-mce-object":s,class:"mce-preview-object mce-object-"+s}),a(e,t,r),i=new n(s,1),i.attr({src:t.attr("src"),allowfullscreen:t.attr("allowfullscreen"),width:t.attr("width")||"300",height:t.attr("height")||("audio"===s?"30":"150"),frameborder:"0"}),o=new n("span",1),o.attr("class","mce-shim"),r.append(i),r.append(o),r},a=function(t,n,r){var i,o,a,s,l;for(a=n.attributes,s=a.length;s--;)i=a[s].name,o=a[s].value,"width"!==i&&"height"!==i&&"style"!==i&&("data"!==i&&"src"!==i||(o=t.convertURL(o,i)),r.attr("data-mce-p-"+i,o));l=n.firstChild&&n.firstChild.value,l&&(r.attr("data-mce-html",escape(e.sanitize(t,l))),r.firstChild=null)},s=function(e){return function(n){for(var a,s,l,c=n.length;c--;)a=n[c],a.parent&&(a.parent.attr("data-mce-object")||("script"!==a.name||(l=t.getVideoScriptMatch(e.settings.media_scripts,a.attr("src"))))&&(l&&(l.width&&a.attr("width",l.width.toString()),l.height&&a.attr("height",l.height.toString())),s="iframe"===a.name&&e.settings.media_live_embeds!==!1&&r.ceFalse?o(e,a):i(e,a),a.replace(s)))}};return{createPreviewNode:o,createPlaceholderNode:i,placeHolderConverter:s}}),a("0",["1","2","3","4","5"],function(e,t,n,r,i){var o=function(e){e.on("ResolveName",function(e){var t;1===e.target.nodeType&&(t=e.target.getAttribute("data-mce-object"))&&(e.name=t)}),e.on("preInit",function(){var t=e.schema.getSpecialElements();tinymce.each("video audio iframe object".split(" "),function(e){t[e]=new RegExp("</"+e+"[^>]*>","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('<span class="mce-shim"></span>')})}),e.addCommand("mceMedia",this.showDialog)};return e.add("media",o),function(){}}),r("0")()}();