-
-
Save imemohit/e1c456999ef826635d3a5cad5b16af50 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function($) { | |
dtGlobals.magnificPopupBaseConfig = { | |
type: 'image', | |
tLoading: 'Loading image ...', | |
mainClass: 'mfp-img-mobile', | |
removalDelay: 300, | |
image: { | |
tError: '<a href="%url%">The image #%curr%</a> could not be loaded.', | |
titleSrc: function(item) { | |
return this.st.dt.getItemTitle(item); | |
} | |
}, | |
iframe: { | |
markup: '<div class="mfp-iframe-scaler">'+ | |
'<div class="mfp-close"></div>'+ | |
'<iframe class="mfp-iframe" frameborder="0" allowfullscreen></iframe>'+ | |
'<div class="mfp-bottom-bar">'+ | |
'<div class="mfp-title"></div>'+ | |
'<div class="mfp-counter"></div>'+ | |
'</div>'+ | |
'</div>' | |
}, | |
callbacks: { | |
markupParse: function(template, values, item) { | |
if ( 'iframe' == item.type ) { | |
template.find('.mfp-title').html( this.st.dt.getItemTitle(item) ); | |
} | |
if ( !this.ev.attr('data-pretty-share') ) { | |
template.addClass("no-share-buttons"); | |
} | |
}, | |
change: function() { | |
if (this.isOpen) { | |
/*transition between the images in the gallery*/ | |
this.wrap.addClass('mfp-open'); | |
} | |
}, | |
beforeClose: function() { | |
$('body, html').css('overflow',''); | |
this.wrap.removeClass('mfp-open'); | |
this.content.addClass('mfp-removing'); | |
}, | |
close: function() { | |
this.content.removeClass('mfp-removing'); | |
}, | |
beforeOpen: function() { | |
var magnificPopup = this; | |
// create settings container | |
if ( typeof this.st.dt == 'undefined' ) { | |
this.st.dt = {}; | |
} | |
// save share buttons array | |
this.st.dt.shareButtonsList = this.ev.attr('data-pretty-share') ? this.ev.attr('data-pretty-share').split(',') : new Array(); | |
// share buttons template | |
this.st.dt.shareButtonsTemplates = { | |
twitter : '<a href="//twitter.com/home?status={location_href}%20{share_title}" class="share-button twitter" target="_blank" title="twitter"><svg class="icon" viewBox="0 0 22 22"><path d="M17.614,5.604c-0.556,0.325-1.171,0.56-1.822,0.688c-0.526-0.551-1.271-0.895-2.099-0.895c-1.586,0-2.873,1.268-2.873,2.83c0,0.221,0.025,0.438,0.074,0.645C8.508,8.753,6.393,7.625,4.977,5.913C4.729,6.33,4.588,6.816,4.588,7.336c0,0.982,0.508,1.85,1.276,2.354c-0.47-0.014-0.912-0.141-1.3-0.354c0,0.013,0,0.024,0,0.035c0,1.372,0.991,2.514,2.304,2.775c-0.241,0.062-0.495,0.101-0.756,0.101c-0.186,0-0.365-0.019-0.541-0.054c0.365,1.127,1.427,1.945,2.682,1.97c-0.982,0.756-2.222,1.208-3.567,1.208c-0.232,0-0.461-0.016-0.686-0.04c1.271,0.804,2.78,1.272,4.402,1.272c5.286,0,8.171-4.312,8.171-8.053c0-0.123-0.003-0.246-0.009-0.367c0.563-0.397,1.05-0.895,1.436-1.463c-0.516,0.225-1.068,0.378-1.648,0.446C16.943,6.817,17.398,6.262,17.614,5.604z"/></svg></a>', | |
facebook : '<a href="//www.facebook.com/sharer.php?s=100&p[url]={location_href}&p[title]={share_title}&p[images][0]={image_src}" class="share-button facebook" target="_blank" title="facebook"><svg class="icon" viewBox="0 0 22 22" ><path d="M13.537,10.513l-1.74,0.001l0.051,6.648H9.395l0.014-6.648H7.816V8.413l1.592-0.001L9.407,7.177c0-1.713,0.485-2.755,2.593-2.755h1.758v2.101H12.66c-0.824,0-0.863,0.292-0.863,0.84l-0.004,1.049h1.975L13.537,10.513z"/></svg></a>', | |
google : '<a href="////plus.google.com/share?url={location_href}&title={share_title}" class="share-button google" target="_blank" title="google+"><svg class="icon" viewBox="0 0 22 22" ><path d="M18.02,9.145h-1.953l0.021,1.958h-1.344l-0.022-1.937l-1.854-0.019l-0.024-1.258l1.896-0.008V5.864h1.343V7.86l1.936,0.042L18.02,9.145L18.02,9.145z M12.254,14.303c0,1.217-1.108,2.698-3.9,2.698c-2.043,0-3.748-0.884-3.748-2.364c0-1.146,0.725-2.625,4.107-2.625c-0.5-0.412-0.625-0.984-0.318-1.604c-1.98,0-2.995-1.166-2.995-2.645c0-1.447,1.076-2.762,3.271-2.762c0.557,0,3.54,0,3.54,0l-0.809,0.823h-0.923C11.13,6.241,11.52,6.97,11.52,7.813c0,0.778-0.427,1.407-1.036,1.874c-1.085,0.838-0.807,1.354,0.312,2.133c1.091,0.845,1.464,1.47,1.464,2.482H12.254z M9.863,7.771C9.712,6.847,8.967,6.09,8.095,6.068c-0.872-0.021-1.457,0.687-1.307,1.61C6.939,8.615,7.726,9.24,8.663,9.24c0.848,0.093,1.305-0.531,1.201-1.458L9.863,7.771z M10.544,14.486c0-0.707-0.78-1.379-2.087-1.379c-1.178-0.015-2.179,0.615-2.179,1.354c0,0.729,0.833,1.354,1.978,1.359c1.56-0.031,2.338-0.553,2.338-1.334H10.544z"/></svg></a>', | |
pinterest : '<a href="//pinterest.com/pin/create/button/?url={location_href}&description={share_title}&media={image_src}" class="share-button pinterest" target="_blank" title="pin it"><svg class="icon" viewBox="0 0 22 22"><path d="M7.318,12.361c0.703-1.242-0.227-1.515-0.372-2.415c-0.596-3.68,4.244-6.193,6.779-3.622c1.754,1.781,0.599,7.257-2.229,6.688C8.786,12.467,12.82,8.11,10.66,7.255c-1.757-0.696-2.689,2.126-1.856,3.528c-0.489,2.412-1.541,4.683-1.114,7.708c1.381-1.002,1.847-2.923,2.228-4.923c0.695,0.422,1.065,0.859,1.951,0.929c3.264,0.253,5.089-3.258,4.641-6.5c-0.396-2.872-3.259-4.335-6.313-3.992c-2.415,0.27-4.822,2.222-4.922,5.014C5.212,10.723,5.697,12.002,7.318,12.361z"/></svg></a>', | |
linkedin : '<a href="//www.linkedin.com/shareArticle?mini=true&url={location_href}&title={share_title}" class="share-button linkedin" target="_blank" ><svg class="icon" viewBox="0 0 22 22"><path d="M9.269 7.02c0 0.714-0.586 1.293-1.307 1.293c-0.722 0-1.307-0.579-1.307-1.293 c0-0.712 0.585-1.291 1.307-1.291C8.683 5.7 9.3 6.3 9.3 7.02H9.269z M9.061 9.279H6.873v7.392h2.188V9.279z M12.91 9.3 h-1.795l-0.027 7.392h2.044c0 0 0-2.742 0-3.879c0-1.04 0.775-1.79 1.7-1.665c0.824 0.1 1.1 0.6 1.1 1.7 c0 1.028-0.021 3.915-0.021 3.89h2.025c0 0 0.025-2.729 0.025-4.708c0-1.981-1.006-2.78-2.604-2.78 c-1.599 0-2.248 1.096-2.248 1.096v-1H12.91z"/></svg></a>' | |
}; | |
// share buttons | |
this.st.dt.getShareButtons = function ( itemData ) { | |
var shareButtons = magnificPopup.st.dt.shareButtonsList, | |
pinterestIndex = -1, | |
shareButtonsLemgth = shareButtons.length, | |
html = ''; | |
for( var i = 0; i < shareButtons.length; i++ ) { | |
if ( 'pinterest' == shareButtons[i] ) { | |
pinterestIndex = i; | |
break; | |
} | |
} | |
if ( shareButtonsLemgth <= 0 ) { | |
return ''; | |
} | |
for ( var i = 0; i < shareButtonsLemgth; i++ ) { | |
// exclude pinterest button for iframes | |
if ( 'iframe' == itemData['type'] && pinterestIndex == i ) { | |
continue; | |
} | |
var itemTitle = itemData['title'], | |
itemSrc = itemData['src'], | |
itemLocation = itemData['location']; | |
if ( 'google' == shareButtons[i] ) { | |
itemTitle = itemTitle.replace(' ', '+'); | |
} | |
html += magnificPopup.st.dt.shareButtonsTemplates[ shareButtons[i] ].replace('{location_href}', encodeURIComponent(itemLocation)).replace('{share_title}', encodeURIComponent(itemTitle)).replace('{image_src}', encodeURIComponent(itemSrc)); | |
} | |
return '<div class="entry-share"><div class="soc-ico">' + html + '<div></div>'; | |
} | |
// item title | |
this.st.dt.getItemTitle = function(item) { | |
var imgTitle = item.el.attr('title') || '', | |
imgSrc = item.el.attr('href'), | |
imgDesc = item.el.attr('data-dt-img-description') || '', | |
imgLocation = item.el.attr('data-dt-location') || location.href, | |
shareButtons = magnificPopup.st.dt.getShareButtons( { 'title': imgDesc, 'src': imgSrc, 'type': item.type, 'location': imgLocation } ); | |
return imgTitle + '<small>' + imgDesc + '</small>' + shareButtons; | |
} | |
} | |
} | |
}; | |
// trigger click on first anchor in the gallery container | |
// work only for posts list | |
$('.dt-gallery-mfp-popup').addClass('mfp-ready').on('click', function(){ | |
var $this = $(this), | |
$container = $this.parents('article.post').first(); | |
if ($this.parents(".ts-wrap").hasClass("ts-interceptClicks")) return; | |
if ( $container.length > 0 ) { | |
var $target = $container.find('.dt-gallery-container a.dt-mfp-item'); | |
if ( $target.length > 0 ) { | |
$target.first().trigger('click'); | |
} | |
}; | |
return false; | |
}); | |
// trigger click on first a.dt-mfp-item in the container | |
$('.dt-trigger-first-mfp').addClass('mfp-ready').on('click', function(){ | |
var $this = $(this), | |
$container = $this.parents('article.post'); | |
if ($this.parents(".ts-wrap").hasClass("ts-interceptClicks")) return; | |
if ( $container.length > 0 ) { | |
var $target = $container.find('a.dt-mfp-item'); | |
if ( $target.length > 0 ) { | |
$target.first().trigger('click'); | |
} | |
}; | |
return false; | |
}); | |
// single opup | |
$('.dt-single-image').addClass('mfp-ready').magnificPopup({ | |
type: 'image' | |
}); | |
$('.dt-single-video').addClass('mfp-ready').magnificPopup({ | |
type: 'iframe' | |
}); | |
$('.dt-single-mfp-popup').on("click", function(e){ | |
var $this = $(this); | |
if ($this.parents(".ts-wrap").hasClass("ts-interceptClicks")) { | |
e.preventDefault(); | |
e.stopImmediatePropagation(); | |
}; | |
if($this.parents(".photo-scroller").length > 0){ | |
var parScroller = $this.parents(".photo-scroller"), | |
parAutoPlay = parScroller.find(".auto-play-btn"); | |
if( parAutoPlay.hasClass("paused") ){ | |
parScroller.addClass("mfp-opened"); | |
parScroller.find(".auto-play-btn.paused").trigger("click"); | |
}; | |
}; | |
if($this.parents(".slider-wrapper").length > 0){ | |
var parScrollerShor = $this.parents(".slider-wrapper"), | |
parAutoPlayShor = parScrollerShor.find(".auto-play-btn"); | |
if( parAutoPlayShor.hasClass("paused") ){ | |
parScrollerShor.addClass("mfp-opened"); | |
parScrollerShor.find(".auto-play-btn.paused").trigger("click"); | |
}; | |
} | |
}); | |
$('.dt-single-mfp-popup').addClass('mfp-ready').magnificPopup($.extend( true, dtGlobals.magnificPopupBaseConfig, { | |
callbacks: { | |
close: function() { | |
$(".photo-scroller.mfp-opened").find(".auto-play-btn").trigger("click"); | |
$(".photo-scroller").removeClass("mfp-opened"); | |
$(".slider-wrapper.mfp-opened").find(".auto-play-btn").trigger("click"); | |
$(".slider-wrapper").removeClass("mfp-opened"); | |
} | |
} | |
})); | |
$(".dt-gallery-container").each(function(){ | |
if($(this).parents(".slider-wrapper").length > 0){ | |
var $this = $(this).parents(".slider-wrapper"); | |
}else{ | |
var $this = $(this); | |
} | |
var $thisPlay = $this.find(".auto-play-btn"); | |
$(this).addClass('mfp-ready').magnificPopup( $.extend( true, dtGlobals.magnificPopupBaseConfig, { | |
delegate: 'a.dt-mfp-item', | |
tLoading: 'Loading image #%curr%...', | |
gallery: { | |
enabled: true, | |
navigateByImgClick: true, | |
preload: [0,1] // Will preload 0 - before current, and 1 after the current image | |
}, | |
callbacks: { | |
open: function() { | |
var stopAutoPlay = ( 'true' === $this.attr("data-autoslide") ) ? true : false; | |
if(stopAutoPlay){ | |
if( $thisPlay.hasClass("paused") ){ | |
$this.addClass("mfp-opened"); | |
$this.find(".auto-play-btn.paused").trigger("click"); | |
}; | |
} | |
}, | |
close: function() { | |
if( $this.hasClass("mfp-opened") ){ | |
$this.find(".auto-play-btn").trigger("click"); | |
$this.removeClass("mfp-opened"); | |
} | |
} | |
} | |
} ) ); | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment