6

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.

Gajotres
  • 57,309
  • 16
  • 102
  • 130
Sakib
  • 472
  • 5
  • 17
  • Plz help me... I am trying but no luck for me. – Sakib May 06 '13 at 03:48
  • 1
    what error are you getting? can you reproduce the problem using jsfiddle? – Omar May 06 '13 at 08:55
  • @Omar, I am getting any error. Back, play, previous, next buttons are working fine but view all button don't work. I have use "ps-toolbar-close" for both back and view all. is it a problem? if yes i have no idea about how to solve it. – Sakib May 06 '13 at 09:29
  • sorry, means do not get any error. – Sakib May 06 '13 at 09:49
  • I solved my extrabutton problem by adding a button on my header and show the gallery in a custom target. But cann't solve the real problem that i posted here to solve. – Sakib May 10 '13 at 11:27

1 Answers1

7

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();
    });
});
Community
  • 1
  • 1
Gajotres
  • 57,309
  • 16
  • 102
  • 130