Construindo componentes em PHP e jQuery
Você já deve ter visto alguns frameworks na internet que implementam diversas facilidades ao desenvolvimento de páginas e sistemas web como MVC e outros. Ao mesmo tempo pode ter visto frameworks javascript que implementam componentes visuais com um visual bacana e que facilitam, muitas vezes, a vida do programador na hora de desenvolver suas interfaces.
Parte 2: Testando a classe
Para que o nosso teste funcione você deve baixar o jQuery, jQuery UI e mais dois plugins. Abaixo seguem as URLs para que você possa baixá-los:
jQuery
http://www.jquery.com/
jQuery UI
http://ui.jquery.com/
Price Format
http://meiaduzia.com.br/cuducos2/priceformat/
Maskedinput
http://www.tidbits.com.br/plugin-de-mascara-para-jquery-masked-input
Após baixá-los você deve organizar nas pastas como mostrado na seção HEAD do arquivo teste.input.php, cujo código segue abaixo.
Crie um arquivo teste.input.php e vamos testar a implementação da nossa classe Input.
teste.input.php:
jQuery
http://www.jquery.com/
jQuery UI
http://ui.jquery.com/
Price Format
http://meiaduzia.com.br/cuducos2/priceformat/
Maskedinput
http://www.tidbits.com.br/plugin-de-mascara-para-jquery-masked-input
Após baixá-los você deve organizar nas pastas como mostrado na seção HEAD do arquivo teste.input.php, cujo código segue abaixo.
Crie um arquivo teste.input.php e vamos testar a implementação da nossa classe Input.
teste.input.php:
<?
require "class.input.lib.php";
$cpf = new Input("cpfinput",null,false,0,0,"cpf");
?><html>
<head>
<link rel="stylesheet" href="http://localhost:8085/css/ui.all.css" />
<script src="http://localhost:8085/js/jquery-ui/jquery-1.3.js" type="text/javascript"></script>
<script src="http://localhost:8085/js/jquery.maskedinput.js" type="text/javascript"></script>
<script src="http://localhost:8085/js/jquery.price_format.1.0.js" type="text/javascript"></script>
<script src="http://localhost:8085/js/jquery-ui/jquery.ui.all.js" type="text/javascript"></script>
<script>$(document).ready(function() {
<? echo $cpf->getOutScript(); ?>
});</script>
</head>
<body>
<? echo $cpf->render(); ?>
</body>
</html>
require "class.input.lib.php";
$cpf = new Input("cpfinput",null,false,0,0,"cpf");
?><html>
<head>
<link rel="stylesheet" href="http://localhost:8085/css/ui.all.css" />
<script src="http://localhost:8085/js/jquery-ui/jquery-1.3.js" type="text/javascript"></script>
<script src="http://localhost:8085/js/jquery.maskedinput.js" type="text/javascript"></script>
<script src="http://localhost:8085/js/jquery.price_format.1.0.js" type="text/javascript"></script>
<script src="http://localhost:8085/js/jquery-ui/jquery.ui.all.js" type="text/javascript"></script>
<script>$(document).ready(function() {
<? echo $cpf->getOutScript(); ?>
});</script>
</head>
<body>
<? echo $cpf->render(); ?>
</body>
</html>