| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346 | /*前进后退处理区域用于场景1、导航前进后退处理2、记录用户步骤处理3、url前进后退处理*/Namespace.register("U.AFB");//#region 前进后退使用处理区域U.AFB.GoList = {}; //前进后退处理U.AFB.UTH = null //url处理//#endregion//#region 前进后退处理/*** 前进后退公开调用区域** @param  {string} 前进后退在指定的域* @param  {boolean} 是否重新加载*/U.AFB.RGoL = function (UTF, UFT) {    var _UDE = U.AFB.GoList;    //根据类类型 获取前进后退类    if (_UDE[UTF] && UFT !== true) { //已经存在域的前进后退        return _UDE[UTF].UT;    }    else { //创建一个新的前进后退处理        return new U.AFB.init(UTF);    }}/*** 注册前进后退** @param  {string} 前进后退在指定的域 如 disk 那就在disk导航*/U.AFB.init = function (UTF) {    /*    描述     -----OF: 当前前进后退集合    -----OL: 前进后退所在的位置    -----UT: 当前的域    */    U.Ut.AddObj(this, { OF: [], OL: 0, UT: this });    U.AFB.GoList[UTF] = this; //添加到集合里面}/*** 添加前进后退** @param  {function} 前进后退函数添加* @param  {string} 前进后退在指定的域*/U.AFB.AddEvent = function (UCB, UTF) {    var _UTE = U.AFB.RGoL(UTF);    UCB = U.M.apply(_UTE, UCB);    _UTE.AddDrawBack(UCB); UCB(); //添加执行前进后退}/*** 添加前进后退事件** @param  {function} 前进后退函数添加*/U.AFB.AddDrawBack = function (UCB) {    this.OF.splice(this.OL, this.OF.length - this.OL, UCB); //添加一个前进后退时间    this.OL++; //位置加一}/*** 前进后退统一处理区** @param  {number} 前进后退处理参数----------1 前进处理----------0 后退处理*/U.AFB.GQH = function (UTF) {    var _UCB = this.OF[this.OL - UTF * 2]; //获取前进后退事件    (_UCB) && (_UCB(), this.OL += ((-UTF * 2) + 1)); //前进后退执行}/*** 后退执行** @param  {string} 前进后退在指定的域*/U.AFB.DrawBack = function (UTF) {    U.AFB.GoList[UTF]["UT"].GQH(1);}/*** 前进执行** @param  {string} 前进后退在指定的域*/U.AFB.GoForward = function (UTF) {    U.AFB.GoList[UTF]["UT"].GQH(0);}//设置原型 运行实例化使用U.AFB.init.prototype = {    AddEvent: U.AFB.AddEvent,    AddDrawBack: U.AFB.AddDrawBack,    GQH: U.AFB.GQH,    DrawBack: U.AFB.DrawBack,    GoForward: U.AFB.GoForward}//#endregion//#region 网页路由使用/*** 添加路由监视** @param  {function} 监督url hash变化的处理*/U.AFB.UrlRoute = function (UCB) {    if (!U.AFB.UTH) { //监视使用的地址变化导航        U.AFB.UTH = new U.AFB.Path(UCB).init();    }    return U.AFB.UTH; //返回路由}/*** 初始化url导航** @param  {function} 监督url hash变化的处理*/U.AFB.Path = function (UCB) {    this.UH = window.location.hash; //Hash值    this.UDE = []; //前进后退记录    this.UCB = UCB; //回调函数记录    this.UIE = window.history.length; //当前浏览了多少页面    this.UGT = this.UTF = true; //hash是否在变化    this.IE = !("onhashchange" in window) || (document.documentMode < 8); //判断是否支持onhashchange}//路由统计区域U.AFB.TJ = function (UDE) {    this.UE = UDE[0]; //记录的url处理    this.UCB = UDE[1]; //回调函数}//添加独立路由设置U.AFB.Set = function (UDE) {    var i, j, _UCE,    _UTE = U.AFB.UrlRoute(),    _UAE = _UTE.UDE;    _UCE: for (i = 0; i < UDE.length; i++) {//生成添加        for (j = 0; j < _UAE.length; j++) {            //判断url所在的域下            if (_UAE[j].UE.join("/") == UDE[i][0].join("/")) {                continue _UCE;            }        }        //        _UAE.push(new this.TJ(UDE[i]));    }}//添加设置HashU.AFB.Add = function (UDE, UN) {    if (UDE) {        var i, _UST = UDE.join("/");        _UST = _UST ? "#!/" + _UST : "";        if (this.IE) {            this.UGT = true;            this.UTF = false; this.ICHT(this.UH, _UST);        } //IE7要产生记录s        this.setNC();        $(document).addAttrArray({ "location": { "hash": _UST }, "title": "云端 - " + (UN ? UN : "1473.cn") }); return false; //生成Hash      }}////设置功能U.AFB.Path.prototype = {    constructor: U.AFB.Path,    UrlRoute: U.AFB.UrlRoute,    TJ: U.AFB.TJ,    Set: U.AFB.Set,    Add: U.AFB.Add,    init: function () {//初始化        this.UH = window.location.hash; //生成        if (this.UH) { this.Ch(); }        if (this.IE) { document.documentElement.onpropertychange = window.onpropertychange = document.onpropertychange = U.M.apply(this, [[this.ICH]]); } //支持ie6 7处理        window.onhashchange = U.M.apply(this, [[this.Ch]]);        return this; //初始化的判断是否有值    },    Ch: function () { //地址变化使用        if (this.UTF && !this.NC) {            var i, _UTF, _USE, _UAE = this.UDE, _UDE = U.M.GetUF();            if (_UDE[0]) { //路由事件使用                for (i = 0; i < _UAE.length; i++) { //触发指定的回调                    if (_UAE[i].UE.join("/").indexOf(_UDE.join("/")) > -1) {                        (_UAE[i].UCB) && (_UAE[i].UCB()); return;                    }                }                //生成url的前进后退                this.setNC();                this.UCB(_UDE); //url回调                 //                _USE = U.M.GetUF(); //获取hash值                //                ((_UTF = _UDE.join("") == _USE.join(""))) && (this.Add[]);                //                this.Add(_UDE.slice(1));                //                _USE = U.M.GetUF();                //                ((_UTF = _UDE.join("") == _USE.join(""))) && (this.Add[]);                //                this.GO(-1);                //                (_UTF) && ((U.M.GetUF().join("") == _UDE.join("")) && (this.GO(-1)));                //                this.Add(_UDE.slice(1));                //                this.UCB(_UDE); //设置url            }        }    },    setNC: function () { //处理onhashchange 重复        if (!this.NC) {            this.NC = true;            setTimeout(U.M.apply(this, function () { this.NC = false; }), 0);        } //设置当前使用    },    ICH: function () { //Hash值ie变化        var _UE = window.event, _UHE = window.location.hash;        if (_UE.propertyName == "onbeforeeditfocus" && this.UGT && _UHE != this.UH) {//判断是否需要加载hash            if (this.UTF) { this.UGT = this.UTF = false; setTimeout(this.GO, 0); setTimeout(U.M.apply(this, [[this.AddHS, [_UHE]]]), 0); } //回车检测设置            else { this.UH = _UHE; this.Ch(); } //统一设置        }    },    AddHS: function (UH) { //IE6-7支持        this.Add(UH.split("/").slice(1));        this.UH = UH; this.UTF = true;    },    ICHT: function (UH, UNH) {//IE8一下的浏览器保存记录        var _UDID = Guid.guidNoDash(),        _UDOD = $$("iframe", { "UrlRoute": [UH, UNH, (this.UIE++)], "tabindex": "-1", "id": _UDID, "name": _UDID, "style": { "cssText": "width:0;height:0;display:none" }, "src": "about:blank" }, $("body")[0]); //创建记录的Iframe "javascript:void((function(){document.open();document.domain='" + document.domain + "';document.close()})())"         U.M.AddEvent("load", _UDOD, U.M.apply(this, [[this.UQJH, [_UDOD]]])); //添加生成    },    UQJH: function (UDOD) {//产生一个接收前进后退的Iframe        U.M.ReEvent("load", UDOD, arguments.callee.caller);        var _UW = UDOD.contentWindow,        _UD = _UW.document.open();        _UD.close(); //生成记录        U.M.AddEvent("load", UDOD, U.M.apply(this, [[this.AUQJH, [UDOD]]])); //前进后退变化    },    AUQJH: function (UDOD) {//前进后退回调        var _UH = this.UH,        _UNH = UDOD.UrlRoute,        _UIE = this.UIE - _UNH[2];        _UNH = _UNH[1 - _UIE]; //前进后退的判断        this.UGT = true; this.UTF = false; this.UIE -= (_UIE * 2 - 1); if (_UH != _UNH) { document.location.hash = _UNH; } //重新设置hash值    },    GO: function (UTF) {        window.history.go(UTF || -1);    } //前进后退执行}////设置功能//U.M.Setprototype(U.AFB.Path, {//    constructor: U.AFB.Path,//    UrlRoute: U.AFB.UrlRoute,//    TJ: U.AFB.TJ,//    Set: U.AFB.Set,//    Add: U.AFB.Add,//    init: function () {//初始化//        this.UH = window.location.hash; //生成//        if (this.UH) { this.Ch(); }//        if (this.IE) { document.documentElement.onpropertychange = window.onpropertychange = document.onpropertychange = U.M.apply(this, [[this.ICH]]); } //支持ie6 7处理//        window.onhashchange = U.M.apply(this, [[this.Ch]]);//        return this; //初始化的判断是否有值//    },//    Ch: function () { //地址变化使用//        if (this.UTF && !this.NC) {//            var i, _UTF, _USE, _UAE = this.UDE, _UDE = U.M.GetUF();//            if (_UDE[0]) { //路由事件使用//                for (i = 0; i < _UAE.length; i++) { //触发指定的回调//                    if (_UAE[i].UE.join("/").indexOf(_UDE.join("/")) > -1) {//                        (_UAE[i].UCB) && (_UAE[i].UCB()); return;//                    }//                }//                //生成url的前进后退//                this.setNC();//                this.UCB(_UDE); //url回调 //                //                _USE = U.M.GetUF(); //获取hash值//                //                ((_UTF = _UDE.join("") == _USE.join(""))) && (this.Add[]);//                //                this.Add(_UDE.slice(1));//                //                _USE = U.M.GetUF();//                //                ((_UTF = _UDE.join("") == _USE.join(""))) && (this.Add[]);//                //                this.GO(-1);//                //                (_UTF) && ((U.M.GetUF().join("") == _UDE.join("")) && (this.GO(-1)));//                //                this.Add(_UDE.slice(1));//                //                this.UCB(_UDE); //设置url//            }//        }//    },//    setNC: function () { //处理onhashchange 重复//        if (!this.NC) {//            this.NC = true;//            setTimeout(U.M.apply(this, function () { this.NC = false; }), 0);//        } //设置当前使用//    },//    ICH: function () { //Hash值ie变化//        var _UE = window.event, _UHE = window.location.hash;//        if (_UE.propertyName == "onbeforeeditfocus" && this.UGT && _UHE != this.UH) {//判断是否需要加载hash//            if (this.UTF) { this.UGT = this.UTF = false; setTimeout(this.GO, 0); setTimeout(U.M.apply(this, [[this.AddHS, [_UHE]]]), 0); } //回车检测设置//            else { this.UH = _UHE; this.Ch(); } //统一设置//        }//    },//    AddHS: function (UH) { //IE6-7支持//        this.Add(UH.split("/").slice(1));//        this.UH = UH; this.UTF = true;//    },//    ICHT: function (UH, UNH) {//IE8一下的浏览器保存记录//        var _UDID = Guid.guidNoDash(),//        _UDOD = $$("iframe", { "UrlRoute": [UH, UNH, (this.UIE++)], "tabindex": "-1", "id": _UDID, "name": _UDID, "style": { "cssText": "width:0;height:0;display:none" }, "src": "about:blank" }, $("body")[0]); //创建记录的Iframe "javascript:void((function(){document.open();document.domain='" + document.domain + "';document.close()})())" //        U.M.AddEvent("load", _UDOD, U.M.apply(this, [[this.UQJH, [_UDOD]]])); //添加生成//    },//    UQJH: function (UDOD) {//产生一个接收前进后退的Iframe//        U.M.ReEvent("load", UDOD, arguments.callee.caller);//        var _UW = UDOD.contentWindow,//        _UD = _UW.document.open();//        _UD.close(); //生成记录//        U.M.AddEvent("load", UDOD, U.M.apply(this, [[this.AUQJH, [UDOD]]])); //前进后退变化//    },//    AUQJH: function (UDOD) {//前进后退回调//        var _UH = this.UH,//        _UNH = UDOD.UrlRoute,//        _UIE = this.UIE - _UNH[2];//        _UNH = _UNH[1 - _UIE]; //前进后退的判断//        this.UGT = true; this.UTF = false; this.UIE -= (_UIE * 2 - 1); if (_UH != _UNH) { document.location.hash = _UNH; } //重新设置hash值//    },//    GO: function (UTF) {//        window.history.go(UTF || -1);//    } //前进后退执行//});//U.M.Setprototype(U.AFB.Path.prototype.init, U.AFB.Path.prototype);//#endregion
 |