Fixed S5 output for Safari

Safari can now receive S5 slideshows as real XHTML.
This commit is contained in:
Jacques Distler 2007-07-27 13:47:19 -05:00
parent b42a4c5fec
commit dbed460843
2 changed files with 34 additions and 18 deletions

View file

@ -152,8 +152,7 @@ class ApplicationController < ActionController::Base
elsif %w(tex).include?(action_name) elsif %w(tex).include?(action_name)
response.headers['Content-Type'] = 'text/plain; charset=UTF-8' response.headers['Content-Type'] = 'text/plain; charset=UTF-8'
elsif request.env['HTTP_USER_AGENT'] =~ /Validator/ or request.env.include?('HTTP_ACCEPT') && elsif request.env['HTTP_USER_AGENT'] =~ /Validator/ or request.env.include?('HTTP_ACCEPT') &&
Mime::Type.parse(request.env["HTTP_ACCEPT"]).include?(Mime::XHTML) && Mime::Type.parse(request.env["HTTP_ACCEPT"]).include?(Mime::XHTML)
!(request.env['HTTP_USER_AGENT'] =~ /Safari/ and %w(s5).include?(action_name))
response.headers['Content-Type'] = 'application/xhtml+xml; charset=UTF-8' response.headers['Content-Type'] = 'application/xhtml+xml; charset=UTF-8'
elsif request.env['HTTP_USER_AGENT'] =~ /MathPlayer/ elsif request.env['HTTP_USER_AGENT'] =~ /MathPlayer/
response.headers['Content-Type'] = 'application/xhtml+xml' response.headers['Content-Type'] = 'application/xhtml+xml'

View file

