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
This commit is contained in:
Ingo Schommer 2010-04-13 22:01:11 +00:00
parent 8c06bda962
commit 03bbc1d40d
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 // Gotta change their ID's because otherwise we get clashes between two tabs
widget.id = widget.id + '-'+this.name; widget.id = widget.id + '-'+this.name;
if(widget.id) { if(widget.id) {
widget.onclick = function(event) { // Clicking applies to the h3 element only, not the widget div itself
parts = event.currentTarget.id.split('-'); var header = widget.childNodes[1];
header.onclick = function(event) {
parts = event.currentTarget.parentNode.id.split('-');
var widgetArea = parts.pop(); var widgetArea = parts.pop();
var className = parts.pop(); var className = parts.pop();
$('WidgetAreaEditor-'+widgetArea).addWidget(className, widgetArea); $('WidgetAreaEditor-'+widgetArea).addWidget(className, widgetArea);
@ -167,10 +169,9 @@ WidgetAreaEditorClass.prototype = {
var usedWidgets = $('usedWidgets-'+this.name).childNodes; var usedWidgets = $('usedWidgets-'+this.name).childNodes;
// Give the widget a unique id // Give the widget a unique id
widget = document.createElement('div'); widgetContent = response.responseText.replace(/Widget\[0\]/gi, "Widget[new-" + (++$('usedWidgets-'+this.name).parentNode.parentNode.maxid) + "]");
widget.innerHTML = response.responseText.replace(/Widget\[0\]/gi, "Widget[new-" + (++$('usedWidgets-'+this.name).parentNode.parentNode.maxid) + "]"); new Insertion.Top($('usedWidgets-'+this.name), widgetContent);
$('usedWidgetsStart-'+this.name).appendChild(widget.childNodes[0]);
$('usedWidgets-'+this.name).parentNode.parentNode.rewriteWidgetAreaAttributes(); $('usedWidgets-'+this.name).parentNode.parentNode.rewriteWidgetAreaAttributes();
UsedWidget.applyToChildren($('usedWidgets-'+this.name), 'div.Widget'); 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> <p><% _t('TOADD', 'To add widgets, click one on the left to add it here') %></p>
<div class="usedWidgets" id="usedWidgets-$Name"> <div class="usedWidgets" id="usedWidgets-$Name">
<div id="usedWidgetsStart-$Name"><!-- --></div>
<% if UsedWidgets %> <% if UsedWidgets %>
<% control UsedWidgets %> <% control UsedWidgets %>
$EditableSegment $EditableSegment