123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- import React from "react"
- import { Link } from "react-router"
- export default function(props) {
- return (
- <nav className="misago-pagination pull-left">
- <Pager {...props} />
- <More more={props.posts.more} />
- </nav>
- )
- }
- export function Pager(props) {
- return (
- <div className="row row-paginator">
- <div className="col-xs-3">
- <FirstPage {...props} />
- </div>
- <div className="col-xs-3">
- <PreviousPage {...props} />
- </div>
- <div className="col-xs-3">
- <NextPage {...props} />
- </div>
- <div className="col-xs-3">
- <LastPage {...props} />
- </div>
- </div>
- )
- }
- export function FirstPage(props) {
- if (props.posts.isLoaded && props.posts.first) {
- return (
- <Link
- className="btn btn-default btn-block btn-outline btn-icon"
- to={props.thread.url.index}
- title={gettext("Go to first page")}
- >
- <span className="material-icon">first_page</span>
- </Link>
- )
- } else {
- return (
- <span
- className="btn btn-default btn-block btn-outline btn-icon disabled"
- title={gettext("Go to first page")}
- >
- <span className="material-icon">first_page</span>
- </span>
- )
- }
- }
- export function PreviousPage(props) {
- if (props.posts.isLoaded && props.posts.page > 1) {
- let previousUrl = ""
- if (props.posts.previous) {
- previousUrl = props.posts.previous + "/"
- }
- return (
- <Link
- className="btn btn-default btn-block btn-outline btn-icon"
- to={props.thread.url.index + previousUrl}
- title={gettext("Go to previous page")}
- >
- <span className="material-icon">chevron_left</span>
- </Link>
- )
- } else {
- return (
- <span
- className="btn btn-default btn-block btn-outline btn-icon disabled"
- title={gettext("Go to previous page")}
- >
- <span className="material-icon">chevron_left</span>
- </span>
- )
- }
- }
- export function NextPage(props) {
- if (props.posts.isLoaded && props.posts.more) {
- let nextUrl = ""
- if (props.posts.next) {
- nextUrl = props.posts.next + "/"
- }
- return (
- <Link
- className="btn btn-default btn-block btn-outline btn-icon"
- to={props.thread.url.index + nextUrl}
- title={gettext("Go to next page")}
- >
- <span className="material-icon">chevron_right</span>
- </Link>
- )
- } else {
- return (
- <span
- className="btn btn-default btn-block btn-outline btn-icon disabled"
- title={gettext("Go to next page")}
- >
- <span className="material-icon">chevron_right</span>
- </span>
- )
- }
- }
- export function LastPage(props) {
- if (props.posts.isLoaded && props.posts.last) {
- return (
- <Link
- className="btn btn-default btn-block btn-outline btn-icon"
- to={props.thread.url.index + props.posts.last + "/"}
- title={gettext("Go to last page")}
- >
- <span className="material-icon">last_page</span>
- </Link>
- )
- } else {
- return (
- <span
- className="btn btn-default btn-block btn-outline btn-icon disabled"
- title={gettext("Go to last page")}
- >
- <span className="material-icon">last_page</span>
- </span>
- )
- }
- }
- export function More(props) {
- let message = null
- if (props.more) {
- message = ngettext(
- "There is %(more)s more post in this thread.",
- "There are %(more)s more posts in this thread.",
- props.more
- )
- message = interpolate(message, { more: props.more }, true)
- } else {
- message = gettext("There are no more posts in this thread.")
- }
- return <p>{message}</p>
- }
|