diff --git a/lib/jquery_lazyload/.gitignore b/lib/jquery_lazyload/.gitignore new file mode 100644 index 0000000000..b512c09d47 --- /dev/null +++ b/lib/jquery_lazyload/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/lib/jquery_lazyload/.jshintrc b/lib/jquery_lazyload/.jshintrc new file mode 100644 index 0000000000..886f45bd2b --- /dev/null +++ b/lib/jquery_lazyload/.jshintrc @@ -0,0 +1,15 @@ +{ + "curly": true, + "eqeqeq": true, + "eqnull": true, + "immed": true, + "noarg": true, + "quotmark": "double", + "trailing": true, + "undef": true, + "unused": true, + + "node": true, + "jquery": true, + "browser": true +} \ No newline at end of file diff --git a/lib/jquery_lazyload/CHANGELOG.textile b/lib/jquery_lazyload/CHANGELOG.textile new file mode 100644 index 0000000000..ab7aa4cd57 --- /dev/null +++ b/lib/jquery_lazyload/CHANGELOG.textile @@ -0,0 +1,121 @@ +h1. Lazy Load Plugin for jQuery + +Lazy Load delays loading of images in long web pages. Images outside of viewport wont be loaded before user scrolls to them. This is opposite of image preloading. + +Using Lazy Load on long web pages containing many large images makes the page load faster. Browser will be in ready state after loading visible images. In some cases it can also help to reduce server load. + +Lazy Load is inspired by "YUI ImageLoader":http://developer.yahoo.com/yui/imageloader/ Utility by Matt Mlinac. + +h2. How to Use? + +Lazy Load depends on jQuery. Include them both in end of your HTML code: + +

