| 1 |
<?php
|
| 2 |
header('Content-type: text/javascript');
|
| 3 |
$browser = array (
|
| 4 |
"MSIE", // parent
|
| 5 |
"OPERA",
|
| 6 |
"MOZILLA", // parent
|
| 7 |
"NETSCAPE",
|
| 8 |
"FIREFOX",
|
| 9 |
"SAFARI"
|
| 10 |
);
|
| 11 |
|
| 12 |
$info[browser] = "OTHER";
|
| 13 |
|
| 14 |
foreach ($browser as $parent) {
|
| 15 |
$s = strpos(strtoupper($_SERVER['HTTP_USER_AGENT']), $parent);
|
| 16 |
$f = $s + strlen($parent);
|
| 17 |
$version = substr($_SERVER['HTTP_USER_AGENT'], $f, 5);
|
| 18 |
$version = preg_replace('/[^0-9,.]/','',$version);
|
| 19 |
|
| 20 |
if (strpos(strtoupper($_SERVER['HTTP_USER_AGENT']), $parent)) {
|
| 21 |
$info[browser] = $parent;
|
| 22 |
$info[version] = $version;
|
| 23 |
}
|
| 24 |
}
|
| 25 |
?>
|
| 26 |
|
| 27 |
$(document).ready(function(){
|
| 28 |
$('.multimage-image').each(function() {
|
| 29 |
|
| 30 |
if (Drupal.settings[$(this).attr('id') + '-mode'] == 'single')
|
| 31 |
return;
|
| 32 |
|
| 33 |
var images = Drupal.settings[$(this).attr('id')];
|
| 34 |
var captions = Drupal.settings[$(this).attr('id') + '-captions'];
|
| 35 |
|
| 36 |
var container = $(this).parent().parent(); //Unused variable, for future additions.
|
| 37 |
var top = $(this).parent();
|
| 38 |
var bottom = $(this).parent().next();
|
| 39 |
var buffer = $(this).parent().next().next();
|
| 40 |
|
| 41 |
//Load all images as soon as the page loads, that way the user won't have to wait on each click.
|
| 42 |
for (x = 0; x < images.length; x++) {
|
| 43 |
buffer.attr('src', images[x]); //GET method in JQuery 1.01 is buggy when used in IE, so buffering must be done 'manually'.
|
| 44 |
}
|
| 45 |
var count = 1;
|
| 46 |
$(this).click(function() {
|
| 47 |
if (count == images.length )
|
| 48 |
count = 0;
|
| 49 |
|
| 50 |
<? if (($info[browser] == "MSIE") && ($info[version] >= 7) || ($info[browser] != "MSIE")) {?>
|
| 51 |
|
| 52 |
bottom.fadeOut(200);
|
| 53 |
top.fadeOut(200, function(){
|
| 54 |
|
| 55 |
$(this).children().attr('src', images[count]);
|
| 56 |
bottom.html(captions[count]);
|
| 57 |
top.fadeIn(200);
|
| 58 |
bottom.fadeIn(200);
|
| 59 |
count++;}
|
| 60 |
);
|
| 61 |
<? } else {?>
|
| 62 |
$(this).attr('src', images[count]);
|
| 63 |
bottom.html(captions[count]);
|
| 64 |
count++;
|
| 65 |
<? } ?>
|
| 66 |
|
| 67 |
});
|
| 68 |
|
| 69 |
});
|
| 70 |
});
|
| 71 |
|