dharajoshi_first_gem 0.1.0 → 0.1.1
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 +4 -4
- data/.idea/workspace.xml +9 -26
- data/app/assets/javascripts/image_zoomer.js +113 -0
- data/lib/dharajoshi_first_gem/engine.rb +5 -0
- data/lib/dharajoshi_first_gem/version.rb +1 -1
- data/lib/dharajoshi_first_gem.rb +2 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2d0321c8eb304a925a49921d9e3f599ea3622ae6
|
|
4
|
+
data.tar.gz: 879fce0ce8b087a7329e1791253b0f99bb214dfa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e60dca6015332a2cfd70013a2080e0a8dd50c3822d1188abee6be7d396df0b88cab05cf1f2f4383afbbfe241f993f20ba64a5177d4f4f77aca7ae3dbe768c823
|
|
7
|
+
data.tar.gz: dee22c728074c39236063b5ed8b29ebca579bb3153f747dc505b7c1a5f843c5f8f4d624534c50d51cd2bde1d91ec320e4dd450c324c650d93f6052966b6fdd7b
|
data/.idea/workspace.xml
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<file path="/version_test.rb" changelist="dd48a1af-7b08-4d26-865d-cacb03764e63" time="1430484716754" ignored="false" />
|
|
15
15
|
<file path="/a.dummy" changelist="dd48a1af-7b08-4d26-865d-cacb03764e63" time="1430814728774" ignored="false" />
|
|
16
16
|
<file path="/railtie.rb" changelist="dd48a1af-7b08-4d26-865d-cacb03764e63" time="1430814765388" ignored="false" />
|
|
17
|
-
<file path="/dharajoshi_first_gem.rb" changelist="dd48a1af-7b08-4d26-865d-cacb03764e63" time="
|
|
17
|
+
<file path="/dharajoshi_first_gem.rb" changelist="dd48a1af-7b08-4d26-865d-cacb03764e63" time="1430818745701" ignored="false" />
|
|
18
18
|
<file path="$PROJECT_DIR$/../../test_my_first_gem/Gemfile" changelist="dd48a1af-7b08-4d26-865d-cacb03764e63" time="1430807701280" ignored="false" />
|
|
19
19
|
<file path="$PROJECT_DIR$/../../test_my_first_gem/config/database.yml" changelist="dd48a1af-7b08-4d26-865d-cacb03764e63" time="1430720314201" ignored="false" />
|
|
20
20
|
<file path="/database.yml" changelist="dd48a1af-7b08-4d26-865d-cacb03764e63" time="1430720314201" ignored="false" />
|
|
@@ -26,11 +26,12 @@
|
|
|
26
26
|
<file path="$PROJECT_DIR$/../../um_shop/app/assets/javascripts/ember/routes/products/browse.coffee" changelist="dd48a1af-7b08-4d26-865d-cacb03764e63" time="1430733731898" ignored="false" />
|
|
27
27
|
<file path="$PROJECT_DIR$/../../um_shop/app/assets/javascripts/ember/routes/products/highlights.coffee" changelist="dd48a1af-7b08-4d26-865d-cacb03764e63" time="1430733753353" ignored="false" />
|
|
28
28
|
<file path="/Gemfile" changelist="dd48a1af-7b08-4d26-865d-cacb03764e63" time="1430807701280" ignored="false" />
|
|
29
|
-
<file path="$PROJECT_DIR$/../../test_my_first_gem/Gemfile.lock" changelist="dd48a1af-7b08-4d26-865d-cacb03764e63" time="
|
|
29
|
+
<file path="$PROJECT_DIR$/../../test_my_first_gem/Gemfile.lock" changelist="dd48a1af-7b08-4d26-865d-cacb03764e63" time="1430818627850" ignored="false" />
|
|
30
30
|
<file path="$PROJECT_DIR$/../../test_my_first_gem/app/views/site/index.html.erb" changelist="dd48a1af-7b08-4d26-865d-cacb03764e63" time="1430817267979" ignored="false" />
|
|
31
31
|
<file path="/index.html.erb" changelist="dd48a1af-7b08-4d26-865d-cacb03764e63" time="1430816923051" ignored="false" />
|
|
32
32
|
<file path="$PROJECT_DIR$/../../test_my_first_gem/config/routes.rb" changelist="dd48a1af-7b08-4d26-865d-cacb03764e63" time="1430817205845" ignored="false" />
|
|
33
33
|
<file path="/engine.rb" changelist="dd48a1af-7b08-4d26-865d-cacb03764e63" time="1430817635515" ignored="false" />
|
|
34
|
+
<file path="$PROJECT_DIR$/../../test_my_first_gem/app/assets/javascripts/application.js" changelist="dd48a1af-7b08-4d26-865d-cacb03764e63" time="1430818644271" ignored="false" />
|
|
34
35
|
<option name="TRACKING_ENABLED" value="true" />
|
|
35
36
|
<option name="SHOW_DIALOG" value="false" />
|
|
36
37
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
@@ -53,7 +54,7 @@
|
|
|
53
54
|
<file leaf-file-name="dharajoshi_first_gem.rb" pinned="false" current="false" current-in-tab="false">
|
|
54
55
|
<entry file="file://$PROJECT_DIR$/lib/dharajoshi_first_gem.rb">
|
|
55
56
|
<provider selected="true" editor-type-id="text-editor">
|
|
56
|
-
<state line="
|
|
57
|
+
<state line="8" column="26" selection-start="249" selection-end="249" vertical-scroll-proportion="0.0">
|
|
57
58
|
<folding />
|
|
58
59
|
</state>
|
|
59
60
|
</provider>
|
|
@@ -99,9 +100,9 @@
|
|
|
99
100
|
<option value="$PROJECT_DIR$/test/lib/dharajoshi_first_gem/version_test.rb" />
|
|
100
101
|
<option value="$PROJECT_DIR$/test/test_helper.rb" />
|
|
101
102
|
<option value="$PROJECT_DIR$/lib/dharajoshi_first_gem/railtie.rb" />
|
|
102
|
-
<option value="$PROJECT_DIR$/lib/dharajoshi_first_gem.rb" />
|
|
103
103
|
<option value="$PROJECT_DIR$/app/assets/javascripts/image_zoomer.js" />
|
|
104
104
|
<option value="$PROJECT_DIR$/lib/dharajoshi_first_gem/engine.rb" />
|
|
105
|
+
<option value="$PROJECT_DIR$/lib/dharajoshi_first_gem.rb" />
|
|
105
106
|
<option value="$PROJECT_DIR$/lib/dharajoshi_first_gem/version.rb" />
|
|
106
107
|
</list>
|
|
107
108
|
</option>
|
|
@@ -170,24 +171,6 @@
|
|
|
170
171
|
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
|
171
172
|
</PATH_ELEMENT>
|
|
172
173
|
</PATH>
|
|
173
|
-
<PATH>
|
|
174
|
-
<PATH_ELEMENT>
|
|
175
|
-
<option name="myItemId" value="dharajoshi_first_gem" />
|
|
176
|
-
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
|
|
177
|
-
</PATH_ELEMENT>
|
|
178
|
-
<PATH_ELEMENT>
|
|
179
|
-
<option name="myItemId" value="dharajoshi_first_gem" />
|
|
180
|
-
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
|
181
|
-
</PATH_ELEMENT>
|
|
182
|
-
<PATH_ELEMENT>
|
|
183
|
-
<option name="myItemId" value="lib" />
|
|
184
|
-
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
|
185
|
-
</PATH_ELEMENT>
|
|
186
|
-
<PATH_ELEMENT>
|
|
187
|
-
<option name="myItemId" value="dharajoshi_first_gem" />
|
|
188
|
-
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
|
189
|
-
</PATH_ELEMENT>
|
|
190
|
-
</PATH>
|
|
191
174
|
<PATH>
|
|
192
175
|
<PATH_ELEMENT>
|
|
193
176
|
<option name="myItemId" value="dharajoshi_first_gem" />
|
|
@@ -467,16 +450,16 @@
|
|
|
467
450
|
</state>
|
|
468
451
|
</provider>
|
|
469
452
|
</entry>
|
|
470
|
-
<entry file="file://$PROJECT_DIR$/lib/dharajoshi_first_gem.rb">
|
|
453
|
+
<entry file="file://$PROJECT_DIR$/lib/dharajoshi_first_gem/engine.rb">
|
|
471
454
|
<provider selected="true" editor-type-id="text-editor">
|
|
472
|
-
<state line="
|
|
455
|
+
<state line="1" column="30" selection-start="56" selection-end="56" vertical-scroll-proportion="0.0">
|
|
473
456
|
<folding />
|
|
474
457
|
</state>
|
|
475
458
|
</provider>
|
|
476
459
|
</entry>
|
|
477
|
-
<entry file="file://$PROJECT_DIR$/lib/dharajoshi_first_gem
|
|
460
|
+
<entry file="file://$PROJECT_DIR$/lib/dharajoshi_first_gem.rb">
|
|
478
461
|
<provider selected="true" editor-type-id="text-editor">
|
|
479
|
-
<state line="
|
|
462
|
+
<state line="8" column="26" selection-start="249" selection-end="249" vertical-scroll-proportion="0.0">
|
|
480
463
|
<folding />
|
|
481
464
|
</state>
|
|
482
465
|
</provider>
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
(function($) {
|
|
2
|
+
|
|
3
|
+
var zoom_context, zoom_canvas = "<canvas id='zoom_canvas' style='position: absolute; border: solid 1px #e8e8e8;'></canvas>";
|
|
4
|
+
var zoom_canvas_container_name = "#zoom_canvas_container", zoom_canvas_name = "#zoom_canvas", temp_image_canvas_context, remove_image_zoomer_timer;
|
|
5
|
+
|
|
6
|
+
$.fn.image_zoomer = function(options) {
|
|
7
|
+
|
|
8
|
+
if (typeof options == "string" && options == "destroy") {
|
|
9
|
+
this.data("is_destroyed", true);
|
|
10
|
+
return this;
|
|
11
|
+
} else {
|
|
12
|
+
// extend default options with passed ones
|
|
13
|
+
var options = $.extend({
|
|
14
|
+
height: 90,
|
|
15
|
+
width: 90,
|
|
16
|
+
scale: 1.5
|
|
17
|
+
}, options);
|
|
18
|
+
this.data("is_destroyed", false);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
var image = this;
|
|
22
|
+
|
|
23
|
+
this.mouseenter(function(e) {
|
|
24
|
+
if ($(this).data("is_destroyed")) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
if ($(zoom_canvas_container_name).length == 0) {
|
|
28
|
+
$(this).wrap("<span id='zoom_canvas_container'></span>");
|
|
29
|
+
var zoom_canvas_container = $(zoom_canvas_container_name);
|
|
30
|
+
var temp_image_canvas = _insert_temp_canvas(zoom_canvas_container, image);
|
|
31
|
+
$(zoom_canvas_container).mousemove(function(e) {
|
|
32
|
+
if ($(zoom_canvas_name).length == 0) {
|
|
33
|
+
create_zoom_canvas(options);
|
|
34
|
+
$(zoom_canvas_name).mousemove(function(e) {
|
|
35
|
+
zoom_image_mousemove(zoom_canvas_container, e, options, image, temp_image_canvas, true);
|
|
36
|
+
return false;
|
|
37
|
+
}).mouseleave(zoom_image_mouseleave);
|
|
38
|
+
}
|
|
39
|
+
zoom_image_mousemove(zoom_canvas_container, e, options, image, temp_image_canvas, false);
|
|
40
|
+
return false;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
});
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function create_zoom_canvas(options) {
|
|
49
|
+
$("body").append(zoom_canvas);
|
|
50
|
+
$(zoom_canvas_name).attr("width", options.width).attr("height", options.height);
|
|
51
|
+
zoom_context = $(zoom_canvas_name).get(0).getContext('2d');
|
|
52
|
+
zoom_context.scale(options.scale, options.scale);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function zoom_image_mousemove(elem, e, options, image, temp_image_canvas, check_bounds) {
|
|
56
|
+
var image_offset = image.offset();
|
|
57
|
+
if (check_if_in_bounds(e, image, image_offset)) {
|
|
58
|
+
zoom_context.clearRect(0, 0, options.width, options.height);
|
|
59
|
+
zoom_image(e, options, temp_image_canvas, image_offset);
|
|
60
|
+
} else if (check_bounds) {
|
|
61
|
+
zoom_image_mouseleave();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function zoom_image_mouseleave(e) {
|
|
66
|
+
remove_image_zoomer();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function zoom_image(e, options, temp_image_canvas, image_offset) {
|
|
70
|
+
var coordinates = _prepare_coordinates(e, options, image_offset);
|
|
71
|
+
$(zoom_canvas_name).css({left: coordinates.page_x, top: coordinates.page_y, "z-index": 99});
|
|
72
|
+
try {
|
|
73
|
+
zoom_context.drawImage(temp_image_canvas.get(0), coordinates.image_x, coordinates.image_y, options.width, options.height, 0, 0, options.width, options.height);
|
|
74
|
+
} catch(err){};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function _prepare_coordinates(e, options, image_offset) {
|
|
78
|
+
var page_x = e.pageX, page_y = e.pageY, coordinates;
|
|
79
|
+
coordinates = {page_x: page_x - options.width / 2, page_y: page_y - options.height / 2};
|
|
80
|
+
coordinates.image_x = (page_x - image_offset.left) - (options.width / 2 / options.scale);
|
|
81
|
+
coordinates.image_y = (page_y - image_offset.top) - (options.height / 2 / options.scale);
|
|
82
|
+
return coordinates;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function _insert_temp_canvas(zoom_canvas_container, image) {
|
|
86
|
+
var width = image.width(), height = image.height(), temp_image_canvas;
|
|
87
|
+
zoom_canvas_container.append("<canvas id='temp_image_canvas' width='" + width + "' height='" + height + "' style='position: absolute; left: -5000px;'></canvas>");
|
|
88
|
+
temp_image_canvas = $("#temp_image_canvas");
|
|
89
|
+
temp_image_canvas_context = temp_image_canvas.get(0).getContext("2d");
|
|
90
|
+
temp_image_canvas_context.drawImage(image.get(0), 0, 0, width, height);
|
|
91
|
+
return temp_image_canvas;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function check_if_in_bounds(e, image, image_offset) {
|
|
95
|
+
if (e.pageX < image_offset.left) { // User moved mouse out in left direction
|
|
96
|
+
return false;
|
|
97
|
+
} else if (e.pageY < image_offset.top) { // User moved mouse out in top direction
|
|
98
|
+
return false;
|
|
99
|
+
} else if (e.pageX > image_offset.left + image.width()) { // User moved mouse out in right direction
|
|
100
|
+
return false;
|
|
101
|
+
} else if (e.pageY > image_offset.top + image.height()) { // User moved mouse out in bottom direction
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function remove_image_zoomer() {
|
|
108
|
+
$(zoom_canvas_name).remove();
|
|
109
|
+
$(zoom_canvas_container_name).find("img").unwrap();
|
|
110
|
+
$("#temp_image_canvas").remove();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
})(jQuery);
|
data/lib/dharajoshi_first_gem.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dharajoshi_first_gem
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dhara Joshi
|
|
@@ -59,8 +59,10 @@ files:
|
|
|
59
59
|
- LICENSE.txt
|
|
60
60
|
- README.md
|
|
61
61
|
- Rakefile
|
|
62
|
+
- app/assets/javascripts/image_zoomer.js
|
|
62
63
|
- dharajoshi_first_gem.gemspec
|
|
63
64
|
- lib/dharajoshi_first_gem.rb
|
|
65
|
+
- lib/dharajoshi_first_gem/engine.rb
|
|
64
66
|
- lib/dharajoshi_first_gem/railtie.rb
|
|
65
67
|
- lib/dharajoshi_first_gem/version.rb
|
|
66
68
|
- test/lib/dharajoshi_first_gem/version_test.rb
|