Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
33c411ce
Commit
33c411ce
authored
Nov 30, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rewrite table sorter to correctly handle colspan
parent
c29d270f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
32 deletions
+35
-32
weblate/media/js/loader.js
weblate/media/js/loader.js
+35
-32
No files found.
weblate/media/js/loader.js
View file @
33c411ce
...
...
@@ -147,49 +147,52 @@ function cell_cmp(a, b) {
function
load_table_sorting
()
{
$
(
'
table.sort
'
).
each
(
function
()
{
var
table
=
$
(
this
);
var
table
=
$
(
this
),
tbody
=
table
.
find
(
'
tbody
'
),
thead
=
table
.
find
(
'
thead
'
),
thIndex
=
0
;
$
(
this
).
find
(
'
thead th
'
)
.
each
(
function
(){
var
th
=
$
(
this
),
thIndex
=
th
.
index
(),
inverse
=
1
,
tbody
=
th
.
parents
(
'
table
'
).
find
(
'
tbody
'
),
thead
=
th
.
parents
(
'
table
'
).
find
(
'
thead
'
);
if
(
th
.
text
()
==
''
)
{
return
;
inverse
=
1
;
// handle colspan
if
(
th
.
attr
(
'
colspan
'
))
{
thIndex
+=
parseInt
(
th
.
attr
(
'
colspan
'
))
-
1
;
}
if
(
th
.
find
(
'
span.ui-icon
'
).
length
>
0
)
{
return
;
}
// Second column contains percent with colspan
if
(
thIndex
>=
2
&&
!
table
.
hasClass
(
'
simple
'
))
{
thIndex
+=
1
;
}
th
.
attr
(
'
title
'
,
gettext
(
"
Sort this column
"
)).
addClass
(
'
sort
'
).
append
(
'
<span class="sort ui-icon ui-icon-carat-2-n-s" />
'
);
// skip empty cells and cells with icon (probably already processed)
if
(
th
.
text
()
!=
''
&&
th
.
find
(
'
span.ui-icon
'
).
length
==
0
)
{
// Store index copy
var
myIndex
=
thIndex
;
// Add icon, title and class
th
.
attr
(
'
title
'
,
gettext
(
"
Sort this column
"
)).
addClass
(
'
sort
'
).
append
(
'
<span class="sort ui-icon ui-icon-carat-2-n-s" />
'
);
th
.
click
(
function
(){
// Click handler
th
.
click
(
function
(){
tbody
.
find
(
'
td,th
'
).
filter
(
function
(){
return
$
(
this
).
index
()
===
th
Index
;
}).
sortElements
(
function
(
a
,
b
){
return
inverse
*
cell_cmp
(
$
.
text
([
a
]),
$
.
text
([
b
]));
},
function
(){
tbody
.
find
(
'
td,th
'
).
filter
(
function
(){
return
$
(
this
).
index
()
===
my
Index
;
}).
sortElements
(
function
(
a
,
b
){
return
inverse
*
cell_cmp
(
$
.
text
([
a
]),
$
.
text
([
b
]));
},
function
(){
// parentNode is the element we want to move
return
this
.
parentNode
;
// parentNode is the element we want to move
return
this
.
parentNode
;
});
thead
.
find
(
'
span.sort
'
).
removeClass
(
'
ui-icon-carat-1-n ui-icon-carat-1-s
'
).
addClass
(
'
ui-icon-carat-2-n-s
'
);
if
(
inverse
==
1
)
{
$
(
this
).
find
(
'
span.sort
'
).
addClass
(
'
ui-icon-carat-1-n
'
).
removeClass
(
'
ui-icon-carat-2-n-s
'
);
}
else
{
$
(
this
).
find
(
'
span.sort
'
).
addClass
(
'
ui-icon-carat-1-s
'
).
removeClass
(
'
ui-icon-carat-2-n-s
'
);
}
});
thead
.
find
(
'
span.sort
'
).
removeClass
(
'
ui-icon-carat-1-n ui-icon-carat-1-s
'
).
addClass
(
'
ui-icon-carat-2-n-s
'
);
if
(
inverse
==
1
)
{
$
(
this
).
find
(
'
span.sort
'
).
addClass
(
'
ui-icon-carat-1-n
'
).
removeClass
(
'
ui-icon-carat-2-n-s
'
);
}
else
{
$
(
this
).
find
(
'
span.sort
'
).
addClass
(
'
ui-icon-carat-1-s
'
).
removeClass
(
'
ui-icon-carat-2-n-s
'
);
}
inverse
=
inverse
*
-
1
;
inverse
=
inverse
*
-
1
;
});
});
}
// Increase index
thIndex
+=
1
;
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment