PageSourceSearch

https://www.visegradgroup.eu/js/aitia/aitia_style.js?ts=1610541287

js visegradgroup.eu collected 2026-09-24 18:14:57 UTC 8,441 bytes, 287 lines download raw bytes

1// függőségek
2if ("undefined" == typeof AITIA) {
3	alert("AITIA include missing!");
4}
5if ("undefined" == typeof AITIA_BROWSER) {
6	alert("AITIA_BROWSER include missing!");
7}
8
9
10
11// többszörös include
12if ("undefined" != typeof AITIA_STYLE) {
13	 alert("AITIA_STYLE multiple insert!");
14}
15
16AITIA_STYLE = 1;
17
18Aitia.Style = {};
19
20////TODO benchmark: regexp vs split array
21Aitia.Style.hasClass = function(el,className) {
22	if ( el && typeof el.className!='undefined' ) {
23		//var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)');
24		var re = new RegExp("(^|\\s)" + className + "(\\s|$)","gi");
25	
26		return re.test(el.className);
27	} else {
28		return false;
29	}
30} // hasClass
31
32
33Aitia.Style.addClass = function(el, className) {
34  if (null == el.className || "undefined" == typeof el.className || "" == el.className) {  //opera miatt
35    el.className = className;
36  } else if (false == this.hasClass(el, className)) {
37    el.className += ' ' + className;
38  }  
39} // addClass
40
41Aitia.Style.removeClass = function(el, className) {
42  if (!(el && el.className)) {
43    return;
44  }
45  var cls = el.className.split(' ');
46  var ar = new Array();
47  for (var i = cls.length; i > 0;) {
48    if (cls[--i] != className) {
49      ar[ar.length] = cls[i];
50    }
51  }
52  el.className = ar.join(' ');
53} // removeClass
54
55
56Aitia.Style.removeStyle = function(el,attr) {
57  if (el && el.style) {
58    if (Aitia.Browser.ieDom) {
59      el.style.removeAttribute(attr);  //IE
60    } else {
61      el.style.removeProperty(attr);
62    }
63  }
64} // removeStyle
65
66
67Aitia.Style.getCssRuleBySelectorFromSheet = function(sheet,selector) {
68  if (Aitia.Browser.nsDom) {
69    var ruleList = sheet.cssRules;
70
71    for (var j = 0; j < ruleList.length; ++j) {
72      //    alert("selector:"+ruleList[j].selectorText);
73      if (ruleList[j].type == CSSRule.STYLE_RULE && ruleList[j].selectorText == selector) {
74        return ruleList[j];
75      } else if (ruleList[j].type == CSSRule.IMPORT_RULE) {
76        //         alert("import!!:"+ruleList[j].href);
77        var ret = this.getCssRuleBySelectorFromSheet(ruleList[j].styleSheet,selector);
78        if (ret != null) {
79          return ret;
80        }
81      }
82    }
83  } else if (Aitia.Browser.ieDom) {
84    //elobb az importalt sheet-et keressuk
85    for (var j = 0; j < sheet.imports.length; ++j) {
86      var ret = this.getCssRuleBySelectorFromSheet(sheet.imports[j],selector);
87      if (ret != null) {
88        return ret;
89      }
90    }
91    var ruleList = sheet.rules;
92    for (var j = 0; j < ruleList.length; ++j) {
93//    alert(ruleList[j].selectorText);
94      if (ruleList[j].selectorText == selector) {
95        return ruleList[j];
96      }   
97    }
98  
99  }
100  return null;
101} // getCssRuleBySelectorFromSheet
102
103//ez a style objektumot adja vissza, 
104//lehet, hogy a cssrule-t kellene
105Aitia.Style.getCssRuleBySelector = function( selector ) {
106  var sheetList = document.styleSheets;
107  var ruleList;
108  var i, j;
109
110
111  if (sheetList) {
112    /* look through stylesheets in reverse order that
113       they appear in the document */
114    for (i = sheetList.length-1; i >= 0; --i) {
115      var ret = this.getCssRuleBySelectorFromSheet(sheetList[i],selector);
116      if (ret != null) {
117        return ret;
118      }
119    }
120  }
121  return null;
122} // getCssRuleBySelector
123
124
125//node.style -ebben az van, ami inline, vagy js-ből lett beállítva
126Aitia.Style.getStyle = function(el,attr,num) {
127  var value = el.style[this.toCamelCase(attr)];
128  if ("" == value) {
129    if (document.defaultView) {
130      value = document.defaultView.getComputedStyle(el, "").getPropertyValue(attr);
131    } else if (el.currentStyle) {
132      value = el.currentStyle[this.toCamelCase(attr)];
133    }
134  }
135  if (num) {
136    value = parseInt(value,10);
137    if (isNaN(value)) {
138      value = 0;
139    }
140  }
141  return value;
142} // getStyle
143
144Aitia.Style.toCamelCase = function( sInput ) {
145  var sArray = sInput.split('-');
146  if(1 == sArray.length) {
147    return sArray[0];
148  }
149  var ret = sArray[0];
150  for(var i = 1; i < sArray.length; ++i){
151    var s = sArray[i];
152    ret += s.charAt(0).toUpperCase() + s.substring(1)
153  }
154  return ret;
155} // toCamelCase
156
157Aitia.Style.fromCamelCase = function(camel) {
158  return camel.replace(/([A-Z])/g,"-$1").toLowerCase();
159} // fromCamelCase
160
161
162
163Aitia.Style.camelize = function(currentElement) {
164	var parts = currentElement.split('-'), len = parts.length;
165	if (len == 1) return parts[0];
166
167	var camelized = currentElement.charAt(0) == '-'
168	? parts[0].charAt(0).toUpperCase() + parts[0].substring(1)
169	: parts[0];
170
171	for (var i = 1; i < len; i++)
172	camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1);
173
174	return camelized;
175}
176
177Aitia.Style.capitalize = function(currentElement) {
178	return currentElement.charAt(0).toUpperCase() + currentElement.substring(1).toLowerCase();
179}
180
181Aitia.Style.getComputedStyle = function(currentElement, style, currentWindow) {
182	currentWindow = typeof currentWindow!='undefined' && currentWindow ? currentWindow : window;
183	
184	if ( Aitia.Browser.ieVersion>0 ) {
185		style = (style=='float' || style=='cssFloat') ? 'styleFloat' : this.camelize(style);
186		var value = currentElement.style[style];
187		
188		if ( !value && currentElement.currentStyle ) {
189			value = currentElement.currentStyle[style];
190		}
191
192		if ( style=='opacity' ) {
193			if ( value = (this.getComputedStyle(currentElement,'filter',currentWindow) || '').match(/alpha\(opacity=(.*)\)/) ) {
194				if ( value[1] ) {
195					return parseFloat(value[1]) / 100;
196				}
197			}
198			
199			return 1.0;
200		}
201
202		if ( value=='auto' ) {
203			if ( style=='width' && Aitia.Style.getComputedStyle(currentElement,'display')!='none' ) {
204				var width = currentElement['offset' + this.capitalize(style)];
205				
206				var padding = parseInt(Aitia.Style.getComputedStyle(currentElement,'padding-left'),10);
207				padding = ( isNaN(padding) ? 0 : padding );
208				var padding2 = parseInt(Aitia.Style.getComputedStyle(currentElement,'padding-right'),10);
209				padding2 = ( isNaN(padding2) ? 0 : padding2 );
210				
211				var border = parseInt(Aitia.Style.getComputedStyle(currentElement,'border-left-width'),10);
212				border = ( isNaN(border) ? 0 : border );
213				var border2 = parseInt(Aitia.Style.getComputedStyle(currentElement,'border-right-width'),10);
214				border2 = ( isNaN(border2) ? 0 : border2 );
215				
216				value = width-(padding+padding2+border+border2)+'px';
217			} else if ( style=='height' && Aitia.Style.getComputedStyle(currentElement,'display')!='none' ) {
218				var height = currentElement['offset' + this.capitalize(style)];
219				
220				var padding = parseInt(Aitia.Style.getComputedStyle(currentElement,'padding-top'),10);
221				padding = ( isNaN(padding) ? 0 : padding );
222				var padding2 = parseInt(Aitia.Style.getComputedStyle(currentElement,'padding-bottom'),10);
223				padding2 = ( isNaN(padding2) ? 0 : padding2 );
224				
225				var border = parseInt(Aitia.Style.getComputedStyle(currentElement,'border-top-width'),10);
226				border = ( isNaN(border) ? 0 : border );
227				var border2 = parseInt(Aitia.Style.getComputedStyle(currentElement,'border-bottom-width'),10);
228				border2 = ( isNaN(border2) ? 0 : border2 );
229				
230				value = height-(padding+padding2+border+border2)+'px';
231			} else {
232				value = null;
233			}
234			
235			return value;
236		}
237		
238		if (typeof value=='undefined') {
239			return null;
240		}
241		
242		return value;
243	} else if (currentWindow.document.defaultView.getComputedStyle) {
244		style = (style=='float' || style=='styleFloat') ? 'cssFloat' : this.camelize(style);
245		var value = currentElement.style[style];
246		
247		if ( !value || value=='auto' ) {
248			// document.defaultView - window
249			var css = currentWindow.document.defaultView.getComputedStyle(currentElement, null);
250			value = css ? css[style] : null;
251		}
252		
253		if ( style=='opacity' ) {
254			return value ? parseFloat(value) : 1.0;
255		}
256		
257		if (typeof value=='undefined') {
258			return null;
259		}
260		
261		return value=='auto' ? null : value;
262	}
263	
264	return null;
265}
266
267Aitia.Style.getAllComputedStyle = function(currentElement, currentWindow) {
268	var computedStyle;
269
270	currentWindow = typeof currentWindow!='undefined' && currentWindow ? currentWindow : window;
271
272	if (typeof currentElement.currentStyle != "undefined") {
273		computedStyle = currentElement.currentStyle;
274	}
275	else {
276		computedStyle = currentWindow.document.defaultView.getComputedStyle(currentElement, null);
277	}
278
279	return computedStyle;
280}
281
282
283// a float értékét más attrubutmmal lehet elérni, böngészőktől függően.
284function cssFloatStr()
285{
286	return (document.documentElement.style.cssFloat === undefined ? "styleFloat" : "cssFloat");
287}

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.