You are here

function sheetnode_plugin_style::render_ajax in Sheetnode 6

2 calls to sheetnode_plugin_style::render_ajax()
sheetnode_plugin_style::options_form in views/sheetnode_plugin_style.inc
sheetnode_plugin_style::render in views/sheetnode_plugin_style.inc

File

views/sheetnode_plugin_style.inc, line 396

Class

sheetnode_plugin_style

Code

function render_ajax($value, $save_element) {
  $sheet_id = 'sheetview-' . str_replace('_', '-', $this->view->name);
  if (!empty($this->view->live_preview)) {
    $sheet_id .= '-preview';
  }
  $settings = drupal_to_js(array(
    'sheetnode' => array(
      $sheet_id => array(
        'aliases' => array(
          $this->view->name,
        ),
        'value' => $value,
        'imagePrefix' => base_path() . drupal_get_path('module', 'sheetnode') . '/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' => array(
          'entity-type' => 'view',
          'oid' => $this->view->name,
        ),
      ),
    ),
  ));
  return <<<EOS
<div class="sheetview" id="{<span class="php-variable">$sheet_id</span>}">
<script language="javascript" type="text/javascript">
  Drupal.behaviors.sheetview = function(context) {
    jQuery.extend(Drupal.settings, {<span class="php-variable">$settings</span>});
    Drupal.behaviors.sheetnode(context);
  }
</script>
</div>
EOS;
}