Go to the source code of this file.
Functions | |
function | dean_addEvent (element, type, handler) |
function | fixEvent (event) |
function | handleEvent (event) |
function | removeEvent (element, type, handler) |
Variables | |
String | forEach |
dean_addEvent | guid = 1 |
fixEvent | preventDefault |
sorttable | |
var | stIsIE = false |
SortTable version 2 7th April 2007 Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/. | |
fixEvent | stopPropagation |
function dean_addEvent | ( | element, | |
type, | |||
handler | |||
) |
Definition at line 396 of file sorttable.js.
References handleEvent(), and type.
{ if (element.addEventListener) { element.addEventListener(type, handler, false); } else { // assign each event handler a unique ID if (!handler.$$guid) handler.$$guid = dean_addEvent.guid++; // create a hash table of event types for the element if (!element.events) element.events = {}; // create a hash table of event handlers for each element/event pair var handlers = element.events[type]; if (!handlers) { handlers = element.events[type] = {}; // store the existing event handler (if there is one) if (element["on" + type]) { handlers[0] = element["on" + type]; } } // store the event handler in the hash table handlers[handler.$$guid] = handler; // assign a global event handler to do all the work element["on" + type] = handleEvent; } };
function fixEvent | ( | event | ) |
Definition at line 449 of file sorttable.js.
Referenced by handleEvent().
function handleEvent | ( | event | ) |
Definition at line 433 of file sorttable.js.
References fixEvent().
Referenced by dean_addEvent().
{ var returnValue = true; // grab the event object (IE uses a global event object) event = event || fixEvent(((this.ownerDocument || this.document || this).parentWindow || window).event); // get a reference to the hash table of event handlers var handlers = this.events[event.type]; // execute each event handler for (var i in handlers) { this.$$handleEvent = handlers[i]; if (this.$$handleEvent(event) === false) { returnValue = false; } } return returnValue; };
function removeEvent | ( | element, | |
type, | |||
handler | |||
) |
Definition at line 422 of file sorttable.js.
References type.
var forEach |
function(string, block, context) { Array.forEach(string.split(""), function(chr, index) { block.call(context, chr, index, string); }); }
Definition at line 488 of file sorttable.js.
dean_addEvent guid = 1 |
Definition at line 420 of file sorttable.js.
function() { this.returnValue = false; }
Definition at line 455 of file sorttable.js.
Definition at line 41 of file sorttable.js.
Referenced by ask_navigator(), and boxsearch_card().
SortTable version 2 7th April 2007 Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/.
Instructions: Download this file Add <script src="sorttable.js"></script> to your HTML Add class="sortable" to any table you'd like to make sortable Click on the headers to sort
Thanks to many, many people for contributions and suggestions. Licenced as X11: http://www.kryogenix.org/code/browser/licence.html This basically means: do what you want with it.
Show the default order example:
....
.... ▾
Sort on date
// format YYYYMMDD
force as numeric (normally useless):
Part number
To avoid the sort on the last row, use tfoot
Definition at line 39 of file sorttable.js.
function() { this.cancelBubble = true; } if (!Array.forEach) { Array.forEach = function(array, block, context) { for (var i = 0; i < array.length; i++) { block.call(context, array[i], i, array); } }; } Function.prototype.forEach = function(object, block, context) { for (var key in object) { if (typeof this.prototype[key] == "undefined") { block.call(context, object[key], key, object); } } }
Definition at line 458 of file sorttable.js.