PageSourceSearch

https://static-cdn.wotgame.cn/static/6.16.0_bbf399/portal/js/page_wrapper_manager.js

js wotgame.cn collected 2026-10-05 23:53:20 UTC 2,864 bytes, 90 lines download raw bytes

1(function ($, _, amplify, ResolutionManager) {
2'use strict';
3
4function PageWrapperManager() {
5    $(_.bind(function() {
6        this.init();
7    }, this));
8}
9
10PageWrapperManager.prototype.init = function() {
11    this.$pageWrapper = $('.js-page-wrapper');
12    this.cropClass = this.$pageWrapper.data('popupMobileHidden');
13    this.activeCrops = [];
14    this.isCropActive = false;
15    this.savedScrollPosition = 0;
16
17    amplify.subscribe('resolution:statechanged', this, function(newState) {
18        this.updateState(newState);
19    });
20};
21
22PageWrapperManager.prototype.request = function(requesterId, options) {
23    var obj = new Crop(requesterId, options);
24
25    this.activeCrops.push(obj);
26    if (!this.isCropActive) {
27        this.savedScrollPosition = $(window).scrollTop();
28    }
29    this.updateState(ResolutionManager.getCurrentState());
30
31    return obj.id;
32};
33
34PageWrapperManager.prototype.revoke = function(requesterId) {
35    _.remove(this.activeCrops, function(cropItem) { return (cropItem.requesterId === requesterId);});
36    this.updateState(ResolutionManager.getCurrentState());
37};
38
39PageWrapperManager.prototype.updateState = function(newResolutionState) {
40    var isAnyActiveCrop = false;
41
42    _.each(this.activeCrops, function(cropObj) {
43        if (newResolutionState >= cropObj.minResolution && newResolutionState <= cropObj.maxResolution) {
44            isAnyActiveCrop = true;
45        }
46    }, this);
47
48    this.changeCropActive(isAnyActiveCrop);
49};
50
51PageWrapperManager.prototype.changeCropActive = function(newIsCropActive) {
52    if (this.isCropActive !== newIsCropActive) {
53        this.isCropActive = newIsCropActive;
54
55        this.$pageWrapper.toggleClass(this.cropClass, this.isCropActive);
56
57        if (!this.isCropActive) {
58            amplify.publish('mainmenu:stopscrolldetect');
59            $(window).scrollTop(this.savedScrollPosition);
60            amplify.publish('mainmenu:resumescrolldetect');
61        }
62    }
63};
64
65PageWrapperManager.prototype.requestMobileCrop = function(requesterId) {
66    return this.request(requesterId, {maxResolution: ResolutionManager.RESOLUTION_MOBILE_WIDE});
67};
68
69PageWrapperManager.prototype.requestTabletCrop = function(requesterId) {
70    return this.request(requesterId, {maxResolution: ResolutionManager.RESOLUTION_TABLET});
71};
72
73function Crop(requesterId, options) {
74    var defaultOptions = {
75            minResolution: ResolutionManager.RESOLUTION_MIN,
76            maxResolution: ResolutionManager.RESOLUTION_MAX,
77            id: _.uniqueId('pageWrapperCrop_')
78        };
79
80    this.options = $.extend({}, defaultOptions, options);
81
82    this.requesterId = requesterId;
83    this.id = this.options.id;
84    this.minResolution = this.options.minResolution;
85    this.maxResolution = this.options.maxResolution;
86}
87
88window.PageWrapperManager = new PageWrapperManager();
89
90})(jQuery, _, amplify, ResolutionManager);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.