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