dom111.co.uk http://www.dom111.co.uk/blog Move along. Nothing to see here. Wed, 26 Oct 2011 16:37:09 +0000 en hourly 1 http://wordpress.org/?v=3.2.1 Prototype 1.6: Event.live http://www.dom111.co.uk/blog/coding/prototype-1-6-event-live/295 http://www.dom111.co.uk/blog/coding/prototype-1-6-event-live/295#comments Wed, 26 Oct 2011 16:33:30 +0000 dom111 http://www.dom111.co.uk/blog/?p=295 I’ve recently been using Prototype 1.6 and had a need for a jQuery.live() clone. The following code appears to emulate mouse events well (form submits [and maybe more...] do not work in IE):

Event.live = function(s, e, f) {
    Event.observe(document, e, function(event) {
        if (Element.match(event.target, s)) {
            if (!(f.call(event.target, event))) {
                event.stop();
            }
        }
    });
}

To use this run something like the following:

Event.live('div#doesnt_exist_yet a.button', 'click', function() {
    // run this when the button is clicked
});

Hope this helps!

]]>
http://www.dom111.co.uk/blog/coding/prototype-1-6-event-live/295/feed 0
jQuery serializeObject 0.1 http://www.dom111.co.uk/blog/coding/jquery-serializeobject-0-1/283 http://www.dom111.co.uk/blog/coding/jquery-serializeobject-0-1/283#comments Thu, 31 Mar 2011 22:37:47 +0000 dom111 http://www.dom111.co.uk/blog/?p=283 I found myself in a situation recently where I wanted to have access to variables that would have been posted, in a the same structure as if the form had been posted and returned the JSON, using this jQuery plugin and Douglas Crockford’s JSON library, I think I’ve done it!

You can download the script here and there’s a demo here.

]]>
http://www.dom111.co.uk/blog/coding/jquery-serializeobject-0-1/283/feed 0
jQuery Ajaxify Lite http://www.dom111.co.uk/blog/coding/jquery-ajaxify-lite/275 http://www.dom111.co.uk/blog/coding/jquery-ajaxify-lite/275#comments Fri, 29 Oct 2010 09:33:19 +0000 dom111 http://www.dom111.co.uk/blog/?p=275 I’ve been using the ajaxify plugin for a while now and felt it needed an update.

Since .live() is supported for more events now, I thought it was time to get it working how I always wanted it to work.

Using the same syntax on links as before, you can specify the target div, using the target=”" attribute and the url is automatically extracted from the href=”" or action=”" attribute meaning you can keep your code simple and valid but have easily Ajax populated content, as since I’m using .live() any future links/forms that match the original selector will continue to be ‘ajaxified’.

There’s a demo here and source code too, as ever.

Also available through Google Code.

]]>
http://www.dom111.co.uk/blog/coding/jquery-ajaxify-lite/275/feed 3
simpleGallery 0.2 – Minor updates http://www.dom111.co.uk/blog/coding/simplegallery-0-2-minor-updates/268 http://www.dom111.co.uk/blog/coding/simplegallery-0-2-minor-updates/268#comments Mon, 25 Oct 2010 13:39:49 +0000 dom111 http://www.dom111.co.uk/blog/?p=268 I’ve updated the gallery script I created in July. I’ve re-factored the code into a static class for easier modification and have created a config.ini settings file, to save modifying the script itself.

New features:

* Image titles
* Separate configuration
* Standard mode with safe URLs as well as mod_rewrite enabled ‘nice’ URLs
* Added ‘..’ parent folder to galleries

The demo page has been updated and the script is available to download here.

]]>
http://www.dom111.co.uk/blog/coding/simplegallery-0-2-minor-updates/268/feed 0
TextMate: Minify CSS Regular Expression http://www.dom111.co.uk/blog/coding/textmate-minify-css-regular-expression/258 http://www.dom111.co.uk/blog/coding/textmate-minify-css-regular-expression/258#comments Fri, 08 Oct 2010 09:36:29 +0000 dom111 http://www.dom111.co.uk/blog/?p=258 I love TextMate. It’s saved me so much time since I’ve started using, I think I’d find it impossible to use another editor. However, the format CSS compressed snippet, doesn’t quite do what I’d expect.

Luckily the Find and Replace regular expression engine is pretty cool!

I’ve got this small (!) regular expression that should minify your CSS, by putting:

;?\s*([:;,{}])\s*|\s*/\*()[\S\s]+?\*/\s*|(\s)\s+

in the Find box and:

$1

in the replace box, and by ensuring that Regular expression is ticked, you should be able to minify CSS with the Replace All button!

