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

11 lines
8.0 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(m){"use strict";var n,t,r,e,o,u,i=tinymce.util.Tools.resolve("tinymce.PluginManager"),c=function(){},a=function(n){return function(){return n}},l=function(n){return n},f=a(!1),s=a(!0),d=f,g=s,y=function(){return p},p=(e={fold:function(n,t){return n()},is:d,isSome:d,isNone:g,getOr:r=function(n){return n},getOrThunk:t=function(n){return n()},getOrDie:function(n){throw new Error(n||"error: getOrDie called on none.")},getOrNull:function(){return null},getOrUndefined:function(){return undefined},or:r,orThunk:t,map:y,ap:y,each:function(){},bind:y,flatten:y,exists:d,forall:g,filter:y,equals:n=function(n){return n.isNone()},equals_:n,toArray:function(){return[]},toString:a("none()")},Object.freeze&&Object.freeze(e),e),h=function(r){var n=function(){return r},t=function(){return o},e=function(n){return n(r)},o={fold:function(n,t){return t(r)},is:function(n){return r===n},isSome:g,isNone:d,getOr:n,getOrThunk:n,getOrDie:n,getOrNull:n,getOrUndefined:n,or:t,orThunk:t,map:function(n){return h(n(r))},ap:function(n){return n.fold(y,function(n){return h(n(r))})},each:function(n){n(r)},bind:e,flatten:n,exists:e,forall:e,filter:function(n){return n(r)?o:p},equals:function(n){return n.is(r)},equals_:function(n,t){return n.fold(d,function(n){return t(r,n)})},toArray:function(){return[r]},toString:function(){return"some("+r+")"}};return o},v={some:h,none:y,from:function(n){return null===n||n===undefined?p:h(n)}},O=(o="function",function(n){return function(n){if(null===n)return"null";var t=typeof n;return"object"===t&&(Array.prototype.isPrototypeOf(n)||n.constructor&&"Array"===n.constructor.name)?"array":"object"===t&&(String.prototype.isPrototypeOf(n)||n.constructor&&"String"===n.constructor.name)?"string":t}(n)===o}),b=Array.prototype.slice,w=function(n,t){for(var r=0,e=n.length;r<e;r++){if(t(n[r],r,n))return v.some(r)}return v.none()},k=(O(Array.from)&&Array.from,function(n,t){return-1!==n.indexOf(t)}),A=function(n,t){return k(n.title.toLowerCase(),t)||(r=n.keywords,w(r,function(n){return k(n.toLowerCase(),t)}).isSome());var r},T=function(n,t,r){for(var e=[],o=t.toLowerCase(),i=r.fold(function(){return f},function(t){return function(n){return t<=n}}),u=0;u<n.length&&(0!==t.length&&!A(n[u],o)||(e.push({value:n[u]["char"],text:n[u].title,icon:n[u]["char"]}),!i(e.length)));u++);return e},j=function(n){var t=n,r=function(){return t};return{get:r,set:function(n){t=n},clone:function(){return j(r())}}},C="undefined"!=typeof m.window?m.window:Function("return this;")(),S=Object.keys,_=Object.hasOwnProperty,x=function(n,t){for(var r=S(n),e=0,o=r.length;e<o;e++){var i=r[e];t(n[i],i,n)}},D=function(e,o){var i={};return x(e,function(n,t){var r=o(n,t,e);i[r.k]=r.v}),i},L=function(r){return{is:function(n){return r===n},isValue:s,isError:f,getOr:a(r),getOrThunk:a(r),getOrDie:a(r),or:function(n){return L(r)},orThunk:function(n){return L(r)},fold:function(n,t){return t(r)},map:function(n){return L(n(r))},mapError:function(n){return L(r)},each:function(n){n(r)},bind:function(n){return n(r)},exists:function(n){return n(r)},forall:function(n){return n(r)},toOption:function(){return v.some(r)}}},E=function(r){return{is:f,isValue:f,isError:s,getOr:l,getOrThunk:function(n){return n()},getOrDie:function(){return n=String(r),function(){throw new Error(n)}();var n},or:function(n){return n},orThunk:function(n){return n()},fold:function(n,t){return n(r)},map:function(n){return E(r)},mapError:function(n){return E(n(r))},each:c,bind:function(n){return E(r)},exists:f,forall:s,toOption:v.none}},P={value:L,error:E,fromOption:function(n,t){return n.fold(function(){return E(t)},L)}},N=Object.prototype.hasOwnProperty,F=(u=function(n,t){return t},function(){for(var n=new Array(arguments.length),t=0;t<n.length;t++)n[t]=arguments[t];if(0===n.length)throw new Error("Can't merge zero objects");for(var r={},e=0;e<n.length;e++){var o=n[e];for(var i in o)N.call(o,i)&&(r[i]=u(r[i],o[i]))}return r}),q=tinymce.util.Tools.resolve("tinymce.dom.ScriptLoader"),z=tinymce.util.Tools.resolve("tinymce.util.Promise"),I=tinymce.util.Tools.resolve("tinymce.util.Delay"),U=function(n,t){return n.getParam("emoticons_database_url",t+"/js/emojis"+n.suffix+".js")},M=function(n){return n.getParam("emoticons_append",{},"object")},R="All",V={symbols:"Symbols",people:"People",animals_and_nature:"Animals and Nature",food_and_drink:"Food and Drink",activity:"Activity",travel_and_places:"Travel and Places",objects:"Objects",flags:"Flags",user:"User Defined"},B="emoticons_plugin_database",G=function(n,t){return r=n,e=t,_.call(r,e)?n[t]:t;var r,e},H=function(n){var e,t=M(n);return e=function(n){return F({keywords:[],category:"user"},n)},D(t,function(n,t,r){return{k:t,v:e(n,t,r)}})},J=function(e,o){var u=j(v.none()),c=j(v.none());e.on("init",function(){q.ScriptLoader.loadScript(o,function(){(function(n){if(C.tinymce[B]){var t=P.value(C.tinymce[B]);return delete C.tinymce[B],t}return P.error("URL "+n+" did not contain the expected format for emoticons")})(o).fold(function(n){m.console.log(n),u.set(v.some({})),c.set(v.some([]))},function(n){var t,o,i,r=H(e);t=F(n,r),o={},i=[],x(t,function(n,t){var r={title:t,keywords:n.keywords,"char":n["char"],category:G(V,n.category)},e=o[r.category]!==undefined?o[r.category]:[];o[r.category]=e.concat([r]),i.push(r)}),u.set(v.some(o)),c.set(v.some(i))})},function(){})});var n=function(){return c.get().getOr([])},i=function(){return u.get().isSome()&&c.get().isSome()};return{listCategories:function(){return[R].concat(S(u.get().getOr({})))},hasLoaded:i,waitForLoad:function(){return i()?z.resolve(!0):new z(function(n,t){var r=3,e=I.setInterval(function(){i()?(I.clearInterval(e),n(!0)):--r<0&&(m.console.log("Could not load emojis from url: "+o),I.clearInterval(e),t(!1))},500)})},listAll:n,listCategory:function(t){return t===R?n():u.get().bind(function(n){return v.from(n[t])}).getOr([])}}},K="pattern",Q=function(o,u){var r,e,i,n={pattern:"",results:T(u.listAll(),"",v.some(300))},c=j(R),a=(r=function(n){var t,r,e,o,i;r=(t=n).getData(),e=c.get(),o=u.listCategory(e),i=T(o,r[K],e===R?v.some(300):v.none()),t.setData({results:i})},e=200,i=null,{cancel:function(){null!==i&&(m.clearTimeout(i),i=null)},throttle:function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];null!==i&&m.clearTimeout(i),i=m.setTimeout(function(){r.apply(null,n),i=null},e)}}),t={label:"Search",type:"input",name:K},l={type:"collection",name:"results"},f=function(){return{title:"Emoticons",size:"normal",body:{type:"tabpanel",tabs:function(n,t){for(var r=n.length,e=new Array(r),o=0;o<r;o++){var i=n[o];e[o]=t(i,o,n)}return e}(u.listCategories(),function(n){return{title:n,name:n,items:[t,l]}})},initialData:n,onTabChange:function(n,t){c.set(t.newTabName),a.throttle(n)},onChange:a.throttle,onAction:function(n,t){var r,e;"results"===t.name&&(r=o,e=t.value,r.insertContent(e),n.close())},buttons:[{type:"cancel",text:"Close",primary:!0}]}},s=o.windowManager.open(f());s.focus(K),u.hasLoaded()||(s.block("Loading emoticons..."),u.waitForLoad().then(function(){s.redial(f()),a.throttle(s),s.focus(K),s.unblock()})["catch"](function(n){s.redial({title:"Emoticons",body:{type:"panel",items:[{type:"alertbanner",level:"error",icon:"warning",text:"<p>Could not load emoticons</p>"}]},buttons:[{type:"cancel",text:"Close",primary:!0}],initialData:{pattern:"",results:[]}}),s.focus(K),s.unblock()}))},W=function(n,t){var r=function(){return Q(n,t)};n.ui.registry.addButton("emoticons",{tooltip:"Emoticons",icon:"emoji",onAction:r}),n.ui.registry.addMenuItem("emoticons",{text:"Emoticons...",icon:"emoji",onAction:r})};!function X(){i.add("emoticons",function(n,t){var e,o,r=U(n,t),i=J(n,r);W(n,i),o=i,(e=n).ui.registry.addAutocompleter("emoticons",{ch:":",columns:"auto",minChars:2,fetch:function(t,r){return o.waitForLoad().then(function(){var n=o.listAll();return T(n,t,v.some(r))})},onAction:function(n,t,r){e.selection.setRng(t),e.insertContent(r),n.hide()}})})}()}(window);