Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tui-pagination

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tui-pagination - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

ISSUE_TEMPLATE.md

243

.eslintrc.js

@@ -14,245 +14,4 @@ module.exports = {

"tui": true,
"loadFixtures": true,
"ActiveXObject": true
},
"rules": {
//Possible Errors
"comma-dangle": [2, "never"],
"no-cond-assign": [2, "always"],
"no-console": 1,
"no-constant-condition": 2,
"no-control-regex": 2,
"no-debugger": 2,
"no-dupe-args": 2,
"no-dupe-keys": 2,
"no-duplicate-case": 2,
"no-empty-character-class": 2,
"no-empty": [2, {
"allowEmptyCatch": false
}],
"no-ex-assign": 2,
"no-extra-boolean-cast": 2,
"no-extra-parens": [2, "functions"],
"no-extra-semi": 2,
"no-func-assign": 2,
"no-inner-declarations": [2, "both"],
"no-invalid-regexp": 2,
"no-irregular-whitespace": [2, {
"skipComments": true
}],
"no-negated-in-lhs": 2,
"no-obj-calls": 2,
"no-prototype-builtins": 0,
"no-regex-spaces": 2,
"no-sparse-arrays": 2,
"no-template-curly-in-string": 2,
"no-unexpected-multiline": 2,
"no-unreachable": 2,
"use-isnan": 2,
"valid-jsdoc": [2, {
"prefer": {
"return": "returns"
},
"requireReturnDescription": false,
"requireReturn": false
}],
"valid-typeof": 2,
//Best Practices
"accessor-pairs": [2, {
"getWithoutSet": true
}],
"block-scoped-var": 2,
"complexity": [1, 6],
"consistent-return": 2,
"curly": 2,
"default-case": 2,
"dot-location": [2, "property"],
"dot-notation": [2, {
"allowKeywords": false
}],
"eqeqeq": [2, "always"],
"guard-for-in": 2,
"no-alert": 0,
"no-caller": 2,
"no-case-declarations": 2,
"no-div-regex": 2,
"no-else-return": 2,
"no-empty-pattern": 2,
"no-eq-null": 2,
"no-eval": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-fallthrough": 2,
"no-floating-decimal": 2,
"no-implicit-coercion": [2, {
"boolean": false
}],
"no-implied-eval": 2,
"no-iterator": 2,
"no-labels": 2,
"no-lone-blocks": 2,
"no-loop-func": 2,
"no-multi-spaces": 2,
"no-multi-str": 2,
"no-native-reassign": 2,
"no-new-func": 2,
"no-new-wrappers": 2,
"no-new": 2,
"no-octal-escape": 2,
"no-octal": 2,
"no-param-reassign": 0,
"no-process-env": 2,
"no-proto": 2,
"no-redeclare": 2,
"no-return-assign": [2, "always"],
"no-script-url": 2,
"no-self-compare": 2,
"no-sequences": 2,
"no-throw-literal": 2,
"no-unsafe-finally": 2,
"no-unused-expressions": 2,
"no-useless-call": 2,
"no-useless-concat": 2,
"no-void": 2,
"no-warning-comments": 1,
"no-with": 2,
"radix": 2,
"vars-on-top": 2,
"wrap-iife": [2, "inside"],
"yoda": 2,
"no-useless-escape": 2,
// Strict Mode
"strict": [2, "global"],
// Variables
"init-declarations": 0,
"no-catch-shadow": 2,
"no-delete-var": 2,
"no-label-var": 2,
"no-shadow-restricted-names": 2,
"no-shadow": 2,
"no-undef-init": 2,
"no-undef": 2,
"no-undefined": 2,
"no-unused-vars": 2,
"no-use-before-define": [2, "nofunc"],
"no-restricted-globals": [1, "event", "fdescribe", "fit"],
// Node.js and CommonJS
"global-require": 2,
"handle-callback-err": 2,
"no-mixed-requires": [2, true],
"no-new-require": 2,
"no-path-concat": 2,
"no-process-exit": 2,
"no-restricted-modules": 0,
"no-sync": 0,
//Stylistic Issues
"array-bracket-spacing": [2, "never"],
"block-spacing": [2, "never"],
"brace-style": [2, "1tbs", {
"allowSingleLine": false
}],
"camelcase": 2,
"comma-spacing": [2, {
"before": false,
"after": true
}],
"comma-style": [2, "last"],
"computed-property-spacing": [2, "never"],
"consistent-this": [2, "self"],
"eol-last": 2,
"func-names": 0,
"func-style": 0,
"func-call-spacing": [2, "never"],
"id-length": 0,
"id-match": 0,
"indent": [2, 4, {
"SwitchCase": 1
}],
"jsx-quotes": [2, "prefer-double"],
"key-spacing": [2, {
"beforeColon": false,
"afterColon": true
}],
"keyword-spacing": 2,
"linebreak-style": [2, "unix"],
"lines-around-comment": 0,
"max-depth": [2, 3],
"max-len": [2, 120, 4],
"max-nested-callbacks": [2, 3],
"max-params": [2, 5],
"max-statements": 0,
"multiline-ternary": [2, "never"],
"new-cap": 2,
"new-parens": 2,
"newline-after-var": 0,
"no-array-constructor": 0,
"no-bitwise": 0,
"no-continue": 0,
"no-inline-comments": 0,
"no-lonely-if": 2,
"no-mixed-operators": [2, {
"allowSamePrecedence": true
}],
"no-mixed-spaces-and-tabs": [2, "smart-tabs"],
"no-multiple-empty-lines": [2, {
"max": 2
}],
"no-nested-ternary": 2,
"no-new-object": 2,
"no-plusplus": 2,
"no-restricted-syntax": [2, "WithStatement"],
"no-spaced-func": 2,
"no-tabs": 2,
"no-ternary": 0,
"no-trailing-spaces": 2,
"no-underscore-dangle": 0,
"no-unneeded-ternary": 2,
"object-curly-newline": 0,
"object-curly-spacing": [2, "never"],
"object-property-newline": [2, {
"allowMultiplePropertiesPerLine": false
}],
"one-var": 0,
"operator-assignment": 0,
"operator-linebreak": 0,
"padded-blocks": [2, "never"],
"quote-props": 0,
"quotes": [2, "single", {
"avoidEscape": true,
"allowTemplateLiterals": true
}],
"require-jsdoc": 1,
"semi-spacing": [2, {
"before": false,
"after": true
}],
"semi": 2,
"sort-keys": 0,
"sort-vars": 0,
"space-before-blocks": 2,
"space-before-function-paren": [2, "never"],
"space-in-parens": [2, "never"],
"space-infix-ops": 2,
"space-unary-ops": [2, {
"words": true,
"nonwords": false
}],
"spaced-comment": [2, "always", {
"block": {
"markers": ["*"],
"exceptions": ["*"]
}
}],
"wrap-regex": 0,
"newline-before-return": 1,
"max-statements-per-line": [2, {
"max": 1
}],
"unicode-bom": [2, "never"],
"loadFixtures": true
}
};

@@ -12,3 +12,5 @@ {

"ignore": [
".*",
"**/.*",
"node_modules",
"bower_components",
"examples",

@@ -20,7 +22,8 @@ "src",

"webpack.config.js",
"package.json"
"package.json",
"package-lock.json"
],
"dependencies": {
"tui-code-snippet": "~1.2.5"
"tui-code-snippet": "^1.2.5"
}
}
/*!
* tui-pagination.js
* @version 3.0.0
* @version 3.1.0
* @author NHNEnt FE Development Team <dl_javascript@nhnent.com>

@@ -190,11 +190,2 @@ * @license MIT

/**
* Get current page
* @returns {number} Current page
* @private
*/
_getCurrentPage: function() {
return this._currentPage || this._options.page;
},
/**
* Get last page number

@@ -239,3 +230,3 @@ * @returns {number} Last page number

var isPrevMove = (moveType === 'prev');
var currentPage = this._getCurrentPage();
var currentPage = this.getCurrentPage();

@@ -252,3 +243,3 @@ return isPrevMove ? currentPage - 1 : currentPage + 1;

_getMorePageIndex: function(moveType) {
var currentPageIndex = this._getPageIndex(this._getCurrentPage());
var currentPageIndex = this._getPageIndex(this.getCurrentPage());
var pageCount = this._options.visiblePages;

@@ -417,16 +408,16 @@ var isPrevMove = (moveType === 'prev');

/**
* @event Pagination#beforeMove
* @param {object} eventData - Custom event object
* @param {Number} page - Moved page
* @example
* paganation.on('beforeMove', function(eventData) {
* var currentPage = eventData.page;
*
* if (currentPage === 10) {
* return false;
* // return true;
* }
* });
*/
/**
* @event Pagination#beforeMove
* @param {object} eventData - Custom event object
* @param {Number} page - Moved page
* @example
* paganation.on('beforeMove', function(eventData) {
* var currentPage = eventData.page;
*
* if (currentPage === 10) {
* return false;
* // return true;
* }
* });
*/
if (!this.invoke('beforeMove', {page: targetPage})) {

@@ -465,2 +456,10 @@ return;

this._options.itemsPerPage = itemCount;
},
/**
* Get current page
* @returns {number} Current page
*/
getCurrentPage: function() {
return this._currentPage || this._options.page;
}

@@ -467,0 +466,0 @@ });

