Skip to content

Instantly share code, notes, and snippets.

@notmatt
Forked from silentrob/gist:2897913
Created June 8, 2012 20:29
Show Gist options
  • Save notmatt/2897994 to your computer and use it in GitHub Desktop.
Save notmatt/2897994 to your computer and use it in GitHub Desktop.

Revisions

  1. notmatt revised this gist Jun 8, 2012. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    FMWK = { 'hulk' : 'smash' }
    FMWK.button = function() {
      var _this = this;
    console.log(this.hasOwnProperty('hulk') ? "HULK SMASH" : "");
    this.el = document.createElement('button');
      ['hide','show'].forEach(function(method){
        FMWK.button.prototype[method] = function(){
  2. @silentrob silentrob revised this gist Jun 8, 2012. 1 changed file with 3 additions and 4 deletions.
    7 changes: 3 additions & 4 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,16 @@

    FMWK.button = function() {
      var _this = this;
    this.el = document.createElement('button');
      ['hide','show'].forEach(function(method){
        FMWK.button.prototype[method] = function(){
          $(_this.el)[method].apply($(_this.el), Array.prototype.slice.call(arguments))            
          $(_this.el)[method].apply($(_this.el), Array.prototype.slice.call(arguments));
         }
      });

    return this;
    }

    var b1 = FMWK.button();
    var b2 = FMWK.button();
    var b1 = new FMWK.button();
    var b2 = new FMWK.button();

    b1.hide() // fires on b2
  3. @silentrob silentrob created this gist Jun 8, 2012.
    17 changes: 17 additions & 0 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@

    FMWK.button = function() {
      var _this = this;
    this.el = document.createElement('button');
      ['hide','show'].forEach(function(method){
        FMWK.button.prototype[method] = function(){
          $(_this.el)[method].apply($(_this.el), Array.prototype.slice.call(arguments))            
         }
      });

    return this;
    }

    var b1 = FMWK.button();
    var b2 = FMWK.button();

    b1.hide() // fires on b2