1 2/******************************************************************************/ 3/******************************************************************************/ 4 5(function($) 6{ 7 /**************************************************************************/ 8 9 var NextPost=function(options) 10 { 11 /**********************************************************************/ 12 13 var $this=this; 14 15 $this.defaults= 16 { 17 18 }; 19 20 $this.options=$.extend($this.defaults,options); 21 22 $this.nextPost=$('#next-post'); 23 $this.prevPost=$('#prev-post'); 24 25 $this.nextPostClose=false; 26 $this.prevPostClose=false; 27 28 $this.state={'next':0,'prev':0}; 29 30 /**********************************************************************/ 31 32 this.load=function() 33 { 34 $this.setStyle($this.nextPost,$this.options.nextPost,'next'); 35 $this.setStyle($this.prevPost,$this.options.prevPost,'prev'); 36 37 $(window).bind('scroll',function() 38 { 39 $this.process($this.nextPost,$this.options.nextPost,'next'); 40 $this.process($this.prevPost,$this.options.prevPost,'prev'); 41 }); 42 43 $(window).bind('resize',function() 44 { 45 $this.process($this.nextPost,$this.options.nextPost,'next'); 46 $this.process($this.prevPost,$this.options.prevPost,'prev'); 47 }); 48 49 $this.nextPost.find('a.next-post-close-button').bind('click',function(e) 50 { 51 e.preventDefault(); 52 53 $this.nextPostClose=true; 54 $this.close($this.nextPost,$this.options.nextPost,'next'); 55 }); 56 57 $this.prevPost.find('a.next-post-close-button').bind('click',function(e) 58 { 59 e.preventDefault(); 60 61 $this.prevPostClose=true; 62 $this.close($this.prevPost,$this.options.prevPost,'prev'); 63 }); 64 65 $(window).trigger('scroll'); 66 }; 67 68 /**********************************************************************/ 69 70 this.getWindowWidth=function() 71 { 72 return($(window).width()); 73 }; 74 75 /**********************************************************************/ 76 77 this.getWindowHeight=function() 78 { 79 return($(window).height()); 80 }; 81 82 /**********************************************************************/ 83 84 this.getScrollPercent=function() 85 { 86 var windowHeight=parseInt($(window).height()); 87 var documentHeight=parseInt($(document).height()); 88 var scrollPosition=parseInt($(window).scrollTop()); 89 90 var result=Math.round((scrollPosition/(documentHeight-windowHeight))*100); 91 92 return(result); 93 }; 94 95 /**********************************************************************/ 96 97 this.isScrolledIntoView=function(elem) 98 { 99 var docViewTop=$(window).scrollTop(); 100 var docViewBottom=docViewTop+$(window).height(); 101 102 var elemTop=$(elem).offset().top; 103 104 return(docViewBottom>=elemTop); 105 }; 106 107 /**********************************************************************/ 108 109 this.process=function(object,options,type) 110 { 111 if(object.length!==1) return; 112 if((type==='next') && ($this.nextPostClose)) return; 113 if((type==='prev') && ($this.prevPostClose)) return; 114 115 var windowWidth=$this.getWindowWidth(); 116 var windowHeight=$this.getWindowHeight(); 117 118 if(parseInt(options.responsive.width.enable)===1) 119 { 120 if(windowWidth<=options.responsive.width.value) 121 { 122 $this.close(object,options,type); 123 return; 124 } 125 } 126 127 if(parseInt(options.responsive.height.enable)===1) 128 { 129 if(windowHeight<=options.responsive.height.value) 130 { 131 $this.close(object,options,type); 132 return; 133 } 134 } 135 136 var width=$this.getBoxWidth(options); 137 object.css('width',width+'px'); 138 139 var elementSelector=jQuery.trim(options.dimension.offsetElement); 140 141 if($(elementSelector).first().length===1) 142 { 143 var element=$(elementSelector).first(); 144 var visible=$this.isScrolledIntoView(element); 145 146 if(visible) $this.open(object,options,type); 147 else $this.close(object,options,type); 148 } 149 else 150 { 151 var percent=$this.getScrollPercent(); 152 if(percent>=options.dimension.offset) $this.open(object,options,type); 153 else $this.close(object,options,type); 154 } 155 }; 156 157 /**********************************************************************/ 158
159 this.open=function(object,options,type) 160 { 161 if((parseInt($this.state[type])===2) || (parseInt($this.state[type])===3)) return; 162 163 $this.state[type]=2; 164 165 var style=$this.getAnimationStyle(object,options,type,'open'); 166 object.css({display:'block'}); 167 168 object.stop(false,false).animate(style.to,{easing:options.animation.open.easing,duration:options.animation.open.speed,complete:function() 169 { 170 $this.state[type]=3; 171 $(this).addClass('next-post-open'); 172 }}); 173 }; 174 175 /**********************************************************************/ 176 177 this.close=function(object,options,type) 178 { 179 if((parseInt($this.state[type])===0) || (parseInt($this.state[type])===1)) return; 180 181 $this.state[type]=1; 182 183 var style=$this.getAnimationStyle(object,options,type,'close'); 184 185 object.stop(false,false).animate(style.to,{easing:options.animation.close.easing,duration:options.animation.close.speed,complete:function() 186 { 187 $this.state[type]=0; 188 object.css({display:'none'}); 189 $(this).removeClass('next-post-open'); 190 }}); 191 }; 192 193 /**********************************************************************/ 194 195 this.getAnimationStyle=function(object,options,type,action) 196 { 197 var style={}; 198 199 switch(options.animation.type) 200 { 201 case 'slide': 202 203 switch(type) 204 { 205 case 'next': 206 207 if(action==='open') style={to:{right:'0px'}}; 208 if(action==='close') style={to:{right:(-1*object.outerWidth(true))+'px'}}; 209 210 break; 211 212 case 'prev': 213 214 if(action==='open') style={to:{left:'0px'}}; 215 if(action==='close') style={to:{left:(-1*object.outerWidth(true))+'px'}}; 216 217 break; 218 } 219 220 break; 221 222 case 'fade': 223 224 if(action==='open') style={to:{opacity:1}}; 225 if(action==='close') style={to:{opacity:0}}; 226 227 break; 228 } 229 230 return(style); 231 }; 232 233 /**********************************************************************/ 234 235 this.setStyle=function(object,options,type) 236 { 237 if(object.length!==1) return; 238 239 object.css('width',$this.getBoxWidth(options)+'px'); 240 object.css(options.dimension.position.type,options.dimension.position.value+'%'); 241 242 switch(options.animation.type) 243 { 244 case 'slide': 245 246 if(type==='next') object.css({right:(-1*object.outerWidth(true))+'px'}); 247 if(type==='prev') object.css({left:(-1*object.outerWidth(true))+'px'}); 248 249 break; 250 251 case 'fade': 252 253 object.css({opacity:0}); 254 255 break; 256 } 257 }; 258 259 /**********************************************************************/ 260 261 this.getBoxWidth=function(options) 262 { 263 var width=options.dimension.box.width; 264 265 if(parseInt($this.options.general.responsive.enable)===1) 266 { 267 var windowWidth=$this.getWindowWidth(); 268 if(width>windowWidth) return(windowWidth); 269 } 270 271 return(width); 272 }; 273 274 /**********************************************************************/ 275 }; 276 277 /***************************************************************************/ 278 279 $.fn.nextPost=function(options) 280 { 281 /**********************************************************************/ 282 283 var nextPost=new NextPost(options); 284 nextPost.load(); 285 286 /**********************************************************************/ 287 }; 288 289 /**************************************************************************/ 290 291})(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.