|
1 | 1 | // ==================================================
|
2 |
| -// fancyBox v3.1.23 |
| 2 | +// fancyBox v3.1.24 |
3 | 3 | //
|
4 | 4 | // Licensed GPLv3 for open source use
|
5 | 5 | // or fancyBox Commercial License for commercial use
|
|
2629 | 2629 |
|
2630 | 2630 | $.fancybox = {
|
2631 | 2631 |
|
2632 |
| - version : "3.1.23", |
| 2632 | + version : "3.1.24", |
2633 | 2633 | defaults : defaults,
|
2634 | 2634 |
|
2635 | 2635 |
|
|
3074 | 3074 |
|
3075 | 3075 | // Examples:
|
3076 | 3076 | // http://maps.google.com/?ll=48.857995,2.294297&spn=0.007666,0.021136&t=m&z=16
|
3077 |
| - // http://maps.google.com/?ll=48.857995,2.294297&spn=0.007666,0.021136&t=m&z=16 |
3078 |
| - // https://www.google.lv/maps/place/Googleplex/@37.4220041,-122.0833494,17z/data=!4m5!3m4!1s0x0:0x6c296c66619367e0!8m2!3d37.4219998!4d-122.0840572 |
3079 |
| - google_maps : { |
| 3077 | + // https://www.google.com/maps/@37.7852006,-122.4146355,14.65z |
| 3078 | + // https://www.google.com/maps/place/Googleplex/@37.4220041,-122.0833494,17z/data=!4m5!3m4!1s0x0:0x6c296c66619367e0!8m2!3d37.4219998!4d-122.0840572 |
| 3079 | + gmap_place : { |
3080 | 3080 | matcher : /(maps\.)?google\.([a-z]{2,3}(\.[a-z]{2})?)\/(((maps\/(place\/(.*)\/)?\@(.*),(\d+.?\d+?)z))|(\?ll=))(.*)?/i,
|
3081 | 3081 | type : 'iframe',
|
3082 | 3082 | url : function (rez) {
|
3083 | 3083 | return '//maps.google.' + rez[2] + '/?ll=' + ( rez[9] ? rez[9] + '&z=' + Math.floor( rez[10] ) + ( rez[12] ? rez[12].replace(/^\//, "&") : '' ) : rez[12] ) + '&output=' + ( rez[12] && rez[12].indexOf('layer=c') > 0 ? 'svembed' : 'embed' );
|
3084 | 3084 | }
|
| 3085 | + }, |
| 3086 | + |
| 3087 | + // Examples: |
| 3088 | + // https://www.google.com/maps/search/Empire+State+Building/ |
| 3089 | + // https://www.google.com/maps/search/?api=1&query=centurylink+field |
| 3090 | + // https://www.google.com/maps/search/?api=1&query=47.5951518,-122.3316393 |
| 3091 | + gmap_search : { |
| 3092 | + matcher : /(maps\.)?google\.([a-z]{2,3}(\.[a-z]{2})?)\/(maps\/search\/)(.*)/i, |
| 3093 | + type : 'iframe', |
| 3094 | + url : function (rez) { |
| 3095 | + return '//maps.google.' + rez[2] + '/maps?q=' + rez[5].replace('query=', 'q=').replace('api=1', '') + '&output=embed'; |
| 3096 | + } |
3085 | 3097 | }
|
3086 | 3098 | };
|
3087 | 3099 |
|
|
3170 | 3182 |
|
3171 | 3183 | item.contentProvider = provider;
|
3172 | 3184 |
|
3173 |
| - item.opts.slideClass += ' fancybox-slide--' + ( provider == 'google_maps' ? 'map' : 'video' ); |
| 3185 | + item.opts.slideClass += ' fancybox-slide--' + ( provider == 'gmap_place' || provider == 'gmap_search' ? 'map' : 'video' ); |
3174 | 3186 | }
|
3175 | 3187 |
|
3176 | 3188 | } else {
|
|
4728 | 4740 | };
|
4729 | 4741 | }
|
4730 | 4742 |
|
| 4743 | + // Create new history entry only once |
| 4744 | + var shouldCreateHistory = true; |
| 4745 | + |
4731 | 4746 | // Variable containing last hash value set by fancyBox
|
4732 | 4747 | // It will be used to determine if fancyBox needs to close after hash change is detected
|
4733 | 4748 | var currentHash = null;
|
4734 | 4749 |
|
4735 |
| - // Throtlling the history change |
| 4750 | + // Throttling the history change |
4736 | 4751 | var timerID = null;
|
4737 | 4752 |
|
4738 | 4753 | // Get info about gallery name and current index from url
|
|
4763 | 4778 | // If we can find element matching 'data-fancybox' atribute, then trigger click event for that ..
|
4764 | 4779 | $el = $( "[data-fancybox='" + $.escapeSelector( url.gallery ) + "']" ).eq( url.index - 1 );
|
4765 | 4780 |
|
4766 |
| - if ( $el.length ) { |
4767 |
| - $el.trigger( 'click' ); |
4768 |
| - |
4769 |
| - } else { |
4770 |
| - |
| 4781 | + if ( !$el.length ) { |
4771 | 4782 | // .. if not, try finding element by ID
|
4772 |
| - $( "#" + $.escapeSelector( url.gallery ) + "" ).trigger( 'click' ); |
| 4783 | + $el = $( "#" + $.escapeSelector( url.gallery ) + "" ); |
| 4784 | + } |
4773 | 4785 |
|
| 4786 | + if ( $el.length ) { |
| 4787 | + shouldCreateHistory = false; |
| 4788 | + |
| 4789 | + $el.trigger( 'click' ); |
4774 | 4790 | }
|
4775 | 4791 |
|
4776 | 4792 | }
|
|
4819 | 4835 |
|
4820 | 4836 | },
|
4821 | 4837 |
|
4822 |
| - 'beforeShow.fb' : function( e, instance, current, firstRun ) { |
| 4838 | + 'beforeShow.fb' : function( e, instance, current ) { |
4823 | 4839 | var gallery;
|
4824 | 4840 |
|
4825 | 4841 | if ( current.opts.hash === false ) {
|
|
4843 | 4859 | }
|
4844 | 4860 |
|
4845 | 4861 | timerID = setTimeout(function() {
|
4846 |
| - window.history[ firstRun ? 'pushState' : 'replaceState' ]( {} , document.title, window.location.pathname + window.location.search + '#' + currentHash ); |
| 4862 | + window.history[ shouldCreateHistory ? 'pushState' : 'replaceState' ]( {} , document.title, window.location.pathname + window.location.search + '#' + currentHash ); |
4847 | 4863 |
|
4848 | 4864 | timerID = null;
|
4849 | 4865 |
|
| 4866 | + shouldCreateHistory = false; |
| 4867 | + |
4850 | 4868 | }, 300);
|
4851 | 4869 |
|
4852 | 4870 | } else {
|
|
4898 | 4916 | currentHash = null;
|
4899 | 4917 |
|
4900 | 4918 | $.fancybox.close();
|
| 4919 | + |
| 4920 | + shouldCreateHistory = true; |
4901 | 4921 | }
|
4902 | 4922 |
|
4903 | 4923 | } else if ( url.gallery !== '' ) {
|
4904 | 4924 | triggerFromUrl( url );
|
4905 | 4925 | }
|
4906 | 4926 | });
|
4907 | 4927 |
|
4908 |
| - // If navigating away from current page |
4909 |
| - $(window).one('unload.fb popstate.fb', function() { |
4910 |
| - $.fancybox.getInstance( 'close', true, 0 ); |
4911 |
| - }); |
4912 |
| - |
4913 | 4928 | // Check current hash and trigger click event on matching element to start fancyBox, if needed
|
4914 | 4929 | triggerFromUrl( parseUrl() );
|
4915 | 4930 |
|
|
0 commit comments