function opening_hours_js_attach_common in Opening hours 7
Common JavaScript attachments.
Generates an array suitable for use with #attached. See http://shomeya.com/articles/getting-used-to-attached for details.
2 calls to opening_hours_js_attach_common()
- opening_hours_js_attach_admin in ./
opening_hours.module - Admin-specific attachments.
- opening_hours_js_attach_presentation in ./
opening_hours.module - Attachments for the presentation page.
File
- ./
opening_hours.module, line 557 - Opening hours module.
Code
function opening_hours_js_attach_common($nid = NULL) {
$attachments =& drupal_static(__FUNCTION__);
if (empty($attachments)) {
// Provide common JavaScript settings.
$attachments['js'][] = array(
'data' => array(
'OpeningHours' => opening_hours_js_settings($nid),
),
'type' => 'setting',
);
$path = drupal_get_path('module', 'opening_hours') . '/js/';
$attachments['js'][] = $path . 'opening_hours.prototype.js';
$attachments['js'][] = $path . 'opening_hours.core.js';
$attachments['js'][] = array(
// Use the minified version of Underscore when JS aggregation is enabled.
'data' => variable_get('preprocess_js', FALSE) ? $path . 'underscore-min.js' : $path . 'underscore.js',
'type' => 'file',
'group' => JS_LIBRARY,
);
// We need the datepicker plugin for formatting and selecting dates.
// TODO: Figure out if this can be loaded via attachments.
date_popup_add();
// Only return the attachments the first time, to avoid these files
// being added to the page twice, messing up the order.
return $attachments;
}
}