You are at the archive for the General Web work - technical Category:

SproutCore models

http://github.com/sproutit/sproutcore/wikis/sproutcore-s-modern-model-layer
http://github.com/sproutit/sproutcore/wikis/sproutcore-s-modern-model-layer-part-2
http://github.com/sproutit/sproutcore/wikis/sproutcore-s-modern-model-layer-part-3
Those links (if you haven't checked 'em out) provide some nice insight into how the SproutCore team is thinking about javascript models. It's an interesting pattern of separation.
Basically:
In a model you use MyModel.get('blah') and MyModel.set('blah') and then (it uses ruby helpers) in a view you do something like this:
PLAIN TEXT
RUBY:

<%= progress_view :progress_bar_id,
      [...]

New Version of the Motionbox EventHandler

Take a look at the new and improved Motionbox EventHandler (now on GitHub):
http://github.com/tobowers/motionbox-eventhandler/tree/master
New and improved compatibility (and requirement) for Prototype 1.6
Better extension of custom events and better ie6 and ie7 cleanup to work around a Prototype bug (which looks like it'll be fixed).

Rollovers using the Motionbox EventHandler

YUI has yet another nice writeup on unobtrusive rollovers.
I wanted to take a sec and show you how cleanly we've implemented it using our bubbling library: the Motionbox EventHandler.
PLAIN TEXT
JavaScript:

var handleMouseover = function (evt) {
        var el = evt.element();
        var movingFrom = evt.relatedTarget;
        var isMouseover [...]

Javascript Lazy Function Definition

This is an oldy-but-goody.
If you have an expensive function in javascript that will always return the same results... make it do its dirty-work only once:
PLAIN TEXT
JavaScript:

var foo = function() {
    var t = new Date();
    foo = function() {
        return t;
    };
    return foo();
};

From: http://peter.michaux.ca/article/3556

Urgency in software development

http://www.37signals.com/svn/posts/966-urgency-is-poisonous
When a few days extra turns into a few weeks extra then there’s a problem, but what really has to be done by Friday that can’t wait for Monday or Tuesday? If your deliveries are that critical to the hour or day, maybe you’re setting up false priorities and dangerous expectations.
Sometimes I think we all [...]

Maintaining Sass constants in one file… the easy, hacky way

If you're like us and you want to have multiple separated sass files (where the resulting css gets bundled at build time) but want to maintain constants for use across the whole site in one other file, this monkey patch is for you.
Just add a file to your /lib directory (for rails) and require it [...]

Client side validation for free (as in beer)

Ruby, Rails, Web2.0 » Blog Archive » Live Validation - Easy Client-side Javascript Validation
My library of choice is livevalidation, which has a Rails companion too - if you are using Rails form helpers and standard validation on your models, you don’t have to touch anything just install livevalidation (=drop it to your javascripts folder, it’s [...]

Getting blur, focus and change (in ie) events to bubble using the Motionbox Event Handler

You might notice that blur, focus and change events do not necessarily bubble. At Motionbox we use the following hack to subscribe to all form fields at dom ready and then fire custom events so you maintain the same interface to events as everything else.
We do two things in the JS that won't work [...]

OpenID using your google account

http://openid-provider.appspot.com/
This lets your users use their Google ID to log into any OpenID consumer. It seems that the google accounts page is supporting this now someone has implemented OpenID using Google's new AppEngine. That means Yahoo, AOL, Google all support OpenID... with pledged support from Microsoft. Why bother implementing your own system [...]

The Motionbox EventHandler in use

Sometimes you just have to like convenience. Using our EventHandler I was just able to write the following code:
PLAIN TEXT
JavaScript:

MOBX.HighlightTextField = (function() {
   
    var highlightText = function (evt) {
        var el = evt.element();
        el.focus();
        el.select();
    };
   
    MOBX.EventHandler.subscribe(".highlight_on_click", "click", [...]