Source for file PHPJQueryToggler.php
Documentation is available at PHPJQueryToggler.php
* PHP JQuery Toggler - A class library to manage toggle in JQuery
* Copyright (C) 2010 Daniele Monti (monska13 [at] gmail.com)
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
define("NO_TXT_DEFINIED","Ricontrolla di aver configurato i testi di apertura e chiusura.");
define("NO_IMG_DEFINIED","Ricontrolla di aver configurato le immagini di apertura e chiusura.");
define("DEFAULT_DURATION","slow");
define("BUTTON_TYPE_TEXT","T");
define("BUTTON_TYPE_IMAGE","I");
define("BUTTON_OPEN_DEFAULT_TXT","Apri");
define("BUTTON_CLOSE_DEFAULT_TXT","Chiudi");
* @inline Class to implements slideUp and slideDown div
* @var string contains button's div id
* @var string contains content's div id
* @var integer set motion duration in milliseconds
* @var char set button type [I|T] Image|Text
* @var string contains image path of open button
* @var string contains image path of closed button
* @var string contains text of open string
* @var string contains text of close string
* @var integer set the init status [1|0] open|close
* @var mixed array of functions to call at open action
* @var mixed array of functions to call at close action
* @method void phpToggler() phpToggler($button,$content,$button_type=BUTTON_TYPE_TEXT,$start_status=STATUS_CLOSE,$motion_duration=DEFAULT_DURATION) is class costructor
* @param string $button contains button's div id
* @param string $content contains content's div id
* @param char $button_type [I|T] set button type Image|Text
* @param integer $start_status [1|0] set init status Open|Close
* @param integer motion_duration set motion duration in milliseconds
function phpToggler($button,$content,$button_type= BUTTON_TYPE_TEXT,$start_status= STATUS_CLOSE,$motion_duration= DEFAULT_DURATION)
* @method void|stringincludeJQuery() includeJQuery($path,$return=false) print or return the include string of JQuery
* @param string $path contains JQuery path
* @param bool $return set print|return type
echo "<script src=\"". $path. "\"></script>\n\n";
return "<script src=\"". $path. "\"></script>\n\n";
* @method void setOpenCloseImg() setOpenCloseImg($open_image,$close_image) set images used as open|close button
* @param string $open_image contains open image path
* @param string $close_image contains close image path
* @method void setOpenCloseTxt() setOpenCloseTxt($open_txt,$close_txt) set text used as open|close text
* @param string $open_txt contains open text
* @param string $close_txt contains close text
* @method void setOpenFunction() setOpenFunction($array) set the open funcions
* @param mixed $array array of javascript functions to call at open action
* @method void setCloseFunction() setCloseFunction($array) set the close funcions
* @param mixed $array array of javascript functions to call at close action
* @method void addOpenFunction() addOpenFunction($function) add function at openFunction array
* @param string $function call string of javascript function at open action
* @method void addCloseFunction() addCloseFunction($function) add function at closeFunction array
* @param string $function call string of javascript function at close action
* @method void|stringprintJs() addOpenFunction($return=false) print or return javascript code
* @param bool $return set print or return mode
$js .= "<script type=\"text/javascript\">\n";
$js .= "function toggleImg(div,img)\n";
$js .= "document.getElementById(div).src=img;\n";
$js .= "function toggleTxt(div,txt)\n";
$js .= "document.getElementById(div).innerHTML=txt;\n";
$js .= "\$('#". $this->div_button. "').click( function()\n";
$js .= "if(". $this->div_content. "_status == \"close\")\n";
* @method void checkAll() checkAll() check configuration
* @method void checkButton() checkButton() check if image or text are set
* @method void printVars() printVars() debug function to print all configuration vars
echo "OPEN TXT: ". $this->open_txt. "<br />\n";
echo "CLOSE TXT: ". $this->close_txt. "<br />\n";
echo "OPEN FUNCTION:<br />\n";
echo "CLOSE FUNCTION:<br />\n";
|