toolbar landing 44756

This commit is contained in:
ben%netscape.com 2006-09-14 05:52:23 +00:00
parent a5fca72c45
commit 3d53d6c3c8
5 changed files with 116 additions and 16 deletions

View File

@ -73,6 +73,7 @@ catch (ex)
// focused frame URL
var gFocusedURL = null;
var gNavigated = -1;
/**
* Save the document at a given location to disk
@ -100,6 +101,7 @@ function savePage( url )
**/
function getContentAreaFrameCount()
{
gNavigated++;
var saveFrameItem = document.getElementById("savepage");
if (!window._content.frames.length ||
!isDocumentFrame(document.commandDispatcher.focusedWindow))
@ -479,6 +481,7 @@ function Startup()
initConsoleListener();
}
function Shutdown()
{
try
@ -933,7 +936,8 @@ function RevealSearchPanel()
fp.appendFilters(nsIFilePicker.filterHTML | nsIFilePicker.filterText |
nsIFilePicker.filterAll | nsIFilePicker.filterImages | nsIFilePicker.filterXML);
if (fp.show() == nsIFilePicker.returnOK) {
openTopWin(fp.fileURL.spec);
var fn = !gNavigated ? openTopWin : openNewWindowWith;
fn(fp.fileURL.spec);
}
} catch (ex) { }
}

View File

@ -243,12 +243,12 @@ Contributor(s): ______________________________________. -->
var gBookmarkPopup = null;
</script>
<toolbox class="toolbox-top">
<toolbox id="navigator-toolbox" class="toolbox-top" deferattached="true">
<!-- Menu -->
<menubar id="main-menubar"/>
<menubar id="main-menubar" persist="collapsed" grippytooltip="aTooltip" grippytooltiptext="&menuBar.tooltip;"/>
<toolbar class="toolbar-primary chromeclass-toolbar" id="nav-bar"
persist="collapsed" grippytooltip="aTooltip" grippytooltiptext="&navigationBar.tooltip;">
<toolbar class="toolbar-primary chromeclass-toolbar" id="nav-bar" persist="collapsed"
grippytooltip="aTooltip" grippytooltiptext="&navigationBar.tooltip;">
<menubutton class="menubutton-dual toolbar top" id="back-button" value="&backButton.label;"
crop="right" observes="canGoBack" oncommand="gotoHistoryIndex(event);"
tooltip="aTooltip"
@ -296,8 +296,9 @@ Contributor(s): ______________________________________. -->
ondragover="nsDragAndDrop.dragOver(event, personalToolbarObserver);"
ondragdrop="nsDragAndDrop.drop(event, personalToolbarObserver);"
ondraggesture="nsDragAndDrop.startDrag(event, personalToolbarObserver);"
ondragexit="nsDragAndDrop.dragExit(event, personalToolbarObserver);"
grippytooltip="aTooltip" grippytooltiptext="&personalBar.tooltip;"
last-toolbar="true">
last-toolbar="true" persist="collapsed">
<!-- Personal toolbar items -->
<box id="innermostBox" flex="1" style="min-width: 1px;" context="contextual"
@ -341,7 +342,7 @@ Contributor(s): ______________________________________. -->
</rule>
</template>
<button class="button-toolbar" id="homebutton" value="&homeButton.label;"
<button class="button-toolbar bookmarkitem" id="homebutton" value="&homeButton.label;"
tooltip="aTooltip"
ondraggesture="nsDragAndDrop.startDrag(event, homeButtonObserver);"
ondragover="nsDragAndDrop.dragOver(event, homeButtonObserver);"

View File

