ultimate-pagination
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -14,10 +14,10 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ | ||
/******/ // Create a new module (and put it into the cache) | ||
@@ -29,23 +29,23 @@ /******/ var module = installedModules[moduleId] = { | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.loaded = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ // Load entry module and return exports | ||
@@ -60,3 +60,3 @@ /******/ return __webpack_require__(0); | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -67,5 +67,5 @@ value: true | ||
exports.getPaginationModel = getPaginationModel; | ||
var _ultimatePaginationConstants = __webpack_require__(1); | ||
Object.defineProperty(exports, 'ITEM_TYPES', { | ||
@@ -83,16 +83,16 @@ enumerable: true, | ||
}); | ||
var _ultimatePaginationUtils = __webpack_require__(2); | ||
var _ultimatePaginationItemFactories = __webpack_require__(3); | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
function getPaginationModel(options) { | ||
var currentPage = options.currentPage; | ||
var totalPages = options.totalPages; | ||
var paginationModel = []; | ||
var createPage = (0, _ultimatePaginationItemFactories.createPageFunctionFactory)(options); | ||
// Calculate group of central pages | ||
@@ -102,26 +102,26 @@ var mainPagesStart = Math.max(currentPage - 1, 3) - Math.max(0, currentPage + 3 - totalPages); | ||
var mainPages = (0, _ultimatePaginationUtils.createRange)(mainPagesStart, mainPagesEnd).map(createPage); | ||
paginationModel.push((0, _ultimatePaginationItemFactories.createFirstPageLink)(options)); | ||
paginationModel.push((0, _ultimatePaginationItemFactories.createPreviousPageLink)(options)); | ||
// Always add the first page | ||
paginationModel.push(createPage(1)); | ||
// Show '...' or second page between the last page and main pages group if needed | ||
if (mainPagesStart > 3) { | ||
paginationModel.push((0, _ultimatePaginationItemFactories.createFirstEllipsis)()); | ||
paginationModel.push((0, _ultimatePaginationItemFactories.createFirstEllipsis)(mainPagesStart - 1)); | ||
} else { | ||
paginationModel.push(createPage(2)); | ||
} | ||
// Add pages +/- from the current page | ||
paginationModel.push.apply(paginationModel, _toConsumableArray(mainPages)); | ||
// Show '...' or penult page between main pages group and the last page if needed | ||
if (mainPagesEnd < totalPages - 2) { | ||
paginationModel.push((0, _ultimatePaginationItemFactories.createSecondEllipsis)()); | ||
paginationModel.push((0, _ultimatePaginationItemFactories.createSecondEllipsis)(mainPagesEnd + 1)); | ||
} else { | ||
paginationModel.push(createPage(totalPages - 1)); | ||
} | ||
// Always add the last page | ||
@@ -131,3 +131,3 @@ paginationModel.push(createPage(totalPages)); | ||
paginationModel.push((0, _ultimatePaginationItemFactories.createLastPageLink)(options)); | ||
return paginationModel; | ||
@@ -141,3 +141,3 @@ } | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -154,3 +154,3 @@ value: true | ||
}; | ||
var ITEM_KEYS = exports.ITEM_KEYS = { | ||
@@ -170,3 +170,3 @@ FIRST_ELLIPSIS: -1, | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -189,3 +189,3 @@ value: true | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -195,22 +195,26 @@ value: true | ||
exports.createPageFunctionFactory = exports.createLastPageLink = exports.createNextPageLink = exports.createPreviousPageLink = exports.createFirstPageLink = exports.createSecondEllipsis = exports.createFirstEllipsis = undefined; | ||
var _ultimatePaginationConstants = __webpack_require__(1); | ||
var createFirstEllipsis = exports.createFirstEllipsis = function createFirstEllipsis() { | ||
var createFirstEllipsis = exports.createFirstEllipsis = function createFirstEllipsis(value) { | ||
return { | ||
type: _ultimatePaginationConstants.ITEM_TYPES.ELLIPSIS, | ||
key: _ultimatePaginationConstants.ITEM_KEYS.FIRST_ELLIPSIS | ||
key: _ultimatePaginationConstants.ITEM_KEYS.FIRST_ELLIPSIS, | ||
value: value, | ||
isActive: false | ||
}; | ||
}; | ||
var createSecondEllipsis = exports.createSecondEllipsis = function createSecondEllipsis() { | ||
var createSecondEllipsis = exports.createSecondEllipsis = function createSecondEllipsis(value) { | ||
return { | ||
type: _ultimatePaginationConstants.ITEM_TYPES.ELLIPSIS, | ||
key: _ultimatePaginationConstants.ITEM_KEYS.SECOND_ELLISPIS | ||
key: _ultimatePaginationConstants.ITEM_KEYS.SECOND_ELLISPIS, | ||
value: value, | ||
isActive: false | ||
}; | ||
}; | ||
var createFirstPageLink = exports.createFirstPageLink = function createFirstPageLink(_ref) { | ||
var currentPage = _ref.currentPage; | ||
return { | ||
@@ -223,7 +227,7 @@ type: _ultimatePaginationConstants.ITEM_TYPES.FIRST_PAGE_LINK, | ||
}; | ||
var createPreviousPageLink = exports.createPreviousPageLink = function createPreviousPageLink(_ref2) { | ||
var currentPage = _ref2.currentPage; | ||
var totalPages = _ref2.totalPages; | ||
return { | ||
@@ -236,7 +240,7 @@ type: _ultimatePaginationConstants.ITEM_TYPES.PREVIOS_PAGE_LINK, | ||
}; | ||
var createNextPageLink = exports.createNextPageLink = function createNextPageLink(_ref3) { | ||
var currentPage = _ref3.currentPage; | ||
var totalPages = _ref3.totalPages; | ||
return { | ||
@@ -249,7 +253,7 @@ type: _ultimatePaginationConstants.ITEM_TYPES.NEXT_PAGE_LINK, | ||
}; | ||
var createLastPageLink = exports.createLastPageLink = function createLastPageLink(_ref4) { | ||
var currentPage = _ref4.currentPage; | ||
var totalPages = _ref4.totalPages; | ||
return { | ||
@@ -262,6 +266,6 @@ type: _ultimatePaginationConstants.ITEM_TYPES.LAST_PAGE_LINK, | ||
}; | ||
var createPageFunctionFactory = exports.createPageFunctionFactory = function createPageFunctionFactory(_ref5) { | ||
var currentPage = _ref5.currentPage; | ||
return function (pageNumber) { | ||
@@ -280,2 +284,3 @@ return { | ||
}); | ||
; | ||
; | ||
//# sourceMappingURL=ultimate-pagination.js.map |
{ | ||
"name": "ultimate-pagination", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "", | ||
"main": "dist/ultimate-pagination.js", | ||
"main": "lib/ultimate-pagination.js", | ||
"files": [ | ||
"dist", | ||
"README.md", | ||
"LICENSE" | ||
"lib" | ||
], | ||
"scripts": { | ||
"prebuild": "rm -rf dist", | ||
"build": "webpack", | ||
"prebuild": "rm -rf dist lib", | ||
"build": "npm-run-all --parallel build:*", | ||
"build:main": "babel src -d lib", | ||
"build:umd": "webpack --output-filename ultimate-pagination.js", | ||
"build:umd.min": "webpack --output-filename ultimate-pagination.min.js -p", | ||
"test": "karma start" | ||
@@ -27,2 +29,3 @@ }, | ||
"devDependencies": { | ||
"babel-cli": "^6.7.7", | ||
"babel-core": "^6.7.6", | ||
@@ -36,2 +39,3 @@ "babel-loader": "^6.2.4", | ||
"karma-webpack": "^1.7.0", | ||
"npm-run-all": "^1.8.0", | ||
"phantomjs-prebuilt": "^2.1.7", | ||
@@ -38,0 +42,0 @@ "webpack": "^1.13.0" |
49995
11
395
12