Skip to content

Commit

Permalink
AUI-1264 - Source formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Mak committed Apr 16, 2014
1 parent 30ec805 commit fe259c3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
1 change: 0 additions & 1 deletion src/aui-pagination/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ AUI Pagination
@VERSION@
------
* #AUI-1106 - Image Viewer Gallery styling issues

* #AUI-1264 - Add skip to first and last page buttons
31 changes: 18 additions & 13 deletions src/aui-pagination/js/aui-pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ var Pagination = A.Component.create({
},

/**
* Shift increments page index by the value. Set to 0 if Prev and Next
* Shift increments page index by the value. Set to 0 if Prev and Next
* are the only controls. Set to 1 if controls contain First, Last,
* Prev, and Next.
*
Expand Down Expand Up @@ -475,6 +475,7 @@ var Pagination = A.Component.create({
}

var items = instance.get('items'),
shift = instance.get('shift'),
index = items.indexOf(item),
lastIndex = items.size() - 1,
nextIndex = items.size() - 2;
Expand All @@ -493,12 +494,12 @@ var Pagination = A.Component.create({
break;
case lastIndex:
instance._dispatchRequest({
page: items.size() - (instance.TOTAL_CONTROLS / 2) - instance.get('shift') - 1
page: items.size() - (instance.TOTAL_CONTROLS / 2) - shift - 1
});
break;
default:
instance._dispatchRequest({
page: index - instance.get('shift')
page: (index - shift)
});
break;
}
Expand Down Expand Up @@ -538,12 +539,12 @@ var Pagination = A.Component.create({
buffer = '';

buffer += Lang.sub(tpl, {
content: instance.getString('first') ? instance.getString('first') : '«',
content: instance.getString('first') || '«',
cssClass: CSS_PAGINATION_CONTROL
});

buffer += Lang.sub(tpl, {
content: instance.getString('prev') ? instance.getString('prev') : '‹',
content: instance.getString('prev') || '‹',
cssClass: CSS_PAGINATION_CONTROL
});

Expand All @@ -552,12 +553,12 @@ var Pagination = A.Component.create({
}

buffer += Lang.sub(tpl, {
content: instance.getString('next') ? instance.getString('next') : '›',
content: instance.getString('next') || '›',
cssClass: CSS_PAGINATION_CONTROL
});

buffer += Lang.sub(tpl, {
content: instance.getString('last') ? instance.getString('last') : '»',
content: instance.getString('last') || '»',
cssClass: CSS_PAGINATION_CONTROL
});

Expand Down Expand Up @@ -597,21 +598,25 @@ var Pagination = A.Component.create({
*/
_syncNavigationUI: function() {
var instance = this,
items = instance.get('items');
items = instance.get('items'),
page = instance.get('page'),
total = instance.get('total'),
isFirst = (page === 1),
isLast = (page === total);

if (!instance.get('circular')) {
items.item(1).toggleClass(
CSS_DISABLED, instance.get('page') === 1);
CSS_DISABLED, isFirst);

items.item(items.size()-2).toggleClass(
CSS_DISABLED, instance.get('page') === instance.get('total'));
items.item(items.size() - 2).toggleClass(
CSS_DISABLED, isLast);
}

items.first().toggleClass(
CSS_DISABLED, instance.get('page') === 1);
CSS_DISABLED, isFirst);

items.last().toggleClass(
CSS_DISABLED, instance.get('page') === instance.get('total'));
CSS_DISABLED, isLast);
},

/**
Expand Down
2 changes: 1 addition & 1 deletion src/aui-pagination/tests/unit/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h1>AUI Pagination Tests</h1>

<div id="pagination"></div>

<div id="pagination_first_last"></div>
<div id="paginationFirstLast"></div>
</div>
</div>
</div>
Expand Down
14 changes: 6 additions & 8 deletions src/aui-pagination/tests/unit/js/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ YUI.add('aui-pagination-tests', function(Y) {
total: 10
}).render();

var pagination_first_last = new Y.Pagination({
boundingBox: '#pagination_first_last',
var paginationFirstLast = new Y.Pagination({
boundingBox: '#paginationFirstLast',
total: 10
}).render();

Expand Down Expand Up @@ -55,42 +55,40 @@ YUI.add('aui-pagination-tests', function(Y) {

// Tests: AUI-1264
'#1 First li should have text First': function() {
var listItems = Y.one('#pagination_first_last').all('li');
var listItems = Y.one('#paginationFirstLast').all('li');

Y.Assert.isTrue(
listItems.first().get('text') === 'First', 'First li should have text First');
},

'#2 Last li should have text Last': function() {
var listItems = Y.one('#pagination_first_last').all('li');
var listItems = Y.one('#paginationFirstLast').all('li');

Y.Assert.isTrue(
listItems.last().get('text') === 'Last', 'Last li should have text Last');
},

'#3 Clicking on last button should move to last page and disable last button': function() {
var test = this,
listItems = Y.one('#pagination_first_last').all('li'),
listItems = Y.one('#paginationFirstLast').all('li'),
lastButton = listItems.last(),
lastPage = listItems.item(listItems.size() - 3);

lastButton.simulate('click');

Y.Assert.isTrue(lastPage.hasClass('active'));

Y.Assert.isTrue(lastButton.hasClass('disabled'));
},

'#4 Clicking on first button should move to first page and disable first button': function() {
var test = this,
listItems = Y.one('#pagination_first_last').all('li'),
listItems = Y.one('#paginationFirstLast').all('li'),
firstButton = listItems.item(0),
firstPage = listItems.item(2);

firstButton.simulate('click');

Y.Assert.isTrue(firstPage.hasClass('active'));

Y.Assert.isTrue(firstButton.hasClass('disabled'));
}
}));
Expand Down

0 comments on commit fe259c3

Please sign in to comment.