Skip to content

Instantly share code, notes, and snippets.

@zbabtkis
Created July 16, 2013 15:17
Show Gist options
  • Select an option

  • Save zbabtkis/6009675 to your computer and use it in GitHub Desktop.

Select an option

Save zbabtkis/6009675 to your computer and use it in GitHub Desktop.

Revisions

  1. zbabtkis created this gist Jul 16, 2013.
    44 changes: 44 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    var Bani = (function() {
    var types = {
    'View': {
    cool: 'hi',
    age: new Date()
    }
    };

    function extend(name, type, obj) {
    var extension = function() {};

    for(var key in types[type]) {
    extension.prototype[key] = types[type][key];
    }

    for(var key in obj) {
    extension.prototype[key] = obj[key];
    }

    types[name] = extension;
    }

    function get(name) {
    var obj = new types[name]();
    if(obj.initialize) obj.initialize.apply(obj);
    return obj;
    }

    return {
    get: get,
    extend: extend
    };
    }());

    Banni.extend('SubView', 'View', {
    el: '#main-view',
    initialize: function() {
    this.$el = $(this.el);

    console.log(this)
    }
    });

    var building = Bldr.get('SubView');