getdave / Tanlinell

Boilerplate Wordpress theme for rapid development of new WP themes. Based on the great work of the _s ("Underscore") theme.
GNU General Public License v2.0
6 stars 2 forks source link

Add standard Dictionary object #277

Closed getdave closed 10 years ago

getdave commented 10 years ago

Add a standard Dictionary object to the framework.

(function() {

    var Dictionary = function(startValues) {
        this.values = startValues || {};
    };

    Dictionary.prototype.store = function(name, value) {
        this.values[name] = value;
    };

    Dictionary.prototype.lookup = function(name) {
        return this.values[name];
    };

    Dictionary.prototype.contains = function(name) {
        return Object.prototype.hasOwnProperty.call(this.values, name) && Object.prototype.propertyIsEnumerable.call(this.values, name);
    };

    // Register widget
    SITE.utils.Dictionary = Dictionary;
}());
getdave commented 10 years ago

Please note that due to the order in which the JS is compiled by Grunt all utils needs to be defined in the globals.js file.

getdave commented 10 years ago

Fixed in feature branch. Will close via commit.