-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.min.js
More file actions
10 lines (10 loc) · 6.23 KB
/
plugin.min.js
File metadata and controls
10 lines (10 loc) · 6.23 KB
1
2
3
4
5
6
7
8
9
10
(()=>{(function(g){"use strict";let s=["google_staticmap","google_embed"];s.google_staticmap={name:"Google Static Map",api:"//maps.googleapis.com/maps/api/staticmap?",type:"img"},s.google_embed={name:"Google Embed Map",api:"//www.google.com/maps/embed/v1/place?",type:"iframe"};let u=/^(?:color:)?([^|]*)(?:\|.*)?$/;function d(t,o){let n=[],e,i;for(e in o)i=o[e],i&&n.push(e+"="+i);return t+=n.join("&"),t}function m(t,o){let n=s[t.service||"google_staticmap"];if(!n)return"";let e=n.type;delete t.service;let i=t.width,r=t.height;t.size=i+"x"+r,t.scale&&(t.scale=2),t.markers&&(t.markers=t.markers.replace(u,"color:$1|"+t.center));let a=t.center||t.q;e==="iframe"&&(t.q=t.center,delete t.center,delete t.markers,delete t.width,delete t.height,delete t.size,delete t.scale,delete t.format),t.key||(t.key=n.key||"");let l=d(n.api,t);return l="<"+e+" src='"+l+"'",l+=" width='"+i+"' height='"+r+"'",e==="img"&&(l+=" alt='Map of "+a+"' title='"+a+"'"),o&&(l+=" style='max-width:100%;height:auto'"),l+=" />",l}function c(t,o){this.editor=t,this.url=o,s.forEach(function(e){let i=s[e];i.key=t.options.get(e+"_api_key")||""}),this.formFields=[{type:"listbox",name:"service",label:"Map service",tooltip:"Available: Google.",items:s.map(function(e){return{text:s[e].name,value:e}})},{type:"input",name:"key",label:"API Key"},{type:"input",name:"center",label:"Location",tooltip:"This parameter takes a location as either a comma-separated {latitude,longitude} pair (e.g. '40.714728,-73.998672') or a string address (e.g. 'city hall, new york, ny') identifying a unique location on the face of the earth"},{type:"grid",columns:2,items:[{type:"listbox",name:"zoom",label:"Zoom level",tooltip:"This parameter takes a numerical value corresponding to the zoom level of the region desired",items:["10","11","12","13","14","15","16","17","18","19","20"].map(function(e){return{text:e,value:e+""}})},{type:"listbox",name:"markers",label:"Marker",items:["No marker","black","brown","green","purple","yellow","blue","gray","orange","red","white"].map(function(e,i){return{text:e,value:i===0?"":e}})}]},{type:"grid",columns:2,items:[{type:"input",name:"width",label:"Width"},{type:"input",name:"height",label:"Height"}]},{type:"checkbox",label:"Retina (2x)",name:"retina"},{type:"listbox",name:"maptype",label:"Map type",tooltip:"The map type to display. Default to roadmap.",items:["roadmap","satellite"].map(function(e){return{text:e,value:e}})},{type:"textarea",name:"style",label:"Style",tooltip:"Custom style to alter the presentation of a specific feature (roads, parks, and other features) of the map",multiline:!0,rows:3},{type:"listbox",name:"format",label:"Format",tooltip:"JPEG typically provides greater compression, while GIF and PNG provide greater detail.",items:["png8","png32","gif","jpg","jpg-baseline"].map(function(e){return{text:e,value:e}})}],this.showDialog=this.showDialog.bind(this),this.init(t,o)}c.prototype.init=function(o,n){let e=this;o.addCommand("beInsertMap",function(a,l,p){o.insertContent(m(p))}),o.ui.registry.addIcon("map",`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 296.999 296.999" xml:space="preserve" width="24px" height="24px">
<g>
<path d="M141.914,185.802c1.883,1.656,4.234,2.486,6.587,2.486c2.353,0,4.705-0.83,6.587-2.486 c2.385-2.101,58.391-52.021,58.391-103.793c0-35.842-29.148-65.002-64.977-65.002c-35.83,0-64.979,29.16-64.979,65.002 C83.521,133.781,139.529,183.701,141.914,185.802z M148.501,65.025c9.302,0,16.845,7.602,16.845,16.984 c0,9.381-7.543,16.984-16.845,16.984c-9.305,0-16.847-7.604-16.847-16.984C131.654,72.627,139.196,65.025,148.501,65.025z" fill="#333333"/>
<path d="M273.357,185.773l-7.527-26.377c-1.222-4.281-5.133-7.232-9.583-7.232h-53.719c-1.942,2.887-3.991,5.785-6.158,8.699 c-15.057,20.23-30.364,33.914-32.061,35.41c-4.37,3.848-9.983,5.967-15.808,5.967c-5.821,0-11.434-2.117-15.81-5.969 c-1.695-1.494-17.004-15.18-32.06-35.408c-2.167-2.914-4.216-5.813-6.158-8.699h-53.72c-4.45,0-8.361,2.951-9.583,7.232 l-8.971,31.436l200.529,36.73L273.357,185.773z" fill="#333333"/>
<path d="M296.617,267.291l-19.23-67.396l-95.412,80.098h105.06c3.127,0,6.072-1.467,7.955-3.963 C296.873,273.533,297.474,270.297,296.617,267.291z" fill="#333333"/>
<path d="M48.793,209.888l-30.44-5.576L0.383,267.291c-0.857,3.006-0.256,6.242,1.628,8.738c1.883,2.496,4.828,3.963,7.955,3.963 h38.827V209.888z" fill="#333333"/>
<polygon points="62.746,212.445 62.746,279.992 160.273,279.992 208.857,239.207" fill="#333333"/>
</g>
</svg>`),o.ui.registry.addButton("map",{icon:"map",tooltip:"Insert/edit map",onAction:r=>e.showDialog()}),o.ui.registry.addMenuItem("map",{icon:"map",text:"Map",onAction:r=>e.showDialog(),context:"insert"})},c.prototype.showDialog=function(){let o=this,n=this.editor,e=n.dom,i={},r;if(r=n.selection.getNode(),r){let a=e.getAttrib(r,"src");if(a||(a=e.getAttrib(r,"data-mce-p-src")),a.indexOf("//")===0&&(a="https:"+a),a.indexOf("http")===0){let l=new URL(a),p=new URLSearchParams(l.search);for(let[h,f]of p)i[h]=f}i.retina==="true"?i.retina=!0:i.retina=!1,i.center||(i.center=i.q||""),i.service="google_staticmap",s.forEach(function(p){let h=s[p];a.indexOf(h.api)>-1&&(i.service=p)}),i.markers&&(i.markers=i.markers.replace(u,"$1")),i.width=e.getAttrib(r,"width"),i.height=e.getAttrib(r,"height")}i.width||(i.width="400"),i.height||(i.height="300"),this.window=null,this.window=this.editor.windowManager.open({title:"Insert a map",size:"medium",initialData:i,body:{type:"panel",items:[{type:"grid",columns:2,items:[{type:"panel",items:this.formFields},{type:"htmlpanel",html:"<div id='map'></div>"}]}]},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],onChange:function(l){o.render()},onSubmit:function(l){o.onsubmit(),l.close()}}),this.render()},c.prototype.onsubmit=function(o){let e=this.window.getData();this.editor.insertContent(m(e))},c.prototype.render=function(o){let n=this.window.getData(),e="";n.key===""?e="<div class='error'>Please enter a Google Maps API key.</div>":e=m(n,!0);let i=$AM.find("#map")[0];return i.innerHTML=e,e},g.PluginManager.add("map",(t,o)=>{let n=new c(t,o);return{getMetadata:()=>({name:"Map - Fully customizable map for your content.",url:"http://www.brandextract.com"})}})})(window.tinymce);})();
//# sourceMappingURL=plugin.min.js.map