Changeset 406362
- Timestamp:
- 07/07/2011 06:13:54 PM (15 years ago)
- Location:
- infinite-scroll/trunk
- Files:
-
- 4 edited
-
jquery.infinitescroll.js (modified) (22 diffs)
-
jquery.infinitescroll.min.js (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
wp_infinite_scroll.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
infinite-scroll/trunk/jquery.infinitescroll.js
r402198 r406362 4 4 -------------------------------- 5 5 + https://github.com/paulirish/infinitescroll 6 + version 2.0b2.110 6286 + version 2.0b2.110706 7 7 + Copyright 2011 Paul Irish & Luke Shumard 8 8 + Licensed under the MIT license … … 22 22 23 23 $.infinitescroll.defaults = { 24 loading: { 25 finished: undefined, 26 finishedMsg: "<em>Congratulations, you've reached the end of the internet.</em>", 27 img: "http://www.infinite-scroll.com/loading.gif", 28 msg: null, 29 msgText: "<em>Loading the next set of posts...</em>", 30 selector: null, 31 speed: 'fast', 32 start: undefined 33 }, 34 state: { 35 isDuringAjax: false, 36 isInvalidPage: false, 37 isDestroyed: false, 38 isDone: false, // For when it goes all the way through the archive. 39 isPaused: false, 40 currPage: 1 41 }, 24 42 callback: undefined, 25 43 debug: false, … … 27 45 binder: $(window), // used to cache the selector 28 46 nextSelector: "div.navigation a:first", 29 loadMsgSelector: null,30 loadingMsgRevealSpeed: 'fast', // controls how fast you want the loading message to come in, ex: 'fast', 'slow', 200 (milliseconds)31 loadingImg: "http://www.infinite-scroll.com/loading.gif",32 loadingText: "<em>Loading the next set of posts...</em>",33 loadingStart: undefined,34 loadingEnd: undefined,35 donetext: "<em>Congratulations, you've reached the end of the internet.</em>",36 47 navSelector: "div.navigation", 37 48 contentSelector: null, // rename to pageFragment … … 43 54 appendCallback: true, 44 55 bufferPx: 40, 45 orientation: 'height',46 56 errorCallback: function () { }, 47 currPage: 1,48 57 infid: 0, //Instance ID 49 isDuringAjax: false,50 isInvalidPage: false,51 isDestroyed: false,52 isDone: false, // For when it goes all the way through the archive.53 isPaused: false,54 58 pixelsFromNavToBottom: undefined, 55 pagesLoaded: null, 56 path: undefined, 57 loadingMsg: undefined 59 path: undefined 58 60 }; 59 61 … … 115 117 opts.contentSelector = opts.contentSelector || this.element; 116 118 117 // load MsgSelector - if we want to place the load message in a specific selector, defaulted to the contentSelector118 opts.load MsgSelector = opts.loadMsgSelector || opts.contentSelector;119 // loading.selector - if we want to place the load message in a specific selector, defaulted to the contentSelector 120 opts.loading.selector = opts.loading.selector || opts.contentSelector; 119 121 120 122 // if there's not path, return … … 124 126 opts.path = this._determinepath(path); 125 127 126 // Define loading Msg127 opts.loading Msg = $('<div id="infscr-loading"><img alt="Loading..." src="' + opts.loadingImg + '" /><div>' + opts.loadingText + '</div></div>');128 129 // Preload loading Img130 (new Image()).src = opts.loading Img;128 // Define loading.msg 129 opts.loading.msg = $('<div id="infscr-loading"><img alt="Loading..." src="' + opts.loading.img + '" /><div>' + opts.loading.msgText + '</div></div>'); 130 131 // Preload loading.img 132 (new Image()).src = opts.loading.img; 131 133 132 134 // distance from nav links to bottom … … 134 136 opts.pixelsFromNavToBottom = $(document).height() - $(opts.navSelector).offset().top; 135 137 136 // determine loading Start actions137 opts.loading Start = opts.loadingStart || function() {138 // determine loading.start actions 139 opts.loading.start = opts.loading.start || function() { 138 140 139 141 $(opts.navSelector).hide(); 140 142 141 opts.loading Msg142 .appendTo(opts.load MsgSelector)143 .show(opts.loading MsgRevealSpeed, function () {143 opts.loading.msg 144 .appendTo(opts.loading.selector) 145 .show(opts.loading.speed, function () { 144 146 beginAjax(opts); 145 147 }); 146 148 }; 147 149 148 // determine loading End actions149 opts.loading End = opts.loadingEnd || function() {150 opts.loading Msg.fadeOut('normal');150 // determine loading.finished actions 151 opts.loading.finished = opts.loading.finished || function() { 152 opts.loading.msg.fadeOut('normal'); 151 153 }; 152 154 153 155 // callback loading 154 opts.callback = opts.callback || callback || function () { }; 156 opts.callback = function(instance,data) { 157 if (!!opts.behavior && instance['_callback_'+opts.behavior] !== undefined) { 158 instance['_callback_'+opts.behavior].call($(opts.contentSelector)[0], data); 159 } 160 if (callback) { 161 callback.call($(opts.contentSelector)[0], data); 162 } 163 }; 155 164 156 165 this._setup(); … … 208 217 this._debug('Sorry, we couldn\'t parse your Next (Previous Posts) URL. Verify your the css selector points to the correct A tag. If you still get this error: yell, scream, and kindly ask for help at infinite-scroll.com.'); 209 218 // Get rid of isInvalidPage to allow permalink to state 210 opts. isInvalidPage = true; //prevent it from running on this page.219 opts.state.isInvalidPage = true; //prevent it from running on this page. 211 220 } 212 221 } … … 237 246 } 238 247 239 opts.isDone = true; 240 opts.currPage = 1; // if you need to go back to this instance 241 opts.isPaused = false; 242 248 opts.state.isDone = true; 249 opts.state.currPage = 1; // if you need to go back to this instance 250 opts.state.isPaused = false; 243 251 this._binding('unbind'); 244 252 … … 250 258 var opts = this.options, 251 259 callback = this.options.callback, // GLOBAL OBJECT FOR CALLBACK 252 result = (opts. isDone) ? 'done' : (!opts.appendCallback) ? 'no-append' : 'append',260 result = (opts.state.isDone) ? 'done' : (!opts.appendCallback) ? 'no-append' : 'append', 253 261 frag; 254 262 … … 308 316 309 317 // loadingEnd function 310 opts.loading End.call($(opts.contentSelector)[0],opts)318 opts.loading.finished.call($(opts.contentSelector)[0],opts) 311 319 312 320 … … 314 322 if (opts.animate) { 315 323 var scrollTo = $(window).scrollTop() + $('#infscr-loading').height() + opts.extraScrollPx + 'px'; 316 $('html,body').animate({ scrollTop: scrollTo }, 800, function () { opts. isDuringAjax = false; });317 } 318 319 if (!opts.animate) opts. isDuringAjax = false; // once the call is done, we can allow it again.320 321 callback .call($(opts.contentSelector)[0],data);324 $('html,body').animate({ scrollTop: scrollTo }, 800, function () { opts.state.isDuringAjax = false; }); 325 } 326 327 if (!opts.animate) opts.state.isDuringAjax = false; // once the call is done, we can allow it again. 328 329 callback(this,data); 322 330 323 331 }, … … 361 369 switch (pause) { 362 370 case 'pause': 363 opts. isPaused = true;371 opts.state.isPaused = true; 364 372 break; 365 373 366 374 case 'resume': 367 opts. isPaused = false;375 opts.state.isPaused = false; 368 376 break; 369 377 370 378 case 'toggle': 371 opts. isPaused = !opts.isPaused;379 opts.state.isPaused = !opts.state.isPaused; 372 380 break; 373 381 } 374 382 375 this._debug('Paused', opts. isPaused);383 this._debug('Paused', opts.state.isPaused); 376 384 return false; 377 385 … … 407 415 } 408 416 409 opts.loading Msg417 opts.loading.msg 410 418 .find('img') 411 419 .hide() 412 420 .parent() 413 .find('div').html(opts. donetext).animate({ opacity: 1 }, 2000, function () {421 .find('div').html(opts.loading.finishedMsg).animate({ opacity: 1 }, 2000, function () { 414 422 $(this).parent().fadeOut('normal'); 415 423 }); … … 447 455 destroy: function infscr_destroy() { 448 456 449 this.options. isDestroyed = true;457 this.options.state.isDestroyed = true; 450 458 return this._error('destroy'); 451 459 … … 470 478 box, frag, desturl, method, condition, 471 479 pageNum = pageNum || null, 472 getPage = (!!pageNum) ? pageNum : opts. currPage;480 getPage = (!!pageNum) ? pageNum : opts.state.currPage; 473 481 beginAjax = function infscr_ajax(opts) { 474 482 475 483 // increment the URL bit. e.g. /page/3/ 476 opts. currPage++;484 opts.state.currPage++; 477 485 478 486 instance._debug('heading into ajax', path); … … 481 489 box = $(opts.contentSelector).is('table') ? $('<tbody/>') : $('<div/>'); 482 490 483 desturl = path.join(opts. currPage);491 desturl = path.join(opts.state.currPage); 484 492 485 493 method = (opts.dataType == 'html' || opts.dataType == 'json') ? opts.dataType : 'html+callback'; … … 489 497 490 498 case 'html+callback': 491 492 499 493 500 instance._debug('Using HTML via .load() method'); … … 524 531 525 532 // for manual triggers, if destroyed, get out of here 526 if (opts. isDestroyed) {533 if (opts.state.isDestroyed) { 527 534 this._debug('Instance is destroyed'); 528 535 return false; … … 530 537 531 538 // we dont want to fire the ajax multiple times 532 opts. isDuringAjax = true;533 534 opts.loading Start.call($(opts.contentSelector)[0],opts);539 opts.state.isDuringAjax = true; 540 541 opts.loading.start.call($(opts.contentSelector)[0],opts); 535 542 536 543 }, … … 539 546 scroll: function infscr_scroll() { 540 547 541 var opts = this.options; 548 var opts = this.options, 549 state = opts.state; 542 550 543 551 // if behavior is defined and this function is extended, call that instead of default … … 547 555 } 548 556 549 if ( opts.isDuringAjax || opts.isInvalidPage || opts.isDone || opts.isDestroyed || opts.isPaused) return;557 if (state.isDuringAjax || state.isInvalidPage || state.isDone || state.isDestroyed || state.isPaused) return; 550 558 551 559 if (!this._nearbottom()) return; -
infinite-scroll/trunk/jquery.infinitescroll.min.js
r402198 r406362 4 4 -------------------------------- 5 5 + https://github.com/paulirish/infinitescroll 6 + version 2.0b2.110 6286 + version 2.0b2.110706 7 7 + Copyright 2011 Paul Irish & Luke Shumard 8 8 + Licensed under the MIT license … … 12 12 */ 13 13 14 (function(window,$,undefined){$.infinitescroll=function infscr(options,callback,element){this.element=$(element);this._create(options,callback);};$.infinitescroll.defaults={ callback:undefined,debug:false,behavior:undefined,binder:$(window),nextSelector:"div.navigation a:first",loadMsgSelector:null,loadingMsgRevealSpeed:'fast',loadingImg:"http://www.infinite-scroll.com/loading.gif",loadingText:"<em>Loading the next set of posts...</em>",loadingStart:undefined,loadingEnd:undefined,donetext:"<em>Congratulations, you've reached the end of the internet.</em>",navSelector:"div.navigation",contentSelector:null,extraScrollPx:150,itemSelector:"div.post",animate:false,pathParse:undefined,dataType:'html',appendCallback:true,bufferPx:40,orientation:'height',errorCallback:function(){},currPage:1,infid:0,isDuringAjax:false,isInvalidPage:false,isDestroyed:false,isDone:false,isPaused:false,pixelsFromNavToBottom:undefined,pagesLoaded:null,path:undefined,loadingMsg:undefined};$.infinitescroll.prototype={_binding:function infscr_binding(binding){var instance=this,opts=instance.options;if(!!opts.behavior&&this['_binding_'+opts.behavior]!==undefined){this['_binding_'+opts.behavior].call(this);return;}14 (function(window,$,undefined){$.infinitescroll=function infscr(options,callback,element){this.element=$(element);this._create(options,callback);};$.infinitescroll.defaults={loading:{finished:undefined,finishedMsg:"<em>Congratulations, you've reached the end of the internet.</em>",img:"http://www.infinite-scroll.com/loading.gif",msg:null,msgText:"<em>Loading the next set of posts...</em>",selector:null,speed:'fast',start:undefined},state:{isDuringAjax:false,isInvalidPage:false,isDestroyed:false,isDone:false,isPaused:false,currPage:1},callback:undefined,debug:false,behavior:undefined,binder:$(window),nextSelector:"div.navigation a:first",navSelector:"div.navigation",contentSelector:null,extraScrollPx:150,itemSelector:"div.post",animate:false,pathParse:undefined,dataType:'html',appendCallback:true,bufferPx:40,errorCallback:function(){},infid:0,pixelsFromNavToBottom:undefined,path:undefined};$.infinitescroll.prototype={_binding:function infscr_binding(binding){var instance=this,opts=instance.options;if(!!opts.behavior&&this['_binding_'+opts.behavior]!==undefined){this['_binding_'+opts.behavior].call(this);return;} 15 15 if(binding!=='bind'&&binding!=='unbind'){this._debug('Binding value '+binding+' not valid') 16 16 return false;} 17 17 if(binding=='unbind'){(this.options.binder).unbind('smartscroll.infscr.'+instance.options.infid);}else{(this.options.binder)[binding]('smartscroll.infscr.'+instance.options.infid,function(){instance.scroll();});};this._debug('Binding',binding);},_create:function infscr_create(options,callback){if(!this._validate(options)){return false;} 18 var opts=this.options=$.extend({},$.infinitescroll.defaults,options),relurl=/(.*?\/\/).*?(\/.*)/,path=$(opts.nextSelector).attr('href');opts.contentSelector=opts.contentSelector||this.element;opts.loadMsgSelector=opts.loadMsgSelector||opts.contentSelector;if(!path){this._debug('Navigation selector not found');return;} 19 opts.path=this._determinepath(path);opts.loadingMsg=$('<div id="infscr-loading"><img alt="Loading..." src="'+opts.loadingImg+'" /><div>'+opts.loadingText+'</div></div>');(new Image()).src=opts.loadingImg;opts.pixelsFromNavToBottom=$(document).height()-$(opts.navSelector).offset().top;opts.loadingStart=opts.loadingStart||function(){$(opts.navSelector).hide();opts.loadingMsg.appendTo(opts.loadMsgSelector).show(opts.loadingMsgRevealSpeed,function(){beginAjax(opts);});};opts.loadingEnd=opts.loadingEnd||function(){opts.loadingMsg.fadeOut('normal');};opts.callback=opts.callback||callback||function(){};this._setup();},_debug:function infscr_debug(){if(this.options.debug){return window.console&&console.log.call(console,arguments);}},_determinepath:function infscr_determinepath(path){var opts=this.options;if(!!opts.behavior&&this['_determinepath_'+opts.behavior]!==undefined){this['_determinepath_'+opts.behavior].call(this,path);return;} 18 var opts=this.options=$.extend({},$.infinitescroll.defaults,options),relurl=/(.*?\/\/).*?(\/.*)/,path=$(opts.nextSelector).attr('href');opts.contentSelector=opts.contentSelector||this.element;opts.loading.selector=opts.loading.selector||opts.contentSelector;if(!path){this._debug('Navigation selector not found');return;} 19 opts.path=this._determinepath(path);opts.loading.msg=$('<div id="infscr-loading"><img alt="Loading..." src="'+opts.loading.img+'" /><div>'+opts.loading.msgText+'</div></div>');(new Image()).src=opts.loading.img;opts.pixelsFromNavToBottom=$(document).height()-$(opts.navSelector).offset().top;opts.loading.start=opts.loading.start||function(){$(opts.navSelector).hide();opts.loading.msg.appendTo(opts.loading.selector).show(opts.loading.speed,function(){beginAjax(opts);});};opts.loading.finished=opts.loading.finished||function(){opts.loading.msg.fadeOut('normal');};opts.callback=function(instance,data){if(!!opts.behavior&&instance['_callback_'+opts.behavior]!==undefined){instance['_callback_'+opts.behavior].call($(opts.contentSelector)[0],data);} 20 if(callback){callback.call($(opts.contentSelector)[0],data);}};this._setup();},_debug:function infscr_debug(){if(this.options.debug){return window.console&&console.log.call(console,arguments);}},_determinepath:function infscr_determinepath(path){var opts=this.options;if(!!opts.behavior&&this['_determinepath_'+opts.behavior]!==undefined){this['_determinepath_'+opts.behavior].call(this,path);return;} 20 21 if(!!opts.pathParse){this._debug('pathParse manual');return opts.pathParse;}else if(path.match(/^(.*?)\b2\b(.*?$)/)){path=path.match(/^(.*?)\b2\b(.*?$)/).slice(1);}else if(path.match(/^(.*?)2(.*?$)/)){if(path.match(/^(.*?page=)2(\/.*|$)/)){path=path.match(/^(.*?page=)2(\/.*|$)/).slice(1);return path;} 21 path=path.match(/^(.*?)2(.*?$)/).slice(1);}else{if(path.match(/^(.*?page=)1(\/.*|$)/)){path=path.match(/^(.*?page=)1(\/.*|$)/).slice(1);return path;}else{this._debug('Sorry, we couldn\'t parse your Next (Previous Posts) URL. Verify your the css selector points to the correct A tag. If you still get this error: yell, scream, and kindly ask for help at infinite-scroll.com.');opts. isInvalidPage=true;}}22 path=path.match(/^(.*?)2(.*?$)/).slice(1);}else{if(path.match(/^(.*?page=)1(\/.*|$)/)){path=path.match(/^(.*?page=)1(\/.*|$)/).slice(1);return path;}else{this._debug('Sorry, we couldn\'t parse your Next (Previous Posts) URL. Verify your the css selector points to the correct A tag. If you still get this error: yell, scream, and kindly ask for help at infinite-scroll.com.');opts.state.isInvalidPage=true;}} 22 23 this._debug('determinePath',path);return path;},_error:function infscr_error(xhr){var opts=this.options;if(!!opts.behavior&&this['_error_'+opts.behavior]!==undefined){this['_error_'+opts.behavior].call(this,xhr);return;} 23 24 if(xhr!=='destroy'&&xhr!=='end'){xhr='unknown';} 24 25 this._debug('Error',xhr);if(xhr=='end'){this._showdonemsg();} 25 opts. isDone=true;opts.currPage=1;opts.isPaused=false;this._binding('unbind');},_loadcallback:function infscr_loadcallback(box,data){var opts=this.options,callback=this.options.callback,result=(opts.isDone)?'done':(!opts.appendCallback)?'no-append':'append',frag;if(!!opts.behavior&&this['_loadcallback_'+opts.behavior]!==undefined){this['_loadcallback_'+opts.behavior].call(this,box,data);return;}26 opts.state.isDone=true;opts.state.currPage=1;opts.state.isPaused=false;this._binding('unbind');},_loadcallback:function infscr_loadcallback(box,data){var opts=this.options,callback=this.options.callback,result=(opts.state.isDone)?'done':(!opts.appendCallback)?'no-append':'append',frag;if(!!opts.behavior&&this['_loadcallback_'+opts.behavior]!==undefined){this['_loadcallback_'+opts.behavior].call(this,box,data);return;} 26 27 switch(result){case'done':this._showdonemsg();return false;break;case'no-append':if(opts.dataType=='html'){data='<div>'+data+'</div>';data=$(data).find(opts.itemSelector);};break;case'append':var children=box.children();if(children.length==0){return this._error('end');} 27 28 frag=document.createDocumentFragment();while(box[0].firstChild){frag.appendChild(box[0].firstChild);} 28 29 this._debug('contentSelector',$(opts.contentSelector)[0]) 29 30 $(opts.contentSelector)[0].appendChild(frag);data=children.get();break;} 30 opts.loading End.call($(opts.contentSelector)[0],opts)31 if(opts.animate){var scrollTo=$(window).scrollTop()+$('#infscr-loading').height()+opts.extraScrollPx+'px';$('html,body').animate({scrollTop:scrollTo},800,function(){opts. isDuringAjax=false;});}32 if(!opts.animate)opts. isDuringAjax=false;callback.call($(opts.contentSelector)[0],data);},_nearbottom:function infscr_nearbottom(){var opts=this.options,pixelsFromWindowBottomToBottom=0+$(document).height()-(opts.binder.scrollTop())-$(window).height();if(!!opts.behavior&&this['_nearbottom_'+opts.behavior]!==undefined){this['_nearbottom_'+opts.behavior].call(this);return;}31 opts.loading.finished.call($(opts.contentSelector)[0],opts) 32 if(opts.animate){var scrollTo=$(window).scrollTop()+$('#infscr-loading').height()+opts.extraScrollPx+'px';$('html,body').animate({scrollTop:scrollTo},800,function(){opts.state.isDuringAjax=false;});} 33 if(!opts.animate)opts.state.isDuringAjax=false;callback(this,data);},_nearbottom:function infscr_nearbottom(){var opts=this.options,pixelsFromWindowBottomToBottom=0+$(document).height()-(opts.binder.scrollTop())-$(window).height();if(!!opts.behavior&&this['_nearbottom_'+opts.behavior]!==undefined){this['_nearbottom_'+opts.behavior].call(this);return;} 33 34 this._debug('math:',pixelsFromWindowBottomToBottom,opts.pixelsFromNavToBottom);return(pixelsFromWindowBottomToBottom-opts.bufferPx<opts.pixelsFromNavToBottom);},_pausing:function infscr_pausing(pause){var opts=this.options;if(!!opts.behavior&&this['_pausing_'+opts.behavior]!==undefined){this['_pausing_'+opts.behavior].call(this,pause);return;} 34 if(pause!=='pause'&&pause!=='resume'&&pause!==null){this._debug('Invalid argument. Toggling pause value instead');};pause=(pause&&(pause=='pause'||pause=='resume'))?pause:'toggle';switch(pause){case'pause':opts. isPaused=true;break;case'resume':opts.isPaused=false;break;case'toggle':opts.isPaused=!opts.isPaused;break;}35 this._debug('Paused',opts. isPaused);return false;},_setup:function infscr_setup(){var opts=this.options;if(!!opts.behavior&&this['_setup_'+opts.behavior]!==undefined){this['_setup_'+opts.behavior].call(this);return;}35 if(pause!=='pause'&&pause!=='resume'&&pause!==null){this._debug('Invalid argument. Toggling pause value instead');};pause=(pause&&(pause=='pause'||pause=='resume'))?pause:'toggle';switch(pause){case'pause':opts.state.isPaused=true;break;case'resume':opts.state.isPaused=false;break;case'toggle':opts.state.isPaused=!opts.state.isPaused;break;} 36 this._debug('Paused',opts.state.isPaused);return false;},_setup:function infscr_setup(){var opts=this.options;if(!!opts.behavior&&this['_setup_'+opts.behavior]!==undefined){this['_setup_'+opts.behavior].call(this);return;} 36 37 this._binding('bind');return false;},_showdonemsg:function infscr_showdonemsg(){var opts=this.options;if(!!opts.behavior&&this['_showdonemsg_'+opts.behavior]!==undefined){this['_showdonemsg_'+opts.behavior].call(this);return;} 37 opts.loading Msg.find('img').hide().parent().find('div').html(opts.donetext).animate({opacity:1},2000,function(){$(this).parent().fadeOut('normal');});opts.errorCallback.call($(opts.contentSelector)[0],'done');},_validate:function infscr_validate(opts){for(var key in opts){if(key.indexOf&&key.indexOf('Selector')>-1&&$(opts[key]).length===0){this._debug('Your '+key+' found no elements.');return false;}38 return true;}},bind:function infscr_bind(){this._binding('bind');},destroy:function infscr_destroy(){this.options. isDestroyed=true;return this._error('destroy');},pause:function infscr_pause(){this._pausing('pause');},resume:function infscr_resume(){this._pausing('resume');},retrieve:function infscr_retrieve(pageNum){var instance=this,opts=instance.options,path=opts.path,box,frag,desturl,method,condition,pageNum=pageNum||null,getPage=(!!pageNum)?pageNum:opts.currPage;beginAjax=function infscr_ajax(opts){opts.currPage++;instance._debug('heading into ajax',path);box=$(opts.contentSelector).is('table')?$('<tbody/>'):$('<div/>');desturl=path.join(opts.currPage);method=(opts.dataType=='html'||opts.dataType=='json')?opts.dataType:'html+callback';if(opts.appendCallback&&opts.dataType=='html')method+='+callback'38 opts.loading.msg.find('img').hide().parent().find('div').html(opts.loading.finishedMsg).animate({opacity:1},2000,function(){$(this).parent().fadeOut('normal');});opts.errorCallback.call($(opts.contentSelector)[0],'done');},_validate:function infscr_validate(opts){for(var key in opts){if(key.indexOf&&key.indexOf('Selector')>-1&&$(opts[key]).length===0){this._debug('Your '+key+' found no elements.');return false;} 39 return true;}},bind:function infscr_bind(){this._binding('bind');},destroy:function infscr_destroy(){this.options.state.isDestroyed=true;return this._error('destroy');},pause:function infscr_pause(){this._pausing('pause');},resume:function infscr_resume(){this._pausing('resume');},retrieve:function infscr_retrieve(pageNum){var instance=this,opts=instance.options,path=opts.path,box,frag,desturl,method,condition,pageNum=pageNum||null,getPage=(!!pageNum)?pageNum:opts.state.currPage;beginAjax=function infscr_ajax(opts){opts.state.currPage++;instance._debug('heading into ajax',path);box=$(opts.contentSelector).is('table')?$('<tbody/>'):$('<div/>');desturl=path.join(opts.state.currPage);method=(opts.dataType=='html'||opts.dataType=='json')?opts.dataType:'html+callback';if(opts.appendCallback&&opts.dataType=='html')method+='+callback' 39 40 switch(method){case'html+callback':instance._debug('Using HTML via .load() method');box.load(desturl+' '+opts.itemSelector,null,function infscr_ajax_callback(responseText){instance._loadcallback(box,responseText);});break;case'html':case'json':instance._debug('Using '+(method.toUpperCase())+' via $.ajax() method');$.ajax({url:desturl,dataType:opts.dataType,complete:function infscr_ajax_callback(jqXHR,textStatus){condition=(typeof(jqXHR.isResolved)!=='undefined')?(jqXHR.isResolved()):(textStatus==="success"||textStatus==="notmodified");(condition)?instance._loadcallback(box,jqXHR.responseText):instance._error('end');}});break;}};if(!!opts.behavior&&this['retrieve_'+opts.behavior]!==undefined){this['retrieve_'+opts.behavior].call(this,pageNum);return;} 40 if(opts. isDestroyed){this._debug('Instance is destroyed');return false;};opts.isDuringAjax=true;opts.loadingStart.call($(opts.contentSelector)[0],opts);},scroll:function infscr_scroll(){var opts=this.options;if(!!opts.behavior&&this['scroll_'+opts.behavior]!==undefined){this['scroll_'+opts.behavior].call(this);return;}41 if( opts.isDuringAjax||opts.isInvalidPage||opts.isDone||opts.isDestroyed||opts.isPaused)return;if(!this._nearbottom())return;this.retrieve();},toggle:function infscr_toggle(){this._pausing();},unbind:function infscr_unbind(){this._binding('unbind');},update:function infscr_options(key){if($.isPlainObject(key)){this.options=$.extend(true,this.options,key);}}}41 if(opts.state.isDestroyed){this._debug('Instance is destroyed');return false;};opts.state.isDuringAjax=true;opts.loading.start.call($(opts.contentSelector)[0],opts);},scroll:function infscr_scroll(){var opts=this.options,state=opts.state;if(!!opts.behavior&&this['scroll_'+opts.behavior]!==undefined){this['scroll_'+opts.behavior].call(this);return;} 42 if(state.isDuringAjax||state.isInvalidPage||state.isDone||state.isDestroyed||state.isPaused)return;if(!this._nearbottom())return;this.retrieve();},toggle:function infscr_toggle(){this._pausing();},unbind:function infscr_unbind(){this._binding('unbind');},update:function infscr_options(key){if($.isPlainObject(key)){this.options=$.extend(true,this.options,key);}}} 42 43 $.fn.infinitescroll=function infscr_init(options,callback){var thisCall=typeof options;switch(thisCall){case'string':var args=Array.prototype.slice.call(arguments,1);this.each(function(){var instance=$.data(this,'infinitescroll');if(!instance){return false;} 43 44 if(!$.isFunction(instance[options])||options.charAt(0)==="_"){return false;} -
infinite-scroll/trunk/readme.txt
r402198 r406362 4 4 Tags: ajax, pagination, scrolling, scroll, endless, reading 5 5 Requires at least: 2.6 6 Tested up to: 3. 1.36 Tested up to: 3.2 7 7 Stable tag: 2.0b 8 8 … … 49 49 50 50 == Changelog == 51 = 2.0b2.110706 = 52 * HTTPS loading image fix. 53 * Better debug support (switches between minified and non). 54 51 55 = 2.0b2.110629 = 52 56 * Callback (custom javascript) fix. -
infinite-scroll/trunk/wp_infinite_scroll.php
r402198 r406362 2 2 /* 3 3 Plugin Name: Infinite Scroll 4 Version: 2.0b2.110 6294 Version: 2.0b2.110706 5 5 Plugin URI: http://www.infinite-scroll.com 6 6 Description: Automatically loads the next page of posts into the bottom of the initial page. … … 190 190 $plugin_dir = plugins_url('infinite-scroll'); 191 191 $js_calls = stripslashes(get_option(key_infscr_js_calls)); 192 $loading_image = stripslashes(get_option(key_infscr_image)); 192 //Fancy stuff (not) to detect https or http 193 $noscheme = parse_url(stripslashes(get_option(key_infscr_image))); 194 if (is_ssl()) 195 $scheme = "https://"; 196 else 197 $scheme = "http://"; 198 $loading_image = $scheme.$noscheme['host'].$noscheme['path']; 193 199 $loading_text = stripslashes(get_option(key_infscr_text)); 194 200 $donetext = stripslashes(get_option(key_infscr_donetext));
Note: See TracChangeset
for help on using the changeset viewer.