Exemplo n.º 1
0
 /**
  * Initializes the widget
  */
 public function init()
 {
     $this->assets = array('js' => YII_DEBUG ? 'foundation/foundation.clearing.js' : 'foundation.min.js');
     Html::addCssClass($this->htmlOptions, Enum::CLEARING_THUMBS);
     ArrayHelper::addValue('data-clearing', 'data-clearing', $this->htmlOptions);
     parent::init();
 }
Exemplo n.º 2
0
 /**
  * Initializes the widget
  */
 public function init()
 {
     $this->assets = array('js' => YII_DEBUG ? 'foundation/foundation.joyride.js' : 'foundation.min.js');
     Html::addCssClass($this->htmlOptions, Enum::JOYRIDE_LIST);
     ArrayHelper::addValue('data-joyride', 'data-joyride', $this->htmlOptions);
     $this->registerClientScript();
     parent::init();
 }
Exemplo n.º 3
0
 /**
  * Initializes the widget
  */
 public function init()
 {
     $this->assets = array('js' => YII_DEBUG ? 'foundation/foundation.dropdown.js' : 'foundation.min.js');
     Html::addCssClass($this->htmlOptions, Enum::DROPDOWN_LIST);
     ArrayHelper::addValue('data-dropdown-content', '-', $this->htmlOptions);
     if ($this->type === Enum::DROPDOWN_CONTENT) {
         Html::addCssClass($this->htmlOptions, Enum::CONTENT);
     }
     parent::init();
 }
Exemplo n.º 4
0
 /**
  * Generates an icon.
  * @param string $icon the icon type.
  * @param array $htmlOptions additional HTML attributes.
  * @param string $tagName the icon HTML tag.
  * @return string the generated icon.
  */
 public static function icon($icon, $htmlOptions = array(), $tagName = 'i')
 {
     if (is_string($icon)) {
         if (strpos($icon, 'foundicon-') === false) {
             $icon = 'foundicon-' . implode(' foundicon-', array_unique(explode(' ', $icon)));
         }
         ArrayHelper::addValue('class', $icon, $htmlOptions);
         return \CHtml::openTag($tagName, $htmlOptions) . \CHtml::closeTag($tagName);
     }
     return '';
 }
Exemplo n.º 5
0
 public static function bar($percent, $htmlOptions = array())
 {
     $percent = substr(trim($percent), -1) !== '%' ? $percent . '%' : $percent;
     ArrayHelper::addValue('class', Enum::PROGRESS, $htmlOptions);
     ob_start();
     echo \CHtml::openTag('div', $htmlOptions);
     echo \CHtml::openTag('span', array('class' => Enum::PROGRESS_METER, 'style' => 'width:' . $percent));
     echo \CHtml::closeTag('span');
     echo \CHtml::closeTag('div');
     return ob_get_clean();
 }
Exemplo n.º 6
0
 /**
  * Initializes the widget
  */
 public function init()
 {
     $this->assets = array('js' => YII_DEBUG ? 'foundation/foundation.tooltips.js' : 'foundation.min.js');
     Html::addCssClass($this->htmlOptions, Enum::TOOLTIP);
     Html::addCssClass($this->htmlOptions, $this->position);
     ArrayHelper::addValue('title', $this->tip, $this->htmlOptions);
     ArrayHelper::addValue('data-tooltip', 'data-tooltip', $this->htmlOptions);
     if ($this->tip === null || $this->text === null) {
         throw new InvalidConfigException('"tip" and "text" cannot be null.');
     }
     $this->registerClientScript();
     parent::init();
 }
Exemplo n.º 7
0
 /**
  * Renders menu items. It differs from [[Dropdown]] widget as it is factorial to render multi-level dropdown menus.
  * @param array $items the items to render
  * @param bool $encodeLabels whether to encode link labels or not
  * @return string the resulting dropdown element.
  * @throws \foundation\exception\InvalidConfigException
  */
 public static function dropdown($items, $encodeLabels = true)
 {
     $li = array();
     foreach ($items as $item) {
         if (is_string($item)) {
             $li[] = $item;
             continue;
         }
         if (!isset($item['label'])) {
             throw new InvalidConfigException("The 'label' option is required.");
         }
         $label = $encodeLabels ? \CHtml::encode($item['label']) : $item['label'];
         $options = ArrayHelper::getValue($item, 'options', array());
         $items = ArrayHelper::getValue($item, 'items');
         $url = \CHtml::normalizeUrl(ArrayHelper::getValue($item, 'url', '#'));
         $linkOptions = ArrayHelper::getValue($item, 'linkOptions', array());
         if (ArrayHelper::getValue($item, 'active')) {
             ArrayHelper::addValue('class', 'active', $options);
         }
         if ($items !== null) {
             ArrayHelper::addValue('class', 'has-dropdown', $options);
             if (is_array($items)) {
                 $items = static::dropdown($items, $encodeLabels);
             }
         }
         $li[] = \CHtml::tag('li', $options, \CHtml::link($label, $url, $linkOptions) . $items);
     }
     return \CHtml::tag('ul', array('class' => 'dropdown'), implode("\n", $li));
 }
