diff --git a/assets/js/be_main.js b/assets/js/be_main.js index d3d9222..bad57ad 100644 --- a/assets/js/be_main.js +++ b/assets/js/be_main.js @@ -115,13 +115,17 @@ var renameElement = function(element) { var initListSort = function(listInner) { + if (!listInner.getElements('.drag-handle').length) { + return; + } + var ds = new Scroller(document.body, { onChange: function(x, y) { this.element.scrollTo(this.element.getScroll().x, y); } }); - var sort = listInner.retrieve('listSort', new Sortables(listInner, { + listInner.retrieve('listSort', new Sortables(listInner, { contstrain: true, opacity: 0.6, handle: '.drag-handle', @@ -198,7 +202,9 @@ var newElementAtPosition = function(listElement, position) { renameElement(el); }); - listInner.retrieve('listSort').addItems(newItem); + if (listInner.retrieve('listSort')) { + listInner.retrieve('listSort').addItems(newItem); + } try { window.fireEvent('ajax_change'); @@ -230,7 +236,9 @@ var deleteElement = function(linkElement) { var element = $(linkElement).getParent('.rsce_list_item'); var listInner = element.getParent('.rsce_list_inner'); var nextElements = element.getAllNext('.rsce_list_item'); - listInner.retrieve('listSort').removeItems(element); + if (listInner.retrieve('listSort')) { + listInner.retrieve('listSort').removeItems(element); + } element.destroy(); nextElements.each(function(nextElement) { renameElement(nextElement); diff --git a/src/MadeYourDay/Contao/CustomElements.php b/src/MadeYourDay/Contao/CustomElements.php index 5716f2d..315bd85 100644 --- a/src/MadeYourDay/Contao/CustomElements.php +++ b/src/MadeYourDay/Contao/CustomElements.php @@ -447,11 +447,13 @@ protected function createDcaItem($fieldPrefix, $fieldName, $fieldConfig, &$palet else { // remap page and file picker to get them work without a database field - if ($fieldConfig['inputType'] === 'fileTree') { - $fieldConfig['inputType'] = 'rsce_file_tree'; - } - if ($fieldConfig['inputType'] === 'pageTree') { - $fieldConfig['inputType'] = 'rsce_page_tree'; + if (version_compare(VERSION, '3.1', '>=')) { + if ($fieldConfig['inputType'] === 'fileTree') { + $fieldConfig['inputType'] = 'rsce_file_tree'; + } + if ($fieldConfig['inputType'] === 'pageTree') { + $fieldConfig['inputType'] = 'rsce_page_tree'; + } } $GLOBALS['TL_DCA'][$dc->table]['fields'][$fieldPrefix . $fieldName] = $fieldConfig;