Bug 304458: Feed icon/menu doesn't respect key modifiers / middle mouse button, patch by Nickolay Ponomarev <asqueella@gmail.com>, r=mano

This commit is contained in:
gavin%gavinsharp.com 2006-08-18 08:11:46 +00:00
parent 8f7962d0cd
commit c15fab5d8b
4 changed files with 57 additions and 40 deletions

View File

@ -440,7 +440,8 @@
#else
label="&addLiveBookmarkMenuitem.label;"
#endif
oncommand="return FeedHandler.buildFeedList(event);"
oncommand="return FeedHandler.subscribeToFeed(null, event);"
onclick="checkForMiddleClick(this, event);"
disabled="true"/>
<menu id="subscribeToPageMenupopup"
#ifdef MOZ_FEEDS
@ -450,8 +451,9 @@
#endif
hidden="true">
<menupopup id="subscribeToPageSubmenuMenupopup"
onpopupshowing="return FeedHandler.buildFeedList(event);"
oncommand="return FeedHandler.subscribeToFeed(event.target.getAttribute('feed'));"/>
onpopupshowing="return FeedHandler.buildFeedList(event.target);"
oncommand="return FeedHandler.subscribeToFeed(null, event);"
onclick="checkForMiddleClick(this, event);"/>
</menu>
<menuitem id="bookmarkAllCmd"
# Accel+Shift+A-F are reserved on GTK2
@ -489,7 +491,8 @@
#else
label="&addLiveBookmarkMenuitem.label;"
#endif
oncommand="return FeedHandler.buildFeedList(event);"
oncommand="return FeedHandler.subscribeToFeed(null, event);"
onclick="checkForMiddleClick(this, event);"
disabled="true"/>
<menu id="subscribeToPageMenupopup"
#ifdef MOZ_FEEDS
@ -499,8 +502,9 @@
#endif
hidden="true">
<menupopup id="subscribeToPageSubmenuMenupopup"
onpopupshowing="return FeedHandler.buildFeedList(event);"
oncommand="return FeedHandler.subscribeToFeed(event.target.getAttribute('feed'));"/>
onpopupshowing="return FeedHandler.buildFeedList(event.target);"
oncommand="return FeedHandler.subscribeToFeed(null, event);"
onclick="checkForMiddleClick(this, event);"/>
</menu>
<menuitem label="&addCurPagesCmd.label;"
command="Browser:BookmarkAllTabs" key="bookmarkAllTabsKb"/>

View File

