# HG changeset patch # User hertzhaft # Date 1300049429 -3600 # Node ID 29f214f596542dbe810830f6af228c001fc600e8 # Parent d46706f0eedefceffddb917c1b871b69ced922ce copy more region attributes diff -r d46706f0eede -r 29f214f59654 client/digitallibrary/jquery/jquery.digilib.regions.js --- a/client/digitallibrary/jquery/jquery.digilib.regions.js Sun Mar 13 18:50:38 2011 +0100 +++ b/client/digitallibrary/jquery/jquery.digilib.regions.js Sun Mar 13 21:50:29 2011 +0100 @@ -262,20 +262,22 @@ }; // add a region to data.$elem - var addRegionDiv = function (data, index, url) { + var addRegionDiv = function (data, index, attributes) { var nr = index + 1; // we count regions from 1 // create a digilib URL for this detail - url = url || getRegionUrl(data, index); + var url = attributes.href || getRegionUrl(data, index); var $regionDiv = $('
'); $regionDiv.attr("id", ID_PREFIX + nr); data.$elem.append($regionDiv); if (data.settings.showRegionNumbers) { var $regionLink = $(''); - $regionLink.attr('href', url); + $regionLink.attr(attributes); $regionLink.text(nr); $regionDiv.append($regionLink); } if (data.settings.autoRegionLinks) { + delete attributes.href; + $regionDiv.attr(attributes); $regionDiv.bind('click.dlRegion', function() { window.location = url; }); @@ -284,8 +286,8 @@ }; // create a region div from the data.regions array - var createRegionDiv = function (regions, index, url) { - var $regionDiv = addRegionDiv(data, index, url); + var createRegionDiv = function (regions, index, attributes) { + var $regionDiv = addRegionDiv(data, index, attributes); var region = regions[index]; region.$div = $regionDiv; return $regionDiv; @@ -314,9 +316,13 @@ var pos = coords.split(",", 4); var rect = geom.rectangle(pos[0], pos[1], pos[2], pos[3]); regions.push(rect); + // save the attributes + var attributes = {}; + if ($a.attr('id')) { attributes.id = $a.attr('id') }; + if ($a.attr('href')) { attributes.href = $a.attr('href') }; + if ($a.attr('title')) { attributes.title = $a.attr('title') }; // create the div - var href = $a.attr('href'); - var $regionDiv = createRegionDiv(regions, index, href); + var $regionDiv = createRegionDiv(regions, index, attributes); var $contents = $a.contents().clone(); $regionDiv.append($contents); });