+
+ +You must alter your HTML code. URL of the real image must be put into data-original attribute. It is good idea to give Lazy Loaded image a specific class. This way you can easily control which images plugin is binded to. Note that you should have width and height attributes in your image tag. + +
+ +then in your code do: + +
$("img.lazy").lazyload();
+ +This causes all images of class lazy to be lazy loaded. + +More information on "Lazy Load":http://www.appelsiini.net/projects/lazyload project page. + +h4. Install with "bower":http://bower.io + +
$ bower install jquery.lazyload
+ +h1. License + +All code licensed under the "MIT License":http://www.opensource.org/licenses/mit-license.php. All images licensed under "Creative Commons Attribution 3.0 Unported License":http://creativecommons.org/licenses/by/3.0/deed.en_US. In other words you are basically free to do whatever you want. Just don't remove my name from the source. + +h1. Changelog + +h2. 1.9.3 + +* Improved Bower support + +h2. 1.9.2 + +* Bower support ("mrzmyr":https://github.com/mrzmyr) + +h2. 1.9.1 + +* Fix iOS5 detection for iPhone ("Berik Visschens":https://github.com/berikv) +* Use .attr() instead of .data() since jQuery caches values when using latter. Fixes "#37":https://github.com/tuupola/jquery_lazyload/pull/37, "#144":https://github.com/tuupola/jquery_lazyload/issues/144 and "#101":https://github.com/tuupola/jquery_lazyload/issues/101 ("Lorenz an Mey":https://github.com/swiftyone). +* Do not add data:uri placeholder for non image elements. + +h3. 1.9.0 + +* Add support for CSS background images. +* Make external placeholder image optional by providing default 1x1 grey image as data uri ("Dave Mc Nicoll":https://github.com/mcNdave) +* Fix bug "#47":https://github.com/tuupola/jquery_lazyload/pull/47 and "#71":https://github.com/tuupola/jquery_lazyload/issues/71. Mobile Safari window height changes when scrolling. ("Girvan":https://github.com/girvan) + +h3. 1.8.5 + +* Revert "#70":https://github.com/tuupola/jquery_lazyload/issues/70 because it causes more problem than solves. Only proper fix in Webkit browsers is to set width and height either as attributes or in CSS. Without width and height Webkit sees image as size 0x0 and causes jQuery to assume they are not visible. Fixes bugs "#99":https://github.com/tuupola/jquery_lazyload/pull/99, "#98":https://github.com/tuupola/jquery_lazyload/issues/98 and "#88":https://github.com/tuupola/jquery_lazyload/issues/88. +* Fix bug "#118":https://github.com/tuupola/jquery_lazyload/issues/118. Scrollstop event was not compatible with jQuery 1.9.x. +* Fix bug "#120":https://github.com/tuupola/jquery_lazyload/pull/120. Sometimes event.originalEvent was not defined under iOS. ("David G. Durand":https://github.com/daviddurand) + +h3. 1.8.4 + +* Support for "jQuery plugin repository":http://plugins.jquery.com/ + +h3. 1.8.3 + +* Proper fix for "#48":https://github.com/tuupola/jquery_lazyload/pull/48. If image did not have width and height set Webkit browsers needed initial scroll for images to display. ("@sc-aboudreau":https://github.com/sc-aboudreau) + +h3. 1.8.2 + +* Workaround for bug "#30":https://github.com/tuupola/jquery_lazyload/issues/30 IOS5 Safari did not load images when navigating with back button. + +h3. 1.8.1 + +* Fix bug "#48":https://github.com/tuupola/jquery_lazyload/pull/48. In some cases initial scroll was needed for images to load. ("Nick George":https://github.com/Izzmo) +* Fix bug "#42":https://github.com/tuupola/jquery_lazyload/pull/42. Reset internal failure counter when image is found. Makes counter logic more intuitive. ("Josep del Rio":https://github.com/joseprio) +* Fix bug "#52":https://github.com/tuupola/jquery_lazyload/pull/42. Fix :in-viewport convenience method. ("Jonathan Palardy":https://github.com/jpalardy) + + +h3. 1.8.0 + +* Allow different elements to use different containers. ("Rob Walch":https://github.com/robwalch) + +h3. 1.7.1 + +* Fix bug "#18":https://github.com/tuupola/jquery_lazyload/pull/18. Document was always scrolled to top issue on IE 7 and Chrome 17 if using jQuery 1.6 or older. ("Ross Allen":https://github.com/ssorallen) +* General code speedup ("Valentin Zwick":https://github.com/vzwick) + +h3. 1.7.0 + +* Optimized viewport selectors. Around 25% "speed increase":http://jsperf.com/lazyload-1-7-0 compared to "1.6.0":http://jsperf.com/lazyload-1-6-0. +* Add _data_attribute_ parameter. Allows custom naming of original data attribute. ("Bryan Chow":https://github.com/bryanchow) +* Track window resize event. ("Simon Baynes":https://github.com/baynezy) +* Add _appear_ event. This function is called when image appears to viewport but before it is loaded. +* Add _load_ event. This function is called when image is loaded. ("Nick Larson":https://github.com/ifightcrime) +* Renamed _effectspeed_ parameter to _effect_speed_. Old version will still works couple of versions. This parameter was previously undocumented. +* Fix _failure_limit_ bug "#19":https://github.com/tuupola/jquery_lazyload/issues/19. ("Brandon":https://github.com/Brandon0) + +h3. 1.6.0 + +* Rename original attribute to data-original to be HTML5 friendly. +* Remove all code regarding placeholder and automatically removing src attribute. It does not work with modern browsers. Must use data-original attribute instead. +* Add support for James Padolseys "scrollstop event":http://james.padolsey.com/javascript/special-scroll-events-for-jquery/. Use when you have hundreds of images. +* Add _skip_invisible_ parameter. When true plugin will skip invisible images. ("Valentin Zwick":https://github.com/vzwick) +* Renamed _failurelimit_ parameter to _failure_limit_. Old version will still work couple of versions. + +h3. 1.5.0 + +* Support for removing the src attribute already in HTML. This is not a drop in solution but gives additional speed for those who need it. (Jeremy Pollock) + +h3. 1.4.0 + +* When scrolling down quickly do not load the images above the top. (Bart Bruil) + +h3. 1.3.2 + +* Support for scrolling within a container. +* Fixed IE not loading images. diff --git a/lib/jquery_lazyload/CONTRIBUTING.md b/lib/jquery_lazyload/CONTRIBUTING.md new file mode 100644 index 0000000000..4a5fb22afc --- /dev/null +++ b/lib/jquery_lazyload/CONTRIBUTING.md @@ -0,0 +1,39 @@ +# Contributing to Lazy Load + +## Only one feature or change per pull request + +Make pull requests only one feature or change at the time. For example you have fixed a bug. You also have optimized some code. Optimization is not related to a bug. These should be submitted as separate pull requests. This way I can easily choose what to include. It is also easier to understand the code changes. Commit messages should be descriptive and full sentences. + +Do not commit minified versions. Do not touch the version number. Make the pull requests against [1.9.x branch](https://github.com/tuupola/jquery_lazyload/commits/1.9.x). + +## Write meaningful commit messages + +Proper commit message is full sentence. It starts with capital letter but does not end with period. Headlines do not end with period. The GitHub default `Update filename.js` is not enough. When needed include also longer explanation what the commit does. + +``` +Capitalized, short (50 chars or less) summary + +More detailed explanatory text, if necessary. Wrap it to about 72 +characters or so. In some contexts, the first line is treated as the +subject of an email and the rest of the text as the body. The blank +line separating the summary from the body is critical (unless you omit +the body entirely); tools like rebase can get confused if you run the +two together. +``` + +When in doubt see Tim Pope's blogpost [A Note About Git Commit Messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) + +## Follow the existing coding standards + +When contributing to open source project it is polite to follow the original authors coding standars. They might be different than yours. It is not a holy war. Just follow then original. + +```javascript +var snake_case = "something"; + +function camelCase(options) { +} + +if (true !== false) { + console.log("here be dragons"); +} +``` diff --git a/lib/jquery_lazyload/Gruntfile.js b/lib/jquery_lazyload/Gruntfile.js new file mode 100644 index 0000000000..b0b5522474 --- /dev/null +++ b/lib/jquery_lazyload/Gruntfile.js @@ -0,0 +1,46 @@ +module.exports = function(grunt) { + "use strict"; + + grunt.initConfig({ + pkg: grunt.file.readJSON("package.json"), + uglify : { + options: { + banner: "/*! Lazy Load <%= pkg.version %> - MIT license - Copyright 2010-2015 Mika Tuupola */\n" + }, + target: { + files: { + "jquery.lazyload.min.js" : "jquery.lazyload.js", + "jquery.scrollstop.min.js" : "jquery.scrollstop.js" + } + } + }, + watch: { + files: ["*.js", "!*.min.js" ,"test/spec/*Spec.js"], + tasks: ["test"], + }, + jshint: { + files: ["*.js", "!*.min.js" ,"test/spec/*Spec.js"], + options: { + jshintrc: ".jshintrc" + } + }, + jasmine: { + src: ["jquery.lazyload.js"], + options: { + helpers: "test/spec/*Helper.js", + specs: "test/spec/*Spec.js", + vendor: ["test/vendor/jquery-1.9.0.js", "test/vendor/jasmine-jquery.js"] + } + } + }); + + grunt.loadNpmTasks("grunt-contrib-uglify"); + grunt.loadNpmTasks("grunt-contrib-jshint"); + grunt.loadNpmTasks("grunt-contrib-jasmine"); + grunt.loadNpmTasks("grunt-contrib-watch"); + + //grunt.registerTask("test", ["jshint", "jasmine"]); + grunt.registerTask("test", ["jshint"]); + grunt.registerTask("default", ["test", "uglify"]); + +}; \ No newline at end of file diff --git a/lib/jquery_lazyload/README.md b/lib/jquery_lazyload/README.md new file mode 100644 index 0000000000..a9626eeff6 --- /dev/null +++ b/lib/jquery_lazyload/README.md @@ -0,0 +1,48 @@ +# Lazy Load Plugin for jQuery + +Lazy Load delays loading of images in long web pages. Images outside of viewport wont be loaded before user scrolls to them. This is opposite of image preloading. + +Using Lazy Load on long web pages containing many large images makes the page load faster. Browser will be in ready state after loading visible images. In some cases it can also help to reduce server load. + +Lazy Load is inspired by [YUI ImageLoader](http://developer.yahoo.com/yui/imageloader/) Utility by Matt Mlinac. + +## How to Use? + +Lazy Load depends on jQuery. Include them both in end of your HTML code: + +```html + + +``` + +You must alter your HTML code. URL of the real image must be put into data-original attribute. It is good idea to give Lazy Loaded image a specific class. This way you can easily control which images plugin is binded to. Note that you should have width and height attributes in your image tag. + +```html + +``` + +then in your code do: + +```js +$("img.lazy").lazyload(); +``` + +This causes all images of class lazy to be lazy loaded. + +More information on [Lazy Load](http://www.appelsiini.net/projects/lazyload) project page. + +## Install + +You can install with [bower](http://bower.io/) or [npm](https://www.npmjs.com/). + + +```sh +$ bower install jquery.lazyload +$ npm install jquery-lazyload +``` + + +# License + +All code licensed under the [MIT License](http://www.opensource.org/licenses/mit-license.php). All images licensed under [Creative Commons Attribution 3.0 Unported License](http://creativecommons.org/licenses/by/3.0/deed.en_US). In other words you are basically free to do whatever you want. Just don't remove my name from the source. + diff --git a/lib/jquery_lazyload/bower.json b/lib/jquery_lazyload/bower.json new file mode 100644 index 0000000000..929d3c446a --- /dev/null +++ b/lib/jquery_lazyload/bower.json @@ -0,0 +1,27 @@ +{ + "name": "jquery_lazyload", + "version": "1.9.4", + "homepage": "http://www.appelsiini.net/projects/lazyload", + "authors": [ + "Mika Tuupola " + ], + "description": "jQuery plugin for lazy loading images", + "main": [ + "jquery.lazyload.js", + "jquery.scrollstop.js" + ], + "license": "MIT", + "ignore": [ + "**/.*", + "**/*.min.js", + "**/*.html", + "**/*.textile", + "Gruntfile.js", + "lazyload.jquery.json", + "package.json", + "node_modules", + "bower_components", + "test", + "img" + ] +} diff --git a/lib/jquery_lazyload/disabled.html b/lib/jquery_lazyload/disabled.html new file mode 100644 index 0000000000..5a5451bb3e --- /dev/null +++ b/lib/jquery_lazyload/disabled.html @@ -0,0 +1,110 @@ + + + + + + Lazy Load Disabled + + + + + + + + + + +
+
+
+

