Browse Source

Merge pull request #527 from jordandukart/7.x-METRO-53

Make print not add JS and instead be a tab.
pull/530/head
Adam 11 years ago
parent
commit
f1d6100d14
  1. 49
      islandora.module
  2. 18
      js/add_print.js

49
islandora.module

@ -142,9 +142,11 @@ function islandora_menu() {
'access arguments' => array(ISLANDORA_VIEW_OBJECTS, 2),
);
$items['islandora/object/%islandora_object/print_object'] = array(
'title' => 'Print Object',
'weight' => 20,
'page callback' => 'islandora_printer_object',
'page arguments' => array(2),
'type' => MENU_NORMAL_ITEM,
'type' => MENU_LOCAL_TASK,
'access callback' => 'islandora_object_access',
'access arguments' => array(ISLANDORA_VIEW_OBJECTS, 2),
);
@ -1024,17 +1026,6 @@ function islandora_view_object(AbstractObject $object) {
module_load_include('inc', 'islandora', 'includes/breadcrumb');
module_load_include('inc', 'islandora', 'includes/utilities');
// Add the print button via JavaScript.
$path = drupal_get_path('module', 'islandora');
drupal_add_js(array(
'islandora' => array(
'print_img' => $path . '/images/print-icon.png'),
), array(
'type' => 'setting'));
drupal_add_js(array('islandora' => array('print_link' => 'islandora/object/' . $object->id . '/print_object')), array('type' => 'setting'));
drupal_add_js($path . '/js/add_print.js');
drupal_set_title($object->label);
drupal_set_breadcrumb(islandora_get_breadcrumbs($object));
@ -1929,3 +1920,37 @@ function islandora_find_package($package_name) {
function islandora_ingest_form_pre_submit($form, &$form_state) {
module_load_include('inc', 'islandora', 'includes/ingest.form');
}
/**
* Implements hook_menu_local_tasks_alter().
*/
function islandora_menu_local_tasks_alter(&$data, $router_item, $root_path) {
if (strpos($root_path, 'islandora/object/%') === 0) {
if (isset($data['tabs'][0]['output'])) {
foreach ($data['tabs'][0]['output'] as $key => &$tab) {
if ($tab['#link']['path'] == 'islandora/object/%/print_object') {
if ($root_path == 'islandora/object/%') {
$islandora_path = drupal_get_path('module', 'islandora');
$tab['#theme'] = 'link';
$tab['#text'] = theme('image', array(
'path' => "$islandora_path/images/print-icon.png",
'alt' => t('Print Object'),
'attributes' => array(
'id' => 'print_btn',
),
));
$tab['#path'] = "{$router_item['href']}/print_object";
$tab['#options'] = array(
'attributes' => array(),
'html' => TRUE,
);
}
else {
unset($data['tabs'][0]['output'][$key]);
break;
}
}
}
}
}
}

18
js/add_print.js

@ -1,18 +0,0 @@
/**
* @file
* JavaScript file responsable for the print button behaviour.
*
* The print button is added automatically to every view, as metadata
* can be printed from every object.
*
*/
(function ($) {
$(document).ready(function() {
$('.tabs .primary').append('<img id="print_btn" title="Print" src="' + Drupal.settings.basePath + Drupal.settings.islandora.print_img + '"></img>');
$('#print_btn').css("cursor","pointer");
$('#print_btn').click(function() {
window.location=Drupal.settings.basePath + Drupal.settings.islandora.print_link;
});
});
})(jQuery);
Loading…
Cancel
Save