<?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>Martini Lab Blog &#187; hacks</title>
	<atom:link href="http://www.martinilab.com/blog/tag/hacks/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.martinilab.com/blog</link>
	<description>Web design, CSS, scripting, Adobe, tips and other scraps of things that come my way</description>
	<lastBuildDate>Fri, 20 Aug 2010 20:58:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Mobile Safari needs a little jQuery .live() love</title>
		<link>http://www.martinilab.com/blog/209/mobile-safari-needs-a-little-jquery-live-love/</link>
		<comments>http://www.martinilab.com/blog/209/mobile-safari-needs-a-little-jquery-live-love/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 22:53:08 +0000</pubDate>
		<dc:creator>Chris Williams</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[WebKit]]></category>

		<guid isPermaLink="false">http://www.martinilab.com/blog/?p=209</guid>
		<description><![CDATA[file under: the importance of device testing Just a quick note about how Mobile Safari gets along with .live(). As a matter of coding style, I usually assign my actions to links and buttons. Sometimes I don’t. &#60;li&#62;Title of Something &#8230; <a href="http://www.martinilab.com/blog/209/mobile-safari-needs-a-little-jquery-live-love/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><em>file under: the importance of device testing</em></p>
<p>Just a quick note about how Mobile Safari gets along with <code>.live()</code>.  As a matter of coding style, I usually assign my actions to links and buttons.  Sometimes I don’t.</p>
<pre>
&lt;li&gt;Title of Something &lt;span class="more"&gt;&lt;/span&gt;&lt;/li&gt;
</pre>
<p>This code won’t get followed by a bot to show more info about the list item.</p>
<pre>
$('.more').click(function () {
    showMore();
});
</pre>
<p>Now I have an event assigned.  However, if this list item is added dynamically…</p>
<pre>
$(myListItem).appendTo('ul');

$('.more').live('click', function () {
    showMore();
});
</pre>
<p>Works great, except on Mobile Safari.  The workaround is <strong>really</strong> hacky though.  If this ‘more’ were a link (<code>&lt;a href="#" class="more"&gt;&lt;/a&gt;</code>), there wouldn’t be a problem, just like adding <code>onclick=""</code>.</p>
<pre>
&lt;li&gt;Title of Something &lt;span class="more" onclick=""&gt;&lt;/span&gt;&lt;/li&gt;
</pre>
<p>Problem Solved.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinilab.com/blog/209/mobile-safari-needs-a-little-jquery-live-love/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Let Them Die</title>
		<link>http://www.martinilab.com/blog/167/let-them-die/</link>
		<comments>http://www.martinilab.com/blog/167/let-them-die/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 18:19:48 +0000</pubDate>
		<dc:creator>Chris Williams</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[scalability]]></category>
		<category><![CDATA[usability]]></category>

		<guid isPermaLink="false">http://www.martinilab.com/blog/?p=167</guid>
		<description><![CDATA[This month’s edition of A List Apart covers how to manage multiple browser vendors and their varying support for html5 and css3 1. We’re all aware of the different uses of border-radius in both FireFox and Webkit. And being able &#8230; <a href="http://www.martinilab.com/blog/167/let-them-die/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This month’s edition of A List Apart covers how to manage multiple browser vendors and their varying support for html5 and css3 <a href="#links"><sup>1</sup></a>.  We’re all aware of the different uses of <code>border-radius</code> in both FireFox and Webkit.  And being able to not fork the code in making rounded corners by simply writing standard css3 is tempting.  In fact, it’s ideal.  Having it managed with javascript is actually very clever, and… cool!</p>
<p>But I would propose something different entirely.  Instead of using a js library to help browsers properly render a soundly constructed html5/css5 webpage, short of making sure it doesn’t look like “total ass” on IE, just let the page render as it lay.</p>
<p>By now, web designers are largely aware of the rendering quirks of various browsers.  Little things like not adding margins to floating divs for IE’s sake, or not applying –webkit gradients to divs that contain text fields, are a part of mental mine field map that goes into our work.</p>
<p>Using a javascript library to get around this isn’t the answer.  Remember that script that lets IE6 properly render PNG transparency?  It might have been relevant to a couple of years ago when there were still a vast majority of users that used IE6, but most web designers have abandoned even trying to support the browser, much less trying to make every pixel line up properly or make every image look decent.  At some point (if our bosses let us), we move on.  </p>
<p>Sadly, we moved onto other scripts that do what html5 is supposed to do already.</p>
<p>Here’s my advice.  Write your site to work just fine without any javascript (or css for that matter) needed.  If you can still use the site, you’re good to go.  Using ajax history to browse back and forth with the browser chrome?  Make sure it works without javascript and move on.  If you’ve got some killer CSS mojo for your site, just write it.  Write that widget that does that thing with the stuff, but to say that we have to cover every contingency is unreasonable.  </p>
<p>When did we go from saying “to hell with bad browsers” to using libraries to keep these browsers on “the same page?”</p>
<p>Older browsers won’t go away (I still see Netscape occasionally show up on Google Analytics), but the support we give them can.  </p>
<p>I like to look at these barbaric browsers like the Klingons in Star Trek XI.  Their survival was in jeopardy and Kirk was having none of it.  Eventually, he came around and now we’re stuck with the Klingons and their foreheads forever.</p>
<p>Don’t let this happen to bad browsers.  Let them die.</p>
<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/Swvf3w6hcY4&#038;hl=en_US&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Swvf3w6hcY4&#038;hl=en_US&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<p><a name="links">1. Links</a></p>
<ul>
<li><a href="http://www.alistapart.com/articles/stop-forking-with-css3/">Stop Forking With CSS3</a></li>
<li><a href="http://www.alistapart.com/articles/taking-advantage-of-html5-and-css3-with-modernizr/">Taking Advantage of HTML5 and CSS3 with Modernizr</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.martinilab.com/blog/167/let-them-die/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tackling Safari’s slow gif “feature” with jQuery</title>
		<link>http://www.martinilab.com/blog/75/tackling-safaris-slow-gif-feature-with-jquery/</link>
		<comments>http://www.martinilab.com/blog/75/tackling-safaris-slow-gif-feature-with-jquery/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 23:19:36 +0000</pubDate>
		<dc:creator>Chris Williams</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Photoshop]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[WebKit]]></category>

		<guid isPermaLink="false">http://www.martinilab.com/blog/?p=75</guid>
		<description><![CDATA[Safari’s WebKit has a funny behavior of displaying animated gif files at a lower frame rate than Firefox. From what I can tell, WebKit (including Google Chrome) caps the animated gif frame rates at 10fps. While it may be faster &#8230; <a href="http://www.martinilab.com/blog/75/tackling-safaris-slow-gif-feature-with-jquery/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Safari’s WebKit has a funny behavior of displaying animated gif files at a lower frame rate than Firefox. From what I can tell, WebKit (including Google Chrome) caps the animated gif frame rates at 10fps. While it may be faster than some IE6 browsers, it’s not exactly helpful for those files with higher frame rates.</p>
<p>For example, the popular ajax loader file that hails from Apple’s own <a href="http://developer.apple.com/documentation/userexperience/Conceptual/AppleHIGuidelines/XHIGControls/XHIGControls.html">asynchronous progress indicator</a>, has 12 points and loops around once a second.  Well, for one thing, 12fps is really choppy, but it already plays slower on Apple’s nifty browser.</p>
<h2>jQuery to the rescue</h2>
<p>Did you know that jQuery can control css background positions? Are you thinking what I’m thinking?<br />
<span id="more-75"></span></p>
<h2>But first, back to drawing board</h2>
<p>So the first part was to break up the animated gif frames and spread them out across a very long canvas. Since Photoshop no longer opens animated gif files (unless you own ImageReady somewhere), Fireworks can open the file. Use Fireworks to export the frames to individual files and THEN Photoshop can import all the files as a stack.</p>
<p>File <code>&lt;Scripts&gt;</code> Load Files into Stack…</p>
<p>For our ajax loader, expand all the layers next to each other and then save it out to its own gif.  The file size won’t be that difference in fact.</p>
<h2>Now let’s get back to jQuery</h2>
<p>In our html, just set the div with a width and height to match your gif to prevent clipping and let the script do the rest.</p>
<pre lang="javascript" line="1">

$(document).ready(function(){
	var bgimage = 'url(images/ajax-loader-long.gif)';
	var frames = 24;
	var mpf = parseInt(1000/frames)  // how many miliseconds in each frame
	var currentFrame = 0;
	var offset = 0;

	$('.animate').css('background-image', bgimage);

	function animate() {
		offset = currentFrame * 64;
		$('.animate').css('background-position', '-' + offset + 'px 0px');
		currentFrame = (currentFrame == frames) ? 1 : currentFrame + 1;
	}

	setInterval(animate, mpf);
});
</pre>
<p>Now we have a script that will snap the position of the background over each “frame” at the correct frame rate. Actually, the frame rate is not divisible by 1000, but it’s close and it’s not like you could tell.</p>
<p>The only problem with this script is that it’s constantly running. If you look at the page in Firebug, your going to see the code whipping around with new values all the time. Annoying! Also, chances are your page isn’t going to need some animation playing constantly. Ajax loaders are intermittently called when a simple action is called as a… asynchronous progress indicator! Who knew.</p>
<p>So we’re going to put in a cancel command to this script: <strong>clearTimeout</strong>.</p>
<pre lang="javascript" line="1">

$(document).ready(function(){
	var bgimage = 'url(images/ajax-loader-long.gif)';
	var frames = 24;
	var mpf = parseInt(1000/frames)  // how many miliseconds in each frame
	var currentFrame = 0;
	var offset = 0;
	var runAnimate = 0;

	$('.animate').css('background-image', bgimage);

	function animate() {
		offset = currentFrame * 64;
		$('.animate').css('background-position', '-' + offset + 'px 0px');
		currentFrame = (currentFrame == frames) ? 1 : currentFrame + 1;
	}

	runAnimate = setInterval(animate, mpf);

	$('.animate').toggle(
		function () {
			clearTimeout(runAnimate);
		},
		function () {
			runAnimate = setInterval(animate, mpf);
		}
	);
});
</pre>
<p>Add in a toggle so show how to turn on and off the animation and were done.</p>
<p>It even works on ie6!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinilab.com/blog/75/tackling-safaris-slow-gif-feature-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My Peeps on Twitter</title>
		<link>http://www.martinilab.com/blog/43/my-peeps-on-twitter/</link>
		<comments>http://www.martinilab.com/blog/43/my-peeps-on-twitter/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 18:52:31 +0000</pubDate>
		<dc:creator>Chris Williams</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[usability]]></category>

		<guid isPermaLink="false">http://www.martinilab.com/blog/?p=43</guid>
		<description><![CDATA[Somehow I’ve ended up following too many people on Twitter. Not that I don’t want to read each and every person’s tweet, but sometimes, I really don’t care and just want to follow a select few. LiveJournal has a filter &#8230; <a href="http://www.martinilab.com/blog/43/my-peeps-on-twitter/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Somehow I’ve ended up following too many people on Twitter.  Not that I don’t want to read each and every person’s tweet, but sometimes, I really don’t care and just want to follow a select few.  LiveJournal has a filter feature for both posting and reading specific sets of your LJ buddies.  Maybe twitter will set up some kind of filter.</p>
<p>Until then, here’s some css code file you can add to your Safari preferences.</p>
<pre lang="html4strict" line="1">
/* turn off all tweets */
li.status {
	display: none;
}

/* now turn on for your peeps */
li.u-zeuscomics, li.u-kingbaz, li.u-pvponline, li.u-seanjackson, li.u-AronHead, li.u-UltraboyNYC {
	display: block;
}
</pre>
<p>NOTE: css is case-sensitive.</p>
<p>It doesn’t fix the timeline of the site, so if your “peeps” haven’t updated in a while, you’ll get a blank page.  Ah, the silence!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinilab.com/blog/43/my-peeps-on-twitter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
