Mercurial > snowl
annotate content/collections.js @ 344:62557df25569
make the River menuitem toggle the river view open and closed; fix the Wide Message layout problem (chrome gets messed up in Wide Message mode, particularly when using extensions like Sidebar Tabs)
author | alta88 <alta88@gmail.com> |
---|---|
date | Fri, 24 Oct 2008 14:13:17 -0700 |
parents | 27a89f014e81 |
children | f95f6f24516f |
rev | line source |
---|---|
229
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
1 /* ***** BEGIN LICENSE BLOCK ***** |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
3 * |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
4 * The contents of this file are subject to the Mozilla Public License Version |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
5 * 1.1 (the "License"); you may not use this file except in compliance with |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
6 * the License. You may obtain a copy of the License at |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
7 * http://www.mozilla.org/MPL/ |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
8 * |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
9 * Software distributed under the License is distributed on an "AS IS" basis, |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
11 * for the specific language governing rights and limitations under the |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
12 * License. |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
13 * |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
14 * The Original Code is Snowl. |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
15 * |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
16 * The Initial Developer of the Original Code is Mozilla. |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
17 * Portions created by the Initial Developer are Copyright (C) 2008 |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
18 * the Initial Developer. All Rights Reserved. |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
19 * |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
20 * Contributor(s): |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
21 * Myk Melez <myk@mozilla.org> |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
22 * |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
23 * Alternatively, the contents of this file may be used under the terms of |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
24 * either the GNU General Public License Version 2 or later (the "GPL"), or |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
26 * in which case the provisions of the GPL or the LGPL are applicable instead |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
27 * of those above. If you wish to allow use of your version of this file only |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
28 * under the terms of either the GPL or the LGPL, and not to allow others to |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
29 * use your version of this file under the terms of the MPL, indicate your |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
30 * decision by deleting the provisions above and replace them with the notice |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
31 * and other provisions required by the GPL or the LGPL. If you do not delete |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
32 * the provisions above, a recipient may use your version of this file under |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
33 * the terms of any one of the MPL, the GPL or the LGPL. |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
34 * |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
35 * ***** END LICENSE BLOCK ***** */ |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
36 |
45
a3811857c5dc
register the resource alias to the top-level directory rather than the modules directory for consistency with resource://gre/modules/ URLs and so we can use it to load resources from elsewhere in the extension later; this means converting chrome://snowl/module.js URLs into chrome://snowl/modules/module.js URLs
Myk Melez <myk@mozilla.org>
parents:
39
diff
changeset
|
37 Cu.import("resource://snowl/modules/service.js"); |
a3811857c5dc
register the resource alias to the top-level directory rather than the modules directory for consistency with resource://gre/modules/ URLs and so we can use it to load resources from elsewhere in the extension later; this means converting chrome://snowl/module.js URLs into chrome://snowl/modules/module.js URLs
Myk Melez <myk@mozilla.org>
parents:
39
diff
changeset
|
38 Cu.import("resource://snowl/modules/datastore.js"); |
a3811857c5dc
register the resource alias to the top-level directory rather than the modules directory for consistency with resource://gre/modules/ URLs and so we can use it to load resources from elsewhere in the extension later; this means converting chrome://snowl/module.js URLs into chrome://snowl/modules/module.js URLs
Myk Melez <myk@mozilla.org>
parents:
39
diff
changeset
|
39 Cu.import("resource://snowl/modules/log4moz.js"); |
108
ec5e374be495
show favicons in the subscriptions sidebar
Myk Melez <myk@mozilla.org>
parents:
106
diff
changeset
|
40 Cu.import("resource://snowl/modules/source.js"); |
106
2a08b4a82802
integrate OPML import into the sidebar
Myk Melez <myk@mozilla.org>
parents:
105
diff
changeset
|
41 Cu.import("resource://snowl/modules/feed.js"); |
2a08b4a82802
integrate OPML import into the sidebar
Myk Melez <myk@mozilla.org>
parents:
105
diff
changeset
|
42 Cu.import("resource://snowl/modules/URI.js"); |
165 | 43 Cu.import("resource://snowl/modules/identity.js"); |
169
d5cc6dfafc40
basic support for grouping in the collection object
Myk Melez <myk@mozilla.org>
parents:
167
diff
changeset
|
44 Cu.import("resource://snowl/modules/collection.js"); |
275
5982695f4890
factor out OPML export code from the collections view
Myk Melez <myk@mozilla.org>
parents:
238
diff
changeset
|
45 Cu.import("resource://snowl/modules/opml.js"); |
16
8efec269810d
get rid of init.js and a bunch of unused code in snowl.js
Myk Melez <myk@mozilla.org>
parents:
12
diff
changeset
|
46 |
194
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
47 // FIXME: make this configurable. |
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
48 const SNOWL_COLLECTIONS_HIERARCHICAL = false; |
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
49 |
317
27a89f014e81
rename SourcesView to CollectionsView
Myk Melez <myk@mozilla.org>
parents:
316
diff
changeset
|
50 let CollectionsView = { |
21 | 51 _log: null, |
52 | |
10
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
53 // Observer Service |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
54 get _obsSvc() { |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
55 let obsSvc = Cc["@mozilla.org/observer-service;1"]. |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
56 getService(Ci.nsIObserverService); |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
57 delete this._obsSvc; |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
58 this._obsSvc = obsSvc; |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
59 return this._obsSvc; |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
60 }, |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
61 |
8
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
62 get _tree() { |
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
63 delete this._tree; |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
64 return this._tree = document.getElementById("sourcesView"); |
8
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
65 }, |
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
66 |
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
67 get _children() { |
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
68 delete this._children; |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
69 return this._children = this._tree.getElementsByTagName("treechildren")[0]; |
8
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
70 }, |
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
71 |
106
2a08b4a82802
integrate OPML import into the sidebar
Myk Melez <myk@mozilla.org>
parents:
105
diff
changeset
|
72 |
2a08b4a82802
integrate OPML import into the sidebar
Myk Melez <myk@mozilla.org>
parents:
105
diff
changeset
|
73 //**************************************************************************// |
2a08b4a82802
integrate OPML import into the sidebar
Myk Melez <myk@mozilla.org>
parents:
105
diff
changeset
|
74 // Initialization & Destruction |
2a08b4a82802
integrate OPML import into the sidebar
Myk Melez <myk@mozilla.org>
parents:
105
diff
changeset
|
75 |
8
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
76 init: function() { |
21 | 77 this._log = Log4Moz.Service.getLogger("Snowl.Sidebar"); |
10
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
78 this._obsSvc.addObserver(this, "sources:changed", true); |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
79 this._getCollections(); |
21 | 80 this._tree.view = this; |
81 | |
344
62557df25569
make the River menuitem toggle the river view open and closed; fix the Wide Message layout problem (chrome gets messed up in Wide Message mode, particularly when using extensions like Sidebar Tabs)
alta88 <alta88@gmail.com>
parents:
317
diff
changeset
|
82 // Ensure collection selection maintained, if in List sidebar |
62557df25569
make the River menuitem toggle the river view open and closed; fix the Wide Message layout problem (chrome gets messed up in Wide Message mode, particularly when using extensions like Sidebar Tabs)
alta88 <alta88@gmail.com>
parents:
317
diff
changeset
|
83 if (document.getElementById("snowlSidebar")) |
62557df25569
make the River menuitem toggle the river view open and closed; fix the Wide Message layout problem (chrome gets messed up in Wide Message mode, particularly when using extensions like Sidebar Tabs)
alta88 <alta88@gmail.com>
parents:
317
diff
changeset
|
84 this._tree.view.selection.select( |
62557df25569
make the River menuitem toggle the river view open and closed; fix the Wide Message layout problem (chrome gets messed up in Wide Message mode, particularly when using extensions like Sidebar Tabs)
alta88 <alta88@gmail.com>
parents:
317
diff
changeset
|
85 gMessageViewWindow.SnowlMessageView._listCollectionIndex); |
62557df25569
make the River menuitem toggle the river view open and closed; fix the Wide Message layout problem (chrome gets messed up in Wide Message mode, particularly when using extensions like Sidebar Tabs)
alta88 <alta88@gmail.com>
parents:
317
diff
changeset
|
86 |
21 | 87 // Add a capturing click listener to the tree so we can find out if the user |
88 // clicked on a row that is already selected (in which case we let them edit | |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
89 // the collection name). |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
90 // FIXME: disable this for names that can't be changed. |
317
27a89f014e81
rename SourcesView to CollectionsView
Myk Melez <myk@mozilla.org>
parents:
316
diff
changeset
|
91 this._tree.addEventListener("mousedown", function(aEvent) { CollectionsView.onClick(aEvent) }, true); |
21 | 92 }, |
93 | |
94 | |
95 //**************************************************************************// | |
96 // nsITreeView | |
97 | |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
98 selection: null, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
99 |
108
ec5e374be495
show favicons in the subscriptions sidebar
Myk Melez <myk@mozilla.org>
parents:
106
diff
changeset
|
100 get rowCount() { |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
101 return this._rows.length; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
102 }, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
103 |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
104 // FIXME: consolidate these two references. |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
105 _treebox: null, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
106 setTree: function(treeBox) { |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
107 this._treeBox = treeBox; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
108 }, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
109 |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
110 getCellText : function(row, column) { |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
111 return this._rows[row].name; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
112 }, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
113 |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
114 isContainer: function(row) { |
177 | 115 //this._log.info("isContainer: " + (this._rows[row].groups ? true : false)); |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
116 return (this._rows[row].groups ? true : false); |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
117 }, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
118 isContainerOpen: function(row) { |
177 | 119 //this._log.info("isContainerOpen: " + this._rows[row].isOpen); |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
120 return this._rows[row].isOpen; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
121 }, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
122 isContainerEmpty: function(row) { |
177 | 123 //this._log.info("isContainerEmpty: " + row + " " + this._rows[row].groups.length + " " + (this._rows[row].groups.length == 0)); |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
124 return (this._rows[row].groups.length == 0); |
108
ec5e374be495
show favicons in the subscriptions sidebar
Myk Melez <myk@mozilla.org>
parents:
106
diff
changeset
|
125 }, |
ec5e374be495
show favicons in the subscriptions sidebar
Myk Melez <myk@mozilla.org>
parents:
106
diff
changeset
|
126 |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
127 isSeparator: function(row) { return false }, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
128 isSorted: function() { return false }, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
129 |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
130 // FIXME: make this return true for collection names that are editable, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
131 // and then implement name editing on the new architecture. |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
132 isEditable: function(row, column) { return false }, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
133 |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
134 getParentIndex: function(row) { |
177 | 135 //this._log.info("getParentIndex: " + row); |
136 | |
179
ab9b528514e6
don't indent the All collection, and support more flexible hierarchy
Myk Melez <myk@mozilla.org>
parents:
178
diff
changeset
|
137 let thisLevel = this.getLevel(row); |
ab9b528514e6
don't indent the All collection, and support more flexible hierarchy
Myk Melez <myk@mozilla.org>
parents:
178
diff
changeset
|
138 |
194
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
139 if (thisLevel == 0) |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
140 return -1; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
141 for (let t = row - 1; t >= 0; t--) |
179
ab9b528514e6
don't indent the All collection, and support more flexible hierarchy
Myk Melez <myk@mozilla.org>
parents:
178
diff
changeset
|
142 if (this.getLevel(t) < thisLevel) |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
143 return t; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
144 |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
145 throw "getParentIndex: couldn't figure out parent index for row " + row; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
146 }, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
147 |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
148 getLevel: function(row) { |
177 | 149 //this._log.info("getLevel: " + row); |
150 | |
194
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
151 if (!SNOWL_COLLECTIONS_HIERARCHICAL) |
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
152 return 0; |
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
153 |
179
ab9b528514e6
don't indent the All collection, and support more flexible hierarchy
Myk Melez <myk@mozilla.org>
parents:
178
diff
changeset
|
154 return this._rows[row].level; |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
155 }, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
156 |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
157 hasNextSibling: function(idx, after) { |
177 | 158 //this._log.info("hasNextSibling: " + idx + " " + after); |
159 | |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
160 let thisLevel = this.getLevel(idx); |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
161 for (let t = idx + 1; t < this._rows.length; t++) { |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
162 let nextLevel = this.getLevel(t); |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
163 if (nextLevel == thisLevel) |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
164 return true; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
165 if (nextLevel < thisLevel) |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
166 return false; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
167 } |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
168 |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
169 return false; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
170 }, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
171 |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
172 getImageSrc: function(row, column) { |
177 | 173 if (column.id == "nameCol") { |
211
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
174 let iconURL = this._rows[row].iconURL; |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
175 if (iconURL) |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
176 return iconURL.spec; |
177 | 177 } |
178 | |
108
ec5e374be495
show favicons in the subscriptions sidebar
Myk Melez <myk@mozilla.org>
parents:
106
diff
changeset
|
179 return null; |
21 | 180 }, |
28
0d34d2108b49
use a custom view for the message pane
Myk Melez <myk@mozilla.org>
parents:
21
diff
changeset
|
181 |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
182 toggleOpenState: function(idx) { |
177 | 183 //this._log.info("toggleOpenState: " + idx); |
184 | |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
185 let item = this._rows[idx]; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
186 if (!item.groups) |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
187 return; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
188 |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
189 if (item.isOpen) { |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
190 item.isOpen = false; |
28
0d34d2108b49
use a custom view for the message pane
Myk Melez <myk@mozilla.org>
parents:
21
diff
changeset
|
191 |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
192 let thisLevel = this.getLevel(idx); |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
193 let numToDelete = 0; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
194 for (let t = idx + 1; t < this._rows.length; t++) { |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
195 if (this.getLevel(t) > thisLevel) |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
196 numToDelete++; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
197 else |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
198 break; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
199 } |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
200 if (numToDelete) { |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
201 this._rows.splice(idx + 1, numToDelete); |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
202 this._treeBox.rowCountChanged(idx + 1, -numToDelete); |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
203 } |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
204 } |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
205 else { |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
206 item.isOpen = true; |
108
ec5e374be495
show favicons in the subscriptions sidebar
Myk Melez <myk@mozilla.org>
parents:
106
diff
changeset
|
207 |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
208 let groups = this._rows[idx].groups; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
209 for (let i = 0; i < groups.length; i++) |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
210 this._rows.splice(idx + 1 + i, 0, groups[i]); |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
211 this._treeBox.rowCountChanged(idx + 1, groups.length); |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
212 } |
108
ec5e374be495
show favicons in the subscriptions sidebar
Myk Melez <myk@mozilla.org>
parents:
106
diff
changeset
|
213 }, |
ec5e374be495
show favicons in the subscriptions sidebar
Myk Melez <myk@mozilla.org>
parents:
106
diff
changeset
|
214 |
195 | 215 getRowProperties: function (row, properties) {}, |
216 getCellProperties: function (row, column, properties) {}, | |
217 getColumnProperties: function(columnID, column, properties) {}, | |
28
0d34d2108b49
use a custom view for the message pane
Myk Melez <myk@mozilla.org>
parents:
21
diff
changeset
|
218 |
0d34d2108b49
use a custom view for the message pane
Myk Melez <myk@mozilla.org>
parents:
21
diff
changeset
|
219 setCellText: function(aRow, aCol, aValue) { |
75
877a7694445f
update the sources table schema, changing the title column to name and differentiating between machine-processable and human-readable URIs
Myk Melez <myk@mozilla.org>
parents:
45
diff
changeset
|
220 let statement = SnowlDatastore.createStatement("UPDATE sources SET name = :name WHERE id = :id"); |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
221 statement.params.name = this._rows[aRow].name = aValue; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
222 statement.params.id = this._rows[aRow].id; |
21 | 223 |
224 try { | |
225 statement.execute(); | |
226 } | |
227 finally { | |
228 statement.reset(); | |
229 } | |
10
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
230 }, |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
231 |
28
0d34d2108b49
use a custom view for the message pane
Myk Melez <myk@mozilla.org>
parents:
21
diff
changeset
|
232 |
10
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
233 //**************************************************************************// |
21 | 234 // Misc XPCOM Interface Implementations |
10
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
235 |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
236 // nsISupports |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
237 QueryInterface: function(aIID) { |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
238 if (aIID.equals(Ci.nsIObserver) || |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
239 aIID.equals(Ci.nsISupportsWeakReference) || |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
240 aIID.equals(Ci.nsISupports)) |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
241 return this; |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
242 |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
243 throw Cr.NS_ERROR_NO_INTERFACE; |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
244 }, |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
245 |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
246 // nsIObserver |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
247 observe: function(subject, topic, data) { |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
248 switch (topic) { |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
249 case "sources:changed": |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
250 this._getCollections(); |
105
cd3267665afd
reinit the sidebar view when the number of rows changes
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
251 // Rebuild the view to reflect the new collection of messages. |
cd3267665afd
reinit the sidebar view when the number of rows changes
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
252 // Since the number of rows might have changed, we do this by reinitializing |
cd3267665afd
reinit the sidebar view when the number of rows changes
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
253 // the view instead of merely invalidating the box object (which doesn't |
cd3267665afd
reinit the sidebar view when the number of rows changes
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
254 // expect changes to the number of rows). |
cd3267665afd
reinit the sidebar view when the number of rows changes
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
255 this._tree.view = this; |
10
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
256 break; |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
257 } |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
258 }, |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
259 |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
260 _collections: null, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
261 _getCollections: function() { |
178
1a27019af73e
reimplement the 'All' collection on the new architecture
Myk Melez <myk@mozilla.org>
parents:
177
diff
changeset
|
262 this._collections = []; |
1a27019af73e
reimplement the 'All' collection on the new architecture
Myk Melez <myk@mozilla.org>
parents:
177
diff
changeset
|
263 |
211
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
264 let statement = SnowlDatastore.createStatement( |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
265 "SELECT id, name, iconURL, grouped, groupIDColumn, groupNameColumn, " + |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
266 "groupHomeURLColumn, groupIconURLColumn FROM collections ORDER BY orderKey" |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
267 ); |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
268 |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
269 statement.QueryInterface(Ci.mozIStorageStatementWrapper); |
165 | 270 |
211
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
271 try { |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
272 while (statement.step()) { |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
273 this._collections.push(new SnowlCollection(statement.row.id, |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
274 statement.row.name, |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
275 URI.get(statement.row.iconURL), |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
276 null, |
212
cf89d5c676c0
persist collection and group in the URL, and delay loading content until the collections sidebar has loaded
Myk Melez <myk@mozilla.org>
parents:
211
diff
changeset
|
277 null, |
211
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
278 statement.row.grouped ? true : false, |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
279 statement.row.groupIDColumn, |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
280 statement.row.groupNameColumn, |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
281 statement.row.groupHomeURLColumn, |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
282 statement.row.groupIconURLColumn)); |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
283 } |
175
5409a8759186
collection object rearch: encapsulate grouping info into grouping object
Myk Melez <myk@mozilla.org>
parents:
174
diff
changeset
|
284 } |
211
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
285 finally { |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
286 statement.reset(); |
180 | 287 } |
288 | |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
289 // Build the list of rows in the tree. By default, all containers |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
290 // are closed, so this is the same as the list of collections, although |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
291 // in the future we might persist and restore the open state. |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
292 // XXX Should this work be in a separate function? |
194
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
293 if (SNOWL_COLLECTIONS_HIERARCHICAL) { |
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
294 this._rows = [collection for each (collection in this._collections)]; |
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
295 } |
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
296 else { |
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
297 this._rows = []; |
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
298 for each (let collection in this._collections) { |
211
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
299 if (collection.grouped) |
194
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
300 for each (let group in collection.groups) |
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
301 this._rows.push(group); |
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
302 else |
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
303 this._rows.push(collection); |
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
304 } |
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
305 } |
21 | 306 }, |
307 | |
8
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
308 onSelect: function(aEvent) { |
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
309 if (this._tree.currentIndex == -1) |
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
310 return; |
173
4d59aa183d57
get loading of a group into the list view working
Myk Melez <myk@mozilla.org>
parents:
172
diff
changeset
|
311 |
4d59aa183d57
get loading of a group into the list view working
Myk Melez <myk@mozilla.org>
parents:
172
diff
changeset
|
312 let collection = this._rows[this._tree.currentIndex]; |
344
62557df25569
make the River menuitem toggle the river view open and closed; fix the Wide Message layout problem (chrome gets messed up in Wide Message mode, particularly when using extensions like Sidebar Tabs)
alta88 <alta88@gmail.com>
parents:
317
diff
changeset
|
313 let index = this._tree.currentIndex; |
62557df25569
make the River menuitem toggle the river view open and closed; fix the Wide Message layout problem (chrome gets messed up in Wide Message mode, particularly when using extensions like Sidebar Tabs)
alta88 <alta88@gmail.com>
parents:
317
diff
changeset
|
314 gMessageViewWindow.SnowlMessageView.setCollection(collection, index); |
9
d8abd85fc94d
implement basic subscribe and unsubscribe
Myk Melez <myk@mozilla.org>
parents:
8
diff
changeset
|
315 }, |
d8abd85fc94d
implement basic subscribe and unsubscribe
Myk Melez <myk@mozilla.org>
parents:
8
diff
changeset
|
316 |
21 | 317 onClick: function(aEvent) { |
318 this._log.info("on click"); | |
319 //this._log.info(Log4Moz.enumerateProperties(aEvent).join("\n")); | |
320 //this._log.info(aEvent.target.nodeName); | |
321 | |
322 let row = {}, col = {}, child = {}; | |
323 this._tree.treeBoxObject.getCellAt(aEvent.clientX, aEvent.clientY, row, col, child); | |
324 if (this._tree.view.selection.isSelected(row.value)) | |
325 this._log.info(row.value + " is selected"); | |
326 else | |
327 this._log.info(row.value + " is not selected"); | |
297 | 328 }, |
329 | |
330 unsubscribe: function() { | |
331 let collection = this._rows[this._tree.currentIndex]; | |
332 | |
333 if (!collection.parent || collection.parent.groupIDColumn != "sources.id") | |
334 return; | |
335 | |
336 let sourceID = this._rows[this._tree.currentIndex].groupID; | |
337 | |
338 SnowlDatastore.dbConnection.beginTransaction(); | |
339 try { | |
340 SnowlDatastore.dbConnection.executeSimpleSQL("DELETE FROM metadata WHERE messageID IN (SELECT id FROM messages WHERE sourceID = " + sourceID + ")"); | |
341 SnowlDatastore.dbConnection.executeSimpleSQL("DELETE FROM parts WHERE messageID IN (SELECT id FROM messages WHERE sourceID = " + sourceID + ")"); | |
342 SnowlDatastore.dbConnection.executeSimpleSQL("DELETE FROM messages WHERE sourceID = " + sourceID); | |
343 SnowlDatastore.dbConnection.executeSimpleSQL("DELETE FROM sources WHERE id = " + sourceID); | |
344 SnowlDatastore.dbConnection.commitTransaction(); | |
345 } | |
346 catch(ex) { | |
347 SnowlDatastore.dbConnection.rollbackTransaction(); | |
348 throw ex; | |
349 } | |
350 | |
351 this._obsSvc.notifyObservers(null, "sources:changed", null); | |
352 this._obsSvc.notifyObservers(null, "messages:changed", null); | |
8
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
353 } |
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
354 |
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
355 }; |
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
356 |
317
27a89f014e81
rename SourcesView to CollectionsView
Myk Melez <myk@mozilla.org>
parents:
316
diff
changeset
|
357 window.addEventListener("load", function() { CollectionsView.init() }, true); |