From 334beaeedddaa17f392a37050b9acaf7e730a8e8 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Tue, 26 Jan 2010 01:19:45 +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 git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@97541 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 448e2ea8..995cc2a4 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); @@ -166,10 +168,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