jquery_lazy_load 0.1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 38acc36a3163f030b2eb076b108ff2651d532a92
4
+ data.tar.gz: 910954afc0142c840258fdbab324cc3c3e2659e2
5
+ SHA512:
6
+ metadata.gz: 2913e6b756c7fd657d50aab110e896c340bc8ea37e7779663ea6444b41399da0dea341393d224ce0b282abc92fab186a4732b8a657fbe12353f34eabeee47624
7
+ data.tar.gz: fc62bd6b12b5525812945ae945e563fb9d1504cde13378084e2e4e31c2f771aa030198fe813c66c1219eb7cf5b91626226dff265ec42415e6cd8499942749bb4
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ .idea
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.4
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jquery_lazy_load.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 C80609A
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # JqueryLazyLoad
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/jquery_lazy_load.svg)](http://badge.fury.io/rb/jquery_lazy_load)
4
+ [![Build Status](https://travis-ci.org/c080609a/jquery_lazy_load.svg?branch=master)](https://travis-ci.org/c080609a/jquery_lazy_load)
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'jquery_lazy_load'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install jquery_lazy_load
21
+
22
+ NOTE: this is a jQuery plugin so you will also need the `jquery-rails` gem:
23
+
24
+ * https://github.com/rails/jquery-rails
25
+
26
+ ## Usage
27
+
28
+ You will need to add this line into your `application.js`:
29
+
30
+ //= require jquery_lazy_load
31
+
32
+ And add this line into `application.scss`:
33
+
34
+ @import "jquery_lazy_load";
35
+
36
+ Gem functionality applies to code snippets like this:
37
+
38
+ <a title="TITLE" class="lazy-image-wrapper" href="HREF">
39
+ <img alt="ALT" data-original="image800x600.jpg" src="transparent800x600.gif">
40
+ </a>
41
+
42
+ ## Development
43
+
44
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
45
+
46
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
47
+
48
+ ## Contributing
49
+
50
+ 1. Fork it ( https://github.com/[my-github-username]/jquery_lazy_load/fork )
51
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
52
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
53
+ 4. Push to the branch (`git push origin my-new-feature`)
54
+ 5. Create a new Pull Request
55
+
56
+ Copyright (c) 2015 [C80609A](http://link-studio.pro)
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
Binary file
@@ -0,0 +1,247 @@
1
+ /*
2
+ * Lazy Load - jQuery plugin for lazy loading images
3
+ *
4
+ * Copyright (c) 2007-2013 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.9.3
13
+ *
14
+ */
15
+
16
+ (function($, window, document, undefined) {
17
+ var $window = $(window);
18
+
19
+ $.fn.lazyload = function(options) {
20
+ var elements = this;
21
+ var $container;
22
+ var settings = {
23
+ threshold : 0,
24
+ failure_limit : 0,
25
+ event : "scroll",
26
+ effect : "show",
27
+ container : window,
28
+ data_attribute : "original",
29
+ skip_invisible : true,
30
+ appear : null,
31
+ load : null,
32
+ placeholder : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC"
33
+ };
34
+
35
+ function update() {
36
+ var counter = 0;
37
+
38
+ elements.each(function() {
39
+ var $this = $(this);
40
+ if (settings.skip_invisible && !$this.is(":visible")) {
41
+ return;
42
+ }
43
+ if ($.abovethetop(this, settings) ||
44
+ $.leftofbegin(this, settings)) {
45
+ /* Nothing. */
46
+ } else if (!$.belowthefold(this, settings) &&
47
+ !$.rightoffold(this, settings)) {
48
+ $this.trigger("appear");
49
+ /* if we found an image we'll load, reset the counter */
50
+ counter = 0;
51
+ } else {
52
+ if (++counter > settings.failure_limit) {
53
+ return false;
54
+ }
55
+ }
56
+ });
57
+
58
+ }
59
+
60
+ if(options) {
61
+ /* Maintain BC for a couple of versions. */
62
+ if (undefined !== options.failurelimit) {
63
+ options.failure_limit = options.failurelimit;
64
+ delete options.failurelimit;
65
+ }
66
+ if (undefined !== options.effectspeed) {
67
+ options.effect_speed = options.effectspeed;
68
+ delete options.effectspeed;
69
+ }
70
+
71
+ $.extend(settings, options);
72
+ }
73
+
74
+ /* Cache container as jQuery as object. */
75
+ $container = (settings.container === undefined ||
76
+ settings.container === window) ? $window : $(settings.container);
77
+
78
+ /* Fire one scroll event per scroll. Not one scroll event per image. */
79
+ if (0 === settings.event.indexOf("scroll")) {
80
+ $container.bind(settings.event, function() {
81
+ return update();
82
+ });
83
+ }
84
+
85
+ this.each(function() {
86
+ var self = this;
87
+ var $self = $(self);
88
+
89
+ self.loaded = false;
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
+
98
+ /* If data-original is "null" - return. */
99
+ if ($self.attr("data-" + settings.data_attribute) == "null") {
100
+ return;
101
+ }
102
+
103
+ /* When appear is triggered load original image. */
104
+ $self.one("appear", function() {
105
+ if (!this.loaded) {
106
+ if (settings.appear) {
107
+ var elements_left = elements.length;
108
+ settings.appear.call(self, elements_left, settings);
109
+ }
110
+ $("<img />")
111
+ .bind("load", function() {
112
+
113
+ var original = $self.attr("data-" + settings.data_attribute);
114
+ $self.hide();
115
+ if ($self.is("img")) {
116
+ $self.attr("src", original);
117
+ } else {
118
+ $self.css("background-image", "url('" + original + "')");
119
+ }
120
+ $self[settings.effect](settings.effect_speed);
121
+
122
+ self.loaded = true;
123
+
124
+ /* Remove image from array so it is not looped next time. */
125
+ var temp = $.grep(elements, function(element) {
126
+ return !element.loaded;
127
+ });
128
+ elements = $(temp);
129
+
130
+ if (settings.load) {
131
+ var elements_left = elements.length;
132
+ settings.load.call(self, elements_left, settings);
133
+ }
134
+ })
135
+ .attr("src", $self.attr("data-" + settings.data_attribute));
136
+ }
137
+ });
138
+
139
+ /* When wanted event is triggered load original image */
140
+ /* by triggering appear. */
141
+ if (0 !== settings.event.indexOf("scroll")) {
142
+ $self.bind(settings.event, function() {
143
+ if (!self.loaded) {
144
+ $self.trigger("appear");
145
+ }
146
+ });
147
+ }
148
+ });
149
+
150
+ /* Check if something appears when window is resized. */
151
+ $window.bind("resize", function() {
152
+ update();
153
+ });
154
+
155
+ /* With IOS5 force loading images when navigating with back button. */
156
+ /* Non optimal workaround. */
157
+ if ((/(?:iphone|ipod|ipad).*os 5/gi).test(navigator.appVersion)) {
158
+ $window.bind("pageshow", function(event) {
159
+ if (event.originalEvent && event.originalEvent.persisted) {
160
+ elements.each(function() {
161
+ $(this).trigger("appear");
162
+ });
163
+ }
164
+ });
165
+ }
166
+
167
+ /* Force initial check if images should appear. */
168
+ $(document).ready(function() {
169
+ update();
170
+ });
171
+
172
+ return this;
173
+ };
174
+
175
+ /* Convenience methods in jQuery namespace. */
176
+ /* Use as $.belowthefold(element, {threshold : 100, container : window}) */
177
+
178
+ $.belowthefold = function(element, settings) {
179
+ var fold;
180
+
181
+ if (settings.container === undefined || settings.container === window) {
182
+ fold = (window.innerHeight ? window.innerHeight : $window.height()) + $window.scrollTop();
183
+ } else {
184
+ fold = $(settings.container).offset().top + $(settings.container).height();
185
+ }
186
+
187
+ return fold <= $(element).offset().top - settings.threshold;
188
+ };
189
+
190
+ $.rightoffold = function(element, settings) {
191
+ var fold;
192
+
193
+ if (settings.container === undefined || settings.container === window) {
194
+ fold = $window.width() + $window.scrollLeft();
195
+ } else {
196
+ fold = $(settings.container).offset().left + $(settings.container).width();
197
+ }
198
+
199
+ return fold <= $(element).offset().left - settings.threshold;
200
+ };
201
+
202
+ $.abovethetop = function(element, settings) {
203
+ var fold;
204
+
205
+ if (settings.container === undefined || settings.container === window) {
206
+ fold = $window.scrollTop();
207
+ } else {
208
+ fold = $(settings.container).offset().top;
209
+ }
210
+
211
+ return fold >= $(element).offset().top + settings.threshold + $(element).height();
212
+ };
213
+
214
+ $.leftofbegin = function(element, settings) {
215
+ var fold;
216
+
217
+ if (settings.container === undefined || settings.container === window) {
218
+ fold = $window.scrollLeft();
219
+ } else {
220
+ fold = $(settings.container).offset().left;
221
+ }
222
+
223
+ return fold >= $(element).offset().left + settings.threshold + $(element).width();
224
+ };
225
+
226
+ $.inviewport = function(element, settings) {
227
+ return !$.rightoffold(element, settings) && !$.leftofbegin(element, settings) &&
228
+ !$.belowthefold(element, settings) && !$.abovethetop(element, settings);
229
+ };
230
+
231
+ /* Custom selectors for your convenience. */
232
+ /* Use as $("img:below-the-fold").something() or */
233
+ /* $("img").filter(":below-the-fold").something() which is faster */
234
+
235
+ $.extend($.expr[":"], {
236
+ "below-the-fold" : function(a) { return $.belowthefold(a, {threshold : 0}); },
237
+ "above-the-top" : function(a) { return !$.belowthefold(a, {threshold : 0}); },
238
+ "right-of-screen": function(a) { return $.rightoffold(a, {threshold : 0}); },
239
+ "left-of-screen" : function(a) { return !$.rightoffold(a, {threshold : 0}); },
240
+ "in-viewport" : function(a) { return $.inviewport(a, {threshold : 0}); },
241
+ /* Maintain BC for couple of versions. */
242
+ "above-the-fold" : function(a) { return !$.belowthefold(a, {threshold : 0}); },
243
+ "right-of-fold" : function(a) { return $.rightoffold(a, {threshold : 0}); },
244
+ "left-of-fold" : function(a) { return !$.rightoffold(a, {threshold : 0}); }
245
+ });
246
+
247
+ })(jQuery, window, document);
@@ -0,0 +1,10 @@
1
+ var fLazyStart = function () {
2
+ $(".lazy-image-wrapper img").lazyload({
3
+ effect : "fadeIn"//,
4
+ // event: "scrollstop"
5
+ });
6
+ };
7
+
8
+ $(function() {
9
+ fLazyStart();
10
+ });
@@ -0,0 +1,2 @@
1
+ #= require jquery.lazyload
2
+ #= require jquery.lazyload.start
@@ -0,0 +1 @@
1
+ @import "lazy-image";
@@ -0,0 +1,15 @@
1
+ /* Ссылка, которая содержит lazy-картинку, оснащается loading.gif прелоадером
2
+ А сама lazy-картинка делается max-width: 100%; по ширине.
3
+ */
4
+
5
+ a.lazy-image-wrapper {
6
+ display: inline-block;
7
+ background: rgba(25,25,25,0.01) url(image_path('loading.gif')) no-repeat 50% 50% !important;
8
+ outline: none;
9
+
10
+ img {
11
+ max-width: 100%;
12
+ height: auto;
13
+ vertical-align: middle;
14
+ }
15
+ }
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "jquery_lazy_load"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jquery_lazy_load/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jquery_lazy_load"
8
+ spec.version = JqueryLazyLoad::VERSION
9
+ spec.authors = ["C80609A"]
10
+ spec.email = ["c080609a@gmail.com"]
11
+
12
+ spec.summary = "simple jquery lazy load gem and some additions"
13
+ spec.description = 'nuff said'
14
+ spec.homepage = "https://github.com/c080609a/jquery_lazy_load"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency 'railties'
23
+ spec.add_development_dependency "bundler", "~> 1.7"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ end
@@ -0,0 +1,8 @@
1
+ require "jquery_lazy_load/version"
2
+
3
+ module JqueryLazyLoad
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module JqueryLazyLoad
2
+ VERSION = "0.1.0.9"
3
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jquery_lazy_load
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.9
5
+ platform: ruby
6
+ authors:
7
+ - C80609A
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-12-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: nuff said
56
+ email:
57
+ - c080609a@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".travis.yml"
64
+ - CODE_OF_CONDUCT.md
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - app/assets/images/loading.gif
70
+ - app/assets/javascripts/jquery.lazyload.js
71
+ - app/assets/javascripts/jquery.lazyload.start.js
72
+ - app/assets/javascripts/jquery_lazy_load.js.coffee
73
+ - app/assets/stylesheets/jquery_lazy_load.scss
74
+ - app/assets/stylesheets/lazy-image.scss
75
+ - bin/console
76
+ - bin/setup
77
+ - jquery_lazy_load.gemspec
78
+ - lib/jquery_lazy_load.rb
79
+ - lib/jquery_lazy_load/version.rb
80
+ homepage: https://github.com/c080609a/jquery_lazy_load
81
+ licenses:
82
+ - MIT
83
+ metadata: {}
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 2.4.7
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: simple jquery lazy load gem and some additions
104
+ test_files: []