зеркало из https://github.com/mozilla/pjs.git
Bug 403263 (along with 405776, 413977, 418813) - deleting a separator in menus deletes all items preceding it. r=mak77.
This commit is contained in:
Родитель
547763099f
Коммит
de0a24997d
|
@ -128,7 +128,8 @@ PlacesController.prototype = {
|
|||
case "placesCmd_open":
|
||||
case "placesCmd_open:window":
|
||||
case "placesCmd_open:tab":
|
||||
return this._view.selectedURINode;
|
||||
var selectedNode = this._view.selectedNode;
|
||||
return selectedNode && PlacesUtils.nodeIsURI(selectedNode);
|
||||
case "placesCmd_new:folder":
|
||||
case "placesCmd_new:livemark":
|
||||
return this._canInsert();
|
||||
|
@ -140,8 +141,8 @@ PlacesController.prototype = {
|
|||
this._view.getResult().sortingMode ==
|
||||
Ci.nsINavHistoryQueryOptions.SORT_BY_NONE;
|
||||
case "placesCmd_show:info":
|
||||
if (this._view.hasSingleSelection) {
|
||||
var selectedNode = this._view.selectedNode;
|
||||
var selectedNode = this._view.selectedNode;
|
||||
if (selectedNode) {
|
||||
if (PlacesUtils.nodeIsFolder(selectedNode) ||
|
||||
(PlacesUtils.nodeIsBookmark(selectedNode) &&
|
||||
!PlacesUtils.nodeIsLivemarkItem(selectedNode)))
|
||||
|
@ -149,24 +150,13 @@ PlacesController.prototype = {
|
|||
}
|
||||
return false;
|
||||
case "placesCmd_reloadMicrosummary":
|
||||
if (this._view.hasSingleSelection) {
|
||||
var selectedNode = this._view.selectedNode;
|
||||
if (PlacesUtils.nodeIsBookmark(selectedNode)) {
|
||||
var mss = PlacesUtils.microsummaries;
|
||||
if (mss.hasMicrosummary(selectedNode.itemId))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
var selectedNode = this._view.selectedNode;
|
||||
return selectedNode && PlacesUtils.nodeIsBookmark(selectedNode) &&
|
||||
PlacesUtils.microsummaries.hasMicrosummary(selectedNode.itemId);
|
||||
case "placesCmd_reload":
|
||||
if (this._view.hasSingleSelection) {
|
||||
var selectedNode = this._view.selectedNode;
|
||||
|
||||
// Livemark containers
|
||||
if (PlacesUtils.nodeIsLivemarkContainer(selectedNode))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
// Livemark containers
|
||||
var selectedNode = this._view.selectedNode;
|
||||
return selectedNode && PlacesUtils.nodeIsLivemarkContainer(selectedNode);
|
||||
case "placesCmd_sortBy:name":
|
||||
var selectedNode = this._view.selectedNode;
|
||||
return selectedNode &&
|
||||
|
@ -277,9 +267,6 @@ PlacesController.prototype = {
|
|||
* false otherwise.
|
||||
*/
|
||||
_hasRemovableSelection: function PC__hasRemovableSelection(aIsMoveCommand) {
|
||||
if (!this._view.hasSelection)
|
||||
return false;
|
||||
|
||||
var nodes = this._view.getSelectionNodes();
|
||||
var root = this._view.getResultNode();
|
||||
|
||||
|
@ -328,14 +315,13 @@ PlacesController.prototype = {
|
|||
* Determines whether or not the root node for the view is selected
|
||||
*/
|
||||
rootNodeIsSelected: function PC_rootNodeIsSelected() {
|
||||
if (this._view.hasSelection) {
|
||||
var nodes = this._view.getSelectionNodes();
|
||||
var root = this._view.getResultNode();
|
||||
for (var i = 0; i < nodes.length; ++i) {
|
||||
if (nodes[i] == root)
|
||||
return true;
|
||||
}
|
||||
var nodes = this._view.getSelectionNodes();
|
||||
var root = this._view.getResultNode();
|
||||
for (var i = 0; i < nodes.length; ++i) {
|
||||
if (nodes[i] == root)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
|
@ -411,12 +397,10 @@ PlacesController.prototype = {
|
|||
*/
|
||||
_buildSelectionMetadata: function PC__buildSelectionMetadata() {
|
||||
var metadata = [];
|
||||
var nodes = [];
|
||||
var root = this._view.getResult().root;
|
||||
if (this._view.hasSelection)
|
||||
nodes = this._view.getSelectionNodes();
|
||||
else // See the second note above
|
||||
nodes = [root];
|
||||
var nodes = this._view.getSelectionNodes();
|
||||
if (nodes.length == 0)
|
||||
nodes.push(root); // See the second note above
|
||||
|
||||
for (var i=0; i < nodes.length; i++) {
|
||||
var nodeData = {};
|
||||
|
@ -646,8 +630,9 @@ PlacesController.prototype = {
|
|||
* see also openUILinkIn
|
||||
*/
|
||||
openSelectedNodeIn: function PC_openSelectedNodeIn(aWhere) {
|
||||
var node = this._view.selectedURINode;
|
||||
if (node && PlacesUtils.checkURLSecurity(node)) {
|
||||
var node = this._view.selectedNode;
|
||||
if (node && PlacesUtils.nodeIsURI(node) &&
|
||||
PlacesUtils.checkURLSecurity(node)) {
|
||||
var isBookmark = PlacesUtils.nodeIsBookmark(node);
|
||||
|
||||
if (isBookmark)
|
||||
|
@ -699,11 +684,9 @@ PlacesController.prototype = {
|
|||
* Reloads the selected livemark if any.
|
||||
*/
|
||||
reloadSelectedLivemark: function PC_reloadSelectedLivemark() {
|
||||
if (this._view.hasSingleSelection) {
|
||||
var selectedNode = this._view.selectedNode;
|
||||
if (PlacesUtils.nodeIsLivemarkContainer(selectedNode))
|
||||
PlacesUtils.livemarks.reloadLivemarkFolder(selectedNode.itemId);
|
||||
}
|
||||
var selectedNode = this._view.selectedNode;
|
||||
if (selectedNode && PlacesUtils.nodeIsLivemarkContainer(selectedNode))
|
||||
PlacesUtils.livemarks.reloadLivemarkFolder(selectedNode.itemId);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -768,7 +751,7 @@ PlacesController.prototype = {
|
|||
*/
|
||||
openSelectionInTabs: function PC_openLinksInTabs(aEvent) {
|
||||
var node = this._view.selectedNode;
|
||||
if (this._view.hasSingleSelection && PlacesUtils.nodeIsContainer(node))
|
||||
if (node && PlacesUtils.nodeIsContainer(node))
|
||||
PlacesUtils.openContainerNodeInTabs(this._view.selectedNode, aEvent);
|
||||
else
|
||||
PlacesUtils.openURINodesInTabs(this._view.getSelectionNodes(), aEvent);
|
||||
|
@ -1036,11 +1019,14 @@ PlacesController.prototype = {
|
|||
var oldViewer = result.viewer;
|
||||
try {
|
||||
result.viewer = null;
|
||||
var nodes = null;
|
||||
if (dragAction == Ci.nsIDragService.DRAGDROP_ACTION_COPY)
|
||||
nodes = this._view.getCopyableSelection();
|
||||
else
|
||||
nodes = this._view.getDragableSelection();
|
||||
var nodes = this._view.getDragableSelection();
|
||||
if (dragAction == Ci.nsIDragService.DRAGDROP_ACTION_MOVE) {
|
||||
nodes = nodes.filter(function(node) {
|
||||
var parent = node.parent;
|
||||
return parent && !PlacesUtils.nodeIsReadOnly(parent);
|
||||
});
|
||||
}
|
||||
|
||||
var dataSet = new TransferDataSet();
|
||||
for (var i = 0; i < nodes.length; ++i) {
|
||||
var node = nodes[i];
|
||||
|
@ -1086,14 +1072,14 @@ PlacesController.prototype = {
|
|||
var oldViewer = result.viewer;
|
||||
try {
|
||||
result.viewer = null;
|
||||
var nodes = this._view.getCopyableSelection();
|
||||
var nodes = this._view.getSelectionNodes();
|
||||
|
||||
var xferable = Cc["@mozilla.org/widget/transferable;1"].
|
||||
createInstance(Ci.nsITransferable);
|
||||
var foundFolder = false, foundLink = false;
|
||||
var copiedFolders = [];
|
||||
var placeString = mozURLString = htmlString = unicodeString = "";
|
||||
|
||||
|
||||
for (var i = 0; i < nodes.length; ++i) {
|
||||
var node = nodes[i];
|
||||
if (this._shouldSkipNode(node, copiedFolders))
|
||||
|
@ -1114,7 +1100,7 @@ PlacesController.prototype = {
|
|||
uri) + suffix);
|
||||
htmlString += (PlacesUtils.wrapNode(node, PlacesUtils.TYPE_HTML,
|
||||
uri) + suffix);
|
||||
|
||||
|
||||
var placeSuffix = i < (nodes.length - 1) ? "," : "";
|
||||
return PlacesUtils.wrapNode(node, type, overrideURI) + placeSuffix;
|
||||
}
|
||||
|
|
|
@ -102,11 +102,9 @@ function historyAddBookmarks()
|
|||
// no need to check gHistoryTree.view.selection.count
|
||||
// node will be null if there is a multiple selection
|
||||
// or if the selected item is not a URI node
|
||||
var node = gHistoryTree.selectedURINode;
|
||||
if (!node)
|
||||
return;
|
||||
|
||||
PlacesUtils.showMinimalAddBookmarkUI(PlacesUtils._uri(node.uri), node.title);
|
||||
var node = gHistoryTree.selectedNode;
|
||||
if (node && PlacesUtils.nodeIsURI(node))
|
||||
PlacesUtils.showMinimalAddBookmarkUI(PlacesUtils._uri(node.uri), node.title);
|
||||
}
|
||||
|
||||
function searchHistory(aInput)
|
||||
|
|
|
@ -187,11 +187,12 @@
|
|||
<parameter name="aXferData"/>
|
||||
<parameter name="aDragAction"/>
|
||||
<body><![CDATA[
|
||||
this._rootView._selection = aEvent.target.node;
|
||||
this._rootView._cachedInsertionPoint = undefined;
|
||||
|
||||
if (aEvent.ctrlKey)
|
||||
aDragAction.action = Ci.nsIDragService.DRAGDROP_ACTION_COPY;
|
||||
|
||||
// activate the view and cache the dragged node
|
||||
this._rootView._draggedNode = aEvent.target.node;
|
||||
this._rootView.focus();
|
||||
aXferData.data = this._rootView.controller
|
||||
.getTransferData(aDragAction.action);
|
||||
]]></body>
|
||||
|
@ -506,8 +507,6 @@
|
|||
]]></body>
|
||||
</method>
|
||||
|
||||
<field name="_selection">null</field>
|
||||
|
||||
<!-- nsIPlacesView -->
|
||||
<method name="getResult">
|
||||
<body><![CDATA[
|
||||
|
@ -587,6 +586,11 @@
|
|||
}
|
||||
}
|
||||
|
||||
// if document.popupNode pointed to this child, null it out,
|
||||
// otherwise controller's command-updating may rely on the removed
|
||||
// item still being "selected".
|
||||
if (document.popupNode == child)
|
||||
document.popupNode = null;
|
||||
child.parentNode.removeChild(child);
|
||||
]]></body>
|
||||
</method>
|
||||
|
@ -871,21 +875,15 @@
|
|||
<!-- nsIPlacesView -->
|
||||
<property name="hasSelection">
|
||||
<getter><![CDATA[
|
||||
return this._selection != null;
|
||||
]]></getter>
|
||||
</property>
|
||||
|
||||
<!-- nsIPlacesView -->
|
||||
<property name="hasSingleSelection">
|
||||
<getter><![CDATA[
|
||||
return this.hasSelection;
|
||||
return this.selectedNode != null;
|
||||
]]></getter>
|
||||
</property>
|
||||
|
||||
<!-- nsIPlacesView -->
|
||||
<method name="getSelectionNodes">
|
||||
<body><![CDATA[
|
||||
return this.hasSelection ? [this.selectedNode] : [];
|
||||
var selectedNode = this.selectedNode;
|
||||
return selectedNode ? [selectedNode] : [];
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
|
@ -896,77 +894,58 @@
|
|||
]]></body>
|
||||
</method>
|
||||
|
||||
<!-- nsIPlacesView -->
|
||||
<method name="getCopyableSelection">
|
||||
<body><![CDATA[
|
||||
return this.getSelectionNodes();
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<!-- nsIPlacesView -->
|
||||
<method name="getDragableSelection">
|
||||
<body><![CDATA[
|
||||
if (PlacesUtils.nodeIsReadOnly(this._resultNode))
|
||||
return null;
|
||||
return this.getSelectionNodes();
|
||||
return [this._draggedNode];
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<!-- nsIPlacesView -->
|
||||
<property name="selectedNode">
|
||||
<getter><![CDATA[
|
||||
return this.hasSelection ? this._selection : null;
|
||||
]]></getter>
|
||||
</property>
|
||||
|
||||
<!-- nsIPlacesView -->
|
||||
<property name="selectedURINode">
|
||||
<getter><![CDATA[
|
||||
var node = this.selectedNode;
|
||||
return node && PlacesUtils.nodeIsURI(node) ? node : null;
|
||||
if (this._contextMenuShown) {
|
||||
var popupNode = document.popupNode;
|
||||
return popupNode.node || popupNode.parentNode._resultNode || null;
|
||||
}
|
||||
return null;
|
||||
]]></getter>
|
||||
</property>
|
||||
|
||||
<!-- nsIPlacesView -->
|
||||
<property name="insertionPoint">
|
||||
<getter><![CDATA[
|
||||
if (this._cachedInsertionPoint !== undefined)
|
||||
return this._cachedInsertionPoint;
|
||||
|
||||
// By default, the insertion point is at the top level, at the end.
|
||||
var index = -1;
|
||||
var folderId = 0;
|
||||
if (PlacesUtils.nodeIsFolder(this._resultNode))
|
||||
folderId = PlacesUtils.getConcreteItemId(this._resultNode);
|
||||
|
||||
if (this.hasSelection) {
|
||||
if (PlacesUtils.nodeIsFolder(this.selectedNode)) {
|
||||
var selectedNode = this.selectedNode;
|
||||
if (selectedNode) {
|
||||
if (PlacesUtils.nodeIsFolder(selectedNode)) {
|
||||
// If there is a folder selected, the insertion point is the
|
||||
// end of the folder.
|
||||
folderId = PlacesUtils.getConcreteItemId(this.selectedNode);
|
||||
} else {
|
||||
folderId = PlacesUtils.getConcreteItemId(selectedNode);
|
||||
}
|
||||
else {
|
||||
// If there is another type of node selected, the insertion point
|
||||
// is after that node.
|
||||
folderId = PlacesUtils.getConcreteItemId(this.selectedNode.parent);
|
||||
index = PlacesUtils.getIndexOfNode(this.selectedNode)
|
||||
folderId = PlacesUtils.getConcreteItemId(selectedNode.parent);
|
||||
index = PlacesUtils.getIndexOfNode(selectedNode)
|
||||
}
|
||||
}
|
||||
this._cachedInsertionPoint = new InsertionPoint(folderId, index);
|
||||
return this._cachedInsertionPoint;
|
||||
return new InsertionPoint(folderId, index);
|
||||
]]></getter>
|
||||
</property>
|
||||
|
||||
<!-- nsIPlacesView -->
|
||||
<method name="selectAll">
|
||||
<body><![CDATA[
|
||||
// Nothing
|
||||
]]></body>
|
||||
<body/>
|
||||
</method>
|
||||
|
||||
<method name="selectItems">
|
||||
<body><![CDATA[
|
||||
// Nothing
|
||||
]]></body>
|
||||
<body/>
|
||||
</method>
|
||||
|
||||
<property name="selType" readonly="true" onget="return 'single';"/>
|
||||
|
@ -975,6 +954,7 @@
|
|||
<parameter name="aPopup"/>
|
||||
<body><![CDATA[
|
||||
this._ensureInitialized();
|
||||
this._contextMenuShown = true;
|
||||
this.focus();
|
||||
return this.controller.buildContextMenu(aPopup);
|
||||
]]></body>
|
||||
|
@ -984,6 +964,7 @@
|
|||
<parameter name="aPopup"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
this._contextMenuShown = false;
|
||||
if (window.content)
|
||||
window.content.focus();
|
||||
]]>
|
||||
|
@ -1012,28 +993,6 @@
|
|||
// when the folder closes because it is no longer applicable.
|
||||
popup.removeAttribute("autoopened");
|
||||
]]></handler>
|
||||
|
||||
<!-- Set selected node on DOMMenuItemActive/contextmenu events
|
||||
so that they're set up when command and click events fire. -->
|
||||
<handler event="DOMMenuItemActive"><![CDATA[
|
||||
// Set the selection to the node that was activated. If that
|
||||
// node has a command but no data associated with it, it should
|
||||
// act on the entire menu.
|
||||
if (event.target.parentNode._resultNode) {
|
||||
this._cachedInsertionPoint = undefined;
|
||||
this._selection = event.target.node ||
|
||||
event.target.parentNode._resultNode;
|
||||
}
|
||||
]]></handler>
|
||||
<handler event="contextmenu"><![CDATA[
|
||||
// DOMMenuItemActive is not dispatched for disabled menuitems and
|
||||
// menuseparators. Set the selection here manually.
|
||||
var popupNode = document.popupNode;
|
||||
// |popupNode == menupopup| happens when the area between
|
||||
// menuseparators is clicked.
|
||||
this._selection = popupNode.node || popupNode.parentNode._resultNode;
|
||||
this._cachedInsertionPoint = undefined;
|
||||
]]></handler>
|
||||
</handlers>
|
||||
</binding>
|
||||
|
||||
|
|
|
@ -238,10 +238,11 @@ var PlacesOrganizer = {
|
|||
if (aEvent.target.localName != "treechildren")
|
||||
return;
|
||||
|
||||
if (currentView.hasSingleSelection && aEvent.button == 1) {
|
||||
var selectedNode = currentView.selectedNode;
|
||||
if (selectedNode && aEvent.button == 1) {
|
||||
if (PlacesUtils.nodeIsURI(currentView.selectedNode))
|
||||
controller.openSelectedNodeWithEvent(aEvent);
|
||||
else if (PlacesUtils.nodeIsContainer(currentView.selectedNode)) {
|
||||
else if (PlacesUtils.nodeIsContainer(selectedNode)) {
|
||||
// The command execution function will take care of seeing the
|
||||
// selection is a folder/container and loading its contents in
|
||||
// tabs for us.
|
||||
|
@ -525,23 +526,21 @@ var PlacesOrganizer = {
|
|||
|
||||
var contentTree = document.getElementById("placeContent");
|
||||
var detailsDeck = document.getElementById("detailsDeck");
|
||||
if (contentTree.hasSelection) {
|
||||
detailsDeck.selectedIndex = 1;
|
||||
if (contentTree.hasSingleSelection) {
|
||||
var selectedNode = contentTree.selectedNode;
|
||||
if (selectedNode.itemId != -1 &&
|
||||
!PlacesUtils.nodeIsSeparator(selectedNode)) {
|
||||
if (this._paneDisabled) {
|
||||
this._setDetailsFieldsDisabledState(false);
|
||||
this._paneDisabled = false;
|
||||
}
|
||||
|
||||
gEditItemOverlay.initPanel(selectedNode.itemId,
|
||||
{ hiddenRows: ["folderPicker"] });
|
||||
|
||||
this._detectAndSetDetailsPaneMinimalState(selectedNode);
|
||||
return;
|
||||
detailsDeck.selectedIndex = 1;
|
||||
var selectedNode = contentTree.selectedNode;
|
||||
if (selectedNode) {
|
||||
if (selectedNode.itemId != -1 &&
|
||||
!PlacesUtils.nodeIsSeparator(selectedNode)) {
|
||||
if (this._paneDisabled) {
|
||||
this._setDetailsFieldsDisabledState(false);
|
||||
this._paneDisabled = false;
|
||||
}
|
||||
|
||||
gEditItemOverlay.initPanel(selectedNode.itemId,
|
||||
{ hiddenRows: ["folderPicker"] });
|
||||
|
||||
this._detectAndSetDetailsPaneMinimalState(selectedNode);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -122,8 +122,6 @@
|
|||
<field name="_dropIndicatorBar">document.getAnonymousElementByAttribute(this, "class", "toolbar-drop-indicator-bar")</field>
|
||||
<field name="_chevron">document.getAnonymousElementByAttribute(this, "class", "chevron")</field>
|
||||
|
||||
<field name="_selection">null</field>
|
||||
|
||||
<field name="_openedMenuButton">null</field>
|
||||
|
||||
<field name="_result">null</field>
|
||||
|
@ -232,6 +230,11 @@
|
|||
}
|
||||
}
|
||||
|
||||
// if document.popupNode pointed to this child, null it out,
|
||||
// otherwise controller's command-updating may rely on the removed
|
||||
// item still being "selected".
|
||||
if (document.popupNode == child)
|
||||
document.popupNode = null;
|
||||
child.parentNode.removeChild(child);
|
||||
]]></body>
|
||||
</method>
|
||||
|
@ -331,85 +334,65 @@
|
|||
<!-- nsIPlacesView -->
|
||||
<property name="hasSelection">
|
||||
<getter><![CDATA[
|
||||
return this._selection != null;
|
||||
]]></getter>
|
||||
</property>
|
||||
|
||||
<!-- nsIPlacesView -->
|
||||
<property name="hasSingleSelection">
|
||||
<getter><![CDATA[
|
||||
return this.hasSelection;
|
||||
return this.selectedNode != null;
|
||||
]]></getter>
|
||||
</property>
|
||||
|
||||
<!-- nsIPlacesView -->
|
||||
<method name="getSelectionNodes">
|
||||
<body><![CDATA[
|
||||
return this.hasSelection ? [this.selectedNode] : [];
|
||||
var selectedNode = this.selectedNode;
|
||||
return selectedNode ? [selectedNode] : [];
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<!-- nsIPlacesView -->
|
||||
<method name="getRemovableSelectionRanges">
|
||||
<body><![CDATA[
|
||||
<body><![CDATA[
|
||||
return [this.getSelectionNodes()];
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<!-- nsIPlacesView -->
|
||||
<method name="getCopyableSelection">
|
||||
<body><![CDATA[
|
||||
return this.getSelectionNodes();
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<!-- nsIPlacesView -->
|
||||
<method name="getDragableSelection">
|
||||
<body><![CDATA[
|
||||
if (PlacesUtils.nodeIsReadOnly(this._result.root))
|
||||
return null;
|
||||
return this.getSelectionNodes();
|
||||
return [this._draggedNode];
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<!-- nsIPlacesView -->
|
||||
<property name="selectedNode">
|
||||
<getter><![CDATA[
|
||||
return this.hasSelection ? this._selection : null;
|
||||
]]></getter>
|
||||
</property>
|
||||
|
||||
<!-- nsIPlacesView -->
|
||||
<property name="selectedURINode">
|
||||
<getter><![CDATA[
|
||||
var node = this.selectedNode;
|
||||
return node && PlacesUtils.nodeIsURI(node) ? node : null;
|
||||
if (this._contextMenuShown) {
|
||||
var popupNode = document.popupNode;
|
||||
return popupNode.node || popupNode.parentNode._resultNode || null;
|
||||
}
|
||||
return null;
|
||||
]]></getter>
|
||||
</property>
|
||||
|
||||
<!-- nsIPlacesView -->
|
||||
<property name="insertionPoint">
|
||||
<getter><![CDATA[
|
||||
if (this._cachedInsertionPoint !== undefined)
|
||||
return this._cachedInsertionPoint;
|
||||
|
||||
// By default, the insertion point is at the top level, at the end.
|
||||
var index = -1;
|
||||
var folderId = PlacesUtils.getConcreteItemId(this._result.root);
|
||||
|
||||
if (this.hasSelection) {
|
||||
if (PlacesUtils.nodeIsFolder(this.selectedNode)) {
|
||||
var selectedNode = this.selectedNode;
|
||||
if (selectedNode) {
|
||||
if (PlacesUtils.nodeIsFolder(selectedNode)) {
|
||||
// If there is a folder selected, the insertion point is the
|
||||
// end of the folder.
|
||||
folderId = PlacesUtils.getConcreteItemId(this.selectedNode);
|
||||
} else {
|
||||
folderId = PlacesUtils.getConcreteItemId(selectedNode);
|
||||
}
|
||||
else {
|
||||
// If there is another type of node selected, the insertion point
|
||||
// is after that node.
|
||||
index = PlacesUtils.getIndexOfNode(this.selectedNode);
|
||||
folderId = PlacesUtils.getConcreteItemId(selectedNode.parent);
|
||||
index = PlacesUtils.getIndexOfNode(selectedNode);
|
||||
}
|
||||
}
|
||||
this._cachedInsertionPoint = new InsertionPoint(folderId, index, 1);
|
||||
return this._cachedInsertionPoint;
|
||||
return new InsertionPoint(folderId, index, 1);
|
||||
]]></getter>
|
||||
</property>
|
||||
|
||||
|
@ -704,7 +687,7 @@
|
|||
this._overFolder.node.open = true;
|
||||
this._overFolder.openTimer = null;
|
||||
}
|
||||
|
||||
|
||||
// Timer to close a menubutton that's been dragged off of.
|
||||
if (timer == this._overFolder.closeTimer) {
|
||||
// Only close the menubutton if the drag session isn't currently over
|
||||
|
@ -728,7 +711,7 @@
|
|||
this._clearOverFolder();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// The mouse is no longer dragging over the stored menubutton.
|
||||
// Close the menubutton, clear out drag styles, and clear all
|
||||
// timers for opening/closing it.
|
||||
|
@ -749,7 +732,7 @@
|
|||
this._overFolder.closeTimer = null;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// This function returns information about where to drop when
|
||||
// dragging over this menu--insertion point, child index to drop
|
||||
// before, and folder to drop into.
|
||||
|
@ -758,7 +741,7 @@
|
|||
var result = this._self.getResult();
|
||||
if (!PlacesUtils.nodeIsFolder(result.root))
|
||||
return null;
|
||||
|
||||
|
||||
var dropPoint = { ip: null, beforeIndex: null, folderNode: null };
|
||||
// Loop through all the nodes to see which one this should
|
||||
// get dropped in/next to
|
||||
|
@ -787,7 +770,8 @@
|
|||
dropPoint.folderNode = xulNode;
|
||||
return dropPoint;
|
||||
}
|
||||
} else{
|
||||
}
|
||||
else {
|
||||
// This is a non-folder node. If the mouse is left of the middle,
|
||||
// drop to the left of the folder. If it's right, drop to the right.
|
||||
if (event.clientX < xulNode.boxObject.x + (xulNode.boxObject.width / 2)) {
|
||||
|
@ -809,6 +793,10 @@
|
|||
},
|
||||
|
||||
onDragStart: function TBV_DO_onDragStart(event, xferData, dragAction) {
|
||||
// sub menus have their own d&d handlers
|
||||
if (event.target.parentNode != this._self)
|
||||
return false;
|
||||
|
||||
if (event.target.localName == "toolbarbutton" &&
|
||||
event.target.getAttribute("type") == "menu") {
|
||||
#ifdef XP_WIN
|
||||
|
@ -823,19 +811,22 @@
|
|||
#endif
|
||||
}
|
||||
|
||||
if (event.ctrlKey) {
|
||||
if (event.ctrlKey)
|
||||
dragAction.action = Ci.nsIDragService.DRAGDROP_ACTION_COPY;
|
||||
}
|
||||
|
||||
// activate the view and cache the dragged node
|
||||
this._self._draggedNode = event.target.node;
|
||||
this._self.focus();
|
||||
xferData.data = this._self._controller.getTransferData(dragAction.action);
|
||||
#ifdef XP_WIN
|
||||
return true;
|
||||
#endif
|
||||
},
|
||||
|
||||
|
||||
canDrop: function TBV_DO_canDrop(event, session) {
|
||||
return PlacesControllerDragHelper.canDrop();
|
||||
},
|
||||
|
||||
|
||||
onDragOver: function TBV_DO_onDragOver(event, flavor, session) {
|
||||
PlacesControllerDragHelper.currentDropTarget = event.target;
|
||||
var dropPoint = this._getDropPoint(event);
|
||||
|
@ -874,7 +865,8 @@
|
|||
else
|
||||
ind.style.marginLeft = this._self.childNodes[dropPoint.beforeIndex].boxObject.x -
|
||||
this._self.boxObject.x - halfInd + 'px';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
halfInd = Math.floor(halfInd);
|
||||
if (dropPoint.beforeIndex == -1 || !this._self.childNodes.length)
|
||||
ind.style.marginRight = '0px';
|
||||
|
@ -946,6 +938,7 @@
|
|||
<method name="buildContextMenu">
|
||||
<parameter name="aPopup"/>
|
||||
<body><![CDATA[
|
||||
this._contextMenuShown = true;
|
||||
this.focus();
|
||||
return this.controller.buildContextMenu(aPopup);
|
||||
]]></body>
|
||||
|
@ -954,6 +947,7 @@
|
|||
<method name="destroyContextMenu">
|
||||
<parameter name="aPopup"/>
|
||||
<body><![CDATA[
|
||||
this._contextMenuShown = false;
|
||||
if (window.content)
|
||||
window.content.focus();
|
||||
]]></body>
|
||||
|
@ -1052,22 +1046,6 @@
|
|||
<handler event="mouseout"><![CDATA[
|
||||
window.XULBrowserWindow.setOverLink("", null);
|
||||
]]></handler>
|
||||
<handler event="mousedown"><![CDATA[
|
||||
// When the user clicks down on a button, set it as the selection and
|
||||
// tell the controller that we are the active view.
|
||||
//
|
||||
var target = event.target;
|
||||
if (target == this)
|
||||
this._selection = this.getResult().root;
|
||||
else if (target.parentNode == this &&
|
||||
(target.localName == "toolbarbutton" ||
|
||||
target.localName == "toolbarseparator"))
|
||||
this._selection = target.node;
|
||||
else // Sub-menus are handled by the DOMMenuItemActive handler
|
||||
return;
|
||||
|
||||
this._cachedInsertionPoint = undefined;
|
||||
]]></handler>
|
||||
<handler event="draggesture"><![CDATA[
|
||||
if (event.target.localName == "toolbarbutton" ||
|
||||
event.target.localName == "toolbarseparator")
|
||||
|
@ -1120,35 +1098,6 @@
|
|||
this._openedMenuButton = null;
|
||||
]]></handler>
|
||||
|
||||
<!-- Set selected node on DOMMenuItemActive/contextmenu events
|
||||
so that they're set up when command and click events fire. -->
|
||||
<handler event="DOMMenuItemActive"><![CDATA[
|
||||
// Set the selection to the node that was activated. If that
|
||||
// node has a command but no data associated with it, it should
|
||||
// act on the entire menu.
|
||||
if (event.target.parentNode._resultNode) {
|
||||
// the chevron has its own view
|
||||
if (this._isChevronChild(event.target))
|
||||
return;
|
||||
|
||||
this._cachedInsertionPoint = undefined;
|
||||
this._selection = event.target.node ||
|
||||
event.target.parentNode._resultNode;
|
||||
}
|
||||
]]></handler>
|
||||
<handler event="contextmenu"><![CDATA[
|
||||
// DOMMenuItemActive is not dispatched for disabled menuitems and
|
||||
// menuseparators. Set the selection here manually.
|
||||
var popupNode = document.popupNode;
|
||||
// the chevron has its own view
|
||||
if (this._isChevronChild(popupNode))
|
||||
return;
|
||||
|
||||
// |popupNode == menupopup| happens when the area between menuseparators
|
||||
// is clicked.
|
||||
this._selection = popupNode.node || popupNode.parentNode._resultNode;
|
||||
this._cachedInsertionPoint = undefined;
|
||||
]]></handler>
|
||||
<handler event="mousemove"><![CDATA[
|
||||
if (this._openedMenuButton == null || PlacesControllerDragHelper.getSession())
|
||||
return;
|
||||
|
|
|
@ -340,13 +340,6 @@
|
|||
return this.view.selection.count >= 1;
|
||||
]]></getter>
|
||||
</property>
|
||||
|
||||
<!-- nsIPlacesView -->
|
||||
<property name="hasSingleSelection">
|
||||
<getter><![CDATA[
|
||||
return this.view.selection.count == 1;
|
||||
]]></getter>
|
||||
</property>
|
||||
|
||||
<!-- nsIPlacesView -->
|
||||
<method name="getSelectionNodes">
|
||||
|
@ -418,23 +411,10 @@
|
|||
]]></body>
|
||||
</method>
|
||||
|
||||
<!-- nsIPlacesView -->
|
||||
<method name="getCopyableSelection">
|
||||
<body><![CDATA[
|
||||
// XXXben implement me!
|
||||
return this.getSelectionNodes();
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<!-- nsIPlacesView -->
|
||||
<method name="getDragableSelection">
|
||||
<body><![CDATA[
|
||||
var nodes = this.getSelectionNodes();
|
||||
for (var i = nodes.length - 1; i >= 0; i--) {
|
||||
if (PlacesUtils.nodeIsReadOnly(nodes[i].parent))
|
||||
nodes.splice(i, 1);
|
||||
}
|
||||
return nodes;
|
||||
return this.getSelectionNodes();
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
|
@ -442,36 +422,16 @@
|
|||
<property name="selectedNode">
|
||||
<getter><![CDATA[
|
||||
var view = this.view;
|
||||
var selection = view.selection;
|
||||
var rc = selection.getRangeCount();
|
||||
if (rc != 1)
|
||||
if (view.selection.count != 1)
|
||||
return null;
|
||||
|
||||
var selection = view.selection;
|
||||
var min = { }, max = { };
|
||||
selection.getRangeAt(0, min, max);
|
||||
|
||||
return this.getResultView().nodeForTreeIndex(min.value);
|
||||
]]></getter>
|
||||
</property>
|
||||
|
||||
<!-- nsIPlacesView -->
|
||||
<property name="selectedURINode">
|
||||
<getter><![CDATA[
|
||||
var view = this.view;
|
||||
var selection = view.selection;
|
||||
var rc = selection.getRangeCount();
|
||||
if (rc != 1)
|
||||
return null;
|
||||
var min = { }, max = { };
|
||||
selection.getRangeAt(0, min, max);
|
||||
|
||||
// only URI nodes should be returned
|
||||
var node = this.getResultView().nodeForTreeIndex(min.value);
|
||||
if (PlacesUtils.nodeIsURI(node))
|
||||
return node;
|
||||
return null;
|
||||
]]></getter>
|
||||
</property>
|
||||
|
||||
|
||||
<!-- nsIPlacesView -->
|
||||
<property name="insertionPoint">
|
||||
|
@ -526,7 +486,7 @@
|
|||
// into it even if it is not opened
|
||||
var itemId =
|
||||
PlacesUtils.getConcreteItemId(resultView.nodeForTreeIndex(max.value));
|
||||
if (this.hasSingleSelection && resultView.isContainer(max.value) &&
|
||||
if (selection.count == 1 && resultView.isContainer(max.value) &&
|
||||
(resultView.isContainerOpen(max.value) ||
|
||||
itemId == PlacesUtils.bookmarksMenuFolderId))
|
||||
orientation = Ci.nsITreeView.DROP_ON;
|
||||
|
|
|
@ -69,8 +69,8 @@ var SelectBookmarkDialog = {
|
|||
|
||||
onItemDblClick: function SBD_onItemDblClick() {
|
||||
var bookmarks = document.getElementById("bookmarks");
|
||||
if (bookmarks.hasSingleSelection &&
|
||||
PlacesUtils.nodeIsURI(bookmarks.selectedNode)) {
|
||||
var selectedNode = bookmarks.selectedNode;
|
||||
if (selectedNode && PlacesUtils.nodeIsURI(selectedNode)) {
|
||||
/**
|
||||
* The user has double clicked on a tree row that is a link. Take this to
|
||||
* mean that they want that link to be their homepage, and close the dialog.
|
||||
|
|
Загрузка…
Ссылка в новой задаче