1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
CKEDITOR.dialog.add( 'mediaembedDialog', function( editor ) {
|
7
|
var numberRegex = /^\d+(?:\.\d+)?$/;
|
8
|
var cssifyLength = function( length )
|
9
|
{
|
10
|
if ( numberRegex.test( length ) )
|
11
|
return length + 'px';
|
12
|
return length;
|
13
|
}
|
14
|
return {
|
15
|
title : Drupal.t('Embed Media Dialog'),
|
16
|
minWidth : 400,
|
17
|
minHeight : 200,
|
18
|
contents : [
|
19
|
{
|
20
|
id : 'mediaTab',
|
21
|
label : Drupal.t('Embed media code'),
|
22
|
title : Drupal.t('Embed media code'),
|
23
|
elements :
|
24
|
[
|
25
|
{
|
26
|
id : 'embed',
|
27
|
type : 'textarea',
|
28
|
rows : 9,
|
29
|
label : Drupal.t('Paste embed code here')
|
30
|
}
|
31
|
]
|
32
|
}
|
33
|
],
|
34
|
onOk : function() {
|
35
|
var editor = this.getParentEditor();
|
36
|
var content = this.getValueOf( 'mediaTab', 'embed' );
|
37
|
if ( content.length>0 ) {
|
38
|
var realElement = CKEDITOR.dom.element.createFromHtml('<div class="media_embed"></div>');
|
39
|
realElement.setHtml(content);
|
40
|
var fakeElement = editor.createFakeElement( realElement , 'cke_mediaembed', 'div', true);
|
41
|
var matches = content.match(/width=(["']?)(\d+)\1/i);
|
42
|
if (matches && matches.length == 3) {
|
43
|
fakeElement.setStyle('width', cssifyLength(matches[2]));
|
44
|
}
|
45
|
matches = content.match(/height=([\"\']?)(\d+)\1/i);
|
46
|
if (matches && matches.length == 3) {
|
47
|
fakeElement.setStyle('height', cssifyLength(matches[2]));
|
48
|
}
|
49
|
editor.insertElement(fakeElement);
|
50
|
}
|
51
|
}
|
52
|
};
|
53
|
});
|
54
|
|