How does one open PhotoListWidget thumbnails in a new window?

192 views
Skip to first unread message

JayLink1971

unread,
Feb 23, 2012, 6:56:21 PM2/23/12
to panora...@googlegroups.com
The API reference says, "the default behavior when a photo is clicked is to open the corresponding Panoramio photo page in a new browser window or tab" but mine still open in the same window.
 
I presume the answer has something to do with panoramio.events.EventType.PHOTO_CLICKED and Class events.PhotoClickedEvent but I'm not sure what to do.
 
Thanks!

QuentinUK

unread,
Feb 26, 2012, 6:38:30 PM2/26/12
to panora...@googlegroups.com
Yes, override the default event, ie prevent default and add  photo clicked function:-
 
var myRequest = {
  'tag': 'sunset'
};
// add disable clicks to the options
var myOptions = {
  'disableDefaultEvents':[panoramio.events.EventType.PHOTO_CLICKED]
};
var widget = new panoramio.PhotoListWidget('wapiblock', myRequest, myOptions);
panoramio.events.listen(widget, panoramio.events.EventType.PHOTO_CLICKED, photoClicked); 
widget.setPosition(0);// call after setting the listener
function photoClicked(event){
    var photo=event.getPhoto();
    if(photo){
        MaximizeWindow(window.open(photo.getPhotoUrl())); // opens a new window
    }
}
function MaximizeWindow(hWnd){
    hWnd.moveTo(0,0);
    hWnd.resizeTo(screen.width, screen.height);
}

JayLink1971

unread,
Feb 26, 2012, 6:48:21 PM2/26/12
to panora...@googlegroups.com
Thanks so much!

QuentinUK

unread,
Feb 27, 2012, 4:41:14 PM2/27/12
to panora...@googlegroups.com
Some people prefer to let the user make the choice. Since the user can use Click to open the image in the same window or Ctrl-Click to bring up a menu to select whether to open the photo in a new tab or a new window.
Reply all
Reply to author
Forward
0 new messages