<?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>irama.org &#187; DHTML</title> <atom:link href="http://irama.org/news/category/technology/web/development/dhtml/feed/" rel="self" type="application/rss+xml" /><link>http://irama.org</link> <description>the web and I</description> <lastBuildDate>Tue, 08 Nov 2011 11:00:36 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.2.1</generator> <item><title>Get the text within an element&#8212;including alt text&#8212;using jQuery</title><link>http://irama.org/news/2011/08/20/get-the-text-within-an-elementincluding-alt-textusing-jquery/</link> <comments>http://irama.org/news/2011/08/20/get-the-text-within-an-elementincluding-alt-textusing-jquery/#comments</comments> <pubDate>Sat, 20 Aug 2011 00:11:12 +0000</pubDate> <dc:creator>Andrew Ramsden</dc:creator> <category><![CDATA[Accessibility]]></category> <category><![CDATA[DHTML]]></category> <guid
isPermaLink="false">http://irama.org/?p=815</guid> <description><![CDATA[When working on the butterfly lightbox I needed a way to grab the text with a link including the alt text from any images within. I couldn&#8217;t find any existing approaches, so I put together this small plugin to do the job. I thought I should post it here before I forget, or in case [...]]]></description> <content:encoded><![CDATA[<p>When working on the <a
href="/web/dhtml/butterfly/">butterfly lightbox</a> I needed a way to grab the text with a link including the alt text from any images within.</p><p>I couldn&#8217;t find any existing approaches, so I put together this small plugin to do the job. I thought I should post it here before I forget, or in case anyone else might find it useful too.</p><h2>Example</h2><p>If you had the following html:</p><p><code
class="xhtml"><pre>&lt;a id="smiley" href="">The symbol for happiness is &lt;img src="smiley.png" alt="a smiley face" />&lt;/a></pre><p></code></p><p>You could grab the accessible text using the jQuery plugin like this:</p><p><code
class="javascript"><pre>$('#smiley').accessibleText();</pre><p></code></p><p>Which would return the text &#8216;<samp>The symbol for happiness is a smiley face</samp>&#8216;.</p><h2>Plugin code</h2><p><code
class="javascript"><pre>/**
 * jQuery plugin that returns the text nodes within the target element, combined/concatenated
 * with any alt text or input values.
 */
$.fn.accessibleText = function() {
	if (this.is('img')) {
		return this.attr( 'alt' );
	} else if (this.is('input')) {
		return this.attr( 'value' );
	} else {
		return $.map( this.contents(), function( domElement ) {
			if ( domElement.nodeType === 3 ) {
				return domElement.data;
			} else if ( domElement.nodeType === 1 ) {
				var $element = $( domElement );
				if ( $element.is( 'img, imput' ) || $element.find( 'img[alt], input[value]' ).length > 0 ) {
					return $element.accessibleText();
				} else {
					return $element.text();
				}
			}
		}).join( '' );
	}
};</pre><p></code></p><p>Let me know if you found this useful, or if you know of a better solution!</p><p>Edit: Much improved version above, thanks to <a
href="http://ultimate.benboyle.id.au/">Ben</a>!<br
/> Edit again: I have updated it again to support input elements, and support using the plugin on inputs and imgs directly (this should really go on github).<br
/> Final edit: Here it is, <a
href="https://github.com/forces/usetheforces-accessibleText/">accessibleText on github</a>.</p> ]]></content:encoded> <wfw:commentRss>http://irama.org/news/2011/08/20/get-the-text-within-an-elementincluding-alt-textusing-jquery/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Butterfly lightbox, now with gallery support</title><link>http://irama.org/news/2011/06/07/butterfly-lightbox-now-with-gallery-support/</link> <comments>http://irama.org/news/2011/06/07/butterfly-lightbox-now-with-gallery-support/#comments</comments> <pubDate>Mon, 06 Jun 2011 14:27:09 +0000</pubDate> <dc:creator>Andrew Ramsden</dc:creator> <category><![CDATA[DHTML]]></category> <guid
isPermaLink="false">http://irama.org/?p=795</guid> <description><![CDATA[By popular demand (thanks Ray) the butterfly lightbox has been extended with new functionality. The biggest new feature is the addition of support for galleries. Specify a gallery using either a container element to wrap the related links, or by using the same rel attribute on related links allows a series of lightbox links to [...]]]></description> <content:encoded><![CDATA[<p>By popular demand (thanks <a
href="http://au.linkedin.com/in/raylatchmanan">Ray</a>) the butterfly lightbox has been extended with new functionality.</p><p>The biggest new feature is the addition of support for galleries. Specify a gallery using either a container element to wrap the related links, or by using the same <code
class="xhtml">rel</code> attribute on related links allows a series of lightbox links to work together, with &#8216;next&#8217; and &#8216;previous&#8217; controls presented beside the lightbox content to allow navigation between each gallery item.</p><p>Try it out here:</p><div
class="butterfly-gallery-demo"><ul><li><a
href="/assets/images/dhtml/butterfly/butterfly-1.jpg" rel="butterflies"><img
src="/assets/images/dhtml/butterfly/butterfly-1-preview.jpg" alt="Cairns Birdwing" /></a></li><li><a
href="/assets/images/dhtml/butterfly/butterfly-2.jpg" rel="butterflies"><img
src="/assets/images/dhtml/butterfly/butterfly-2-preview.jpg" alt="Orange butterfly" /></a></li><li><a
href="/assets/images/dhtml/butterfly/butterfly-3.jpg" rel="butterflies"><img
src="/assets/images/dhtml/butterfly/butterfly-3-preview.jpg" alt="Blue butterfly" /></a></li><li><a
href="/assets/images/dhtml/butterfly/butterfly-4.jpg" rel="butterflies"><img
src="/assets/images/dhtml/butterfly/butterfly-4-preview.jpg" alt="Green butterfly" /></a></li></ul></div><p>See <a
href="/web/dhtml/butterfly/">full examples, downloads and changelog</a> for more detail.</p> ]]></content:encoded> <wfw:commentRss>http://irama.org/news/2011/06/07/butterfly-lightbox-now-with-gallery-support/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Cached images have no width or height in webkit (e.g. Chrome or Safari)</title><link>http://irama.org/news/2011/06/05/cached-images-have-no-width-or-height-in-webkit-e-g-chrome-or-safari/</link> <comments>http://irama.org/news/2011/06/05/cached-images-have-no-width-or-height-in-webkit-e-g-chrome-or-safari/#comments</comments> <pubDate>Sun, 05 Jun 2011 02:03:15 +0000</pubDate> <dc:creator>Andrew Ramsden</dc:creator> <category><![CDATA[DHTML]]></category> <guid
isPermaLink="false">http://irama.org/?p=784</guid> <description><![CDATA[Stackoverflow (SO) has always been a handy resource. Today I noticed a particularly valuable comment with 0 votes. I created an SO account with the explicit purpose of voting this comment upwards, but unfortunately, I have no reputation on SO, and am not able to do this (yet). For lack of a better way to [...]]]></description> <content:encoded><![CDATA[<p><a
href="http://stackoverflow.com/">Stackoverflow</a> (SO) has always been a handy resource. Today I noticed a particularly valuable comment with <strong>0</strong> votes.</p><p>I created an SO account with the explicit purpose of voting this comment upwards, but unfortunately, I have no reputation on SO, and am not able to do this (yet).</p><p>For lack of a better way to credit <a
href="http://stackoverflow.com/users/144149/jks">JKS</a> for his <a
href="http://stackoverflow.com/questions/318630/get-real-image-width-and-height-with-javascript-in-safari-chrome#answer-4909227">insightful solution</a> I thought I&#8217;d recognise it here.</p><h2>Problem</h2><p>In webkit browsers (e.g: Chrome or Safari) the <code
class="javascript">onload</code> event fires for both cached and non-cached images, but images loading from cache seem to return dimensions of <code
class="javascript">0</code>&mdash;for both <code
class="javascript">width</code> and <code
class="javascript">height</code>.</p><h2>Solution</h2><p>JKS proposes a simple solution, a seemingly redundant <code
class="javascript">setTimeout</code> before taking your measurements seems to magically restore cached image dimensions. In jQuery, that would look like this:</p><pre><code class="javascript">$('img').load(function(){
    setTimeout(function(){
        // do something based on $('img').width and/or $('img').height
    }, 0);
});</code></pre><h2>Thanks</h2><p>Thanks again to JKS for the tip!</p> ]]></content:encoded> <wfw:commentRss>http://irama.org/news/2011/06/05/cached-images-have-no-width-or-height-in-webkit-e-g-chrome-or-safari/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>unrecognized expression: #</title><link>http://irama.org/news/2010/11/15/unrecognized-expression/</link> <comments>http://irama.org/news/2010/11/15/unrecognized-expression/#comments</comments> <pubDate>Mon, 15 Nov 2010 11:32:59 +0000</pubDate> <dc:creator>Andrew Ramsden</dc:creator> <category><![CDATA[DHTML]]></category> <guid
isPermaLink="false">http://irama.org/?p=750</guid> <description><![CDATA[I&#8217;ve tried to use one of my own jQuery plugins&#8212;that I know works&#8212;only to receive the following console messages without any reference to a code line number, hence no way to track down the culprit: uncaught exception: Syntax error, unrecognized expression: # I&#8217;m sure this has caught me out a number of times. Each time [...]]]></description> <content:encoded><![CDATA[<p>I&#8217;ve tried to use one of my own jQuery plugins&mdash;that I know works&mdash;only to receive the following console messages without any reference to a code line number, hence no way to track down the culprit:</p><p><samp
class="console exception">uncaught exception: Syntax error, unrecognized expression: #</samp></p><p>I&#8217;m sure this has caught me out a number of times. Each time is far enough apart that I have forgotten how I debugged the issue previously. And each time I <a
href="http://www.google.com/search?q=%22uncaught%20exception%3A%20Syntax%20error%2C%20unrecognized%20expression%3A%20%23%22">search the interwebs</a> in vain. No one seems to have clearly explained what causes this exception!</p><p>Next time I encounter this problem, hopefully I remember&mdash;or find&mdash;this post, solution follows&#8230;</p><h2>Solution</h2><p>This exception is thrown by jQuery when you ask it to resolve the selector <code
class="javascript">'#'</code> without an <code
class="xhtml">id</code> following. In my case it is often caused by my plugin code assuming an element has an <code
class="xhtml">id</code>. If the element doesn&#8217;t have an <code
class="xhtml">id</code>, the exception is thrown, for example:</p><pre><code class="javascript">...
var storedID = $(this).attr('id');
...
$('#'+storedID).doSomething();
...</code></pre><p>When <code
class="javascript">this</code> doesn&#8217;t have an <code
class="xhtml">id</code>, I&#8217;ve essentially asked jQuery to resolve the following:</p><pre><code class="javascript">...
$('#').doSomething();
...</code></pre><p>Which jQuery doesn&#8217;t like to do, hence the exception.</p><p><a
href="http://en.wiktionary.org/wiki/HTH">HTH</a></p> ]]></content:encoded> <wfw:commentRss>http://irama.org/news/2010/11/15/unrecognized-expression/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Zippitydoodah</title><link>http://irama.org/news/2010/08/30/zippitydoodah/</link> <comments>http://irama.org/news/2010/08/30/zippitydoodah/#comments</comments> <pubDate>Mon, 30 Aug 2010 12:44:15 +0000</pubDate> <dc:creator>Andrew Ramsden</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[DHTML]]></category> <guid
isPermaLink="false">http://irama.org/?p=682</guid> <description><![CDATA[Finally got around to fixing my corrupt zip file issues. Fresh and flawless zip files are now available for the latest versions of all widgets and plugins. BTW the compact content plugins have been updated with a bunch of small fixes (IE6 benefits the most from this release). See new examples, downloads and changelog for [...]]]></description> <content:encoded><![CDATA[<p>Finally got around to fixing my corrupt zip file issues. Fresh and flawless zip files are now available for the latest versions of all widgets and plugins.</p><p><abbr
title="By the way">BTW</abbr> the compact content plugins have been updated with a bunch of small fixes (IE6 benefits the most from this release). See <a
href="http://irama.org/web/dhtml/compact/">new examples, downloads and changelog for version 3.5</a>.</p> ]]></content:encoded> <wfw:commentRss>http://irama.org/news/2010/08/30/zippitydoodah/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
