Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

photoswipe custom toolbar with jquery mobile

I am new in jquery mobile and jquery also. I am working on a project with phonegap and jquery mobile. I am using PhotoSwipe for image gallery. It is working nice and show the images. But I want to make a custom toolbar for photoswipe for my gallery. I saw their given custom-toolbar sample and almost made it. But though I am new in this sector so I failed to integrate it with jquery mobile. And my custom button does not work at all. Here is my code sample.

for (var i = 0; i < photo_len; i++) {
    $('.GalleryAccessories').append('<li><a href="' + image_item[i].original + '" rel="external"><img src="' + image_item[i].original + '" alt=""/></a></li>');
}

$('.GalleryAccessories').trigger("create");

var myPhotoSwipe = $(".GalleryAccessories a").photoSwipe({
    getToolbar: function(){
        return '<div class="ps-toolbar-close" style="padding-top: 12px;">Back</div><div class="ps-toolbar-play" style="padding-top: 12px;">Play</div><div class="ps-toolbar-previous" style="padding-top: 12px;">Previous</div><div class="ps-toolbar-next" style="padding-top: 12px;">Next</div><div class="ps-toolbar-close" style="padding-top: 12px;">View All</div>';
    },
    jQueryMobile: true,
    loop: false,
    enableMouseWheel: false,
    enableKeyboard: false
});

myPhotoSwipe.show(0);

View All button doesn't work at all. I have tried their given code but no luck. I even tried just what i do now but still it doesn't work. Sorry for my poor english. Please help me... Thanks in advance.

like image 806
Sakib Avatar asked May 03 '13 13:05

Sakib


1 Answers

Explanation

This is a PhotoSwipe bug, maybe not a bug but still a problem.

First let me ask you why do you want to have two buttons with same properties? Button Back and your button View All would do the same thing.

Photoswipe will enhance only first occurrence of a class ps-toolbar-close all others will be disregarded. To be hones I don't see the point of this solution. If user wants more buttons just let them have it.

This problem can be solved programmatically.

Solution

Working example: http://jsfiddle.net/Gajotres/nBZfT/

HTML :

<div class="ps-toolbar-close second-close" style="padding-top: 12px;">View All</div>

Javascript :

myPhotoSwipe.addEventHandler(window.Code.PhotoSwipe.EventTypes.onShow, function(e) {
    $(document).off('click', '.second-close').on('click', '.second-close', function(){    
        e.target.hide();
    });
});
like image 152
Gajotres Avatar answered Nov 17 '22 15:11

Gajotres