Last active
August 29, 2015 13:56
-
-
Save mfrancois/9003214 to your computer and use it in GitHub Desktop.
Bootstrap application javascript (with jQuery)
This file contains hidden or 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
| // 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(); |
This file contains hidden or 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
| <!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> |
This file contains hidden or 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
| // 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; | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment