agenda-libre-ruby/public/assets/tinymce/plugins/template/plugin-b654d8c049ccf2d33a9af54bfa5db8b74d8dbc0c46dcaa92f41775dde643cb4b.js
2019-08-04 22:45:24 +02:00

11 lines
7.9 KiB
JavaScript

/**
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
* Licensed under the LGPL or a commercial license.
* For LGPL see License.txt in the project root for license information.
* For commercial licenses see https://www.tiny.cloud/
*
* Version: 5.0.12 (2019-07-18)
*/
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=function(e){return function(){return e}};var n,r,a,o,u,c=t(!1),i=t(!0),p=tinymce.util.Tools.resolve("tinymce.util.Tools"),m=tinymce.util.Tools.resolve("tinymce.util.XHR"),l=function(e){return e.getParam("template_cdate_classes","cdate")},s=function(e){return e.getParam("template_mdate_classes","mdate")},f=function(e){return e.getParam("template_selected_content_classes","selcontent")},d=function(e){return e.getParam("template_preview_replace_values")},g=function(e){return e.getParam("template_replace_values")},y=function(e){return e.templates},v=function(e){return e.getParam("template_cdate_format",e.translate("%Y-%m-%d"))},h=function(e){return e.getParam("template_mdate_format",e.translate("%Y-%m-%d"))},b=function(e,t){if((e=""+e).length<t)for(var n=0;n<t-e.length;n++)e="0"+e;return e},O=function(e,t,n){var r="Sun Mon Tue Wed Thu Fri Sat Sun".split(" "),a="Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(" "),o="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),u="January February March April May June July August September October November December".split(" ");return n=n||new Date,t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=t.replace("%D","%m/%d/%Y")).replace("%r","%I:%M:%S %p")).replace("%Y",""+n.getFullYear())).replace("%y",""+n.getYear())).replace("%m",b(n.getMonth()+1,2))).replace("%d",b(n.getDate(),2))).replace("%H",""+b(n.getHours(),2))).replace("%M",""+b(n.getMinutes(),2))).replace("%S",""+b(n.getSeconds(),2))).replace("%I",""+((n.getHours()+11)%12+1))).replace("%p",n.getHours()<12?"AM":"PM")).replace("%B",""+e.translate(u[n.getMonth()]))).replace("%b",""+e.translate(o[n.getMonth()]))).replace("%A",""+e.translate(a[n.getDay()]))).replace("%a",""+e.translate(r[n.getDay()]))).replace("%%","%")},T=function(n,e){return p.each(e,function(e,t){"function"==typeof e&&(e=e(t)),n=n.replace(new RegExp("\\{\\$"+t+"\\}","g"),e)}),n},M=function(e,t){var r=e.dom,a=g(e);p.each(r.select("*",t),function(n){p.each(a,function(e,t){r.hasClass(n,t)&&"function"==typeof a[t]&&a[t](n)})})},S=function(e,t){return new RegExp("\\b"+t+"\\b","g").test(e.className)},_=function(t,n){return function(){var e=y(t);"function"!=typeof e?"string"==typeof e?m.send({url:e,success:function(e){n(JSON.parse(e))}}):n(e):e(n)}},x=T,P=M,A=function(t,e,n){var r,a,o=t.dom,u=t.selection.getContent();n=T(n,g(t)),r=o.create("div",null,n),(a=o.select(".mceTmpl",r))&&0<a.length&&(r=o.create("div",null)).appendChild(a[0].cloneNode(!0)),p.each(o.select("*",r),function(e){S(e,l(t).replace(/\s+/g,"|"))&&(e.innerHTML=O(t,v(t))),S(e,s(t).replace(/\s+/g,"|"))&&(e.innerHTML=O(t,h(t))),S(e,f(t).replace(/\s+/g,"|"))&&(e.innerHTML=u)}),M(t,r),t.execCommand("mceInsertContent",!1,r.innerHTML),t.addVisual()},w=function(e){e.addCommand("mceInsertTemplate",function t(r){for(var a=[],e=1;e<arguments.length;e++)a[e-1]=arguments[e];return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=a.concat(e);return r.apply(null,n)}}(A,e))},D=function(r){r.on("PreProcess",function(e){var t=r.dom,n=h(r);p.each(t.select("div",e.node),function(e){t.hasClass(e,"mceTmpl")&&(p.each(t.select("*",e),function(e){t.hasClass(e,r.getParam("template_mdate_classes","mdate").replace(/\s+/g,"|"))&&(e.innerHTML=O(r,n))}),P(r,e))})})},C=c,N=i,H=function(){return k},k=(o={fold:function(e,t){return e()},is:C,isSome:C,isNone:N,getOr:a=function(e){return e},getOrThunk:r=function(e){return e()},getOrDie:function(e){throw new Error(e||"error: getOrDie called on none.")},getOrNull:function(){return null},getOrUndefined:function(){return undefined},or:a,orThunk:r,map:H,ap:H,each:function(){},bind:H,flatten:H,exists:C,forall:N,filter:H,equals:n=function(e){return e.isNone()},equals_:n,toArray:function(){return[]},toString:t("none()")},Object.freeze&&Object.freeze(o),o),I=function(n){var e=function(){return n},t=function(){return a},r=function(e){return e(n)},a={fold:function(e,t){return t(n)},is:function(e){return n===e},isSome:N,isNone:C,getOr:e,getOrThunk:e,getOrDie:e,getOrNull:e,getOrUndefined:e,or:t,orThunk:t,map:function(e){return I(e(n))},ap:function(e){return e.fold(H,function(e){return I(e(n))})},each:function(e){e(n)},bind:r,flatten:e,exists:r,forall:r,filter:function(e){return e(n)?a:k},equals:function(e){return e.is(n)},equals_:function(e,t){return e.fold(C,function(e){return t(n,e)})},toArray:function(){return[n]},toString:function(){return"some("+n+")"}};return a},J={some:I,none:H,from:function(e){return null===e||e===undefined?k:I(e)}},L=(u="function",function(e){return function(e){if(null===e)return"null";var t=typeof e;return"object"===t&&(Array.prototype.isPrototypeOf(e)||e.constructor&&"Array"===e.constructor.name)?"array":"object"===t&&(String.prototype.isPrototypeOf(e)||e.constructor&&"String"===e.constructor.name)?"string":t}(e)===u}),Y=Array.prototype.slice,j=(L(Array.from)&&Array.from,tinymce.util.Tools.resolve("tinymce.util.Promise")),q=Object.hasOwnProperty,F=function(e,t){return q.call(e,t)},B={'"':"&quot;","<":"&lt;",">":"&gt;","&":"&amp;","'":"&#039;"},E=function(e){return e.replace(/["'<>&]/g,function(e){return(t=B,n=e,F(t,n)?J.from(t[n]):J.none()).getOr(e);var t,n})},R=function(l,t){var e=function(e){return function(e,t){for(var n=e.length,r=new Array(n),a=0;a<n;a++){var o=e[a];r[a]=t(o,a,e)}return r}(e,function(e){return{text:e.text,value:e.text}})},s=function(e,t){return function(e,t){for(var n=0,r=e.length;n<r;n++){var a=e[n];if(t(a,n,e))return J.some(a)}return J.none()}(e,function(e){return e.text===t})},f=function(e){return new j(function(t,n){e.value.url?m.send({url:e.value.url,success:function(e){t(e)},error:function(e){n(e)}}):t(e.value.content)})};(function(){if(t&&0!==t.length)return J.from(p.map(t,function(e,t){return{selected:0===t,text:e.title,value:{url:e.url,content:e.content,description:e.description}}}));var e=l.translate("No templates defined.");return l.notificationManager.open({text:e,type:"info"}),J.none()})().each(function(o){var u=e(o),c=function(e,t){return{title:"Insert Template",size:"large",body:{type:"panel",items:e},initialData:t,buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],onSubmit:(n=o,function(t){var e=t.getData();s(n,e.template).each(function(e){f(e).then(function(e){A(l,!1,e),t.close()})})}),onChange:(r=o,a=i,function(n,e){if("template"===e.name){var t=n.getData().template;s(r,t).each(function(t){n.block("Loading..."),f(t).then(function(e){a(n,t,e),n.unblock()})})}})};var r,a,n},i=function(e,t,n){var r=function(t,e){if(-1===e.indexOf("<html>")){var n="";p.each(t.contentCSS,function(e){n+='<link type="text/css" rel="stylesheet" href="'+t.documentBaseURI.toAbsolute(e)+'">'});var r=t.settings.body_class||"";-1!==r.indexOf("=")&&(r=(r=t.getParam("body_class","","hash"))[t.id]||"");var a=t.dom.encode,o=t.getBody().dir,u=o?' dir="'+a(o)+'"':"";e="<!DOCTYPE html><html><head>"+n+'</head><body class="'+a(r)+'"'+u+">"+e+"</body></html>"}return x(e,d(t))}(l,n),a=[{type:"selectbox",name:"template",label:"Templates",items:u},{type:"htmlpanel",html:'<p aria-live="polite">'+E(t.value.description)+"</p>"},{label:"Preview",type:"iframe",name:"preview",sandboxed:!1}],o={template:t.text,preview:r};e.unblock(),e.redial(c(a,o)),e.focus("template")},t=l.windowManager.open(c([],{template:"",preview:""}));t.block("Loading..."),f(o[0]).then(function(e){i(t,o[0],e)})})},z=function(t){return function(e){R(t,e)}},U=function(e){e.ui.registry.addButton("template",{icon:"template",tooltip:"Insert template",onAction:_(e.settings,z(e))}),e.ui.registry.addMenuItem("template",{icon:"template",text:"Insert template...",onAction:_(e.settings,z(e))})};!function W(){e.add("template",function(e){U(e),w(e),D(e)})}()}();