PHP Class kop\y2sp\ScrollPager

ScrollPager works with a [[Pagination]] object which specifies the totally number of pages and the current page number.
Example usage: echo ListView::widget([ 'dataProvider' => $dataProvider, 'itemOptions' => ['class' => 'item'], 'itemView' => '_item_view', 'pager' => ['class' => \kop\y2sp\ScrollPager::className()] ]); This widget is using {@link http://infiniteajaxscroll.com/ JQuery Infinite Ajax Scroll plugin}.
Author: Ivan Koptiev ([email protected])
Inheritance: extends yii\base\Widget
显示文件 Open project: kop/yii2-scroll-pager Class Usage Examples

Public Properties

Property Type Description
$container string Enter the selector of the element containing your items that you want to paginate.
$delay integer Minimal number of milliseconds to stay in a loading state.
$enabledExtensions array The list of the enabled plugin extensions.
$eventOnLoad string | yii\web\JsExpression Triggered when a new url will be loaded from the server.
$eventOnLoaded string | yii\web\JsExpression Triggered after a new page was loaded from the server.
$eventOnNext string | yii\web\JsExpression Triggered when the next page should be loaded. Happens before loading of the next page starts. With this event it is possible to cancel the loading of the next page. You can do this by returning false from your callback.
$eventOnNoneLeft string | yii\web\JsExpression Triggered when there are no more pages left.
$eventOnPageChange string | yii\web\JsExpression Triggered when a used scroll to another page.
$eventOnReady string | yii\web\JsExpression Triggered when IAS and all the extensions have been initialized.
$eventOnRender string | yii\web\JsExpression Triggered before new items will be rendered.
$eventOnRendered string | yii\web\JsExpression Triggered after new items have rendered. Note: This event is only fired once.
$eventOnScroll string | yii\web\JsExpression Triggered when the visitors scrolls.
$historyPrev string Enter the selector of the link element that links to the previous page. The href attribute of this element will be used to get the items from the previous page. Make sure there is only one element that matches the selector.
$item string Enter the selector of the element that each item has. Make sure the elements are inside the container element.
$negativeMargin integer
$next string Enter the selector of the link element that links to the next page. The href attribute of this element will be used to get the items from the next page. Make sure there is only one(1) element that matches the selector.
$noneLeftTemplate string Allows you to override the "nothing left" message html template.
$noneLeftText string Text of the "nothing left" message. Default: "You reached the end".
$overflowContainer string A selector for "div" HTML element to use as an overflow container.
$pagination The pagination object that this pager is associated with. You must set this property in order to make ScrollPager work.
$paginationSelector string Enter the selector of the element containing the pagination.
$spinnerSrc string The src attribute of the spinner image.
$spinnerTemplate string Allows you to override the spinner html template.
$triggerOffset integer The number of pages which should load automatically. After that the trigger is shown for every subsequent page.

For example:
if you set the offset to 2, the pages 2 and 3 (page 1 is always shown) would load automatically and for every subsequent page the user has to press the trigger to load it.
$triggerTemplate string Allows you to override the trigger html template.
$triggerText string Text of trigger the link. Default: "Load more items".

Public Methods

Method Description
init ( ) Initializes the pager.
run ( ) : mixed Executes the widget.

Protected Methods

Method Description
checkEnabledExtensions ( string | array $extensions ) : boolean Check whether the given extensions are enabled.
registerAssets ( ) Register required asset bundles.
registerEventHandlers ( array $config ) Register jQuery IAS event handlers.
registerExtensions ( array $config ) Register jQuery IAS extensions.

Method Details

checkEnabledExtensions() protected method

Check whether the given extensions are enabled.
protected checkEnabledExtensions ( string | array $extensions ) : boolean
$extensions string | array Single or multiple extensions names.
return boolean Operation result.

init() public method

Initializes the pager.
public init ( )

registerAssets() protected method

You can override this method in case if you want to use your own JQuery Infinite Ajax Scroll plugin files (for example, some forked plugin version).
protected registerAssets ( )

registerEventHandlers() protected method

This method takes jQuery IAS event handlers definition as a parameter and registers this event handlers.
protected registerEventHandlers ( array $config )
$config array jQuery IAS event handlers definition.

registerExtensions() protected method

This method takes jQuery IAS extensions definition as a parameter and registers this extensions.
protected registerExtensions ( array $config )
$config array jQuery IAS extensions definition.

run() public method

This overrides the parent implementation by initializing jQuery IAS and displaying the generated page buttons.
public run ( ) : mixed
return mixed

Property Details

$container public_oe property

Enter the selector of the element containing your items that you want to paginate.
public string $container
return string

$delay public_oe property

Minimal number of milliseconds to stay in a loading state.
public int $delay
return integer

$enabledExtensions public_oe property

The list of the enabled plugin extensions.
public array $enabledExtensions
return array

$eventOnLoad public_oe property

Triggered when a new url will be loaded from the server.
See also: http://infiniteajaxscroll.com/docs/events.html
public string|JsExpression,yii\web $eventOnLoad
return string | yii\web\JsExpression

$eventOnLoaded public_oe property

Triggered after a new page was loaded from the server.
See also: http://infiniteajaxscroll.com/docs/events.html
public string|JsExpression,yii\web $eventOnLoaded
return string | yii\web\JsExpression

$eventOnNext public_oe property

Triggered when the next page should be loaded. Happens before loading of the next page starts. With this event it is possible to cancel the loading of the next page. You can do this by returning false from your callback.
See also: http://infiniteajaxscroll.com/docs/events.html
public string|JsExpression,yii\web $eventOnNext
return string | yii\web\JsExpression

$eventOnNoneLeft public_oe property

Triggered when there are no more pages left.
See also: http://infiniteajaxscroll.com/docs/events.html
public string|JsExpression,yii\web $eventOnNoneLeft
return string | yii\web\JsExpression

$eventOnPageChange public_oe property

Triggered when a used scroll to another page.
See also: http://infiniteajaxscroll.com/docs/extension-paging.html
public string|JsExpression,yii\web $eventOnPageChange
return string | yii\web\JsExpression

$eventOnReady public_oe property

Triggered when IAS and all the extensions have been initialized.
See also: http://infiniteajaxscroll.com/docs/events.html
public string|JsExpression,yii\web $eventOnReady
return string | yii\web\JsExpression

$eventOnRender public_oe property

Triggered before new items will be rendered.
See also: http://infiniteajaxscroll.com/docs/events.html
public string|JsExpression,yii\web $eventOnRender
return string | yii\web\JsExpression

$eventOnRendered public_oe property

Triggered after new items have rendered. Note: This event is only fired once.
See also: http://infiniteajaxscroll.com/docs/events.html
public string|JsExpression,yii\web $eventOnRendered
return string | yii\web\JsExpression

$eventOnScroll public_oe property

Triggered when the visitors scrolls.
See also: http://infiniteajaxscroll.com/docs/events.html
public string|JsExpression,yii\web $eventOnScroll
return string | yii\web\JsExpression

$historyPrev public_oe property

Enter the selector of the link element that links to the previous page. The href attribute of this element will be used to get the items from the previous page. Make sure there is only one element that matches the selector.
public string $historyPrev
return string

$item public_oe property

Enter the selector of the element that each item has. Make sure the elements are inside the container element.
public string $item
return string

$negativeMargin public_oe property

public int $negativeMargin
return integer

$next public_oe property

Enter the selector of the link element that links to the next page. The href attribute of this element will be used to get the items from the next page. Make sure there is only one(1) element that matches the selector.
public string $next
return string

$noneLeftTemplate public_oe property

Allows you to override the "nothing left" message html template.
public string $noneLeftTemplate
return string

$noneLeftText public_oe property

Text of the "nothing left" message. Default: "You reached the end".
public string $noneLeftText
return string

$overflowContainer public_oe property

A selector for "div" HTML element to use as an overflow container.
See also: http://infiniteajaxscroll.com/examples/overflow.html
public string $overflowContainer
return string

$pagination public_oe property

The pagination object that this pager is associated with. You must set this property in order to make ScrollPager work.
public $pagination

$paginationSelector public_oe property

Enter the selector of the element containing the pagination.
public string $paginationSelector
return string

$spinnerSrc public_oe property

The src attribute of the spinner image.
public string $spinnerSrc
return string

$spinnerTemplate public_oe property

Allows you to override the spinner html template.
public string $spinnerTemplate
return string

$triggerOffset public_oe property

The number of pages which should load automatically. After that the trigger is shown for every subsequent page.

For example:
if you set the offset to 2, the pages 2 and 3 (page 1 is always shown) would load automatically and for every subsequent page the user has to press the trigger to load it.
public int $triggerOffset
return integer

$triggerTemplate public_oe property

Allows you to override the trigger html template.
public string $triggerTemplate
return string

$triggerText public_oe property

Text of trigger the link. Default: "Load more items".
public string $triggerText
return string