%PDF- %PDF-
| Direktori : /data/old/home/stash/atlassian/stash/3.7.1/atlassian-stash/static/page/source/ |
| Current File : //data/old/home/stash/atlassian/stash/3.7.1/atlassian-stash/static/page/source/source-min.js |
define("page/source",["aui","jquery","lodash","memoir","stash/api/util/navbuilder","util/ajax","util/events","model/commit-range","model/file-change","model/file-content-modes","model/page-state","model/path","model/revision","model/revision-reference","widget/faux-scrollbar","feature/changeset/changeset-badge","feature/file-content","layout/page-scrolling-manager","exports"],function(I,E,T,O,H,N,A,G,L,B,M,R,K,U,F,D,J,C,S){var P;S.onReady=function(k,u,Z,i,f,Y,n){C.acceptScrollForwardingRequests();var s=new F();A.on("stash.feature.fileContent.fileBlameExpandedStateChanged",function(){s.containerSizeChanged(true)});var r=window.location.href,X=new R(k),h=new U(u),b=new K(Z),W=B.DIFF===i?B.DIFF:B.SOURCE;var m=new J(f,Y,J.sourcePreset);A.on("memoir.changestate",function(AE){var AC,z,AF,v;var w=AE.state;if(w){AC=new R(w.path);z=new U(w.headRef);AF=w.untilRevision?new K(w.untilRevision):null;v=w.mode?w.mode:B.SOURCE;var AG=b?b.getId():null,AH=AF?AF.getId():null;var x=AC.toString()!==X.toString(),AB=h.getId()!==z.getId(),AD=AH!==AG,y=v!==W,AA=x||AB||AD||y;X=AC;b=AF;h=z;W=v;if(AB){A.trigger("stash.page.source.revisionRefChanged",null,h)}if(AA){p()}r=window.location.href}else{var AI=q(a(window.location.href),a(r));if(!AI){window.location.reload()}}});function g(){return new G({untilRevision:b,sinceRevision:b.hasParents()?b.getParents()[0]:undefined})}function a(v){var w=v.lastIndexOf("#");return w===-1?v:v.substring(0,w-1)}function q(w,v){return w.lastIndexOf(v)===w.length-v.length}A.on("stash.feature.fileContent.optionsChanged",function(w){var v=["hideComments","hideEdiff"];if(!T.contains(v,w.key)){p()}});var d=null;function p(){if(d){d.abort();d=null}if(!b){d=e(X,h);m.reset();d.always(function(){d=null}).done(function(v){b=v;p()})}else{c().then(V);o(b)}}function c(){var w=E.extend({toolbarWebFragmentLocationPrimary:"stash.file-content."+W+".toolbar.primary",toolbarWebFragmentLocationSecondary:"stash.file-content."+W+".toolbar.secondary"},J[W+"Preset"]);w.relevantContextLines=n;var v=new L({commitRange:g(),path:X,repository:M.getRepository()});return m.init(v,h,l(),w)}function V(){var w=W===B.DIFF;var v=!w&&m.$self.find(".CodeMirror-hscrollbar")[0];if(v){s.init(v,{hideAbove:false})}else{s.destroy();s=new F()}}function o(v){E(".branch-selector-toolbar .changeset-badge-container").empty().append(D.create(v.toJSON(),M.getRepository().toJSON())).fadeIn("fast")}function t(x,w,v,y){return{path:x.toString(),headRef:w.toJSON(),untilRevision:v?v.toJSON():null,mode:y}}function j(y,w,v,z){var x=H.currentRepo();if(z===B.DIFF){x=x.diff(new L({commitRange:new G({untilRevision:v}),path:y,repository:M.getRepository()}))}else{x=x.browse().path(y);if(v){x=x.until(v.getId())}}if(!w.isDefault()){x=x.at(w.getId())}O.pushState(t(y,w,v,z),null,x.build())}function l(){var w=window.location.hash,v=w.match(/#(\d+)/);return v&&Number(v[1])}function e(x,z){var w=H.rest().currentRepo().commit(z.getLatestChangeset());var y=N.rest({url:w.withParams({path:x.toString(),avatarSize:stash.widget.avatarSizeInPx({size:"xsmall"})}).build(),statusCode:{"404":function(){return E.Deferred().resolve({id:z.getId(),displayId:z.getDisplayId(),author:{name:"Unknown"},authorTimestamp:NaN})}}}),v=y.then(function(AA){return new K(AA)});A.trigger("stash.page.source.requestedRevisionData");return v.promise(y)}O.initialState(t(X,h,b,W));c().then(V);A.on("stash.layout.branch.revisionRefChanged",function(v){if(h!==v){j(X,v,null,"source")}});A.on("stash.feature.*.untilRevisionChanged",function(v){if(b.getId()!==v.getId()){j(X,h,v,W)}});A.on("stash.feature.*.requestedModeChange",function(v){if(W!==v){j(X,h,b,v)}});A.on("stash.feature.sourceview.onError",function(v){E(".branch-selector-toolbar .changeset-badge-container").fadeOut("fast")});A.on("stash.layout.*.urlChanged",function(v){window.location=v});A.on("stash.feature.*.urlChanged",function(v){window.location=v});A.on("stash.widget.branchselector.dialogShown",function(){P=true});A.on("stash.widget.branchselector.dialogHidden",function(){P=false});E(window).on("hashchange",function(){r=window.location.href;if(O.nativeSupport()){O.replaceState(t(X,h,b),null,r)}var v=window.location.hash.substring(1).match(/\d+/);A.trigger("stash.page.source.selectedLineChanged",null,v?Number(v[0]):null)});A.on("stash.widget.keyboard-shortcuts.register-contexts",function(v){v.enableContext("sourceview");v.enableContext("diff-view")});Q()};function Q(){A.on("stash.keyboard.shortcuts.requestOpenParentHandler",function(V){(this.execute?this:I.whenIType(V)).execute(function(){if(!P){var W=E(".breadcrumbs").find("a:last");if(W.length){if(O.nativeSupport()){W.click()}else{window.location.href=W.attr("href")}}}})})}});