Archive for October, 2007

Adding effects to your website

Tuesday, October 16th, 2007

This post might be a little over the standard in terms of technicality. But then, this is a developer’s blog, so why not enlighten you. In this episode, we are going to teach you how to add very simple effects and animations to your page.

Over the last few years, the term AJAX and web 2.0 have become synonym with bleeding edge web software. Although we are not going to show you how to do AJAX, we will show you how to use some of the really nice javascript animations that are available in today’s web 2.0 world. This short tutorial DOES require that you know of some HTML and that you have put your eyes on javascript before. So let’s get this started.

We’re going to take our starting point in the Scriptaculous javascript library (which is an extension of the prototype library). The combination of Scriptaculous and Prototype is what we have used at motigo from the beginning.

We start out by having a <div> layer, which is a standard element in HTML. Our <div> looks like this:

<div id="my_element" style="width: 200px; height: 50px; background: red; color: white; padding: 5px;">
  This is the content inside the DIV
</div>

The code above produces this: (a box with the dimensions of 200×50 pixels, a red background, white text, and an inside margin of 5 pixels)

This is the content inside the DIV

Now - we can begin to manipulate it. Notice that the ID of the DIV is my_element. That means that we can do this (with scriptaculous and prototype loaded):

<a href="#" onclick="Effect.toggle('my_element', 'blind'); return false;">Toggle blind effect</a>
<a href="#" onclick="Effect.toggle('my_element', 'appear'); return false;">Toggle appear effect</a>

This produces this:
Toggle blind effect
Toggle appear effect

Try to click the links and see what happens with the red box.

Pretty neat. Pretty simple!

The reason why we say return false; in the end of the onclick="" attribute, is that we don’t want to redirect the browser to the link of href="".

What allows us to do all this, is because we have Scriptaculous and Prototype loaded on this page. We have done so, first by downloading the Scriptaculous and Prototype files over on the Scriptaculous website, uploaded these files to our server, and including the following HTML code at the top of our page (inside the <head> tag):

<script type="text/javascript" src="/js/prototype.js"></script>
<script type="text/javascript" src="/js/scriptaculous.js"></script>

The downside of using Scriptaculous and Prototype is it’s large size (in kilobytes). Other smaller libraries include Dojo, MooTools, and Ext JS.

Let us know if this is too advanced, or if you would like to know more.

UPDATE: This article seems to have hit a too high level of complexity. We are sorry if all this doesn’t make much sense. The primary problem our readers have experiences is that they are not aware that they need to upload the javascript files from Scriptaculous and Prototype to their own server - and that it is those files that allow us to do the effects.

NOTICE: The effects work in the most popular browsers. Some older browsers are not supported.

Build your website from reusable components

Tuesday, October 9th, 2007

Building an entire new website from scratch is a large task. To ease the task, we often tend to fall back and reuse parts of old websites we have created. This is how you evolve your own look-and-feel. As we develop more and more websites, our vocabulary of possible outcomes of a website designs increase. We thus become better at building websites over time, as our over time larger design vocabulary lets us pick and choose exactly what we want. Our designs in this way become more and more refined as we develop more and more websites. Our experience grow.

We are all in the same boat! What separates us is the magnitude of our experience: the number of websites we have created. You, the reader might just have created your first website, or you might be a veteran - either way you are in quest for the same thing: to expand your design vocabulary.

Fortunately, we are all in luck. Several individuals and organizations have been jotting down their experience in website design, and put it out for free on the internet for you to use. These websites hold collections of user interface design patterns. In formal words, design pattern are:

“…recurring solutions to solve common problems…”

Source: ui-patterns.com

Jennifer Tidwell continues:

“Each of these patterns (which are more general) and techniques (more specific) are intended to help you solve design problems. They’re common problems, and there’s no point in reinventing the wheel every time you need, say, a sortable table — plenty of folks have already done it, and learned how to do it well.”

Source: Designing Interfaces

At motigo, we find design patterns extremely useful. This is why we would like you to get started using them. Why not harvest the knowledge of many experienced designers before you? Start out by checking out these sites:

How have you used design patterns? And have you been using them without knowing about them?