diff --git a/panels_ipe/js/panels_ipe.js b/panels_ipe/js/panels_ipe.js index e83ddf295c38e820a1d40bfbe7eed1a720790471..ef4a641500e349c7c3f0289757f9dd79edb5dee0 100644 --- a/panels_ipe/js/panels_ipe.js +++ b/panels_ipe/js/panels_ipe.js @@ -110,8 +110,9 @@ function DrupalPanelsIPE(cache_key, cfg) { }); // Perform visual effects in a particular sequence. - ipe.initButton.css('position', 'absolute'); - ipe.initButton.fadeOut('normal'); +// ipe.initButton.css('position', 'absolute'); + $('div.panels-ipe-off').fadeOut('normal'); +// ipe.initButton.fadeOut('normal'); $('.panels-ipe-on').show('normal'); // $('.panels-ipe-on').fadeIn('normal'); ipe.topParent.addClass('panels-ipe-editing'); @@ -124,7 +125,7 @@ function DrupalPanelsIPE(cache_key, cfg) { // Re-hide all the IPE meta-elements $('div.panels-ipe-on').hide('fast'); - ipe.initButton.css('position', 'static'); +// ipe.initButton.css('position', 'static'); ipe.topParent.removeClass('panels-ipe-editing'); $('div.panels-ipe-sort-container', ipe.topParent).sortable("destroy"); }; diff --git a/panels_ipe/panels_ipe.module b/panels_ipe/panels_ipe.module index a0343073e6eb90ec11a22deb687b5c24aa8b9d41..d9334b8d9bf1d9d7298057c3bbe4b0139c71dc95 100644 --- a/panels_ipe/panels_ipe.module +++ b/panels_ipe/panels_ipe.module @@ -50,6 +50,12 @@ function panels_ipe_theme() { 'panels_ipe_dnd_form_container' => array( 'variables' => array('link' => NULL, 'cache_key' => NULL, 'display' => NULL), ), + 'panels_ipe_toolbar' => array( + 'variables' => array('buttons' => NULL), + ), + 'panels_ipe_edit_button' => array( + 'variables' => array('class' => array(), 'text' => NULL), + ), ); } @@ -126,12 +132,19 @@ function theme_panels_ipe_add_pane_button($vars) { return '
' . $link . '
'; } +/** + * @deprecated + */ function panels_ipe_get_cache_key($key = NULL) { - static $cache; - if (isset($key)) { - $cache = $key; - } - return $cache; + return array(); +} + +/** + * Add a button to the IPE toolbar. + */ +function panels_ipe_toolbar_add_button($cache_key, $id, $button) { + $buttons = &drupal_static('panels_ipe_toolbar_buttons', array()); + $buttons[$cache_key][$id] = $button; } /** @@ -142,21 +155,48 @@ function panels_ipe_get_cache_key($key = NULL) { * @param unknown_type $main */ function panels_ipe_page_alter(&$page) { - $key = panels_ipe_get_cache_key(); - if (!isset($key)) { + $buttons = &drupal_static('panels_ipe_toolbar_buttons', array()); + if (empty($buttons)) { return; } - // TODO should be moved into the IPE plugin - WAAAY too hardcoded right now - $output = "
"; - $output .= "
"; - $output .= "
"; - $output .= "" . t('Customize this page') . ""; - $output .= "
"; - $output .= "
"; - $output .= "
"; + $output = theme('panels_ipe_toolbar', array('buttons' => $buttons)); $page['page_bottom']['panels_ipe'] = array( '#markup' => $output, ); } + +function theme_panels_ipe_toolbar($vars) { + $buttons = $vars['buttons']; + + $output = "
"; + foreach ($buttons as $key => $ipe_buttons) { + $output .= "
"; + + // Controls in this container will appear when the IPE is not on. + $output .= '
'; + foreach ($ipe_buttons as $button) { + $output .= $button; + } + $output .= '
'; + + // Controls in this container will appear when the IPE is on. It is usually + // filled via AJAX. + $output .= "
"; + + } + + $output .= "
"; + + return $output; +} + +function theme_panels_ipe_edit_button($vars) { + $class = $vars['class']; + $output = "
"; + $output .= " " . $vars['text'] . ""; + $output .= "
"; + + return $output; +} diff --git a/panels_ipe/plugins/display_renderers/panels_renderer_ipe.class.php b/panels_ipe/plugins/display_renderers/panels_renderer_ipe.class.php index b3bcabadfb5d87b3410f5894ee4d64c53446f07b..c64373a5fb4f0d4d823fc25c50f9f446f6853d88 100644 --- a/panels_ipe/plugins/display_renderers/panels_renderer_ipe.class.php +++ b/panels_ipe/plugins/display_renderers/panels_renderer_ipe.class.php @@ -25,7 +25,10 @@ class panels_renderer_ipe extends panels_renderer_editor { ctools_include('cleanstring'); $this->clean_key = ctools_cleanstring($this->display->cache_key); - panels_ipe_get_cache_key($this->clean_key); + $button = theme('panels_ipe_edit_button', array('class' => 'panels-ipe-startedit', 'text' => t('Customize this page'))); + panels_ipe_toolbar_add_button($this->clean_key, 'panels-ipe-startedit', $button); + +// panels_ipe_get_cache_key($this->clean_key); ctools_include('ajax'); ctools_include('modal');