init
This commit is contained in:
129
modules/EcmDocuments/j123.js
Executable file
129
modules/EcmDocuments/j123.js
Executable file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
j123 -- JavaScript common library
|
||||
mail: sebastian.hanula@gmail.com
|
||||
www: http://www.hanula.com/lab/j123
|
||||
|
||||
j123 core library
|
||||
*/
|
||||
|
||||
|
||||
j123 = {
|
||||
ver : { major:0,minor:1},
|
||||
|
||||
onInitFunctions:[],
|
||||
registerOnInit : function(fn) {
|
||||
this.onInitFunctions.push(fn);
|
||||
},
|
||||
|
||||
init: function() {
|
||||
for(var i=0;i<this.onInitFunctions.length;i++) {
|
||||
this.onInitFunctions[i]();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
j123.browser = {
|
||||
isIE : null,
|
||||
isOpera:null,
|
||||
|
||||
init : function() {
|
||||
var ua = navigator.userAgent.toLowerCase();
|
||||
j123.browser.isIE = (ua.indexOf('msie') != -1);
|
||||
j123.browser.isOpera = (ua.indexOf('opera') != -1);
|
||||
}
|
||||
};
|
||||
j123.registerOnInit(j123.browser.init);
|
||||
|
||||
|
||||
j123.common = {
|
||||
each : function(arr,fn) {
|
||||
for(var i=0;i<arr.length;i++) fn(arr[i]);
|
||||
},
|
||||
init: function() {
|
||||
|
||||
}
|
||||
};
|
||||
j123.registerOnInit(j123.common.init);
|
||||
|
||||
|
||||
/////////// HTML
|
||||
|
||||
function $(x){ return document.getElementById(x);}
|
||||
|
||||
function findPosX(obj) {
|
||||
var curleft = 0;
|
||||
if (obj.offsetParent)
|
||||
{
|
||||
while (obj.offsetParent)
|
||||
{
|
||||
curleft += obj.offsetLeft
|
||||
obj = obj.offsetParent;
|
||||
}
|
||||
}
|
||||
else if (obj.x)
|
||||
curleft += obj.x;
|
||||
return curleft;
|
||||
};
|
||||
|
||||
j123.HTML = {
|
||||
showElement : function(el) {
|
||||
if(j123.browser.isIE) {
|
||||
|
||||
}
|
||||
el.style.visibility.display = 'visible';
|
||||
},
|
||||
hideElement: function(el) {
|
||||
el.style.visiblity = 'hidden';
|
||||
},
|
||||
|
||||
removeElement: function(el) {
|
||||
if(el.parentNode) el.parentNode.removeChild(el);
|
||||
},
|
||||
|
||||
// a przed b
|
||||
moveBefore: function(a,b) {
|
||||
b.parentNode.insertBefore(a,b);
|
||||
j123.HTML.removeElement(a);
|
||||
},
|
||||
|
||||
// a za b
|
||||
moveAfter : function(a,b) {
|
||||
a.parentNode.insertBefore(a, a ? b.nextSibling :null);
|
||||
ji123.HTML.removeElement(a);
|
||||
},
|
||||
|
||||
findPosY : function(el) {
|
||||
var curtop = 0;
|
||||
if (el.offsetParent) {
|
||||
while (el.offsetParent) {
|
||||
curtop += el.offsetTop
|
||||
el = el.offsetParent;
|
||||
}
|
||||
}
|
||||
else if (el.y)
|
||||
curtop += el.y;
|
||||
return curtop;
|
||||
},
|
||||
findPosX : function(el) {
|
||||
var curleft = 0;
|
||||
if (el.offsetParent) {
|
||||
while (el.offsetParent) {
|
||||
curleft += el.offsetLeft
|
||||
el = el.offsetParent;
|
||||
}
|
||||
}
|
||||
else if (el.x)
|
||||
curleft += el.x;
|
||||
return curleft;
|
||||
},
|
||||
setTextContent :function(el,content) {
|
||||
if(j123.browser.isIE || j123.browser.isOpera) el.innerText = content;
|
||||
else el.textContent = content;
|
||||
},
|
||||
getTextContent :function(el) {
|
||||
if(j123.browser.isIE || j123.browser.isOpera) return el.innerText;
|
||||
else return el.textContent;
|
||||
}
|
||||
|
||||
// TODO CSS
|
||||
};
|
||||
Reference in New Issue
Block a user