bloc_showhide.tpl.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
  3. * Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. // Protection to avoid direct call of template
  20. if (empty($blocname)) {
  21. print "Error, template page can't be called as URL";
  22. exit;
  23. }
  24. $hide = true; // Hide by default
  25. if (isset($parameters['showblocbydefault'])) {
  26. $hide = (empty($parameters['showblocbydefault']) ? true : false);
  27. }
  28. if (isset($object->extraparams[$blocname]['showhide'])) {
  29. $hide = (empty($object->extraparams[$blocname]['showhide']) ? true : false);
  30. }
  31. ?>
  32. <!-- BEGIN PHP TEMPLATE bloc_showhide.tpl.php -->
  33. <?php
  34. print '<script>'."\n";
  35. print '$(document).ready(function() {'."\n";
  36. print '$("#hide-'.$blocname.'").click(function(){'."\n";
  37. print ' setShowHide(0);'."\n";
  38. print ' $("#'.$blocname.'_bloc").hide("blind", {direction: "vertical"}, 300).removeClass("nohideobject");'."\n";
  39. print ' $(this).hide();'."\n";
  40. print ' $("#show-'.$blocname.'").show();'."\n";
  41. print '});'."\n";
  42. print '$("#show-'.$blocname.'").click(function(){'."\n";
  43. print ' setShowHide(1);'."\n";
  44. print ' $("#'.$blocname.'_bloc").show("blind", {direction: "vertical"}, 300).addClass("nohideobject");'."\n";
  45. print ' $(this).hide();'."\n";
  46. print ' $("#hide-'.$blocname.'").show();'."\n";
  47. print '});'."\n";
  48. print 'function setShowHide(status) {'."\n";
  49. print ' var id = '.$object->id.";\n";
  50. print " var element = '".$object->element."';\n";
  51. print " var htmlelement = '".$blocname."';\n";
  52. print ' var type = "showhide";'."\n";
  53. print ' $.get("'.dol_buildpath('/core/ajax/extraparams.php', 1);
  54. print '?id="+id+"&element="+element+"&htmlelement="+htmlelement+"&type="+type+"&value="+status);'."\n";
  55. print '}'."\n";
  56. print '});'."\n";
  57. print '</script>'."\n";
  58. print '<div style="float:right; position: relative; top: 3px; right:5px;" id="hide-'.$blocname.'"';
  59. print ' class="linkobject'.($hide ? ' hideobject' : '').'">'.img_picto('', '1uparrow.png').'</div>'."\n";
  60. print '<div style="float:right; position: relative; top: 3px; right:5px;" id="show-'.$blocname.'"';
  61. print ' class="linkobject'.($hide ? '' : ' hideobject').'">'.img_picto('', '1downarrow.png').'</div>'."\n";
  62. print '<div id="'.$blocname.'_title" class="liste_titre">'.$title.'</div>'."\n";
  63. print '<div id="'.$blocname.'_bloc" class="'.($hide ? 'hideobject' : 'nohideobject').'">'."\n";
  64. include DOL_DOCUMENT_ROOT.'/core/tpl/'.$blocname.'.tpl.php';
  65. print '</div><br>';
  66. ?>
  67. <!-- END PHP TEMPLATE BLOC SHOW/HIDE -->