2012-05-30 20:48:24 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2013-04-10 18:31:24 +04:00
|
|
|
|
2008-07-22 16:21:15 +04:00
|
|
|
var gSubscribeTree = null;
|
|
|
|
var gSearchTree;
|
|
|
|
var okCallback = null;
|
|
|
|
var gChangeTable = {};
|
|
|
|
var gServerURI = null;
|
|
|
|
var gSubscribableServer = null;
|
|
|
|
var gStatusBar = null;
|
|
|
|
var gNameField = null;
|
|
|
|
var gNameFieldLabel = null;
|
|
|
|
var gFolderDelimiter = ".";
|
|
|
|
var gStatusFeedback = new nsMsgStatusFeedback;
|
|
|
|
var gTimelineEnabled = false;
|
|
|
|
var gMessengerBundle = null;
|
|
|
|
var gSubscribeDeck = null;
|
|
|
|
var gSearchView = null;
|
|
|
|
var gSearchTreeBoxObject = null;
|
|
|
|
// the rdf service
|
|
|
|
var RDF = Components.classes['@mozilla.org/rdf/rdf-service;1'].getService(Components.interfaces.nsIRDFService);
|
|
|
|
var subscribeDS = RDF.GetDataSource("rdf:subscribe");
|
|
|
|
|
|
|
|
var gSubscribeBundle;
|
|
|
|
|
|
|
|
function goDoCommand()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
function Stop()
|
|
|
|
{
|
|
|
|
if (gSubscribableServer) {
|
|
|
|
gSubscribableServer.stopPopulating(msgWindow);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function SetServerTypeSpecificTextValues()
|
|
|
|
{
|
2013-04-10 18:31:24 +04:00
|
|
|
if (!gServerURI)
|
|
|
|
return;
|
2008-07-22 16:21:15 +04:00
|
|
|
|
|
|
|
var serverType = GetMsgFolderFromUri(gServerURI, true).server.type;
|
|
|
|
|
|
|
|
// set the server specific ui elements
|
|
|
|
var nameColumnLabel = gSubscribeBundle.getString("columnHeader-" + serverType);
|
|
|
|
var currentListTab = "currentListTab-" + serverType;
|
|
|
|
var currentListTabLabel = gSubscribeBundle.getString(currentListTab + ".label");
|
|
|
|
var currentListTabAccesskey = gSubscribeBundle.getString(currentListTab + ".accesskey");
|
|
|
|
|
|
|
|
document.getElementById("currentListTab").setAttribute('label', currentListTabLabel);
|
|
|
|
document.getElementById("currentListTab").setAttribute('accesskey', currentListTabAccesskey);
|
|
|
|
document.getElementById("newGroupsTab").collapsed = (serverType != "nntp"); // show newGroupsTab only for nntp servers
|
|
|
|
document.getElementById("nameColumn").setAttribute('label', nameColumnLabel);
|
|
|
|
document.getElementById("nameColumn2").setAttribute('label',nameColumnLabel);
|
|
|
|
|
|
|
|
//set the delimiter
|
|
|
|
try {
|
|
|
|
gFolderDelimiter = gSubscribableServer.delimiter;
|
|
|
|
}
|
|
|
|
catch (ex) {
|
|
|
|
//dump(ex + "\n");
|
|
|
|
gFolderDelimiter = ".";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onServerClick(event)
|
|
|
|
{
|
|
|
|
gServerURI = event.target.id;
|
|
|
|
|
|
|
|
SetServerTypeSpecificTextValues();
|
|
|
|
ShowCurrentList();
|
|
|
|
}
|
|
|
|
|
|
|
|
var MySubscribeListener = {
|
|
|
|
OnDonePopulating: function() {
|
|
|
|
gStatusFeedback._stopMeteors();
|
|
|
|
|
|
|
|
// only re-root the tree, if it is null.
|
|
|
|
// otherwise, we are in here because we are populating
|
|
|
|
// a part of the tree
|
|
|
|
var refValue = gSubscribeTree.getAttribute('ref');
|
|
|
|
if (!refValue) {
|
|
|
|
gSubscribeTree.database.AddDataSource(subscribeDS);
|
|
|
|
gSubscribeTree.setAttribute('ref',gServerURI);
|
|
|
|
}
|
|
|
|
|
|
|
|
document.getElementById("refreshButton").disabled = false;
|
|
|
|
document.getElementById("currentListTab").disabled = false;
|
|
|
|
document.getElementById("newGroupsTab").disabled = false;
|
2013-04-10 18:31:24 +04:00
|
|
|
}
|
2008-07-22 16:21:15 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
function SetUpTree(forceToServer, getOnlyNew)
|
|
|
|
{
|
|
|
|
gStatusBar = document.getElementById('statusbar-icon');
|
|
|
|
if (!gServerURI)
|
|
|
|
return;
|
|
|
|
|
|
|
|
var server = GetMsgFolderFromUri(gServerURI, true).server;
|
|
|
|
try
|
2013-04-10 18:31:24 +04:00
|
|
|
{
|
2008-07-22 16:21:15 +04:00
|
|
|
CleanUpSearchView();
|
|
|
|
gSubscribableServer = server.QueryInterface(Components.interfaces.nsISubscribableServer);
|
2013-01-03 22:46:20 +04:00
|
|
|
gSubscribeTree.setAttribute('ref', '');
|
2008-07-22 16:21:15 +04:00
|
|
|
|
|
|
|
// enable (or disable) the search related UI
|
|
|
|
EnableSearchUI();
|
|
|
|
|
|
|
|
// clear out the text field when switching server
|
|
|
|
gNameField.value = "";
|
|
|
|
|
|
|
|
// since there is no text, switch to the non-search view...
|
|
|
|
SwitchToNormalView();
|
|
|
|
|
|
|
|
gSubscribeTree.database.RemoveDataSource(subscribeDS);
|
|
|
|
gSubscribableServer.subscribeListener = MySubscribeListener;
|
|
|
|
|
|
|
|
var currentListTab = document.getElementById("currentListTab");
|
|
|
|
if (currentListTab.selected)
|
|
|
|
document.getElementById("newGroupsTab").disabled = true;
|
|
|
|
else
|
|
|
|
currentListTab.disabled = true;
|
|
|
|
|
|
|
|
document.getElementById("refreshButton").disabled = true;
|
|
|
|
|
|
|
|
gStatusFeedback._startMeteors();
|
|
|
|
gStatusFeedback.showStatusString(gSubscribeBundle.getString("pleaseWaitString"));
|
|
|
|
|
|
|
|
gSubscribableServer.startPopulating(msgWindow, forceToServer, getOnlyNew);
|
|
|
|
}
|
2013-04-10 18:31:24 +04:00
|
|
|
catch (ex)
|
2008-07-22 16:21:15 +04:00
|
|
|
{
|
|
|
|
dump("failed to populate subscribe ds: " + ex + "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function SubscribeOnUnload()
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
CleanUpSearchView();
|
|
|
|
gSubscribeTree.database.RemoveDataSource(subscribeDS);
|
|
|
|
}
|
|
|
|
catch (ex) {
|
|
|
|
dump("failed to remove the subscribe ds: " + ex + "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function EnableSearchUI()
|
|
|
|
{
|
|
|
|
if (gSubscribableServer.supportsSubscribeSearch) {
|
|
|
|
gNameField.removeAttribute('disabled');
|
|
|
|
gNameFieldLabel.removeAttribute('disabled');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
gNameField.setAttribute('disabled',true);
|
|
|
|
gNameFieldLabel.setAttribute('disabled',true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function SubscribeOnLoad()
|
|
|
|
{
|
|
|
|
gSubscribeBundle = document.getElementById("bundle_subscribe");
|
|
|
|
gMessengerBundle = document.getElementById("bundle_messenger");
|
2013-04-10 18:31:24 +04:00
|
|
|
|
2008-07-22 16:21:15 +04:00
|
|
|
gSubscribeTree = document.getElementById("subscribeTree");
|
|
|
|
gSearchTree = document.getElementById("searchTree");
|
|
|
|
gSearchTreeBoxObject = document.getElementById("searchTree").treeBoxObject;
|
|
|
|
gNameField = document.getElementById("namefield");
|
|
|
|
gNameFieldLabel = document.getElementById("namefieldlabel");
|
|
|
|
|
|
|
|
gSubscribeDeck = document.getElementById("subscribedeck");
|
|
|
|
|
2011-02-16 06:39:04 +03:00
|
|
|
msgWindow = Components.classes["@mozilla.org/messenger/msgwindow;1"]
|
|
|
|
.createInstance(Components.interfaces.nsIMsgWindow);
|
2013-04-10 18:31:24 +04:00
|
|
|
msgWindow.domWindow = window;
|
2008-07-22 16:21:15 +04:00
|
|
|
msgWindow.statusFeedback = gStatusFeedback;
|
|
|
|
msgWindow.rootDocShell.allowAuth = true;
|
|
|
|
msgWindow.rootDocShell.appType = Components.interfaces.nsIDocShell.APP_TYPE_MAIL;
|
|
|
|
|
2013-04-10 19:17:18 +04:00
|
|
|
// look in arguments[0] for parameters
|
|
|
|
if (window.arguments && window.arguments[0]) {
|
|
|
|
if ( window.arguments[0].okCallback ) {
|
|
|
|
top.okCallback = window.arguments[0].okCallback;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gServerURI = null;
|
|
|
|
CleanUpSearchView();
|
|
|
|
var folder = window.arguments[0].folder;
|
|
|
|
if (folder && folder.server instanceof Components.interfaces.nsISubscribableServer)
|
|
|
|
{
|
|
|
|
gSubscribableServer = folder.server;
|
|
|
|
gServerURI = folder.server.serverURI;
|
|
|
|
// enable (or disable) the search related UI
|
|
|
|
EnableSearchUI();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gSubscribableServer = null;
|
|
|
|
gServerURI = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
var serverMenu = document.getElementById("serverMenu");
|
|
|
|
var menuitems = serverMenu.getElementsByTagName("menuitem");
|
|
|
|
|
|
|
|
if (!gServerURI) {
|
|
|
|
//dump("subscribe: no uri\n");
|
|
|
|
//dump("xxx todo: use the default news server. right now, I'm just using the first server\n");
|
|
|
|
|
|
|
|
if (menuitems.length > 1) {
|
|
|
|
gServerURI = menuitems[1].id;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
//dump("xxx todo none of your servers are subscribable\n");
|
|
|
|
//dump("xxx todo fix this by disabling subscribe if no subscribable server or, add a CREATE SERVER button, like in 4.x\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var menuitem = serverMenu.getElementsByAttribute("id", gServerURI);
|
|
|
|
if (menuitem.length)
|
|
|
|
serverMenu.selectedItem = menuitem[0];
|
|
|
|
|
|
|
|
SetServerTypeSpecificTextValues();
|
2008-07-22 16:21:15 +04:00
|
|
|
|
|
|
|
ShowCurrentList();
|
|
|
|
|
|
|
|
gNameField.focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
function subscribeOK()
|
|
|
|
{
|
2013-04-10 18:31:24 +04:00
|
|
|
if (top.okCallback) {
|
|
|
|
top.okCallback(top.gChangeTable);
|
|
|
|
}
|
|
|
|
Stop();
|
|
|
|
if (gSubscribableServer) {
|
|
|
|
gSubscribableServer.subscribeCleanup();
|
|
|
|
}
|
|
|
|
return true;
|
2008-07-22 16:21:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function subscribeCancel()
|
|
|
|
{
|
|
|
|
Stop();
|
|
|
|
if (gSubscribableServer) {
|
|
|
|
gSubscribableServer.subscribeCleanup();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function SetState(name,state)
|
|
|
|
{
|
|
|
|
var changed = gSubscribableServer.setState(name, state);
|
|
|
|
if (changed)
|
|
|
|
StateChanged(name,state);
|
|
|
|
}
|
|
|
|
|
2013-04-10 18:31:24 +04:00
|
|
|
function changeTableRecord(server, name, state)
|
2008-07-22 16:21:15 +04:00
|
|
|
{
|
|
|
|
this.server = server;
|
|
|
|
this.name = name;
|
|
|
|
this.state = state;
|
|
|
|
}
|
|
|
|
|
|
|
|
function StateChanged(name,state)
|
|
|
|
{
|
|
|
|
if (gServerURI in gChangeTable) {
|
|
|
|
if (name in gChangeTable[gServerURI]) {
|
|
|
|
var oldValue = gChangeTable[gServerURI][name];
|
|
|
|
if (oldValue != state)
|
|
|
|
delete gChangeTable[gServerURI][name];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
gChangeTable[gServerURI][name] = state;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
gChangeTable[gServerURI] = {};
|
|
|
|
gChangeTable[gServerURI][name] = state;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function InSearchMode()
|
|
|
|
{
|
|
|
|
// search is the second card in the deck
|
|
|
|
return (gSubscribeDeck.getAttribute("selectedIndex") == "1");
|
|
|
|
}
|
|
|
|
|
|
|
|
function SearchOnClick(event)
|
|
|
|
{
|
|
|
|
// we only care about button 0 (left click) events
|
|
|
|
if (event.button != 0 || event.originalTarget.localName != "treechildren") return;
|
|
|
|
|
2014-12-23 21:09:05 +03:00
|
|
|
var cell = gSearchTreeBoxObject.getCellAt(event.clientX, event.clientY);
|
|
|
|
if (cell.row == -1 || cell.row > gSearchView.rowCount - 1)
|
2008-07-22 16:21:15 +04:00
|
|
|
return;
|
|
|
|
|
2014-12-23 21:09:05 +03:00
|
|
|
if (cell.col.id == "subscribedColumn2") {
|
2008-07-22 16:21:15 +04:00
|
|
|
if (event.detail != 2) {
|
2013-04-10 18:31:24 +04:00
|
|
|
// single clicked on the check box
|
2008-07-22 16:21:15 +04:00
|
|
|
// (in the "subscribedColumn2" column) reverse state
|
|
|
|
// if double click, do nothing
|
2014-12-23 21:09:05 +03:00
|
|
|
ReverseStateFromRow(cell.row);
|
2008-07-22 16:21:15 +04:00
|
|
|
}
|
|
|
|
} else if (event.detail == 2) {
|
|
|
|
// double clicked on a row, reverse state
|
2014-12-23 21:09:05 +03:00
|
|
|
ReverseStateFromRow(cell.row);
|
2008-07-22 16:21:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// invalidate the row
|
2014-12-23 21:09:05 +03:00
|
|
|
InvalidateSearchTreeRow(cell.row);
|
2008-07-22 16:21:15 +04:00
|
|
|
}
|
|
|
|
|
2013-04-10 19:17:18 +04:00
|
|
|
function ReverseStateFromRow(aRow)
|
2008-07-22 16:21:15 +04:00
|
|
|
{
|
2013-04-10 19:17:18 +04:00
|
|
|
// To determine if the row is subscribed or not,
|
2008-07-22 16:21:15 +04:00
|
|
|
// we get the properties for the "subscribedColumn2" cell in the row
|
2013-04-10 19:17:18 +04:00
|
|
|
// and look for the "subscribed" property.
|
|
|
|
// If the "subscribed" string is in the list of properties
|
|
|
|
// we are subscribed.
|
2008-07-22 16:21:15 +04:00
|
|
|
var col = gSearchTree.columns["subscribedColumn2"];
|
2013-04-10 19:17:18 +04:00
|
|
|
var properties = gSearchView.getCellProperties(aRow, col);
|
2013-03-04 23:29:55 +04:00
|
|
|
var isSubscribed = /\bsubscribed\b/.test(properties);
|
2013-05-04 08:57:40 +04:00
|
|
|
SetStateFromRow(aRow, !isSubscribed);
|
2008-07-22 16:21:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function SetStateFromRow(row, state)
|
|
|
|
{
|
|
|
|
var col = gSearchTree.columns["nameColumn2"];
|
|
|
|
var name = gSearchView.getCellText(row, col);
|
|
|
|
SetState(name, state);
|
|
|
|
}
|
|
|
|
|
|
|
|
function SetSubscribeState(state)
|
|
|
|
{
|
|
|
|
try {
|
2013-04-10 18:31:24 +04:00
|
|
|
// we need to iterate over the tree selection, and set the state for
|
2008-07-22 16:21:15 +04:00
|
|
|
// all rows in the selection
|
|
|
|
var inSearchMode = InSearchMode();
|
|
|
|
var view = inSearchMode ? gSearchView : gSubscribeTree.view;
|
|
|
|
var colId = inSearchMode ? "nameColumn2" : "nameColumn";
|
2013-04-10 18:31:24 +04:00
|
|
|
|
2008-07-22 16:21:15 +04:00
|
|
|
var sel = view.selection;
|
|
|
|
for (var i = 0; i < sel.getRangeCount(); ++i) {
|
|
|
|
var start = {}, end = {};
|
|
|
|
sel.getRangeAt(i, start, end);
|
|
|
|
for (var k = start.value; k <= end.value; ++k) {
|
|
|
|
if (inSearchMode)
|
|
|
|
SetStateFromRow(k, state);
|
|
|
|
else {
|
|
|
|
var rowRes = gSubscribeTree.builderView.getResourceAtIndex(k);
|
|
|
|
var name = GetRDFProperty(rowRes, "Name");
|
|
|
|
SetState(name, state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-04-10 18:31:24 +04:00
|
|
|
|
2008-07-22 16:21:15 +04:00
|
|
|
if (inSearchMode) {
|
|
|
|
// force a repaint
|
|
|
|
InvalidateSearchTree();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (ex) {
|
|
|
|
dump("SetSubscribedState failed: " + ex + "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function ReverseStateFromNode(row)
|
|
|
|
{
|
|
|
|
var rowRes = gSubscribeTree.builderView.getResourceAtIndex(row);
|
|
|
|
var isSubscribed = GetRDFProperty(rowRes, "Subscribed");
|
|
|
|
var name = GetRDFProperty(rowRes, "Name");
|
|
|
|
|
|
|
|
SetState(name, isSubscribed != "true");
|
|
|
|
}
|
|
|
|
|
|
|
|
function GetRDFProperty(aRes, aProp)
|
|
|
|
{
|
|
|
|
var propRes = RDF.GetResource("http://home.netscape.com/NC-rdf#"+aProp);
|
|
|
|
var valueRes = gSubscribeTree.database.GetTarget(aRes, propRes, true);
|
|
|
|
return valueRes ? valueRes.QueryInterface(Components.interfaces.nsIRDFLiteral).Value : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
function SubscribeOnClick(event)
|
|
|
|
{
|
|
|
|
// we only care about button 0 (left click) events
|
|
|
|
if (event.button != 0 || event.originalTarget.localName != "treechildren")
|
|
|
|
return;
|
2013-04-10 18:31:24 +04:00
|
|
|
|
2014-12-23 21:09:05 +03:00
|
|
|
var cell = gSubscribeTree.treeBoxObject.getCellAt(event.clientX, event.clientY);
|
|
|
|
if (cell.row == -1 || cell.row > (gSubscribeTree.view.rowCount - 1))
|
2008-07-22 16:21:15 +04:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (event.detail == 2) {
|
|
|
|
// only toggle subscribed state when double clicking something
|
|
|
|
// that isn't a container
|
2014-12-23 21:09:05 +03:00
|
|
|
if (!gSubscribeTree.view.isContainer(cell.row)) {
|
|
|
|
ReverseStateFromNode(cell.row);
|
2008-07-22 16:21:15 +04:00
|
|
|
return;
|
2013-04-10 18:31:24 +04:00
|
|
|
}
|
2008-07-22 16:21:15 +04:00
|
|
|
}
|
|
|
|
else if (event.detail == 1)
|
|
|
|
{
|
2014-12-23 21:09:05 +03:00
|
|
|
if (cell.childElt == "twisty") {
|
|
|
|
if (gSubscribeTree.view.isContainerOpen(cell.row)) {
|
|
|
|
var uri = gSubscribeTree.builderView.getResourceAtIndex(cell.row).Value;
|
2008-07-22 16:21:15 +04:00
|
|
|
|
|
|
|
gStatusFeedback._startMeteors();
|
|
|
|
gStatusFeedback.showStatusString(gSubscribeBundle.getString("pleaseWaitString"));
|
|
|
|
|
|
|
|
gSubscribableServer.startPopulatingWithUri(msgWindow, true /* force to server */, uri);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// if the user single clicks on the subscribe check box, we handle it here
|
2014-12-23 21:09:05 +03:00
|
|
|
if (cell.col.id == "subscribedColumn")
|
|
|
|
ReverseStateFromNode(cell.row);
|
2008-07-22 16:21:15 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function Refresh()
|
|
|
|
{
|
|
|
|
// clear out the textfield's entry
|
|
|
|
gNameField.value = "";
|
|
|
|
|
|
|
|
var newGroupsTab = document.getElementById("newGroupsTab");
|
|
|
|
SetUpTree(true, newGroupsTab.selected);
|
|
|
|
}
|
|
|
|
|
|
|
|
function ShowCurrentList()
|
|
|
|
{
|
|
|
|
// clear out the textfield's entry on call of Refresh()
|
|
|
|
gNameField.value = "";
|
|
|
|
|
|
|
|
// make sure the current list tab is selected
|
|
|
|
document.getElementById("subscribeTabs").selectedIndex = 0;
|
|
|
|
|
|
|
|
// try loading the hostinfo before talk to server
|
|
|
|
SetUpTree(false, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
function ShowNewGroupsList()
|
|
|
|
{
|
|
|
|
// clear out the textfield's entry
|
|
|
|
gNameField.value = "";
|
|
|
|
|
|
|
|
// make sure the new groups tab is selected
|
|
|
|
document.getElementById("subscribeTabs").selectedIndex = 1;
|
|
|
|
|
|
|
|
// force it to talk to the server and get new groups
|
|
|
|
SetUpTree(true, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
function InvalidateSearchTreeRow(row)
|
|
|
|
{
|
|
|
|
gSearchTreeBoxObject.invalidateRow(row);
|
|
|
|
}
|
|
|
|
|
|
|
|
function InvalidateSearchTree()
|
|
|
|
{
|
|
|
|
gSearchTreeBoxObject.invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
function SwitchToNormalView()
|
|
|
|
{
|
|
|
|
// the first card in the deck is the "normal" view
|
|
|
|
gSubscribeDeck.setAttribute("selectedIndex","0");
|
|
|
|
}
|
|
|
|
|
|
|
|
function SwitchToSearchView()
|
|
|
|
{
|
|
|
|
// the second card in the deck is the "search" view
|
|
|
|
gSubscribeDeck.setAttribute("selectedIndex","1");
|
|
|
|
}
|
|
|
|
|
|
|
|
function Search()
|
|
|
|
{
|
|
|
|
var searchValue = gNameField.value;
|
|
|
|
if (searchValue.length && gSubscribableServer.supportsSubscribeSearch) {
|
|
|
|
SwitchToSearchView();
|
|
|
|
gSubscribableServer.setSearchValue(searchValue);
|
|
|
|
|
|
|
|
if (!gSearchView && gSubscribableServer) {
|
|
|
|
gSearchView = gSubscribableServer.QueryInterface(Components.interfaces.nsITreeView);
|
|
|
|
gSearchView.selection = null;
|
|
|
|
gSearchTreeBoxObject.view = gSearchView;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
SwitchToNormalView();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function CleanUpSearchView()
|
|
|
|
{
|
|
|
|
if (gSearchView) {
|
|
|
|
gSearchView.selection = null;
|
|
|
|
gSearchView = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onSearchTreeKeyPress(event)
|
|
|
|
{
|
|
|
|
// for now, only do something on space key
|
|
|
|
if (event.charCode != KeyEvent.DOM_VK_SPACE)
|
|
|
|
return;
|
|
|
|
|
2013-04-10 18:31:24 +04:00
|
|
|
var treeSelection = gSearchView.selection;
|
2008-07-22 16:21:15 +04:00
|
|
|
for (var i=0;i<treeSelection.getRangeCount();i++) {
|
|
|
|
var start = {}, end = {};
|
|
|
|
treeSelection.getRangeAt(i,start,end);
|
|
|
|
for (var k=start.value;k<=end.value;k++)
|
|
|
|
ReverseStateFromRow(k);
|
|
|
|
|
|
|
|
// force a repaint
|
|
|
|
InvalidateSearchTree();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onSubscribeTreeKeyPress(event)
|
|
|
|
{
|
|
|
|
// for now, only do something on space key
|
|
|
|
if (event.charCode != KeyEvent.DOM_VK_SPACE)
|
|
|
|
return;
|
|
|
|
|
2013-04-10 18:31:24 +04:00
|
|
|
var treeSelection = gSubscribeTree.view.selection;
|
2008-07-22 16:21:15 +04:00
|
|
|
for (var i=0;i<treeSelection.getRangeCount();i++) {
|
|
|
|
var start = {}, end = {};
|
|
|
|
treeSelection.getRangeAt(i,start,end);
|
|
|
|
for (var k=start.value;k<=end.value;k++)
|
|
|
|
ReverseStateFromNode(k);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-10 18:31:24 +04:00
|
|
|
function doHelpButton()
|
2008-07-22 16:21:15 +04:00
|
|
|
{
|
|
|
|
openHelp("mail-subscribe");
|
|
|
|
}
|