import * as v from "./utils" ; export function isNoPreviousOrDisabled ( this ) { return this . noPrevious || this . disabled ; } export function isNoNextOrDisabled ( this ) { return this . noNext || this . disabled ; } export function noNext ( this ) { return this . value . currentPage === this . totalPages ; } export function noPrevious ( this ) { return this . value . currentPage === 1 ; } export function totalPages ( this ) { let totalPages = this . itemsPerPage < 1 ? 1 : Math . ceil ( this . totalItems / this . itemsPerPage ) ; return Math . max ( totalPages || 0 , 1 ) ; } export function pages ( this ) { let pages = [ ] ; if ( this . currentPage <= 0 || this . currentPage > this . totalPages ) { return pages ; } let startPage = 1 , endPage = this . totalPages ; let isMaxSized = v . isDefined ( this . maxSize ) && this . maxSize < this . totalPages ; if ( isMaxSized ) { if ( this . rotate ) { startPage = Math . max ( this . currentPage - Math . floor ( this . maxSize / 2 ) , 1 ) ; endPage = startPage + this . maxSize - 1 ; if ( endPage > this . totalPages ) { endPage = this . totalPages ; startPage = endPage - this . maxSize + 1 ; } } else { startPage = ( Math . ceil ( this . currentPage / this . maxSize ) - 1 ) * this . maxSize + 1 ; endPage = Math . min ( startPage + this . maxSize - 1 , this . totalPages ) ; } } for ( let number = startPage ; number <= endPage ; number ++ ) { let page = this . makePage ( number , this . pageLabel ( number ) , number === this . currentPage ) ; pages . push ( page ) ; } if ( isMaxSized && this . maxSize > 0 && ( ! this . rotate || this . forceEllipses || this . boundaryLinkNumbers ) ) { if ( startPage > 1 ) { if ( ! this . boundaryLinkNumbers || startPage > 3 ) { let previousPageSet = this . makePage ( startPage - 1 , '...' , false ) ; pages . unshift ( previousPageSet ) ; } if ( this . boundaryLinkNumbers ) { if ( startPage === 3 ) { let secondPageLink = this . makePage ( 2 , '2' , false ) ; pages . unshift ( secondPageLink ) ; } let firstPageLink = this . makePage ( 1 , '1' , false ) ; pages . unshift ( firstPageLink ) ; } } if ( endPage < this . totalPages ) { if ( ! this . boundaryLinkNumbers || endPage < this . totalPages - 2 ) { let nextPageSet = this . makePage ( endPage + 1 , '...' , false ) ; pages . push ( nextPageSet ) ; } if ( this . boundaryLinkNumbers ) { if ( endPage === this . totalPages - 2 ) { let secondToLastPageLink = this . makePage ( this . totalPages - 1 , this . totalPages - 1 , false ) ; pages . push ( secondToLastPageLink ) ; } let lastPageLink = this . makePage ( this . totalPages , this . totalPages , false ) ; pages . push ( lastPageLink ) ; } } } this . $emit ( "input" , this . createDataForModel ( this . currentPage , this . totalPages ) ) ; return pages ; }