policybot/fassets/js/components/tinymce/plugins/fullpage/plugin.min.js

9 lines
7.7 KiB
JavaScript
Raw Normal View History

2021-11-30 10:56:55 +00:00
/**
* 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.8.1 (2021-05-20)
*/
!function(){"use strict";var s=function(e){var t=e;return{get:function(){return t},set:function(e){t=e}}},e=tinymce.util.Tools.resolve("tinymce.PluginManager"),u=function(){return(u=Object.assign||function(e){for(var t,n=1,l=arguments.length;n<l;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},p=tinymce.util.Tools.resolve("tinymce.util.Tools"),t=tinymce.util.Tools.resolve("tinymce.html.DomParser"),m=tinymce.util.Tools.resolve("tinymce.html.Node"),f=tinymce.util.Tools.resolve("tinymce.html.Serializer"),h=function(e){return e.getParam("fullpage_hide_in_source_view")},i=function(e){return e.getParam("fullpage_default_encoding")},g=function(e){return e.getParam("fullpage_default_font_family")},y=function(e){return e.getParam("fullpage_default_font_size")},v=function(e){return t({validate:!1,root_name:"#document"}).parse(e,{format:"xhtml"})},d=function(l,i){var e,t,n,o,r,a,c,s=(e=l,t=i.get(),r=v(t),c=function(e,t){return e.attr(t)||""},(a={}).fontface=g(e),a.fontsize=y(e),7===(n=r.firstChild).type&&(a.xml_pi=!0,(o=/encoding="([^"]+)"/.exec(n.value))&&(a.docencoding=o[1])),(n=r.getAll("#doctype")[0])&&(a.doctype="<!DOCTYPE"+n.value+">"),(n=r.getAll("title")[0])&&n.firstChild&&(a.title=n.firstChild.value),p.each(r.getAll("meta"),function(e){var t,n=e.attr("name"),l=e.attr("http-equiv");n?a[n.toLowerCase()]=e.attr("content"):"Content-Type"===l&&(t=/charset\s*=\s*(.*)\s*/gi.exec(e.attr("content")))&&(a.docencoding=t[1])}),(n=r.getAll("html")[0])&&(a.langcode=c(n,"lang")||c(n,"xml:lang")),a.stylesheets=[],p.each(r.getAll("link"),function(e){"stylesheet"===e.attr("rel")&&a.stylesheets.push(e.attr("href"))}),(n=r.getAll("body")[0])&&(a.langdir=c(n,"dir"),a.style=c(n,"style"),a.visited_color=c(n,"vlink"),a.link_color=c(n,"link"),a.active_color=c(n,"alink")),a),d=u(u({},{title:"",keywords:"",description:"",robots:"",author:"",docencoding:""}),s);l.windowManager.open({title:"Metadata and Document Properties",size:"normal",body:{type:"panel",items:[{name:"title",type:"input",label:"Title"},{name:"keywords",type:"input",label:"Keywords"},{name:"description",type:"input",label:"Description"},{name:"robots",type:"input",label:"Robots"},{name:"author",type:"input",label:"Author"},{name:"docencoding",type:"input",label:"Encoding"}]},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:d,onSubmit:function(e){var t=e.getData(),n=function(e,o,t){var r,n,l=e.dom,i=function(e,t,n){e.attr(t,n||undefined)},a=function(e){s.firstChild?s.insert(e,s.firstChild):s.append(e)},c=v(t),s=c.getAll("head")[0];s||(r=c.getAll("html")[0],s=new m("head",1),r.firstChild?r.insert(s,r.firstChild,!0):r.append(s)),r=c.firstChild,o.xml_pi?(n='version="1.0"',o.docencoding&&(n+=' encoding="'+o.docencoding+'"'),7!==r.type&&(r=new m("xml",7),c.insert(r,c.firstChild,!0)),r.value=n):r&&7===r.type&&r.remove(),r=c.getAll("#doctype")[0],o.doctype?(r||(r=new m("#doctype",10),o.xml_pi?c.insert(r,c.firstChild):a(r)),r.value=o.doctype.substring(9,o.doctype.length-1)):r&&r.remove(),r=null,p.each(c.getAll("meta"),function(e){"Content-Type"===e.attr("http-equiv")&&(r=e)}),o.docencoding?(r||((r=new m("meta",1)).attr("http-equiv","Content-Type"),r.shortEnded=!0,a(r)),r.attr("content","text/html; charset="+o.docencoding)):r&&r.remove(),r=c.getAll("title")[0],o.title?(r?r.empty():(r=new m("title",1),a(r)),r.append(new m("#text",3)).value=o.title):r&&r.remove(),p.each("keywords,description,author,copyright,robots".split(","),function(e){for(var t,n=c.getAll("meta"),l=o[e],i=0;i<n.length;i++)if((t=n[i]).attr("name")===e)return void(l?t.attr("content",l):t.remove());l&&((r=new m("meta",1)).attr("name",e),r.attr("content",l),r.shortEnded=!0,a(r))});var d={};p.each(c.getAll("link"),function(e){"stylesheet"===e.attr("rel")&&(d[e.attr("href")]=e)}),p.each(o.stylesheets,function(e){d[e]||((r=new m("link",1)).attr({rel:"stylesheet",text:"text/css",href:e}),r.shortEnded=!0,a(r)),delete d[e]}),p.each(d,function(e){e.remove()}),(r=c.getAll("body")[0])&&(i(r,"dir",o.