315940 allow links and places to be dropped onto the toolbar. NPOB.

This commit is contained in:
beng%bengoodger.com 2005-11-28 07:30:30 +00:00
parent c572c9bc03
commit 80680498d2
3 changed files with 53 additions and 5 deletions

View File

@ -51,10 +51,15 @@ const SELECTION_IS_CHANGEABLE = 0x10;
const SELECTION_IS_REMOVABLE = 0x20;
const SELECTION_IS_MOVABLE = 0x40;
// Place entries that are containers, e.g. bookmark folders or queries.
const TYPE_X_MOZ_PLACE_CONTAINER = "text/x-moz-place-container";
// Place entries that are not containers
const TYPE_X_MOZ_PLACE = "text/x-moz-place";
// Place entries in shortcut url format (url\ntitle)
const TYPE_X_MOZ_URL = "text/x-moz-url";
// Place entries formatted as HTML anchors
const TYPE_HTML = "text/html";
// Place entries as raw URL text
const TYPE_UNICODE = "text/unicode";
function STACK(args) {

View File

@ -312,7 +312,7 @@
<field name="_DNDObserver"><![CDATA[({
// XXXben ew.
_self: this,
onDragStart: function(event, xferData, dragAction) {
onDragStart: function TV_DO_onDragStart(event, xferData, dragAction) {
if (this._self.getAttribute("sortActive") == "true")
throw Components.results.NS_OK;
xferData.data = PlacesController.getTransferData();
@ -320,12 +320,12 @@
if (event.ctrlKey)
dragAction.action = Ci.nsIDragService.DRAGDROP_ACTION_COPY;
},
canDrop: function(event, session) {
canDrop: function TV_DO_canDrop(event, session) {
return this._self._viewObserver.canDrop(-1, -1);
},
onDragOver: function(event, flavor, session) {
onDragOver: function TV_DO_onDragOver(event, flavor, session) {
},
getSupportedFlavours: function() {
getSupportedFlavours: function TV_DO_getSupportedFlavours() {
var flavorSet = new FlavourSet();
for (var i = 0; i < this._self.supportedDropTypes.length; ++i)
flavorSet.appendFlavour(this._self.supportedDropTypes[i]);

View File

@ -184,12 +184,47 @@
<field name="_DNDObserver"><![CDATA[({
// XXXben ew.
_self: this,
onDragStart: function(event, xferData, dragAction) {
onDragStart: function TBV_DO_onDragStart(event, xferData, dragAction) {
xferData.data = PlacesController.getTransferData();
// XXXben - the drag wrapper should do this automatically.
if (event.ctrlKey)
dragAction.action = Ci.nsIDragService.DRAGDROP_ACTION_COPY;
},
canDrop: function TBV_DO_canDrop(event, session) {
return PlacesControllerDragHelper.canDrop(this._self, -1);
},
onDragOver: function TBV_DO_onDragOver(event, flavor, session) {
},
onDrop: function TBV_DO_onDrop(event, dropData, session) {
var result = this._self.getResult();
var destContainer = result.folderId;
var destIndex = -1;
var orientation = 1;
if (event.target.localName == "toolbarbutton") {
if (PlacesController.nodeIsFolder(event.target.node)) {
destContainer = event.target.node.folderId;
destIndex = -1;
orientation = 0;
}
else {
destIndex = PlacesController.getIndexOfNode(event.target.node);
var bo = event.target.boxObject;
orientation = (event.screenX < bo.screenX + (bo.width / 2)) ? -1 : 1;
if (orientation == 1)
++destIndex;
}
}
PlacesControllerDragHelper.onDrop(this._self, destContainer,
destIndex, orientation);
},
getSupportedFlavours: function TBV_DO_getSupportedFlavours() {
var flavorSet = new FlavourSet();
for (var i = 0; i < this._self.supportedDropTypes.length; ++i)
flavorSet.appendFlavour(this._self.supportedDropTypes[i]);
return flavorSet;
},
})]]></field>
</implementation>
<handlers>
@ -210,6 +245,14 @@
!event.target.hasAttribute("type"))
nsDragAndDrop.startDrag(event, this._DNDObserver);
]]></handler>
<handler event="dragover"><![CDATA[
// XXXben ew.
nsDragAndDrop.dragOver(event, this._DNDObserver);
]]></handler>
<handler event="dragdrop"><![CDATA[
// XXXben ew.
nsDragAndDrop.drop(event, this._DNDObserver);
]]></handler>
</handlers>
</binding>