| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325 | //#region 浏览器兼容使用/*设置兼容性的写法 ie里面有innerText,outerHTML,而HTML5没有这些属性,为了使得TML5兼容ie特性,写了如下兼容js,HTML5也在逐步形成上诉函数。*/Namespace.register("U.MB")//通过修改浏览器内置属性 设置兼容,添加兼容,此兼容模块兼容ie6以上,firefox,safiry,chromeU.MB.init = function () {    //如果是html5浏览器,则执行判断内的内容,ie则不用进入下面内容。    if (window.HTMLElement) {        HTMLElement.prototype.__defineGetter__("onmousewheel", function () {            return this.onwheel;        });        HTMLElement.prototype.__defineSetter__("onmousewheel", function (UCB) {            this.onwheel = UCB;        });        if (!("onmousewheel" in HTMLElement)) {            if ("onwheel" in HTMLElement.prototype) {                U.M.HEPropert(HTMLElement.prototype, "onmousewheel", function () {                    return this.onwheel;                },            function (UCB) {                this.onwheel = UCB;            });            }            else {                //firefox支持onmousewheel                if (browser.firefox) {                    (function () {                        window.addEventListener("DOMMouseScroll", function (UE) {                            //监控Scroll事件                            var _UOE = null                          , _UDOD = UE.srcElement;                            do {                                _UOE = $(_UDOD).attr("onmousewheel") || _UDOD.onmousewheel;                                _UDOD = $(_UDOD).Parent();                            } while (!(_UOE || !_UDOD)); //冒泡的顶部获取                            if (_UOE) {                                (typeof _UOE == "string") && (_UDOD.onmousewheel = new Function(_UOE));                                U.M.StopDefault();                                //阻止页面固定事件                                setTimeout(function () {                                    _UOE.call(this, UE);                                }                            , 0);                                //异步执行 解决锁定的bug                            }                        }                    , false);                    }                )();                }            }        }        if (!("innerText" in HTMLElement.prototype)) {/*检测浏览器是否支持innerText这个方法*/            U.M.HEPropert(HTMLElement.prototype, "innerText",              function () {                  return this.textContent;              },               function (UDE) {                   this.textContent = UDE;               }        );        }        if (!("outerHTML" in HTMLElement.prototype)) {/*检测浏览器是否支持outerHTML这个方法*/            U.M.HEPropert(HTMLElement.prototype, "outerHTML",            function () {                var _UDOD = this.cloneNode(true),                _UDTD = $$("div", {});                _UDTD.appendChild(_UDOD);                return _UDTD.innerHTML; /*如果不支持就使用innerhtml插入*/            },             function (UTH) {                 var i, _UDOD = $(this), _UDPD = _UDOD.Parent(), _UDCD = $$("div", {                     "innerHTML": UTH                 }).childNodes, _UDTD = document.createDocumentFragment;                 for (i = 0; i < _UDCD.length; i++) {                     _UDTD.appendChild(_UDCD[i]);                 }                 ; _UDTD.insertBefore(_UDTD, this);                 _UDOD.remove();             }        );        }        if (!("outerText" in HTMLElement.prototype)) {/*检测浏览器是否支持outerText这个方法*/            U.M.HEPropert(HTMLElement.prototype, "outerText",           function () {               var _UDOD = this.cloneNode(true)                      , _UDTD = $$("div", {});               _UDTD.appendChld(_UDOD);               return _UDTD.innerText; /*如果不支持就使用innerText插入*/           },          function (UTH) {              var i, _UDOD = $(this), _UDPD = _UDOD.Parent(), _UDCD = $$("div", {                  "innerText": UTH              }).childNodes, _UDTD = document.createDocumentFragment;              for (i = 0; i < _UDCD.length; i++) {                  _UDTD.appendChild(_UDCD[i]);              }              _UDTD.insertBefore(_UDTD, this);              _UDOD.remove();          });        }        if (!("componentFromPoint" in HTMLElement.prototype)) {            U.M.HEPropert(HTMLElement.prototype, "componentFromPoint", function () {                return function () {                    var _UE = U.M.GetMousep();                    var _UDE = U.M.GetElementAllInfo(this);                    if ((_UE["X"] > _UDE["CW"] + _UDE["TX"]) || (_UE["Y"] > _UDE["CH"] + _UDE["TY"])) {                        return "outside";                    }                    return "";                }            },        function () { });        }        if (!("currentStyle" in HTMLElement.prototype)) {            U.M.HEPropert(HTMLElement.prototype, "currentStyle", function () {                return getComputedStyle(this, false);            },        function () { });        }        if (!("onreadystatechange" in HTMLElement.prototype)) {            U.M.HEPropert(HTMLElement.prototype, "onreadystatechange", function () {                return this.onload;            },        function (UCB) {            this.onload = UCB;        });        }        if (!("setCapture" in HTMLElement.prototype)) {            U.M.HEPropert(HTMLElement.prototype, "setCapture", function () {                return function () { window.captureEvents(Event.MOUSEMOVE); }            },        function () { });        }        if (!("releaseCapture" in HTMLElement.prototype)) {            U.M.HEPropert(HTMLElement.prototype, "releaseCapture", function () {                return function () {                    window.releaseEvents(Event.MOUSEMOVE);                }            },        function () { });        }        if (!("onresize" in HTMLElement.prototype) || !browser.msie) {            U.MB.onresize = function (UDOD, UDTD, UCB) {                //Size事件设置                if (UCB) {                    UDOD.contentDocument.defaultView.onresize = function () { U.M.apply(UDTD, [[UCB]])(); }  //                }                else {                    try {                        delete this.__SizeElement__;                    } catch (e) { }                }            }            U.M.HEPropert(HTMLElement.prototype, "onresize", function () {                try {                    this.__SizeElement__.contentDocument.defaultView.onresize;                } catch (e) {                    return null;                }            },        function (UCB) {            if (this.tagName) {                //设置Set事件                var _UDOD = this.__SizeElement__;                (U.M.GetStyle(this, "position") == "static") && (this.style.position = "relative");                if (!_UDOD || $(_UDOD).Parent() != this && UCB) {                    _UDOD = this.__SizeElement__ = $$("object", {                        "onload": [[U.MB.onresize, ["this", this, UCB]]],                        "type": "text/html",                        "data": "about:blank",                        "style": {                            "cssText": "display:block;position:absolute;top:0;left:0;height:100%;width:100%;overflow:hidden;pointer-events:none;z-index:-1;visibility:hidden;margin:0;padding:0;"                        }                    }, this)[0];                }                else {                    U.MB.onresize(_UDOD, this, UCB);                }            }        });        }        if (!("componentFromPoint" in HTMLElement.prototype)) {            U.M.HEPropert(HTMLElement.prototype, "componentFromPoint", function () {                return function () {                    var _UE = U.M.GetMousep();                    var _UDE = U.M.GetElementAllInfo(this);                    if ((_UE["X"] > _UDE["CW"] + _UDE["TX"]) || (_UE["Y"] > _UDE["CH"] + _UDE["TY"])) {                        return "outside";                    }                    return "";                }            },        function () { });        }        if (!("event" in window.constructor.prototype)) {/*检测浏览器是否支持鼠标键盘事件*/            U.M.HEPropert(window.constructor.prototype, "event", function () {                var _UDE = arguments.callee;                while (_UDE.caller) {                    _UDE = _UDE.caller;                }                return _UDE.arguments ? _UDE.arguments[0] : null;            }, function () { });        }        if (window.Event.prototype) {            if (!("srcElement" in window.Event.prototype)) {                U.M.HEPropert(window.Event.prototype, "srcElement", function () {                    return event.target;                },        function () { });            }            if (!("keyCode" in window.Event.prototype)) {                U.M.HEPropert(window.Event.prototype, "keyCode", function () {                    return event.which;                },        function () { });            }        }    }}U.M.QSEM; //防止选择器创建多个样式style/*** querySelectorAll 兼容** @param  {string} 搜索的内容* @param  {element} 搜索的元素区域*/document.querySelectorAll = document.querySelectorAll || function (USE, UOE) {    var _UDTD = U.M.QSEM, //判断是否已经添加了上style识别样式    _UDE = [],    _UDOD = document.documentElement.firstChild,    _UAE = (UOE || document).all, //搜索区域    i = _UAE.length;    try {        //添加的style link        _UDTD.styleSheet.cssText = USE + "{q:1}";    }    catch (e) {        _UDTD = (U.M.QSEM = $$("style", {            "type": "text/css",            "styleSheet": {                "cssText": USE + "{q:1}"            }        }, _UDOD));    }    //全局筛选    while (i--) {        (_UAE[i].currentStyle.q) && (_UDE.unshift(_UAE[i]));    }    return _UDE;};/*** querySelector 兼容** @param  {number} 搜索的内容*/document.querySelector = document.querySelector || function (USE) {    var _UDE = document.querySelectorAll(USE);    return _UDE.length ? _UDE[0] : null;};/*** 选择元素区域 自定义搜索元素选择函数** @param  {number} 搜索的内容*/window.SelectorElement = function (USE, UD) {    var _UTF = (UD.id === "" && UD != document), _UTP = $$("div").querySelectorAll; //判断是否支持选择器    if (_UTF) {        UD.id = UD.uniqueID;    }    try { //选择器获取        return (_UTP ? (UD || document) : document).querySelectorAll((UD.id ? ("#" + UD.id + " ") : " ") + USE, UD);    }    catch (e) {        return null;    }    finally {        (_UTF) && (UD.id = "");    }}//#region 手机兼容处理,只要引用了uform框架,会自动使手机在滑动的过程中不会触发点击事件//Touch事件执行if ("ontouchstart" in document) {    (U.M.OTS) && (U.M.ReEvent("touchstart", document, U.M.OTS, true));    //touchstart    U.M.AddEvent("touchstart", document, U.M.OTS = function () {        var i, _UDOD = event.srcElement; U.M.UTX = null; U.M.StopBubble();        U.M.ReEvent("touchstart", document, U.M.OTS, true); //移除start事件        U.M.TouchE(_UDOD, "touchstart"); U.M.AddEvent("touchstart", document, U.M.OTS, true); //添加事件取消冒泡         U.M.AddEvent("touchmove", document, U.M.OTSM); //添加move事件监听        U.M.AddEvent("touchend", document, U.M.OTSE, true); //end事件等待    }, true);    U.M.OTSM = function () { //移动监视        U.M.UTX = true; U.M.ReEvent("touchmove", document, U.M.OTSM); U.M.TouchE(event.srcElement, "touchmove"); U.M.StopBubble();    }    //执行toucastart    U.M.OTSE = function (UDOD) {        U.M.ReEvent("touchend", document, U.M.OTSE, true); U.M.StopBubble(); //移除事件        if (!U.M.UTX) { U.M.TouchE(event.srcElement, "touchend"); } //事件执行    }}//#endregion
 |