From b53835c14761d88e6c2299d98552e18dbd89aa30 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Thu, 16 Jul 2015 01:03:11 -0700 Subject: [PATCH] allow additions to ListBar while it is detached. see #148. --- lib/widgets/listbar.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/widgets/listbar.js b/lib/widgets/listbar.js index 2f6ff71..d05cc55 100644 --- a/lib/widgets/listbar.js +++ b/lib/widgets/listbar.js @@ -298,6 +298,17 @@ Listbar.prototype.select = function(offset) { offset = this.items.indexOf(offset); } + if (offset < 0) { + offset = 0; + } else if (offset >= this.items.length) { + offset = this.items.length - 1; + } + + if (!this.parent) { + this.emit('select item', el, offset); + return; + } + var lpos = this._getCoords(); if (!lpos) return; @@ -307,12 +318,6 @@ Listbar.prototype.select = function(offset) { , visible = 0 , el; - if (offset < 0) { - offset = 0; - } else if (offset >= this.items.length) { - offset = this.items.length - 1; - } - el = this.items[offset]; if (!el) return;