You are here

function fivestar_add_js in Fivestar 6.2

Same name and namespace in other branches
  1. 5 fivestar.module \fivestar_add_js()
  2. 6 fivestar.module \fivestar_add_js()

Add necessary JS files and settings to render the fivestar widget.

1 call to fivestar_add_js()
fivestar_init in ./fivestar.module
Implementation of hook_init().

File

./fivestar.module, line 1191
A simple n-star voting widget, usable in other forms.

Code

function fivestar_add_js() {
  static $js_added = FALSE;

  // Add necessary javascript only once per page.
  if (!$js_added) {
    $settings = array(
      'titleUser' => t('Your rating') . ': ',
      'titleAverage' => t('Average') . ': ',
      'feedbackSavingVote' => t('Saving your vote...'),
      'feedbackVoteSaved' => t('Your vote has been saved.'),
      'feedbackDeletingVote' => t('Deleting your vote...'),
      'feedbackVoteDeleted' => t('Your vote has been deleted.'),
    );
    drupal_add_js(drupal_get_path('module', 'fivestar') . '/js/fivestar.js');
    drupal_add_js(array(
      'fivestar' => $settings,
    ), 'setting');
    $js_added = TRUE;
  }
}