Skip to content

Commit

Permalink
Classes and ID handed over to Template
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Zoldak committed Dec 14, 2023
1 parent e288cee commit dc69e1b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 55 deletions.
14 changes: 0 additions & 14 deletions assets/js/comparison_slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,8 @@
comparisonSliderWidth = $(this).width();
}

// $(this)
// .find('.image_container')
// .each(function () {
// console.log(document.querySelector('.ce_comparison-slider img').naturalHeight);
// document.querySelector('.ce_comparison-slider img').onload = function () {
// console.log(document.querySelector('.ce_comparison-slider img').naturalHeight);
// };
// document.querySelector('.ce_comparison-slider img')
comparisonSliderRatio =
$(this).find('img').get(0).naturalHeight / $(this).find('img').get(0).naturalWidth;
// console.log($(this).find('img').get(0));
// console.log($(this).find('img').get(0).naturalHeight);
// console.log(comparisonSliderWidth);
// console.log(comparisonSliderRatio);
// $(this).css('height', comparisonSliderWidth / comparisonSliderRatio);
// });

$(this).css('height', comparisonSliderWidth * comparisonSliderRatio);
$(this).find('.image_container:first-child').css('width', '');
Expand Down
5 changes: 3 additions & 2 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
* @license http://creativecommons.org/licenses/by-sa/4.0/ CC BY-SA 4.0
*/

use Contao\ArrayUtil;

/*
* Content elements
*/
array_insert($GLOBALS['TL_CTE'], 1, array
(

ArrayUtil::arrayInsert($GLOBALS['TL_CTE'], 1, array(
'Comparison Slider' => array(
'Einzelelement' => 'ComparisonSlider\ContentComparisonSlider'
),
Expand Down
37 changes: 3 additions & 34 deletions dca/tl_content.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Contao\Input;
use Contao\Backend;
use Contao\Message;
use Contao\ArrayUtil;
use Contao\FilesModel;
use Contao\BackendUser;
use Contao\DataContainer;
Expand All @@ -28,53 +29,25 @@

if (!$objUser->hasAccess('themes', 'modules') || !$objUser->hasAccess('layout', 'themes'))
return;

// $objCte = ContentModel::findByPk($dc->id);

// if ($objCte === null)
// return;

// switch ($objCte->type)
// {
// case 'juiTabStart':
// case 'juiTabSeparator':
// case 'juiTabStop':
// Message::addInfo(sprintf($GLOBALS['TL_LANG']['tl_content']['includeTemplate'], 'j_ui_tabs'));
// break;
// }
};


/*
* Palettes
*/
//$GLOBALS['TL_DCA']['tl_content']['palettes']['__selector__'][] = 'juiTabShowDropdown';

array_insert($GLOBALS['TL_DCA']['tl_content']['palettes'], 0, array(
ArrayUtil::arrayInsert($GLOBALS['TL_DCA']['tl_content']['palettes'], 0, array(

'Einzelelement' => '{type_legend},type;{Slider Einstellungen}, pictureLeftSRC,pictureRightSRC,size, textLeft, textLeftPosition ,textRight, textRightPosition;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space;{invisible_legend:hide},invisible,start,stop',

));

$GLOBALS['TL_DCA']['tl_content']['config']['onsubmit_callback'][] = array('tl_comparison_slider', 'checkFileSize');


/*
* Subpalettes
*/
//$GLOBALS['TL_DCA']['tl_content']['subpalettes']['juiTabShowDropdown'] = 'juiTabDropdownLabel';


/*
* Fields
*/
array_insert($GLOBALS['TL_DCA']['tl_content']['fields'], 0, array(

// 'pictureInfoField' => array(
// 'input_field_callback' => array(
// 'tl_comparison_slider', 'pictureInfoField'
// )
// ),
ArrayUtil::arrayInsert($GLOBALS['TL_DCA']['tl_content']['fields'], 0, array(

'pictureLeftSRC' => array(
'label' => &$GLOBALS['TL_LANG']['tl_content']['pictureLeftSRC'],
Expand Down Expand Up @@ -131,10 +104,6 @@

class tl_comparison_slider extends Backend {

// public function pictureInfoField() {
// return "<div><p class=\"tl_help tl_tip\" style=\"margin:1em 0 1em; padding-bottom:0.5em; border-bottom: solid 1px #ddd;\">Hinweis: Beide Bilder müssen in Breite und Höhe übereinstimmen.</p></div>";
// }

public function checkFileSize(DataContainer $dc) {
$pictureLeft = FilesModel::findByUuid($dc->activeRecord->pictureLeftSRC);
$pictureRight = FilesModel::findByUuid($dc->activeRecord->pictureRightSRC);
Expand Down
6 changes: 2 additions & 4 deletions elements/ContentComparisonSlider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
use Contao\BackendTemplate;

class ContentComparisonSlider extends ContentElement {


/**
* Template
* @var string
Expand Down Expand Up @@ -52,8 +50,8 @@ public function generate() {
protected function compile() {
$this->Template->classNames .= "ce_comparison-slider";

if (!empty($this->Template->classes)) {
$this->Template->classNames .= " " . explode(" ", $this->Template->classes);
if (!empty($this->Template->cssID[1])) {
$this->Template->classNames .= " " . $this->Template->cssID[1];
}

if (isset($this->pictureLeftSRC) && isset($this->pictureRightSRC)) {
Expand Down
2 changes: 1 addition & 1 deletion templates/ce_comparison_slider.html5
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="<?= $this->classNames ?>">
<div class="<?= $this->classNames ?>" <?= $this->cssID ?>>

<?php $this->insert('image', $this->picture_one) ?>
<?php $this->insert('image', $this->picture_two) ?>
Expand Down

0 comments on commit dc69e1b

Please sign in to comment.