Jump to content

image map


Hugo.b
 Share

Recommended Posts

Bonjour,

j'ai fais une image map responsive. Je veux mettre mon code dans le module editeur home.

Le fichier jquery et l'image sont sur mon serveur cependant le respOnsive ne passe pas... sur le site

 

ps : le responsive marche quand je test dans un navigateur.

 

fichier jquery :

 
;(function(a){a.fn.rwdImageMaps=function(){var c=this;var b=function(){c.each(function(){if(typeof(a(this).attr("usemap"))=="undefined"){return}var e=this,d=a(e);a("<img />").load(function(){var g="width",m="height",n=d.attr(g),j=d.attr(m);if(!n||!j){var o=new Image();o.src=d.attr("src");if(!n){n=o.width}if(!j){j=o.height[spam-filter]var f=d.width()/100,k=d.height()/100,i=d.attr("usemap").replace("#",""),l="coords";a('map[name='+i+']').find("area").each(function(){var r=a(this);if(!r.data(l)){r.data(l,r.attr(l))}var q=r.data(l).split(","),p=new Array(q.length);for(var h=0;h<p.length;++h){if(h%2===0){p[h]=parseInt(((q[h]/n)*100)*f)}else{p[h]=parseInt(((q[h]/j)*100)*k)[spam-filter]r.attr(l,p.toString())})}).attr("src",d.attr("src"))})};a(window).resize(B).trigger("resize");return this[spam-filter])(jQuery);
 
merci pour votre aide

responsive_map_avd-responsive.html

post-1214321-0-05790000-1476377212_thumb.jpg

Share this post


Link to post
Share on other sites

Bonjour,

 

Le code jquery est en général un code fonctionnel.

Le code que tu présentes ici est un code minifié, non exploitable.

Au vu des éléments présentés, j'irais plutôt sollicité un support du coté du dev de la fonctionnalité de mapping

Share this post


Link to post
Share on other sites

Voici le code,

 

;(function($) {
$.fn.rwdImageMaps = function() {
var $img = this;
 
var rwdImageMap = function() {
$img.each(function() {
if (typeof($(this).attr('usemap')) == 'undefined')
return;
 
var that = this,
$that = $(that);
 
// Since WebKit doesn't know the height until after the image has loaded, perform everything in an onload copy
$('<img />').on('load', function() {
var attrW = 'width',
attrH = 'height',
w = $that.attr(attrW),
h = $that.attr(attrH);
 
if (!w || !h) {
var temp = new Image();
temp.src = $that.attr('src');
if (!w)
w = temp.width;
if (!h)
h = temp.height;
}
 
var wPercent = $that.width()/100,
hPercent = $that.height()/100,
map = $that.attr('usemap').replace('#', ''),
c = 'coords';
 
$('map[name=' + map + ']').find('area').each(function() {
var $this = $(this);
if (!$this.data©)
$this.data(c, $this.attr©);
 
var coords = $this.data©.split(','),
coordsPercent = new Array(coords.length);
 
for (var i = 0; i < coordsPercent.length; ++i) {
if (i % 2 === 0)
coordsPercent = parseInt(((coords/w)*100)*wPercent);
else
coordsPercent = parseInt(((coords/h)*100)*hPercent);
}
$this.attr(c, coordsPercent.toString());
});
}).attr('src', $that.attr('src'));
});
};
$(window).resize(rwdImageMap).trigger('resize');
 
return this;
};

})(jQuery); 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More