function opening_hours_js_attach_admin in Opening hours 7
Admin-specific attachments.
2 calls to opening_hours_js_attach_admin()
- opening_hours_add_js in ./
opening_hours.module - Helper function to load our JavaScript dependencies.
- opening_hours_node_edit_page in includes/
opening_hours.pages.inc - Page for editing the opening hours for a specific node.
File
- ./
opening_hours.module, line 591 - Opening hours module.
Code
function opening_hours_js_attach_admin($nid) {
$attachments =& drupal_static(__FUNCTION__ . ':' . $nid);
if (empty($attachments)) {
$path = drupal_get_path('module', 'opening_hours') . '/js/';
$attachments = opening_hours_js_attach_common();
// A bit of extra styling.
drupal_add_library('system', 'ui.datepicker');
drupal_add_library('system', 'ui.dialog');
$attachments['css'][] = drupal_get_path('module', 'opening_hours') . '/css/opening_hours.admin.css';
// We need the dialog library.
$attachments['library'][] = array(
'system',
'ui.dialog',
);
$attachments['js'][] = array(
// Use the minified version of Backbone when JS aggregation is enabled.
'data' => variable_get('preprocess_js', FALSE) ? $path . 'backbone-min.js' : $path . 'backbone.js',
'type' => 'file',
'group' => JS_LIBRARY,
);
$attachments['js'][] = $path . 'opening_hours.models.js';
$attachments['js'][] = $path . 'opening_hours.collections.js';
$attachments['js'][] = $path . 'opening_hours.views.js';
$attachments['js'][] = $path . 'opening_hours.routers.js';
$attachments['js'][] = $path . 'opening_hours.admin.js';
// For the admin page, we need the node ID, passed from the page callback.
$attachments['js'][0]['data']['OpeningHours'] += array(
'nid' => $nid,
'path' => base_path() . drupal_get_path('module', 'opening_hours'),
);
}
return $attachments;
}