@ -96,13 +96,12 @@ var personalToolbarObserver = {
//if (!isBookmark(uri))
// return;
var title = aEvent.target.value;
var htmlString = "<A HREF='" + uri + "'>" + title + "</A>";
var flavourList = { };
flavourList["moz/toolbaritem"] = { width: 2, data: uri };
flavourList["text/x-moz-url"] = { width: 2, data: homepage + " " + "[ TEMP TITLE ]" };
flavourList["text/x-moz-url"] = { width: 2, data: uri + " " + "[ TEMP TITLE ]" };
flavourList["text/html"] = { width: 2, data: htmlString };
flavourList["text/unicode"] = { width: 2, data: uri };
return flavourList;
@ -115,7 +114,9 @@ var personalToolbarObserver = {
return false;
var element = aData.data.data;
var dropElement = aEvent.target.id;
var elementRes = RDFUtils.getResource(element);
var dropElementRes = RDFUtils.getResource(dropElement);
var personalToolbarRes = RDFUtils.getResource("NC:PersonalToolbarFolder");
var childDB = document.getElementById("innermostBox").database;
@ -123,9 +124,8 @@ var personalToolbarObserver = {
"nsIRDFContainer");
rdfContainer.Init(childDB, personalToolbarRes);
var newIndex = 1; // XXX need .offset* to figure out where to drop element
var dropIndex = rdfContainer.IndexOf(elementRes);
if (dropIndex > 0)
var elementIsOnToolbar = rdfContainer.IndexOf(elementRes);
if (elementIsOnToolbar > 0)
rdfContainer.RemoveElement(elementRes, true);
else if (dropIndex == -1)
{
@ -145,7 +145,39 @@ var personalToolbarObserver = {
gRDFService.GetLiteral(linkTitle),
true);
}
rdfContainer.InsertElementAt(elementRes, newIndex, true);
var dropIndex = rdfContainer.IndexOf(dropElementRes);
// determine the drop position
var dropPosition = this.determineDropPosition(aEvent);
switch (dropPosition) {
case -1:
rdfContainer.InsertElementAt(elementRes, dropIndex, true);
break;
case 0:
// do something here to drop into subfolders
var childContainer = nsJSComponentManager.createInstance("component://netscape/rdf/container",
"nsIRDFContainer");
childContainer.Init(childDB, dropElementRes);
childContainer.AppendElement(elementRes);
break;
case 1:
default:
rdfContainer.InsertElementAt(elementRes, dropIndex+1, true);
break;
}
},
mCurrentDragOverButton: null,
mCurrentDragPosition: null,
onDragExit: function (aEvent, aDragSession)
{
if (this.mCurrentDragOverButton)
{
this.mCurrentDragOverButton.removeAttribute("dragover-left");
this.mCurrentDragOverButton.removeAttribute("dragover-right");
this.mCurrentDragOverButton.removeAttribute("dragover-top");
this.mCurrentDragOverButton.removeAttribute("open");
}
},
onDragOver: function (aEvent, aFlavour, aDragSession)
@ -153,9 +185,41 @@ var personalToolbarObserver = {
// temporary
if (!isPToolbarDNDEnabled())
return false;
var toolbar = document.getElementById("PersonalToolbar");
toolbar.setAttribute("dd-triggerrepaint", 0);
var dropPosition = this.determineDropPosition(aEvent);
if (this.mCurrentDragOverButton != aEvent.target ||
(this.mCurrentDragOverButton == aEvent.target &&
this.mCurrentDragPosition != dropPosition))
{
if (this.mCurrentDragOverButton)
{
this.mCurrentDragOverButton.removeAttribute("dragover-left");
this.mCurrentDragOverButton.removeAttribute("dragover-right");
this.mCurrentDragOverButton.removeAttribute("dragover-top");
this.mCurrentDragOverButton.removeAttribute("open");
}
this.mCurrentDragOverButton = aEvent.target;
this.mCurrentDragPosition = dropPosition;
}
switch (dropPosition)
{
case -1:
aEvent.target.setAttribute("dragover-left", "true");
break;
case 1:
aEvent.target.setAttribute("dragover-right", "true");
break;
case 0:
default:
if (aEvent.target.getAttribute("container") == "true") {
aEvent.target.setAttribute("dragover-top", "true");
//cant open a menu during a drag! suck!
//aEvent.target.setAttribute("open", "true");
}
break;
}
},
getSupportedFlavours: function ()
@ -169,6 +233,32 @@ var personalToolbarObserver = {
flavourList["text/unicode"] = { width: 2, iid: "nsISupportsWString" };
return flavourList;
},
determineDropPosition: function (aEvent)
{
var overButton = aEvent.target;
var overButtonBoxObject = overButton.boxObject.QueryInterface(Components.interfaces.nsIBoxObject);
if (aEvent.clientX < (overButtonBoxObject.x + overButtonBoxObject.width/3))
{
if (aEvent.clientY > overButtonBoxObject.y &&
aEvent.clientY < overButtonBoxObject.y + overButtonBoxObject.height)
return -1;
}
else if (aEvent.clientX > (overButtonBoxObject.x + 2*(overButtonBoxObject.width/3)))
{
if (aEvent.clientY > overButtonBoxObject.y &&
aEvent.clientY < overButtonBoxObject.y + overButtonBoxObject.height)
return 1;
}
else if (aEvent.clientX > (overButtonBoxObject.x + overButtonBoxObject.width/3) &&
aEvent.clientX < ((overButtonBoxObject.x + 2*(overButtonBoxObject.width/3))))
{
if (aEvent.clientY > overButtonBoxObject.y &&
aEvent.clientY < overButtonBoxObject.y + overButtonBoxObject.height)
return 0;
}
},
};
var contentAreaDNDObserver = {

View File

@ -121,6 +121,10 @@ Contributor(s): Blake Ross <BlakeR1234@aol.com>. -->
<broadcaster id="cmd_viewpersonaltoolbar" type="checkbox" oncommand="goToggleToolbar('PersonalToolbar','cmd_viewpersonaltoolbar');" checked="true"/>
<broadcaster id="cmd_viewtaskbar" type="checkbox" oncommand="goToggleToolbar('taskbar','cmd_viewtaskbar');" checked="true"/>
<broadcaster id="cmd_viewnavbar" class="menuitem-iconic" type="checkbox" oncommand="goToggleToolbar( 'nav-bar','cmd_viewnavbar');" checked="true"/>
<broadcaster id="cmd_viewpersonaltoolbar" class="menuitem-iconic" type="checkbox" oncommand="goToggleToolbar('PersonalToolbar','cmd_viewpersonaltoolbar');" checked="true"/>
<broadcaster id="cmd_viewtaskbar" class="menuitem-iconic" type="checkbox" oncommand="goToggleToolbar('taskbar','cmd_viewtaskbar');" checked="true"/>
<broadcaster id="Browser:Open" value="&openCmd.label;" oncommand="BrowserOpenWindow();"/>
<broadcaster id="Browser:OpenFile" value="&openFileCmd.label;" oncommand="BrowserOpenFileWindow();"/>

View File

@ -316,6 +316,7 @@
<!ENTITY locationBar.tooltip "Location and search field">
<!ENTITY internetKeyword.tooltip "Return to previously viewed page or choose keyword">
<!ENTITY menuBar.tooltip "Menu bar">
<!ENTITY personalBar.tooltip "Personal toolbar">
<!ENTITY navigationBar.tooltip "Navigation toolbar">