";
var mediaButtonsElement = getElementFromDocument(this.viewerElementId + '_media_buttons');
mediaButtonsElement.style.position = "absolute";
mediaButtonsElement.style.top = "0px";
mediaButtonsElement.style.left = "200px";
mediaButtonsElement.style.height = "30px";
mediaButtonsElement.style.width = (getElementWidth(this.viewerElementId + '_slide') - 200) + "px";
// mediaButtonsElement.style.border = "1px solid #0f0";
var textElement = getElementFromDocument(this.viewerElementId + '_slide_text');
textElement.style.position = "absolute";
textElement.style.left = "0px";
textElement.style.top = "0px";
textElement.style.height = (getElementHeight(this.viewerElementId + '_slide') - 5) + "px";
textElement.style.width = "195px";
textElement.style.overflow = "auto";
textElement.style.paddingTop = "5px";
textElement.style.paddingLeft = "5px";
// textElement.style.border = "1px solid #f00";
textElement.innerHTML = "\n
" + this.title + "
";
textElement.innerHTML += "\n" + this.caption + "
";
var imageElement = getElementFromDocument(this.viewerElementId + '_media');
imageElement.style.position = "absolute";
imageElement.style.left = "200px";
if (this.media.length > 1) {
imageElement.style.top = "30px";
imageElement.style.height = (getElementHeight(this.viewerElementId + '_slide') - 30) + "px";
} else {
imageElement.style.top = "0px";
imageElement.style.height = getElementHeight(this.viewerElementId + '_slide') + "px";
}
imageElement.style.width = (getElementWidth(this.viewerElementId + '_slide') - 200) + "px";
imageElement.style.overflow = "auto";
// imageElement.style.border = "1px solid #00f";
if (this.media[this.currentMediaIndex])
this.media[this.currentMediaIndex].display(mediaSize);
this.displayMediaButtons();
}
/**
* @since 8/22/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: TextRightSlide.class.js,v 1.9 2006/06/15 19:43:09 adamfranco Exp $
*/
TextRightSlide.prototype = new Slide();
TextRightSlide.prototype.constructor = TextRightSlide;
TextRightSlide.superclass = TextRightSlide.prototype;
/**
* The Show is a controlling class wich maintains the order of slides and controls
* their creation.
*
* @since 8/22/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: TextRightSlide.class.js,v 1.9 2006/06/15 19:43:09 adamfranco Exp $
*/
function TextRightSlide ( viewerElementId, slideXmlNode) {
if ( arguments.length > 0 ) {
this.init( viewerElementId, slideXmlNode );
}
}
/**
* Display the slide content in the 'slide' div.
*
* @param string mediaSize
* @return void
* @access public
* @since 8/22/05
*/
TextRightSlide.prototype.doDisplay = function (mediaSize) {
this.currentMediaSize = mediaSize;
this.load(mediaSize);
var destination = getElementFromDocument(this.viewerElementId + '_slide');
destination.innerHTML = "";
destination.innerHTML += "\n";
destination.innerHTML += "\n
";
destination.innerHTML += "\n
";
var imageElement = getElementFromDocument(this.viewerElementId + '_media');
imageElement.style.position = "absolute";
imageElement.style.left = "0px";
if (this.media.length > 1) {
imageElement.style.top = "30px";
imageElement.style.height = (getElementHeight(this.viewerElementId + '_slide') - 30) + "px";
} else {
imageElement.style.top = "0px";
imageElement.style.height = getElementHeight(this.viewerElementId + '_slide') + "px";
}
imageElement.style.width = (getElementWidth(this.viewerElementId + '_slide') - 200) + "px";
imageElement.style.overflow = "auto";
// imageElement.style.border = "1px solid #00f";
var mediaButtonsElement = getElementFromDocument(this.viewerElementId + '_media_buttons');
mediaButtonsElement.style.position = "absolute";
mediaButtonsElement.style.top = "0px";
mediaButtonsElement.style.left = "0px";
mediaButtonsElement.style.height = "30px";
mediaButtonsElement.style.width = (getElementWidth(this.viewerElementId + '_slide') - 200) + "px";
// mediaButtonsElement.style.border = "1px solid #0f0";
var textElement = getElementFromDocument(this.viewerElementId + '_slide_text');
textElement.style.position = "absolute";
textElement.style.left = getElementWidth(this.viewerElementId + '_media') + "px";
textElement.style.top = "0px";
textElement.style.height = (getElementHeight(this.viewerElementId + '_slide') - 5) + "px";
textElement.style.width = "195px";
textElement.style.overflow = "auto";
textElement.style.paddingTop = "5px";
textElement.style.paddingLeft = "5px";
// textElement.style.border = "1px solid #f00";
textElement.innerHTML = "\n
" + this.title + "
";
textElement.innerHTML += "\n" + this.caption + "
";
if (this.media[this.currentMediaIndex])
this.media[this.currentMediaIndex].display(mediaSize);
this.displayMediaButtons();
}
/**
* @since 8/22/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: TextBottomSlide.class.js,v 1.9 2006/06/15 19:43:09 adamfranco Exp $
*/
TextBottomSlide.prototype = new Slide();
TextBottomSlide.prototype.constructor = TextBottomSlide;
TextBottomSlide.superclass = TextBottomSlide.prototype;
/**
* The Show is a controlling class wich maintains the order of slides and controls
* their creation.
*
* @since 8/22/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: TextBottomSlide.class.js,v 1.9 2006/06/15 19:43:09 adamfranco Exp $
*/
function TextBottomSlide ( viewerElementId, slideXmlNode) {
if ( arguments.length > 0 ) {
this.init( viewerElementId, slideXmlNode );
}
}
/**
* Display the slide content in the 'slide' div.
*
* @param string mediaSize
* @return void
* @access public
* @since 8/22/05
*/
TextBottomSlide.prototype.doDisplay = function (mediaSize) {
this.currentMediaSize = mediaSize;
this.load(mediaSize);
var destination = getElementFromDocument(this.viewerElementId + '_slide');
destination.innerHTML = "";
destination.innerHTML += "\n";
destination.innerHTML += "\n
";
destination.innerHTML += "\n
";
var imageElement = getElementFromDocument(this.viewerElementId + '_media');
imageElement.style.position = "absolute";
imageElement.style.left = "0px";
imageElement.style.top = "0px";
if (this.media.length > 1) {
imageElement.style.height = (getElementHeight(this.viewerElementId + '_slide') - 130) + "px";
} else {
imageElement.style.height = (getElementHeight(this.viewerElementId + '_slide') - 100) + "px";
}
imageElement.style.width = getElementWidth(this.viewerElementId + '_slide') + "px";
imageElement.style.overflow = "auto";
// imageElement.style.border = "1px solid #00f";
var mediaButtonsElement = getElementFromDocument(this.viewerElementId + '_media_buttons');
mediaButtonsElement.style.position = "absolute";
mediaButtonsElement.style.top = (getElementHeight(this.viewerElementId + '_slide') - 230) + "px";
mediaButtonsElement.style.left = "0px";
mediaButtonsElement.style.height = "30px";
mediaButtonsElement.style.width = getElementWidth(this.viewerElementId + '_slide') + "px";
// mediaButtonsElement.style.border = "1px solid #0f0";
var textElement = getElementFromDocument(this.viewerElementId + '_slide_text');
textElement.style.position = "absolute";
textElement.style.left = "0px";
textElement.style.top = (getElementHeight(this.viewerElementId + '_slide') - 100) + "px";
textElement.style.height = "95px";
textElement.style.width = (getElementWidth(this.viewerElementId + '_slide') - 5) + "px";
textElement.style.overflow = "auto";
textElement.style.paddingTop = "5px";
textElement.style.paddingLeft = "5px";
textElement.style.textAlign = "center";
// textElement.style.border = "1px solid #f00";
textElement.innerHTML = "\n
" + this.title + "
";
textElement.innerHTML += "\n" + this.caption + "
";
if (this.media[this.currentMediaIndex])
this.media[this.currentMediaIndex].display(mediaSize);
this.displayMediaButtons();
}
/**
* @since 8/22/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: TextTopSlide.class.js,v 1.9 2006/06/15 19:43:10 adamfranco Exp $
*/
TextTopSlide.prototype = new Slide();
TextTopSlide.prototype.constructor = TextTopSlide;
TextTopSlide.superclass = TextTopSlide.prototype;
/**
* The Show is a controlling class wich maintains the order of slides and controls
* their creation.
*
* @since 8/22/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: TextTopSlide.class.js,v 1.9 2006/06/15 19:43:10 adamfranco Exp $
*/
function TextTopSlide ( viewerElementId, slideXmlNode) {
if ( arguments.length > 0 ) {
this.init( viewerElementId, slideXmlNode );
}
}
/**
* Display the slide content in the 'slide' div.
*
* @param string mediaSize
* @return void
* @access public
* @since 8/22/05
*/
TextTopSlide.prototype.doDisplay = function (mediaSize) {
this.currentMediaSize = mediaSize;
this.load(mediaSize);
var destination = getElementFromDocument(this.viewerElementId + '_slide');
destination.innerHTML = "";
destination.innerHTML += "\n";
destination.innerHTML += "\n
";
destination.innerHTML += "\n
";
var imageElement = getElementFromDocument(this.viewerElementId + '_media');
imageElement.style.position = "absolute";
imageElement.style.left = "0px";
imageElement.style.top = "200px";
if (this.media.length > 1) {
imageElement.style.height = (getElementHeight(this.viewerElementId + '_slide') - 230) + "px";
} else {
imageElement.style.height = (getElementHeight(this.viewerElementId + '_slide') - 200) + "px";
}
imageElement.style.width = getElementWidth(this.viewerElementId + '_slide') + "px";
imageElement.style.overflow = "auto";
// imageElement.style.border = "1px solid #00f";
var mediaButtonsElement = getElementFromDocument(this.viewerElementId + '_media_buttons');
mediaButtonsElement.style.position = "absolute";
mediaButtonsElement.style.top = (getElementHeight(this.viewerElementId + '_slide') - 30) + "px";
mediaButtonsElement.style.left = "0px";
mediaButtonsElement.style.height = "30px";
mediaButtonsElement.style.width = getElementWidth(this.viewerElementId + '_slide') + "px";
// mediaButtonsElement.style.border = "1px solid #0f0";
var textElement = getElementFromDocument(this.viewerElementId + '_slide_text');
textElement.style.position = "absolute";
textElement.style.left = "0px";
textElement.style.top = "0px";
textElement.style.height = "195px";
textElement.style.width = getElementWidth(this.viewerElementId + '_slide') + "px";
textElement.style.overflow = "auto";
textElement.style.paddingTop = "5px";
textElement.style.paddingLeft = "5px";
// textElement.style.border = "1px solid #f00";
textElement.innerHTML = "\n
" + this.title + "
";
textElement.innerHTML += "\n" + this.caption + "
";
if (this.media[this.currentMediaIndex])
this.media[this.currentMediaIndex].display(mediaSize);
this.displayMediaButtons();
}
/**
* @since 8/22/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: TextCenterSlide.class.js,v 1.3 2005/12/16 18:55:24 adamfranco Exp $
*/
TextCenterSlide.prototype = new Slide();
TextCenterSlide.prototype.constructor = TextCenterSlide;
TextCenterSlide.superclass = TextCenterSlide.prototype;
/**
* The Show is a controlling class wich maintains the order of slides and controls
* their creation.
*
* @since 8/22/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: TextCenterSlide.class.js,v 1.3 2005/12/16 18:55:24 adamfranco Exp $
*/
function TextCenterSlide ( viewerElementId, slideXmlNode) {
if ( arguments.length > 0 ) {
this.init( viewerElementId, slideXmlNode );
}
}
/**
* Display the slide content in the 'slide' div.
*
* @param string mediaSize
* @return void
* @access public
* @since 8/22/05
*/
TextCenterSlide.prototype.doDisplay = function (mediaSize) {
this.currentMediaSize = mediaSize;
this.load(mediaSize);
var destination = getElementFromDocument(this.viewerElementId + '_slide');
destination.innerHTML = "\n";
var textElement = getElementFromDocument(this.viewerElementId + '_slide_text');
textElement.style.position = "absolute";
textElement.style.left = "0px";
textElement.style.top = "0px";
textElement.style.height = (getElementHeight(this.viewerElementId + '_slide') - 5) + "px";
textElement.style.width = (getElementWidth(this.viewerElementId + '_slide') - 5) + "px";
textElement.style.overflow = "auto";
textElement.style.paddingTop = "5px";
textElement.style.paddingLeft = "5px";
textElement.style.textAlign = "center";
// textElement.style.border = "1px solid #f00";
var html = "\n
";
html += "\n\t
";
textElement.innerHTML = html;
var innertextElement = getElementFromDocument(this.viewerElementId + '_innertext');
innertextElement.style.position = "absolute";
var centeredTop = (getElementHeight(this.viewerElementId + '_slide_text')/2 - innertextElement.offsetHeight/2);
if (centeredTop > 0)
innertextElement.style.top = centeredTop + "px";
else
innertextElement.style.top = "0px";
var centeredLeft = (getElementWidth(this.viewerElementId + '_slide_text')/2 - innertextElement.offsetWidth/2);
if (centeredLeft > 0)
innertextElement.style.left = centeredLeft + "px";
else
innertextElement.style.left = "0px";
}
/**
* @since 8/22/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: NoTextSlide.class.js,v 1.3 2006/06/15 19:43:09 adamfranco Exp $
*/
NoTextSlide.prototype = new Slide();
NoTextSlide.prototype.constructor = NoTextSlide;
NoTextSlide.superclass = NoTextSlide.prototype;
/**
* The Show is a controlling class wich maintains the order of slides and controls
* their creation.
*
* @since 8/22/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: NoTextSlide.class.js,v 1.3 2006/06/15 19:43:09 adamfranco Exp $
*/
function NoTextSlide ( viewerElementId, slideXmlNode) {
if ( arguments.length > 0 ) {
this.init( viewerElementId, slideXmlNode );
}
}
/**
* Display the slide content in the 'slide' div.
*
* @param string mediaSize
* @return void
* @access public
* @since 8/22/05
*/
NoTextSlide.prototype.doDisplay = function (mediaSize) {
this.currentMediaSize = mediaSize;
this.load(mediaSize);
var destination = getElementFromDocument(this.viewerElementId + '_slide');
destination.innerHTML = "";
destination.innerHTML += "\n" + this.title + "
";
html += "\n\t" + this.caption + "
";
html += "\n";
destination.innerHTML += "\n
";
var newWindow = window.open("", "_blank", "toolbar=no,location=no,directories=no,statusbar=no,scrollbars=yes,resizable=yes,width=800,height=800");
newWindow.document.write(temp);
newWindow.document.close();
newWindow.focus();
}/**
* The source of this file was downloaded from
* http://www.alistapart.com/stories/alternate/
* and was at the time of its inclusion here offered for use without restrictions.
*
*
* @since 5/23/06
*
* @author Paul Sowden (http://www.idontsmoke.co.uk/)
* @copyright Copyright © 1998-2006 A List Apart Magazine and the authors.
*
* @version $Id: styleswitcher.js,v 1.1 2006/05/23 21:09:38 adamfranco Exp $
*/
function setActiveStyleSheet(title) {
var i, a, main;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
a.disabled = true;
if(a.getAttribute("title") == title) a.disabled = false;
}
}
}
function getActiveStyleSheet() {
var i, a;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
}
return null;
}
function getPreferredStyleSheet() {
var i, a;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1
&& a.getAttribute("rel").indexOf("alt") == -1
&& a.getAttribute("title")
) return a.getAttribute("title");
}
return null;
}
/**
* Answer an array of all style sheets.
*
* @return array
* @access public
* @since 5/23/06
* @author Adam Franco
*/
function getStyleSheets() {
var i, a;
var j = 0;
var sheets = new Array();
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
sheets[j] = a.getAttribute("title");
j++;
}
}
return sheets;
}
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
window.onload = function(e) {
var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
}
window.onunload = function(e) {
var title = getActiveStyleSheet();
createCookie("style", title, 365);
}
var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
";
var imageElement = getElementFromDocument(this.viewerElementId + '_media');
imageElement.style.position = "absolute";
imageElement.style.left = "0px";
if (this.media.length > 1) {
imageElement.style.top = "30px";
imageElement.style.height = (getElementHeight(this.viewerElementId + '_slide') - 30) + "px";
} else {
imageElement.style.top = "0px";
imageElement.style.height = getElementHeight(this.viewerElementId + '_slide') + "px";
}
imageElement.style.width = (getElementWidth(this.viewerElementId + '_slide') - 0) + "px";
imageElement.style.overflow = "auto";
// imageElement.style.border = "1px solid #00f";
var mediaButtonsElement = getElementFromDocument(this.viewerElementId + '_media_buttons');
mediaButtonsElement.style.position = "absolute";
mediaButtonsElement.style.top = "0px";
mediaButtonsElement.style.left = "0px";
mediaButtonsElement.style.height = "30px";
mediaButtonsElement.style.width = (getElementWidth(this.viewerElementId + '_slide') - 0) + "px";
// mediaButtonsElement.style.border = "1px solid #0f0";
if (this.media[this.currentMediaIndex])
this.media[this.currentMediaIndex].display(mediaSize);
this.displayMediaButtons();
}
/**
* @since 8/23/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: MediaContainer.class.js,v 1.10 2006/05/03 20:11:21 adamfranco Exp $
*/
/**
* The media class represents a media file in a slide.
*
* @since 8/23/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: MediaContainer.class.js,v 1.10 2006/05/03 20:11:21 adamfranco Exp $
*/
function MediaContainer ( viewerElementId, mediaXMLNode) {
if ( arguments.length > 0 ) {
this.init( viewerElementId, mediaXMLNode );
}
}
/**
* Initialize this object
*
* @param string viewerElementId
* @param string xmlDocumentUrl
* @return void
* @access public
* @since 9/21/05
*/
MediaContainer.prototype.init = function ( viewerElementId, mediaXMLNode) {
this.versions = new Array ();
this.sizeOptions = new Array('thumb', 'small', 'medium', 'large', 'original');
this.mediaClasses = new Array(TiffMedia, ImageMedia, QuicktimeMedia, RealMedia, WindowsMediaMedia, VideoMedia, FileMedia);
this.currentMediaSize = 'original';
this.viewerElementId = viewerElementId;
var versionElements = mediaXMLNode.getElementsByTagName("version");
for (var i = 0; i < versionElements.length; i++) {
var sizeElements = versionElements[i].getElementsByTagName("size");
if (sizeElements.length > 0)
var size = this.getSizeIndex(sizeElements[0].firstChild.nodeValue);
else
var size = this.getSizeIndex('original');
for (var j = 0; j < this.mediaClasses.length; j++) {
if (this.mediaClasses[j].prototype.supportsNode(versionElements[i])) {
this.versions[size] = new this.mediaClasses[j] (this.viewerElementId, versionElements[i]);
break;
}
}
}
}
/**
* Display the slide content in the 'slide' div.
*
* @param string mediaSize
* @return void
* @access public
* @since 8/22/05
*/
MediaContainer.prototype.display = function (mediaSize) {
this.currentMediaSize = mediaSize;
var size = this.selectSizeIndex(mediaSize);
this.versions[size].display();
}
/**
* Redisplay the media based on our current media size
*
* @return void
* @access public
* @since 8/25/05
*/
MediaContainer.prototype.redisplay = function () {
this.display(this.currentMediaSize);
}
/**
* Load and cache the image
*
* @param string mediaSize
* @return void
* @access public
* @since 8/23/05
*/
MediaContainer.prototype.load = function (mediaSize) {
var size = this.selectSizeIndex(mediaSize);
this.versions[size].load();
}
/**
* unload and clear our image cache
*
* @return void
* @access public
* @since 8/23/05
*/
MediaContainer.prototype.unload = function () {
for (var i in this.versions) {
this.versions[i].unload();
}
}
/**
* Answer the availible sizes of media
*
* @return array
* @access public
* @since 8/24/05
*/
MediaContainer.prototype.getMediaSizes = function () {
var sizes = new Array();
for (var i in this.versions) {
sizes.push(this.sizeOptions[i]);
}
return arrayUnique(sizes);
}
/**
* Answer the integer size that corresponds to the text name.
*
* @param string sizeName
* @return integer
* @access public
* @since 8/24/05
*/
MediaContainer.prototype.getSizeIndex = function (sizeName) {
for (var i = 0; i < this.sizeOptions.length; i++) {
if (sizeName == this.sizeOptions[i])
return i;
}
alert("Media version size, '" + sizeName + "', is not in the allowed list:\n " + this.sizeOptions);
}
/**
* Answer the size index that equal to sizeName if a version exists for that
* size, otherwise, the next bigger existing version index. If no large version
* exists, then return a smaller version.
*
* @param string sizeName
* @return integer
* @access public
* @since 8/24/05
*/
MediaContainer.prototype.selectSizeIndex = function (sizeName) {
var targetIndex = this.getSizeIndex(sizeName);
// Look for the desired or larger versions
for (var i = targetIndex; i <= this.sizeOptions.length; i++) {
if (this.versions[i])
return i;
}
// Look for smaller versions
for (var i = targetIndex - 1; i >= 0; i--) {
if (this.versions[i])
return i;
}
alert("No media version exists.");
}
/**
* Zoom in and redisplay
*
* @return void
* @access public
* @since 8/25/05
*/
MediaContainer.prototype.zoomIn = function () {
this.versions[this.selectSizeIndex(this.currentMediaSize)].zoomIn();
}
/**
* Zoom in and redisplay
*
* @return void
* @access public
* @since 8/25/05
*/
MediaContainer.prototype.zoomOut = function () {
this.versions[this.selectSizeIndex(this.currentMediaSize)].zoomOut();
}
/**
* Zoom to 100% and redisplay
*
* @return void
* @access public
* @since 8/25/05
*/
MediaContainer.prototype.zoomToFull = function () {
this.versions[this.selectSizeIndex(this.currentMediaSize)].zoomToFull();
}
/**
* Zoom to fit and redisplay
*
* @return void
* @access public
* @since 8/25/05
*/
MediaContainer.prototype.zoomToFit = function () {
this.versions[this.selectSizeIndex(this.currentMediaSize)].zoomToFit();
}
/**
* Clear the zoom levels of the media
*
* @return void
* @access public
* @since 8/23/05
*/
MediaContainer.prototype.resetZoom = function () {
var sizes = this.getMediaSizes();
for (var i = 0; i < sizes.length; i++) {
this.versions[this.getSizeIndex(sizes[i])].resetZoom();
}
}
/**
* @since 8/23/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: Media.class.js,v 1.11 2005/09/21 22:28:30 adamfranco Exp $
*/
/**
* The media class represents a media file in a slide.
*
* @since 8/23/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: Media.class.js,v 1.11 2005/09/21 22:28:30 adamfranco Exp $
*/
function Media ( viewerElementId, mediaXMLNode) {
if ( arguments.length > 0 ) {
this.init( viewerElementId, mediaXMLNode );
}
}
/**
* initialize our object. Necessary for proper inheritance to work.
*
* @param object Node mediaXMLNode
* @return void
* @access public
* @since 8/26/05
*/
Media.prototype.init = function ( viewerElementId, mediaXMLNode) {
this.zoomLevel = 1;
this.zoomIncrement = 1.25;
this.fitMargin = 0;
this.scrollXPercent = 0.5;
this.scrollYPercent = 0.5;
this.viewerElementId = viewerElementId;
var urlElements = mediaXMLNode.getElementsByTagName("url");
if (urlElements.length > 0)
this.url = urlElements[0].firstChild.nodeValue;
var typeElements = mediaXMLNode.getElementsByTagName("type");
if (typeElements.length > 0)
this.type = typeElements[0].firstChild.nodeValue;
var heightElements = mediaXMLNode.getElementsByTagName("height");
if (heightElements.length > 0)
this.height = heightElements[0].firstChild.nodeValue;
else
this.height = "0px";
var widthElements = mediaXMLNode.getElementsByTagName("width");
if (widthElements.length > 0)
this.width = widthElements[0].firstChild.nodeValue;
else
this.width = "0px";
}
/**
* Display the slide content in the 'slide' div.
*
* @param string mediaSize
* @return void
* @access public
* @since 8/22/05
*/
Media.prototype.display = function (mediaSize) {
this.load();
var html = "";
html += "";
var destination = getElementFromDocument(this.viewerElementId + '_media');
destination.innerHTML = html;
var downloadLink = getElementFromDocument(this.viewerElementId + '_download_link');
downloadLink.style.top = this.getCenteredY(downloadLink.offsetHeight) + "px";
downloadLink.style.left = this.getCenteredX(downloadLink.offsetWidth) + "px";
}
/**
* Answer true if this media class supports the node passed
*
* @param object Element xmlNode
* @return boolean
* @access public
* @since 9/12/05
*/
Media.prototype.supportsNode = function (xmlNode) {
alert("Error: over-ride method Media.supportsNode(xmlNode) in child class!");
}
/**
* Load and cache the image
*
* @param string mediaSize
* @return void
* @access public
* @since 8/23/05
*/
Media.prototype.load = function (mediaSize) {
// override to cache our target if possible
}
/**
* unload and clear our image cache
*
* @return void
* @access public
* @since 8/23/05
*/
Media.prototype.unload = function () {
// if we are caching, override to un-cache.
}
/**
* Zoom in and redisplay
*
* @return void
* @access public
* @since 8/25/05
*/
Media.prototype.zoomIn = function () {
this.zoomLevel = this.zoomLevel * this.zoomIncrement;
this.display();
}
/**
* Zoom in and redisplay
*
* @return void
* @access public
* @since 8/25/05
*/
Media.prototype.zoomOut = function () {
this.zoomLevel = this.zoomLevel / this.zoomIncrement;
this.display();
}
/**
* Zoom to 100% and redisplay
*
* @return void
* @access public
* @since 8/25/05
*/
Media.prototype.zoomToFull = function () {
this.zoomLevel = 1;
this.display();
}
/**
* Answer the height
*
* @return integer
* @access public
* @since 8/25/05
*/
Media.prototype.getHeightPx = function () {
return pixelsToInteger(this.height);
}
/**
* Answer the width
*
* @return integer
* @access public
* @since 8/25/05
*/
Media.prototype.getWidthPx = function () {
return pixelsToInteger(this.width);
}
/**
* Answer the height after the zoom factor is taken into account
*
* @return integer
* @access public
* @since 8/25/05
*/
Media.prototype.getZoomedHeightPx = function () {
return this.getHeightPx() * this.zoomLevel;
}
/**
* Answer the width after the zoom factor is taken into account
*
* @return integer
* @access public
* @since 8/25/05
*/
Media.prototype.getZoomedWidthPx = function () {
return this.getWidthPx() * this.zoomLevel;
}
/**
* Zoom to fit and redisplay
*
* @return void
* @access public
* @since 8/25/05
*/
Media.prototype.zoomToFit = function () {
if (this.getHeightPx() != 0 && this.getWidthPx() != 0) {
var targetHeight = getElementHeight(this.viewerElementId + '_media') - this.fitMargin;
var targetWidth = getElementWidth(this.viewerElementId + '_media') - this.fitMargin;
var heightRatio = targetHeight/this.getHeightPx();
var widthRatio = targetWidth/this.getWidthPx();
if (heightRatio <= widthRatio)
this.zoomLevel = heightRatio;
else
this.zoomLevel = widthRatio;
this.display();
}
}
/**
* Answer the integer number of pixels in the X-direction to offset the
* image in order to center it.
*
* @return integer
* @access public
* @since 8/25/05
*/
Media.prototype.getCenteredX = function (imageWidth) {
var targetWidth = getElementWidth(this.viewerElementId + '_media') - this.fitMargin;
if (imageWidth == null)
var imageWidth = this.getZoomedWidthPx();
if (imageWidth > targetWidth) {
return 0;
} else {
return ((targetWidth/2) - (imageWidth/2));
}
}
/**
* Answer the integer number of pixels in the X-direction to offset the
* image in order to center it.
*
* @return integer
* @access public
* @since 8/25/05
*/
Media.prototype.getCenteredY = function (imageHeight) {
var targetHeight = getElementHeight(this.viewerElementId + '_media') - this.fitMargin;
if (imageHeight == null)
var imageHeight = this.getZoomedHeightPx();
if (imageHeight > targetHeight) {
return 0;
} else {
return ((targetHeight/2) - (imageHeight/2));
}
}
/**
* Answer the percentage that the image is scrolled in the X-direction.
*
* @return integer
* @access public
* @since 8/25/05
*/
Media.prototype.getScrollXPercent = function () {
var target = getElementFromDocument(this.viewerElementId + '_media');
return ((target.scrollLeft + target.clientWidth/2)/target.scrollWidth);
}
/**
* Answer the percentage that the image is scrolled in the Y-direction.
*
* @return integer
* @access public
* @since 8/25/05
*/
Media.prototype.getScrollYPercent = function () {
var target = getElementFromDocument(this.viewerElementId + '_media');
return ((target.scrollTop + target.clientHeight/2)/target.scrollHeight);
}
/**
* Set the new scroll amount so that it is the same percentage scroll as
* the parameter
*
* @return integer
* @access public
* @since 8/25/05
*/
Media.prototype.setScrollXPercent = function (scrollPercent) {
var target = getElementFromDocument(this.viewerElementId + '_media');
target.scrollLeft = Math.round((target.scrollWidth * scrollPercent) - target.clientWidth/2);
}
/**
* Set the new scroll amount so that it is the same percentage scroll as
* the parameter
*
* @return integer
* @access public
* @since 8/25/05
*/
Media.prototype.setScrollYPercent = function (scrollPercent) {
var target = getElementFromDocument(this.viewerElementId + '_media');
target.scrollTop = Math.round((target.scrollHeight * scrollPercent) - target.clientHeight/2);
}
/**
* Update the scroll percentage based on the the current one.
* "this" will be the element that onscroll was set to, so it must
* have its target set at the same time as the onscroll event was set.
*
* @return void
* @access public
* @since 8/25/05
*/
updateScroll = function () {
this._scrollTarget.scrollXPercent = this._scrollTarget.getScrollXPercent();
this._scrollTarget.scrollYPercent = this._scrollTarget.getScrollYPercent();
}
/**
* Answer true if the image is larger than the target area it will go in.
*
* @return boolean
* @access public
* @since 8/25/05
*/
Media.prototype.isLargerThanTarget = function () {
var targetHeight = getElementHeight(this.viewerElementId + '_media') - this.fitMargin;
var targetWidth = getElementWidth(this.viewerElementId + '_media') - this.fitMargin;
if (this.getHeightPx() < targetHeight && this.getWidthPx() < targetWidth)
return false;
else
return true;
}
/**
* Clear the zoom level.
*
* @return void
* @access public
* @since 8/23/05
*/
Media.prototype.resetZoom = function () {
// Do nothing. Override in children that can zoom.
}
/**
* @since 8/23/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: ImageMedia.class.js,v 1.18 2006/06/15 19:43:09 adamfranco Exp $
*/
ImageMedia.prototype = new Media();
ImageMedia.prototype.constructor = ImageMedia;
ImageMedia.superclass = Media.prototype;
/**
* The media class represents a media file in a slide.
*
* @since 8/23/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: ImageMedia.class.js,v 1.18 2006/06/15 19:43:09 adamfranco Exp $
*/
function ImageMedia ( viewerElementId, mediaXMLNode) {
if ( arguments.length > 0 ) {
this.init( viewerElementId, mediaXMLNode );
}
}
/**
* initialize our object. Necessary for proper inheritance to work.
*
* @param object Node mediaXMLNode
* @return void
* @access public
* @since 8/26/05
*/
ImageMedia.prototype.init = function ( viewerElementId, mediaXMLNode) {
ImageMedia.superclass.init.call(this, viewerElementId, mediaXMLNode);
this.startAtZoomToFit = true;
this.image = null;
}
/**
* Answer true if this media class supports the node passed
*
* @param object Element xmlNode
* @return boolean
* @access public
* @since 9/12/05
*/
ImageMedia.prototype.supportsNode = function (xmlNode) {
var typeElements = xmlNode.getElementsByTagName("type");
if (typeElements.length > 0) {
var regex = new RegExp("^image(/[a-z]+)?$", "i");
if (regex.exec(typeElements[0].firstChild.nodeValue))
return true;
}
return false;
}
/**
* Display the slide content in the 'slide' div.
*
* @param string mediaSize
* @return void
* @access public
* @since 8/22/05
*/
ImageMedia.prototype.display = function (mediaSize) {
this.load();
var html = "";
html += "
";
var destination = getElementFromDocument(this.viewerElementId + '_media');
destination.innerHTML = html;
destination._scrollTarget = this;
destination.onscroll = updateScroll;
var image = getElementFromDocument(this.viewerElementId + '_image');
image._scrollTarget = this;
image.onclick = center;
image.onmousemove = setCursor;
// Wait for our image to load, and then set-up the initital position
this.setUpPositionOnComplete()
}
/**
* Resize the image once it has finished loading
*
* @return void
* @access public
* @since 1/05/06
*/
ImageMedia.prototype.setUpPositionOnComplete = function () {
if (this.isComplete()) {
this.setStartingPositionAndZoom();
} else {
if (!window.media_objects)
window.media_objects = new Array();
window.media_objects[this.url] = this;
window.setTimeout('setUpPositionIfComplete("' + this.url + '");', 100);
}
}
/**
* Resize the the media if it has been loaded.
*
* @param string url
* @return void
* @access public
* @since 1/5/06
*/
function setUpPositionIfComplete (url) {
var media_object = this.media_objects[url];
if (media_object.isComplete()) {
var loading = getElementFromDocument(media_object.viewerElementId + '_loading')
loading.style.display = 'none';
media_object.setStartingPositionAndZoom();
} else {
var loading = getElementFromDocument(media_object.viewerElementId + '_loading')
loading.style.display = 'block';
window.setTimeout('setUpPositionIfComplete("' + url + '");', 100);
}
}
/**
* Answer true if the size of the image is known
*
* @return boolean
* @access public
* @since 1/5/06
*/
ImageMedia.prototype.isComplete = function () {
if (this.height && this.height != "0px"
&& this.width && this.width != "0px")
{
return true;
} else {
return this.loadNaturalSize();
}
}
/**
* Answer true if the image has finished loading (and has a non-zero height
* and width). Put the natural height in this object
*
* @return boolean
* @access public
* @since 1/5/06
*/
ImageMedia.prototype.loadNaturalSize = function () {
var imageElement = getElementFromDocument(this.viewerElementId + '_image');
if (imageElement.naturalHeight > 0 && imageElement.naturalWidth > 0) {
// alert ("imageElement.naturalHeight=" + imageElement.naturalHeight +
// "imageElement.naturalWidth=" + imageElement.naturalWidth);
this.height = imageElement.naturalHeight;
this.width = imageElement.naturalWidth;
return true;
}
// It seems that IE first returns invalid sizes in the
// image itself, before it loads the image element with
// the correct size.
if (imageElement.complete && imageElement.height > 0 && imageElement.width > 0) {
// alert ("imageElement.height=" + imageElement.height
// + "imageElement.width=" + imageElement.width);
this.height = imageElement.height;
this.width = imageElement.width;
return true;
}
return false;
}
/**
* Set up the starting zoom and scroll.
*
* @param string mediaSize
* @return void
* @access public
* @since 8/22/05
*/
ImageMedia.prototype.setStartingPositionAndZoom = function () {
// If we haven't displayed this media yet, zoom to fit.
if (this.startAtZoomToFit != null) {
this.startAtZoomToFit = null;
if (this.isLargerThanTarget()) {
this.zoomToFit();
return;
}
}
var imageElement = getElementFromDocument(this.viewerElementId + '_image');
imageElement.height = this.getZoomedHeightPx();
imageElement.width = this.getZoomedWidthPx();
imageElement.style.position = 'absolute';
imageElement.style.top = this.getCenteredY() + "px";
imageElement.style.left = this.getCenteredX() + "px";
this.setScrollXPercent(this.scrollXPercent);
this.setScrollYPercent(this.scrollYPercent);
}
/**
* Load and cache the image
*
* @param string mediaSize
* @return void
* @access public
* @since 8/23/05
*/
ImageMedia.prototype.load = function (mediaSize) {
if (this.image == null) {
this.image = new Image();
this.image.src = this.url;
}
}
/**
* unload and clear our image cache
*
* @return void
* @access public
* @since 8/23/05
*/
ImageMedia.prototype.unload = function () {
this.image = null;
}
/**
* Answer the distance X-direction from the edge of the image to the
* center of the scrolled window.
*
* @return integer
* @access public
* @since 8/25/05
*/
ImageMedia.prototype.getScrollCenterX = function () {
var target = getElementFromDocument(this.viewerElementId + '_media');
return target.scrollLeft + Math.round(target.clientWidth/2) + this.getCenteredX();
}
/**
* Answer the distance Y-direction from the edge of the image to the
* center of the scrolled window.
*
* @return integer
* @access public
* @since 8/25/05
*/
ImageMedia.prototype.getScrollCenterY = function () {
var target = getElementFromDocument(this.viewerElementId + '_media');
return target.scrollTop + Math.round(target.clientHeight/2) + this.getCenteredY();
}
/**
* Center the image on the place where the mouse was clicked.
*
* @return void
* @access public
* @since 9/15/05
*/
center = function (event) {
var zoomIn = false;
var zoomOut = false;
if (event) {
// Mozilla/Konqueror/Safari version
var clickedX = event.layerX;
var clickedY = event.layerY;
} else {
// IE version
var event = window.event;
var clickedX = window.event.offsetX;
var clickedY = window.event.offsetY;
}
if (event.ctrlKey || event.metaKey) {
if (event.shiftKey)
zoomOut = true;
else
zoomIn = true;
}
var changeX = -(this._scrollTarget.getScrollCenterX() - clickedX);
var changeY = -(this._scrollTarget.getScrollCenterY() - clickedY);
var target = getElementFromDocument(this._scrollTarget.viewerElementId + '_media');
if (target.scrollLeft >= 0
&& target.scrollLeft <= (target.scrollWidth - target.clientWidth/2))
{
target.scrollLeft = target.scrollLeft + changeX;
this._scrollTarget.scrollXPercent = (target.clientWidth/2 + target.scrollLeft)/target.scrollWidth;
}
if (target.scrollTop >= 0
&& target.scrollTop <= (target.scrollHeight - target.clientHeight/2))
{
target.scrollTop = target.scrollTop + changeY;
this._scrollTarget.scrollYPercent = (target.clientHeight/2 + target.scrollTop)/target.scrollHeight;
}
if (zoomIn)
this._scrollTarget.zoomIn();
else if (zoomOut)
this._scrollTarget.zoomOut();
}
/**
* Set the cursor based on the meta-keys pressed.
*
* @return void
* @access public
* @since 9/15/05
*/
setCursor = function (event) {
if (!event)
event = window.event;
if (event.ctrlKey || event.metaKey) {
if (event.shiftKey)
this.style.cursor = 'help';
else
this.style.cursor = 'crosshair';
} else {
this.style.cursor = 'default';
}
}
/**
* Clear the zoom level.
*
* @return void
* @access public
* @since 8/23/05
*/
ImageMedia.prototype.resetZoom = function () {
this.startAtZoomToFit = true;
this.zoomLevel = 1;
}
/**
* @since 8/23/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: VideoMedia.class.js,v 1.8 2005/09/21 22:28:30 adamfranco Exp $
*/
VideoMedia.prototype = new Media();
VideoMedia.prototype.constructor = VideoMedia;
VideoMedia.superclass = Media.prototype;
/**
* The media class represents a media file in a slide.
*
* @since 8/23/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: VideoMedia.class.js,v 1.8 2005/09/21 22:28:30 adamfranco Exp $
*/
function VideoMedia ( viewerElementId, mediaXMLNode) {
if ( arguments.length > 0 ) {
this.init( viewerElementId, mediaXMLNode );
}
}
/**
* initialize our object. Necessary for proper inheritance to work.
*
* @param object Node mediaXMLNode
* @return void
* @access public
* @since 8/26/05
*/
VideoMedia.prototype.init = function ( viewerElementId, mediaXMLNode) {
VideoMedia.superclass.init.call(this, viewerElementId, mediaXMLNode);
this.startAtZoomToFit = true;
}
/**
* Answer true if this media class supports the node passed
*
* @param object Element xmlNode
* @return boolean
* @access public
* @since 9/12/05
*/
VideoMedia.prototype.supportsNode = function (xmlNode) {
var typeElements = xmlNode.getElementsByTagName("type");
if (typeElements.length > 0) {
// Quicktime MIME type
var regex = new RegExp("^(video|audio)(/.+)?$", "i");
if (regex.exec(typeElements[0].firstChild.nodeValue))
return true;
if (typeElements[0].firstChild.nodeValue == "video"
|| typeElements[0].firstChild.nodeValue == "audio")
{
var urlElements = xmlNode.getElementsByTagName("url");
var regex = new RegExp("^.+\.(mov|moov|qt|aac|adts)$", "i");
if (regex.exec(urlElements[0].firstChild.nodeValue))
return true;
}
}
return false;
}
/**
* Display the slide content in the 'slide' div.
*
* @param string mediaSize
* @return void
* @access public
* @since 8/22/05
*/
VideoMedia.prototype.display = function (mediaSize) {
this.load();
// If we haven't displayed this media yet, zoom to fit.
if (this.startAtZoomToFit != null) {
this.startAtZoomToFit = null;
if (this.isLargerThanTarget()) {
this.zoomToFit();
return;
}
}
// Write the elements
var html = "";
html += "
";
var destination = getElementFromDocument(this.viewerElementId + '_media');
destination.innerHTML = html;
// positioning
var videoElement = getElementFromDocument(this.viewerElementId + '_video');
if (this.getCenteredY() > (this.getControlHeight()/2))
videoElement.style.top = (this.getCenteredY() - (this.getControlHeight()/2)) + "px";
else
videoElement.style.top = "0px";
videoElement.style.left = this.getCenteredX() + "px";
var downloadLink = getElementFromDocument(this.viewerElementId + '_download_link');
downloadLink.style.top = (pixelsToInteger(videoElement.style.top) + pixelsToInteger(videoElement.height)) + "px";
downloadLink.style.left = this.getCenteredX(downloadLink.offsetWidth) + "px";
// Scroll positioning.
destination._scrollTarget = this;
destination.onscroll = updateScroll;
this.setScrollXPercent(this.scrollXPercent);
this.setScrollYPercent(this.scrollYPercent);
}
/**
* Answer the height of the controls for this player.
*
* @return integer
* @access public
* @since 9/12/05
*/
VideoMedia.prototype.getControlHeight = function () {
// A nice default value, over-ride for specific players.
return 25;
}
/**
* Answer the URL where the plugin can be downloaded
*
* @return string OR false
* @access public
* @since 9/12/05
*/
VideoMedia.prototype.getPluginsPage = function () {
return false;
}
/**
* Answer additional attributes to add to the embed tag
*
* @return string OR false
* @access public
* @since 9/12/05
*/
VideoMedia.prototype.getAdditionalAttras = function () {
return false;
}
/**
* Answer the width, with a non-zero default.
*
* @return integer
* @access public
* @since 8/25/05
*/
VideoMedia.prototype.getWidthPx = function () {
var px = pixelsToInteger(this.width);
if (px > 0)
return px;
else
return 100;
}
/**
* Clear the zoom level.
*
* @return void
* @access public
* @since 8/23/05
*/
VideoMedia.prototype.resetZoom = function () {
// Do nothing. Override in children that can zoom.
this.startAtZoomToFit = true;
this.zoomLevel = 1;
}
/**
* @since 8/23/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: TiffMedia.class.js,v 1.1 2006/05/03 20:11:21 adamfranco Exp $
*/
TiffMedia.prototype = new ImageMedia();
TiffMedia.prototype.constructor = TiffMedia;
TiffMedia.superclass = ImageMedia.prototype;
/**
* The media class represents a media file in a slide. More information on
* embedding Tiff images in web pages can be found at:
* http://www.apple.com/quicktime/tutorials/embed.html
*
* @since 8/23/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: TiffMedia.class.js,v 1.1 2006/05/03 20:11:21 adamfranco Exp $
*/
function TiffMedia ( viewerElementId, mediaXMLNode) {
if ( arguments.length > 0 ) {
this.init( viewerElementId, mediaXMLNode );
}
}
/**
* initialize our object. Necessary for proper inheritance to work.
*
* @param object Node mediaXMLNode
* @return void
* @access public
* @since 8/26/05
*/
TiffMedia.prototype.init = function ( viewerElementId, mediaXMLNode) {
TiffMedia.superclass.init.call(this, viewerElementId, mediaXMLNode);
}
/**
* Answer true if this media class supports the node passed
*
* @param object Element xmlNode
* @return boolean
* @access public
* @since 9/12/05
*/
TiffMedia.prototype.supportsNode = function (xmlNode) {
var typeElements = xmlNode.getElementsByTagName("type");
if (typeElements.length > 0) {
// Tiff MIME type
var regex = new RegExp("^image/tiff$", "i");
if (regex.exec(typeElements[0].firstChild.nodeValue))
return true;
if (typeElements[0].firstChild.nodeValue == "image")
{
var urlElements = xmlNode.getElementsByTagName("url");
var regex = new RegExp("^.+\.(tiff|tif)$", "i");
if (regex.exec(urlElements[0].firstChild.nodeValue))
return true;
}
}
return false;
}
/**
* Display the slide content in the 'slide' div.
*
* @param string mediaSize
* @return void
* @access public
* @since 8/22/05
*/
TiffMedia.prototype.display = function (mediaSize) {
TiffMedia.superclass.display.call(this, mediaSize);
// Add a "download" link for Firefox, etc which cannot display tiffs inline
var destination = getElementFromDocument(this.viewerElementId + '_media');
var html = "";
destination.innerHTML = destination.innerHTML + html;
// positioning
var imageElement = getElementFromDocument(this.viewerElementId + '_image');
var downloadLink = getElementFromDocument(this.viewerElementId + '_download_link');
downloadLink.style.top = (pixelsToInteger(imageElement.style.top) + pixelsToInteger(imageElement.height)) + "px";
downloadLink.style.left = this.getCenteredX(downloadLink.offsetWidth) + "px";
}
/**
* @since 8/23/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: QuicktimeMedia.class.js,v 1.2 2005/09/16 15:53:22 adamfranco Exp $
*/
QuicktimeMedia.prototype = new VideoMedia();
QuicktimeMedia.prototype.constructor = QuicktimeMedia;
QuicktimeMedia.superclass = VideoMedia.prototype;
/**
* The media class represents a media file in a slide. More information on
* embedding Quicktime in web pages can be found at:
* http://www.apple.com/quicktime/tutorials/embed.html
*
* @since 8/23/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: QuicktimeMedia.class.js,v 1.2 2005/09/16 15:53:22 adamfranco Exp $
*/
function QuicktimeMedia ( viewerElementId, mediaXMLNode) {
if ( arguments.length > 0 ) {
this.init( viewerElementId, mediaXMLNode );
}
}
/**
* initialize our object. Necessary for proper inheritance to work.
*
* @param object Node mediaXMLNode
* @return void
* @access public
* @since 8/26/05
*/
QuicktimeMedia.prototype.init = function ( viewerElementId, mediaXMLNode) {
QuicktimeMedia.superclass.init.call(this, viewerElementId, mediaXMLNode);
}
/**
* Answer true if this media class supports the node passed
*
* @param object Element xmlNode
* @return boolean
* @access public
* @since 9/12/05
*/
QuicktimeMedia.prototype.supportsNode = function (xmlNode) {
var typeElements = xmlNode.getElementsByTagName("type");
if (typeElements.length > 0) {
// Quicktime MIME type
var regex = new RegExp("^(video/quicktime)|(audio/(aac|x-aac))$", "i");
if (regex.exec(typeElements[0].firstChild.nodeValue))
return true;
if (typeElements[0].firstChild.nodeValue == "video"
|| typeElements[0].firstChild.nodeValue == "audio")
{
var urlElements = xmlNode.getElementsByTagName("url");
var regex = new RegExp("^.+\.(mov|moov|qt|aac|adts)$", "i");
if (regex.exec(urlElements[0].firstChild.nodeValue))
return true;
}
}
return false;
}
/**
* Answer the height of the controls for this player
*
* @return integer
* @access public
* @since 9/12/05
*/
QuicktimeMedia.prototype.getControlHeight = function () {
return 16;
}
/**
* Answer the URL where the plugin can be downloaded
*
* @return string OR false
* @access public
* @since 9/12/05
*/
QuicktimeMedia.prototype.getPluginsPage = function () {
return 'http://www.apple.com/quicktime/download/';
}
/**
* @since 8/23/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: WindowsMediaMedia.class.js,v 1.1 2005/09/14 21:25:27 adamfranco Exp $
*/
WindowsMediaMedia.prototype = new VideoMedia();
WindowsMediaMedia.prototype.constructor = WindowsMediaMedia;
WindowsMediaMedia.superclass = VideoMedia.prototype;
/**
* The media class represents a media file in a slide.
*
* @since 8/23/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: WindowsMediaMedia.class.js,v 1.1 2005/09/14 21:25:27 adamfranco Exp $
*/
function WindowsMediaMedia ( viewerElementId, mediaXMLNode) {
if ( arguments.length > 0 ) {
this.init( viewerElementId, mediaXMLNode );
}
}
/**
* initialize our object. Necessary for proper inheritance to work.
*
* @param object Node mediaXMLNode
* @return void
* @access public
* @since 8/26/05
*/
WindowsMediaMedia.prototype.init = function ( viewerElementId, mediaXMLNode) {
WindowsMediaMedia.superclass.init.call(this, viewerElementId, mediaXMLNode);
}
/**
* Answer true if this media class supports the node passed
*
* @param object Element xmlNode
* @return boolean
* @access public
* @since 9/12/05
*/
WindowsMediaMedia.prototype.supportsNode = function (xmlNode) {
var typeElements = xmlNode.getElementsByTagName("type");
if (typeElements.length > 0) {
// Quicktime MIME type
var regex = new RegExp("^(video|audio)(/x-ms-[a-z]{2,3})?$", "i");
if (regex.exec(typeElements[0].firstChild.nodeValue))
return true;
if (typeElements[0].firstChild.nodeValue == "video"
|| typeElements[0].firstChild.nodeValue == "audio")
{
var urlElements = xmlNode.getElementsByTagName("url");
var regex = new RegExp("^.+\.(asf|asx|wma|wmv|wax|wvx|wm|wmz|wmd)$", "i");
if (regex.exec(urlElements[0].firstChild.nodeValue))
return true;
}
}
return false;
}
/**
* Answer the height of the controls for this player
*
* @return integer
* @access public
* @since 9/12/05
*/
WindowsMediaMedia.prototype.getControlHeight = function () {
return 46;
}
/**
* Answer the URL where the plugin can be downloaded
*
* @return string OR false
* @access public
* @since 9/12/05
*/
WindowsMediaMedia.prototype.getPluginsPage = function () {
return 'http://www.microsoft.com/Windows/MediaPlayer/';
}
/**
* @since 8/23/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: RealMedia.class.js,v 1.1 2005/09/15 18:04:52 adamfranco Exp $
*/
RealMedia.prototype = new VideoMedia();
RealMedia.prototype.constructor = RealMedia;
RealMedia.superclass = VideoMedia.prototype;
/**
* The media class represents a RealNetworks media file in a slide.
* For more information on the Real plugin, see:
* http://service.real.com/help/library/guides/realone/ProductionGuide/HTML/realpgd.htm?page=htmfiles/embed.htm%23overview
*
* @since 8/23/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: RealMedia.class.js,v 1.1 2005/09/15 18:04:52 adamfranco Exp $
*/
function RealMedia ( viewerElementId, mediaXMLNode) {
if ( arguments.length > 0 ) {
this.init( viewerElementId, mediaXMLNode );
}
}
/**
* initialize our object. Necessary for proper inheritance to work.
*
* @param object Node mediaXMLNode
* @return void
* @access public
* @since 8/26/05
*/
RealMedia.prototype.init = function ( viewerElementId, mediaXMLNode) {
RealMedia.superclass.init.call(this, viewerElementId, mediaXMLNode);
}
/**
* Answer true if this media class supports the node passed
*
* @param object Element xmlNode
* @return boolean
* @access public
* @since 9/12/05
*/
RealMedia.prototype.supportsNode = function (xmlNode) {
var typeElements = xmlNode.getElementsByTagName("type");
if (typeElements.length > 0) {
// Quicktime MIME type
var regex = new RegExp("^(video|audio|application)/(vnd.rn|x-pn)-real(audio|video|media)$", "i");
if (regex.exec(typeElements[0].firstChild.nodeValue))
return true;
if (typeElements[0].firstChild.nodeValue == "video"
|| typeElements[0].firstChild.nodeValue == "audio"
|| typeElements[0].firstChild.nodeValue == "application")
{
var urlElements = xmlNode.getElementsByTagName("url");
var regex = new RegExp("^.+\.(rm|rv|ra|ram)$", "i");
if (regex.exec(urlElements[0].firstChild.nodeValue))
return true;
}
}
return false;
}
/**
* Answer the height of the controls for this player
*
* @return integer
* @access public
* @since 9/12/05
*/
RealMedia.prototype.getControlHeight = function () {
return 66;
}
/**
* Answer the URL where the plugin can be downloaded
*
* @return string OR false
* @access public
* @since 9/12/05
*/
RealMedia.prototype.getPluginsPage = function () {
return 'http://www.real.com/';
}
/**
* Answer additional attributes to add to the embed tag
*
* @return string OR false
* @access public
* @since 9/12/05
*/
RealMedia.prototype.getAdditionalAttras = function () {
return "type='audio/x-pn-realaudio-plugin' controls='ImageWindow,ControlPanel,StatusBar' maintainaspect='true'";
}
/**
* @since 8/23/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: FileMedia.class.js,v 1.4 2005/09/12 21:44:16 adamfranco Exp $
*/
FileMedia.prototype = new Media();
FileMedia.prototype.constructor = FileMedia;
FileMedia.superclass = Media.prototype;
/**
* The media class represents a media file in a slide.
*
* @since 8/23/05
* @package viewer.js_library
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: FileMedia.class.js,v 1.4 2005/09/12 21:44:16 adamfranco Exp $
*/
function FileMedia ( viewerElementId, mediaXMLNode) {
if ( arguments.length > 0 ) {
this.init( viewerElementId, mediaXMLNode );
}
}
/**
* initialize our object. Necessary for proper inheritance to work.
*
* @param object Node mediaXMLNode
* @return void
* @access public
* @since 8/26/05
*/
FileMedia.prototype.init = function ( viewerElementId, mediaXMLNode) {
FileMedia.superclass.init.call(this, viewerElementId, mediaXMLNode);
}
/**
* Answer true if this media class supports the node passed
*
* @param object Element xmlNode
* @return boolean
* @access public
* @since 9/12/05
*/
FileMedia.prototype.supportsNode = function (xmlNode) {
return true;
}/**
* Run our slideshow
*
* @access public
* @since 8/22/05
*/
function runSlideShow (slideshowXML) {
slideShow = new SlideShow();
slideShow.loadXMLDoc(slideshowXML);
}
/**
* Answer the element of the document by id.
*
* @param string id
* @return object The html element
* @access public
* @since 8/25/05
*/
function getElementFromDocument(id) {
// Gecko, KHTML, Opera, IE6+
if (document.getElementById) {
return document.getElementById(id);
}
// IE 4-5
if (document.all) {
return document.all[id];
}
}
/**
* Answer an array only the unique elements of the input array
*
* @param array inputArray
* @return array
* @access public
* @since 8/24/05
*/
function arrayUnique ( inputArray ) {
var uniqueArray = new Array();
var i = 0;
for (var j = 0; j < inputArray.length; j++) {
if (!inArray(inputArray[j], uniqueArray)) {
uniqueArray[i] = inputArray[j];
i++;
}
}
return uniqueArray;
}
/**
* Answer true if the value passed is in the array
*
* @param mixed value
* @param array array
* @return boolean
* @access public
* @since 8/24/05
*/
function inArray ( value, array ) {
for (var i = 0; i < array.length; i++) {
if (array[i] == value)
return true;
}
return false;
}
/**
* Answer the pixel height of the specified element if availible.
*
* @param string elementId
* @return string
* @access public
* @since 8/25/05
*/
function getElementHeight (elementId) {
var element = getElementFromDocument(elementId);
if (element == null || element.style.height == null)
alert("Unknown height for element, '" + elementId + "'");
return pixelsToInteger(element.style.height);
}
/**
* Answer the pixel width of the specified element if availible.
*
* @param string elementId
* @return string
* @access public
* @since 8/25/05
*/
function getElementWidth (elementId) {
var element = getElementFromDocument(elementId);
if (element == null || element.style.width ==null)
alert("Unknown width for element, '" + elementId + "'");
return pixelsToInteger(element.style.width);
}
/**
* Answer the integer that corresponds tho the given pixel value.
* strip of the 'px' component of the string.
*
* @param string pixelString
* @return integer
* @access public
* @since 8/25/05
*/
function pixelsToInteger (pixelString) {
var sizeRegEx = new RegExp("^([0-9\.]+)(px)?$", "i");
var sizeString = new String (pixelString);
var matches = sizeString.match(sizeRegEx);
if (matches)
return new Number(matches[1]);
else
return 0;
}
/**
* Inspect an object in a popup window
*
* @param object object
* @return void
* @access public
* @since 5/23/06
*/
function inspect (object) {
var temp = "\nInspecting: " + object.constructor.toString() + "
";
temp += "\n";
for (x in object)
temp += "\n\t\n\t\t\n\t\t\n\t";
temp += "\n" + x + " | " + object[x] + " |