Skip to content

Commit

Permalink
impl backwards comp. code
Browse files Browse the repository at this point in the history
  • Loading branch information
alnv committed Aug 24, 2020
1 parent 86ece12 commit 0611a7e
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 3 deletions.
72 changes: 70 additions & 2 deletions assets/FModule.js
Expand Up @@ -3,14 +3,82 @@ var FModule = {};
(function () {

'use strict';

if ( typeof window.addEventListener !== 'undefined' ) {

window.addEventListener( 'DOMContentLoaded', initialize, false );
}

function initialize() {

FModule.xOptionsWizard = function (el, command, id) {
var table = $(id),
tbody = table.getElement('tbody'),
parent = $(el).getParent('tr'),
rows = tbody.getChildren(),
tabindex = tbody.get('data-tabindex'),
input, childs, i, j;

Backend.getScrollOffset();

switch (command) {
case 'copy':
var tr = new Element('tr');
childs = parent.getChildren();
for (i=0; i<childs.length; i++) {
var next = childs[i].clone(true).inject(tr, 'bottom');
if (input = childs[i].getFirst('input')) {
next.getFirst('input').value = input.value;
if (input.type == 'checkbox') {
next.getFirst('input').checked = input.checked ? 'checked' : '';
}
}
}
tr.inject(parent, 'after');
break;
case 'up':
if (tr = parent.getPrevious('tr')) {
parent.inject(tr, 'before');
} else {
parent.inject(tbody, 'bottom');
}
break;
case 'down':
if (tr = parent.getNext('tr')) {
parent.inject(tr, 'after');
} else {
parent.inject(tbody, 'top');
}
break;
case 'delete':
if (rows.length > 1) {
parent.destroy();
}
break;
}

rows = tbody.getChildren();

for (i=0; i<rows.length; i++) {
childs = rows[i].getChildren();
for (j=0; j<childs.length; j++) {
if (input = childs[j].getFirst('input')) {
input.set('tabindex', tabindex++);
input.name = input.name.replace(/\[[0-9]+]/g, '[' + i + ']');
if (input.type == 'checkbox') {
input.id = input.name.replace(/\[[0-9]+]/g, '').replace(/\[/g, '_').replace(/]/g, '') + '_' + i;
input.getNext('label').set('for', input.id);
}
}
}
}

new Sortables(tbody, {
constrain: true,
opacity: 0.6,
handle: '.drag-handle'
});
}

FModule.optionsWizard = function(el, command, id) {

var table = $(id),
Expand Down Expand Up @@ -82,7 +150,7 @@ var FModule = {};
};

FModule.keyValueWizardCustom = function ( el, command, id ) {

alert("ss");
var table = $(id),
tbody = table.getElement('tbody'),
parent = $(el).getParent('tr'),
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/contao/widgets/OptionWizardExtended.php
Expand Up @@ -153,7 +153,7 @@ public function generate()
if ($button == 'drag') {
$return .= \Image::getHtml('drag.gif', '', 'class="drag-handle" title="' . sprintf($GLOBALS['TL_LANG']['MSC']['move']) . '"');
} else {
$return .= '<a tabindex="-1" href="' . $this->addToUrl('&amp;' . $strCommand . '=' . $button . '&amp;cid=' . $i . '&amp;id=' . $this->currentRecord) . '"' . $class . ' title="' . specialchars($GLOBALS['TL_LANG']['MSC']['ow_' . $button]) . '" onclick="Backend.optionsWizard(this,\'' . $button . '\',\'ctrl_' . $this->strId . '\');return false">' . \Image::getHtml($button . '.gif', $GLOBALS['TL_LANG']['MSC']['ow_' . $button]) . '</a> ';
$return .= '<a tabindex="-1" href="' . $this->addToUrl('&amp;' . $strCommand . '=' . $button . '&amp;cid=' . $i . '&amp;id=' . $this->currentRecord) . '"' . $class . ' title="' . specialchars($GLOBALS['TL_LANG']['MSC']['ow_' . $button]) . '" onclick="FModule.xOptionsWizard(this,\'' . $button . '\',\'ctrl_' . $this->strId . '\');return false">' . \Image::getHtml($button . '.gif', $GLOBALS['TL_LANG']['MSC']['ow_' . $button]) . '</a> ';
}
}

Expand Down

0 comments on commit 0611a7e

Please sign in to comment.