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

📄 grids.js

📁 Bindows 1.01 完全版 Bindows 框架提供给你: 基于类的面向对象 API; 一个完整的窗口系统
💻 JS
📖 第 1 页 / 共 5 页
字号:
        if (items[i][methodName](oValue))            return items[i];    }    for (i = 0; i < nStartIndex; i++)    {        if (items[i][methodName](oValue))            return items[i];    }    return null;};_p._getMouseEventInfo = function(e, inEl){    var el = inEl || e._event.srcElement || e._event.target;    if (el == null)        return null;    var res = {    };    res.expandIconClicked = el.tagName == "IMG" && el.className == "bi-tree-expand-icon";    var cellRe = /bi-tree-cell/;    var cellEl = el;    while (cellEl != null && !cellRe.test(cellEl.className))        cellEl = cellEl.parentNode;    if (cellEl != null)    {        if (cellRe.test(cellEl.className))        {            res.cellIndex = Number(cellEl.className.replace(/.*col-(\d+).*/, "$1"));        }        el = cellEl;    }    else    {        res.cellIndex = -1;    }    while (el != null && el.className != "bi-tree-node")        el = el.parentNode;    if (el == null)        return null;    res.treeNode = this._getAllNodes()[el.id];    return res;};_p._onMouseEvent = function(e){    var info = this._getMouseEventInfo(e);    if (info == null || info.treeNode == null)        return;    var node = info.treeNode;    switch (e.getType())    {        case "mousedown":        if (info.expandIconClicked && node.hasNodes())        {            node.toggle();            if (node.getExpanded())                node._scrollSubTreeIntoView();        }        else            this._selectionModel.handleMouseDown(node, e);        break;        case "mouseup":        if (!info.expandIconClicked || !node.hasNodes())            this._selectionModel.handleMouseUp(node, e);        break;        case "click":        this._selectionModel.handleClick(node, e);        break;        case "dblclick":        if (node && node.hasNodes())        {            node.toggle();            if (node.getExpanded())                node._scrollSubTreeIntoView();        }        else            this._selectionModel.handleDblClick(node, e);        break;    }};_p._onKeyDown = function(e){    var leadItem = this._selectionModel.getLeadItem();    if (leadItem)    {        switch (e.getKeyCode())        {            case BiKeyboardEvent.RIGHT:            if (leadItem.hasNodes())            {                if (leadItem.getExpanded())                    this._selectionModel.setLeadItem(leadItem.getFirstNode());                else                {                    leadItem.setExpanded(true);                    leadItem._scrollSubTreeIntoView();                }            }            break;            case BiKeyboardEvent.LEFT:            if (leadItem.hasNodes() && leadItem.getExpanded())                leadItem.setExpanded(false);            else            {                var p = leadItem.getParentNode();                if (p == leadItem.getTree())                    break;                this._selectionModel.setLeadItem(p);            }            break;        }    }    this._selectionModel.handleKeyDown(e);};_p.getExpanded = function(){    return true;} ;_p.setExpanded = function(b){} ;_p.reveal = function(){} ;_p._sort = function(fCompare, bAscending){    if (this.hasNodes())    {        for (var i = 0; i < this._nodes.length; i++)            this._nodes[i]._sort(fCompare, bAscending);        this._nodes.sort(fCompare);        if (!bAscending)            this._nodes.reverse();    }};_p.getRowAtPoint = _p.getNodeAtPoint = function(nClientX, nClientY){    var el = this._document.elementFromPoint(nClientX, nClientY);    if (el == null)        return null;    var res = this._getMouseEventInfo(null, el);    return res ? res.treeNode : null;};function BiTreeNode(oData){    BiAbstractGridRow.call(this);    this._nodes = [];    this._data = oData || [];}var _p = BiTreeNode.prototype = new BiAbstractGridRow;_p._className = "BiTreeNode";_p._indentWidth = 19;_p._expanded = true;_p._icon = BiTree.DEFAULT_ICON;_p.getData = function(nCol){    return this._data[nCol];} ;_p.setData = function(nCol, oData){    this._data[nCol] = oData;} ;_p.matchesString = function(sText){    return sText != "" && BiLabel.htmlToText(this.getCellHtml(0).toLowerCase()).indexOf(sText.toLowerCase()) == 0;} ;_p.matchesStringExact = function(sText){    return sText != "" && BiLabel.htmlToText(this.getCellHtml(0)).toLowerCase() == String(sText).toLowerCase();} ;_p.getHtml = function(){    var childrenHtml;    if (this.hasNodes())    {        var childrenSb = [];        var cs = this._nodes;        var l = cs.length;        for (var y = 0; y < l; y++)            childrenSb[y] = cs[y].getHtml();        childrenHtml            = "<div class=\"bi-tree-children\" style=\""+this._getLineStyle()+(this.getExpanded()?"":"display:none;")+"\">" + childrenSb.join("")                  + "</div>"    }    else        childrenHtml = "";    return "<div class=\"bi-tree-node\" id=\""+this.toHashCode()+"\">" + this.getRowHtml() + childrenHtml + "</div>";};_p.getRowHtml = function(){    var tree = this.getTree();    var cellsSb = [];    var l = tree._columnCount;    for (var x = 0; x < l; x++)        cellsSb[x] = this.getCellHtml(tree._columnOrders[x]);    return "<div class=\""+this.getCssClassName()+"\""+this._getStyle()+">" + cellsSb.join("") + "</div>";};_p.getCssClassName = function(){    var f = this._grid && this._grid.getFocused();    return "bi-tree-row" + (this._selected && f ? " selected-tree-node-focused"                               : "") + (this._selected && !f ? " selected-tree-node" : "");};_p.getCellHtml = function(nCol){    var t = this.getTree();    return "<span class=\"bi-tree-cell col-"+nCol+"\">" + (nCol == t.getIndentColumn() ? this.getExpandIconHtml()                                                              : "") + (nCol == t.getIconColumn()                                                                          ? this.getIconHtml() : "") + this.getLabelHtml(                                                                                                           nCol)        + "</span>";};_p.getLabelHtml = function(nCol){    return this._data[nCol];} ;_p.getIconHtml = function(){    var i = this.getIcon();    if (!i)        return "";    if (i.getIconHtml)        return i.getIconHtml(this.getLabelHtml() != "", true, "left", 3, "bi-tree-icon");    else        return "<img class=\"bi-tree-icon\" src=\""+i+"\">";};_p.getExpandIconSrc = function(){    var src;    var tree = this.getTree();    if (this.hasNodes())    {        if (!tree.getShowLines() || this.getLevel() == 1 && !tree.getShowRootLines())        {            if (!tree.getShowPlusMinus())                src = BiTree.BLANK_ICON;            else if (this.getExpanded())                src = BiTree.MINUS_ICON;            else                src = BiTree.PLUS_ICON;        }        else if (this.isLastSiblingNode())        {            if (!tree.getShowPlusMinus())                src = BiTree.L_ICON;            else if (this.getExpanded())                src = BiTree.L_MINUS_ICON;            else                src = BiTree.L_PLUS_ICON;        }        else        {            if (!tree.getShowPlusMinus())                src = BiTree.T_ICON;            else if (this.getExpanded())                src = BiTree.T_MINUS_ICON;            else                src = BiTree.T_PLUS_ICON;        }    }    else    {        if (!this.getTree().getShowLines() || this.getLevel() == 1 && !tree.getShowRootLines())            src = BiTree.BLANK_ICON;        else if (this.isLastSiblingNode())            src = BiTree.L_ICON;        else            src = BiTree.T_ICON;    }    return src;};_p.getExpandIconHtml = function(){    if (!this.getTree().getShowPlusMinus() && !this.getTree().getShowLines())        return "";    return "<img class=\"bi-tree-expand-icon\" src=\""+this.getExpandIconSrc()+"\">";};_p._getLineStyle = function(){    return !this._getShowChildrenLine() ? "background-position: -100px 0 !important;" : "";} ;_p._getShowChildrenLine = function(){    var tree = this.getTree();    return tree.getShowLines() && !this.isLastSiblingNode() && !(!tree.getShowRootLines() && this.getLevel() == 1);};_p.update = function(){    BiAbstractGridRow.prototype.update.call(this);    this.getTree()._updateHeadersWidth();};_p.updateRow = function(){    if (!this.getCreated() || !this.getTree())        return;    if (BiBrowserCheck.ie)        this._element.firstChild.outerHTML = this.getRowHtml();    else    {        var dummy = this.getTree()._document.createElement("DIV");        dummy.innerHTML = this.getRowHtml();        this._element.firstChild.parentNode.replaceChild(dummy.firstChild, this._element.firstChild);    }    this.getTree()._clearCache();};_p.addNode = function(oChild, oBefore){    var p = oChild._parentNode;    if (oBefore == null)    {        if (p != null)            p.removeNode(oChild);        this._nodes.push(oChild);    }    else    {        if (oBefore._parentNode != this)            throw new Error("Can only add components before siblings");        if (p != null)            p.removeNode(oChild);        var i = this._nodes.indexOf(oBefore);        this._nodes.insertAt(oChild, i);    }    oChild._parentNode = this;    if (this.getTree())    {        oChild._grid = this.getTree();        oChild._grid._clearCache();    }    if (this.getLevel() != null)        oChild._level = this.getLevel() + 1;};_p.removeNode = function(oChild){    if (oChild._parentNode != this)        throw new Error("Can only remove children");    this._nodes.remove(oChild);    oChild._parentNode = null;    if (oChild._grid)    {        oChild._grid._clearCache();    }    oChild._grid = null;    oChild._level = null;    return oChild;};_p.removeAll = function(){    var cs = this.getChildren();    var l = cs.length;    for (var i = 0; i < l; i++)    {        this.remove(cs[i]);        cs[i].dispose();    }};BiTreeNode.prototype.getParentNode = function(){    return this._parentNode;} ;_p.getNodes = function(){    return this._nodes;} ;_p.containsNode = function(oDescendant){    if (oDescendant == null)        return false;    if (oDescendant == this)        return true;    var p = oDescendant._parentNode;    return this.containsNode(p);};_p.getFirstNode = function(){    return this._nodes[0];} ;_p.getLastNode = function(){    return this._nodes[this._nodes.length - 1];} ;_p.getPreviousSiblingNode = function(){    var p = this._parentNode;    if (p == null)        return null;    var cs = p._nodes;    return cs[cs.indexOf(this) - 1]};_p.getNextSiblingNode = function(){    var p = this._parentNode;    if (p == null)        return null;    var cs = p._nodes;    return cs[cs.indexOf(this) + 1]};_p.getLevel = function(){    if (this._level != null)        return this._level;    if (this._parentNode)    {        var pd = this._parentNode.getLevel();        return this._level = (pd != null ? pd + 1 : null);    }    return null;};_p.hasNodes = function(){    return this._nodes.length > 0;} ;_p.isLeaf = function(){    return !this.hasNodes();} ;_p.getGrid = _p.getTree = function(){    if (this._grid)        return this._grid;    if (this._parentNode)        return this._grid = this._parentNode.getTree();    return null;};_p.getDepth = function(){    var d = 0;    var cs = this._nodes;    var l = cs.length;    for (var i = 0; i < l; i++)        d = Math.max(d, cs[i].getDepth() + 1);    return d;};_p.isLastSiblingNode = function(){    return this._parentNode && this == this._parentNode.getLastNode();} ;_p.getExpanded = function(){    return this._expanded;} ;_p.dispose = function(){    if (this._disposed)        return;    for (var i = this._

⌨️ 快捷键说明

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