/*!
* tui-pagination.min.js
* @version 3.0.0
* @version 3.1.0
* @author NHNEnt FE Development Team <dl_javascript@nhnent.com>
* @license MIT
*/
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("tui-code-snippet")):"function"==typeof define&&define.amd?define(["tui-code-snippet"],e):"object"==typeof exports?exports.Pagination=e(require("tui-code-snippet")):(t.tui=t.tui||{},t.tui.Pagination=e(t.tui&&t.tui.util))}(this,function(t){return function(t){function e(i){if(n[i])return n[i].exports;var s=n[i]={exports:{},id:i,loaded:!1};return t[i].call(s.exports,s,s.exports,e),s.loaded=!0,s.exports}var n={};return e.m=t,e.c=n,e.p="dist",e(0)}([function(t,e,n){"use strict";n(5),t.exports=n(2)},function(e,n){e.exports=t},function(t,e,n){"use strict";var i=n(1),s=n(4),a={totalItems:10,itemsPerPage:10,visiblePages:10,page:1,centerAlign:!1,firstItemClassName:"tui-first-child",lastItemClassName:"tui-last-child"},r=i.defineClass({init:function(t,e){this._options=i.extend({},a,e),this._currentPage=0,this._view=new s(t,this._options,i.bind(this._onClickHandler,this)),this._paginate()},_setCurrentPage:function(t){this._currentPage=t||this._options.page},_getCurrentPage:function(){return this._currentPage||this._options.page},_getLastPage:function(){var t=Math.ceil(this._options.totalItems/this._options.itemsPerPage);return t?t:1},_getPageIndex:function(t){var e,n;return this._options.centerAlign?(e=Math.floor(this._options.visiblePages/2),n=t-e,n=Math.max(n,1),n=Math.min(n,this._getLastPage()-this._options.visiblePages+1)):Math.ceil(t/this._options.visiblePages)},_getRelativePage:function(t){var e="prev"===t,n=this._getCurrentPage();return e?n-1:n+1},_getMorePageIndex:function(t){var e,n=this._getPageIndex(this._getCurrentPage()),i=this._options.visiblePages,s="prev"===t;return e=this._options.centerAlign?s?n-1:n+i:s?(n-1)*i:n*i+1},_convertToValidPage:function(t){var e=this._getLastPage();return t=Math.max(t,1),t=Math.min(t,e)},_paginate:function(t){var e=this._makeViewData(t||this._options.page);this._setCurrentPage(t),this._view.update(e)},_makeViewData:function(t){var e={},n=this._getLastPage(),i=this._getPageIndex(t),s=this._getPageIndex(n),a=this._getEdge(t);return e.leftPageNumber=a.left,e.rightPageNumber=a.right,e.prevMore=i>1,e.nextMore=i<s,e.page=t,e.currentPageIndex=t,e.lastPage=n,e.lastPageListIndex=n,e},_getEdge:function(t){var e,n,i,s=this._getLastPage(),a=this._options.visiblePages,r=this._getPageIndex(t);return this._options.centerAlign?(i=Math.floor(a/2),e=Math.max(t-i,1),n=e+a-1,n>s&&(e=Math.max(s-a+1,1),n=s)):(e=(r-1)*a+1,n=r*a,n=Math.min(n,s)),{left:e,right:n}},_onClickHandler:function(t,e){switch(t){case"first":e=1;break;case"prev":e=this._getRelativePage("prev");break;case"next":e=this._getRelativePage("next");break;case"prevMore":e=this._getMorePageIndex("prev");break;case"nextMore":e=this._getMorePageIndex("next");break;case"last":e=this._getLastPage();break;default:if(!e)return}this.movePageTo(e)},reset:function(t){i.isUndefined(t)&&(t=this._options.totalItems),this._options.totalItems=t,this._paginate(1)},movePageTo:function(t){t=this._convertToValidPage(t),this.invoke("beforeMove",{page:t})&&(this._paginate(t),this.fire("afterMove",{page:t}))},setTotalItems:function(t){this._options.totalItems=t},setItemsPerPage:function(t){this._options.itemsPerPage=t}});i.CustomEvents.mixin(r),t.exports=r},function(t,e,n){"use strict";var i=n(1).isFunction,s={addEventListener:function(t,e,n){t.addEventListener?t.addEventListener(e,n,!1):t.attachEvent("on"+e,n)},preventDefault:function(t){t.preventDefault?t.preventDefault():t.returnValue=!1},getTargetElement:function(t){return t.target||t.srcElement},addClass:function(t,e){t&&(""===t.className?t.className=e:s.hasClass(t,e)||(t.className+=" "+e))},hasClass:function(t,e){var n=s.getClass(t);return n.indexOf(e)>-1},getClass:function(t){return t&&t.getAttribute&&(t.getAttribute("class")||t.getAttribute("className")||"")},capitalizeFirstLetter:function(t){return t.substring(0,1).toUpperCase()+t.substring(1,t.length)},isContained:function(t,e){return!!e&&(t===e||e.contains(t))},replaceTemplate:function(t,e){var n=t.replace(/\{\{(\w*)\}\}/g,function(t,n){return e.hasOwnProperty(n)?e[n]:""});return n},changeTemplateToElement:function(t,e){var n;return n=i(t)?t(e):s.replaceTemplate(t,e),s.getElementFromTemplate(n)},getElementFromTemplate:function(t){var e=document.createElement("div");return e.innerHTML=t,e.children[0]}};t.exports=s},function(t,e,n){"use strict";var i=n(1),s=n(3),a=i.extend,r=i.forEach,o=i.isString,u=i.bind,l=i.isHTMLNode,p={page:'<a href="#" class="tui-page-btn">{{page}}</a>',currentPage:'<strong class="tui-page-btn tui-is-selected">{{page}}</strong>',moveButton:'<a href="#" class="tui-page-btn tui-{{type}}"><span class="tui-ico-{{type}}">{{type}}</span></a>',disabledMoveButton:'<span class="tui-page-btn tui-is-disabled tui-{{type}}"><span class="tui-ico-{{type}}">{{type}}</span></span>',moreButton:'<a href="#" class="tui-page-btn tui-{{type}}-is-ellip"><span class="tui-ico-ellip">...</span></a>'},h=["first","prev","next","last"],g=["prev","next"],c="The container element is invalid.",_=i.defineClass({init:function(t,e,n){this._containerElement=null,this._firstItemClassName=e.firstItemClassName,this._lastItemClassName=e.lastItemClassName,this._template=a({},p,e.template),this._buttons={},this._enabledPageElements=[],this._setRootElement(t),this._setMoveButtons(),this._setDisabledMoveButtons(),this._setMoreButtons(),this._attachClickEvent(n)},_setRootElement:function(t){if(o(t)?t=document.getElementById(t):t.jquery&&(t=t[0]),!l(t))throw new Error(c);this._containerElement=t},_setMoveButtons:function(){var t=this._template.moveButton;r(h,function(e){this._buttons[e]=s.changeTemplateToElement(t,{type:e})},this)},_setDisabledMoveButtons:function(){var t,e=this._template.disabledMoveButton;r(h,function(n){t="disabled"+s.capitalizeFirstLetter(n),this._buttons[t]=s.changeTemplateToElement(e,{type:n})},this)},_setMoreButtons:function(){var t,e=this._template.moreButton;r(g,function(n){t=n+"More",this._buttons[t]=s.changeTemplateToElement(e,{type:n})},this)},_getContainerElement:function(){return this._containerElement},_appendFirstButton:function(t){var e;e=t.page>1?this._buttons.first:this._buttons.disabledFirst,this._getContainerElement().appendChild(e)},_appendPrevButton:function(t){var e;e=t.currentPageIndex>1?this._buttons.prev:this._buttons.disabledPrev,this._getContainerElement().appendChild(e)},_appendNextButton:function(t){var e;e=t.currentPageIndex<t.lastPageListIndex?this._buttons.next:this._buttons.disabledNext,this._getContainerElement().appendChild(e)},_appendLastButton:function(t){var e;e=t.page<t.lastPage?this._buttons.last:this._buttons.disabledLast,this._getContainerElement().appendChild(e)},_appendPrevMoreButton:function(t){var e;t.prevMore&&(e=this._buttons.prevMore,s.addClass(e,this._firstItemClassName),this._getContainerElement().appendChild(e))},_appendNextMoreButton:function(t){var e;t.nextMore&&(e=this._buttons.nextMore,s.addClass(e,this._lastItemClassName),this._getContainerElement().appendChild(e))},_appendPages:function(t){var e,n,i=this._template,a=t.leftPageNumber,r=t.rightPageNumber;for(n=a;n<=r;n+=1)n===t.page?e=s.changeTemplateToElement(i.currentPage,{page:n}):(e=s.changeTemplateToElement(i.page,{page:n}),this._enabledPageElements.push(e)),n!==a||t.prevMore||s.addClass(e,this._firstItemClassName),n!==r||t.nextMore||s.addClass(e,this._lastItemClassName),this._getContainerElement().appendChild(e)},_attachClickEvent:function(t){var e=this._getContainerElement();s.addEventListener(e,"click",u(function(e){var n,i,a=s.getTargetElement(e);s.preventDefault(e),i=this._getButtonType(a),i||(n=this._getPageNumber(a)),t(i,n)},this))},_getButtonType:function(t){var e,n=this._buttons;return r(n,function(n,i){return!s.isContained(t,n)||(e=i,!1)},this),e},_getPageNumber:function(t){var e,n=this._findPageElement(t);return n&&(e=parseInt(n.innerText,10)),e},_findPageElement:function(t){var e,n,i;for(e=0,n=this._enabledPageElements.length;e<n;e+=1)if(i=this._enabledPageElements[e],s.isContained(t,i))return i;return null},_empty:function(){this._enabledPageElements=[],r(this._buttons,function(t,e){this._buttons[e]=t.cloneNode(!0)},this),this._getContainerElement().innerHTML=""},update:function(t){this._empty(),this._appendFirstButton(t),this._appendPrevButton(t),this._appendPrevMoreButton(t),this._appendPages(t),this._appendNextMoreButton(t),this._appendNextButton(t),this._appendLastButton(t)}});t.exports=_},function(t,e){}])});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("tui-code-snippet")):"function"==typeof define&&define.amd?define(["tui-code-snippet"],e):"object"==typeof exports?exports.Pagination=e(require("tui-code-snippet")):(t.tui=t.tui||{},t.tui.Pagination=e(t.tui&&t.tui.util))}(this,function(t){return function(t){function e(i){if(n[i])return n[i].exports;var s=n[i]={exports:{},id:i,loaded:!1};return t[i].call(s.exports,s,s.exports,e),s.loaded=!0,s.exports}var n={};return e.m=t,e.c=n,e.p="dist",e(0)}([function(t,e,n){"use strict";n(5),t.exports=n(2)},function(e,n){e.exports=t},function(t,e,n){"use strict";var i=n(1),s=n(4),a={totalItems:10,itemsPerPage:10,visiblePages:10,page:1,centerAlign:!1,firstItemClassName:"tui-first-child",lastItemClassName:"tui-last-child"},r=i.defineClass({init:function(t,e){this._options=i.extend({},a,e),this._currentPage=0,this._view=new s(t,this._options,i.bind(this._onClickHandler,this)),this._paginate()},_setCurrentPage:function(t){this._currentPage=t||this._options.page},_getLastPage:function(){var t=Math.ceil(this._options.totalItems/this._options.itemsPerPage);return t?t:1},_getPageIndex:function(t){var e,n;return this._options.centerAlign?(e=Math.floor(this._options.visiblePages/2),n=t-e,n=Math.max(n,1),n=Math.min(n,this._getLastPage()-this._options.visiblePages+1)):Math.ceil(t/this._options.visiblePages)},_getRelativePage:function(t){var e="prev"===t,n=this.getCurrentPage();return e?n-1:n+1},_getMorePageIndex:function(t){var e,n=this._getPageIndex(this.getCurrentPage()),i=this._options.visiblePages,s="prev"===t;return e=this._options.centerAlign?s?n-1:n+i:s?(n-1)*i:n*i+1},_convertToValidPage:function(t){var e=this._getLastPage();return t=Math.max(t,1),t=Math.min(t,e)},_paginate:function(t){var e=this._makeViewData(t||this._options.page);this._setCurrentPage(t),this._view.update(e)},_makeViewData:function(t){var e={},n=this._getLastPage(),i=this._getPageIndex(t),s=this._getPageIndex(n),a=this._getEdge(t);return e.leftPageNumber=a.left,e.rightPageNumber=a.right,e.prevMore=i>1,e.nextMore=i<s,e.page=t,e.currentPageIndex=t,e.lastPage=n,e.lastPageListIndex=n,e},_getEdge:function(t){var e,n,i,s=this._getLastPage(),a=this._options.visiblePages,r=this._getPageIndex(t);return this._options.centerAlign?(i=Math.floor(a/2),e=Math.max(t-i,1),n=e+a-1,n>s&&(e=Math.max(s-a+1,1),n=s)):(e=(r-1)*a+1,n=r*a,n=Math.min(n,s)),{left:e,right:n}},_onClickHandler:function(t,e){switch(t){case"first":e=1;break;case"prev":e=this._getRelativePage("prev");break;case"next":e=this._getRelativePage("next");break;case"prevMore":e=this._getMorePageIndex("prev");break;case"nextMore":e=this._getMorePageIndex("next");break;case"last":e=this._getLastPage();break;default:if(!e)return}this.movePageTo(e)},reset:function(t){i.isUndefined(t)&&(t=this._options.totalItems),this._options.totalItems=t,this._paginate(1)},movePageTo:function(t){t=this._convertToValidPage(t),this.invoke("beforeMove",{page:t})&&(this._paginate(t),this.fire("afterMove",{page:t}))},setTotalItems:function(t){this._options.totalItems=t},setItemsPerPage:function(t){this._options.itemsPerPage=t},getCurrentPage:function(){return this._currentPage||this._options.page}});i.CustomEvents.mixin(r),t.exports=r},function(t,e,n){"use strict";var i=n(1).isFunction,s={addEventListener:function(t,e,n){t.addEventListener?t.addEventListener(e,n,!1):t.attachEvent("on"+e,n)},preventDefault:function(t){t.preventDefault?t.preventDefault():t.returnValue=!1},getTargetElement:function(t){return t.target||t.srcElement},addClass:function(t,e){t&&(""===t.className?t.className=e:s.hasClass(t,e)||(t.className+=" "+e))},hasClass:function(t,e){var n=s.getClass(t);return n.indexOf(e)>-1},getClass:function(t){return t&&t.getAttribute&&(t.getAttribute("class")||t.getAttribute("className")||"")},capitalizeFirstLetter:function(t){return t.substring(0,1).toUpperCase()+t.substring(1,t.length)},isContained:function(t,e){return!!e&&(t===e||e.contains(t))},replaceTemplate:function(t,e){var n=t.replace(/\{\{(\w*)\}\}/g,function(t,n){return e.hasOwnProperty(n)?e[n]:""});return n},changeTemplateToElement:function(t,e){var n;return n=i(t)?t(e):s.replaceTemplate(t,e),s.getElementFromTemplate(n)},getElementFromTemplate:function(t){var e=document.createElement("div");return e.innerHTML=t,e.children[0]}};t.exports=s},function(t,e,n){"use strict";var i=n(1),s=n(3),a=i.extend,r=i.forEach,o=i.isString,u=i.bind,l=i.isHTMLNode,p={page:'<a href="#" class="tui-page-btn">{{page}}</a>',currentPage:'<strong class="tui-page-btn tui-is-selected">{{page}}</strong>',moveButton:'<a href="#" class="tui-page-btn tui-{{type}}"><span class="tui-ico-{{type}}">{{type}}</span></a>',disabledMoveButton:'<span class="tui-page-btn tui-is-disabled tui-{{type}}"><span class="tui-ico-{{type}}">{{type}}</span></span>',moreButton:'<a href="#" class="tui-page-btn tui-{{type}}-is-ellip"><span class="tui-ico-ellip">...</span></a>'},h=["first","prev","next","last"],g=["prev","next"],c="The container element is invalid.",_=i.defineClass({init:function(t,e,n){this._containerElement=null,this._firstItemClassName=e.firstItemClassName,this._lastItemClassName=e.lastItemClassName,this._template=a({},p,e.template),this._buttons={},this._enabledPageElements=[],this._setRootElement(t),this._setMoveButtons(),this._setDisabledMoveButtons(),this._setMoreButtons(),this._attachClickEvent(n)},_setRootElement:function(t){if(o(t)?t=document.getElementById(t):t.jquery&&(t=t[0]),!l(t))throw new Error(c);this._containerElement=t},_setMoveButtons:function(){var t=this._template.moveButton;r(h,function(e){this._buttons[e]=s.changeTemplateToElement(t,{type:e})},this)},_setDisabledMoveButtons:function(){var t,e=this._template.disabledMoveButton;r(h,function(n){t="disabled"+s.capitalizeFirstLetter(n),this._buttons[t]=s.changeTemplateToElement(e,{type:n})},this)},_setMoreButtons:function(){var t,e=this._template.moreButton;r(g,function(n){t=n+"More",this._buttons[t]=s.changeTemplateToElement(e,{type:n})},this)},_getContainerElement:function(){return this._containerElement},_appendFirstButton:function(t){var e;e=t.page>1?this._buttons.first:this._buttons.disabledFirst,this._getContainerElement().appendChild(e)},_appendPrevButton:function(t){var e;e=t.currentPageIndex>1?this._buttons.prev:this._buttons.disabledPrev,this._getContainerElement().appendChild(e)},_appendNextButton:function(t){var e;e=t.currentPageIndex<t.lastPageListIndex?this._buttons.next:this._buttons.disabledNext,this._getContainerElement().appendChild(e)},_appendLastButton:function(t){var e;e=t.page<t.lastPage?this._buttons.last:this._buttons.disabledLast,this._getContainerElement().appendChild(e)},_appendPrevMoreButton:function(t){var e;t.prevMore&&(e=this._buttons.prevMore,s.addClass(e,this._firstItemClassName),this._getContainerElement().appendChild(e))},_appendNextMoreButton:function(t){var e;t.nextMore&&(e=this._buttons.nextMore,s.addClass(e,this._lastItemClassName),this._getContainerElement().appendChild(e))},_appendPages:function(t){var e,n,i=this._template,a=t.leftPageNumber,r=t.rightPageNumber;for(n=a;n<=r;n+=1)n===t.page?e=s.changeTemplateToElement(i.currentPage,{page:n}):(e=s.changeTemplateToElement(i.page,{page:n}),this._enabledPageElements.push(e)),n!==a||t.prevMore||s.addClass(e,this._firstItemClassName),n!==r||t.nextMore||s.addClass(e,this._lastItemClassName),this._getContainerElement().appendChild(e)},_attachClickEvent:function(t){var e=this._getContainerElement();s.addEventListener(e,"click",u(function(e){var n,i,a=s.getTargetElement(e);s.preventDefault(e),i=this._getButtonType(a),i||(n=this._getPageNumber(a)),t(i,n)},this))},_getButtonType:function(t){var e,n=this._buttons;return r(n,function(n,i){return!s.isContained(t,n)||(e=i,!1)},this),e},_getPageNumber:function(t){var e,n=this._findPageElement(t);return n&&(e=parseInt(n.innerText,10)),e},_findPageElement:function(t){var e,n,i;for(e=0,n=this._enabledPageElements.length;e<n;e+=1)if(i=this._enabledPageElements[e],s.isContained(t,i))return i;return null},_empty:function(){this._enabledPageElements=[],r(this._buttons,function(t,e){this._buttons[e]=t.cloneNode(!0)},this),this._getContainerElement().innerHTML=""},update:function(t){this._empty(),this._appendFirstButton(t),this._appendPrevButton(t),this._appendPrevMoreButton(t),this._appendPages(t),this._appendNextMoreButton(t),this._appendNextButton(t),this._appendLastButton(t)}});t.exports=_},function(t,e){}])});
{
"source": {
"include": ["src", "README.md"],
"exclude": [],
"includePattern": ".+\\.js(doc)?$",
"excludePattern": "(^|\\/|\\\\)_"
},
"plugins": ["plugins/markdown"],
"templates": {
"name": "Pagination",
"logo": {
"url": "https://cloud.githubusercontent.com/assets/12269563/20029815/01133928-a39a-11e6-80f3-12500a91c755.png",
"width": "150px",
"height": "13px",
"link": "https://github.com/nhnent/tui.jsdoc-template"
}
},
"opts": {
"recurse": true,
"destination": "doc",
"tutorials": "examples",
"template": "./node_modules/tui-jsdoc-template"
"source": {
"include": [
"src",
"README.md"
],
"exclude": [],
"includePattern": ".+\\.js(doc)?$",
"excludePattern": "(^|\\/|\\\\)_"
},
"plugins": [
"plugins/markdown"
],
"templates": {
"name": "Pagination",
"logo": {
"url": "https://cloud.githubusercontent.com/assets/12269563/20029815/01133928-a39a-11e6-80f3-12500a91c755.png",
"width": "150px",
"height": "13px",
"link": "https://github.com/nhnent/tui.jsdoc-template"
}
},
"opts": {
"private": false,
"recurse": true,
"destination": "doc",
"tutorials": "examples",
"template": "./node_modules/tui-jsdoc-template",
"package": "package.json"
}
}

@@ -0,4 +1,8 @@

/**
* Config file for testing
* @author NHN Ent. FE Development Lab <dl_javascript@nhnent.com>
*/
var pkg = require('./package.json');
var webpack = require('webpack');
'use strict';
var webdriverConfig = {

@@ -10,2 +14,7 @@ hostname: 'fe.nhnent.com',

/**
* Set config by environment
* @param {object} defaultConfig - default config
* @param {string} server - server type ('ne' or local)
*/
function setConfig(defaultConfig, server) {

@@ -18,3 +27,3 @@ if (server === 'ne') {

browserName: 'internet explorer',
version: 8
version: '8'
},

@@ -25,3 +34,3 @@ 'IE9': {

browserName: 'internet explorer',
version: 9
version: '9'
},

@@ -32,3 +41,3 @@ 'IE10': {

browserName: 'internet explorer',
version: 10
version: '10'
},

@@ -39,3 +48,3 @@ 'IE11': {

browserName: 'internet explorer',
version: 11
version: '11'
},

@@ -63,4 +72,6 @@ 'Edge': {

'IE11',
'Edge',
'Chrome-WebDriver',
'Firefox-WebDriver'
// 'Safari-WebDriver' // active only when safari test is needed
];

@@ -88,3 +99,3 @@ defaultConfig.reporters.push('coverage');

defaultConfig.junitReporter = {
outputDir: 'report',
outputDir: 'report/junit',
suite: ''

@@ -94,3 +105,3 @@ };

defaultConfig.browsers = [
'Chrome'
'ChromeHeadless'
];

@@ -117,2 +128,7 @@ }

test: /\.js$/,
exclude: /(test|bower_components|node_modules)/,
loader: 'istanbul-instrumenter'
},
{
test: /\.js$/,
include: /src/,

@@ -131,6 +147,3 @@ exclude: /(bower_components|node_modules)/,

]
},
plugins: [
new webpack.HotModuleReplacementPlugin()
]
}
},

