Created
August 12, 2011 00:28
-
-
Save eniolopes/1141171 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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