From a56f9775d30378cbb80622fcdbd34b1ca4638662 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Wed, 16 Dec 2009 06:00:08 +0000 Subject: [PATCH] MINOR fixed bug where widget area editor would not be activated (from r94829) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@95652 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- javascript/WidgetAreaEditor.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/javascript/WidgetAreaEditor.js b/javascript/WidgetAreaEditor.js index 834172ee..644b8139 100644 --- a/javascript/WidgetAreaEditor.js +++ b/javascript/WidgetAreaEditor.js @@ -5,8 +5,7 @@ WidgetAreaEditorClass.prototype = { this.name = this.getAttribute('name'); this.rewriteWidgetAreaAttributes(); UsedWidget.applyToChildren($('usedWidgets-'+this.name), 'div.Widget'); - - // Make available widgets draggable + var availableWidgets = $('availableWidgets-'+this.name).childNodes; for(var i = 0; i < availableWidgets.length; i++) { @@ -114,8 +113,8 @@ WidgetAreaEditorClass.prototype = { if ($('WidgetAreaEditor-'+holder).getAttribute('maxwidgets')) { var maxCount = $('WidgetAreaEditor-'+holder).getAttribute('maxwidgets'); var count = $$('#usedWidgets-'+holder+' .Widget').length; - if (count > maxCount) { - alert('Sorry, you have reached the maximum number of widgets in this area'); + if (count+1 > maxCount) { + alert(ss.i18n._t('WidgetAreaEditor.TOOMANY')); return; } } @@ -255,11 +254,4 @@ WidgetTreeDropdownField.prototype = { } WidgetTreeDropdownField.applyTo('div.usedWidgets .TreeDropdownField'); - -// Loop over all WidgetAreas and fire 'em up -var wAs = $$('.WidgetAreaEditor'); -for(var i = 0; i < wAs.length; i++) { - WidgetAreaEditorClass.applyTo('div#'+wAs[i].id); - -} - +WidgetAreaEditorClass.applyTo('.WidgetAreaEditor'); \ No newline at end of file