@@ -144,4 +157,5 @@ port: 9876,

/* eslint-disable */
setConfig(defaultConfig, process.env.KARMA_SERVER);
config.set(defaultConfig);
};
{
"name": "tui-pagination",
"version": "3.0.0",
"version": "3.1.0",
"description": "TOAST UI Components: Pagination",

@@ -31,3 +31,3 @@ "main": "dist/tui-pagination",

"es5-shim": "^4.5.9",
"eslint": "^3.10.2",
"eslint": "^4.5.0",
"eslint-config-tui": "^1.0.1",

@@ -37,18 +37,16 @@ "eslint-loader": "^1.6.1",

"file-loader": "^0.9.0",
"jasmine-ajax": "^3.2.0",
"jasmine-core": "^2.3.4",
"jasmine-jquery": "^2.0.5",
"jsdoc": "git+https://github.com/jsdoc3/jsdoc.git",
"istanbul-instrumenter-loader": "^1.0.0",
"jasmine-core": "^2.4.1",
"jasmine-jquery": "^2.1.0",
"jsdoc": "^3.5.4",
"karma": "1.3.0",
"karma-es5-shim": "0.0.4",
"karma-chrome-launcher": "^2.0.0",
"karma-coverage": "latest",
"karma-firefox-launcher": "^1.0.0",
"karma-coverage": "^1.1.1",
"karma-es5-shim": "^0.0.4",
"karma-jasmine": "^1.0.2",
"karma-junit-reporter": "^1.1.0",
"karma-jasmine-jquery": "^0.1.1",
"karma-jquery": "^0.2.2",
"karma-mocha-reporter": "latest",
"karma-phantomjs-launcher": "^1.0.2",
"karma-junit-reporter": "^1.2.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-webdriver-launcher": "git+https://github.com/nhnent/karma-webdriver-launcher.git",
"karma-webdriver-launcher": "git+https://github.com/nhnent/karma-webdriver-launcher.git#v1.1.0",
"karma-webpack": "^1.8.0",

@@ -55,0 +53,0 @@ "safe-umd-webpack-plugin": "^0.0.1",

# Pagination
Components to make page list and provide indicator of pages
Component to make page list and provide indicator of pages

@@ -16,3 +16,3 @@ ## Feature

## Dependency
* tui-code-snippet ~1.2.5
* [tui-code-snippet](https://github.com/nhnent/tui.code-snippet) >=1.2.5

@@ -22,4 +22,6 @@ ## Test Environment

* IE8~11
* Edge
* Chrome
* Firefox
* Safari

@@ -38,3 +40,3 @@ ## Usage

```
$ npm install tui-pagination@<tag> --save
$ npm install tui-pagination@<version> --save
```

@@ -41,0 +43,0 @@

@@ -102,11 +102,2 @@ 'use strict';

/**
* Get current page
* @returns {number} Current page
* @private
*/
_getCurrentPage: function() {
return this._currentPage || this._options.page;
},
/**
* Get last page number

@@ -151,3 +142,3 @@ * @returns {number} Last page number

var isPrevMove = (moveType === 'prev');
var currentPage = this._getCurrentPage();
var currentPage = this.getCurrentPage();

@@ -164,3 +155,3 @@ return isPrevMove ? currentPage - 1 : currentPage + 1;

_getMorePageIndex: function(moveType) {
var currentPageIndex = this._getPageIndex(this._getCurrentPage());
var currentPageIndex = this._getPageIndex(this.getCurrentPage());
var pageCount = this._options.visiblePages;

@@ -329,16 +320,16 @@ var isPrevMove = (moveType === 'prev');

/**
* @event Pagination#beforeMove
* @param {object} eventData - Custom event object
* @param {Number} page - Moved page
* @example
* paganation.on('beforeMove', function(eventData) {
* var currentPage = eventData.page;
*
* if (currentPage === 10) {
* return false;
* // return true;
* }
* });
*/
/**
* @event Pagination#beforeMove
* @param {object} eventData - Custom event object
* @param {Number} page - Moved page
* @example
* paganation.on('beforeMove', function(eventData) {
* var currentPage = eventData.page;
*
* if (currentPage === 10) {
* return false;
* // return true;
* }
* });
*/
if (!this.invoke('beforeMove', {page: targetPage})) {

@@ -377,2 +368,10 @@ return;

this._options.itemsPerPage = itemCount;
},
/**
* Get current page
* @returns {number} Current page
*/
getCurrentPage: function() {
return this._currentPage || this._options.page;
}

@@ -379,0 +378,0 @@ });

