Skip to content

Commit

Permalink
Fixing pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
weotch committed Dec 13, 2017
1 parent 8cffa39 commit 01f4b0d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 25 deletions.
19 changes: 2 additions & 17 deletions classes/Markup/UrlWindow.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,6 @@ class UrlWindow extends LaravelUrlWindow {
*/
protected $edge_count = 2;

/**
* Set edge count
*
* @param int $edge_count
* @return $this
*/
public function setEdgeCount($edge_count)
{
$this->edge_count = $edge_count;
return $this;
}

/**
* Get the slider of URLs when too close to beginning of window.
*
Expand Down Expand Up @@ -71,7 +59,7 @@ protected function getSliderTooCloseToEnding($window)
*/
public function getStart()
{
return $this->paginator->getUrlRange(1, $this->edge_count);
return false;
}

/**
Expand All @@ -81,10 +69,7 @@ public function getStart()
*/
public function getFinish()
{
return $this->paginator->getUrlRange(
$this->lastPage() - $this->edge_count + 1,
$this->lastPage()
);
return false;
}

}
7 changes: 2 additions & 5 deletions views/shared/pagination/desktop.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@
use Bkwld\Decoy\Markup\UrlWindow;
// Make a smaller window
$window = new UrlWindow($paginator);
$window->setEdgeCount(0);
$window = $window->get(3);
$window = (new UrlWindow($paginator))->get(3);
// Add dots to the window
$elements = [
$window['first'],
is_array($window['slider']) ? '...' : null,
$window['slider'],
is_array($window['last']) ? '...' : null,
is_array($window['slider']) ? '...' : null,
$window['last'],
];
$elements = array_filter($elements);
?>
@if ($paginator->hasPages())
Expand Down
13 changes: 10 additions & 3 deletions views/shared/pagination/mobile.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@
use Bkwld\Decoy\Markup\UrlWindow;
// Make a smaller window
$window = new UrlWindow($paginator);
$window->setEdgeCount(0);
$elements = array_filter($window->get(1));
$window = (new UrlWindow($paginator))->get(1);
// Add dots to the window
$elements = [
$window['first'],
is_array($window['slider']) ? '...' : null,
$window['slider'],
is_array($window['slider']) ? '...' : null,
$window['last'],
];
?>
@if ($paginator->hasPages())
Expand Down

0 comments on commit 01f4b0d

Please sign in to comment.