This repository has been archived by the owner on Jun 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from arandilopez/master
Pagination for MaterializeCSS
- Loading branch information
Showing
7 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php namespace Landish\Pagination; | ||
|
||
|
||
class Materialize extends Pagination { | ||
|
||
/** | ||
* Available page wrapper HTML. | ||
* | ||
* @var string | ||
*/ | ||
protected $availablePageWrapper = '<li class="waves-effect"><a href="%s">%s</a></li>'; | ||
|
||
/** | ||
* Get active page wrapper HTML. | ||
* | ||
* @var string | ||
*/ | ||
protected $activePageWrapper = '<li class="active"><a href="#!">%s</a></li>'; | ||
|
||
/** | ||
* Get disabled page wrapper HTML. | ||
* | ||
* @var string | ||
*/ | ||
protected $disabledPageWrapper = '<li class="disabled"><a href="#!">%s</a></li>'; | ||
|
||
/** | ||
* Previous button text. | ||
* | ||
* @var string | ||
*/ | ||
protected $previousButtonText = '<i class="mdi-navigation-chevron-left"></i>'; | ||
|
||
/** | ||
* Next button text. | ||
* | ||
* @var string | ||
*/ | ||
protected $nextButtonText = '<i class="mdi-navigation-chevron-right"></i>'; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
/** | ||
* Materialize Pagination Test | ||
*/ | ||
use Illuminate\Pagination\LengthAwarePaginator; | ||
use Landish\Pagination\Materialize as MaterializePresenter; | ||
|
||
class MaterializePaginationTest extends PHPUnit_Framework_TestCase | ||
{ | ||
protected $array = []; | ||
protected $dir; | ||
protected $presenter; | ||
|
||
public function __construct() { | ||
|
||
parent::__construct(); | ||
|
||
for ($i = 1; $i <= 13; $i++) { | ||
$this->array[$i] = 'item'.$i; | ||
} | ||
|
||
$this->dir = __DIR__.'/fixtures/materialize/'; | ||
} | ||
|
||
public function testMaterializePresenterCanGenerateLinksForSlider() | ||
{ | ||
$p = new LengthAwarePaginator($this->array, count($this->array), 1, 7); | ||
$presenter = new MaterializePresenter($p); | ||
|
||
$this->assertEquals( | ||
trim(file_get_contents($this->dir.'slider.html')), | ||
$presenter->render() | ||
); | ||
} | ||
|
||
public function testMaterializePresenterCanGenerateLinksForTooCloseToBegining() | ||
{ | ||
$p = new LengthAwarePaginator($this->array, count($this->array), 1, 2); | ||
$presenter = new MaterializePresenter($p); | ||
|
||
$this->assertEquals( | ||
trim(file_get_contents($this->dir.'beginning.html')), | ||
$presenter->render() | ||
); | ||
} | ||
|
||
public function testMaterializePresenterCanGenerateLinksForTooCloseToEnding() | ||
{ | ||
$p = new LengthAwarePaginator($this->array, count($this->array), 1, 12); | ||
$presenter = new MaterializePresenter($p); | ||
|
||
$this->assertEquals( | ||
trim(file_get_contents($this->dir.'ending.html')), | ||
$presenter->render() | ||
); | ||
} | ||
|
||
public function testMaterializePresenterCanGenerateLinksForLastPage() | ||
{ | ||
$p = new LengthAwarePaginator($this->array, count($this->array), 1, 13); | ||
$presenter = new MaterializePresenter($p); | ||
|
||
$this->assertEquals( | ||
trim(file_get_contents($this->dir.'last_page.html')), | ||
$presenter->render() | ||
); | ||
} | ||
|
||
public function testMaterializePresenterCanGenerateLinksForFirstPage() | ||
{ | ||
$p = new LengthAwarePaginator($this->array, count($this->array), 1, 1); | ||
$presenter = new MaterializePresenter($p); | ||
|
||
$this->assertEquals( | ||
trim(file_get_contents($this->dir.'first_page.html')), | ||
$presenter->render() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<ul class="pagination"><li class="waves-effect"><a href="/?page=1"><i class="mdi-navigation-chevron-left"></i></a></li> <li class="waves-effect"><a href="/?page=1">1</a></li><li class="active"><a href="#!">2</a></li><li class="waves-effect"><a href="/?page=3">3</a></li><li class="waves-effect"><a href="/?page=4">4</a></li><li class="waves-effect"><a href="/?page=5">5</a></li><li class="waves-effect"><a href="/?page=6">6</a></li><li class="waves-effect"><a href="/?page=7">7</a></li><li class="waves-effect"><a href="/?page=8">8</a></li><li class="disabled"><a href="#!">...</a></li><li class="waves-effect"><a href="/?page=12">12</a></li><li class="waves-effect"><a href="/?page=13">13</a></li> <li class="waves-effect"><a href="/?page=3"><i class="mdi-navigation-chevron-right"></i></a></li></ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<ul class="pagination"><li class="waves-effect"><a href="/?page=11"><i class="mdi-navigation-chevron-left"></i></a></li> <li class="waves-effect"><a href="/?page=1">1</a></li><li class="waves-effect"><a href="/?page=2">2</a></li><li class="disabled"><a href="#!">...</a></li><li class="waves-effect"><a href="/?page=5">5</a></li><li class="waves-effect"><a href="/?page=6">6</a></li><li class="waves-effect"><a href="/?page=7">7</a></li><li class="waves-effect"><a href="/?page=8">8</a></li><li class="waves-effect"><a href="/?page=9">9</a></li><li class="waves-effect"><a href="/?page=10">10</a></li><li class="waves-effect"><a href="/?page=11">11</a></li><li class="active"><a href="#!">12</a></li><li class="waves-effect"><a href="/?page=13">13</a></li> <li class="waves-effect"><a href="/?page=13"><i class="mdi-navigation-chevron-right"></i></a></li></ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<ul class="pagination"><li class="disabled"><a href="#!"><i class="mdi-navigation-chevron-left"></i></a></li> <li class="active"><a href="#!">1</a></li><li class="waves-effect"><a href="/?page=2">2</a></li><li class="waves-effect"><a href="/?page=3">3</a></li><li class="waves-effect"><a href="/?page=4">4</a></li><li class="waves-effect"><a href="/?page=5">5</a></li><li class="waves-effect"><a href="/?page=6">6</a></li><li class="waves-effect"><a href="/?page=7">7</a></li><li class="waves-effect"><a href="/?page=8">8</a></li><li class="disabled"><a href="#!">...</a></li><li class="waves-effect"><a href="/?page=12">12</a></li><li class="waves-effect"><a href="/?page=13">13</a></li> <li class="waves-effect"><a href="/?page=2"><i class="mdi-navigation-chevron-right"></i></a></li></ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<ul class="pagination"><li class="waves-effect"><a href="/?page=12"><i class="mdi-navigation-chevron-left"></i></a></li> <li class="waves-effect"><a href="/?page=1">1</a></li><li class="waves-effect"><a href="/?page=2">2</a></li><li class="disabled"><a href="#!">...</a></li><li class="waves-effect"><a href="/?page=5">5</a></li><li class="waves-effect"><a href="/?page=6">6</a></li><li class="waves-effect"><a href="/?page=7">7</a></li><li class="waves-effect"><a href="/?page=8">8</a></li><li class="waves-effect"><a href="/?page=9">9</a></li><li class="waves-effect"><a href="/?page=10">10</a></li><li class="waves-effect"><a href="/?page=11">11</a></li><li class="waves-effect"><a href="/?page=12">12</a></li><li class="active"><a href="#!">13</a></li> <li class="disabled"><a href="#!"><i class="mdi-navigation-chevron-right"></i></a></li></ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<ul class="pagination"><li class="waves-effect"><a href="/?page=6"><i class="mdi-navigation-chevron-left"></i></a></li> <li class="waves-effect"><a href="/?page=1">1</a></li><li class="waves-effect"><a href="/?page=2">2</a></li><li class="disabled"><a href="#!">...</a></li><li class="waves-effect"><a href="/?page=4">4</a></li><li class="waves-effect"><a href="/?page=5">5</a></li><li class="waves-effect"><a href="/?page=6">6</a></li><li class="active"><a href="#!">7</a></li><li class="waves-effect"><a href="/?page=8">8</a></li><li class="waves-effect"><a href="/?page=9">9</a></li><li class="waves-effect"><a href="/?page=10">10</a></li><li class="disabled"><a href="#!">...</a></li><li class="waves-effect"><a href="/?page=12">12</a></li><li class="waves-effect"><a href="/?page=13">13</a></li> <li class="waves-effect"><a href="/?page=8"><i class="mdi-navigation-chevron-right"></i></a></li></ul> |