jquery-zoom-rails 0.0.3
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.
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/app/assets/images/grab.cur +0 -0
- data/app/assets/images/grabbed.cur +0 -0
- data/app/assets/images/icon.png +0 -0
- data/app/assets/javascripts/jquery.zoom-min.js +6 -0
- data/app/assets/javascripts/jquery.zoom.js +173 -0
- data/jquery-zoom-rails.gemspec +19 -0
- data/lib/jquery-zoom-rails.rb +9 -0
- data/lib/jquery-zoom-rails/engine.rb +8 -0
- data/lib/jquery-zoom-rails/version.rb +7 -0
- metadata +59 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Theo Mills
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Jquery::Zoom::Rails
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'jquery-zoom-rails'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install jquery-zoom-rails
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,6 @@
|
|
1
|
+
/*
|
2
|
+
jQuery Zoom v1.7.1 - 2013-03-12
|
3
|
+
(c) 2013 Jack Moore - jacklmoore.com/zoom
|
4
|
+
license: http://www.opensource.org/licenses/mit-license.php
|
5
|
+
*/
|
6
|
+
(function(o){var t={url:!1,callback:!1,target:!1,duration:120,on:"mouseover"};o.zoom=function(t,n,e){var i,u,a,c,r,m=o(t).css("position");return o(t).css({position:/(absolute|fixed)/.test()?m:"relative",overflow:"hidden"}),o(e).addClass("zoomImg").css({position:"absolute",top:0,left:0,opacity:0,width:e.width,height:e.height,border:"none",maxWidth:"none"}).appendTo(t),{init:function(){i=o(t).outerWidth(),u=o(t).outerHeight(),a=(e.width-i)/o(n).outerWidth(),c=(e.height-u)/o(n).outerHeight(),r=o(n).offset()},move:function(o){var t=o.pageX-r.left,n=o.pageY-r.top;n=Math.max(Math.min(n,u),0),t=Math.max(Math.min(t,i),0),e.style.left=t*-a+"px",e.style.top=n*-c+"px"}}},o.fn.zoom=function(n){return this.each(function(){var e=o.extend({},t,n||{}),i=e.target||this,u=this,a=new Image,c=o(a),r="mousemove",m=!1;(e.url||(e.url=o(u).find("img").attr("src"),e.url))&&(a.onload=function(){function t(t){s.init(),s.move(t),c.stop().fadeTo(o.support.opacity?e.duration:0,1)}function n(){c.stop().fadeTo(e.duration,0)}var s=o.zoom(i,u,a);"grab"===e.on?o(u).on("mousedown",function(e){o(document).one("mouseup",function(){n(),o(document).off(r,s.move)}),t(e),o(document).on(r,s.move),e.preventDefault()}):"click"===e.on?o(u).on("click",function(e){return m?void 0:(m=!0,t(e),o(document).on(r,s.move),o(document).one("click",function(){n(),m=!1,o(document).off(r,s.move)}),!1)}):"toggle"===e.on?o(u).on("click",function(o){m?n():t(o),m=!m}):(s.init(),o(u).on("mouseenter",t).on("mouseleave",n).on(r,s.move)),o.isFunction(e.callback)&&e.callback.call(a)},a.src=e.url)})},o.fn.zoom.defaults=t})(window.jQuery);
|
@@ -0,0 +1,173 @@
|
|
1
|
+
/*
|
2
|
+
jQuery Zoom v1.7.1 - 2013-03-12
|
3
|
+
(c) 2013 Jack Moore - jacklmoore.com/zoom
|
4
|
+
license: http://www.opensource.org/licenses/mit-license.php
|
5
|
+
*/
|
6
|
+
(function ($) {
|
7
|
+
var defaults = {
|
8
|
+
url: false,
|
9
|
+
callback: false,
|
10
|
+
target: false,
|
11
|
+
duration: 120,
|
12
|
+
on: 'mouseover' // other options: 'grab', 'click', 'toggle'
|
13
|
+
};
|
14
|
+
|
15
|
+
// Core Zoom Logic, independent of event listeners.
|
16
|
+
$.zoom = function(target, source, img) {
|
17
|
+
var outerWidth,
|
18
|
+
outerHeight,
|
19
|
+
xRatio,
|
20
|
+
yRatio,
|
21
|
+
offset,
|
22
|
+
position = $(target).css('position');
|
23
|
+
|
24
|
+
// The parent element needs positioning so that the zoomed element can be correctly positioned within.
|
25
|
+
$(target).css({
|
26
|
+
position: /(absolute|fixed)/.test() ? position : 'relative',
|
27
|
+
overflow: 'hidden'
|
28
|
+
});
|
29
|
+
|
30
|
+
$(img)
|
31
|
+
.addClass('zoomImg')
|
32
|
+
.css({
|
33
|
+
position: 'absolute',
|
34
|
+
top: 0,
|
35
|
+
left: 0,
|
36
|
+
opacity: 0,
|
37
|
+
width: img.width,
|
38
|
+
height: img.height,
|
39
|
+
border: 'none',
|
40
|
+
maxWidth: 'none'
|
41
|
+
})
|
42
|
+
.appendTo(target);
|
43
|
+
|
44
|
+
return {
|
45
|
+
init: function() {
|
46
|
+
outerWidth = $(target).outerWidth();
|
47
|
+
outerHeight = $(target).outerHeight();
|
48
|
+
xRatio = (img.width - outerWidth) / $(source).outerWidth();
|
49
|
+
yRatio = (img.height - outerHeight) / $(source).outerHeight();
|
50
|
+
offset = $(source).offset();
|
51
|
+
},
|
52
|
+
move: function (e) {
|
53
|
+
var left = (e.pageX - offset.left),
|
54
|
+
top = (e.pageY - offset.top);
|
55
|
+
|
56
|
+
top = Math.max(Math.min(top, outerHeight), 0);
|
57
|
+
left = Math.max(Math.min(left, outerWidth), 0);
|
58
|
+
|
59
|
+
img.style.left = (left * -xRatio) + 'px';
|
60
|
+
img.style.top = (top * -yRatio) + 'px';
|
61
|
+
}
|
62
|
+
};
|
63
|
+
};
|
64
|
+
|
65
|
+
$.fn.zoom = function (options) {
|
66
|
+
return this.each(function () {
|
67
|
+
var
|
68
|
+
settings = $.extend({}, defaults, options || {}),
|
69
|
+
//target will display the zoomed iamge
|
70
|
+
target = settings.target || this,
|
71
|
+
//source will provide zoom location info (thumbnail)
|
72
|
+
source = this,
|
73
|
+
img = new Image(),
|
74
|
+
$img = $(img),
|
75
|
+
mousemove = 'mousemove',
|
76
|
+
clicked = false;
|
77
|
+
|
78
|
+
// If a url wasn't specified, look for an image element.
|
79
|
+
if (!settings.url) {
|
80
|
+
settings.url = $(source).find('img').attr('src');
|
81
|
+
if (!settings.url) {
|
82
|
+
return;
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
img.onload = function () {
|
87
|
+
var zoom = $.zoom(target, source, img);
|
88
|
+
|
89
|
+
function start(e) {
|
90
|
+
zoom.init();
|
91
|
+
zoom.move(e);
|
92
|
+
|
93
|
+
// Skip the fade-in for IE8 and lower since it chokes on fading-in
|
94
|
+
// and changing position based on mousemovement at the same time.
|
95
|
+
$img.stop()
|
96
|
+
.fadeTo($.support.opacity ? settings.duration : 0, 1);
|
97
|
+
}
|
98
|
+
|
99
|
+
function stop() {
|
100
|
+
$img.stop()
|
101
|
+
.fadeTo(settings.duration, 0);
|
102
|
+
}
|
103
|
+
|
104
|
+
if (settings.on === 'grab') {
|
105
|
+
$(source).on('mousedown',
|
106
|
+
function (e) {
|
107
|
+
$(document).one('mouseup',
|
108
|
+
function () {
|
109
|
+
stop();
|
110
|
+
|
111
|
+
$(document).off(mousemove, zoom.move);
|
112
|
+
}
|
113
|
+
);
|
114
|
+
|
115
|
+
start(e);
|
116
|
+
|
117
|
+
$(document).on(mousemove, zoom.move);
|
118
|
+
|
119
|
+
e.preventDefault();
|
120
|
+
}
|
121
|
+
);
|
122
|
+
} else if (settings.on === 'click') {
|
123
|
+
$(source).on('click',
|
124
|
+
function (e) {
|
125
|
+
if (clicked) {
|
126
|
+
// bubble the event up to the document to trigger the unbind.
|
127
|
+
return;
|
128
|
+
} else {
|
129
|
+
clicked = true;
|
130
|
+
start(e);
|
131
|
+
$(document).on(mousemove, zoom.move);
|
132
|
+
$(document).one('click',
|
133
|
+
function () {
|
134
|
+
stop();
|
135
|
+
clicked = false;
|
136
|
+
$(document).off(mousemove, zoom.move);
|
137
|
+
}
|
138
|
+
);
|
139
|
+
return false;
|
140
|
+
}
|
141
|
+
}
|
142
|
+
);
|
143
|
+
} else if (settings.on === 'toggle') {
|
144
|
+
$(source).on('click',
|
145
|
+
function (e) {
|
146
|
+
if (clicked) {
|
147
|
+
stop();
|
148
|
+
} else {
|
149
|
+
start(e);
|
150
|
+
}
|
151
|
+
clicked = !clicked;
|
152
|
+
}
|
153
|
+
);
|
154
|
+
} else {
|
155
|
+
zoom.init(); // Pre-emptively call init because IE7 will fire the mousemove handler before the hover handler.
|
156
|
+
|
157
|
+
$(source)
|
158
|
+
.on('mouseenter', start)
|
159
|
+
.on('mouseleave', stop)
|
160
|
+
.on(mousemove, zoom.move);
|
161
|
+
}
|
162
|
+
|
163
|
+
if ($.isFunction(settings.callback)) {
|
164
|
+
settings.callback.call(img);
|
165
|
+
}
|
166
|
+
};
|
167
|
+
|
168
|
+
img.src = settings.url;
|
169
|
+
});
|
170
|
+
};
|
171
|
+
|
172
|
+
$.fn.zoom.defaults = defaults;
|
173
|
+
}(window.jQuery));
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jquery-zoom-rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "jquery-zoom-rails"
|
8
|
+
gem.version = Jquery::Zoom::Rails::VERSION
|
9
|
+
gem.authors = ["Theo Mills"]
|
10
|
+
gem.email = ["twmills@twmills.com"]
|
11
|
+
gem.description = %q{Jack Moore's jQuery image zoom plugin for rails}
|
12
|
+
gem.summary = %q{Jack Moore's jQuery image zoom plugin for rails}
|
13
|
+
gem.homepage = "https://github.com/twmills/jquery-zoom-rails"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jquery-zoom-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Theo Mills
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-02 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Jack Moore's jQuery image zoom plugin for rails
|
15
|
+
email:
|
16
|
+
- twmills@twmills.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- LICENSE.txt
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- app/assets/images/grab.cur
|
27
|
+
- app/assets/images/grabbed.cur
|
28
|
+
- app/assets/images/icon.png
|
29
|
+
- app/assets/javascripts/jquery.zoom-min.js
|
30
|
+
- app/assets/javascripts/jquery.zoom.js
|
31
|
+
- jquery-zoom-rails.gemspec
|
32
|
+
- lib/jquery-zoom-rails.rb
|
33
|
+
- lib/jquery-zoom-rails/engine.rb
|
34
|
+
- lib/jquery-zoom-rails/version.rb
|
35
|
+
homepage: https://github.com/twmills/jquery-zoom-rails
|
36
|
+
licenses: []
|
37
|
+
post_install_message:
|
38
|
+
rdoc_options: []
|
39
|
+
require_paths:
|
40
|
+
- lib
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
requirements: []
|
54
|
+
rubyforge_project:
|
55
|
+
rubygems_version: 1.8.24
|
56
|
+
signing_key:
|
57
|
+
specification_version: 3
|
58
|
+
summary: Jack Moore's jQuery image zoom plugin for rails
|
59
|
+
test_files: []
|