make justify gallery work with more than one albums per page (eg album widget)

This commit is contained in:
Mario Vavti 2015-12-07 12:13:51 +01:00
parent 53627c89a7
commit 69c9f4588c
6 changed files with 12 additions and 9 deletions

View File

@ -1338,6 +1338,7 @@ function widget_album($args) {
$o .= replace_macros($tpl, array(
'$photos' => $photos,
'$album' => (($title) ? $title : $album),
'$album_id' => rand(),
'$album_edit' => array(t('Edit Album'), $album_edit),
'$can_post' => false,
'$upload' => array(t('Upload'), z_root() . '/photos/' . get_app()->profile['channel_address'] . '/upload/' . bin2hex($album)),

View File

@ -779,6 +779,7 @@ function photos_content(&$a) {
$o .= replace_macros($tpl, array(
'$photos' => $photos,
'$album' => $album,
'$album_id' => rand(),
'$album_edit' => array(t('Edit Album'), $album_edit),
'$can_post' => $can_post,
'$upload' => array(t('Upload'), $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/upload/' . bin2hex($album)),
@ -1313,6 +1314,7 @@ function photos_content(&$a) {
$tpl = get_markup_template('photos_recent.tpl');
$o .= replace_macros($tpl, array(
'$title' => t('Recent Photos'),
'$album_id' => rand(),
'$can_post' => $can_post,
'$upload' => array(t('Upload'), $a->get_baseurl().'/photos/'.$a->data['channel']['channel_address'].'/upload'),
'$photos' => $photos,

View File

@ -758,9 +758,9 @@ function pageUpdate() {
});
}
function justifyPhotos() {
function justifyPhotos(id) {
justifiedGalleryActive = true;
$('#photo-album-contents').justifiedGallery({
$('#' + id).justifiedGallery({
selector: '> a, > div:not(.spinner, #page-end)',
margins: 3,
border: 0,
@ -775,9 +775,9 @@ function justifyPhotos() {
}).on('jg.complete', function(e){ justifiedGalleryActive = false; });
}
function justifyPhotosAjax() {
function justifyPhotosAjax(id) {
justifiedGalleryActive = true;
$('#photo-album-contents').justifiedGallery('norewind').on('jg.complete', function(e){ justifiedGalleryActive = false; });
$('#' + id).justifiedGallery('norewind').on('jg.complete', function(e){ justifiedGalleryActive = false; });
}
function notify_popup_loader(notifyType) {

View File

@ -21,7 +21,7 @@
{{$upload_form}}
{{$album_edit.1}}
<div class="section-content-wrapper-np">
<div id="photo-album-contents">
<div id="photo-album-contents-{{$album_id}}">
{{foreach $photos as $photo}}
{{include file="photo_top.tpl"}}
{{/foreach}}
@ -30,5 +30,5 @@
</div>
</div>
<div class="photos-end"></div>
<script>$(document).ready(function() { loadingPage = false; justifyPhotos(); });</script>
<script>$(document).ready(function() { loadingPage = false; justifyPhotos('photo-album-contents-{{$album_id}}'); });</script>
<div id="page-spinner"></div>

View File

@ -8,7 +8,7 @@
</div>
{{$upload_form}}
<div class="section-content-wrapper-np">
<div id="photo-album-contents">
<div id="photo-album-contents-{{$album_id}}">
{{foreach $photos as $photo}}
{{include file="photo_top.tpl"}}
{{/foreach}}
@ -17,5 +17,5 @@
</div>
</div>
<div class="photos-end"></div>
<script>$(document).ready(function() { loadingPage = false; justifyPhotos(); });</script>
<script>$(document).ready(function() { loadingPage = false; justifyPhotos('photo-album-contents-{{$album_id}}'); });</script>
<div id="page-spinner"></div>

View File

@ -1,4 +1,4 @@
{{foreach $photos as $photo}}
{{include file="photo_top.tpl"}}
{{/foreach}}
<script>justifyPhotosAjax()</script>
<script>justifyPhotosAjax('photo-album-contents-{{$album_id}}')</script>