function content_lock_js in Content locking (anti-concurrent editing) 7.3
Load module javascript.
1 call to content_lock_js()
- content_lock_node_ajax_callback in includes/
content_lock.ajax.inc - AJAX callback to lock a node manually.
1 string reference to 'content_lock_js'
- content_lock_form_alter in ./
content_lock.module - Implements hook_form_alter().
File
- ./
content_lock.module, line 609
Code
function content_lock_js($form, $form_state = array()) {
if (variable_get('content_lock_unload_js', TRUE)) {
// Add content_lock javascript.
$path = drupal_get_path('module', 'content_lock');
drupal_add_js($path . '/js/content_lock.url.js', array(
'group' => JS_LIBRARY,
));
drupal_add_js($path . '/js/content_lock.core.js', array(
'group' => JS_LIBRARY,
));
drupal_add_js($path . '/js/content_lock.init.js', array(
'group' => JS_DEFAULT,
'weight' => 100,
));
$nid = empty($form['nid']['#value']) ? NULL : $form['nid']['#value'];
$internal_urls = array();
$internal_form_selectors = array();
// We're on a locked revision reversion page.
if (!empty($form['#node_revision']->nid)) {
$nid = $form['#node_revision']->nid;
// Don't ask the user if he wants to leave the page when
// cancelling a reversion.
$internal_urls[] = $form['actions']['cancel']['#href'];
$internal_form_selectors[] = '.confirmation';
}
$internal_urls[] = 'node/' . $nid . '/edit';
$internal_form_selectors[] = 'form.node-form';
// Check lock status.
$lock = content_lock_fetch_lock($nid);
if ($lock) {
$lock_ajax_key = $lock->ajax_key;
}
else {
$lock_ajax_key = FALSE;
}
// Get tokens.
$token = content_lock_get_release_token($nid);
// Prepare settings.
$settings = array(
'nid' => $nid,
'ajax_key' => $lock_ajax_key,
'token' => $token,
'unload_js_message_enable' => variable_get('content_lock_unload_js_message_enable', TRUE),
'internal_urls' => implode('|', $internal_urls),
'internal_forms' => implode(', ', $internal_form_selectors),
);
if ($settings['unload_js_message_enable']) {
$settings['unload_js_message'] = variable_get('content_lock_unload_js_message', 'If you proceed, ALL of your changes will be lost.');
}
drupal_add_js(array(
'content_lock' => $settings,
), 'setting');
}
return $form;
}