jQuery-rwdImageMaps-rails 1.6.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 30fb65d05caae4f63ba5f9640000dde6aaac21a9570514c6bc0c592af88bfc1c
4
+ data.tar.gz: bda0266b272c0fd54e9a48b0c8aaf1dcf2b50a3c93746e2e79554e7a3306a5d1
5
+ SHA512:
6
+ metadata.gz: fe0ebe9027927a7a5b2cc709ba81e70c90d79595c5d66db0402e7e798a4ff97eb2f3b4afb929f55bb86b98f0411b22790e9cb67ca223a79817b3193b76740b23
7
+ data.tar.gz: 4e9b8fda0344680a5f6b81f8316dd76dc6fa63cf95002840de473692ccec6583a496d65d3ac5d5916cfbeb4b94bf5c5b1034ac606d3630e155f7e8adb98a1b19
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 Matt Stow
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 all
13
+ 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 THE
21
+ SOFTWARE.
@@ -0,0 +1,27 @@
1
+ jQuery-rwdImageMaps-rails [![Gem Version][version-badge]][rubygems]
2
+ ===================
3
+
4
+ [jQuery-rwdImageMaps-rails](https://github.com/Eric-Guo/jQuery-rwdImageMaps-rails), Rails wrap of Responsive Image Maps jQuery Plugin.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'jQuery-rwdImageMaps-rails'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ ## How to use
17
+
18
+ Add to your JavaScript manifest file (application.js):
19
+
20
+ ```js
21
+ //= require jquery.rwdImageMaps
22
+ ```
23
+
24
+ Visit [official doc](https://github.com/stowball/jQuery-rwdImageMaps#jquery-rwd-image-maps)
25
+
26
+ [version-badge]: https://badge.fury.io/rb/jQuery-rwdImageMaps-rails.svg
27
+ [rubygems]: https://rubygems.org/gems/jQuery-rwdImageMaps-rails
@@ -0,0 +1,10 @@
1
+ require 'jQuery-rwdImageMaps-rails/version'
2
+
3
+ module Jquery
4
+ module RwdImageMaps
5
+ module Rails
6
+ class Engine < ::Rails::Engine
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ module Jquery
2
+ module RwdImageMaps
3
+ VERSION = '1.6.0'.freeze
4
+ end
5
+ end
@@ -0,0 +1,75 @@
1
+ /*
2
+ * rwdImageMaps jQuery plugin v1.6
3
+ *
4
+ * Allows image maps to be used in a responsive design by recalculating the area coordinates to match the actual image size on load and window.resize
5
+ *
6
+ * Copyright (c) 2016 Matt Stow
7
+ * https://github.com/stowball/jQuery-rwdImageMaps
8
+ * http://mattstow.com
9
+ * Licensed under the MIT license
10
+ */
11
+ ;(function($) {
12
+ $.fn.rwdImageMaps = function() {
13
+ var $img = this;
14
+
15
+ var rwdImageMap = function() {
16
+ $img.each(function() {
17
+ if (typeof($(this).attr('usemap')) == 'undefined')
18
+ return;
19
+
20
+ var that = this,
21
+ $that = $(that);
22
+
23
+ // Since WebKit doesn't know the height until after the image has loaded, perform everything in an onload copy
24
+ $('<img />').on('load', function() {
25
+ var w, h;
26
+ if ($that.data('w') && $that.data('h')) {
27
+ w = $that.data('w');
28
+ h = $that.data('h');
29
+ } else {
30
+ var attrW = 'width',
31
+ attrH = 'height';
32
+ w = $that.attr(attrW);
33
+ h = $that.attr(attrH);
34
+
35
+ if (!w || !h) {
36
+ var temp = new Image();
37
+ temp.src = $that.attr('src');
38
+ if (!w)
39
+ w = temp.width;
40
+ if (!h)
41
+ h = temp.height;
42
+ }
43
+ $that.data('w', w);
44
+ $that.data('h', h);
45
+ }
46
+
47
+ var wPercent = $that.width()/100,
48
+ hPercent = $that.height()/100,
49
+ map = $that.attr('usemap').replace('#', ''),
50
+ c = 'coords';
51
+
52
+ $('map[name="' + map + '"]').find('area').each(function() {
53
+ var $this = $(this);
54
+ if (!$this.data(c))
55
+ $this.data(c, $this.attr(c));
56
+
57
+ var coords = $this.data(c).split(','),
58
+ coordsPercent = new Array(coords.length);
59
+
60
+ for (var i = 0; i < coordsPercent.length; ++i) {
61
+ if (i % 2 === 0)
62
+ coordsPercent[i] = parseInt(((coords[i]/w)*100)*wPercent);
63
+ else
64
+ coordsPercent[i] = parseInt(((coords[i]/h)*100)*hPercent);
65
+ }
66
+ $this.attr(c, coordsPercent.toString());
67
+ });
68
+ }).attr('src', $that.attr('src'));
69
+ });
70
+ };
71
+ $(window).resize(rwdImageMap).trigger('resize');
72
+
73
+ return this;
74
+ };
75
+ })(jQuery);
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jQuery-rwdImageMaps-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.6.0
5
+ platform: ruby
6
+ authors:
7
+ - Matt Stow
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-05-23 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Rails wrap of Responsive Image Maps jQuery Plugin.
14
+ email:
15
+ - matt@mattstow.com
16
+ - eric.guocz@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - LICENSE
22
+ - README.md
23
+ - lib/jQuery-rwdImageMaps-rails.rb
24
+ - lib/jQuery-rwdImageMaps-rails/version.rb
25
+ - vendor/assets/javascripts/jquery.rwdImageMaps.js
26
+ homepage: https://github.com/Eric-Guo/jQuery-rwdImageMaps-rails
27
+ licenses:
28
+ - MIT
29
+ metadata: {}
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubygems_version: 3.0.3
46
+ signing_key:
47
+ specification_version: 4
48
+ summary: Rails wrap of Responsive Image Maps jQuery Plugin.
49
+ test_files: []