Lazy Load Plugin for jQuery

+ Blog + Projects +
+
+ + +
+
+
+
+ +
+
+

Plugin disabled

+

+ All images are loaded. Page takes long time to load. Shift-reload to test again. + But wait there is more! You can also lazy load sideways or + gazillion images. +

+ + BMW M1 Hood
+ BMW M1 Side
+ Viper 1
+ Viper Corner
+ BMW M3 GT
+ Corvette Pitstop
+ +
+
+ +
+
+
+
+
CATEGORIES
+ +
+ +
+
ABOUT
+ +
+
+ Built using the awesome Flat UI Pro framework by Designmodo. +

+ © 2013 Mika Tuupola. +
+
+
+
+ + + + + diff --git a/lib/jquery_lazyload/enabled.html b/lib/jquery_lazyload/enabled.html new file mode 100644 index 0000000000..5737a7ab86 --- /dev/null +++ b/lib/jquery_lazyload/enabled.html @@ -0,0 +1,123 @@ + + + + + + Lazy Load Enabled + + + + + + + + + + +
+
+
+

Lazy Load Plugin for jQuery

+ Blog + Projects +
+
+ + +
+
+
+
+ +
+
+ +

Plugin enabled

+

+ Images below the fold (the ones lower than window bottom) are not loaded. When scrolling down + they are loaded when needed. Empty cache and shift-reload to test again. Compare this to page + where plugin is disabled, same page with + fadein effect, page with wide + layout or wide content inside container. +

+ +
$("img.lazy").lazyload();
+
<img class="lazy" data-original="img/example.jpg" width="765" height="574">
+ +
+ BMW M1 Hood
+ BMW M1 Side
+ Viper 1
+ Viper Corner
+ BMW M3 GT
+ Corvette Pitstop
+
+
+
+ +
+
+
+
+
CATEGORIES
+ +
+ +
+
ABOUT
+ +
+
+ Built using the awesome Flat UI Pro framework by Designmodo. +

+ © 2013 Mika Tuupola. +
+
+
+
+ + + + + + + diff --git a/lib/jquery_lazyload/enabled_ajax.html b/lib/jquery_lazyload/enabled_ajax.html new file mode 100644 index 0000000000..607edb12c6 --- /dev/null +++ b/lib/jquery_lazyload/enabled_ajax.html @@ -0,0 +1,126 @@ + + + + + + Lazy Load Enabled With AJAX Content + + + + + + + + + + +
+
+
+

Lazy Load Plugin for jQuery

+ Blog + Projects +
+
+ + +
+
+
+
+ +
+
+ +

Plugin enabled with AJAX loaded content

+

+ Images are loaded via AJAX(H) call after you click the container. Lazy Load + is applied in the callback. +

+
+ $("#container").one("click", function() {
+     $("#container").load("images.html", function(response, status, xhr) {
+         $("img.lazy").lazyload();
+     });              
+ });
+
 <img class="lazy" data-original="img/example.jpg" width="765" height="574">
+
+ Click me to load content... +
+ +
+
+ +
+
+
+
+
CATEGORIES
+ +
+ +
+
ABOUT
+ +
+
+ Built using the awesome Flat UI Pro framework by Designmodo. +

