⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 toolbar.htc

📁 浏览器端看到树型目录结构,用户可以完整地看到像windows资源管理器一样的效果
💻 HTC
📖 第 1 页 / 共 5 页
字号:
        img.src = cacheImage.src;

        if (content.hasChildNodes())
            content.insertBefore(img, content.childNodes[0]);
        else
            content.insertBefore(img);
        content.setAttribute("_imageAdded", "true", 0);
    }

    f_AdjustContents(item);
}

//+----------------------------------------------------------------------------
//  Function:       f_GetItem
//  Description:    Returns the item that the index indicates.
//  Parameters:     nIndex      The index of the item to return
//  Returns:        The item or undefined
//-----------------------------------------------------------------------------
function f_GetItem(nIndex)
{
    var oParent = f_GetParent();

    if (oParent != null)
    {
        if ((nIndex < 0) || (nIndex >= oParent.children.length))
            return null;

        // If vertical, then this is a TR, otherwise TD
        var oCell = oParent.children[nIndex];
        if (orientation == "vertical")
        {
            if (oCell.children.length > 0)
                return oCell.children[0];
        }
        else
        {
            return oCell;
        }
    }

    return null;
}

//+----------------------------------------------------------------------------
//  Function:       f_NumItems
//  Description:    Returns the number of items in the toolbar.
//  Returns:        Returns the number of items in the toolbar.
//-----------------------------------------------------------------------------
function f_NumItems()
{
    var oParent = f_GetParent();
    
    if (oParent != null)
    {
        return oParent.children.length;
    }

    return 0;
}

//+----------------------------------------------------------------------------
//  Function:       f_OnPropertyChange
//  Description:    When certain properties change, alter the toolbar.
//-----------------------------------------------------------------------------
function f_OnPropertyChange()
{
    switch (event.propertyName)
    {
    case "innerHTML":
        // We need to rebuild the toolbar in this case
        f_CreateToolbar();
        break;
    case "_submitting":
        _IsSubmitting = (element.getAttribute("_submitting") == "true");
        _OnStopCount = 0;
        break;
    case "style.direction":
        _oTable.style.direction = element.style.direction;
        break;
    case "dir":
        _oTable.dir = element.dir;
        break;
    }
}

//+----------------------------------------------------------------------------
//  Function:       f_CreateToolbar
//  Description:    Initializes the toolbar.
//-----------------------------------------------------------------------------
function f_CreateToolbar()
{
    element.document.releaseCapture();
    f_AddStopEvent();

    if (f_IsMoveable())
    {
        defaults.style.position = "absolute";
        defaults.style.zIndex = "1";
        defaults.style.overflow = "hidden";
    }

    // Create the elements that make up the toolbar
    var oTable = element.document.createElement("TABLE");
    var oTBody = element.document.createElement("TBODY");

    // Adjust styles and attributes of the inner table
    _oTable = oTable;
    oTable.style.fontSize = currentStyle.fontSize;
    oTable.style.fontFamily = currentStyle.fontFamily;
    oTable.style.fontWeight = currentStyle.fontWeight;
    oTable.style.color = currentStyle.color;
    oTable.cellSpacing = 0;
    oTable.cellPadding = 0;
    if (element.currentStyle.direction != element.style.direction)
        oTable.style.direction = element.currentStyle.direction;
    else
        oTable.style.direction = element.style.direction;
    oTable.dir = element.dir;

    if (orientation != "vertical")
    {
        var oRow = element.document.createElement("TR");
        oTBody.appendChild(oRow);
    }

    oTable.appendChild(oTBody);

    // Add the toolbar items
    var aNodes = f_CreateNodesFromHtml(element.innerHTML);
    for (var nIndex = 0; nIndex < aNodes.length; nIndex++)
    {
        f_AppendToolbarItem(aNodes[nIndex]);
    }

    f_ApplyStylesToChildren();

    // Hook up events
    oTable.attachEvent("onclick", f_OnClick);
    oTable.attachEvent("ondblclick", f_OnClick);
    oTable.attachEvent("onmousedown", f_OnMouseDown);
    oTable.attachEvent("onmouseup", f_OnMouseUp);
    oTable.attachEvent("onmouseover", f_OnMouseOver);
    oTable.attachEvent("onmouseout", f_OnMouseOut);
    oTable.attachEvent("onmousemove", f_Drag);
    oTable.attachEvent("oncontextmenu", f_CancelInteractEvents);
    oTable.attachEvent("onselectstart", f_CancelInteractEvents);

    var oBody = element.document.createElement("BODY");
    var oHtml = element.document.createElement("HTML");
    oBody.appendChild(oTable);
    oHtml.appendChild(oBody);

    defaults.viewLink = oHtml.document;
    _Ready = true;

    defaults.style.display = "block";
}

