Archive for the ‘Javascript’ Category

New York, New York

Monday, November 12th, 2007

I’ve been living in Melbourne for 7 years now, and I have decidely itchy feet.

I moved to Melbourne for work just after the dot-com crash of 2000 and it was always meant to be a temporary stop on my way to New York, which I visited and fell in love with.

I think it’s time to get that dream moving again.

I am happy to work remotely to get a foot in the door, if that suits. Happy to sign up for a short-term contract if it gets me to your fair city.

So, if you’re in New York and need a developer with lots of experience, expert skills in Java, PHP and Ruby, and a penchant for user experience, drop me a line.

Speaking at Melbourne Ruby User Group

Friday, August 24th, 2007

I’m speaking at the Melbourne Ruby User Group next week. Either on using Amazon Web Services. or hacking with Prototype (probably focussed on the new 1.6.0 features).

Lineup & Location

ThoughtWorks
Level 11, 155 Queen St

  • Pete Yandell - SpiffyAttributes
  • Clifford Heath - HAML
  • Mike Bailey - Jester
  • Ben Schwarz  - JS Hacking
  • Toby Hede - Amazon AWS and/or Prototype Hacking
  • Marty Andrews - Logging and/or the Rails Plugin Architecture

Snippets: dynamic CSS classes

Tuesday, August 14th, 2007

I found myself over the weekend needing to create CSS classes dynamically. Not just add a class to a DOM element, which is easy, but actually building a CSS class based on user input and attaching it to selected elements.

Proved to be harder than it sounds.

  var green = {
    color: "#00FF00"
  };

  Object.extend(Element.Methods, {
    setClass:function(element, className) {
      element = $(element);
      element.addClassName(className);
      klass = eval(className);
      for (var property in klass) {
        element.style[property] = klass[property];
      }
    }
  });
  Element.addMethods();

  function changeClass() {
    elements = document.getElementsByClassName("red");
    elements.each(function(e) {
      e.setClass("green");
    });
  }

This code lets you specify a “CSS Class” as a Javascript object. Then you can use the Element.setClass to add the properties to the element style. The changeClass() function finds all the “red” elements and sets them to use the “green” Virtual CSS class. I use addClassName to add the new class name, which may cause conflicts with existing CSS classes.

The name is added because I was thinking that I would need a way to remove the class. At the moment I don’t, but it wouldn’t be all that hard to implement. You would store the element’s original properties and remove the class name, and reset all the overridden styles. The disadvantage of what I am doing is overriding the styles at the element level - these will take precedence in CSS.

I am positive there is an easier way of doing this with Prototype and Scriptaculous, so let me know if find one. I looked at interacting with the styles directly using the DOM, but it’s pretty messy.

Multimedia died for a reason

Thursday, June 28th, 2007

The 37 Signals Blog has stirred up controversy again with a post about HTML, CSS, and JavaScript:

On the user experience side of things, we’re not even close to tapping out the potential of HTML. The majority of web sites and applications still suck.

Of course, the flame-war began immediately:

“Flex/Flash/Apollo is totally the future”
“No it isn’t”

I think that is definitely true that we have only scratched the surface of HTML. It’s only in the last couple of years that HTML, JavaScript and CSS have really become advanced, stable and widespread enough to be used for complex application development.  Even features that have gained ubiquity, like auto-complete text fields that talk back to the server, are very recent additions to the developer’s toolkit.

Having worked with WebStart for several years now, the hardest problem to solve is the additional installation. Java makes this particularly hard, but when you use a runtime on-top of the browser, you will always have this additional barrier to adoption. Rather than prospective customers being able to use your application straight away, you are placing an extra hurdle in front of them.

The problem is not insurmountable, but it is there.

On top of all of this, most RIAs I have seen don’t really do much more than a “vanilla” Web 2.0 application anyway. I come from a Multimedia background  (I did a lot of CD Authoring with Director in the 90s) and I’ve done far too much Swing, so I’ve seen many, many fantastically bad applications. There is a reason why software tends toward the a standard set of application principles - business applications don’t need much singing and dancing.

Auto-complete, edit-in-place, drag/drop, lists, options are all standard fare with HTML, CSS and JavaScript  About the only piece that is really missing from the stack is the ability to zoom effectively.

Whichever side of the debate you come down on, you have to admit that it’s going to be an interesting few years.