jquery-lazy-images 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4d4fb93ea11bdd3afa29c00e3b5b5d0ce1f97cc4
4
- data.tar.gz: f6170288aa8f2671f79c49734ed6c623fe89e2a5
3
+ metadata.gz: c6fccf0d1886cd0ca7f3b1bf0dee75a698d60b35
4
+ data.tar.gz: 78b5c96b02668a01163098981d744920a15bbe3a
5
5
  SHA512:
6
- metadata.gz: fe55589083da0433742adf2837158b83c7b6ea4be6c2cd0e8a2fb4cef8821b081542885431321d1ecf1cff198f1c1e9d38463c7a0916c380f6c7e98550fa5061
7
- data.tar.gz: 6bea4a75fbded9e779763f30ce068e55363ccb22b55124b7bbcf05f04acc13153d697db90fafcdcdcd132ac5c20b55e549aef67a4669148b7987779905a79b2c
6
+ metadata.gz: 5d302669927453aed3354202df111ef5b1bf10140c412dfc9f88f26dbfdcc81388e55a8cd2feaef71cf0d544f0a8e3254f00d7945b8d9807d1e86ea2d7f4a8d0
7
+ data.tar.gz: b21fba7305f49157bcd09d06c40b8bd6b3fae14fe32defea8a71e15c83a21561b1d406bc42f751039249f72d4051912ec27fa6276ac9e1c907a1aa609464b51c
@@ -1,3 +1,3 @@
1
1
  module JqueryLazyImages
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * Lazy Load - jQuery plugin for lazy loading images
3
3
  *
4
- * Copyright (c) 2007-2012 Mika Tuupola
4
+ * Copyright (c) 2007-2013 Mika Tuupola
5
5
  *
6
6
  * Licensed under the MIT license:
7
7
  * http://www.opensource.org/licenses/mit-license.php
@@ -9,9 +9,10 @@
9
9
  * Project home:
10
10
  * http://www.appelsiini.net/projects/lazyload
11
11
  *
12
- * Version: 1.8.2
12
+ * Version: 1.9.3
13
13
  *
14
14
  */