+ © 2013 Mika Tuupola. +
+
+
+
+ + + + + + + + + + diff --git a/lib/jquery_lazyload/enabled_background.html b/lib/jquery_lazyload/enabled_background.html new file mode 100644 index 0000000000..1149dc84e5 --- /dev/null +++ b/lib/jquery_lazyload/enabled_background.html @@ -0,0 +1,123 @@ + + + + + + Lazy Load Enabled With CSS Background Images + + + + + + + + + + +
+
+
+

Lazy Load Plugin for jQuery

+ Blog + Projects +
+
+ + +
+
+
+
+ +
+
+ +

Plugin enabled on css background images with fadein effect

+

+ Here be dragons. +

+
+  <div class="lazy" data-original="img/bmw_m1_hood.jpg" style="background-image: url('img/grey.gif'); width: 765px; height: 574px;"></div>
+
+  $("div.lazy").lazyload({
+      effect : "fadeIn"
+  });
+      
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
CATEGORIES
+ +
+ +
+
ABOUT
+ +
+
+ Built using the awesome Flat UI Pro framework by Designmodo. +

+ © 2013 Mika Tuupola. +
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/lib/jquery_lazyload/enabled_container.html b/lib/jquery_lazyload/enabled_container.html new file mode 100644 index 0000000000..e2ae4999e2 --- /dev/null +++ b/lib/jquery_lazyload/enabled_container.html @@ -0,0 +1,136 @@ + + + + + + Lazy Load Enabled on Container + + + + + + + + + + +
+
+
+

Lazy Load Plugin for jQuery

+ Blog + Projects +
+
+ + +
+
+
+
+ +
+
+ +

Plugin enabled on container

+

+ Images below the visible area (the ones lower than container bottom) are not loaded. When scrolling down + they are loaded when needed. Empty cache and shift-reload to test again. Compare this to page where plugin is + disabled or same page with fadein effect. +

+
+$("img.lazy").lazyload({         
+    effect : "fadeIn",
+    container: $("#container")
+});
+      
+
+#container {
+    height: 600px;
+    overflow: scroll;
+}
+      
+
<img class="lazy" data-original="img/example.jpg" width="765" height="574">
+
+ BMW M1 Hood
+ BMW M1 Side
+ Viper 1
+ Viper Corner
+ BMW M3 GT
+ Corvette Pitstop
+
+ +
+
+ +
+
+
+
+
CATEGORIES
+ +
+ +
+
ABOUT
+ +
+
+ Built using the awesome Flat UI Pro framework by Designmodo. +

+ © 2013 Mika Tuupola. +
+
+
+
+ + + + + + + diff --git a/lib/jquery_lazyload/enabled_fadein.html b/lib/jquery_lazyload/enabled_fadein.html new file mode 100644 index 0000000000..6d28e4949a --- /dev/null +++ b/lib/jquery_lazyload/enabled_fadein.html @@ -0,0 +1,128 @@ + + + + + + Lazy Load Enabled With FadeIn Effect + + + + + + + + + + +
+
+
+

Lazy Load Plugin for jQuery

+ Blog + Projects +
+
+ + +
+
+
+
+ +
+
+ +

Plugin enabled with fadein effect

+

+ Images below the fold (the ones lower than window bottom) are not loaded. When scrolling down + they are loaded when needed. Images appear using fadeIn + effect. Empty cache and shift-reload to test again. Compare this to page where plugin is + without effects. +

+
+$("img.lazy").lazyload({
+    effect : "fadeIn"
+});
+      
+
<img class="lazy" data-original="img/example.jpg" width="765" height="574">
+
+ BMW M1 Hood
+ BMW M1 Side
+ Viper 1
+ Viper Corner
+ BMW M3 GT
+ Corvette Pitstop
+
+ +
+
+ +
+
+
+
+
CATEGORIES
+ +
+ +
+
ABOUT
+ +
+
+ Built using the awesome Flat UI Pro framework by Designmodo. +

+ © 2013 Mika Tuupola. +
+
+
+
+ + + + + + + diff --git a/lib/jquery_lazyload/enabled_gazillion.html b/lib/jquery_lazyload/enabled_gazillion.html new file mode 100644 index 0000000000..dc33bad320 --- /dev/null +++ b/lib/jquery_lazyload/enabled_gazillion.html @@ -0,0 +1,283 @@ + + + + + + Lazy Load Enabled With Gazillion Images + + + + + + + + + + +
+
+
+

Lazy Load Plugin for jQuery

+ Blog + Projects +
+
+ + +
+
+
+
+ +
+
+ +

Plugin enabled with gazillion images

+

+ When you have hundreds of images it is best to use James Padolseys scrollstop event. + Compate this to page where plugin is disabled or page with + larger images. +

+ +
<script src="jquery.scrollstop.js" type="text/javascript"></script> 
+
<img class="lazy" data-original="img/example.jpg" width="80" height="120" alt="">
+
$("img.lazy").lazyload({
+  event: "scrollstop"
+});
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+
+
+
+
CATEGORIES
+ +
+ +
+
ABOUT
+ +
+
+ Built using the awesome Flat UI Pro framework by Designmodo. +

+ © 2013 Mika Tuupola. +
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/lib/jquery_lazyload/enabled_noscript.html b/lib/jquery_lazyload/enabled_noscript.html new file mode 100644 index 0000000000..1906de9121 --- /dev/null +++ b/lib/jquery_lazyload/enabled_noscript.html @@ -0,0 +1,144 @@ + + + + + + Lazy Load Enabled With Noscript Fallback + + + + + + + + + + +
+
+
+

Lazy Load Plugin for jQuery

+ Blog + Projects +
+
+ + +
+
+
+
+ +
+
+ +

Plugin enabled with noscript fallback

+

+ This page deprecates gracefully for non JavaScript browsers. It requires hiding + lazy loaded images with css and adding a <noscript> block which contains + the real image and it is shown when JavaScript is not enabled. If JavaScript is enabled + show() function is called before initializing Lazy Load plugin. +

