<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>Demos/demo.js</filename>
    </added>
    <added>
      <filename>SubtleController.tmproj</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -13,13 +13,6 @@
 
 &lt;script type=&quot;text/javascript&quot; src=&quot;mootools.js&quot;&gt; &lt;/script&gt;
 &lt;script src=&quot;../Source/Plugins/SubtleController.js&quot; type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;
-&lt;script type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;
-
-var myThing = new SubtleController({
-	option1: 1,
-	option8: true
-});
-
-&lt;/script&gt;
+&lt;script src=&quot;demo.js&quot; type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;
 &lt;/body&gt;
 &lt;/html&gt;</diff>
      <filename>Demos/SubtleController.html</filename>
    </modified>
    <modified>
      <diff>@@ -1,28 +1,200 @@
 /*
 Script: SubtleController.js
-	MooTools - My Object Oriented JavaScript Tools.
+	SubtleController - A simple MVC style controller extension for MooTools
 
 License:
 	MIT-style license.
 
 Copyright:
-	Copyright (c) 2006-2007 [copyright holders](http://).
+	Copyright (c) 2008-2009 [Thomas Aylott](http://subtleGradient.com/).
 
 */
 var SubtleController = new Class({
 	
 	Implements: [Options, Events],
 	
-	options: {
+	options:{
 		
 	},
 	
-	initialize: function(options){
+	initialize: function(data, options){
 		this.setOptions(options);
+		this.bindings = $H(data);
+		window.addEvent('domready',function(){ this.ready = true; }.bind(this));
+		return this.fireEvent('initialize');
+	},
+	
+	update: function(keys){
+		try{console.log( &quot;	update(&quot;+keys+&quot;)&quot; );}catch(e){};
+		keys = $splat(keys);
+		
+		keys.each(this.updateOne, this);
+		try{console.log( &quot;	/update(&quot;+keys+&quot;)&quot; );}catch(e){};
+	},
+	
+	updateOne: function(key, value){
+		try{console.log( &quot;		updateOne(&quot;+key+&quot;)&quot; );}catch(e){};
+		var self = this;
+		
+		var bindings = this.bindings.get(key);
+		var bindingValue = value;
+		if (value==undefined || value===0)
+			bindingValue = bindings[0].get();
+		
+		bindings.each(function(binding){
+			if (!binding) return;
+			// if (binding == bindings[0])	return;
+			binding.set(bindingValue);
+		},this);
+		try{console.log( &quot;		/updateOne(&quot;+key+&quot;)&quot; );}catch(e){};
+	},
+	
+	// addBinding(binding)
+	// binding required interface:
+	// 	get(key,value)
+	// 	set(key,value)
+	// 
+	// 
+	// addBinding({
+	//     get:function(key,value){},
+	//     set:function(key,value){}
+	// });
+	// 
+	// addBinding({
+	//     get:myInstance.get.bind(myInstance),
+	//     set:myInstance.set.bind(myInstance)
+	// });
+	// 
+	// addBinding(myInstance);
+	// 
+	// addBinding(myInstance, 'key', 'key');
+	// 
+	// addBindings(myInstance, {
+	// 	'key': 'key',
+	// 	'key1': 'key1'
+	// });
+	// 
+	
+	addBinding: function(bindable, key, bindableKey){
+		try{console.log( &quot;  addBinding(&quot; + [bindable, key, bindableKey] + &quot;)&quot; );}catch(e){};
+		if (key==undefined) return this.addBindings(bindable);
+		var self = this;
+		
+		if (!this.ready &amp;&amp; /element|string/.test($type(bindable))){
+			window.addEvent('domready',function(){
+				self.addBinding(bindable, key, bindableKey);
+			});
+			return this;
+		}
+		
+		if (typeof bindable == 'string') bindable = $(bindable);
+		bindableKey = bindableKey || key;
+		
+		var thinggy = {};
+		
+		thinggy.get = bindableKey.get || function(){
+			console.log('thinggy.get(', key, bindableKey, bindable.get(bindableKey));
+			return bindable.get(bindableKey);
+		};
+		thinggy.set = bindableKey.set || function(value){
+			console.log('thinggy.set(', key, bindableKey, value);
+			return bindable.set(bindableKey, value);
+		};
+		
+		(this.bindings.get(key) || this.bindings.set(key, []).get(key)).push(thinggy);
+		
+		if (bindable.addEvent) bindable.addEvent('change', function(){
+			myController.updateOne(key, this.get(bindableKey));
+		})
+		
+		this.update(key);
+		try{console.log( &quot;  /addBinding(&quot; + [bindable, key, bindableKey] + &quot;)&quot; );}catch(e){};
+		return this.fireEvent('addBinding');
+	},
+	
+	addBindings: function(bindable, mapping){
+		try{console.log( &quot;addBindings(&quot; + [bindable, mapping] + &quot;)&quot; );}catch(e){};
+		
+		var MAPPING = {};
+		mapping = mapping || Hash.getKeys(bindable);
 		
-		$$('p').setStyle('background','blue');
+		switch($type(mapping)){
+		case 'string':
+			mapping = $splat(mapping);
+		case 'array':
+			mapping.each(function(key){
+				MAPPING[key] = key;
+			});
+			break;
+		case 'object':
+			if (!mapping.set){
+				MAPPING = mapping;
+				break;
+			}
+			
+			MAPPING = { $:mapping };
+			break;
+		default:
+			return this;
+		}
 		
-		this.fireEvent(&quot;initialize&quot;);
+		try{console.log( MAPPING );}catch(e){};
+		
+		Hash.each(MAPPING, function(bindableKey, key){
+			this.addBinding(bindable, key, bindableKey);
+		}, this);
+		
+		try{console.log( &quot;/addBindings(&quot; + [bindable, mapping] + &quot;)&quot; );}catch(e){};
+		return this.fireEvent('addBindings');
 	}
 	
 });
+
+SubtleController.Hash = new Class({
+	
+	Extends: SubtleController
+	
+});
+SubtleController.Array = new Class({
+	
+	Extends: SubtleController
+	
+});
+SubtleController.Tree = new Class({
+	
+	Extends: SubtleController
+	
+});
+SubtleController.Defaults = new Class({
+	
+	Extends: SubtleController.Hash
+	
+});
+
+
+// MEDIATING CONTROLLERS
+// Establish the bindings between properties of view objects and properties of the controller object, 
+// and then between those controller properties and specific properties of a model object.
+// 
+//     * Commit and Discard Changes
+//     * Management of Selections
+//     * Placeholder Values
+// 
+// NSController
+//     NSObjectController
+//     NSArrayController
+//     NSUserDefaultsController
+//     NSTreeController
+
+
+// COORDINATING CONTROLLERS
+// Oversee&#8212;or coordinate&#8212;the functioning of the entire application or of part of the application.
+// 
+//    * Responding to delegation messages and observing notifications
+//    * Responding to action messages
+//    * Managing the life cycle of &quot;owned&quot; objects (for example, releasing them at the proper time)
+//    * Establishing connections between objects and performing other set-up tasks
+// 
+//     NSWindowController
+//     NSDocumentController
+// </diff>
      <filename>Source/Plugins/SubtleController.js</filename>
    </modified>
    <modified>
      <diff>@@ -1,13 +1,82 @@
 describe('SubtleController', {
 
 	'before all': function(){
+		controller = new SubtleController();
 	},
 
 	'after all': function(){
+		controller = null;
 	},
+	
+	'should exist'                 : function(){ value_of(SubtleController).should_not_be_undefined(); },
+	
+	'should implement get'         : function(){ value_of(typeof controller.get         ).should_be('function'); },
+	'should implement set'         : function(){ value_of(typeof controller.set         ).should_be('function'); },
+	'should implement updateOne'   : function(){ value_of(typeof controller.updateOne   ).should_be('function'); },
+	'should implement update'      : function(){ value_of(typeof controller.update      ).should_be('function'); },
+	'should implement addBindings' : function(){ value_of(typeof controller.addBindings ).should_be('function'); },
+	'should implement addBinding'  : function(){ value_of(typeof controller.addBinding  ).should_be('function'); },
+	
+	'should implement addBinding': function(){
+		value_of(typeof controller.addBinding).should_be('function');
+	},
+
+	'':$empty
+});
+
+
+
+describe('SubtleController.Hash', {
+
+	'before all': function(){
+		controller = new SubtleController.Hash();
+	},
+
+	'after all': function(){
+		controller = null;
+	},
+
+	'should exist': function(){ value_of(SubtleController.Hash).should_not_be_undefined(); },
+	
+	'should implement get'         : function(){ value_of(typeof controller.get         ).should_be('function'); },
+	'should implement set'         : function(){ value_of(typeof controller.set         ).should_be('function'); },
+	'should implement updateOne'   : function(){ value_of(typeof controller.updateOne   ).should_be('function'); },
+	'should implement update'      : function(){ value_of(typeof controller.update      ).should_be('function'); },
+	'should implement addBindings' : function(){ value_of(typeof controller.addBindings ).should_be('function'); },
+	'should implement addBinding'  : function(){ value_of(typeof controller.addBinding  ).should_be('function'); },
+	
+	'':$empty
+});
+
 
-	'should do what it was designed to do': function(){
-		value_of( 'value' ).should_be( 'result' );
-	}
+
+describe('SubtleController.Array', {
+
+	'before all': function(){
+		controller = new SubtleController.Array();
+	},
+
+	'after all': function(){
+		controller = null;
+	},
+
+	'should exist': function(){ value_of(SubtleController.Array).should_not_be_undefined(); },
+	
+	// Basic controller functionality
+	'should implement get'         : function(){ value_of(typeof controller.get         ).should_be('function'); },
+	'should implement set'         : function(){ value_of(typeof controller.set         ).should_be('function'); },
+	'should implement updateOne'   : function(){ value_of(typeof controller.updateOne   ).should_be('function'); },
+	'should implement update'      : function(){ value_of(typeof controller.update      ).should_be('function'); },
+	'should implement addBindings' : function(){ value_of(typeof controller.addBindings ).should_be('function'); },
+	'should implement addBinding'  : function(){ value_of(typeof controller.addBinding  ).should_be('function'); },
+	
+	// Array specific functionality
+	'should implement getSelection': function(){ value_of(typeof controller.getSelection  ).should_be('function'); },
+	'should implement setSelection': function(){ value_of(typeof controller.setSelection  ).should_be('function'); },
+	
+	'':$empty
 
 });
+
+
+</diff>
      <filename>Specs/Plugins/SubtleController.js</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>267a772c0c5d35910419b91ef28f7e346d6ce653</id>
    </parent>
  </parents>
  <author>
    <name>Thomas Aylott</name>
    <email>oblivious+git@subtlegradient.com</email>
  </author>
  <url>http://github.com/subtleGradient/mootools-mvc-controller/commit/956a02e1b866bbca88044e88e1ed3fa39fb70afd</url>
  <id>956a02e1b866bbca88044e88e1ed3fa39fb70afd</id>
  <committed-date>2008-12-26T07:45:57-08:00</committed-date>
  <authored-date>2008-12-26T07:45:57-08:00</authored-date>
  <message>WIP</message>
  <tree>673d1a62ce4f6c2a5c41af74fab45758eb89f931</tree>
  <committer>
    <name>Thomas Aylott</name>
    <email>oblivious+git@subtlegradient.com</email>
  </committer>
</commit>
