Skip to content

Commit

Permalink
Fixed backward compatibility for Contao 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ausi committed Sep 16, 2013
1 parent 86fa3be commit 7111e37
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
14 changes: 11 additions & 3 deletions assets/js/be_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 7 additions & 5 deletions src/MadeYourDay/Contao/CustomElements.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7111e37

Please sign in to comment.