@ -1,4 +1,5 @@
// S5 v1.2a1 slides.js -- released into the Public Domain // S5 v1.2a2 slides.js -- released into the Public Domain
// Many modifications by Jacques Distler to allow operation as real XHTML.
// //
// Please see http://www.meyerweb.com/eric/tools/s5/credits.html for information // Please see http://www.meyerweb.com/eric/tools/s5/credits.html for information
// about all the wonderful and talented contributors to this code! // about all the wonderful and talented contributors to this code!
@ -30,6 +31,7 @@ var countdown = {
var isIE = navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.indexOf('Opera') < 1 ? 1 : 0; var isIE = navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.indexOf('Opera') < 1 ? 1 : 0;
var isOp = navigator.userAgent.indexOf('Opera') > -1 ? 1 : 0; var isOp = navigator.userAgent.indexOf('Opera') > -1 ? 1 : 0;
var isSa = navigator.userAgent.indexOf('Safari') > -1 ? 1 : 0;
var isGe = navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('Safari') < 1 ? 1 : 0; var isGe = navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('Safari') < 1 ? 1 : 0;
function hasClass(object, className) { function hasClass(object, className) {
@ -111,8 +113,15 @@ function slideLabel() {
for (var o = 0; o < menunodes.length; o++) { for (var o = 0; o < menunodes.length; o++) {
otext += nodeValue(menunodes[o]); otext += nodeValue(menunodes[o]);
} }
if (isSa) {
var option = createElement('option');
option.setAttribute('value', n);
option.appendChild(document.createTextNode(n + ' : ' + otext) );
list.appendChild(option);
} else {
list.options[list.length] = new Option(n + ' : ' + otext, n); list.options[list.length] = new Option(n + ' : ' + otext, n);
} }
}
} }
function currentSlide() { function currentSlide() {
@ -122,12 +131,12 @@ function currentSlide() {
} else { } else {
cs = document.currentSlide; cs = document.currentSlide;
} }
var plink = document.createElement('a'); var plink = createElement('a');
plink.id = 'plink'; plink.id = 'plink';
plink.setAttribute('href', ''); plink.setAttribute('href', '');
var csHere = document.createElement('span'); var csHere = createElement('span');
var csSep = document.createElement('span'); var csSep = createElement('span');
var csTotal = document.createElement('span'); var csTotal = createElement('span');
csHere.id = 'csHere'; csHere.id = 'csHere';
csSep.id = 'csSep'; csSep.id = 'csSep';
csTotal.id = 'csTotal'; csTotal.id = 'csTotal';
@ -376,7 +385,7 @@ function slideJump() {
function fixLinks() { function fixLinks() {
var thisUri = window.location.href; var thisUri = window.location.href;
thisUri = thisUri.slice(0, thisUri.length - window.location.hash.length); thisUri = thisUri.slice(0, thisUri.length - window.location.hash.length);
var aelements = document.getElementsByTagName('A'); var aelements = document.getElementsByTagName('a');
for (var i = 0; i < aelements.length; i++) { for (var i = 0; i < aelements.length; i++) {
var a = aelements[i].href; var a = aelements[i].href;
var slideID = a.match('\#slide[0-9]{1,2}'); var slideID = a.match('\#slide[0-9]{1,2}');
@ -418,43 +427,43 @@ function permaLink() {
function createControls() { function createControls() {
var controlsDiv = document.getElementById("controls"); var controlsDiv = document.getElementById("controls");
if (!controlsDiv) return; if (!controlsDiv) return;
var controlForm = document.createElement('form'); var controlForm = createElement('form');
controlForm.id = 'controlForm'; controlForm.id = 'controlForm';
controlForm.setAttribute('action', '#'); controlForm.setAttribute('action', '#');
if (controlVis == 'hidden') { if (controlVis == 'hidden') {
controlForm.setAttribute('onmouseover', 'showHide(\'s\');'); controlForm.setAttribute('onmouseover', 'showHide(\'s\');');
controlForm.setAttribute('onmouseout', 'showHide(\'h\');'); controlForm.setAttribute('onmouseout', 'showHide(\'h\');');
} }
var navLinks = document.createElement('div'); var navLinks = createElement('div');
navLinks.id = 'navLinks'; navLinks.id = 'navLinks';
var showNotes = document.createElement('a'); var showNotes = createElement('a');
showNotes.id = 'show-notes'; showNotes.id = 'show-notes';
showNotes.setAttribute('accesskey', 'n'); showNotes.setAttribute('accesskey', 'n');
showNotes.setAttribute('href', 'javascript:createNotesWindow();'); showNotes.setAttribute('href', 'javascript:createNotesWindow();');
showNotes.setAttribute('title', 'Show Notes'); showNotes.setAttribute('title', 'Show Notes');
showNotes.appendChild(document.createTextNode('\u2261')); showNotes.appendChild(document.createTextNode('\u2261'));
var toggle = document.createElement('a'); var toggle = createElement('a');
toggle.id = 'toggle'; toggle.id = 'toggle';
toggle.setAttribute('accesskey', 't'); toggle.setAttribute('accesskey', 't');
toggle.setAttribute('href', 'javascript:toggle();'); toggle.setAttribute('href', 'javascript:toggle();');
toggle.appendChild(document.createTextNode('\u00D8')); toggle.appendChild(document.createTextNode('\u00D8'));
var prev = document.createElement('a'); var prev = createElement('a');
prev.id = 'prev'; prev.id = 'prev';
prev.setAttribute('accesskey', 'z'); prev.setAttribute('accesskey', 'z');
prev.setAttribute('href', 'javascript:go(-1);'); prev.setAttribute('href', 'javascript:go(-1);');
prev.appendChild(document.createTextNode('\u00AB')); prev.appendChild(document.createTextNode('\u00AB'));
var next = document.createElement('a'); var next = createElement('a');
next.id = 'next'; next.id = 'next';
next.setAttribute('accesskey', 'x'); next.setAttribute('accesskey', 'x');
next.setAttribute('href', 'javascript:go(1);'); next.setAttribute('href', 'javascript:go(1);');
next.appendChild(document.createTextNode('\u00BB')); next.appendChild(document.createTextNode('\u00BB'));
var navList = document.createElement('div'); var navList = createElement('div');
navList.id = 'navList'; navList.id = 'navList';
if (controlVis != 'hidden') { if (controlVis != 'hidden') {
navList.setAttribute('onmouseover', 'showHide(\'s\');'); navList.setAttribute('onmouseover', 'showHide(\'s\');');
navList.setAttribute('onmouseout', 'showHide(\'h\');'); navList.setAttribute('onmouseout', 'showHide(\'h\');');
} }
var jumplist = document.createElement('select'); var jumplist = createElement('select');
jumplist.id = 'jumplist'; jumplist.id = 'jumplist';
jumplist.setAttribute('onchange', 'go(\'j\');'); jumplist.setAttribute('onchange', 'go(\'j\');');
navList.appendChild(jumplist); navList.appendChild(jumplist);
@ -503,7 +512,7 @@ function fontScale() { // causes layout problems in FireFox that get fixed if b
function fontSize(value) { function fontSize(value) {
if (!(s5ss = document.getElementById('s5ss'))) { if (!(s5ss = document.getElementById('s5ss'))) {
if (!document.createStyleSheet) { if (!document.createStyleSheet) {
document.getElementsByTagName('head')[0].appendChild(s5ss = document.createElement('style')); document.getElementsByTagName('head')[0].appendChild(s5ss = createElement('style'));
s5ss.setAttribute('media','screen, projection'); s5ss.setAttribute('media','screen, projection');
s5ss.setAttribute('id','s5ss'); s5ss.setAttribute('id','s5ss');
} else { } else {
@ -784,6 +793,14 @@ function readTime(val) {
} }
} }
function createElement(element) {
if (typeof document.createElementNS != 'undefined') {
return document.createElementNS('http://www.w3.org/1999/xhtml', element);
} else {
return document.createElement(element);
}
}
function windowChange() { function windowChange() {
fontScale(); fontScale();
} }