<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MooTools Brasil&#187; Mootools / Categoria / tutoriais</title>
	<atom:link href="http://mootools.com.br/category/tutoriais/feed/" rel="self" type="application/rss+xml" />
	<link>http://mootools.com.br</link>
	<description>Tudo sobre MooTools, Javascript, CSS, Ajax</description>
	<lastBuildDate>Mon, 08 Mar 2010 16:02:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Destrinchando com Mootools 1 &#8211; Script de Redimensionamento</title>
		<link>http://mootools.com.br/2009/09/destrinchando-com-mootools-1/</link>
		<comments>http://mootools.com.br/2009/09/destrinchando-com-mootools-1/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 19:01:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Destrinchando]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[exemplos]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mootools]]></category>

		<guid isPermaLink="false">http://mootools.com.br/?p=74</guid>
		<description><![CDATA[Esta semana um visitante vez uma solicitação para mim, destrinchar os javascripts de um site específico que contém scripts utilizando Mootools.
Achei uma excelente idéia, fica muito mais fácil eu pegar um script pronto, comentar o código em português afim de tentar explicar o funcionamento, e óbiviamente explicar também como incorporar o script no site.
Simplesmente adorei, [...]]]></description>
			<content:encoded><![CDATA[<p>Esta semana um visitante vez uma solicitação para mim, destrinchar os javascripts de um site específico que contém scripts utilizando Mootools.</p>
<p>Achei uma excelente idéia, fica muito mais fácil eu pegar um script pronto, comentar o código em português afim de tentar explicar o funcionamento, e óbiviamente explicar também como incorporar o script no site.</p>
<p>Simplesmente adorei, este visitante me deu a seguinte URL como exemplo: <a href="http://ammunitiongroup.com/index.php/work/" target="_blank">http://ammunitiongroup.com/index.php/work/</a></p>
<p>Como podem ver existem diversos scripts nesta página, resultando em diversos efeitos diferentes.</p>
<p>O que irei fazer é explicar efeito por efeito, acredito que desta forma todos poderão compreender alguns dos scripts.</p>
<h3>O Resultado final</h3>
<p>Clique no link abaixo para abrir o script já em funcionamento, redimensione a janela do navegador e veja como ficará o conteúdo da página.</p>
<p><a href="http://mootools.com.br/scripts/resize/teste.html" target="_blank">Clique aqui para ver o resultado final.</a></p>
<h3>Destrinchando o script</h3>
<p>Ok, abaixo está o código, tentei comentar tudo que entendi, caso tenham dúvidas basta comentar que tentarei ajudar.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// algumas definições iniciais</span>
<span style="color: #003366; font-weight: bold;">var</span> ratio <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>		<span style="color: #006600; font-style: italic;">//propoção inicial, 1 = 100%</span>
<span style="color: #003366; font-weight: bold;">var</span> objs <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>		<span style="color: #006600; font-style: italic;">//objetos que serão monitoradis e redimensionados</span>
<span style="color: #003366; font-weight: bold;">var</span> id_index <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>	<span style="color: #006600; font-style: italic;">//uma variável para um contador</span>
&nbsp;
<span style="color: #006600; font-style: italic;">/*
Classe principal, responsável por definir a cada objeto html que chamar
esta classe os estilos que podem ser redimensionados, ou seja, nem todos
os objetos html possuem todos os estilos citados abaixo, esta classe
basicamente testa e filtra os filtros compatíveis
*/</span>
<span style="color: #003366; font-weight: bold;">var</span> ScalableObject <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> <span style="color: #003366; font-weight: bold;">Class</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
  initialize<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>id<span style="color: #339933;">,</span> obj<span style="color: #339933;">,</span> compatible<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>compatible<span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">'Array'</span><span style="color: #009900;">&#41;</span>
      <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">compatible</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'height'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'width'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'top'</span><span style="color: #339933;">,</span>
        <span style="color: #3366CC;">'left'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'font-size'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'margin-top'</span><span style="color: #339933;">,</span>
        <span style="color: #3366CC;">'margin-bottom'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'margin-left'</span><span style="color: #339933;">,</span>
        <span style="color: #3366CC;">'margin-right'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'padding-top'</span><span style="color: #339933;">,</span>
        <span style="color: #3366CC;">'padding-left'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'padding-bottom'</span><span style="color: #339933;">,</span>
        <span style="color: #3366CC;">'padding-right'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'line-height'</span><span style="color: #339933;">,</span>
        <span style="color: #3366CC;">'bottom'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'right'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">else</span>
      <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">compatible</span> <span style="color: #339933;">=</span> compatible<span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">obj</span> <span style="color: #339933;">=</span> obj<span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">store</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'scaleID'</span><span style="color: #339933;">,</span> id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">styleList</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">id</span> <span style="color: #339933;">=</span> id<span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>this.<span style="color: #660066;">compatible</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getStyle</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">compatible</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'px'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">compatible</span>.<span style="color: #660066;">splice</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        i<span style="color: #339933;">--;</span>
      <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">styleList</span>.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span>
          $<span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getStyle</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">compatible</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'px'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
<span style="color: #006600; font-style: italic;">/*
o arqumento &quot;r&quot; é a proporção na qual o objeto em questão será
redimensionado este valor será em porcento porém em decimais,
exemplo, 50% seria 0.5, 80% = 0.8 e por aí vai
*/</span>
  scale<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>r<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">/*
basicamente para cada estilo compatível, calcula o tamanho de
acordo com a propoção passada e redimensiona
*/</span>
    <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>this.<span style="color: #660066;">compatible</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
      <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">obj</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getStyle</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">compatible</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'%'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">obj</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">setStyle</span><span style="color: #009900;">&#40;</span>
          <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">compatible</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">styleList</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> r <span style="color: #339933;">+</span><span style="color: #3366CC;">'px'</span>
        <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// Uma verificação básica para ver se é Safari no Mac</span>
<span style="color: #003366; font-weight: bold;">var</span> isMacSafari <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>
  navigator.<span style="color: #660066;">vendor</span> <span style="color: #339933;">&amp;&amp;</span>
  navigator.<span style="color: #660066;">vendor</span>.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Apple'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span> <span style="color: #339933;">&amp;&amp;</span>
  navigator.<span style="color: #660066;">platform</span> <span style="color: #339933;">&amp;&amp;</span>
  navigator.<span style="color: #660066;">platform</span>.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Mac'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">/*
Repare que para todos os outros navegadores está sendo chamado no
domready somente no Safari do Mac que é chamado no load
*/</span>
window.<span style="color: #660066;">addEvent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>isMacSafari<span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #3366CC;">'load'</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">'domready'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">/*
chama a função responsável por definir os objetos compatíveis
a serem redimensionados
*/</span>
  init_resize<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #006600; font-style: italic;">// já calcula e redimensiona os objetos</span>
  resize<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #006600; font-style: italic;">// aqui é que fica algo muito importante, será chamado a função</span>
  <span style="color: #006600; font-style: italic;">// resize() sempre que a tela for redimensionada</span>
  window.<span style="color: #660066;">addEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'resize'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    resize<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">/*
Função que define quais elementos serão redimensionados,
reparem que não são todos os elementos e alguns outros
não é nem necessário utilizar todos as propriedades css
compatíveis, portanto o ideal é definir quais propriedades
css você quer redimensionar, isso é importante pois
dependendo do css original de sua página você poderá
distorcendo tudo.
*/</span>
<span style="color: #003366; font-weight: bold;">function</span> init_resize<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #006600; font-style: italic;">// todas as divs</span>
  <span style="color: #003366; font-weight: bold;">var</span> divs <span style="color: #339933;">=</span> $$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #006600; font-style: italic;">// todas as imagens</span>
  <span style="color: #003366; font-weight: bold;">var</span> images <span style="color: #339933;">=</span> $$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #006600; font-style: italic;">// todos os que estão aí abaixo</span>
  <span style="color: #003366; font-weight: bold;">var</span> text <span style="color: #339933;">=</span> $$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'h1'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'h2'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'h3'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'p'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'input'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'textarea'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>divs.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
	objs.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> ScalableObject<span style="color: #009900;">&#40;</span>id_index<span style="color: #339933;">++,</span> divs<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #006600; font-style: italic;">// repare que para as imagens somente as propriedades css que</span>
  <span style="color: #006600; font-style: italic;">// foram definidas aqui serão trabalhadas</span>
  <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>images.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
    objs.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span>
      <span style="color: #003366; font-weight: bold;">new</span> ScalableObject<span style="color: #009900;">&#40;</span>
        id_index<span style="color: #339933;">++,</span>
        images<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'height'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'width'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'margin-bottom'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'margin-right'</span><span style="color: #009900;">&#93;</span>
      <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>text.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
      objs.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> ScalableObject<span style="color: #009900;">&#40;</span>id_index<span style="color: #339933;">++,</span> text<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> resize<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">/*
a proporção a ser definda nos objetos da página é de acordo com o
limite definido abaixo, ou seja, o ideal seria que a altura da página
fosse 735px, qualquer coisa acima ou abaixo disso será redimensionada.
O mesmo ocorre para a largura, o ideal é que a altura fosse 1000px,
qualquer coisa acima disso será redimensionado.
Abaixo será escolhido a menor proporção.
*/</span>
  ratio <span style="color: #339933;">=</span> Math.<span style="color: #660066;">min</span><span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">getSize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">y</span> <span style="color: #009966; font-style: italic;">/ 735, window.getSize().x /</span> <span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #006600; font-style: italic;">// repare que a propoção será no máximo 100% e no mínimo 34%</span>
  ratio <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>ratio <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #CC0000;">1</span> <span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span>ratio <span style="color: #339933;">&lt;</span> .34<span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> .34 <span style="color: #339933;">:</span> ratio<span style="color: #339933;">;</span>
  <span style="color: #006600; font-style: italic;">// manda redimensionar todos os objetos de acordo com a proporção</span>
  <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>objs.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
    objs<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">scale</span><span style="color: #009900;">&#40;</span>ratio<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>Baixe os arquivos e incorpore em seu site</h3>
<p>O javascript utilizado neste exemplo pode ser baixado clicando no link ao lado: <a href="http://mootools.com.br/scripts/resize/resize.js">Clique aqui para baixar</a></p>
<p>Primeiro você precisa incluir o Mootools na página, sugiro utilizar o AJAX APIs do Google para incluir o Mootools na página, veja abaixo como incluir facilmente o Mootools em seu site utilizando o Google AJAX API.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.google.com/jsapi&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
google.load(&quot;mootools&quot;, &quot;1.2.3&quot;);
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

<p>Agora basta incluir o script de redimensionamento de conteúdo na sua página, note que ambos os scripts devem ser inclusos no HEAD do documento, reparem também que o Mootools está sendo incluso antes de chamar o script.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.google.com/jsapi&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
google.load(&quot;mootools&quot;, &quot;1.2.3&quot;);
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;resize.js&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span></pre></div></div>

<h3>Conclusão</h3>
<p>Reparem que é um script muito básico, é claro que é possível fazer isso tudo sem utilizar o Mootools, mas com Mootools o código fica muito mais fácil de ler e compreender.</p>
<p>Espero que tenham gostado e e até a próxima.</p>
]]></content:encoded>
			<wfw:commentRss>http://mootools.com.br/2009/09/destrinchando-com-mootools-1/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Iniciando com Mootools</title>
		<link>http://mootools.com.br/2009/05/iniciando-com-mootools/</link>
		<comments>http://mootools.com.br/2009/05/iniciando-com-mootools/#comments</comments>
		<pubDate>Sat, 23 May 2009 16:22:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[exemplos]]></category>
		<category><![CDATA[tutoriais]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[iniciante]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mootools]]></category>

		<guid isPermaLink="false">http://mootools.com.br/?p=55</guid>
		<description><![CDATA[Mootools é basicamente uma biblioteca contendo diversas funções de auxilio e que permite que você se concentre em criar os códigos ao invés de se preocupar com as diferenças entre os diversos navegadores e suas formas de programar javascript.
Com Mootools você terá um ambiente fácil de programar sem se preocupar com o javascript para os [...]]]></description>
			<content:encoded><![CDATA[<p>Mootools é basicamente uma biblioteca contendo diversas funções de auxilio e que permite que você se concentre em criar os códigos ao invés de se preocupar com as diferenças entre os diversos navegadores e suas formas de programar javascript.</p>
<p>Com Mootools você terá um ambiente fácil de programar sem se preocupar com o javascript para os diversos navegadores, á API cuidará de todo o trabalho de compatibilidade e você só precisa criar aquilo que você precisa só que utilizando Mootools.</p>
<h3>O que você precisa saber?</h3>
<p>O ideal é que você tenha alguma noção de javascript, isso ajuda quando você deseja criar seus próprios scripts com Mootools, aqui vai um link para aprender um pouco de javascript <a title="tutorial básico de javascript" href="http://www.javascript-tutorial.com.br/content-cat-1.html">http://www.javascript-tutorial.com.br/content-cat-1.html</a></p>
<p>Lembrando que para inserir scripts prontos com Mootools não é necessário que você saiba javascript mas uma noção e pelo menos um conhecimento de CSS e HTML são necessários.</p>
<h3>Baixando Mootools</h3>
<p>Pra baixar o Mootools é bem fácil, <a title="Baixe o mootools, informações em português de como baixar" href="http://mootools.com.br/downloads/">veja a página de downloads para saber como baixar no site oficial do Mootools</a>.</p>
<p>Caso você esteja querendo aprender mais sobre a biblioteca do Mootools, e já tenha algum conhecimento avançado com javascript, eu sugiro baixar a versão sem compactação, desta forma você poderá ver como é feito por trás.</p>
<h3>Adicionando em suas páginas</h3>
<p>Pra adicionar o Mootools em suas páginas é bem simples, basta incluir as tags &lt;script&gt; dentro da tag &lt;head&gt;, coloque primeiro a biblioteca do Mootools e depois coloque o seu script com as instruções que utilizam a biblioteca, você pode colocar as instruções na própria página ou em um arquivo externo, segue um exemplo abaixo com arquivo externo.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;</span>
<span style="color: #00bbdd;">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span> xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span> xml:<span style="color: #000066;">lang</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;en&quot;</span> <span style="color: #000066;">lang</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;en&quot;</span> <span style="color: #000066;">dir</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ltr&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span> <span style="color: #000066;">profile</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://gmpg.org/xfn/11&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">http-equiv</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Content-Type&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/html; charset=UTF-8&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>Your title<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;mootools.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;scripts.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
    // Códigos incorporados na própria página
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>....<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

<h3>Escrevendo os seus próprios scripts</h3>
<p>Agora que você já sabe adicionar a API do Mootools é hora de aprender a criar seus próprios scripts, leia alguns dos <a title="Veja os tutoriais e exemplos de Mootools em português" href="http://mootools.com.br/exemplos-e-tutoriais/">tutoriais e exemplos</a> disponíveis aqui no site e não se esqueça de consultar a <a title="Documentação do Mootools em português" href="http://mootools.com.br/documentacao/">documentação</a>.</p>
<p>Algo que eu geralmente recomento é executar os seus scripts dentro do evento <em>domready</em> isso irá garantir que o seu script seja executado assim que o html for carregado, antes mesmo das imagens serem carregadas, em breve maiores informações sobre isso.</p>
]]></content:encoded>
			<wfw:commentRss>http://mootools.com.br/2009/05/iniciando-com-mootools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
