mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-14 10:43:24 +00:00
Bug 480151 - remember the last field modified first in the Add Bookmark dialog and start with focus there next time. r=dietrich.
This commit is contained in:
parent
6a55f079f9
commit
bfb7065461
@ -800,3 +800,7 @@ pref("browser.privatebrowsing.autostart", false);
|
||||
|
||||
// Whether we should skip prompting before starting the private browsing mode
|
||||
pref("browser.privatebrowsing.dont_prompt_on_enter", false);
|
||||
|
||||
// Don't try to alter this pref, it'll be reset the next time you use the
|
||||
// bookmarking dialog
|
||||
pref("browser.bookmarks.editDialog.firstEditField", "namePicker");
|
||||
|
@ -236,12 +236,17 @@ var StarUI = {
|
||||
function SU_panelShown(aEvent) {
|
||||
if (aEvent.target == this.panel) {
|
||||
if (!this._element("editBookmarkPanelContent").hidden) {
|
||||
var namePicker = this._element("editBMPanel_namePicker");
|
||||
namePicker.focus();
|
||||
namePicker.select();
|
||||
fieldToFocus = "editBMPanel_" +
|
||||
gPrefService.getCharPref("browser.bookmarks.editDialog.firstEditField");
|
||||
var elt = this._element(fieldToFocus);
|
||||
elt.focus();
|
||||
elt.select();
|
||||
}
|
||||
else
|
||||
else {
|
||||
// Note this isn't actually used anymore, we should remove this
|
||||
// once we decide not to bring back the page bookmarked notification
|
||||
this.panel.focus();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -55,6 +55,10 @@ var gEditItemOverlay = {
|
||||
_staticFoldersListBuilt: false,
|
||||
_initialized: false,
|
||||
|
||||
// the first field which was edited after this panel was initialized for
|
||||
// a certain item
|
||||
_firstEditedField: "",
|
||||
|
||||
get itemId() {
|
||||
return this._itemId;
|
||||
},
|
||||
@ -548,18 +552,19 @@ var gEditItemOverlay = {
|
||||
this._allTags = [];
|
||||
this._itemIds = [];
|
||||
this._multiEdit = false;
|
||||
this._firstEditedField = "";
|
||||
this._initialized = false;
|
||||
},
|
||||
|
||||
onTagsFieldBlur: function EIO_onTagsFieldBlur() {
|
||||
this._updateTags();
|
||||
if (this._updateTags()) // if anything has changed
|
||||
this._mayUpdateFirstEditField("tagsField");
|
||||
},
|
||||
|
||||
_updateTags: function EIO__updateTags() {
|
||||
if (this._multiEdit)
|
||||
this._updateMultipleTagsForItems();
|
||||
else
|
||||
this._updateSingleTagForItem();
|
||||
return this._updateMultipleTagsForItems();
|
||||
return this._updateSingleTagForItem();
|
||||
},
|
||||
|
||||
_updateSingleTagForItem: function EIO__updateSingleTagForItem() {
|
||||
@ -591,8 +596,32 @@ var gEditItemOverlay = {
|
||||
// Ensure the tagsField is in sync, clean it up from empty tags
|
||||
var tags = PlacesUtils.tagging.getTagsForURI(this._uri, {}).join(", ");
|
||||
this._initTextField("tagsField", tags, false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Stores the first-edit field for this dialog, if the passed-in field
|
||||
* is indeed the first edited field
|
||||
* @param aNewField
|
||||
* the id of the field that may be set (without the "editBMPanel_"
|
||||
* prefix)
|
||||
*/
|
||||
_mayUpdateFirstEditField: function EIO__mayUpdateFirstEditField(aNewField) {
|
||||
// * The first-edit-field behavior is not applied in the multi-edit case
|
||||
// * if this._firstEditedField is already set, this is not the first field,
|
||||
// so there's nothing to do
|
||||
if (this._multiEdit || this._firstEditedField)
|
||||
return;
|
||||
|
||||
this._firstEditedField = aNewField;
|
||||
|
||||
// set the pref
|
||||
var prefs = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefBranch);
|
||||
prefs.setCharPref("browser.bookmarks.editDialog.firstEditField", aNewField);
|
||||
},
|
||||
|
||||
_updateMultipleTagsForItems: function EIO__updateMultipleTagsForItems() {
|
||||
@ -636,8 +665,10 @@ var gEditItemOverlay = {
|
||||
|
||||
// Ensure the tagsField is in sync, clean it up from empty tags
|
||||
this._initTextField("tagsField", tags, false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
onNamePickerInput: function EIO_onNamePickerInput() {
|
||||
@ -656,6 +687,7 @@ var gEditItemOverlay = {
|
||||
// Here we update either the item title or its cached static title
|
||||
var newTitle = this._element("userEnteredName").label;
|
||||
if (this._getItemStaticTitle() != newTitle) {
|
||||
this._mayUpdateFirstEditField("namePicker");
|
||||
if (PlacesUIUtils.microsummaries.hasMicrosummary(this._itemId)) {
|
||||
// Note: this implicitly also takes care of the microsummary->static
|
||||
// title case, the removeMicorosummary method in the service will set
|
||||
|
Loading…
Reference in New Issue
Block a user