merge
authorSandrine Ribeau <sandrine.ribeau@logilab.fr>
Wed, 07 Jan 2009 11:36:16 -0800
changeset 359 164307023401
parent 358 e7347a1e3659 (current diff)
parent 357 e1ba696130da (diff)
child 360 600dd2fe8b40
child 362 a6a319f000c3
merge
web/data/cubicweb.sortable.js
--- a/common/test/unittest_uilib.py	Wed Jan 07 11:35:31 2009 -0800
+++ b/common/test/unittest_uilib.py	Wed Jan 07 11:36:16 2009 -0800
@@ -22,112 +22,54 @@
             got = uilib.remove_html_tags(text)
             self.assertEquals(got, expected)
        
-    def test_safe_cut(self):
-        """ tests uilib.safe_cut() behaviour with very long text"""
+    def test_fallback_safe_cut(self):
+        self.assertEquals(uilib.fallback_safe_cut(u'ab <a href="hello">cd</a>', 4), u'ab c...')
+        self.assertEquals(uilib.fallback_safe_cut(u'ab <a href="hello">cd</a>', 5), u'ab <a href="hello">cd</a>')
+        self.assertEquals(uilib.fallback_safe_cut(u'ab <a href="hello">&amp;d</a>', 4), u'ab &amp;...')
+        self.assertEquals(uilib.fallback_safe_cut(u'ab <a href="hello">&amp;d</a> ef', 5), u'ab &amp;d...')
+        self.assertEquals(uilib.fallback_safe_cut(u'&amp; <a href="hello">&amp;d</a> ef', 4), u'&amp; &amp;d...')
         
-        data = [
-            ('opkolk', '<div><p>opkolk</p></div>'),
-            ("""<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
- tempor incididunt <strong>ut</strong> labore et dolore magna aliqua. Ut enim ad minim veniam,
- quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
- consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
- cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
- proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
- Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
- tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
- quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
- consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
- cillum dolore eu fugiat nulla pariatur.</p> ""","""<div><p>Lorem ipsum dolor sit amet, consectetur</p></div>"""),
-            ("""<p>empor incididunt utlabore et dolore magna aliqua. Ut enim ad minim veniam,
-quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
-consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
-cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
-proident, sunt in culpa qui officia d</p>""","""<div><p>empor incididunt utlabore et dolore magna aliqua.</p></div>"""),
-            ("""empor <strong>incididunt</strong> utlabore et dolore magna aliqua. Ut enim ad minim veniam,
-quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
-consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
-cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
-proident, sunt in culpa qui officia""","""<div><p>empor <strong>incididunt</strong> utlabore et dolore magna aliqua.</p></div>"""),
-            ("""<p>Lorem <strong>ipsum</strong> dolor <it>sit</it> amet, <strong>consectetur</strong> adipisicing elit, sed do eiusmod
- tempor incididunt <strong>ut</strong> labore et dolore magna aliqua. Ut enim ad minim veniam,
- quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
- consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
- cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
- proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
- Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
- tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
- quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
- consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
- cillum dolore eu fugiat nulla pariatur.</p>""","""<div><p>Lorem <strong>ipsum</strong> dolor <it>sit</it> amet, <strong>consectetur</strong></p></div>"""),
-            ("""&iexcl;""",u"""<div><p>\xa1</p></div>"""),
-            ("""<strong>&iexcl; &iexcl; &iexcl; &iexcl;</strong>""",
-             u"""<div><strong>\xa1 \xa1 \xa1 \xa1</strong></div>"""),
-            ("""<strong>&iexcl; &iexcl; &iexcl; &iexcl;</strong><strong>&iexcl; &iexcl; &iexcl; &iexcl;</strong><strong>&iexcl; &iexcl; &iexcl; &iexcl;</strong><strong>&iexcl; &iexcl; &iexcl; &iexcl;</strong><strong>&iexcl; &iexcl; &iexcl; &iexcl;</strong><strong>&iexcl; &iexcl; &iexcl; &iexcl;</strong><strong>&iexcl; &iexcl; &iexcl; &iexcl;</strong><strong>&iexcl; &iexcl; &iexcl; &iexcl;</strong><strong>&iexcl; &iexcl; &iexcl; &iexcl;</strong><strong>&iexcl; &iexcl; &iexcl; &iexcl;</strong><strong>&iexcl; &iexcl; &iexcl; &iexcl;</strong><strong>&iexcl; &iexcl; &iexcl; &iexcl;</strong><strong>&iexcl; &iexcl; &iexcl; &iexcl;</strong><strong>&iexcl; &iexcl; &iexcl; &iexcl;</strong>""",
-             u"""<div><strong>\xa1 \xa1 \xa1 \xa1</strong><strong>\xa1 \xa1 \xa1 \xa1</strong><strong>\xa1 \xa1 \xa1 \xa1</strong><strong>\xa1 \xa1 \xa1 \xa1</strong><strong>\xa1 \xa1 \xa1 \xa1</strong><strong>\xa1 \xa1 \xa1 \xa1</strong><strong>\xa1 \xa1 \xa1 \xa1</strong><strong>\xa1 \xa1 \xa1 \xa1</strong></div>"""),
-                      
-                       
-            ]
-        for text, expected in data:
-            got = uilib.safe_cut(text, 30)
-            self.assertEquals(got, expected)
+    def test_lxml_safe_cut(self):
+        self.assertEquals(uilib.safe_cut(u'aaa<div>aaad</div> ef', 4), u'<p>aaa</p><div>a...</div>')
+        self.assertEquals(uilib.safe_cut(u'aaa<div>aaad</div> ef', 7), u'<p>aaa</p><div>aaad</div>...')
+        self.assertEquals(uilib.safe_cut(u'aaa<div>aaad</div>', 7), u'<p>aaa</p><div>aaad</div>')
+        # Missing ellipsis due to space management but we don't care
+        self.assertEquals(uilib.safe_cut(u'ab <a href="hello">&amp;d</a>', 4), u'<p>ab <a href="hello">&amp;...</a></p>')
 
     def test_cut(self):
         """tests uilib.cut() behaviour"""
         data = [
             ('hello', 'hello'),
-            ('hello world', 'hello...'),
-            ("hell<b>O'</b> world", "hell<..."),
+            ('hello world', 'hello wo...'),
+            ("hell<b>O'</b> world", "hell<b>O..."),
             ]
         for text, expected in data:
             got = uilib.cut(text, 8)
             self.assertEquals(got, expected)
 
