mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-07 11:56:51 +00:00
Bug #281237 --> hook up edit feed functionality to the new rss subscription dialog.
This commit is contained in:
parent
f8ffd68fff
commit
cecf130ad7
@ -38,8 +38,11 @@
|
||||
|
||||
function onLoad()
|
||||
{
|
||||
var feedLocationEl = document.getElementById('feedLocation');
|
||||
var rssAccountMenuItem = document.getElementById('rssAccountMenuItem');
|
||||
|
||||
if (window.arguments[0].feedLocation)
|
||||
document.getElementById('feedLocation').value = window.arguments[0].feedLocation;
|
||||
feedLocationEl.value = window.arguments[0].feedLocation;
|
||||
|
||||
// root the location picker to the news & blogs server
|
||||
document.getElementById('selectFolder').setAttribute('ref', window.arguments[0].serverURI);
|
||||
@ -47,15 +50,18 @@ function onLoad()
|
||||
SetFolderPicker(window.arguments[0].folderURI ? window.arguments[0].folderURI : window.arguments[0].serverURI, 'selectFolder');
|
||||
document.getElementById('selectFolder').setInitialSelection();
|
||||
|
||||
document.getElementById('rssAccountMenuItem').label = window.arguments[0].serverPrettyName;
|
||||
document.getElementById('rssAccountMenuItem').value = window.arguments[0].serverURI;
|
||||
rssAccountMenuItem.label = window.arguments[0].serverPrettyName;
|
||||
rssAccountMenuItem.value = window.arguments[0].serverURI;
|
||||
|
||||
// set quick mode value
|
||||
document.getElementById('quickMode').checked = window.arguments[0].quickMode;
|
||||
|
||||
// if we are editing an existing feed, disable the top level account
|
||||
if (!window.arguments[0].newFeed)
|
||||
document.getElementById('rssAccountMenuItem').setAttribute('disabled', 'true');
|
||||
{
|
||||
// if we are editing an existing feed, disable the top level account
|
||||
rssAccountMenuItem.setAttribute('disabled', 'true');
|
||||
feedLocationEl.disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
function onOk()
|
||||
|
@ -426,6 +426,8 @@ var gFeedSubscriptionsWindow = {
|
||||
}
|
||||
}
|
||||
this.mView.mRowCount = numFolders;
|
||||
|
||||
gFeedSubscriptionsWindow.mTree.focus();
|
||||
},
|
||||
|
||||
updateFeedData: function (aItem)
|
||||
@ -447,8 +449,19 @@ var gFeedSubscriptionsWindow = {
|
||||
for (i = 0; i < ids.length; ++i)
|
||||
document.getElementById(ids[i]).disabled = !aItem || aItem.container;
|
||||
},
|
||||
|
||||
onRSSFeedSelected: function ()
|
||||
|
||||
onKeyPress: function(aEvent)
|
||||
{
|
||||
if (aEvent.keyCode == aEvent.DOM_VK_ENTER || aEvent.keyCode == aEvent.DOM_VK_RETURN)
|
||||
{
|
||||
var seln = this.mTree.view.selection;
|
||||
item = this.mView.getItemAtIndex(seln.currentIndex);
|
||||
if (item && !item.container)
|
||||
this.editFeed();
|
||||
}
|
||||
},
|
||||
|
||||
onSelect: function ()
|
||||
{
|
||||
var properties, item;
|
||||
var seln = this.mTree.view.selection;
|
||||
@ -602,6 +615,58 @@ var gFeedSubscriptionsWindow = {
|
||||
feed.download(true, this.mFeedDownloadCallback);
|
||||
},
|
||||
|
||||
editFeed: function()
|
||||
{
|
||||
var seln = this.mView.selection;
|
||||
if (seln.count != 1)
|
||||
return;
|
||||
|
||||
var itemToEdit = this.mView.getItemAtIndex(seln.currentIndex);
|
||||
if (!itemToEdit || itemToEdit.container)
|
||||
return;
|
||||
|
||||
var resource = rdf.GetResource(itemToEdit.url);
|
||||
var feed = new Feed(resource, this.mRSSServer);
|
||||
|
||||
var ds = getSubscriptionsDS(this.mRSSServer);
|
||||
var currentFolder = ds.GetTarget(resource, FZ_DESTFOLDER, true);
|
||||
var currentFolderURI = currentFolder.QueryInterface(Components.interfaces.nsIRDFResource).Value;
|
||||
|
||||
var userModifiedFeed = false;
|
||||
var feedProperties = { feedLocation: itemToEdit.url, serverURI: this.mRSSServer.serverURI,
|
||||
serverPrettyName: this.mRSSServer.prettyName, folderURI: currentFolderURI,
|
||||
quickMode: feed.quickMode, newFeed: false, result: userModifiedFeed};
|
||||
|
||||
feedProperties = openFeedEditor(feedProperties);
|
||||
if (!feedProperties.result) // did the user cancel?
|
||||
return;
|
||||
|
||||
// check to see if the quickMode value changed
|
||||
if (feed.quickMode != feedProperties.quickMode)
|
||||
feed.quickMode = feedProperties.quickMode;
|
||||
|
||||
// did the user change the folder URI for storing the feed?
|
||||
if (feedProperties.folderURI && feedProperties.folderURI != currentFolderURI)
|
||||
{
|
||||
// we need to find the index of the new parent folder...
|
||||
var newParentIndex = kRowIndexUndefined;
|
||||
for (index = 0; index < this.mView.rowCount; index++)
|
||||
{
|
||||
var item = this.mView.getItemAtIndex(index);
|
||||
if (item && item.container && item.url == feedProperties.folderURI)
|
||||
{
|
||||
newParentIndex = index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (newParentIndex != kRowIndexUndefined)
|
||||
this.moveFeed(seln.currentIndex, newParentIndex)
|
||||
}
|
||||
|
||||
ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush(); // flush any changes
|
||||
},
|
||||
|
||||
// moves the feed located at aOldFeedIndex to a child of aNewParentIndex
|
||||
moveFeed: function(aOldFeedIndex, aNewParentIndex)
|
||||
{
|
||||
@ -759,62 +824,3 @@ function clearStatusInfo()
|
||||
document.getElementById('statusText').value = "";
|
||||
document.getElementById('progressMeter').collapsed = true;
|
||||
}
|
||||
|
||||
function doEdit() {
|
||||
// XXX There should be some way of correlating feed RDF resources
|
||||
// with their corresponding Feed objects. Perhaps in the end much
|
||||
// of this code could hang off methods of the Feed object.
|
||||
var ds = getSubscriptionsDS(this.mRSSServer);
|
||||
var tree = document.getElementById('subscriptions');
|
||||
var item = tree.view.getItemAtIndex(tree.view.selection.currentIndex);
|
||||
var resource = rdf.GetResource(item.id);
|
||||
var old_url = ds.GetTarget(resource, DC_IDENTIFIER, true);
|
||||
old_url = old_url ? old_url.QueryInterface(Components.interfaces.nsIRDFLiteral).Value : "";
|
||||
var feed = new Feed(resource);
|
||||
|
||||
var currentFolder = ds.GetTarget(resource, FZ_DESTFOLDER, true);
|
||||
var currentFolderURI = currentFolder.QueryInterface(Components.interfaces.nsIRDFResource).Value;
|
||||
|
||||
currentFolder = rdf.GetResource(currentFolderURI).QueryInterface(Components.interfaces.nsIMsgFolder);
|
||||
|
||||
var userModifiedFeed = false;
|
||||
var feedProperties = { feedLocation: old_url, serverURI: this.mRSSServer.serverURI,
|
||||
serverPrettyName: this.mRSSServer.prettyName, folderURI: currentFolderURI,
|
||||
quickMode: feed.quickMode, result: userModifiedFeed};
|
||||
|
||||
feedProperties = openFeedEditor(feedProperties);
|
||||
if (!feedProperties.result) // did the user cancel?
|
||||
return;
|
||||
|
||||
// did the user change the folder URI for storing the feed?
|
||||
if (feedProperties.folderURI && feedProperties.folderURI != currentFolderURI)
|
||||
{
|
||||
// unassert the older URI, add an assertion for the new URI...
|
||||
ds.Change(resource, FZ_DESTFOLDER, currentFolder, rdf.GetResource(feedProperties.folderURI));
|
||||
|
||||
// we need to update the feed url attributes on the databases for each folder
|
||||
var folderResource = rdf.GetResource(feedProperties.folderURI);
|
||||
var newFolder = folderResource.QueryInterface(Components.interfaces.nsIMsgFolder);
|
||||
currentFolder = rdf.GetResource(currentFolderURI).QueryInterface(Components.interfaces.nsIMsgFolder);
|
||||
|
||||
updateFolderFeedUrl(currentFolder, old_url, true); // remove our feed url property from the current folder
|
||||
updateFolderFeedUrl(newFolder, feedProperties.feedLocation, false); // add our feed url property to the new folder
|
||||
|
||||
currentFolder = newFolder; // the folder has changed
|
||||
}
|
||||
|
||||
// check to see if the location changed
|
||||
if (feedProperties.feedLocation && feedProperties.feedLocation != old_url)
|
||||
{
|
||||
ds.Change(resource, DC_IDENTIFIER, rdf.GetLiteral(old_url), rdf.GetLiteral(feedProperties.feedLocation));
|
||||
// now update our feed url property on the destination folder
|
||||
updateFolderFeedUrl(currentFolder, old_url, false); // remove the old url
|
||||
updateFolderFeedUrl(currentFolder, feedProperties.feedLocation, true); // add the new one
|
||||
}
|
||||
|
||||
// check to see if the quickMode value changed
|
||||
if (feed.quickMode != feedProperties.quickMode)
|
||||
feed.quickMode = feedProperties.quickMode;
|
||||
|
||||
ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush(); // flush any changes
|
||||
}
|
||||
|
@ -75,12 +75,13 @@
|
||||
|
||||
<tree id="rssSubscriptionsList" flex="1" style="height: 10em;"
|
||||
hidecolumnpicker="true"
|
||||
onselect="gFeedSubscriptionsWindow.onRSSFeedSelected();"
|
||||
onselect="gFeedSubscriptionsWindow.onSelect();"
|
||||
onkeypress="gFeedSubscriptionsWindow.onKeyPress(event);"
|
||||
seltype="single">
|
||||
<treecols>
|
||||
<treecol id="folderNameCol" flex="2" primary="true" hideheader="true"/>
|
||||
</treecols>
|
||||
<treechildren id="subscriptionChildren" ondraggesture="gFeedSubscriptionsWindow.beginDrag(event);"/>
|
||||
<treechildren id="subscriptionChildren" ondblclick="gFeedSubscriptionsWindow.editFeed();" ondraggesture="gFeedSubscriptionsWindow.beginDrag(event);"/>
|
||||
</tree>
|
||||
|
||||
<hbox id="rssFeedInfoBox">
|
||||
|
Loading…
Reference in New Issue
Block a user