| 7 js_example.module | js_example_js_weights() |
| 8 js_example.module | js_example_js_weights() |
js_example_weights implementation.
Related topics
1 string reference to 'js_example_js_weights'
File
- js_example/
js_example.module, line 48 - Examples showing how to use some of the new JavaScript features in Drupal 7.
Code
function js_example_js_weights() {
// Add some css to show which line is output by which script
drupal_add_css(drupal_get_path('module', 'js_example') . '/css/jsweights.css');
//
$weights = array(
'red' => 100,
'blue' => 23,
'green' => 3,
'brown' => 45,
'black' => 5,
'purple' => 60,
);
drupal_add_js(array('js_weights' => $weights), array('type' => 'setting'));
drupal_add_js(drupal_get_path('module', 'js_example') . '/js/red.js', array('weight' => $weights['red']));
drupal_add_js(drupal_get_path('module', 'js_example') . '/js/blue.js', array('weight' => $weights['blue']));
drupal_add_js(drupal_get_path('module', 'js_example') . '/js/green.js', array('weight' => $weights['green']));
drupal_add_js(drupal_get_path('module', 'js_example') . '/js/brown.js', array('weight' => $weights['brown']));
drupal_add_js(drupal_get_path('module', 'js_example') . '/js/black.js', array('weight' => $weights['black']));
drupal_add_js(drupal_get_path('module', 'js_example') . '/js/purple.js', array('weight' => $weights['purple']));
$output = '<div id="js-weights"></div>';
return $output;
}
Login or register to post comments