Mule Design Studio's Blog: Ads are Content

Please read this piece about ads on your page, it makes a good point that the ads are part of your brand. And that you should pick them with care, not accept anything a banner farm throws at your site.

Mule Design Studio's Blog: Ads are Content: "The ads you allow on your site are part of your brand."

In my opinion this also is true about the speed you want to give your visitors. Still too many banner farms ( I won't name and shame, but you know how you are. ) and ad agencys don't do anything about speed. Using for instance extremely slow javascript solutions to serve the banners. At one of my clients I tried to convince them to just give us some xml or json and let us place the banners from the link provided by them, but they didn't wanted to do that. Hiding behind tracking the visitor 'cause it was important to them, the continued to worsen the experience we could provide for our visitors.

In fact it was so bad the the load time was multiplied by 5 with banners. FIVE times as long, all because they wanted to track users to better their experience...

Redesign in progress

As I have just upgraded my blog from wordpress to habari, I am now faced with a really nice gray skin called 'charcoal'. If you know me, you must know that this out of the box style is not my thing. So I am going for a redesign and will build a new theme as I am at it. The redesign will NOT be visible on this page, but you can follow it on habari.wnas.nl.

This is a clone of this site, as it uses the same database and stuff. In doing this I can work with real data, no lorum ipsum for me please and I won't bother you, the reader, with unnecessary breakage and stuff.

Be warned that I will not try to make the site look the same in every browser, in the end a user with ie6 or below should be able to read everything. But the really nice things will be done with css3 selectors and so on.

I short I will be pulling an andy on you. I will not be slowed down by the lowest common denominator. So for now peek behind the vail and please comment if you see anything you like...

jQuery UI slider

The past few weeks I had a lot of fun playing with jQuery UI for a client. They wanted to replace some elements in an application, sliders and such, with a more accessible solution. For that I turned to jQuery UI, as I had previously introduced jQuery as the standard javascript library for them.

As I started to play with the code I couldn't helped but be impressed by the great work that has been done by the UI team on this project. But as I looked at it more closely I found some things that could be improved.

So here are some of my grieves with it and a possible way to solve them. I am going to concentrate on the slider ( docs / demo ), as it was with that widget that I started to notice some things missing.

The way you use it is in a true jquery fashion nice and unobtrusive, once you have included the correct javascript files (for that see the documentation), you just do:

$("#slider").slider();

And shazaam, #slider has turned into a slider, nice... But, what happens to the input that people provide...

This solution is nothing without javascript, so in my book it is a nono. I can not imagine that I could use this widget on my sony erikkson k800 phone. So accessible it is not, at least not in the way the demo shows us. And as most people will just copy and paste from demo's, most sliders will not be accessible.

So what you say, a slider can never be accessible, rubbish I say. Stick with me and I will show you a very simple way to make this accessible. And in a few day I will put up some example sliders to accompany the code as suggested by Danny Lagrouw.

Improvement

First we will look at what a slider does, it provides a user the possibility to enter data. Whoa, a whole new concept... eh no.

Lets start with an simple < input type="text" /> that gives people a good opportunity to enter a value, no? But what about stepping you say, that we can solve with a few < input type="radio" />. All we have to do is write javascript that sends the value of the slider to the input and when the form is submitted, the server can sort it out.

If a user has no javascript a viable alternative is provided. So not only advantages on the user level, but did you notice that we just solved the data to server problem, in a way that requires us to write zero I admit it is boring but if you want your fancy interface to do something, it has to interface with the back-end as well.

So we start with the html, as that is the base for accessible solutions, we set up a free form slider. As we do this, we make sure that we create a fully functional option for everybody. That is, the purpose of the slider is to set a value.

<div class="slider free" id="slider">
<label for="text">
label
</label>
<input type="text" id="text" />
</div>

As you see a nice and clean solution where data can be entered and processed. What we miss is the fancy slider, which we will create with javascript like this:

// add a slider container div
// add a slider handle to slider container
// place a span to recieve the value
// and add a class to the container
// find and set the input to readonly
jQuery('.slider')
.append('<div class="slideContainer"> // br
<div class="ui-slider-handle""> // br
</div> // br
</div> // br
<span class="value"></span>') //br
.addClass('sliding') // br
.find('input').attr("readonly","readonly");
// linebreaks (br) added for readability

There you have it, an accessible solution for a slider, simple as that.

But wait, what if I have 5 steps that I want people to choose from. That I cannot do, so your solution sucks and I still am stuck with a pure javascript solution says the sceptic (I know who you are...). Oke, the second one is a slider with steps for you.

First let us see what that is, it is simply a option you choose from a limited number of options isn't it. The html solution for this is really easy, radio buttons. So of we go with html

<div class="slider steps" id="slider2">
<fieldset class="radios">
<legend>legend</legend>
<input type="radio" name="radio" value="0" id="v0" />
<label for="v0">zero</label>
<input type="radio" name="radio" value="1" id="v1" />
<label for="v1">one</label>
<input type="radio" name="radio" value="2" id="v2" />
<label for="v2">two</label>
<input type="radio" name="radio" value="3" id="v3" />
<label for="v3">three</label>
<input type="radio" name="radio" value="4" id="v4" />
<label for="v4">four</label>
</fieldset>
</div>

Just like that we have a viable and accessible solution in plain old semantic html, now for the javascript.

var sliderSteps = {
radiobuttons : ((jQuery(this) //br
.find('input[type="radio"]') //br
.length)-1) //br
.toFixed(0),
init : function(targ){
sliderSteps.createSlider(targ);
sliderSteps.set(targ)
},
set : function(targ){
var w = (100/((sliderSteps.radiobuttons*1)+1));
jQuery(targ) //br
.find('label, .ui-slider-handle') //br
.width(w+'%');
},
createSlider : function(targ){
jQuery(targ).slider({
// zoveel stappen als er radio button zijn...
steps : sliderSteps.radiobuttons,
change:function(e,ui){
var x = jQuery(this).slider('value');
var a = (x/100*((jQuery(this). //br
find('input[type="radio"]').//br
length)-1)).toFixed(0);
// set the value somewhere...
jQuery(this).find('.value').text(a);
// check the radiobutton.
var t = jQuery(this). //br
find('input[@type="radio"]')[a];
jQuery(t).attr('checked','true');
}}
);
}
}
sliderSteps.init('#slider2.steps');
// linebreaks (br) added for readability

So there you have it, a nice clean and accessible slider solution for the folks at jquery ui to include in their demos. And for everybody else to look at and maybe even use. So have fun with it and let me know if you like it.

If you see any faults in the code please let me know, but as I am on holiday now, don't except me to rush...

Here is all the demo code zip file wn.slider.zip for you to play with.

Technorati Tags:, , ,

jQuery plugin - autotab

Autotab

I recently came across a itch in jquery plugins. They are too well written, with tons of attributes and files to edit in order to configure them.
I don't want that, so I wrote a simple plug in just for auto tab.

HTML

The itch was caused by a project where the client wanted three fields for the date and wanted autotab from day to month to year. After that the user should tab himself further... I searched for a plugin as I am a lazy bastard, but the plugins available where too much for me. Some even had me giving id's to the input fields, something that I could not do as they are placed by jsf that generates id's for you. So I wanted a simple solution based on my situation, which is not an uncommon one I think.

I have three input fields on the page, with maxlength attributes so that the user could not enter wrong dates.

<input type="text" maxlength="2 />
<input type="text" maxlength="2" />
<input type="text" maxlength="4" />

As a user would want to have autotab on the page they would have to change the html to have a class of autotab on the input's that he wanted to have autotab, like this:

<input type="text" maxlength="2" class="autotab" />
<input type="text" maxlength="2" class="autotab" />
<input type="text" maxlength="4" />

Note that we need the maxlength attribute to make this work. I will explain later why...

All a user has to do to use the plugin is, include jquery on your page and the plugin, than write in you own code in the document ready function:

jQuery(document).ready(function() {
jQuery('input.autotab').autotab();
});
Presto you are done, let the script take over and relax.

the plugin

The plugin works like this, first we define that it is a plug in, something that I picked up reading this article.

jQuery.fn.autotab = function (){

Then we set it up to trigger on key up, as we need to measure the amount of code entered after his input.

 jQuery(this).keyup(function(e){

We then set up a couple of keys to be ignored as they only get in the way. For instance, if you let the tab key trigger the function it will not let you enter the field using shift tab. So no undo for you buddy...

switch(e.keyCode){
// ignore the following keys
case 9: // tab
return false;
case 16: // shift
return false;
case 20: // capslock
return false;

Once we have that sorted, we can decide it is time for action, so we will begin

default: // any other keyup actions will trigger 

First off we read out the maxlength of the targeted element and put it into a variable

var maxlength = jQuery(this).attr('maxlength');
// get maxlength value

Once we have the maximum of characters, we seek the current amount entered. (here is why we do keyup instead of keydown.)

var inputlength = jQuery(this).val().length;
// get the length of the text

If the amount of characters is equal or more than the max length

if ( inputlength >= maxlength ){
// if the text is equal or more
// than the max length

Set the focus on the next field

jQuery(this).next('input[type="text"]').focus();
// set focus to the next text field

Enjoy

Go and get the code with comments here or minified, let me know what you think of it...

And thanks for reading this far... :)

Technorati Tags:, ,

css naked day

What happened to the design?

To know more about why styles are disabled on this website visit theAnnual CSS Naked Day website for more information.

on air tour (part 1)

this is a quick write up of the first part of the onair tour, I will clean this up later...

keynote Ryan stewart

Ryan Stewart, a Platform Evangelist at Adobe, provides an introduction to Adobe AIR and how it fits into the Adobe technology platform, and the larger RIA landscape.

marketing talk, adobe rules and stuff

focuses on the cross platform strength of air
talks about 'cocomo' and 'pacifica' server side stuff. nice, but still closed source...
air wants to bring the web developers to the desktop, by bringing the good parts of the web there.

shows a air app called uvlayer. Looks nice but still too much eye candy to me.
google analytics app is cool, adds animation in a nice unobtrusive way...
uses flash with html on one screen. pdf is used well, to render a print view.
mapcache is a cool app

why ria on the desktop?
branding, extended functionality. data access. you can use the flash player to access the same information on different platforms (web mobile desktop wii).

how
using existing tools like textmate or aptana.

new
1.1 more languages
post 1.1 three platforms the same...
max 2008 dec 1-4 2008 milan italy

Building your first Adobe AIR application with Adobe Flex (Mike Chambers)

Learn how to setup your development environment and build your first AIR application using Flex 3 and Flex Builder 3.

flexbuilder based on eclipse

configuration in xml looks easy.

flex looks nasty, absolute positioning and stuff

good warning on certification, get a good one if you go commercial

Building your first AIR application with HTML and JavaScript (Kevin Hoyt)

After this session you will know how to setup the Adobe AIR SDK to allow you to develop and package AIR applications from the command line. You will also be able to leverage the Adobe AIR command line tools to enable development of HTML and JavaScript based applications. Finally, the session will demonstrate built in support for AIR development from Adobe Dreamweaver and the Eclipse based Aptana.

shows how to build air apps with textmate and terminal. explains how app development is different than web development. app development has many things in common with java development

application sandbox? javascript is more insecure on the desktop, there is where the sandbox comes in. script injection and eval should be in the non-application sandbox and the application sandbox has the more advanced air js stuff.
html rules

Leveraging HTML and JavaScript within Adobe AIR (Kevin Hoyt)

Gain a better understanding of the HTML and JavaScript environments within Adobe AIR, and explore how these technologies can be leveraged in both Flash / Flex and HTML / JavaScript-based applications. JavaScript and ActionScript script bridging will be covered, as well as how to use AIR, Flash Player and ActionScript Library APIs directly from JavaScript.

even flex developers have the java bug, putting presentation in the structure, boe..
maybe it is for demo purposes, but the stupid thing is that tons of people will copy/paste this. so that is why it is important to build your demo's as clean as possible.

Kevin's site

redesign

in progress and this time it's live. Check every few hours to see the design form slowly...

  1. step 1 setting up reset.css and looking at how to customize the php...
  2. step 2 setting up css after sleeping on a design..wnas-website-20080322.png
  3. Tweaking the css for almost a day now, got it asides from some usability issues. The logo (which is the a inside the h1) is clickable, but I got a h2 with the blog name not a link. In order to solve that I gotta throw a lot around in the php. Not used to dabbling in php anymore, so step lively now...
  4. Now for a break, will look at the icons and javascript after this, in no particular order... Site is now build using only two images (besides the ones in the articles), no javascript so just POSH..

Using javascript to help users

As javascript is maturing at a fast rate, so are developers and designers of web applications and pages. At first javascript was a frowned upon language and profession, that has changed. Now we see a situation where javascript is being called upon to help the back end developer extend the functionality. But it can also work in other fields, the user interface design part for instance, in ways that not many people are doing.

Not by creating superficial animations and such, but by understanding the needs of the user and anticipating on them. Today such a situation presented itself to me.

If you want to know what I am talking about you can skip to the demo demo page here, make sure you come back to check out the explanation...

Reducing

You know of the need to help the visitor of your page with extra functionality. For instance a 'scroll to top' link at the bottom of your page, like this.

<a href="#topP" id="scrollToTop">scroll to top</a>

Useful, if it is needed, but rather useless when the whole page is already visible to that visitor. All you do is give the visitor yet another link to be distracted by, not help him. That link should only be visible when it is needed.

That is where javascript comes into play. With a few simple lines you remove the link from the visitor when he has no need for it.

How?

First you need to know the height of you viewport, for that we turn to the infamous PPK with his script that does just that.For the script and the explanation I direct you to his page about this script which you can find on quirksmode.

We then use this script to see where on the page the link is. First we check if the link is one the page, only than we do something. We get the height of the viewport and the y-position of the link and calculate the difference. If the link is above the fold, we give it a class of inViewPort.

>> = linebreak
function hideScrollToTop(){
// we start by seeking the height of the browser
var height = (typeof window.innerHeight != 'undefined' >> ? window.innerHeight : document.body.offsetHeight);
// first we seek the link with class of scrollToTop
var up = getElementsById('scrollToTop');
// if the link exists.
if(up){
// we get the coordinates from the ppk.
var coors = findPos(up);
// we then extract the y position
yPos = coors[1];
// we calculate what's left..
var left = height - yPos;
// if the link is 'above the fold'
// aka if there is a positive number left.
// we give it a class of 'inViewPort'
if( left <= 0 ){
up.className += ' inViewPort';
}
}
}

In css we set the display of inViewPort to none and we are off.

.inViewPort {
display: none;
}

So there you have it a way of helping users by reducing visual clutter instead of putting up more stuff. You can find the script working on it's own demo page, with all of the javascript needed in the head. Go and play with it.

Technorati Tags:, , ,

@media 2008

After long consideration, about 5 minutes that is, I booked for @media 2008, I even got the super early bird discount. After being there for 3 times, including last November's @media ajax, I look forward to attending my 4th @media in a row.

@media2008.png

It promises the same conflict the other two (normal) @media's had, two tracks presenting you with the choice which one you will follow. Often the two are equally interesting and offer something for everyone.

I do hope though that the presentations will be more challenging than last years, I had a blast but didn't learn all that much that summer. No offence to the fine people from vivabit though, more a confirmation that I am on the right track maybe...

@media ajax was different though, a very focused two days which left me with my head spinning at times and not just from the beer. The presentations there varied from extremely challenging (Brendan Eich) to hilarious (Stuart Langridge).

Enough said, hope to see you all there, maybe for a few Fronteers beers....

Update, flight and hotel booked. more than 3 months in advance, a record for me...

Is web equal to print? (aka : The Question)

Warning, rave ahead

The past 10+ years, I have been building web applications and sites. And with me coming from a print / graphic design background, you inevitably get The Question popped to you one way or the other. The question is what drives us, kinda like in the matrix. And it is:

Is web equal to print?

The people who ask me (or us if you are fellow web worker) this question have different background. They are skilled project managers, very talented graphic designer and even user interface designers that ask The Question.

The Question can be asked in many different ways, it kinda depends whom it comes from...

From project managers you hear it like this:
  1. I want this to look exactly the same in every browser.
  2. It looks kinda funny on my computer (with strange settings), but don't spend any time on accessability. Just fix it!
From graphic designers you may hear something like:
  1. I really want that header in Baskerville SemiBold Italic font.
  2. Make sure that you align this the same no matter what.
  3. Just make it look like my psd.
From user interface designers you get:
  1. This is not like my visio.
  2. I don't care what the browser does, do it like I said

The strange thing is that a lot of these people have been around for quite some time doing web work. And they still don't know what the answer to The Question is.>

If you really want to know, I will provide you with a gentle answer:

the answer

So take it from me, if you want a happy, productive web worker. Don't ever asume that you know the answer to The Question is anything other than I just provided for you.

We as web developers are being hired for our skill, so use it and ask us before you assume anything about your design.

No project managers, graphic designers or user interface developers were harmed writing this post

Technorati Tags:, , , ,