1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
//********************************************************************************/
// updateLyteboxItems()
// Loops through anchor tags looking for 'lytebox' or 'lyteshow' references and
// adds onclick events to the appropriate links.
//********************************************************************************/
LyteBox.prototype.updateLyteboxItems = function() {
// populate array of anchors from the appropriate window (could be the parent or iframe document)
var anchors = (this.isFrame) ? window.parent.frames[window.name].document.getElementsByTagName('a') : document.getElementsByTagName('a');
var areas = (this.isFrame) ? window.parent.frames[window.name].document.getElementsByTagName('area') : document.getElementsByTagName('area');
anchors = areas.concat(anchors);
// loop through all anchor tags
for (var i = 0; i < anchors.length; i++) {
var anchor = anchors[i];
var relAttribute = String(anchor.getAttribute('rel'));
// use the string.match() method to catch 'lytebox' references in the rel attribute
if (anchor.getAttribute('href')) {
if (relAttribute.toLowerCase().match('lytebox')) {
anchor.onclick = function () { myLytebox.start(this, false, false); return false; }
} else if (relAttribute.toLowerCase().match('lyteshow')) {
anchor.onclick = function () { myLytebox.start(this, true, false); return false; }
} else if (relAttribute.toLowerCase().match('lyteframe')) {
anchor.onclick = function () { myLytebox.start(this, false, true); return false; }
}
}
}
}; |
Partager