Skip to content

Commit

Permalink
Merge branch 'media'
Browse files Browse the repository at this point in the history
  • Loading branch information
zerocrates committed Jan 8, 2016
2 parents 7da1f20 + e707c22 commit e4bbf59
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 89 deletions.
13 changes: 12 additions & 1 deletion admin/themes/default/javascripts/globals.js
Expand Up @@ -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);
55 changes: 25 additions & 30 deletions application/views/helpers/FileMarkup.php
Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="'.$options['width'].'" height="'.$options['height'].'">'
. '<param name="src" value="'.$path.'" />'
. '<param name="controller" value="'.($options['controller'] ? 'true' : 'false').'" />'
. '<param name="autoplay" value="'.($options['autoplay'] ? 'true' : 'false').'" />'
. '<param name="loop" value="'.($options['loop'] ? 'true' : 'false').'" />'
. '<param name="scale" value="' . $options['scale'] . '" />'
. '<embed src="'.$path.'" scale="' . $options['scale'] . '" width="'.$options['width'].'" height="'.$options['height'].'" controller="'.($options['controller'] ? 'true' : 'false').'" autoplay="'.($options['autoplay'] ? 'true' : 'false').'" pluginspage="http://www.apple.com/quicktime/download/" type="video/quicktime"></embed>'
. '</object>';
return $html;
return $this->_media('video', $file, $options);
}

/**
Expand All @@ -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 = '<audio ' . tag_attributes($attrs) . '>'
. '<a href="' . $escapedUrl . '">' . $escapedUrl . '</a>'
$html = '<' . $type . ' ' . tag_attributes($attrs) . '>'
. '<a href="' . $escapedUrl . '">' . metadata($file, 'display_title') . '</a>'
. '</audio>';
return $html;
}
Expand Down
123 changes: 65 additions & 58 deletions application/views/scripts/javascripts/globals.js
Expand Up @@ -3,68 +3,75 @@ if (!Omeka) {
}

(function($) {
$(document).ready(function () {

// Skip to content
Omeka.skipNav = function() {
$("#skipnav").click(function() {
$("#content").focus()
});
// 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 = '<a href="#" class="show-advanced button">Advanced Search</a>';
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"
};

// Show advanced options for site-wide search.
Omeka.showAdvancedForm = function () {
var advanced_form = $('#advanced-form');
var show_advanced = '<a href="#" class="show-advanced button">Advanced Search</a>';
var search_submit = $('#search-form button');
$.extend(menuOptions, customMenuOptions);

// 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');
});
};
$(menuSelector).accessibleMegaMenu(menuOptions);
};

Omeka.megaMenu = function (menuSelector, customMenuOptions) {
if (typeof menuSelector === 'undefined') {
menuSelector = '#primary-nav';
$(document).ready(function () {
$('.omeka-media').on('error', function () {
if (this.networkState === HTMLMediaElement.NETWORK_NO_SOURCE ||
this.networkState === HTMLMediaElement.NETWORK_EMPTY
) {
$(this).replaceWith(this.innerHTML);
}

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"
};

$.extend(menuOptions, customMenuOptions);

$(menuSelector).accessibleMegaMenu(menuOptions);
};
});
});
})(jQuery);

0 comments on commit e4bbf59

Please sign in to comment.