first commit

This commit is contained in:
2024-11-04 19:13:57 +01:00
commit 546cc34310
7718 changed files with 982818 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,286 @@
CKEDITOR.dialog.add( 'googlemapsIcons', function( editor ) {
'use strict';
var MarkerColors = editor.config.googleMaps_markerColors || [ 'green', 'purple', 'yellow', 'blue', 'orange', 'red' ],
columns = MarkerColors.length,
images = [],
dialog;
for (var i = 0; i < columns; i++ ) {
var name = MarkerColors[i];
images.push({ name:name, src:'https://maps.gstatic.com/mapfiles/ms/micons/' + name + '-dot.png' } );
}
var icons = editor.config.googleMaps_Icons;
if (icons) {
for (name in icons) {
var icon = icons[ name ];
images.push( { name:name, src:icon.marker.image } );
}
columns = Math.min( 10, images.length );
}
/**
* Simulate "this" of a dialog for non-dialog events.
* @type {CKEDITOR.dialog}
*/
var onClick = function( evt ) {
var target = evt.data.getTarget(),
targetName = target.getName();
if ( targetName == 'a' )
target = target.getChild( 0 );
else if ( targetName != 'img' )
return;
var name = target.getAttribute( 'data-name' );
dialog.onSelect( name );
dialog.hide();
evt.data.preventDefault();
};
var onKeydown = CKEDITOR.tools.addFunction( function( ev, element ) {
ev = new CKEDITOR.dom.event( ev );
element = new CKEDITOR.dom.element( element );
var relative, nodeToMove;
var keystroke = ev.getKeystroke();
var rtl = editor.lang.dir == 'rtl';
switch ( keystroke ) {
// UP-ARROW
case 38 :
// relative is TR
if ( ( relative = element.getParent().getParent().getPrevious() ) ) {
nodeToMove = relative.getChild( [ element.getParent().getIndex(), 0 ] );
nodeToMove.focus();
}
ev.preventDefault();
break;
// DOWN-ARROW
case 40 :
// relative is TR
if ( ( relative = element.getParent().getParent().getNext() ) ) {
nodeToMove = relative.getChild( [ element.getParent().getIndex(), 0 ] );
if ( nodeToMove )
nodeToMove.focus();
}
ev.preventDefault();
break;
// ENTER
// SPACE
case 32 :
onClick( { data: ev } );
ev.preventDefault();
break;
// RIGHT-ARROW
case rtl ? 37 : 39 :
// TAB
case 9 :
// relative is TD
if ( ( relative = element.getParent().getNext() ) ) {
nodeToMove = relative.getChild( 0 );
nodeToMove.focus();
ev.preventDefault(true);
} else {
// relative is TR
if ( ( relative = element.getParent().getParent().getNext() ) ) {
nodeToMove = relative.getChild( [ 0, 0 ] );
if ( nodeToMove )
nodeToMove.focus();
ev.preventDefault(true);
}
}
break;
// LEFT-ARROW
case rtl ? 39 : 37 :
// SHIFT + TAB
case CKEDITOR.SHIFT + 9 :
// relative is TD
if ( ( relative = element.getParent().getPrevious() ) ) {
nodeToMove = relative.getChild( 0 );
nodeToMove.focus();
ev.preventDefault(true);
} else {
// relative is TR
if ( ( relative = element.getParent().getParent().getPrevious() ) ) {
nodeToMove = relative.getLast().getChild( 0 );
nodeToMove.focus();
ev.preventDefault(true);
}
}
break;
default :
// Do not stop not handled events.
return;
}
});
var buildHtml = function() {
// Build the HTML for the images table.
var html = [
'<table style="width:100%;height:100%" cellspacing="2" cellpadding="2"',
CKEDITOR.env.ie && CKEDITOR.env.quirks ? ' style="position:absolute;"' : '',
'><tbody>'
];
for ( i = 0 ; i < images.length ; i++ ) {
if ( i % columns === 0 )
html.push( '<tr>' );
var image = images[ i ];
html.push(
'<td class="cke_centered" style="vertical-align: middle;">' +
'<a href="javascript:void(0)"',
' class="cke_hand" tabindex="-1" onkeydown="CKEDITOR.tools.callFunction( ', onKeydown, ', event, this );">',
'<img class="cke_hand" ' +
' src="', image.src , '"',
' data-name="', image.name, '"',
// IE BUG: Below is a workaround to an IE image loading bug to ensure the image sizes are correct.
( CKEDITOR.env.ie ? ' onload="this.setAttribute(\'width\', 2); this.removeAttribute(\'width\');" ' : '' ),
'>' +
'</a>',
'</td>' );
if ( i % columns == columns - 1 )
html.push( '</tr>' );
}
if ( i < columns - 1 ) {
for ( ; i < columns - 1 ; i++ )
html.push( '<td></td>' );
html.push( '</tr>' );
}
html.push( '</tbody></table>' );
return html.join( '' );
};
var imagesSelector = {
type : 'html',
html : '<div>' + buildHtml() + '</div>',
id : 'imagesSelector',
onLoad : function( event ) {
dialog = event.sender;
},
focus : function() {
var size = images.length,
i;
for ( i = 0 ; i < size ; i++ ) {
if (images[i].name == dialog.initialName)
break;
}
var initialImage = this.getElement().getElementsByTag( 'a' ).getItem( i );
initialImage.focus();
},
onClick : onClick,
style : 'width: 100%; border-collapse: separate;'
};
function resolveUrl(url) {
// Resolve the url so it becomes a full URL including the host
var img = document.createElement('IMG');
img.src = url;
url = img.src;
img = null;
return url;
}
return {
title : editor.lang.googlemaps.selectIcon,
minWidth : 270,
minHeight : 80,
contents : [
{
id : 'Info',
label : '',
title : '',
padding : 0,
elements : [
imagesSelector,
{
type:'hbox',
children: [
{
type : 'button',
id : 'browse',
style : 'margin-top:4px;margin-bottom:2px; display:inline-block;',
label : editor.lang.common.browseServer,
filebrowser :
{
action : 'Browse',
target: 'Info:txtUrl',
url: editor.config.filebrowserIconBrowseUrl || editor.config.filebrowserImageBrowseUrl || editor.config.filebrowserBrowseUrl
}
},
{
type:'text',
hidden:true,
id:'txtUrl',
onChange: function() {
// Add new icon and select it:
var value = resolveUrl(this.getValue()),
nameParts = value.match(/([^\/]+)\.[^\/]*$/) || value.match(/([^\/]+)[^\/]*$/),
name = nameParts && nameParts[1] || value,
dialog = this.getDialog(),
resized = false;
// clean up
name = name.replace(/[^\w]/g, '');
// Initialize the object if it doesn't exist
if (!editor.config.googleMaps_Icons)
editor.config.googleMaps_Icons = {};
// Add the image if it isn't available in the set
if (!editor.config.googleMaps_Icons[ name ]) {
// Push the new marker
var marker = { marker : { image: value } },
shadow = editor.config.googleMaps_shadowMarker;
if (shadow) {
if (typeof shadow != 'string')
shadow = shadow( value );
marker.shadow = { image: shadow };
}
editor.config.googleMaps_Icons[ name ] = marker;
images.push( { name:name, src:value } );
var contents = dialog.parts.contents,
contentTable = contents.getFirst().getFirst().$,
initial = { width:contentTable.offsetWidth, height: contentTable.offsetHeight };
// rebuild the table so it shows correctly when the dialog opens again
dialog.getContentElement('Info', 'imagesSelector').getElement().setHtml( buildHtml() );
// Check if we need to resize the dialog
if (contentTable.offsetWidth > initial.width || contentTable.offsetHeight > initial.height) {
resized = true;
dialog.resize( contentTable.offsetWidth, contentTable.offsetHeight);
}
}
// select it
dialog.onSelect( name );
if ( !resized || !CKEDITOR.env.ie || CKEDITOR.env.ie9Compat )
dialog.hide();
else {
// In some skins there's a function executed on a timeout after a dialog resize,
// so we must delay the hide until it's performed.
setTimeout( function() { dialog.hide(); }, ( editor.lang.dir == 'rtl' ? 1001 : 101) );
}
}
}
]
}
]
}
],
buttons : [ CKEDITOR.dialog.cancelButton ]
};
} );