//+----------------------------------------------------------------------------
//  Function:       f_CreateNodesFromHtml
//  Description:    Creates toolbaritems from a piece of HTML.
//  Returns:        An array of created elements
//-----------------------------------------------------------------------------
function f_CreateNodesFromHtml(htmlText)
{
    // Create a SPAN and insert the htmlText into it
    var oSpan = element.document.createElement("span");
    oSpan.innerHTML = htmlText;

    return f_CreateNodes(oSpan.childNodes);
}

//+----------------------------------------------------------------------------
//  Function:       f_CreateNodes
//  Description:    Creates toolbaritems from an array of nodes
//  Returns:        An array of created toolbar items
//-----------------------------------------------------------------------------
function f_CreateNodes(aNodes)
{
    var tbNodes = new Array();
    var nNumNodes = (aNodes == null) ? 0 : aNodes.length;

    for (var nIndex = 0; nIndex < nNumNodes; nIndex++)
    {
        var node = aNodes[nIndex];
        if (node != null)
            tbNodes = tbNodes.concat(f_CreateToolbarItems(node));
    }

    return tbNodes;
}

//+----------------------------------------------------------------------------
//  Function:       f_CreateToolbarItems
//  Description:    Takes a node and converts it into toolbar items.
//  Parameter:      oNode    The toolbaritem to convert
//  Returns:        The TD element or undefined
//-----------------------------------------------------------------------------
function f_CreateToolbarItems(oNode)
{
    var aNodes;
    var szTagName = (oNode.tagName == null) ? "" : oNode.tagName.toLowerCase();

    switch (szTagName)
    {
    case "toolbarbutton":
        aNodes = new Array(f_CreateButton(oNode));
        break;

    case "toolbarcheckbutton":
        aNodes = new Array(f_CreateCheckbutton(oNode));
        break;

    case "toolbarseparator":
        aNodes = new Array(f_CreateSeparator(oNode));
        break;

    case "toolbarcheckgroup":
        aNodes = f_CreateCheckGroup(oNode);
        break;

    case "toolbardropdownlist":
        aNodes = new Array(f_CreateDropDownList(oNode));
        break;

    case "toolbartextbox":
        aNodes = new Array(f_CreateTextBox(oNode));
        break;

    case "toolbarlabel":
        aNodes = new Array(f_CreateLabel(oNode));
        break;

    case "toolbargripper":
        aNodes = new Array(f_CreateGripper(oNode));
        break;

    default:
        aNodes = new Array();
        break;
    }

    for (var nIndex = 0; nIndex < aNodes.length; nIndex++)
        f_AdjustContents(aNodes[nIndex]);

    return aNodes;
}

//+----------------------------------------------------------------------------
//  Function:       f_Interactable
//  Description:    Given a toolbaritem, determines through its type
//                  whether a user can interact with it.
//  Parameters:
//                  oCell       The toolbaritem to check
//  Returns:
//                  true        If interactable
//                  false       otherwise
//-----------------------------------------------------------------------------
function f_Interactable(oCell)
{
    switch (oCell._type)
    {
    case "checkbutton":
    case "button":
        return true;

    default:
        return false;
    }
}

