123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423 |
-
- Namespace.register("U.UF.EL");
- U.UF.EL.getElementPosition = function (el) {
- var _key,
- _arr = [0, 0]
- while (el && (el = el.offsetParent)) {
- _key = U.UF.EL.getStyle(el, "position");
-
- if (_key != "static") {
- _arr[0] += el.offsetTop;
- _arr[1] += el.offsetLeft;
- }
- }
- return _arr;
- }
- U.UF.EL.getElementRealWidth = function (el) {
- var _offset;
-
- _offset = parseInt(Math.min(el.offsetWidth, el.scrollWidth, el.clientWidth));
-
- if (_offset <= 0) {
- _offset = parseInt(el.style.height);
- }
-
- return _offset;
- }
- U.UF.EL.getElementRealHeight = function (el) {
- var _offset;
-
- _offset = parseInt(Math.min(el.offsetHeight, el.scrollHeight, el.clientHeight));
-
- if (_offset <= 0) {
- _offset = parseInt(el.style.height);
- }
-
- return _offset;
- }
- U.UF.EL.getElementInfo = function (el) {
- var _elgetbc = el.getBoundingClientRect(),
- _elp = U.UF.EL.offsetParent(el);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- return {
- ancestorscrollbartop: (document.documentElement.scrollTop) + _elp.scrollTop,
- ancestorscrollbarleft: (document.documentElement.scrollLeft) + _elp.scrollLeft,
- SH: el.scrollHeight,
- SW: el.scrollWidth,
- SL: el.scrollLeft,
- ST: el.scrollTop,
- CH: el.clientHeight,
- CW: el.clientWidth,
- CT: el.clientTop,
- CL: el.clientLeft,
- OH: el.offsetHeight,
- OW: el.offsetWidth,
- OL: el.offsetLeft,
- OT: el.offsetTop,
- BCRH: _elgetbc.bottom - _elgetbc.top,
- BCRW: _elgetbc.right - _elgetbc.left,
- BCRT: _elgetbc.top,
- BCRL: _elgetbc.left,
- BCRB: _elgetbc.bottom,
- BCRR: _elgetbc.right
- }
- }
- U.UF.EL.offsetParent = function (el1, b, str) {
- var _str,
- _el1 = document.body;
-
- while (el1 && el1 != _el1) {
- _str = U.UF.EL.getStyle(el1, "position");
-
- if ((!str && _str != "static") || (_str == str)) {
- break;
- }
- el1 = el1.offsetParent;
- }
- return el1;
- }
- U.UF.EL.getAncestor = function (el, str) {
-
- while (el && !(el == str || el.id == str)) {
- el = el.parentNode;
- }
- return el;
- }
- U.UF.EL.getChildrenNoText = function (el, str) {
- var i,
- _arr = [];
- for (i = 0; i < el.length; i++) {
-
-
- if (el[i].nodeType == 1 && (!str || str.indexOf(el[i].tagName.toLowerCase()) == -1)) {
- _arr.push(el[i]);
- }
- }
- return _arr;
- }
- U.UF.EL.getAncestorEditElement = function (el) {
- var _el1 = document.body;
- while (el && _el1 != el) {
- if (el.tagName) {
-
-
- if ("textarea,input".indexOf(el.tagName.toLocaleLowerCase()) > -1 || el.contentEditable == "true") {
- break;
- }
- }
- el = U.selectEl(el).Parent();
- }
- return el;
- }
- U.UF.EL.isChild = function (el1, el2) {
-
- if (el1 && el2) {
-
- if (el1.contains) {
-
- if (el1.contains(el2)) {
- return true;
- }
- }
-
- else if (el1.compareDocumentPosition) {
-
- if (!(!!(el1.compareDocumentPosition(el2)))) {
- return true;
- }
- }
- }
- return false;
- }
- U.UF.EL.indexOfParent = function (el) {
- var _el = U.selectEl(el).Parent();
- var _el2 = U.selectEl(_el).Child();
- return _el2.indexOf(el);
- }
- U.UF.EL.isCustomAttributes = function (el, str) {
- el = el || $$("div");
- var _att = el.attributes;
-
- if (_att) {
-
- if (_att[str]) {
- return _att[str].expando == true;
- } else {
-
- return el.getAttribute(str) !== null || el[str] === void 0;
- }
- }
- }
- U.UF.EL.addAttributes = function (el, name, value) {
-
- el.setAttribute(name, value)
- }
- U.UF.EL.delAttributes = function (el, name) {
-
- if (el.hasAttribute(name)) {
- el.removeAttribute(name)
- }
- }
- U.UF.EL.getStyle = function (el, str) {
-
- if (el && el.style) {
- var _str = U.UF.EL.styleConversion(str);
-
- if (el.style[_str] || _str == "cssText") {
- return el.style[_str];
- } else {
-
- if (el.currentStyle) {
- return el.currentStyle[_str];
- } else {
- return "";
- }
- }
- return "";
- }
- }
- U.UF.EL.addClass = function (el, str) {
- var _Reg = el.className.match(new RegExp("(\\s|^)" + str + "(\\s|$)"));
- var _b = !!(_Reg);
- if (!_b) {
- el.className += " " + str;
- }
- }
- U.UF.EL.removeClass = function (el, str) {
- var _Reg = el.className.match(new RegExp("(\\s|^)" + str + "(\\s|$)"));
- var _b = !!(_Reg);
- if (_b) {
- el.className = el.className.replace(new RegExp("(\\s|^)" + str + "(\\s|$)"), " ").trim();
- }
- }
- U.UF.EL.isHasClass = function (el, str) {
-
- if ((el.className).indexOf(str) > -1) {
- return true;
- }
- return false;
- }
- U.UF.EL.styleConversion = function (el, str) {
- if (str) {
- str = [/[A-Z]/g, "-", 0, "toLowerCase"];
- }
- else {
- str = [/-[a-z ]/g, "", 1, "toUpperCase"];
- }
- return el.replace(str[0], function (el2) {
- return str[1] + el2.charAt(str[2])[str[3]]();
- });
- }
- U.UF.EL.getMousePosition = function (el) {
- var _eltop = 0, _elleft = 0,
- _mouseevent = event || window.event;
-
- if (_mouseevent.touches && _mouseevent.touches[0]) {
- _mouseevent = _mouseevent.touches[0];
- }
-
- else {
- _mouseevent = _mouseevent;
- }
-
- var _mousex = _mouseevent.clientX || 0,
- _mousey = _mouseevent.clientY || 0;
-
- while (el) {
- _elleft += el.offsetLeft;
- _eltop += el.offsetTop;
- el = el.offsetParent;
- }
-
- _elx = _mousex - _elleft,
- _ely = _mousey - _eltop;
- return { x: _elx, y: _ely}
- }
- U.UF.EL.rightMenu = function (arr, el, e) {
- var i, _menu;
- if ($("#U_UF_EL_rightmenu")[0]) {
- U.selectEl("#U_UF_EL_rightmenu")[0].remove();
- }
- _menu = $$("div", { "style": { "position": "fixed", "width": "150px", "border": "1px solid #e4e4e4", "backgroundColor": "White", "left": "100px", "display": "none", "z-index": "999" }, "id": "U_UF_EL_rightmenu" }, U.selectEl(el)[0]);
- for (i = 0; i < arr.length; i++) {
- var _div = $$('div', { "style": { "height": "25px", "lineHeight": "25px", "textAlign": "center", "width": "100%", "cursor": "pointer", "padding": "5px 0", "border-bottom": "1px solid rgb(228,228,228)" }, "className": "rightlist" }, _menu);
- U.selectEl(_div).addAttrArray(arr[i]);
- }
- U.selectEl(_menu)[0].style.display = "block";
- U.UF.C.rightClickMenuLocation($(_menu)[0]);
- e = e || window.event;
- var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
- var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
- var x = e.pageX || (e.clientX + scrollX);
- var y = e.pageY || (e.clientY + scrollY);
- var _top = _menu.offsetHeight;
- var _left = _menu.offsetWidth;
- if (_top > y) {
- _menu.style.top = y + "px";
- }
- if (_left > x) {
- _menu.style.left = x + "px";
- }
- U.selectEl(_menu).bind('contextmenu', function (e) {
- U.UF.EV.stopBubble(e);
- });
- }
- ;
|