From d77982b9b47b8b17051000cfcf3db1a8945d6279 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Wed, 5 Aug 2009 17:09:19 -0400 Subject: added Infinite Scroll plugin --- plugins/InfiniteScroll/InfiniteScrollPlugin.php | 66 +++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 plugins/InfiniteScroll/InfiniteScrollPlugin.php (limited to 'plugins/InfiniteScroll/InfiniteScrollPlugin.php') diff --git a/plugins/InfiniteScroll/InfiniteScrollPlugin.php b/plugins/InfiniteScroll/InfiniteScrollPlugin.php new file mode 100644 index 000000000..6738dc760 --- /dev/null +++ b/plugins/InfiniteScroll/InfiniteScrollPlugin.php @@ -0,0 +1,66 @@ +. + * + * @category Plugin + * @package Laconica + * @author Craig Andrews + * @copyright 2009 Craig Andrews http://candrews.integralblue.com + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +if (!defined('LACONICA')) { + exit(1); +} + +class InfiniteScrollPlugin extends Plugin +{ + function __construct() + { + parent::__construct(); + } + + function onEndShowScripts($action) + { + $action->element('script', + array('type' => 'text/javascript', + 'src' => common_path('plugins/InfiniteScroll/jquery.infinitescroll.min.js')), + ''); + + $loading_image = common_path('plugins/InfiniteScroll/ajax-loader.gif'); + $js_string = << +jQuery(document).ready(function($){ + $('notices_primary').infinitescroll({ + nextSelector : "li.nav_next a", + loadingImg : "$loading_image", + text : "Loading the next set of posts...", + donetext : "Congratulations, you\'ve reached the end of the Internet.", + navSelector : "div.pagination", + contentSelector : "#notices_primary", + itemSelector : "ol.notices" + }); +}); + +EOT; + $action->raw($js_string); + } +} -- cgit v1.2.3-54-g00ecf From 9a9195ecd8eea36943dbb5e46adf685aef9edc4e Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Wed, 5 Aug 2009 19:54:46 -0400 Subject: Used script() function to write out the javascript link --- plugins/InfiniteScroll/InfiniteScrollPlugin.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'plugins/InfiniteScroll/InfiniteScrollPlugin.php') diff --git a/plugins/InfiniteScroll/InfiniteScrollPlugin.php b/plugins/InfiniteScroll/InfiniteScrollPlugin.php index 6738dc760..7e942550a 100644 --- a/plugins/InfiniteScroll/InfiniteScrollPlugin.php +++ b/plugins/InfiniteScroll/InfiniteScrollPlugin.php @@ -40,11 +40,7 @@ class InfiniteScrollPlugin extends Plugin function onEndShowScripts($action) { - $action->element('script', - array('type' => 'text/javascript', - 'src' => common_path('plugins/InfiniteScroll/jquery.infinitescroll.min.js')), - ''); - + $action->script('plugins/InfiniteScroll/jquery.infinitescroll.min.js'); $loading_image = common_path('plugins/InfiniteScroll/ajax-loader.gif'); $js_string = << -- cgit v1.2.3-54-g00ecf From 932d1fb7ce06081c788ea088171fd69ef03cd394 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Thu, 6 Aug 2009 15:26:13 -0400 Subject: Move inline javascript to a separate js file --- plugins/InfiniteScroll/InfiniteScrollPlugin.php | 18 +----------------- plugins/InfiniteScroll/infinitescroll.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 17 deletions(-) create mode 100644 plugins/InfiniteScroll/infinitescroll.js (limited to 'plugins/InfiniteScroll/InfiniteScrollPlugin.php') diff --git a/plugins/InfiniteScroll/InfiniteScrollPlugin.php b/plugins/InfiniteScroll/InfiniteScrollPlugin.php index 7e942550a..1e4a03e4f 100644 --- a/plugins/InfiniteScroll/InfiniteScrollPlugin.php +++ b/plugins/InfiniteScroll/InfiniteScrollPlugin.php @@ -41,22 +41,6 @@ class InfiniteScrollPlugin extends Plugin function onEndShowScripts($action) { $action->script('plugins/InfiniteScroll/jquery.infinitescroll.min.js'); - $loading_image = common_path('plugins/InfiniteScroll/ajax-loader.gif'); - $js_string = << -jQuery(document).ready(function($){ - $('notices_primary').infinitescroll({ - nextSelector : "li.nav_next a", - loadingImg : "$loading_image", - text : "Loading the next set of posts...", - donetext : "Congratulations, you\'ve reached the end of the Internet.", - navSelector : "div.pagination", - contentSelector : "#notices_primary", - itemSelector : "ol.notices" - }); -}); - -EOT; - $action->raw($js_string); + $action->script('plugins/InfiniteScroll/infinitescroll.js'); } } diff --git a/plugins/InfiniteScroll/infinitescroll.js b/plugins/InfiniteScroll/infinitescroll.js new file mode 100644 index 000000000..b80bd4ec5 --- /dev/null +++ b/plugins/InfiniteScroll/infinitescroll.js @@ -0,0 +1,12 @@ +jQuery(document).ready(function($){ + $('notices_primary').infinitescroll({ + nextSelector : "li.nav_next a", + loadingImg : $('address .url')[0].href+'plugins/InfiniteScroll/ajax-loader.gif', + text : "Loading the next set of posts...", + donetext : "Congratulations, you\'ve reached the end of the Internet.", + navSelector : "div.pagination", + contentSelector : "#notices_primary", + itemSelector : "ol.notices" + }); +}); + -- cgit v1.2.3-54-g00ecf