PageSourceSearch

https://framesi.it/nextgest/assets/_core/js/control.js

js framesi.it collected 2026-10-02 06:31:44 UTC 8,613 bytes, 280 lines download raw bytes

1/////////////////////////////////
2// Controls-related functionality
3/////////////////////////////////
4
5	qcubed.getControl = function(mixControl) {
6		if (typeof(mixControl) == 'string')
7			return document.getElementById(mixControl);
8		else
9			return mixControl;
10	};
11
12	qcubed.getWrapper = function(mixControl) {
13		var objControl;
14		if (!(objControl = qcubed.getControl(mixControl))) 
15		{
16            //maybe it doesn't have a child control, just the wrapper
17			if (typeof(mixControl) == 'string')
18		    	return this.getControl(mixControl + "_ctl");
19		    	
20		    return;
21		}
22
23		if (objControl)
24			return this.getControl(objControl.id + "_ctl");			
25		else
26			return null;
27	};
28
29
30
31/////////////////////////////
32// Register Control - General
33/////////////////////////////
34	
35	qcubed.controlModifications = new Object;
36	qcubed.javascriptStyleToQcodo = new Object;
37	qcubed.javascriptStyleToQcodo["backgroundColor"] = "BackColor";
38	qcubed.javascriptStyleToQcodo["borderColor"] = "BorderColor";
39	qcubed.javascriptStyleToQcodo["borderStyle"] = "BorderStyle";
40	qcubed.javascriptStyleToQcodo["border"] = "BorderWidth";
41	qcubed.javascriptStyleToQcodo["height"] = "Height";
42	qcubed.javascriptStyleToQcodo["width"] = "Width";
43	qcubed.javascriptStyleToQcodo["text"] = "Text";
44
45	qcubed.javascriptWrapperStyleToQcodo = new Object;
46	qcubed.javascriptWrapperStyleToQcodo["position"] = "Position";
47	qcubed.javascriptWrapperStyleToQcodo["top"] = "Top";
48	qcubed.javascriptWrapperStyleToQcodo["left"] = "Left";
49
50	qcubed.recordControlModification = function(strControlId, strProperty, strNewValue) {
51		if (!qcubed.controlModifications[strControlId])
52			qcubed.controlModifications[strControlId] = new Object;
53		qcubed.controlModifications[strControlId][strProperty] = strNewValue;	
54	};
55
56	qcubed.registerControl = function(mixControl) {
57		var objControl; 
58		objControl = qcubed.getControl(mixControl);
59
60		// Link the Wrapper and the Control together
61		var objWrapper = this.getWrapper(mixControl);
62		if(!objWrapper) return;
63
64	    if(objControl !== null)
65    		objControl.wrapper = objWrapper;
66    	
67		objWrapper.control = objControl;
68
69		// Add the wrapper to the global qcodo wrappers array
70		qcubed.wrappers[objWrapper.id] = objWrapper;
71
72
73		// Create New Methods, etc.
74		// Like: objWrapper.something = xyz;
75
76		// Updating Style-related Things
77		objWrapper.updateStyle = function(strStyleName, strNewValue) {
78		    if(this.control === null)
79		    {
80			    switch (strStyleName) {
81				    case "display":
82					    if (strNewValue) {
83						    objWrapper.style.display = "inline";
84					    } else {
85						    objWrapper.style.display = "none";
86					    };
87					    break;
88				    default:
89					    if (qcubed.javascriptWrapperStyleToQcodo[strStyleName]) {
90						    this.style[strStyleName] = strNewValue;
91					    };
92					    break;
93			    };
94    		    return;
95		    }
96		
97			var objControl = this.control;
98			
99			switch (strStyleName) {
100				case "className":
101					objControl.className = strNewValue;
102					qcubed.recordControlModification(objControl.id, "CssClass", strNewValue);
103					break;
104					
105				case "parent":
106					if (strNewValue) {
107						var objNewParentControl = qcubed.getControl(strNewValue);
108						objNewParentControl.appendChild(this);
109						qcubed.recordControlModification(objControl.id, "Parent", strNewValue);
110					} else {
111						var objParentControl = this.parentNode;
112						objParentControl.removeChild(this);
113						qcubed.recordControlModification(objControl.id, "Parent", "");
114					};
115					break;
116				
117				case "displayStyle":
118					objControl.style.display = strNewValue;
119					qcubed.recordControlModification(objControl.id, "DisplayStyle", strNewValue);
120					break;
121
122				case "display":
123					if (strNewValue) {
124						objWrapper.style.display = "inline";
125						qcubed.recordControlModification(objControl.id, "Display", "1");
126					} else {
127						objWrapper.style.display = "none";
128						qcubed.recordControlModification(objControl.id, "Display", "0");
129					};
130					break;
131
132				case "enabled":
133					if (strNewValue) {
134						objWrapper.control.disabled = false;
135						qcubed.recordControlModification(objControl.id, "Enabled", "1");
136					} else {
137						objWrapper.control.disabled = true;
138						qcubed.recordControlModification(objControl.id, "Enabled", "0");
139					};
140					break;
141					
142				case "width":
143				case "height":
144					objControl.style[strStyleName] = strNewValue;
145					if (qcubed.javascriptStyleToQcodo[strStyleName])
146						qcubed.recordControlModification(objControl.id, qcubed.javascriptStyleToQcodo[strStyleName], strNewValue);
147					if (objWrapper.handle)
148						objWrapper.updateHandle();
149					break;
150
151				case "text":
152					objControl.innerHTML = strNewValue;
153					qcubed.recordControlModification(objControl.id, "Text", strNewValue);
154					break;
155
156				default:
157					if (qcubed.javascriptWrapperStyleToQcodo[strStyleName]) {
158						this.style[strStyleName] = strNewValue;
159						qcubed.recordControlModification(objControl.id, qcubed.javascriptWrapperStyleToQcodo[strStyleName], strNewValue);
160					} else {
161						objControl.style[strStyleName] = strNewValue;
162						if (qcubed.javascriptStyleToQcodo[strStyleName])
163							qcubed.recordControlModification(objControl.id, qcubed.javascriptStyleToQcodo[strStyleName], strNewValue);
164					};
165					break;
166			};
167		};
168
169		// Positioning-related functions
170
171		objWrapper.getAbsolutePosition = function() {
172			var intOffsetLeft = 0;
173			var intOffsetTop = 0;
174
175			var objControl = this.control;
176
177			while (objControl) {
178				// If we are IE, we don't want to include calculating
179				// controls who's wrappers are position:relative
180				if ((objControl.wrapper) && (objControl.wrapper.style.position == "relative")) {
181					
182				} else {
183					intOffsetLeft += objControl.offsetLeft;
184					intOffsetTop += objControl.offsetTop;
185				};
186				objControl = objControl.offsetParent;
187			};
188
189			return {x:intOffsetLeft, y:intOffsetTop};
190		};
191
192		objWrapper.setAbsolutePosition = function(intNewX, intNewY, blnBindToParent) {
193			var objControl = this.offsetParent;
194
195			while (objControl) {
196				intNewX -= objControl.offsetLeft;
197				intNewY -= objControl.offsetTop;
198				objControl = objControl.offsetParent;
199			};
200
201			if (blnBindToParent) {
202				if (this.parentNode.nodeName.toLowerCase() != 'form') {
203					// intNewX and intNewY must be within the parent's control
204					intNewX = Math.max(intNewX, 0);
205					intNewY = Math.max(intNewY, 0);
206
207					intNewX = Math.min(intNewX, this.offsetParent.offsetWidth - this.offsetWidth);
208					intNewY = Math.min(intNewY, this.offsetParent.offsetHeight - this.offsetHeight);
209				};
210			};
211
212			this.updateStyle("left", intNewX + "px");
213			this.updateStyle("top", intNewY + "px");
214		};
215
216		// Toggle Display / Enabled
217		objWrapper.toggleDisplay = function(strShowOrHide) {
218			// Toggles the display/hiding of the entire control (including any design/wrapper HTML)
219			// If ShowOrHide is blank, then we toggle
220			// Otherwise, we'll execute a "show" or a "hide"
221			if (strShowOrHide) {
222				if (strShowOrHide == "show")
223					this.updateStyle("display", true);
224				else
225					this.updateStyle("display", false);
226			} else
227				this.updateStyle("display", (this.style.display == "none") ? true : false);
228		};
229
230		objWrapper.toggleEnabled = function(strEnableOrDisable) {
231			if (strEnableOrDisable) {
232				if (strEnableOrDisable == "enable")
233					this.updateStyle("enabled", true);
234				else
235					this.updateStyle("enabled", false);
236			} else
237				this.updateStyle("enabled", (this.control.disabled) ? true : false);
238		};
239
240		objWrapper.registerClickPosition = function(objEvent) {			
241			var intX = objEvent.pageX - this.control.offsetLeft;
242			var intY = objEvent.pageY - this.control.offsetTop;
243			
244			$j('#' + this.control.id + "_x").val(intX);
245			$j('#' + this.control.id + "_y").val(intY);
246		};
247		
248		// Focus
249		objWrapper.focus = function() {
250			$j('#' + this.control.id).focus();	
251		};
252		
253		// Select All (will only work for textboxes only)
254		objWrapper.select = function() {
255			$j('#' + this.control.id).select();
256		};
257
258		// Blink
259		objWrapper.blink = function(strFromColor, strToColor) {		
260			$j('#' + this.control.id).css('background-color', '' + strFromColor);
261			$j('#' + this.control.id).animate({ backgroundColor: '' + strToColor }, 500)
262		};
263	}
264
265	qcubed.registerControlArray = function(mixControlArray) {
266		var intLength = mixControlArray.length;
267		for (var intIndex = 0; intIndex < intLength; intIndex++)
268			qcubed.registerControl(mixControlArray[intIndex]);
269	};
270
271
272
273//////////////////
274// Qcodo Shortcuts
275//////////////////
276
277	qc.getC = qcubed.getControl;
278	qc.getW = qcubed.getWrapper;
279	qc.regC = qcubed.registerControl;
280	qc.regCA = qcubed.registerControlArray;

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.