client/public/elements/components/pagination.js
/**
   * @method _constructCenterPageArray
   * @description Sets centerPages property. Called on element update.
   */
@method _constructCenterPageArray
@description Sets centerPages property. Called on element update.
@method _constructCenterPageArray @description Sets centerPages property . Called on element update .
_constructCenterPagesArray(){
    let pages = [{page: this.currentPage, selected: true}];
    let remainder = this.pagesPerSide * 2;
    let self = this;
    addPages(this.pagesPerSide);
    addPages(remainder);
    if (pages[0].page == this.minPage + 2 ) {
      pages.unshift({page: this.minPage + 1, selected: false});
    }
    if (pages.slice(-1)[0].page == this.maxPage - 2) {
      pages.push({page: this.maxPage - 1, selected: false});
    }
    if (pages[0].page - this.minPage === 1) {
      pages.unshift({page: this.minPage, selected: false});
    }
    if (this.maxPage - pages.slice(-1)[0].page === 1) {
      pages.push({page: this.maxPage, selected: false});
    }
    this.centerPages = pages;
    function addPages(loops){
      let directions = ['left', 'right'];
      for (let direction of directions) {
        if (direction === 'left') {
          for (let i = 0; i < loops; i++) {
            let first = pages[0].page;
            if (first > self.minPage) {
              pages.unshift({page: first - 1, selected: false});
              remainder -= 1;
            }
          }
        }
        if (direction === 'right') {
          for (let i = 0; i < loops; i++) {
            let last = pages.slice(-1)[0].page;
            if (last < self.maxPage) {
              pages.push({page: last + 1, selected: false});
              remainder -= 1;
            }
          }
        }
      }
    }
  }
_constructCenterPagesArray ( ) { let pages = [ { page : this . currentPage , selected : true } ] ; let remainder = this . pagesPerSide * 2 ; let self = this ; addPages ( this . pagesPerSide ) ; addPages ( remainder ) ; if ( pages [ 0 ] . page == this . minPage + 2 ) { pages . unshift ( { page : this . minPage + 1 , selected : false } ) ; } if ( pages . slice ( - 1 ) [ 0 ] . page == this . maxPage - 2 ) { pages . push ( { page : this . maxPage - 1 , selected : false } ) ; } if ( pages [ 0 ] . page - this . minPage === 1 ) { pages . unshift ( { page : this . minPage , selected : false } ) ; } if ( this . maxPage - pages . slice ( - 1 ) [ 0 ] . page === 1 ) { pages . push ( { page : this . maxPage , selected : false } ) ; } this . centerPages = pages ; function addPages ( loops ) { let directions = [ 'left' , 'right' ] ; for ( let direction of directions ) { if ( direction === 'left' ) { for ( let i = 0 ; i < loops ; i ++ ) { let first = pages [ 0 ] . page ; if ( first > self . minPage ) { pages . unshift ( { page : first - 1 , selected : false } ) ; remainder -= 1 ; } } } if ( direction === 'right' ) { for ( let i = 0 ; i < loops ; i ++ ) { let last = pages . slice ( - 1 ) [ 0 ] . page ; if ( last < self . maxPage ) { pages . push ( { page : last + 1 , selected : false } ) ; remainder -= 1 ; } } } } } }
@method _constructCenterPageArray
 @description Sets centerPages property.
@method _constructCenterPageArray @description Sets centerPages property .
// mete out pages-per-side to either side of the current page. // Add pages to beginning/end of array if within 2 of min/max page /**
     * @function addPages
     * @description private function for _constructCenterPageArray that builds the pages array
     * @param {Number} loops - Number of pages to be added on either side of the pages array
     */