summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEarl Miles2011-08-25 22:10:40 (GMT)
committer Earl Miles2011-08-25 22:10:40 (GMT)
commit1342aa257d375a616f33916a448516e7a88e591e (patch)
tree93a4f1d27aebafd5b30e9ccccbc9a8a9c8011701
parent351d26f22519659211d9536cae5d05e875733e4b (diff)
Issue #1249332: Make IPE "customize this page" button themable.
-rw-r--r--panels_ipe/js/panels_ipe.js7
-rw-r--r--panels_ipe/panels_ipe.module70
-rw-r--r--panels_ipe/plugins/display_renderers/panels_renderer_ipe.class.php5
3 files changed, 63 insertions, 19 deletions
diff --git a/panels_ipe/js/panels_ipe.js b/panels_ipe/js/panels_ipe.js
index e83ddf2..ef4a641 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 a034307..d9334b8 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 '<div class="panels-ipe-newblock panels-ipe-on panels-ipe-portlet-static">' . $link . '</div>';
}
+/**
+ * @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 = "<div id='panels-ipe-control-container' class='clearfix'>";
- $output .= "<div id='panels-ipe-control-$key' class='panels-ipe-control'>";
- $output .= "<div class='panels-ipe-startedit panels-ipe-pseudobutton panels-ipe-off'>";
- $output .= "<span>" . t('Customize this page') . "</span>";
- $output .= "</div>";
- $output .= "<div class='panels-ipe-form-container panels-ipe-on clearfix'</div>";
- $output .= "</div></div>";
+ $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 = "<div id='panels-ipe-control-container' class='clearfix'>";
+ foreach ($buttons as $key => $ipe_buttons) {
+ $output .= "<div id='panels-ipe-control-$key' class='panels-ipe-control'>";
+
+ // Controls in this container will appear when the IPE is not on.
+ $output .= '<div class="panels-ipe-off">';
+ foreach ($ipe_buttons as $button) {
+ $output .= $button;
+ }
+ $output .= '</div>';
+
+ // Controls in this container will appear when the IPE is on. It is usually
+ // filled via AJAX.
+ $output .= "<div class='panels-ipe-form-container panels-ipe-on clearfix'></div>";
+
+ }
+
+ $output .= "</div>";
+
+ return $output;
+}
+
+function theme_panels_ipe_edit_button($vars) {
+ $class = $vars['class'];
+ $output = "<div class='$class panels-ipe-pseudobutton'>";
+ $output .= " <span>" . $vars['text'] . "</span>";
+ $output .= "</div>";
+
+ 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 b3bcaba..c64373a 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');