+ +
.lazy {
+    display: none;
+}
+ +
$("img.lazy").show().lazyload({
+    effect : "fadeIn"
+});
+ +
<img class="lazy" src="img/grey.gif" data-original="img/example.jpg" width="765" height="574">
+     <noscript><img src="img/example.jpg" width="765" height="574"></noscript>
+ + BMW M1 Hood
+ BMW M1 Side
+ Viper 1
+ Viper Corner
+ BMW M3 GT
+ Corvette Pitstop
+ + + +
+
+ +
+
+
+
+
CATEGORIES
+ +
+ +
+
ABOUT
+ +
+
+ Built using the awesome Flat UI Pro framework by Designmodo. +

+ © 2013 Mika Tuupola. +
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/lib/jquery_lazyload/enabled_timeout.html b/lib/jquery_lazyload/enabled_timeout.html new file mode 100644 index 0000000000..07998ef8ac --- /dev/null +++ b/lib/jquery_lazyload/enabled_timeout.html @@ -0,0 +1,135 @@ + + + + + + Lazy Load Images After 5 Second Timeout + + + + + + + + + + +
+
+
+

Lazy Load Plugin for jQuery

+ Blog + Projects +
+
+ + +
+
+
+
+ +
+
+ +

Load images after five second delay

+

+ Here Lazy Load + plugin is enabled. Images below the fold are not loaded. Timeout will trigger five seconds after + all other elements of page have been loaded. +

+
$(function() {
+    $("img.lazy").lazyload({
+        event : "sporty"
+    });
+});
+
+$(window).bind("load", function() {
+    var timeout = setTimeout(function() { $("img.lazy").trigger("sporty") }, 5000);
+});      
+ +
<img class="lazy" src="img/grey.gif" data-original="img/example.jpg" width="765" height="574">
+ +
+ BMW M1 Hood
+ BMW M1 Side
+ Viper 1
+ Viper Corner
+ BMW M3 GT
+ Corvette Pitstop
+
+ +
+
+ +
+
+
+
+
CATEGORIES
+ +
+ +
+
ABOUT
+ +
+
+ Built using the awesome Flat UI Pro framework by Designmodo. +

+ © 2013 Mika Tuupola. +
+
+
+
+ + + + + + + diff --git a/lib/jquery_lazyload/enabled_wide.html b/lib/jquery_lazyload/enabled_wide.html new file mode 100644 index 0000000000..5020e2f55c --- /dev/null +++ b/lib/jquery_lazyload/enabled_wide.html @@ -0,0 +1,126 @@ + + + + + + Lazy Load Enabled + + + + + + + + + + +
+
+
+

Lazy Load Plugin for jQuery

+ Blog + Projects +
+
+ + +
+
+
+
+ +
+
+ +

Plugin enabled

+

+ Images right of the fold are not loaded. When scrolling left they are loaded when needed. + Shift-reload to test again. Compare this to page where plugin is + disabled or page with + gazillion images. +

+
$("img.lazy").lazyload({
+    effect: "fadeIn"
+});
+
<img class="lazy" data-original="img/example.jpg" width="765" height="574">
+ + BMW M1 Hood + BMW M1 Side + Viper 1 + Viper Corner + BMW M3 GT + Corvette Pitstop + +
+
+ +
+
+
+
+
CATEGORIES
+ +
+ +
+
ABOUT
+ +
+
+ Built using the awesome Flat UI Pro framework by Designmodo. +

+ © 2013 Mika Tuupola. +
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/lib/jquery_lazyload/enabled_wide_container.html b/lib/jquery_lazyload/enabled_wide_container.html new file mode 100644 index 0000000000..c93b68be15 --- /dev/null +++ b/lib/jquery_lazyload/enabled_wide_container.html @@ -0,0 +1,134 @@ + + + + + + Lazy Load Enabled on Horizontal Container + + + + + + + + + + +
+
+
+

Lazy Load Plugin for jQuery

+ Blog + Projects +
+
+ + +
+
+
+
+ +
+
+ +

Plugin enabled on horizontal container

+

+ Images right of the visible area are not loaded. When scrolling left they are loaded when needed. + Shift-reload to test again. Compare this to page where plugin is + disabled or page with + gazillion images. +

+
$("img.lazy").lazyload({
+    container: $("#container")
+});
+
+
+ BMW M1 Hood + BMW M1 Side + Viper 1 + Viper Corner + BMW M3 GT + Corvette Pitstop +
+
+ +
+
+ +
+
+
+
+
CATEGORIES
+ +
+ +
+
ABOUT
+ +
+
+ Built using the awesome Flat UI Pro framework by Designmodo. +

