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

📄 datatable-debug.js

📁 这是YUI的源码及相关示例。里面有很多很炫的Javascript效果。
💻 JS
📖 第 1 页 / 共 5 页
字号:
            }        },        /**         * Handles drag events on the Column resizer.         *         * @method onDrag         * @param e {string} The drag event         */        onDrag : function(e) {            var newX = YAHOO.util.Event.getXY(e)[0];            if(newX > YAHOO.util.Dom.getX(this.headCellLiner)) {                var offsetX = newX - this.startX;                var newWidth = this.startWidth + offsetX - this.nLinerPadding;                if(newWidth > 0) {                    this.datatable.setColumnWidth(this.column, newWidth);                }            }        }    });}///////////////////////////////////////////////////////////////////////////////// Deprecated////////////////////////////////////////////////////////////////////////////////** * @property editorOptions * @deprecated Pass configs directly to CellEditor constructor.  */(function () {var lang   = YAHOO.lang,    util   = YAHOO.util,    widget = YAHOO.widget,        Dom    = util.Dom,    Ev     = util.Event,    DT     = widget.DataTable;/****************************************************************************//****************************************************************************//****************************************************************************//** * A RecordSet defines and manages a set of Records. * * @namespace YAHOO.widget * @class RecordSet * @param data {Object || Object[]} An object literal or an array of data. * @constructor */YAHOO.widget.RecordSet = function(data) {    // Internal variables    this._sId = "yui-rs" + widget.RecordSet._nCount;    widget.RecordSet._nCount++;    this._records = [];    //this._length = 0;    if(data) {        if(lang.isArray(data)) {            this.addRecords(data);        }        else if(lang.isObject(data)) {            this.addRecord(data);        }    }    YAHOO.log("RecordSet initialized", "info", this.toString());};var RS = widget.RecordSet;/** * Internal class variable to name multiple Recordset instances. * * @property RecordSet._nCount * @type Number * @private * @static */RS._nCount = 0;RS.prototype = {    /////////////////////////////////////////////////////////////////////////////    //    // Private member variables    //    /////////////////////////////////////////////////////////////////////////////    /**     * Unique String identifier assigned at instantiation.     *     * @property _sId     * @type String     * @private     */    _sId : null,    /**     * Internal counter of how many Records are in the RecordSet.     *     * @property _length     * @type Number     * @private     * @deprecated No longer used     */    //_length : null,    /////////////////////////////////////////////////////////////////////////////    //    // Private methods    //    /////////////////////////////////////////////////////////////////////////////    /**     * Adds one Record to the RecordSet at the given index. If index is null,     * then adds the Record to the end of the RecordSet.     *     * @method _addRecord     * @param oData {Object} An object literal of data.     * @param index {Number} (optional) Position index.     * @return {YAHOO.widget.Record} A Record instance.     * @private     */    _addRecord : function(oData, index) {        var oRecord = new YAHOO.widget.Record(oData);                if(YAHOO.lang.isNumber(index) && (index > -1)) {            this._records.splice(index,0,oRecord);        }        else {            //index = this.getLength();            //this._records[index] = oRecord;            this._records[this._records.length] = oRecord;        }        //this._length++;        return oRecord;    },    /**     * Sets/replaces one Record to the RecordSet at the given index.  Existing     * Records with higher indexes are not shifted.  If no index specified, the     * Record is added to the end of the RecordSet.     *     * @method _setRecord     * @param oData {Object} An object literal of data.     * @param index {Number} (optional) Position index.     * @return {YAHOO.widget.Record} A Record instance.     * @private     */    _setRecord : function(oData, index) {        if (!lang.isNumber(index) || index < 0) {            index = this._records.length;        }        return (this._records[index] = new widget.Record(oData));        /*        if(lang.isNumber(index) && (index > -1)) {            this._records[index] = oRecord;            if((index+1) > this.getLength()) {                this._length = index+1;            }        }        else {            this._records[this.getLength()] = oRecord;            this._length++;        }        return oRecord;        */    },    /**     * Deletes Records from the RecordSet at the given index. If range is null,     * then only one Record is deleted.     *     * @method _deleteRecord     * @param index {Number} Position index.     * @param range {Number} (optional) How many Records to delete     * @private     */    _deleteRecord : function(index, range) {        if(!lang.isNumber(range) || (range < 0)) {            range = 1;        }        this._records.splice(index, range);        //this._length = this._length - range;    },    /////////////////////////////////////////////////////////////////////////////    //    // Public methods    //    /////////////////////////////////////////////////////////////////////////////    /**     * Returns unique name of the RecordSet instance.     *     * @method getId     * @return {String} Unique name of the RecordSet instance.     */    getId : function() {        return this._sId;    },    /**     * Public accessor to the unique name of the RecordSet instance.     *     * @method toString     * @return {String} Unique name of the RecordSet instance.     */    toString : function() {        return "RecordSet instance " + this._sId;    },    /**     * Returns the number of Records held in the RecordSet.     *     * @method getLength     * @return {Number} Number of records in the RecordSet.     */    getLength : function() {            //return this._length;            return this._records.length;    },    /**     * Returns Record by ID or RecordSet position index.     *     * @method getRecord     * @param record {YAHOO.widget.Record | Number | String} Record instance,     * RecordSet position index, or Record ID.     * @return {YAHOO.widget.Record} Record object.     */    getRecord : function(record) {        var i;        if(record instanceof widget.Record) {            for(i=0; i<this._records.length; i++) {                if(this._records[i] && (this._records[i]._sId === record._sId)) {                    return record;                }            }        }        else if(lang.isNumber(record)) {            if((record > -1) && (record < this.getLength())) {                return this._records[record];            }        }        else if(lang.isString(record)) {            for(i=0; i<this._records.length; i++) {                if(this._records[i] && (this._records[i]._sId === record)) {                    return this._records[i];                }            }        }        // Not a valid Record for this RecordSet        return null;    },    /**     * Returns an array of Records from the RecordSet.     *     * @method getRecords     * @param index {Number} (optional) Recordset position index of which Record to     * start at.     * @param range {Number} (optional) Number of Records to get.     * @return {YAHOO.widget.Record[]} Array of Records starting at given index and     * length equal to given range. If index is not given, all Records are returned.     */    getRecords : function(index, range) {        if(!lang.isNumber(index)) {            return this._records;        }        if(!lang.isNumber(range)) {            return this._records.slice(index);        }        return this._records.slice(index, index+range);    },    /**     * Returns a boolean indicating whether Records exist in the RecordSet at the     * specified index range.  Returns true if and only if a Record exists at each     * index in the range.     * @method hasRecords     * @param index     * @param range     * @return {Boolean} true if all indices are populated in the RecordSet     */    hasRecords : function (index, range) {        var recs = this.getRecords(index,range);        for (var i = 0; i < range; ++i) {            if (typeof recs[i] === 'undefined') {                return false;            }        }        return true;    },    /**     * Returns current position index for the given Record.     *     * @method getRecordIndex     * @param oRecord {YAHOO.widget.Record} Record instance.     * @return {Number} Record's RecordSet position index.     */    getRecordIndex : function(oRecord) {        if(oRecord) {            for(var i=this._records.length-1; i>-1; i--) {                if(this._records[i] && oRecord.getId() === this._records[i].getId()) {                    return i;                }            }        }        return null;    },    /**     * Adds one Record to the RecordSet at the given index. If index is null,     * then adds the Record to the end of the RecordSet.     *     * @method addRecord     * @param oData {Object} An object literal of data.     * @param index {Number} (optional) Position index.     * @return {YAHOO.widget.Record} A Record instance.     */    addRecord : function(oData, index) {        if(lang.isObject(oData)) {            var oRecord = this._addRecord(oData, index);            this.fireEvent("recordAddEvent",{record:oRecord,data:oData});            YAHOO.log("Added Record at index " + index +                    " with data " + lang.dump(oData), "info", this.toString());            return oRecord;        }        else {            YAHOO.log("Could not add Record with data" +                    lang.dump(oData), "info", this.toString());            return null;        }    },    /**     * Adds multiple Records at once to the RecordSet at the given index with the     * given object literal data. If index is null, then the new Records are     * added to the end of the RecordSet.     *     * @method addRecords     * @param aData {Object[]} An object literal data or an array of data object literals.     * @param index {Number} (optional) Position index.     * @return {YAHOO.widget.Record[]} An array of Record instances.     */    addRecords : function(aData, index) {        if(lang.isArray(aData)) {            var newRecords = [],                idx,i,len;            index = lang.isNumber(index) ? index : this._records.length;            idx = index;            // Can't go backwards bc we need to preserve order            for(i=0,len=aData.length; i<len; ++i) {                if(lang.isObject(aData[i])) {                    var record = this._addRecord(aData[i], idx++);                    newRecords.push(record);                }           }            this.fireEvent("recordsAddEvent",{records:newRecords,data:aData});            YAHOO.log("Added " + newRecords.length + " Record(s) at index " + index +                    " with data " + lang.dump(aData), "info", this.toString());           return newRecords;        }        else if(lang.isObject(aData)) {            var oRecord = this._addRecord(aData);            this.fireEvent("recordsAddEvent",{records:[oRecord],data:aData});            YAHOO.log("Added 1 Record at index " + index +                    " with data " + lang.dump(aData), "info", this.toString());            return oRecord;        }        else {            YAHOO.log("Could not add Records with data " +                    lang.dump(aData), "info", this.toString());            return null;        }    },    /**     * Sets or replaces one Record to the RecordSet at the given index. Unlike     * addRecord, an existing Record at that index is not shifted to preserve it.     * If no index is specified, it adds the Record to the end of the RecordSet.     *     * @method setRecord     * @param oData {Object} An object literal of data.     * @param index {Number} (optional) Position index.     * @return {YAHOO.widget.Record} A Record instance.     */    setRecord : function(oData, index) {        if(lang.isObject(oData)) {            var oRecord = this._setRecord(oData, index);            this.fireEvent("recordSetEvent",{record:oRecord,data:oData});            YAHOO.

⌨️ 快捷键说明

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