bug 42438, add wallet capture and prefill to context menu

This commit is contained in:
morse%netscape.com 2000-08-14 04:11:02 +00:00
parent a489c05fae
commit 26356313c2
3 changed files with 75 additions and 0 deletions

View File

@ -226,6 +226,14 @@ Contributor(s): ______________________________________. -->
value="&pasteCmd.label;"
accesskey="&pasteCmd.accesskey;"
observes="cmd_paste"/>
<menuitem id="context-capture"
value="&captureCmd.label;"
accesskey=""
oncommand="contextMenu.capture();"/>
<menuitem id="context-prefill"
value="&prefillCmd.label;"
accesskey=""
oncommand="contextMenu.prefill();"/>
<menuitem id="context-copylink"
value="&copyLinkCmd.label;"
accesskey="&copyLinkCmd.accesskey;"

View File

@ -137,6 +137,12 @@ nsContextMenu.prototype = {
// whether the user pref is enabled.
this.showItem( "context-blockimage", this.onImage && this.isBlockingImages() );
// Capture depends on whether a form is being displayed.
this.showItem( "context-capture", this.okToCapture() );
// Prefill depends on whether a form is being displayed.
this.showItem( "context-prefill", this.okToPrefill() );
// Remove separator if all items are removed.
this.showItem( "context-sep-view", !this.inDirList || this.inFrame || this.onImage );
},
@ -403,6 +409,64 @@ nsContextMenu.prototype = {
copyImage : function () {
this.copyToClipboard( this.imageURL );
},
// Capture the values that are filled in on the form being displayed.
capture : function () {
if( appCore ) {
status = appCore.walletRequestToCapture(window._content);
}
},
// Prefill the form being displayed.
prefill : function () {
if( appCore ) {
appCore.walletPreview(window, window._content);
}
},
// Determine if "Save Form Data" is to appear in the menu.
okToCapture: function () {
var capture = document.getElementById("menu_capture");
if (!window._content.document) {
return false;
}
var formsArray = window._content.document.forms;
var form;
for (form=0; form<formsArray.length; form++) {
var elementsArray = formsArray[form].elements;
var element;
for (element=0; element<elementsArray.length; element++) {
var type = elementsArray[element].type;
var value = elementsArray[element].value;
if ((type=="" || type=="text") && value!="") {
return true;
}
}
}
return false;
},
// Determine if "Prefill Form" is to appear in the menu.
okToPrefill: function () {
var prefill = document.getElementById("menu_prefill");
if (!window._content.document) {
return false;
}
var formsArray = window._content.document.forms;
var form;
for (form=0; form<formsArray.length; form++) {
var elementsArray = formsArray[form].elements;
var element;
for (element=0; element<elementsArray.length; element++) {
var type = elementsArray[element].type;
var value = elementsArray[element].value;
if (type=="" || type=="text" || type=="select-one") {
return true;
}
}
}
return false;
},
// Determine if "Block Image" is to appear in the menu.
// Return true if "imageBlocker.enabled" pref is set and image is not already blocked.
isBlockingImages: function () {

View File

@ -41,6 +41,9 @@
<!ENTITY pasteCmd.label "Paste">
<!ENTITY pasteCmd.accesskey "p">
<!ENTITY captureCmd.label "Save Form Data">
<!ENTITY prefillCmd.label "Prefill Form">
<!ENTITY viewMenu.label "View">
<!ENTITY viewMenu.accesskey "v">