Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nick Kallen
committed
Apr 8, 2008
1 parent
9a3b35f
commit 4e30c5e
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
(function($) { | ||
$.extend(jQuery.expr[":"], { | ||
eq : function(a, i, m) { | ||
if (!isNaN(Number(m[3]))) { | ||
return jQuery(a).text() == m[3]; | ||
} else | ||
return jQuery(a).text() == jQuery(a).siblings(m[3]).text(); | ||
} | ||
}); | ||
$.fn.where = function(condition) { | ||
return this.find('tr:has(' + condition + ')').filter('tr'); | ||
}; | ||
$.fn.and = function(condition) { | ||
return this.filter(':has(' + condition + ')'); | ||
}; | ||
$.fn.select = function(attributes) { | ||
return this | ||
.map(function() { | ||
return $(this).find(attributes) | ||
.map(function() { return $(this).text() }); | ||
}); | ||
}; | ||
$.fn.join = function(other) { | ||
var left = this, right = $(other); | ||
var table = $('<table>') | ||
this | ||
.find('tr').each(function() { | ||
var left_row = $(this); | ||
$(other).find('tr').each(function() { | ||
$(this) | ||
.clone() | ||
.find('td') | ||
.each(function() { | ||
$(this).addClass(right.attr('class')); | ||
}) | ||
.end() | ||
.append( | ||
left_row | ||
.clone() | ||
.find('td') | ||
.each(function() { | ||
$(this).addClass(left.attr('class')); | ||
}) | ||
) | ||
.appendTo(table); | ||
}); | ||
}); | ||
return table; | ||
}; | ||
})(jQuery); |