@do_while das Problem liegt hier:
PHP-Code:
<script>
<?php if(strlen($GLOBALS['EASYZOOM']['easyopts']) > 0): ?>
var $easyopts = { <?php echo $GLOBALS['EASYZOOM']['easyopts']; ?> };
var $easyzoom = $('.easyzoom').easyZoom($easyopts);
<?php else: ?>
var $easyzoom = $('.easyzoom').easyZoom();
<?php endif; ?>
<?php if($GLOBALS['EASYZOOM']['thumbnails']): ?>
var api1 = $easyzoom.filter('.easyzoom--with-thumbnails').data('easyZoom');
$('.easyzoomthumbnails').on('click', 'a', function(e) {
var $this = $(this);
e.preventDefault();
api1.swap($this.data('standard'), $this.attr('href'));
});
<?php endif; ?>
<?php if($GLOBALS['EASYZOOM']['toogle']): ?>
var api2 = $easyzoom.filter('.easyzoom--with-toggle').data('easyZoom');
$('.toggle').on('click', function() {
var $this = $(this);
if ($this.data("active") === true) {
$this.text("Switch on").data("active", false);
api2.teardown();
} else {
$this.text("Switch off").data("active", true);
api2._init();
}
});
<?php endif; ?>
</script>
Du musst das korrekt wrappen, andernfalls kann man MooTools und jQuery nicht gleichzeitig einsetzen.
PHP-Code:
<script>
(function($)
{
"use strict";
<?php if(strlen($GLOBALS['EASYZOOM']['easyopts']) > 0): ?>
var $easyopts = { <?php echo $GLOBALS['EASYZOOM']['easyopts']; ?> };
var $easyzoom = $('.easyzoom').easyZoom($easyopts);
<?php else: ?>
var $easyzoom = $('.easyzoom').easyZoom();
<?php endif; ?>
<?php if($GLOBALS['EASYZOOM']['thumbnails']): ?>
var api1 = $easyzoom.filter('.easyzoom--with-thumbnails').data('easyZoom');
$('.easyzoomthumbnails').on('click', 'a', function(e) {
var $this = $(this);
e.preventDefault();
api1.swap($this.data('standard'), $this.attr('href'));
});
<?php endif; ?>
<?php if($GLOBALS['EASYZOOM']['toogle']): ?>
var api2 = $easyzoom.filter('.easyzoom--with-toggle').data('easyZoom');
$('.toggle').on('click', function() {
var $this = $(this);
if ($this.data("active") === true) {
$this.text("Switch on").data("active", false);
api2.teardown();
} else {
$this.text("Switch off").data("active", true);
api2._init();
}
});
<?php endif; ?>
})(jQuery);
</script>
Außerdem sollte der Code doch auch lieber erst ausgeführt werden, wenn der DOM fertig geladen ist, oder nicht?
PHP-Code:
<script>
(function($)
{
"use strict";
$(document).ready(function()
{
<?php if(strlen($GLOBALS['EASYZOOM']['easyopts']) > 0): ?>
var $easyopts = { <?php echo $GLOBALS['EASYZOOM']['easyopts']; ?> };
var $easyzoom = $('.easyzoom').easyZoom($easyopts);
<?php else: ?>
var $easyzoom = $('.easyzoom').easyZoom();
<?php endif; ?>
<?php if($GLOBALS['EASYZOOM']['thumbnails']): ?>
var api1 = $easyzoom.filter('.easyzoom--with-thumbnails').data('easyZoom');
$('.easyzoomthumbnails').on('click', 'a', function(e) {
var $this = $(this);
e.preventDefault();
api1.swap($this.data('standard'), $this.attr('href'));
});
<?php endif; ?>
<?php if($GLOBALS['EASYZOOM']['toogle']): ?>
var api2 = $easyzoom.filter('.easyzoom--with-toggle').data('easyZoom');
$('.toggle').on('click', function() {
var $this = $(this);
if ($this.data("active") === true) {
$this.text("Switch on").data("active", false);
api2.teardown();
} else {
$this.text("Switch off").data("active", true);
api2._init();
}
});
<?php endif; ?>
});
})(jQuery);
</script>
@Schmidty bis das in der Extension behoben ist könntest du dir dein eigenes j_easyzoom Template anlegen und folgenden Inhalt einfügen:
PHP-Code:
<?php
// Add the colorbox style sheet
$GLOBALS['TL_CSS'][] = 'system/modules/easyzoom/vendor/easyzoom/css/easyzoom.min.css|static';
?>
<script src="system/modules/easyzoom/vendor/easyzoom/js/easyzoom.min.js"></script>
<script>
(function($)
{
"use strict";
$(document).ready(function()
{
<?php if(strlen($GLOBALS['EASYZOOM']['easyopts']) > 0): ?>
var $easyopts = { <?php echo $GLOBALS['EASYZOOM']['easyopts']; ?> };
var $easyzoom = $('.easyzoom').easyZoom($easyopts);
<?php else: ?>
var $easyzoom = $('.easyzoom').easyZoom();
<?php endif; ?>
<?php if($GLOBALS['EASYZOOM']['thumbnails']): ?>
var api1 = $easyzoom.filter('.easyzoom--with-thumbnails').data('easyZoom');
$('.easyzoomthumbnails').on('click', 'a', function(e) {
var $this = $(this);
e.preventDefault();
api1.swap($this.data('standard'), $this.attr('href'));
});
<?php endif; ?>
<?php if($GLOBALS['EASYZOOM']['toogle']): ?>
var api2 = $easyzoom.filter('.easyzoom--with-toggle').data('easyZoom');
$('.toggle').on('click', function() {
var $this = $(this);
if ($this.data("active") === true) {
$this.text("Switch on").data("active", false);
api2.teardown();
} else {
$this.text("Switch off").data("active", true);
api2._init();
}
});
<?php endif; ?>
});
})(jQuery);
</script>
Lesezeichen