//+----------------------------------------------------------------------------
//  Function:       f_IsSelected
//  Description:    Determines if the cell is selected.
//  Parameters:     oCell       The cell to test
//  Returns:        true if it is selected, false otherwise
//-----------------------------------------------------------------------------
function f_IsSelected(oCell)
{
    if (oCell._type != "checkbutton")
        return false;

    var szSelected = oCell.getAttribute("selected");

    return ((szSelected != null) && (String(szSelected).toLowerCase() == "true"));
}

//+----------------------------------------------------------------------------
//  Function:       f_SetSelected
//  Description:    Sets a cell's selected attribute to the given value.
//  Parameters:     oCell       The cell to modify
//                  bSelected   true to specify selected, false otherwise
//-----------------------------------------------------------------------------
function f_SetSelected(oCell, bSelected)
{
    if (oCell._type != "checkbutton")
        return;

    oCell.setAttribute("selected", bSelected ? "true" : "false", 0);
}

//+----------------------------------------------------------------------------
//  Function:       f_CheckButton
//  Description:    Selects a checkbutton and deselects the other buttons in
//                  its group.
//  Parameters:     oSelected       One of the cell to select
//-----------------------------------------------------------------------------
function f_CheckButton(oSelected)
{
    if ((oSelected == null) || (oSelected._type != "checkbutton"))
        return;

    if (oSelected._group != null)
    {
        var oPrevID = oSelected._group.oSelected;
        if (oPrevID != null)
        {
            var oPrevSel = oSelected.document.all[oPrevID];
            if (oPrevSel != null)
            {
                if (oPrevSel.uniqueID == oSelected.uniqueID)
                    return;
                f_SetSelected(oPrevSel, false);
                f_ApplyNeutralStyle(oPrevSel);
                oSelected._group.oSelected = null;
                f_FireCheckChange(oPrevSel);
            }
        }
    }

    f_SetSelected(oSelected, true);
    f_ApplyNeutralStyle(oSelected);
    if (oSelected._group != null)
        oSelected._group.oSelected = oSelected.uniqueID;
    f_FireCheckChange(oSelected);
}

//+----------------------------------------------------------------------------
//  Function:       f_AppendToolbarItem
//  Description:    Inserts a toolbar item into the toolbar.
//  Parameter:      oToolbarItem    The toolbaritem to convert and insert
//-----------------------------------------------------------------------------
function f_AppendToolbarItem(oCell)
{
    var oParent = f_GetParent();
    if ((oCell == null) || (oParent == null))
        return;

    // Append the item
    if (orientation == "vertical")
    {
        var trRow = element.document.createElement("TR");
        if (oCell._type == "emptygroup")
            trRow.style.display = "none";
        trRow.appendChild(oCell);
        oParent.appendChild(trRow);
    }
    else
    {
        oParent.appendChild(oCell);
    }
}

//+----------------------------------------------------------------------------
//  Function:       f_AdjustContents
//  Description:    Turns the non-image tags 90 degrees in the passed in object
//                  if it is a vertical toolbar.
//                  Aligns the images absmiddle.
//  Parameters:     oCell           The cell to have its contents adjusted
//-----------------------------------------------------------------------------
function f_AdjustContents(oCell)
{
    if (oCell._turnContent == null)
        oCell._turnContent = false;
    var bTurnContent = false;

    if (turnVerticalContent)
    {
        switch (oCell._type)
        {
        case "label":
        case "button":
        case "checkbutton":
            bTurnContent = (orientation == "vertical");
            break;

        default:
            return;
        }

        if (bTurnContent)
        {
            oCell._turnContent = true;
            oCell.style.writingMode = "tb-rl";
        }
    }

    if (oCell._turnContent && !bTurnContent)
    {
        oCell._turnContent = false;
        oCell.style.writingMode = "lr-tb";
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -