Skip to content

Commit

Permalink
Item8646: finished colspan support, plus minor fixes for IE
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/JQTablePlugin@6627 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
CrawfordCurrie authored and CrawfordCurrie committed Mar 3, 2010
1 parent 694970c commit ee24bc8
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 15 deletions.
6 changes: 4 additions & 2 deletions data/System/JQTablePlugin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ Some notable omissions:
* Sorting doesn't work correctly if you have multiple header rows

*when used without TablePlugin*
* No sort icon in table headers (just click the header to sort)
* No sort icon in table headers (just click the header to sort).
* Sorting can be a bit strange when rowspans and colspans are used.
* The sorted data background doesn't alternate if more than one colour is given.
* The way column and row spans are calculated is slightly different to TablePlugin, which may give slightly different visual effect sin some extreme cases.

*when used with TablePlugin:*
* Sorted column background doesn't work
Expand All @@ -42,7 +44,7 @@ Another great Foswiki extension from the <a style="text-decoration:none" href="h

| Author(s): | Crawford Currie http://c-dot.co.uk |
| Copyright: | Copyright &copy; 2010 Crawford Currie |
| License: | [http://www.gnu.org/licenses/old-licenses/gpl-2.0.html][Gnu General Public License v2]] |
| License: | [[http://www.gnu.org/licenses/old-licenses/gpl-2.0.html][Gnu General Public License v2]] |
| Release: | %$RELEASE% |
| Version: | %$VERSION% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
Expand Down
2 changes: 1 addition & 1 deletion lib/Foswiki/Plugins/JQTablePlugin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use Foswiki::Plugins (); # For the API version
use Foswiki::Plugins::JQueryPlugin ();

our $VERSION = '$Rev: 5771 $';
our $RELEASE = '1.1.1';
our $RELEASE = '1.1.2';
our $SHORTDESCRIPTION = 'Javascript implementation of the classic TablePlugin, using JQuery';
our $NO_PREFS_IN_TOPIC = 1;
our $DEFAULT_TABLE_SETTINGS =
Expand Down
59 changes: 47 additions & 12 deletions pub/System/JQTablePlugin/tables_src.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ jQuery(document).ready(
var jqtp = {
// Mappings for tableframe attributes
tableframe: {
void: 'none',
above: 'solid none none none',
below: 'none none solid none',
lhs: 'none none none solid',
rhs: 'none solid none none',
hsides: 'solid none solid none',
vsides: 'none solid none solid',
box: 'solid',
border: 'solid'
'void': 'none',
'above': 'solid none none none',
'below': 'none none solid none',
'lhs': 'none none none solid',
'rhs': 'none solid none none',
'hsides': 'solid none solid none',
'vsides': 'none solid none solid',
'box': 'solid',
'border': 'solid'
},

// Process elements marked with "jqtp_process". These are generated
Expand Down Expand Up @@ -76,7 +76,9 @@ jQuery(document).ready(
var frc = p.footerrows;

jqtp.cleanHeadAndFoot(t, hrc, frc);


jqtp.collapseCells(t);

jqtp.colours(p, t);
jqtp.borders(p, t);
jqtp.layout(p, t);
Expand All @@ -86,6 +88,39 @@ jQuery(document).ready(
}
},

// Find cell-collapse marks (^) and assign a rowspan
// to the first non-^ cell in the rows above.
collapseCells : function(t) {
var span = /^\s*\^\s*$/;
t.find("tr").each(
function () {
$(this).find("td")
.add($(this).find("th"))
.filter(
function() {
return span.test( $(this).text() );
})
.each(
function() {
var offset = $(this).prevAll().length;
var rb = $(this);
do {
rb = rb.parent().prev()
.children().eq(offset);
} while (span.test(rb.text()));
rb.attr("rowspan", rb.attr("rowspan") + 1);
});
});
// Now chop out the spanned cells
t.find("td")
.add($(this).find("th"))
.filter(
function() {
return span.test( $(this).text() );
})
.remove();
},

// try and pull out head and foot
cleanHeadAndFoot : function(t, hrc, frc) {
var bodies = t.find('tbody');
Expand All @@ -101,7 +136,7 @@ jQuery(document).ready(
// See if we can find header rows by groping
hrc = 0;
var fc = b.firstChild;
while (fc && fc.firstChild.tagName == 'TH') {
while (fc && fc.firstChild && fc.firstChild.tagName == 'TH') {
hrc++;
fc = fc.nextSibling;
}
Expand Down Expand Up @@ -134,7 +169,7 @@ jQuery(document).ready(
// if we can find footer rows by groping
frc = 0;
var lc = b.lastChild;
while (lc && lc.firstChild.tagName == 'TH') {
while (lc && lc.firstChild && lc.firstChild.tagName == 'TH') {
frc++;
lc = lc.previousSibling;
}
Expand Down

0 comments on commit ee24bc8

Please sign in to comment.