Ignore:
Timestamp:
Sep 18, 2013, 6:36:27 PM (11 years ago)
Author:
rvelices
Message:

smartpocket retina aware thumbnails display on index page

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/themes/smartpocket/js/smartpocket.js

    r23745 r24514  
    2121    // onToolbarTap - listen out for when the toolbar is tapped
    2222    myPhotoSwipe.addEventHandler(PhotoSwipe.EventTypes.onToolbarTap, function(e){
    23     if (e.toolbarAction === PhotoSwipe.Toolbar.ToolbarAction.none){
    24       if (e.tapTarget === more_link || Util.DOM.isChildOf(e.tapTarget, more_link)){
    25         var currentImage = myPhotoSwipe.getCurrentImage();
    26         window.location=currentImage.metaData.picture_url;
    27       }
    28     }
    29 });     $(document).bind('orientationchange', set_thumbnails_width);
    30     set_thumbnails_width();
     23                        if (e.toolbarAction === PhotoSwipe.Toolbar.ToolbarAction.none){
     24                                if (e.tapTarget === more_link || Util.DOM.isChildOf(e.tapTarget, more_link)){
     25                                        var currentImage = myPhotoSwipe.getCurrentImage();
     26                                        window.location=currentImage.metaData.picture_url;
     27                                }
     28                        }
     29                });
     30                $(window).bind('orientationchange', set_thumbnails_width);
     31                set_thumbnails_width();
    3132  });
    3233}(window, window.jQuery, window.Code.PhotoSwipe));
    3334
    3435function set_thumbnails_width() {
    35   nb_thumbs = Math.max(3, Math.ceil($('.thumbnails').width() / 130));
    36   width = Math.floor(1000000 / nb_thumbs) / 10000;
    37   $('.thumbnails li').css('width', width+'%');
     36        var dpr = window.devicePixelRatio>1 ? window.devicePixelRatio : 1
     37                , nb_thumbs = Math.max(2, Math.ceil($('.thumbnails').width() / (var_thumb_width/dpr+2*5)))
     38                , width = Math.floor(1000000 / nb_thumbs) / 10000;
     39        $('.thumbnails li').css('width', width+'%');
    3840}
    3941
Note: See TracChangeset for help on using the changeset viewer.