magnifierjs-rails 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module Magnifierjs
2
2
  module Rails
3
- VERSION = "0.0.1"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -1,27 +1,53 @@
1
- W = 1341
2
- H = 1171
3
- w = 670
4
- h = 585
5
-
6
1
  $ ->
7
- $("#zoomimage").mouseover (e) ->
8
- $(document).mousemove(myMM)
9
- $("#glass").fadeIn('slow')
10
-
11
- myMM = (e) ->
12
- image = $("#zoomimage")
13
- glass = $("#glass")
14
-
15
- xPosition = e.pageX - image.offset().left
16
- yPosition = e.pageY - image.offset().top
17
- backgroundXPosition = glass.width() / 2 - xPosition*W/w
18
- backgroundYPosition = glass.height()/ 2 - yPosition*H/h
19
-
20
- glass.css
21
- 'left': xPosition-100
22
- 'top': yPosition-100
23
- 'background-position': backgroundXPosition+"px "+backgroundYPosition+"px"
24
-
25
- if (backgroundXPosition<-W || backgroundYPosition<-H || backgroundXPosition>200 || backgroundYPosition>200)
26
- image.unbind('mousemove', myMM)
27
- glass.fadeOut('fast')
2
+ image = $("#magnifierjs-image")
3
+ larW = 0
4
+ larH = 0
5
+
6
+ glass = $('<div id="magnifierjs-glass"></div>').appendTo($('body'))
7
+
8
+ setLargeSrc = () ->
9
+ largeSrc = image.data('magnifierjs-zoomimage')
10
+
11
+ loader = $('<img>')
12
+ loader.load ->
13
+ larW = this.width
14
+ larH = this.height
15
+ loader.attr('src', largeSrc)
16
+ glass.css 'background-image': "url("+largeSrc+")"
17
+
18
+ setLargeSrc()
19
+
20
+ image.mouseover ->
21
+ setLargeSrc()
22
+ $(document).mousemove(moveGlass)
23
+ glass.fadeIn('slow')
24
+
25
+ moveGlass = (e) ->
26
+ imgW = image.width()
27
+ imgH = image.height()
28
+ imgX = image.offset().left
29
+ imgY = image.offset().top
30
+
31
+ curX = e.pageX
32
+ curY = e.pageY
33
+
34
+ glaX = curX - glass.width() / 2
35
+ glaY = curY - glass.width() / 2
36
+
37
+ innX = curX - imgX
38
+ innY = curY - imgY
39
+
40
+ bgX = glass.width() / 2 - innX * larW / imgW
41
+ bgY = glass.height()/ 2 - innY * larH / imgH
42
+ # console.log larW+" "+larH+" "+bgX+" "+bgY
43
+
44
+ glass.css
45
+ 'left': glaX
46
+ 'top': glaY
47
+ 'background-position': bgX+"px "+bgY+"px"
48
+
49
+ # console.log imgX+" "+curX+" "+(imgX + imgW)+" | "+imgY+" "+curY+" "+(imgY + imgH)
50
+ if (curX < imgX) || (curY < imgY) || (curX > (imgX + imgW)) || (curY > (imgY + imgH))
51
+ # console.log "OUT >>"
52
+ $(document).unbind('mousemove', moveGlass)
53
+ glass.fadeOut('fast')
@@ -0,0 +1,13 @@
1
+ #magnifierjs-glass
2
+ background-color: transparent
3
+ background-repeat: no-repeat
4
+ width: 200px
5
+ height: 200px
6
+ border: 1px solid black
7
+ margin: 0
8
+ padding: 0
9
+ position: absolute
10
+ display: none
11
+ border-radius: 100px
12
+ -moz-border-radius: 100px
13
+ cursor: none
metadata CHANGED
@@ -1,91 +1,105 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: magnifierjs-rails
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.1
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
5
10
  platform: ruby
6
- authors:
11
+ authors:
7
12
  - Alexander Presber
8
13
  autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
- date: 2013-11-09 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
16
+
17
+ date: 2013-11-15 00:00:00 +01:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
14
21
  name: railties
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ~>
18
- - !ruby/object:Gem::Version
19
- version: '4.0'
20
- type: :runtime
21
22
  prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
24
25
  - - ~>
25
- - !ruby/object:Gem::Version
26
- version: '4.0'
27
- - !ruby/object:Gem::Dependency
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 4
29
+ - 0
30
+ version: "4.0"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
28
34
  name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ~>
32
- - !ruby/object:Gem::Version
33
- version: '1.3'
34
- type: :development
35
35
  prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ requirements:
38
38
  - - ~>
39
- - !ruby/object:Gem::Version
40
- version: '1.3'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - '>='
46
- - !ruby/object:Gem::Version
47
- version: '0'
39
+ - !ruby/object:Gem::Version
40
+ segments:
41
+ - 1
42
+ - 3
43
+ version: "1.3"
48
44
  type: :development
45
+ version_requirements: *id002
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
49
48
  prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
49
+ requirement: &id003 !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ segments:
54
+ - 0
55
+ version: "0"
56
+ type: :development
57
+ version_requirements: *id003
55
58
  description: magnifying glass for images
56
- email:
59
+ email:
57
60
  - post@momolog.info
58
61
  executables: []
62
+
59
63
  extensions: []
64
+
60
65
  extra_rdoc_files: []
61
- files:
66
+
67
+ files:
62
68
  - lib/magnifierjs/rails/version.rb
63
69
  - lib/magnifierjs/rails.rb
64
70
  - vendor/assets/javascripts/magnifierjs.coffee
71
+ - vendor/assets/stylesheets/magnifierjs.sass
65
72
  - LICENSE.txt
66
73
  - README.md
67
- homepage: ''
68
- licenses:
74
+ has_rdoc: true
75
+ homepage: ""
76
+ licenses:
69
77
  - MIT
70
- metadata: {}
71
78
  post_install_message:
72
79
  rdoc_options: []
73
- require_paths:
80
+
81
+ require_paths:
74
82
  - lib
75
- required_ruby_version: !ruby/object:Gem::Requirement
76
- requirements:
77
- - - '>='
78
- - !ruby/object:Gem::Version
79
- version: '0'
80
- required_rubygems_version: !ruby/object:Gem::Requirement
81
- requirements:
82
- - - '>='
83
- - !ruby/object:Gem::Version
84
- version: '0'
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ segments:
88
+ - 0
89
+ version: "0"
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ segments:
95
+ - 0
96
+ version: "0"
85
97
  requirements: []
98
+
86
99
  rubyforge_project:
87
- rubygems_version: 2.0.6
100
+ rubygems_version: 1.3.6
88
101
  signing_key:
89
- specification_version: 4
102
+ specification_version: 3
90
103
  summary: magnifying glass for images
91
104
  test_files: []
105
+
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 49f2849be4c39f29376d1c4db202c97fcb075892
4
- data.tar.gz: 367f1adf0b57c930386b32730c60c7e82eca5237
5
- SHA512:
6
- metadata.gz: 6af03557c4d608e396983d77ef990b6852f1e18c2c6a62b35e1575202b26fd11059637e44e470b7f0fbf3105af1b1f0c1ef79fb9ae7ae2ccdd3bd6f17eaf0a17
7
- data.tar.gz: 1e406e9c6f117e13725912235b50aa815619081fa1b190a40398ba15758acaa49c4b58ea9ddd79e299f139e3c50603c06c25d74ce881784243eff21b2c012cff