Version Notes
Automatic load next page of current product list.
Support for Magento 1.3 up to 1.7
Download this release
Release Info
| Developer | Magento Core Team |
| Extension | Strategery_InfiniteScroll2 |
| Version | 2.1.2 |
| Comparing to | |
| See all releases | |
Code changes from version 2.1.1 to 2.1.2
- app/code/community/Strategery/Infinitescroll2/Model/Catalog/Observer.php +25 -13
- app/code/community/Strategery/Infinitescroll2/etc/config.xml +1 -1
- app/design/frontend/base/default/layout/strategery-infinitescroll2.xml +0 -158
- app/design/frontend/base/default/template/strategery/infinitescroll2/js.phtml +0 -25
- app/design/frontend/base/default/template/strategery/infinitescroll2/toolbar.phtml +0 -55
- app/design/frontend/default/default/layout/strategery-infinitescroll2.xml +4 -0
- js/jquery/infinitescroll2/behaviors/infinitescroll-magento.js +103 -0
- js/jquery/infinitescroll2/jquery.infinitescroll.js +747 -706
- js/jquery/infinitescroll2/jquery.infinitescroll.min.js +31 -47
- package.xml +4 -4
app/code/community/Strategery/Infinitescroll2/Model/Catalog/Observer.php
CHANGED
|
@@ -21,29 +21,32 @@ class Strategery_Infinitescroll2_Model_Catalog_Observer
|
|
| 21 |
|
| 22 |
public function modifyCollection($observer)
|
| 23 |
{
|
|
|
|
| 24 |
$this->hardReset();
|
|
|
|
| 25 |
$helper = Mage::helper('infinitescroll2');
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
{
|
| 28 |
// info:
|
| 29 |
-
$event = $observer->getEvent();
|
| 30 |
-
$collection = $event->getCollection();
|
| 31 |
$pageId = Mage::registry('current_category')->getId();
|
| 32 |
$pageByParam = $helper->getNextPageNumber();
|
| 33 |
-
$
|
|
|
|
|
|
|
|
|
|
| 34 |
// actions:
|
| 35 |
if(!$helper->isScrollCall())
|
| 36 |
{
|
| 37 |
if(!Mage::getSingleton('checkout/session')->getData('recursiveCollection'))
|
| 38 |
{
|
| 39 |
-
$pageLoaded = $helper->loadMemory($pageId);
|
| 40 |
if($pageLoaded>1)
|
| 41 |
{
|
| 42 |
Mage::getSingleton('checkout/session')->setData('recursiveCollection',true);
|
| 43 |
Mage::getSingleton('checkout/session')->setData('pageLoaded',$pageLoaded);
|
| 44 |
-
// default page size save:
|
| 45 |
-
$defaultPageSize = $collection->getPageSize();
|
| 46 |
-
Mage::getSingleton('checkout/session')->setData('defautlPageSize',$defaultPageSize);
|
| 47 |
// replace page size:
|
| 48 |
$tmpPageSize = $defaultPageSize*$pageLoaded;
|
| 49 |
$collection->setPageSize($tmpPageSize);
|
|
@@ -58,11 +61,18 @@ class Strategery_Infinitescroll2_Model_Catalog_Observer
|
|
| 58 |
else
|
| 59 |
{
|
| 60 |
$nextPage = Mage::getSingleton('checkout/session')->getData('nextPage');
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
if($nextPage>1 && $nextPage<=$lastPageNumber)
|
| 62 |
{
|
| 63 |
$pageByParam=$nextPage;
|
| 64 |
}
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
| 66 |
$collection->setCurPage($pageByParam);
|
| 67 |
Mage::getSingleton('checkout/session')->setData('pageLoaded',$pageByParam);
|
| 68 |
}
|
|
@@ -72,13 +82,15 @@ class Strategery_Infinitescroll2_Model_Catalog_Observer
|
|
| 72 |
|
| 73 |
public function restoreCollection($observer)
|
| 74 |
{
|
|
|
|
| 75 |
$helper = Mage::helper('infinitescroll2');
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
{
|
| 78 |
// info:
|
| 79 |
-
$helper = Mage::helper('infinitescroll2');
|
| 80 |
-
$event = $observer->getEvent();
|
| 81 |
-
$collection = $event->getCollection();
|
| 82 |
$pageLoaded = Mage::getSingleton('checkout/session')->getData('pageLoaded');
|
| 83 |
$nextPageSaved = Mage::getSingleton('checkout/session')->getData('nextPage');
|
| 84 |
$tmpNext = false;
|
| 21 |
|
| 22 |
public function modifyCollection($observer)
|
| 23 |
{
|
| 24 |
+
// reset:
|
| 25 |
$this->hardReset();
|
| 26 |
+
// helper:
|
| 27 |
$helper = Mage::helper('infinitescroll2');
|
| 28 |
+
// observer data:
|
| 29 |
+
$event = $observer->getEvent();
|
| 30 |
+
$collection = $event->getCollection();
|
| 31 |
+
$lastPageNumber = $collection->getLastPageNumber();
|
| 32 |
+
if(Mage::registry('current_category') && $helper->isMemoryActive() && $lastPageNumber>1)
|
| 33 |
{
|
| 34 |
// info:
|
|
|
|
|
|
|
| 35 |
$pageId = Mage::registry('current_category')->getId();
|
| 36 |
$pageByParam = $helper->getNextPageNumber();
|
| 37 |
+
$pageLoaded = $helper->loadMemory($pageId);
|
| 38 |
+
// default page size save:
|
| 39 |
+
$defaultPageSize = $collection->getPageSize();
|
| 40 |
+
Mage::getSingleton('checkout/session')->setData('defautlPageSize',$defaultPageSize);
|
| 41 |
// actions:
|
| 42 |
if(!$helper->isScrollCall())
|
| 43 |
{
|
| 44 |
if(!Mage::getSingleton('checkout/session')->getData('recursiveCollection'))
|
| 45 |
{
|
|
|
|
| 46 |
if($pageLoaded>1)
|
| 47 |
{
|
| 48 |
Mage::getSingleton('checkout/session')->setData('recursiveCollection',true);
|
| 49 |
Mage::getSingleton('checkout/session')->setData('pageLoaded',$pageLoaded);
|
|
|
|
|
|
|
|
|
|
| 50 |
// replace page size:
|
| 51 |
$tmpPageSize = $defaultPageSize*$pageLoaded;
|
| 52 |
$collection->setPageSize($tmpPageSize);
|
| 61 |
else
|
| 62 |
{
|
| 63 |
$nextPage = Mage::getSingleton('checkout/session')->getData('nextPage');
|
| 64 |
+
if($pageLoaded>$nextPage)
|
| 65 |
+
{
|
| 66 |
+
$nextPage = $pageLoaded+1;
|
| 67 |
+
}
|
| 68 |
if($nextPage>1 && $nextPage<=$lastPageNumber)
|
| 69 |
{
|
| 70 |
$pageByParam=$nextPage;
|
| 71 |
}
|
| 72 |
+
if($nextPage<=$lastPageNumber)
|
| 73 |
+
{
|
| 74 |
+
$helper->saveMemory($pageByParam,$pageId);
|
| 75 |
+
}
|
| 76 |
$collection->setCurPage($pageByParam);
|
| 77 |
Mage::getSingleton('checkout/session')->setData('pageLoaded',$pageByParam);
|
| 78 |
}
|
| 82 |
|
| 83 |
public function restoreCollection($observer)
|
| 84 |
{
|
| 85 |
+
// helper:
|
| 86 |
$helper = Mage::helper('infinitescroll2');
|
| 87 |
+
// observer data:
|
| 88 |
+
$event = $observer->getEvent();
|
| 89 |
+
$collection = $event->getCollection();
|
| 90 |
+
$lastPageNumber = $collection->getLastPageNumber();
|
| 91 |
+
if(Mage::registry('current_category') && $helper->isMemoryActive() && $lastPageNumber>1)
|
| 92 |
{
|
| 93 |
// info:
|
|
|
|
|
|
|
|
|
|
| 94 |
$pageLoaded = Mage::getSingleton('checkout/session')->getData('pageLoaded');
|
| 95 |
$nextPageSaved = Mage::getSingleton('checkout/session')->getData('nextPage');
|
| 96 |
$tmpNext = false;
|
app/code/community/Strategery/Infinitescroll2/etc/config.xml
CHANGED
|
@@ -25,7 +25,7 @@
|
|
| 25 |
<config>
|
| 26 |
<modules>
|
| 27 |
<Strategery_Infinitescroll2>
|
| 28 |
-
<version>2.1.
|
| 29 |
</Strategery_Infinitescroll2>
|
| 30 |
</modules>
|
| 31 |
<global>
|
| 25 |
<config>
|
| 26 |
<modules>
|
| 27 |
<Strategery_Infinitescroll2>
|
| 28 |
+
<version>2.1.2</version>
|
| 29 |
</Strategery_Infinitescroll2>
|
| 30 |
</modules>
|
| 31 |
<global>
|
app/design/frontend/base/default/layout/strategery-infinitescroll2.xml
DELETED
|
@@ -1,158 +0,0 @@
|
|
| 1 |
-
<?xml version="1.0"?>
|
| 2 |
-
<!--
|
| 3 |
-
/**
|
| 4 |
-
* InfiniteScroll - Magento Integration
|
| 5 |
-
*
|
| 6 |
-
* NOTICE OF LICENSE
|
| 7 |
-
*
|
| 8 |
-
* This source file is subject to the Academic Free License (AFL 3.0),
|
| 9 |
-
* available through the world-wide-web at this URL:
|
| 10 |
-
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
-
*
|
| 12 |
-
* @category Strategery
|
| 13 |
-
* @package Strategery_Infinitescroll2
|
| 14 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 15 |
-
* @copyright Copyright (c) 2011 Strategery Inc. (http://usestrategery.com)
|
| 16 |
-
*
|
| 17 |
-
* @author Gabriel Somoza (me@gabrielsomoza.com)
|
| 18 |
-
* @link http://gabrielsomoza.com/
|
| 19 |
-
*
|
| 20 |
-
* Update 2.0.0
|
| 21 |
-
* @author Damian A. Pastorini (admin@dwdesigner.com)
|
| 22 |
-
* @link http://www.dwdesigner.com/
|
| 23 |
-
*/
|
| 24 |
-
-->
|
| 25 |
-
<layout version="0.1.0">
|
| 26 |
-
<infinitescroll2_js_index>
|
| 27 |
-
<reference name="root">
|
| 28 |
-
<action method="setTemplate" ifconfig="infinitescroll2/general/enabled">
|
| 29 |
-
<template>strategery/infinitescroll2/js.phtml</template>
|
| 30 |
-
</action>
|
| 31 |
-
</reference>
|
| 32 |
-
</infinitescroll2_js_index>
|
| 33 |
-
|
| 34 |
-
<catalog_category_default>
|
| 35 |
-
<reference name="head">
|
| 36 |
-
<action method="addItem" ifconfig="infinitescroll2/general/enabled">
|
| 37 |
-
<type>js</type>
|
| 38 |
-
<name>jquery/jquery.latest.min.js</name>
|
| 39 |
-
</action>
|
| 40 |
-
<action method="addItem" ifconfig="infinitescroll2/general/enabled">
|
| 41 |
-
<type>js</type>
|
| 42 |
-
<name>jquery/infinitescroll2/https.js</name>
|
| 43 |
-
</action>
|
| 44 |
-
<action method="addItem" ifconfig="infinitescroll2/general/enabled">
|
| 45 |
-
<type>js</type>
|
| 46 |
-
<name>jquery/infinitescroll2/jquery.infinitescroll.js</name>
|
| 47 |
-
</action>
|
| 48 |
-
<action method="addItem" ifconfig="infinitescroll2/general/enabled">
|
| 49 |
-
<type>js</type>
|
| 50 |
-
<name>jquery/infinitescroll2/behaviors/infinitescroll-magento.js</name>
|
| 51 |
-
</action>
|
| 52 |
-
</reference>
|
| 53 |
-
<reference name="before_body_end">
|
| 54 |
-
<block type="core/text" name="infinitescroll2_config">
|
| 55 |
-
<action method="setText">
|
| 56 |
-
<text><![CDATA[<script type="text/javascript" src="/infinitescroll2/js"></script>]]></text>
|
| 57 |
-
</action>
|
| 58 |
-
</block>
|
| 59 |
-
</reference>
|
| 60 |
-
<reference name="product_list_toolbar">
|
| 61 |
-
<action method="setTemplate" ifconfig="infinitescroll2/design/hide_toolbar">
|
| 62 |
-
<template>strategery/infinitescroll2/toolbar.phtml</template>
|
| 63 |
-
</action>
|
| 64 |
-
</reference>
|
| 65 |
-
</catalog_category_default>
|
| 66 |
-
|
| 67 |
-
<catalog_category_layered>
|
| 68 |
-
<reference name="head">
|
| 69 |
-
<action method="addItem" ifconfig="infinitescroll2/general/enabled">
|
| 70 |
-
<type>js</type>
|
| 71 |
-
<name>jquery/jquery.latest.min.js</name>
|
| 72 |
-
</action>
|
| 73 |
-
<action method="addItem" ifconfig="infinitescroll2/general/enabled">
|
| 74 |
-
<type>js</type>
|
| 75 |
-
<name>jquery/infinitescroll2/https.js</name>
|
| 76 |
-
</action>
|
| 77 |
-
<action method="addItem" ifconfig="infinitescroll2/general/enabled">
|
| 78 |
-
<type>js</type>
|
| 79 |
-
<name>jquery/infinitescroll2/jquery.infinitescroll.js</name>
|
| 80 |
-
</action>
|
| 81 |
-
<action method="addItem" ifconfig="infinitescroll2/general/enabled">
|
| 82 |
-
<type>js</type>
|
| 83 |
-
<name>jquery/infinitescroll2/behaviors/infinitescroll-magento.js</name>
|
| 84 |
-
</action>
|
| 85 |
-
</reference>
|
| 86 |
-
<reference name="before_body_end">
|
| 87 |
-
<block type="core/text" name="infinitescroll2_config">
|
| 88 |
-
<action method="setText">
|
| 89 |
-
<text><![CDATA[<script type="text/javascript" src="/infinitescroll2/js"></script>]]></text>
|
| 90 |
-
</action>
|
| 91 |
-
</block>
|
| 92 |
-
</reference>
|
| 93 |
-
<reference name="product_list_toolbar">
|
| 94 |
-
<action method="setTemplate" ifconfig="infinitescroll2/design/hide_toolbar">
|
| 95 |
-
<template>strategery/infinitescroll2/toolbar.phtml</template>
|
| 96 |
-
</action>
|
| 97 |
-
</reference>
|
| 98 |
-
</catalog_category_layered>
|
| 99 |
-
|
| 100 |
-
<catalogsearch_result_index>
|
| 101 |
-
<reference name="head">
|
| 102 |
-
<action method="addItem" ifconfig="infinitescroll2/general/enabled">
|
| 103 |
-
<type>js</type>
|
| 104 |
-
<name>jquery/jquery.latest.min.js</name>
|
| 105 |
-
</action>
|
| 106 |
-
<action method="addItem" ifconfig="infinitescroll2/general/enabled">
|
| 107 |
-
<type>js</type>
|
| 108 |
-
<name>jquery/infinitescroll2/jquery.infinitescroll.js</name>
|
| 109 |
-
</action>
|
| 110 |
-
<action method="addItem" ifconfig="infinitescroll2/general/enabled">
|
| 111 |
-
<type>js</type>
|
| 112 |
-
<name>jquery/infinitescroll2/behaviors/infinitescroll-magento.js</name>
|
| 113 |
-
</action>
|
| 114 |
-
</reference>
|
| 115 |
-
<reference name="before_body_end">
|
| 116 |
-
<block type="core/text" name="infinitescroll2_config">
|
| 117 |
-
<action method="setText">
|
| 118 |
-
<text><![CDATA[<script type="text/javascript" src="/infinitescroll2/js"></script>]]></text>
|
| 119 |
-
</action>
|
| 120 |
-
</block>
|
| 121 |
-
</reference>
|
| 122 |
-
<reference name="product_list_toolbar">
|
| 123 |
-
<action method="setTemplate" ifconfig="infinitescroll2/design/hide_toolbar">
|
| 124 |
-
<template>strategery/infinitescroll2/toolbar.phtml</template>
|
| 125 |
-
</action>
|
| 126 |
-
</reference>
|
| 127 |
-
</catalogsearch_result_index>
|
| 128 |
-
|
| 129 |
-
<catalogsearch_advanced_index>
|
| 130 |
-
<reference name="head">
|
| 131 |
-
<action method="addItem" ifconfig="infinitescroll2/general/enabled">
|
| 132 |
-
<type>js</type>
|
| 133 |
-
<name>jquery/jquery.latest.min.js</name>
|
| 134 |
-
</action>
|
| 135 |
-
<action method="addItem" ifconfig="infinitescroll2/general/enabled">
|
| 136 |
-
<type>js</type>
|
| 137 |
-
<name>jquery/infinitescroll2/jquery.infinitescroll.js</name>
|
| 138 |
-
</action>
|
| 139 |
-
<action method="addItem" ifconfig="infinitescroll2/general/enabled">
|
| 140 |
-
<type>js</type>
|
| 141 |
-
<name>jquery/infinitescroll2/behaviors/infinitescroll-magento.js</name>
|
| 142 |
-
</action>
|
| 143 |
-
</reference>
|
| 144 |
-
<reference name="before_body_end">
|
| 145 |
-
<block type="core/text" name="infinitescroll2_config">
|
| 146 |
-
<action method="setText">
|
| 147 |
-
<text><![CDATA[<script type="text/javascript" src="/infinitescroll2/js"></script>]]></text>
|
| 148 |
-
</action>
|
| 149 |
-
</block>
|
| 150 |
-
</reference>
|
| 151 |
-
<reference name="product_list_toolbar">
|
| 152 |
-
<action method="setTemplate" ifconfig="infinitescroll2/design/hide_toolbar">
|
| 153 |
-
<template>strategery/infinitescroll2/toolbar.phtml</template>
|
| 154 |
-
</action>
|
| 155 |
-
</reference>
|
| 156 |
-
</catalogsearch_advanced_index>
|
| 157 |
-
|
| 158 |
-
</layout>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/base/default/template/strategery/infinitescroll2/js.phtml
DELETED
|
@@ -1,25 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* InfiniteScroll - Magento Integration
|
| 4 |
-
*
|
| 5 |
-
* NOTICE OF LICENSE
|
| 6 |
-
*
|
| 7 |
-
* This source file is subject to the Academic Free License (AFL 3.0),
|
| 8 |
-
* available through the world-wide-web at this URL:
|
| 9 |
-
* http://opensource.org/licenses/afl-3.0.php
|
| 10 |
-
*
|
| 11 |
-
* @category Strategery
|
| 12 |
-
* @package Strategery_Infinitescroll2
|
| 13 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 14 |
-
* @copyright Copyright (c) 2011 Strategery Inc. (http://usestrategery.com)
|
| 15 |
-
*
|
| 16 |
-
* @author Gabriel Somoza (me@gabrielsomoza.com)
|
| 17 |
-
* @link http://gabrielsomoza.com/
|
| 18 |
-
*/
|
| 19 |
-
$helper = $this->helper('infinitescroll2');
|
| 20 |
-
?>
|
| 21 |
-
jQuery(document).ready(function ($) {
|
| 22 |
-
$('<?php echo $helper->getConfigData('selectors/content') ?>').infinitescroll({
|
| 23 |
-
<?php echo $helper->getJsConfig(); ?>
|
| 24 |
-
});
|
| 25 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/base/default/template/strategery/infinitescroll2/toolbar.phtml
DELETED
|
@@ -1,55 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* InfiniteScroll - Magento Integration
|
| 4 |
-
*
|
| 5 |
-
* NOTICE OF LICENSE
|
| 6 |
-
*
|
| 7 |
-
* This source file is subject to the Academic Free License (AFL 3.0),
|
| 8 |
-
* available through the world-wide-web at this URL:
|
| 9 |
-
* http://opensource.org/licenses/afl-3.0.php
|
| 10 |
-
*
|
| 11 |
-
* @category Strategery
|
| 12 |
-
* @package Strategery_Infinitescroll2
|
| 13 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 14 |
-
* @copyright Copyright (c) 2011 Strategery Inc. (http://usestrategery.com)
|
| 15 |
-
*
|
| 16 |
-
* @author Gabriel Somoza (me@gabrielsomoza.com)
|
| 17 |
-
* @link http://gabrielsomoza.com/
|
| 18 |
-
*
|
| 19 |
-
* Update 2.0.0
|
| 20 |
-
* @author Damian A. Pastorini (admin@dwdesigner.com)
|
| 21 |
-
* @link http://www.dwdesigner.com/
|
| 22 |
-
*/
|
| 23 |
-
?>
|
| 24 |
-
<?php if(Mage::getVersion()>1.3): ?>
|
| 25 |
-
<?php if($this->getCollection()->getSize()): ?>
|
| 26 |
-
<div class="toolbar" style="display:none;">
|
| 27 |
-
<?php echo $this->getPagerHtml() ?>
|
| 28 |
-
</div>
|
| 29 |
-
<?php endif ?>
|
| 30 |
-
<?php else: ?>
|
| 31 |
-
<?php if($this->getCollection()->getSize() && $this->getLastPageNum()>1): ?>
|
| 32 |
-
<table class="pager" cellspacing="0" style="display:none;">
|
| 33 |
-
<tr>
|
| 34 |
-
<td class="pages">
|
| 35 |
-
<strong><?php echo $this->__('Page:') ?></strong>
|
| 36 |
-
<ol>
|
| 37 |
-
<?php if (!$this->isFirstPage()): ?>
|
| 38 |
-
<li><a href="<?php echo $this->getPreviousPageUrl() ?>"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_left.gif') ?>" alt="<?php echo $this->__('Previous') ?>" /></a></li>
|
| 39 |
-
<?php endif ?>
|
| 40 |
-
<?php foreach ($this->getPages() as $_page): ?>
|
| 41 |
-
<?php if ($this->isPageCurrent($_page)): ?>
|
| 42 |
-
<li><span class="on"><?php echo $_page ?></span></li>
|
| 43 |
-
<?php else: ?>
|
| 44 |
-
<li><a href="<?php echo $this->getPageUrl($_page) ?>"><?php echo $_page ?></a></li>
|
| 45 |
-
<?php endif ?>
|
| 46 |
-
<?php endforeach;; ?>
|
| 47 |
-
<?php if (!$this->isLastPage()): ?>
|
| 48 |
-
<li><a href="<?php echo $this->getNextPageUrl() ?>"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_right.gif') ?>" alt="<?php echo $this->__('Next') ?>" /></a></li>
|
| 49 |
-
<?php endif ?>
|
| 50 |
-
</ol>
|
| 51 |
-
</td>
|
| 52 |
-
</tr>
|
| 53 |
-
</table>
|
| 54 |
-
<?php endif ?>
|
| 55 |
-
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/default/default/layout/strategery-infinitescroll2.xml
CHANGED
|
@@ -37,10 +37,12 @@
|
|
| 37 |
<type>js</type>
|
| 38 |
<name>jquery/jquery.latest.min.js</name>
|
| 39 |
</action>
|
|
|
|
| 40 |
<action method="addItem" ifconfig="infinitescroll2/general/enabled">
|
| 41 |
<type>js</type>
|
| 42 |
<name>jquery/infinitescroll2/https.js</name>
|
| 43 |
</action>
|
|
|
|
| 44 |
<action method="addItem" ifconfig="infinitescroll2/general/enabled">
|
| 45 |
<type>js</type>
|
| 46 |
<name>jquery/infinitescroll2/jquery.infinitescroll.js</name>
|
|
@@ -70,10 +72,12 @@
|
|
| 70 |
<type>js</type>
|
| 71 |
<name>jquery/jquery.latest.min.js</name>
|
| 72 |
</action>
|
|
|
|
| 73 |
<action method="addItem" ifconfig="infinitescroll2/general/enabled">
|
| 74 |
<type>js</type>
|
| 75 |
<name>jquery/infinitescroll2/https.js</name>
|
| 76 |
</action>
|
|
|
|
| 77 |
<action method="addItem" ifconfig="infinitescroll2/general/enabled">
|
| 78 |
<type>js</type>
|
| 79 |
<name>jquery/infinitescroll2/jquery.infinitescroll.js</name>
|
| 37 |
<type>js</type>
|
| 38 |
<name>jquery/jquery.latest.min.js</name>
|
| 39 |
</action>
|
| 40 |
+
<!--
|
| 41 |
<action method="addItem" ifconfig="infinitescroll2/general/enabled">
|
| 42 |
<type>js</type>
|
| 43 |
<name>jquery/infinitescroll2/https.js</name>
|
| 44 |
</action>
|
| 45 |
+
-->
|
| 46 |
<action method="addItem" ifconfig="infinitescroll2/general/enabled">
|
| 47 |
<type>js</type>
|
| 48 |
<name>jquery/infinitescroll2/jquery.infinitescroll.js</name>
|
| 72 |
<type>js</type>
|
| 73 |
<name>jquery/jquery.latest.min.js</name>
|
| 74 |
</action>
|
| 75 |
+
<!--
|
| 76 |
<action method="addItem" ifconfig="infinitescroll2/general/enabled">
|
| 77 |
<type>js</type>
|
| 78 |
<name>jquery/infinitescroll2/https.js</name>
|
| 79 |
</action>
|
| 80 |
+
-->
|
| 81 |
<action method="addItem" ifconfig="infinitescroll2/general/enabled">
|
| 82 |
<type>js</type>
|
| 83 |
<name>jquery/infinitescroll2/jquery.infinitescroll.js</name>
|
js/jquery/infinitescroll2/behaviors/infinitescroll-magento.js
CHANGED
|
@@ -74,7 +74,110 @@
|
|
| 74 |
this.options.wasDoneLastTime=true;
|
| 75 |
}
|
| 76 |
callback.call($(opts.contentSelector)[0], data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
});
|
| 79 |
});
|
| 80 |
})(jQuery);
|
| 74 |
this.options.wasDoneLastTime=true;
|
| 75 |
}
|
| 76 |
callback.call($(opts.contentSelector)[0], data);
|
| 77 |
+
},
|
| 78 |
+
// Retrieve next set of content items
|
| 79 |
+
retrieve: function infscr_retrieve(pageNum) {
|
| 80 |
+
|
| 81 |
+
var instance = this,
|
| 82 |
+
opts = instance.options,
|
| 83 |
+
path = opts.path,
|
| 84 |
+
box, frag, desturl, method, condition,
|
| 85 |
+
pageNum = pageNum || null,
|
| 86 |
+
getPage = (!!pageNum) ? pageNum : opts.state.currPage;
|
| 87 |
+
beginAjax = function infscr_ajax(opts) {
|
| 88 |
+
|
| 89 |
+
// increment the URL bit. e.g. /page/3/
|
| 90 |
+
opts.state.currPage++;
|
| 91 |
+
|
| 92 |
+
instance._debug('heading into ajax', path);
|
| 93 |
+
|
| 94 |
+
// if we're dealing with a table we can't use DIVs
|
| 95 |
+
box = $(opts.contentSelector).is('table') ? $('<tbody/>') : $('<div/>');
|
| 96 |
+
|
| 97 |
+
desturl = path.join(opts.state.currPage);
|
| 98 |
+
|
| 99 |
+
desturl += '&scrollCall=1';
|
| 100 |
+
|
| 101 |
+
method = (opts.dataType == 'html' || opts.dataType == 'json' ) ? opts.dataType : 'html+callback';
|
| 102 |
+
if (opts.appendCallback && opts.dataType == 'html') method += '+callback'
|
| 103 |
+
|
| 104 |
+
switch (method) {
|
| 105 |
+
|
| 106 |
+
case 'html+callback':
|
| 107 |
+
|
| 108 |
+
instance._debug('Using HTML via .load() method');
|
| 109 |
+
box.load(desturl + ' ' + opts.itemSelector, null, function infscr_ajax_callback(responseText) {
|
| 110 |
+
instance._loadcallback(box, responseText);
|
| 111 |
+
});
|
| 112 |
+
|
| 113 |
+
break;
|
| 114 |
+
|
| 115 |
+
case 'html':
|
| 116 |
+
instance._debug('Using ' + (method.toUpperCase()) + ' via $.ajax() method');
|
| 117 |
+
$.ajax({
|
| 118 |
+
// params
|
| 119 |
+
url: desturl,
|
| 120 |
+
dataType: opts.dataType,
|
| 121 |
+
complete: function infscr_ajax_callback(jqXHR, textStatus) {
|
| 122 |
+
condition = (typeof (jqXHR.isResolved) !== 'undefined') ? (jqXHR.isResolved()) : (textStatus === "success" || textStatus === "notmodified");
|
| 123 |
+
(condition) ? instance._loadcallback(box, jqXHR.responseText) : instance._error('end');
|
| 124 |
+
}
|
| 125 |
+
});
|
| 126 |
+
|
| 127 |
+
break;
|
| 128 |
+
case 'json':
|
| 129 |
+
instance._debug('Using ' + (method.toUpperCase()) + ' via $.ajax() method');
|
| 130 |
+
$.ajax({
|
| 131 |
+
dataType: 'json',
|
| 132 |
+
type: 'GET',
|
| 133 |
+
url: desturl,
|
| 134 |
+
success: function(data, textStatus, jqXHR) {
|
| 135 |
+
condition = (typeof (jqXHR.isResolved) !== 'undefined') ? (jqXHR.isResolved()) : (textStatus === "success" || textStatus === "notmodified");
|
| 136 |
+
if(opts.appendCallback) {
|
| 137 |
+
// if appendCallback is true, you must defined template in options.
|
| 138 |
+
// note that data passed into _loadcallback is already an html (after processed in opts.template(data)).
|
| 139 |
+
if(opts.template != undefined) {
|
| 140 |
+
var theData = opts.template(data);
|
| 141 |
+
box.append(theData);
|
| 142 |
+
(condition) ? instance._loadcallback(box, theData) : instance._error('end');
|
| 143 |
+
} else {
|
| 144 |
+
instance._debug("template must be defined.");
|
| 145 |
+
instance._error('end');
|
| 146 |
+
}
|
| 147 |
+
} else {
|
| 148 |
+
// if appendCallback is false, we will pass in the JSON object. you should handle it yourself in your callback.
|
| 149 |
+
(condition) ? instance._loadcallback(box, data) : instance._error('end');
|
| 150 |
+
}
|
| 151 |
+
},
|
| 152 |
+
error: function(jqXHR, textStatus, errorThrown) {
|
| 153 |
+
instance._debug("JSON ajax request failed.");
|
| 154 |
+
instance._error('end');
|
| 155 |
+
}
|
| 156 |
+
});
|
| 157 |
+
|
| 158 |
+
break;
|
| 159 |
+
}
|
| 160 |
+
};
|
| 161 |
+
|
| 162 |
+
// if behavior is defined and this function is extended, call that instead of default
|
| 163 |
+
if (!!opts.behavior && this['retrieve_'+opts.behavior] !== undefined) {
|
| 164 |
+
this['retrieve_'+opts.behavior].call(this,pageNum);
|
| 165 |
+
return;
|
| 166 |
}
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
// for manual triggers, if destroyed, get out of here
|
| 170 |
+
if (opts.state.isDestroyed) {
|
| 171 |
+
this._debug('Instance is destroyed');
|
| 172 |
+
return false;
|
| 173 |
+
};
|
| 174 |
+
|
| 175 |
+
// we dont want to fire the ajax multiple times
|
| 176 |
+
opts.state.isDuringAjax = true;
|
| 177 |
+
|
| 178 |
+
opts.loading.start.call($(opts.contentSelector)[0],opts);
|
| 179 |
+
|
| 180 |
+
}
|
| 181 |
});
|
| 182 |
});
|
| 183 |
})(jQuery);
|
js/jquery/infinitescroll2/jquery.infinitescroll.js
CHANGED
|
@@ -1,706 +1,747 @@
|
|
| 1 |
-
/*
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
*/
|
| 13 |
-
|
| 14 |
-
(function (window, $, undefined) {
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
(this.options.binder)
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
//
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
//
|
| 137 |
-
opts.
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
},
|
| 177 |
-
|
| 178 |
-
//
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
this
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
this.
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
case 'append':
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
case '
|
| 379 |
-
opts.state.isPaused =
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
opts.
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
| 544 |
-
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
this
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
|
| 567 |
-
|
| 568 |
-
|
| 569 |
-
|
| 570 |
-
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
|
| 578 |
-
|
| 579 |
-
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
|
| 585 |
-
|
| 586 |
-
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
| 602 |
-
|
| 603 |
-
|
| 604 |
-
|
| 605 |
-
|
| 606 |
-
|
| 607 |
-
|
| 608 |
-
|
| 609 |
-
|
| 610 |
-
|
| 611 |
-
|
| 612 |
-
|
| 613 |
-
|
| 614 |
-
|
| 615 |
-
|
| 616 |
-
|
| 617 |
-
|
| 618 |
-
|
| 619 |
-
|
| 620 |
-
|
| 621 |
-
|
| 622 |
-
|
| 623 |
-
|
| 624 |
-
|
| 625 |
-
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
|
| 630 |
-
|
| 631 |
-
|
| 632 |
-
|
| 633 |
-
|
| 634 |
-
|
| 635 |
-
|
| 636 |
-
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
| 641 |
-
|
| 642 |
-
|
| 643 |
-
|
| 644 |
-
|
| 645 |
-
|
| 646 |
-
|
| 647 |
-
|
| 648 |
-
|
| 649 |
-
|
| 650 |
-
|
| 651 |
-
|
| 652 |
-
|
| 653 |
-
|
| 654 |
-
|
| 655 |
-
|
| 656 |
-
|
| 657 |
-
|
| 658 |
-
|
| 659 |
-
|
| 660 |
-
|
| 661 |
-
|
| 662 |
-
|
| 663 |
-
|
| 664 |
-
|
| 665 |
-
|
| 666 |
-
|
| 667 |
-
|
| 668 |
-
|
| 669 |
-
|
| 670 |
-
|
| 671 |
-
|
| 672 |
-
|
| 673 |
-
|
| 674 |
-
|
| 675 |
-
|
| 676 |
-
|
| 677 |
-
|
| 678 |
-
|
| 679 |
-
|
| 680 |
-
|
| 681 |
-
|
| 682 |
-
|
| 683 |
-
|
| 684 |
-
|
| 685 |
-
|
| 686 |
-
|
| 687 |
-
|
| 688 |
-
|
| 689 |
-
|
| 690 |
-
|
| 691 |
-
|
| 692 |
-
|
| 693 |
-
|
| 694 |
-
|
| 695 |
-
|
| 696 |
-
|
| 697 |
-
|
| 698 |
-
|
| 699 |
-
|
| 700 |
-
|
| 701 |
-
|
| 702 |
-
|
| 703 |
-
|
| 704 |
-
|
| 705 |
-
|
| 706 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
--------------------------------
|
| 3 |
+
Infinite Scroll
|
| 4 |
+
--------------------------------
|
| 5 |
+
+ https://github.com/paulirish/infinite-scroll
|
| 6 |
+
+ version 2.0b2.120519
|
| 7 |
+
+ Copyright 2011/12 Paul Irish & Luke Shumard
|
| 8 |
+
+ Licensed under the MIT license
|
| 9 |
+
|
| 10 |
+
+ Documentation: http://infinite-scroll.com/
|
| 11 |
+
|
| 12 |
+
*/
|
| 13 |
+
|
| 14 |
+
(function (window, $, undefined) {
|
| 15 |
+
|
| 16 |
+
$.infinitescroll = function infscr(options, callback, element) {
|
| 17 |
+
|
| 18 |
+
this.element = $(element);
|
| 19 |
+
|
| 20 |
+
// Flag the object in the event of a failed creation
|
| 21 |
+
if (!this._create(options, callback)) {
|
| 22 |
+
this.failed = true;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
};
|
| 26 |
+
|
| 27 |
+
$.infinitescroll.defaults = {
|
| 28 |
+
loading: {
|
| 29 |
+
finished: undefined,
|
| 30 |
+
finishedMsg: "<em>Congratulations, you've reached the end of the internet.</em>",
|
| 31 |
+
img: "http://www.infinite-scroll.com/loading.gif",
|
| 32 |
+
msg: null,
|
| 33 |
+
msgText: "<em>Loading the next set of posts...</em>",
|
| 34 |
+
selector: null,
|
| 35 |
+
speed: 'fast',
|
| 36 |
+
start: undefined
|
| 37 |
+
},
|
| 38 |
+
state: {
|
| 39 |
+
isDuringAjax: false,
|
| 40 |
+
isInvalidPage: false,
|
| 41 |
+
isDestroyed: false,
|
| 42 |
+
isDone: false, // For when it goes all the way through the archive.
|
| 43 |
+
isPaused: false,
|
| 44 |
+
currPage: 1
|
| 45 |
+
},
|
| 46 |
+
callback: undefined,
|
| 47 |
+
debug: false,
|
| 48 |
+
behavior: undefined,
|
| 49 |
+
binder: $(window), // used to cache the selector
|
| 50 |
+
nextSelector: "div.navigation a:first",
|
| 51 |
+
navSelector: "div.navigation",
|
| 52 |
+
contentSelector: null, // rename to pageFragment
|
| 53 |
+
extraScrollPx: 150,
|
| 54 |
+
itemSelector: "div.post",
|
| 55 |
+
animate: false,
|
| 56 |
+
pathParse: undefined,
|
| 57 |
+
dataType: 'html',
|
| 58 |
+
appendCallback: true,
|
| 59 |
+
bufferPx: 40,
|
| 60 |
+
errorCallback: function () { },
|
| 61 |
+
infid: 0, //Instance ID
|
| 62 |
+
pixelsFromNavToBottom: undefined,
|
| 63 |
+
path: undefined
|
| 64 |
+
};
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
$.infinitescroll.prototype = {
|
| 68 |
+
|
| 69 |
+
/*
|
| 70 |
+
----------------------------
|
| 71 |
+
Private methods
|
| 72 |
+
----------------------------
|
| 73 |
+
*/
|
| 74 |
+
|
| 75 |
+
// Bind or unbind from scroll
|
| 76 |
+
_binding: function infscr_binding(binding) {
|
| 77 |
+
|
| 78 |
+
var instance = this,
|
| 79 |
+
opts = instance.options;
|
| 80 |
+
|
| 81 |
+
opts.v = '2.0b2.111027';
|
| 82 |
+
|
| 83 |
+
// if behavior is defined and this function is extended, call that instead of default
|
| 84 |
+
if (!!opts.behavior && this['_binding_'+opts.behavior] !== undefined) {
|
| 85 |
+
this['_binding_'+opts.behavior].call(this);
|
| 86 |
+
return;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
if (binding !== 'bind' && binding !== 'unbind') {
|
| 90 |
+
this._debug('Binding value ' + binding + ' not valid')
|
| 91 |
+
return false;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
if (binding == 'unbind') {
|
| 95 |
+
|
| 96 |
+
(this.options.binder).unbind('smartscroll.infscr.' + instance.options.infid);
|
| 97 |
+
|
| 98 |
+
} else {
|
| 99 |
+
|
| 100 |
+
(this.options.binder)[binding]('smartscroll.infscr.' + instance.options.infid, function () {
|
| 101 |
+
instance.scroll();
|
| 102 |
+
});
|
| 103 |
+
|
| 104 |
+
};
|
| 105 |
+
|
| 106 |
+
this._debug('Binding', binding);
|
| 107 |
+
|
| 108 |
+
},
|
| 109 |
+
|
| 110 |
+
// Fundamental aspects of the plugin are initialized
|
| 111 |
+
_create: function infscr_create(options, callback) {
|
| 112 |
+
|
| 113 |
+
// Add custom options to defaults
|
| 114 |
+
var opts = $.extend(true, {}, $.infinitescroll.defaults, options);
|
| 115 |
+
|
| 116 |
+
// Validate selectors
|
| 117 |
+
if (!this._validate(options)) { return false; }
|
| 118 |
+
this.options = opts;
|
| 119 |
+
|
| 120 |
+
// Validate page fragment path
|
| 121 |
+
var path = $(opts.nextSelector).attr('href');
|
| 122 |
+
if (!path) {
|
| 123 |
+
this._debug('Navigation selector not found');
|
| 124 |
+
return false;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
// Set the path to be a relative URL from root.
|
| 128 |
+
opts.path = this._determinepath(path);
|
| 129 |
+
|
| 130 |
+
// contentSelector is 'page fragment' option for .load() / .ajax() calls
|
| 131 |
+
opts.contentSelector = opts.contentSelector || this.element;
|
| 132 |
+
|
| 133 |
+
// loading.selector - if we want to place the load message in a specific selector, defaulted to the contentSelector
|
| 134 |
+
opts.loading.selector = opts.loading.selector || opts.contentSelector;
|
| 135 |
+
|
| 136 |
+
// Define loading.msg
|
| 137 |
+
opts.loading.msg = $('<div id="infscr-loading"><img alt="Loading..." src="' + opts.loading.img + '" /><div>' + opts.loading.msgText + '</div></div>');
|
| 138 |
+
|
| 139 |
+
// Preload loading.img
|
| 140 |
+
(new Image()).src = opts.loading.img;
|
| 141 |
+
|
| 142 |
+
// distance from nav links to bottom
|
| 143 |
+
// computed as: height of the document + top offset of container - top offset of nav link
|
| 144 |
+
opts.pixelsFromNavToBottom = $(document).height() - $(opts.navSelector).offset().top;
|
| 145 |
+
|
| 146 |
+
// determine loading.start actions
|
| 147 |
+
opts.loading.start = opts.loading.start || function() {
|
| 148 |
+
|
| 149 |
+
$(opts.navSelector).hide();
|
| 150 |
+
opts.loading.msg
|
| 151 |
+
.appendTo(opts.loading.selector)
|
| 152 |
+
.show(opts.loading.speed, function () {
|
| 153 |
+
beginAjax(opts);
|
| 154 |
+
});
|
| 155 |
+
};
|
| 156 |
+
|
| 157 |
+
// determine loading.finished actions
|
| 158 |
+
opts.loading.finished = opts.loading.finished || function() {
|
| 159 |
+
opts.loading.msg.fadeOut('normal');
|
| 160 |
+
};
|
| 161 |
+
|
| 162 |
+
// callback loading
|
| 163 |
+
opts.callback = function(instance,data) {
|
| 164 |
+
if (!!opts.behavior && instance['_callback_'+opts.behavior] !== undefined) {
|
| 165 |
+
instance['_callback_'+opts.behavior].call($(opts.contentSelector)[0], data);
|
| 166 |
+
}
|
| 167 |
+
if (callback) {
|
| 168 |
+
callback.call($(opts.contentSelector)[0], data, opts);
|
| 169 |
+
}
|
| 170 |
+
};
|
| 171 |
+
|
| 172 |
+
this._setup();
|
| 173 |
+
|
| 174 |
+
// Return true to indicate successful creation
|
| 175 |
+
return true;
|
| 176 |
+
},
|
| 177 |
+
|
| 178 |
+
// Console log wrapper
|
| 179 |
+
_debug: function infscr_debug() {
|
| 180 |
+
|
| 181 |
+
if (this.options && this.options.debug) {
|
| 182 |
+
return window.console && console.log.call(console, arguments);
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
},
|
| 186 |
+
|
| 187 |
+
// find the number to increment in the path.
|
| 188 |
+
_determinepath: function infscr_determinepath(path) {
|
| 189 |
+
|
| 190 |
+
var opts = this.options;
|
| 191 |
+
|
| 192 |
+
// if behavior is defined and this function is extended, call that instead of default
|
| 193 |
+
if (!!opts.behavior && this['_determinepath_'+opts.behavior] !== undefined) {
|
| 194 |
+
this['_determinepath_'+opts.behavior].call(this,path);
|
| 195 |
+
return;
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
if (!!opts.pathParse) {
|
| 199 |
+
|
| 200 |
+
this._debug('pathParse manual');
|
| 201 |
+
return opts.pathParse(path, this.options.state.currPage+1);
|
| 202 |
+
|
| 203 |
+
} else if (path.match(/^(.*?)\b2\b(.*?$)/)) {
|
| 204 |
+
path = path.match(/^(.*?)\b2\b(.*?$)/).slice(1);
|
| 205 |
+
|
| 206 |
+
// if there is any 2 in the url at all.
|
| 207 |
+
} else if (path.match(/^(.*?)2(.*?$)/)) {
|
| 208 |
+
|
| 209 |
+
// page= is used in django:
|
| 210 |
+
// http://www.infinite-scroll.com/changelog/comment-page-1/#comment-127
|
| 211 |
+
if (path.match(/^(.*?page=)2(\/.*|$)/)) {
|
| 212 |
+
path = path.match(/^(.*?page=)2(\/.*|$)/).slice(1);
|
| 213 |
+
return path;
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
path = path.match(/^(.*?)2(.*?$)/).slice(1);
|
| 217 |
+
|
| 218 |
+
} else {
|
| 219 |
+
|
| 220 |
+
// page= is used in drupal too but second page is page=1 not page=2:
|
| 221 |
+
// thx Jerod Fritz, vladikoff
|
| 222 |
+
if (path.match(/^(.*?page=)1(\/.*|$)/)) {
|
| 223 |
+
path = path.match(/^(.*?page=)1(\/.*|$)/).slice(1);
|
| 224 |
+
return path;
|
| 225 |
+
} else {
|
| 226 |
+
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.');
|
| 227 |
+
// Get rid of isInvalidPage to allow permalink to state
|
| 228 |
+
opts.state.isInvalidPage = true; //prevent it from running on this page.
|
| 229 |
+
}
|
| 230 |
+
}
|
| 231 |
+
this._debug('determinePath', path);
|
| 232 |
+
return path;
|
| 233 |
+
|
| 234 |
+
},
|
| 235 |
+
|
| 236 |
+
// Custom error
|
| 237 |
+
_error: function infscr_error(xhr) {
|
| 238 |
+
|
| 239 |
+
var opts = this.options;
|
| 240 |
+
|
| 241 |
+
// if behavior is defined and this function is extended, call that instead of default
|
| 242 |
+
if (!!opts.behavior && this['_error_'+opts.behavior] !== undefined) {
|
| 243 |
+
this['_error_'+opts.behavior].call(this,xhr);
|
| 244 |
+
return;
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
if (xhr !== 'destroy' && xhr !== 'end') {
|
| 248 |
+
xhr = 'unknown';
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
this._debug('Error', xhr);
|
| 252 |
+
|
| 253 |
+
if (xhr == 'end') {
|
| 254 |
+
this._showdonemsg();
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
opts.state.isDone = true;
|
| 258 |
+
opts.state.currPage = 1; // if you need to go back to this instance
|
| 259 |
+
opts.state.isPaused = false;
|
| 260 |
+
this._binding('unbind');
|
| 261 |
+
|
| 262 |
+
},
|
| 263 |
+
|
| 264 |
+
// Load Callback
|
| 265 |
+
_loadcallback: function infscr_loadcallback(box, data) {
|
| 266 |
+
|
| 267 |
+
var opts = this.options,
|
| 268 |
+
callback = this.options.callback, // GLOBAL OBJECT FOR CALLBACK
|
| 269 |
+
result = (opts.state.isDone) ? 'done' : (!opts.appendCallback) ? 'no-append' : 'append',
|
| 270 |
+
frag;
|
| 271 |
+
|
| 272 |
+
// if behavior is defined and this function is extended, call that instead of default
|
| 273 |
+
if (!!opts.behavior && this['_loadcallback_'+opts.behavior] !== undefined) {
|
| 274 |
+
this['_loadcallback_'+opts.behavior].call(this,box,data);
|
| 275 |
+
return;
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
switch (result) {
|
| 279 |
+
|
| 280 |
+
case 'done':
|
| 281 |
+
|
| 282 |
+
this._showdonemsg();
|
| 283 |
+
return false;
|
| 284 |
+
|
| 285 |
+
break;
|
| 286 |
+
|
| 287 |
+
case 'no-append':
|
| 288 |
+
|
| 289 |
+
if (opts.dataType == 'html') {
|
| 290 |
+
data = '<div>' + data + '</div>';
|
| 291 |
+
data = $(data).find(opts.itemSelector);
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
break;
|
| 295 |
+
|
| 296 |
+
case 'append':
|
| 297 |
+
|
| 298 |
+
var children = box.children();
|
| 299 |
+
|
| 300 |
+
// if it didn't return anything
|
| 301 |
+
if (children.length == 0) {
|
| 302 |
+
return this._error('end');
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
|
| 306 |
+
// use a documentFragment because it works when content is going into a table or UL
|
| 307 |
+
frag = document.createDocumentFragment();
|
| 308 |
+
while (box[0].firstChild) {
|
| 309 |
+
frag.appendChild(box[0].firstChild);
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
this._debug('contentSelector', $(opts.contentSelector)[0])
|
| 313 |
+
$(opts.contentSelector)[0].appendChild(frag);
|
| 314 |
+
// previously, we would pass in the new DOM element as context for the callback
|
| 315 |
+
// however we're now using a documentfragment, which doesnt havent parents or children,
|
| 316 |
+
// so the context is the contentContainer guy, and we pass in an array
|
| 317 |
+
// of the elements collected as the first argument.
|
| 318 |
+
|
| 319 |
+
data = children.get();
|
| 320 |
+
|
| 321 |
+
|
| 322 |
+
break;
|
| 323 |
+
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
// loadingEnd function
|
| 327 |
+
opts.loading.finished.call($(opts.contentSelector)[0],opts)
|
| 328 |
+
|
| 329 |
+
|
| 330 |
+
// smooth scroll to ease in the new content
|
| 331 |
+
if (opts.animate) {
|
| 332 |
+
var scrollTo = $(window).scrollTop() + $('#infscr-loading').height() + opts.extraScrollPx + 'px';
|
| 333 |
+
$('html,body').animate({ scrollTop: scrollTo }, 800, function () { opts.state.isDuringAjax = false; });
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
if (!opts.animate) opts.state.isDuringAjax = false; // once the call is done, we can allow it again.
|
| 337 |
+
|
| 338 |
+
callback(this,data);
|
| 339 |
+
|
| 340 |
+
},
|
| 341 |
+
|
| 342 |
+
_nearbottom: function infscr_nearbottom() {
|
| 343 |
+
|
| 344 |
+
var opts = this.options,
|
| 345 |
+
pixelsFromWindowBottomToBottom = 0 + $(document).height() - (opts.binder.scrollTop()) - $(window).height();
|
| 346 |
+
|
| 347 |
+
// if behavior is defined and this function is extended, call that instead of default
|
| 348 |
+
if (!!opts.behavior && this['_nearbottom_'+opts.behavior] !== undefined) {
|
| 349 |
+
return this['_nearbottom_'+opts.behavior].call(this);
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
this._debug('math:', pixelsFromWindowBottomToBottom, opts.pixelsFromNavToBottom);
|
| 353 |
+
|
| 354 |
+
// if distance remaining in the scroll (including buffer) is less than the orignal nav to bottom....
|
| 355 |
+
return (pixelsFromWindowBottomToBottom - opts.bufferPx < opts.pixelsFromNavToBottom);
|
| 356 |
+
|
| 357 |
+
},
|
| 358 |
+
|
| 359 |
+
// Pause / temporarily disable plugin from firing
|
| 360 |
+
_pausing: function infscr_pausing(pause) {
|
| 361 |
+
|
| 362 |
+
var opts = this.options;
|
| 363 |
+
|
| 364 |
+
// if behavior is defined and this function is extended, call that instead of default
|
| 365 |
+
if (!!opts.behavior && this['_pausing_'+opts.behavior] !== undefined) {
|
| 366 |
+
this['_pausing_'+opts.behavior].call(this,pause);
|
| 367 |
+
return;
|
| 368 |
+
}
|
| 369 |
+
|
| 370 |
+
// If pause is not 'pause' or 'resume', toggle it's value
|
| 371 |
+
if (pause !== 'pause' && pause !== 'resume' && pause !== null) {
|
| 372 |
+
this._debug('Invalid argument. Toggling pause value instead');
|
| 373 |
+
};
|
| 374 |
+
|
| 375 |
+
pause = (pause && (pause == 'pause' || pause == 'resume')) ? pause : 'toggle';
|
| 376 |
+
|
| 377 |
+
switch (pause) {
|
| 378 |
+
case 'pause':
|
| 379 |
+
opts.state.isPaused = true;
|
| 380 |
+
break;
|
| 381 |
+
|
| 382 |
+
case 'resume':
|
| 383 |
+
opts.state.isPaused = false;
|
| 384 |
+
break;
|
| 385 |
+
|
| 386 |
+
case 'toggle':
|
| 387 |
+
opts.state.isPaused = !opts.state.isPaused;
|
| 388 |
+
break;
|
| 389 |
+
}
|
| 390 |
+
|
| 391 |
+
this._debug('Paused', opts.state.isPaused);
|
| 392 |
+
return false;
|
| 393 |
+
|
| 394 |
+
},
|
| 395 |
+
|
| 396 |
+
// Behavior is determined
|
| 397 |
+
// If the behavior option is undefined, it will set to default and bind to scroll
|
| 398 |
+
_setup: function infscr_setup() {
|
| 399 |
+
|
| 400 |
+
var opts = this.options;
|
| 401 |
+
|
| 402 |
+
// if behavior is defined and this function is extended, call that instead of default
|
| 403 |
+
if (!!opts.behavior && this['_setup_'+opts.behavior] !== undefined) {
|
| 404 |
+
this['_setup_'+opts.behavior].call(this);
|
| 405 |
+
return;
|
| 406 |
+
}
|
| 407 |
+
|
| 408 |
+
this._binding('bind');
|
| 409 |
+
|
| 410 |
+
return false;
|
| 411 |
+
|
| 412 |
+
},
|
| 413 |
+
|
| 414 |
+
// Show done message
|
| 415 |
+
_showdonemsg: function infscr_showdonemsg() {
|
| 416 |
+
|
| 417 |
+
var opts = this.options;
|
| 418 |
+
|
| 419 |
+
// if behavior is defined and this function is extended, call that instead of default
|
| 420 |
+
if (!!opts.behavior && this['_showdonemsg_'+opts.behavior] !== undefined) {
|
| 421 |
+
this['_showdonemsg_'+opts.behavior].call(this);
|
| 422 |
+
return;
|
| 423 |
+
}
|
| 424 |
+
|
| 425 |
+
opts.loading.msg
|
| 426 |
+
.find('img')
|
| 427 |
+
.hide()
|
| 428 |
+
.parent()
|
| 429 |
+
.find('div').html(opts.loading.finishedMsg).animate({ opacity: 1 }, 2000, function () {
|
| 430 |
+
$(this).parent().fadeOut('normal');
|
| 431 |
+
});
|
| 432 |
+
|
| 433 |
+
// user provided callback when done
|
| 434 |
+
opts.errorCallback.call($(opts.contentSelector)[0],'done');
|
| 435 |
+
|
| 436 |
+
},
|
| 437 |
+
|
| 438 |
+
// grab each selector option and see if any fail
|
| 439 |
+
_validate: function infscr_validate(opts) {
|
| 440 |
+
|
| 441 |
+
for (var key in opts) {
|
| 442 |
+
if (key.indexOf && key.indexOf('Selector') > -1 && $(opts[key]).length === 0) {
|
| 443 |
+
this._debug('Your ' + key + ' found no elements.');
|
| 444 |
+
return false;
|
| 445 |
+
}
|
| 446 |
+
}
|
| 447 |
+
|
| 448 |
+
return true;
|
| 449 |
+
|
| 450 |
+
},
|
| 451 |
+
|
| 452 |
+
/*
|
| 453 |
+
----------------------------
|
| 454 |
+
Public methods
|
| 455 |
+
----------------------------
|
| 456 |
+
*/
|
| 457 |
+
|
| 458 |
+
// Bind to scroll
|
| 459 |
+
bind: function infscr_bind() {
|
| 460 |
+
this._binding('bind');
|
| 461 |
+
},
|
| 462 |
+
|
| 463 |
+
// Destroy current instance of plugin
|
| 464 |
+
destroy: function infscr_destroy() {
|
| 465 |
+
|
| 466 |
+
this.options.state.isDestroyed = true;
|
| 467 |
+
return this._error('destroy');
|
| 468 |
+
|
| 469 |
+
},
|
| 470 |
+
|
| 471 |
+
// Set pause value to false
|
| 472 |
+
pause: function infscr_pause() {
|
| 473 |
+
this._pausing('pause');
|
| 474 |
+
},
|
| 475 |
+
|
| 476 |
+
// Set pause value to false
|
| 477 |
+
resume: function infscr_resume() {
|
| 478 |
+
this._pausing('resume');
|
| 479 |
+
},
|
| 480 |
+
|
| 481 |
+
// Retrieve next set of content items
|
| 482 |
+
retrieve: function infscr_retrieve(pageNum) {
|
| 483 |
+
|
| 484 |
+
var instance = this,
|
| 485 |
+
opts = instance.options,
|
| 486 |
+
path = opts.path,
|
| 487 |
+
box, frag, desturl, method, condition,
|
| 488 |
+
pageNum = pageNum || null,
|
| 489 |
+
getPage = (!!pageNum) ? pageNum : opts.state.currPage;
|
| 490 |
+
beginAjax = function infscr_ajax(opts) {
|
| 491 |
+
|
| 492 |
+
// increment the URL bit. e.g. /page/3/
|
| 493 |
+
opts.state.currPage++;
|
| 494 |
+
|
| 495 |
+
instance._debug('heading into ajax', path);
|
| 496 |
+
|
| 497 |
+
// if we're dealing with a table we can't use DIVs
|
| 498 |
+
box = $(opts.contentSelector).is('table') ? $('<tbody/>') : $('<div/>');
|
| 499 |
+
|
| 500 |
+
desturl = path.join(opts.state.currPage);
|
| 501 |
+
|
| 502 |
+
method = (opts.dataType == 'html' || opts.dataType == 'json' ) ? opts.dataType : 'html+callback';
|
| 503 |
+
if (opts.appendCallback && opts.dataType == 'html') method += '+callback'
|
| 504 |
+
|
| 505 |
+
switch (method) {
|
| 506 |
+
|
| 507 |
+
case 'html+callback':
|
| 508 |
+
|
| 509 |
+
instance._debug('Using HTML via .load() method');
|
| 510 |
+
box.load(desturl + ' ' + opts.itemSelector, null, function infscr_ajax_callback(responseText) {
|
| 511 |
+
instance._loadcallback(box, responseText);
|
| 512 |
+
});
|
| 513 |
+
|
| 514 |
+
break;
|
| 515 |
+
|
| 516 |
+
case 'html':
|
| 517 |
+
instance._debug('Using ' + (method.toUpperCase()) + ' via $.ajax() method');
|
| 518 |
+
$.ajax({
|
| 519 |
+
// params
|
| 520 |
+
url: desturl,
|
| 521 |
+
dataType: opts.dataType,
|
| 522 |
+
complete: function infscr_ajax_callback(jqXHR, textStatus) {
|
| 523 |
+
condition = (typeof (jqXHR.isResolved) !== 'undefined') ? (jqXHR.isResolved()) : (textStatus === "success" || textStatus === "notmodified");
|
| 524 |
+
(condition) ? instance._loadcallback(box, jqXHR.responseText) : instance._error('end');
|
| 525 |
+
}
|
| 526 |
+
});
|
| 527 |
+
|
| 528 |
+
break;
|
| 529 |
+
case 'json':
|
| 530 |
+
instance._debug('Using ' + (method.toUpperCase()) + ' via $.ajax() method');
|
| 531 |
+
$.ajax({
|
| 532 |
+
dataType: 'json',
|
| 533 |
+
type: 'GET',
|
| 534 |
+
url: desturl,
|
| 535 |
+
success: function(data, textStatus, jqXHR) {
|
| 536 |
+
condition = (typeof (jqXHR.isResolved) !== 'undefined') ? (jqXHR.isResolved()) : (textStatus === "success" || textStatus === "notmodified");
|
| 537 |
+
if(opts.appendCallback) {
|
| 538 |
+
// if appendCallback is true, you must defined template in options.
|
| 539 |
+
// note that data passed into _loadcallback is already an html (after processed in opts.template(data)).
|
| 540 |
+
if(opts.template != undefined) {
|
| 541 |
+
var theData = opts.template(data);
|
| 542 |
+
box.append(theData);
|
| 543 |
+
(condition) ? instance._loadcallback(box, theData) : instance._error('end');
|
| 544 |
+
} else {
|
| 545 |
+
instance._debug("template must be defined.");
|
| 546 |
+
instance._error('end');
|
| 547 |
+
}
|
| 548 |
+
} else {
|
| 549 |
+
// if appendCallback is false, we will pass in the JSON object. you should handle it yourself in your callback.
|
| 550 |
+
(condition) ? instance._loadcallback(box, data) : instance._error('end');
|
| 551 |
+
}
|
| 552 |
+
},
|
| 553 |
+
error: function(jqXHR, textStatus, errorThrown) {
|
| 554 |
+
instance._debug("JSON ajax request failed.");
|
| 555 |
+
instance._error('end');
|
| 556 |
+
}
|
| 557 |
+
});
|
| 558 |
+
|
| 559 |
+
break;
|
| 560 |
+
}
|
| 561 |
+
};
|
| 562 |
+
|
| 563 |
+
// if behavior is defined and this function is extended, call that instead of default
|
| 564 |
+
if (!!opts.behavior && this['retrieve_'+opts.behavior] !== undefined) {
|
| 565 |
+
this['retrieve_'+opts.behavior].call(this,pageNum);
|
| 566 |
+
return;
|
| 567 |
+
}
|
| 568 |
+
|
| 569 |
+
|
| 570 |
+
// for manual triggers, if destroyed, get out of here
|
| 571 |
+
if (opts.state.isDestroyed) {
|
| 572 |
+
this._debug('Instance is destroyed');
|
| 573 |
+
return false;
|
| 574 |
+
};
|
| 575 |
+
|
| 576 |
+
// we dont want to fire the ajax multiple times
|
| 577 |
+
opts.state.isDuringAjax = true;
|
| 578 |
+
|
| 579 |
+
opts.loading.start.call($(opts.contentSelector)[0],opts);
|
| 580 |
+
|
| 581 |
+
},
|
| 582 |
+
|
| 583 |
+
// Check to see next page is needed
|
| 584 |
+
scroll: function infscr_scroll() {
|
| 585 |
+
|
| 586 |
+
var opts = this.options,
|
| 587 |
+
state = opts.state;
|
| 588 |
+
|
| 589 |
+
// if behavior is defined and this function is extended, call that instead of default
|
| 590 |
+
if (!!opts.behavior && this['scroll_'+opts.behavior] !== undefined) {
|
| 591 |
+
this['scroll_'+opts.behavior].call(this);
|
| 592 |
+
return;
|
| 593 |
+
}
|
| 594 |
+
|
| 595 |
+
if (state.isDuringAjax || state.isInvalidPage || state.isDone || state.isDestroyed || state.isPaused) return;
|
| 596 |
+
|
| 597 |
+
if (!this._nearbottom()) return;
|
| 598 |
+
|
| 599 |
+
this.retrieve();
|
| 600 |
+
|
| 601 |
+
},
|
| 602 |
+
|
| 603 |
+
// Toggle pause value
|
| 604 |
+
toggle: function infscr_toggle() {
|
| 605 |
+
this._pausing();
|
| 606 |
+
},
|
| 607 |
+
|
| 608 |
+
// Unbind from scroll
|
| 609 |
+
unbind: function infscr_unbind() {
|
| 610 |
+
this._binding('unbind');
|
| 611 |
+
},
|
| 612 |
+
|
| 613 |
+
// update options
|
| 614 |
+
update: function infscr_options(key) {
|
| 615 |
+
if ($.isPlainObject(key)) {
|
| 616 |
+
this.options = $.extend(true,this.options,key);
|
| 617 |
+
}
|
| 618 |
+
}
|
| 619 |
+
|
| 620 |
+
}
|
| 621 |
+
|
| 622 |
+
|
| 623 |
+
/*
|
| 624 |
+
----------------------------
|
| 625 |
+
Infinite Scroll function
|
| 626 |
+
----------------------------
|
| 627 |
+
|
| 628 |
+
Borrowed logic from the following...
|
| 629 |
+
|
| 630 |
+
jQuery UI
|
| 631 |
+
- https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.widget.js
|
| 632 |
+
|
| 633 |
+
jCarousel
|
| 634 |
+
- https://github.com/jsor/jcarousel/blob/master/lib/jquery.jcarousel.js
|
| 635 |
+
|
| 636 |
+
Masonry
|
| 637 |
+
- https://github.com/desandro/masonry/blob/master/jquery.masonry.js
|
| 638 |
+
|
| 639 |
+
*/
|
| 640 |
+
|
| 641 |
+
$.fn.infinitescroll = function infscr_init(options, callback) {
|
| 642 |
+
|
| 643 |
+
|
| 644 |
+
var thisCall = typeof options;
|
| 645 |
+
|
| 646 |
+
switch (thisCall) {
|
| 647 |
+
|
| 648 |
+
// method
|
| 649 |
+
case 'string':
|
| 650 |
+
|
| 651 |
+
var args = Array.prototype.slice.call(arguments, 1);
|
| 652 |
+
|
| 653 |
+
this.each(function () {
|
| 654 |
+
|
| 655 |
+
var instance = $.data(this, 'infinitescroll');
|
| 656 |
+
|
| 657 |
+
if (!instance) {
|
| 658 |
+
// not setup yet
|
| 659 |
+
// return $.error('Method ' + options + ' cannot be called until Infinite Scroll is setup');
|
| 660 |
+
return false;
|
| 661 |
+
}
|
| 662 |
+
if (!$.isFunction(instance[options]) || options.charAt(0) === "_") {
|
| 663 |
+
// return $.error('No such method ' + options + ' for Infinite Scroll');
|
| 664 |
+
return false;
|
| 665 |
+
}
|
| 666 |
+
|
| 667 |
+
// no errors!
|
| 668 |
+
instance[options].apply(instance, args);
|
| 669 |
+
|
| 670 |
+
});
|
| 671 |
+
|
| 672 |
+
break;
|
| 673 |
+
|
| 674 |
+
// creation
|
| 675 |
+
case 'object':
|
| 676 |
+
|
| 677 |
+
this.each(function () {
|
| 678 |
+
|
| 679 |
+
var instance = $.data(this, 'infinitescroll');
|
| 680 |
+
|
| 681 |
+
if (instance) {
|
| 682 |
+
|
| 683 |
+
// update options of current instance
|
| 684 |
+
instance.update(options);
|
| 685 |
+
|
| 686 |
+
} else {
|
| 687 |
+
|
| 688 |
+
// initialize new instance
|
| 689 |
+
instance = new $.infinitescroll(options, callback, this);
|
| 690 |
+
|
| 691 |
+
// don't attach if instantiation failed
|
| 692 |
+
if (!instance.failed) {
|
| 693 |
+
$.data(this, 'infinitescroll', instance);
|
| 694 |
+
}
|
| 695 |
+
|
| 696 |
+
}
|
| 697 |
+
|
| 698 |
+
});
|
| 699 |
+
|
| 700 |
+
break;
|
| 701 |
+
|
| 702 |
+
}
|
| 703 |
+
|
| 704 |
+
return this;
|
| 705 |
+
|
| 706 |
+
};
|
| 707 |
+
|
| 708 |
+
|
| 709 |
+
|
| 710 |
+
/*
|
| 711 |
+
* smartscroll: debounced scroll event for jQuery *
|
| 712 |
+
* https://github.com/lukeshumard/smartscroll
|
| 713 |
+
* Based on smartresize by @louis_remi: https://github.com/lrbabe/jquery.smartresize.js *
|
| 714 |
+
* Copyright 2011 Louis-Remi & Luke Shumard * Licensed under the MIT license. *
|
| 715 |
+
*/
|
| 716 |
+
|
| 717 |
+
var event = $.event,
|
| 718 |
+
scrollTimeout;
|
| 719 |
+
|
| 720 |
+
event.special.smartscroll = {
|
| 721 |
+
setup: function () {
|
| 722 |
+
$(this).bind("scroll", event.special.smartscroll.handler);
|
| 723 |
+
},
|
| 724 |
+
teardown: function () {
|
| 725 |
+
$(this).unbind("scroll", event.special.smartscroll.handler);
|
| 726 |
+
},
|
| 727 |
+
handler: function (event, execAsap) {
|
| 728 |
+
// Save the context
|
| 729 |
+
var context = this,
|
| 730 |
+
args = arguments;
|
| 731 |
+
|
| 732 |
+
// set correct event type
|
| 733 |
+
event.type = "smartscroll";
|
| 734 |
+
|
| 735 |
+
if (scrollTimeout) { clearTimeout(scrollTimeout); }
|
| 736 |
+
scrollTimeout = setTimeout(function () {
|
| 737 |
+
$.event.handle.apply(context, args);
|
| 738 |
+
}, execAsap === "execAsap" ? 0 : 100);
|
| 739 |
+
}
|
| 740 |
+
};
|
| 741 |
+
|
| 742 |
+
$.fn.smartscroll = function (fn) {
|
| 743 |
+
return fn ? this.bind("smartscroll", fn) : this.trigger("smartscroll", ["execAsap"]);
|
| 744 |
+
};
|
| 745 |
+
|
| 746 |
+
|
| 747 |
+
})(window, jQuery);
|
js/jquery/infinitescroll2/jquery.infinitescroll.min.js
CHANGED
|
@@ -1,47 +1,31 @@
|
|
| 1 |
-
/*
|
| 2 |
-
--------------------------------
|
| 3 |
-
Infinite Scroll
|
| 4 |
-
--------------------------------
|
| 5 |
-
+ https://github.com/paulirish/
|
| 6 |
-
+ version 2.0b2.
|
| 7 |
-
+ Copyright 2011 Paul Irish & Luke Shumard
|
| 8 |
-
+ Licensed under the MIT license
|
| 9 |
-
|
| 10 |
-
+ Documentation: http://infinite-scroll.com/
|
| 11 |
-
|
| 12 |
-
*/
|
| 13 |
-
|
| 14 |
-
(function(
|
| 15 |
-
if(
|
| 16 |
-
return
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
this._debug(
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
this.
|
| 30 |
-
|
| 31 |
-
|
| 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;}
|
| 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;}
|
| 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;}
|
| 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;}
|
| 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'
|
| 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;}
|
| 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);}}}
|
| 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;}
|
| 44 |
-
if(!$.isFunction(instance[options])||options.charAt(0)==="_"){return false;}
|
| 45 |
-
instance[options].apply(instance,args);});break;case'object':this.each(function(){var instance=$.data(this,'infinitescroll');if(instance){instance.update(options);}else{$.data(this,'infinitescroll',new $.infinitescroll(options,callback,this));}});break;}
|
| 46 |
-
return this;};var event=$.event,scrollTimeout;event.special.smartscroll={setup:function(){$(this).bind("scroll",event.special.smartscroll.handler);},teardown:function(){$(this).unbind("scroll",event.special.smartscroll.handler);},handler:function(event,execAsap){var context=this,args=arguments;event.type="smartscroll";if(scrollTimeout){clearTimeout(scrollTimeout);}
|
| 47 |
-
scrollTimeout=setTimeout(function(){$.event.handle.apply(context,args);},execAsap==="execAsap"?0:100);}};$.fn.smartscroll=function(fn){return fn?this.bind("smartscroll",fn):this.trigger("smartscroll",["execAsap"]);};})(window,jQuery);
|
| 1 |
+
/*
|
| 2 |
+
--------------------------------
|
| 3 |
+
Infinite Scroll
|
| 4 |
+
--------------------------------
|
| 5 |
+
+ https://github.com/paulirish/infinite-scroll
|
| 6 |
+
+ version 2.0b2.120519
|
| 7 |
+
+ Copyright 2011/12 Paul Irish & Luke Shumard
|
| 8 |
+
+ Licensed under the MIT license
|
| 9 |
+
|
| 10 |
+
+ Documentation: http://infinite-scroll.com/
|
| 11 |
+
|
| 12 |
+
*/
|
| 13 |
+
|
| 14 |
+
(function(h,d,e){d.infinitescroll=function(a,c,b){this.element=d(b);this._create(a,c)||(this.failed=!0)};d.infinitescroll.defaults={loading:{finished:e,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:e},state:{isDuringAjax:!1,isInvalidPage:!1,isDestroyed:!1,isDone:!1,isPaused:!1,currPage:1},callback:e,debug:!1,behavior:e,binder:d(h),
|
| 15 |
+
nextSelector:"div.navigation a:first",navSelector:"div.navigation",contentSelector:null,extraScrollPx:150,itemSelector:"div.post",animate:!1,pathParse:e,dataType:"html",appendCallback:!0,bufferPx:40,errorCallback:function(){},infid:0,pixelsFromNavToBottom:e,path:e};d.infinitescroll.prototype={_binding:function(a){var c=this,b=c.options;b.v="2.0b2.111027";if(b.behavior&&this["_binding_"+b.behavior]!==e)this["_binding_"+b.behavior].call(this);else{if("bind"!==a&&"unbind"!==a)return this._debug("Binding value "+
|
| 16 |
+
a+" not valid"),!1;if("unbind"==a)this.options.binder.unbind("smartscroll.infscr."+c.options.infid);else this.options.binder[a]("smartscroll.infscr."+c.options.infid,function(){c.scroll()});this._debug("Binding",a)}},_create:function(a,c){var b=d.extend(!0,{},d.infinitescroll.defaults,a);if(!this._validate(a))return!1;this.options=b;var g=d(b.nextSelector).attr("href");if(!g)return this._debug("Navigation selector not found"),!1;b.path=this._determinepath(g);b.contentSelector=b.contentSelector||this.element;
|
| 17 |
+
b.loading.selector=b.loading.selector||b.contentSelector;b.loading.msg=d('<div id="infscr-loading"><img alt="Loading..." src="'+b.loading.img+'" /><div>'+b.loading.msgText+"</div></div>");(new Image).src=b.loading.img;b.pixelsFromNavToBottom=d(document).height()-d(b.navSelector).offset().top;b.loading.start=b.loading.start||function(){d(b.navSelector).hide();b.loading.msg.appendTo(b.loading.selector).show(b.loading.speed,function(){beginAjax(b)})};b.loading.finished=b.loading.finished||function(){b.loading.msg.fadeOut("normal")};
|
| 18 |
+
b.callback=function(a,g){b.behavior&&a["_callback_"+b.behavior]!==e&&a["_callback_"+b.behavior].call(d(b.contentSelector)[0],g);c&&c.call(d(b.contentSelector)[0],g,b)};this._setup();return!0},_debug:function(){if(this.options&&this.options.debug)return h.console&&console.log.call(console,arguments)},_determinepath:function(a){var c=this.options;if(c.behavior&&this["_determinepath_"+c.behavior]!==e)this["_determinepath_"+c.behavior].call(this,a);else{if(c.pathParse)return this._debug("pathParse manual"),
|
| 19 |
+
c.pathParse(a,this.options.state.currPage+1);if(a.match(/^(.*?)\b2\b(.*?$)/))a=a.match(/^(.*?)\b2\b(.*?$)/).slice(1);else if(a.match(/^(.*?)2(.*?$)/)){if(a.match(/^(.*?page=)2(\/.*|$)/))return a=a.match(/^(.*?page=)2(\/.*|$)/).slice(1);a=a.match(/^(.*?)2(.*?$)/).slice(1)}else{if(a.match(/^(.*?page=)1(\/.*|$)/))return a=a.match(/^(.*?page=)1(\/.*|$)/).slice(1);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.");
|
| 20 |
+
c.state.isInvalidPage=!0}this._debug("determinePath",a);return a}},_error:function(a){var c=this.options;c.behavior&&this["_error_"+c.behavior]!==e?this["_error_"+c.behavior].call(this,a):("destroy"!==a&&"end"!==a&&(a="unknown"),this._debug("Error",a),"end"==a&&this._showdonemsg(),c.state.isDone=!0,c.state.currPage=1,c.state.isPaused=!1,this._binding("unbind"))},_loadcallback:function(a,c){var b=this.options,g=this.options.callback,f=b.state.isDone?"done":!b.appendCallback?"no-append":"append";if(b.behavior&&
|
| 21 |
+
this["_loadcallback_"+b.behavior]!==e)this["_loadcallback_"+b.behavior].call(this,a,c);else{switch(f){case "done":return this._showdonemsg(),!1;case "no-append":"html"==b.dataType&&(c=d("<div>"+c+"</div>").find(b.itemSelector));break;case "append":var i=a.children();if(0==i.length)return this._error("end");for(f=document.createDocumentFragment();a[0].firstChild;)f.appendChild(a[0].firstChild);this._debug("contentSelector",d(b.contentSelector)[0]);d(b.contentSelector)[0].appendChild(f);c=i.get()}b.loading.finished.call(d(b.contentSelector)[0],
|
| 22 |
+
b);b.animate&&(f=d(h).scrollTop()+d("#infscr-loading").height()+b.extraScrollPx+"px",d("html,body").animate({scrollTop:f},800,function(){b.state.isDuringAjax=!1}));b.animate||(b.state.isDuringAjax=!1);g(this,c)}},_nearbottom:function(){var a=this.options,c=0+d(document).height()-a.binder.scrollTop()-d(h).height();if(a.behavior&&this["_nearbottom_"+a.behavior]!==e)return this["_nearbottom_"+a.behavior].call(this);this._debug("math:",c,a.pixelsFromNavToBottom);return c-a.bufferPx<a.pixelsFromNavToBottom},
|
| 23 |
+
_pausing:function(a){var c=this.options;if(c.behavior&&this["_pausing_"+c.behavior]!==e)this["_pausing_"+c.behavior].call(this,a);else{"pause"!==a&&("resume"!==a&&null!==a)&&this._debug("Invalid argument. Toggling pause value instead");switch(a&&("pause"==a||"resume"==a)?a:"toggle"){case "pause":c.state.isPaused=!0;break;case "resume":c.state.isPaused=!1;break;case "toggle":c.state.isPaused=!c.state.isPaused}this._debug("Paused",c.state.isPaused);return!1}},_setup:function(){var a=this.options;if(a.behavior&&
|
| 24 |
+
this["_setup_"+a.behavior]!==e)this["_setup_"+a.behavior].call(this);else return this._binding("bind"),!1},_showdonemsg:function(){var a=this.options;a.behavior&&this["_showdonemsg_"+a.behavior]!==e?this["_showdonemsg_"+a.behavior].call(this):(a.loading.msg.find("img").hide().parent().find("div").html(a.loading.finishedMsg).animate({opacity:1},2E3,function(){d(this).parent().fadeOut("normal")}),a.errorCallback.call(d(a.contentSelector)[0],"done"))},_validate:function(a){for(var c in a)if(c.indexOf&&
|
| 25 |
+
-1<c.indexOf("Selector")&&0===d(a[c]).length)return this._debug("Your "+c+" found no elements."),!1;return!0},bind:function(){this._binding("bind")},destroy:function(){this.options.state.isDestroyed=!0;return this._error("destroy")},pause:function(){this._pausing("pause")},resume:function(){this._pausing("resume")},retrieve:function(a){var c=this,b=c.options,g=b.path,f,i,j,h,a=a||null;beginAjax=function(a){a.state.currPage++;c._debug("heading into ajax",g);f=d(a.contentSelector).is("table")?d("<tbody/>"):
|
| 26 |
+
d("<div/>");i=g.join(a.state.currPage);j="html"==a.dataType||"json"==a.dataType?a.dataType:"html+callback";a.appendCallback&&"html"==a.dataType&&(j+="+callback");switch(j){case "html+callback":c._debug("Using HTML via .load() method");f.load(i+" "+a.itemSelector,null,function(a){c._loadcallback(f,a)});break;case "html":c._debug("Using "+j.toUpperCase()+" via $.ajax() method");d.ajax({url:i,dataType:a.dataType,complete:function(a,b){(h="undefined"!==typeof a.isResolved?a.isResolved():"success"===b||
|
| 27 |
+
"notmodified"===b)?c._loadcallback(f,a.responseText):c._error("end")}});break;case "json":c._debug("Using "+j.toUpperCase()+" via $.ajax() method"),d.ajax({dataType:"json",type:"GET",url:i,success:function(b,d,g){h="undefined"!==typeof g.isResolved?g.isResolved():"success"===d||"notmodified"===d;a.appendCallback?a.template!=e?(b=a.template(b),f.append(b),h?c._loadcallback(f,b):c._error("end")):(c._debug("template must be defined."),c._error("end")):h?c._loadcallback(f,b):c._error("end")},error:function(){c._debug("JSON ajax request failed.");
|
| 28 |
+
c._error("end")}})}};if(b.behavior&&this["retrieve_"+b.behavior]!==e)this["retrieve_"+b.behavior].call(this,a);else{if(b.state.isDestroyed)return this._debug("Instance is destroyed"),!1;b.state.isDuringAjax=!0;b.loading.start.call(d(b.contentSelector)[0],b)}},scroll:function(){var a=this.options,c=a.state;a.behavior&&this["scroll_"+a.behavior]!==e?this["scroll_"+a.behavior].call(this):!c.isDuringAjax&&!c.isInvalidPage&&!c.isDone&&!c.isDestroyed&&!c.isPaused&&this._nearbottom()&&this.retrieve()},toggle:function(){this._pausing()},
|
| 29 |
+
unbind:function(){this._binding("unbind")},update:function(a){d.isPlainObject(a)&&(this.options=d.extend(!0,this.options,a))}};d.fn.infinitescroll=function(a,c){switch(typeof a){case "string":var b=Array.prototype.slice.call(arguments,1);this.each(function(){var c=d.data(this,"infinitescroll");if(!c||!d.isFunction(c[a])||"_"===a.charAt(0))return!1;c[a].apply(c,b)});break;case "object":this.each(function(){var b=d.data(this,"infinitescroll");b?b.update(a):(b=new d.infinitescroll(a,c,this),b.failed||
|
| 30 |
+
d.data(this,"infinitescroll",b))})}return this};var k=d.event,l;k.special.smartscroll={setup:function(){d(this).bind("scroll",k.special.smartscroll.handler)},teardown:function(){d(this).unbind("scroll",k.special.smartscroll.handler)},handler:function(a,c){var b=this,e=arguments;a.type="smartscroll";l&&clearTimeout(l);l=setTimeout(function(){d.event.handle.apply(b,e)},"execAsap"===c?0:100)}};d.fn.smartscroll=function(a){return a?this.bind("smartscroll",a):this.trigger("smartscroll",["execAsap"])}})(window,
|
| 31 |
+
jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Strategery_InfiniteScroll2</name>
|
| 4 |
-
<version>2.1.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/afl-3.0.php">Academic Free License (AFL 3.0)</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -22,9 +22,9 @@ System / Configuration / Catalog / Infinite Scroll.</description>
|
|
| 22 |
<notes>Automatic load next page of current product list.
|
| 23 |
Support for Magento 1.3 up to 1.7</notes>
|
| 24 |
<authors><author><name>Damian Alberto Pastorini</name><user>auto-converted</user><email>damian.pastorini@usestrategery.com</email></author></authors>
|
| 25 |
-
<date>2012-07-
|
| 26 |
-
<time>
|
| 27 |
-
<contents><target name="mageetc"><dir name="modules"><file name="Strategery_Infinitescroll2.xml" hash="8724cb82b6d47b9996610029e302e5d4"/></dir></target><target name="magecommunity"><dir name="Strategery"><dir name="Infinitescroll2"><dir name="Helper"><file name="Data.php" hash="5690979b341d6877b80192ffebfb2a0b"/></dir><dir name="Model"><dir name="Catalog"><file name="Observer.php" hash="
|
| 28 |
<compatible/>
|
| 29 |
<dependencies/>
|
| 30 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Strategery_InfiniteScroll2</name>
|
| 4 |
+
<version>2.1.2</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/afl-3.0.php">Academic Free License (AFL 3.0)</license>
|
| 7 |
<channel>community</channel>
|
| 22 |
<notes>Automatic load next page of current product list.
|
| 23 |
Support for Magento 1.3 up to 1.7</notes>
|
| 24 |
<authors><author><name>Damian Alberto Pastorini</name><user>auto-converted</user><email>damian.pastorini@usestrategery.com</email></author></authors>
|
| 25 |
+
<date>2012-07-27</date>
|
| 26 |
+
<time>14:17:55</time>
|
| 27 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Strategery_Infinitescroll2.xml" hash="8724cb82b6d47b9996610029e302e5d4"/></dir></target><target name="magecommunity"><dir name="Strategery"><dir name="Infinitescroll2"><dir name="Helper"><file name="Data.php" hash="5690979b341d6877b80192ffebfb2a0b"/></dir><dir name="Model"><dir name="Catalog"><file name="Observer.php" hash="706b95a5db767f6d2c8a3c002804edeb"/></dir></dir><dir name="controllers"><file name="JsController.php" hash="3d97abe7a35b69bb70e6bb3ab1414f47"/></dir><dir name="etc"><file name="config.xml" hash="5b1b9aa315e33a4b4a1980c26a233b62"/><file name="system.xml" hash="96e002433cdd53e932ef84fd016e607f"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="strategery-infinitescroll2.xml" hash=""/></dir></dir></dir><dir name="default"><dir name="default"><dir name="layout"><file name="strategery-infinitescroll2.xml" hash="af08113f68cc80131079c098fd6610ab"/></dir><dir name="template"><dir name="strategery"><dir name="infinitescroll2"><file name="js.phtml" hash="e45eb017f11a203291c8c1a66eb7f606"/><file name="toolbar.phtml" hash="d16882d540e2c23501f84a64e33c67e2"/></dir></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="jquery"><dir name="infinitescroll2"><dir name="behaviors"><file name="infinitescroll-magento.js" hash="88a5a092c68911819302952e2128fe34"/></dir><file name="https.js" hash="be476c35fecb93b0a88625d8bc8a128b"/><file name="jquery.infinitescroll.js" hash="862b580a996c3f7a9daa1fcc1fae808d"/><file name="jquery.infinitescroll.min.js" hash="24131ba057a50077af7a97dfa1fcde30"/></dir><file name="jquery.latest.min.js" hash="7ffe78e450bedfa8878241c3abc5edba"/></dir></dir></target></contents>
|
| 28 |
<compatible/>
|
| 29 |
<dependencies/>
|
| 30 |
</package>
|
