Skip to content

Commit 44e6d18

Browse files
committed
Fix IE Compatibility Issue
1 parent 591a3e3 commit 44e6d18

File tree

1 file changed

+72
-72
lines changed

1 file changed

+72
-72
lines changed

src/laravel-vue-pagination.js

Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,82 @@
11
module.exports = {
2-
props: {
3-
data: {
4-
type: Object,
5-
default: function() {
6-
return {
7-
current_page: 1,
8-
data: [],
9-
from: 1,
10-
last_page: 1,
11-
next_page_url: null,
12-
per_page: 10,
13-
prev_page_url: null,
14-
to: 1,
15-
total: 0,
16-
}
17-
}
18-
},
19-
limit: {
20-
type: Number,
21-
default: 0
22-
}
23-
},
2+
props: {
3+
data: {
4+
type: Object,
5+
default: function() {
6+
return {
7+
current_page: 1,
8+
data: [],
9+
from: 1,
10+
last_page: 1,
11+
next_page_url: null,
12+
per_page: 10,
13+
prev_page_url: null,
14+
to: 1,
15+
total: 0,
16+
}
17+
}
18+
},
19+
limit: {
20+
type: Number,
21+
default: 0
22+
}
23+
},
2424

25-
template: '<ul class="pagination" v-if="data.total > data.per_page">\
26-
<li class="page-item" v-if="data.prev_page_url">\
27-
<a class="page-link" href="#" aria-label="Previous" @click.prevent="selectPage(--data.current_page)"><span aria-hidden="true">&laquo;</span></a>\
28-
</li>\
29-
<li class="page-item" v-for="n in getPages()" :class="{ \'active\': n == data.current_page }"><a class="page-link" href="#" @click.prevent="selectPage(n)">{{ n }}</a></li>\
30-
<li class="page-item" v-if="data.next_page_url">\
31-
<a class="page-link" href="#" aria-label="Next" @click.prevent="selectPage(++data.current_page)"><span aria-hidden="true">&raquo;</span></a>\
32-
</li>\
33-
</ul>',
25+
template: '<ul class="pagination" v-if="data.total > data.per_page">\
26+
<li class="page-item" v-if="data.prev_page_url">\
27+
<a class="page-link" href="#" aria-label="Previous" @click.prevent="selectPage(--data.current_page)"><span aria-hidden="true">&laquo;</span></a>\
28+
</li>\
29+
<li class="page-item" v-for="n in getPages()" :class="{ \'active\': n == data.current_page }"><a class="page-link" href="#" @click.prevent="selectPage(n)">{{ n }}</a></li>\
30+
<li class="page-item" v-if="data.next_page_url">\
31+
<a class="page-link" href="#" aria-label="Next" @click.prevent="selectPage(++data.current_page)"><span aria-hidden="true">&raquo;</span></a>\
32+
</li>\
33+
</ul>',
3434

35-
methods: {
36-
selectPage: function(page) {
37-
if (page === '...') {
38-
return;
39-
}
35+
methods: {
36+
selectPage: function(page) {
37+
if (page === '...') {
38+
return;
39+
}
4040

41-
this.$emit('pagination-change-page', page);
42-
},
43-
getPages: function() {
44-
if (this.limit === -1) {
45-
return 0;
46-
}
41+
this.$emit('pagination-change-page', page);
42+
},
43+
getPages: function() {
44+
if (this.limit === -1) {
45+
return 0;
46+
}
4747

48-
if (this.limit === 0) {
49-
return this.data.last_page;
50-
}
48+
if (this.limit === 0) {
49+
return this.data.last_page;
50+
}
5151

52-
var current = this.data.current_page,
53-
last = this.data.last_page,
54-
delta = this.limit,
55-
left = current - delta,
56-
right = current + delta + 1,
57-
range = [],
58-
pages = [],
59-
l;
52+
var current = this.data.current_page,
53+
last = this.data.last_page,
54+
delta = this.limit,
55+
left = current - delta,
56+
right = current + delta + 1,
57+
range = [],
58+
pages = [],
59+
l;
6060

61-
for (var i = 1; i <= last; i++) {
62-
if (i == 1 || i == last || (i >= left && i < right)) {
63-
range.push(i);
64-
}
65-
}
61+
for (var i = 1; i <= last; i++) {
62+
if (i == 1 || i == last || (i >= left && i < right)) {
63+
range.push(i);
64+
}
65+
}
6666

67-
for (var i of range) {
68-
if (l) {
69-
if (i - l === 2) {
70-
pages.push(l + 1);
71-
} else if (i - l !== 1) {
72-
pages.push('...');
73-
}
74-
}
75-
pages.push(i);
76-
l = i;
77-
}
67+
range.forEach(function (i) {
68+
if (l) {
69+
if (i - l === 2) {
70+
pages.push(l + 1);
71+
} else if (i - l !== 1) {
72+
pages.push('...');
73+
}
74+
}
75+
pages.push(i);
76+
l = i;
77+
});
7878

79-
return pages;
80-
}
81-
}
79+
return pages;
80+
}
81+
}
8282
};

0 commit comments

Comments
 (0)