function fivestar_add_js in Fivestar 5
Same name and namespace in other branches
- 6.2 fivestar.module \fivestar_add_js()
- 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(). Not that this will cause Drupal to post a warning on the admin screen when agressive caching is activated. Like CCK, Fivestar's use of hook_init IS compatible with agressive caching, we just need a way to annouce that.
File
- ./
fivestar.module, line 1432 - 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;
}
}