toggle.class.php 943 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * The zui toggle class file of zin lib.
  4. *
  5. * @copyright Copyright 2023 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
  6. * @author Hao Sun <sunhao@easycorp.ltd>
  7. * @package zin
  8. * @version $Id
  9. * @link https://www.zentao.net
  10. */
  11. namespace zin;
  12. require_once dirname(__DIR__) . DS . 'core' . DS . 'set.class.php';
  13. class toggle
  14. {
  15. /**
  16. * @param string $name
  17. * @param mixed[] $args
  18. */
  19. public static function __callStatic($name, $args)
  20. {
  21. return toggle($name, empty($args) ? array() : $args[0]);
  22. }
  23. }
  24. /**
  25. * Add data-toggle=* to widget element and set other data attributes.
  26. *
  27. * @param string $name
  28. * @param array $dataset
  29. */
  30. function toggle($name, $dataset = array())
  31. {
  32. $props = array('zui-toggle' => $name);
  33. if(!empty($dataset)) $props["zui-toggle-$name"] = $dataset;
  34. return set($props);
  35. }