Bug 463155 Add video/audio controls to message context menu, since the regular controls depend on JavaScript. r=philringnalda ui-review=clarkbw
This commit is contained in:
Родитель
34ad58fa00
Коммит
7e61c4a8ab
|
@ -467,3 +467,7 @@ pref("browser.formfill.enable", true);
|
|||
pref("browser.history_expire_days", 180);
|
||||
pref("browser.history_expire_days_min", 90);
|
||||
pref("browser.history_expire_sites", 40000);
|
||||
|
||||
// Disable autoplay as we don't handle audio elements in emails very well.
|
||||
// See bug 515082.
|
||||
pref("media.autoplay.enabled", false);
|
||||
|
|
|
@ -128,11 +128,11 @@ function fillMailContextMenu(event)
|
|||
(gContextMenu.onImage || gContextMenu.onLink);
|
||||
var single = (numSelected == 1);
|
||||
|
||||
let onPlayableMedia = gContextMenu.onVideo || gContextMenu.onAudio;
|
||||
|
||||
// Select-all and copy are only available in the message-pane
|
||||
if (inThreadPane) {
|
||||
document.getElementById("mailContext-selectall").hidden = true;
|
||||
document.getElementById("mailContext-copy").hidden = true;
|
||||
}
|
||||
ShowMenuItem("mailContext-selectall", !inThreadPane && !onPlayableMedia);
|
||||
ShowMenuItem("mailContext-copy", !inThreadPane && !onPlayableMedia);
|
||||
|
||||
// Show the Open in New Window and New Tab options if there is exactly one
|
||||
// message selected.
|
||||
|
@ -142,6 +142,8 @@ function fillMailContextMenu(event)
|
|||
/**
|
||||
* Most menu items are visible if there's 1 or 0 messages selected, and
|
||||
* enabled if there's exactly one selected. Handle those here.
|
||||
* Exception: playable media is selected, in which case, don't show them.
|
||||
*
|
||||
* @param aID the id of the element to display/enable
|
||||
* @param aHide (optional) an additional criteria to evaluate when we
|
||||
* decide whether to display the element. If false, we'll hide
|
||||
|
@ -149,7 +151,7 @@ function fillMailContextMenu(event)
|
|||
*/
|
||||
function setSingleSelection(aID, aHide) {
|
||||
var hide = aHide != undefined ? aHide : true;
|
||||
ShowMenuItem(aID, single && !hideMailItems && hide);
|
||||
ShowMenuItem(aID, single && !hideMailItems && hide && !onPlayableMedia);
|
||||
EnableMenuItem(aID, single);
|
||||
}
|
||||
|
||||
|
@ -172,26 +174,28 @@ function fillMailContextMenu(event)
|
|||
|
||||
// Set up the move menu. We can't move from newsgroups.
|
||||
ShowMenuItem("mailContext-moveMenu",
|
||||
!isNewsgroup && !hideMailItems && msgFolder);
|
||||
!isNewsgroup && !hideMailItems && msgFolder && !onPlayableMedia);
|
||||
|
||||
// disable move if we can't delete message(s) from this folder
|
||||
var canMove = msgFolder && msgFolder.canDeleteMessages;
|
||||
EnableMenuItem("mailContext-moveMenu", canMove);
|
||||
EnableMenuItem("mailContext-moveMenu", canMove && !onPlayableMedia);
|
||||
|
||||
// Copy is available as long as something is selected.
|
||||
ShowMenuItem("mailContext-copyMenu", !hideMailItems && msgFolder);
|
||||
ShowMenuItem("mailContext-copyMenu",
|
||||
!hideMailItems && msgFolder && !onPlayableMedia);
|
||||
|
||||
ShowMenuItem("mailContext-moveToFolderAgain", !hideMailItems && msgFolder);
|
||||
if (!hideMailItems) {
|
||||
let hideMoveToFolderAgain = !hideMailItems && msgFolder && !onPlayableMedia;
|
||||
ShowMenuItem("mailContext-moveToFolderAgain", hideMoveToFolderAgain);
|
||||
if (hideMoveToFolderAgain) {
|
||||
initMoveToFolderAgainMenu(document.getElementById("mailContext-moveToFolderAgain"));
|
||||
goUpdateCommand("cmd_moveToFolderAgain");
|
||||
}
|
||||
|
||||
ShowMenuItem("paneContext-afterMove", !inThreadPane);
|
||||
|
||||
ShowMenuItem("mailContext-tags", !hideMailItems && msgFolder);
|
||||
ShowMenuItem("mailContext-tags", !hideMailItems && msgFolder && !onPlayableMedia);
|
||||
|
||||
ShowMenuItem("mailContext-mark", !hideMailItems && msgFolder);
|
||||
ShowMenuItem("mailContext-mark", !hideMailItems && msgFolder && !onPlayableMedia);
|
||||
|
||||
setSingleSelection("mailContext-saveAs");
|
||||
if (Application.platformIsMac)
|
||||
|
@ -199,9 +203,10 @@ function fillMailContextMenu(event)
|
|||
else
|
||||
setSingleSelection("mailContext-printpreview");
|
||||
|
||||
ShowMenuItem("mailContext-print", !hideMailItems);
|
||||
ShowMenuItem("mailContext-print", !hideMailItems && !onPlayableMedia);
|
||||
|
||||
ShowMenuItem("mailContext-delete", !hideMailItems && (isNewsgroup || canMove));
|
||||
ShowMenuItem("mailContext-delete",
|
||||
!hideMailItems && (isNewsgroup || canMove) && !onPlayableMedia);
|
||||
// This function is needed for the case where a folder is just loaded (while
|
||||
// there isn't a message loaded in the message pane), a right-click is done
|
||||
// in the thread pane. This function will disable enable the 'Delete
|
||||
|
|
|
@ -532,6 +532,22 @@
|
|||
accesskey="©Cmd.accesskey;"
|
||||
command="cmd_copy"/>
|
||||
<menuseparator id="mailContext-sep-open"/>
|
||||
<menuitem id="mailContext-media-play"
|
||||
label="&contextPlay.label;"
|
||||
accesskey="&contextPlay.accesskey;"
|
||||
oncommand="gContextMenu.mediaCommand('play');"/>
|
||||
<menuitem id="mailContext-media-pause"
|
||||
label="&contextPause.label;"
|
||||
accesskey="&contextPause.accesskey;"
|
||||
oncommand="gContextMenu.mediaCommand('pause');"/>
|
||||
<menuitem id="mailContext-media-mute"
|
||||
label="&contextMute.label;"
|
||||
accesskey="&contextMute.accesskey;"
|
||||
oncommand="gContextMenu.mediaCommand('mute');"/>
|
||||
<menuitem id="mailContext-media-unmute"
|
||||
label="&contextUnmute.label;"
|
||||
accesskey="&contextUnmute.accesskey;"
|
||||
oncommand="gContextMenu.mediaCommand('unmute');"/>
|
||||
<menuitem id="mailContext-openNewWindow"
|
||||
label="&contextOpenNewWindow.label;"
|
||||
accesskey="&contextOpenNewWindow.accesskey;"
|
||||
|
|
|
@ -46,6 +46,8 @@ function nsContextMenu(aXulMenu) {
|
|||
this.onTextInput = false;
|
||||
this.onImage = false;
|
||||
this.onLoadedImage = false;
|
||||
this.onVideo = false;
|
||||
this.onAudio = false;
|
||||
this.onLink = false;
|
||||
this.onMailtoLink = false;
|
||||
this.onSaveableLink = false;
|
||||
|
@ -55,6 +57,7 @@ function nsContextMenu(aXulMenu) {
|
|||
this.linkURL = "";
|
||||
this.linkURI = null;
|
||||
this.linkProtocol = null;
|
||||
this.mediaURL = "";
|
||||
this.inFrame = false;
|
||||
this.hasBGImage = false;
|
||||
this.isContentSelected = false;
|
||||
|
@ -82,6 +85,7 @@ nsContextMenu.prototype = {
|
|||
initItems : function CM_initItems() {
|
||||
this.initSaveItems();
|
||||
this.initClipboardItems();
|
||||
this.initMediaPlayerItems();
|
||||
},
|
||||
initSaveItems : function CM_initSaveItems() {
|
||||
this.showItem("mailContext-savelink", this.onSaveableLink);
|
||||
|
@ -100,6 +104,21 @@ nsContextMenu.prototype = {
|
|||
this.showItem("mailContext-copylink", this.onLink);
|
||||
this.showItem("mailContext-copyimage", this.onImage);
|
||||
},
|
||||
initMediaPlayerItems: function CM_initMediaPlayerItems() {
|
||||
let onMedia = this.onVideo || this.onAudio;
|
||||
// Several mutually exclusive items.... play/pause, mute/unmute, show/hide
|
||||
this.showItem("mailContext-media-play", onMedia && this.target.paused);
|
||||
this.showItem("mailContext-media-pause", onMedia && !this.target.paused);
|
||||
this.showItem("mailContext-media-mute", onMedia && !this.target.muted);
|
||||
this.showItem("mailContext-media-unmute", onMedia && this.target.muted);
|
||||
if (onMedia) {
|
||||
let hasError = this.target.error != null;
|
||||
this.setItemAttr("mailContext-media-play", "disabled", hasError);
|
||||
this.setItemAttr("mailContext-media-pause", "disabled", hasError);
|
||||
this.setItemAttr("mailContext-media-mute", "disabled", hasError);
|
||||
this.setItemAttr("mailContext-media-unmute", "disabled", hasError);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the nsContextMenu properties based on the selected node and
|
||||
|
@ -118,6 +137,9 @@ nsContextMenu.prototype = {
|
|||
this.onTextInput = false;
|
||||
this.imageURL = "";
|
||||
this.onLink = false;
|
||||
this.onVideo = false;
|
||||
this.onAudio = false;
|
||||
this.mediaURL = "";
|
||||
this.linkURL = "";
|
||||
this.linkURI = null;
|
||||
this.linkProtocol = null;
|
||||
|
@ -144,6 +166,12 @@ nsContextMenu.prototype = {
|
|||
this.onTextInput = this.isTargetATextBox(this.target);
|
||||
} else if (this.target instanceof HTMLTextAreaElement) {
|
||||
this.onTextInput = true;
|
||||
} else if (this.target instanceof HTMLVideoElement) {
|
||||
this.onVideo = true;
|
||||
this.mediaURL = this.target.currentSrc || this.target.src;
|
||||
} else if (this.target instanceof HTMLAudioElement) {
|
||||
this.onAudio = true;
|
||||
this.mediaURL = this.target.currentSrc || this.target.src;
|
||||
} else if (this.target instanceof HTMLHtmlElement) {
|
||||
var bodyElt = this.target.ownerDocument.body;
|
||||
if (bodyElt) {
|
||||
|
@ -529,5 +557,26 @@ nsContextMenu.prototype = {
|
|||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
mediaCommand : function CM_mediaCommand(command) {
|
||||
var media = this.target;
|
||||
|
||||
switch (command) {
|
||||
case "play":
|
||||
media.play();
|
||||
break;
|
||||
case "pause":
|
||||
media.pause();
|
||||
break;
|
||||
case "mute":
|
||||
media.muted = true;
|
||||
break;
|
||||
case "unmute":
|
||||
media.muted = false;
|
||||
break;
|
||||
// XXX hide controls & show controls don't work in emails as Javascript is
|
||||
// disabled. May want to consider later for RSS feeds.
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -684,6 +684,16 @@ you can use these alternative items. Otherwise, their values should be empty. -
|
|||
<!ENTITY contextPrintPreview.label "Print Preview">
|
||||
<!ENTITY contextPrintPreview.accesskey "v">
|
||||
|
||||
<!-- Media (video/audio) controls -->
|
||||
<!ENTITY contextPlay.label "Play">
|
||||
<!ENTITY contextPlay.accesskey "P">
|
||||
<!ENTITY contextPause.label "Pause">
|
||||
<!ENTITY contextPause.accesskey "P">
|
||||
<!ENTITY contextMute.label "Mute">
|
||||
<!ENTITY contextMute.accesskey "M">
|
||||
<!ENTITY contextUnmute.label "Unmute">
|
||||
<!ENTITY contextUnmute.accesskey "m">
|
||||
|
||||
<!-- Junk Bar -->
|
||||
<!ENTITY junkBarMessage1.label "Junk Mail">
|
||||
<!ENTITY junkBarButton1.label "Not Junk">
|
||||
|
|
Загрузка…
Ссылка в новой задаче