datatable-sort.js revision a3b15d60042c81a524cebb94370e5a234a19d04b
1472N/A * Plugs DataTable with sorting functionality. 220N/A * @submodule datatable-sort 220N/A * Adds column sorting to DataTable. 1472N/A TEMPLATE =
'<a class="{link_class}" title="{link_title}" href="{link_href}">{value}</a>';
220N/A///////////////////////////////////////////////////////////////////////////// 220N/A///////////////////////////////////////////////////////////////////////////// 220N/A * The namespace for the plugin. This will be the property on the host which 220N/A * references the plugin instance. 220N/A * @value "dataTableSort" 220N/A///////////////////////////////////////////////////////////////////////////// 220N/A///////////////////////////////////////////////////////////////////////////// 220N/A * @description Defines the trigger that causes a column to be sorted: 220N/A * {event, selector}, where "event" is an event type and "selector" is 220N/A * is a node query selector. 220N/A * @default {event:"click", selector:"th"} 220N/A * @writeOnce "initOnly" 220N/A * @attribute lastSortedBy 220N/A * @description Describes last known sort state: {key,dir}, where 220N/A * "key" is column key and "dir" is either "asc" or "desc". 220N/A * @description Tokenized markup template for TH sort element. 220N/A * @default '<a class="{link_class}" title="{link_title}" href="{link_href}">{value}</a>' 220N/A * Strings used in the UI elements. 220N/A * The strings used are defaulted from the datatable-sort language pack 220N/A * for the language identified in the YUI "lang" configuration (which 220N/A * Configurable strings are "sortBy" and "reverseSortBy", which are 220N/A * assigned to the sort link's title attribute. 220N/A///////////////////////////////////////////////////////////////////////////// 220N/A///////////////////////////////////////////////////////////////////////////// 220N/A ///////////////////////////////////////////////////////////////////////////// 220N/A ///////////////////////////////////////////////////////////////////////////// 220N/A * @param config {Object} Config object. 220N/A // Wrap link around TH value 220N/A // Attach trigger handlers 220N/A this.
on(
"lastSortedByChange",
function(e) {
220N/A //dt.after("recordset:mutation", function() {//reset lastSortedBy}); 220N/A //add Column sortFn ATTR 220N/A // Update UI after the fact (render-then-plug case) 220N/A * @method _setLastSortedBy 220N/A * @description Normalizes lastSortedBy 220N/A * @param val {String | Object} {key, dir} or "key" 220N/A * @return {key, dir, notdir} 220N/A * @method _uiSetLastSortedBy 220N/A * @param val {Object} New lastSortedBy object {key,dir}. 220N/A * @param dt {Y.DataTable.Base} Host. 220N/A * Before header cell element is created, inserts link markup around {value}. 220N/A * @method _beforeCreateTheadThNode 220N/A * @param o {Object} {value, column, tr}. 220N/A "reverseSortBy" :
"sortBy";
220N/A * Before header cell element is attached, sets applicable class names. 220N/A * @method _beforeAttachTheadThNode 220N/A * @param o {Object} {value, column, tr}. 220N/A // This Column is sortable 220N/A // This Column is currently sorted 220N/A * Before header cell element is attached, sets applicable class names. 220N/A * @method _beforeAttachTbodyTdNode 220N/A * @param o {Object} {record, column, tr, headers, classnames, value}. 220N/A // This Column is sortable 220N/A // This Column is currently sorted 220N/A * In response to the "trigger" event, sorts the underlying Recordset and 220N/A * updates the lastSortedBy attribute. 220N/A * @method _onEventSortColumn 220N/A * @param o {Object} {value, column, tr}. 220N/A //TODO: normalize e.currentTarget to TH