service_wev8.js 1.63 KB
define("mService",["mUtil","mobilebone","i18n"],function(c,l,d){var v={},s="mService/",a={setService:function(e,t){this[e]=t},getService:function(e){return this[e]}};function u(e){var t=a.getService(e);if(t)return t;var i=e.indexOf("/"),n=-1===i?e:e.substring(0,i);this.id=e,this.name=s+e,this.css="css!"+s+n+"_css",this.html=s+e+"_html",this.setService=function(e){this.service=e},this.setTpl=function(e){this.tpl=e},a.setService(e,this)}return u.prototype={load:function(i){var n=$.Deferred(),s=this;return i=i||function(){},s.tpl?(i(s.tpl,s.service),n.resolve(s.tpl,s.service)):(require([this.name,this.css],function(t){require([s.html],function(e){i(e,t),n.resolve(e,t),s.setTpl(e),s.setService(t)})}),n)},preload:function(){require([this.name,this.css])}},{show:function(e,i){var t="page_service_"+e.replace("/","_"),n=i&&i._identity;n&&(t+="_"+n);var s=!0,a=v[t];a?s=!n:(a=$('<div id="'+t+'" class="page out" data-onpagefirstinto="none" data-callback="serviceChange"><div class="page-loading wev-loading">'+d.LOADING_DATA+"</div></div>"),$(document.body).append(a),v[t]=a);var r=a[0],o=$(".in."+l.classPage);(i.classAnimation&&!i.preload&&(o.attr("data-form",i.classAnimation),a.attr("data-form",i.classAnimation),r.flagAniBind=!1,r.animationend=function(e,t){"out"==t&&e.classList.contains("reverse")&&(o.removeAttr("data-form").removeClass(i.classAnimation),a.removeAttr("data-form").removeClass(i.classAnimation))}),!i.preload&&l.transition(r,o[0],!1,{}),s)&&new u(e).load().then(function(e,t){e=c.replaceI18n(e),a.html(e),t.mounted(a,i)})},preload:function(e){new u(e).preload()},load:function(e,t){new u(e).load(t)},getService:function(e){return new u(e)}}});