Skip to content

Commit

Permalink
Header buttons support base
Browse files Browse the repository at this point in the history
  • Loading branch information
fragoulis committed Jan 2, 2013
1 parent ce7dee9 commit 5840bb8
Showing 1 changed file with 43 additions and 4 deletions.
47 changes: 43 additions & 4 deletions EMetabox.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,38 @@
* refresh with an internval or timeout.
*
* @author Yannis Fragkoulis <yannis.fragkoulis@gmail.com>
* @version 0.4
* @version 0.5
*/
class EMetabox extends CWidget
{

/**
* @var array the javascript options
* @since 0.1
*/
public $options = array();

/**
* @var array the html options
* @since 0.1
*/
public $htmlOptions = array();

/**
* @var string ajax loading indicator
* @since 0.1
*/
public $loadingIndicator;

/**
* @var mixed the refresh url
* @since 0.1
*/
public $url;

/**
* @var boolean if true the metabox will refresh on window load
* @since 0.1
*/
public $refreshOnInit = false;

Expand All @@ -55,19 +60,26 @@ class EMetabox extends CWidget
*/
public $content;

/**
* @var array the header buttons. Optional.
* @since 0.5
*/
public $headerButtons;

/**
* @var string the default css class
* @since 0.4
*/
public $cssClass = 'metabox';

/**
* @var type
* @var string
* @since 0.1
*/
static private $_assets;

/**
*
* @since 0.1
*/
public function init()
{
Expand Down Expand Up @@ -104,6 +116,7 @@ public function init()

/**
* Register extension assets
* @since 0.1
*/
public function run()
{
Expand All @@ -128,16 +141,25 @@ public function run()
$cs->registerScript('metabox#' . $id, "$('#{$id}').metabox({$options});", CClientScript::POS_READY);
}

/**
* Renders the header
* @since 0.4
*/
protected function renderHeader()
{
if ($this->header)
if ($this->header || $this->headerButtons)
{
echo CHtml::openTag('div', array('class' => $this->cssClass . '-header'));
echo $this->header;
$this->renderHeaderButtons();
echo '</div>'; // close header div
}
}

/**
* Renders the footer
* @since 0.4
*/
protected function renderFooter()
{
if ($this->footer)
Expand All @@ -146,11 +168,28 @@ protected function renderFooter()
}
}

/**
* Renders the content
* @since 0.4
*/
protected function renderContent()
{
echo $this->content;
}

/**
* Renders the header buttons
* @since 0.5
*/
protected function renderHeaderButtons()
{
if ($this->headerButtons)
{
echo CHtml::openTag('div', array('class' => $this->cssClass . '-header-buttons'));
echo '</div>';
}
}

}

?>

0 comments on commit 5840bb8

Please sign in to comment.