Bug 385266 - New starring, bookmarking and tagging UI, changes noted in comment 333. r=dietrich.

This commit is contained in:
mozilla.mano@sent.com 2007-08-28 14:47:43 -07:00
Родитель 4901eb7dd6
Коммит bb205dfebc
10 изменённых файлов: 95 добавлений и 86 удалений

Просмотреть файл

@ -105,10 +105,13 @@ var PlacesCommandHook = {
},
/**
* Adds a bookmark to the page loaded in the given browser
* Adds a bookmark to the page loaded in the given browser.
*
* @param aBrowser
* a <browser> element
* a <browser> element.
* @param [optional] aParent
* The folder in which to create a new bookmark if the page loaded in
* aBrowser isn't bookmarked yet, defaults to the places root.
* @param [optional] aShowEditUI
* whether or not to show the edit-bookmark UI for the bookmark item
* @param [optional] aAnchorElement
@ -116,10 +119,9 @@ var PlacesCommandHook = {
* @param [optional] aPosition
* required if aShowEditUI is set, see popup's openPopup.
*/
bookmarkPage: function PCH_bookmarkPage(aBrowser, aShowEditUI,
bookmarkPage: function PCH_bookmarkPage(aBrowser, aParent, aShowEditUI,
aAnchorElement, aPosition) {
var uri = aBrowser.currentURI;
var itemId = PlacesUtils.getMostRecentBookmarkForURI(uri);
if (itemId == -1) {
// Copied over from addBookmarkForBrowser:
@ -138,8 +140,9 @@ var PlacesCommandHook = {
}
catch (e) { }
var parent = aParent != undefined ? aParent : PlacesUtils.placesRootId;
var descAnno = { name: DESCRIPTION_ANNO, value: description };
var txn = PlacesUtils.ptm.createItem(uri, PlacesUtils.placesRootId, -1,
var txn = PlacesUtils.ptm.createItem(uri, parent, -1,
title, null, [descAnno]);
PlacesUtils.ptm.commitTransaction(txn);
if (aShowEditUI)
@ -153,33 +156,36 @@ var PlacesCommandHook = {
/**
* Adds a bookmark to the page loaded in the current tab.
*/
bookmarkCurrentPage: function PCH_bookmarkCurrentPage(aShowEditUI) {
bookmarkCurrentPage: function PCH_bookmarkCurrentPage(aShowEditUI, aParent) {
// dock the panel to the star icon if it is visible, otherwise dock
// it to the content area
var starIcon = document.getElementById("star-icon");
var starIcon = document.getElementById("star-button");
if (starIcon && isElementVisible(starIcon)) {
this.bookmarkPage(getBrowser().selectedBrowser, aShowEditUI, starIcon,
"after_end");
var dockTo = document.getElementById("go-button-bottom");
this.bookmarkPage(getBrowser().selectedBrowser, aParent, aShowEditUI,
dockTo, "after_start");
}
else {
this.bookmarkPage(getBrowser().selectedBrowser, aShowEditUI, getBrowser(),
"overlap");
this.bookmarkPage(getBrowser().selectedBrowser, aParent, aShowEditUI,
getBrowser(), "overlap");
}
},
/**
* Adds a bookmark to the page targeted by a link.
* @param url
* The address of the link target
* @param title
* The link text
* @param aParent
* The folder in which to create a new bookmark if aURL isn't
* bookmarked.
* @param aURL (string)
* the address of the link target
* @param aTitle
* The link text
*/
bookmarkLink: function PCH_bookmarkLink(url, title) {
var linkURI = IO.newURI(url)
bookmarkLink: function PCH_bookmarkLink(aParent, aURL, aTitle) {
var linkURI = IO.newURI(aURL)
var itemId = PlacesUtils.getMostRecentBookmarkForURI(linkURI);
if (itemId == -1) {
var txn = PlacesUtils.ptm.createItem(linkURI, PlacesUtils.placesRootId, -1,
title);
var txn = PlacesUtils.ptm.createItem(linkURI, aParent, -1, aTitle);
PlacesUtils.ptm.commitTransaction(txn);
itemId = PlacesUtils.getMostRecentBookmarkForURI(linkURI);
}
@ -728,12 +734,12 @@ var PlacesStarButton = {
_batching: false,
updateState: function PSB_updateState() {
var starIcon = document.getElementById("star-icon");
var starIcon = document.getElementById("star-button");
if (!starIcon)
return;
var uri = getBrowser().currentURI;
this._starred = uri && PlacesUtils.bookmarks.isBookmarked(uri);
this._starred = uri && (PlacesUtils.getMostRecentBookmarkForURI(uri) != -1);
if (this._starred)
starIcon.setAttribute("starred", "true");
else

Просмотреть файл

@ -88,7 +88,7 @@
observes="isImage"/>
<!-- work-around bug 392512 -->
<command id="Browser:AddBookmarkAs"
oncommand="setTimeout(function() { PlacesCommandHook.bookmarkCurrentPage(true); }, 0);"/>
oncommand="PlacesCommandHook.bookmarkCurrentPage(true, PlacesUtils.bookmarksRootId);"/>
<!-- The command is disabled for the hidden window. Otherwise its enabled
state is handled by the BookmarkAllTabsHandler object. -->
<command id="Browser:BookmarkAllTabs"

Просмотреть файл

@ -284,10 +284,9 @@ function BookmarkThisTab()
if (tab.localName != "tab")
tab = getBrowser().mCurrentTab;
setTimeout(function() { // workaround bug 392512
PlacesCommandHook.bookmarkPage(tab.linkedBrowser, true, getBrowser(),
"overlap")
}, 0);
PlacesCommandHook.bookmarkPage(tab.linkedBrowser,
PlacesUtils.bookmarksRootId,
true, getBrowser(), "overlap");
}
/**

Просмотреть файл

@ -261,7 +261,6 @@
level="safe"
onclick="goDoCommand('safebrowsing-show-warning')" />
#endif
<image id="star-icon" onclick="if (event.button == 0) PlacesStarButton.onClick(event);"/>
</hbox>
</textbox>
<stack id="go-button-stack">
@ -284,15 +283,17 @@
chromedir="&locale.dir;" />
</vbox>
<toolbarbutton id="go-button"
flex="1"
chromedir="&locale.dir;"
label="&goEndCap.label;"
onclick="handleURLBarCommand(event);"
ondragover="nsDragAndDrop.dragOver(event, goButtonObserver);"
ondragdrop="nsDragAndDrop.drop(event, goButtonObserver);"
ondragexit="nsDragAndDrop.dragExit(event, goButtonObserver);"
tooltiptext="&goEndCap.tooltip;"/>
<hbox>
<toolbarbutton id="star-button" onclick="if (event.button == 0) PlacesStarButton.onClick(event);"/>
<toolbarbutton id="go-button"
chromedir="&locale.dir;"
label="&goEndCap.label;"
onclick="handleURLBarCommand(event);"
ondragover="nsDragAndDrop.dragOver(event, goButtonObserver);"
ondragdrop="nsDragAndDrop.drop(event, goButtonObserver);"
ondragexit="nsDragAndDrop.dragExit(event, goButtonObserver);"
tooltiptext="&goEndCap.tooltip;"/>
</hbox>
</stack>
</hbox>
</toolbaritem>

Просмотреть файл

@ -1123,17 +1123,13 @@ nsContextMenu.prototype = {
},
bookmarkThisPage: function CM_bookmarkThisPage() {
// workaround bug 392512
setTimeout(function(aSelf) {
PlacesCommandHook.bookmarkPage(aSelf.browser, true, aSelf.browser,
"overlap"); }, 0, this);
PlacesCommandHook.bookmarkPage(this.browser, PlacesUtils.bookmarksRootId,
true, this.browser, "overlap");
},
bookmarkLink: function CM_bookmarkLink() {
// workaround bug 392512
setTimeout(function(aSelf) {
PlacesCommandHook.bookmarkLink(aSelf.linkURL, aSelf.linkText());
}, 0, this);
PlacesCommandHook.bookmarkLink(PlacesUtils.bookmarksRootId, this.linkURL,
this.linkText());
},
addBookmarkForFrame: function CM_addBookmarkForFrame() {
@ -1146,16 +1142,13 @@ nsContextMenu.prototype = {
var description = PlacesUtils.getDescriptionFromDocument(doc);
var descAnno = { name: DESCRIPTION_ANNO, value: description };
var txn = PlacesUtils.ptm.createItem(uri, PlacesUtils.placesRootId, -1,
var txn = PlacesUtils.ptm.createItem(uri, PlacesUtils.bookmarksRootId, -1,
title, null, [descAnno]);
PlacesUtils.ptm.commitTransaction(txn);
itemId = PlacesUtils.getMostRecentBookmarkForURI(uri);
}
// workaround bug 392512
setTimeout(function(aSelf) {
PlacesCommandHook.showEditBookmarkPopup(itemId, aSelf.browser, "overlap");
}, 0, this);
PlacesCommandHook.showEditBookmarkPopup(itemId, this.browser, "overlap");
},
savePageAs: function CM_savePageAs() {

Просмотреть файл

@ -348,7 +348,7 @@ var gEditItemOverlay = {
// hide the tag selector if it was previously visible
var tagsSelector = this._element("tagsSelector");
if (!tagsSelector.collapsed)
tagsSelector.collapsed = true;
this._toggleTagsSelector();
}
if (this._observersAdded) {
@ -547,7 +547,7 @@ var gEditItemOverlay = {
// Update folder-tree selection
if (isElementVisible(this._folderTree)) {
var selectedNode = this._folderTree.selectedNode;
if (selectedNode.itemId != container)
if (!selectedNode || selectedNode.itemId != container)
this._folderTree.selectFolders([container]);
}
},
@ -558,13 +558,7 @@ var gEditItemOverlay = {
return;
var folderId = selectedNode.itemId;
// Don't set the selected item if the static item for the folder is
// already selected
var oldSelectedItem = this._folderMenuList.selectedItem;
if ((oldSelectedItem.id == "editBMPanel_toolbarFolderItem" &&
folderId == PlacesUtils.toolbarFolderId) ||
(oldSelectedItem.id == "editBMPanel_bmRootItem" &&
folderId == PlacesUtils.bookmarksRootId))
if (this._getFolderIdFromMenuList() == folderId)
return;
var folderItem = this._getFolderMenuItem(folderId, false);

Просмотреть файл

@ -74,12 +74,14 @@
</menupopup>
</menulist>
</row>
<row align="center" id="editBMPanel_locationRow">
<label value="&editBookmarkOverlay.location.label;"
contorl="editBMPanel_locationField"/>
<textbox id="editBMPanel_locationField"
onblur="gEditItemOverlay.onLocationFieldBlur();"/>
</row>
<row align="center" id="editBMPanel_folderRow">
<label value="&editBookmarkOverlay.folder.label;"
control="editBMPanel_folderMenuList"/>
@ -107,6 +109,7 @@
tooltiptextup="&editBookmarkOverlay.expanderUp.tooltip;"
oncommand="gEditItemOverlay.toggleFolderTreeVisibility();"/>
</row>
<tree id="editBMPanel_folderTree"
class="placesTree"
type="places"
@ -121,6 +124,7 @@
</treecols>
<treechildren flex="1"/>
</tree>
<row align="center" id="editBMPanel_tagsRow">
<label value="&editBookmarkOverlay.tags.label;"
control="tagsField"/>
@ -134,10 +138,7 @@
oncommand="gEditItemOverlay.toggleTagsSelector();"/>
</row>
<!-- XXX: Temporary workaround -->
</rows></grid>
<listbox id="editBMPanel_tagsSelector" height="150" collapsed="true"/>
<grid flex="1"><columns><column/><column flex="1"/></columns><rows>
<row id="editBMPanel_descriptionRow" align="center">
<label value="&editBookmarkOverlay.description.label;"

Просмотреть файл

@ -1495,7 +1495,7 @@ var PlacesUtils = {
/**
* Get the most recently added/modified bookmark for a URL, excluding items
* under tag containers. -1 is returned if no item is found.
* under tag or livemark containers. -1 is returned if no item is found.
*/
getMostRecentBookmarkForURI:
function PU_getMostRecentBookmarkForURI(aURI) {
@ -1503,10 +1503,12 @@ var PlacesUtils = {
for each (var bk in bmkIds) {
// Find the first folder which isn't a tag container
var folder = this.bookmarks.getFolderIdForItem(bk);
if (folder == this.placesRootId ||
this.bookmarks.getFolderIdForItem(folder) != this.tagRootId) {
if (folder == this.placesRootId)
return bk;
var parent = this.bookmarks.getFolderIdForItem(folder)
if (parent != this.tagRootId &&
!this.annotations.itemHasAnnotation(parent, "livemark/feedURI"))
return bk;
}
}
return -1;
}

Просмотреть файл

@ -1037,6 +1037,26 @@ toolbarpaletteitem:not([place="toolbar"]) .search-go-button {
padding: 0px;
}
/* STAR BUTTON */
#star-button {
list-style-image: url("chrome://browser/skin/places/starPage.png");
margin: 0;
padding: 0;
max-width: 0;
height: 24px;
}
#star-button > .toolbarbutton-icon {
padding: 2px 2px 2px 0;
border: 1px solid #A3A3A3;
border-left: 0;
background: url("chrome://global/skin/10pct_transparent_grey.png") repeat;
}
#star-button[starred="true"] {
list-style-image: url("chrome://browser/skin/places/pageStarred.png");
}
/* ----- SIDEBAR ELEMENTS ----- */
sidebarheader {
@ -1666,13 +1686,3 @@ toolbarbutton.bookmark-item[dragover="true"][open="true"] {
-moz-border-left-colors: ThreeDLightShadow ThreeDHighlight !important;
}
/* star icon */
#star-icon {
list-style-image: url("chrome://browser/skin/places/starPage.png");
width: 16px;
height: 16px;
}
#star-icon[starred="true"] {
list-style-image: url("chrome://browser/skin/places/pageStarred.png");
}

Просмотреть файл

@ -1025,6 +1025,20 @@ toolbar:not([mode="text"]) #go-button,
padding: 0;
}
/* star button */
toolbar:not([mode="text"]) #star-button,
#palette-box #star-button {
-moz-appearance: none;
list-style-image: url("chrome://browser/skin/places/starPage.png");
padding: 0;
border: none;
}
toolbar:not([mode="text"]) #star-button[starred="true"],
#palette-box #star-button[starred="true"] {
list-style-image: url("chrome://browser/skin/places/pageStarred.png");
}
#go-button[chromedir="rtl"] {
list-style-image: url("chrome://browser/skin/Go-arrow-rtl.png");
}
@ -1928,14 +1942,3 @@ toolbarbutton.bookmark-item[dragover="true"][open="true"] {
.bookmark-item[dragover-bottom="true"] {
-moz-border-bottom-colors: #000000;
}
/* star icon */
#star-icon {
list-style-image: url("chrome://browser/skin/places/starPage.png");
width: 16px;
height: 16px;
}
#star-icon[starred="true"] {
list-style-image: url("chrome://browser/skin/places/pageStarred.png");
}