Skip to content

Commit b095015

Browse files
author
hikki
committed
v3.6
1 parent 002e212 commit b095015

File tree

4 files changed

+19
-27
lines changed

4 files changed

+19
-27
lines changed

src/Widget/CascadeDot.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ public static function panel($name,array $selected,array $select,int $limit=1,ar
4848
}
4949

5050
return <<<EOF
51-
<div id="{$name}" style="$style_string"></div>
52-
<script>
53-
new ComponentCascadeDot("{$name}",JSON.parse('{$selected}'),JSON.parse('{$select}'),{$limit});
54-
</script>
51+
<div id="{$name}" style="$style_string"></div><script>new ComponentCascadeDot("{$name}",JSON.parse('{$selected}'),JSON.parse('{$select}'),{$limit});</script>
5552
EOF;
5653
}
5754
}

src/Widget/CascadeLine.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ public static function panel($name,array $select,string $xhr,array $style=[],arr
5858
}
5959

6060
return <<<EOF
61-
<div id="{$name}" style="$style_string"></div>
62-
<script>
63-
new ComponentCascadeLine("{$name}",JSON.parse('{$select}'),'{$xhr}',JSON.parse('{$options}'));
64-
</script>
61+
<div id="{$name}" style="$style_string"></div><script>new ComponentCascadeLine("{$name}",JSON.parse('{$select}'),'{$xhr}',JSON.parse('{$options}'));</script>
6562
EOF;
6663
}
6764
}

src/Widget/Dot.php

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,39 +19,40 @@ public function render()
1919
$limit = isset($this->attributes['limit']) ? (int)$this->attributes['limit'] : 0;
2020
$width = isset($this->attributes['width']) ? $this->attributes['width'] : '100%';
2121
$height = isset($this->attributes['height']) ? $this->attributes['height'] : '200px';
22-
$this->addVariables(['width'=>$width,'height' => $height]);
22+
$menu_mode = isset($this->attributes['menu_mode']) ? (bool)$this->attributes['menu_mode'] : false;
23+
$menu_placeholder = isset($this->attributes['menu_placeholder']) ? $this->attributes['menu_mode'] : '未选择';
24+
$this->addVariables(['width' => $width, 'height' => $height]);
2325
$select = json_encode($this->options, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
2426
$selected = json_encode($this->checked);
2527
$this->script = <<<EOT
26-
new ComponentDot("{$id}",JSON.parse('{$selected}'),JSON.parse('{$select}'),{$limit});
28+
new ComponentDot("{$id}",JSON.parse('{$selected}'),JSON.parse('{$select}'),{$limit},{$menu_mode},'{$menu_placeholder}');
2729
EOT;
2830
return parent::render();
2931
}
3032

3133
/**
3234
* 直接调用ComponentDot组件
33-
* @param string $name 名称
34-
* @param array $selected 已选择id组 [1,2,3...]
35-
* @param array $select 全部选项
36-
* @param int $limit 选择限制数 默认0:无限
37-
* @param array $style 组件样式设置 宽:width 高:height
35+
* @param string $name 名称
36+
* @param array $selected 已选择id组 [1,2,3...]
37+
* @param array $select 全部选项
38+
* @param int $limit 选择限制数 默认0:无限
39+
* @param array $style 组件样式设置 宽:width 高:height
40+
* @param boolean $menu_mode 组件模式设置 false:默认模式 true:下拉列表模式
41+
* @param string $menu_placeholder 下拉列表模式 默认未选择占位
3842
* @return string
3943
*/
40-
public static function panel($name,array $selected,array $select,int $limit=1,array $style=[])
44+
public static function panel($name, array $selected, array $select, int $limit = 1, array $style = [], $menu_mode = false, $menu_placeholder = '未选择')
4145
{
4246
$selected = json_encode($selected, JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
4347
$select = json_encode($select, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT | JSON_HEX_APOS);
44-
$style = array_merge(['width'=>'100%','height'=>'200px'],$style);
48+
$style = array_merge(['width' => '100%', 'height' => '200px'], $style);
4549
$style_string = '';
46-
foreach ($style as $k=>$s){
47-
$style_string.="$k:$s;";
50+
foreach ($style as $k => $s) {
51+
$style_string .= "$k:$s;";
4852
}
4953

5054
return <<<EOF
51-
<div id="{$name}" style="$style_string"></div>
52-
<script>
53-
new ComponentDot("{$name}",JSON.parse('{$selected}'),JSON.parse('{$select}'),{$limit});
54-
</script>
55+
<div id="{$name}" style="$style_string"></div><script>new ComponentDot("{$name}",JSON.parse('{$selected}'),JSON.parse('{$select}'),{$limit},{$menu_mode},{$menu_placeholder});</script>
5556
EOF;
5657
}
5758
}

src/Widget/Linear.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,7 @@ public static function panel($name,array $columns, array $data, array $style = [
7171
$options = json_encode(array_merge(['sortable' => true, 'delete' => true, 'insert' => true], $options));
7272

7373
return <<<EOF
74-
<div id="{$name}" style="$style_string"></div>
75-
<script>
76-
new ComponentLine("{$name}",JSON.parse('{$columns}'),JSON.parse('{$data}'),JSON.parse('{$options}'));
77-
</script>
74+
<div id="{$name}" style="$style_string"></div><script>new ComponentLine("{$name}",JSON.parse('{$columns}'),JSON.parse('{$data}'),JSON.parse('{$options}'));</script>
7875
EOF;
7976
}
8077
}

0 commit comments

Comments
 (0)