하지만 버그가 내 코드에 존재하고 나는 그것이 어디에서 왔는지 알 수 없다.
내가 선택한 솔루션은 새로운 클래스 MyCat을 소개하는 것이며 내 수정은이 클래스가 이미지가 현재 범주에 해당하고 jquery가이 클래스를 고려하면이 클래스가 존재하는지 확인하려고합니다.
다음은이 버그에 대한 설명입니다. 이것은 처음에 x 이미지가 포함 된 범주를 필터링하고이를 통해 탐색하고 마지막 이미지의 탐색에서 벗어날 때 발생합니다. 그러면 x 이미지보다 작은 카테고리로 필터링하고 y라고 말하면됩니다. 이미지를 클릭하면 이미지가 나타나지 않거나 이미지가 손상 될 수 있습니다.) 올바른 이미지를 얻으려면 이전 이미지 링크 (y-x)를 클릭해야합니다. 현재 다음 이미지 링크를 사용할 수 없으므로 시스템이 안정화되었습니다.
내가 알지 못하면 내 설명을 이해할 수 있기를 바랍니다. 좀 더 우아한 방법이 있는지 모르겠지만 거의 효과가 있습니다. 버그를 설명 할 수있는 것이 있으면 알려주세요.
gallery.php :
...
<?php if((!empty($this->lead_items) || (!empty($this->intro_items))) && $this->params->get('show_filter')): ?>
<div class="filters">
<ul id="filters" class="unstyled">
<li><a href="#" data-filter="*" class="selected"><?php echo JText::_('TPL_COM_CONTENT_GALLERY_FILTER_SHOW_ALL'); ?></a></li>
<?php
foreach ($galleryCategories as $key => $value) :
?>
<li><a class="" href="#"data-filter=".<?php echo special_chars_replace($value); ?>"><?php echo ucwords(str_replace("_"," ",$value)); ?></a></li>
<?php endforeach; ?>
</ul>
<div class="clearfix"></div>
</div>
<?php endif; ?>
...
<div class="row-fluid">
<ul id="isotopeContainer" class="gallery items-row cols-<?php echo (int) $this->columns;?>">
<?php
$valgtr = array();
$keysgtr = array_keys($this->intro_items);
shuffle($keysgtr);
foreach($keysgtr as $keygtr) $valgtr[] = $this->intro_items[$keygtr];
foreach ($valgtr as $key => &$item) :
?>
<?php
$key = ($key - $leadingcount) + 1;
$rowcount = (((int) $key - 1) % (int) $this->columns) + 1;
if ($rowcount == 1) : ?>
<?php endif; ?>
<li class="gallery-item <?php echo special_chars_replace(strtolower(str_replace(" ","_",$item->category_title))); ?>">
<?php
$this->item = &$item;
echo $this->loadTemplate('item');
...
<script type="text/javascript">
jQuery(document).ready(function() {
(function($){
$(window).load(function(){
var $cols = <?php echo $this->columns; ?>;
var $container = $('#isotopeContainer');
$item = $('.gallery-item')
$item.outerWidth(Math.floor($container.width()/$cols));
$container.isotope({
animationEngine: 'best-available',
animationOptions: {
queue: false,
duration: 800
},
containerClass : 'isotope',
containerStyle: {
position: 'relative',
overflow: 'hidden'
},
hiddenClass : 'isotope-hidden',
itemClass : 'isotope-item',
resizable: true,
resizesContainer : true,
transformsEnabled: !$.browser.opera // disable transforms in Opera
});
if($container.width() <= '767'){
$item.outerWidth($container.width());
$item.addClass('straightDown');
$container.isotope({
layoutMode: 'straightDown'
});
} else {
$item.removeClass('straightDown');
$container.isotope({
layoutMode: 'fitRows'
});
}
$(window).resize(function(){
$item.outerWidth(Math.floor($container.width()/$cols));
if($container.width() <= '767'){
$item.outerWidth($container.width());
$item.addClass('straightDown');
$container.isotope({
layoutMode: 'straightDown'
});
} else {
$item.outerWidth(Math.floor($container.width()/$cols));
$item.removeClass('straightDown');
$container.isotope({
layoutMode: 'fitRows'
});
}
});
});
})(jQuery);
});
</script>
<?php if($this->params->get('show_filter')): ?>
<script type="text/javascript">
jQuery(document).ready(function() {
(function($){
$(window).load(function(){
var $container = $('#isotopeContainer');
// filter items when filter link is clicked
$('#filters a').click(function(){
var selector = $(this).attr('data-filter');
$container.isotope({ filter: selector });
if(selector == "*"){
$(".touchGalleryLink").addClass("MyCat");
} else {
$(".touchGalleryLink").removeClass("MyCat");
$(".touchGalleryLink").each(function() {
var tmpvar = $(this).parent().parent().attr('class').split(" ",2);
if(tmpvar[1] == selector.substr(1)){
$(this).addClass("MyCat");
}
});
}
jQuery('a.touchGalleryLink.MyCat').touchTouch();
return false;
});
$("#filters a:first").trigger("click");
var $optionSets = $('#filters li'),
$optionLinks = $optionSets.find('a');
$optionLinks.click(function(){
var $this = $(this);
// don't proceed if already selected
if ($this.hasClass('selected')) {
return false;
}
var $optionSet = $this.parents('#filters');
$optionSet.find('.selected').removeClass('selected');
$this.addClass('selected');
// make option object dynamically, i.e. { filter: '.my-filter-class' }
var options = {},
key = $optionSet.attr('data-option-key'),
value = $this.attr('data-option-value');
// parse 'false' as false boolean
value = value === 'false' ? false : value;
options[ key ] = value;
if (key === 'layoutMode' && typeof changeLayoutMode === 'function') {
// changes in layout modes need extra logic
changeLayoutMode($this, options)
} else {
// otherwise, apply new options
$container.isotope(options);
}
return false;
});
});
})(jQuery);
});
</script>
<?php endif; ?>
touch.gallery.js : 여기
내가 수정이 개 중요한 파일의 코드
(function($){
/* Private variables */
var overlay = $('<div id="galleryOverlay">'),
slider = $('<div id="gallerySlider">'),
prevArrow = $('<a id="prevArrow"></a>'),
nextArrow = $('<a id="nextArrow"></a>'),
overlayVisible = false;
/* Creating the plugin */
$.fn.touchTouch = function(){
var placeholders = $([]),
index = 0,
items = this;
gtritems = items;
$.each(gtritems, function() {
if(!$(this).hasClass("MyCat")){
$(this).remove();
}
});
console.log(gtritems);
// Appending the markup to the page
overlay.hide().appendTo('body');
slider.appendTo(overlay);
// Creating a placeholder for each image
gtritems.each(function(){
placeholders = placeholders.add($('<div class="placeholder">'));
});
$("#gallerySlider").empty();
// Hide the gallery if the background is touched/clicked
slider.append(placeholders).on('click',function(e){
if(!$(e.target).is('img')){
hideOverlay();
}
});
// Listen for touch events on the body and check if they
// originated in #gallerySlider img - the images in the slider.
$('body').on('touchstart', '#gallerySlider img', function(e){
var touch = e.originalEvent,
startX = touch.changedTouches[0].pageX;
slider.on('touchmove',function(e){
e.preventDefault();
touch = e.originalEvent.touches[0] ||
e.originalEvent.changedTouches[0];
if(touch.pageX - startX > 10){
slider.off('touchmove');
showPrevious();
}
else if (touch.pageX - startX < -10){
slider.off('touchmove');
showNext();
}
});
// Return false to prevent image
// highlighting on Android
return false;
}).on('touchend',function(){
slider.off('touchmove');
});
// Listening for clicks on the thumbnails
gtritems.on('click', function(e){
e.preventDefault();
// Find the position of this image
// in the collection
index = gtritems.index(this);
console.log(this);
showOverlay(index);
showImage(index);
// Preload the next image
preload(index+1);
// Preload the previous
preload(index-1);
});
// If the browser does not have support
// for touch, display the arrows
if (!("ontouchstart" in window)){
overlay.append(prevArrow).append(nextArrow);
prevArrow.click(function(e){
e.preventDefault();
showPrevious();
});
nextArrow.click(function(e){
e.preventDefault();
showNext();
});
}
// Listen for arrow keys
$(window).bind('keydown', function(e){
if (e.keyCode == 37){
showPrevious();
}
else if (e.keyCode==39){
showNext();
}
});
/* Private functions */
function showOverlay(index){
// If the overlay is already shown, exit
if (overlayVisible){
return false;
}
// Show the overlay
overlay.show();
setTimeout(function(){
// Trigger the opacity CSS transition
overlay.addClass('visible');
}, 100);
// Move the slider to the correct image
offsetSlider(index);
// Raise the visible flag
overlayVisible = true;
}
function hideOverlay(){
// If the overlay is not shown, exit
if(!overlayVisible){
return false;
}
// Hide the overlay
overlay.hide().removeClass('visible');
overlayVisible = false;
}
function offsetSlider(index){
// This will trigger a smooth css transition
slider.css('left',(-index*100)+'%');
}
// Preload an image by its index in the items array
function preload(index){
setTimeout(function(){
showImage(index);
}, 1000);
}
// Show image in the slider
function showImage(index){
// If the index is outside the bonds of the array
if(index < 0 || index >= gtritems.length){
return false;
}
// Call the load function with the href attribute of the item
loadImage(gtritems.eq(index).attr('href'), function(){
placeholders.eq(index).html(this);
});
}
// Load the image and execute a callback function.
// Returns a jQuery object
function loadImage(src, callback){
var img = $('<img>').on('load', function(){
callback.call(img);
});
img.attr('src',src);
}
function showNext(){
// If this is not the last image
if(index+1 < gtritems.length){
index++;
offsetSlider(index);
preload(index+1);
}
else{
// Trigger the spring animation
slider.addClass('rightSpring');
setTimeout(function(){
slider.removeClass('rightSpring');
},500);
}
}
function showPrevious(){
// If this is not the first image
if(index>0){
index--;
offsetSlider(index);
preload(index-1);
}
else{
// Trigger the spring animation
slider.addClass('leftSpring');
setTimeout(function(){
slider.removeClass('leftSpring');
},500);
}
}
};
})(jQuery);