Bug 467670: Bookmark management (part 1), r=gavin

This commit is contained in:
Mark Finkle 2009-02-25 01:20:45 -05:00
Родитель df880a3bca
Коммит 529613465f
12 изменённых файлов: 916 добавлений и 320 удалений

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

@ -30,7 +30,7 @@
</method>
</implementation>
</binding>
<binding id="popup_autocomplete">
<content hidden="true">
<xul:vbox class="autocomplete-box" flex="1">
@ -82,7 +82,7 @@
this._selectedItem = item;
this._styleItem(this._selectedItem, true);
}
return this._selectedIndex = val;
]]></setter>
</property>
@ -178,7 +178,7 @@
this.selectedIndex = newIndex;
]]></body>
</method>
<!-- Helpers -->
<field name="_items">
document.getAnonymousElementByAttribute(this,
@ -199,7 +199,7 @@
this.closePopup();
]]></body>
</method>
<method name="_styleItem">
<parameter name="aItem"/>
<parameter name="aAddStyle"/>
@ -227,38 +227,20 @@
</handlers>
</binding>
<binding id="editbookmark">
<content flex="1">
<grid flex="1"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<columns>
<column/>
<column flex="1"/>
<column/>
</columns>
<rows>
<row align="center">
<label value="&editBookmarkName.label;"/>
<textbox anonid="name" xbl:inherits="value=name"/>
<button label="&editBookmarkDone.label;"
oncommand="document.getBindingParent(this).stopEditing(true)"/>
</row>
<row align="center">
<label value="&editBookmarkURI.label;"/>
<textbox anonid="uri" xbl:inherits="value=uri"/>
<button class="close-button"
oncommand="document.getBindingParent(this).remove()"/>
</row>
<row align="center">
<label value="&editBookmarkTags.label;"/>
<textbox anonid="tags" xbl:inherits="value=tags"/>
</row>
</rows>
</grid>
</content>
<binding id="place-base">
<content/>
<implementation>
<field name="_bookmarkItem"/>
<field name="_bookmarkURI"/>
<constructor>
<![CDATA[
this._itemId = this.getAttribute("itemid");
this.init();
]]>
</constructor>
<field name="_itemId"/>
<field name="_uri"/>
<field name="_isEditing">false</field>
<field name="_nameField">
document.getAnonymousElementByAttribute(this, "anonid", "name");
</field>
@ -268,6 +250,8 @@
<field name="_tagsField">
document.getAnonymousElementByAttribute(this, "anonid", "tags");
</field>
<property name="itemId" onget="return this._itemId"/>
<property name="type" onget="return this.getAttribute('type');"/>
<property name="name" onget="return this._nameField.value"
onset="this._nameField.value = val; return val;"/>
<property name="uri" onget="return this._uriField.value"
@ -294,21 +278,55 @@
]]>
</getter>
</property>
<method name="startEditing">
<parameter name="uri"/>
<property name="isEditing" readonly="true" onget="return this._isEditing;"/>
<property name="control" readonly="true">
<getter>
<![CDATA[
let parent = this.parentNode;
while (parent) {
if (parent.localName == "placelist")
return parent;
parent = parent.parentNode;
}
return null;
]]>
</getter>
</property>
<method name="init">
<body>
<![CDATA[
var item = PlacesUtils.getMostRecentBookmarkForURI(uri);
if (item == -1)
this.name = PlacesUtils.bookmarks.getItemTitle(this._itemId);
try {
this._uri = PlacesUtils.bookmarks.getBookmarkURI(this._itemId);
} catch (e) {}
if (this._uri) {
this.uri = this._uri.spec;
let fis = Cc["@mozilla.org/browser/favicon-service;1"].getService(Ci.nsIFaviconService);
let icon = document.getAnonymousElementByAttribute(this, "anonid", "favicon");
icon.src = fis.getFaviconImageForPage(this._uri).spec;
}
]]>
</body>
</method>
<method name="startEditing">
<body>
<![CDATA[
if (this._itemId == -1)
return;
this._bookmarkItem = item;
this._bookmarkURI = uri;
this._isEditing = true;
if (this.control)
this.control.activeItem = this;
this.name = PlacesUtils.bookmarks.getItemTitle(item);
this.uri = uri.spec;
var currentTags = PlacesUtils.tagging.getTagsForURI(uri, {});
this.tags = currentTags.join(", ");
this.updateFields();
if (this._uri) {
var currentTags = PlacesUtils.tagging.getTagsForURI(this._uri, {});
this.tags = currentTags.join(", ");
}
this._nameField.focus();
]]>
@ -321,6 +339,12 @@
if (shouldSave)
this.save();
this._isEditing = false;
if (this.control)
this.control.activeItem = null;
this.updateFields();
let event = document.createEvent("Events");
event.initEvent("close", true, false);
this.dispatchEvent(event);
@ -330,39 +354,39 @@
<method name="save">
<body>
<![CDATA[
var item = this._bookmarkItem;
var uri = this._bookmarkURI;
// Update the name
PlacesUtils.bookmarks.setItemTitle(this._bookmarkItem, this.name);
PlacesUtils.bookmarks.setItemTitle(this._itemId, this.name);
// Update the tags
var currentTags = PlacesUtils.tagging.getTagsForURI(uri, {});
var tags = this.tagsAsArray;
if (tags.length > 0 || currentTags.length > 0) {
var tagsToRemove = [];
var tagsToAdd = [];
var i;
for (i = 0; i < currentTags.length; i++) {
if (tags.indexOf(currentTags[i]) == -1)
tagsToRemove.push(currentTags[i]);
}
for (i = 0; i < tags.length; i++) {
if (currentTags.indexOf(tags[i]) == -1)
tagsToAdd.push(tags[i]);
if (this._uri) {
var currentTags = PlacesUtils.tagging.getTagsForURI(this._uri, {});
var tags = this.tagsAsArray;
if (tags.length > 0 || currentTags.length > 0) {
var tagsToRemove = [];
var tagsToAdd = [];
var i;
for (i = 0; i < currentTags.length; i++) {
if (tags.indexOf(currentTags[i]) == -1)
tagsToRemove.push(currentTags[i]);
}
for (i = 0; i < tags.length; i++) {
if (currentTags.indexOf(tags[i]) == -1)
tagsToAdd.push(tags[i]);
}
if (tagsToAdd.length > 0)
PlacesUtils.tagging.tagURI(this._uri, tagsToAdd);
if (tagsToRemove.length > 0)
PlacesUtils.tagging.untagURI(this._uri, tagsToRemove);
}
if (tagsToAdd.length > 0)
PlacesUtils.tagging.tagURI(uri, tagsToAdd);
if (tagsToRemove.length > 0)
PlacesUtils.tagging.untagURI(uri, tagsToRemove);
}
// If the URI was updated change it in the bookmark
if (this._uri.spec != this.uri) {
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
uri = ios.newURI(this.uri, null, null);
if (uri.spec != this.uri) {
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
var newuri = ios.newURI(this.uri, null, null);
PlacesUtils.bookmarks.changeBookmarkURI(item, newuri);
PlacesUtils.bookmarks.changeBookmarkURI(this._itemId, this._uri);
}
}
]]>
</body>
@ -370,26 +394,502 @@
<method name="remove">
<body>
<![CDATA[
PlacesUtils.bookmarks.removeItem(this._bookmarkItem);
PlacesUtils.bookmarks.removeItem(this._itemId);
// If this was the last bookmark (excluding tag-items and livemark
// children, see getMostRecentBookmarkForURI) for the bookmark's url,
// remove the url from tag containers as well.
var uri = this._bookmarkURI;
if (PlacesUtils.getMostRecentBookmarkForURI(uri) == -1) {
var tags = PlacesUtils.tagging.getTagsForURI(uri, {});
PlacesUtils.tagging.untagURI(uri, tags);
if (this._uri) {
if (PlacesUtils.getMostRecentBookmarkForURI(this._uri) == -1) {
var tags = PlacesUtils.tagging.getTagsForURI(this._uri, {});
PlacesUtils.tagging.untagURI(this._uri, tags);
}
}
let event = document.createEvent("Events");
event.initEvent("RemoveBookmark", true, false);
this.dispatchEvent(event);
this.stopEditing(false);
if (this.control)
this.control.removeItem(this);
let event = document.createEvent("Events");
event.initEvent("BookmarkRemove", true, false);
this.dispatchEvent(event);
]]>
</body>
</method>
<method name="selectFolder">
<body>
<![CDATA[
if (this.control)
this.control.activeItem = this;
let control = this.control || this;
let code = control.getAttribute("onfolder");
if (code) {
let func = new Function(code);
func.call(control);
}
]]>
</body>
</method>
<method name="updateFields">
<body>
<![CDATA[
// implemented by sub classes
]]>
</body>
</method>
</implementation>
</binding>
<binding id="place-item" extends="chrome://browser/content/bindings.xml#place-base">
<content align="start">
<xul:image anonid="favicon" class="bookmark-item-image"/>
<xul:grid flex="1">
<xul:columns>
<xul:column flex="1"/>
<xul:column/>
</xul:columns>
<xul:rows>
<xul:row align="center">
<xul:textbox anonid="name" readonly="true" xbl:inherits="value=name"/>
<xul:hbox anonid="edit-controls" class="bookmark-manage-controls">
<xul:button anonid="close-button" class="close-button"
oncommand="document.getBindingParent(this).remove()"/>
<xul:button anonid="folder-button" label="&editBookmarkMove.label;"
oncommand="document.getBindingParent(this).selectFolder()"/>
<xul:button anonid="edit-button" label="&editBookmarkEdit.label;"
oncommand="document.getBindingParent(this).startEditing()"/>
<xul:button anonid="done-button" label="&editBookmarkDone.label;" hidden="true"
oncommand="document.getBindingParent(this).stopEditing(true)"/>
</xul:hbox>
</xul:row>
<xul:row anonid="uri-row" align="center" hidden="true">
<xul:textbox anonid="uri" xbl:inherits="value=uri"/>
</xul:row>
<xul:row anonid="tags-row" align="center" hidden="true">
<xul:textbox anonid="tags" xbl:inherits="value=tags" emptytext="&editBookmarkTags.label;"/>
</xul:row>
</xul:rows>
</xul:grid>
</content>
<implementation>
<method name="updateFields">
<body>
<![CDATA[
this._nameField.readOnly = !this._isEditing;
document.getAnonymousElementByAttribute(this, "anonid", "edit-button").hidden = this._isEditing;
document.getAnonymousElementByAttribute(this, "anonid", "done-button").hidden = !this._isEditing;
document.getAnonymousElementByAttribute(this, "anonid", "uri-row").hidden = !this._isEditing;
document.getAnonymousElementByAttribute(this, "anonid", "tags-row").hidden = !this._isEditing;
]]>
</body>
</method>
</implementation>
</binding>
<binding id="place-folder" extends="chrome://browser/content/bindings.xml#place-base">
<content align="center">
<xul:image anonid="favicon" class="bookmark-folder-image"/>
<xul:grid flex="1">
<xul:columns>
<xul:column flex="1"/>
<xul:column/>
</xul:columns>
<xul:rows>
<xul:row align="center">
<xul:textbox anonid="name" readonly="true" xbl:inherits="value=name"/>
<xul:hbox anonid="edit-controls" class="bookmark-manage-controls">
<xul:button anonid="close-button" class="close-button"
oncommand="document.getBindingParent(this).remove()"/>
<xul:button anonid="folder-button" label="&editBookmarkMove.label;"
oncommand="document.getBindingParent(this).selectFolder()"/>
<xul:button anonid="edit-button" label="&editBookmarkEdit.label;"
oncommand="document.getBindingParent(this).startEditing()"/>
<xul:button anonid="done-button" label="&editBookmarkDone.label;" hidden="true"
oncommand="document.getBindingParent(this).stopEditing(true)"/>
</xul:hbox>
</xul:row>
</xul:rows>
</xul:grid>
</content>
<implementation>
<method name="updateFields">
<body>
<![CDATA[
this._nameField.readOnly = !this._isEditing;
document.getAnonymousElementByAttribute(this, "anonid", "edit-button").hidden = this._isEditing;
document.getAnonymousElementByAttribute(this, "anonid", "done-button").hidden = !this._isEditing;
]]>
</body>
</method>
</implementation>
</binding>
<binding id="place-label" extends="chrome://browser/content/bindings.xml#place-base">
<content align="center">
<xul:spacer xbl:inherits="width=indent"/>
<xul:image anonid="favicon" class="bookmark-folder-image"/>
<xul:label anonid="name" crop="end" flex="1"/>
</content>
</binding>
<binding id="place-list">
<content orient="vertical" flex="1">
<xul:vbox anonid="parent-items" class="place-list-parents">
</xul:vbox>
<xul:richlistbox anonid="child-items" class="place-list-children" flex="1"/>
</content>
<implementation>
<constructor>
<![CDATA[
this._type = this.getAttribute("type");
this._mode = this.getAttribute("mode");
let bs = Cc["@mozilla.org/intl/stringbundle;1"].getService(Ci.nsIStringBundleService);
this._bundle = bs.createBundle("chrome://browser/locale/browser.properties");
]]>
</constructor>
<field name="_bundle">null</field>
<field name="_type"/>
<field name="_mode"/>
<field name="_activeItem">null</field>
<field name="_ignoreEditing">false</field>
<field name="_manageUI">false</field>
<field name="_parents">
document.getAnonymousElementByAttribute(this, "anonid", "parent-items");
</field>
<field name="_children">
document.getAnonymousElementByAttribute(this, "anonid", "child-items");
</field>
<property name="activeItem">
<getter>
<![CDATA[
return this._activeItem;
]]>
</getter>
<setter>
<![CDATA[
if (!this._ignoreEditing) {
if (this._activeItem && this._activeItem.isEditing) {
this._ignoreEditing = true;
this._activeItem.stopEditing(false);
this._ignoreEditing = false;
}
this._activeItem = val;
}
return val;
]]>
</setter>
</property>
<property name="manageUI">
<getter>
<![CDATA[
return this._manageUI;
]]>
</getter>
<setter>
<![CDATA[
if (this._manageUI != val) {
this._manageUI = val;
if (this._manageUI) {
this.setAttribute("ui", "manage");
}
else {
if (this._activeItem)
this._activeItem.stopEditing();
this.removeAttribute("ui");
}
}
return val;
]]>
</setter>
</property>
<method name="_getChildren">
<parameter name="aFolder"/>
<body>
<![CDATA[
let items = [];
let options = PlacesUtils.history.getNewQueryOptions();
options.queryType = (this._type == "bookmarks" ? options.QUERY_TYPE_BOOKMARKS : options.QUERY_TYPE_HISTORY);
let query = PlacesUtils.history.getNewQuery();
if (aFolder)
query.setFolders([aFolder], 1);
let result = PlacesUtils.history.executeQuery(query, options);
let rootNode = result.root;
rootNode.containerOpen = true;
let cc = rootNode.childCount;
for (var i=0; i<cc; ++i) {
var node = rootNode.getChild(i);
if (this._mode == "folders" && node.type == node.RESULT_TYPE_FOLDER) {
items.push(node);
}
else if (this._mode == "") {
items.push(node);
}
}
rootNode.containerOpen = false;
return items;
]]>
</body>
</method>
<method name="openFolder">
<parameter name="aRootFolder"/>
<body>
<![CDATA[
aRootFolder = aRootFolder || PlacesUtils.bookmarks.bookmarksMenuFolder;
this._activeItem = null;
let parents = this._parents;
while (parents.firstChild)
parents.removeChild(parents.firstChild);
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
var self = this;
let folderId = aRootFolder;
do {
let parent = document.createElementNS(XULNS, "placelabel");
parent.setAttribute("class", "bookmark-folder");
parent.setAttribute("itemid", folderId);
parent.setAttribute("indent", 0);
parents.insertBefore(parent, parents.firstChild);
// XXX Fix me - use <handler>?
parent.addEventListener("click", function(e) { self.openFolder(e.target.itemId); }, false);
folderId = PlacesUtils.bookmarks.getFolderIdForItem(folderId);
} while (folderId != PlacesUtils.bookmarks.placesRoot)
let children = this._children;
while (children.firstChild)
children.removeChild(children.firstChild);
let childItems = this._getChildren(aRootFolder);
for (let i=0; i<childItems.length; i++) {
let node = childItems[i];
this.appendItem(node.itemId, node.type);
}
// Add the "<new folder>" item
let newFolder = document.createElementNS(XULNS, "button");
newFolder.setAttribute("class", "bookmark-folder-new");
newFolder.setAttribute("label", this._bundle.GetStringFromName("editBookmarkAddFolder"));
children.appendChild(newFolder);
// XXX Fix me - use <handler>?
newFolder.addEventListener("click", function(e) { self.addFolder(); }, false);
]]>
</body>
</method>
<method name="addFolder">
<body>
<![CDATA[
let parents = this._parents;
let parent = parents.lastChild;
if ("itemId" in parent) {
let children = this._children;
let newId = PlacesUtils.bookmarks.createFolder(parent.itemId, this._bundle.GetStringFromName("editBookmarkNewFolder"), PlacesUtils.bookmarks.DEFAULT_INDEX);
let child = this.appendItem(newId, Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER, children.lastChild);
child.startEditing();
}
]]>
</body>
</method>
<method name="appendItem">
<parameter name="aItemId"/>
<parameter name="aType"/>
<parameter name="aBefore"/>
<body>
<![CDATA[
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
let child = document.createElementNS(XULNS, "placeitem");
child.setAttribute("itemid", aItemId);
child.setAttribute("class", "bookmark-item");
if (aType == Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER)
child.setAttribute("type", "folder");
this._children.insertBefore(child, aBefore);
// XXX make a <handler> for the mousedown
var self = this;
child.addEventListener("mouseup", function(e) { self._fireOpen(e, child); }, false);
return child;
]]>
</body>
</method>
<method name="removeItem">
<parameter name="aItem"/>
<body>
<![CDATA[
this._children.removeChild(aItem);
]]>
</body>
</method>
<method name="_fireOpen">
<parameter name="aEvent"/>
<parameter name="aItem"/>
<body>
<![CDATA[
if (aEvent.target.isEditing || aEvent.originalTarget.localName == "button")
return;
if (aItem.type == "folder") {
this.openFolder(aItem.itemId);
}
else {
// Force the item to be active
this._activeItem = aItem;
// This is a callback used to forward information to some
// external code [we fire an event & a pseudo attribute event]
let event = document.createEvent("Events");
event.initEvent("BookmarkOpen", true, false);
this.dispatchEvent(event);
let func = new Function("event", this.getAttribute("onopen"));
func.call(this, event);
}
]]>
</body>
</method>
</implementation>
</binding>
<binding id="place-tree">
<content orient="vertical" flex="1">
<xul:richlistbox anonid="items" class="place-tree-items" flex="1"/>
</content>
<implementation>
<constructor>
<![CDATA[
this._type = this.getAttribute("type");
this._mode = this.getAttribute("mode");
]]>
</constructor>
<field name="_type"/>
<field name="_mode"/>
<field name="_items">
document.getAnonymousElementByAttribute(this, "anonid", "items");
</field>
<property name="selectedItem" readonly="true">
<getter>
<![CDATA[
return this._items.selectedItem;
]]>
</getter>
</property>
<method name="_getChildren">
<parameter name="aFolder"/>
<body>
<![CDATA[
let items = [];
let options = PlacesUtils.history.getNewQueryOptions();
options.queryType = (this._type == "bookmarks" ? options.QUERY_TYPE_BOOKMARKS : options.QUERY_TYPE_HISTORY);
let query = PlacesUtils.history.getNewQuery();
if (aFolder)
query.setFolders([aFolder], 1);
let result = PlacesUtils.history.executeQuery(query, options);
let rootNode = result.root;
rootNode.containerOpen = true;
let cc = rootNode.childCount;
for (var i=0; i<cc; ++i) {
var node = rootNode.getChild(i);
if (this._mode == "folders" && node.type == node.RESULT_TYPE_FOLDER) {
items.push(node);
}
else if (this._mode == "") {
items.push(node);
}
}
rootNode.containerOpen = false;
return items;
]]>
</body>
</method>
<method name="openFolder">
<parameter name="aRootFolder"/>
<parameter name="aLevel"/>
<body>
<![CDATA[
aRootFolder = aRootFolder || PlacesUtils.bookmarks.bookmarksMenuFolder;
aLevel = aLevel || 0;
let items = this._items;
if (!aLevel) {
while (items.firstChild)
items.removeChild(items.firstChild);
}
let childItems = this._getChildren(aRootFolder);
for (let i=0; i<childItems.length; i++) {
let node = childItems[i];
let child = this.appendItem(node.itemId, node.type, aLevel);
this.openFolder(node.itemId, aLevel + 24);
}
]]>
</body>
</method>
<method name="appendItem">
<parameter name="aItemId"/>
<parameter name="aType"/>
<parameter name="aLevel"/>
<body>
<![CDATA[
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
let child = document.createElementNS(XULNS, "placelabel");
child.setAttribute("type", "folder");
child.setAttribute("itemid", aItemId);
child.setAttribute("indent", aLevel);
this._items.appendChild(child);
// XXX make a <handler> for the mouseup
var self = this;
child.addEventListener("mouseup", function(e) { self._fireOpen(e, child); }, false);
return child;
]]>
</body>
</method>
<method name="_fireOpen">
<parameter name="aEvent"/>
<parameter name="aItem"/>
<body>
<![CDATA[
// Force the item to be selected
this._items.selectedItem = aItem;
// This is a callback used to forward information to some
// external code
let func = new Function(this.getAttribute("onopen"));
func.call(this);
]]>
</body>
</method>
</implementation>
</binding>
</bindings>

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

@ -45,10 +45,9 @@ const UIMODE_NONE = 0;
const UIMODE_URLVIEW = 1;
const UIMODE_URLEDIT = 2;
const UIMODE_BOOKMARK = 3;
const UIMODE_BOOKMARKLIST = 4;
const UIMODE_TABS = 5;
const UIMODE_CONTROLS = 6;
const UIMODE_PANEL = 7;
const UIMODE_TABS = 4;
const UIMODE_CONTROLS = 5;
const UIMODE_PANEL = 6;
const kMaxEngines = 4;
const kDefaultFavIconURL = "chrome://browser/skin/images/default-favicon.png";
@ -146,27 +145,6 @@ var BrowserUI = {
this._favicon.src = faviconURI.spec;
},
_getBookmarks : function(aFolders) {
var items = [];
var hs = Cc["@mozilla.org/browser/nav-history-service;1"].getService(Ci.nsINavHistoryService);
var options = hs.getNewQueryOptions();
//options.resultType = options.RESULTS_AS_URI;
var query = hs.getNewQuery();
query.setFolders(aFolders, 1);
var result = hs.executeQuery(query, options);
var rootNode = result.root;
rootNode.containerOpen = true;
var cc = rootNode.childCount;
for (var i=0; i<cc; ++i) {
var node = rootNode.getChild(i);
items.push(node);
}
rootNode.containerOpen = false;
return items;
},
_getHistory : function(aCount) {
var items = [];
@ -420,13 +398,9 @@ var BrowserUI = {
if (this.mode == aMode)
return;
if (this.mode == UIMODE_BOOKMARKLIST && aMode != UIMODE_BOOKMARKLIST)
window.removeEventListener("keypress", BrowserUI.closePopup, false);
this.mode = aMode;
let bookmark = document.getElementById("bookmark-container");
let urllist = document.getElementById("urllist-container");
let container = document.getElementById("browser-container");
let panelUI = document.getElementById("panel-container");
@ -435,7 +409,6 @@ var BrowserUI = {
this._editToolbar(false);
bookmark.hidden = true;
urllist.hidden = true;
panelUI.hidden = true;
}
else if (aMode == UIMODE_URLEDIT) {
@ -443,33 +416,18 @@ var BrowserUI = {
this._editToolbar(true);
bookmark.hidden = true;
urllist.hidden = true;
panelUI.hidden = true;
}
else if (aMode == UIMODE_BOOKMARK) {
this._showToolbar(true);
this._editToolbar(false);
urllist.hidden = true;
panelUI.hidden = true;
bookmark.hidden = false;
bookmark.width = container.boxObject.width;
}
else if (aMode == UIMODE_BOOKMARKLIST) {
this._showToolbar(false);
this._editToolbar(false);
window.addEventListener("keypress", this.closeBookmarks, false);
bookmark.hidden = true;
panelUI.hidden = true;
urllist.hidden = false;
urllist.width = container.boxObject.width;
urllist.height = container.boxObject.height;
}
else if (aMode == UIMODE_PANEL) {
bookmark.hidden = true;
urllist.hidden = true;
panelUI.hidden = false;
panelUI.width = container.boxObject.width;
panelUI.height = container.boxObject.height;
@ -481,59 +439,11 @@ var BrowserUI = {
else if (aMode == UIMODE_NONE) {
this._showToolbar(false);
this._edit.reallyClosePopup();
urllist.hidden = true;
bookmark.hidden = true;
panelUI.hidden = true;
}
},
_showPlaces : function(aItems) {
var list = document.getElementById("urllist-items");
while (list.firstChild) {
list.removeChild(list.firstChild);
}
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
var fis = Cc["@mozilla.org/browser/favicon-service;1"].getService(Ci.nsIFaviconService);
for (var i=0; i<aItems.length; i++) {
let node = aItems[i];
let listItem = document.createElement("richlistitem");
listItem.align = "center";
listItem.className = "urllist-item";
listItem.setAttribute("value", node.uri);
let image = document.createElement("image");
image.setAttribute("class", "urllist-image");
let icon = node.icon ? node.icon.spec : fis.getFaviconImageForPage(ios.newURI(node.uri, null, null)).spec
image.setAttribute("src", icon);
listItem.appendChild(image);
let box = document.createElement("hbox");
box.align = "center";
box.flex = 1;
let label = document.createElement("label");
label.className = "urllist-text";
label.setAttribute("value", node.title);
label.setAttribute("crop", "end");
label.flex = 1;
box.appendChild(label);
let button = document.createElement("button");
button.setAttribute("label", "Edit");
box.appendChild(button);
listItem.appendChild(box);
list.appendChild(listItem);
button.addEventListener("command", BrowserUI.editBookmark, false);
box.addEventListener("click", BrowserUI.goToBookmark, false);
}
list.focus();
},
updateStar : function() {
var star = document.getElementById("tool-star");
if (PlacesUtils.getMostRecentBookmarkForURI(Browser.selectedBrowser.currentURI) != -1)
@ -550,78 +460,12 @@ var BrowserUI = {
BrowserUI.goToURI(list.selectedItem.value)
},
editBookmark : function(aEvent) {
var selectedItem = document.getElementById("urllist-items").selectedItem;
if (!selectedItem)
return;
if (BrowserUI._editingBookmark)
BrowserUI._editingBookmark.lastChild.stopEditing(true);
BrowserUI._editingBookmark = selectedItem;
selectedItem.childNodes[1].collapsed = true; // the hbox
var bookmarkEdit = document.createElement("editbookmark");
selectedItem.appendChild(bookmarkEdit);
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
var uri = ios.newURI(selectedItem.value, null, null);
bookmarkEdit.startEditing(uri);
bookmarkEdit.addEventListener("RemoveBookmark", BrowserUI.removeBookmark, false);
},
stopEditBookmark : function() {
var item = this._editingBookmark;
if (!item)
return;
var edititem = item.lastChild;
edititem.removeEventListener("RemoveBookmark", BrowserUI.removeBookmark, false);
item.value = edititem.uri;
item.childNodes[1].firstChild.value = edititem.name; // the bookmark title label
item.childNodes[1].collapsed = false; // the hbox
this._editingBookmark.removeChild(edititem);
this._editingBookmark = null;
this.updateStar();
document.getElementById("urllist-items").focus();
},
removeBookmark : function() {
if (BrowserUI._editingBookmark) {
var list = document.getElementById("urllist-items");
list.removeItemAt(list.getIndexOfItem(BrowserUI._editingBookmark));
BrowserUI._editingBookmark = null;
}
BrowserUI.updateStar();
},
closeBookmarks : function(aEvent) {
if (aEvent.type == "keypress" && aEvent.keyCode != aEvent.DOM_VK_ESCAPE)
return;
if (BrowserUI._editingBookmark)
BrowserUI._editingBookmark.lastChild.stopEditing(true);
BrowserUI.show(UIMODE_NONE);
document.getElementById("urllist-items").blur();
},
closePopup : function(aEvent) {
if (aEvent.keyCode == aEvent.DOM_VK_ESCAPE)
BrowserUI.show(UIMODE_NONE);
},
showHistory : function() {
this._showPlaces(this._getHistory(6));
// XXX Fix me with a real UI
},
showBookmarks : function () {
this.show(UIMODE_BOOKMARKLIST);
var bms = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].getService(Ci.nsINavBookmarksService);
this._showPlaces(this._getBookmarks([bms.bookmarksMenuFolder]));
BookmarkList.show();
},
newTab : function() {
@ -784,21 +628,100 @@ var BrowserUI = {
};
var BookmarkHelper = {
edit : function(aURI) {
edit: function(aURI) {
var bookmarkEdit = document.getElementById("bookmark-edit");
bookmarkEdit.startEditing(aURI);
window.addEventListener("keypress", this, true);
},
close : function() {
close: function() {
var bookmarkEdit = document.getElementById("bookmark-edit");
window.removeEventListener("keypress", this, true);
BrowserUI.show(UIMODE_NONE);
BrowserUI.updateStar();
},
handleEvent: function (aEvent) {
handleEvent: function(aEvent) {
if (aEvent.keyCode == aEvent.DOM_VK_ESCAPE)
document.getElementById("bookmark-edit").stopEditing(true);
}
};
var BookmarkList = {
_panel: null,
_bookmarks: null,
show: function() {
let container = document.getElementById("browser-container");
this._panel = document.getElementById("bookmarklist-container");
this._panel.hidden = false;
this._panel.width = container.boxObject.width;
this._panel.height = container.boxObject.height;
this._bookmarks = document.getElementById("bookmark-items");
this._bookmarks.manageUI = false;
this._bookmarks.openFolder();
window.addEventListener("keypress", this, true);
},
close: function() {
window.removeEventListener("keypress", this, true);
BrowserUI.updateStar();
if (this._bookmarks.isEditing)
this._bookmarks.stopEditing();
this._bookmarks.blur();
this._panel.hidden = true;
},
toggleManage: function() {
this._bookmarks.manageUI = !(this._bookmarks.manageUI);
},
openBookmark: function() {
let item = this._bookmarks.activeItem;
if (item.uri) {
this._panel.hidden = true;
BrowserUI.goToURI(item.uri)
}
},
handleEvent: function(aEvent) {
if (aEvent.keyCode == aEvent.DOM_VK_ESCAPE)
this.close();
}
};
var FolderHelper = {
_control: null,
_panel: null,
show: function(aControl) {
let container = document.getElementById("browser-container");
this._panel = document.getElementById("folder-container");
this._panel.hidden = false;
this._panel.width = container.boxObject.width;
this._panel.height = container.boxObject.height;
this._control = aControl;
let folders = document.getElementById("folder-items");
folders.openFolder();
},
close: function() {
this._panel.hidden = true;
},
selectFolder: function() {
let folders = document.getElementById("folder-items");
let folderId = PlacesUtils.bookmarks.getFolderIdForItem(this._control.activeItem.itemId);
if (folders.selectedItem.itemId != folderId) {
PlacesUtils.bookmarks.moveItem(this._control.activeItem.itemId, folders.selectedItem.itemId, PlacesUtils.bookmarks.DEFAULT_INDEX);
this._control.removeItem(this._control.activeItem);
}
this.close();
}
};

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

@ -43,6 +43,22 @@ notification button {
-moz-binding: url("chrome://browser/content/bindings.xml#popup_autocomplete");
}
editbookmark {
-moz-binding: url("chrome://browser/content/bindings.xml#editbookmark");
placeitem {
-moz-binding: url("chrome://browser/content/bindings.xml#place-item");
}
placeitem[type="folder"] {
-moz-binding: url("chrome://browser/content/bindings.xml#place-folder");
}
placelist {
-moz-binding: url("chrome://browser/content/bindings.xml#place-list");
}
placetree {
-moz-binding: url("chrome://browser/content/bindings.xml#place-tree");
}
placelabel {
-moz-binding: url("chrome://browser/content/bindings.xml#place-label");
}

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

@ -320,18 +320,6 @@
</deck>
</hbox>
<vbox id="urllist-container" hidden="true" style="-moz-stack-sizing: ignore;" top="0" left="0">
<vbox id="urllist-items-container" flex="1">
<richlistbox id="urllist-items" flex="1"
onkeypress="if (event.target == this &amp;&amp; event.keyCode == event.DOM_VK_RETURN)
BrowserUI.goToBookmark(this)"
onclose="BrowserUI.stopEditBookmark()"/>
</vbox>
<hbox pack="end">
<button class="close-button" oncommand="BrowserUI.closeBookmarks(event)"/>
</hbox>
</vbox>
<vbox id="popup_autocomplete" style="-moz-stack-sizing: ignore;" top="60" left="0" constraint="ignore-x,vp-relative">
<hbox id="autocomplete_navbuttons" align="center" flex="1"
oncommand="BrowserUI.doButtonSearch(event.target);">
@ -342,11 +330,33 @@
<vbox id="bookmark-container" hidden="true" style="-moz-stack-sizing: ignore;" top="60" left="0">
<hbox id="bookmark-form" align="start">
<image id="bookmark-image" src="chrome://browser/skin/images/starred48.png"/>
<editbookmark id="bookmark-edit" flex="1" onclose="BookmarkHelper.close()"
onchange="this.save()"/>
<placeitem id="bookmark-edit" type="bookmark" flex="1"
onclose="BookmarkHelper.close()"
onchange="this.save()"/>
</hbox>
</vbox>
<vbox id="bookmarklist-container" hidden="true" style="-moz-stack-sizing: ignore;" top="0" left="0">
<hbox id="bookmarklist-header" style="height: 60px">
<description flex="1">&bookmarksHeader.label;</description>
<toolbarbutton id="tool-bookmarks-manage" class="text-button" label="&bookmarksManage.label;"
oncommand="BookmarkList.toggleManage();"/>
<toolbarbutton id="tool-bookmarks-close" class="urlbar-button"
oncommand="BookmarkList.close();"/>
</hbox>
<placelist id="bookmark-items" type="bookmarks" flex="1" onfolder="FolderHelper.show(this);"
onopen="BookmarkList.openBookmark();"/>
</vbox>
<vbox id="folder-container" hidden="true" style="-moz-stack-sizing: ignore;" top="0" left="0">
<hbox id="folder-header" style="height: 60px">
<description flex="1">&foldersHeader.label;</description>
<toolbarbutton id="tool-folders-close" class="urlbar-button"
oncommand="FolderHelper.close()"/>
</hbox>
<placetree id="folder-items" type="bookmarks" mode="folders" flex="1" onopen="FolderHelper.selectFolder();"/>
</vbox>
</stack>
</box>

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

@ -32,11 +32,14 @@
<!ENTITY noSuggestions.label "(No suggestions)">
<!ENTITY addToDictionary.label "Add to Dictionary">
<!ENTITY editBookmarkName.label "Name:">
<!ENTITY editBookmarkURI.label "Address:">
<!ENTITY editBookmarkTags.label "Tags:">
<!ENTITY bookmarkRemove.label "Remove Bookmark">
<!ENTITY bookmarksHeader.label "Bookmarks">
<!ENTITY bookmarksManage.label "Manage">
<!ENTITY foldersHeader.label "Folders">
<!ENTITY editBookmarkEdit.label "Edit">
<!ENTITY editBookmarkMove.label "Move">
<!ENTITY editBookmarkDone.label "Done">
<!ENTITY editBookmarkTags.label "Add tags here">
<!ENTITY findOnCmd.label "Find in This Page…">
<!ENTITY findOnCmd.accesskey "F">

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

@ -1,3 +1,7 @@
# Bookmarks
editBookmarkAddFolder=Add a new folder
editBookmarkNewFolder=New folder
# Popup Blocker
popupWarning=%S prevented this site from opening a pop-up window.
popupWarningMultiple=%S prevented this site from opening %S pop-up windows.

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

@ -334,9 +334,103 @@ toolbarbutton.panel-button {
}
/* URL List and autocomplete navigation popup ------------------------------ */
#urllist-container {
#tool-bookmarks-close {
-moz-image-region: rect(48px 48px 96px 0px);
}
#tool-bookmarks-close:hover:active {
-moz-image-region: rect(0px 48px 48px 0px);
}
#tool-bookmarks-manage {
color: rgb(255,255,255);
border: 3px groove gray !important;
height: 46px;
padding-top: 2px;
-moz-border-radius: 6px;
}
#tool-bookmarks-manage .toolbarbutton-text {
display: block !important;
}
#tool-folders-close {
-moz-image-region: rect(48px 48px 96px 0px);
}
#tool-folders-close:hover:active {
-moz-image-region: rect(0px 48px 48px 0px);
}
#bookmarklist-container {
background-color: rgb(123,125,123);
padding: 8px;
padding: 0px;
}
#bookmarklist-header, #folder-header {
color: rgb(255,255,255);
-moz-box-align: center;
background: url("chrome://browser/skin/images/toolbar_background.png") repeat-x;
padding: 0px 10px;
}
#bookmark-items, #folder-items {
-moz-appearance: none !important;
background-color: rgb(255,255,255);
padding: 0px;
}
.place-list-parents {
background-color: rgb(207,207,207);
padding: 4px;
}
.place-list-children {
-moz-appearance: none;
border: none !important;
padding: 0px;
}
.bookmark-folder, .bookmark-item {
padding: 5px 2px;
border-bottom: 1px solid rgb(207,207,207);
}
.bookmark-folder textbox[readonly="true"], .bookmark-item textbox[readonly="true"] {
-moz-appearance: none !important;
background-color: transparent;
padding: 0px 9px !important;
margin: 0px !important;
border: none !important;
}
placelabel.bookmark-folder {
border-bottom: 1px solid rgb(255,255,255);
}
.bookmark-item-image, .bookmark-folder-image {
width: 24px;
height: 24px;
}
/* hack to align with 1st grid/row */
.bookmark-item-image {
margin-top: 8px;
}
/* folders have a fixed image */
.bookmark-folder-image {
list-style-image: url("chrome://browser/skin/images/folder.png");
}
/* control the manage controls */
.bookmark-manage-controls, .bookmark-folder-new {
visibility: hidden;
}
placelist[ui="manage"] .bookmark-manage-controls,
placelist[ui="manage"] .bookmark-folder-new {
visibility: visible;
}
.close-button {
@ -347,16 +441,6 @@ toolbarbutton.panel-button {
list-style-image: url("chrome://browser/skin/images/close-small.png");
}
.urllist-item {
-moz-appearance: none !important;
margin: 8px;
}
.urllist-image {
width: 24px;
height: 24px;
}
#popup_autocomplete {
background: url(images/navigation_background.png) repeat-x;
-moz-appearance: none;
@ -378,21 +462,6 @@ toolbarbutton.panel-button {
font-size: 12pt !important;
}
/* old rules */
#urllist-items {
-moz-appearance: none !important;
background-color: rgb(207,207,207);
border: 2px solid #fff !important;
-moz-border-radius: 10px;
}
/* XXX new rules that don't work
#urllist-items {
-moz-appearance: none;
}
#urllist-items,
*/
#autocomplete_navbuttons {
-moz-border-image: url(images/navigation_search_caps.png) 0 23 0 23;
border-width: 0 23px;

Двоичные данные
mobile/themes/hildon/images/folder.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 411 B

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

@ -41,3 +41,4 @@ classic.jar:
images/navigation_search_caps.png (images/navigation_search_caps.png)
images/navigation_magnifier.gif (images/navigation_magnifier.gif)
images/page_buttons.png (images/page_buttons.png)
images/folder.png (images/folder.png)

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

@ -334,9 +334,103 @@ toolbarbutton.panel-button {
}
/* URL List and autocomplete navigation popup ------------------------------ */
#urllist-container {
#tool-bookmarks-close {
-moz-image-region: rect(48px 48px 96px 0px);
}
#tool-bookmarks-close:hover:active {
-moz-image-region: rect(0px 48px 48px 0px);
}
#tool-bookmarks-manage {
color: rgb(255,255,255);
border: 3px groove gray !important;
height: 46px;
padding-top: 2px;
-moz-border-radius: 6px;
}
#tool-bookmarks-manage .toolbarbutton-text {
display: block !important;
}
#tool-folders-close {
-moz-image-region: rect(48px 48px 96px 0px);
}
#tool-folders-close:hover:active {
-moz-image-region: rect(0px 48px 48px 0px);
}
#bookmarklist-container {
background-color: rgb(123,125,123);
padding: 8px;
padding: 0px;
}
#bookmarklist-header, #folder-header {
color: rgb(255,255,255);
-moz-box-align: center;
background: url("chrome://browser/skin/images/toolbar_background.png") repeat-x;
padding: 0px 10px;
}
#bookmark-items, #folder-items {
-moz-appearance: none !important;
background-color: rgb(255,255,255);
padding: 0px;
}
.place-list-parents {
background-color: rgb(207,207,207);
padding: 4px;
}
.place-list-children {
-moz-appearance: none;
border: none !important;
padding: 0px;
}
.bookmark-folder, .bookmark-item {
padding: 5px 2px;
border-bottom: 1px solid rgb(207,207,207);
}
.bookmark-folder textbox[readonly="true"], .bookmark-item textbox[readonly="true"] {
-moz-appearance: none !important;
background-color: transparent;
padding: 0px 9px !important;
margin: 0px !important;
border: none !important;
}
placelabel.bookmark-folder {
border-bottom: 1px solid rgb(255,255,255);
}
.bookmark-item-image, .bookmark-folder-image {
width: 24px;
height: 24px;
}
/* hack to align with 1st grid/row */
.bookmark-item-image {
margin-top: 8px;
}
/* folders have a fixed image */
.bookmark-folder-image {
list-style-image: url("chrome://browser/skin/images/folder.png");
}
/* control the manage controls */
.bookmark-manage-controls, .bookmark-folder-new {
visibility: hidden;
}
placelist[ui="manage"] .bookmark-manage-controls,
placelist[ui="manage"] .bookmark-folder-new {
visibility: visible;
}
.close-button {
@ -347,16 +441,6 @@ toolbarbutton.panel-button {
list-style-image: url("chrome://browser/skin/images/close-small.png");
}
.urllist-item {
-moz-appearance: none !important;
margin: 8px;
}
.urllist-image {
width: 24px;
height: 24px;
}
#popup_autocomplete {
background: url(images/navigation_background.png) repeat-x;
-moz-appearance: none;
@ -378,21 +462,6 @@ toolbarbutton.panel-button {
font-size: 12pt !important;
}
/* old rules */
#urllist-items {
-moz-appearance: none !important;
background-color: rgb(207,207,207);
border: 2px solid #fff !important;
-moz-border-radius: 10px;
}
/* XXX new rules that don't work
#urllist-items {
-moz-appearance: none;
}
#urllist-items,
*/
#autocomplete_navbuttons {
-moz-border-image: url(images/navigation_search_caps.png) 0 23 0 23;
border-width: 0 23px;

Двоичные данные
mobile/themes/wince/images/folder.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 411 B

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

@ -41,3 +41,4 @@ classic.jar:
images/navigation_search_caps.png (images/navigation_search_caps.png)
images/navigation_magnifier.gif (images/navigation_magnifier.gif)
images/page_buttons.png (images/page_buttons.png)
images/folder.png (images/folder.png)