r2775 - finalized pageup, pagedown to match native implementation
Author: scottjehl
Date: Mon Jun 15 13:56:52 2009
New Revision: 2775
Modified:
branches/labs/selectmenu/ui.selectmenu.js
Log:
finalized pageup, pagedown to match native implementation
Modified: branches/labs/selectmenu/ui.selectmenu.js
==============================================================================
--- branches/labs/selectmenu/ui.selectmenu.js (original)
+++ branches/labs/selectmenu/ui.selectmenu.js Mon Jun 15 13:56:52 2009
@@ -204,12 +204,18 @@
$(event.target).blur().parents('li:eq(0)').next().find('a:eq(0)').focus();
}
break;
- case $.ui.keyCode.PAGE_UP:
case $.ui.keyCode.HOME:
$(event.target).blur();
self.list.find('a:first').focus();
break;
+ case $.ui.keyCode.PAGE_UP:
+ ret = false;
+ self._scrollPage(event.target, 'up');
+ break;
case $.ui.keyCode.PAGE_DOWN:
+ ret = false;
+ self._scrollPage(event.target, 'down');
+ break;
case $.ui.keyCode.END:
ret = false;
$(event.target).blur();
@@ -351,6 +357,17 @@
}
}
return newText;
+ },
+
+ _scrollPage: function(curTarget,direction){
+ var numPerPage = Math.floor(this.list.outerHeight() /
this.list.find('li:first').outerHeight());
+ var currentIndex = parseInt(
$(curTarget).parents('li:eq(0)').data('index') );
+ var nextIndex = (direction == 'up') ? currentIndex - numPerPage :
currentIndex + numPerPage;
+ nextIndex = ':eq('+nextIndex+')';
+ if(this.list.find('li' + nextIndex).size() < 1){
+ nextIndex = (direction == 'up') ? ':first' : ':last';
+ }
+ this.list.find('li' + nextIndex + ' a').focus();
},
_selectedIndex: function(){