function _sheetnode_inject in Sheetnode 6
Same name and namespace in other branches
- 5 sheetnode.module \_sheetnode_inject()
- 7.2 sheetnode.module \_sheetnode_inject()
- 7 sheetnode.module \_sheetnode_inject()
Helper function to inject Sheetnode JavaScript.
5 calls to _sheetnode_inject()
- sheetnode_form in ./
sheetnode.module - Implementation of hook_form().
- sheetnode_validate in ./
sheetnode.module - Implementation of hook_validate().
- sheetnode_view in ./
sheetnode.module - Implementation of hook_view().
- theme_sheetnode_formatter_default in ./
sheetnode.module - Theme function for sheetfield default formatter.
- _sheetfield_spreadsheet_process in ./
sheetnode.module - Process function for sheetfield_spreadsheet element.
File
- ./
sheetnode.module, line 203
Code
function _sheetnode_inject($sheet_id, $sheet_aliases, $value, $save_element, $context, $ahah = FALSE) {
$path = drupal_get_path('module', 'sheetnode');
drupal_add_js($path . '/socialcalc/socialcalcconstants.js');
drupal_add_js($path . '/socialcalc/socialcalc-3.js');
drupal_add_js($path . '/socialcalc/socialcalctableeditor.js');
drupal_add_js($path . '/socialcalc/formatnumber2.js');
drupal_add_js($path . '/socialcalc/formula1.js');
drupal_add_js($path . '/socialcalc/socialcalcpopup.js');
drupal_add_js($path . '/socialcalc/socialcalcspreadsheetcontrol.js');
drupal_add_js($path . '/socialcalc/socialcalcviewer.js');
drupal_add_js($path . '/sheetnode.js');
drupal_add_css($path . '/socialcalc/socialcalc.css');
drupal_add_css($path . '/sheetnode.css');
// Allow other modules to add their own JS/CSS.
module_invoke_all('sheetnode_plugins', $value, $save_element, $context, $ahah);
// Lower-case sheet aliases.
$sheet_aliases = array_map('strtolower', (array) $sheet_aliases);
if ($ahah) {
static $settings = NULL;
$settings['sheetnode'][$sheet_id] = array(
'aliases' => $sheet_aliases,
'value' => $value,
'imagePrefix' => base_path() . $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,
);
$js_settings = drupal_to_js($settings);
return <<<EOS
<script language="javascript" type="text/javascript">
Drupal.behaviors.sheetnodeAHAH = function(context) {
jQuery.extend(Drupal.settings, {<span class="php-variable">$js_settings</span>});
Drupal.behaviors.sheetnode(context);
}
</script>
<div class="sheetview" id="{<span class="php-variable">$sheet_id</span>}"></div>
EOS;
}
else {
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() . $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>';
}
}