maphilight-rails 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NTJlZGMzYzRjY2E2NmFkZWU5ZTY3NGU1MmEzZjFkZmQxZDcyYTIxYQ==
5
+ data.tar.gz: !binary |-
6
+ NGYzYzFmYjBjYTU2ODI4YjY1ZTdjMmE1NzEyY2U0YjYwY2Y3NDg0MA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MzljMDkxYjUxOTFlZGM3ZTcyMjdiMzU2MjNlMzc0YjQ4NzQ0NmQyN2ZkOTcy
10
+ MTIwMjNjNWU0ZjQ2NzVhZGQwYjNkYWQ4ZDFlOTY3YzJmMTgyNTM0ZGUzMTg1
11
+ YTFlYzM4NjJjNTc2MWVlM2M2NDI2NGYxNjkzOTA1NWI2Mjg4YjE=
12
+ data.tar.gz: !binary |-
13
+ OGNiMTkzODQxNjk1MGYzM2IwMWE5ZjA2OTdiNDk2OTVhOWJiOWVmOTNhMGE5
14
+ MzhhYWEyMDBlMzY4ZWQ4ZGU3MDQzOGZkYjZkNDFiN2Y2ZTgwYzVlNTMxZjBm
15
+ OTkwNzc5Mzc4OTk5MWQ3MjRiOWYwZTVhNDQ5NGU1MjllYWYyZWY=
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in maphilight-rails.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 producao02
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.
@@ -0,0 +1 @@
1
+ # maphilight-rails
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,368 @@
1
+ (function($) {
2
+ var has_VML, has_canvas, create_canvas_for, add_shape_to, clear_canvas, shape_from_area,
3
+ canvas_style, hex_to_decimal, css3color, is_image_loaded, options_from_area;
4
+
5
+ has_canvas = !!document.createElement('canvas').getContext;
6
+
7
+ // VML: more complex
8
+ has_VML = (function() {
9
+ var a = document.createElement('div');
10
+ a.innerHTML = '<v:shape id="vml_flag1" adj="1" />';
11
+ var b = a.firstChild;
12
+ b.style.behavior = "url(#default#VML)";
13
+ return b ? typeof b.adj == "object": true;
14
+ })();
15
+
16
+ if(!(has_canvas || has_VML)) {
17
+ $.fn.maphilight = function() { return this; };
18
+ return;
19
+ }
20
+
21
+ if(has_canvas) {
22
+ hex_to_decimal = function(hex) {
23
+ return Math.max(0, Math.min(parseInt(hex, 16), 255));
24
+ };
25
+ css3color = function(color, opacity) {
26
+ return 'rgba('+hex_to_decimal(color.substr(0,2))+','+hex_to_decimal(color.substr(2,2))+','+hex_to_decimal(color.substr(4,2))+','+opacity+')';
27
+ };
28
+ create_canvas_for = function(img) {
29
+ var c = $('<canvas style="width:'+$(img).width()+'px;height:'+$(img).height()+'px;"></canvas>').get(0);
30
+ c.getContext("2d").clearRect(0, 0, $(img).width(), $(img).height());
31
+ return c;
32
+ };
33
+ var draw_shape = function(context, shape, coords, x_shift, y_shift) {
34
+ x_shift = x_shift || 0;
35
+ y_shift = y_shift || 0;
36
+
37
+ context.beginPath();
38
+ if(shape == 'rect') {
39
+ // x, y, width, height
40
+ context.rect(coords[0] + x_shift, coords[1] + y_shift, coords[2] - coords[0], coords[3] - coords[1]);
41
+ } else if(shape == 'poly') {
42
+ context.moveTo(coords[0] + x_shift, coords[1] + y_shift);
43
+ for(i=2; i < coords.length; i+=2) {
44
+ context.lineTo(coords[i] + x_shift, coords[i+1] + y_shift);
45
+ }
46
+ } else if(shape == 'circ') {
47
+ // x, y, radius, startAngle, endAngle, anticlockwise
48
+ context.arc(coords[0] + x_shift, coords[1] + y_shift, coords[2], 0, Math.PI * 2, false);
49
+ }
50
+ context.closePath();
51
+ }
52
+ add_shape_to = function(canvas, shape, coords, options, name) {
53
+ var i, context = canvas.getContext('2d');
54
+
55
+ // Because I don't want to worry about setting things back to a base state
56
+
57
+ // Shadow has to happen first, since it's on the bottom, and it does some clip /
58
+ // fill operations which would interfere with what comes next.
59
+ if(options.shadow) {
60
+ context.save();
61
+ if(options.shadowPosition == "inside") {
62
+ // Cause the following stroke to only apply to the inside of the path
63
+ draw_shape(context, shape, coords);
64
+ context.clip();
65
+ }
66
+
67
+ // Redraw the shape shifted off the canvas massively so we can cast a shadow
68
+ // onto the canvas without having to worry about the stroke or fill (which
69
+ // cannot have 0 opacity or width, since they're what cast the shadow).
70
+ var x_shift = canvas.width * 100;
71
+ var y_shift = canvas.height * 100;
72
+ draw_shape(context, shape, coords, x_shift, y_shift);
73
+
74
+ context.shadowOffsetX = options.shadowX - x_shift;
75
+ context.shadowOffsetY = options.shadowY - y_shift;
76
+ context.shadowBlur = options.shadowRadius;
77
+ context.shadowColor = css3color(options.shadowColor, options.shadowOpacity);
78
+
79
+ // Now, work out where to cast the shadow from! It looks better if it's cast
80
+ // from a fill when it's an outside shadow or a stroke when it's an interior
81
+ // shadow. Allow the user to override this if they need to.
82
+ var shadowFrom = options.shadowFrom;
83
+ if (!shadowFrom) {
84
+ if (options.shadowPosition == 'outside') {
85
+ shadowFrom = 'fill';
86
+ } else {
87
+ shadowFrom = 'stroke';
88
+ }
89
+ }
90
+ if (shadowFrom == 'stroke') {
91
+ context.strokeStyle = "rgba(0,0,0,1)";
92
+ context.stroke();
93
+ } else if (shadowFrom == 'fill') {
94
+ context.fillStyle = "rgba(0,0,0,1)";
95
+ context.fill();
96
+ }
97
+ context.restore();
98
+
99
+ // and now we clean up
100
+ if(options.shadowPosition == "outside") {
101
+ context.save();
102
+ // Clear out the center
103
+ draw_shape(context, shape, coords);
104
+ context.globalCompositeOperation = "destination-out";
105
+ context.fillStyle = "rgba(0,0,0,1);";
106
+ context.fill();
107
+ context.restore();
108
+ }
109
+ }
110
+
111
+ context.save();
112
+
113
+ draw_shape(context, shape, coords);
114
+
115
+ // fill has to come after shadow, otherwise the shadow will be drawn over the fill,
116
+ // which mostly looks weird when the shadow has a high opacity
117
+ if(options.fill) {
118
+ context.fillStyle = css3color(options.fillColor, options.fillOpacity);
119
+ context.fill();
120
+ }
121
+ // Likewise, stroke has to come at the very end, or it'll wind up under bits of the
122
+ // shadow or the shadow-background if it's present.
123
+ if(options.stroke) {
124
+ context.strokeStyle = css3color(options.strokeColor, options.strokeOpacity);
125
+ context.lineWidth = options.strokeWidth;
126
+ context.stroke();
127
+ }
128
+
129
+ context.restore();
130
+
131
+ if(options.fade) {
132
+ $(canvas).css('opacity', 0).animate({opacity: 1}, 100);
133
+ }
134
+ };
135
+ clear_canvas = function(canvas) {
136
+ canvas.getContext('2d').clearRect(0, 0, canvas.width,canvas.height);
137
+ };
138
+ } else { // ie executes this code
139
+ create_canvas_for = function(img) {
140
+ return $('<var style="zoom:1;overflow:hidden;display:block;width:'+img.width+'px;height:'+img.height+'px;"></var>').get(0);
141
+ };
142
+ add_shape_to = function(canvas, shape, coords, options, name) {
143
+ var fill, stroke, opacity, e;
144
+ for (var i in coords) { coords[i] = parseInt(coords[i], 10); }
145
+ fill = '<v:fill color="#'+options.fillColor+'" opacity="'+(options.fill ? options.fillOpacity : 0)+'" />';
146
+ stroke = (options.stroke ? 'strokeweight="'+options.strokeWidth+'" stroked="t" strokecolor="#'+options.strokeColor+'"' : 'stroked="f"');
147
+ opacity = '<v:stroke opacity="'+options.strokeOpacity+'"/>';
148
+ if(shape == 'rect') {
149
+ e = $('<v:rect name="'+name+'" filled="t" '+stroke+' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:'+coords[0]+'px;top:'+coords[1]+'px;width:'+(coords[2] - coords[0])+'px;height:'+(coords[3] - coords[1])+'px;"></v:rect>');
150
+ } else if(shape == 'poly') {
151
+ e = $('<v:shape name="'+name+'" filled="t" '+stroke+' coordorigin="0,0" coordsize="'+canvas.width+','+canvas.height+'" path="m '+coords[0]+','+coords[1]+' l '+coords.join(',')+' x e" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:0px;left:0px;width:'+canvas.width+'px;height:'+canvas.height+'px;"></v:shape>');
152
+ } else if(shape == 'circ') {
153
+ e = $('<v:oval name="'+name+'" filled="t" '+stroke+' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:'+(coords[0] - coords[2])+'px;top:'+(coords[1] - coords[2])+'px;width:'+(coords[2]*2)+'px;height:'+(coords[2]*2)+'px;"></v:oval>');
154
+ }
155
+ e.get(0).innerHTML = fill+opacity;
156
+ $(canvas).append(e);
157
+ };
158
+ clear_canvas = function(canvas) {
159
+ // jquery1.8 + ie7
160
+ var $html = $("<div>" + canvas.innerHTML + "</div>");
161
+ $html.children('[name=highlighted]').remove();
162
+ canvas.innerHTML = $html.html();
163
+ };
164
+ }
165
+
166
+ shape_from_area = function(area) {
167
+ var i, coords = area.getAttribute('coords').split(',');
168
+ for (i=0; i < coords.length; i++) { coords[i] = parseFloat(coords[i]); }
169
+ return [area.getAttribute('shape').toLowerCase().substr(0,4), coords];
170
+ };
171
+
172
+ options_from_area = function(area, options) {
173
+ var $area = $(area);
174
+ return $.extend({}, options, $.metadata ? $area.metadata() : false, $area.data('maphilight'));
175
+ };
176
+
177
+ is_image_loaded = function(img) {
178
+ if(!img.complete) { return false; } // IE
179
+ if(typeof img.naturalWidth != "undefined" && img.naturalWidth === 0) { return false; } // Others
180
+ return true;
181
+ };
182
+
183
+ canvas_style = {
184
+ position: 'absolute',
185
+ left: 0,
186
+ top: 0,
187
+ padding: 0,
188
+ border: 0
189
+ };
190
+
191
+ var ie_hax_done = false;
192
+ $.fn.maphilight = function(opts) {
193
+ opts = $.extend({}, $.fn.maphilight.defaults, opts);
194
+
195
+ if(!has_canvas && !ie_hax_done) {
196
+ $(window).ready(function() {
197
+ document.namespaces.add("v", "urn:schemas-microsoft-com:vml");
198
+ var style = document.createStyleSheet();
199
+ var shapes = ['shape','rect', 'oval', 'circ', 'fill', 'stroke', 'imagedata', 'group','textbox'];
200
+ $.each(shapes,
201
+ function() {
202
+ style.addRule('v\\:' + this, "behavior: url(#default#VML); antialias:true");
203
+ }
204
+ );
205
+ });
206
+ ie_hax_done = true;
207
+ }
208
+
209
+ return this.each(function() {
210
+ var img, wrap, options, map, canvas, canvas_always, mouseover, highlighted_shape, usemap;
211
+ img = $(this);
212
+
213
+ if(!is_image_loaded(this)) {
214
+ // If the image isn't fully loaded, this won't work right. Try again later.
215
+ return window.setTimeout(function() {
216
+ img.maphilight(opts);
217
+ }, 200);
218
+ }
219
+
220
+ options = $.extend({}, opts, $.metadata ? img.metadata() : false, img.data('maphilight'));
221
+
222
+ // jQuery bug with Opera, results in full-url#usemap being returned from jQuery's attr.
223
+ // So use raw getAttribute instead.
224
+ usemap = img.get(0).getAttribute('usemap');
225
+
226
+ if (!usemap) {
227
+ return
228
+ }
229
+
230
+ map = $('map[name="'+usemap.substr(1)+'"]');
231
+
232
+ if(!(img.is('img,input[type="image"]') && usemap && map.size() > 0)) {
233
+ return;
234
+ }
235
+
236
+ if(img.hasClass('maphilighted')) {
237
+ // We're redrawing an old map, probably to pick up changes to the options.
238
+ // Just clear out all the old stuff.
239
+ var wrapper = img.parent();
240
+ img.insertBefore(wrapper);
241
+ wrapper.remove();
242
+ $(map).unbind('.maphilight').find('area[coords]').unbind('.maphilight');
243
+ }
244
+
245
+ wrap = $('<div></div>').css({
246
+ display:'block',
247
+ background:'url("'+this.src+'")',
248
+ position:'relative',
249
+ padding:0,
250
+ width:this.width,
251
+ height:this.height
252
+ });
253
+ if(options.wrapClass) {
254
+ if(options.wrapClass === true) {
255
+ wrap.addClass($(this).attr('class'));
256
+ } else {
257
+ wrap.addClass(options.wrapClass);
258
+ }
259
+ }
260
+ img.before(wrap).css('opacity', 0).css(canvas_style).remove();
261
+ if(has_VML) { img.css('filter', 'Alpha(opacity=0)'); }
262
+ wrap.append(img);
263
+
264
+ canvas = create_canvas_for(this);
265
+ $(canvas).css(canvas_style);
266
+ canvas.height = this.height;
267
+ canvas.width = this.width;
268
+
269
+ mouseover = function(e) {
270
+ var shape, area_options;
271
+ area_options = options_from_area(this, options);
272
+ if(
273
+ !area_options.neverOn
274
+ &&
275
+ !area_options.alwaysOn
276
+ ) {
277
+ shape = shape_from_area(this);
278
+ add_shape_to(canvas, shape[0], shape[1], area_options, "highlighted");
279
+ if(area_options.groupBy) {
280
+ var areas;
281
+ // two ways groupBy might work; attribute and selector
282
+ if(/^[a-zA-Z][\-a-zA-Z]+$/.test(area_options.groupBy)) {
283
+ areas = map.find('area['+area_options.groupBy+'="'+$(this).attr(area_options.groupBy)+'"]');
284
+ } else {
285
+ areas = map.find(area_options.groupBy);
286
+ }
287
+ var first = this;
288
+ areas.each(function() {
289
+ if(this != first) {
290
+ var subarea_options = options_from_area(this, options);
291
+ if(!subarea_options.neverOn && !subarea_options.alwaysOn) {
292
+ var shape = shape_from_area(this);
293
+ add_shape_to(canvas, shape[0], shape[1], subarea_options, "highlighted");
294
+ }
295
+ }
296
+ });
297
+ }
298
+ // workaround for IE7, IE8 not rendering the final rectangle in a group
299
+ if(!has_canvas) {
300
+ $(canvas).append('<v:rect></v:rect>');
301
+ }
302
+ }
303
+ }
304
+
305
+ $(map).bind('alwaysOn.maphilight', function() {
306
+ // Check for areas with alwaysOn set. These are added to a *second* canvas,
307
+ // which will get around flickering during fading.
308
+ if(canvas_always) {
309
+ clear_canvas(canvas_always);
310
+ }
311
+ if(!has_canvas) {
312
+ $(canvas).empty();
313
+ }
314
+ $(map).find('area[coords]').each(function() {
315
+ var shape, area_options;
316
+ area_options = options_from_area(this, options);
317
+ if(area_options.alwaysOn) {
318
+ if(!canvas_always && has_canvas) {
319
+ canvas_always = create_canvas_for(img[0]);
320
+ $(canvas_always).css(canvas_style);
321
+ canvas_always.width = img[0].width;
322
+ canvas_always.height = img[0].height;
323
+ img.before(canvas_always);
324
+ }
325
+ area_options.fade = area_options.alwaysOnFade; // alwaysOn shouldn't fade in initially
326
+ shape = shape_from_area(this);
327
+ if (has_canvas) {
328
+ add_shape_to(canvas_always, shape[0], shape[1], area_options, "");
329
+ } else {
330
+ add_shape_to(canvas, shape[0], shape[1], area_options, "");
331
+ }
332
+ }
333
+ });
334
+ });
335
+
336
+ $(map).trigger('alwaysOn.maphilight').find('area[coords]')
337
+ .bind('mouseover.maphilight', mouseover)
338
+ .bind('mouseout.maphilight', function(e) { clear_canvas(canvas); });
339
+
340
+ img.before(canvas); // if we put this after, the mouseover events wouldn't fire.
341
+
342
+ img.addClass('maphilighted');
343
+ });
344
+ };
345
+ $.fn.maphilight.defaults = {
346
+ fill: true,
347
+ fillColor: '000000',
348
+ fillOpacity: 0.2,
349
+ stroke: true,
350
+ strokeColor: 'ff0000',
351
+ strokeOpacity: 1,
352
+ strokeWidth: 1,
353
+ fade: true,
354
+ alwaysOn: false,
355
+ neverOn: false,
356
+ groupBy: false,
357
+ wrapClass: true,
358
+ // plenty of shadow:
359
+ shadow: false,
360
+ shadowX: 0,
361
+ shadowY: 0,
362
+ shadowRadius: 6,
363
+ shadowColor: '000000',
364
+ shadowOpacity: 0.8,
365
+ shadowPosition: 'outside',
366
+ shadowFrom: false
367
+ };
368
+ })(jQuery);
@@ -0,0 +1 @@
1
+ (function(G){var B,J,C,K,N,M,I,E,H,A,L;J=!!document.createElement("canvas").getContext;B=(function(){var P=document.createElement("div");P.innerHTML='<v:shape id="vml_flag1" adj="1" />';var O=P.firstChild;O.style.behavior="url(#default#VML)";return O?typeof O.adj=="object":true})();if(!(J||B)){G.fn.maphilight=function(){return this};return }if(J){E=function(O){return Math.max(0,Math.min(parseInt(O,16),255))};H=function(O,P){return"rgba("+E(O.substr(0,2))+","+E(O.substr(2,2))+","+E(O.substr(4,2))+","+P+")"};C=function(O){var P=G('<canvas style="width:'+O.width+"px;height:"+O.height+'px;"></canvas>').get(0);P.getContext("2d").clearRect(0,0,P.width,P.height);return P};var F=function(Q,O,R,P,S){P=P||0;S=S||0;Q.beginPath();if(O=="rect"){Q.rect(R[0]+P,R[1]+S,R[2]-R[0],R[3]-R[1])}else{if(O=="poly"){Q.moveTo(R[0]+P,R[1]+S);for(i=2;i<R.length;i+=2){Q.lineTo(R[i]+P,R[i+1]+S)}}else{if(O=="circ"){Q.arc(R[0]+P,R[1]+S,R[2],0,Math.PI*2,false)}}}Q.closePath()};K=function(Q,T,U,X,O){var S,P=Q.getContext("2d");if(X.shadow){P.save();if(X.shadowPosition=="inside"){F(P,T,U);P.clip()}var R=Q.width*100;var W=Q.height*100;F(P,T,U,R,W);P.shadowOffsetX=X.shadowX-R;P.shadowOffsetY=X.shadowY-W;P.shadowBlur=X.shadowRadius;P.shadowColor=H(X.shadowColor,X.shadowOpacity);var V=X.shadowFrom;if(!V){if(X.shadowPosition=="outside"){V="fill"}else{V="stroke"}}if(V=="stroke"){P.strokeStyle="rgba(0,0,0,1)";P.stroke()}else{if(V=="fill"){P.fillStyle="rgba(0,0,0,1)";P.fill()}}P.restore();if(X.shadowPosition=="outside"){P.save();F(P,T,U);P.globalCompositeOperation="destination-out";P.fillStyle="rgba(0,0,0,1);";P.fill();P.restore()}}P.save();F(P,T,U);if(X.fill){P.fillStyle=H(X.fillColor,X.fillOpacity);P.fill()}if(X.stroke){P.strokeStyle=H(X.strokeColor,X.strokeOpacity);P.lineWidth=X.strokeWidth;P.stroke()}P.restore();if(X.fade){G(Q).css("opacity",0).animate({opacity:1},100)}};N=function(O){O.getContext("2d").clearRect(0,0,O.width,O.height)}}else{C=function(O){return G('<var style="zoom:1;overflow:hidden;display:block;width:'+O.width+"px;height:"+O.height+'px;"></var>').get(0)};K=function(P,T,U,X,O){var V,W,R,S;for(var Q in U){U[Q]=parseInt(U[Q],10)}V='<v:fill color="#'+X.fillColor+'" opacity="'+(X.fill?X.fillOpacity:0)+'" />';W=(X.stroke?'strokeweight="'+X.strokeWidth+'" stroked="t" strokecolor="#'+X.strokeColor+'"':'stroked="f"');R='<v:stroke opacity="'+X.strokeOpacity+'"/>';if(T=="rect"){S=G('<v:rect name="'+O+'" filled="t" '+W+' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:'+U[0]+"px;top:"+U[1]+"px;width:"+(U[2]-U[0])+"px;height:"+(U[3]-U[1])+'px;"></v:rect>')}else{if(T=="poly"){S=G('<v:shape name="'+O+'" filled="t" '+W+' coordorigin="0,0" coordsize="'+P.width+","+P.height+'" path="m '+U[0]+","+U[1]+" l "+U.join(",")+' x e" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:0px;left:0px;width:'+P.width+"px;height:"+P.height+'px;"></v:shape>')}else{if(T=="circ"){S=G('<v:oval name="'+O+'" filled="t" '+W+' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:'+(U[0]-U[2])+"px;top:"+(U[1]-U[2])+"px;width:"+(U[2]*2)+"px;height:"+(U[2]*2)+'px;"></v:oval>')}}}S.get(0).innerHTML=V+R;G(P).append(S)};N=function(P){var O=G("<div>"+P.innerHTML+"</div>");O.children("[name=highlighted]").remove();P.innerHTML=O.html()}}M=function(P){var O,Q=P.getAttribute("coords").split(",");for(O=0;O<Q.length;O++){Q[O]=parseFloat(Q[O])}return[P.getAttribute("shape").toLowerCase().substr(0,4),Q]};L=function(Q,P){var O=G(Q);return G.extend({},P,G.metadata?O.metadata():false,O.data("maphilight"))};A=function(O){if(!O.complete){return false}if(typeof O.naturalWidth!="undefined"&&O.naturalWidth===0){return false}return true};I={position:"absolute",left:0,top:0,padding:0,border:0};var D=false;G.fn.maphilight=function(O){O=G.extend({},G.fn.maphilight.defaults,O);if(!J&&!D){G(window).ready(function(){document.namespaces.add("v","urn:schemas-microsoft-com:vml");var Q=document.createStyleSheet();var P=["shape","rect","oval","circ","fill","stroke","imagedata","group","textbox"];G.each(P,function(){Q.addRule("v\\:"+this,"behavior: url(#default#VML); antialias:true")})});D=true}return this.each(function(){var U,R,Y,Q,T,V,X,S,W;U=G(this);if(!A(this)){return window.setTimeout(function(){U.maphilight(O)},200)}Y=G.extend({},O,G.metadata?U.metadata():false,U.data("maphilight"));W=U.get(0).getAttribute("usemap");if(!W){return }Q=G('map[name="'+W.substr(1)+'"]');if(!(U.is('img,input[type="image"]')&&W&&Q.size()>0)){return }if(U.hasClass("maphilighted")){var P=U.parent();U.insertBefore(P);P.remove();G(Q).unbind(".maphilight").find("area[coords]").unbind(".maphilight")}R=G("<div></div>").css({display:"block",background:'url("'+this.src+'")',position:"relative",padding:0,width:this.width,height:this.height});if(Y.wrapClass){if(Y.wrapClass===true){R.addClass(G(this).attr("class"))}else{R.addClass(Y.wrapClass)}}U.before(R).css("opacity",0).css(I).remove();if(B){U.css("filter","Alpha(opacity=0)")}R.append(U);T=C(this);G(T).css(I);T.height=this.height;T.width=this.width;X=function(c){var a,b;b=L(this,Y);if(!b.neverOn&&!b.alwaysOn){a=M(this);K(T,a[0],a[1],b,"highlighted");if(b.groupBy){var Z;if(/^[a-zA-Z][\-a-zA-Z]+$/.test(b.groupBy)){Z=Q.find("area["+b.groupBy+'="'+G(this).attr(b.groupBy)+'"]')}else{Z=Q.find(b.groupBy)}var d=this;Z.each(function(){if(this!=d){var f=L(this,Y);if(!f.neverOn&&!f.alwaysOn){var e=M(this);K(T,e[0],e[1],f,"highlighted")}}})}if(!J){G(T).append("<v:rect></v:rect>")}}};G(Q).bind("alwaysOn.maphilight",function(){if(V){N(V)}if(!J){G(T).empty()}G(Q).find("area[coords]").each(function(){var Z,a;a=L(this,Y);if(a.alwaysOn){if(!V&&J){V=C(U[0]);G(V).css(I);V.width=U[0].width;V.height=U[0].height;U.before(V)}a.fade=a.alwaysOnFade;Z=M(this);if(J){K(V,Z[0],Z[1],a,"")}else{K(T,Z[0],Z[1],a,"")}}})});G(Q).trigger("alwaysOn.maphilight").find("area[coords]").bind("mouseover.maphilight",X).bind("mouseout.maphilight",function(Z){N(T)});U.before(T);U.addClass("maphilighted")})};G.fn.maphilight.defaults={fill:true,fillColor:"000000",fillOpacity:0.2,stroke:true,strokeColor:"ff0000",strokeOpacity:1,strokeWidth:1,fade:true,alwaysOn:false,neverOn:false,groupBy:false,wrapClass:true,shadow:false,shadowX:0,shadowY:0,shadowRadius:6,shadowColor:"000000",shadowOpacity:0.8,shadowPosition:"outside",shadowFrom:false}})(jQuery);
@@ -0,0 +1,8 @@
1
+ require "maphilight-rails/version"
2
+
3
+ module Maphilight
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ module Maphilight
2
+ module Rails
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'maphilight-rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "maphilight-rails"
8
+ spec.version = Maphilight::Rails::VERSION
9
+ spec.authors = ["TwoWeb"]
10
+ spec.email = ["dev@twoweb.com.br"]
11
+ spec.summary = "gem for Maphilight jQuery plugin"
12
+ spec.description = "Maphilight jQuery plugin for rails"
13
+ spec.homepage = "https://github.com/twoweb/maphilight-rails"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: maphilight-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - TwoWeb
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Maphilight jQuery plugin for rails
42
+ email:
43
+ - dev@twoweb.com.br
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - Gemfile
49
+ - LICENSE.txt
50
+ - README.md
51
+ - Rakefile
52
+ - app/assets/javascripts/jquery.maphilight.js
53
+ - app/assets/javascripts/jquery.maphilight.min.js
54
+ - lib/maphilight-rails.rb
55
+ - lib/maphilight-rails/version.rb
56
+ - maphilight-rails.gemspec
57
+ homepage: https://github.com/twoweb/maphilight-rails
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.0.0.rc.2
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: gem for Maphilight jQuery plugin
81
+ test_files: []