v1.php 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * The colorPicker widget class file of zin module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  6. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author sunhao<sunhao@easycorp.ltd>
  8. * @package zin
  9. * @link http://www.zentao.net
  10. */
  11. namespace zin;
  12. /**
  13. * 颜色选择器(colorPicker)部件类
  14. * The colorPicker widget class
  15. */
  16. class colorPicker extends wg
  17. {
  18. /**
  19. * Define widget properties.
  20. *
  21. * @var array
  22. * @access protected
  23. */
  24. protected static $defineProps = array(
  25. 'id?: string="$GID"', // 组件根元素的 ID。
  26. 'formID?: string', // 组件隐藏的表单元素 ID。
  27. 'className?: string|array', // 类名。
  28. 'style?: array', // 样式。
  29. 'tagName?: string', // 组件根元素的标签名。
  30. 'attrs?: array', // 附加到组件根元素上的属性。
  31. 'clickType?: "toggle"|"open"', // 点击类型,`toggle` 表示点击按钮时切换显示隐藏,`open` 表示点击按钮时只打。
  32. 'afterRender?: function', // 渲染完成后的回调函数。
  33. 'beforeDestroy?: function', // 销毁前的回调函数。
  34. 'name?: string', // 作为表单项的名称。
  35. 'value?: string|string[]', // 默认值。
  36. 'onChange?: function', // 值变更回调函数。
  37. 'disabled?: boolean', // 是否禁用。
  38. 'multiple?: boolean|number=false', // 是否允许选择多个值,如果指定为数字,则限制多选的数目,默认 `false`。
  39. 'required?: boolean', // 是否必选(不允许空值,不可以被清除)。
  40. 'items?: string | string[]', // 颜色选项列表。
  41. 'icon?: string|array="color"', // 将触发按钮显示为图标。
  42. 'syncValue?: string', // 指定选择器同步颜色值作为文本到的元素。
  43. 'syncColor?: string', // 指定选择器同步文字颜色到的元素。
  44. 'syncBackground?: string', // 指定选择器同步背景颜色到的元素。
  45. 'syncBorder?: string', // 指定选择器同步边框颜色到的元素。
  46. 'hint?: string', // 提示文字。
  47. 'closeBtn?: boolean', // 是否在弹出面板上显示关闭按钮。
  48. 'popPlacement?: string', // 弹出面板方向。
  49. 'heading?: string|array' // 弹出面板的标题。
  50. );
  51. /**
  52. * Build widget.
  53. *
  54. * @access protected
  55. */
  56. protected function build()
  57. {
  58. list($props, $restProps) = $this->props->split(array_keys(static::definedPropsList()));
  59. if(isset($props['id']))
  60. {
  61. $props['_id'] = $props['id'];
  62. unset($props['id']);
  63. }
  64. if(!isset($props['items']))
  65. {
  66. global $app, $lang;
  67. $moduleName = $app->getModuleName();
  68. if(isset($lang->$moduleName->colorList)) $props['items'] = $lang->$moduleName->colorList;
  69. }
  70. return zui::colorPicker
  71. (
  72. set::_class('form-group-wrapper center'),
  73. set::_map(array('value' => 'defaultValue', 'items' => 'colors', 'formID' => 'id')),
  74. set::_props($restProps),
  75. set($props),
  76. $this->children()
  77. );
  78. }
  79. }