Release preparation, documentation, fixing vc bugs
diff --git a/dev/js/src/menu.js b/dev/js/src/menu.js
index 2bc356b..cc42855 100644
--- a/dev/js/src/menu.js
+++ b/dev/js/src/menu.js
@@ -1,10 +1,11 @@
/**
- * Create scrollable drop-down menus.
+ * Scrollable drop-down menus with view filter.
*
* @author Nils Diewald
*/
/*
* TODO: space is not a valid prefix!
+ * TODO: Prefix should be case sensitive!
*/
define([
'menu/item',
@@ -13,7 +14,6 @@
], function (defaultItemClass,
defaultPrefixClass) {
- // Todo: This may not be necessary
// Default maximum number of menu items
var menuLimit = 8;
@@ -58,10 +58,15 @@
delete this._prefix['_menu'];
},
+
+ /**
+ * Focus on this menu.
+ */
focus : function () {
this._element.focus();
},
+
// mouse wheel treatment
_mousewheel : function (e) {
var delta = 0;
@@ -74,6 +79,7 @@
e.halt();
},
+
// Arrow key and prefix treatment
_keydown : function (e) {
var code = _codeFromEvent(e);
@@ -122,7 +128,7 @@
e.halt();
break;
case 8: // 'Backspace'
- this._prefix.backspace();
+ this._prefix.chop();
this.show();
e.halt();
break;
@@ -214,22 +220,23 @@
},
/**
- * Get the instantiated HTML element
+ * Get the associated dom element.
*/
element : function () {
return this._element;
},
+
/**
- * Get the creator object for items
+ * Get the creator class for items
*/
itemClass : function () {
return this._itemClass;
},
/**
- * Get and set numerical value for limit,
- * i.e. the number of items visible.
+ * Get and set the numerical value
+ * for the maximum number of items visible.
*/
limit : function (limit) {
if (arguments.length === 1) {
@@ -239,6 +246,7 @@
return this._limit;
},
+
/**
* Upgrade this object to another object,
* while private data stays intact.
@@ -252,6 +260,7 @@
return this;
},
+
// Reset chosen item and prefix
_reset : function () {
this._offset = 0;
@@ -259,6 +268,7 @@
this._prefix.value('');
},
+
/**
* Filter the list and make it visible
*
@@ -287,15 +297,23 @@
return true;
},
+
+ /**
+ * Hide the menu and call the onHide callback.
+ */
hide : function () {
this.active = false;
this.delete();
this._element.style.opacity = 0;
+ this._prefix.clear();
this.onHide();
/* this._element.blur(); */
},
- // To be override
+ /**
+ * Function released when the menu hides.
+ * This method is expected to be overridden.
+ */
onHide : function () {},
// Initialize the list
@@ -356,6 +374,7 @@
this.item(this._list[this._list.length - 1]).noMore(bool);
},
+
/**
* Get the prefix for filtering,
* e.g. "ve" for "verb"
@@ -368,6 +387,7 @@
return this._prefix.value();
},
+
// Append Items that should be shown
_showItems : function (offset) {
this.delete();
@@ -644,7 +664,9 @@
},
- // Length of the filtered list
+ /**
+ * Length of the filtered item list.
+ */
liveLength : function () {
if (this._list === undefined)
this._initList();