h1. Entwine - Support for Concrete UI style programming in jQuery By Hamish Friedlander, with thanks to "SilverStripe":http://www.silverstripe.com/ Entwine tries to provide a new model of code organisation - a replacement for Object Oriented programming that is focused on adding functions to groups of DOM elements based on the structure and contents of those DOM elements. It's a merging of the model and view layer that initially seems weird, but can give very powerful results. We're standing on the shoulders of giants here - combining ideas from Prototype's behaviour & lowpro and jQuery's effen & livequery (who themselves stole ideals from Self's Morphic UI and others), but extending & combining the concepts presented in those tools to provide a complete alternative to traditional OO concepts - self-aware methods, inheritance, polymorphisim and namespacing without a single class definition. h2. Requirements Currently Entwine layers itself on top of jQuery. Any patch level of jQuery from 1.7 through 1.10 or 2.0 should work. Because we patch some internal jQuery APIs there can be a delay between a new version of jQuery being released and Entwine providing support. h2. Getting Started * Walk through the "Tutorial":http://hafriedlander.github.com/jquery.entwine/tutorial/ * Watch the "Screencast":http://www.vimeo.com/6353390 (shot during a introductory developer meeting at SilverStripe) * Join the "Google Group":http://groups.google.com/group/jquery-entwine and let us know what you think, or what other features you'd like to see h2. Name change jQuery Entwine used to be called jQuery Concrete. The name was changed to avoid confusion with another product. The concrete function remains as an alias, but all new code should use entwine h2. Basic use h4. First intro To attach methods to DOM nodes, call the `entwine` function on a jQuery selector object, passing a hash listing the method names and bodys
  $('div').entwine({
    foo: function(..){..},
    bar: function(..){..}
  });
  $('#a').foo();
  
    Internal text
    
    Nonsense
  
  $('.internal_text').entwine({
    foo: function(){ console.log(this.text()); }
  });
  $('.attribute_text').entwine({
    foo: function(){ console.log(this.attr('rel')); }
  });
  $('div').foo();
  Internal text
  Attribute text  
  $('div', el).entwine(...)
  $([ela, elb, elc]).entwine(...)
  $('').entwine(...)
  
    Internal text
    
    Nonsense
  
  $('div').entwine({
    foo: function(){ console.log(this.text()); }
  });
  $('.attribute_text').entwine({
    foo: function(){ console.log(this.attr('rel')); }
  });
  $('div').foo();
  Internal text
  Attribute text
  Nonsense
  
    
  
    Background will turn blue when clicked on
    Will also have blue background when clicked on
    Will have green text when clicked on. Background color will not change
  
  $.entwine('foo.bar', function($){
    $('div').entwine({
      baz: function(){}
    });
  });
  $('div').entwine('foo.bar').baz()
  $('div').entwine({
    onclick: function(){ this.css({backgroundColor: 'blue'}); }
  });
  
  $.entwine('foo', function($){
    $('div').entwine({
      onclick: function(){ this.css({color: 'green'}); }
    });
  });
  $.entwine('foo', function($){
    $('div').entwine({
      bar: function() { this.baz(); this.qux(); }
      baz: function() { console.log('baz'); }
    })
  })
  
  $('div').entwine({
    qux: function() { console.log('qux'); }
  })
  Internal text
  $.entwine('foo', function($){
    $('div').entwine({
      bar: function() { this.baz(); }
    });
    $('span').entwine({
      baz: function() { console.log('a'); }
    });
  })
  
  
  $('div').entwine({
    baz: function() { console.log('b'); }
  })
  $.entwine('zap', function($){
    $('div').entwine({
      bar: function() { .. }
    })
    $.entwine('pow', function($){
      $('div').entwine({
        baz: function() { .. }
      })
    })
  })
  $.entwine('foo', function($){
    $('div').entwine({
      bar: function() { this.entwine('.').baz(); }
    })
  })
  $.entwine('foo', function($){
    $('div').entwine({
      bar: function() { console.log('a'); }
    })
  })
  
  $('div').entwine('foo', function(){
    this.bar();
    this.bar();
    this.bar();
  });
	sudo gem install gemcutter
    sudo gem tumble
    sudo gem install jspec
    jspec spec/spec.html -p src,spec