<?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>Dave Ruiz Blog &#187; Programación</title>
	<atom:link href="http://blog.daveruiz.net/category/programacion/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.daveruiz.net</link>
	<description>Freelance Web Developer</description>
	<lastBuildDate>Sat, 21 Jan 2012 12:24:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>JSPopViewer v1.1</title>
		<link>http://blog.daveruiz.net/general/jspopviewer-v1-1/</link>
		<comments>http://blog.daveruiz.net/general/jspopviewer-v1-1/#comments</comments>
		<pubDate>Thu, 10 Mar 2011 12:45:45 +0000</pubDate>
		<dc:creator>Dave Ruiz</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Programación]]></category>

		<guid isPermaLink="false">http://blog.daveruiz.net/?p=407</guid>
		<description><![CDATA[Por fín, he decidido meter mano a este viejo script. Visto que se está empleando en varios sitios he intentado arreglar algunos problemas que tenía, y he añadido algunas mejoras. Añadido soporte de pie de foto: Segundo parámetro de la funcion open() o el atributo &#8216;title&#8217; de la imagen. Añadido atributo &#8216;effect&#8217; para definir la [...]]]></description>
			<content:encoded><![CDATA[<p>Por fín, he decidido meter mano a este viejo script. Visto que se está empleando en varios sitios he intentado arreglar algunos problemas que tenía, y he añadido algunas mejoras.</p>
<ul>
<li>Añadido soporte de pie de foto: Segundo parámetro de la funcion open() o el atributo &#8216;title&#8217; de la imagen.</li>
<li>Añadido atributo &#8216;effect&#8217; para definir la animación al aparecer/desaparecer. De momento disponibles &#8216;bounce&#8217; (por defecto) o &#8216;easeout&#8217;.</li>
<li>Haciendo click fuera de la imagen esta se cierra (ya no se cierra al hacer click en ella).</li>
<li>Ya no es necesario declarar el objeto JSPopViewer al final del documento.</li>
<li>Corregido problema comprobar si la imagen ha cargado.</li>
<li>Corregido problema comprobar el tamaño de la imagen en IE.</li>
<li>Corregidos algunos problemas con los estilos.</li>
</ul>
<p>Se puede descargar en el siguiente enlace: [<a href="http://lab.daveruiz.net/webapp.jspopviewer/" target="_blank">Descargar</a>]</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.daveruiz.net/general/jspopviewer-v1-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery: Evento &#8216;onResize&#8217; para cualquier elemento HTML</title>
		<link>http://blog.daveruiz.net/programacion/jquery-evento-onresize-para-cualquier-elemento-html/</link>
		<comments>http://blog.daveruiz.net/programacion/jquery-evento-onresize-para-cualquier-elemento-html/#comments</comments>
		<pubDate>Mon, 04 Oct 2010 10:49:37 +0000</pubDate>
		<dc:creator>Dave Ruiz</dc:creator>
				<category><![CDATA[Programación]]></category>

		<guid isPermaLink="false">http://blog.daveruiz.net/?p=400</guid>
		<description><![CDATA[El evento &#8216;onresize&#8217; se lanza cuando un elemento HTML cambia de tamaño. Pero tenemos el problema de que sólo Internet Explorer lo lanza en el momento del cambio de tamaño del elemento, mientras que el resto de navegadores lo hace solo al cambiar el tamaño de la ventana del navegador. Este pequeño plugin jQuery ayudará [...]]]></description>
			<content:encoded><![CDATA[<p>El evento <strong>&#8216;onresize&#8217; </strong> se lanza cuando un elemento HTML cambia de tamaño. Pero tenemos el problema de que sólo Internet Explorer lo lanza en el momento del cambio de tamaño del elemento, mientras que el resto de navegadores lo hace solo al cambiar el tamaño de la ventana del navegador.</p>
<p>Este pequeño plugin <strong>jQuery</strong> ayudará a detectar cambios de tamaño en cualquier elemento HTML, lanzando un evento onResize &#8216;casi&#8217; en el momento del cambio.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$.<span style="color: #660066;">fn</span>.<span style="color: #660066;">addOnResizeEvent</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>custom_options<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">var</span> options <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
		timeInterval <span style="color: #339933;">:</span> <span style="color: #CC0000;">100</span><span style="color: #339933;">,</span>
		forceIE <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	$.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span> custom_options<span style="color: #339933;">,</span> options <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">// Soporte nativo IE</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$.<span style="color: #660066;">browser</span>.<span style="color: #660066;">ie</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #339933;">!</span>options.<span style="color: #660066;">forceIE</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</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>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> target <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> lw<span style="color: #339933;">,</span> lh<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> interval <span style="color: #339933;">=</span> setInterval<span style="color: #009900;">&#40;</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>
&nbsp;
			<span style="color: #003366; font-weight: bold;">var</span> w <span style="color: #339933;">=</span> target.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				h <span style="color: #339933;">=</span> target.<span style="color: #660066;">height</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>lw <span style="color: #339933;">==</span> undefined<span style="color: #009900;">&#41;</span> lw <span style="color: #339933;">=</span> w<span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>lh <span style="color: #339933;">==</span> undefined<span style="color: #009900;">&#41;</span> lh <span style="color: #339933;">=</span> h<span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> lw <span style="color: #339933;">!=</span> w <span style="color: #339933;">||</span> lh <span style="color: #339933;">!=</span> h <span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				lw <span style="color: #339933;">=</span> w<span style="color: #339933;">;</span>
				lh <span style="color: #339933;">=</span> h<span style="color: #339933;">;</span>
				target.<span style="color: #660066;">trigger</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;resize&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> 
&nbsp;
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> options.<span style="color: #660066;">timeInterval</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Y su modo de uso:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div.miDiv&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addOnResizeEvent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
&nbsp;
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div.miDiv&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">resize</span><span style="color: #009900;">&#40;</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: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Cambié de tamaño&quot;</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></pre></div></div>

<p>En caso de estar navegando con Internet Explorer este plugin no tendrá efecto dejando la activación del evento nativa. Sin embargo, puede forzarse pasandole un parametro &#8216;<strong>forceIE</strong>&#8216; como &#8216;<em>true</em>&#8216;.</p>
<p>Además, permite modificar el tiempo entre chequeos de tamaño por el parámetro &#8216;<strong>timeInterval</strong>&#8216;, indicando la espera en milisegundos.</p>
<p>El modo de asignar los parámetros es el siguiente:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div.miDiv&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addOnResizeEvent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
	timeInterval <span style="color: #339933;">:</span> <span style="color: #CC0000;">200</span><span style="color: #339933;">,</span>
	forceIE <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>Una última recomendación, y por temas de rendimiento, es la de asignar esta función solamente a aquellos elementos que quiera registrarse un cambio de tamaño.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.daveruiz.net/programacion/jquery-evento-onresize-para-cualquier-elemento-html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery: Subrayar automáticamente las letras de acceso rápido (accesskey) en los enlaces.</title>
		<link>http://blog.daveruiz.net/programacion/jquery-subrayar-automaticamente-las-letras-de-acceso-rapido-accesskey-en-los-enlaces/</link>
		<comments>http://blog.daveruiz.net/programacion/jquery-subrayar-automaticamente-las-letras-de-acceso-rapido-accesskey-en-los-enlaces/#comments</comments>
		<pubDate>Fri, 01 Oct 2010 13:14:45 +0000</pubDate>
		<dc:creator>Dave Ruiz</dc:creator>
				<category><![CDATA[Programación]]></category>

		<guid isPermaLink="false">http://blog.daveruiz.net/?p=380</guid>
		<description><![CDATA[Otro pequeño aporte para resaltar las teclas de acceso rápido (el atributo &#8216;accesskey&#8217;) de los enlaces, cómo no, con la ayuda de jQuery (en este caso pequeña). Muy útil, por ejemplo, para la realización de menús de navegación sin tener que &#8216;ensuciar&#8217; el HTML. Primero, necesitamos asignar un estilo a la letra a resaltar. Optaremos [...]]]></description>
			<content:encoded><![CDATA[<p>Otro pequeño aporte para resaltar las teclas de acceso rápido (el atributo &#8216;accesskey&#8217;) de los enlaces, cómo no, con la ayuda de jQuery (en este caso pequeña). Muy útil, por ejemplo, para la realización de menús de navegación sin tener que &#8216;ensuciar&#8217; el HTML.</p>
<p>Primero, necesitamos asignar un estilo a la letra a resaltar. Optaremos por un simple subrayado.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">a <span style="color: #6666ff;">.accesskey</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">underline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Y ahora viene la magia. Realizamos un recorrido por los enlaces de la página y realizamos el cambio:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</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: #003366; font-weight: bold;">var</span> html<span style="color: #339933;">,</span> reg<span style="color: #339933;">,</span> rep<span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">accessKey</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		html <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!/&lt;/</span>g.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>html<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span> 	<span style="color: #006600; font-style: italic;">// No contiene HTML</span>
			reg <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;(&quot;</span><span style="color: #339933;">+</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">accessKey</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;)&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;i&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			rep <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&lt;span class='accesskey'&gt;$1&lt;/span&gt;&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000066; font-weight: bold;">else</span>
		<span style="color: #009900;">&#123;</span> 	<span style="color: #006600; font-style: italic;">// Contiene HTML</span>
			reg <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;(&lt;[^&gt;]*&gt;.*)(&quot;</span><span style="color: #339933;">+</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">accessKey</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;)(.*&lt;/[^&gt;]*&gt;)&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;i&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			rep <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;$1&lt;span class='accesskey'&gt;$2&lt;/span&gt;$3&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span> html.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span> reg<span style="color: #339933;">,</span> rep <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: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Evidentemente, será requisito que el texto del enlace contenga la letra equivalente a la tecla de acceso rápido.</p>
<p>Y muy importante, por supuesto, realizar este escaneo una vez sea accesible el DOM completo de la página.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</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>
&nbsp;
	<span style="color: #006600; font-style: italic;">// Nuestro script</span>
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.daveruiz.net/programacion/jquery-subrayar-automaticamente-las-letras-de-acceso-rapido-accesskey-en-los-enlaces/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery: Colocar puntos suspensivos cuando un texto no cabe en una linea.</title>
		<link>http://blog.daveruiz.net/programacion/jquery-colocar-puntos-suspensivos-cuando-un-texto-no-cabe-en-una-linea/</link>
		<comments>http://blog.daveruiz.net/programacion/jquery-colocar-puntos-suspensivos-cuando-un-texto-no-cabe-en-una-linea/#comments</comments>
		<pubDate>Thu, 26 Aug 2010 10:07:02 +0000</pubDate>
		<dc:creator>Dave Ruiz</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[ellipsis]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[puntos suspensivos]]></category>
		<category><![CDATA[textoverflow]]></category>

		<guid isPermaLink="false">http://blog.daveruiz.net/?p=356</guid>
		<description><![CDATA[Un pequeño script rápido y muy sencillo que he elaborado para jQuery, que hace lo que el título de esta entrada. Hasta ahora estaba usando uno de los textOverflow que andan por ahí, pero me estaban dando algún problema. $.fn.ellipsis = function&#40;&#41; &#123; return this.each&#40; function&#40;&#41; &#123; &#160; var tar = $&#40;this&#41;, ow, ls, tg, [...]]]></description>
			<content:encoded><![CDATA[<p>Un pequeño script rápido y muy sencillo que he elaborado para <strong>jQuery</strong>, que hace lo que el título de esta entrada. Hasta ahora estaba usando uno de los <em>textOverflow</em> que andan <a href="http://www.google.es/search?hl=es&amp;q=jquery+textoverflow&amp;aq=f&amp;aqi=&amp;aql=&amp;oq=&amp;gs_rfai=" target="_blank">por ahí</a>, pero me estaban dando algún problema.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$.<span style="color: #660066;">fn</span>.<span style="color: #660066;">ellipsis</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: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</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>
&nbsp;
	<span style="color: #003366; font-weight: bold;">var</span> tar <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		ow<span style="color: #339933;">,</span> ls<span style="color: #339933;">,</span> tg<span style="color: #339933;">,</span> 
		tw<span style="color: #339933;">=</span>tar.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;display&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;block&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;white-space&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;nowrap&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> 
		ot<span style="color: #339933;">=</span>tar.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> pt<span style="color: #339933;">=</span>ot<span style="color: #339933;">,</span>
		alt<span style="color: #339933;">=</span>tar.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		ok<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> 
		ct<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span>
		el<span style="color: #339933;">=</span><span style="color: #3366CC;">' &amp;hellip;'</span><span style="color: #339933;">;</span>
&nbsp;
	tar.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;position&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;absolute&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>ok<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		ow <span style="color: #339933;">=</span> tar.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;width&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;auto&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>ow <span style="color: #339933;">&gt;</span> tw<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			ls <span style="color: #339933;">=</span> pt.<span style="color: #660066;">lastIndexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot; &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			tg <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;&lt;[^&gt;]*$&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;g&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span> pt.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> ls<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>ls <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
				pt <span style="color: #339933;">=</span> pt.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> ls<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				tar.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span> pt <span style="color: #339933;">+</span> el <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				ct<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
				tar.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span> el <span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;title&quot;</span><span style="color: #339933;">,</span> alt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				ok<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">true</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span>tg<span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span> 
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>ct<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				tar.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;title&quot;</span><span style="color: #339933;">,</span> alt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				tar.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;display&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;block&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;width&quot;</span><span style="color: #339933;">:</span>tw<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;px&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			ok <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	tar.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;position&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Y para usarlo.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.textodeunalinea&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ellipsis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p><strong>Actualización 27-10-2010:</strong> Se han hecho algunas correcciones. Y un detalle; se porta un poquito mal cuando hay Html en el texto. Pendiente de corregir.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.daveruiz.net/programacion/jquery-colocar-puntos-suspensivos-cuando-un-texto-no-cabe-en-una-linea/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JS: Convertir un objeto en una cadena XML</title>
		<link>http://blog.daveruiz.net/programacion/js-convertir-un-objeto-en-una-cadena-xml/</link>
		<comments>http://blog.daveruiz.net/programacion/js-convertir-un-objeto-en-una-cadena-xml/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 09:53:33 +0000</pubDate>
		<dc:creator>Dave Ruiz</dc:creator>
				<category><![CDATA[Programación]]></category>

		<guid isPermaLink="false">http://blog.daveruiz.net/?p=308</guid>
		<description><![CDATA[Os dejo una pequeña y sencilla función para realizar esta tarea en Javascript. Evidentemente, está sujeto a las mejoras que creáis convenientes. function XMLString&#40; object, name, recursiveCall &#41; &#123; var xml = &#34;&#34;, i; var isArray = typeof&#40;object&#41; === 'object' &#38;&#38; typeof&#40;object.length&#41; === 'number' &#38;&#38; !&#40;object.propertyIsEnumerable&#40;'length'&#41;&#41; &#38;&#38; typeof&#40;object.splice === 'function'&#41;; &#160; if &#40;!recursiveCall&#41; &#123; xml += &#34;&#60;?xml [...]]]></description>
			<content:encoded><![CDATA[<p>Os dejo una pequeña y sencilla función para realizar esta tarea en Javascript. Evidentemente, está sujeto a las mejoras que creáis convenientes.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> XMLString<span style="color: #009900;">&#40;</span> object<span style="color: #339933;">,</span> <span style="color: #000066;">name</span><span style="color: #339933;">,</span> recursiveCall <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> xml <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,</span> i<span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> isArray <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>object<span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #3366CC;">'object'</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>object.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #3366CC;">'number'</span> <span style="color: #339933;">&amp;&amp;</span>  <span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span>object.<span style="color: #660066;">propertyIsEnumerable</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'length'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>object.<span style="color: #660066;">splice</span> <span style="color: #339933;">===</span> <span style="color: #3366CC;">'function'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>recursiveCall<span style="color: #009900;">&#41;</span>	<span style="color: #009900;">&#123;</span>
		xml <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;&lt;?xml version=<span style="color: #000099; font-weight: bold;">\&quot;</span>1.0<span style="color: #000099; font-weight: bold;">\&quot;</span> ?&gt;&quot;</span><span style="color: #339933;">;;</span>
		xml <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;&lt;&quot;</span><span style="color: #339933;">+</span><span style="color: #000066;">name</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot; xmlns:xsi=<span style="color: #000099; font-weight: bold;">\&quot;</span>http://www.w3.org/2001/XMLSchema-instance<span style="color: #000099; font-weight: bold;">\&quot;</span> xmlns:xsd=<span style="color: #000099; font-weight: bold;">\&quot;</span>http://www.w3.org/2001/XMLSchema<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><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;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>isArray<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		xml <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;&lt;&quot;</span><span style="color: #339933;">+</span><span style="color: #000066;">name</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&gt;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<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>object<span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #3366CC;">&quot;undefined&quot;</span> <span style="color: #339933;">||</span> object <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//Nada</span>
	<span style="color: #000066; font-weight: bold;">else</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>object<span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #3366CC;">&quot;object&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #000066; font-weight: bold;">in</span> object<span style="color: #009900;">&#41;</span> xml <span style="color: #339933;">+=</span> XMLString<span style="color: #009900;">&#40;</span> object<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> isArray<span style="color: #339933;">?</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span>i<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Un objeto o array</span>
	<span style="color: #000066; font-weight: bold;">else</span> xml <span style="color: #339933;">+=</span> object<span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Un texto</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>isArray <span style="color: #339933;">||</span> <span style="color: #339933;">!</span>recursiveCall<span style="color: #009900;">&#41;</span> xml <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;&lt;/&quot;</span><span style="color: #339933;">+</span><span style="color: #000066;">name</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">return</span> xml<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Y un ejemplo de uso sería:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> objeto <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
	campo1 <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;valor1&quot;</span><span style="color: #339933;">,</span>
	campo2 <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;valor2&quot;</span><span style="color: #339933;">,</span>
	campo3 <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;valor3&quot;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span> XMLString<span style="color: #009900;">&#40;</span> objeto<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;XML&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Donde el <strong>primer parámetro</strong> es el <span style="text-decoration: underline;">objeto a convertir</span>, y el <strong>segundo</strong> es el <span style="text-decoration: underline;">nombre del elemento raíz</span>. Con el ejemplo anterior obtendríamos como salida la siguiente cadena:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;XML</span> <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span> <span style="color: #000066;">xmlns:xsd</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;campo1<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>valor1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/campo1<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;campo2<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>valor2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/campo2<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;campo3<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>valor3<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/campo3<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/XML<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Con 4 cambios es posible convertirlo en código AS2 o AS3. Aunque en estos casos creo que hay métodos mejores y nativos para hacer esta función.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.daveruiz.net/programacion/js-convertir-un-objeto-en-una-cadena-xml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript: Habilitar :hover en todos los elementos para Internet Explorer con jQuery</title>
		<link>http://blog.daveruiz.net/programacion/javascript-habilitar-hover-en-todos-los-elementos-para-internet-explorer-con-jquery/</link>
		<comments>http://blog.daveruiz.net/programacion/javascript-habilitar-hover-en-todos-los-elementos-para-internet-explorer-con-jquery/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 15:49:28 +0000</pubDate>
		<dc:creator>Dave Ruiz</dc:creator>
				<category><![CDATA[Programación]]></category>

		<guid isPermaLink="false">http://blog.daveruiz.net/?p=286</guid>
		<description><![CDATA[De todos es conocido el problema de emplear la pseudo-clase :hover con Internet Explorer 6. Este funciona solamente con los hipervínculos (&#60;a&#62;&#60;/a&#62;) dejando fuera al resto de elementos. Con la ayuda de jQuery, podemos solventar de manera fácil este problema añadiendo unas lineas al inicio del script, y teniendo en cuenta una regla en el [...]]]></description>
			<content:encoded><![CDATA[<p>De todos es conocido el problema de emplear la pseudo-clase <strong>:hover</strong> con Internet Explorer 6. Este funciona solamente con los hipervínculos (<em>&lt;a&gt;&lt;/a&gt;</em>) dejando fuera al resto de elementos.</p>
<p>Con la ayuda de <strong>jQuery</strong>, podemos solventar de manera fácil este problema añadiendo unas lineas al inicio del script, y teniendo en cuenta una regla en el CSS que contenga los estilos.</p>
<p>Por ejemplo, teniendo el siguiente CSS:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#menu</span> li<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">underline</span><span style="color: #00AA00;">:</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Habría que modificarlo tal que:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#menu</span> li<span style="color: #3333ff;">:hover</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#menu</span> li<span style="color: #6666ff;">.hover</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">underline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>De manera que podamos acceder a dicho estilo mediante una clase.</p>
<p>Y ahora, solo quedaría realizar un script que añada la clase o la elimine según el evento llamado. Para ello emplearemos la función hover(mouseOver, mouseOut) que nos facilita jQuery.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</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: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$.<span style="color: #660066;">browser</span>.<span style="color: #660066;">msie</span><span style="color: #009900;">&#41;</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;*&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hover</span><span style="color: #009900;">&#40;</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: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;hover&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</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: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;hover&quot;</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></pre></div></div>

<p>Y a funcionar <img src='http://blog.daveruiz.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.daveruiz.net/programacion/javascript-habilitar-hover-en-todos-los-elementos-para-internet-explorer-con-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AS3: Detener descarga del componente FLVPlayback</title>
		<link>http://blog.daveruiz.net/programacion/as3-detener-descarga-del-componente-flvplayback/</link>
		<comments>http://blog.daveruiz.net/programacion/as3-detener-descarga-del-componente-flvplayback/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 07:19:07 +0000</pubDate>
		<dc:creator>Dave Ruiz</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[componente]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[flv]]></category>
		<category><![CDATA[flvcomponent]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://blog.daveruiz.net/?p=257</guid>
		<description><![CDATA[Por alguna razón, Adobe no implementó un método para detener la descarga de un archivo FLV cuando queremos eliminar un componente FLVPlayback. Puedes crear un reproductor FLV dinámicamente y luego destruirlo, pero si ha comenzado la reproducción el fichero FLV continuará descargándose hasta que termine. La clase FLVPlayback implementa el método closeVideoPlayer( índice ) que [...]]]></description>
			<content:encoded><![CDATA[<p>Por alguna razón, Adobe no implementó un método para detener la descarga de un archivo FLV cuando queremos eliminar un componente FLVPlayback. Puedes crear un reproductor FLV dinámicamente y luego destruirlo, pero si ha comenzado la reproducción el fichero FLV continuará descargándose hasta que termine.</p>
<p>La clase FLVPlayback implementa el método <em>closeVideoPlayer( índice ) </em>que permite detener la descarga del archivo FLV que esté descargando, pero está limitado a cuando abres múltiples vídeos en un solo componente. La limitación consiste en no dejarte eliminar la conexión de video con la que creaste el reproductor.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// Creamos el reproductor y lo ponemos a reproducir</span>
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">video</span>:FlvPlayback = <span style="color: #000000; font-weight: bold;">new</span> FlvPlayback<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0066CC;">video</span>.<span style="color: #0066CC;">play</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;video.flv&quot;</span> <span style="color: #66cc66;">&#41;</span>;</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// Ahora intentamos cerrar el reproductor</span>
<span style="color: #0066CC;">video</span>.<span style="color: #0066CC;">stop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0066CC;">video</span>.<span style="color: #006600;">closeVideoPlayer</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Debería detener la descarga, pero nos lanza un error</span>
<span style="color: #0066CC;">video</span> = <span style="color: #000000; font-weight: bold;">null</span>; <span style="color: #808080; font-style: italic;">// Para que el Garbage Collector lo elimine de memoria</span></pre></div></div>

<p>Si en el ejemplo omitimos <em>video.closeVideoPlayer(0)</em>, el reproductor se elimina, pero el vídeo continúa descargándose y consumiendo ancho de banda.</p>
<p>Esto puede ser un problema cuando haces uso de varias instancias de este componente, y debido a las circunstancias no puedes usar uno solo. Cada una de ellas llamará a la descarga de un FLV, y puede darse el caso de estar descargando varios FLV a la vez, con el consiguiente consumo de ancho de banda.</p>
<p>La solución, acceder a la primera instancia VideoPlayer y detenerlo uno mismo:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// Ahora intentamos cerrar el reproductor</span>
<span style="color: #0066CC;">video</span>.<span style="color: #0066CC;">stop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0066CC;">video</span>.<span style="color: #006600;">getVideoPlayer</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">close</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Ahora sí, detiene la descarga del archivo FLV</span>
<span style="color: #0066CC;">video</span> = <span style="color: #000000; font-weight: bold;">null</span>; <span style="color: #808080; font-style: italic;">// Para que el Garbage Collector lo elimine de memoria</span></pre></div></div>

<p>Algo muy sencillo, pero que ya me ha hecho perder algo de tiempo buscándolo <img src='http://blog.daveruiz.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> .  Aquí lo dejo como apunte.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.daveruiz.net/programacion/as3-detener-descarga-del-componente-flvplayback/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Javascript: Cuando onload no es lanzado (actualizado)</title>
		<link>http://blog.daveruiz.net/programacion/cuando-onload-no-es-lanzado/</link>
		<comments>http://blog.daveruiz.net/programacion/cuando-onload-no-es-lanzado/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 22:10:30 +0000</pubDate>
		<dc:creator>Dave Ruiz</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[complete]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[onload]]></category>

		<guid isPermaLink="false">http://blog.daveruiz.net/?p=238</guid>
		<description><![CDATA[En ocasiones, ocurre que el evento onLoad, por ejemplo, de una imagen no es lanzado a la hora de cargar una página. Imaginemos que en el script de una página, una vez cargado el DOM, añadimos una función determinada cuando carga la imagen de cabecera: &#60;script type=&#34;text/javascript&#34;&#62; // Función que ejecutamos al cargar el DOM [...]]]></description>
			<content:encoded><![CDATA[<p>En ocasiones, ocurre que el evento <strong>onLoad</strong>, por ejemplo, de una imagen no es lanzado a la hora de cargar una página.</p>
<p>Imaginemos que en el script de una página, una vez cargado el DOM, añadimos una función determinada cuando carga la imagen de cabecera:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
  <span style="color: #006600; font-style: italic;">// Función que ejecutamos al cargar el DOM de la página</span>
  window.<span style="color: #000066;">onload</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: #003366; font-weight: bold;">var</span> cabecera <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;cabecera&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// Funcion lanzada cuando carga la imagen 'cabecera'</span>
    cabecera.<span style="color: #000066;">onload</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: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;carga completa&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Nos encontraremos con que en algún navegador (por ejemplo, Internet Explorer) lanza la primera vez el evento, pero en las posteriores cargas este no es lanzado.</p>
<p>La razón es que, en la segunda carga, la imagen se encuentra cacheada y por tanto el navegador carga la imagen en cuanto inserta el elemento <em>IMG</em>, lanzando el correspondiente evento <em>onLoad</em>. Como en ese preciso momento todavía estamos cargando la estructura de la página y el evento no ha sido asignado (no se asigna hasta la carga completa de la estructura), cuando queremos asignarlo ya es demasiado tarde.</p>
<p><del datetime="2009-08-12T06:19:12+00:00">Otros navegadores como Mozilla Firefox no lanzan los eventos hasta que se ha completado la carga del DOM, haciendo inexistente este problema.</del></p>
<p>Una solución sencilla es comprobar, después de asignar el evento <em>onLoad </em>a la imagen, si esta ya se encuentra cargada complétamente. Nos serviremos del parámetro <strong>complete</strong>. Si nos devuelve <em>true</em>, lanzamos el evento <em>onLoad</em> manualmente.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
  <span style="color: #006600; font-style: italic;">// Función que ejecutamos al cargar el DOM de la página</span>
  window.<span style="color: #000066;">onload</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: #003366; font-weight: bold;">var</span> cabecera <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;cabecera&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// Funcion lanzada cuando carga la imagen 'cabecera'</span>
    cabecera.<span style="color: #000066;">onload</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: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;carga completa&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>cabecera.<span style="color: #660066;">complete</span> <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> cabecera.<span style="color: #000066;">onload</span><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: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p><strong>Actualización:</strong></p>
<p>Me comenta Marc Palau (y con toda la razón) que el ejemplo anterior no es válido porque <em>onLoad</em> no es lanzado hasta que carga toda la página, incluidas las imágenes. En este caso, nunca seran llamados los eventos <em>onLoad</em> de las imágenes porque se están definiendo después de haberlas cargado.</p>
<p>Para reproducir el error, he preparado <a href="http://lab.daveruiz.net/jquery.problema_onload/">una prueba</a> en la que se testea el framework <strong>jQuery</strong> y la función <strong><a href="http://www.thefutureoftheweb.com/blog/adddomloadevent">addDOMLoadEvent</a></strong> (el ejemplo que ponen en el enlace añade la imagen dinámicamente y no lo reproduce). Del mismo modo, se presenta una solución para ambas basados en el mismo procedimiento comentado antes.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.daveruiz.net/programacion/cuando-onload-no-es-lanzado/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Resaltar automáticamente enlaces con jQuery</title>
		<link>http://blog.daveruiz.net/programacion/auto-marcado-de-enlaces-con-jquery/</link>
		<comments>http://blog.daveruiz.net/programacion/auto-marcado-de-enlaces-con-jquery/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 09:27:25 +0000</pubDate>
		<dc:creator>Dave Ruiz</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[auto-highlight]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[marcado de enlaces]]></category>

		<guid isPermaLink="false">http://blog.daveruiz.net/?p=209</guid>
		<description><![CDATA[A modo de apunte, os dejo un método breve, usando jQuery, para resaltar los enlaces que apuntan a la página en la que nos encontramos. Muy útil, por ejemplo, para destacar en los menús la opción seleccionada automáticamente sin recurrir a PHP o a hacerlo manualmente: $&#40;document&#41;.ready&#40; function&#40;&#41; &#123; var loc = document.location.href.split&#40;/[\?#]/&#41;.shift&#40;&#41;.replace&#40;/\/$/, ''&#41;; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>A modo de apunte, os dejo un método breve, usando <a href="http://jquery.com/" target="_blank">jQuery</a>, para resaltar los enlaces que apuntan a la página en la que nos encontramos. Muy útil, por ejemplo, para destacar en los menús la opción seleccionada automáticamente sin recurrir a PHP o a hacerlo manualmente:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</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: #003366; font-weight: bold;">var</span> loc <span style="color: #339933;">=</span> document.<span style="color: #660066;">location</span>.<span style="color: #660066;">href</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/[\?#]/</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">shift</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\/$/</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</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: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">href</span> <span style="color: #339933;">==</span> loc<span style="color: #009900;">&#41;</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;selected&quot;</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></pre></div></div>

<p>El funcionamiento es muy simple. Recorre todos los elementos <strong>&lt;a&gt;</strong> de la página y compara el parámetro <strong>href</strong> con la url actual. Si coincide, añade la clase &#8216;<strong>selected</strong>&#8216; a dicho elemento. La clase &#8216;selected&#8217; deberá estar definida dentro de los estilos css de la página.</p>
<p>Un ejemplo <a href="http://lab.daveruiz.net/jquery.linkhighlight">aquí</a>.</p>
<p><strong>Actualización:</strong> Ahora no tiene en cuenta si la URL tiene barra al final o no (como en el caso de las carpetas)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.daveruiz.net/programacion/auto-marcado-de-enlaces-con-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Precarga Flash de una sola linea.</title>
		<link>http://blog.daveruiz.net/programacion/precarga-flash-de-una-sola-linea/</link>
		<comments>http://blog.daveruiz.net/programacion/precarga-flash-de-una-sola-linea/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 12:26:50 +0000</pubDate>
		<dc:creator>Dave Ruiz</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[precarga]]></category>

		<guid isPermaLink="false">http://blog.daveruiz.net/?p=199</guid>
		<description><![CDATA[Una precarga (muy) sencilla para Flash (AS3).  Suponiendo que el primer fotograma está vacío, podemos incluir el siguiente código en la linea de tiempo principal: stop(); root.loaderInfo.addEventListener(Event.COMPLETE, function(e:Event) { play(); }); Esto comenzará a reproducir el flash en cuanto termine de cargar. Además, podemos aprovechar el primer fotograma para poner un mensaje &#8216;cargando&#8230; &#8216;, que [...]]]></description>
			<content:encoded><![CDATA[<p>Una <strong>precarga (muy) sencilla </strong>para Flash (<strong>AS3</strong>).  Suponiendo que el primer fotograma está vacío, podemos incluir el siguiente código en la linea de tiempo principal:</p>
<p><code>stop(); root.loaderInfo.addEventListener(Event.COMPLETE, function(e:Event) { play(); });</code></p>
<p>Esto comenzará a reproducir el flash en cuanto termine de cargar. Además, podemos aprovechar el primer fotograma para poner un mensaje &#8216;<em>cargando&#8230; </em>&#8216;, que será lo que se muestre mientras se completa la carga.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.daveruiz.net/programacion/precarga-flash-de-una-sola-linea/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

