-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dennis Patzer
committed
Mar 21, 2018
1 parent
cf30e68
commit afb5fdb
Showing
5 changed files
with
135 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
huh: | ||
encore: | ||
entries: | ||
- { name: contao-list-bundle, file: "vendor/heimrichhannot/contao-list-bundle/src/Resources/public/js/jquery.list-bundle.es6.js" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
var jQuery = require('jquery'); | ||
|
||
(function($) | ||
{ | ||
window.LIST_BUNDLE = { | ||
init: function() | ||
{ | ||
this.initPagination(); | ||
this.initMasonry(); | ||
}, | ||
initPagination: function() | ||
{ | ||
$('.huh-list .ajax-pagination').each(function() | ||
{ | ||
var $list = $(this).closest('.huh-list'), | ||
$items = $list.find('.items'), | ||
$wrapper = $list.find('.wrapper'), | ||
id = '#' + $wrapper.attr('id'); | ||
|
||
$wrapper.jscroll({ | ||
loadingHtml: '<div class="loading"><span class="text">Lade...</span></div>', | ||
nextSelector: '.ajax-pagination a.next', | ||
autoTrigger: $wrapper.data('add-infinite-scroll') == 1, | ||
contentSelector: id, | ||
callback: function() | ||
{ | ||
var $jscrollAdded = $(this), | ||
$newItems = $jscrollAdded.find('.item'); | ||
|
||
$newItems.hide(); | ||
|
||
$jscrollAdded.imagesLoaded(function() | ||
{ | ||
$items.append($newItems.fadeIn(300)); | ||
|
||
if ($wrapper.attr('data-add-masonry') === "1") { | ||
$items.masonry('appended', $newItems); | ||
$items.masonry(); | ||
} | ||
|
||
// remove item counters... | ||
$items.find('.item').removeClass(function(index, cssClass) | ||
{ | ||
var matches = cssClass.match(/item_\d+/g); | ||
|
||
if (matches instanceof Array && matches.length > 0) | ||
{ | ||
return matches[0]; | ||
} | ||
}); | ||
|
||
//... and readd them again | ||
$items.find('.item').each(function(index) | ||
{ | ||
var $item = $(this), | ||
itemIndex = index + 1; | ||
|
||
$(this).addClass('item_' + itemIndex).removeClass('odd even first last'); | ||
|
||
// odd/even | ||
if (itemIndex % 2 == 0) | ||
{ | ||
$item.addClass('even'); | ||
} | ||
else | ||
{ | ||
$item.addClass('odd'); | ||
} | ||
|
||
// add first and last | ||
if (itemIndex == 1) | ||
{ | ||
$item.addClass('first'); | ||
} | ||
|
||
if (itemIndex == $items.find('.item').length) | ||
{ | ||
$item.addClass('last'); | ||
} | ||
}); | ||
|
||
$jscrollAdded.find('.ajax-pagination').appendTo($jscrollAdded.closest('.jscroll-inner')); | ||
$jscrollAdded.remove(); | ||
}); | ||
} | ||
}); | ||
}); | ||
}, | ||
initMasonry: function() | ||
{ | ||
$('.huh-list .wrapper[data-add-masonry="1"]').each(function() | ||
{ | ||
var $this = $(this).find('.items'), | ||
options = $(this).data('masonry-options'); | ||
|
||
var $grid = $this.imagesLoaded(function() | ||
{ | ||
$grid.masonry({ | ||
// fitWidth: true, | ||
itemSelector: '.item', | ||
stamp: '.stamp-item' | ||
}); | ||
|
||
// update due to stamps | ||
$grid.masonry(); | ||
}); | ||
}); | ||
} | ||
}; | ||
|
||
$(document).ready(function() { | ||
LIST_BUNDLE.init(); | ||
}); | ||
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.