Skip to content
Browse files

tagged version 1.3

  • Loading branch information...
0 parents commit 7e234fca57223e0f8574c7ecfb9af2343d5da9f7 @candrews candrews committed
BIN ajax-loader.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
251 jquery.infinitescroll.js
@@ -0,0 +1,251 @@
+
+/*!
+// Infinite Scroll jQuery plugin
+// copyright Paul Irish, licensed GPL & MIT
+// version 1.2.090804
+
+// home and docs: http://www.infinite-scroll.com
+*/
+
+// todo: add preloading option.
+
+;(function($){
+
+ $.fn.infinitescroll = function(options,callback){
+
+ // console log wrapper.
+ function debug(){
+ if (opts.debug) { window.console && console.log.call(console,arguments)}
+ }
+
+ // grab each selector option and see if any fail.
+ function areSelectorsValid(opts){
+ for (var key in opts){
+ if (key.indexOf && key.indexOf('Selector') && $(opts[key]).length === 0){
+ debug('Your ' + key + ' found no elements.');
+ return false;
+ }
+ return true;
+ }
+ }
+
+
+ // find the number to increment in the path.
+ function determinePath(path){
+
+ path.match(relurl) ? path.match(relurl)[2] : path;
+
+ // there is a 2 in the url surrounded by slashes, e.g. /page/2/
+ if ( path.match(/^(.*?)\b2\b(.*?$)/) ){
+ path = path.match(/^(.*?)\b2\b(.*?$)/).slice(1);
+ } else
+ // if there is any 2 in the url at all.
+ if (path.match(/^(.*?)2(.*?$)/)){
+ debug('Trying backup next selector parse technique. Treacherous waters here, matey.');
+ path = path.match(/^(.*?)2(.*?$)/).slice(1);
+ } else {
+ 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.');
+ props.isInvalidPage = true; //prevent it from running on this page.
+ }
+
+ return path;
+ }
+
+
+ // 'document' means the full document usually, but sometimes the content of the overflow'd div in local mode
+ function getDocumentHeight(){
+ // weird doubletouch of scrollheight because http://soulpass.com/2006/07/24/ie-and-scrollheight/
+ return opts.localMode ? ($(props.container)[0].scrollHeight && $(props.container)[0].scrollHeight)
+ // needs to be document's height. (not props.container's) html's height is wrong in IE.
+ : $(document).height()
+ }
+
+
+
+ function isNearBottom(opts,props){
+
+ // distance remaining in the scroll
+ // computed as: document height - distance already scroll - viewport height - buffer
+ var pixelsFromWindowBottomToBottom = getDocumentHeight() -
+ (opts.localMode ? $(props.container).scrollTop() :
+ // have to do this bs because safari doesnt report a scrollTop on the html element
+ ($(props.container).scrollTop() || $(props.container.ownerDocument.body).scrollTop())) -
+ $(opts.localMode ? props.container : window).height();
+
+ debug('math:',pixelsFromWindowBottomToBottom, props.pixelsFromNavToBottom);
+
+ // if distance remaining in the scroll (including buffer) is less than the orignal nav to bottom....
+ return (pixelsFromWindowBottomToBottom - opts.bufferPx < props.pixelsFromNavToBottom);
+ }
+
+ function showDoneMsg(){
+ props.loadingMsg
+ .find('img').hide()
+ .parent()
+ .find('div').html(opts.donetext).animate({opacity: 1},2000).fadeOut('normal');
+
+ // user provided callback when done
+ opts.errorCallback();
+ }
+
+ function infscrSetup(path,opts,props,callback){
+
+ if (props.isDuringAjax || props.isInvalidPage || props.isDone) return;
+
+ if ( !isNearBottom(opts,props) ) return;
+
+ // we dont want to fire the ajax multiple times
+ props.isDuringAjax = true;
+
+ // show the loading message and hide the previous/next links
+ props.loadingMsg.appendTo( opts.contentSelector ).show();
+ $( opts.navSelector ).hide();
+
+ // increment the URL bit. e.g. /page/3/
+ props.currPage++;
+
+ debug('heading into ajax',path);
+
+ // if we're dealing with a table we can't use DIVs
+ var box = $(opts.contentSelector).is('table') ? $('<tbody/>') : $('<div/>');
+
+ box
+ .attr('id','infscr-page-'+props.currPage)
+ .addClass('infscr-pages')
+ .appendTo( opts.contentSelector )
+ .load( path.join( props.currPage ) + ' ' + opts.itemSelector,null,function(){
+
+ // if we've hit the last page...
+ if (props.isDone){
+ showDoneMsg();
+ return false;
+
+ } else {
+
+ // if it didn't return anything
+ if (box.children().length == 0){
+ // fake an ajaxError so we can quit.
+ $.event.trigger( "ajaxError", [{status:404}] );
+ }
+
+ // fadeout currently makes the <em>'d text ugly in IE6
+ props.loadingMsg.fadeOut('normal' );
+
+ // smooth scroll to ease in the new content
+ if (opts.animate){
+ var scrollTo = $(window).scrollTop() + $('#infscr-loading').height() + opts.extraScrollPx + 'px';
+ $('html,body').animate({scrollTop: scrollTo}, 800,function(){ props.isDuringAjax = false; });
+ }
+
+ // pass in the new DOM element as context for the callback
+ callback.call( box[0] );
+
+ if (!opts.animate) props.isDuringAjax = false; // once the call is done, we can allow it again.
+ }
+ }); // end of load()
+
+
+ } // end of infscrSetup()
+
+
+
+
+ // lets get started.
+
+ var opts = $.extend({}, $.infinitescroll.defaults, options);
+ var props = $.infinitescroll; // shorthand
+ callback = callback || function(){};
+
+ if (!areSelectorsValid(opts)){ return false; }
+
+ // we doing this on an overflow:auto div?
+ props.container = opts.localMode ? this : document.documentElement;
+
+ // contentSelector we'll use for our .load()
+ opts.contentSelector = opts.contentSelector || this;
+
+
+ // get the relative URL - everything past the domain name.
+ var relurl = /(.*?\/\/).*?(\/.*)/;
+ var path = $(opts.nextSelector).attr('href');
+
+
+ if (!path) { debug('Navigation selector not found'); return; }
+
+ // set the path to be a relative URL from root.
+ path = determinePath(path);
+
+
+ // reset scrollTop in case of page refresh:
+ if (opts.localMode) $(props.container)[0].scrollTop = 0;
+
+ // distance from nav links to bottom
+ // computed as: height of the document + top offset of container - top offset of nav link
+ props.pixelsFromNavToBottom = getDocumentHeight() +
+ $(props.container).offset().top -
+ $(opts.navSelector).offset().top;
+
+ // define loading msg
+ props.loadingMsg = $('<div id="infscr-loading" style="text-align: center;"><img alt="Loading..." src="'+
+ opts.loadingImg+'" /><div>'+opts.loadingText+'</div></div>');
+ // preload the image
+ (new Image()).src = opts.loadingImg;
+
+
+
+ // set up our bindings
+ $(document).ajaxError(function(e,xhr,opt){
+ debug('Page not found. Self-destructing...');
+
+ // die if we're out of pages.
+ if (xhr.status == 404){
+ showDoneMsg();
+ props.isDone = true;
+ $(opts.localMode ? this : window).unbind('scroll.infscr');
+ }
+ });
+
+ // bind scroll handler to element (if its a local scroll) or window
+ $(opts.localMode ? this : window)
+ .bind('scroll.infscr', function(){ infscrSetup(path,opts,props,callback); } )
+ .trigger('scroll.infscr'); // trigger the event, in case it's a short page
+
+
+ return this;
+
+ } // end of $.fn.infinitescroll()
+
+
+
+ // options and read-only properties object
+
+ $.infinitescroll = {
+ defaults : {
+ debug : false,
+ preload : false,
+ nextSelector : "div.navigation a:first",
+ loadingImg : "http://www.infinite-scroll.com/loading.gif",
+ loadingText : "<em>Loading the next set of posts...</em>",
+ donetext : "<em>Congratulations, you've reached the end of the internet.</em>",
+ navSelector : "div.navigation",
+ contentSelector : null, // not really a selector. :) it's whatever the method was called on..
+ extraScrollPx : 150,
+ itemSelector : "div.post",
+ animate : false,
+ localMode : false,
+ bufferPx : 40,
+ errorCallback : function(){}
+ },
+ loadingImg : undefined,
+ loadingMsg : undefined,
+ container : undefined,
+ currPage : 1,
+ currDOMChunk : null, // defined in setup()'s load()
+ isDuringAjax : false,
+ isInvalidPage : false,
+ isDone : false // for when it goes all the way through the archive.
+ };
+
+
+
+})(jQuery);
8 jquery.infinitescroll.min.js
@@ -0,0 +1,8 @@
+/*
+// Infinite Scroll jQuery plugin
+// copyright Paul Irish, licensed GPL & MIT
+// version 1.2.090804
+
+// home and docs: http://www.infinite-scroll.com
+*/
+(function(A){A.fn.infinitescroll=function(N,L){function E(){if(B.debug){window.console&&console.log.call(console,arguments)}}function G(P){for(var O in P){if(O.indexOf&&O.indexOf("Selector")&&A(P[O]).length===0){E("Your "+O+" found no elements.");return false}return true}}function K(O){O.match(C)?O.match(C)[2]:O;if(O.match(/^(.*?)\b2\b(.*?$)/)){O=O.match(/^(.*?)\b2\b(.*?$)/).slice(1)}else{if(O.match(/^(.*?)2(.*?$)/)){E("Trying backup next selector parse technique. Treacherous waters here, matey.");O=O.match(/^(.*?)2(.*?$)/).slice(1)}else{E("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.");H.isInvalidPage=true}}return O}function I(){return B.localMode?(A(H.container)[0].scrollHeight&&A(H.container)[0].scrollHeight):A(document).height()}function F(Q,P){var O=I()-(Q.localMode?A(P.container).scrollTop():(A(P.container).scrollTop()||A(P.container.ownerDocument.body).scrollTop()))-A(Q.localMode?P.container:window).height();E("math:",O,P.pixelsFromNavToBottom);return(O-Q.bufferPx<P.pixelsFromNavToBottom)}function J(){H.loadingMsg.find("img").hide().parent().find("div").html(B.donetext).animate({opacity:1},2000).fadeOut("normal");B.errorCallback()}function D(R,Q,O,S){if(O.isDuringAjax||O.isInvalidPage||O.isDone){return }if(!F(Q,O)){return }O.isDuringAjax=true;O.loadingMsg.appendTo(Q.contentSelector).show();A(Q.navSelector).hide();O.currPage++;E("heading into ajax",R);var P=A(Q.contentSelector).is("table")?A("<tbody/>"):A("<div/>");P.attr("id","infscr-page-"+O.currPage).addClass("infscr-pages").appendTo(Q.contentSelector).load(R.join(O.currPage)+" "+Q.itemSelector,null,function(){if(O.isDone){J();return false}else{if(P.children().length==0){A.event.trigger("ajaxError",[{status:404}])}O.loadingMsg.fadeOut("normal");if(Q.animate){var T=A(window).scrollTop()+A("#infscr-loading").height()+Q.extraScrollPx+"px";A("html,body").animate({scrollTop:T},800,function(){O.isDuringAjax=false})}S.call(P[0]);if(!Q.animate){O.isDuringAjax=false}}})}var B=A.extend({},A.infinitescroll.defaults,N);var H=A.infinitescroll;L=L||function(){};if(!G(B)){return false}H.container=B.localMode?this:document.documentElement;B.contentSelector=B.contentSelector||this;var C=/(.*?\/\/).*?(\/.*)/;var M=A(B.nextSelector).attr("href");if(!M){E("Navigation selector not found");return }M=K(M);if(B.localMode){A(H.container)[0].scrollTop=0}H.pixelsFromNavToBottom=I()+A(H.container).offset().top-A(B.navSelector).offset().top;H.loadingMsg=A('<div id="infscr-loading" style="text-align: center;"><img alt="Loading..." src="'+B.loadingImg+'" /><div>'+B.loadingText+"</div></div>");(new Image()).src=B.loadingImg;A(document).ajaxError(function(P,Q,O){E("Page not found. Self-destructing...");if(Q.status==404){J();H.isDone=true;A(B.localMode?this:window).unbind("scroll.infscr")}});A(B.localMode?this:window).bind("scroll.infscr",function(){D(M,B,H,L)}).trigger("scroll.infscr");return this};A.infinitescroll={defaults:{debug:false,preload:false,nextSelector:"div.navigation a:first",loadingImg:"http://www.infinite-scroll.com/loading.gif",loadingText:"<em>Loading the next set of posts...</em>",donetext:"<em>Congratulations, you've reached the end of the internet.</em>",navSelector:"div.navigation",contentSelector:null,extraScrollPx:150,itemSelector:"div.post",animate:false,localMode:false,bufferPx:40,errorCallback:function(){}},loadingImg:undefined,loadingMsg:undefined,container:undefined,currPage:1,currDOMChunk:null,isDuringAjax:false,isInvalidPage:false,isDone:false}})(jQuery);
69 readme.txt
@@ -0,0 +1,69 @@
+=== Plugin Name ===
+Contributors: paul.irish, dirkhaim, candrews
+Donate link: http://www.infinite-scroll.com
+Tags: ajax, pagination, scrolling, scroll, endless, reading
+Requires at least: 2.3
+Tested up to: 2.8.3
+Stable tag: 1.3
+
+Automatically append the next page of posts (via AJAX) to your page when a user scrolls to the bottom.
+
+== Description ==
+
+Infinite Scroll adds the following functionality to your wordpress installation: **When a user scrolls towards the bottom of the page, the next page of posts is automatically retrieved and appended**. This means they never need to click "Next Page", which *dramatically increases stickiness*.
+
+Features:
+
+* Fully embraces progressive enhancement: RSS readers and js-off folks will be happy.
+* Fully customizable by text, css, and images.
+* Works on 80% of wordpress themes, with little or no configuration.
+* Hackable source code to modify the behavior.
+* Tested back to 2.3, but probably works on earlier versions.
+* Requires no (hopefully) template hacking, only a knowledge of CSS selectors.
+
+Full information on [infinite-scroll.com](http://www.infinite-scroll.com)
+
+
+== Installation ==
+
+1. Download the plugin.
+1. Install it to your /wp-content/plugins/ directory
+1. Activate the plugin in your Wordpress Admin UI.
+1. Visit the Settings / Infinite Scroll page to [set up the css selectors](http://www.infinite-scroll.com/installation/).
+1. The plugin will now work for a logged in Admin, but will be disabled for all other users; you can change this.
+
+
+== Frequently Asked Questions ==
+
+= Can I change the number of posts loaded? =
+
+Yup. But that's a Wordpress thing. Go to Settings / Reading
+
+= Why is this FAQ so short? =
+
+Because it is. Go to [infinite-scroll.com](http://www.infinite-scroll.com) for more.
+
+== Screenshots ==
+
+1. Loading the next set of posts
+
+== Changelog ==
+
+= 1.3 =
+Use proper Wordpress function to register the javascript
+Use plugins_url to determine plugin url
+
+= 1.2 =
+* 2009 August 4th
+* getoption(’siteurl’) fix made.
+* jQuery plugin version updated. many more options available.
+* Release backwards compatible
+
+= 1.1 =
+* 2008 September 25
+* JavaScript rewritten as a proper jQuery plugin.
+* Added animation
+
+= 1.0 =
+* June 29 - 1.0 release.
+
BIN screenshot-1.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
460 wp_infinite_scroll.php
@@ -0,0 +1,460 @@
+<?php
+
+/*
+Plugin Name: Infinite Scroll
+Version: 1.3.090805
+Plugin URI: http://www.infinite-scroll.com
+Description: Automatically loads the next page of posts into the bottom of the initial page.
+Author: dirkhaim & Paul Irish
+Author URI: http://www.infinite-scroll.com
+License : http://creativecommons.org/licenses/GPL/2.0/
+
+/*
+ Copyright 2009 dirkhaim & Paul Irish
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+BUGS:
+ - javascript insertion doesnt work on themes: qwiilm!, craving4green, Lush, no limits, stripedplus
+
+TODO:
+ - Allow to customize the speed of the fadeOut effect (or maybe even choose a different effect like hide..)
+ - deal with the IE6 + opacity + cleartype + <em> issue.
+ - What error handling do we need?
+ - Mention div#infscr-loading so users can customize look more.
+ - Check if you're in a table and thus you can't add divs.
+
+*/
+
+// constants for enables/disabled
+define('infscr_enabled' , 'enabled');
+define('infscr_disabled' , 'disabled');
+define('infscr_maint' , 'disabledforadmins');
+define('infscr_config' , 'enabledforadmins');
+
+
+// options keys constants
+define('key_infscr_state' , 'infscr_state');
+define('key_infscr_js_calls' , 'infscr_js_calls');
+define('key_infscr_image' , 'infscr_image');
+define('key_infscr_text' , 'infscr_text');
+define('key_infscr_donetext' , 'infscr_donetext');
+define('key_infscr_content_selector' , 'infscr_content_selector');
+define('key_infscr_nav_selector' , 'infscr_nav_selector');
+define('key_infscr_post_selector' , 'infscr_post_selector');
+define('key_infscr_next_selector' , 'infscr_next_selector');
+
+
+// defaults
+define('infscr_state_default' , infscr_config);
+define('infscr_js_calls_default' , '');
+
+$image_path = plugins_url('/infinite-scroll/ajax-loader.gif');
+define('infscr_image_default' , $image_path);
+define('infscr_text_default' , '<em>Loading the next set of posts...</em>');
+define('infscr_donetext_default' , '<em>Congratulations, you\'ve reached the end of the internet.</em>');
+define('infscr_content_selector_default' , '#content');
+define('infscr_post_selector_default' , '#content > div.post');
+define('infscr_nav_selector_default' , 'div.navigation');
+define('infscr_next_selector_default', 'div.navigation a:first');
+
+
+// add options
+add_option(key_infscr_state , infscr_state_default , 'If InfiniteScroll is turned on, off, or in maintenance');
+add_option(key_infscr_js_calls , infscr_js_calls_default , 'Javascript to execute when new content loads in');
+add_option(key_infscr_image , infscr_image_default , 'Loading image');
+add_option(key_infscr_text , infscr_text_default , 'Loading text');
+add_option(key_infscr_donetext , infscr_donetext_default , 'Completed text');
+add_option(key_infscr_content_selector , infscr_content_selector_default , 'Content Div css selector');
+add_option(key_infscr_nav_selector , infscr_nav_selector_default , 'Navigation Div css selector');
+add_option(key_infscr_post_selector , infscr_post_selector_default , 'Post Div css selector');
+add_option(key_infscr_next_selector , infscr_next_selector_default , 'Next page Anchor css selector');
+
+
+// adding actions
+add_action('init' , 'wp_inf_scoll_init');
+add_action('wp_footer' , 'wp_inf_scroll_add');
+add_action('admin_menu' , 'add_wp_inf_scroll_options_page');
+
+
+
+
+
+/*
+// used because wordpress doesnt like to tell us for sure what the homepage is.
+// removed because it doesnt quite work..
+function is_frontpage()
+{
+ global $post;
+ $id = $post->ID;
+ $show_on_front = get_option('show_on_front');
+ $page_on_front = get_option('page_on_front');
+
+ if ($show_on_front == 'page' && $page_on_front == $id ) { return true; }
+ else { return false; }
+}
+*/
+
+
+
+if ( get_option(key_infscr_state) == infscr_state_default && !isset($_POST['submit']) ) {
+ function setup_warning() {
+ echo "
+ <div id='infinitescroll-warning' class='updated fade'><p><strong>".__('Infinite Scroll is almost ready.')."</strong> ".sprintf(__('Please <a href="%1$s">review the configuration and set the state to enabled for all users</a>.'), "options-general.php?page=wp_infinite_scroll.php")."</p></div>
+ ";
+ }
+ add_action('admin_notices', 'setup_warning');
+ return;
+}
+
+
+function add_wp_inf_scroll_options_page()
+{
+ global $wpdb;
+ add_options_page('Infinite Scroll Options', 'Infinite Scroll', 8, basename(__FILE__), 'wp_inf_scroll_options_page');
+}
+
+function wp_inf_scroll_options_page()
+{
+ // if postback, store options
+ if (isset($_POST['info_update']))
+ {
+ check_admin_referer();
+
+ // update state
+ $infscr_state = $_POST[key_infscr_state];
+ if ($infscr_state != infscr_enabled && $infscr_state != infscr_disabled && $infscr_state != infscr_maint && $infscr_state != infscr_config)
+ $infscr_state = infscr_state_default;
+ update_option(key_infscr_state, $infscr_state);
+
+ // update js calls field
+ $infscr_js_calls = $_POST[key_infscr_js_calls];
+ update_option(key_infscr_js_calls, $infscr_js_calls);
+
+ // update image
+ $infscr_image = $_POST[key_infscr_image];
+ update_option(key_infscr_image, $infscr_image);
+
+ // update text
+ $infscr_text = $_POST[key_infscr_text];
+ update_option(key_infscr_text, $infscr_text);
+
+ // update done text
+ $infscr_donetext = $_POST[key_infscr_donetext];
+ update_option(key_infscr_donetext, $infscr_donetext);
+
+ // update content selector
+ $content_selector = $_POST[key_infscr_content_selector];
+ update_option(key_infscr_content_selector, $content_selector);
+
+ // update the navigation selector
+ $navigation_selector = $_POST[key_infscr_nav_selector];
+ update_option(key_infscr_nav_selector, $navigation_selector);
+
+ // update the post selector
+ $post_selector = $_POST[key_infscr_post_selector];
+ update_option(key_infscr_post_selector, $post_selector);
+
+ // update the next selector
+ $next_selector = $_POST[key_infscr_next_selector];
+ update_option(key_infscr_next_selector, $next_selector);
+
+
+ // update notification
+ echo "<div class='updated'><p><strong>Infinite Scroll options updated</strong></p></div>";
+ }
+
+ // output the options page
+
+?>
+<form method="post" action="options-general.php?page=<?php echo basename(__FILE__); ?>">
+ <div class="wrap">
+<?php if (get_option(key_infscr_state) == infscr_disabled) { ?>
+ <div style="margin:10px auto; border:3px #f00 solid; background-color: #fdd; color: #000; padding: 10px; text-align: center;">
+ Infinite Scroll plugin is <strong>disabled</strong>.
+ </div>
+<?php } ?>
+<?php if ( false && get_option(key_infscr_state) != infscr_disabled && get_option(key_infscr_js_calls) == '') { // disabled for now?>
+ <div style="margin:10px auto; border:1px #f00 solid; background-color:#fdd; color:#000; padding:10px; text-align:center;">
+ No Javascript calls will be made after the content is added. This might cause errors in newly added content.
+ </div>
+<?php } ?>
+ <style type="text/css">
+ table.infscroll-opttable { width: 100%;}
+ table.infscroll-opttable td, table.infscroll-opttable th { vertical-align: top; padding: 9px 4px; }
+ table.infscroll-opttable th { padding-top: 13px; text-align: right;}
+ table.infscroll-opttable td p { margin: 0;}
+ table.infscroll-opttable dl { font-size: 90%; color: #666; margin-top: 5px; }
+ table.infscroll-opttable dd { margin-bottom: 0 }
+ </style>
+
+ <h2>Infinite Scroll Options</h2>
+
+ <p>All CSS selectors are found with the jQuery javascript library. See the <a href="http://docs.jquery.com/Selectors">jQuery CSS Selector documentation</a> for an overview of all possibilities. Single-quotes are not allowed&mdash;only double-quotes may be used.
+
+ <table class="editform infscroll-opttable" cellspacing="0" >
+ <tbody>
+ <tr>
+ <th width="30%" >
+ <label for="<?php echo key_infscr_state; ?>">Infinite Scroll state is:</label>
+ </th>
+ <td>
+ <?php
+ echo "<select name='".key_infscr_state."' id='".key_infscr_state."'>\n";
+ echo "<option value='".infscr_enabled."'";
+ if (get_option(key_infscr_state) == infscr_enabled)
+ echo "selected='selected'";
+ echo ">Enabled for all users</option>\n";
+
+ echo "<option value='".infscr_disabled."'";
+ if (get_option(key_infscr_state) == infscr_disabled)
+ echo "selected='selected'";
+ echo ">Disabled for all users</option>\n";
+
+ echo "<option value='".infscr_config."'";
+ if (get_option(key_infscr_state) == infscr_config)
+ echo "selected='selected'";
+ echo ">Enabled for admins only</option>\n";
+
+ echo "<option value='".infscr_maint."'";
+ if (get_option(key_infscr_state) == infscr_maint)
+ echo "selected='selected'";
+ echo ">Disabled for admins only</option>\n";
+ echo "</select>";
+ ?>
+ </td>
+ <td width="50%">
+ "Enabled for admins only" will enable the plugin code only for logged-in administrators&mdash;visitors will not be affected while you configure the plugin. "Disabled for admins only" is useful for administrators when customizing the blog&mdash;infinite scroll will be disabled for them, but still enabled for any visitors.
+ </td>
+ </tr>
+
+
+ <tr>
+ <th>
+ <label for="<?php echo key_infscr_content_selector; ?>">Content CSS Selector:</label>
+ </th>
+ <td>
+ <?php
+ echo "<input name='".key_infscr_content_selector."' id='".key_infscr_content_selector."' value='".stripslashes(get_option(key_infscr_content_selector))."' size='30' type='text'>\n";
+ ?>
+ </td>
+ <td>
+ <p>The selector of the content div on the main page.</p>
+ </td>
+ </tr>
+
+ <tr>
+ <th >
+ <label for="<?php echo key_infscr_post_selector; ?>">Post CSS Selector:</label>
+ </th>
+ <td>
+ <?php
+ echo "<input name='".key_infscr_post_selector."' id='".key_infscr_post_selector."' value='".stripslashes(get_option(key_infscr_post_selector))."' size='30' type='text'>\n";
+ ?>
+ </td>
+ <td>
+ <p>The selector of the post block.</p>
+ <dl>
+ <dt>Examples:</dt>
+ <dd>#content &gt; *</dd>
+ <dd>#content div.post</dd>
+ <dd>div.primary div.entry</dd>
+ </dl>
+ </td>
+ </tr>
+
+ <tr>
+ <th>
+ <label for="<?php echo key_infscr_nav_selector; ?>">Navigation Links CSS Selector:</label>
+ </th>
+ <td>
+ <?php
+ echo "<input name='".key_infscr_nav_selector."' id='".key_infscr_nav_selector."' value='".stripslashes(get_option(key_infscr_nav_selector))."' size='30' type='text'>\n";
+ ?>
+
+ </td>
+ <td>
+ <p>The selector of the navigation div (the one that includes the next and previous links).</p>
+ </td>
+ </tr>
+
+ <tr>
+ <th>
+ <label for="<?php echo key_infscr_next_selector; ?>">Previous posts CSS Selector:</label>
+ </th>
+ <td>
+ <?php
+ echo "<input name='".key_infscr_next_selector."' id='".key_infscr_next_selector."' value='".stripslashes(get_option(key_infscr_next_selector))."' size='30' type='text'>\n";
+ ?>
+ </td>
+ <td>
+ <p>The selector of the previous posts (next page) A tag.</p>
+ <dl>
+ <dt>Examples:</dt>
+ <dd>div.navigation a:first</dd>
+ <dd>div.navigation a:contains(Previous)</dd>
+ </dl>
+ </td>
+ </tr>
+
+
+ <tr>
+ <th>
+ <label for="<?php echo key_infscr_js_calls; ?>">Javascript to be called after the next posts are fetched:</label>
+ </th>
+ <td>
+ <?php
+ echo "<textarea name='".key_infscr_js_calls."' rows='2' style='width: 95%;'>\n";
+ echo stripslashes(get_option(key_infscr_js_calls));
+ echo "</textarea>\n";
+ ?>
+ </td>
+ <td>
+ <p>Any functions that are applied to the post contents on page load will need to be executed when the new content comes in.</p>
+ </td>
+ </tr>
+
+ <tr>
+ <th>
+ <label for="<?php echo key_infscr_image; ?>">Loading image:</label>
+ </th>
+ <td>
+ <?php
+ echo "<input name='".key_infscr_image."' id='".key_infscr_image."' value='".stripslashes(get_option(key_infscr_image))."' size='30' type='text'>\n";
+ ?>
+ </td>
+ <td>
+ <p>URL of image that will be displayed while content is being loaded. Visit <a href="http://www.ajaxload.info" target="_blank">www.ajaxload.info</a> to customize your own loading spinner.</p>
+ </td>
+ </tr>
+
+ <tr>
+ <th>
+ <label for="<?php echo key_infscr_text; ?>">Loading text:</label>
+ </th>
+ <td>
+ <?php
+ echo "<input name='".key_infscr_text."' id='".key_infscr_text."' value='".stripslashes(get_option(key_infscr_text))."' size='30' type='text'>\n";
+ ?>
+ </td>
+ <td>
+ <p>Text will be displayed while content is being loaded. <small><acronym>HTML</acrynom> allowed.</small></p>
+ </td>
+ </tr>
+
+ <tr>
+ <th>
+ <label for="<?php echo key_infscr_donetext; ?>">"You've reached the end" text:</label>
+ </th>
+ <td>
+ <?php
+ echo '<input name="'.key_infscr_donetext.'" id="'.key_infscr_donetext.'" value="'.stripslashes(get_option(key_infscr_donetext)).'" size="30" type="text">';
+ ?>
+ </td>
+ <td>
+ <p>Text will be displayed when all entries have already been retrieved. The plugin will show this message, fade it out, and cease working. <small><acronym>HTML</acrynom> allowed.</small></p>
+ </td>
+ </tr>
+
+ </tbody>
+ </table>
+
+ <p class="submit">
+ <input type='submit' name='info_update' value='Update Options' />
+ </p>
+ </div>
+</form>
+
+<?php
+}
+
+function wp_inf_scoll_init(){
+ wp_enqueue_script('jquery-infinitescroll',plugins_url('infinite-scroll/jquery.infinitescroll.min.js'),array('jquery'),'1.3');
+}
+
+function wp_inf_scroll_add()
+{
+ global $user_level;
+
+ if (get_option(key_infscr_state) == infscr_disabled)
+ return;
+
+ if (is_page() || is_single() ) /* single posts/pages dont get it */
+ {
+ echo '<!-- Infinite-Scroll not added for this page (single post/page) -->';
+ return;
+ }
+
+ /*
+ if (! is_paged() ) non-paged dont get it
+ {
+ echo '<!-- Infinite-Scroll not added for this page (not paged) -->';
+ return;
+ }
+ */
+ /* !is_home() || !is_paged() || paged (archive, tags, categories) and home do. */
+
+ if (get_option(key_infscr_state) == infscr_maint && $user_level >= 8)
+ {
+ echo '<!-- Infinite-Scroll not added for administrator (maintenance state) -->';
+ return;
+ }
+
+ if (get_option(key_infscr_state) == infscr_config && $user_level <= 8)
+ {
+ echo '<!-- Infinite-Scroll not added for visitors (configuration state) -->';
+ return;
+ }
+
+ $js_calls = stripslashes(get_option(key_infscr_js_calls));
+ $loading_image = stripslashes(get_option(key_infscr_image));
+ $loading_text = stripslashes(get_option(key_infscr_text));
+ $donetext = stripslashes(get_option(key_infscr_donetext));
+ $content_selector = stripslashes(get_option(key_infscr_content_selector));
+ $navigation_selector = stripslashes(get_option(key_infscr_nav_selector));
+ $post_selector = stripslashes(get_option(key_infscr_post_selector));
+ $next_selector = stripslashes(get_option(key_infscr_next_selector));
+ if ($user_level >= 8) {$isAdmin = "true"; }else {$isAdmin = "false";}
+
+$js_string = <<<EOT
+
+<script type="text/javascript" >
+jQuery(document).ready(function($){
+ // Infinite Scroll jQuery+Wordpress plugin
+ $('$content_selector').infinitescroll({
+ debug : $isAdmin,
+ nextSelector : "$next_selector",
+ loadingImg : "$loading_image",
+ text : "$loading_text",
+ donetext : "$donetext",
+ navSelector : "$navigation_selector",
+ contentSelector : "$content_selector",
+ itemSelector : "$post_selector"
+ },function(){
+$js_calls
+ });
+});
+</script>
+
+EOT;
+
+ echo $js_string;
+ return;
+}
+
+
+
+?>

0 comments on commit 7e234fc

Please sign in to comment.
Something went wrong with that request. Please try again.