Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pagination] disabled prop #456

Merged
merged 15 commits into from May 26, 2017
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/components/input-group-addon.vue
@@ -1,5 +1,5 @@
<template>
<div class="input-group-addon" :id="id">
<div class="input-group-addon" :id="id || null">
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how this got in this PR, but it is OK.

<slot></slot>
</div>
</template>
Expand Down
27 changes: 21 additions & 6 deletions lib/components/pagination.vue
@@ -1,7 +1,7 @@
<template>
<ul :class="['pagination',btnSize]"
role="group"
tabindex="0"
:aria-disabled="disabled ? 'true' : 'false'"
:aria-label="ariaLabel ? ariaLabel : null"
@focusin.self="focusCurrent"
@keydown.left.prevent="focusPrev"
Expand All @@ -10,7 +10,7 @@
@keydown.shift.right.prevent="focusLast"
>

<li v-if="isActive(1)" class="page-item disabled" aria-hidden="true">
<li v-if="isActive(1) || disabled" class="page-item disabled" aria-hidden="true">
<span class="page-link">&laquo;</span>
</li>
<li v-else class="page-item">
Expand All @@ -27,7 +27,9 @@

<li v-if="showPrev" class="page-item">
<a role="button"
:class="['page-link', isActive(1)?'active':'']"
:class="['page-link', {disabled}, isActive(1)?'active':'']"
:disabled="disabled"
:aria-disabled="disabled ? 'true' : 'false'"
:aria-label="labelPage + ' 1'"
:aria-current="isActive(1) ? 'true' : 'false'"
:aria-posinset="1"
Expand All @@ -45,7 +47,9 @@

<li class="page-item" v-for="_,index in pageLinks" :key="index">
<a role="button"
:class="['page-link', isActive(index + diff)?'active':'' , isActive(index + diff)?'':'hidden-xs-down']"
:class="['page-link',{disabled},isActive(index + diff)?'active':'',isActive(index + diff)?'':'hidden-xs-down']"
:disabled="disabled"
:aria-disabled="disabled ? 'true' : 'false'"
:aria-label="labelPage + ' ' + (index + diff)"
:aria-current="isActive(index + diff) ? 'true' : 'false'"
:aria-posinset="index + diff"
Expand All @@ -63,7 +67,9 @@

<li class="page-item" v-if="showNext">
<a role="button"
:class="['page-link', isActive(numberOfPages) ? 'active' : '']"
:class="['page-link', {disabled}, isActive(numberOfPages) ? 'active' : '']"
:disabled="disabled"
:aria-disabled="disabled ? 'true' : 'false'"
:aria-label="labelPage + ' ' + numberOfPages"
:aria-current="isActive(numberOfPages) ? 'true' : 'false'"
:aria-posinset="numberOfPages"
Expand All @@ -75,7 +81,7 @@
>{{numberOfPages}}</a>
</li>

<li v-if="isActive(numberOfPages)" class="page-item disabled" aria-hidden="true">
<li v-if="isActive(numberOfPages) || disabled" class="page-item disabled" aria-hidden="true">
<span class="page-link">&raquo;</span>
</li>
<li v-else class="page-item">
Expand Down Expand Up @@ -155,6 +161,11 @@
return page === this.currentPage;
},
setPage(e, num) {
if (disabled) {
e.preventDefault();
e.stopPropagation();
return;
}
this.currentPage = num;
this.$nextTick(() => {
// Keep the current button focused if possible
Expand Down Expand Up @@ -230,6 +241,10 @@
}
},
props: {
disabled: {
type: Boolean,
default: 3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this is 3 ? :))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, Typo

},
value: {
type: Number,
default: 1
Expand Down