PageSourceSearch

https://www.joinkfa.com/nexacro17lib/component/ComComp/CheckBox.js

js joinkfa.com collected 2026-10-02 06:31:57 UTC 10,537 bytes, 420 lines download raw bytes

1//==============================================================================
2//
3//  TOBESOFT Co., Ltd.
4//  Copyright 2017 TOBESOFT Co., Ltd.
5//  All Rights Reserved.
6//
7//  NOTICE: TOBESOFT permits you to use, modify, and distribute this file 
8//          in accordance with the terms of the license agreement accompanying it.
9//
10//  Readme URL: http://www.nexacro.co.kr/legal/nexacro17-public-license-readme-1.1.html
11//
12//==============================================================================
13
14if (!nexacro.CheckBox) {
15	nexacro.CheckBoxChangedEventInfo = function (obj, id, prevalue, postvalue) {
16		this.id = this.eventid = id || "onchanged";
17		this.prevalue = prevalue;
18		this.postvalue = postvalue;
19		this.fromobject = this.fromreferenceobject = obj;
20	};
21
22	var _pCheckBoxChangedEventInfo = nexacro._createPrototype(nexacro.ChangedEventInfo, nexacro.CheckBoxChangedEventInfo);
23	nexacro.CheckBoxChangedEventInfo.prototype = _pCheckBoxChangedEventInfo;
24	_pCheckBoxChangedEventInfo._type_name = "CheckBoxChangedEventInfo";
25
26	delete _pCheckBoxChangedEventInfo;
27
28	nexacro.CheckBox = function (id, left, top, width, height, right, bottom, minwidth, maxwidth, minheight, maxheight, parent) {
29		nexacro._IconText.call(this, id, left, top, width, height, right, bottom, minwidth, maxwidth, minheight, maxheight, parent);
30	};
31
32	var _pCheckBox = nexacro._createPrototype(nexacro._IconText, nexacro.CheckBox);
33	nexacro.CheckBox.prototype = _pCheckBox;
34	_pCheckBox._type_name = "CheckBox";
35
36
37	_pCheckBox.value = false;
38	_pCheckBox.readonly = false;
39	_pCheckBox.falsevalue = null;
40	_pCheckBox.truevalue = null;
41	_pCheckBox.tabstop = true;
42
43
44	_pCheckBox._is_focus_accept = true;
45	_pCheckBox._use_selected_status = true;
46	_pCheckBox._use_readonly_status = true;
47
48	_pCheckBox.accessibilityrole = "checkbox";
49
50
51	_pCheckBox._event_list = 
52		{
53		"canchange" : 1, 
54		"onchanged" : 1, 
55		"onclick" : 1, 
56		"ondrag" : 1, 
57		"ondragenter" : 1, 
58		"ondragmove" : 1, 
59		"ondragleave" : 1, 
60		"ondrop" : 1, 
61		"onkeydown" : 1, 
62		"onkeyup" : 1, 
63		"onkillfocus" : 1, 
64		"onsetfocus" : 1, 
65		"onlbuttondown" : 1, 
66		"onlbuttonup" : 1, 
67		"onrbuttondown" : 1, 
68		"onrbuttonup" : 1, 
69		"onmousedown" : 1, 
70		"onmouseup" : 1, 
71		"onmouseenter" : 1, 
72		"onmousemove" : 1, 
73		"onmouseleave" : 1, 
74		"onmove" : 1, 
75		"onsize" : 1, 
76		"oncontextmenu" : 1, 
77		"ontouchstart" : 1, 
78		"ontouchmove" : 1, 
79		"ontouchend" : 1
80	};
81
82	_pCheckBox.on_created_contents = function (win) {
83		nexacro._IconText.prototype.on_created_contents.call(this, win);
84
85		this._setAccessibilityStatChecked(this.isChecked());
86	};
87
88	_pCheckBox.on_attach_contents_handle = function (win) {
89		nexacro._IconText.prototype.on_attach_contents_handle.call(this, win);
90
91		this._setAccessibilityStatChecked(this.isChecked());
92	};
93
94	_pCheckBox.on_destroy_contents = function () {
95		nexacro._IconText.prototype.on_destroy_contents.call(this);
96
97		this.falsevalue = null;
98		this.truevalue = null;
99	};
100
101	_pCheckBox.on_init_bindSource = function (columnid, propid, ds) {
102		if (propid == "value") {
103			this._setValue(this._changeValue(undefined));
104			this.on_apply_value();
105		}
106	};
107
108	_pCheckBox.on_change_bindSource = function (propid, ds, row, col) {
109		if (propid == "value") {
110			this._setValue(this._changeValue(ds.getColumn(row, col)));
111			this.on_apply_value();
112		}
113	};
114
115	_pCheckBox.on_getBindableProperties = function () {
116		return "value";
117	};
118
119	_pCheckBox.on_get_accessibility_label = function () {
120		return this.text ? this.text : "";
121	};
122
123	_pCheckBox._on_hotkey = function (key_code, alt_key, ctrl_key, shift_key) {
124		this.on_fire_onclick("", alt_key, ctrl_key, shift_key, -1, -1, -1, -1, -1, -1, this, this, false);
125	};
126
127	_pCheckBox._isFocusAcceptable = function () {
128		return this._is_focus_accept;
129	};
130
131	_pCheckBox.set_value = function (v) {
132		v = this._changeValue(v);
133		if (this.value != v) {
134			if (this.applyto_bindSource("value", v)) {
135				this._setValue(v);
136				this.on_apply_value();
137			}
138		}
139	};
140
141	_pCheckBox.on_apply_value = function () {
142		if (this.isChecked()) {
143			this._changeUserStatus("selected", true);
144		}
145		else {
146			this._changeUserStatus("selected", false);
147		}
148	};
149
150	_pCheckBox.set_truevalue = function (v) {
151		if (v != undefined) {
152			v = v.toString();
153		}
154
155		if (this.truevalue !== v) {
156			if (this.isChecked()) {
157				if (this.applyto_bindSource("value", v)) {
158					this._setValue(v);
159				}
160			}
161			this.truevalue = v;
162		}
163	};
164
165	_pCheckBox.set_falsevalue = function (v) {
166		if (v != undefined) {
167			v = v.toString();
168		}
169
170		if (this.falsevalue !== v) {
171			if (!this.isChecked()) {
172				if (this.applyto_bindSource("value", v)) {
173					this._setValue(v);
174				}
175			}
176			this.falsevalue = v;
177		}
178	};
179
180	_pCheckBox.set_readonly = function (v) {
181		v = nexacro._toBoolean(v);
182		if (v != this.readonly) {
183			this.readonly = v;
184			this.on_apply_readonly(v);
185		}
186	};
187
188	_pCheckBox.on_apply_readonly = function (readonly) {
189		this._changeStatus("readonly", readonly);
190	};
191
192	_pCheckBox.isChecked = function () {
193		return this._isChecked(this.value);
194	};
195
196	_pCheckBox.on_keyup_basic_action = function (key_code, alt_key, ctrl_key, shift_key, refer_comp, meta_key) {
197		if (key_code == nexacro.Event.KEY_SPACE) {
198			this.on_fire_onclick("", alt_key, ctrl_key, shift_key, -1, -1, -1, -1, -1, -1, refer_comp, refer_comp, meta_key);
199		}
200	};
201
202	_pCheckBox.on_fire_onclick = function (button, alt_key, ctrl_key, shift_key, screenX, screenY, canvasX, canvasY, clientX, clientY, from_comp, from_refer_comp, meta_key) {
203		if (!this.enable || this.readonly) {
204			return false;
205		}
206
207		var pre_val = this.value;
208		var post_val;
209		if (this._isChecked(pre_val)) {
210			if (nexacro._isNull(this.falsevalue)) {
211				post_val = false;
212			}
213			else {
214				post_val = this.falsevalue;
215			}
216		}
217		else {
218			if (nexacro._isNull(this.truevalue)) {
219				post_val = true;
220			}
221			else {
222				post_val = this.truevalue;
223			}
224		}
225
226		var ret = this.on_fire_canchange(this, pre_val, post_val);
227		if (ret) {
228			if (this.applyto_bindSource("value", post_val)) {
229				this._setValue(post_val);
230			}
231
232			if (pre_val !== post_val) {
233				this.on_fire_onchanged(this, pre_val, post_val);
234			}
235			if (this._is_alive) {
236				this.on_apply_value();
237			}
238		}
239
240		if (this._is_alive) {
241			return nexacro.Component.prototype.on_fire_onclick.call(this, button, alt_key, ctrl_key, shift_key, screenX, screenY, canvasX, canvasY, clientX, clientY, from_comp, from_refer_comp, meta_key);
242		}
243	};
244
245	_pCheckBox.on_fire_canchange = function (obj, prevalue, postvalue) {
246		if (this.canchange && this.canchange._has_handlers) {
247			var evt = new nexacro.CheckBoxChangedEventInfo(this, "canchange", prevalue, postvalue);
248			return this.canchange._fireCheckEvent(this, evt);
249		}
250
251		return true;
252	};
253
254	_pCheckBox.on_fire_onchanged = function (obj, prevalue, postvalue) {
255		if (this.onchanged && this.onchanged._has_handlers) {
256			var evt = new nexacro.CheckBoxChangedEventInfo(this, "onchanged", prevalue, postvalue);
257			return this.onchanged._fireEvent(this, evt);
258		}
259	};
260
261	_pCheckBox._on_click = function (elem, button, alt_key, ctrl_key, shift_key, canvasX, canvasY, screenX, screenY, meta_key) {
262		if (!this._is_alive) {
263			return;
264		}
265
266		if (this.visible && this._isEnable()) {
267			var clientXY = this._getClientXY(canvasX, canvasY);
268			this.on_fire_onclick(button, alt_key, ctrl_key, shift_key, screenX, screenY, canvasX, canvasY, clientXY[0], clientXY[1], this, this, meta_key);
269			this.on_click_basic_action(elem, button, alt_key, ctrl_key, shift_key, canvasX, canvasY, screenX, screenY, meta_key);
270		}
271	};
272
273	_pCheckBox._setValue = function (v) {
274		this.value = v;
275		this._setAccessibilityStatChecked(this.isChecked());
276	};
277
278	_pCheckBox._isChecked = function (value) {
279		if (this.truevalue != null) {
280			if (this.falsevalue != null) {
281				if (value === this.falsevalue || value === undefined) {
282					return false;
283				}
284
285				if (value === this.truevalue || nexacro._toBoolean(value)) {
286					return true;
287				}
288
289				if (this.value === this.truevalue) {
290					return true;
291				}
292
293				return false;
294			}
295			else {
296				if (value === this.truevalue || nexacro._toBoolean(value)) {
297					return true;
298				}
299
300				return false;
301			}
302		}
303		else {
304			if (this.falsevalue != null) {
305				if (value === this.falsevalue) {
306					return false;
307				}
308
309				return true;
310			}
311			else {
312				return nexacro._toBoolean(value);
313			}
314		}
315	};
316
317	_pCheckBox._changeValue = function (v) {
318		var use_truevalue = !nexacro._isNull(this.truevalue);
319		var use_falsevalue = !nexacro._isNull(this.falsevalue);
320
321		if (nexacro._isNull(v)) {
322			if (use_falsevalue) {
323				return this.falsevalue;
324			}
325			else {
326				return false;
327			}
328		}
329
330		v = v.toString();
331		if (use_truevalue) {
332			if (v === this.truevalue) {
333				return v;
334			}
335
336			if (use_falsevalue) {
337				if (v === this.falsevalue) {
338					return v;
339				}
340				else {
341					return this.value;
342				}
343			}
344			else {
345				if (parseInt(v) === 0) {
346					return 0;
347				}
348				else if (!nexacro._toBoolean(v)) {
349					return false;
350				}
351				else {
352					return this.value;
353				}
354			}
355		}
356		else {
357			if (use_falsevalue) {
358				if (v === this.falsevalue) {
359					return v;
360				}
361				else if (parseInt(v) === 1) {
362					return 1;
363				}
364				else if (nexacro._toBoolean(v)) {
365					return true;
366				}
367				else {
368					return this.value;
369				}
370			}
371			else {
372				if (parseInt(v) === 0) {
373					return 0;
374				}
375				else if (parseInt(v) === 1) {
376					return 1;
377				}
378				else {
379					return nexacro._toBoolean(v);
380				}
381			}
382		}
383	};
384
385	_pCheckBox._applyStatus = function () {
386		var pre_val = this.value;
387		var post_val;
388		if (this._isChecked(pre_val)) {
389			if (nexacro._isNull(this.falsevalue)) {
390				post_val = false;
391			}
392			else {
393				post_val = this.falsevalue;
394			}
395		}
396		else {
397			if (nexacro._isNull(this.truevalue)) {
398				post_val = true;
399			}
400			else {
401				post_val = this.truevalue;
402			}
403		}
404
405		var ret = this.on_fire_canchange(this, pre_val, post_val);
406		if (ret) {
407			if (this.applyto_bindSource("value", post_val)) {
408				this._setValue(post_val);
409			}
410
411			if (pre_val !== post_val) {
412				this.on_fire_onchanged(this, pre_val, post_val);
413			}
414			if (this._is_alive) {
415				this.on_apply_value();
416			}
417		}
418	};
419	delete _pCheckBox;
420}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.