You are here

function _sheetnode_inject in Sheetnode 7

Same name and namespace in other branches
  1. 5 sheetnode.module \_sheetnode_inject()
  2. 6 sheetnode.module \_sheetnode_inject()
  3. 7.2 sheetnode.module \_sheetnode_inject()

Helper function to inject Sheetnode JavaScript.

7 calls to _sheetnode_inject()
sheetnode_field_formatter_view in ./sheetnode.module
Implements hook_field_formatter_view().
sheetnode_field_widget_form in ./sheetnode.module
Implements hook_field_widget_form().
sheetnode_form in ./sheetnode.module
Implements hook_form().
sheetnode_node_validate in ./sheetnode.module
Implements hook_node_validate().
sheetnode_validate in ./sheetnode.module
Implements hook_validate().

... See full list

File

./sheetnode.module, line 217
Module file for the sheetnode module.

Code

function _sheetnode_inject($sheet_id, $sheet_aliases, $value, $save_element, $context) {
  $library_path = drupal_get_path('module', 'sheetnode');
  $module_path = drupal_get_path('module', 'sheetnode');
  drupal_add_js($library_path . '/socialcalc/formatnumber2.js', array(
    'weight' => 1,
  ));
  drupal_add_js($library_path . '/socialcalc/formula1.js', array(
    'weight' => 2,
  ));
  drupal_add_js($library_path . '/socialcalc/socialcalcconstants.js', array(
    'weight' => 3,
  ));
  drupal_add_js($library_path . '/socialcalc/socialcalc-3.js', array(
    'weight' => 4,
  ));
  drupal_add_js($library_path . '/socialcalc/socialcalctableeditor.js', array(
    'weight' => 5,
  ));
  drupal_add_js($library_path . '/socialcalc/socialcalcpopup.js', array(
    'weight' => 6,
  ));
  drupal_add_js($library_path . '/socialcalc/socialcalcspreadsheetcontrol.js', array(
    'weight' => 7,
  ));
  drupal_add_js($library_path . '/socialcalc/socialcalcviewer.js', array(
    'weight' => 8,
  ));
  drupal_add_js($module_path . '/js/sheetnode.js', array(
    'weight' => 9,
  ));
  drupal_add_css($library_path . '/socialcalc/socialcalc.css');
  drupal_add_css($module_path . '/css/sheetnode.css');

  // Allow other modules to add their own JS/CSS.
  module_invoke_all('sheetnode_plugins', $value, $save_element, $context);

  // Lower-case sheet aliases.
  $sheet_aliases = array_map('strtolower', (array) $sheet_aliases);
  static $sheets = NULL;
  if (!isset($sheets[$sheet_id])) {
    drupal_add_js(array(
      'sheetnode' => array(
        $sheet_id => array(
          'aliases' => $sheet_aliases,
          'value' => $value,
          'imagePrefix' => base_path() . $library_path . '/socialcalc/images/sc-',
          'containerElement' => $sheet_id,
          'saveElement' => $save_element,
          'viewMode' => variable_get('sheetnode_view_mode', SHEETNODE_VIEW_FIDDLE),
          'showToolbar' => variable_get('sheetnode_view_toolbar', FALSE),
          'permissions' => array(
            'edit sheetnode settings' => user_access('edit sheetnode settings'),
          ),
          'context' => $context,
        ),
      ),
    ), 'setting');
    $sheets[$sheet_id] = TRUE;
  }
  return '<div class="sheetview" id="' . $sheet_id . '"></div>';
}