Exemplo n.º 1
0
 /**
  * @param HtmlTagBuilder $tag
  * @param \Render\APIs\APIv1\RenderAPI $renderApi
  * @param \Render\Unit $unit
  * @param \Render\ModuleInfo $moduleInfo
  */
 protected function modifyWrapperTag($tag, $renderApi, $unit, $moduleInfo)
 {
     // use a only if not in edit mode (to be able to use inline editor)
     if (!$renderApi->isEditMode()) {
         $tag->setTagName('a');
         $tag->set('href', $this->geturl($renderApi, $unit));
         if ($renderApi->getFormValue($unit, 'openNewWindow')) {
             $tag->set('target', '_blank');
         }
     }
     // add title
     $linkTitle = $renderApi->getFormValue($unit, 'linkTitle');
     if (!empty($linkTitle)) {
         $tag->set('title', $linkTitle);
     }
     // add active/current classes when linking to internal page
     if ($renderApi->getFormValue($unit, 'linkType') == 'page') {
         $pageId = $renderApi->getFormValue($unit, 'pageId');
         if (!empty($pageId)) {
             $nav = $renderApi->getNavigation();
             $navIds = $this->getNavigatorIds($nav);
             if ($this->isPageActive($pageId, $navIds)) {
                 $tag->addClass('linkPageActive');
             }
             if ($pageId == $nav->getCurrentPageId()) {
                 $tag->addClass('linkPageCurrent');
             }
         }
     }
 }
Exemplo n.º 2
0
 /**
  * @param HtmlTagBuilder $tag
  * @param \Render\APIs\APIv1\RenderAPI $renderApi
  * @param \Render\Unit $unit
  * @param \Render\ModuleInfo $moduleInfo
  */
 protected function modifyWrapperTag($tag, $renderApi, $unit, $moduleInfo)
 {
     // use a only if not in edit mode (to be able to use inline editor)
     if (!$renderApi->isEditMode()) {
         $tag->setTagName('a');
         $tag->set('href', $this->geturl($renderApi, $unit));
         if ($renderApi->getFormValue($unit, 'openNewWindow')) {
             $tag->set('target', '_blank');
         }
     }
     // add title
     $linkTitle = $renderApi->getFormValue($unit, 'linkTitle');
     if (!empty($linkTitle)) {
         $tag->set('title', $linkTitle);
     }
     // add active/current classes when linking to internal page
     if ($renderApi->getFormValue($unit, 'linkType') == 'page') {
         $pageId = $renderApi->getFormValue($unit, 'pageId');
         if (!empty($pageId)) {
             $nav = $renderApi->getNavigation();
             $navIds = $this->getNavigatorIds($nav);
             if ($this->isPageActive($pageId, $navIds)) {
                 $tag->addClass('linkPageActive');
             }
             if ($pageId == $nav->getCurrentPageId()) {
                 $tag->addClass('linkPageCurrent');
             }
         }
     }
     // anchor
     if ($renderApi->getFormValue($unit, 'linkType') == 'anchor' && !$renderApi->isEditMode()) {
         $jsCode = "\$.scrollTo('" . $renderApi->getFormValue($unit, 'anchorId') . "', " . intval($renderApi->getFormValue($unit, 'scrollSpeed')) . ", {";
         $jsCode .= "easing: 'swing',axis: 'y'}); return false;";
         $tag->set('onclick', $jsCode);
     }
 }