Category: JavaScript

May8

 

InfoQ posted a “virtual panel” in which framework authors answer questions about HTML5. Thomas Fuchs and I, among others, answer questions about how (if?) HTML5 will make our lives easier, and what more we want out of JavaScript in the future.

Mar24

 

Dean Edwards explains how the standard “callback” pattern in JavaScript is too brittle for something like a “DOM ready” event. Prototype appears to be the one major library that handles this “correctly.” WIN!

Mar20

 

That SXSW panel I was on the other day (I am, um, awful at self-promotion, even on my own blog) has already been released via podcast, to my own astonishment. John Resig’s got the slides, so as soon as he posts them I’m sure we’ll find a way to synchronize them to this audio.

Feb19

 

Aren’t you annoyed at having to remember to declare your script tags in the correct order? Your dependency management solution has become tiresome. As I explain on the Prototype blog, we hope that Sprockets will become a natural part of how Prototype add-ons are distributed.

Jan21

 

Thomas and Amy apparently don’t have enough awesome stuff going on yet, so they’ve decided to release a book on JavaScript performance. Thomas tells me his findings have some implications for how we package Prototype & script.aculo.us.

Jan11

 

How to write a robust isArray. Faced with a long-standing problem, Juriy finds the solution by reading the spec. Let this be a lesson to all of us.

Jan8

 

Git has a redesigned homepage that boasts about the major open-source projects that use the up-and-coming DVCS. Prototype is one of them. Thanks, Scott!

Jan5

 

Code: Disabling text selection

Inspired by Thomas's classic and event delegation.

/**
 *  Element.enableTextSelection(element, isEnabled)
 *  
 *  Enables or disables text selection within the given element.
 *  - element (Element): The element within which a dragging motion
 *    _should_ or _should not_ behave like text selection.
 *  - isEnabled (boolean): Whether to enable or disable text selection.
**/
(function() {
  var IGNORED_ELEMENTS = [];
  function _textSelectionHandler(event) {
    var element = Event.element(event);
    if (!element) return;
    for (var i = 0, node; node = IGNORED_ELEMENTS[i]; i++) {
      if (element === node || element.descendantOf(node)) {
        Event.stop(event);
        break;
      }
    }
  }
  
  if (document.attachEvent)
    document.onselectstart = _textSelectionHandler.bindAsEventListener(window);    
  else
    document.observe('mousedown', _textSelectionHandler);
    

  Element.addMethods({
    enableTextSelection: function(element, isEnabled) {
      if (isEnabled) {
        IGNORED_ELEMENTS = IGNORED_ELEMENTS.without(element);
      } else {
        if (!IGNORED_ELEMENTS.include(element))
          IGNORED_ELEMENTS.push(element);
      }
    }
  });
})();

Dec10

 

This image “evolution” simulator would be a good benchmark for the up-and-coming JavaScript engines… but, sadly, Google Chrome doesn’t yet support Canvas#getImageData. Anyway, both Firefox 3.1b2 and the latest WebKit nightly do very well.

Nov16

 

PDoc: inline documentation for Prototype

As 2008 turns into 2009, it’s past time to dust off some dormant projects in the Prototype realm. I’ve been playing around with PDoc for the first time since April in an effort to get it ready for the next major Prototype release.
Wait — have I not talked about PDoc yet? How is that possible?
OK,

Built with WordPress, Prototype, Slicehost, and other accoutrements. Colophon →