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
This commit is contained in:
Sean Harvey 2010-01-26 01:19:45 +00:00 committed by Sam Minnee
parent 47f782c907
commit 334beaeedd
2 changed files with 7 additions and 7 deletions

View File

@ -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');

View File

@ -20,7 +20,6 @@
<p><% _t('TOADD', 'To add widgets, click one on the left to add it here') %></p>
<div class="usedWidgets" id="usedWidgets-$Name">
<div id="usedWidgetsStart-$Name"><!-- --></div>
<% if UsedWidgets %>
<% control UsedWidgets %>
$EditableSegment