HusseyCoding_InfiniteScroll - Version 1.0.0

Version Notes

Initial release.

Download this release

Release Info

Developer Hussey Coding
Extension HusseyCoding_InfiniteScroll
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/HusseyCoding/Common/etc/system.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <husseycoding translate="label">
5
+ <label>Hussey Coding</label>
6
+ <sort_order>500</sort_order>
7
+ </husseycoding>
8
+ </tabs>
9
+ </config>
app/code/community/HusseyCoding/InfiniteScroll/Block/Init.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class HusseyCoding_InfiniteScroll_Block_Init extends Mage_Core_Block_Template
3
+ {
4
+ public function isActive()
5
+ {
6
+ return Mage::getStoreConfig('infinitescroll/general/enabled');
7
+ }
8
+
9
+ public function shouldLoad()
10
+ {
11
+ $toolbar = $this->getLayout()->getBlock('product_list_toolbar');
12
+ if (!empty($toolbar) && $toolbar->getCollection() && $toolbar->getLastPageNum() > 1):
13
+ return true;
14
+ endif;
15
+
16
+ return false;
17
+ }
18
+
19
+ public function getLastPage()
20
+ {
21
+ $toolbar = $this->getLayout()->getBlock('product_list_toolbar');
22
+
23
+ return !empty($toolbar) && $toolbar->getCollection() ? $toolbar->getLastPageNum() : 1;
24
+ }
25
+
26
+ public function getMode()
27
+ {
28
+ $toolbar = $this->getLayout()->getBlock('product_list_toolbar');
29
+
30
+ return !empty($toolbar) ? $toolbar->getCurrentMode() : false;
31
+ }
32
+ }
app/code/community/HusseyCoding/InfiniteScroll/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class HusseyCoding_InfiniteScroll_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+
5
+ }
app/code/community/HusseyCoding/InfiniteScroll/Model/Observer.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class HusseyCoding_InfiniteScroll_Model_Observer
3
+ {
4
+
5
+ public function frontendControllerActionLayoutLoadBefore($observer)
6
+ {
7
+ $params = Mage::app()->getRequest()->getParams();
8
+ if (isset($params['_escaped_fragment_'])):
9
+ $observer->getLayout()->getUpdate()->addHandle('infinitescroll_all');
10
+ endif;
11
+ }
12
+ }
app/code/community/HusseyCoding/InfiniteScroll/etc/adminhtml.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <all>
6
+ <title>Allow Everything</title>
7
+ </all>
8
+ <admin>
9
+ <children>
10
+ <system>
11
+ <children>
12
+ <config>
13
+ <children>
14
+ <infinitescroll module="infinitescroll">
15
+ <title>Infinite Scroll</title>
16
+ </infinitescroll>
17
+ </children>
18
+ </config>
19
+ </children>
20
+ </system>
21
+ </children>
22
+ </admin>
23
+ </resources>
24
+ </acl>
25
+ </config>
app/code/community/HusseyCoding/InfiniteScroll/etc/config.xml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <HusseyCoding_InfiniteScroll>
5
+ <version>1.0.0</version>
6
+ </HusseyCoding_InfiniteScroll>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <infinitescroll>
11
+ <class>HusseyCoding_InfiniteScroll_Model</class>
12
+ </infinitescroll>
13
+ </models>
14
+ <blocks>
15
+ <infinitescroll>
16
+ <class>HusseyCoding_InfiniteScroll_Block</class>
17
+ </infinitescroll>
18
+ </blocks>
19
+ <helpers>
20
+ <infinitescroll>
21
+ <class>HusseyCoding_InfiniteScroll_Helper</class>
22
+ </infinitescroll>
23
+ </helpers>
24
+ </global>
25
+ <frontend>
26
+ <layout>
27
+ <updates>
28
+ <infinitescroll>
29
+ <file>infinitescroll.xml</file>
30
+ </infinitescroll>
31
+ </updates>
32
+ </layout>
33
+ <events>
34
+ <controller_action_layout_load_before>
35
+ <observers>
36
+ <frontend_controller_action_layout_load_before_infinitescroll>
37
+ <class>infinitescroll/observer</class>
38
+ <method>frontendControllerActionLayoutLoadBefore</method>
39
+ </frontend_controller_action_layout_load_before_infinitescroll>
40
+ </observers>
41
+ </controller_action_layout_load_before>
42
+ </events>
43
+ </frontend>
44
+ </config>
app/code/community/HusseyCoding/InfiniteScroll/etc/system.xml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <infinitescroll translate="label" module="infinitescroll">
5
+ <label>Infinite Scroll</label>
6
+ <tab>husseycoding</tab>
7
+ <frontend_type>text</frontend_type>
8
+ <sort_order>1</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>1</show_in_store>
12
+ <groups>
13
+ <general translate="label">
14
+ <label>General</label>
15
+ <frontend_type>text</frontend_type>
16
+ <sort_order>1</sort_order>
17
+ <show_in_default>1</show_in_default>
18
+ <show_in_website>1</show_in_website>
19
+ <show_in_store>1</show_in_store>
20
+ <fields>
21
+ <enabled>
22
+ <label>Enable Infinite Scroll</label>
23
+ <frontend_type>select</frontend_type>
24
+ <source_model>adminhtml/system_config_source_yesno</source_model>
25
+ <sort_order>1</sort_order>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>1</show_in_website>
28
+ <show_in_store>1</show_in_store>
29
+ </enabled>
30
+ </fields>
31
+ </general>
32
+ </groups>
33
+ </infinitescroll>
34
+ </sections>
35
+ </config>
app/design/frontend/base/default/layout/infinitescroll.xml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <infinitescroll_init>
4
+ <reference name="head">
5
+ <action method="addItem">
6
+ <type>skin_js</type>
7
+ <name>js/infinitescroll.js</name>
8
+ </action>
9
+ <action method="addItem">
10
+ <type>skin_css</type>
11
+ <name>css/infinitescroll.css</name>
12
+ </action>
13
+ <block type="core/text" name="fragment_meta" before="-">
14
+ <action method="setText">
15
+ <text>
16
+ <![CDATA[<meta name="fragment" content="!">]]>
17
+ </text>
18
+ </action>
19
+ </block>
20
+ </reference>
21
+ <reference name="content">
22
+ <block type="infinitescroll/init" name="infinitescroll_init" template="infinitescroll/init.phtml" />
23
+ </reference>
24
+ </infinitescroll_init>
25
+ <catalog_category_default>
26
+ <update handle="infinitescroll_init" />
27
+ </catalog_category_default>
28
+ <catalog_category_layered>
29
+ <update handle="infinitescroll_init" />
30
+ </catalog_category_layered>
31
+ <catalogsearch_result_index>
32
+ <update handle="infinitescroll_init" />
33
+ </catalogsearch_result_index>
34
+ <catalogsearch_advanced_result>
35
+ <update handle="infinitescroll_init" />
36
+ </catalogsearch_advanced_result>
37
+ <infinitescroll_all>
38
+ <reference name="product_list_toolbar">
39
+ <action method="addPagerLimit" translate="label"><mode>list</mode><limit>all</limit><label>All</label></action>
40
+ <action method="addPagerLimit" translate="label"><mode>grid</mode><limit>all</limit><label>All</label></action>
41
+ <action method="setDefaultListPerPage"><limit>all</limit></action>
42
+ <action method="setDefaultGridPerPage"><limit>all</limit></action>
43
+ </reference>
44
+ </infinitescroll_all>
45
+ </layout>
app/design/frontend/base/default/template/infinitescroll/init.phtml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ($this->isActive()): ?>
2
+ <script type="text/javascript">
3
+ //<![CDATA[
4
+ var thisinfinitescroll = new infinitescroll();
5
+ thisinfinitescroll.shouldload = <?php echo $this->shouldLoad() ? 'true' : 'false'; ?>;
6
+ thisinfinitescroll.nextpage = 2;
7
+ thisinfinitescroll.lastpage = <?php echo $this->getLastPage(); ?>;
8
+ thisinfinitescroll.mode = "<?php echo $this->getMode(); ?>";
9
+ //]]>
10
+ </script>
11
+ <?php endif; ?>
app/etc/modules/HusseyCoding_Common.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <HusseyCoding_Common>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </HusseyCoding_Common>
8
+ </modules>
9
+ </config>
app/etc/modules/HusseyCoding_InfiniteScroll.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <HusseyCoding_InfiniteScroll>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <HusseyCoding_Common />
9
+ </depends>
10
+ </HusseyCoding_InfiniteScroll>
11
+ </modules>
12
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>HusseyCoding_InfiniteScroll</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Adds SEO friendly infinite scroll functionality to category pages.</summary>
10
+ <description>Adds infinite scroll functionality to category pages making use of _escaped_fragment_ functionality to remain SEO friendly. New category products are loaded as you scroll towards the bottom of the page.</description>
11
+ <notes>Initial release.</notes>
12
+ <authors><author><name>Hussey Coding</name><user>husseycoding</user><email>info@husseycoding.co.uk</email></author></authors>
13
+ <date>2015-02-25</date>
14
+ <time>11:07:53</time>
15
+ <contents><target name="magecommunity"><dir name="HusseyCoding"><dir name="InfiniteScroll"><dir name="Block"><file name="Init.php" hash="7db4e6f0e7db8f39428891b33492c482"/></dir><dir name="etc"><file name="adminhtml.xml" hash="15ca3c797660ceec34d6834487111db8"/><file name="config.xml" hash="56b595274e1047e3438269474af2bd7d"/><file name="system.xml" hash="a0b0b23c90acf3dec7a120e953f02fba"/></dir><dir name="Helper"><file name="Data.php" hash="b7fbbed1273ed20236f46f637e84ff62"/></dir><dir name="Model"><file name="Observer.php" hash="058febf54d511599a776e66799973af5"/></dir></dir><dir name="Common"><dir name="etc"><file name="system.xml" hash="6c9ba9f227b9adfc9abf97f17b46fdbf"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="HusseyCoding_InfiniteScroll.xml" hash="5609ca99cc8904346e9a2b94d1a9ef21"/><file name="HusseyCoding_Common.xml" hash="31e82d3d9b3179c2fa9e002f9669da47"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="infinitescroll.xml" hash="ea902de6a641b72d9b02a8282de62c79"/></dir><dir name="template"><dir name="infinitescroll"><file name="init.phtml" hash="68c11c9c456d4fecbc6dea2917f6e2c6"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="js"><file name="infinitescroll.js" hash="5ce9fe03f389fd8bd380c32b583f9b42"/></dir><dir name="css"><file name="infinitescroll.css" hash="1ef7cf72905d03ea47d2201878d53970"/></dir><dir name="images"><file name="infinitescroll-loading.gif" hash="e01916be17aa4b1b73a93bb7022f22e4"/></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
skin/frontend/base/default/css/infinitescroll.css ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ #infinitescroll-loading { background:url("../images/infinitescroll-loading.gif") no-repeat center; padding:50px 0; }
2
+ #infinitescroll-showmore { color:#1e7ec8; text-align:center; font-size:16px; font-weight:bold; cursor:pointer; padding:10px 0; }
3
+ #infinitescroll-showmore a { text-decoration:none; }
skin/frontend/base/default/images/infinitescroll-loading.gif ADDED
Binary file
skin/frontend/base/default/js/infinitescroll.js ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var infinitescroll = Class.create({
2
+ afterInit: function() {
3
+ this.restyle();
4
+ this.addShowMore();
5
+ },
6
+ restyle: function() {
7
+ $$(".pager").each(function(e) {
8
+ e.remove();
9
+ });
10
+ },
11
+ addShowMore: function() {
12
+ if (this.shouldload) {
13
+ Event.observe(window, "scroll", function() {
14
+ this.makeRequest();
15
+ }.bind(this));
16
+ this.makeRequest();
17
+ }
18
+ },
19
+ testRequest: function() {
20
+ if ((document.viewport.getScrollOffsets().top + document.viewport.getHeight()) >= this.getTriggerHeight()) {
21
+ return true;
22
+ }
23
+ return false;
24
+ },
25
+ addLoading: function() {
26
+ if (this.mode == "grid") {
27
+ this.getInsertElement().insert({ before:"<div id=\"infinitescroll-loading\"></div>" });
28
+ } else {
29
+ this.getInsertElement().insert({ bottom:"<div id=\"infinitescroll-loading\"></div>" });
30
+ }
31
+ },
32
+ makeRequest: function() {
33
+ if (this.testRequest()) {
34
+ Event.stopObserving(window, "scroll");
35
+ this.addLoading();
36
+ var url = window.location.href;
37
+ var args = url.split("?");
38
+ if (args.length > 1) {
39
+ url += "&p=" + this.nextpage;
40
+ } else {
41
+ url += "?p=" + this.nextpage;
42
+ }
43
+ new Ajax.Request(url, {
44
+ onSuccess: function(response) {
45
+ this.nextpage++;
46
+ $("infinitescroll-loading").remove();
47
+ this.addContent(response);
48
+ }.bind(this)
49
+ });
50
+ }
51
+ },
52
+ addContent: function(response) {
53
+ if (this.mode == "grid") {
54
+ this.addGridContent(response);
55
+ } else {
56
+ this.addListContent(response);
57
+ }
58
+ this.disable.bind(this).defer();
59
+ this.addShowMore.bind(this).defer();
60
+ },
61
+ addGridContent: function(response) {
62
+ $$(".category-products > .last").each(function(e) {
63
+ e.removeClassName("last");
64
+ });
65
+ var page = new Element("div").update(response.responseText);
66
+ this.removeToolbar(page);
67
+ this.getInsertElement().insert({ before:page.down(".category-products").innerHTML });
68
+ },
69
+ addListContent: function(response) {
70
+ $$(".products-list > .last").each(function(e) {
71
+ e.removeClassName("last");
72
+ });
73
+ var page = new Element("div").update(response.responseText);
74
+ this.removeToolbar(page);
75
+ this.getInsertElement().insert({ bottom:page.down(".products-list").innerHTML });
76
+ this.getInsertElement().insert({ bottom:page.down(".category-products script") });
77
+ },
78
+ removeToolbar: function(page) {
79
+ while (page.down(".toolbar")) {
80
+ page.down(".toolbar").remove();
81
+ }
82
+ while (page.down(".toolbar-bottom")) {
83
+ page.down(".toolbar-bottom").remove();
84
+ }
85
+ },
86
+ getInsertElement: function() {
87
+ if (this.mode == "grid") {
88
+ return $$(".toolbar-bottom")[0];
89
+ } else {
90
+ return $$(".products-list")[0];
91
+ }
92
+ },
93
+ disable: function() {
94
+ if (this.nextpage > this.lastpage) {
95
+ this.shouldload = false;
96
+ }
97
+ },
98
+ getTriggerHeight: function() {
99
+ return this.getInsertElement().up().cumulativeOffset().top + this.getInsertElement().up().getHeight();
100
+ }
101
+ });
102
+
103
+ document.observe("dom:loaded", function() {
104
+ if (typeof(thisinfinitescroll) == "object") {
105
+ thisinfinitescroll.afterInit();
106
+ }
107
+ });