зеркало из https://github.com/mozilla/pjs.git
Bug 392820 (Bookmarks 'star' panel should capture keyboard shortcuts) - * block accel+w/accel+shift+w within the panel. * close the panel on enter/esc. * focus the name-field/picker and select its contents when opening the panel. * focus the content-area when the panel is closed. r=dietrich.
This commit is contained in:
Родитель
dd79a2d2f1
Коммит
7f16a38dfb
|
@ -53,12 +53,48 @@ var PlacesCommandHook = {
|
||||||
return document.getElementById("editBookmarkPanel");
|
return document.getElementById("editBookmarkPanel");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// list of command elements (by id) to disable when the panel is opened
|
||||||
|
_blockedCommands: ["cmd_close", "cmd_closeWindow"],
|
||||||
|
|
||||||
|
_blockCommands: function PCH__blockCommands() {
|
||||||
|
for each(var key in this._blockedCommands) {
|
||||||
|
var elt = document.getElementById(key);
|
||||||
|
if (elt.getAttribute("disabled") == "true")
|
||||||
|
elt.setAttribute("wasDisabled", "true");
|
||||||
|
else {
|
||||||
|
elt.setAttribute("wasDisabled", "false");
|
||||||
|
elt.setAttribute("disabled", "true");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_restoreCommandsState: function PCH__restoreCommandsState() {
|
||||||
|
for each(var key in this._blockedCommands) {
|
||||||
|
var elt = document.getElementById(key);
|
||||||
|
if (elt.getAttribute("wasDisabled") != "true")
|
||||||
|
elt.removeAttribute("disabled");
|
||||||
|
elt.removeAttribute("wasDisabled");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// nsIDOMEventListener
|
// nsIDOMEventListener
|
||||||
handleEvent: function PCH_handleEvent(aEvent) {
|
handleEvent: function PCH_handleEvent(aEvent) {
|
||||||
if (aEvent.originalTarget != this.panel)
|
switch (aEvent.type) {
|
||||||
return;
|
case "popuphiding":
|
||||||
|
if (aEvent.originalTarget == this.panel) {
|
||||||
gEditItemOverlay.uninitPanel(true);
|
gEditItemOverlay.uninitPanel(true);
|
||||||
|
this._restoreCommandsState();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "keypress":
|
||||||
|
if (aEvent.keyCode == KeyEvent.DOM_VK_ESCAPE ||
|
||||||
|
aEvent.keyCode == KeyEvent.DOM_VK_RETURN) {
|
||||||
|
// focus the content area and hide the panel
|
||||||
|
window.content.focus();
|
||||||
|
this.panel.hidePopup();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_overlayLoaded: false,
|
_overlayLoaded: false,
|
||||||
|
@ -98,10 +134,17 @@ var PlacesCommandHook = {
|
||||||
|
|
||||||
_doShowEditBookmarkPanel:
|
_doShowEditBookmarkPanel:
|
||||||
function PCH__doShowEditBookmarkPanel(aItemId, aAnchorElement, aPosition) {
|
function PCH__doShowEditBookmarkPanel(aItemId, aAnchorElement, aPosition) {
|
||||||
|
this.panel.addEventListener("keypress", this, true);
|
||||||
|
this._blockCommands(); // un-done in the popuphiding handler
|
||||||
this.panel.openPopup(aAnchorElement, aPosition, -1, -1);
|
this.panel.openPopup(aAnchorElement, aPosition, -1, -1);
|
||||||
|
|
||||||
gEditItemOverlay.initPanel(aItemId,
|
gEditItemOverlay.initPanel(aItemId,
|
||||||
{ hiddenRows: ["description", "location"] });
|
{ hiddenRows: ["description", "location"] });
|
||||||
|
setTimeout(function() {
|
||||||
|
var namePicker = document.getElementById("editBMPanel_namePicker");
|
||||||
|
namePicker.focus();
|
||||||
|
namePicker.editor.selectAll();
|
||||||
|
}, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Загрузка…
Ссылка в новой задаче