-    def test_text_cut_no_text(self):
+    def test_text_cut(self):
         """tests uilib.text_cut() behaviour with no text"""
-        data = [('','')]
-        for text, expected in data:
-            got = uilib.text_cut(text, 8)
-            self.assertEquals(got, expected)
-
-    def test_text_cut_long_text(self):
-        """tests uilib.text_cut() behaviour with long text"""
-        data = [("""Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
+        data = [('',''),
+                ("""Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
 tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
 quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
 consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
-cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
-proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
-Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
-tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
-quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
-consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
-cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
-proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
-""","""Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
-tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
-quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
-consequat.""")]
-        for text, expected in data:
-            got = uilib.text_cut(text, 30)
-            self.assertEquals(got, expected)
-
-    def  test_text_cut_no_point(self):
-        """tests uilib.text_cut() behaviour with no point"""
-        data = [("""Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
+cillum dolore eu fugiat nulla pariatur.""",
+                 "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod \
+tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, \
+quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo \
+consequat."),
+                ("""Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
 tempor incididunt ut labore et dolore magna aliqua Ut enim ad minim veniam,
 quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
 consequat Duis aute irure dolor in reprehenderit in voluptate velit esse
 cillum dolore eu fugiat nulla pariatur Excepteur sint occaecat cupidatat non
 proident, sunt in culpa qui officia deserunt mollit anim id est laborum
-Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
-tempor incididunt ut labore et dolore magna aliqua Ut enim ad minim veniam,
-quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
-consequat Duis aute irure dolor in reprehenderit in voluptate velit esse
-cillum dolore eu fugiat nulla pariatur Excepteur sint occaecat cupidatat non
-proident, sunt in culpa qui officia deserunt mollit anim id est laborum
-""","""Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
-tempor incididunt ut labore et dolore magna aliqua Ut enim ad minim veniam,
-quis nostrud exercitation ullamco laboris nisi""")]
+""",
+                 "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod \
+tempor incididunt ut labore et dolore magna aliqua Ut enim ad minim veniam, \
+quis nostrud exercitation ullamco laboris nisi"),
+                ]
         for text, expected in data:
             got = uilib.text_cut(text, 30)
             self.assertEquals(got, expected)
--- a/common/uilib.py	Wed Jan 07 11:35:31 2009 -0800
+++ b/common/uilib.py	Wed Jan 07 11:36:16 2009 -0800
@@ -15,7 +15,7 @@
 import re
 from urllib import quote as urlquote
 from cStringIO import StringIO
-from xml.parsers.expat import ExpatError
+from xml.sax.saxutils import unescape
 from copy import deepcopy
 
 import simplejson
@@ -23,6 +23,7 @@
 from mx.DateTime import DateTimeType, DateTimeDeltaType
 
 from logilab.common.textutils import unormalize
+from logilab.mtconverter import html_escape
 
 def ustrftime(date, fmt='%Y-%m-%d'):
     """like strftime, but returns a unicode string instead of an encoded
@@ -116,12 +117,15 @@
     tags from given text if cut is necessary."""
     if text is None:
         return u''
-    text_nohtml = remove_html_tags(text)
+    noenttext = unescape(text)
+    text_nohtml = remove_html_tags(noenttext)
     # try to keep html tags if text is short enough
     if len(text_nohtml) <= length:
         return text
     # else if un-tagged text is too long, cut it
-    return text_nohtml[:length-3] + u'...'
+    return html_escape(text_nohtml[:length] + u'...')
+
+fallback_safe_cut = safe_cut
 
 
 try:
@@ -152,40 +156,64 @@
             """
             if text is None:
                 return u''
-            textParse = etree.HTML(text)
-            compteur = 0
-
-            for element in textParse.iter():
-                if compteur > length:
+            dom = etree.HTML(text)
+            curlength = 0
+            add_ellipsis = False
+            for element in dom.iter():
+                if curlength >= length:
                     parent = element.getparent()
                     parent.remove(element)
+                    if curlength == length and (element.text or element.tail):
+                        add_ellipsis = True
                 else:
                     if element.text is not None:
-                        text_resum = text_cut_letters(element.text,length)
-                        len_text_resum = len(''.join(text_resum.split()))
-                        compteur = compteur + len_text_resum
-                        element.text = text_resum
-
+                        element.text = cut(element.text, length - curlength)
+                        curlength += len(element.text)
                     if element.tail is not None:
-                        if compteur < length:
-                            text_resum = text_cut_letters(element.tail,length)
-                            len_text_resum = len(''.join(text_resum.split()))
-                            compteur = compteur + len_text_resum
-                            element.tail = text_resum
+                        if curlength < length:
+                            element.tail = cut(element.tail, length - curlength)
+                            curlength += len(element.tail)
+                        elif curlength == length:
+                            element.tail = '...'
                         else:
                             element.tail = ''
+            text = etree.tounicode(dom[0])[6:-7] # remove wrapping <body></body>
+            if add_ellipsis:
+                return text + u'...'
+            return text
+        
+def text_cut(text, nbwords=30):
+    """from the given plain text, return a text with at least <nbwords> words,
+    trying to go to the end of the current sentence.
 
