Blaze Blog

Archive For: AJAX

Oct23

Using CSS Tweak for Deployment

A few people have asked me recently how and why they should use CSS optimization tools like CSS Tweak.

I think there is a general misunderstanding about when these tools should be used, and how they can benefit your site overall. The issue for most people is that once they have optimized their CSS, it is completely unreadable and impossible to update. Optimizing the local development copy of your CSS isn’t really the right way to use the tool.

The idea of CSS Tweak is to provide optimization for deployment. So, this means you would keep a development copy of all your CSS files on your local machine. Then, when you are ready to upload your site, run the CSS through CSS Tweak, and upload the optimized files. This way, you have a perfectly maintainable copy on your own machine, and an identical copy on the server, only fully optimized, reducing your site load times and bandwidth usage.

That’s all really, I just thought I’d talk about this briefly, as it seems to be a recurring question. I don’t think I made this all that clear when I first released CSS Tweak, so really it’s my own fault! Has anyone been using CSS Tweak in this fashion already?

May17

Durable: Best Overall Design!

Durable has been named the best overall design in the Wordpress Theme Competition.

Arena WPI am very honored to have been named the winner by the judges as the field contained many great designs this time around.

Well, actually to be honest I am a little surprised. There were designs in the competition that are aesthetically far more pleasing than Durable. I was sure that those designs would have the extra edge over the themes that concentrated on function over form. I guess that was where the multiple categories came into play, my personal favorite was Derek’s very beautiful Foliage Mod Theme which won “Most Creative Design”. Well done Derek.

That begs a question though, are people beginning to pick themes based not solely on the look and feel, but also the bundled functionality? I can’t help but think that people’s feelings towards what makes a good Wordpress theme have changed quite a lot since the Wordpress 1.5 competition. The boundaries of what theme authors can do with Wordpress has been pushed since 1.5, simply because better documentation is now available, and we’ve had more time to fiddle around with the Wordpress code.

Anyway, that was more of a brain dump than anything. It’s just great to see that judges really took time to look at the themes, judging functionality just as much as the look and feel.

Thanks to everyone who put in their free time to make this competition possible, your hard work is much appreciated.

Update: I have released a minor update to Durable. Version 0.2.1 is available for download and decreases page load times by 25%.

Jan18

Multiple AJAX loading indicators

By Andy in AJAX, Development

One of my biggest issues in the latest version of this site was how to get multiple AJAX loading indicators working on one page.

Getting a single AJAX loading progress indicator into your web application can be a relatively straightforward task thanks to a simple piece of Javascript from Thomas Fuchs:

// lang javascript
Ajax.Responders.register({
onCreate: function() {
 if($('busy') && Ajax.activeRequestCount>0)
 Effect.Appear('busy',{duration:0.5,queue:'end'});
},

onComplete: function() {
 if($(’busy’) && Ajax.activeRequestCount==0)
 Effect.Fade(’busy’,{duration:0.5,queue:’end’});
}
});

However, from what I could tell (and subsequently experienced) is that by using this code, you are limited to only one progress indicator per page. This caused me problems, as on my Archives page I have a progress indicator for when the application is fetching monthly archives, but also for the live search function that appears on every page. Whenever I activated an AJAX request by using either function, both the loading indicators would be displayed, thus confusing the user.

So, how is it possible to get around this? Well, from what I can see it’s impossible to pass the ID of a loading indicator into Thomas’ script. The trick is to move the hiding and displaying of the indicators into function calls for the “onComplete” and “onCreate” events within your specific AJAX request:

// lang javascript
function getMonthResults(vars)
{
  var url = 'archives_month.php';
  var pars = 'm=' + vars;
  var target = 'monthResults';
  var myAjax = new Ajax.Updater(target, url, {
asynchronous:true,
onCreate: function() { showLoader('mArchive_loader'); },
onComplete: function() { hideLoader('mArchive_loader'); },
parameters: pars,
method: 'get'
  });
  var element = document.getElementById(target);
}

The two events now call separate functions that pass the ID of the loading indicator, allowing you to define which indicator to hide or display:

// lang javascript
function showLoader(loader)
{
   new Effect.Appear($(loader), {duration: 0.5});
}

function hideLoader(loader)
{
   new Effect.Fade($(loader), {duration: 0.5});
}

Simple as that. Now, I’m not saying that this is the “offical” or “ideal” way of going about this task, but it’s the one that worked for me. You can also extend the show and hide functions, to add an effect to your target container by passing the target as well as the loader to the function. For example, I have used the following as my show and hide functions:

// lang javascript
function loadingRequest(loader, target)
{
   new Effect.Appear($(loader), {duration: 0.5});
   $(target).style.display = "none";
}

function completedRequest(loader, target)
{
   new Effect.Fade($(loader), {duration: 0.5});
   new Effect.BlindDown($(target));
}

This means that when the AJAX request has completed, the results will slide into view using the “BlindDown” effect from the Scriptaculous library. A nice added extra.

Technorati Tags: ,

Oct22

Getting into Ruby on Rails

I’ve been reading the new book “Agile Web Development with Rails” over the last day or two, and I have been truly amazed with what this language and framework combination can achieve.

It’s refreshing to see a web language that is truly object oriented, and a framework that strictly adheres to the “Model, View, Controller” method of development.

If you haven’t heard of Ruby on Rails yet, then you should go and check out this online video of a simple blogging application being produced in 15 mins. Take note that not a single line of SQL is written. Truly remarkable.

I’ll be writing more about rails once I have finished the book and have a grasp of everything it has to offer as a framework. So far, it seems to be killing PHP development in every area.

Jul23

Colour Mod

By Andy in AJAX, Javascript, News

This is a seriously cool piece of work. It’s one of those gems that you find now and again and think “how in the world did they do that?”

Colour Mod is a colour selector tool that can be used on a website to let users dynamically change stylesheet colour settings. One of it’s most practical applications that I’ve seen so far is on Color Combos, where you can change any colour within a combo dynamically without any page refreshes.

The entire tool is coded in javascript & css, and surprisingly (thanks to some proprietary DirectX alpha filters) works in IE6.0 ( although not IE5 Mac). Anyway, what really caught my eye was the actual color palette, where you can drag a bullet around just like you do in Photoshop. The effect was so seamless that it took me several uses to realize that this was all thanks with some very creative javascript – and not just a regular form element.

The tool can be downloaded and plugged into your own website ( which also gives people like me a chance to study just how on earth it was done ) as well as a dashboard widget for OS X 10.4.

Even if you don’t end up using this tool, just take a look at how it is done. Clever and creative, I love it.