Skip to content

Instantly share code, notes, and snippets.

@JordanDelcros
Last active August 29, 2015 14:22
Show Gist options
  • Save JordanDelcros/0d44bb5ee1083f57a162 to your computer and use it in GitHub Desktop.
Save JordanDelcros/0d44bb5ee1083f57a162 to your computer and use it in GitHub Desktop.

Revisions

  1. Jordan Delcros renamed this gist Jul 30, 2015. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions Class.js → elegant-class.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    /*
    Must easy and elegant way to create classes or complex objects in JavaScript
    */
    (function( window, document ){

    function Class( options ){
  2. Jordan Delcros revised this gist May 29, 2015. 1 changed file with 20 additions and 22 deletions.
    42 changes: 20 additions & 22 deletions Class.js
    Original file line number Diff line number Diff line change
    @@ -1,35 +1,33 @@
    (function( window, document ){

    // The Class

    function Class( options ){

    if( this instanceof Class ){

    return Class.fn.init(options);

    }
    else {

    return new Class.fn.init(options);


    };


    if( this instanceof Class ){

    return Class.fn.init(options);

    }
    else {

    return new Class.fn.init(options);

    };

    };

    Class.fn = Class.prototype = {
    constructor: Class,
    init: function(options){
    init: function( options ){

    return this;

    },
    myMethodA: function(){},
    myMethodB: function(){}
    };

    Class.fn.init.prototype = Class.fn;

    window.Class = Class;

    })(window, document);
  3. Jordan Delcros renamed this gist May 29, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. Jordan Delcros created this gist May 29, 2015.
    35 changes: 35 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    (function( window, document ){

    // The Class
    function Class( options ){

    if( this instanceof Class ){

    return Class.fn.init(options);

    }
    else {

    return new Class.fn.init(options);


    };

    };

    Class.fn = Class.prototype = {
    constructor: Class,
    init: function(options){

    return this;

    },
    myMethodA: function(){},
    myMethodB: function(){}
    };

    Class.fn.init.prototype = Class.fn;

    window.Class = Class;

    })(window, document);