Advertisement
aivavic

magnificPopup

Apr 20th, 2016
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     $('.gallery').magnificPopup({
  2.         delegate: 'a',
  3.         type: 'image',
  4.         tLoading: 'Loading image #%curr%...',
  5.         mainClass: 'mfp-img-mobile',
  6.         gallery: {
  7.             enabled: true,
  8.             navigateByImgClick: true,
  9.             preload: [0,1] // Will preload 0 - before current, and 1 after the current image
  10.         },
  11.         image: {
  12.             tError: '<a href="%url%">The image #%curr%</a> could not be loaded.',
  13.             titleSrc: function(item) {
  14.                 //return //item.el.attr('title');
  15.                 var $gallery = $('.gallery');
  16.                 var $result = '';
  17.                 if ($gallery.find('li').length>0) {
  18.                     $result = '<div class="mfp-pager">' +
  19.                         '<div class="arrow_prev">' +
  20.                             '<button type="button" class="prev arrow" onclick="javascript:$(\'.gallery\').magnificPopup(\'prev\');return false;">Previous</button>' +
  21.                         '</div>' +
  22.                         '<div class="dots">' +
  23.                             '<ul class="dots" style="display: inline-block;">';
  24.                     for (var i=0; i<$gallery.find('li').length; i++) {
  25.                         var $cl_active = '';
  26.                         if (item.index == i) $cl_active = ' class="active"'; else $cl_active = '';
  27.                         var $thumb = $gallery.find('li:eq('+i+')').find('img').attr('src');
  28.                         $result += '<li'+$cl_active+'>' +
  29.               '<img class=\'pagination\' src=\''+$thumb+'\' onclick="javascript:$(\'.gallery\').magnificPopup(\'goTo\', '+i+');return false;">'
  30.                                 // '<button type="button" onclick="javascript:$(\'.gallery\').magnificPopup(\'goTo\', '+i+');return false;">' + i + '</button>'
  31.               +
  32.                             '</li>';
  33.                     }
  34.                     $result += '</ul>' +
  35.                         '</div>' +
  36.                         '<div class="arrow_next">' +
  37.                             '<button type="button" class="next arrow" onclick="javascript:$(\'.gallery\').magnificPopup(\'next\');return false;">Next</button>' +
  38.                         '</div>' +
  39.                     '</div>';
  40.                 }
  41.                 return $result;
  42.             }
  43.         }
  44.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement