CKEDITOR.dialog.add( 'googlemapsMarker', function( editor ) { 'use strict'; var numbering = function( id ) { return id + CKEDITOR.tools.getNextNumber(); }, markerIcon = numbering( 'markerIcon' ), GMapTexts = numbering( 'GMapTexts' ), googleMaps_Icons = editor.config.googleMaps_Icons, markerImage, point, theDialog; function getIcon( color ) { var data = googleMaps_Icons && googleMaps_Icons[ color ]; if (!data) return 'https://maps.gstatic.com/mapfiles/ms/micons/' + color + '-dot.png'; // fixme... return data.marker.image; } return { title : editor.lang.googlemaps.markerProperties, minWidth : 310, minHeight : 240, buttons : [ { type : 'button', id : 'deleteMarker', label : editor.lang.googlemaps.deleteMarker, onClick : function( evt ) { var dialog = evt.sender.getDialog(); dialog.onRemoveMarker(); dialog.hide(); } }, CKEDITOR.dialog.okButton, CKEDITOR.dialog.cancelButton ], onLoad: function() { theDialog = this; this.setValues = function( data ) { this.definition.setValues.call(this, data); }; this.getValues = function() { return this.definition.getValues.call(this); }; // We have to destroy the internal CKEditor instance when this dialog is destroyed: this.destroy = CKEDITOR.tools.override( this.destroy, function( original ) { return function() { CKEDITOR.instances[ GMapTexts ].destroy(); original.call( this ); }; } ); }, setValues : function(data) { point = data; var control = this.getContentElement( 'Info', 'txtTooltip'); control.setValue( data.title ); control.setInitValue(); control = this.getContentElement( 'Info', 'txtWidth'); control.setValue( data.maxWidth ); control.setInitValue(); var instance = CKEDITOR.instances[ GMapTexts ]; if (instance) instance.setData( data.text ); else document.getElementById( GMapTexts ).value = data.text; markerImage = data.color; document.getElementById( markerIcon ).src = getIcon( markerImage ); }, getValues : function() { return { title: this.getValueOf( 'Info', 'txtTooltip'), maxWidth: this.getValueOf( 'Info', 'txtWidth'), text: CKEDITOR.instances[ GMapTexts ].getData(), color: markerImage }; }, contents : [ { id : 'Info', elements : [ { type : 'hbox', widths : [ '150px', '80px; padding-right:2px', '10px', '60px' ], children : [ { id : 'txtTooltip', type : 'text', widths: [ '70px', '90px' ], width : '160px', labelLayout : 'horizontal', label : editor.lang.googlemaps.tooltip }, { id : 'txtWidth', type : 'text', widths: [ '40px', '36px' ], width : '50px', labelLayout : 'horizontal', label : editor.lang.googlemaps.width }, { type : 'html', html : '