# HG changeset patch # User Sylvain Thenault # Date 1231341165 -3600 # Node ID ebe40a8c7cc9e3e62e56c1a34efef249c61a8bfb # Parent 2e48b50ce635734d29ef6e25ead68525657d9544 deprecated code diff -r 2e48b50ce635 -r ebe40a8c7cc9 web/data/cubicweb.sortable.js --- a/web/data/cubicweb.sortable.js Wed Jan 07 15:37:04 2009 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,249 +0,0 @@ -/* Adapted from MochiKit's example to use custom cubicweb attribute - and a stable sort (merge sort) instead of default's js array sort - -merge sort JS implementation was found here : -http://en.literateprograms.org/Merge_sort_(JavaScript) - - -On page load, the SortableManager: - -- Finds the table by its id (sortable_table). -- Parses its thead for columns with a "mochi:format" attribute. -- Parses the data out of the tbody based upon information given in the - "cubicweb:sorvalue" attribute, and clones the tr elements for later re-use. -- Clones the column header th elements for use as a template when drawing - sort arrow columns. -- Stores away a reference to the tbody, as it will be replaced on each sort. - -On sort request: - -- Sorts the data based on the given key and direction -- Creates a new tbody from the rows in the new ordering -- Replaces the column header th elements with clickable versions, adding an - indicator (↑ or ↓) to the most recently sorted column. - -*/ - -//************** merge sort implementation ***************// -Sortable = {} - -Sortable.msort = function(array, begin, end, cmpfunc) { - var size=end-begin; - if(size<2) return; - - var begin_right=begin+Math.floor(size/2); - - Sortable.msort(array, begin, begin_right, cmpfunc); - Sortable.msort(array, begin_right, end, cmpfunc); - Sortable.merge(array, begin, begin_right, end, cmpfunc); -} - -Sortable.merge_sort = function(array, cmpfunc) { - Sortable.msort(array, 0, array.length, cmpfunc); -} - -Sortable.merge = function(array, begin, begin_right, end, cmpfunc) { - for(;begin array[begin_right] - if(cmpfunc(array[begin], array[begin_right]) == 1) { - var v = array[begin]; - array[begin] = array[begin_right]; - Sortable.insert(array, begin_right, end, v, cmpfunc); - } - } -} - -Array.prototype.swap=function(a, b) { - var tmp = this[a]; - this[a] = this[b]; - this[b] = tmp; -} - - -Sortable.insert = function(array, begin, end, v, cmpfunc) { - // while(begin+1