Fixed pageup and pagedown with prefix in menus
diff --git a/dev/js/spec/menuSpec.js b/dev/js/spec/menuSpec.js
index 1825917..327dd6c 100644
--- a/dev/js/spec/menuSpec.js
+++ b/dev/js/spec/menuSpec.js
@@ -1172,6 +1172,41 @@
expect(menu.shownItem(2).active()).toBe(false);
});
+ it('should be page downable with prefix', function () {
+ var menu = KorAP.OwnMenu.create(demolonglist);
+ menu.limit(3);
+
+ expect(menu.prefix('e').show(0)).toBe(true);
+
+ expect(menu.shownItem(0).active()).toBe(true);
+ expect(menu.shownItem(0).lcField()).toEqual(' titel');
+ expect(menu.shownItem(1).active()).toBe(false);
+ expect(menu.shownItem(1).lcField()).toEqual(' untertitel');
+ expect(menu.shownItem(2).active()).toBe(false);
+ expect(menu.shownItem(2).lcField()).toEqual(' veröffentlichungsdatum');
+ expect(menu.shownItem(3)).toBe(undefined);
+
+ menu.pageDown();
+
+ expect(menu.shownItem(0).active()).toBe(false);
+ expect(menu.shownItem(0).lcField()).toEqual(' länge');
+ expect(menu.shownItem(1).active()).toBe(false);
+ expect(menu.shownItem(1).lcField()).toEqual(' genre');
+ expect(menu.shownItem(2).active()).toBe(false);
+ expect(menu.shownItem(2).lcField()).toEqual(' textid');
+
+ // Doesn't matter
+ menu.pageDown();
+
+ expect(menu.shownItem(0).active()).toBe(false);
+ expect(menu.shownItem(0).lcField()).toEqual(' länge');
+ expect(menu.shownItem(1).active()).toBe(false);
+ expect(menu.shownItem(1).lcField()).toEqual(' genre');
+ expect(menu.shownItem(2).active()).toBe(false);
+ expect(menu.shownItem(2).lcField()).toEqual(' textid');
+ });
+
+
it('should be page upable', function () {
var menu = KorAP.OwnMenu.create(demolonglist);
menu.limit(3);
@@ -1208,6 +1243,41 @@
expect(menu.shownItem(2).active()).toBe(false);
});
+ it('should be page upable with prefix', function () {
+ var menu = KorAP.OwnMenu.create(demolonglist);
+ menu.limit(3);
+
+ // Choose the final value
+ expect(menu.prefix("e").show(1000)).toBe(true);
+
+ expect(menu.shownItem(0).active()).toBe(false);
+ expect(menu.shownItem(0).lcField()).toEqual(' länge');
+ expect(menu.shownItem(1).active()).toBe(false);
+ expect(menu.shownItem(1).lcField()).toEqual(' genre');
+ expect(menu.shownItem(2).active()).toBe(true);
+ expect(menu.shownItem(2).lcField()).toEqual(' textid');
+ expect(menu.shownItem(3)).toBe(undefined);
+
+ menu.pageUp();
+
+ expect(menu.shownItem(0).lcField()).toEqual(' titel');
+ expect(menu.shownItem(0).active()).toBe(false);
+ expect(menu.shownItem(1).active()).toBe(false);
+ expect(menu.shownItem(1).lcField()).toEqual(' untertitel');
+ expect(menu.shownItem(2).active()).toBe(false);
+ expect(menu.shownItem(2).lcField()).toEqual(' veröffentlichungsdatum');
+
+ // Doesn't matter
+ menu.pageUp();
+
+ expect(menu.shownItem(0).lcField()).toEqual(' titel');
+ expect(menu.shownItem(0).active()).toBe(false);
+ expect(menu.shownItem(1).active()).toBe(false);
+ expect(menu.shownItem(1).lcField()).toEqual(' untertitel');
+ expect(menu.shownItem(2).active()).toBe(false);
+ expect(menu.shownItem(2).lcField()).toEqual(' veröffentlichungsdatum');
+ });
+
it('should scroll to a chosen value', function () {
var menu = KorAP.OwnMenu.create(demolist);
menu.limit(3);
@@ -1232,8 +1302,6 @@
});
- xit('should be page upable with prefix');
- xit('should be page downable with prefix');
xit('should highlight a chosen value');
xit('should move the viewport to active, if active is not in the viewport');
});
diff --git a/dev/js/src/menu.js b/dev/js/src/menu.js
index 602eb37..0b013b9 100644
--- a/dev/js/src/menu.js
+++ b/dev/js/src/menu.js
@@ -326,8 +326,8 @@
if (nr < 0) {
nr = 0
}
- else if (nr > (this.length() - this.limit())) {
- nr = (this.length() - this.limit());
+ else if (nr > (this.liveLength() - this.limit())) {
+ nr = (this.liveLength() - this.limit());
};
if (this._offset === nr)
@@ -411,11 +411,12 @@
show : function (active) {
// show menu based on initial offset
- this._unmark(); // Unmark everything that was marked before
+ this._unmark(); // Unmark everything that was marked before
this.unshow(); // Delete everything that is shown
// Initialize the list
if (!this._initList()) {
+
// The prefix is not active
this._prefix.active(true);
@@ -435,14 +436,14 @@
if (active < 0) {
active = 0;
}
- else if (active > this.length()) {
- active = this.length() - 1;
+ else if (active > this.liveLength()) {
+ active = this.liveLength() - 1;
};
if (active > this._limit) {
offset = active;
- if (offset > (this.length() - this._limit)) {
- offset = this.length() - this._limit;
+ if (offset > (this.liveLength() - this._limit)) {
+ offset = this.liveLength() - this._limit;
};
};