1/** 2* Plugin main Frontend JavaScript file 3*/ 4(function($){ 5$(document).ready(function() { 6 7 'use strict'; 8 9 // Calculations in Single post page 10 if($('.single-post').length > 0) { 11 var post_container_height = $('.blog-post.blog-post-single').height(); 12 var post_container_top = $('.blog-post.blog-post-single').offset().top; 13 var post_container_bottom = post_container_top + post_container_height; 14 } 15 16 // Post reading progress for single post page 17 if($('.single-post .blog-post-reading-progress').length > 0) { 18 19 var current_position_inside_post = 0; 20 var current_progress = 0; 21 22 $(window).scroll(function () { 23 24 current_position_inside_post = $(window).scrollTop() - post_container_top; 25 current_progress = current_position_inside_post * 100 / post_container_height; 26 27 if(current_progress > 100) { 28 current_progress = 100; 29 } 30 31 if(current_progress < 0) { 32 current_progress = 0; 33 } 34 35 $('.blog-post-reading-progress').width(current_progress + '%'); 36 37 }); 38 } 39 40 // Fixed social share for single post page 41 if($('.single-post .inhype-social-share-fixed').length > 0) { 42 43 var current_position_inside_post2 = 0; 44 var current_progress2 = -1; 45 46 inhype_fixedSocialWorker(); 47 48 $(window).scroll(function () { 49 50 inhype_fixedSocialWorker(); 51 52 }); 53 } 54 55 function inhype_fixedSocialWorker() { 56 57 if(post_container_height > $('.single-post .inhype-social-share-fixed').height()) { 58 current_position_inside_post2 = $(window).scrollTop() - post_container_top; 59 60 current_progress2 = current_position_inside_post2 * 100 / (post_container_height - $('.single-post .inhype-social-share-fixed').height()); 61 62 if(current_progress2 > 100) { 63 64 $('.single-post .inhype-social-share-fixed').css('position', 'absolute'); 65 $('.single-post .inhype-social-share-fixed').css('bottom', 0); 66 $('.single-post .inhype-social-share-fixed').css('top', 'auto'); 67 $('.single-post .inhype-social-share-fixed').css('opacity', 0); 68 69 } else if(current_progress2 > 90) { 70 $('.single-post .inhype-social-share-fixed').css('opacity', 0); 71 } else if(current_progress2 < 0) { 72 73 $('.single-post .inhype-social-share-fixed').css('position', 'absolute'); 74 $('.single-post .inhype-social-share-fixed').css('bottom', 'auto'); 75 $('.single-post .inhype-social-share-fixed').css('top', 0); 76 $('.single-post .inhype-social-share-fixed').css('margin-top', 0); 77 $('.single-post .inhype-social-share-fixed').css('opacity', 1); 78 79 } else { 80 81 $('.single-post .inhype-social-share-fixed').css('position', 'fixed'); 82 $('.single-post .inhype-social-share-fixed').css('bottom', 'auto'); 83 $('.single-post .inhype-social-share-fixed').css('top', 0); 84 $('.single-post .inhype-social-share-fixed').css('margin-top', '200px'); 85 $('.single-post .inhype-social-share-fixed').css('opacity', 1); 86 87 } 88 } 89 90 } 91 92 // Worth reading block display 93 if($('.post-worthreading-post-wrapper').length > 0) { 94 95 var current_position_inside_post3 = 0; 96 var current_progress3 = -1; 97 98 inhype_WorthReadingWorker(); 99 100 $(window).scroll(function () { 101 102 inhype_WorthReadingWorker(); 103 104 }); 105 } 106 107 function inhype_WorthReadingWorker() { 108 109 current_position_inside_post3 = $(window).scrollTop() - post_container_top; 110 111 current_progress3 = current_position_inside_post3 * 100 / post_container_height; 112 113 if(current_progress3 > 70) { 114 115 $('.single-post .post-worthreading-post-wrapper .post-worthreading-post-container').addClass('opened'); 116 117 } else { 118 119 $('.single-post .post-worthreading-post-wrapper .post-worthreading-post-container').removeClass('opened'); 120 121 } 122 123 } 124 125 $('.single-post .post-worthreading-post-wrapper .post-worthreading-post-container .btn-close').on('click', function(e){ 126 $('.single-post .post-worthreading-post-wrapper .post-worthreading-post-container').addClass('disabled'); 127 }); 128 129 /** 130 * Social share for posts 131 */ 132 133 function inhype_socialshare(type, post_url, post_title, post_image) { 134 135 switch (type) { 136 case 'facebook': 137 window.open( 'https://www.facebook.com/sharer/sharer.php?u='+post_url, "facebookWindow", "height=380,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0" ); 138 break; 139 case 'twitter': 140 window.open( 'http://twitter.com/intent/tweet?text='+post_title + ' ' + post_url, "twitterWindow", "height=370,width=600,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0" ); 141 break; 142 case 'pinterest': 143 window.open( 'http://pinterest.com/pin/create/button/?url='+post_url+'&media='+post_image
143+'&description='+post_title, "pinterestWindow", "height=620,width=600,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0" ); 144 break; 145 case 'whatsapp': 146 window.open( 'https://api.whatsapp.com/send?text='+post_title+' '+post_url, "whatsupWindow", "height=620,width=600,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0" ); 147 break; 148 case 'vk': 149 window.open( 'https://vk.com/share.php?url='+post_url+'&title='+post_title+'&description=&image='+post_image, "vkWindow", "height=620,width=600,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0" ); 150 break; 151 case 'linkedin': 152 window.open( 'https://www.linkedin.com/shareArticle?url='+post_url+'&title='+post_title, "linkedinWindow", "height=620,width=600,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0" ); 153 break; 154 case 'reddit': 155 window.open( 'https://reddit.com/submit?url='+post_url, "linkedinWindow", "height=620,width=600,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0" ); 156 break; 157 default: 158 window.location.href=post_url; 159 160 break; 161 162 } 163 164 return false; 165 } 166 167 $('body').on('click', '.post-social a', function(e){ 168 169 if($(this).data('type') !== 'link') { 170 e.preventDefault(); 171 e.stopPropagation(); 172 173 var share_type = $(this).data('type'); 174 var post_image = $(this).data('image'); 175 var post_title = encodeURIComponent($(this).data('title')); 176 var post_url = $(this).attr('href'); 177 178 inhype_socialshare(share_type, post_url, post_title, post_image); 179 } 180 181 }); 182 183 184}); 185})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.