@@ -39,7 +39,7 @@ 'use strict';

var page1, page2, page3;
page1 = pagination1._getCurrentPage();
page1 = pagination1.getCurrentPage();
expect(page1).toBe(1); // default
page2 = pagination2._getCurrentPage();
page2 = pagination2.getCurrentPage();
expect(page2).toBe(22);
page3 = pagination3._getCurrentPage();
page3 = pagination3.getCurrentPage();
expect(page3).toBe(15);

@@ -92,15 +92,15 @@ });

pagination2.movePageTo(1);
page1 = pagination2._getCurrentPage();
page1 = pagination2.getCurrentPage();
expect(page1).toBe(1);
pagination2.movePageTo(2);
page2 = pagination2._getCurrentPage();
page2 = pagination2.getCurrentPage();
expect(page2).toBe(2);
pagination2.movePageTo(3);
page3 = pagination2._getCurrentPage();
page3 = pagination2.getCurrentPage();
expect(page3).toBe(3);
pagination2.movePageTo(100);
page4 = pagination2._getCurrentPage();
page4 = pagination2.getCurrentPage();
lastPage = pagination2._getLastPage();

@@ -114,3 +114,3 @@ expect(page4).toBe(lastPage);

pagination3.reset();
currentPage = pagination3._getCurrentPage();
currentPage = pagination3.getCurrentPage();
expect(currentPage).toBe(1);