@ -6419,18 +6419,33 @@ var FeedHandler = {
true);
},
/**
* The click handler for the Feed icon in the location bar. Opens the
* subscription page if user is not given a choice of feeds.
* (Otherwise the list of available feeds will be presented to the
* user in a popup menu.)
*/
onFeedButtonClick: function(event) {
event.stopPropagation();
if (event.target.hasAttribute("feed") &&
event.eventPhase == Event.AT_TARGET &&
(event.button == 0 || event.button == 1)) {
this.subscribeToFeed(null, event);
}
},
/**
* Called when the user clicks on the Feed icon in the location bar.
* Builds a menu of unique feeds associated with the page, and if there
* is only one, shows the feed inline in the browser window.
* @param event
* The popupshowing event from the feed list menupopup
* @param menuPopup
* The feed list menupopup to be populated.
* @returns true if the menu should be shown, false if there was only
* one feed and the feed should be shown inline in the browser
* window (do not show the menupopup).
*/
buildFeedList: function(event) {
var menuPopup = event.target;
buildFeedList: function(menuPopup) {
var feeds = gBrowser.selectedBrowser.feeds;
if (feeds == null) {
// XXX hack -- menu opening depends on setting of an "open"
@ -6449,10 +6464,8 @@ var FeedHandler = {
// Get the list of unique feeds, and if there's only one unique entry,
// show the feed in the browser rather than displaying a menu.
var feeds = this.harvestFeeds(feeds);
if (feeds.length == 1) {
this.subscribeToFeed(feeds[0].href);
if (feeds.length == 1)
return false;
}
// Build the menu showing the available feed choices for viewing.
for (var i = 0; i < feeds.length; ++i) {
@ -6479,22 +6492,22 @@ var FeedHandler = {
* 3. Page has multiple feeds and user selects from feed icon popup
* 4. Page has multiple feeds and user selects from Subscribe submenu
* @param href
* The feed to subscribe to
* The feed to subscribe to. May be null, in which case the
* event target's feed attribute is examined.
* @param event
* The event this method is handling. Used to decide where
* to open the preview UI. (Optional, unless href is null)
*/
subscribeToFeed: function(href) {
subscribeToFeed: function(href, event) {
#ifdef MOZ_FEEDS
// Just load the feed in the content area to either subscribe or show the
// preview UI
if (!href)
href = event.target.getAttribute("feed");
this.loadFeed(href, event);
#else
#ifdef MOZ_PLACES
#ifdef MOZ_FEEDS
// Just load the feed in the content area to either subscribe or show the
// preview UI
this.loadFeed(href);
#else
PlacesCommandHook.addLiveBookmark(feeds[0].href);
#endif
#else
#ifdef MOZ_FEEDS
// Just load the feed in the content area to either subscribe or show the
// preview UI
this.loadFeed(href);
#else
this.addLiveBookmark(feeds[0].href);
#endif
@ -6580,10 +6593,10 @@ var FeedHandler = {
#endif
#ifdef MOZ_FEEDS
loadFeed: function(href) {
loadFeed: function(href, event) {
var feeds = gBrowser.selectedBrowser.feeds;
try {
loadURI(href, null, null, false);
openUILink(href, event, false, true, false, null);
}
finally {
// We might default to a livebookmarks modal dialog,
@ -6608,8 +6621,8 @@ var FeedHandler = {
var feeds = gBrowser.mCurrentBrowser.feeds;
if (!feeds || feeds.length == 0) {
if (feedButton.hasAttribute("feeds"))
feedButton.removeAttribute("feeds");
feedButton.removeAttribute("feeds");
feedButton.removeAttribute("feed");
feedButton.setAttribute("tooltiptext",
gNavigatorBundle.getString("feedNoFeeds"));
this._feedMenuitem.setAttribute("disabled", "true");
@ -6629,7 +6642,10 @@ var FeedHandler = {
if (feeds.length > 1) {
this._feedMenuitem.setAttribute("hidden", "true");
this._feedMenupopup.removeAttribute("hidden");
feedButton.removeAttribute("feed");
} else {
feedButton.setAttribute("feed", feeds[0].href);
this._feedMenuitem.setAttribute("feed", feeds[0].href);
this._feedMenuitem.removeAttribute("disabled");
this._feedMenuitem.removeAttribute("hidden");
this._feedMenupopup.setAttribute("hidden", "true");

View File

@ -253,18 +253,15 @@
class="plain"
id="feed-button"
chromedir="&locale.dir;"
onclick="event.stopPropagation();">
onclick="return FeedHandler.onFeedButtonClick(event);">
<menupopup position="after_end"
onpopupshowing="return FeedHandler.buildFeedList(event);"
onpopupshowing="return FeedHandler.buildFeedList(this);"
#ifdef MOZ_FEEDS
oncommand="return FeedHandler.subscribeToFeed(null, event);"
onclick="checkForMiddleClick(this, event);"/>
#else
#ifdef MOZ_PLACES
#ifdef MOZ_FEEDS
oncommand="FeedHandler.loadFeed(event.target.getAttribute('feed'));" />
#else
oncommand="PlacesCommandHook.addLiveBookmark(event.target.getAttribute('feed'));" />
#endif
#else
#ifdef MOZ_FEEDS
oncommand="FeedHandler.loadFeed(event.target.getAttribute('feed'));" />
#else
oncommand="FeedHandler.addLiveBookmark(event.target.getAttribute('feed'));" />
#endif

View File

@ -123,7 +123,7 @@ function openUILink( url, e, ignoreButton, ignoreAlt, allowKeywordFixup, postDat
*/
function whereToOpenLink( e, ignoreButton, ignoreAlt )
{
if (e == null)
if (!e)
e = { shiftKey:false, ctrlKey:false, metaKey:false, altKey:false, button:0 };
var shift = e.shiftKey;