1/** 2 * Advanced post navigator WordPress plugin 3 * Version: 1.3 4 * Requirements: jQuery Library 5 * Author: Aakash Chakravarthy 6 * Website: www.aakashweb.com 7 * 8 **/ 9 10var anpnStat = { 11 'next': 0, 12 'prev': 0 13}; 14 15var anpnEffects = { 16 'fade': { 17 'next': { 18 'init': { 'opacity': 0 }, 19 'act': { 'opacity': 1 } 20 }, 21 'prev': { 22 'init': { 'opacity': 0 }, 23 'act': { 'opacity': 1 } 24 } 25 }, 26 27 'slide':{ 28 'next': { 29 'init': { 'opacity': 0 , 'margin-right': '-10px'}, 30 'act': { 'opacity': 1 , 'margin-right': 0 } 31 }, 32 'prev': { 33 'init': { 'opacity': 0 , 'margin-left': '-10px' }, 34 'act': { 'opacity': 1 , 'margin-left': 0 } 35 } 36 }, 37 38 'none': { 39 'next': { 40 'init': {}, 41 'act': {} 42 }, 43 'prev': { 44 'init': {}, 45 'act': {} 46 } 47 } 48}; 49 50var anpnDefaults = { 51 'effect': "fade", 52 'duration': "0.3", 53 'keyMode': 'showOpen', 54 'scrollBottom': true, 55 'scrollOffset': 0 56}; 57 58var anpnSets = {}; 59 60jQuery(document).ready(function(){ 61 62 // Check whether anpnConfig variable is present in the page 63 if(typeof anpnConfig === "undefined") return 0; 64 65 // Map the defaults and the settings 66 anpnSets = jQuery.extend({}, anpnDefaults, anpnConfig); 67 68 // Action to perform when the arrow is hovered 69 jQuery('.anpn-wrap').mouseenter(function() { 70 var type = jQuery(this).attr('data-type'); 71 if(anpnStat[type] == 0) 72 anpnShow(jQuery(this)); 73 }).mouseleave(function() { 74 anpnHide(jQuery(this)); 75 }); 76 77 jQuery('.anpn-text').bind('touchstart', function(e) { 78 var type = jQuery(this).attr('data-type'); 79 // If closed, open it and prevent click or else open link. Since ANPN v1.6 80 if(anpnStat[type] == 0){ 81 e.preventDefault(); 82 anpnShow(jQuery(this)); 83 } 84 }); 85 86 // Keyboard navigation 87 jQuery('body').keydown(function(e) { 88 89 if(anpnSets.keyMode != 'none' && ( !jQuery( 'textarea, input' ).is( ':focus' ) )) 90 91 if(e.keyCode == 37) { // left 92 93 if(anpnSets.keyMode == 'show' || 'showOpen'){ 94 if(anpnStat.prev == 0){ 95 anpnHide2(jQuery('.anpn-wrap')); 96 anpnShow(jQuery('.anpn-prev')); 97 } 98 else if(anpnStat.prev == 1 && anpnSets.keyMode == 'showOpen'){ 99 anpnOpen('prev'); 100 } 101 } 102 103 if(anpnSets.keyMode == 'open'){ 104 anpnOpen('prev'); 105 } 106 107 } 108 else if(e.keyCode == 39) { // right 109 110 if(anpnSets.keyMode == 'show' || 'showOpen'){ 111 if(anpnStat.next == 0){ 112 anpnHide2(jQuery('.anpn-wrap')); 113 anpnShow(jQuery('.anpn-next')); 114 } 115 else if(anpnStat.next == 1 && anpnSets.keyMode == 'showOpen'){ 116 anpnOpen('next'); 117 } 118 } 119 120 if(anpnSets.keyMode == 'open'){ 121 anpnOpen('next'); 122 } 123 124 } 125 else if(e.keyCode == 27) { // escape 126 anpnHide2(jQuery('.anpn-wrap')); 127 } 128 129 }); 130 131 jQuery(window).scroll(function() { 132 if(anpnSets.scrollBottom == true){ 133 if(jQuery(window).scrollTop() + jQuery(window).height() >= anpnGetDocHeight() - anpnSets.scrollOffset) { 134 if(anpnStat.next == 0){ 135 anpnHide2(jQuery('.anpn-prev')); 136 anpnShow(jQuery('.anpn-next')); 137 } 138 } 139 } 140 }); 141 142}); 143
144function anpnShow(obj){ 145 146 if( obj.length == 0 ) return false; 147 148 var $wrap = obj; 149 var type = $wrap.attr('data-type'); 150 var effc = anpnEffects[anpnSets.effect][type]; 151 var $bub = $wrap.find('.anpn-bubble').show(); 152 153 $bub.css({'top': '50%', 'margin-top': -$bub.outerHeight()/2 + 'px'}); 154 $bub.css(effc.init).stop().animate(effc.act, anpnSets.duration * 1000); 155 156 anpnStat[type] = 1; 157} 158 159function anpnHide(obj){ 160 161 if( obj.length == 0 ) return false; 162 163 var $wrap = obj; 164 var type = $wrap.attr('data-type'); 165 var effc = anpnEffects[anpnSets.effect][type]; 166 167 $bub = $wrap.find('.anpn-bubble').show().css(effc.act).stop().animate(effc.init, 'fast', function(){ 168 jQuery(this).hide(); 169 }); 170 171 anpnStat[type] = 0; 172} 173 174function anpnHide2(obj){ 175 176 if( obj.length == 0 ) return false; 177 178 var $wrap = obj; 179 var $bub = $wrap.find('.anpn-bubble').show(); 180 181 $bub.hide(); 182 183 anpnStat.next = anpnStat.prev = 0; 184} 185
186function anpnOpen(type){ 187 var url = jQuery('.anpn-' + type).find('.anpn-text a').attr('href'); 188 189 if ( url && ( !jQuery( 'textarea, input' ).is( ':focus' ) ) ) { 190 window.location = url; 191 } 192 193} 194 195function anpnGetDocHeight() { 196 var D = document; 197 return Math.max( 198 Math.max(D.body.scrollHeight, D.documentElement.scrollHeight), 199 Math.max(D.body.offsetHeight, D.documentElement.offsetHeight), 200 Math.max(D.body.clientHeight, D.documentElement.clientHeight) 201 ); 202}
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.