Powered By Blogger

Monday, November 29, 2010

Create Chevron using example function

function Dummy_ResizeToolbar()
{
try
{
var Dummy_Pos_Last_Element_Pos_X, Dummy_Pos_Last_Element_Pos_Y, countResize;
var mainWindow = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindow);

var Dummy_FX_Window_Width = mainWindow.innerWidth ;

var Dummy_ToolbarPaletteObject = document.getElementById("Dummytoolbar");

var Dummy_ToolbarPalette_CountChild = Dummy_ToolbarPaletteObject.childNodes.length;

// Set Hidden Property to True
for (countResize = 0; countResize < Dummy_ToolbarPalette_CountChild ; countResize++)
{
Dummy_ToolbarPaletteObject.childNodes[countResize].setAttribute("hidden", "false");
if (Dummy_ToolbarPaletteObject.childNodes[countResize].getAttribute("label") == ">>")
{Dummy_ToolbarPaletteObject.removeChild(Dummy_ToolbarPaletteObject.childNodes[countResize]);}
if (Dummy_ToolbarPaletteObject.childNodes[countResize].getAttribute("id") == "Dummy_Chevron_Menubar")
{Dummy_ToolbarPaletteObject.removeChild(Dummy_ToolbarPaletteObject.childNodes[countResize]);}
}

// Set Hidden Property to True
Dummy_ToolbarPalette_CountChild = Dummy_ToolbarPaletteObject.childNodes.length ;
var Dummy_ChevronMenubar = document.createElement('menubar');
Dummy_ChevronMenubar.setAttribute("id","Dummy_Chevron_Menubar");
var Dummy_ChevronToolbarButtonObj = document.createElement('toolbarbutton');
Dummy_ChevronToolbarButtonObj.setAttribute("type","menu");
Dummy_ChevronToolbarButtonObj.setAttribute("label",">>");
var Dummy_ActivateChevron =0 ;
var Dummy_ChevronMenuPopupObj = document.createElement("menupopup");
for (countResize = 0; countResize < Dummy_ToolbarPalette_CountChild; countResize++)
{
var Dummy_Chevron_ItemList_Name , Dummy_Chevron_ItemList_ToolTip;
var Dummy_Chevron_ItemList_Command, Dummy_ChevronPopupMenuList, Dummy_Chevron_ItemList_Image;
Dummy_Pos_Last_Element_Pos_X = Dummy_ToolbarPaletteObject.childNodes[countResize].boxObject.x + 150;
if (Dummy_Pos_Last_Element_Pos_X > Dummy_FX_Window_Width)
{
Dummy_Chevron_ItemList_Name = Dummy_ToolbarPaletteObject.childNodes[countResize].getAttribute("label");
Dummy_Chevron_ItemList_ToolTip = Dummy_ToolbarPaletteObject.childNodes[countResize].getAttribute("tooltiptext");
Dummy_Chevron_ItemList_Command = Dummy_ToolbarPaletteObject.childNodes[countResize].getAttribute("oncommand");
Dummy_Chevron_ItemList_Image = Dummy_ToolbarPaletteObject.childNodes[countResize].getAttribute("image");

var Dummy_Check_ToolTip_Item = Dummy_Chevron_ItemList_ToolTip.toLowerCase();
var Dummy_ChevronPopupMenuList = document.createElement('menuitem');

if (countResize == 0)
Dummy_ChevronPopupMenuList.setAttribute("oncommand", "Dummy_LoadUrl('http://www.JustDial.com');");
else
Dummy_ChevronPopupMenuList.setAttribute("oncommand", Dummy_Chevron_ItemList_Command);

if (Dummy_Chevron_ItemList_Name == "")
Dummy_ChevronPopupMenuList.setAttribute("label", " "+Dummy_Chevron_ItemList_ToolTip);
else
Dummy_ChevronPopupMenuList.setAttribute("label", " "+Dummy_Chevron_ItemList_Name);

Dummy_ChevronPopupMenuList.setAttribute("class","menuitem-iconic");
Dummy_ChevronPopupMenuList.setAttribute("image",Dummy_Chevron_ItemList_Image);

if (Dummy_ToolbarPaletteObject.childNodes[countResize].nodeName == "toolbarbutton" )
{
Dummy_ChevronMenuPopupObj.appendChild(Dummy_ChevronPopupMenuList);
}

Dummy_ToolbarPaletteObject.childNodes[countResize].setAttribute("hidden", "true");
Dummy_ActivateChevron++;
}
}

Dummy_ChevronToolbarButtonObj.appendChild(Dummy_ChevronMenuPopupObj);
Dummy_ChevronMenubar.appendChild(Dummy_ChevronToolbarButtonObj);
if (Dummy_ActivateChevron > 0)
{
Dummy_ToolbarPaletteObject.appendChild(Dummy_ChevronMenubar);
}
}

catch(ee)
{
alert(ee.message);
}
}
// Add event listener
window.addEventListener("load", Dummy_ResizeToolbar, false);
window.addEventListener("resize", Dummy_ResizeToolbar, false);

No comments:

Post a Comment