+ © 2013 Mika Tuupola. +
+
+
+
+ + + + + + + + diff --git a/lib/jquery_lazyload/img/bmw_m1_hood.jpg b/lib/jquery_lazyload/img/bmw_m1_hood.jpg new file mode 100644 index 0000000000..d9246a9dbc Binary files /dev/null and b/lib/jquery_lazyload/img/bmw_m1_hood.jpg differ diff --git a/lib/jquery_lazyload/img/bmw_m1_side.jpg b/lib/jquery_lazyload/img/bmw_m1_side.jpg new file mode 100644 index 0000000000..67559a1036 Binary files /dev/null and b/lib/jquery_lazyload/img/bmw_m1_side.jpg differ diff --git a/lib/jquery_lazyload/img/bmw_m3_gt.jpg b/lib/jquery_lazyload/img/bmw_m3_gt.jpg new file mode 100644 index 0000000000..2c471ea241 Binary files /dev/null and b/lib/jquery_lazyload/img/bmw_m3_gt.jpg differ diff --git a/lib/jquery_lazyload/img/corvette_pitstop.jpg b/lib/jquery_lazyload/img/corvette_pitstop.jpg new file mode 100644 index 0000000000..d6653f4803 Binary files /dev/null and b/lib/jquery_lazyload/img/corvette_pitstop.jpg differ diff --git a/lib/jquery_lazyload/img/grey.gif b/lib/jquery_lazyload/img/grey.gif new file mode 100644 index 0000000000..8d74456e3d Binary files /dev/null and b/lib/jquery_lazyload/img/grey.gif differ diff --git a/lib/jquery_lazyload/img/transparent.gif b/lib/jquery_lazyload/img/transparent.gif new file mode 100644 index 0000000000..35d42e808f Binary files /dev/null and b/lib/jquery_lazyload/img/transparent.gif differ diff --git a/lib/jquery_lazyload/img/viper_1.jpg b/lib/jquery_lazyload/img/viper_1.jpg new file mode 100644 index 0000000000..41a3df95a1 Binary files /dev/null and b/lib/jquery_lazyload/img/viper_1.jpg differ diff --git a/lib/jquery_lazyload/img/viper_corner.jpg b/lib/jquery_lazyload/img/viper_corner.jpg new file mode 100644 index 0000000000..1d9bb84a3f Binary files /dev/null and b/lib/jquery_lazyload/img/viper_corner.jpg differ diff --git a/lib/jquery_lazyload/img/white.gif b/lib/jquery_lazyload/img/white.gif new file mode 100644 index 0000000000..2799b45c65 Binary files /dev/null and b/lib/jquery_lazyload/img/white.gif differ diff --git a/lib/jquery_lazyload/jquery.lazyload.js b/lib/jquery_lazyload/jquery.lazyload.js new file mode 100644 index 0000000000..26fab660ae --- /dev/null +++ b/lib/jquery_lazyload/jquery.lazyload.js @@ -0,0 +1,242 @@ +/*! + * Lazy Load - jQuery plugin for lazy loading images + * + * Copyright (c) 2007-2015 Mika Tuupola + * + * Licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * Project home: + * http://www.appelsiini.net/projects/lazyload + * + * Version: 1.9.5 + * + */ + +(function($, window, document, undefined) { + var $window = $(window); + + $.fn.lazyload = function(options) { + var elements = this; + var $container; + var settings = { + threshold : 0, + failure_limit : 0, + event : "scroll", + effect : "show", + container : window, + data_attribute : "original", + skip_invisible : false, + appear : null, + load : null, + placeholder : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" + }; + + function update() { + var counter = 0; + + elements.each(function() { + var $this = $(this); + if (settings.skip_invisible && !$this.is(":visible")) { + return; + } + if ($.abovethetop(this, settings) || + $.leftofbegin(this, settings)) { + /* Nothing. */ + } else if (!$.belowthefold(this, settings) && + !$.rightoffold(this, settings)) { + $this.trigger("appear"); + /* if we found an image we'll load, reset the counter */ + counter = 0; + } else { + if (++counter > settings.failure_limit) { + return false; + } + } + }); + + } + + if(options) { + /* Maintain BC for a couple of versions. */ + if (undefined !== options.failurelimit) { + options.failure_limit = options.failurelimit; + delete options.failurelimit; + } + if (undefined !== options.effectspeed) { + options.effect_speed = options.effectspeed; + delete options.effectspeed; + } + + $.extend(settings, options); + } + + /* Cache container as jQuery as object. */ + $container = (settings.container === undefined || + settings.container === window) ? $window : $(settings.container); + + /* Fire one scroll event per scroll. Not one scroll event per image. */ + if (0 === settings.event.indexOf("scroll")) { + $container.bind(settings.event, function() { + return update(); + }); + } + + this.each(function() { + var self = this; + var $self = $(self); + + self.loaded = false; + + /* If no src attribute given use data:uri. */ + if ($self.attr("src") === undefined || $self.attr("src") === false) { + if ($self.is("img")) { + $self.attr("src", settings.placeholder); + } + } + + /* When appear is triggered load original image. */ + $self.one("appear", function() { + if (!this.loaded) { + if (settings.appear) { + var elements_left = elements.length; + settings.appear.call(self, elements_left, settings); + } + $("") + .bind("load", function() { + + var original = $self.attr("data-" + settings.data_attribute); + $self.hide(); + if ($self.is("img")) { + $self.attr("src", original); + } else { + $self.css("background-image", "url('" + original + "')"); + } + $self[settings.effect](settings.effect_speed); + + self.loaded = true; + + /* Remove image from array so it is not looped next time. */ + var temp = $.grep(elements, function(element) { + return !element.loaded; + }); + elements = $(temp); + + if (settings.load) { + var elements_left = elements.length; + settings.load.call(self, elements_left, settings); + } + }) + .attr("src", $self.attr("data-" + settings.data_attribute)); + } + }); + + /* When wanted event is triggered load original image */ + /* by triggering appear. */ + if (0 !== settings.event.indexOf("scroll")) { + $self.bind(settings.event, function() { + if (!self.loaded) { + $self.trigger("appear"); + } + }); + } + }); + + /* Check if something appears when window is resized. */ + $window.bind("resize", function() { + update(); + }); + + /* With IOS5 force loading images when navigating with back button. */ + /* Non optimal workaround. */ + if ((/(?:iphone|ipod|ipad).*os 5/gi).test(navigator.appVersion)) { + $window.bind("pageshow", function(event) { + if (event.originalEvent && event.originalEvent.persisted) { + elements.each(function() { + $(this).trigger("appear"); + }); + } + }); + } + + /* Force initial check if images should appear. */ + $(document).ready(function() { + update(); + }); + + return this; + }; + + /* Convenience methods in jQuery namespace. */ + /* Use as $.belowthefold(element, {threshold : 100, container : window}) */ + + $.belowthefold = function(element, settings) { + var fold; + + if (settings.container === undefined || settings.container === window) { + fold = (window.innerHeight ? window.innerHeight : $window.height()) + $window.scrollTop(); + } else { + fold = $(settings.container).offset().top + $(settings.container).height(); + } + + return fold <= $(element).offset().top - settings.threshold; + }; + + $.rightoffold = function(element, settings) { + var fold; + + if (settings.container === undefined || settings.container === window) { + fold = $window.width() + $window.scrollLeft(); + } else { + fold = $(settings.container).offset().left + $(settings.container).width(); + } + + return fold <= $(element).offset().left - settings.threshold; + }; + + $.abovethetop = function(element, settings) { + var fold; + + if (settings.container === undefined || settings.container === window) { + fold = $window.scrollTop(); + } else { + fold = $(settings.container).offset().top; + } + + return fold >= $(element).offset().top + settings.threshold + $(element).height(); + }; + + $.leftofbegin = function(element, settings) { + var fold; + + if (settings.container === undefined || settings.container === window) { + fold = $window.scrollLeft(); + } else { + fold = $(settings.container).offset().left; + } + + return fold >= $(element).offset().left + settings.threshold + $(element).width(); + }; + + $.inviewport = function(element, settings) { + return !$.rightoffold(element, settings) && !$.leftofbegin(element, settings) && + !$.belowthefold(element, settings) && !$.abovethetop(element, settings); + }; + + /* Custom selectors for your convenience. */ + /* Use as $("img:below-the-fold").something() or */ + /* $("img").filter(":below-the-fold").something() which is faster */ + + $.extend($.expr[":"], { + "below-the-fold" : function(a) { return $.belowthefold(a, {threshold : 0}); }, + "above-the-top" : function(a) { return !$.belowthefold(a, {threshold : 0}); }, + "right-of-screen": function(a) { return $.rightoffold(a, {threshold : 0}); }, + "left-of-screen" : function(a) { return !$.rightoffold(a, {threshold : 0}); }, + "in-viewport" : function(a) { return $.inviewport(a, {threshold : 0}); }, + /* Maintain BC for couple of versions. */ + "above-the-fold" : function(a) { return !$.belowthefold(a, {threshold : 0}); }, + "right-of-fold" : function(a) { return $.rightoffold(a, {threshold : 0}); }, + "left-of-fold" : function(a) { return !$.rightoffold(a, {threshold : 0}); } + }); + +})(jQuery, window, document); diff --git a/lib/jquery_lazyload/jquery.lazyload.min.js b/lib/jquery_lazyload/jquery.lazyload.min.js new file mode 100644 index 0000000000..575abfb2b4 --- /dev/null +++ b/lib/jquery_lazyload/jquery.lazyload.min.js @@ -0,0 +1,2 @@ +/*! Lazy Load 1.9.5 - MIT license - Copyright 2010-2015 Mika Tuupola */ +!function(a,b,c,d){var e=a(b);a.fn.lazyload=function(f){function g(){var b=0;i.each(function(){var c=a(this);if(!j.skip_invisible||c.is(":visible"))if(a.abovethetop(this,j)||a.leftofbegin(this,j));else if(a.belowthefold(this,j)||a.rightoffold(this,j)){if(++b>j.failure_limit)return!1}else c.trigger("appear"),b=0})}var h,i=this,j={threshold:0,failure_limit:0,event:"scroll",effect:"show",container:b,data_attribute:"original",skip_invisible:!1,appear:null,load:null,placeholder:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC"};return f&&(d!==f.failurelimit&&(f.failure_limit=f.failurelimit,delete f.failurelimit),d!==f.effectspeed&&(f.effect_speed=f.effectspeed,delete f.effectspeed),a.extend(j,f)),h=j.container===d||j.container===b?e:a(j.container),0===j.event.indexOf("scroll")&&h.bind(j.event,function(){return g()}),this.each(function(){var b=this,c=a(b);b.loaded=!1,(c.attr("src")===d||c.attr("src")===!1)&&c.is("img")&&c.attr("src",j.placeholder),c.one("appear",function(){if(!this.loaded){if(j.appear){var d=i.length;j.appear.call(b,d,j)}a("").bind("load",function(){var d=c.attr("data-"+j.data_attribute);c.hide(),c.is("img")?c.attr("src",d):c.css("background-image","url('"+d+"')"),c[j.effect](j.effect_speed),b.loaded=!0;var e=a.grep(i,function(a){return!a.loaded});if(i=a(e),j.load){var f=i.length;j.load.call(b,f,j)}}).attr("src",c.attr("data-"+j.data_attribute))}}),0!==j.event.indexOf("scroll")&&c.bind(j.event,function(){b.loaded||c.trigger("appear")})}),e.bind("resize",function(){g()}),/(?:iphone|ipod|ipad).*os 5/gi.test(navigator.appVersion)&&e.bind("pageshow",function(b){b.originalEvent&&b.originalEvent.persisted&&i.each(function(){a(this).trigger("appear")})}),a(c).ready(function(){g()}),this},a.belowthefold=function(c,f){var g;return g=f.container===d||f.container===b?(b.innerHeight?b.innerHeight:e.height())+e.scrollTop():a(f.container).offset().top+a(f.container).height(),g<=a(c).offset().top-f.threshold},a.rightoffold=function(c,f){var g;return g=f.container===d||f.container===b?e.width()+e.scrollLeft():a(f.container).offset().left+a(f.container).width(),g<=a(c).offset().left-f.threshold},a.abovethetop=function(c,f){var g;return g=f.container===d||f.container===b?e.scrollTop():a(f.container).offset().top,g>=a(c).offset().top+f.threshold+a(c).height()},a.leftofbegin=function(c,f){var g;return g=f.container===d||f.container===b?e.scrollLeft():a(f.container).offset().left,g>=a(c).offset().left+f.threshold+a(c).width()},a.inviewport=function(b,c){return!(a.rightoffold(b,c)||a.leftofbegin(b,c)||a.belowthefold(b,c)||a.abovethetop(b,c))},a.extend(a.expr[":"],{"below-the-fold":function(b){return a.belowthefold(b,{threshold:0})},"above-the-top":function(b){return!a.belowthefold(b,{threshold:0})},"right-of-screen":function(b){return a.rightoffold(b,{threshold:0})},"left-of-screen":function(b){return!a.rightoffold(b,{threshold:0})},"in-viewport":function(b){return a.inviewport(b,{threshold:0})},"above-the-fold":function(b){return!a.belowthefold(b,{threshold:0})},"right-of-fold":function(b){return a.rightoffold(b,{threshold:0})},"left-of-fold":function(b){return!a.rightoffold(b,{threshold:0})}})}(jQuery,window,document); \ No newline at end of file diff --git a/lib/jquery_lazyload/jquery.scrollstop.js b/lib/jquery_lazyload/jquery.scrollstop.js new file mode 100644 index 0000000000..a0bb637100 --- /dev/null +++ b/lib/jquery_lazyload/jquery.scrollstop.js @@ -0,0 +1,72 @@ +/* http://james.padolsey.com/javascript/special-scroll-events-for-jquery/ */ + +(function(){ + + var special = jQuery.event.special, + uid1 = "D" + (+new Date()), + uid2 = "D" + (+new Date() + 1); + + special.scrollstart = { + setup: function() { + + var timer, + handler = function(evt) { + + var _self = this, + _args = arguments; + + if (timer) { + clearTimeout(timer); + } else { + evt.type = "scrollstart"; + jQuery.event.dispatch.apply(_self, _args); + } + + timer = setTimeout( function(){ + timer = null; + }, special.scrollstop.latency); + + }; + + jQuery(this).bind("scroll", handler).data(uid1, handler); + + }, + teardown: function(){ + jQuery(this).unbind( "scroll", jQuery(this).data(uid1) ); + } + }; + + special.scrollstop = { + latency: 300, + setup: function() { + + var timer, + handler = function(evt) { + + var _self = this, + _args = arguments; + + if (timer) { + clearTimeout(timer); + } + + timer = setTimeout( function(){ + + timer = null; + evt.type = "scrollstop"; + jQuery.event.dispatch.apply(_self, _args); + + + }, special.scrollstop.latency); + + }; + + jQuery(this).bind("scroll", handler).data(uid2, handler); + + }, + teardown: function() { + jQuery(this).unbind( "scroll", jQuery(this).data(uid2) ); + } + }; + +})(); \ No newline at end of file diff --git a/lib/jquery_lazyload/jquery.scrollstop.min.js b/lib/jquery_lazyload/jquery.scrollstop.min.js new file mode 100644 index 0000000000..8a1bde1bc7 --- /dev/null +++ b/lib/jquery_lazyload/jquery.scrollstop.min.js @@ -0,0 +1,2 @@ +/*! Lazy Load 1.9.5 - MIT license - Copyright 2010-2015 Mika Tuupola */ +!function(){var a=jQuery.event.special,b="D"+ +new Date,c="D"+(+new Date+1);a.scrollstart={setup:function(){var c,d=function(b){var d=this,e=arguments;c?clearTimeout(c):(b.type="scrollstart",jQuery.event.dispatch.apply(d,e)),c=setTimeout(function(){c=null},a.scrollstop.latency)};jQuery(this).bind("scroll",d).data(b,d)},teardown:function(){jQuery(this).unbind("scroll",jQuery(this).data(b))}},a.scrollstop={latency:300,setup:function(){var b,d=function(c){var d=this,e=arguments;b&&clearTimeout(b),b=setTimeout(function(){b=null,c.type="scrollstop",jQuery.event.dispatch.apply(d,e)},a.scrollstop.latency)};jQuery(this).bind("scroll",d).data(c,d)},teardown:function(){jQuery(this).unbind("scroll",jQuery(this).data(c))}}}(); \ No newline at end of file diff --git a/lib/jquery_lazyload/lazyload.jquery.json b/lib/jquery_lazyload/lazyload.jquery.json new file mode 100644 index 0000000000..e97841694f --- /dev/null +++ b/lib/jquery_lazyload/lazyload.jquery.json @@ -0,0 +1,35 @@ +{ + "name": "lazyload", + "version": "1.9.5", + "title": "Lazy Load", + "author": { + "name": "Mika Tuupola", + "email": "tuupola@appelsiini.net", + "url": "http://www.appelsiini.net/" + }, + "licenses": [ + { + "type": "MIT", + "url": "http://www.opensource.org/licenses/mit-license.php" + } + ], + "dependencies": { + }, + "description": "Delay loading of images in long web pages. Images outside of viewport wont be loaded before user scrolls to them.", + "keywords": [ + "lazyload", + "lazy", + "load", + "image" + ], + "homepage": "http://www.appelsiini.net/projects/lazyload", + "bugs": "https://github.com/tuupola/jquery_lazyload/issues", + "docs": "http://www.appelsiini.net/projects/lazyload", + "demo": "http://www.appelsiini.net/projects/lazyload/enabled_fadein.html", + "files": [ + "jquery.lazyload.js", + "jquery.lazyload.min.js", + "jquery.scrollstop.js", + "jquery.scrollstop.min.js" + ] +} \ No newline at end of file diff --git a/lib/jquery_lazyload/package.json b/lib/jquery_lazyload/package.json new file mode 100644 index 0000000000..ce1388e8ca --- /dev/null +++ b/lib/jquery_lazyload/package.json @@ -0,0 +1,37 @@ +{ + "name": "jquery-lazyload", + "version": "1.9.5", + "engines": { + "node": ">= 0.8.0" + }, + "repository": { + "type": "git", + "url": "git@github.com:tuupola/jquery_lazyload.git" + }, + "author": "Mika Tuupola ", + "scripts": { + "test": "grunt test" + }, + "devDependencies": { + "grunt": "~0.4.1", + "grunt-contrib-jshint": "~0.6.4", + "grunt-contrib-uglify": "~0.2.4", + "grunt-contrib-jasmine": "~0.5.2", + "grunt-contrib-watch": "~0.5.3" + }, + "description": "Lazyload images with jQuery", + "bugs": { + "url": "https://github.com/tuupola/jquery_lazyload/issues" + }, + "homepage": "http://www.appelsiini.net/projects/lazyload", + "main": "Gruntfile.js", + "files": [ + "jquery.lazyload.js", + "jquery.scrollstop.js" + ], + "keywords": [ + "jquery-plugin", + "ecosystem:jquery" + ], + "license": "MIT" +}