@@ -141,3 +141,3 @@

var mock = jasmine.createSpy('"beforeMove" handler').and.returnValue(false);
var prevPage = pagination2._getCurrentPage();
var prevPage = pagination2.getCurrentPage();
var currentPage;

@@ -148,3 +148,3 @@

currentPage = pagination2._getCurrentPage();
currentPage = pagination2.getCurrentPage();
expect(currentPage).toBe(prevPage);

@@ -156,3 +156,3 @@ });

var mock = jasmine.createSpy('"beforeMove" handler').and.returnValue(true);
var prevPage = pagination2._getCurrentPage();
var prevPage = pagination2.getCurrentPage();
var currentPage;

@@ -163,3 +163,3 @@

currentPage = pagination2._getCurrentPage();
currentPage = pagination2.getCurrentPage();
expect(currentPage).not.toBe(prevPage);

@@ -185,3 +185,3 @@ });

currentPage = pagination3._getCurrentPage();
currentPage = pagination3.getCurrentPage();
expect(currentPage).toBe(1);

@@ -191,3 +191,3 @@ });

it('When the "prev" move button is clicked, the page is changed to previous page.', function() {
var prevPage = pagination3._getCurrentPage();
var prevPage = pagination3.getCurrentPage();
var currentPage;

@@ -197,3 +197,3 @@

currentPage = pagination3._getCurrentPage();
currentPage = pagination3.getCurrentPage();
expect(currentPage).toBe(prevPage - 1);

@@ -203,3 +203,3 @@ });

it('When the "next" move button is clicked, the page is changed to next page.', function() {
var prevPage = pagination3._getCurrentPage();
var prevPage = pagination3.getCurrentPage();
var currentPage;

@@ -209,3 +209,3 @@

currentPage = pagination3._getCurrentPage();
currentPage = pagination3.getCurrentPage();
expect(currentPage).toBe(prevPage + 1);

@@ -220,3 +220,3 @@ });

currentPage = pagination3._getCurrentPage();
currentPage = pagination3.getCurrentPage();
expect(currentPage).toBe(lastPage);

@@ -231,3 +231,3 @@ });

currentPage = pagination3._getCurrentPage();
currentPage = pagination3.getCurrentPage();
expect(currentPage).toBe(9); // first page of current page list is 10 -> 9

@@ -242,3 +242,3 @@ });

currentPage = pagination3._getCurrentPage();
currentPage = pagination3.getCurrentPage();
expect(currentPage).toBe(21); // last page of current page list is 20 -> 21

@@ -248,3 +248,3 @@ });

it('When the page is clicked and is enabled, the current page is changed.', function() {
var prevPage = pagination3._getCurrentPage();
var prevPage = pagination3.getCurrentPage();
var currentPage;

@@ -254,3 +254,3 @@

currentPage = pagination3._getCurrentPage();
currentPage = pagination3.getCurrentPage();
expect(currentPage).not.toBe(prevPage);

@@ -263,7 +263,7 @@ });

pagination3.movePageTo(3);
prevPage = pagination3._getCurrentPage();
prevPage = pagination3.getCurrentPage();
pagination3._onClickHandler(null, 3);
currentPage = pagination3._getCurrentPage();
currentPage = pagination3.getCurrentPage();
expect(currentPage).toBe(prevPage);

@@ -270,0 +270,0 @@ });

/**
* webpack.config.js updated on 2017. 07
* Configs file for bundling
* @author NHN Ent. FE Development Lab <dl_javascript@nhnent.com>
*/
'use strict';
/* eslint-disable vars-on-top, no-process-env, require-jsdoc */
var pkg = require('./package.json');

@@ -9,0 +9,0 @@ var webpack = require('webpack');

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc