123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852 |
-
- U.quickCreate = window.$$ = function (str, obj, parentel, child) {
- var i, _element;
-
- var _obj = {
- "frag": "createDocumentFragment"
-
- };
-
- if (_obj[str]) {
- _element = document[_obj[str]]();
- }
-
- else {
- _element = document.createElement(str);
- }
-
- if (obj) {
- U.selectEl(_element).addAttrArray(obj);
- }
-
- if (parentel) {
-
- if (child) {
- parentel.insertBefore(_element, child);
- }
-
- else {
- parentel.appendChild(_element);
- }
- }
-
- return _element;
- }
- $ = U.selectEl = function (name, el) {
-
- return new U.select(name, el);
- }
- U.select = function (selector, el) {
-
- this.length = 0;
- this.context = el || document;
-
- this.select(selector, el);
- }
- U.select.EVENTS = [];
- U.select.prototype = {
-
- select: function (name, el) {
- var _selectel;
-
- if (U.UF.C.isString(name)) {
- var _r = name.substring(0, 1),
- _n = name.substring(1, name.length),
- _doc = el || document;
-
- try {
- switch (_r) {
- case "#":
- if (_doc == document && U.UF.S.EN.test(_n)) {
- _selectel = document.getElementById(_n);
- }
- break;
- case ".":
- if (U.UF.S.EN.test(_n)) {
- _selectel = _doc.getElementsByClassName(_n);
- }
- break;
- case "*":
-
- if (U.UF.S.EN.test(_n)) {
- _selectel = document[_n];
- if (!_selectel) {
- if (U.UF.CI.getBrowser().browser == "msie") {
- _selectel = document.getElementById(_n);
- }
-
- else {
- _selectel = document.embeds[_n];
- }
- }
- }
-
- else {
- _selectel = _doc.getElementsByTagName("*");
- }
- break;
- default:
- if (U.UF.S.EN.test(name)) {
- _selectel = _doc.getElementsByTagName(name);
- }
- break;
- }
- }
- catch (e) {
- }
-
- if (_selectel == null) {
- _selectel = U.UF.CP.selectorElement(name, _doc);
- }
- }
-
- else if (name) {
- _selectel = name;
- }
-
- if (_selectel) {
- this.addElement(_selectel);
- }
- return this;
- },
-
- addElement: function (els) {
-
- if ((U.UF.C.isElement(els) || els.length == null) || els.toString() == "[object Window]") {
- els = [els];
- }
-
- for (var i = 0; i < els.length; i++) {
-
- this[i] = els[i];
-
- if (els[i].id) {
- this[els[i].id] = els[i];
- }
- this.length++;
- }
- },
-
- find: function (name, item) {
- var i = item || 0,
- _length = item + 1 || this.length,
- _elements = new U.select();
- for (; i < _length; i++) {
- _elements.select(name, this[i]);
- }
- return _elements;
- },
-
- prev: function (item) {
- var _selectel,
- _selects = [],
- i = item || 0,
- _length = item + 1 || this.length,
- _elements = new U.select();
-
- for (; i < _length; i++) {
- _selectel = this[i];
- if (_selectel) {
-
- do {
- _selectel = _selectel.previousSibling;
- }
- while (_selectel && _selectel.nodeType !== 1)
- }
-
- if (_selectel) {
- _selects.push(_selectel);
- }
- }
-
- _elements.addElement(_selects);
- return _elements;
- },
-
- next: function (item) {
- var _selectel,
- _selects = [],
- i = item || 0,
- _length = item + 1 || this.length,
- _elements = new U.select();
-
- for (; i < _length; i++) {
- _selectel = this[i];
- if (_selectel) {
-
- do {
- _selectel = _selectel.nextSibling;
- }
- while (_selectel && _selectel.nodeType !== 1)
- }
-
- if (_selectel) {
- _selects.push(_selectel);
- }
- }
-
- _elements.addElement(_selects);
- return _elements;
- },
-
- Nodes: function (item) {
- item = item || 0;
-
- if (this[item]) {
- this[item].childNodes;
- }
- ;
- },
-
- Child: function (item) {
- item = item || 0;
-
- if (this[item]) {
- return U.UF.EL.getChildrenNoText(this[item].childNodes)
- }
- },
-
- Parent: function (obj) {
- var _while,
- _istrue,
- _el = this[0];
- obj = obj || 1;
- if (U.UF.C.isNumber(obj)) {
- for (i = 0; i < obj; i++) {
- if (_el) {
- _el = _el.parentNode;
- }
- }
- }
- else {
-
- _while: while (_el && _el != document) {
- _istrue = true;
-
- for (i in obj) {
-
- if (obj[i] != _el[i] && (!_el.getAttribute || _el.getAttribute(i) != obj[i])) {
- _istrue = false;
- break;
- }
- }
-
- if (_istrue) {
- break _while;
- }
-
- else {
- _el = _el.parentNode;
- }
- }
- }
-
- return _el;
- },
-
- childs: function (item) {
- return new U.select(this.Child(item));
- },
-
- parentElement: function (obj, item) {
- return new U.select(this.Parent(obj, item));
- },
-
- clone: function (deep, item) {
- var i = item || 0,
- _returnarr = [],
- _length = i + 1 || this.length;
-
- for (; i < _length; i++) {
- _returnarr.push(this[i].cloneNode(deep));
- }
-
- return new U.select(_returnarr);
- },
-
- appendTo: function (parentel, item, childel) {
- var i = item || 0,
- _length = item + 1 || this.length;
-
- for (; i < _length; i++) {
-
- if (childel) {
- parentel.insertBefore(this[i], childel);
- }
-
- else {
- parentel.appendChild(this[i]);
- }
- }
- return this;
- },
-
- append: function (el, item, childel) {
- item = item || 0;
-
- if (childel) {
- this[item].insertBefore(el, childel);
- }
-
- else {
- this[item].appendChild(el);
- }
- return this;
- },
-
- remove: function (item) {
- var i = item || 0,
- _length = item != null ? item + 1 : this.length;
-
- for (; i < _length; i++) {
-
- if (this[i] && this[i].parentNode) {
- this[i].parentNode.removeChild(this[i]);
- }
- }
- return this;
- },
-
- Center: function (item) {
- var i = item || 0,
- _length = item + 1 || this.length;
-
- for (; i < _length; i++) {
- U.UF.F.windowTopCenter(this[i]);
- }
- return this;
- },
-
- getElementInfo: function (item) {
- return U.UF.EL.getElementInfo(this[item || 0]);
- },
-
- css: function (obj, value, item) {
- var i = item || 0,
- _length = item + 1 || this.length,
- _isobject = U.UF.C.isObject(obj);
-
- if (_isobject) {
- this.addAttrArray({ "style": obj }, value);
- }
-
- else if (value != null) {
-
- for (i; i < _length; i++) {
- obj = U.UF.EL.styleConversion(obj);
- try {
- this[i].style[obj] = value;
- } catch (e) { }
- }
- }
-
- else {
- return U.UF.EL.getStyle(this[i], obj);
- }
- return this;
- },
-
- addClass: function (classname, item) {
- var i = item || 0,
- _length = item + 1 || this.length;
-
- for (; i < _length; i++) {
- U.UF.EL.addClass(this[i], classname);
- }
- return this;
- },
-
- removeClass: function (classname, item) {
- var i = item || 0,
- _length = item + 1 || this.length;
-
- for (; i < _length; i++) {
- U.UF.EL.removeClass(this[i], classname);
- }
- return this;
- },
-
- hasClass: function (classname, item) {
- item = item || 0;
- return U.UF.EL.isHasClass(this[item], classname);
- },
-
- attr: function (obj, value, item) {
- var j,
- i,
- _length,
- _isobject = U.UF.C.isObject(obj);
-
- if (_isobject) {
- i = value || 0;
- _length = value + 1 || this.length;
-
- for (; i < _length; i++) {
- for (j in obj) {
- U.UF.EL.addAttributes(this[i], j, obj[j]);
- }
- }
- }
-
- else if (value != null) {
- i = item || 0;
- _length = item + 1 || this.length;
-
- for (i; i < _length; i++) {
- U.UF.EL.addAttributes(this[i], obj, value);
- }
- }
-
- else {
- return this[item || 0].getAttribute(obj);
- }
- return this;
- },
-
- rmAttr: function (name, item) {
- U.UF.EL.delAttributes(this[item || 0], name);
- return this;
- },
-
- addAttrArray: function (obj, item) {
- var j, k,
- _newcsstext,
- _csstype,
- _csstext = "",
- i = item || 0,
- _length = item + 1 || this.length;
-
- for (; i < _length; i++) {
-
- for (j in obj) {
-
- if (j == "style") {
- _csstext = "";
- _newcsstext = obj[j]["cssText"];
- for (k in obj[j]) {
- _csstype = U.UF.EL.styleConversion(k, true);
-
- if (_csstype == "css-text") {
- continue;
- }
-
- else if (k in this[i][j]) {
- _csstext += _csstype + ":" + obj[j][k] + ";";
- }
-
- else {
- this[i][j][k] = obj[j][k];
- }
- }
-
- if (_newcsstext) {
- _csstext = this[i][j]["cssText"] + ";" + _newcsstext + ";" + _csstext;
- }
-
- else if (_newcsstext !== "") {
- _csstext = this[i][j]["cssText"] + ";" + _csstext;
- }
- this[i][j]["cssText"] = _csstext;
- }
-
- else {
-
- if (j.indexOf("on") == 0 && U.UF.C.isString(obj[j])) {
- this[i][j] = new Function(obj[j]);
- continue;
- }
-
-
- else if (U.UF.C.isString(obj[j]) && U.UF.EL.isCustomAttributes(this[i], j)) {
-
- try {
- this[i].setAttribute(j, obj[j]);
- }
- catch (e) {
- }
- }
- try {
- this[i][j] = obj[j];
- }
- catch (e) { }
- }
- }
- }
- return this;
- },
-
- hide: function (item) {
- this.css({ "display": "none" }, item);
- },
-
- show: function (item) {
- this.css({ "display": "block" }, item);
- },
-
- width: function () {
- return U.UF.EL.getElementRealWidth(this[0]);
- },
-
- height: function () {
- return U.UF.EL.getElementRealHeight(this[0]);
- },
-
- mouseenter: function (cb, item) {
-
- this.addAttrArray({
- "onmouseover": function () {
- U.UF.EV.stopBubbleMouseOutOrOver(this, cb);
- }
- }, item);
- return this;
- },
-
- mouseleave: function (cb, item) {
-
- this.addAttrArray({
- "onmouseout": function () {
- U.UF.EV.stopBubbleMouseOutOrOver(this, cb);
- }
- }, item);
- return this;
- },
-
- gt: function (item) {
- var i = item,
- _returnarr = [],
- _elements = new U.select();
-
- for (; i < this.length; i++) {
- _returnarr.push(this[i]);
- }
-
- _elements.addElement(_returnarr);
- return _elements;
- },
-
- lt: function (item) {
- var i = 0,
- _returnarr = [];
-
- for (; i < item; i++) {
- _returnarr.push(this[i]);
- }
-
- return new U.select(_returnarr);
- },
-
- bind: function (obj, value, item) {
- var j,
- i,
- _length,
- _isobject = U.UF.C.isObject(obj);
-
- if (_isobject) {
- i = value || 0;
- _length = value + 1 || this.length;
-
- for (; i < _length; i++) {
- for (j in obj) {
- U.UF.EV.addElementEvent(j, this[i], obj[j]);
-
- U.select.EVENTS.push({
- element: this[i],
- event: j,
- fun: obj[j]
- });
- }
- }
- }
-
- else if (value != null) {
- i = item || 0;
- _length = item + 1 || this.length;
-
- for (i; i < _length; i++) {
- U.UF.EV.addElementEvent(obj, this[i], value);
-
- U.select.EVENTS.push({
- element: this[i],
- event: obj,
- fun: value
- });
- }
- }
- return this;
- },
-
- unbind: function (obj, value, item) {
- var j,
- i,
- k,
- _length,
- _isobject = U.UF.C.isObject(obj);
-
- if (_isobject) {
- i = value || 0;
- _length = value + 1 || this.length;
-
- for (; i < _length; i++) {
- for (j in obj) {
- U.UF.EV.delElementEvent(j, this[i], obj[j]);
- for (k = 0; k < U.select.EVENTS.length; k++) {
- if (U.select.EVENTS[k].element == this[i] && U.select.EVENTS[k].event == j && U.select.EVENTS[k].fun == obj[j]) {
- U.select.EVENTS.splice(k, 1);
- k--;
- }
- }
- }
- }
- }
-
- else if (obj != null) {
- i = item || 0;
- _length = item + 1 || this.length;
-
- for (i; i < _length; i++) {
- for (k = 0; k < U.select.EVENTS.length; k++) {
- if (U.select.EVENTS[k].element == this[i] &&
- U.select.EVENTS[k].event == obj &&
- (value == null || U.select.EVENTS[k].fun == value)) {
- U.UF.EV.delElementEvent(obj, this[i], U.select.EVENTS[k].fun);
- U.select.EVENTS.splice(k, 1);
- k--;
- }
- }
- }
- }
-
- else {
- i = item || 0;
- _length = item + 1 || this.length;
- for (i; i < _length; i++) {
- for (k = 0; k < U.select.EVENTS.length; k++) {
- if (U.select.EVENTS[k].element == this[i]) {
- U.UF.EV.delElementEvent(U.select.EVENTS[k].event, this[i], U.select.EVENTS[k].fun);
- U.select.EVENTS.splice(k, 1);
- k--;
- }
- }
- }
- }
- return this;
- }
- }
|