Fun With Mootools Part 2: Protected Methods

2012 Jul18


rivate and protected class methods can come in handy when creating complex applications. While JavaScript doesn't provide these features natively, Mootools provides a mechanism to define protected methods on a class. Protected means that the function can only be called by the originating class or a sub-class of the originating class. An attempt to call a protected function by a different class or from an instance of the class would result in error. Here is how you do that with a mootools classs:

var SecretClass = new Class({  
    , initialize: function( options ){
        this.setOptions( options );
        var s = this.protectedMethod();

     * A regular class method 
    ,publicMethod: function( name ){
        alert("Hello" + ( name || "world") + "!");

     * A protected class method
    ,protectedMethod: function( val ){
Read More
filed under:  oop mootools class javascript

Pythonic Iterators With Mootools

2012 Jun12


ython comes standard with an interesting module called, itertools, which provides a set of functions that make performing complex computations that revolve around iteration much easier. It is actually a invaluable set of tools to have at your disposal when you get comfortable with them. The module itself can work with anything that implements the iterator interface. An iterator is an object wrapper around some sequence that exposes a method called next. When the next method is called, the iterator should return the next item in the sequence and throws a StopIteration exception when there is nothing left in the sequence. While JavaScript doesn't offer anything that would resemble an iterator, that are actually very simple to implement when

Read More

Create A File Watcher With NodeJS and Child Process

2012 Apr16


t is not uncommon in the life of a software developer to want to execute a series of tasks every time a file changes. It tends to come up more frequently in development, for example, you might want to concatenate a series of files, or send and email to an administrator, etc. It becomes even more beneficial to be able to watch all of the files in a given directory. Surprisingly, for as much as it seems to creep up, it tends not to be standard machinery it a large number of programming languages and their standard libraries. Luckily, Node.js gives you all of the tools to create a file and or directory watcher.

Now, there are a

Read More

Fun With Mootools Part 1: The Class toElement method

2012 Apr15


he MooTools ( My Object Orientated Tools ) JavaScript framework is a pretty sweet piece of software. It's goal is to make developing with JavaScript easier. It provides large set of tools for building complex JavaScript applications. There are a lot of hidden goodies tucked away in the framework that kick off one of those "AHa!" moments. One of those goodies is the toElement method on classes. One of those goodies is the toElement method on classes.

The Class' method, toElement, works in tandem with the MooTools ( $ ) method. In most cases, Classes center around a DOM element for some reason or another. As a convenience, the ( $ ) will call the toElement method when it is passed

Read More
filed under:  dom oop mootools class javascript