123 |
- /** Yufp-core Copyright © 2017-present Yusys All Rights Reserved. */
- window.yufp={core:{version:"1.2.12"}},console.log("yufp.core-1.2.12-2021-03-09"),function(h){function t(){}t.prototype._toString=Object.prototype.toString,t.prototype.class2type={"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object Array]":"array","[object Date]":"date","[object RegExp]":"regExp","[object Object]":"object"},t.prototype.type=function(t){var e=this._toString.call(t);return null==t?String(t):this.class2type[e]||"object"},t.prototype.isWindow=function(t){return null!=t&&t===t.window},t.prototype.isFunction=function(t){return"function"==this.type(t)},t.prototype.isArray=function(t){return"array"===this.type(t)},t.prototype.isArrayLike=function(t){var e=this.type(t);if("function"===e||this.isWindow(t))return!1;var r=!!t&&"length"in t&&t.length;return"array"===e||0===r||"number"==typeof r&&0<r&&r-1 in t},t.prototype.merge=function(t,e){for(var r=t.length,i=0,o=+e.length;i<o;i++)t[r++]=e[i];return t.length=r,t},t.prototype.makeArray=function(t,e){var r=e||[];return null!=t&&(this.isArrayLike(Object(t))?this.merge(r,"string"==typeof t?[t]:t):r.push(t)),r},t.prototype.isPlainObject=function(t){if(!t||"object"!==this.type(t)||t.nodeType||this.isWindow(t))return!1;var e,r=Object.prototype.hasOwnProperty;if(t.constructor&&!r.call(t,"constructor")&&!r.call(t.constructor.prototype,"isPrototypeOf"))return!1;for(e in t)break;return void 0===e||r.call(t,e)},t.prototype.clone=function(t,e){return this.extend(!0,e,t)},t.prototype.getInnerText=function(t){var e="string"==typeof t.innerText?t.innerText:t.textContent;return t=null,e},t.prototype.setInnerText=function(t,e){"string"==typeof t.innerText?t.innerText=e:t.textContent=e,t=null},t.prototype.getNextElementSibling=function(t){var e=null,e=t.nextElementSibling?t.nextElementSibling:t.nextSibling;return t=null,e},t.prototype.getFirstElementChild=function(t){var e=null,e=t.firstElementChild?t.firstElementChild:t.firstChild;return t=null,e},t.prototype.args2Arr=function(t){return 1===t.length?[t[0]]:Array.apply(null,t)},t.prototype.extend=function(){var t=h.utils.args2Arr(arguments),e=t[0]||{},r=1,i=t.length,o=!1;for("boolean"==typeof e&&(o=e,e=t[r]||{},r++),"object"==typeof e||this.isFunction(e)||(e={}),r===i&&(e=this,r--);r<i;r++){var n=t[r];if(null!=n&&null!=n)for(var s in n){var a,u,l=e[s],c=n[s];e!==c&&(a=!1,o&&c&&(this.isPlainObject(c)||(a=this.isArray(c)))?(u=void 0,u=a?l&&this.isArray(l)?l:[]:l&&this.isPlainObject(l)?l:{},e[s]=this.extend(o,u,c)):void 0!==c&&(e[s]=c))}}return e},t.prototype.each=function(t,e,r){if(this.isArrayLike(t))for(var i=0,o=t.length;i<o&&!1!==e.call(t[i],i,t[i]);i++);else for(var n in t)if(r){if(t.hasOwnProperty(n)&&!1===e.call(t[n],n,t[n]))break}else if(!1===e.call(t[n],n,t[n]))break;return t},t.prototype.uidStore={},t.prototype.uid=function(t,e,r){t=t||"UID",e=e||0,r=r||"";var i=this.uidStore[t]||e;return this.uidStore[t]=++i,r+i},t.prototype.uidcode=function(t,e){return(t=t||"")+e},t.prototype.hashCode=function(t){for(var e=0,r=t.length,i=0;i<r;i++)2147483647<(e=31*e+t.charCodeAt(i))&&(e%=2147483648);return e},t.prototype.location=function(){var t=window.location,e=t.pathname,r=e.substr(1).indexOf("/"),i="/"===(i=-1<r?e.substr(0,r+1):e)?"":i;return{origin:t.protocol+"//"+t.host,basePath:i,hash:t.hash,search:t.search}},t.prototype.urlParam2Object=function(t){var e=t.split("?")[1];return e?JSON.parse('{"'+decodeURIComponent(e).replace(/"/g,'\\"').replace(/&/g,'","').replace(/=/g,'":"').replace(/\n/g,"\\n")+'"}'):{}},h.utils=new t}(yufp.core,yufp),function(n){function s(t){this.id=t,this.children={}}function t(){this.root=new s("_root_")}t.prototype.put=function(){var t=n.utils.args2Arr(arguments),e=t.length;if(e<2)return n.logger.error("core.bus: The parameter includes at least one (key,value)"),!1;for(var r=this.root,i=0;i<e-1;i++){var o=t[i];r.children[o]||(r.children[o]=new s(o)),r=r.children[o]}return r.data=t[e-1],!0},t.prototype.get=function(){var t=n.utils.args2Arr(arguments),e=t.length;if(0!=e){for(var r=this.root,i=0;i<e;i++){var o=t[i];if(!r.children[o])return;r=r.children[o]}return r.data}},t.prototype.remove=function(){var t=n.utils.args2Arr(arguments),e=t.length;if(0==e)return!1;for(var r=this.root,i=0;i<e-1;i++){var o=t[i];if(!r.children[o])return!1;r=r.children[o]}o=t[e-1];return!!r.children[o]&&(delete r.children[o],!0)},n.bus=new t}(yufp.core,yufp),function(e){function t(){this.fn=window.console,this.fn&&(this.fn.debug=this.fn.debug?this.fn.debug:this.fn.info,this.configLevel())}t.prototype.configLevel=function(t){(t=t||{needInfo:!0,needDebug:!0,needwarn:!0,needError:!0}).isStrprint=void 0===window.console.log.apply,e.utils.extend(this,t)},t.prototype._print=function(t){this.fn&&this.fn[t]&&(this.isStrprint?this.fn[t](e.utils.args2Arr(arguments[1]).join(" ")):this.fn[t].apply(this.fn,arguments[1]))},t.prototype.info=function(){this.needInfo&&this.fn&&this._print("info",arguments)},t.prototype.debug=function(){this.needDebug&&this.fn&&this._print("debug",arguments)},t.prototype.warn=function(){this.needwarn&&this.fn&&this._print("warn",arguments)},t.prototype.error=function(){this.needError&&this.fn&&this._print("error",arguments)},e.logger=new t}(yufp.core,yufp),function(l){function e(e){var t=this,r=t.createXHR();if(r){var i={};l.utils.extend(!0,i,t.defaultSetting),l.utils.extend(!0,i,e),e=i,t.asyncTimeout(e,r),t.onreadystatechange(e,r);var o,n=e.type.toUpperCase(),s=t.processData(e,n);if(e.url+="GET"==n&&s?(-1===e.url.indexOf("?")?"?":"&")+s:"",e.responseType&&(r.responseType=e.responseType),r.open(e.type,e.encode?e.url:encodeURI(e.url),e.async),!1!==e.withCredentials&&(r.withCredentials=void 0===e.withCredentials||e.withCredentials),"function"==l.utils.type(e.beforeSend)&&(o={},l.utils.extend(!0,o,e),e.beforeSend.call(t,r,o)),e.cache||r.setRequestHeader("Cache-Control","no-cache"),"object"==typeof e.headers)for(var a in e.headers)r.setRequestHeader(a,e.headers[a]);try{r.send("GET"!=n&&s?s:null)}catch(t){e.error&&e.error(r,t.message),e.complete&&e.complete(r,t.message)}}else l.logger.error("core.ajax: Your browser not support AJAX XMLHttpRequest.")}e.prototype.defaultSetting={type:"GET",async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",dataType:"string",cache:!1,timeout:9e4,processData:!0,encode:!1},e.prototype.processData=function(t,e){var r=null;try{r=t.data&&t.processData&&"string"!=typeof t.data?this.encode(t.data,"GET"==e?"application/x-www-form-urlencoded":t.headers["Content-Type"],t.encode):t.data}catch(t){l.logger.error("core.ajax: Request params format error;"+t.Message,t)}return r},e.prototype.onreadystatechange=function(e,r){var i=this;r.onreadystatechange=function(){try{if(r.readyState<4)return void(e.loading&&e.loading(r.readyState));if(e.success&&(0==r.status||200<=r.status&&r.status<300)){var t=null==r.response?r.responseText:r.response;if(0===r.status&&!t)return void(e.error&&e.error(r,"网络请求异常"));try{t=i.decode(t,e.dataType)}catch(t){return void(e.error&&e.error(r,t.message))}e.success(t,r.status,r)}else e.error&&e.error(r,r.status);e.complete&&e.complete(r,r.status)}catch(t){throw t}}},e.prototype.asyncTimeout=function(t,e){if(t.async)try{e.timeout=t.timeout,e.ontimeout=function(){t.error&&t.error(e,"timeout"),t.complete&&t.complete(e,"timeout"),t=e=null}}catch(t){l.logger.warn("core.ajax: ie timeout, "+t.Message,t)}},e.prototype.createXHR=function(){var e;try{e=new XMLHttpRequest}catch(t){for(var r=["Msxml3.XMLHTTP","Msxml2.XMLHTTP","Microsoft.XMLHTTP"],i=0,o=r.length;i<o;i++)try{e=new window.ActiveXObject(r[i]);break}catch(t){continue}}return e},e.prototype.encode=function(t,e,r){if(!t||"string"==typeof t||!e)return t;e=e.toLowerCase();var i="",o="object"==l.utils.type(t);if(-1<e.indexOf("application/x-www-form-urlencoded"))if(o)for(var n in t){var s=t[n];if("array"==l.utils.type(s))for(var a=0;a<s.length;a++){var u=n+"="+(r?encodeURIComponent(s[a]):s);0<i.length&&(i+="&"),i+=u}else{u=n+"="+(r?encodeURIComponent(s):s);0<i.length&&(i+="&"),i+=u}}else i=t;else-1<e.indexOf("application/json")||0==e.indexOf("text")?o&&(i=JSON.stringify(t)):i=o?JSON.stringify(t):t;return i},e.prototype.decode=function(t,e){if("json"==e&&"string"==l.utils.type(t)&&""!=t)try{t=JSON.parse(t)}catch(t){throw l.logger.error("core.ajax: Response text format error ",t),t}return t},l.ajax=function(t){new e(t)}}(yufp.core,yufp),function(t){var e,r={};function i(){this.doneFns=[],this.failFns=[],this.alwaysFns=[],this.status=r.Running}(e=r)[e.Running=0]="Running",e[e.Done=1]="Done",e[e.Fail=2]="Fail",i.prototype.fire=function(){if(this.status!=r.Running){if(this.alwaysFns)for(;0<this.alwaysFns.length;){this.alwaysFns.shift().apply(this,this.args)}if(this.status==r.Done)for(;0<this.doneFns.length;){this.doneFns.shift().apply(this,this.args)}else if(this.status==r.Fail)for(;0<this.failFns.length;){this.failFns.shift().apply(this,this.args)}}},i.prototype.done=function(t){return this.doneFns.push(t),this.fire(),this},i.prototype.fail=function(t){return this.failFns.push(t),this.fire(),this},i.prototype.always=function(t){return this.alwaysFns.push(t),this.fire(),this},i.prototype.resolve=function(){return this.args=t.utils.args2Arr(arguments),this.status=r.Done,this.fire(),this},i.prototype.reject=function(){return this.args=t.utils.args2Arr(arguments),this.status=r.Fail,this.fire(),this},t.Deferred=i}(yufp.core,yufp),function(e){var t,r={};function i(){this.waitFns=[],this.chain=[],this.status=r.Free}(t=r).Busy="busy",t.Free="free",i.prototype.fire=function(){if(this.args=e.utils.args2Arr(arguments),0!=this.chain.length){if(this.status=r.Busy,0<this.chain.length){var t=this.chain.shift();try{t.apply(this,this.args)}catch(t){e.logger.error("core.EventChain: "+t),this.fire()}}}else{for(;0<this.waitFns.length;){this.waitFns.shift().apply(this,this.args)}this.status=r.Free}},i.prototype.reject=function(){for(this.args=e.utils.args2Arr(arguments),this.status=r.Busy,this.chain=[];0<this.waitFns.length;){this.waitFns.shift().apply(this,this.args)}this.status=r.Free},i.prototype.post=function(t){return"array"==e.utils.type(t)?this.chain=[].concat(this.chain,t):this.chain.push(t),this.status==r.Busy||this.fire(this.args),this},i.prototype.wait=function(t){return this.waitFns.push(t),this.status==r.Busy||this.fire(this.args),this},i.prototype.isFinish=function(){return this.status==r.Free&&0==this.chain.length},e.EventChain=i}(yufp.core,yufp),function(u){var t,n={};function e(){this.register={}}(t=n)[t.limitless=0]="limitless",t[t.once=1]="once",e.prototype.bind=function(t,e,r){var i=this.register[t];i||(i=[],this.register[t]=i);var o={policy:1==r?n.once:n.limitless,callback:e};return i.push(o),this},e.prototype.unbind=function(t){delete this.register[t]},e.prototype.once=function(t,e){return this.bind(t,e,!0)},e.prototype.all=function(){var e=this,t=u.utils.args2Arr(arguments),r=t.length;if(!(r<1)){var i=t[r-1];if(u.utils.isFunction(i)){for(var o=r-1,n=new Array(o),s=[].splice.call(t,0,o),a=0;a<s.length;a++)e.once(s[a],function(t){n[a]=t,0==--o&&i.apply(e,n)});return n=null,this}u.logger.error("core.EventProxy: callback can not benn empty")}},e.prototype.trigger=function(t){var e=u.utils.args2Arr(arguments),r=this.register[t];if(r){for(var i=0;i<r.length;i++){var o=r[i];if(o.policy==n.once&&r.slice(i,1),o.callback)try{o.callback.apply(this,e)}catch(t){u.logger.error("core.EventProxy: ",t.message,t)}}return this}},e.prototype.emit=function(t){var e=u.utils.args2Arr(arguments);return this.trigger(t,e)},u.EventProxy=e}(yufp.core,yufp),function(t){var e,r={};function i(){this.register={}}(e=r)[e.Loading=0]="Loading",e[e.Loaded=1]="Loaded",e[e.Defining=2]="Defining",e[e.Defined=3]="Defined",e.LoadFinish=!1,t.ModuleStatus=r,i.prototype.get=function(t){return this.register[t]},i.prototype.put=function(t,e){this.register[t]=e},i.prototype.remove=function(t){var e=this.register[t];return delete this.register[t],e},i.prototype.contains=function(t){return!!this.register[t]},i.prototype.clear=function(){this.register={}},t.Module=function(){},t.Modules=i}(yufp.core,yufp),function(s){function t(){this.cache={}}t.prototype.get=function(i,t,o,e){var r,n=this;!1===e&&n.cache[i]?(r=n.cache[i],o.call(n,0,r)):s.ajax({url:i,timeout:t,type:"GET",cache:!1,async:!0,data:{},success:function(t,e,r){n.cache[i]=t,o(0,t)},error:function(t,e){o(1,e)}})},s.Resource=t}(yufp.core,yufp),function(y){var t,v={};(t=v)[t.Busy=0]="busy",t[t.Free=1]="free";function m(t,e){this.size=t,this.callback=e,this.status=!0,this.values=[],this.lastIndex=-1}m.prototype.work=function(t,e,r){if(this.status=t,1==this.status&&(this.lastIndex!=e&&this.size--,this.lastIndex=e,this.values.push(r)),0==this.size||0==this.status)try{this.callback(this.status,this.values)}catch(t){y.logger.error("core.require: ",t.Message,t)}},m.prototype.isOK=function(){return this.status};function b(t,e,r,i){this.index=t,this.src=e,this.params=r,this.progress=i}function e(){this.win=window,this.doc=document,this.head=this.doc.head||this.doc.getElementsByTagName("head")[0]||this.doc.documentElement,this.isOldWebKit=+navigator.userAgent.replace(/.*(?:AppleWebKit|AndroidWebKit)\/(\d+).*/,"$1")<536,this.paths={},this.alias={},this.base="",this.charset="UTF-8",this.timeout=-1,this.modules=new y.Modules,this.resource=new y.Resource,this.queue=[],this.status=v.Free,this.version="1.0.0",this.debug=!1}var u=function(t,e){var r,i=t.sheet;if(e.isOldWebKit)i&&(r=!0);else if(i)try{i.cssRules&&(r=!0)}catch(t){"NS_ERROR_DOM_SECURITY_ERR"===t.name&&(r=!0)}setTimeout(function(){e.time+=20,r?e.success():e.time>e.timeout?e.error():u(t,e)},20)};e.prototype.config=function(t){if(t)return this.paths=t.paths?y.utils.extend({},t.paths):this.paths,this.alias=t.alias?y.utils.clone({},t.alias):this.alias,null!=t.base&&(this.base=t.base),null!=t.charset&&(this.charset=t.charset),null!=t.version&&(this.version=t.version),null!=t.debug&&(this.debug=t.debug),null!=t.runEnv&&(this.runEnv=t.runEnv),this},e.prototype.get=function(t,e,r){t=this.resolvePath(t);var i=this.timeout;return r&&r.timeout&&(i=r.timeout),this.resource.get(t,i,e,this.debug),this},e.prototype.use=function(){return this.require.apply(this,y.utils.args2Arr(arguments))},e.prototype.require=function(){var r,i=this,t=y.utils.args2Arr(arguments),e=[],o=t.length,n={};"object"==y.utils.type(t[o-1])&&(y.utils.extend(!0,n,t[o-1]),o--),"function"==y.utils.type(t[o-1])&&(r=t[o-1],o--);for(var s=0;s<o;s++){if("array"===y.utils.type(t[s]))for(var a=t[s],u=0;u<a.length;u++){null!=a[u]&&(l=this.resolvePath(a[u]),e.push(l))}else for(var l,c=t[s].split(","),u=0;u<c.length;u++){null!=c[u]&&(l=this.resolvePath(c[u]),e.push(l))}}var h=new y.Deferred;if(1==e.length&&this.modules.contains(e[0])){var p=this.modules.get(e[0]);if(p.status==y.ModuleStatus.Defined){var d=p.exports;d.done=function(t){h.done(t)},d.fail=function(t){h.fail(t)};try{r&&r.call(this,d)}catch(t){y.logger.error("core.require: ",t.Message,t)}try{h.resolve(p)}catch(t){y.logger.error("core.require: ",t.Message,t)}return d}}for(var f=new m(e.length,function(t,e){if(f.isOK()){try{r&&r.apply(i,e)}catch(t){y.logger.error("core.require: ",t.Message,t)}try{h.resolve(e)}catch(t){y.logger.error("core.require: ",t.Message,t)}}else{try{r&&r.apply(i,e)}catch(t){y.logger.error("core.require: ",t.Message,t)}try{h.reject(e)}catch(t){y.logger.error("core.require: ",t.Message,t)}}}),s=0;s<e.length;s++){var g=new b(s,e[s],n,f);this.queue.push(g)}return this.status==v.Free&&this.execMountTask(),h},e.prototype.execMountTask=function(){var t;0!=this.queue.length?(this.status=v.Busy,0!=(t=this.queue.shift()).progress.isOK()?this.mount(t):this.execMountTask()):this.status=v.Free},e.prototype.mount=function(t){var e,r=this.getFileNamePostfix(t.src);return"js"!=r?"css"!=r?(e=null==(e=t.params.htmlPoint)?this.doc.body:this.doc.querySelector(e),void this.mountHTML(t,e)):(e=null==(e=t.params.cssPoint)?this.head:this.doc.querySelector(e),void this.mountCSS(t,e)):(e=null==(e=t.params.jsPoint)?this.head:this.doc.querySelector(e),void this.mountJS(t,e))},e.prototype.mountCSS=function(t,e){var r=this,i=t.src,o=this.doc.createElement("link");this.charset&&(o.charset=this.charset),o.setAttribute("crossorigin",!0);var n,s="onload"in o;this.isOldWebKit||!s?(n={timeout:0<this.timeout?this.timeout:3e4,time:0,isOldWebKit:this.isOldWebKit,success:function(){t.progress.work(!0,t.index,t.src),r.execMountTask()},error:function(){try{e.removeChild(o)}catch(t){y.logger.error("core.require: ",t.message,t)}t.progress.work(!1),e=null,r.execMountTask()}},setTimeout(function(){u(o,n)},1)):(o.onload=function(){o.onload=o.onerror=null,t.progress.work(!0,t.index,t.src),r.execMountTask()},o.onerror=function(){try{e.removeChild(o)}catch(t){y.logger.error("core.require: ",t.message,t)}o.onload=o.onerror=null,t.progress.work(!1),r.execMountTask()});var a=this.doc.getElementById(i);a&&(a.parentNode.removeChild(a),a=null),o.async=!0,o.rel="stylesheet",o.type="text/css",o.id=i,o.href=i,e.appendChild(o)},e.prototype.mountHTML=function(r,i){var o=this,t=this.timeout;r.params.timeout&&(t=r.params.timeout);var e=r.src;this.resource.get(e,t,function(t,e){0==t?(i.innerHTML=e,r.progress.work(!0,r.index,e)):(y.logger.error("core.require: ","code:"+t+",message:"+e),r.progress.work(!1)),o.execMountTask()},this.debug)},e.prototype.mountJS=function(t,e){var r=this,i=t.src,o=this.modules.get(i);if(o&&!0===o.LoadFinish&&!1===this.debug)return t.progress.work(!0,t.index,o.exports),void this.execMountTask();(o=new y.Module).id=i,o.src=i,o.status=y.ModuleStatus.Loading,this.modules.put(i,o);var n=this.doc.createElement("script");n.setAttribute("crossorigin","true"),this.charset&&(n.charset=this.charset),"onload"in n?(n.onload=function(){n.onload=n.onerror=null,o.status==y.ModuleStatus.Loading&&t.progress.work(!0,t.index,i),o.LoadFinish=!0,r.execMountTask()},n.onerror=function(){try{e.removeChild(n)}catch(t){y.logger.error("core.require: ",t.message,t)}n.onload=n.onerror=null,e=n=null,t.progress.work(!1),r.execMountTask()}):n.onreadystatechange=function(){/loaded|complete/.test(n.readyState)&&(n.onreadystatechange=null,n=null,o.status==y.ModuleStatus.Loading&&t.progress.work(!0,t.index,i),o.LoadFinish=!0,r.execMountTask())},n.async=!0,n.src=i,delete this.win.define,this.win.define=this.createDefine(o,t),e.appendChild(n)},e.prototype.createDefine=function(n,s){function a(){return u.require.apply(u,y.utils.args2Arr(arguments))}var u=this;return function(){var t,e,r,i=y.utils.args2Arr(arguments);n.status=y.ModuleStatus.Defining;var o=i.length;1===o?(r=i[0],t=void 0):2===o?(r=i[1],y.utils.isArray(i[0])?(e=i[0],t=void 0):e=void 0):(t=i[0],e=i[1],r=i[2]),t&&(n.id=t,u.alias[t]=n.src),e&&""!=e?u.require(e,function(){"function"==y.utils.type(r)?(n.exports={},r.call(n.exports,a,n.exports,n)):n.exports=r,n.status=y.ModuleStatus.Defined,s.progress.work(!0,s.index,n.exports)}):("function"==y.utils.type(r)?(n.exports={},r.call(n.exports,a,n.exports,n)):n.exports=r,n.status=y.ModuleStatus.Defined,s.progress.work(!0,s.index,n.exports))}},e.prototype.resolvePath=function(e){try{e=this.parserPath(e,!0);var t=this.getFileNamePostfix(e);return"js"!=(t=t.toLowerCase())&&"css"!=t&&"html"!=t&&(e+=".js"),-1==e.indexOf("?")?e+="?version=":e+="&version=",e+=this.version}catch(t){throw y.logger.error("core.require: ","resolve path["+e+"] fail",t),t}},e.prototype.getFileNamePostfix=function(t){var e="";if(-1<t.indexOf("script_type=js"))e="js";else if(-1<t.indexOf("script_type=css"))e="css";else if(-1<t.indexOf("script_type=html"))e="html";else{var r=t.lastIndexOf("?");-1==r&&(r=t.length);var i=t.lastIndexOf(".",r);if(-1==i)return"";e=t.substring(i+1,r)}return e},e.prototype.parserPath=function(t,e){if(0==t.indexOf("http://"))return t;if(0==t.indexOf("https://"))return t;if(0==t.indexOf("file:///"))return t;if(0==t.indexOf("/")){var r=this.doc.location.href,i=this.doc.location.pathname,r=this.doc.location.hash?r.replace(this.doc.location.hash,""):r;return"file:"==this.doc.location.protocol?(u=r.lastIndexOf("/"),r.slice(0,u+1)+t):0==i.length?r+t:(u=r.lastIndexOf(i),l=r.slice(0,u),c="",-1!=(u=i.indexOf("/",1))&&(c=i.slice(0,u)),l+c+"/"+t)}if(0==t.indexOf("./")){var o=this.doc.location.href;return u=(o=-1<(u=(o=this.doc.location.hash?o.replace(this.doc.location.hash,""):o).indexOf("?"))?o.slice(0,u):o).lastIndexOf("/"),o.slice(0,u)+t.slice(1)}if(e){var n,s,a=this.alias[t];return a=a||(-1==(u=t.indexOf("/"))?this.base+t:(n=t.slice(0,u),(s=this.paths[n])?s+t.slice(u):this.base+t)),this.parserPath(a,!1)}var u,l,c,h=this.doc.location.href,p=this.doc.location.pathname;return"file:"==this.doc.location.protocol?(u=h.lastIndexOf("/"),h.slice(0,u+1)+t):0==p.length?h+t:(u=h.lastIndexOf(p),l=h.slice(0,u),c="",-1!=(u=p.indexOf("/",1))&&(c=p.slice(0,u)),l+c+"/"+t)},y.Require=e,y.require=new e}(yufp.core,yufp),function(g,h){var t,y={};(t=y)[t.Before=0]="Before",t[t.Mount=1]="Mount",t[t.Ready=2]="Ready",t[t.UnMount=3]="UnMount",t[t.Destroy=4]="Destroy",g.FilterType=y;var e,p={};(e=p)[e.Replace=0]="Replace",e[e.Append=1]="Append",g.OpenPolicy=p;function r(){this.doc=document,this.routeTable={},this.activePages=[],this.history=[],this.historyCacheSize=200,this.filters=[],this.settings={},this.mountHandlers={},this.eventChain=new g.EventChain,this.addMountHandler("default",new i)}r.prototype.addMountHandler=function(t,e){return this.mountHandlers[t]=e,this},r.prototype.getMountHandler=function(t){return this.mountHandlers[t]},r.prototype.removeMountHandler=function(t){return this.mountHandlers[t]&&delete this.mountHandlers[t],this},r.prototype.addFilter=function(t){return this.filters.push(t),this},r.prototype.removeFilter=function(t){for(var e="string"==g.utils.type(t)?t:t.name,r=0;r<this.filters.length&&e!=this.filters[r].name;r++);return r<this.filters.length&&this.filters.splice(r,1),this},r.prototype.doFilters=function(t){for(var e=arguments,r=[],i=1;i<e.length;i++)r[i-1]=e[i];if(t==y.Before){for(var o=0,n=(s=this.filters).length;o<n;o++){if(s[o].before)if(0==(a=s[o].before.apply(this,r)))return r=null,a}return!0}if(t==y.Mount){for(o=0,n=(s=this.filters).length;o<n;o++){if(s[o].mount)if(0==(a=s[o].mount.apply(this,r)))return r=null,a}return!0}if(t==y.Ready){for(o=0,n=(s=this.filters).length;o<n;o++){if(s[o].ready)if(0==(a=s[o].ready.apply(this,r)))return r=null,a}return!0}if(t==y.UnMount){for(o=0,n=(s=this.filters).length;o<n;o++){if(s[o].unMount)if(0==(a=s[o].unMount.apply(this,r)))return r=null,a}return!0}for(var s,a,o=0,n=(s=this.filters).length;o<n;o++){if(s[o].destroy)if(0==(a=s[o].destroy.apply(this,r)))return r=null,a}return!0},r.prototype.addRoute=function(t,e){var r={};g.utils.extend(!0,r,e),this.routeTable[t]=r},r.prototype.removeRoute=function(t){var e=this.routeTable[t];return e&&delete this.routeTable[t],e},r.prototype.getRoute=function(t){var e={};return g.utils.extend(!0,e,this.routeTable[t]),e},r.prototype.addRouteTable=function(t){for(var e in t){var r=t[e];this.addRoute(e,r)}},r.prototype.clearRouteTable=function(){this.routeTable={}},r.prototype.setDefaultRootId=function(t){this.settings.rootId=t},r.prototype.getDefaultRootId=function(){return this.settings.rootId},r.prototype.setHistoryCacheSize=function(t){this.historyCacheSize=t},r.prototype.getHistoryCacheSize=function(){return this.historyCacheSize},r.prototype.addHistory=function(t,e,r,i){0<=this.history.length-this.historyCacheSize&&this.history.splice(0,this.history.length/2);var o={id:t,data:e,rootId:r,options:i};this.history.push(o)},r.prototype.checkHistory=function(e){var r=!1;return this.history.forEach(function(t){t.id!=e.id||t.rootId!=e.rootId||(r=!0)}),r},r.prototype.removeHistory=function(t){for(var e=this.history.length-1;0<=e;e--)if(this.history[e].id===t){this.history.splice(e,1);break}},r.prototype.clearHistory=function(){this.history=[]},r.prototype.back=function(t){var e,r=this.history.length;if(r<=1)return(e=new g.Deferred).reject(""),e;if(!t){for(var i=r-1;0<=i;i--){if((o=this.history[i])&&o.options&&o.options.openPolicy==p.Append)return this.history.splice(i,r-i),void this.remove();if(o.rootId===this.settings.rootId)break}for(var o,n=r-2;0<=n;n--){if((o=this.history[n]).rootId===this.settings.rootId)break}return(h=this.history.splice(n,r-n))[0].isBack=!0,this.to(h[0])}if(!0===t){var s=r-2,a=this.history.splice(s,2);return a[0].isBack=!0,this.to(a[0])}if("number"==g.utils.type(t))for(var u,i=(r=this.history.length)-1,l=Math.min(r,Math.abs(t));r-l<=i;i--)if(u=this.history.splice(i,1)[0]){if(!u.options||u.options.openPolicy!=p.Append)return u.isBack=!0,this.to(u);this.remove()}if(t.id){for(n=-1,i=r-2;0<=i;i--){if(this.history[i].id==t.id){n=i;break}}if(0<=n){for(var c=r-n,h=this.history.splice(n,c),i=0;i<c;i++)this.remove();return h[0].isBack=!0,this.to(h[0])}g.logger.error("core.router: ","can not found the term id:["+t.id+"]")}else{if(!t.before)return(e=new g.Deferred).reject(""),e;for(n=-1,i=0;i<r;i++){if(this.history[i].id==t.before){n=i;break}}if(0<=--n){c=r-n;return(h=this.history.splice(n,c))[0].isBack=!0,this.to(h[0])}g.logger.error("core.router: ","can not found the term before:["+t.before+"]")}},r.prototype.replace=function(){var t,e=g.utils.args2Arr(arguments);if(1==e.length&&"object"==g.utils.type(e[0]))t=e[0];else{t={};for(var r=0;r<e.length;r++)0==r?t.id=e[r]:1==r?t.data=e[r]:2==r?t.rootId=e[r]:3==r&&(t.options=e[r])}return t.options=void 0===t.options?{}:t.options,t.options.openPolicy=p.Replace,this.to(t)},r.prototype.append=function(){var t,e=g.utils.args2Arr(arguments);if(1==e.length&&"object"==g.utils.type(e[0]))t=e[0];else{t={};for(var r=0;r<e.length;r++)0==r?t.id=e[r]:1==r?t.data=e[r]:2==r?t.rootId=e[r]:3==r&&(t.options=e[r])}return t.options=void 0===t.options?{}:t.options,t.options.openPolicy=p.Append,this.to(t)},r.prototype.remove=function(){if(0==this.activePages.length)return!1;for(var t="",e=-1,r=this.activePages.length-1;0<=r;r--){if(1<this.activePages[r].nodes.length){e=r;var i=this.activePages[r].nodes,t=i[i.length-1].cite.root.split(" #")[1];break}var o=this.activePages[r].nodes[0].cite;if(o.options&&o.options.openPolicy===p.Append){e=r;break}}return-1!=e&&this.unMount("",e,t)},r.prototype.to=function(){var t,e=g.utils.args2Arr(arguments);if(1==e.length&&"object"==g.utils.type(e[0]))t=e[0];else{t={};for(var r=0;r<e.length;r++)0==r?t.id=e[r]:1==r?t.data=e[r]:2==r?t.rootId=e[r]:3==r&&(t.options=e[r])}var i=t.id,o=this.getRoute(i);if(!o||o&&!o.html)g.logger.error("core.router: ","Router info not register ["+i+"]");else{t.rootId||(t.rootId=o.rootId),t.rootId||(t.rootId=this.settings.rootId);var n={},s=o.html.indexOf("?");if(-1!=s)for(var a=o.html.substring(s+1,o.html.length).split("&"),r=0;r<a.length;r++){var u=a[r].split("=");n[u[0]]=unescape(u[1])}t.data?h.clone(n,t.data):t.data=n;var l={id:i,rootId:t.rootId,startTime:(new Date).getTime(),options:t.options,isBack:!!t.isBack&&t.isBack};if(0!=this.doFilters(y.Before,i,t.data,l)){var c=new g.Deferred;return this.mount(t,o,l,c),c}}},r.prototype.mount=function(a,t,u,l){var c=this,e=u.options&&u.options.mountHandlerType?u.options.mountHandlerType:"default",r=this.getMountHandler(e);return this.eventChain.post(function(){r.mount(a.id,t,u,c,function(t,e,r){if(0!==t)return g.logger.error("core.router: ","mount fail"),l.reject(a.id),void c.eventChain.fire();null==e&&(e={}),u.root=r;var i,o={target:a,exports:e,cite:u},n=c.lastIndexOfPages(a.rootId);-1==n?(i={id:a.rootId,nodes:[]},c.activePages.push(i)):i=c.activePages[n],i.nodes.push(o),c.addHistory(a.id,a.data,a.rootId,a.options);var s=(new Date).getTime();if(g.logger.debug("core.router: ","Open page ["+a.id+"] Cost:"+(s-u.startTime)+" ms"),e.ready){c.doFilters(y.Ready,e,a.id,a.data,u);try{e.ready(a.id,a.data,u)}catch(t){g.logger.error("core.router: ",t.Message,t)}}l.resolve(a.id),c.eventChain.fire()})}),!0},r.prototype.releasePages=function(t,e,r){for(var i=1==e?0:t.nodes.length-1,o=t.nodes.length-1;i<=o;o--){var n=t.nodes[o].cite,s=t.nodes[o].exports;if(null!=s){var a=t.nodes[o].target,u=this.getRoute(a.id),l=n.options&&n.options.mountHandlerType?n.options.mountHandlerType:"default",c=this.getMountHandler(l);try{c.unMount(a.id,u,n,s,this),!1!==h.core.require.debug&&h.require.modules.remove(h.require.resolvePath(u.js))}catch(t){g.logger.error("core.router: ",t.Message,t)}s.destroy&&(this.doFilters(y.Destroy,s,a.id,n),s.destroy.call(s,a.id,n)),r&&this.removeHistory(a.id),t.nodes.splice(o,1)}}return!0},r.prototype.unMount=function(t,e,r){if(0!=this.activePages.length){var i=null==e;i?e=0:t=this.activePages[e].id,r=r||t;for(var o=this.activePages.length-1;e<=o;o--){var n=this.activePages[o];if(t==n.id)return this.releasePages(n,i,!1),!i&&0!=n.nodes.length||this.activePages.splice(o,1),!0;this.isChildNode(r,n.id)&&(this.releasePages(n,!0,!0),this.activePages.splice(o,1))}return!1}},r.prototype.isChildNode=function(t,e){var r="string"===g.utils.type(t)?this.doc.getElementById(t):t;if(!r)return!1;var i="string"===g.utils.type(e)?this.doc.getElementById(e):e;if(!i)return!1;for(var o=i.parentNode;o!=r&&o!=this.doc;)o=o.parentNode;return o==r},r.prototype.sendMessage=function(t,e,r){var i=this.getRoute(t);if(i&&i.js){var o=this.findPage(t);if(o&&o.exports&&o.exports.onmessage){var n=o?o.cite:{},s=document.querySelector(o.cite.el),a=s&&s.parentNode?s.parentNode.getAttribute(g.vmMgr.vmSeedAttr):"-1",u=g.vmMgr.vmStorageGet(a);return o.exports.onmessage(e,r,n,u)}g.logger.error("core.router: ","exports or exports.onmessage none define")}else g.logger.error("core.router: ","Router info not register ["+t+"],or none js module")},r.prototype.lastIndexOfPages=function(t){for(var e=-1,r=this.activePages.length-1;0<=r;r--)if(this.activePages[r].id===t){e=r;break}return e},r.prototype.findPage=function(t){for(var e=this.activePages.length-1;0<=e;e--)for(var r=this.activePages[e].nodes.length-1;0<=r;r--){var i=this.activePages[e].nodes[r];if(i.target.id===t)return i}};var i=function(){};i.prototype.mount=function(a,t,u,l,c){for(var r=u.rootId,h=document.getElementById(r),p=[],d=[],e=g.utils.getFirstElementChild(h);null!=e;){var i=e.nodeName;"SCRIPT"==(i=i&&i.toUpperCase())?d.push(e):"LINK"==i&&p.push(e),e=g.utils.getNextElementSibling(e)}e=null;var o,f=[];t.css&&(o=t.css.split(","),f=f.concat(o)),t.js&&(o=t.js.split(","),f=f.concat(o)),g.require.get(t.html,function(t,n){if(0!=t)return g.logger.error("core.router: loading html resource failed"),void l.eventChain.fire();l.unMount(r,void 0);var s="#"+h.id,e={cssPoint:s,jsPoint:s};g.require.require(f,function(){for(var t,e=g.utils.args2Arr(arguments),r=0;r<e.length;r++)if("object"==g.utils.type(e[r])){t=e[r];break}if(t&&t.mount){l.doFilters(y.Mount,a,u);try{t.mount(a,u)}catch(t){g.logger.error("core.router: ",t.Message,t)}}for(r=0;h.hasChildNodes()&&r<d.length;r++)try{h.removeChild(d[r])}catch(t){}d=null;for(r=0;h.hasChildNodes()&&r<p.length;r++)try{h.removeChild(p[r])}catch(t){}p=null;var i=document.createElement("div");i.innerHTML=n;var o=g.utils.uidcode("RT_",u.id);document.getElementById(o)&&(o=o+"_"+ +new Date),i.id=o,u.el="#"+o+" :first-child",h.appendChild(i),c(0,t,s),h=i=n=null},e)})},i.prototype.unMount=function(t,e,r,i,o){if(o.doFilters(y.UnMount,t,r),i.unMount)try{i.unMount(t,r)}catch(t){g.logger.error("core.router: ",t.Message,t)}},g.Router=r,g.router=new r}(yufp.core,yufp),function(f){function t(){this.duration=300,this.vmSeedAttr="VM_SEED_ID",this.vmSeed=0,this.vmAlive={},this.minxinExecuted=!1}t.prototype.vmGetSeedId=function(){return this.vmSeed++,"VM_"+this.vmSeed},t.prototype.vmStorageRemove=function(t){var e=this.vmAlive[t];return e&&delete this.vmAlive[t],e},t.prototype.vmStoragePut=function(t,e){this.vmAlive[t]=e},t.prototype.vmStorageGet=function(t){return this.vmAlive[t]},t.prototype.mixin=function(){var r=this;r.minxinExecuted||(r.minxinExecuted=!0,Vue.mixin({mounted:function(){var t=this.$el,e=!(!t||!t.getAttribute)&&t.getAttribute(r.vmSeedAttr);(e=e||!(!t||!t.parentNode)&&t.parentNode.getAttribute(r.vmSeedAttr))&&r.vmStoragePut(e,this)}}))},f.vmMgr=new t;function e(){}e.prototype.replace=function(a,t,u,l,c,h){for(var p=[],d=[],e=f.utils.getFirstElementChild(h);null!=e;){var r=e.nodeName.toUpperCase();"SCRIPT"===r?d.push(e):"LINK"===r&&p.push(e),e=f.utils.getNextElementSibling(e)}e=null;var i=[];t.css&&(i=i.concat(t.css.split(","))),t.js&&(i=i.concat(t.js.split(","))),f.require.get(t.html,function(t,n){if(0!=t)return f.logger.error("core.router.patch: loading html resource failed"),void l.eventChain.fire();var s="#"+h.id,e={cssPoint:s,jsPoint:s};f.require.require(i,function(){l.unMount(u.rootId);for(var t,e=arguments,r=0;r<e.length;r++)if("object"===f.utils.type(e[r])){t=e[r];break}if(t&&t.mount){l.doFilters(f.FilterType.Mount,a,u);try{t.mount(a,u)}catch(t){f.logger.error("core.router.patch: ",t.Message,t)}}for(r=0;h.hasChildNodes()&&r<d.length;r++)try{h.removeChild(d[r])}catch(t){}d=null;for(r=0;h.hasChildNodes()&&r<p.length;r++)try{h.removeChild(p[r])}catch(t){}p=null;var i=document.createElement("div");i.innerHTML=n;var o=f.utils.uidcode("RT_",u.id);document.getElementById(o)&&(o=o+"_"+ +new Date),i.id=o,u.el="#"+o+" :first-child",i.setAttribute(f.vmMgr.vmSeedAttr,f.vmMgr.vmGetSeedId()),h.appendChild(i),c(0,t,s),h=i=n=null},e)})},e.prototype.append=function(u,t,l,c,h,r){var i=[];t.css&&(i=i.concat(t.css.split(","))),t.js&&(i=i.concat(t.js.split(","))),f.require.get(t.html,function(t,n){if(0!=t)return f.logger.error("core.router.patch: loading html resource failed"),void c.eventChain.fire();var s=document.createElement("div");s.classList.add("yu-view"),s.classList.add("yu-view-hide"),s.id=f.utils.uid("html",0,"VW_"),r.appendChild(s);var a="#"+r.id+" #"+s.id,e={cssPoint:a,jsPoint:a};f.require.require(i,function(){for(var t,e=arguments,r=0;r<e.length;r++)if("object"===f.utils.type(e[r])){t=e[r];break}if(t&&t.mount){c.doFilters(f.FilterType.Mount,u,l);try{t.mount(u,l)}catch(t){f.logger.error("core.router.patch: ",t.Message,t)}}var i=document.createElement("div");i.style="height: 100%;";var o=f.utils.uidcode("RT_",l.id);document.getElementById(o)&&(o=o+"_"+ +new Date),i.id=o,l.el="#"+o+" :first-child",i.setAttribute(f.vmMgr.vmSeedAttr,f.vmMgr.vmGetSeedId()),i.innerHTML=n,s.appendChild(i),h(0,t,a),setTimeout(function(){s.classList.remove("yu-view-hide"),l.options&&(1===l.options.noInAnimation||1===l.options.noAnimation)||s.classList.add("yu-view-anim-slidein-right"),s=null},3)},e)})},e.prototype.mount=function(t,e,r,i,o){f.vmMgr.mixin();var n=r.rootId,s=document.getElementById(n);r.options&&r.options.openPolicy===f.OpenPolicy.Append?this.append(t,e,r,i,o,s):this.replace(t,e,r,i,o,s)},e.prototype.unMount=function(t,e,r,i,o){var n=document.querySelector(r.el),s=(n=n.parentNode).getAttribute(f.vmMgr.vmSeedAttr),a=void 0!==s?f.vmMgr.vmStorageRemove(s):null;if(r.options&&r.options.openPolicy==f.OpenPolicy.Append)try{var u=document.querySelector(r.root);u.classList.remove("yu-view-anim-slidein-right"),r.options&&(1===r.options.noOutAnimation||1===r.options.noAnimation)||u.classList.add("yu-view-anim-slideout-right")}finally{setTimeout(function(){u.parentNode&&u.parentNode.removeChild(u),a&&a.$destroy(),a=u=null},f.vmMgr.duration)}else n.parentNode&&n.parentNode.removeChild(n),a&&a.$destroy(),n=a=null;if(o.doFilters(f.FilterType.UnMount,t,r),i.unMount)try{i.unMount(t,r)}catch(t){f.logger.error("core.router.patch: ",t.Message,t)}this._gc()},e.prototype._gc=function(){"function"==typeof window.CollectGarbage&&setTimeout(function(){window.CollectGarbage()},4)},f.router.addMountHandler("default",new e)}(yufp.core,yufp),function(e,t){t.extend=e.utils.extend,t.extend(e.utils),t.bus=e.bus,t.require=e.require,t.router=e.router,t.logger=e.logger,t.eventproxy=new e.EventProxy,t.EventChain=e.EventChain,t.config=function(t){e.require.config(t)}}(yufp.core,yufp);
- //# sourceMappingURL=yufp.core.min.js.map
|