-            div = etree.HTML('<div></div>')[0][0]
-            listNode = textParse[0].getchildren()
-            for node in listNode:
-                div.append(deepcopy(node))
-            return etree.tounicode(div)
+    Note that spaces are normalized.
+    """
+    if text is None:
+        return u''
+    words = text.split()
+    text = ' '.join(words) # normalize spaces
+    minlength = len(' '.join(words[:nbwords]))
+    textlength = text.find('.', minlength) + 1
+    if textlength == 0: # no point found
+        textlength = minlength 
+    return text[:textlength]
+
+def cut(text, length):
+    """returns a string of a maximum length <length> based on <text>
+    (approximatively, since if text has been  cut, '...' is added to the end of the string,
+    resulting in a string of len <length> + 3)
+    """
+    if text is None:
+        return u''
+    if len(text) <= length:
+        return text
+    # else if un-tagged text is too long, cut it
+    return text[:length] + u'...'
+
 
     
 # HTML generation helper functions ############################################
 
-from logilab.mtconverter import html_escape
-
 def tooltipize(text, tooltip, url=None):
     """make an HTML tooltip"""
     url = url or '#'
@@ -221,41 +249,6 @@
         params.append('true')
     return "javascript: replacePageChunk(%s);" % ', '.join(params)
 
-def text_cut(text, nbwords=30):
-    if text is None:
-        return u''
-    minlength = len(' '.join(text.split()[:nbwords]))
-    textlength = text.find('.', minlength) + 1
-    if textlength == 0: # no point found
-        textlength = minlength 
-    return text[:textlength]
-
-def text_cut_letters(text, nbletters):
-    if text is None:
-        return u''
-    if len(''.join(text.split())) <= nbletters:
-           return text
-    else:
-        text_nospace = ''.join(text.split())
-        textlength=text.find('.') + 1
-
-        if textlength==0:
-           textlength=text.find(' ', nbletters+5)
-           
-        return text[:textlength] 
-
-def cut(text, length):
-    """returns a string of length <length> based on <text>
-    post:
-      len(__return__) <= length
-    """
-    if text is None:
-        return u''
-    if len(text) <= length:
-        return text
-    # else if un-tagged text is too long, cut it
-    return text[:length-3] + u'...'
-
 
 from StringIO import StringIO
 
--- a/doc/book/en/B1021-views-selectors.en.txt	Wed Jan 07 11:35:31 2009 -0800
+++ b/doc/book/en/B1021-views-selectors.en.txt	Wed Jan 07 11:36:16 2009 -0800
@@ -47,7 +47,7 @@
 *anonymous_user*
     This selector accepts if user is anonymous.
 
-*authencated_user*
+*authenticated_user*
     This selector accepts if user is authenticated.
 
 
--- a/web/data/cubicweb.sortable.js	Wed Jan 07 11:35:31 2009 -0800
+++ /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 (&uarr; or &darr;) 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<begin_right; ++begin) {
-	// if array[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<end && array[begin+1]<v) {
-    while(begin+1<end && cmpfunc(array[begin+1], v) == -1) {
-	array.swap(begin, begin+1);
-	++begin;
-    }
-    array[begin]=v;
-}
-
-//************** auto-sortable tables ***************//
-
-Sortable.SortableManager = function () {
-    this.thead = null;
-    this.tbody = null;
-    this.columns = [];
-    this.rows = [];
-    this.sortState = {};
-    this.sortkey = 0;
-};
-
-mouseOverFunc = function () {
-    addElementClass(this, "over");
-};
-
-mouseOutFunc = function () {
-    removeElementClass(this, "over");
-};
-
-Sortable.ignoreEvent = function (ev) {
-    if (ev && ev.preventDefault) {
-	ev.preventDefault();
-	ev.stopPropagation();
-    } else if (typeof(event) != 'undefined') {
-	event.cancelBubble = false;
-	event.returnValue = false;
-    }
-};
-
-
-Sortable.getTableHead = function(table) {
-    var thead = table.getElementsByTagName('thead')[0];
-    if ( !thead ) {
-	thead = table.getElementsByTagName('tr')[0];
-    }
-    return thead;
-}
-
-Sortable.getTableBody = function(table) {
-    var tbody = table.getElementsByTagName('tbody')[0];
-    if ( !tbody ) {
-	tobdy = table; // XXX
-    }
-    return tbody;
-}
-
-jQuery.extend(Sortable.SortableManager.prototype, {
-    
-    "initWithTable" : function (table) {
-	/***  Initialize the SortableManager with a table object  ***/
-	// Find the thead
-	this.thead = Sortable.getTableHead(table);
-	// get the mochi:format key and contents for each column header
-	var cols = this.thead.getElementsByTagName('th');
-	for (var i = 0; i < cols.length; i++) {
-	    var node = cols[i];
-	    var o = node.childNodes;
-	    node.onclick = this.onSortClick(i);
-	    node.onmousedown = Sortable.ignoreEvent;
-	    node.onmouseover = mouseOverFunc;
-	    node.onmouseout = mouseOutFunc;
-	    this.columns.push({
-		"element": node,
-		"proto": node.cloneNode(true)
-	    });
-	}
-	// scrape the tbody for data
-	this.tbody = Sortable.getTableBody(table);
-	// every row
-	var rows = this.tbody.getElementsByTagName('tr');
-	for (var i = 0; i < rows.length; i++) {
-	    // every cell
-	    var row = rows[i];
-	    var cols = row.getElementsByTagName('td');
-	    var rowData = [];
-	    for (var j = 0; j < cols.length; j++) {
-		// scrape the text and build the appropriate object out of it
-		var cell = cols[j];
-		rowData.push([evalJSON(cell.getAttribute('cubicweb:sortvalue'))]);
-	    }
-	    // stow away a reference to the TR and save it
-	    rowData.row = row.cloneNode(true);
-	    this.rows.push(rowData);
-	}
-	// do initial sort on first column
-	// this.drawSortedRows(null, true, false);
-
-    },
-
-    "onSortClick" : function (name) {
-	/*** Return a sort function for click events  ***/
-	return method(this, function () {
-	    var order = this.sortState[name];
-	    if (order == null) {
-		order = true;
-	    } else if (name == this.sortkey) {
-		order = !order;
-	    }
-	    this.drawSortedRows(name, order, true);
-	});
-    },
-    
-    "drawSortedRows" : function (key, forward, clicked) {
-	/***  Draw the new sorted table body, and modify the column headers
-              if appropriate
-         ***/
-	this.sortkey = key;
-	// sort based on the state given (forward or reverse)
-	var cmp = (forward ? keyComparator : reverseKeyComparator);
-	Sortable.merge_sort(this.rows, cmp(key));
-	
-	// save it so we can flip next time
-	this.sortState[key] = forward;
-	// get every "row" element from this.rows and make a new tbody
-	var newRows = [];
-	for (var i=0; i < this.rows.length; i++){
-	    var row = this.rows[i].row;
-	    if (i%2) {
-		removeElementClass(row, 'even');
-		addElementClass(row, 'odd');
-	    } else {
-		removeElementClass(row, 'odd');
-		addElementClass(row, 'even');
-	    }
-	    newRows.push(row);
-	}
-	// var newBody = TBODY(null, map(itemgetter("row"), this.rows));
-	var newBody = TBODY(null, newRows);
-	// swap in the new tbody
-	this.tbody = swapDOM(this.tbody, newBody);
-	for (var i = 0; i < this.columns.length; i++) {
-	    var col = this.columns[i];
-	    var node = col.proto.cloneNode(true);
-	    // remove the existing events to minimize IE leaks
-	    col.element.onclick = null;
-	    col.element.onmousedown = null;
-	    col.element.onmouseover = null;
-	    col.element.onmouseout = null;
-	    // set new events for the new node
-	    node.onclick = this.onSortClick(i);
-	    node.onmousedown = Sortable.ignoreEvent;
-	    node.onmouseover = mouseOverFunc;
-	    node.onmouseout = mouseOutFunc;
-	    // if this is the sorted column
-	    if (key == i) {
-		// \u2193 is down arrow, \u2191 is up arrow
-		// forward sorts mean the rows get bigger going down
-		var arrow = (forward ? "\u2193" : "\u2191");
-		// add the character to the column header
-		node.appendChild(SPAN(null, arrow));
-		if (clicked) {
-		    node.onmouseover();
-		}
-	    }
-
-	    // swap in the new th
-	    col.element = swapDOM(col.element, node);
-	}
-    }
-});
-
-var sortableManagers = [];
-
-/*
- * Find each table under `rootNode` and make them sortable
- */
-Sortable.makeTablesSortable = function(rootNode) {
-    var tables = getElementsByTagAndClassName('table', 'listing', rootNode);
-    for(var i=0; i < tables.length; i++) {
-	var sortableManager = new Sortable.SortableManager();
-	sortableManager.initWithTable(tables[i]);
-	sortableManagers.push(sortableManagers);
-    }
-}
-
-jQuery(document).ready(Sortable.makeTablesSortable);
-
-CubicWeb.provide('sortable.js');
Binary file web/data/tab.png has changed