15
+
15
16
  (function($, window, document, undefined) {
16
17
  var $window = $(window);
17
18
 
@@ -27,7 +28,8 @@
27
28
  data_attribute : "original",
28
29
  skip_invisible : true,
29
30
  appear : null,
30
- load : null
31
+ load : null,
32
+ placeholder : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC"
31
33
  };
32
34
 
33
35
  function update() {
@@ -75,7 +77,7 @@
75
77
 
76
78
  /* Fire one scroll event per scroll. Not one scroll event per image. */
77
79
  if (0 === settings.event.indexOf("scroll")) {
78
- $container.bind(settings.event, function(event) {
80
+ $container.bind(settings.event, function() {
79
81
  return update();
80
82
  });
81
83
  }
@@ -86,6 +88,13 @@
86
88
 
87
89
  self.loaded = false;
88
90
 
91
+ /* If no src attribute given use data:uri. */
92
+ if ($self.attr("src") === undefined || $self.attr("src") === false) {
93
+ if ($self.is("img")) {
94
+ $self.attr("src", settings.placeholder);
95
+ }
96
+ }
97
+
89
98
  /* When appear is triggered load original image. */
90
99
  $self.one("appear", function() {
91
100
  if (!this.loaded) {
@@ -95,10 +104,16 @@
95
104
  }
96
105
  $("<img />")
97
106
  .bind("load", function() {
98
- $self
99
- .hide()
100
- .attr("src", $self.data(settings.data_attribute))
101
- [settings.effect](settings.effect_speed);
107
+
108
+ var original = $self.attr("data-" + settings.data_attribute);
109
+ $self.hide();
110
+ if ($self.is("img")) {
111
+ $self.attr("src", original);
112
+ } else {
113
+ $self.css("background-image", "url('" + original + "')");
114
+ }
115
+ $self[settings.effect](settings.effect_speed);
116
+
102
117
  self.loaded = true;
103
118
 
104
119
  /* Remove image from array so it is not looped next time. */
@@ -112,14 +127,14 @@
112
127
  settings.load.call(self, elements_left, settings);
113
128
  }
114
129
  })
115
- .attr("src", $self.data(settings.data_attribute));
130
+ .attr("src", $self.attr("data-" + settings.data_attribute));
116
131
  }
117
132
  });
118
133
 
119
134
  /* When wanted event is triggered load original image */
120
135
  /* by triggering appear. */
121
136
  if (0 !== settings.event.indexOf("scroll")) {
122
- $self.bind(settings.event, function(event) {
137
+ $self.bind(settings.event, function() {
123
138
  if (!self.loaded) {
124
139
  $self.trigger("appear");
125
140
  }
@@ -128,15 +143,15 @@
128
143
  });
129
144
 
130
145
  /* Check if something appears when window is resized. */
131
- $window.bind("resize", function(event) {
146
+ $window.bind("resize", function() {
132
147
  update();
133
148
  });
134
149
 
135
150
  /* With IOS5 force loading images when navigating with back button. */
136
151
  /* Non optimal workaround. */
137
- if ((/iphone|ipod|ipad.*os 5/gi).test(navigator.appVersion)) {
152
+ if ((/(?:iphone|ipod|ipad).*os 5/gi).test(navigator.appVersion)) {
138
153
  $window.bind("pageshow", function(event) {
139
- if (event.originalEvent.persisted) {
154
+ if (event.originalEvent && event.originalEvent.persisted) {
140
155
  elements.each(function() {
141
156
  $(this).trigger("appear");
142
157
  });
@@ -159,7 +174,7 @@
159
174
  var fold;
160
175
 
161
176
  if (settings.container === undefined || settings.container === window) {
162
- fold = $window.height() + $window.scrollTop();
177
+ fold = (window.innerHeight ? window.innerHeight : $window.height()) + $window.scrollTop();
163
178
  } else {
164
179
  fold = $(settings.container).offset().top + $(settings.container).height();
165
180
  }
@@ -212,7 +227,7 @@
212
227
  /* Use as $("img:below-the-fold").something() or */
213
228
  /* $("img").filter(":below-the-fold").something() which is faster */
214
229
 
215
- $.extend($.expr[':'], {
230
+ $.extend($.expr[":"], {
216
231
  "below-the-fold" : function(a) { return $.belowthefold(a, {threshold : 0}); },
217
232
  "above-the-top" : function(a) { return !$.belowthefold(a, {threshold : 0}); },
218
233
  "right-of-screen": function(a) { return $.rightoffold(a, {threshold : 0}); },
@@ -1,15 +1,2 @@
1
- /*
2
- * Lazy Load - jQuery plugin for lazy loading images
3
- *
4
- * Copyright (c) 2007-2012 Mika Tuupola
5
- *
6
- * Licensed under the MIT license:
7
- * http://www.opensource.org/licenses/mit-license.php
8
- *
9
- * Project home:
10
- * http://www.appelsiini.net/projects/lazyload
11
- *
12
- * Version: 1.8.2
13
- *
14
- */
15
- (function(a,b,c,d){var e=a(b);a.fn.lazyload=function(f){function j(){var b=0;g.each(function(){var c=a(this);if(i.skip_invisible&&!c.is(":visible"))return;if(!a.abovethetop(this,i)&&!a.leftofbegin(this,i))if(!a.belowthefold(this,i)&&!a.rightoffold(this,i))c.trigger("appear"),b=0;else if(++b>i.failure_limit)return!1})}var g=this,h,i={threshold:0,failure_limit:0,event:"scroll",effect:"show",container:b,data_attribute:"original",skip_invisible:!0,appear:null,load:null};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(i,f)),h=i.container===d||i.container===b?e:a(i.container),0===i.event.indexOf("scroll")&&h.bind(i.event,function(a){return j()}),this.each(function(){var b=this,c=a(b);b.loaded=!1,c.one("appear",function(){if(!this.loaded){if(i.appear){var d=g.length;i.appear.call(b,d,i)}a("<img />").bind("load",function(){c.hide().attr("src",c.data(i.data_attribute))[i.effect](i.effect_speed),b.loaded=!0;var d=a.grep(g,function(a){return!a.loaded});g=a(d);if(i.load){var e=g.length;i.load.call(b,e,i)}}).attr("src",c.data(i.data_attribute))}}),0!==i.event.indexOf("scroll")&&c.bind(i.event,function(a){b.loaded||c.trigger("appear")})}),e.bind("resize",function(a){j()}),/iphone|ipod|ipad.*os 5/gi.test(navigator.appVersion)&&e.bind("pageshow",function(b){b.originalEvent.persisted&&g.each(function(){a(this).trigger("appear")})}),a(c).ready(function(){j()}),this},a.belowthefold=function(c,f){var g;return f.container===d||f.container===b?g=e.height()+e.scrollTop():g=a(f.container).offset().top+a(f.container).height(),g<=a(c).offset().top-f.threshold},a.rightoffold=function(c,f){var g;return f.container===d||f.container===b?g=e.width()+e.scrollLeft():g=a(f.container).offset().left+a(f.container).width(),g<=a(c).offset().left-f.threshold},a.abovethetop=function(c,f){var g;return f.container===d||f.container===b?g=e.scrollTop():g=a(f.container).offset().top,g>=a(c).offset().top+f.threshold+a(c).height()},a.leftofbegin=function(c,f){var g;return f.container===d||f.container===b?g=e.scrollLeft():g=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)
1
+ /*! Lazy Load 1.9.3 - MIT license - Copyright 2010-2013 Mika Tuupola */
2
+ !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:!0,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("<img />").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);
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery-lazy-images
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Singlebrook Technology
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-27 00:00:00.000000000 Z
11
+ date: 2014-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails