<?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; Technology</title> <atom:link href="http://irama.org/news/category/technology/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>Cache manifests and Firefox</title><link>http://irama.org/news/2011/03/20/cache-manifests-and-firefox/</link> <comments>http://irama.org/news/2011/03/20/cache-manifests-and-firefox/#comments</comments> <pubDate>Sun, 20 Mar 2011 09:32:19 +0000</pubDate> <dc:creator>Andrew Ramsden</dc:creator> <category><![CDATA[HTML5]]></category> <guid
isPermaLink="false">http://irama.org/?p=769</guid> <description><![CDATA[I&#8217;ve been playing with offline web applications this afternoon. Generally, it&#8217;s pretty straightforward: Reference your manifest file in the &#60;html> tag of each page. Fill out your .manifest file with the relevant resources you want to be cached and available offline. Configure your server to serve .manifest files at text/cache-manifest. Most browsers picked this up [...]]]></description> <content:encoded><![CDATA[<p>I&#8217;ve been playing with <a
href="http://www.w3.org/TR/html5/offline.html">offline web applications</a> this afternoon. Generally, it&#8217;s pretty straightforward:</p><ol><li>Reference your manifest file in the <code
class="xhtml">&lt;html></code> tag of each page.</li><li>Fill out your <code>.manifest</code> file with the relevant resources you want to be cached and available offline.</li><li>Configure your server to serve <code>.manifest</code> files at <code>text/cache-manifest</code>.</li></ol><p>Most browsers picked this up fine (tested: Opera 11, Chrome 7, Mobile Safari iOS 4.3), but unfortunately I ran into&#8230;</p><h2>Firefox issues</h2><p>Firefox (tested: 3.6.13 and 4.0b11) refused to pull resources back from appCache&mdash;even though it reported successfully caching 175kB of data&mdash;or request any resources that weren&#8217;t cached. Firefox just presented the plain HTML for each pages without loading images, stylesheets, scripts or any other assets.</p><p>After much searching and trial and error, I came across a recommendation on stackoverflow to use <code>http://*</code> within the <code>NETWORK</code> section of the manifest for the sake of Firefox, and sure enough&#8230;</p><h2>It works!</h2><p>Final code samples as follows&#8230;</p><h3>HTML (<code>/index.html</code>)</h3><p><code
class="xhtml"><pre>&lt;!DOCTYPE HTML>
&lt;html manifest="/path/to/my.manifest">
&lt;body>
...
&lt;/body>
&lt;/html></pre><p></code></p><h3>Manifest (<code>/path/to/my.manifest</code>)</h3><p><code><pre>CACHE MANIFEST
#ver0.08
CACHE:
images/bg-noise-tile.png
images/site-name-bg.png
images/menu-bar-divide.png
# etc ...
NETWORK:
http://*
*</pre><p></code></p><h3>Apache configuration (<code>/.htaccess</code>)</h3><p><code><pre># Ensure manifests are served using the correct mime type
AddType text/cache-manifest .manifest</pre><p></code></p><h2>Thank you</h2><p>Thanks to <a
href="http://dalibornasevic.com/">dalibor</a> for pointing out that <a
href="http://stackoverflow.com/questions/2705023/html5-cache-network-doesnt-work#answer-2943661"><code>http://*</code> is required for Firefox</a>.</p><p>One other handy resource is <a
href="http://diveintomark.org/about">Mark Pilgrim</a>&#8216;s <a
href="http://diveintohtml5.org/offline.html">Let&#8217;s take this offline</a>, and if it had mentioned <code>http://*</code> it would have been perfect!</p> ]]></content:encoded> <wfw:commentRss>http://irama.org/news/2011/03/20/cache-manifests-and-firefox/feed/</wfw:commentRss> <slash:comments>0</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> </channel> </rss>
