зеркало из https://github.com/mozilla/gecko-dev.git
bug 42438, add wallet capture and prefill to context menu
This commit is contained in:
Родитель
a489c05fae
Коммит
26356313c2
|
@ -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="©LinkCmd.label;"
|
||||
accesskey="©LinkCmd.accesskey;"
|
||||
|
|
|
@ -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 () {
|
||||
|
|
|
@ -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">
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче