From 05ade5866b619b31fa25cd87c8c8b227338d9d55 Mon Sep 17 00:00:00 2001 From: g4b0 Date: Fri, 29 Mar 2013 15:50:20 +0100 Subject: [PATCH] BUGFIX: check before shifting classes array in AvailableWidgets BUGFIX: solved bug adding a new widget to the top of the widget area, then moving it to the bottom when saving --- code/form/WidgetAreaEditor.php | 2 +- javascript/WidgetAreaEditor.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/form/WidgetAreaEditor.php b/code/form/WidgetAreaEditor.php index 4edc40f..bc0cff7 100644 --- a/code/form/WidgetAreaEditor.php +++ b/code/form/WidgetAreaEditor.php @@ -40,7 +40,7 @@ class WidgetAreaEditor extends FormField { foreach($this->widgetClasses as $widgetClass) { $classes = ClassInfo::subclassesFor($widgetClass); - array_shift($classes); + if(count($classes) > 1) array_shift($classes); foreach($classes as $class) { $widgets->push(singleton($class)); } diff --git a/javascript/WidgetAreaEditor.js b/javascript/WidgetAreaEditor.js index 0af952a..a041cf1 100644 --- a/javascript/WidgetAreaEditor.js +++ b/javascript/WidgetAreaEditor.js @@ -132,7 +132,7 @@ $(this).data('maxid', newID); var widgetContent = response.replace(/Widget\[0\]/gi, "Widget[new-" + (newID) + "]"); - $('#usedWidgets-'+$(this).attr('name')).prepend(widgetContent); + $('#usedWidgets-'+$(this).attr('name')).append(widgetContent); this.rewriteWidgetAreaAttributes(); },