Existe um bug quando ordenamos numero com o uso da biblioteca javascript jQuery, o bug ocorre quando o primeiro item começa com "0". Os números são interpretados como texto e no final você terá uma sequência completamente errada parecida com a sequência abaixo 1, 10, 2, 3, 31 etc. A solução é simples, basta alterar a expressão regular isDigit no arquivo javascript tablesorter.js para a expressão abaixo:
this.isDigit = function(s, config) {
var exp= '/(\0)|(^[+]?0(\.0+)?$)|(^([-+]?[1-9][0-9]*)$)|(^([-+]?((0?|[1-9][0-9]*)\.([0-9]*)))$)|(^[-+]?[1-9]+[0-9]*\.0+$)/';
return RegExp(exp).test($.trim(s.replace(/,/g, '')));
//Has bug when 0 is first digit in list and interprets as text.
//http://groups.google.com/group/jquery-dev/browse_thread/thread/d8e75a30f7ca3067
//var DECIMAL = '\\' + config.decimal;
//var exp = '/(^[+]?0(' + DECIMAL + '0+)?$)|(^([-+]?[1-9][0-9]*)$)|(^([-+]?((0?|[1-9][0-9]*)' + DECIMAL + '(0*[1-9][0-9]*)))$)|(^[-+]?[1-9]+[0-9]*' + DECIMAL + '0+$)/';
//return RegExp(exp).test($.trim(s));
};
There is a bug when sorting numbers when the first item in the table is a "0". The numbers are interpreted as text instead of digits and you will end up with a sequence like 1, 10, 2, 3, 31 etc. I found the solution in this jquery mailing list thread which uses a different regular expression in the isDigit function in the tablesorter.js plugin.
this.isDigit = function(s, config) {
var exp= '/(\0)|(^[+]?0(\.0+)?$)|(^([-+]?[1-9][0-9]*)$)|(^([-+]?((0?|[1-9][0-9]*)\.([0-9]*)))$)|(^[-+]?[1-9]+[0-9]*\.0+$)/';
return RegExp(exp).test($.trim(s.replace(/,/g, '')));
//Has bug when 0 is first digit in list and interprets as text.
//http://groups.google.com/group/jquery-dev/browse_thread/thread/d8e75a30f7ca3067
//var DECIMAL = '\\' + config.decimal;
//var exp = '/(^[+]?0(' + DECIMAL + '0+)?$)|(^([-+]?[1-9][0-9]*)$)|(^([-+]?((0?|[1-9][0-9]*)' + DECIMAL + '(0*[1-9][0-9]*)))$)|(^[-+]?[1-9]+[0-9]*' + DECIMAL + '0+$)/';
//return RegExp(exp).test($.trim(s));
};
quinta-feira, agosto 06, 2009
quarta-feira, agosto 05, 2009
Zebrado com Smarty Php
Criando um relatório Zebrado com Smarty
No arquivo .php, é preciso apenas setar as cores das linhas.
$smarty = new Smarty();
$smarty->assign("cor_linha", array('#F5F5DC', '#ffffff'));
No arquivo .tpl dentro do foreach é só colocar no tr cycle que automaticamente vai ser
inserido as cores que foram setadas no parâmetro cor_linha
{foreach from=$reports key=id item=rs}
{$rs.attribute1}
{$rs.attribute2}
{foreachelse}
No arquivo .php, é preciso apenas setar as cores das linhas.
$smarty = new Smarty();
$smarty->assign("cor_linha", array('#F5F5DC', '#ffffff'));
No arquivo .tpl dentro do foreach é só colocar no tr cycle que automaticamente vai ser
inserido as cores que foram setadas no parâmetro cor_linha
{foreach from=$reports key=id item=rs}
{foreachelse}
terça-feira, agosto 04, 2009
terça-feira, julho 14, 2009
Bug hover no ie7
Olá Pessoal, tudo bom?
Estava aqui fazendo uns testes em html básico e descobri um novo bug que pode acontecer com o IE7 que nem com csshover.htc resolve, rsrs
O bug ocorre exatamente porque o ie7 segue em teoria o padrão W3C e exige um doctype para a página, então fica simples depois de ler o manual né, é só colocar o doctype na página, pode ser strict, transactional mas tem que ter o doctype antes de tudo.
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
ou
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
ou
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
ou até mesmo
?xml version="1.0" encoding="UTF-8"?>
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
/html>
OBS.:
Foram removidos < antes dos elementos porque dá pau na hora de postar
Estava aqui fazendo uns testes em html básico e descobri um novo bug que pode acontecer com o IE7 que nem com csshover.htc resolve, rsrs
O bug ocorre exatamente porque o ie7 segue em teoria o padrão W3C e exige um doctype para a página, então fica simples depois de ler o manual né, é só colocar o doctype na página, pode ser strict, transactional mas tem que ter o doctype antes de tudo.
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
ou
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
ou
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
ou até mesmo
?xml version="1.0" encoding="UTF-8"?>
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
/html>
OBS.:
Foram removidos < antes dos elementos porque dá pau na hora de postar
terça-feira, maio 05, 2009
Bloquear botão do mouse
Javascript
function lock(mousebutton){
return false;
}
document.onmousedown = lock;
document.oncontextmenu = lock;
function lock(mousebutton){
return false;
}
document.onmousedown = lock;
document.oncontextmenu = lock;
Alinhamento Vertical para qualquer conteúdo
CSS
div#layer{
margin:0 auto 0 auto;
display:table;
width:200px;
height:100px;
border:1px solid #FFCCCC;
background-color:#FFFFCC;
}
div#layer div#text{
display:table-cell;
vertical-align:middle;
}
HTML
<'div id="layer">
<'div id="text">
Texto que vai ficar centralizado na div
<'/div>
<'/div>
div#layer{
margin:0 auto 0 auto;
display:table;
width:200px;
height:100px;
border:1px solid #FFCCCC;
background-color:#FFFFCC;
}
div#layer div#text{
display:table-cell;
vertical-align:middle;
}
HTML
<'div id="layer">
<'div id="text">
Texto que vai ficar centralizado na div
<'/div>
<'/div>
Marcadores:
alinhamento,
alinhamento vertical
segunda-feira, abril 27, 2009
Evento OnLoad, javascript
function init(){
//aqui no metodo iniciar vc coloca os metodos que serao chamados
// por exemplo getAjax()
}
if(window.attachEvent){
window.attachEvent("onload", init);
}else if(document.addEventListener){
document.addEventListener("DOMContentLoaded", init, null);
}
else{
window.onload = init;
init();
}
//aqui no metodo iniciar vc coloca os metodos que serao chamados
// por exemplo getAjax()
}
if(window.attachEvent){
window.attachEvent("onload", init);
}else if(document.addEventListener){
document.addEventListener("DOMContentLoaded", init, null);
}
else{
window.onload = init;
init();
}
terça-feira, março 31, 2009
Bug IE6 OL - Ordered List
Pra variar mais um novo bug do ie6, agora com lista ordenada, ele (IE6) simplesmente não aparece a lista, aparece 1. 1. 1. 1. 1. 1.
veja o exemplo com bug:
ol{
float:left;
width:500px;
}
ol li {
margin:0 0 0 25px;
padding:0 0 0 1px;
width:500px;
}
VEJA O EXEMPLO CORRIGIDO COM O USO DA PROPRIEDADE DISPLAY: list-item;
ol{
float:left;
width:500px;
}
ol li {
display:list-item;
margin:0 0 0 25px;
padding:0 0 0 1px;
width:500px;
height:1%;
}
veja o exemplo com bug:
ol{
float:left;
width:500px;
}
ol li {
margin:0 0 0 25px;
padding:0 0 0 1px;
width:500px;
}
VEJA O EXEMPLO CORRIGIDO COM O USO DA PROPRIEDADE DISPLAY: list-item;
ol{
float:left;
width:500px;
}
ol li {
display:list-item;
margin:0 0 0 25px;
padding:0 0 0 1px;
width:500px;
height:1%;
}
Assinar:
Postagens (Atom)