rework appearance of audio/video tags patch

This commit is contained in:
Andrew Dolgov 2009-06-22 16:50:17 +04:00
parent 99ea1043da
commit 9324c2c24f
3 changed files with 29 additions and 24 deletions

View File

@ -2134,25 +2134,29 @@ function truncate_string(s, length) {
return tmp; return tmp;
} }
function switchToFlash(e) { function switchToFlash(e) {
var targ = e; try {
if (!e) var e = window.event; var targ = e;
if (e.target) targ = e.target; if (!e) var e = window.event;
else if (e.srcElement) targ = e.srcElement; if (e.target) targ = e.target;
if (targ.nodeType == 3) // defeat Safari bug else if (e.srcElement) targ = e.srcElement;
targ = targ.parentNode; if (targ.nodeType == 3) // defeat Safari bug
targ = targ.parentNode;
//targ is the link that was clicked
var audioTag=targ;
do {
audioTag=audioTag.previousSibling;
} while(audioTag && audioTag.nodeType != 1)
var flashPlayer = audioTag.getElementsByTagName('span')[0];
targ.parentNode.insertBefore(flashPlayer,targ);
targ.parentNode.removeChild(targ);
audioTag.parentNode.removeChild(audioTag);
//targ is the link that was clicked return false;
var audioTag=targ; } catch (e) {
do { exception_error("switchToFlash", e);
audioTag=audioTag.previousSibling; }
} while(audioTag && audioTag.nodeType != 1)
var flashPlayer = audioTag.getElementsByTagName('div')[0];
targ.parentNode.insertBefore(flashPlayer,targ);
targ.parentNode.removeChild(targ);
audioTag.parentNode.removeChild(audioTag);
return false;
} }
function html5AudioOrFlash(type) { function html5AudioOrFlash(type) {
var audioTag = document.createElement('audio'); var audioTag = document.createElement('audio');

View File

@ -4709,12 +4709,12 @@
$entry .= "<audio controls=\"controls\"><source src=\"$url\" type=\"$ctype\" />"; $entry .= "<audio controls=\"controls\"><source src=\"$url\" type=\"$ctype\" />";
if (($ctype == __("audio/mpeg")) && if (($ctype == __("audio/mpeg")) &&
(get_pref($link, "ENABLE_FLASH_PLAYER")) ) { (get_pref($link, "ENABLE_FLASH_PLAYER")) ) {
$entry .= "<div><object type=\"application/x-shockwave-flash\" data=\"extras/button/musicplayer.swf?song_url=$url\" width=\"17\" height=\"17\"> <param name=\"movie\" value=\"extras/button/musicplayer.swf?song_url=$url\" /> </object></div>"; $entry .= "<span><object type=\"application/x-shockwave-flash\" data=\"extras/button/musicplayer.swf?song_url=$url\" width=\"17\" height=\"17\"> <param name=\"movie\" value=\"extras/button/musicplayer.swf?song_url=$url\" /> </object></span>";
} }
$entry .= "</audio>"; $entry .= "</audio> ";
if (($ctype == __("audio/mpeg")) && if (($ctype == __("audio/mpeg")) &&
(get_pref($link, "ENABLE_FLASH_PLAYER")) ) { (get_pref($link, "ENABLE_FLASH_PLAYER")) ) {
$entry .= "<a id='switchToFlashLink' href='#' onclick='return switchToFlash(this)'>".__('Switch to Flash Player')."</a><br />"; $entry .= "<a id='switchToFlashLink' href='#' onclick='return switchToFlash(this)'>".__('Switch to Flash Player')."</a>";
$entry .= "<script type='text/javascript'>html5AudioOrFlash('$ctype');</script>"; $entry .= "<script type='text/javascript'>html5AudioOrFlash('$ctype');</script>";
} }
} elseif (substr($ctype,0,6)=="video/") { } elseif (substr($ctype,0,6)=="video/") {
@ -5263,12 +5263,12 @@
$entry .= "<audio controls=\"controls\"><source src=\"$url\" type=\"$ctype\" />"; $entry .= "<audio controls=\"controls\"><source src=\"$url\" type=\"$ctype\" />";
if (($ctype == __("audio/mpeg")) && if (($ctype == __("audio/mpeg")) &&
(get_pref($link, "ENABLE_FLASH_PLAYER")) ) { (get_pref($link, "ENABLE_FLASH_PLAYER")) ) {
$entry .= "<div><object type=\"application/x-shockwave-flash\" data=\"extras/button/musicplayer.swf?song_url=$url\" width=\"17\" height=\"17\"> <param name=\"movie\" value=\"extras/button/musicplayer.swf?song_url=$url\" /> </object></div>"; $entry .= "<span><object type=\"application/x-shockwave-flash\" data=\"extras/button/musicplayer.swf?song_url=$url\" width=\"17\" height=\"17\"> <param name=\"movie\" value=\"extras/button/musicplayer.swf?song_url=$url\" /> </object></span>";
} }
$entry .= "</audio>"; $entry .= "</audio> ";
if (($ctype == __("audio/mpeg")) && if (($ctype == __("audio/mpeg")) &&
(get_pref($link, "ENABLE_FLASH_PLAYER")) ) { (get_pref($link, "ENABLE_FLASH_PLAYER")) ) {
$entry .= "<a id='switchToFlashLink' href='#' onclick='return switchToFlash(this)'>".__('Switch to Flash Player')."</a><br />"; $entry .= "<a id='switchToFlashLink' href='#' onclick='return switchToFlash(this)'>".__('Switch to Flash Player')."</a>";
$entry .= "<script type='text/javascript'>html5AudioOrFlash('$ctype');</script>"; $entry .= "<script type='text/javascript'>html5AudioOrFlash('$ctype');</script>";
} }
} elseif (substr($ctype,0,6)=="video/") { } elseif (substr($ctype,0,6)=="video/") {

View File

@ -2193,3 +2193,4 @@ optgroup {
option { option {
color : black; color : black;
} }