Exemplo n.º 8
0
 /**
  * Generates a split button.
  * Important: Currently split buttons require the dropdown list items to be rendered before the body tag, so the
  * dropdown list hides on document.click. You will have to click again on dropdown to hide the list.
  * Please, use the button widget for better performance. At the moment, Foundation uses a hack until its new release 4.2
  * @param $label
  * @param $list
  * @param array $htmlOptions
  * @return string
  */
 public static function split($label, $list, $htmlOptions = array())
 {
     $id = Enum::ID_PREFIX . '-' . ++Html::$count;
     ArrayHelper::addValue('class', Enum::DROPDOWN_SPLIT, $htmlOptions);
     $label .= ' <span data-dropdown="' . $id . '"></span>';
     $dropHtmlOptions = ArrayHelper::removeValue($htmlOptions, 'dropHtmlOptions', array());
     $dropHtmlOptions['id'] = $id;
     ArrayHelper::addValue('class', Enum::DROPDOWN_LIST, $dropHtmlOptions);
     ob_start();
     echo '<div style="position:relative">';
     // hack
     echo static::link($label, $htmlOptions);
     echo Dropdown::display(array('items' => $list, 'htmlOptions' => $dropHtmlOptions));
     echo '</div>';
     return ob_get_clean();
 }
Exemplo n.º 9
0
 /**
  * Generates a callout panel
  *
  * @param string $content the content to display
  * @param array $htmlOptions the HTML attributes of the panel
  * @return string
  */
 public static function callout($content, $htmlOptions = array())
 {
     ArrayHelper::addValue('class', Enum::PANEL_CALLOUT, $htmlOptions);
     return static::panel($content, $htmlOptions);
 }
Exemplo n.º 10
0
 /**
  * Renders a section item
  * @param array $item the section item
  * @return string the section result
  */
 public function renderItem($item)
 {
     $sectionItem = array();
     $sectionItem[] = \CHtml::tag('p', array('class' => 'title', 'data-section-title' => 'data-section-title'), \CHtml::link(ArrayHelper::getValue($item, 'label', 'Section Title'), '#'));
     $options = ArrayHelper::getValue($item, 'options', array());
     Html::addCssClass($options, 'content');
     ArrayHelper::addValue('data-section-content', 'data-section-content', $options);
     $sectionOptions = array();
     if (ArrayHelper::getValue($item, 'active')) {
         ArrayHelper::addValue('class', 'active', $sectionOptions);
     }
     $sectionItem[] = \CHtml::tag('div', $options, ArrayHelper::getValue($item, 'content', 'Section Content'));
     return \CHtml::tag('section', $sectionOptions, implode("\n", $sectionItem));
 }
Exemplo n.º 11
0
 /**
  * Generates a close link.
  * @param string $label the link label text.
  * @param array $htmlOptions additional HTML attributes.
  * @return string the generated link.
  */
 public static function closeLink($label = '&times;', $htmlOptions = array())
 {
     $htmlOptions = ArrayHelper::defaultValue('href', '#', $htmlOptions);
     ArrayHelper::addValue('class', 'close', $htmlOptions);
     return \CHtml::openTag('a', $htmlOptions) . $label . \CHtml::closeTag('a');
 }
Exemplo n.º 12
0
 /**
  * Renders a widget's item
  * @param mixed $item the item to render
  * @return string the rendering result.
  * @throws InvalidConfigException
  */
 protected function renderItem($item)
 {
     if (is_string($item)) {
         return $item;
     }
     if (!isset($item['label'])) {
         throw new InvalidConfigException("The 'label' option is required.");
     }
     $label = $this->encodeLabels ? \CHtml::encode($item['label']) : $item['label'];
     $options = ArrayHelper::getValue($item, 'options', array());
     $items = ArrayHelper::getValue($item, 'items');
     $url = \CHtml::normalizeUrl(ArrayHelper::getValue($item, 'url', '#'));
     $linkOptions = ArrayHelper::getValue($item, 'linkOptions', array());
     if (ArrayHelper::getValue($item, Enum::STATE_ACTIVE)) {
         ArrayHelper::addValue('class', Enum::STATE_ACTIVE, $options);
     }
     if ($items !== null) {
         Html::addCssClass($options, Enum::DROPDOWN_HAS);
         if (is_array($items)) {
             $items = Nav::dropdown($items, $this->encodeLabels);
         }
     }
     return \CHtml::tag('li', $options, \CHtml::link($label, $url, $linkOptions) . $items);
 }