resources/dist/mobile.special.watchlist.scripts.js
(self.webpackChunkmfModules=self.webpackChunkmfModules||[]).push([[601],{"./src/mobile.special.watchlist.scripts/ScrollEndEventEmitter.js":(t,s,e)=>{var i=e("./src/mobile.startup/util.js"),l=e("./src/mobile.startup/mfExtend.js");function r(t,s){this.threshold=s||100,this.eventBus=t,this.enable(),OO.EventEmitter.call(this)}OO.mixinClass(r,OO.EventEmitter),r.EVENT_SCROLL_END="ScrollEndEventEmitter-scrollEnd",l(r,{_bindScroll:function(){this._scrollHandler||(this._scrollHandler=this._onScroll.bind(this),this.eventBus.on("scroll:throttled",this._scrollHandler))},_unbindScroll:function(){this._scrollHandler&&(this.eventBus.off("scroll:throttled",this._scrollHandler),this._scrollHandler=null)},_onScroll:function(){this.$el&&this.enabled&&this.scrollNearEnd()&&(this.disable(),this.emit(r.EVENT_SCROLL_END))},scrollNearEnd:function(){if(!this.$el||!this.$el.offset())return!1;var t=i.getWindow(),s=t.scrollTop()+t.height(),e=this.$el.offset().top+this.$el.outerHeight();return s+this.threshold>e},enable:function(){this.enabled=!0,this._bindScroll()},disable:function(){this.enabled=!1,this._unbindScroll()},setElement:function(t){this.$el=t}}),t.exports=r},"./src/mobile.special.watchlist.scripts/WatchList.js":(t,s,e)=>{var i=e("./src/mobile.startup/mfExtend.js"),l=e("./src/mobile.startup/PageList.js"),r=e("./src/mobile.startup/watchstar/WatchstarPageList.js"),n=e("./src/mobile.special.watchlist.scripts/ScrollEndEventEmitter.js"),a=e("./src/mobile.startup/util.js"),c=e("./src/mobile.special.watchlist.scripts/WatchListGateway.js");function o(t){var s,e=a.extend({},{isBorderBox:!1},t);this.scrollEndEventEmitter=new n(e.eventBus),this.scrollEndEventEmitter.on(n.EVENT_SCROLL_END,this._loadPages.bind(this)),e.el&&(s=this.getLastTitle(e.el)),this.gateway=new c(e.api,s),r.call(this,e)}i(o,r,{preRender:function(){this.scrollEndEventEmitter.disable(),this.scrollEndEventEmitter.setElement(this.$el)},postRender:function(){l.prototype.postRender.apply(this);var t=this.queryUnitializedItems(),s=Object.keys(this.parsePagesFromItems(t)).reduce((function(t,s){return t[s]=!0,t}),{});this.renderItems(t,s),this.scrollEndEventEmitter.enable()},_loadPages:function(){this.gateway.loadWatchlist().then(function(t){t.forEach(function(t){this.appendPage(t)}.bind(this)),this.render()}.bind(this))},appendPage:function(t){var s=a.extend({},t,{wikidataDescription:void 0});this.$el.append(this.templatePartials.item.render(s))},getLastTitle:function(t){return t.find("li").last().attr("title")}}),t.exports=o},"./src/mobile.special.watchlist.scripts/WatchListGateway.js":(t,s,e)=>{var i=e("./src/mobile.startup/page/pageJSONParser.js"),l=e("./src/mobile.startup/util.js"),r=e("./src/mobile.startup/extendSearchParams.js");function n(t,s){this.api=t,this.limit=50,s?(this.continueParams={continue:"gwrcontinue||",gwrcontinue:"0|"+s.replace(/ /g,"_")},this.shouldSkipFirstTitle=!0):(this.continueParams={continue:""},this.shouldSkipFirstTitle=!1),this.canContinue=!0}n.prototype={loadWatchlist:function(){var t=this,s=r("watchlist",{prop:["info","revisions"],rvprop:"timestamp|user",generator:"watchlistraw",gwrnamespace:"0",gwrlimit:this.limit},this.continueParams);return!1===this.canContinue?l.Deferred().resolve([]):this.api.get(s).then((function(s){return void 0!==s.continue?t.continueParams=s.continue:t.canContinue=!1,t.parseData(s)}))},parseData:function(t){var s;return t.query&&t.query.pages?((s=t.query.pages).sort((function(t,s){return t.title===s.title?0:t.title<s.title?-1:1})),this.shouldSkipFirstTitle&&(s=s.slice(1),this.shouldSkipFirstTitle=!1),s.map(i.parse)):[]}},t.exports=n},"./src/mobile.special.watchlist.scripts/mobile.special.watchlist.scripts.js":(t,s,e)=>{var i=e("./src/mobile.special.watchlist.scripts/WatchList.js"),l=e("./src/mobile.startup/eventBusSingleton.js");$((function(){var t;t=$("ul.mw-mf-watchlist-page-list"),0===$(".mw-mf-watchlist-selector").length&&new i({api:new mw.Api,el:t,funnel:"watchlist",skipTemplateRender:!0,eventBus:l}),t.find(".mw-mf-watchlist-more").remove()}))}},t=>{t.O(0,[569],(()=>t(t.s="./src/mobile.special.watchlist.scripts/mobile.special.watchlist.scripts.js")));var s=t.O();(this.mfModules=this.mfModules||{})["mobile.special.watchlist.scripts"]=s}]);
//# sourceMappingURL=mobile.special.watchlist.scripts.js.map.json