function mediafront_views_pre_render in MediaFront 7.2
Same name and namespace in other branches
- 6.2 mediafront.module \mediafront_views_pre_render()
- 6 mediafront.module \mediafront_views_pre_render()
- 7 mediafront.module \mediafront_views_pre_render()
Implementation of hook_views_pre_render().
Parameters
$view:
File
- views/
mediafront.views.inc, line 98 - mediafront.views.inc Built in plugins for Views output handling.
Code
function mediafront_views_pre_render(&$view) {
// Determine if any field wishes to link to the media player.
foreach ($view->field as $name => &$field) {
$options = mediafront_views_get_options($field);
if (!empty($options['link_to_player'])) {
if (empty($view->mediafront_id)) {
$view->mediafront_id = mediafront_views_get_id($view);
}
$field->options['element_class'] .= " mediafront-views-field";
$field->options['element_wrapper_class'] .= " mediafront-views-field";
drupal_add_js('
(function($) {
$(document).ready(function() {
$(".views-field-' . drupal_clean_css_identifier($name) . '.mediafront-views-field").each(function(index, element) {
var eventData = {index:index, view: "' . $view->name . '", id: "' . $view->mediafront_id . '"};
$(element).click(function(event) {
event.preventDefault();
$(this).trigger("mediafront-view-loaded", eventData);
minplayer.get("' . $view->mediafront_id . '", "playlist", function(playlist) {
playlist.loadItem(index, true);
});
});
// Trigger the load for the first item.
if (index == 0) {
$(element).trigger("mediafront-view-loaded", eventData);
}
});
});
})(jQuery);
', 'inline');
}
}
}