/*
Mag.JS AddOns v0.1
(c) Michael Glazer
https://github.com/magnumjs/mag.js/new/master/new
*/
mag.addons={};
// helper function for non proxy supported browser i.e. NOT firefox
mag.addons.binds=function(data) {
  return {
    _onchange: function(e) {
      data[e.target.name] = e.target.value;
    }
  };
};

// show hide

mag.addons.show = function(condition) {
  return {
    _config: function(n) {
      if (!condition) n.style.display = 'none';
      else n.style.display = 'block';
    }
  };
}

mag.addons.hide = function(condition) {
  return {
    _config: function(n) {
      if (condition) n.style.display = 'none';
    }
  }
}


mag.addons.onload = function(element) {
  element.classList.remove("hide")
};


// hookin

mag.hookin('attributes', 'className', function(data) {
  if(!data.node.classList.contains(data.value)){
    data.value = data.node.classList.length>0 ? data.node.classList + ' ' + data.value : data.value
  }
  // same thing
  //data.node.classList.add(data.value)
  data.key = 'class'
})

@@ -14,16 +14,18 @@
 Ons v0.1
+.2
 %0A(c) Mic
@@ -172,16 +172,55 @@
 firefox%0A
+// state.fom = mag.addons.binds(state)%0A
 mag.addo
@@ -241,28 +241,44 @@
 ion(data
-) %7B%0A  return
+, attachTo) %7B%0A  var addThis=
  %7B%0A    _
@@ -328,16 +328,65 @@
 .name%5D =
+ e.target.type == 'checkbox' ? e.target.checked :
  e.targe
@@ -392,17 +392,16 @@
 et.value
-;
 %0A    %7D%0A 
@@ -406,12 +406,176 @@
 %0A  %7D
-;%0A%7D;
+%0A  if(attachTo) mag.addons.merge(addThis,attachTo)%0Areturn addThis%0A%7D;%0A%0Amag.addons.merge=function(source, destination)%7B%0A  for(var k in source) destination%5Bk%5D =source%5Bk%5D%0A%7D
 %0A%0A//

Update mag.addons.js