Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tart pagination slider #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions classes/Kohana/Tart/Pagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function apply(Jam_Query_Builder_Collection $collection)

return $this;
}

public function per_page($per_page = NULL)
{
if ($per_page !== NULL)
Expand All @@ -38,7 +38,7 @@ public function per_page($per_page = NULL)
}
return $this->_per_page;
}

public function previous()
{
return Tart::html($this, function($h, $self) {
Expand Down Expand Up @@ -97,6 +97,10 @@ public function render()
$h->add("Showing: ".$self->offset().' - '.min($self->offset() + $self->per_page(), $self->total()).' of '.$self->total());
});
$h('span', array('style' => 'display:none'), function($h, $self){
foreach (Request::initial()->query() as $key => $value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please wrap this in an "if" as Request::initial() may be NULL (in tests)

{
$h('input', array('type' => 'hidden', 'name' => $key, 'value' => $value));
}
$h('input', array('id' => 'pagination-slider', 'type' => 'range', 'class' => 'input-large', 'min' => 0, 'step' => $self->per_page(), 'value' => $self->offset(), 'max' => $self->total()));
$h('input', array('id' => 'pagination-input', 'type' => 'number', 'name' => 'offset', 'class' => 'input-mini', 'min' => 0, 'step' => $self->per_page(), 'value' => $self->offset(), 'max' => $self->total()));
$h('button', array('type' => 'submit', 'class' => 'btn'), __('Go'));
Expand All @@ -106,7 +110,7 @@ public function render()
});
});
}

public function offset($offset = NULL)
{
if ($offset !== NULL)
Expand All @@ -116,7 +120,7 @@ public function offset($offset = NULL)
}
return $this->_offset;
}

public function total($total = NULL)
{
if ($total !== NULL)
Expand Down