forked from ckeditor/ckeditor4
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathembedbase.js
More file actions
102 lines (78 loc) · 2.29 KB
/
Copy pathembedbase.js
File metadata and controls
102 lines (78 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
/* global alert */
CKEDITOR.dialog.add( 'embedBase', function( editor ) {
'use strict';
var lang = editor.lang.embedbase;
return {
title: lang.title,
minWidth: 350,
minHeight: 50,
onLoad: function() {
var that = this,
loadContentRequest = null;
this.on( 'ok', function( evt ) {
// We're going to hide it manually, after remote response is fetched.
evt.data.hide = false;
// We don't want the widget system to finalize widget insertion (it happens with priority 20).
evt.stop();
// Indicate visually that waiting for the response (https://dev.ckeditor.com/ticket/13213).
that.setState( CKEDITOR.DIALOG_STATE_BUSY );
var url = that.getValueOf( 'info', 'url' ),
widget = that.getModel( editor );
loadContentRequest = widget.loadContent( url, {
noNotifications: true,
callback: function() {
if ( !widget.isReady() ) {
editor.widgets.finalizeCreation( widget.wrapper.getParent( true ) );
}
editor.fire( 'saveSnapshot' );
that.hide();
unlock();
},
errorCallback: function( messageTypeOrMessage ) {
that.getContentElement( 'info', 'url' ).select();
alert( widget.getErrorMessage( messageTypeOrMessage, url, 'Given' ) );
unlock();
}
} );
}, null, null, 15 );
this.on( 'cancel', function( evt ) {
if ( evt.data.hide && loadContentRequest ) {
loadContentRequest.cancel();
unlock();
}
} );
function unlock() {
// Visual waiting indicator is no longer needed (https://dev.ckeditor.com/ticket/13213).
that.setState( CKEDITOR.DIALOG_STATE_IDLE );
loadContentRequest = null;
}
},
contents: [
{
id: 'info',
elements: [
{
type: 'text',
id: 'url',
label: editor.lang.common.url,
required: true,
setup: function( widget ) {
this.setValue( widget.data.url );
},
validate: function() {
var widget = this.getDialog().getModel( editor );
if ( !widget.isUrlValid( this.getValue() ) ) {
return lang.unsupportedUrlGiven;
}
return true;
}
}
]
}
]
};
} );