%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/985914/root/data/old/home/stash/atlassian-stash/static/widget/
Upload File :
Create Path :
Current File : //proc/985914/root/data/old/home/stash/atlassian-stash/static/widget/paged-scrollable-min.js

define("widget/paged-scrollable",["aui","jquery","underscore","util/deprecation","util/events","util/function","widget/loaded-range"],function(H,C,I,D,J,F,B){var A=C.browser.msie;function G(L,K){this.options=C.extend({},G.defaults,K);this.$scrollElement=C(L||window);if(C.isWindow(this.$scrollElement[0])){var M=window.document.documentElement;this.getPaneHeight=function(){return M.clientHeight};this.getContentHeight=function(){return M.scrollHeight}}this._eventHandlers=[]}G.defaults={pageSize:50,scrollDelay:250,bufferPixels:0,precedingSpaceMaintained:true,suspendOnFailure:true,dataLoadedEvent:"stash.widget.pagedscrollable.dataLoaded",autoLoad:true,preventOverscroll:false,idForEntity:null};G.prototype.init=function(M){G.prototype.reset.call(this);M=M||{};this.loadedRange=M.loadedRange||new B();var L=this;var K=this.options.pageSize;var N=M.targetedItem?Math.floor(M.targetedItem/K)*K:0;if(M.suspended){this.suspend()}if(this.loadedRange.isLoaded(N)){return(this.loadIfRequired()||C.Deferred().resolve()).done(function(){L.onFirstDataLoaded()})}return E(this,N,K).then(undefined,function(){var O=N!==0;if(O){return E(L,0,K)}else{return C.Deferred().rejectWith(this,arguments)}}).fail(function(R,Q,O,P){if(P&&P.errors&&P.errors.length){L.handleErrors(P.errors)}})};G.prototype.reset=function(){if(this.currentXHR){this.cancelRequest()}this.clearListeners();if(this._resizeHandler){C(window).off("resize",this._resizeHandler);this._resizeHandler=null}if(this.options.idForEntity){this._ids={}}this._suspended=false};G.prototype.destroy=function(){this.reset();delete this.$scrollElement};G.prototype.suspend=function(){this._suspended=true};G.prototype.resume=function(){this._suspended=false;return this.loadIfRequired()};G.prototype.isSuspended=function(){return this._suspended};G.prototype.getScrollTop=function(){return this.$scrollElement.scrollTop()};G.prototype.setScrollTop=function(K){this.$scrollElement.scrollTop(K)};G.prototype.getPane=function(){return this.$scrollElement};G.prototype.getPaneHeight=function(){return this.$scrollElement[0].clientHeight};G.prototype.getContentHeight=function(){return this.$scrollElement[0].scrollHeight};G.prototype.getOption=function(K){if(Object.prototype.hasOwnProperty.call(this.options,K)){return this.options[K]}return undefined};G.prototype.setOptions=function(K){if(C.isPlainObject(K)){this.options=C.extend(this.options,K)}};G.prototype.addScrollListener=function(L){var K=this.scrollDelay?I.debounce(L,this.scrollDelay):L;this._eventHandlers.push(K);this.$scrollElement.on("scroll.paged-scrollable",K)};G.prototype.clearScrollListeners=D.fn(G.prototype.clearListeners,"widget/paged-scrollable::clearScrollListeners","widget/paged-scrollable::clearListeners","2.6","3.0");G.prototype._bindOverscrollPrevention=function(){function K(N,O){var L=C(this).outerHeight();var M=this.scrollHeight;if((this.scrollTop===(M-L)&&O<0)||(this.scrollTop===0&&O>0)){N.preventDefault()}}this._eventHandlers.push(K);this.$scrollElement.on("mousewheel.paged-scrollable",K)};G.prototype.clearListeners=function(){var K=this;I.each(this._eventHandlers,function(L){K.$scrollElement.unbind(".paged-scrollable",L)});this._eventHandlers.length=0};G.prototype.loadIfRequired=function(){if(this.isSuspended()||(this.loadedRange.reachedEnd()&&this.loadedRange.reachedStart())){return }var P=this.getScrollTop(),L=this.getPaneHeight(),N=this.getContentHeight(),O=L+P;if(!C.isWindow(this.getPane()[0])&&this.getPane().is(":hidden")){return }if(I.any([true,"previous"],F.eq(this.options.autoLoad))&&P<this.options.bufferPixels+(this.loadedRange.start/this.loadedRange.nextPageStart)*N){var K=this.loadedRange.pageBefore(this.options.pageSize);if(K){return this.load(K.start,K.limit)}}var Q=1;if(I.any([true,"next"],F.eq(this.options.autoLoad))&&O+Q>=N-this.options.bufferPixels){var M=this.loadedRange.pageAfter(this.options.pageSize);if(M){return this.load(M.start,M.limit)}}};function E(L,M,K){if(L.currentXHR){return C.Deferred().reject()}L.currentXHR=L.requestData(M,K);return L.currentXHR.always(function(){L.currentXHR=null}).done(function(N){L.onDataLoaded(M,K,N)}).fail(function(){L.suspend()})}G.prototype.load=function(M,K){var L=this;return E(this,M,K).fail(function(Q,P,N,O){if(O&&O.errors){L.handleErrors(O.errors)}})};G.prototype.loadAfter=function(){var K=this.loadedRange.pageAfter(this.options.pageSize);return K&&this.load(K.start,K.limit)};G.prototype.loadBefore=function(){var K=this.loadedRange.pageBefore(this.options.pageSize);return K&&this.load(K.start,K.limit)};G.prototype.onDataLoaded=function(M,N,P){if(P.start!==undefined){M=P.start}var R=this.loadedRange.isEmpty(),K=this.loadedRange.getAttachmentMethod(M,P.size),Q=K==="prepend";this.loadedRange.add(M,P.size,P.isLastPage,P.nextPageStart);var S,O;if(Q||A){O=this.getScrollTop();S=this.getContentHeight()}P=this._addPage(P,K);if(Q||A){var L=Q?this.getContentHeight()-S:0;this.setScrollTop(O+L)}if(R){this.onFirstDataLoaded(M,N,P)}J.trigger(this.options.dataLoadedEvent,this,M,N,P);this.loadIfRequired()};G.prototype._addPage=function(L,K){L=this._dedupe(L);this.attachNewContent(L,K);return L};G.prototype._dedupe=function(M){if(M&&M.values&&this.options.idForEntity){var L=this._ids;var K=this.options.idForEntity;M=C.extend({},M,{values:I.filter(M.values,function(N){var O=K(N);if(!I.has(L,O)){L[O]=true;return true}return false})})}return M};G.prototype.onFirstDataLoaded=function(){var K=this;this.addScrollListener(function(){K.loadIfRequired()});if(this.options.preventOverscroll){this._bindOverscrollPrevention()}C(window).on("resize",this._resizeHandler=function(){K.loadIfRequired()})};G.prototype.cancelRequest=function(){if(this.currentXHR){if(this.currentXHR.abort){this.currentXHR.abort()}else{if(this.currentXHR.reject){this.currentXHR.reject()}else{H.log("Couldn't cancel the current request.")}}this.currentXHR=null}};G.prototype.add=function(L,K){if(L.length){L=this._addPage({values:L,size:L.length},K||"prepend");return true}return false};G.prototype.remove=function(K){if(this.options.idForEntity){var L=this.options.idForEntity(K);if(I.has(this._ids,L)){delete this._ids[L];if(typeof this.loadedRange.nextPageStart==="number"){this.loadedRange.nextPageStart=Math.max(0,this.loadedRange.nextPageStart-1)}return true}}return false};G.prototype.attachNewContent=function(L,K){throw new Error("attachNewContent is abstract and must be implemented.")};G.prototype.requestData=function(L,K){throw new Error("requestData is abstract and must be implemented.  It must return a promise. It is preferred to return a jqXHR.")};G.prototype.handleErrors=function(K){throw new Error("handleErrors is abstract and must be implemented.")};return G});

Zerion Mini Shell 1.0