From 98e3ca9cdb38280225f8c166f09630977ad512fd Mon Sep 17 00:00:00 2001 From: John Flatness Date: Tue, 5 Jan 2016 17:05:43 -0500 Subject: [PATCH 1/3] Use HTML 5 for video --- application/views/helpers/FileMarkup.php | 55 +++++++++++------------- 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/application/views/helpers/FileMarkup.php b/application/views/helpers/FileMarkup.php index 7bca17467b..11f4c003f5 100644 --- a/application/views/helpers/FileMarkup.php +++ b/application/views/helpers/FileMarkup.php @@ -51,10 +51,10 @@ class Omeka_View_Helper_FileMarkup extends Zend_View_Helper_Abstract 'audio/x-mp4' => 'audio', 'audio/wav' => 'audio', 'audio/x-wav' => 'audio', - 'video/mp4' => 'mov', - 'video/mpeg' => 'mov', - 'video/ogg' => 'mov', - 'video/quicktime' => 'mov', + 'video/mp4' => 'video', + 'video/ogg' => 'video', + 'video/webm' => 'video', + 'video/quicktime' => 'video', 'audio/wma' => 'wma', 'audio/x-ms-wma' => 'wma', 'video/avi' => 'wmv', @@ -96,20 +96,15 @@ class Omeka_View_Helper_FileMarkup extends Zend_View_Helper_Abstract // audio/x-wav 'wav' => 'audio', // video/mp4 - 'mp4' => 'mov', - 'mp4v' => 'mov', - 'mpg4' => 'mov', - // video/mpeg - 'mpeg' => 'mov', - 'mpg' => 'mov', - 'mpe' => 'mov', - 'm1v' => 'mov', - 'm2v' => 'mov', + 'mp4' => 'video', + 'mp4v' => 'video', + 'mpg4' => 'video', // video/ogg - 'ogv' => 'mov', + 'ogv' => 'video', + // video/webm + 'webm' => 'video', // video/quicktime - 'qt' => 'mov', - 'mov' => 'mov', + 'mov' => 'video', // audio/x-ms-wma 'wma' => 'wma', // video/x-msvideo @@ -151,7 +146,7 @@ class Omeka_View_Helper_FileMarkup extends Zend_View_Helper_Abstract 'ShowDisplay'=> 0, 'ShowStatusBar' => 0 ), - 'mov'=>array( + 'video'=>array( 'width' => '320', 'height' => '240', 'autoplay' => false, @@ -423,18 +418,9 @@ public function wma($file, array $options=array()) * width, height, autoplay, controller, loop * @return string */ - public function mov($file, array $options=array()) + public function video($file, array $options=array()) { - $path = html_escape($file->getWebPath('original')); - $html = '' - . '' - . '' - . '' - . '' - . '' - . '' - . ''; - return $html; + return $this->_media('video', $file, $options); } /** @@ -447,18 +433,27 @@ public function mov($file, array $options=array()) */ public function audio($file, array $options) { + return $this->_media('audio', $file, $options); + } + + protected function _media($type, $file, array $options) + { + if ($type !== 'audio' && $type !== 'video') { + $type = 'video'; + } $url = $file->getWebPath('original'); $escapedUrl = html_escape($url); $attrs = array( 'src' => $url, + 'class' => 'omeka-media', 'width' => $options['width'], 'height' => $options['height'], 'controls' => (bool) $options['controller'], 'autoplay' => (bool) $options['autoplay'], 'loop' => (bool) $options['loop'], ); - $html = ''; return $html; } From 2f0d2abace88a0b8c2290e2013043dfc55e451b7 Mon Sep 17 00:00:00 2001 From: John Flatness Date: Tue, 5 Jan 2016 17:10:13 -0500 Subject: [PATCH 2/3] Move public global JS functions out of doc.ready --- .../views/scripts/javascripts/globals.js | 117 +++++++++--------- 1 file changed, 59 insertions(+), 58 deletions(-) diff --git a/application/views/scripts/javascripts/globals.js b/application/views/scripts/javascripts/globals.js index 1dffc72fdb..01b6590789 100644 --- a/application/views/scripts/javascripts/globals.js +++ b/application/views/scripts/javascripts/globals.js @@ -3,68 +3,69 @@ if (!Omeka) { } (function($) { - $(document).ready(function () { - - // Skip to content - Omeka.skipNav = function() { - $("#skipnav").click(function() { - $("#content").focus() - }); - }; - - // Show advanced options for site-wide search. - Omeka.showAdvancedForm = function () { - var advanced_form = $('#advanced-form'); - var show_advanced = 'Advanced Search'; - var search_submit = $('#search-form button'); - - // Set up classes and DOM elements jQuery will use. - if (advanced_form.length > 0) { - $('#search-container').addClass('with-advanced'); - advanced_form.addClass('closed').before(show_advanced); - } - - $('.show-advanced').click(function(e) { - e.preventDefault(); - advanced_form.toggleClass('open').toggleClass('closed'); - }); + // Skip to content + Omeka.skipNav = function() { + $("#skipnav").click(function() { + $("#content").focus() + }); + }; + + // Show advanced options for site-wide search. + Omeka.showAdvancedForm = function () { + var advanced_form = $('#advanced-form'); + var show_advanced = 'Advanced Search'; + var search_submit = $('#search-form button'); + + // Set up classes and DOM elements jQuery will use. + if (advanced_form.length > 0) { + $('#search-container').addClass('with-advanced'); + advanced_form.addClass('closed').before(show_advanced); + } + + $('.show-advanced').click(function(e) { + e.preventDefault(); + advanced_form.toggleClass('open').toggleClass('closed'); + }); + }; + + Omeka.megaMenu = function (menuSelector, customMenuOptions) { + if (typeof menuSelector === 'undefined') { + menuSelector = '#primary-nav'; + } + + var menuOptions = { + /* prefix for generated unique id attributes, which are required + to indicate aria-owns, aria-controls and aria-labelledby */ + uuidPrefix: "accessible-megamenu", + + /* css class used to define the megamenu styling */ + menuClass: "nav-menu", + + /* css class for a top-level navigation item in the megamenu */ + topNavItemClass: "nav-item", + + /* css class for a megamenu panel */ + panelClass: "sub-nav", + + /* css class for a group of items within a megamenu panel */ + panelGroupClass: "sub-nav-group", + + /* css class for the hover state */ + hoverClass: "hover", + + /* css class for the focus state */ + focusClass: "focus", + + /* css class for the open state */ + openClass: "open" }; - Omeka.megaMenu = function (menuSelector, customMenuOptions) { - if (typeof menuSelector === 'undefined') { - menuSelector = '#primary-nav'; - } - - var menuOptions = { - /* prefix for generated unique id attributes, which are required - to indicate aria-owns, aria-controls and aria-labelledby */ - uuidPrefix: "accessible-megamenu", - - /* css class used to define the megamenu styling */ - menuClass: "nav-menu", - - /* css class for a top-level navigation item in the megamenu */ - topNavItemClass: "nav-item", + $.extend(menuOptions, customMenuOptions); - /* css class for a megamenu panel */ - panelClass: "sub-nav", + $(menuSelector).accessibleMegaMenu(menuOptions); + }; - /* css class for a group of items within a megamenu panel */ - panelGroupClass: "sub-nav-group", - - /* css class for the hover state */ - hoverClass: "hover", - - /* css class for the focus state */ - focusClass: "focus", - - /* css class for the open state */ - openClass: "open" - }; - - $.extend(menuOptions, customMenuOptions); + $(document).ready(function () { - $(menuSelector).accessibleMegaMenu(menuOptions); - }; }); })(jQuery); From e707c22e29b08ca6a4456a7ec8830a8baebb44e0 Mon Sep 17 00:00:00 2001 From: John Flatness Date: Tue, 5 Jan 2016 17:11:03 -0500 Subject: [PATCH 3/3] Add JS for fallback to plain link for media --- admin/themes/default/javascripts/globals.js | 13 ++++++++++++- application/views/scripts/javascripts/globals.js | 8 +++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/admin/themes/default/javascripts/globals.js b/admin/themes/default/javascripts/globals.js index a506eee31d..4d05b5f900 100644 --- a/admin/themes/default/javascripts/globals.js +++ b/admin/themes/default/javascripts/globals.js @@ -131,11 +131,22 @@ if (!Omeka) { } }; + Omeka.mediaFallback = function () { + $('.omeka-media').on('error', function () { + if (this.networkState === HTMLMediaElement.NETWORK_NO_SOURCE || + this.networkState === HTMLMediaElement.NETWORK_EMPTY + ) { + $(this).replaceWith(this.innerHTML); + } + }); + }; + Omeka.readyCallbacks = [ [Omeka.deleteConfirm, null], [Omeka.saveScroll, null], [Omeka.stickyNav, null], [Omeka.showAdvancedForm, null], - [Omeka.skipNav, null] + [Omeka.skipNav, null], + [Omeka.mediaFallback, null] ]; })(jQuery); diff --git a/application/views/scripts/javascripts/globals.js b/application/views/scripts/javascripts/globals.js index 01b6590789..261e2c8fd1 100644 --- a/application/views/scripts/javascripts/globals.js +++ b/application/views/scripts/javascripts/globals.js @@ -66,6 +66,12 @@ if (!Omeka) { }; $(document).ready(function () { - + $('.omeka-media').on('error', function () { + if (this.networkState === HTMLMediaElement.NETWORK_NO_SOURCE || + this.networkState === HTMLMediaElement.NETWORK_EMPTY + ) { + $(this).replaceWith(this.innerHTML); + } + }); }); })(jQuery);