/*
Mag.JS AddOns v0.1.6
(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
// state.fom = mag.addons.binds(state)
mag.addons.binds = function(data, attachTo, callback) {
    var handler = function(e) {
        var val =  e.target.type == 'checkbox' ? e.target.checked : e.target.value
        var name = e.target.name
        if(data[name] && data[name].type=='fun' && typeof data[name] == 'function'){
            data[name](val)
        } else {
            data[name] = val
        }
        if(typeof Object.observe !== 'undefined'){
            // two-way bindings
            Object.observe(data, function(changes) {
              // update target with changes
              changes.forEach(function(change) {
                if (change.type == 'update') {
                  // update the related dom
                  if(e.target.name ==change.name)
                    e.target.value = change.object[change.name]
                }
              })
            })
        }
        if(callback && typeof callback == 'function') callback()
    }
    var addThis = {}
    
    Object.observe

    var events = ['_onchange', '_oninput']
    for (var k in events) addThis[events[k]] = handler
    if (attachTo) mag.addons.merge(addThis, attachTo)
    return addThis
};

mag.addons.when=function(arrayOfPromises, callback){
    Promise.all(arrayOfPromises).then(callback)
}

mag.addons.merge = function(source, destination) {
    for (var k in source) destination[k] = source[k]
}

// return object of getter values
mag.addons.getProp=function(data){
    var newData={}
    Object.keys(data).forEach(function(k){
        if(data[k].type=='fun' && typeof data[k] == 'function') newData[k] = data[k]()
    })
    return newData
}

// 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")
};


// hookins

mag.hookin('attributes', 'key', function(data) {
    // remove system key from being added to attributes in html
    data.value = null
})

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'
})

@@ -589,24 +589,27 @@
    %7D%0A       
+ //
  if(typeof O
@@ -648,20 +648,23 @@
         
+//
     
+ 
 // two-w
@@ -678,24 +678,27 @@
 ings%0A       
+ //
      Object.
@@ -734,24 +734,27 @@
 s) %7B%0A       
+ //
        // up
@@ -781,24 +781,27 @@
 nges%0A       
+ //
        chang
@@ -829,32 +829,35 @@
 hange) %7B%0A       
+ //
          if (cha
@@ -880,32 +880,34 @@
 ate') %7B%0A        
+//
           // upd
@@ -896,24 +896,25 @@
 //          
+ 
 // update th
@@ -926,32 +926,35 @@
 ated dom%0A       
+ //
            if(e.
@@ -979,32 +979,35 @@
 ge.name)%0A       
+ //
              e.t
@@ -1050,24 +1050,27 @@
 ame%5D%0A       
+ //
          %7D%0A 
@@ -1071,24 +1071,27 @@
    %7D%0A       
+ //
        %7D)%0A  
@@ -1096,20 +1096,23 @@
         
+//
     
+ 
 %7D)%0A     
@@ -1105,32 +1105,35 @@
 /     %7D)%0A       
+ //
  %7D%0A        if(ca

Update mag.addons.js