You are here

function _sheetnode_inject in Sheetnode 7.2

Same name and namespace in other branches
  1. 5 sheetnode.module \_sheetnode_inject()
  2. 6 sheetnode.module \_sheetnode_inject()
  3. 7 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 = libraries_get_path('socialcalc');
  $module_path = drupal_get_path('module', 'sheetnode');
  drupal_add_js($library_path . '/socialcalc.min.js', array(
    'weight' => 1,
  ));
  drupal_add_js($module_path . '/js/sheetnode.js', array(
    'weight' => 2,
  ));
  drupal_add_css($library_path . '/socialcalc.min.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 . '/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>';
}