// Inspired from Paul Irish and Jason Garber

APP = {};
 
GIStyle = {
  exec: function( controller, action ) {
    var ns = APP, action = ( action === undefined ) ? "init" : action;
 
    if ( controller !== "" && ns[controller] && typeof ns[controller][action] == "function" ) {
      ns[controller][action]();
    }
  },
 
  init: function() {
    var body = document.body,
        controller = body.getAttribute("data-controller"),
        action = body.getAttribute("data-action");
 
    if(typeof APP.init == "function") APP.init();
    GIStyle.exec(controller);
    GIStyle.exec(controller, action);
  }
};

$(document).ready(GIStyle.init);
$(document).on('page:load', GIStyle.init) // support Turbolinks
// Inspired from Paul Irish and Jason Garber

APP = {};
 
GIStyle = {
  exec: function( controller, action ) {
    var ns = APP, action = ( action === undefined ) ? "init" : action;
 
    if ( controller !== "" && ns[controller] && typeof ns[controller][action] == "function" ) {
      ns[controller][action]();
    }
  },
 
  init: function() {
    var body = document.body,
        controller = body.getAttribute("data-controller"),
        action = body.getAttribute("data-action");
 
    if(typeof APP.init == "function") APP.init();
    GIStyle.exec(controller);
    GIStyle.exec(controller, action);
  }
};

$(document).ready(GIStyle.init);
remove turbolinks support, alternativly use jquery.turbolinks gem