Skip to content
This repository
Browse code

BUGFIX Stop "Insert Link" or "Insert Image" header disappearing insid…

…e the HtmlEditorField toolbar

when clicking a link type
  • Loading branch information...
commit 5bb31c4e818661b14cd03c7225916f4746fbc10e 1 parent f3137e5
Sean Harvey authored
2  forms/HtmlEditorField.php
@@ -302,7 +302,7 @@ function LinkForm() {
302 302
 			new FieldList(
303 303
 				new LiteralField(
304 304
 					'Heading', 
305  
-					sprintf('<h3>%s</h3>', _t('HtmlEditorField.LINK', 'Link'))
  305
+					sprintf('<h3>%s</h3>', _t('HtmlEditorField.LINK', 'Insert Link'))
306 306
 				),
307 307
 				$contentComposite = new CompositeField(
308 308
 					new OptionsetField(
26  javascript/HtmlEditorField.js
@@ -345,7 +345,6 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
345 345
 				// Move title from headline to (jQuery compatible) title attribute
346 346
 				var titleEl = this.find(':header:first');
347 347
 				this.getDialog().attr('title', titleEl.text());
348  
-				titleEl.remove();
349 348
 
350 349
 				this.setEditor(ss.editorWrappers['default']());
351 350
 			},
@@ -400,7 +399,7 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
400 399
 				this.addAnchorSelector();
401 400
 
402 401
 				// Toggle field visibility and state based on type selection
403  
-				this.find('.field').hide();
  402
+				this.find('div.content .field').hide();
404 403
 				this.find('.field#LinkType').show();
405 404
 				this.find('.field#' + linkType).show();
406 405
 				if(linkType == 'internal' || linkType == 'anchor') this.find('.field#Anchor').show();
@@ -481,7 +480,7 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
481 480
 					this.find(':input[name=Anchor]').parent().append(anchorSelector);
482 481
 
483 482
 					anchorSelector.focus(function(e) {
484  
-						self.refreshAnchors($(this));
  483
+						self.refreshAnchors();
485 484
 					});
486 485
 				} else {
487 486
 					var buttonRefresh = $('<a id="Form_EditorToolbarLinkForm_AnchorRefresh" title="Refresh the anchor list" alt="Refresh the anchor list" class="buttonRefresh"><span></span></a>');
@@ -489,12 +488,12 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
489 488
 					this.find(':input[name=Anchor]').parent().append(buttonRefresh).append(anchorSelector);
490 489
 
491 490
 					buttonRefresh.click(function(e) {
492  
-						refreshAnchors(anchorSelector);
  491
+						self.refreshAnchors();
493 492
 					});
494 493
 				}
495 494
 
496 495
 				// initialization
497  
-				this.refreshAnchors();
  496
+				self.refreshAnchors();
498 497
 
499 498
 				// copy the value from dropdown to the text field
500 499
 				anchorSelector.change(function(e) {
@@ -503,13 +502,16 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
503 502
 			},
504 503
 			// this function collects the anchors in the currently active editor and regenerates the dropdown
505 504
 			refreshAnchors: function() {
506  
-				var selector = this.find(':input[name=AnchorSelector]'), anchors = [];
  505
+				var selector = this.find(':input[name=AnchorSelector]'), anchors = [], ed = this.getEditor();
507 506
 				// name attribute is defined as CDATA, should accept all characters and entities
508 507
 				// http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#h-12.2
509  
-				var raw = this.getEditor().getContent().match(/name="([^"]+?)"|name='([^']+?)'/gim);
510  
-				if (raw && raw.length) {
511  
-					for(var i = 0; i < raw.length; i++) {
512  
-						anchors.push(raw[i].substr(6).replace(/"$/, ''));
  508
+
  509
+				if(ed) {
  510
+					var raw = ed.getContent().match(/name="([^"]+?)"|name='([^']+?)'/gim);
  511
+					if (raw && raw.length) {
  512
+						for(var i = 0; i < raw.length; i++) {
  513
+							anchors.push(raw[i].substr(6).replace(/"$/, ''));
  514
+						}
513 515
 					}
514 516
 				}
515 517
 
@@ -670,10 +672,6 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
670 672
 				}
671 673
 
672 674
 				this.redraw();
673  
-
674  
-				// HACK: Hide selected node in IE because its drag handles on potentially selected elements
675  
-				// don't respect the z-index of the dialog overlay.
676  
-				// jQuery(ed.getContainer()).hide();
677 675
 			},
678 676
 			redraw: function() {
679 677
 				this._super();
2  lang/en.yml
@@ -260,7 +260,7 @@ en:
260 260
     IMAGEHEIGHTPX: Height
261 261
     IMAGETITLE: 'Title text (tooltip) - for additional information about the image'
262 262
     IMAGEWIDTHPX: Width
263  
-    LINK: Link
  263
+    LINK: 'Insert Link'
264 264
     LINKANCHOR: 'Anchor on this page'
265 265
     LINKDESCR: 'Link description'
266 266
     LINKEMAIL: 'Email address'

0 notes on commit 5bb31c4

Please sign in to comment.
Something went wrong with that request. Please try again.