Friday, January 16, 2009

New Portfolio - Thank You AppEngine

I've been trying to get my act together about showing my talents online. So finally I can ditch my old portfolio(No, I'm not linking to it, it's terrible).

Well, here you go:

Jethro Larson's Online Portfolio Thingy

Tuesday, December 23, 2008

Using ternary to choose between two methods in javascript

I found this little gem while looking at the jQuery source. I'd forgotten that you can reference properties/methods using obj["str"]. Pretty cool tip for getting your code smaller. Plus I like ternaries.

Before:
if($(this).hasClass("myClass")){
 $(this).hide();
}else{
 $(this).show();
}
After:
$(this)[$(this).hasClass("myClass")?"hide":"show"]();

This is doubly useful if you got a big chain in jQuery and don't want to break it for the if statement.

Edit(2009-3-1): As of jQuery 1.3 there's is now an optional parameter for toggle(), toggleClass(), slideToggle(), fadeToggle(). It's a bool that sets the toggle state. So now the previous statement can be written like this as well:

$(this).toggle(!$(this).hasClass("myclass"));

Monday, November 03, 2008

Markdown Ubiquity Command

I wrote this post in Markdown and converted it to html before posting using my new Markdown-to-HTML Ubiquity Command.

Much thanks to John Fraser's Showdown.js. All the hard work he'd already done I just connected it to Ubiquity.

I've very pleased that my first Ubiquity Command is so useful. I hope someone else thinks so too.

Now if only I could save the markdown rather than the html when posting. Someday I'll leave blogger...someday.

Friday, October 31, 2008

background-position-x & background-position-y

I sent the following to the w3c CSS Group:

The background-position-x and background-position-y properties have been in Internet Explorer for a long time now. However they haven't made it into the CSS spec, despite their usefulness. While you can say that the regular background-position property is suitable, without being able to specify the x and y positions separately usage can get excessively verbose when using sprites.

Take the following example:

#tabs li a{background: url(tabs_sprite.png);}

li#slide_2 a{background-position: -122px 0;}
li#slide_3 a{background-position: -244px 0;}
li#slide_4 a{background-position: -366px 0;}
li#slide_1.current a{background-position: 0 -41px;}
li#slide_2.current a{background-position: -122px -41px;}
li#slide_3.current a{background-position: -244px -41px;}
li#slide_4.current a{background-position: -366px -41px;}
li#slide_1 a:hover{background-position: 0 -82px;}

li#slide_2 a:hover{background-position: -122px -82px;}
li#slide_3 a:hover{background-position: -244px -82px;}
li#slide_4 a:hover{background-position: -366px -82px;}

Could be simplified to:

#tabs li a{background: url(tabs_sprite.png);}

li#slide_2 a{background-position-x: -122px;}
li#slide_3 a{background-position-x: -244px;}
li#slide_4 a{background-position-x: -366px;}
#tabs li.current a{background-position-y: -41px;}

#tabs li a:hover{background-position-y: -82px;}

I feel that one of the big goals for CSS3 would be to ease the use of sprites as they can improve performance of pages by a lot. Being able to load up all the UI images into a single file would decrease download time significantly and re-skinning a site would be as simple as changing a single reference and modifying a single image file.

I was actually surprised to learn it's not in the CSS3 spec as it eases spriting by quite a bit.

Browser Implementation This should be trivial since the property pretty straight-forward and two browsers already support it: IE5+ & Safari 1.2+ http://www.aptana.com/reference/html/api/CSS.field.background-position-y.html

Wednesday, October 29, 2008

Using target site's favicon to distinguish external links

I was thinking about how to distinguish internal from external links and I came up with this:(jQuery)

$("a[rel='external']").each(function(){
  $("<img src='http://"
    + this.hostname+"/favicon.ico' class='icon' />")
    .prependTo(this);
});

Thursday, October 02, 2008

7 Deadly Sins of Website Design

  1. Gluttony - Bloated Stylesheets and Markup
  2. Lust - Overuse of “cool” javascript or CSS effects.
  3. Envy - Copying Apple or other high-profile websites
  4. Wrath - Defying standard web conventions for no practical reasons. Such as not using tables for tabular data.
  5. Sloth - Making a bunch of special cases in your Design or Code rather than redesigning.
  6. Greed - Selling out with deplorable advertising tactics like pop-ups, In-text Advertising, and animations.
  7. Pride - Keeping a design well past its expiration or making design elements unquestionable.

Thursday, September 25, 2008

The 7 Plagues of the CSS Amateur

(Draft)

  1. Div-itis
  2. Class-itis
  3. Over-specificity
  4. Redundant Properties and/or Selectors
  5. CSS Frameworks/Reset Stylesheets
  6. Poor accessibility
  7. Poor semantics