datatable-base-debug.js revision 5770dec23508300b0e77edf1fd63b699b89e4615
3998N/A TEMPLATE_TH =
'<th id="{id}" rowspan="{rowspan}" colspan="{colspan}" class="{classnames}" abbr="{abbr}"><div class="'+
CLASS_LINER+
'">{value}</div></th>',
2521N/A * The Column class defines and manages attributes of Columns for DataTable. 2892N/A///////////////////////////////////////////////////////////////////////////// 2892N/A///////////////////////////////////////////////////////////////////////////// 2521N/A///////////////////////////////////////////////////////////////////////////// 2521N/A///////////////////////////////////////////////////////////////////////////// 2521N/A * @description Unique internal identifier, used to stamp ID on TH element. 2521N/A * @description User-supplied identifier. Defaults to id. 3998N/A * @description Points to underlying data field (for sorting or formatting, 3998N/A * for example). Useful when column doesn't hold any data itself, but is 2521N/A * just a visual representation of data from another column or record field. 2521N/A * @description Display label for column header. Defaults to key. 2521N/A * @description Array of child column definitions (for nested headers). 2521N/A * @description TH abbr attribute. 2521N/A //TODO: support custom classnames 2521N/A //sortOptions:defaultDir, sortFn, field 2521N/A //TODO: support editable columns 2521N/A //TODO: support resizeable columns 2521N/A //TODO: support setting widths 2892N/A // requires datatable-colresize 2521N/A///////////////////////////////////////////////////////////////////////////// 2892N/A///////////////////////////////////////////////////////////////////////////// 2892N/A ///////////////////////////////////////////////////////////////////////////// 3998N/A ///////////////////////////////////////////////////////////////////////////// 2925N/A * @description Return ID for instance. 3998N/A * @description Return key for instance. Defaults to ID if one was not 3998N/A * @description Return field for instance. Defaults to key if one was not 3998N/A * @description Return label for instance. Defaults to key if one was not 2892N/A * Updates the UI if changes are made to abbr. 2892N/A * @param e {Event} Custom event for the attribute change. 2892N/A ///////////////////////////////////////////////////////////////////////////// 3998N/A ///////////////////////////////////////////////////////////////////////////// 3998N/A * Reference to Column's current position index within its Columnset's keys 3998N/A * array, if applicable. This property only applies to non-nested and bottom- 3998N/A * level child Columns. Value is set by Columnset code. 3998N/A * @description Array of TH IDs associated with this column, for TD "headers" 3998N/A * attribute. Value is set by Columnset code 2521N/A * Number of cells the header spans. Value is set by Columnset code. 2521N/A * Number of rows the header spans. Value is set by Columnset code. 2892N/A * Column's parent Column instance, if applicable. Value is set by Columnset 2892N/A * The Node reference to the associated TH element. 2892N/A * The Node reference to the associated liner element. 3998N/A ///////////////////////////////////////////////////////////////////////////// 2892N/A ///////////////////////////////////////////////////////////////////////////// 2892N/A * @param config {Object} Config object. 2521N/A * Returns classnames for Column. 2521N/A if(lang.isString(oColumn.className)) { 2521N/A allClasses = [oColumn.className]; 2521N/A else if(lang.isArray(oColumn.className)) { 2521N/A allClasses = oColumn.className; 2892N/A // Hook for setting width with via dynamic style uses key since ID is too disposable 2521N/A allClasses[allClasses.length] = this.getId() + "-col-" +oColumn.getSanitizedKey(); 2521N/A // Column key - minus any chars other than "A-Z", "a-z", "0-9", "_", "-", ".", or ":" 2521N/A allClasses[allClasses.length] = "yui-dt-col-" +oColumn.getSanitizedKey(); 2892N/A var isSortedBy = this.get("sortedBy") || {}; 2892N/A if(oColumn.key === isSortedBy.key) { 2892N/A allClasses[allClasses.length] = isSortedBy.dir || ''; 2521N/A allClasses[allClasses.length] = DT.CLASS_HIDDEN; 2521N/A allClasses[allClasses.length] = DT.CLASS_SELECTED; 2892N/A allClasses[allClasses.length] = DT.CLASS_SORTABLE; 2892N/A allClasses[allClasses.length] = DT.CLASS_RESIZEABLE; 2892N/A allClasses[allClasses.length] = DT.CLASS_EDITABLE; 2892N/A allClasses = allClasses.concat(aAddClasses); 2892N/A return allClasses.join(' ');*/ 2892N/A //////////////////////////////////////////////////////////////////////////// 2892N/A //////////////////////////////////////////////////////////////////////////// 2892N/A * Syncs UI to intial state. 2892N/A * @param val {String} New abbr. 3998N/A * The Columnset class defines and manages a collection of Columns. 2892N/A///////////////////////////////////////////////////////////////////////////// 2892N/A///////////////////////////////////////////////////////////////////////////// 2892N/A ///////////////////////////////////////////////////////////////////////////// 2892N/A ///////////////////////////////////////////////////////////////////////////// 2892N/A * @description Array of column definitions that will populate this Columnset. 2892N/A///////////////////////////////////////////////////////////////////////////// 2892N/A///////////////////////////////////////////////////////////////////////////// 2892N/A ///////////////////////////////////////////////////////////////////////////// 2892N/A ///////////////////////////////////////////////////////////////////////////// 2892N/A * @description Clones definitions before setting. 2892N/A * @param definitions {Array} Array of column definitions. 2892N/A ///////////////////////////////////////////////////////////////////////////// 2892N/A ///////////////////////////////////////////////////////////////////////////// 2892N/A * Top-down tree representation of Column hierarchy. Used to create DOM 2892N/A * Hash of all Columns by ID. 2892N/A * Hash of all Columns by key. 2892N/A * Array of only Columns that are meant to be displayed in DOM. 2892N/A ///////////////////////////////////////////////////////////////////////////// 2892N/A ///////////////////////////////////////////////////////////////////////////// 3998N/A * Initializer. Generates all internal representations of the collection of 3998N/A * @param config {Object} Config object. 3998N/A // DOM tree representation of all Columns 3998N/A // Hash of all Columns by ID 3998N/A // Hash of all Columns by key 3998N/A // Flat representation of only Columns that are meant to display data 3998N/A // Internal recursive function to define Column instances // Create corresponding dom node if not already there for this depth // Parse each node at this depth for attributes and any children // Instantiate a new Column for each node // Cross-reference Column ID back to the original object literal definition // Add the new Column to the hash // Assign its parent as an attribute, if applicable // The Column has descendants // The children themselves must also be parsed for Column instances // This Column does not have any children // Add the Column to the top-down dom tree // Parse out Column instances from the array of object literals // Save to the Columnset instance ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// * Cascade certain properties to children if not defined on their own. * @method _cascadePropertiesToChildren //TODO: this is all a giant todo // Cascade certain properties to children if not defined on their own * @description Calculates and sets colSpan attribute on given Column. * @param column {Array} Column instance. * @param definition {Object} Column definition. // Determine COLSPAN value for this Column // Drill down each branch and count terminal nodes // Reached branch terminus * @description Calculates and sets rowSpan attribute on all Columns. // Determine ROWSPAN value for each Column in the DOM tree // Calculate the max depth of descendants for this row // Column has children, so keep counting // Column has children, so keep counting // No children, is it the max depth? // Count max row depth for each row // Assign the right ROWSPAN values to each Column in the row // else currentColumn.rowSpan =1; // Reset counter for next row * @description Calculates and sets headers attribute on all Columns. * The DataTable widget provides a progressively enhanced DHTML control for * displaying tabular data across A-grade browsers. * Provides the base DataTable implementation, which can be extended to add * additional functionality, such as sorting or scrolling. * @submodule datatable-base * Base class for the DataTable widget. ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// * @description Pointer to Columnset instance. * @type Array | Y.Columnset * @description Pointer to Recordset instance. * @type Array | Y.Recordset * @description Internal state. * @attribute thValueTemplate * @description Tokenized markup template for TH value. * @attribute tdValueTemplate * @description Tokenized markup template for TD value. * @description Tokenized markup template for TR node creation. * @default '<tr id="{id}"></tr>' ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// /*caption: function (srcNode) { ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// * @description Tokenized markup template for TH node creation. * @default '<th id="{id}" rowspan="{rowspan}" colspan="{colspan}" class="{classnames}" abbr="{abbr}"><div class="'+CLASS_LINER+'">{value}</div></th>' * @description Tokenized markup template for TD node creation. * @default '<td headers="{headers}"><div class="'+CLASS_LINER+'">{value}</div></td>' * @description Pointer to THEAD node. * @description Pointer to TBODY node. * @description Pointer to message display node. ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// * @description Converts Array to Y.Columnset. * @param columns {Array | Y.Columnset} * Updates the UI if Columnset is changed. * @method _afterColumnsetChange * @param e {Event} Custom event for the attribute change. * @description Converts Array to Y.Recordset. * @param records {Array | Y.Recordset} * Updates the UI if Recordset is changed. * @method _afterRecordsetChange * @param e {Event} Custom event for the attribute change. * Updates the UI if Recordset records are changed. * @method _afterRecordsChange * @param e {Event} Custom event for the attribute change. * Updates the UI if summary is changed. * @method _afterSummaryChange * @param e {Event} Custom event for the attribute change. * Updates the UI if caption is changed. * @method _afterCaptionChange * @param e {Event} Custom event for the attribute change. //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// * Creates and attaches TABLE element to given container. * @param containerNode {Node} Parent node. * Creates and attaches COLGROUP element to given TABLE. * @method _addColgroupNode * @param tableNode {Node} Parent node. // Add COLs to DOCUMENT FRAGMENT * Creates and attaches THEAD element to given container. * @param tableNode {Node} Parent node. * Creates and attaches TBODY element to given container. * @param tableNode {Node} Parent node. * Creates and attaches message display element to given container. * @method _addMessageNode * @param tableNode {Node} Parent node. * Creates and attaches CAPTION element to given container. * @method _addCaptionNode * @param tableNode {Node} Parent node. //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //TODO: is this necessary? //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// * Syncs UI to intial state. * @param val {String} New summary. * @param val {String} New caption. // prepend of remove necessary //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// * @method _uiSetColumnset * @param cs {Columnset} New Columnset. // Iterate tree of columns to add THEAD rows // Column helpers needs _theadNode to exist //this._createColumnHelpers(); // Re-attach THEAD to DOM * Creates and attaches header row element. * @method _addTheadTrNode * @param o {Object} {thead, columns}. * @param isFirst {Boolean} Is first row. * @param isFirst {Boolean} Is last row. * Creates header row element. * @method _createTheadTrNode * @param o {Object} {thead, columns}. * @param isFirst {Boolean} Is first row. * @param isLast {Boolean} Is last row. //TODO: custom classnames * Attaches header row element. * @method _attachTheadTrNode * @param o {Object} {thead, columns, tr}. * Creates and attaches header cell element. * @method _addTheadThNode * @param o {Object} {value, column, tr}. //TODO: assign all node pointers: thNode, thLinerNode, thLabelNode * Creates header cell element. * @method _createTheadThNode * @param o {Object} {value, column, tr}. // Populate template object o.
id =
column.
get(
"id");
//TODO: validate 1 column ID per document // Clear minWidth on hidden Columns if(column.get("hidden")) { //this._clearMinWidth(column); * Attaches header cell element. * @method _attachTheadThNode * @param o {Object} {value, column, tr}. //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// * @method _uiSetRecordset * @param rs {Recordset} New Recordset. // Replace TBODY with a new one // Build up column data to avoid passing through Attribute APIs inside // render loops for rows and cells // Convert non-function formatters into functions // String formatters are treated as alternate value templates // Any other value for formatter is ignored, falling back to // to the configured tdValueTemplate attribute value. // Iterate Recordset to use existing TR when possible or add new TR // TODO i = this.get("state.offsetIndex") // TODO len =this.get("state.pageLength") * Creates and attaches data row element. * @method _addTbodyTrNode * @param o {Object} {tbody, record} * Creates data row element. * @method _createTbodyTrNode * @param o {Object} {tbody, record} * Attaches data row element. * @method _attachTbodyTrNode * @param o {Object} {tbody, record, tr}. * Creates and attaches data cell element. * @method _addTbodyTdNode * @param o {Object} {record, column, tr}. * Creates data cell element. * @method _createTbodyTdNode * @param o {Object} {record, column, tr}. * Attaches data cell element. * @method _attachTbodyTdNode * @param o {Object} {record, column, tr, headers, classnames, value}. * Returns markup to insert into data cell element. * @param @param o {Object} {record, column, tr, headers, classnames}. },
'@VERSION@' ,{
requires:[
'recordset-base',
'widget',
'substitute',
'event-mouseenter']});