View File

@@ -0,0 +1,232 @@
CKEDITOR.dialog.add( 'googlemapsLine', function( editor ) {
'use strict';
var fldAreaProperties,
mode;
function pickAColor( button, field ) {
var thisDialog = button.getDialog();
editor.openNestedDialog( 'colordialog',
// before showing
function( dialog ) {
var color = thisDialog.getValueOf( 'Info', field),
control = dialog.getContentElement( 'picker', 'selectedColor');
// set initial value
control.setValue( color );
control.setInitValue();
},
// on OK
function( dialog ) {
var control = dialog.getContentElement( 'picker', 'selectedColor');
thisDialog.getContentElement( 'Info', field ).setValue( control.getValue() );
// Reset to empty default
control.setValue( '' );
control.setInitValue();
});
}
return {
title : editor.lang.googlemaps.properties,
minWidth : 230,
minHeight : 140,
resizable : false,
buttons : [ {
type : 'button',
id : 'deleteOverlay',
label : editor.lang.googlemaps.deleteMarker,
onClick : function( evt ) {
var dialog = evt.sender.getDialog();
dialog.onRemoveOverlay();
dialog.hide();
}
}, CKEDITOR.dialog.okButton, CKEDITOR.dialog.cancelButton ],
onLoad: function() {
fldAreaProperties = this.getContentElement( 'Info', 'fldAreaProperties').getElement();
this.setValues = function( data ) { this.definition.setValues.call(this, data); };
this.getValues = function() { return this.definition.getValues.call(this); };
},
setValues : function(data) {
var control = this.getContentElement( 'Info', 'cmbStrokeWeight');
control.setValue( data.strokeWeight );
control.setInitValue();
control = this.getContentElement( 'Info', 'cmbStrokeOpacity');
control.setValue( data.strokeOpacity );
control.setInitValue();
control = this.getContentElement( 'Info', 'txtStrokeColor');
control.setValue( data.strokeColor );
control.setInitValue();
if (data.fillOpacity) {
mode = 'polygon';
fldAreaProperties.show();
control = this.getContentElement( 'Info', 'cmbFillOpacity');
control.setValue( data.fillOpacity );
control.setInitValue();
control = this.getContentElement( 'Info', 'txtFillColor');
control.setValue( data.fillColor );
control.setInitValue();
this.resize(230, 240);
} else {
mode = 'polyline';
fldAreaProperties.hide();
this.resize(230, 140);
}
},
getValues : function() {
var data = {
strokeWeight: parseInt(this.getValueOf( 'Info', 'cmbStrokeWeight'), 10),
strokeOpacity: parseFloat(this.getValueOf( 'Info', 'cmbStrokeOpacity')),
strokeColor: this.getValueOf( 'Info', 'txtStrokeColor')
};
if (mode == 'polygon') {
data.fillOpacity = parseFloat(this.getValueOf( 'Info', 'cmbFillOpacity'));
data.fillColor = this.getValueOf( 'Info', 'txtFillColor');
}
return data;
},
contents : [
{
id : 'Info',
elements :
[
{
type: 'fieldset',
id: 'fldLineProperties',
label: editor.lang.googlemaps.lineProperties,
children:
[
{
id : 'cmbStrokeWeight',
label: editor.lang.googlemaps.strokeWeight + ' ',
labelLayout : 'horizontal',
widths: [ '55px', '65px' ],
style : 'width:130px; margin-bottom:1em;',
inputStyle : 'width:45px; padding-left:0; padding-right:0;',
type : 'select',
items :
[
[ '1', '1' ],
[ '2', '2' ],
[ '3', '3' ],
[ '4', '4' ],
[ '5', '5' ],
[ '6', '6' ],
[ '7', '7' ],
[ '8', '8' ],
[ '9', '9' ],
[ '10', '10' ]
]
},
{
id : 'cmbStrokeOpacity',
label: editor.lang.googlemaps.strokeOpacity + ' ',
labelLayout : 'horizontal',
widths: [ '55px', '65px' ],
style : 'width:130px; margin-bottom:1em;',
inputStyle : 'width:45px; padding-left:0; padding-right:0;',
type : 'select',
items :
[
[ '0.1', '0.1' ],
[ '0.2', '0.2' ],
[ '0.3', '0.3' ],
[ '0.4', '0.4' ],
[ '0.5', '0.5' ],
[ '0.6', '0.6' ],
[ '0.7', '0.7' ],
[ '0.8', '0.8' ],
[ '0.9', '0.9' ],
[ '1', '1' ]
]
},
{
type:'hbox',
widths: [ '130px', '80px' ],
children:
[
{
id : 'txtStrokeColor',
type : 'text',
label: editor.lang.googlemaps.strokeColor,
labelLayout : 'horizontal',
widths: [ '55px', '65px' ],
width: '65px'
},
{
id : 'btnColor',
type : 'button',
label : editor.lang.googlemaps.chooseColor,
onClick : function() {pickAColor( this, 'txtStrokeColor'); }
}
]
}
]
},
{
type: 'fieldset',
id: 'fldAreaProperties',
label: editor.lang.googlemaps.areaProperties,
children:
[
{
id : 'cmbFillOpacity',
label: editor.lang.googlemaps.fillOpacity + ' ',
labelLayout : 'horizontal',
widths: [ '55px', '65px' ],
style : 'width:130px; margin-bottom:1em;',
inputStyle : 'width:45px; padding-left:0; padding-right:0;',
type : 'select',
items :
[
[ '0.1', '0.1' ],
[ '0.2', '0.2' ],
[ '0.3', '0.3' ],
[ '0.4', '0.4' ],
[ '0.5', '0.5' ],
[ '0.6', '0.6' ],
[ '0.7', '0.7' ],
[ '0.8', '0.8' ],
[ '0.9', '0.9' ],
[ '1', '1' ]
]
},
{
type:'hbox',
widths: [ '130px', '80px' ],
children:
[
{
id : 'txtFillColor',
type : 'text',
label: editor.lang.googlemaps.fillColor,
labelLayout : 'horizontal',
widths: [ '55px', '65px' ],
style : 'width:130px; ',
width: '65px'
},
{
id : 'btnFillColor',
type : 'button',
label : editor.lang.googlemaps.chooseColor,
onClick : function() {pickAColor( this, 'txtFillColor'); }
}
]
}
]
}
]
}
]
};
} );

View File

@@ -0,0 +1,183 @@
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 : '<div>px</div>'
},
{
type : 'html',
onClick : function(evt) {
var target = evt.data.getTarget(),
targetName = target.getName();
if (targetName == 'img') {
editor.openNestedDialog( 'googlemapsIcons', function(dialog) {
dialog.initialName = markerImage;
dialog.onSelect = function( name ) { markerImage = name; document.getElementById( markerIcon ).src = getIcon( markerImage );};
}, null);
}
},
html : '<div style="width:60px"><label style="float:left">' + editor.lang.googlemaps.markerIcon + '</label><img id="' + markerIcon + '" class="cke_hand"></div>'
}
]
},
{
type : 'html',
onLoad : function() {
var removePlugins = 'elementspath,resize,googlemaps';
// we have to remove any plugin that was removed in the main instance.
var removed = editor.config.removePlugins;
if (removed)
removePlugins += ',' + removed;
// http://dev.ckeditor.com/ticket/10731
if (editor.config.wsc_stack)
delete editor.config.wsc_stack;
if (CKEDITOR.config.wsc_stack)
CKEDITOR.config.wsc_stack = [];
// Copy all the configuration options
var config = CKEDITOR.tools.clone( editor.config );
config.customConfig = '';
config.width = '450px';
config.height = 140;
config.toolbar = editor.config.googleMaps_toolbar || [ [ 'Bold', 'Italic', 'Link', 'Image' ], [ 'Undo', 'Redo' ], [ 'GMapsInsertDirections' ] ];
config.removePlugins = removePlugins;
config.toolbarCanCollapse = false;
config.on = {
// Add extra buttons
'pluginsLoaded' : function(ev ) {
ev.editor.addCommand( 'gmapsinsertdirections', {
exec : function( thisEditor ) {
var link = 'http://maps.google.com/maps?daddr=' + encodeURIComponent( theDialog.getValueOf('Info', 'txtTooltip')) + ' @' + point.getPosition().toUrlValue();
thisEditor.insertHtml( '<a href="' + link + '" target="_blank">' + editor.lang.googlemaps.directionsTitle + '</a>' );
}
} );
// Add a custom toolbar button
ev.editor.ui.addButton( 'GMapsInsertDirections',
{
label : editor.lang.googlemaps.directions,
/* icon from FamFamFam http://www.famfamfam.com/lab/icons/silk/ */
icon : editor.plugins.googlemaps.path + '/icons/gmapsinsertdirections.png', // %REMOVE_LINE_CORE%
command : 'gmapsinsertdirections'
} );
}
};
CKEDITOR.replace( GMapTexts, config);
},
html : '<textarea id="' + GMapTexts + '"></textarea>'
}
]
}
]
};
} );

View File

@@ -0,0 +1,39 @@
CKEDITOR.dialog.add( 'googlemapsText', function( editor ) {
'use strict';
return {
title : editor.lang.googlemaps.textProperties,
minWidth : 200,
minHeight : 35,
onLoad: function() {
this.setValues = function( data ) { this.definition.setValues.call(this, data); };
this.getValues = function() { return this.definition.getValues.call(this); };
},
setValues : function(data) {
var control = this.getContentElement( 'Info', 'txtTooltip');
control.setValue( data.title );
control.setInitValue();
},
getValues : function() {
return {
title: this.getValueOf( 'Info', 'txtTooltip')
};
},
contents : [
{
id : 'Info',
elements :
[
{
id : 'txtTooltip',
type : 'text'
}
]
}
]
};
} );