TextMate Find and Replace: Minify CSS

Note: I haven’t test this particularly extensively, or with the IE expression(). This may produce undesired results! It certainly seems to be fine on all the standard CSS I’ve tested it with.

]]>
http://www.dom111.co.uk/blog/coding/textmate-minify-css-regular-expression/258/feed 0
SequelPro: Twilight Theme http://www.dom111.co.uk/blog/coding/sequelpro-twilight-theme/252 http://www.dom111.co.uk/blog/coding/sequelpro-twilight-theme/252#comments Thu, 16 Sep 2010 16:56:21 +0000 dom111 http://www.dom111.co.uk/blog/?p=252 I’ve been using SequelPro for quite some time. I think it’s a great app for working with MySQL databases and I love the ability to style the Query Editor.

I created a theme (which might only work with the nightly builds…) that is not entirely disimilar to the Twilight theme for TextMate.

Thought I’d share it, in case anyone else would like it too!

It looks like this:

Download it here.

]]>
http://www.dom111.co.uk/blog/coding/sequelpro-twilight-theme/252/feed 0
autoPopulate 0.1 http://www.dom111.co.uk/blog/coding/autopopulate-0-1/249 http://www.dom111.co.uk/blog/coding/autopopulate-0-1/249#comments Tue, 14 Sep 2010 17:40:17 +0000 dom111 http://www.dom111.co.uk/blog/?p=249 I’ve had it with filling in the same details repeatedly while testing a new form’s validation!

So much so, that I’ve spent time writing a pointless bookmarklet that makes me even more lazy and probably isn’t doing anything for my typos to real words ratio, however, I thought it might be useful to other people too.

There’s a demo here, and a generator for your own custom one here too.

The uncompressed source is linked at the bottom of the demo page, in case you want to see how it works or extend it. There are some comments there too. (But not many…)

]]>
http://www.dom111.co.uk/blog/coding/autopopulate-0-1/249/feed 14
Gallery 0.1 http://www.dom111.co.uk/blog/coding/gallery-0-1/245 http://www.dom111.co.uk/blog/coding/gallery-0-1/245#comments Wed, 14 Jul 2010 19:28:08 +0000 dom111 http://www.dom111.co.uk/blog/?p=245 I recently took it upon myself to create a very small gallery project to easily display images from a folder structure in a fairly pleasing way…

This is the result!

You can get the script here

]]>
http://www.dom111.co.uk/blog/coding/gallery-0-1/245/feed 0
Minify CSS – Shrink your CSS down to size http://www.dom111.co.uk/blog/coding/minify-css-shrink-your-css-down-to-size/238 http://www.dom111.co.uk/blog/coding/minify-css-shrink-your-css-down-to-size/238#comments Fri, 16 Apr 2010 18:07:11 +0000 dom111 http://www.dom111.co.uk/blog/?p=238 I know there are probably many services offering it already out there, and it’s not too hard to run right in TextMate, but I haven’t been able to find it in 30 seconds of Googling (well, I couldn’t at work, but I’ve since found this… Oh well!), so I set up a quick script to do it for me:

http://www.dom111.co.uk/files/minifycss/

If it’s useful, I might set up a memorable URL, let me know in the comments :)

I did set up syntax highlighting, using codemirror, which looked pretty nice, but made the minification (on large-ish files) take far too long. I haven’t really tested on any huge files, so try this at your own risk, but it seems faster that TextMate was.

]]>
http://www.dom111.co.uk/blog/coding/minify-css-shrink-your-css-down-to-size/238/feed 0
jQuery – Persistent Input Labels http://www.dom111.co.uk/blog/coding/jquery-persistent-input-labels/236 http://www.dom111.co.uk/blog/coding/jquery-persistent-input-labels/236#comments Thu, 01 Apr 2010 08:03:58 +0000 dom111 http://www.dom111.co.uk/blog/?p=236 Do you forget whats supposed to go in the field the second you tab onto it?

Are you concerned your users will too?

Never fear! This simple plugin places an element of the same type underneath the current element and shows the contents of the title attribute (or whatever attribute you decide to use) as a label until you type text into the box!

It’s a very early version, and probably has a few bugs, but I’ve implemented enough to make it fairly useful I think. Unfortunately when you resize a textarea in webkit, it doesn’r fire the resize event, so I’ve added a workaround using mousemove (I tried to only capture mousemove if a mousedown had been detected, but to no avail…)

You can see a demo here, and get the files here.

]]>
http://www.dom111.co.uk/blog/coding/jquery-persistent-input-labels/236/feed 0