Repository: 9elements/loadie.js Branch: master Commit: bce48253eec8 Files: 10 Total size: 7.6 KB Directory structure: gitextract_veyou16p/ ├── .gitignore ├── LICENSE ├── README.md ├── bower.json ├── css/ │ ├── .sass-cache/ │ │ └── e695daaca6de778cf5ac49154d92358a4d33b6a7/ │ │ └── main.sassc │ ├── loadie.css │ ├── main.css │ └── main.sass ├── index.html └── js/ └── jquery.loadie.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ .DS_Store .DS_Store? ._* .Spotlight-V100 .Trashes ehthumbs.db Thumbs.db ================================================ FILE: LICENSE ================================================ The MIT License (MIT) Copyright (c) 2013 Dominik Schmidt Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ ## **Loadie.js** is a lightweight jQuery plugin to create a preloader that doesn't suck and that is used by big firms. ### 1. How to include Loadie.js If you haven't already, include jQuery and the latest Loadie.js Script on the AJAX-driven page. Fork me on GitHub ================================================ FILE: js/jquery.loadie.js ================================================ (function( $ ) { var Loadie = {}; /* * Generate a unique id for more than one loadie */ Loadie.uid = function() { var newDate = new Date; return newDate.getTime(); }; /* * Finishes and fades the loadie out. */ Loadie.finish = function(dom) { var loadie = $('#loadie-' + dom.data('loadie-id'), dom); loadie.fadeOut(200); } /* * Updates loadie with a float * * Loadie.update(0.2) * Loadie.update(1) // Finishes loadie, too */ Loadie.update = function(dom, percent) { var loadie = $('#loadie-' + dom.data('loadie-id'), dom); var parentWidth = dom.width(); loadie.css('width', Math.floor(percent * parentWidth) + "px"); } /* * Loadie.js initializer */ Loadie.init = function(dom, percent) { var uid = this.uid(); var loadie = dom.append($('
')); dom.data('loadie-id', uid); dom.css('position', 'relative'); this.update(dom, percent); } $.fn.loadie = function(percent, callback) { var percent = percent || 0; var parent = $(this); if(parent.data('loadie-loaded') !== 1) { Loadie.init(parent, percent); } else { Loadie.update(parent, percent); } if(percent >= 1) { setTimeout(function() { Loadie.finish(parent); }, 200); } parent.data('loadie-loaded', 1); return this; }; }( jQuery ))