Skip to content

Instantly share code, notes, and snippets.

@eniolopes
Created August 12, 2011 00:28
Show Gist options
  • Save eniolopes/1141171 to your computer and use it in GitHub Desktop.
Save eniolopes/1141171 to your computer and use it in GitHub Desktop.
//egenda.js
var egenda = egenda || {
'construtores' : {},
'comportamentos' : {}
};
if(!('console' in window)){
(function() {
var metodos = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
window.console = {};
for (var i = 0; i < metodos.length; ++i) {
window.console[metodos[i]] = function() {};
}
}());
}
(function($){
egenda.executaPropriedade = function(propriedade){
$.each(egenda[propriedade], function(){
if($.isFunction(this)){
this();
}
});
return this;
};
/**
* Aplica comportamentos depois que o pjac carrega o conteudo
*/
egenda.depoisPjax = function(){
$('data-pjax').bind('end.pjax', function(){
egenda.executarPropriedade('comportamentos');
});
};
})(jQuery);
$(function(){
/**
* Inicializa os contrutores das classes
* Os construtores devem ser declarados como egenda.construtores.nomeDoConstrutor = function(){}
*
* Aplica comportamento a elementos da página
* Os comportamentos devem ser declarados como egenda.comportamentos.nomeDoComportamento = function(){}
*/
egenda.executaPropriedade('construtores').executarPropriedade('comportamentos');
egenda.depoisPjax();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment