From 03bbc1d40d817689b454d85de186ba951fa716cb Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 13 Apr 2010 22:01:11 +0000 Subject: [PATCH] BUGFIX Clicking available widgets now applies only to h3 elements BUGFIX Widgets are now prepended to the available widget stack by use of Insertion.Top (from r97541) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@102726 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- javascript/WidgetAreaEditor.js | 13 +++++++------ templates/WidgetAreaEditor.ss | 1 - 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/javascript/WidgetAreaEditor.js b/javascript/WidgetAreaEditor.js index d6a2be25..ec305db7 100644 --- a/javascript/WidgetAreaEditor.js +++ b/javascript/WidgetAreaEditor.js @@ -15,8 +15,10 @@ WidgetAreaEditorClass.prototype = { // Gotta change their ID's because otherwise we get clashes between two tabs widget.id = widget.id + '-'+this.name; if(widget.id) { - widget.onclick = function(event) { - parts = event.currentTarget.id.split('-'); + // Clicking applies to the h3 element only, not the widget div itself + var header = widget.childNodes[1]; + header.onclick = function(event) { + parts = event.currentTarget.parentNode.id.split('-'); var widgetArea = parts.pop(); var className = parts.pop(); $('WidgetAreaEditor-'+widgetArea).addWidget(className, widgetArea); @@ -167,10 +169,9 @@ WidgetAreaEditorClass.prototype = { var usedWidgets = $('usedWidgets-'+this.name).childNodes; // Give the widget a unique id - widget = document.createElement('div'); - widget.innerHTML = response.responseText.replace(/Widget\[0\]/gi, "Widget[new-" + (++$('usedWidgets-'+this.name).parentNode.parentNode.maxid) + "]"); - - $('usedWidgetsStart-'+this.name).appendChild(widget.childNodes[0]); + widgetContent = response.responseText.replace(/Widget\[0\]/gi, "Widget[new-" + (++$('usedWidgets-'+this.name).parentNode.parentNode.maxid) + "]"); + new Insertion.Top($('usedWidgets-'+this.name), widgetContent); + $('usedWidgets-'+this.name).parentNode.parentNode.rewriteWidgetAreaAttributes(); UsedWidget.applyToChildren($('usedWidgets-'+this.name), 'div.Widget'); diff --git a/templates/WidgetAreaEditor.ss b/templates/WidgetAreaEditor.ss index 4a13f55a..d6983eb9 100644 --- a/templates/WidgetAreaEditor.ss +++ b/templates/WidgetAreaEditor.ss @@ -20,7 +20,6 @@

<% _t('TOADD', 'To add widgets, click one on the left to add it here') %>

-
<% if UsedWidgets %> <% control UsedWidgets %> $EditableSegment