Created
February 2, 2010 13:43
-
-
Save nojimage/292669 to your computer and use it in GitHub Desktop.
jquery.firefox_table_fix.js
This file contains hidden or 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
/** | |
* jQuery firefox table border bug fix plugin | |
* | |
* Copyright 2009, nojimage (http://php-tips.com/) | |
* | |
* Licensed under The MIT License | |
* Redistributions of files must retain the above copyright notice. | |
* | |
* @filesource | |
* @version 1.0 | |
* @author nojimage <nojimage at gmail.com> | |
* @copyright 2009 nojimage | |
* @license http://www.opensource.org/licenses/mit-license.php The MIT License | |
* @link http://php-tips.com/ | |
* @modifiedby nojimage <nojimage at gmail.com> | |
* | |
* Usage: | |
* | |
* <script type="text/javascript" src="js/jquery.firefox_table_fix.js" charset="utf-8"></script> | |
* <script type="text/javascript"> | |
* //<!CDATA[ | |
* $(document).ready(function(){ | |
* $.firefoxTableFix(); | |
* }); | |
* //]]> | |
* </script> | |
* | |
*/ | |
(function($) | |
{ | |
var isGecko = function(){ | |
if(navigator){ | |
if(navigator.userAgent){ | |
if(navigator.userAgent.indexOf("Gecko/") != -1){ | |
return true; | |
} | |
} | |
} | |
return false; | |
} | |
jQuery.fn.firefoxTableFix = function() | |
{ | |
if (!isGecko()) { return; } | |
if (jQuery(this).css('borderCollapse') == 'collapse') { | |
var marginLeft = jQuery(this).css('marginLeft').replace(/([0-9]+)px/, '$1') - 0; | |
jQuery(this).css({'marginLeft': (marginLeft + 1) + 'px'}); | |
jQuery(this).width(jQuery(this).width() - 1); | |
} | |
} | |
jQuery.extend( { | |
"firefoxTableFix" : function(selector) | |
{ | |
if (!isGecko()) { return; } | |
if (typeof selector == "undefined") { | |
selector = 'table'; | |
} | |
jQuery(selector).each(function() | |
{ | |
jQuery(this).firefoxTableFix(); | |
}); | |
} | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment