function activity_comments_add_js in Activity 7
Same name and namespace in other branches
- 6.2 activity_comments/activity_comments.module \activity_comments_add_js()
After build function to add the js to the page
2 string references to 'activity_comments_add_js'
- activity_comments_form in activity_comments/
activity_comments.module - Add comment form.
- activity_comments_insert_ajax_callback in activity_comments/
activity_comments.module
File
- activity_comments/
activity_comments.module, line 222 - Provides comment handling for activity messages
Code
function activity_comments_add_js($form, $form_state) {
static $js_added = FALSE;
// rebuild_info is an array of stuff for internal FAPI. It can be non-empty
// and $form_state['rebuild'] = FALSE. (i.e. when it is first submitted and
// being pulled from the form_cache. That is why this uses that as a check
// instead of $form_state['rebuild'].
if (!$js_added && empty($form_state['rebuild_info'])) {
// set the settings for the default text as well
$destination = drupal_get_destination();
drupal_add_js(array(
'activity_comments' => array(
'destination' => drupal_http_build_query($destination),
),
), array(
'type' => 'setting',
'scope' => JS_DEFAULT,
));
drupal_add_js(array(
'activity_comments' => array(
'default_text' => $form['activity_form_items']['activity_comment']['#default_value'],
),
), array(
'type' => 'setting',
'scope' => JS_DEFAULT,
));
$js_added = TRUE;
}
return $form;
}