[gnome-documents] manager: Add forEachItem helper method
- From: Florian MÃllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] manager: Add forEachItem helper method
- Date: Thu, 1 Dec 2011 19:37:38 +0000 (UTC)
commit a0206d284c8192df6d126892c7d9d6e7839e2391
Author: Florian MÃllner <fmuellner gnome org>
Date: Mon Nov 14 01:22:49 2011 +0100
manager: Add forEachItem helper method
Subclasses of BaseManager may want to iterate over the managed
items - add a helper method which allows to do this without
accessing private properties of the parent.
https://bugzilla.gnome.org/show_bug.cgi?id=665158
src/manager.js | 27 +++++++++++----------------
1 files changed, 11 insertions(+), 16 deletions(-)
---
diff --git a/src/manager.js b/src/manager.js
index 81e53f3..c6edb9b 100644
--- a/src/manager.js
+++ b/src/manager.js
@@ -127,25 +127,20 @@ BaseManager.prototype = {
return retval;
},
- _getAllFilter: function() {
- let filter = '';
- let first = true;
-
- for (idx in this._items) {
- let item = this._items[idx];
-
- if (item.id == 'all')
- continue;
+ forEachItem: function(func) {
+ for (idx in this._items)
+ func(this._items[idx]);
+ },
- if (first)
- first = false;
- else
- filter += ' || ';
+ _getAllFilter: function() {
+ let filters = [];
- filter += item.getFilter();
- }
+ this.forEachItem(function(item) {
+ if (item.id != 'all')
+ filters.push(item.getFilter());
+ });
- return '(' + filter + ')';
+ return '(' + filters.join(' || ') + ')';
},
processNewItems: function(newItems) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]