Source for file tabs.php

Documentation is available at tabs.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Libraries
  4.  * @subpackage  HTML
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE
  8.  */
  9.  
  10. defined('JPATH_PLATFORM'or die;
  11.  
  12. /**
  13.  * Utility class for Tabs elements.
  14.  *
  15.  * @package     Joomla.Libraries
  16.  * @subpackage  HTML
  17.  * @since       1.6
  18.  */
  19. abstract class JHtmlTabs
  20. {
  21.     /**
  22.      * Creates a panes and creates the JavaScript object for it.
  23.      *
  24.      * @param   string  $group   The pane identifier.
  25.      * @param   array   $params  An array of option.
  26.      *
  27.      * @return  string 
  28.      *
  29.      * @since   1.6
  30.      */
  31.     public static function start($group 'tabs'$params array())
  32.     {
  33.         static::loadBehavior($group$params);
  34.  
  35.         return '<dl class="tabs" id="' $group '"><dt style="display:none;"></dt><dd style="display:none;">';
  36.     }
  37.  
  38.     /**
  39.      * Close the current pane
  40.      *
  41.      * @return  string  HTML to close the pane
  42.      *
  43.      * @since   1.6
  44.      */
  45.     public static function end()
  46.     {
  47.         return '</dd></dl>';
  48.     }
  49.  
  50.     /**
  51.      * Begins the display of a new panel.
  52.      *
  53.      * @param   string  $text  Text to display.
  54.      * @param   string  $id    Identifier of the panel.
  55.      *
  56.      * @return  string  HTML to start a new panel
  57.      *
  58.      * @since   1.6
  59.      */
  60.     public static function panel($text$id)
  61.     {
  62.         return '</dd><dt class="tabs ' $id '"><span><h3><a href="javascript:void(0);">' $text '</a></h3></span></dt><dd class="tabs">';
  63.     }
  64.  
  65.     /**
  66.      * Load the JavaScript behavior.
  67.      *
  68.      * @param   string  $group   The pane identifier.
  69.      * @param   array   $params  Array of options.
  70.      *
  71.      * @return  void 
  72.      *
  73.      * @since   1.6
  74.      */
  75.     protected static function loadBehavior($group$params array())
  76.     {
  77.         static $loaded array();
  78.  
  79.         if (!array_key_exists((string) $group$loaded))
  80.         {
  81.             // Include MooTools framework
  82.             JHtml::_('behavior.framework'true);
  83.  
  84.             $opt['onActive']            (isset($params['onActive'])) '\\' $params['onActive'null;
  85.             $opt['onBackground']        (isset($params['onBackground'])) '\\' $params['onBackground'null;
  86.             $opt['display']             (isset($params['startOffset'])) ? (int) $params['startOffset'null;
  87.             $opt['useStorage']          (isset($params['useCookie']&& $params['useCookie']'true' 'false';
  88.             $opt['titleSelector']       "dt.tabs";
  89.             $opt['descriptionSelector'"dd.tabs";
  90.  
  91.             $options JHtml::getJSObject($opt);
  92.  
  93.             $js '    window.addEvent(\'domready\', function(){
  94.                         $$(\'dl#' $group '.tabs\').each(function(tabs){
  95.                             new JTabs(tabs, ' $options ');
  96.                         });
  97.                     });';
  98.  
  99.             $document JFactory::getDocument();
  100.             $document->addScriptDeclaration($js);
  101.             JHtml::_('script''system/tabs.js'falsetrue);
  102.  
  103.             $loaded[(string) $grouptrue;
  104.         }
  105.     }
  106. }

Documentation generated on Tue, 19 Nov 2013 15:15:03 +0100 by phpDocumentor 1.4.3