You are here

function node_activeedit_elements in Javascript Tools 5

Implementation of hook_activeedit_elements().

File

activeedit/modules/node.inc, line 98

Code

function node_activeedit_elements($object = NULL) {
  $elements = array();
  $elements['node'] = array(
    '#selector' => 'div.node',
    '#target' => 'node/*/edit',
    '#id_field' => 'nid',
  );
  $elements['node']['node_title'] = array(
    '#title' => t('post title'),
    '#selector' => 'h2.title > a',
    '#submit_text' => t('Submit'),
    '#form' => array(
      'node_form' => array(
        array(
          'title',
        ),
      ),
    ),
    '#require' => 'title',
  );
  $elements['node']['node_body'] = array(
    '#title' => t('post body'),
    '#selector' => 'div.content',
    '#submit_text' => t('Submit'),
    '#form' => array(
      'node_form' => array(
        array(
          'body_filter',
        ),
      ),
    ),
    '#require' => 'body_filter',
  );

  // We generate content separately, on demand, to avoid unneeded processing.
  // Otherwise these calls would all be run on every page load.
  if (isset($_POST) && $_POST['activeedit_submit'] && ($key = $_REQUEST['activeedit_id'])) {
    $content = FALSE;
    switch ($key) {
      case 'node_title':
        $elements['node'][$key]['#content'] = $object->title;
        break;
      case 'node_body':
        $elements['node'][$key]['#content'] = $object->body;
        break;
    }
  }
  return $elements;
}