How NOT to Optimize your Drupal website for a iPhone or iPod

Posted on

Don't follow the advice posted below to "optimize" your site based on the user agent string.  The author suggests doing so in the page.tpl.php for your theme.  However, this means you can NEVER turn caching on for your site.  Also, the uses ereg functions to "detect" the device.  These functions are now deprecated by PHP, meaning they won't be supported in the future.  The matches used are also very simple, and could be done much faster using the strpos or stripos functions. 

Optimise your Drupal website for a iPhone or iPod

If you need to detect the useragent,  you should probably use hook_init() or hook_boot() to do so, since they run regardless of the cache settings.  You'd also have to plan more thoroughly how to react to different devices -  if in fact you thinkg that's a good solution.  A better approach would be to use pretty clean, flexible markup and use CSS media queries to provide device-specific stylesheets, as in Return of the Mobile Stylesheet.

Tags: Drupal

─── ✧ ─── ✦ ─── ✧ ───

BPA harm not scientifically conclusive

Posted on

While its hard to read the press release from the World Health organization below and make any sense of the tortured language, it basically says that while food is the main source of BPA exposure, the science as to its effects is inconclusive. Also, BPA is eliminated from the body rather quickly. Was it a good idea to rush to remove it from plastics, like baby bottles? What do you think - better safe than sorry?

The meeting concluded that, at this stage, it is difficult to interpret the relevance of these studies in the light of current knowledge of this compound. Until these associations can be confirmed, initiation of public health measures would be premature.

WHO HT: Reason

Tags: BPA, Science

─── ✧ ─── ✦ ─── ✧ ───

A jQuery plugin to increase a link's target area

Posted on

I'm working on a mobile web site and one of the things that can be done to make it more usable is to make targets larger, so that user's don't have to be as accurate to trigger an event.  It is an application of Fitt's Law. In this case, I was trying to make the target for a link (a html tag) as large as possible and came up with the following plugin. It will look within an element, and if it finds an a tag, it will make the whole element click to go to the destination found. It will also apply a class to the element when users click on it, so that you can visually indicate its been triggered.

Usage

$('.big-list').linkifyContainer({'hover_class' : 'item-hover'});

Source

/**
 * Linkify's a containing div with the first link it finds.
 */
(function( $ ) {
    $.fn.linkifyContainer = function(options) {
        var settings = {
            'hover_class' : 'link-hover'
        }

        return this.each(function() {
            if (options) {
                $.extend(settings, options);
            }
            if ($('a:first', this).length > 0) {
                $(this).click(function() {
                    window.location = $('a:first', this).attr('href');
                }).mousedown(function() {
                    $(this).addClass(settings.hover_class);
                }).mouseup(function() {
                    $(this).removeClass(settings.hover_class);
                })
            }
        });
    }
})( jQuery );

Tags: jQuery, Usability

─── ✧ ─── ✦ ─── ✧ ───