Version Notes
remove hashbang, add pushstate
add support for cms page display
Download this release
Release Info
Developer | Vinagento |
Extension | Vinagento_Vpager |
Version | 0.1.2 |
Comparing to | |
See all releases |
Code changes from version 0.1.1 to 0.1.2
- app/code/community/Vinagento/Vpager/Block/Catalog/Layer/State.php +6 -0
- app/code/community/Vinagento/Vpager/Block/Catalog/Product/List.php +7 -0
- app/code/community/Vinagento/Vpager/Block/Catalog/Product/List/Toolbar.php +17 -0
- app/code/community/Vinagento/Vpager/Block/Page/Html/Pager.php +6 -0
- app/code/community/Vinagento/Vpager/Block/Product/List.php +8 -0
- app/code/community/Vinagento/Vpager/Block/Product/List/Toolbar.php +13 -0
- app/code/community/Vinagento/Vpager/Controller/Router.php +22 -0
- app/code/community/Vinagento/Vpager/Helper/Data.php +22 -0
- app/code/community/Vinagento/Vpager/Model/Layer/Filter/Item.php +10 -0
- app/code/community/Vinagento/Vpager/controllers/CategoryController.php +33 -0
- app/code/community/Vinagento/Vpager/etc/config.xml +78 -0
- app/design/frontend/base/default/layout/vpager.xml +40 -0
- app/etc/modules/Vinagento_Vpager.xml +12 -0
- package.xml +3 -3
- skin/frontend/base/default/js/vpager.js +90 -0
app/code/community/Vinagento/Vpager/Block/Catalog/Layer/State.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Vinagento_Vpager_Block_Catalog_Layer_State extends Mage_Catalog_Block_Layer_State{
|
3 |
+
public function getClearUrl(){
|
4 |
+
return Mage::helper('vpager')->clearLnav(preg_replace('/\?/', '#%21', parent::getClearUrl()));
|
5 |
+
}
|
6 |
+
}
|
app/code/community/Vinagento/Vpager/Block/Catalog/Product/List.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Vinagento_Vpager_Block_Catalog_Product_List extends Mage_Catalog_Block_Product_List{
|
3 |
+
protected function _prepareLayout(){
|
4 |
+
//Mage::log($this->getRequest()->getParams());
|
5 |
+
//die();
|
6 |
+
}
|
7 |
+
}
|
app/code/community/Vinagento/Vpager/Block/Catalog/Product/List/Toolbar.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Vinagento_Vpager_Block_Catalog_Product_List_Toolbar
|
3 |
+
extends Mage_Catalog_Block_Product_List_Toolbar{
|
4 |
+
public function getLimitUrl($limit)
|
5 |
+
{
|
6 |
+
return Mage::helper('vpager')->addLnav(preg_replace('/\?/', '#%21', parent::getLimitUrl($limit)));
|
7 |
+
|
8 |
+
}
|
9 |
+
public function getModeUrl($mode)
|
10 |
+
{
|
11 |
+
return Mage::helper('vpager')->addLnav(preg_replace('/\?/', '#%21', parent::getModeUrl($mode)));
|
12 |
+
}
|
13 |
+
public function getOrderUrl($order, $direction)
|
14 |
+
{
|
15 |
+
return Mage::helper('vpager')->addLnav(preg_replace('/\?/', '#%21', parent::getOrderUrl($order, $direction)));
|
16 |
+
}
|
17 |
+
}
|
app/code/community/Vinagento/Vpager/Block/Page/Html/Pager.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Vinagento_Vpager_Block_Page_Html_Pager extends Mage_Page_Block_Html_Pager {
|
3 |
+
public function getPageUrl($page) {
|
4 |
+
return Mage::helper('vpager')->addLnav(preg_replace('/\?/', '#%21', parent::getPageUrl($page)));
|
5 |
+
}
|
6 |
+
}
|
app/code/community/Vinagento/Vpager/Block/Product/List.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Vinagento_Vpager_Block_Product_List extends Mage_Catalog_Block_Product_List{
|
3 |
+
protected function _construct()
|
4 |
+
{
|
5 |
+
parent::_construct();
|
6 |
+
$this->_defaultToolbarBlock = 'vpager/product_list_toolbar';
|
7 |
+
}
|
8 |
+
}
|
app/code/community/Vinagento/Vpager/Block/Product/List/Toolbar.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Vinagento_Vpager_Block_Product_List_Toolbar extends Mage_Catalog_Block_Product_List_Toolbar{
|
3 |
+
public function getPagerUrl($params=array())
|
4 |
+
{
|
5 |
+
$params['id'] = $this->getParentBlock()->getCategoryId();
|
6 |
+
$urlParams = array();
|
7 |
+
$urlParams['_current'] = false;
|
8 |
+
$urlParams['_escape'] = true;
|
9 |
+
$urlParams['_use_rewrite'] = FALSE;
|
10 |
+
$urlParams['_query'] = $params;
|
11 |
+
return $this->getUrl('catalog/category/view', $urlParams);
|
12 |
+
}
|
13 |
+
}
|
app/code/community/Vinagento/Vpager/Controller/Router.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Vinagento_Vpager_Controller_Router extends Mage_Core_Controller_Varien_Router_Abstract{
|
3 |
+
|
4 |
+
public function initControllerRouters($observer)
|
5 |
+
{
|
6 |
+
$front = $observer->getEvent()->getFront();
|
7 |
+
$front->addRouter('vpager', $this);
|
8 |
+
}
|
9 |
+
|
10 |
+
public function match(Zend_Controller_Request_Http $request)
|
11 |
+
{
|
12 |
+
if (!Mage::isInstalled()) {
|
13 |
+
Mage::app()->getFrontController()->getResponse()
|
14 |
+
->setRedirect(Mage::getUrl('install'))
|
15 |
+
->sendResponse();
|
16 |
+
exit;
|
17 |
+
}
|
18 |
+
|
19 |
+
|
20 |
+
return true;
|
21 |
+
}
|
22 |
+
}
|
app/code/community/Vinagento/Vpager/Helper/Data.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Vinagento_Vpager_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
+
{
|
4 |
+
public function addLnav($url){
|
5 |
+
if(strpos($url, 'l=0')===false&&strpos($url, 'l=1'===false)){
|
6 |
+
$url .= '&l=0';
|
7 |
+
}
|
8 |
+
return $url;
|
9 |
+
}
|
10 |
+
public function addLnav1($url){
|
11 |
+
$search = array('&l=0','l=0','%26l%3d0');
|
12 |
+
$url = str_replace($search,'',$url);
|
13 |
+
if(strpos($url, 'l=1')===false){
|
14 |
+
$url .= '&l=1';
|
15 |
+
}
|
16 |
+
return $url;
|
17 |
+
}
|
18 |
+
public function clearLnav($url){
|
19 |
+
$search = array('&l=1','l=1','%26l%3d1','#%21l=1','%23!l%3d1','#!l=1');
|
20 |
+
return str_replace($search,'',$url);
|
21 |
+
}
|
22 |
+
}
|
app/code/community/Vinagento/Vpager/Model/Layer/Filter/Item.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Vinagento_Vpager_Model_Layer_Filter_Item
|
3 |
+
extends Mage_Catalog_Model_Layer_Filter_Item{
|
4 |
+
public function getUrl(){
|
5 |
+
return Mage::helper('vpager')->addLnav1(preg_replace('/\?/','#%21',parent::getUrl()));
|
6 |
+
}
|
7 |
+
public function getRemoveUrl(){
|
8 |
+
return Mage::helper('vpager')->addLnav1(preg_replace('/\?/','#%21',parent::getRemoveUrl()));
|
9 |
+
}
|
10 |
+
}
|
app/code/community/Vinagento/Vpager/controllers/CategoryController.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
require_once BP.'/app/code/core/Mage/Catalog/controllers/CategoryController.php';
|
3 |
+
class Vinagento_Vpager_CategoryController extends Mage_Catalog_CategoryController{
|
4 |
+
protected function _getListHtml(){
|
5 |
+
$layout = $this->getLayout();
|
6 |
+
$update = $layout->getUpdate()->load('catalog_category_ajax_view');
|
7 |
+
$layout->generateXml()->generateBlocks();
|
8 |
+
$output = $layout->getOutput();
|
9 |
+
return $output;
|
10 |
+
}
|
11 |
+
protected function _getLayeredNavHtml(){
|
12 |
+
$layout = $this->getLayout();
|
13 |
+
$update = $layout->getUpdate()->load('catalog_category_layered_ajax');
|
14 |
+
$layout->generateXml()->generateBlocks();
|
15 |
+
$output = $layout->getOutput();
|
16 |
+
return $output;
|
17 |
+
}
|
18 |
+
public function viewAction()
|
19 |
+
{
|
20 |
+
$oneRequest = $this->getRequest();
|
21 |
+
if($oneRequest->isXmlHttpRequest()){
|
22 |
+
if ($category = $this->_initCatagory()) {
|
23 |
+
//if($lnav){
|
24 |
+
$this->getResponse()->setBody($this->_getLayeredNavHtml());
|
25 |
+
//}else{
|
26 |
+
// $this->getResponse()->setBody($this->_getListHtml());
|
27 |
+
//}
|
28 |
+
}
|
29 |
+
}else{
|
30 |
+
parent::viewAction();
|
31 |
+
}
|
32 |
+
}
|
33 |
+
}
|
app/code/community/Vinagento/Vpager/etc/config.xml
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Vinagento_Vpager>
|
5 |
+
<version>0.1.2</version>
|
6 |
+
</Vinagento_Vpager>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<catalog>
|
11 |
+
<args>
|
12 |
+
<modules>
|
13 |
+
<vinagento_vpager before="Mage_Catalog">Vinagento_Vpager</vinagento_vpager>
|
14 |
+
</modules>
|
15 |
+
</args>
|
16 |
+
</catalog>
|
17 |
+
<vpager>
|
18 |
+
<use>standart</use>
|
19 |
+
<args>
|
20 |
+
<module>Vinagento_Vpager</module>
|
21 |
+
<frontName>vpager</frontName>
|
22 |
+
</args>
|
23 |
+
</vpager>
|
24 |
+
</routers>
|
25 |
+
<layout>
|
26 |
+
<updates>
|
27 |
+
<vpager>
|
28 |
+
<file>vpager.xml</file>
|
29 |
+
</vpager>
|
30 |
+
</updates>
|
31 |
+
</layout>
|
32 |
+
</frontend>
|
33 |
+
<global>
|
34 |
+
<models>
|
35 |
+
<vpager>
|
36 |
+
<class>Vinagento_Vpager_Model</class>
|
37 |
+
</vpager>
|
38 |
+
<!--catalog>
|
39 |
+
<rewrite>
|
40 |
+
<layer_filter_item>Vinagento_Vpager_Model_Layer_Filter_Item</layer_filter_item>
|
41 |
+
</rewrite>
|
42 |
+
</catalog-->
|
43 |
+
</models>
|
44 |
+
<blocks>
|
45 |
+
<vpager>
|
46 |
+
<class>Vinagento_Vpager_Block</class>
|
47 |
+
</vpager>
|
48 |
+
<!--page>
|
49 |
+
<rewrite>
|
50 |
+
<html_pager>Vinagento_Vpager_Block_Page_Html_Pager</html_pager>
|
51 |
+
</rewrite>
|
52 |
+
</page>
|
53 |
+
<catalog>
|
54 |
+
<rewrite>
|
55 |
+
<product_list_toolbar>Vinagento_Vpager_Block_Catalog_Product_List_Toolbar</product_list_toolbar>
|
56 |
+
<product_list>Vinagento_Vpager_Block_Catalog_Product_List</product_list>
|
57 |
+
<layer_state>Vinagento_Vpager_Block_Catalog_Layer_State</layer_state>
|
58 |
+
</rewrite>
|
59 |
+
</catalog-->
|
60 |
+
</blocks>
|
61 |
+
<helpers>
|
62 |
+
<vpager>
|
63 |
+
<class>Vinagento_Vpager_Helper</class>
|
64 |
+
</vpager>
|
65 |
+
</helpers>
|
66 |
+
<events>
|
67 |
+
<!--controller_front_init_routers>
|
68 |
+
<observers>
|
69 |
+
<mynews>
|
70 |
+
<type>singleton</type>
|
71 |
+
<class>Vinagento_Vpager_Controller_Router</class>
|
72 |
+
<method>initControllerRouters</method>
|
73 |
+
</mynews>
|
74 |
+
</observers>
|
75 |
+
</controller_front_init_routers-->
|
76 |
+
</events>
|
77 |
+
</global>
|
78 |
+
</config>
|
app/design/frontend/base/default/layout/vpager.xml
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<default>
|
4 |
+
<reference name="head">
|
5 |
+
<action method="addItem"><type>skin_js</type><name>js/vpager.js</name></action>
|
6 |
+
<action method="addCss"><stylesheet>css/vpager.css</stylesheet></action>
|
7 |
+
</reference>
|
8 |
+
</default>
|
9 |
+
<catalog_category_ajax_view>
|
10 |
+
<block type="core/template" name="root" output="toHtml" template="page/html/wrapper.phtml">
|
11 |
+
<action method="setId"><id>ajax-list-container</id></action>
|
12 |
+
<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
|
13 |
+
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
|
14 |
+
<block type="page/html_pager" name="product_list_toolbar_pager"/>
|
15 |
+
</block>
|
16 |
+
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
|
17 |
+
</block>
|
18 |
+
</block>
|
19 |
+
</catalog_category_ajax_view>
|
20 |
+
|
21 |
+
<catalog_category_layered_ajax translate="label">
|
22 |
+
<label>Catalog Category (Anchor)</label>
|
23 |
+
<block type="core/template" name="root" output="toHtml" template="page/html/wrapper.phtml">
|
24 |
+
<action method="setId"><id>layered-container</id></action>
|
25 |
+
<block type="core/template" name="ajax-nav-container" template="page/html/wrapper.phtml" id="layered-nav-container">
|
26 |
+
<action method="setId"><id>ajax-nav-container</id></action>
|
27 |
+
<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/>
|
28 |
+
</block>
|
29 |
+
<block type="core/template" name="ajax-list-container" template="page/html/wrapper.phtml">
|
30 |
+
<action method="setId"><id>ajax-list-container</id></action>
|
31 |
+
<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
|
32 |
+
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
|
33 |
+
<block type="page/html_pager" name="product_list_toolbar_pager"/>
|
34 |
+
</block>
|
35 |
+
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
|
36 |
+
</block>
|
37 |
+
</block>
|
38 |
+
</block>
|
39 |
+
</catalog_category_layered_ajax>
|
40 |
+
</layout>
|
app/etc/modules/Vinagento_Vpager.xml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Vinagento_Vpager>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<depends>
|
8 |
+
<Mage_Catalog />
|
9 |
+
</depends>
|
10 |
+
</Vinagento_Vpager>
|
11 |
+
</modules>
|
12 |
+
</config>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Vinagento_Vpager</name>
|
4 |
-
<version>0.1.
|
5 |
<stability>stable</stability>
|
6 |
<license>OSL</license>
|
7 |
<channel>community</channel>
|
@@ -12,8 +12,8 @@
|
|
12 |
add support for cms page display</notes>
|
13 |
<authors><author><name>Vinagento</name><user>vinagento</user><email>vinagento@gmail.com</email></author></authors>
|
14 |
<date>2012-05-18</date>
|
15 |
-
<time>
|
16 |
-
<contents><target name="
|
17 |
<compatible/>
|
18 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
19 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Vinagento_Vpager</name>
|
4 |
+
<version>0.1.2</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>OSL</license>
|
7 |
<channel>community</channel>
|
12 |
add support for cms page display</notes>
|
13 |
<authors><author><name>Vinagento</name><user>vinagento</user><email>vinagento@gmail.com</email></author></authors>
|
14 |
<date>2012-05-18</date>
|
15 |
+
<time>14:56:30</time>
|
16 |
+
<contents><target name="magecommunity"><dir><dir name="Vinagento"><dir name="Vpager"><dir name="Block"><dir name="Catalog"><dir name="Layer"><file name="State.php" hash="c46da78ed4c19bf21cd990b18d76b1f9"/></dir><dir name="Product"><dir name="List"><file name="Toolbar.php" hash="7328be242da02c407326a03002ea4a84"/></dir><file name="List.php" hash="77a809582c071ba7119967d16b6e058f"/></dir></dir><dir name="Page"><dir name="Html"><file name="Pager.php" hash="00df861aaf7347e47d9c3f79c7767395"/></dir></dir><dir name="Product"><dir name="List"><file name="Toolbar.php" hash="6187dc98b1306207259b832d3823af33"/></dir><file name="List.php" hash="ddcc45bf4ba00d6553afe0c35dc217c8"/></dir></dir><dir name="Controller"><file name="Router.php" hash="92a6f0e84af4043ae28113e5ad142039"/></dir><dir name="controllers"><file name="CategoryController.php" hash="a6495fb827ca911ff1e7d037bd989426"/></dir><dir name="etc"><file name="config.xml" hash="ae09391e0766457e1ff5301b02d195c8"/></dir><dir name="Helper"><file name="Data.php" hash="26d3ed48ef6e74c34646ba120d5173cc"/></dir><dir name="Model"><dir name="Layer"><dir name="Filter"><file name="Item.php" hash="9d6f5597900a534f92aeaec00116512c"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="Vinagento_Vpager.xml" hash="8c2343c234e6b7a53f3c5efb3407a508"/></dir></dir></target><target name="mageskin"><dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="js"><file name="vpager.js" hash="223fd2ff9191ec69b272e20aa60d1601"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="vpager.xml" hash="0cd78bd03b3b0c9497f5d2502b90715c"/></dir></dir></dir></dir></dir></target></contents>
|
17 |
<compatible/>
|
18 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
19 |
</package>
|
skin/frontend/base/default/js/vpager.js
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var Vpager = Class.create();
|
2 |
+
Vpager.prototype = {
|
3 |
+
initialize : function() {
|
4 |
+
this.request = null;
|
5 |
+
this.url = null;
|
6 |
+
document.observe("dom:loaded", this.olinks.bind(this));
|
7 |
+
},
|
8 |
+
riff : function(u,layered) {
|
9 |
+
this.showSpinner(false);
|
10 |
+
this.url = u;
|
11 |
+
if (this.request !== null) {
|
12 |
+
this.request.abort();
|
13 |
+
}
|
14 |
+
this.request = new Ajax.Request(u, {
|
15 |
+
method : 'get',
|
16 |
+
onSuccess : this.glist.bind(this),
|
17 |
+
onComplete : this.olinks.bind(this)
|
18 |
+
});
|
19 |
+
},
|
20 |
+
getResult : function(event) {
|
21 |
+
sEle = Event.element(event);
|
22 |
+
//console.log(sEle);
|
23 |
+
if (sEle.tagName.toLowerCase() == 'a') {
|
24 |
+
this.riff(sEle.href);
|
25 |
+
} else {
|
26 |
+
if (sEle.tagName.toLowerCase() == 'img'){
|
27 |
+
this.riff(sEle.up().href);
|
28 |
+
}else{
|
29 |
+
this.riff(sEle.value);
|
30 |
+
}
|
31 |
+
|
32 |
+
}
|
33 |
+
event.stop();
|
34 |
+
},
|
35 |
+
getNavRes: function(event){
|
36 |
+
Event.stop(event);
|
37 |
+
this.isNav = true;
|
38 |
+
sEle = Event.element(event);
|
39 |
+
if (sEle.tagName.toLowerCase() == 'a') {
|
40 |
+
this.riff(sEle.href);
|
41 |
+
}else{
|
42 |
+
if(sEle.tagName.toLowerCase() == 'span'){
|
43 |
+
this.riff(sEle.up().href);
|
44 |
+
}
|
45 |
+
}
|
46 |
+
},
|
47 |
+
olinks : function() {
|
48 |
+
$$('.pages li a', '.view-mode a', '.sorter a').each(function(item) {
|
49 |
+
item.observe('click', this.getResult.bind(this))
|
50 |
+
}.bind(this));
|
51 |
+
$$('.limiter select', '.sorter select').each(function(item) {
|
52 |
+
item.observe('change', this.getResult.bind(this));
|
53 |
+
item.removeAttribute('onchange');
|
54 |
+
}.bind(this));
|
55 |
+
$$('.block-layered-nav a').each(function(item){
|
56 |
+
item.observe('click',this.getNavRes.bind(this))
|
57 |
+
}.bind(this));
|
58 |
+
},
|
59 |
+
glist : function(transport) {
|
60 |
+
ft = transport.responseText;
|
61 |
+
if (typeof(window.history.pushState) == 'function'){
|
62 |
+
window.history.pushState({'changed':true}, document.title, this.url);
|
63 |
+
}
|
64 |
+
var bagEle = new Element('div');
|
65 |
+
bagEle.update(ft);
|
66 |
+
var plist = bagEle.select('div#ajax-list-container')[0];
|
67 |
+
var lnav = bagEle.select('div#ajax-nav-container')[0];
|
68 |
+
$$('.category-products').each(function(item) {
|
69 |
+
Element.replace(item, plist.innerHTML);
|
70 |
+
});
|
71 |
+
$$('.block-layered-nav').each(function(item) {
|
72 |
+
Element.replace(item, lnav.innerHTML);
|
73 |
+
});
|
74 |
+
},
|
75 |
+
showSpinner : function(flag) {
|
76 |
+
$$('.category-products').each(function(item){
|
77 |
+
new Effect.Opacity(item, { from: 1.0, to: 0.5, duration: 0.5 })
|
78 |
+
});
|
79 |
+
$$('.block-layered-nav').each(function(item) {
|
80 |
+
new Effect.Opacity(item, { from: 1.0, to: 0.5, duration: 0.5 })
|
81 |
+
});
|
82 |
+
}
|
83 |
+
};
|
84 |
+
Object.extend(Ajax);
|
85 |
+
Ajax.Request.prototype.abort = function() {
|
86 |
+
this.transport.onreadystatechange = Prototype.emptyFunction;
|
87 |
+
this.transport.abort();
|
88 |
+
Ajax.activeRequestCount--;
|
89 |
+
};
|
90 |
+
var ajaxPager = new Vpager();
|