Restructure screen method in menu view
diff --git a/dev/js/spec/menuSpec.js b/dev/js/spec/menuSpec.js
index 8e6141a..502549f 100644
--- a/dev/js/spec/menuSpec.js
+++ b/dev/js/spec/menuSpec.js
@@ -1087,13 +1087,13 @@
expect(menu.shownItem(0).lcField()).toEqual(' titel');
expect(menu.shownItem(1).lcField()).toEqual(' untertitel');
-/*
menu.screen(0);
expect(menu.shownItem(0).active()).toBe(false);
expect(menu.shownItem(1).active()).toBe(true);
expect(menu.shownItem(2).active()).toBe(false);
expect(menu.shownItem(3)).toBe(undefined);
-*/
+
+/*
console.log('VVVVVVVVVVVVVVVVV');
menu.screen(1);
@@ -1102,9 +1102,11 @@
expect(menu.shownItem(2)).not.toBeUndefined();
expect(menu.shownItem(3)).toBe(undefined);
+
+console.log(menu.element().innerHTML);
+console.log(menu.shownItem(0)._element.outerHTML);
+
expect(menu.shownItem(0).active()).toBe(true);
-console.log('AAAAAAAAAAAAAAAAA');
-/*
expect(menu.shownItem(1).active()).toBe(false);
expect(menu.shownItem(2).active()).toBe(false);
*/
diff --git a/dev/js/src/menu.js b/dev/js/src/menu.js
index ce59f3c..cc75926 100644
--- a/dev/js/src/menu.js
+++ b/dev/js/src/menu.js
@@ -166,6 +166,7 @@
if (this._offset === nr)
return;
+ this.delete();
this._showItems(nr);
},
@@ -328,6 +329,8 @@
return false;
// show based on initial offset
+ this.unmark();
+ this.delete();
this._showItems(0);
// Set the first element to active
@@ -337,6 +340,7 @@
this.position = 0;
this._active = 0;
}
+
else {
this.position = -1;
}
@@ -365,6 +369,7 @@
*/
hide : function () {
this.active = false;
+ this.unmark();
this.delete();
this._element.style.opacity = 0;
this._prefix.clear();
@@ -458,8 +463,6 @@
// Append Items that should be shown
_showItems : function (off) {
- this.delete();
-
// Use list
var shown = 0;
var i;
@@ -472,14 +475,8 @@
var item = this.item(itemNr);
this._append(itemNr);
- /*
- this._items[this._list[i]].active();
- console.dir([i, this._active]);
- if (this._active === i) {
-console.log('True!')
- this._items[this._list[i]].active(true);
- };
- */
+ if (i === this.position)
+ item.active(true);
// this._offset))
if (shown >= (this.limit() + off))
@@ -506,12 +503,6 @@
};
*/
- for (var i in this._list) {
- var item = this._items[this._list[i]];
- item.lowlight();
- item.active(false);
- };
-
// Remove all children
var children = this._element.childNodes;
// Leave the prefix and lengthField
@@ -522,6 +513,14 @@
};
},
+ // Unmark all items
+ unmark : function () {
+ for (var i in this._list) {
+ var item = this._items[this._list[i]];
+ item.lowlight();
+ item.active(false);
+ };
+ },
// Append item to the shown list based on index
_append : function (i) {
@@ -642,6 +641,8 @@
this.position = 0;
newItem = this.liveItem(0);
this._active = 0;
+ this.unmark();
+ this.delete();
this._showItems(0);
};
}
@@ -734,6 +735,8 @@
}
else {
newItem = this.liveItem(this.position);
+ this.unmark();
+ this.delete();
this._showItems(this._offset);
};
}