PluginProbe
Tag Groups is the Advanced Way to Display Your Taxonomy Terms / trunk
Tag Groups is the Advanced Way to Display Your Taxonomy Terms vtrunk
2.2.2 2.2.1 2.2.0 trunk 1.40.0 1.40.2 1.41.0 1.42.1 1.43.0 1.43.1 1.43.10 1.43.10.1 1.43.2 1.43.3 1.43.4 1.43.5 1.43.6 1.43.7 1.43.9 1.44.0 1.44.1 1.44.3 1.44.3.1 2.0.0 2.0.1 All 36 releases
tag-groups / src / modules / handlers.js

handlers.js in Tag Groups is the Advanced Way to Display Your Taxonomy Terms trunk, at src/modules/handlers.js

154 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 export function handleChangeInclude(_this, options) {
2 let selectedInclude = options.map(function (option) {
3 if (!isNaN(option.value)) {
4 return option.value;
5 }
6 });
7
8 // Set the state
9 _this.setState({ selectedInclude });
10
11 // Set the attributes
12 _this.props.setAttributes({
13 include: selectedInclude.join(','),
14 });
15
16
17 if (_this.state.selectedExclude !== undefined) {
18 // remove elements in selectedInclude from selectedExclude
19 let selectedExcludeTmp = _this.state.selectedExclude;
20 selectedInclude.forEach(function (id) {
21 const i = selectedExcludeTmp.indexOf(id);
22 if (i > -1) {
23 selectedExcludeTmp.splice(i, 1);
24 }
25 });
26 _this.setState({ selectedExclude: selectedExcludeTmp });
27 _this.props.setAttributes({
28 exclude: selectedExcludeTmp.join(','),
29 });
30 }
31
32 if (_this.props.show_not_assigned !== undefined) {
33 if (selectedInclude.indexOf(0) > -1) {
34 _this.props.setAttributes({
35 show_not_assigned: 1,
36 });
37 } else {
38 _this.props.setAttributes({
39 show_not_assigned: 0,
40 });
41 }
42 }
43 }
44
45 export function handleChangeExclude(_this, options) {
46 let selectedExclude = options.map(function (option) {
47 if (!isNaN(option.value)) {
48 return option.value;
49 }
50 });
51
52 // Set the state
53 _this.setState({ selectedExclude });
54
55 // Set the attributes
56 _this.props.setAttributes({
57 exclude: selectedExclude.join(','),
58 });
59
60 if (_this.state.selectedInclude !== undefined) {
61 // remove elements in selectedExclude from selectedInclude
62 let selectedIncludeTmp = _this.state.selectedInclude;
63 selectedExclude.forEach(function (id) {
64 const i = selectedIncludeTmp.indexOf(id);
65 if (i > -1) {
66 selectedIncludeTmp.splice(i, 1);
67 }
68 });
69 _this.setState({ selectedInclude: selectedIncludeTmp });
70 _this.props.setAttributes({
71 include: selectedIncludeTmp.join(','),
72 });
73 }
74 }
75
76 export function handleChangeTaxonomy(_this, options) {
77 let selectedTaxonomies = options.map(function (option) {
78 if (typeof option.value === 'string') {
79 return option.value;
80 }
81 });
82
83 // Set the state
84 _this.setState({ selectedTaxonomies });
85
86 // Set the attributes
87 _this.props.setAttributes({
88 taxonomy: selectedTaxonomies.join(','),
89 });
90 }
91
92 export function toggleOptionActive(_this) {
93 let active = _this.props.attributes.active < 0 ? 0 : -1; // -1 is a replacement for false, since data type is integer and 0 is reserved
94 _this.props.setAttributes({ active });
95 }
96
97 export function toggleOptionCollapsible(_this) {
98 let collapsible = _this.props.attributes.collapsible ? 0 : 1;
99 _this.props.setAttributes({ collapsible });
100 }
101
102 export function toggleOptionMouseover(_this) {
103 let mouseover = _this.props.attributes.mouseover ? 0 : 1;
104 _this.props.setAttributes({ mouseover });
105 }
106
107 export function toggleOptionAdjustSeparatorSize(_this) {
108 let adjust_separator_size = _this.props.attributes.adjust_separator_size
109 ? 0
110 : 1;
111 _this.props.setAttributes({ adjust_separator_size });
112 }
113
114 export function toggleOptionAddPremiumFilter(_this) {
115 let add_premium_filter = _this.props.attributes.add_premium_filter ? 0 : 1;
116 _this.props.setAttributes({ add_premium_filter });
117 }
118
119 export function toggleOptionHideEmptyTabs(_this) {
120 let hide_empty_tabs = _this.props.attributes.hide_empty_tabs ? 0 : 1;
121 _this.props.setAttributes({ hide_empty_tabs });
122 }
123
124 export function toggleOptionShowTabs(_this) {
125 let show_tabs = _this.props.attributes.show_tabs ? 0 : 1;
126 _this.props.setAttributes({ show_tabs });
127 }
128
129 export function toggleOptionShowTagCount(_this) {
130 let show_tag_count = _this.props.attributes.show_tag_count ? 0 : 1;
131 _this.props.setAttributes({ show_tag_count });
132 }
133
134 export function toggleOptionDelay(_this) {
135 let delay = _this.props.attributes.delay ? 0 : 1;
136 _this.props.setAttributes({ delay });
137 }
138
139 export function toggleOptionHideEmptyContent(_this) {
140 let hide_empty_content =
141 1 === _this.props.attributes.hide_empty_content ? 0 : 1;
142 _this.props.setAttributes({ hide_empty_content });
143 }
144
145 export function toggleOptionShowAccordion(_this) {
146 let show_accordion = _this.props.attributes.show_accordion ? 0 : 1;
147 _this.props.setAttributes({ show_accordion });
148 }
149
150 export function toggleOptionKeepTogether(_this) {
151 let keep_together = _this.props.attributes.keep_together ? 0 : 1;
152 _this.props.setAttributes({ keep_together });
153 }
154