Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: Joomla-Framework

Developer Network License

The Joomla! Developer Network content is © copyright 2006 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5
Source code for file /joomla/html/pane.php

Documentation is available at pane.php

  1. <?php
  2. /**
  3. @version        $Id: pane.php 6691 2007-02-21 10:00:43Z louis $
  4. @package        Joomla.Framework
  5. @subpackage    HTML
  6. @copyright    Copyright (C) 2005 - 2007 Open Source Matters. All rights reserved.
  7. @license        GNU/GPL, see LICENSE.php
  8. *  Joomla! is free software. This version may have been modified pursuant
  9. *  to the GNU General Public License, and as distributed it includes or
  10. *  is derivative of works licensed under the GNU General Public License or
  11. *  other free or open source software licenses.
  12. *  See COPYRIGHT.php for copyright notices and details.
  13. */
  14.  
  15. // Check to ensure this file is within the rest of the framework
  16. defined('JPATH_BASE'or die();
  17.  
  18. /**
  19.  * JPane abstract class
  20.  *
  21.  * @abstract
  22.  * @author        Johan Janssens <[email protected]>
  23.  * @package        Joomla.Framework
  24.  * @subpackage    HTML
  25.  * @since        1.5
  26.  */
  27. class JPane extends JObject
  28. {
  29.  
  30.     var $useCookies = false;
  31.  
  32.     /**
  33.     * Constructor
  34.     *
  35.      * @param array     $params        Associative array of values
  36.     */
  37.     function __construct$params array() ) {
  38.  
  39.     }
  40.  
  41.     /**
  42.      * Returns a reference to a JPanel object
  43.      *
  44.      * @param string     $behavior   The behavior to use
  45.      * @param boolean    $useCookies Use cookies to remember the state of the panel
  46.      * @param array     $params        Associative array of values
  47.      */
  48.     function &getInstance$behavior 'Tabs'$params array())
  49.     {
  50.         $classname 'JPane'.$behavior;
  51.         $instance new $classname($params);
  52.  
  53.         return $instance;
  54.     }
  55.  
  56.     /**
  57.     * Creates a pane and creates the javascript object for it
  58.     *
  59.     * @abstract
  60.     * @param string The pane identifier
  61.     */
  62.     function startPane$id {
  63.         return;
  64.     }
  65.  
  66.     /**
  67.     * Ends the pane
  68.     *
  69.     * @abstract
  70.     */
  71.     function endPane({
  72.         return;
  73.     }
  74.  
  75.     /**
  76.     * Creates a panel with title text and starts that panel
  77.     *
  78.     * @abstract
  79.     * @param text - The panel name and/or title
  80.     * @param id - The panel identifer
  81.     */
  82.     function startPanel$text$id {
  83.         return;
  84.     }
  85.  
  86.     /**
  87.     * Ends a panel
  88.     *
  89.     * @abstract
  90.     */
  91.     function endPanel({
  92.         return;
  93.     }
  94.  
  95.     /**
  96.     * Load the javascript behavior and attach it to the document
  97.     *
  98.     * @abstract
  99.     */
  100.     function _loadBehavior({
  101.         return;
  102.     }
  103. }
  104.  
  105. /**
  106.  * JPanelTabs class to to draw parameter panes
  107.  *
  108.  * @author        Johan Janssens <[email protected]>
  109.  * @package        Joomla.Framework
  110.  * @subpackage    HTML
  111.  * @since        1.5
  112.  */
  113. class JPaneTabs extends JPane
  114. {
  115.     /**
  116.     * Constructor
  117.     *
  118.     * @param array     $params        Associative array of values
  119.     */
  120.     function __construct$params array() )
  121.     {
  122.         static $loaded false;
  123.  
  124.         parent::__construct($params);
  125.  
  126.         if(!$loaded{
  127.             $this->_loadBehavior($params);
  128.             $loaded true;
  129.         }
  130.     }
  131.  
  132.    /**
  133.     * Creates a pane and creates the javascript object for it
  134.     *
  135.     * @param string The pane identifier
  136.     */
  137.     function startPane$id )
  138.     {
  139.         return '<dl class="tabs" id="'.$id.'">';
  140.     }
  141.  
  142.    /**
  143.     * Ends the pane
  144.     */
  145.     function endPane({
  146.         return "</dl>";
  147.     }
  148.  
  149.     /**
  150.     * Creates a tab panel with title text and starts that panel
  151.     *
  152.     * @param text - The name of the tab
  153.     * @param id - The tab identifier
  154.     */
  155.     function startPanel$text$id )
  156.     {
  157.         return '<dt id="'.$id.'">'.$text.'</dt><dd>';
  158.     }
  159.  
  160.     /**
  161.     * Ends a tab page
  162.     */
  163.     function endPanel({
  164.         return "</dd>";
  165.     }
  166.  
  167.     /**
  168.     * Load the javascript behavior and attach it to the document
  169.     *
  170.     * @param array     $params        Associative array of values
  171.     */
  172.     function _loadBehavior($params array())
  173.     {
  174.         global $mainframe;
  175.  
  176.         $document =JFactory::getDocument();
  177.  
  178.         $options '{';
  179.         $opt['onActive']    (isset($params['onActive'])) $params['onActive'null ;
  180.         $opt['onBackground'](isset($params['onBackground'])) $params['onBackground'null ;
  181.         $opt['display']        (isset($params['startOffset'])) ? (int)$params['startOffset'null ;
  182.         foreach ($opt as $k => $v)
  183.         {
  184.             if ($v{
  185.                 $options .= $k.': '.$v.',';
  186.             }
  187.         }
  188.         if (substr($options-1== ','{
  189.             $options substr($options0-1);
  190.         }
  191.         $options .= '}';
  192.  
  193.         $js '        Window.onDomReady(function(){ $$(\'dl.tabs\').each(function(tabs){ new JTabs(tabs, '.$options.'); }); });';
  194.  
  195.         $document->addScriptDeclaration$js );
  196.         $url $mainframe->isAdmin($mainframe->getSiteURL(JURI::base();
  197.         $document->addScript$url'includes/js/joomla/tabs.js' );
  198.     }
  199. }
  200.  
  201. /**
  202.  * JPanelSliders class to to draw parameter panes
  203.  *
  204.  * @author        Johan Janssens <[email protected]>
  205.  * @package        Joomla.Framework
  206.  * @subpackage    HTML
  207.  * @since        1.5
  208.  */
  209. class JPaneSliders extends JPane
  210. {
  211.     /**
  212.     * Constructor
  213.     *
  214.     * @param int useCookies, if set to 1 cookie will hold last used tab between page refreshes
  215.     */
  216.     function __construct$params array() )
  217.     {
  218.         static $loaded false;
  219.  
  220.         parent::__construct($params);
  221.  
  222.         if(!$loaded{
  223.             $this->_loadBehavior($params);
  224.             $loaded true;
  225.         }
  226.     }
  227.  
  228.    /**
  229.     * Creates a pane and creates the javascript object for it
  230.     *
  231.     * @param string The pane identifier
  232.     */
  233.     function startPane$id )
  234.     {
  235.         return '<div id="'.$id.'" class="pane-sliders">';
  236.     }
  237.  
  238.    /**
  239.     * Ends the pane
  240.     */
  241.     function endPane({
  242.         return '</div>';
  243.     }
  244.  
  245.     /**
  246.     * Creates a tab panel with title text and starts that panel
  247.     *
  248.     * @param text - The name of the tab
  249.     * @param id - The tab identifier
  250.     */
  251.     function startPanel$text$id )
  252.     {
  253.         return '<div class="panel">'
  254.             .'<h3 class="jpane-toggler title" id="'.$id.'"><span>'.$text.'</span></h3>'
  255.             .'<div class="jpane-slider content">';
  256.     }
  257.  
  258.     /**
  259.     * Ends a tab page
  260.     */
  261.     function endPanel({
  262.         return '</div></div>';
  263.     }
  264.  
  265.     /**
  266.     * Load the javascript behavior and attach it to the document
  267.     *
  268.     * @param array     $params        Associative array of values
  269.     */
  270.     function _loadBehavior($params array())
  271.     {
  272.         global $mainframe;
  273.  
  274.         $document =JFactory::getDocument();
  275.  
  276.         $options '{';
  277.         $opt['onActive']    'function(toggler, i) { toggler.addClass(\'jpane-toggler-down\'); toggler.removeClass(\'jpane-toggler\'); }';
  278.         $opt['onBackground']'function(toggler, i) { toggler.addClass(\'jpane-toggler\'); toggler.removeClass(\'jpane-toggler-down\'); }';
  279.         $opt['duration']    (isset($params['duration'])) ? (int)$params['duration'300;
  280.         $opt['display']        (isset($params['startOffset']&& ($params['startTransition'])) ? (int)$params['startOffset'null ;
  281.         $opt['show']        (isset($params['startOffset']&& (!$params['startTransition'])) ? (int)$params['startOffset'null ;
  282.         $opt['opacity']        (isset($params['opacityTransition']&& ($params['opacityTransition'])) 'true' 'false' ;
  283.         $opt['alwaysHide']    (isset($params['allowAllClose']&& ($params['allowAllClose'])) 'true' null ;
  284.         foreach ($opt as $k => $v)
  285.         {
  286.             if ($v{
  287.                 $options .= $k.': '.$v.',';
  288.             }
  289.         }
  290.         if (substr($options-1== ','{
  291.             $options substr($options0-1);
  292.         }
  293.         $options .= '}';
  294.  
  295.         $js '        Window.onDomReady(function(){ new Accordion($$(\'.panel h3.jpane-toggler\'), $$(\'.panel div.jpane-slider\'), '.$options.'); });';
  296.  
  297.         $document->addScriptDeclaration$js );
  298.     }
  299. }
  300. ?>

Documentation generated on Mon, 05 Mar 2007 21:13:00 +0000 by phpDocumentor 1.3.1