Exemplo n.º 1
0
    /**
     * @param WikiLingo\Expression\Plugin $plugin
     * @param string $body
     * @param WikiLingo\Renderer $renderer
     * @param WikiLingo\Parser $parser
     * @return string
     */
    public function render(WikiLingo\Expression\Plugin &$plugin, &$body = '', &$renderer, &$parser)
    {
        $plugin->allowLineAfter = false;
        $id = $plugin->id();
        $parser->scripts->addScript(<<<JS
\$(function() {
\tvar tabs = \$('#{$id}');
\ttabs.tabs();
});
JS
);
        if (!empty($plugin->privateAttributes['titles'])) {
            $ul = $renderer->helper('ul');
            foreach ($plugin->privateAttributes['titles'] as $tabId => $title) {
                $a = $renderer->helper('a');
                $a->attributes['href'] = '#' . $tabId;
                $a->staticChildren[] = $title;
                $li = $renderer->helper('li');
                $li->children[] = $a;
                $ul->children[] = $li;
            }
            $body = $ul->render() . $body;
        }
        $tabs = parent::render($plugin, $body, $renderer, $parser);
        return $tabs;
    }
Exemplo n.º 2
0
 /**
  * @param WikiLingo\Renderer $renderer
  * @param WikiLingo\Parser $parser
  * @return string
  */
 public function render($renderer, $parser)
 {
     $tagType = 'h' . $this->count;
     $children = '';
     foreach ($this->parsed->children as $child) {
         $children .= $parser->renderer->render($child);
     }
     if ($this->pointer) {
         $tagType = 'a';
         $children = strip_tags($children);
     }
     $element = Type::Element($renderer->element(__CLASS__, $tagType));
     $element->staticChildren[] = $children;
     if (isset($this->modifier)) {
         $element->detailedAttributes['data-modifier'] = $this->modifier;
         //TODO: add in js to make expandable
         switch ($this->modifier) {
             case 'toggle':
                 $helper = Type::Helper($renderer->helper('a'));
                 $helper->staticChildren[] = '[+]';
                 $helper->attributes['href'] = '#';
                 $element->staticChildren[] = $helper->render();
                 break;
             case 'hidden':
                 $helper = Type::Helper($renderer->helper('a'));
                 $helper->staticChildren[] = '[-]';
                 $helper->attributes['href'] = '#';
                 $element->staticChildren[] = $helper->render();
                 break;
         }
     }
     if ($this->id == null || $this->block->variableContext != null) {
         $id = trim(preg_replace("/[^0-9a-zA-Z_]+/", "-", trim(strip_tags($children))), '-');
         $id = $parser->events->triggerExpressionBlockTypeHeaderIdLookup($id, $this);
         $this->id = $id;
         if (!isset(self::$ids[$id])) {
             self::$ids[$id] = 1;
         } else {
             $this->id .= self::$ids[$id];
             self::$ids[$id]++;
         }
     }
     if ($this->pointer) {
         $element->attributes['href'] = '#' . urlencode($this->id);
     } else {
         $element->attributes['id'] = $this->id;
     }
     $header = $element->render();
     return $header;
 }
Exemplo n.º 3
0
 /**
  * @param WikiLingo\Expression\Plugin $plugin
  * @param string $body
  * @param WikiLingo\Renderer $renderer
  * @param WikiLingo\Parser $parser
  * @return string
  */
 public function render(WikiLingo\Expression\Plugin &$plugin, &$body, &$renderer, &$parser)
 {
     $header = $renderer->helper('h3');
     $header->staticChildren[] = $plugin->parameter('title');
     $accordion = parent::render($plugin, $body, $renderer, $parser);
     return $header->render() . $accordion;
 }
Exemplo n.º 4
0
    /**
     * @param WikiLingo\Expression\Plugin $plugin
     * @param string $body
     * @param WikiLingo\Renderer $renderer
     * @param WikiLingo\Parser $parser
     * @return string
     */
    public function render(WikiLingo\Expression\Plugin &$plugin, &$body = '', &$renderer, &$parser)
    {
        $plugin->allowLineAfter = false;
        $id = $plugin->id();
        $anchors = array();
        if (!$parser->wysiwyg) {
            if (!empty($plugin->privateAttributes['titles'])) {
                //menu
                $ul = Type::Helper($renderer->helper('ul'));
                $ul->attributes['id'] = $id . '-menu';
                $i = 1;
                //anchors for sections
                foreach ($plugin->privateAttributes['titles'] as $sectionId => $title) {
                    $link = Type::Helper($renderer->helper('span'));
                    $link->attributes['href'] = $sectionId;
                    $link->attributes['onclick'] = <<<JS
\$.fn.fullpage.moveTo({$i});
return false;
JS;
                    $i++;
                    //$anchors[] = $a->attributes['data-index'] = $i++;
                    //$a->attributes['id'] = $sectionId . '-anchor';
                    $link->staticChildren[] = $title;
                    $li = Type::Helper($renderer->helper('li'));
                    $li->children[] = $link;
                    $ul->children[] = $li;
                }
                $body .= $ul->render();
                $anchorsJson = json_encode($anchors);
                Type::Scripts($parser->scripts)->addScriptLocation('~/bower_components/fullPage.js/jquery.fullPage.js')->addCssLocation('~/bower_components/fullPage.js/jquery.fullPage.css')->addScript(<<<JS
    \$(function() {
        \$.fn.fullpage({
            anchors: {$anchorsJson},
            easing: 'easeInOutQuad',
            scrollSpeed: 1100,
            menu: '#{$id}-menu'
        });
    });
JS
)->addCss(<<<CSS
#{$id}-menu {
    height: 40px;
    left: 0;
    margin: 0;
    padding: 0;
    position: fixed;
    top: 0;
    width: 100%;
    list-style: none outside none;
}

#{$id}-menu li {
    background-color: rgba(255, 255, 255, 0.5);
    color: #000000;
    border-radius: 10px;
    display: inline-block;
    margin: 10px;
}

#{$id}-menu li.active {
    background-color: rgba(0, 0, 0, 0.5);
    color: #FFFFFF;
}

#{$id}-menu li span {
    display: block;
    padding: 9px 18px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

CSS
);
            }
        }
        $tabs = parent::render($plugin, $body, $renderer, $parser);
        return $tabs;
    }