From 94b8cff11e2a989e95a02eecd12cb82f95dc52d5 Mon Sep 17 00:00:00 2001 From: Vladimir Kuzmov Date: Wed, 23 Jul 2014 13:01:44 +0300 Subject: [PATCH] Tart pagination slider Add query string parameters as hidden inputs to tart pagination slider form to keep them applied after changing the offset slider. Also some trailing spaces are removed. --- classes/Kohana/Tart/Pagination.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/classes/Kohana/Tart/Pagination.php b/classes/Kohana/Tart/Pagination.php index 501caae..5febe2f 100644 --- a/classes/Kohana/Tart/Pagination.php +++ b/classes/Kohana/Tart/Pagination.php @@ -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) @@ -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) { @@ -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) + { + $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')); @@ -106,7 +110,7 @@ public function render() }); }); } - + public function offset($offset = NULL) { if ($offset !== NULL) @@ -116,7 +120,7 @@ public function offset($offset = NULL) } return $this->_offset; } - + public function total($total = NULL) { if ($total !== NULL)