Bootstrap application javascript (with jQuery)
// Check instance
if (typeof dist == "undefined" || !dist) {
var dist = {};
dist.singletons = {};
}
if (typeof dist.Common == "undefined" || !dist.Common) {
dist.Common = {};
}
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
dist.Common.Util =
{
// Array Remove - By John Resig (MIT Licensed)
array_remove: function(array, from, to) {
var rest = array.slice((to || from) + 1 || array.length);
array.length = from < 0 ? array.length + from : from;
return array.push.apply(array, rest);
},
// Round a float/decimal number (dec = chiffres apres la virgule)
roundNumber: function(num, dec) {
var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
return result;
}
};
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
<body>
<div id="test"></div>
<script type="text/javascript" src="js/app.js"></script>
<script type="text/javascript" src="js/utils.js"></script>
</body>
</html>
// Check instance
if (typeof dist == "undefined" || !dist) {
var dist = {};
}
if (typeof dist.Project == "undefined" || !dist.Project) {
dist.Project = {};
}
dist.Project.Global = function () {
this.init();
};
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// Prototype
dist.Project.Global.prototype = {
ie8: (document.all && document.querySelector && !document.addEventListener) ? true : false,
// --------------------------------------------------------------------------------------------
init: function () {
jQuery(document).ready(jQuery.proxy(this, 'onDocumentReady'));
jQuery(window).load(jQuery.proxy(this, 'onWindowLoad'));
},
// --------------------------------------------------------------------------------------------
onDocumentReady: function () {
},
// --------------------------------------------------------------------------------------------
onWindowLoad: function () {
},
// --------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------
};
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// Run instance
var app = new dist.Project.Global();