Mercurial > hg > digilib
comparison client/digitallibrary/jquery/jquery.digilib.regions.js @ 866:3dd878bf07e0 jquery
copy more region attributes
author | hertzhaft |
---|---|
date | Sun, 13 Mar 2011 21:50:29 +0100 |
parents | e96f4ff42450 |
children | 87d523489ae9 |
comparison
equal
deleted
inserted
replaced
865:e96f4ff42450 | 866:3dd878bf07e0 |
---|---|
260 $html.append(regionInfoDigilib(data)); | 260 $html.append(regionInfoDigilib(data)); |
261 $html.fadeIn(); | 261 $html.fadeIn(); |
262 }; | 262 }; |
263 | 263 |
264 // add a region to data.$elem | 264 // add a region to data.$elem |
265 var addRegionDiv = function (data, index, url) { | 265 var addRegionDiv = function (data, index, attributes) { |
266 var nr = index + 1; // we count regions from 1 | 266 var nr = index + 1; // we count regions from 1 |
267 // create a digilib URL for this detail | 267 // create a digilib URL for this detail |
268 url = url || getRegionUrl(data, index); | 268 var url = attributes.href || getRegionUrl(data, index); |
269 var $regionDiv = $('<div class="region overlay" style="display:none"/>'); | 269 var $regionDiv = $('<div class="region overlay" style="display:none"/>'); |
270 $regionDiv.attr("id", ID_PREFIX + nr); | 270 $regionDiv.attr("id", ID_PREFIX + nr); |
271 data.$elem.append($regionDiv); | 271 data.$elem.append($regionDiv); |
272 if (data.settings.showRegionNumbers) { | 272 if (data.settings.showRegionNumbers) { |
273 var $regionLink = $('<a class="regionnumber"/>'); | 273 var $regionLink = $('<a class="regionnumber"/>'); |
274 $regionLink.attr('href', url); | 274 $regionLink.attr(attributes); |
275 $regionLink.text(nr); | 275 $regionLink.text(nr); |
276 $regionDiv.append($regionLink); | 276 $regionDiv.append($regionLink); |
277 } | 277 } |
278 if (data.settings.autoRegionLinks) { | 278 if (data.settings.autoRegionLinks) { |
279 delete attributes.href; | |
280 $regionDiv.attr(attributes); | |
279 $regionDiv.bind('click.dlRegion', function() { | 281 $regionDiv.bind('click.dlRegion', function() { |
280 window.location = url; | 282 window.location = url; |
281 }); | 283 }); |
282 } | 284 } |
283 return $regionDiv; | 285 return $regionDiv; |
284 }; | 286 }; |
285 | 287 |
286 // create a region div from the data.regions array | 288 // create a region div from the data.regions array |
287 var createRegionDiv = function (regions, index, url) { | 289 var createRegionDiv = function (regions, index, attributes) { |
288 var $regionDiv = addRegionDiv(data, index, url); | 290 var $regionDiv = addRegionDiv(data, index, attributes); |
289 var region = regions[index]; | 291 var region = regions[index]; |
290 region.$div = $regionDiv; | 292 region.$div = $regionDiv; |
291 return $regionDiv; | 293 return $regionDiv; |
292 }; | 294 }; |
293 | 295 |
312 // the "coords" attribute contains the region coords (0..1) | 314 // the "coords" attribute contains the region coords (0..1) |
313 var coords = $a.attr('coords'); | 315 var coords = $a.attr('coords'); |
314 var pos = coords.split(",", 4); | 316 var pos = coords.split(",", 4); |
315 var rect = geom.rectangle(pos[0], pos[1], pos[2], pos[3]); | 317 var rect = geom.rectangle(pos[0], pos[1], pos[2], pos[3]); |
316 regions.push(rect); | 318 regions.push(rect); |
319 // save the attributes | |
320 var attributes = {}; | |
321 if ($a.attr('id')) { attributes.id = $a.attr('id') }; | |
322 if ($a.attr('href')) { attributes.href = $a.attr('href') }; | |
323 if ($a.attr('title')) { attributes.title = $a.attr('title') }; | |
317 // create the div | 324 // create the div |
318 var href = $a.attr('href'); | 325 var $regionDiv = createRegionDiv(regions, index, attributes); |
319 var $regionDiv = createRegionDiv(regions, index, href); | |
320 var $contents = $a.contents().clone(); | 326 var $contents = $a.contents().clone(); |
321 $regionDiv.append($contents); | 327 $regionDiv.append($contents); |
322 }); | 328 }); |
323 }; | 329 }; |
324 | 330 |