Merge pull request #335 from halkyon/link_changes

BUGFIX Stop "Insert Link" or "Insert Image" header disappearing inside insert media/link popup
This commit is contained in:
Sam Minnée 2012-04-16 21:40:17 -07:00
commit cde9b3183b
3 changed files with 14 additions and 16 deletions

View File

@ -302,7 +302,7 @@ class HtmlEditorField_Toolbar extends RequestHandler {
new FieldList( new FieldList(
new LiteralField( new LiteralField(
'Heading', 'Heading',
sprintf('<h3>%s</h3>', _t('HtmlEditorField.LINK', 'Link')) sprintf('<h3>%s</h3>', _t('HtmlEditorField.LINK', 'Insert Link'))
), ),
$contentComposite = new CompositeField( $contentComposite = new CompositeField(
new OptionsetField( new OptionsetField(

View File

@ -345,7 +345,6 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
// Move title from headline to (jQuery compatible) title attribute // Move title from headline to (jQuery compatible) title attribute
var titleEl = this.find(':header:first'); var titleEl = this.find(':header:first');
this.getDialog().attr('title', titleEl.text()); this.getDialog().attr('title', titleEl.text());
titleEl.remove();
this.setEditor(ss.editorWrappers['default']()); this.setEditor(ss.editorWrappers['default']());
}, },
@ -400,7 +399,7 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
this.addAnchorSelector(); this.addAnchorSelector();
// Toggle field visibility and state based on type selection // Toggle field visibility and state based on type selection
this.find('.field').hide(); this.find('div.content .field').hide();
this.find('.field#LinkType').show(); this.find('.field#LinkType').show();
this.find('.field#' + linkType).show(); this.find('.field#' + linkType).show();
if(linkType == 'internal' || linkType == 'anchor') this.find('.field#Anchor').show(); if(linkType == 'internal' || linkType == 'anchor') this.find('.field#Anchor').show();
@ -481,7 +480,7 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
this.find(':input[name=Anchor]').parent().append(anchorSelector); this.find(':input[name=Anchor]').parent().append(anchorSelector);
anchorSelector.focus(function(e) { anchorSelector.focus(function(e) {
self.refreshAnchors($(this)); self.refreshAnchors();
}); });
} else { } else {
var buttonRefresh = $('<a id="Form_EditorToolbarLinkForm_AnchorRefresh" title="Refresh the anchor list" alt="Refresh the anchor list" class="buttonRefresh"><span></span></a>'); 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;
this.find(':input[name=Anchor]').parent().append(buttonRefresh).append(anchorSelector); this.find(':input[name=Anchor]').parent().append(buttonRefresh).append(anchorSelector);
buttonRefresh.click(function(e) { buttonRefresh.click(function(e) {
refreshAnchors(anchorSelector); self.refreshAnchors();
}); });
} }
// initialization // initialization
this.refreshAnchors(); self.refreshAnchors();
// copy the value from dropdown to the text field // copy the value from dropdown to the text field
anchorSelector.change(function(e) { anchorSelector.change(function(e) {
@ -503,13 +502,16 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
}, },
// this function collects the anchors in the currently active editor and regenerates the dropdown // this function collects the anchors in the currently active editor and regenerates the dropdown
refreshAnchors: function() { refreshAnchors: function() {
var selector = this.find(':input[name=AnchorSelector]'), anchors = []; var selector = this.find(':input[name=AnchorSelector]'), anchors = [], ed = this.getEditor();
// name attribute is defined as CDATA, should accept all characters and entities // name attribute is defined as CDATA, should accept all characters and entities
// http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#h-12.2 // http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#h-12.2
var raw = this.getEditor().getContent().match(/name="([^"]+?)"|name='([^']+?)'/gim);
if (raw && raw.length) { if(ed) {
for(var i = 0; i < raw.length; i++) { var raw = ed.getContent().match(/name="([^"]+?)"|name='([^']+?)'/gim);
anchors.push(raw[i].substr(6).replace(/"$/, '')); if (raw && raw.length) {
for(var i = 0; i < raw.length; i++) {
anchors.push(raw[i].substr(6).replace(/"$/, ''));
}
} }
} }
@ -670,10 +672,6 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
} }
this.redraw(); this.redraw();
// HACK: Hide selected node in IE because its drag handles on potentially selected elements
// don't respect the z-index of the dialog overlay.
// jQuery(ed.getContainer()).hide();
}, },
redraw: function() { redraw: function() {
this._super(); this._super();

View File

@ -260,7 +260,7 @@ en:
IMAGEHEIGHTPX: Height IMAGEHEIGHTPX: Height
IMAGETITLE: 'Title text (tooltip) - for additional information about the image' IMAGETITLE: 'Title text (tooltip) - for additional information about the image'
IMAGEWIDTHPX: Width IMAGEWIDTHPX: Width
LINK: Link LINK: 'Insert Link'
LINKANCHOR: 'Anchor on this page' LINKANCHOR: 'Anchor on this page'
LINKDESCR: 'Link description' LINKDESCR: 'Link description'
LINKEMAIL: 'Email address' LINKEMAIL: 'Email address'