diff options
Diffstat (limited to 'sources/plugins/link/dialogs')
-rw-r--r-- | sources/plugins/link/dialogs/anchor.js | 105 | ||||
-rw-r--r-- | sources/plugins/link/dialogs/link.js | 904 |
2 files changed, 1009 insertions, 0 deletions
diff --git a/sources/plugins/link/dialogs/anchor.js b/sources/plugins/link/dialogs/anchor.js new file mode 100644 index 00000000..899f7dc4 --- /dev/null +++ b/sources/plugins/link/dialogs/anchor.js | |||
@@ -0,0 +1,105 @@ | |||
1 | /** | ||
2 | * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. | ||
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license | ||
4 | */ | ||
5 | |||
6 | CKEDITOR.dialog.add( 'anchor', function( editor ) { | ||
7 | // Function called in onShow to load selected element. | ||
8 | var loadElements = function( element ) { | ||
9 | this._.selectedElement = element; | ||
10 | |||
11 | var attributeValue = element.data( 'cke-saved-name' ); | ||
12 | this.setValueOf( 'info', 'txtName', attributeValue || '' ); | ||
13 | }; | ||
14 | |||
15 | function createFakeAnchor( editor, attributes ) { | ||
16 | return editor.createFakeElement( editor.document.createElement( 'a', { | ||
17 | attributes: attributes | ||
18 | } ), 'cke_anchor', 'anchor' ); | ||
19 | } | ||
20 | |||
21 | return { | ||
22 | title: editor.lang.link.anchor.title, | ||
23 | minWidth: 300, | ||
24 | minHeight: 60, | ||
25 | onOk: function() { | ||
26 | var name = CKEDITOR.tools.trim( this.getValueOf( 'info', 'txtName' ) ); | ||
27 | var attributes = { | ||
28 | id: name, | ||
29 | name: name, | ||
30 | 'data-cke-saved-name': name | ||
31 | }; | ||
32 | |||
33 | if ( this._.selectedElement ) { | ||
34 | if ( this._.selectedElement.data( 'cke-realelement' ) ) { | ||
35 | var newFake = createFakeAnchor( editor, attributes ); | ||
36 | newFake.replace( this._.selectedElement ); | ||
37 | |||
38 | // Selecting fake element for IE. (#11377) | ||
39 | if ( CKEDITOR.env.ie ) | ||
40 | editor.getSelection().selectElement( newFake ); | ||
41 | } else { | ||
42 | this._.selectedElement.setAttributes( attributes ); | ||
43 | } | ||
44 | } else { | ||
45 | var sel = editor.getSelection(), | ||
46 | range = sel && sel.getRanges()[ 0 ]; | ||
47 | |||
48 | // Empty anchor | ||
49 | if ( range.collapsed ) { | ||
50 | var anchor = createFakeAnchor( editor, attributes ); | ||
51 | range.insertNode( anchor ); | ||
52 | } else { | ||
53 | if ( CKEDITOR.env.ie && CKEDITOR.env.version < 9 ) | ||
54 | attributes[ 'class' ] = 'cke_anchor'; | ||
55 | |||
56 | // Apply style. | ||
57 | var style = new CKEDITOR.style( { element: 'a', attributes: attributes } ); | ||
58 | style.type = CKEDITOR.STYLE_INLINE; | ||
59 | editor.applyStyle( style ); | ||
60 | } | ||
61 | } | ||
62 | }, | ||
63 | |||
64 | onHide: function() { | ||
65 | delete this._.selectedElement; | ||
66 | }, | ||
67 | |||
68 | onShow: function() { | ||
69 | var sel = editor.getSelection(), | ||
70 | fullySelected = sel.getSelectedElement(), | ||
71 | fakeSelected = fullySelected && fullySelected.data( 'cke-realelement' ), | ||
72 | linkElement = fakeSelected ? | ||
73 | CKEDITOR.plugins.link.tryRestoreFakeAnchor( editor, fullySelected ) : | ||
74 | CKEDITOR.plugins.link.getSelectedLink( editor ); | ||
75 | |||
76 | if ( linkElement ) { | ||
77 | loadElements.call( this, linkElement ); | ||
78 | !fakeSelected && sel.selectElement( linkElement ); | ||
79 | |||
80 | if ( fullySelected ) | ||
81 | this._.selectedElement = fullySelected; | ||
82 | } | ||
83 | |||
84 | this.getContentElement( 'info', 'txtName' ).focus(); | ||
85 | }, | ||
86 | contents: [ { | ||
87 | id: 'info', | ||
88 | label: editor.lang.link.anchor.title, | ||
89 | accessKey: 'I', | ||
90 | elements: [ { | ||
91 | type: 'text', | ||
92 | id: 'txtName', | ||
93 | label: editor.lang.link.anchor.name, | ||
94 | required: true, | ||
95 | validate: function() { | ||
96 | if ( !this.getValue() ) { | ||
97 | alert( editor.lang.link.anchor.errorName ); // jshint ignore:line | ||
98 | return false; | ||
99 | } | ||
100 | return true; | ||
101 | } | ||
102 | } ] | ||
103 | } ] | ||
104 | }; | ||
105 | } ); | ||
diff --git a/sources/plugins/link/dialogs/link.js b/sources/plugins/link/dialogs/link.js new file mode 100644 index 00000000..96dd288a --- /dev/null +++ b/sources/plugins/link/dialogs/link.js | |||
@@ -0,0 +1,904 @@ | |||
1 | /** | ||
2 | * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. | ||
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license | ||
4 | */ | ||
5 | |||
6 | 'use strict'; | ||
7 | |||
8 | ( function() { | ||
9 | CKEDITOR.dialog.add( 'link', function( editor ) { | ||
10 | var plugin = CKEDITOR.plugins.link; | ||
11 | |||
12 | // Handles the event when the "Target" selection box is changed. | ||
13 | var targetChanged = function() { | ||
14 | var dialog = this.getDialog(), | ||
15 | popupFeatures = dialog.getContentElement( 'target', 'popupFeatures' ), | ||
16 | targetName = dialog.getContentElement( 'target', 'linkTargetName' ), | ||
17 | value = this.getValue(); | ||
18 | |||
19 | if ( !popupFeatures || !targetName ) | ||
20 | return; | ||
21 | |||
22 | popupFeatures = popupFeatures.getElement(); | ||
23 | popupFeatures.hide(); | ||
24 | targetName.setValue( '' ); | ||
25 | |||
26 | switch ( value ) { | ||
27 | case 'frame': | ||
28 | targetName.setLabel( editor.lang.link.targetFrameName ); | ||
29 | targetName.getElement().show(); | ||
30 | break; | ||
31 | case 'popup': | ||
32 | popupFeatures.show(); | ||
33 | targetName.setLabel( editor.lang.link.targetPopupName ); | ||
34 | targetName.getElement().show(); | ||
35 | break; | ||
36 | default: | ||
37 | targetName.setValue( value ); | ||
38 | targetName.getElement().hide(); | ||
39 | break; | ||
40 | } | ||
41 | |||
42 | }; | ||
43 | |||
44 | // Handles the event when the "Type" selection box is changed. | ||
45 | var linkTypeChanged = function() { | ||
46 | var dialog = this.getDialog(), | ||
47 | partIds = [ 'urlOptions', 'anchorOptions', 'emailOptions' ], | ||
48 | typeValue = this.getValue(), | ||
49 | uploadTab = dialog.definition.getContents( 'upload' ), | ||
50 | uploadInitiallyHidden = uploadTab && uploadTab.hidden; | ||
51 | |||
52 | if ( typeValue == 'url' ) { | ||
53 | if ( editor.config.linkShowTargetTab ) | ||
54 | dialog.showPage( 'target' ); | ||
55 | if ( !uploadInitiallyHidden ) | ||
56 | dialog.showPage( 'upload' ); | ||
57 | } else { | ||
58 | dialog.hidePage( 'target' ); | ||
59 | if ( !uploadInitiallyHidden ) | ||
60 | dialog.hidePage( 'upload' ); | ||
61 | } | ||
62 | |||
63 | for ( var i = 0; i < partIds.length; i++ ) { | ||
64 | var element = dialog.getContentElement( 'info', partIds[ i ] ); | ||
65 | if ( !element ) | ||
66 | continue; | ||
67 | |||
68 | element = element.getElement().getParent().getParent(); | ||
69 | if ( partIds[ i ] == typeValue + 'Options' ) | ||
70 | element.show(); | ||
71 | else | ||
72 | element.hide(); | ||
73 | } | ||
74 | |||
75 | dialog.layout(); | ||
76 | }; | ||
77 | |||
78 | var setupParams = function( page, data ) { | ||
79 | if ( data[ page ] ) | ||
80 | this.setValue( data[ page ][ this.id ] || '' ); | ||
81 | }; | ||
82 | |||
83 | var setupPopupParams = function( data ) { | ||
84 | return setupParams.call( this, 'target', data ); | ||
85 | }; | ||
86 | |||
87 | var setupAdvParams = function( data ) { | ||
88 | return setupParams.call( this, 'advanced', data ); | ||
89 | }; | ||
90 | |||
91 | var commitParams = function( page, data ) { | ||
92 | if ( !data[ page ] ) | ||
93 | data[ page ] = {}; | ||
94 | |||
95 | data[ page ][ this.id ] = this.getValue() || ''; | ||
96 | }; | ||
97 | |||
98 | var commitPopupParams = function( data ) { | ||
99 | return commitParams.call( this, 'target', data ); | ||
100 | }; | ||
101 | |||
102 | var commitAdvParams = function( data ) { | ||
103 | return commitParams.call( this, 'advanced', data ); | ||
104 | }; | ||
105 | |||
106 | var commonLang = editor.lang.common, | ||
107 | linkLang = editor.lang.link, | ||
108 | anchors; | ||
109 | |||
110 | return { | ||
111 | title: linkLang.title, | ||
112 | minWidth: 350, | ||
113 | minHeight: 230, | ||
114 | contents: [ { | ||
115 | id: 'info', | ||
116 | label: linkLang.info, | ||
117 | title: linkLang.info, | ||
118 | elements: [ { | ||
119 | id: 'linkType', | ||
120 | type: 'select', | ||
121 | label: linkLang.type, | ||
122 | 'default': 'url', | ||
123 | items: [ | ||
124 | [ linkLang.toUrl, 'url' ], | ||
125 | [ linkLang.toAnchor, 'anchor' ], | ||
126 | [ linkLang.toEmail, 'email' ] | ||
127 | ], | ||
128 | onChange: linkTypeChanged, | ||
129 | setup: function( data ) { | ||
130 | this.setValue( data.type || 'url' ); | ||
131 | }, | ||
132 | commit: function( data ) { | ||
133 | data.type = this.getValue(); | ||
134 | } | ||
135 | }, | ||
136 | { | ||
137 | type: 'vbox', | ||
138 | id: 'urlOptions', | ||
139 | children: [ { | ||
140 | type: 'hbox', | ||
141 | widths: [ '25%', '75%' ], | ||
142 | children: [ { | ||
143 | id: 'protocol', | ||
144 | type: 'select', | ||
145 | label: commonLang.protocol, | ||
146 | 'default': 'http://', | ||
147 | items: [ | ||
148 | // Force 'ltr' for protocol names in BIDI. (#5433) | ||
149 | [ 'http://\u200E', 'http://' ], | ||
150 | [ 'https://\u200E', 'https://' ], | ||
151 | [ 'ftp://\u200E', 'ftp://' ], | ||
152 | [ 'news://\u200E', 'news://' ], | ||
153 | [ linkLang.other, '' ] | ||
154 | ], | ||
155 | setup: function( data ) { | ||
156 | if ( data.url ) | ||
157 | this.setValue( data.url.protocol || '' ); | ||
158 | }, | ||
159 | commit: function( data ) { | ||
160 | if ( !data.url ) | ||
161 | data.url = {}; | ||
162 | |||
163 | data.url.protocol = this.getValue(); | ||
164 | } | ||
165 | }, | ||
166 | { | ||
167 | type: 'text', | ||
168 | id: 'url', | ||
169 | label: commonLang.url, | ||
170 | required: true, | ||
171 | onLoad: function() { | ||
172 | this.allowOnChange = true; | ||
173 | }, | ||
174 | onKeyUp: function() { | ||
175 | this.allowOnChange = false; | ||
176 | var protocolCmb = this.getDialog().getContentElement( 'info', 'protocol' ), | ||
177 | url = this.getValue(), | ||
178 | urlOnChangeProtocol = /^(http|https|ftp|news):\/\/(?=.)/i, | ||
179 | urlOnChangeTestOther = /^((javascript:)|[#\/\.\?])/i; | ||
180 | |||
181 | var protocol = urlOnChangeProtocol.exec( url ); | ||
182 | if ( protocol ) { | ||
183 | this.setValue( url.substr( protocol[ 0 ].length ) ); | ||
184 | protocolCmb.setValue( protocol[ 0 ].toLowerCase() ); | ||
185 | } else if ( urlOnChangeTestOther.test( url ) ) { | ||
186 | protocolCmb.setValue( '' ); | ||
187 | } | ||
188 | |||
189 | this.allowOnChange = true; | ||
190 | }, | ||
191 | onChange: function() { | ||
192 | if ( this.allowOnChange ) // Dont't call on dialog load. | ||
193 | this.onKeyUp(); | ||
194 | }, | ||
195 | validate: function() { | ||
196 | var dialog = this.getDialog(); | ||
197 | |||
198 | if ( dialog.getContentElement( 'info', 'linkType' ) && dialog.getValueOf( 'info', 'linkType' ) != 'url' ) | ||
199 | return true; | ||
200 | |||
201 | if ( !editor.config.linkJavaScriptLinksAllowed && ( /javascript\:/ ).test( this.getValue() ) ) { | ||
202 | alert( commonLang.invalidValue ); // jshint ignore:line | ||
203 | return false; | ||
204 | } | ||
205 | |||
206 | if ( this.getDialog().fakeObj ) // Edit Anchor. | ||
207 | return true; | ||
208 | |||
209 | var func = CKEDITOR.dialog.validate.notEmpty( linkLang.noUrl ); | ||
210 | return func.apply( this ); | ||
211 | }, | ||
212 | setup: function( data ) { | ||
213 | this.allowOnChange = false; | ||
214 | if ( data.url ) | ||
215 | this.setValue( data.url.url ); | ||
216 | this.allowOnChange = true; | ||
217 | |||
218 | }, | ||
219 | commit: function( data ) { | ||
220 | // IE will not trigger the onChange event if the mouse has been used | ||
221 | // to carry all the operations #4724 | ||
222 | this.onChange(); | ||
223 | |||
224 | if ( !data.url ) | ||
225 | data.url = {}; | ||
226 | |||
227 | data.url.url = this.getValue(); | ||
228 | this.allowOnChange = false; | ||
229 | } | ||
230 | } ], | ||
231 | setup: function() { | ||
232 | if ( !this.getDialog().getContentElement( 'info', 'linkType' ) ) | ||
233 | this.getElement().show(); | ||
234 | } | ||
235 | }, | ||
236 | { | ||
237 | type: 'button', | ||
238 | id: 'browse', | ||
239 | hidden: 'true', | ||
240 | filebrowser: 'info:url', | ||
241 | label: commonLang.browseServer | ||
242 | } ] | ||
243 | }, | ||
244 | { | ||
245 | type: 'vbox', | ||
246 | id: 'anchorOptions', | ||
247 | width: 260, | ||
248 | align: 'center', | ||
249 | padding: 0, | ||
250 | children: [ { | ||
251 | type: 'fieldset', | ||
252 | id: 'selectAnchorText', | ||
253 | label: linkLang.selectAnchor, | ||
254 | setup: function() { | ||
255 | anchors = plugin.getEditorAnchors( editor ); | ||
256 | |||
257 | this.getElement()[ anchors && anchors.length ? 'show' : 'hide' ](); | ||
258 | }, | ||
259 | children: [ { | ||
260 | type: 'hbox', | ||
261 | id: 'selectAnchor', | ||
262 | children: [ { | ||
263 | type: 'select', | ||
264 | id: 'anchorName', | ||
265 | 'default': '', | ||
266 | label: linkLang.anchorName, | ||
267 | style: 'width: 100%;', | ||
268 | items: [ | ||
269 | [ '' ] | ||
270 | ], | ||
271 | setup: function( data ) { | ||
272 | this.clear(); | ||
273 | this.add( '' ); | ||
274 | |||
275 | if ( anchors ) { | ||
276 | for ( var i = 0; i < anchors.length; i++ ) { | ||
277 | if ( anchors[ i ].name ) | ||
278 | this.add( anchors[ i ].name ); | ||
279 | } | ||
280 | } | ||
281 | |||
282 | if ( data.anchor ) | ||
283 | this.setValue( data.anchor.name ); | ||
284 | |||
285 | var linkType = this.getDialog().getContentElement( 'info', 'linkType' ); | ||
286 | if ( linkType && linkType.getValue() == 'email' ) | ||
287 | this.focus(); | ||
288 | }, | ||
289 | commit: function( data ) { | ||
290 | if ( !data.anchor ) | ||
291 | data.anchor = {}; | ||
292 | |||
293 | data.anchor.name = this.getValue(); | ||
294 | } | ||
295 | }, | ||
296 | { | ||
297 | type: 'select', | ||
298 | id: 'anchorId', | ||
299 | 'default': '', | ||
300 | label: linkLang.anchorId, | ||
301 | style: 'width: 100%;', | ||
302 | items: [ | ||
303 | [ '' ] | ||
304 | ], | ||
305 | setup: function( data ) { | ||
306 | this.clear(); | ||
307 | this.add( '' ); | ||
308 | |||
309 | if ( anchors ) { | ||
310 | for ( var i = 0; i < anchors.length; i++ ) { | ||
311 | if ( anchors[ i ].id ) | ||
312 | this.add( anchors[ i ].id ); | ||
313 | } | ||
314 | } | ||
315 | |||
316 | if ( data.anchor ) | ||
317 | this.setValue( data.anchor.id ); | ||
318 | }, | ||
319 | commit: function( data ) { | ||
320 | if ( !data.anchor ) | ||
321 | data.anchor = {}; | ||
322 | |||
323 | data.anchor.id = this.getValue(); | ||
324 | } | ||
325 | } ], | ||
326 | setup: function() { | ||
327 | this.getElement()[ anchors && anchors.length ? 'show' : 'hide' ](); | ||
328 | } | ||
329 | } ] | ||
330 | }, | ||
331 | { | ||
332 | type: 'html', | ||
333 | id: 'noAnchors', | ||
334 | style: 'text-align: center;', | ||
335 | html: '<div role="note" tabIndex="-1">' + CKEDITOR.tools.htmlEncode( linkLang.noAnchors ) + '</div>', | ||
336 | // Focus the first element defined in above html. | ||
337 | focus: true, | ||
338 | setup: function() { | ||
339 | this.getElement()[ anchors && anchors.length ? 'hide' : 'show' ](); | ||
340 | } | ||
341 | } ], | ||
342 | setup: function() { | ||
343 | if ( !this.getDialog().getContentElement( 'info', 'linkType' ) ) | ||
344 | this.getElement().hide(); | ||
345 | } | ||
346 | }, | ||
347 | { | ||
348 | type: 'vbox', | ||
349 | id: 'emailOptions', | ||
350 | padding: 1, | ||
351 | children: [ { | ||
352 | type: 'text', | ||
353 | id: 'emailAddress', | ||
354 | label: linkLang.emailAddress, | ||
355 | required: true, | ||
356 | validate: function() { | ||
357 | var dialog = this.getDialog(); | ||
358 | |||
359 | if ( !dialog.getContentElement( 'info', 'linkType' ) || dialog.getValueOf( 'info', 'linkType' ) != 'email' ) | ||
360 | return true; | ||
361 | |||
362 | var func = CKEDITOR.dialog.validate.notEmpty( linkLang.noEmail ); | ||
363 | return func.apply( this ); | ||
364 | }, | ||
365 | setup: function( data ) { | ||
366 | if ( data.email ) | ||
367 | this.setValue( data.email.address ); | ||
368 | |||
369 | var linkType = this.getDialog().getContentElement( 'info', 'linkType' ); | ||
370 | if ( linkType && linkType.getValue() == 'email' ) | ||
371 | this.select(); | ||
372 | }, | ||
373 | commit: function( data ) { | ||
374 | if ( !data.email ) | ||
375 | data.email = {}; | ||
376 | |||
377 | data.email.address = this.getValue(); | ||
378 | } | ||
379 | }, | ||
380 | { | ||
381 | type: 'text', | ||
382 | id: 'emailSubject', | ||
383 | label: linkLang.emailSubject, | ||
384 | setup: function( data ) { | ||
385 | if ( data.email ) | ||
386 | this.setValue( data.email.subject ); | ||
387 | }, | ||
388 | commit: function( data ) { | ||
389 | if ( !data.email ) | ||
390 | data.email = {}; | ||
391 | |||
392 | data.email.subject = this.getValue(); | ||
393 | } | ||
394 | }, | ||
395 | { | ||
396 | type: 'textarea', | ||
397 | id: 'emailBody', | ||
398 | label: linkLang.emailBody, | ||
399 | rows: 3, | ||
400 | 'default': '', | ||
401 | setup: function( data ) { | ||
402 | if ( data.email ) | ||
403 | this.setValue( data.email.body ); | ||
404 | }, | ||
405 | commit: function( data ) { | ||
406 | if ( !data.email ) | ||
407 | data.email = {}; | ||
408 | |||
409 | data.email.body = this.getValue(); | ||
410 | } | ||
411 | } ], | ||
412 | setup: function() { | ||
413 | if ( !this.getDialog().getContentElement( 'info', 'linkType' ) ) | ||
414 | this.getElement().hide(); | ||
415 | } | ||
416 | } ] | ||
417 | }, | ||
418 | { | ||
419 | id: 'target', | ||
420 | requiredContent: 'a[target]', // This is not fully correct, because some target option requires JS. | ||
421 | label: linkLang.target, | ||
422 | title: linkLang.target, | ||
423 | elements: [ { | ||
424 | type: 'hbox', | ||
425 | widths: [ '50%', '50%' ], | ||
426 | children: [ { | ||
427 | type: 'select', | ||
428 | id: 'linkTargetType', | ||
429 | label: commonLang.target, | ||
430 | 'default': 'notSet', | ||
431 | style: 'width : 100%;', | ||
432 | 'items': [ | ||
433 | [ commonLang.notSet, 'notSet' ], | ||
434 | [ linkLang.targetFrame, 'frame' ], | ||
435 | [ linkLang.targetPopup, 'popup' ], | ||
436 | [ commonLang.targetNew, '_blank' ], | ||
437 | [ commonLang.targetTop, '_top' ], | ||
438 | [ commonLang.targetSelf, '_self' ], | ||
439 | [ commonLang.targetParent, '_parent' ] | ||
440 | ], | ||
441 | onChange: targetChanged, | ||
442 | setup: function( data ) { | ||
443 | if ( data.target ) | ||
444 | this.setValue( data.target.type || 'notSet' ); | ||
445 | targetChanged.call( this ); | ||
446 | }, | ||
447 | commit: function( data ) { | ||
448 | if ( !data.target ) | ||
449 | data.target = {}; | ||
450 | |||
451 | data.target.type = this.getValue(); | ||
452 | } | ||
453 | }, | ||
454 | { | ||
455 | type: 'text', | ||
456 | id: 'linkTargetName', | ||
457 | label: linkLang.targetFrameName, | ||
458 | 'default': '', | ||
459 | setup: function( data ) { | ||
460 | if ( data.target ) | ||
461 | this.setValue( data.target.name ); | ||
462 | }, | ||
463 | commit: function( data ) { | ||
464 | if ( !data.target ) | ||
465 | data.target = {}; | ||
466 | |||
467 | data.target.name = this.getValue().replace( /([^\x00-\x7F]|\s)/gi, '' ); | ||
468 | } | ||
469 | } ] | ||
470 | }, | ||
471 | { | ||
472 | type: 'vbox', | ||
473 | width: '100%', | ||
474 | align: 'center', | ||
475 | padding: 2, | ||
476 | id: 'popupFeatures', | ||
477 | children: [ { | ||
478 | type: 'fieldset', | ||
479 | label: linkLang.popupFeatures, | ||
480 | children: [ { | ||
481 | type: 'hbox', | ||
482 | children: [ { | ||
483 | type: 'checkbox', | ||
484 | id: 'resizable', | ||
485 | label: linkLang.popupResizable, | ||
486 | setup: setupPopupParams, | ||
487 | commit: commitPopupParams | ||
488 | }, | ||
489 | { | ||
490 | type: 'checkbox', | ||
491 | id: 'status', | ||
492 | label: linkLang.popupStatusBar, | ||
493 | setup: setupPopupParams, | ||
494 | commit: commitPopupParams | ||
495 | |||
496 | } ] | ||
497 | }, | ||
498 | { | ||
499 | type: 'hbox', | ||
500 | children: [ { | ||
501 | type: 'checkbox', | ||
502 | id: 'location', | ||
503 | label: linkLang.popupLocationBar, | ||
504 | setup: setupPopupParams, | ||
505 | commit: commitPopupParams | ||
506 | |||
507 | }, | ||
508 | { | ||
509 | type: 'checkbox', | ||
510 | id: 'toolbar', | ||
511 | label: linkLang.popupToolbar, | ||
512 | setup: setupPopupParams, | ||
513 | commit: commitPopupParams | ||
514 | |||
515 | } ] | ||
516 | }, | ||
517 | { | ||
518 | type: 'hbox', | ||
519 | children: [ { | ||
520 | type: 'checkbox', | ||
521 | id: 'menubar', | ||
522 | label: linkLang.popupMenuBar, | ||
523 | setup: setupPopupParams, | ||
524 | commit: commitPopupParams | ||
525 | |||
526 | }, | ||
527 | { | ||
528 | type: 'checkbox', | ||
529 | id: 'fullscreen', | ||
530 | label: linkLang.popupFullScreen, | ||
531 | setup: setupPopupParams, | ||
532 | commit: commitPopupParams | ||
533 | |||
534 | } ] | ||
535 | }, | ||
536 | { | ||
537 | type: 'hbox', | ||
538 | children: [ { | ||
539 | type: 'checkbox', | ||
540 | id: 'scrollbars', | ||
541 | label: linkLang.popupScrollBars, | ||
542 | setup: setupPopupParams, | ||
543 | commit: commitPopupParams | ||
544 | |||
545 | }, | ||
546 | { | ||
547 | type: 'checkbox', | ||
548 | id: 'dependent', | ||
549 | label: linkLang.popupDependent, | ||
550 | setup: setupPopupParams, | ||
551 | commit: commitPopupParams | ||
552 | |||
553 | } ] | ||
554 | }, | ||
555 | { | ||
556 | type: 'hbox', | ||
557 | children: [ { | ||
558 | type: 'text', | ||
559 | widths: [ '50%', '50%' ], | ||
560 | labelLayout: 'horizontal', | ||
561 | label: commonLang.width, | ||
562 | id: 'width', | ||
563 | setup: setupPopupParams, | ||
564 | commit: commitPopupParams | ||
565 | |||
566 | }, | ||
567 | { | ||
568 | type: 'text', | ||
569 | labelLayout: 'horizontal', | ||
570 | widths: [ '50%', '50%' ], | ||
571 | label: linkLang.popupLeft, | ||
572 | id: 'left', | ||
573 | setup: setupPopupParams, | ||
574 | commit: commitPopupParams | ||
575 | |||
576 | } ] | ||
577 | }, | ||
578 | { | ||
579 | type: 'hbox', | ||
580 | children: [ { | ||
581 | type: 'text', | ||
582 | labelLayout: 'horizontal', | ||
583 | widths: [ '50%', '50%' ], | ||
584 | label: commonLang.height, | ||
585 | id: 'height', | ||
586 | setup: setupPopupParams, | ||
587 | commit: commitPopupParams | ||
588 | |||
589 | }, | ||
590 | { | ||
591 | type: 'text', | ||
592 | labelLayout: 'horizontal', | ||
593 | label: linkLang.popupTop, | ||
594 | widths: [ '50%', '50%' ], | ||
595 | id: 'top', | ||
596 | setup: setupPopupParams, | ||
597 | commit: commitPopupParams | ||
598 | |||
599 | } ] | ||
600 | } ] | ||
601 | } ] | ||
602 | } ] | ||
603 | }, | ||
604 | { | ||
605 | id: 'upload', | ||
606 | label: linkLang.upload, | ||
607 | title: linkLang.upload, | ||
608 | hidden: true, | ||
609 | filebrowser: 'uploadButton', | ||
610 | elements: [ { | ||
611 | type: 'file', | ||
612 | id: 'upload', | ||
613 | label: commonLang.upload, | ||
614 | style: 'height:40px', | ||
615 | size: 29 | ||
616 | }, | ||
617 | { | ||
618 | type: 'fileButton', | ||
619 | id: 'uploadButton', | ||
620 | label: commonLang.uploadSubmit, | ||
621 | filebrowser: 'info:url', | ||
622 | 'for': [ 'upload', 'upload' ] | ||
623 | } ] | ||
624 | }, | ||
625 | { | ||
626 | id: 'advanced', | ||
627 | label: linkLang.advanced, | ||
628 | title: linkLang.advanced, | ||
629 | elements: [ { | ||
630 | type: 'vbox', | ||
631 | padding: 1, | ||
632 | children: [ { | ||
633 | type: 'hbox', | ||
634 | widths: [ '45%', '35%', '20%' ], | ||
635 | children: [ { | ||
636 | type: 'text', | ||
637 | id: 'advId', | ||
638 | requiredContent: 'a[id]', | ||
639 | label: linkLang.id, | ||
640 | setup: setupAdvParams, | ||
641 | commit: commitAdvParams | ||
642 | }, | ||
643 | { | ||
644 | type: 'select', | ||
645 | id: 'advLangDir', | ||
646 | requiredContent: 'a[dir]', | ||
647 | label: linkLang.langDir, | ||
648 | 'default': '', | ||
649 | style: 'width:110px', | ||
650 | items: [ | ||
651 | [ commonLang.notSet, '' ], | ||
652 | [ linkLang.langDirLTR, 'ltr' ], | ||
653 | [ linkLang.langDirRTL, 'rtl' ] | ||
654 | ], | ||
655 | setup: setupAdvParams, | ||
656 | commit: commitAdvParams | ||
657 | }, | ||
658 | { | ||
659 | type: 'text', | ||
660 | id: 'advAccessKey', | ||
661 | requiredContent: 'a[accesskey]', | ||
662 | width: '80px', | ||
663 | label: linkLang.acccessKey, | ||
664 | maxLength: 1, | ||
665 | setup: setupAdvParams, | ||
666 | commit: commitAdvParams | ||
667 | |||
668 | } ] | ||
669 | }, | ||
670 | { | ||
671 | type: 'hbox', | ||
672 | widths: [ '45%', '35%', '20%' ], | ||
673 | children: [ { | ||
674 | type: 'text', | ||
675 | label: linkLang.name, | ||
676 | id: 'advName', | ||
677 | requiredContent: 'a[name]', | ||
678 | setup: setupAdvParams, | ||
679 | commit: commitAdvParams | ||
680 | |||
681 | }, | ||
682 | { | ||
683 | type: 'text', | ||
684 | label: linkLang.langCode, | ||
685 | id: 'advLangCode', | ||
686 | requiredContent: 'a[lang]', | ||
687 | width: '110px', | ||
688 | 'default': '', | ||
689 | setup: setupAdvParams, | ||
690 | commit: commitAdvParams | ||
691 | |||
692 | }, | ||
693 | { | ||
694 | type: 'text', | ||
695 | label: linkLang.tabIndex, | ||
696 | id: 'advTabIndex', | ||
697 | requiredContent: 'a[tabindex]', | ||
698 | width: '80px', | ||
699 | maxLength: 5, | ||
700 | setup: setupAdvParams, | ||
701 | commit: commitAdvParams | ||
702 | |||
703 | } ] | ||
704 | } ] | ||
705 | }, | ||
706 | { | ||
707 | type: 'vbox', | ||
708 | padding: 1, | ||
709 | children: [ { | ||
710 | type: 'hbox', | ||
711 | widths: [ '45%', '55%' ], | ||
712 | children: [ { | ||
713 | type: 'text', | ||
714 | label: linkLang.advisoryTitle, | ||
715 | requiredContent: 'a[title]', | ||
716 | 'default': '', | ||
717 | id: 'advTitle', | ||
718 | setup: setupAdvParams, | ||
719 | commit: commitAdvParams | ||
720 | |||
721 | }, | ||
722 | { | ||
723 | type: 'text', | ||
724 | label: linkLang.advisoryContentType, | ||
725 | requiredContent: 'a[type]', | ||
726 | 'default': '', | ||
727 | id: 'advContentType', | ||
728 | setup: setupAdvParams, | ||
729 | commit: commitAdvParams | ||
730 | |||
731 | } ] | ||
732 | }, | ||
733 | { | ||
734 | type: 'hbox', | ||
735 | widths: [ '45%', '55%' ], | ||
736 | children: [ { | ||
737 | type: 'text', | ||
738 | label: linkLang.cssClasses, | ||
739 | requiredContent: 'a(cke-xyz)', // Random text like 'xyz' will check if all are allowed. | ||
740 | 'default': '', | ||
741 | id: 'advCSSClasses', | ||
742 | setup: setupAdvParams, | ||
743 | commit: commitAdvParams | ||
744 | |||
745 | }, | ||
746 | { | ||
747 | type: 'text', | ||
748 | label: linkLang.charset, | ||
749 | requiredContent: 'a[charset]', | ||
750 | 'default': '', | ||
751 | id: 'advCharset', | ||
752 | setup: setupAdvParams, | ||
753 | commit: commitAdvParams | ||
754 | |||
755 | } ] | ||
756 | }, | ||
757 | { | ||
758 | type: 'hbox', | ||
759 | widths: [ '45%', '55%' ], | ||
760 | children: [ { | ||
761 | type: 'text', | ||
762 | label: linkLang.rel, | ||
763 | requiredContent: 'a[rel]', | ||
764 | 'default': '', | ||
765 | id: 'advRel', | ||
766 | setup: setupAdvParams, | ||
767 | commit: commitAdvParams | ||
768 | }, | ||
769 | { | ||
770 | type: 'text', | ||
771 | label: linkLang.styles, | ||
772 | requiredContent: 'a{cke-xyz}', // Random text like 'xyz' will check if all are allowed. | ||
773 | 'default': '', | ||
774 | id: 'advStyles', | ||
775 | validate: CKEDITOR.dialog.validate.inlineStyle( editor.lang.common.invalidInlineStyle ), | ||
776 | setup: setupAdvParams, | ||
777 | commit: commitAdvParams | ||
778 | } ] | ||
779 | } ] | ||
780 | } ] | ||
781 | } ], | ||
782 | onShow: function() { | ||
783 | var editor = this.getParentEditor(), | ||
784 | selection = editor.getSelection(), | ||
785 | element = null; | ||
786 | |||
787 | // Fill in all the relevant fields if there's already one link selected. | ||
788 | if ( ( element = plugin.getSelectedLink( editor ) ) && element.hasAttribute( 'href' ) ) { | ||
789 | // Don't change selection if some element is already selected. | ||
790 | // For example - don't destroy fake selection. | ||
791 | if ( !selection.getSelectedElement() ) | ||
792 | selection.selectElement( element ); | ||
793 | } else { | ||
794 | element = null; | ||
795 | } | ||
796 | |||
797 | var data = plugin.parseLinkAttributes( editor, element ); | ||
798 | |||
799 | // Record down the selected element in the dialog. | ||
800 | this._.selectedElement = element; | ||
801 | |||
802 | this.setupContent( data ); | ||
803 | }, | ||
804 | onOk: function() { | ||
805 | var data = {}; | ||
806 | |||
807 | // Collect data from fields. | ||
808 | this.commitContent( data ); | ||
809 | |||
810 | var selection = editor.getSelection(), | ||
811 | attributes = plugin.getLinkAttributes( editor, data ); | ||
812 | |||
813 | if ( !this._.selectedElement ) { | ||
814 | var range = selection.getRanges()[ 0 ]; | ||
815 | |||
816 | // Use link URL as text with a collapsed cursor. | ||
817 | if ( range.collapsed ) { | ||
818 | // Short mailto link text view (#5736). | ||
819 | var text = new CKEDITOR.dom.text( data.type == 'email' ? | ||
820 | data.email.address : attributes.set[ 'data-cke-saved-href' ], editor.document ); | ||
821 | range.insertNode( text ); | ||
822 | range.selectNodeContents( text ); | ||
823 | } | ||
824 | |||
825 | // Apply style. | ||
826 | var style = new CKEDITOR.style( { | ||
827 | element: 'a', | ||
828 | attributes: attributes.set | ||
829 | } ); | ||
830 | |||
831 | style.type = CKEDITOR.STYLE_INLINE; // need to override... dunno why. | ||
832 | style.applyToRange( range, editor ); | ||
833 | range.select(); | ||
834 | } else { | ||
835 | // We're only editing an existing link, so just overwrite the attributes. | ||
836 | var element = this._.selectedElement, | ||
837 | href = element.data( 'cke-saved-href' ), | ||
838 | textView = element.getHtml(); | ||
839 | |||
840 | element.setAttributes( attributes.set ); | ||
841 | element.removeAttributes( attributes.removed ); | ||
842 | |||
843 | // Update text view when user changes protocol (#4612). | ||
844 | if ( href == textView || data.type == 'email' && textView.indexOf( '@' ) != -1 ) { | ||
845 | // Short mailto link text view (#5736). | ||
846 | element.setHtml( data.type == 'email' ? | ||
847 | data.email.address : attributes.set[ 'data-cke-saved-href' ] ); | ||
848 | |||
849 | // We changed the content, so need to select it again. | ||
850 | selection.selectElement( element ); | ||
851 | } | ||
852 | |||
853 | delete this._.selectedElement; | ||
854 | } | ||
855 | }, | ||
856 | onLoad: function() { | ||
857 | if ( !editor.config.linkShowAdvancedTab ) | ||
858 | this.hidePage( 'advanced' ); //Hide Advanded tab. | ||
859 | |||
860 | if ( !editor.config.linkShowTargetTab ) | ||
861 | this.hidePage( 'target' ); //Hide Target tab. | ||
862 | }, | ||
863 | // Inital focus on 'url' field if link is of type URL. | ||
864 | onFocus: function() { | ||
865 | var linkType = this.getContentElement( 'info', 'linkType' ), | ||
866 | urlField; | ||
867 | |||
868 | if ( linkType && linkType.getValue() == 'url' ) { | ||
869 | urlField = this.getContentElement( 'info', 'url' ); | ||
870 | urlField.select(); | ||
871 | } | ||
872 | } | ||
873 | }; | ||
874 | } ); | ||
875 | } )(); | ||
876 | // jscs:disable maximumLineLength | ||
877 | /** | ||
878 | * The e-mail address anti-spam protection option. The protection will be | ||
879 | * applied when creating or modifying e-mail links through the editor interface. | ||
880 | * | ||
881 | * Two methods of protection can be chosen: | ||
882 | * | ||
883 | * 1. The e-mail parts (name, domain, and any other query string) are | ||
884 | * assembled into a function call pattern. Such function must be | ||
885 | * provided by the developer in the pages that will use the contents. | ||
886 | * 2. Only the e-mail address is obfuscated into a special string that | ||
887 | * has no meaning for humans or spam bots, but which is properly | ||
888 | * rendered and accepted by the browser. | ||
889 | * | ||
890 | * Both approaches require JavaScript to be enabled. | ||
891 | * | ||
892 | * // href="mailto:tester@ckeditor.com?subject=subject&body=body" | ||
893 | * config.emailProtection = ''; | ||
894 | * | ||
895 | * // href="<a href=\"javascript:void(location.href=\'mailto:\'+String.fromCharCode(116,101,115,116,101,114,64,99,107,101,100,105,116,111,114,46,99,111,109)+\'?subject=subject&body=body\')\">e-mail</a>" | ||
896 | * config.emailProtection = 'encode'; | ||
897 | * | ||
898 | * // href="javascript:mt('tester','ckeditor.com','subject','body')" | ||
899 | * config.emailProtection = 'mt(NAME,DOMAIN,SUBJECT,BODY)'; | ||
900 | * | ||
901 | * @since 3.1 | ||
902 | * @cfg {String} [emailProtection='' (empty string = disabled)] | ||
903 | * @member CKEDITOR.config | ||
904 | */ | ||