Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __d("PhotoSnowlift", ["array-extensions", "event-extensions", "function-extensions", "Arbiter", "AsyncDialog", "AsyncRequest", "Bootloader", "Class", "CSS", "Dialog", "DOM", "DOMControl", "FullScreen", "ImageUtils", "Keys", "LinkController", "Locale", "PageTransitions", "Parent", "PhotosConst", "PhotoSessionLog", "PhotoSnowliftAds", "PhotoStreamCache", "PhotosUtils", "PhotoViewer", "Rect", "ScrollableArea", "Style", "Toggler", "UIPagelet", "URI", "UserAgent", "Vector", "$", "computeRelativeURI", "copyProperties", "createArrayFrom", "csx", "emptyFunction", "ge", "goURI", "tx", "userAction"], function (a, b, c, d, e, f) {
- b('array-extensions');
- b('event-extensions');
- b('function-extensions');
- var g = b('Arbiter'),
- h = b('AsyncDialog'),
- i = b('AsyncRequest'),
- j = b('Bootloader'),
- k = b('Class'),
- l = b('CSS'),
- m = b('Dialog'),
- n = b('DOM'),
- o = b('DOMControl'),
- p = b('FullScreen'),
- q = b('ImageUtils'),
- r = b('Keys'),
- s = b('LinkController'),
- t = b('Locale'),
- u = b('PageTransitions'),
- v = b('Parent'),
- w = b('PhotosConst'),
- x = b('PhotoSessionLog'),
- y = b('PhotoSnowliftAds'),
- z = b('PhotoStreamCache'),
- aa = b('PhotosUtils'),
- ba = b('PhotoViewer'),
- ca = b('Rect'),
- da = b('ScrollableArea'),
- ea = b('Style'),
- fa = b('Toggler'),
- ga = b('UIPagelet'),
- ha = b('URI'),
- ia = b('UserAgent'),
- ja = b('Vector'),
- ka = b('$'),
- la = b('computeRelativeURI'),
- ma = b('copyProperties'),
- na = b('createArrayFrom'),
- oa = b('csx'),
- pa = b('emptyFunction'),
- qa = b('ge'),
- ra = b('goURI'),
- sa = b('tx'),
- ta = b('userAction'),
- ua = b('event-extensions').$E;
- function va() {
- this.parent.construct(this);
- }
- ma(va, {
- STATE_ERROR: 'error',
- STATE_HTML: 'html',
- STATE_IMAGE_PIXELS: 'image_pixels',
- STATE_IMAGE_DATA: 'image',
- LOADING_TIMEOUT: 2000,
- PAGER_FADE: 3000,
- FULL_SCREEN_PADDING: 10,
- STAGE_HIRES_MAX: {
- x: 2048,
- y: 2048
- },
- STAGE_NORMAL_MAX: {
- x: 960,
- y: 960
- },
- STAGE_MIN: {
- x: 520,
- y: 520
- },
- SIDEBAR_SIZE_MAX: 340,
- SIDEBAR_SIZE_MIN: 285,
- STAGE_CHROME: {
- x: 102,
- y: 42
- },
- VIDEO_BOTTOM_BAR_SPACE: 40,
- GOPREV_AREA: 120,
- TIMELINE_STRETCH_WIDTH: 843,
- TIMELINE_STRETCH_MIN: 480,
- MIN_TAG_DISTANCE: 83,
- PADDING_MIN: 40,
- _instance: null,
- getInstance: function () {
- if (!va._instance) va._instance = new va();
- return va._instance;
- },
- initWithSpotlight: function (wa, xa) {
- va.getInstance().init(wa, xa);
- },
- touch: pa,
- addPhotoFbids: function (wa, xa, ya, za) {
- va.getInstance().addPhotoFbids(wa, xa, ya, za);
- },
- attachFollowFlyout: function (wa) {
- n.insertAfter(ka('fbPhotoSnowliftSubscribe'), wa);
- },
- attachSubscribeFlyout: function (wa) {
- n.insertAfter(ka('fbPhotoSnowliftSubscribe'), wa);
- },
- attachTagger: function (wa) {
- va.getInstance().attachTagger(wa);
- },
- preload: function (wa, xa) {
- va.getInstance().preload(wa, xa);
- },
- bootstrap: function (wa, xa) {
- if (wa && ha(wa).getQueryData().hasOwnProperty('share_id')) {
- j.loadModules(['SpotlightShareViewer'], function (ya) {
- ya.bootstrap(wa, xa);
- });
- return;
- }
- va.getInstance().bootstrap(wa, xa);
- },
- closeRefresh: function () {
- va.getInstance().closeRefresh();
- },
- deletePhoto: function (wa) {
- va.getInstance().deletePhoto(wa);
- },
- getImage: function () {
- return va.getInstance().getImage();
- },
- getImageId: function () {
- return va.getInstance().getImageId();
- },
- getLoadQuery: function () {
- return va.getInstance().getLoadQuery();
- },
- getRHCBody: function () {
- return va.getInstance().getRHCBody();
- },
- getRHCFooter: function () {
- return va.getInstance().getRHCFooter();
- },
- getRHCHeader: function () {
- return va.getInstance().getRHCHeader();
- },
- getRoot: function () {
- return va.getInstance().getRoot();
- },
- likePhotoSkipConfirmation: function (wa) {
- va.getInstance().likePhotoSkipConfirmation(wa);
- },
- saveTagsFromPayload: function (wa) {
- va.getInstance().saveTagsFromPayload(wa);
- },
- saveTagsFromPayloadDelayed: function (wa) {
- va.saveTagsFromPayload.curry(wa).defer(2000);
- },
- handleServerError: function (wa, xa) {
- va.getInstance().handleServerError(wa, xa);
- },
- storeFromData: function (wa) {
- va.getInstance().storeFromData(wa);
- },
- swapData: function () {
- va.getInstance().swapData();
- },
- touchMarkup: pa,
- updateTotalCount: function (wa, xa, ya) {
- va.getInstance().updateTotalCount(wa, xa, ya);
- }
- });
- k.extend(va, ba);
- ma(va.prototype, {
- switchTimer: null,
- imageRefreshTimer: null,
- imageLoadingTimer: null,
- lastPage: 0,
- currentMinSize: null,
- currentImageSize: null,
- resetUriStack: true,
- thumbSrc: null,
- shouldStretch: false,
- stageMax: va.STAGE_NORMAL_MAX,
- stageChrome: va.STAGE_CHROME,
- stagePagerPrev: null,
- ua: null,
- PhotoTagger: null,
- showHover: false,
- skipLikePhotoConfirmation: false,
- isShowingLikePhotoConfirmation: false,
- preload: function (wa, xa) {
- j.loadModules(['PhotoTagger', 'fb-photos-snowlift-css', 'Live', 'PhotoTagApproval', 'PhotoTags', 'TagTokenizer', 'fb-photos-snowlift-fullscreen-css'], function (za) {
- this.PhotoTagger = za;
- }.bind(this));
- var ya = this.getImageSrc(ha(wa).getQueryData());
- if (ya)(new Image()).src = ya;
- },
- bootstrap: function (wa, xa) {
- if (wa && ha(wa).getQueryData().makeprofile) {
- this.enableCropperOnInit = true;
- this.isUserProfilePic = ha(wa).getQueryData().makeuserprofile;
- this.isInProfilePicAlbum = ha(wa).getQueryData().inprofilepicalbum;
- }
- this.preload(wa, xa);
- if (this.closeDirty) {
- this.bootstrap.bind(this, wa, xa).defer();
- return;
- }
- y.reset();
- this.resetUriStack = true;
- if (this.isOpen) if (this.openExplicitly) {
- this.closeCleanup();
- this.resetUriStack = false;
- } else return;
- this.ua = ta('snowlift', xa).uai('open');
- this.returningToStart = false;
- this.loading && l.removeClass(this.loading, 'loading');
- if (xa) {
- l.addClass((this.loading = xa), 'loading');
- this.getThumbAndSize(xa);
- } else this.loading = null;
- g.inform('PhotoSnowlift.GO', wa, g.BEHAVIOR_STATE);
- this.loadFrameIfUninitialized();
- },
- getCurrentImageServerSizeDimensions: function () {
- return this.stream.getCurrentImageData().dimensions;
- },
- getEventPrefix: function () {
- return 'PhotoSnowlift';
- },
- getRoot: function () {
- return this.root;
- },
- getSourceString: function () {
- return 'snowlift';
- },
- getVersionConst: function () {
- return w.VIEWER_SNOWLIFT;
- },
- getImage: function () {
- return this.image;
- },
- getImageId: function () {
- return this.stream.getCursor();
- },
- getRHCHeader: function () {
- return this.rhcHeader;
- },
- getRHCBody: function () {
- return this.ufiForm;
- },
- getRHCFooter: function () {
- return this.rhcFooter;
- },
- getLoadQuery: function () {
- return this.loadQuery;
- },
- getCurrentPhotoInfo: function () {
- var wa = this.stream.getCurrentImageData();
- if (wa) return wa.info;
- return null;
- },
- getOwnerId: function () {
- var wa = this.stream.getCurrentImageData();
- if (wa) return wa.info.owner;
- return null;
- },
- getThumbAndSize: function (wa) {
- this.currentImageSize = null;
- this.thumbSrc = null;
- var xa = ha(wa.getAttribute('ajaxify')).getQueryData();
- if (!xa.size) return;
- var ya = ja.deserialize(xa.size);
- if (!ya.x || !ya.y) return;
- this.currentImageSize = ya;
- if (!l.hasClass(wa, 'uiMediaThumb') && !l.hasClass(wa, 'uiPhotoThumb') && !l.hasClass(wa, 'uiScaledThumb')) return;
- if (wa.getAttribute('data-cropped')) return;
- var za = n.scry(wa, 'img')[0],
- ab = n.scry(wa, 'i')[0],
- bb = v.byAttribute(wa, 'data-size');
- this.shouldStretch = bb && this.currentImageSize && za && bb.getAttribute('data-size') === "2" && this.currentImageSize.x > this.currentImageSize.y && this.currentImageSize.x <= va.TIMELINE_STRETCH_WIDTH && za.offsetWidth === va.TIMELINE_STRETCH_WIDTH;
- var cb;
- if (za) {
- cb = za.src;
- } else if (ab) {
- cb = ea.get(ab, 'backgroundImage').replace(/.*url\("?([^"]*)"?\).*/, '$1');
- } else return;
- this.thumbSrc = cb;
- },
- loadFrameIfUninitialized: function () {
- if (this.root) return;
- new i('/ajax/photos/snowlift/init.php').setAllowCrossPageTransition(true).setMethod('GET').setReadOnly(true).send();
- },
- init: function (wa, xa) {
- this.init = pa;
- this.showHover = xa.pivot_hover;
- x.setEndMetrics(xa.pivot_end_metric);
- this.showEndPivot = xa.pivot_end;
- this.enableSnowliftProfilePicCropper = xa.snowlift_profile_pic_cropper;
- this.fullscreen = p.isSupported();
- this.showOGVideos = xa.og_videos;
- this.stageMax = va.STAGE_HIRES_MAX;
- this.spotlight = wa;
- this.spotlight.subscribe('blur', function () {
- this.closingAction = x.OUTSIDE;
- }.bind(this));
- this.spotlight.subscribe('hide', this.closeHandler.shield(this));
- this.spotlight.subscribe('key', this.keyHandler.bind(this));
- this.initializeNodes(this.spotlight.getRoot());
- y.init(this.sideAdUnit, this, xa);
- if (!this.subscription) {
- s.registerHandler(this.handleNavigateAway.bind(this));
- this.subscription = g.subscribe('PhotoSnowlift.GO', function (ya, za) {
- this.openExplicitly = true;
- this.loading && l.removeClass(this.loading, 'loading');
- this.open(za);
- }.bind(this));
- }
- this.transitionHandlerRegistered = false;
- this.returningToStart = false;
- u.registerHandler(this.openHandler.bind(this));
- this.openHandlerRegistered = true;
- g.subscribe('PhotoTagApproval.HILITE_TAG', this.onHiliteTag.bind(this));
- g.subscribe('PhotoTagApproval.UPDATE_TAG_BOX', this.onUpdateTagBox.bind(this));
- if (this.fullscreen) p.subscribe('changed', this.onFullScreenChange.bind(this));
- },
- onFullScreenChange: function () {
- var wa = p.isFullScreen();
- l.conditionClass(document.body, 'fbPhotoSnowliftFullScreenMode', wa);
- if (wa) {
- if (!l.hasClass(this.root, 'fbPhotoSnowliftEditMode')) this.collapseRHC();
- var xa = this.stream.getCurrentImageData();
- if (xa && xa.url && this.image.src !== xa.url && this.shouldShowHiRes(xa)) this.switchImage(xa.url);
- this.adjustForResize();
- } else {
- this.uncollapseRHC();
- if (ia.chrome() && !l.hasClass(this.root, 'fbPhotoSnowliftEditMode')) this.page(0, false);
- g.inform('reflow');
- }
- fa.hide();
- if (this.cropper) this.cropper.resetPhoto();
- },
- initializeNodes: function (wa) {
- this.root = wa;
- this.container = n.find(wa, 'div.fbPhotoSnowliftContainer');
- this.snowliftPopup = n.find(this.container, 'div.fbPhotoSnowliftPopup');
- this.rhc = n.find(this.snowliftPopup, 'div.rhc');
- this.rhcHeader = n.find(this.rhc, 'div.rhcHeader');
- this.rhcFooter = n.find(this.rhc, 'div.rhcFooter');
- this.ufiForm = n.find(this.rhc, 'form.fbPhotosSnowliftFeedbackForm');
- this.ufiInputContainer = n.find(this.rhc, 'div.fbPhotosSnowboxFeedbackInput');
- this.scroller = n.find(this.ufiForm, 'div.rhcScroller');
- this.scrollerBody = n.find(this.scroller, 'div.uiScrollableAreaBody');
- this.stageWrapper = n.find(this.snowliftPopup, 'div.stageWrapper');
- this.overlay = n.find(this.snowliftPopup, 'div.snowliftOverlay');
- this.errorBox = n.find(this.stageWrapper, 'div.stageError');
- this.image = n.find(this.stageWrapper, 'img.spotlight');
- this.stage = n.find(this.stageWrapper, 'div.stage');
- this.videoStage = n.find(this.stageWrapper, 'div.videoStage');
- this.prevPager = n.find(this.snowliftPopup, 'a.snowliftPager.prev');
- this.nextPager = n.find(this.snowliftPopup, 'a.snowliftPager.next');
- this.stageActions = n.find(wa, 'div.stageActions');
- this.buttonActions = n.find(this.stageActions, 'div.fbPhotosPhotoButtons');
- this.sideAdUnit = n.find(wa, "._24q");
- g.inform('Amoeba/instrumentMulti', [
- [this.container, 'snowlift'],
- [this.rhc, 'rhc'],
- [this.rhcHeader, 'rhc_header'],
- [this.ufiForm, 'ufi_form'],
- [this.ufiInputContainer, 'ufi_input'],
- [this.prevPager, 'prev_pager'],
- [this.nextPager, 'next_pager'],
- [this.stageActions, 'stage_actions'],
- [this.sideAdUnit, 'side_ads']
- ], g.BEHAVIOR_PERSISTENT);
- l.conditionClass(this.root, 'fullScreenAvailable', this.fullscreen);
- },
- initializeScroller: function () {
- this.initializeScroller = pa;
- this.scrollableArea = da.fromNative(this.scroller, {
- fade: true,
- persistent: true
- });
- var wa = function (event) {
- var xa = ua(event).getTarget();
- if (n.contains(this.ufiInputContainer, xa)) {
- var ya = o.getInstance(xa);
- if (ya) {
- this.scrollableArea.scrollToBottom();
- var za = ya.subscribe('resize', function () {
- var bb = this.scrollableArea.isScrolledToBottom();
- this.adjustScroller();
- bb && this.scrollableArea.scrollToBottom();
- }.bind(this)),
- ab = Event.listen(xa, 'blur', function () {
- ya.unsubscribe(za);
- ab.remove();
- });
- }
- }
- }.bind(this);
- g.subscribe('ufi/changed', function (xa, ya) {
- if (this.ufiForm === ya.form) {
- this.adjustScrollerIfNecessary();
- this.scrollableArea.scrollToBottom();
- }
- }.bind(this));
- Event.listen(this.rhc, 'click', function (event) {
- var xa = event.getTarget();
- if (v.byTag(xa, 'a') || v.byTag(xa, 'button') || n.isNodeOfType(xa, 'input')) this.adjustScrollerIfNecessary();
- }.bind(this));
- g.subscribe(['reflow', 'CommentUFI.Pager'], function () {
- if (this.isOpen) this.adjustScroller();
- }.bind(this));
- if (this.ufiForm.attachEvent) {
- this.ufiForm.attachEvent('onfocusin', wa);
- } else this.ufiForm.addEventListener('focus', wa, true);
- },
- openHandler: function (wa) {
- if (this.isOpen || wa.getPath() != '/photo.php' || this.returningToStart || wa.getQueryData().closeTheater || wa.getQueryData().permPage || wa.getQueryData().makeprofile) {
- this.openHandlerRegistered = false;
- return false;
- }
- this.open(wa);
- this._uriStack.push(ha(wa).getQualifiedURI().toString());
- u.transitionComplete(true);
- return true;
- },
- getImageSrc: function (wa) {
- if (wa.smallsrc) {
- if (!wa.size) return wa.smallsrc;
- var xa = ja.deserialize(wa.size),
- ya = this.getStageSize(xa);
- if (ya.x <= va.STAGE_NORMAL_MAX.x && ya.y <= va.STAGE_NORMAL_MAX.y) return wa.smallsrc;
- }
- return wa.src;
- },
- open: function (wa) {
- var xa = ha(wa).getQueryData(),
- ya = this.getImageSrc(xa);
- if (ya) {
- delete xa.src;
- delete xa.smallsrc;
- }
- if (this.resetUriStack) this._uriStack = [];
- if (!this.initialLoad) {
- xa.firstLoad = true;
- this.initialLoad = true;
- }
- this.sessionID = Date.now();
- this.loadQuery = ma(xa, {
- ssid: this.sessionID
- });
- this.isOpen = true;
- this.pagersShown = false;
- this.refreshOnClose = false;
- this.hilitedTag = null;
- this.loadingStates = {
- image: false,
- html: false
- };
- this.replaceUrl = false;
- this.stream = new z();
- this.stream.init(w.VIEWER_SNOWLIFT, 'PhotoViewerPagelet');
- this.fetchInitialData();
- this.setLoadingState(va.STATE_HTML, true);
- this.rhcCollapsed = false;
- j.loadModules(['fb-photos-snowlift-css'], this._open.bind(this, wa, ya));
- if (this.showEndPivot) j.loadModules(['PhotoPivot'], function (za) {
- this.pivots = za.getInstance();
- if (xa.relevant_count) this.pivots.setRelevantCount(xa.relevant_count);
- }.bind(this));
- if (this.enableSnowliftProfilePicCropper) j.loadModules(['SnowliftPicCropper'], function (za) {
- this.cropper = za.getInstance(this);
- this.cropper.init();
- if (this.enableCropperOnInit) {
- var ab = g.subscribe('PhotoSnowlift.SWITCH_IMAGE', function () {
- if (this.isInProfilePicAlbum) {
- this.cropper.showPicInProfileAlbumDialog();
- } else this.cropper.enableCropping(this.isUserProfilePic);
- g.unsubscribe(ab);
- }.bind(this));
- this.enableCropperOnInit = false;
- }
- }.bind(this));
- j.loadModules(['PhotosButtonTooltips'], function (za) {
- za.init();
- });
- },
- _open: function (wa, xa) {
- this.createLoader(xa);
- this.spotlight.show();
- this.ua && this.ua.add_event('frame');
- g.inform('layer_shown', {
- type: 'PhotoSnowlift'
- });
- g.inform('PhotoSnowlift.OPEN');
- this.stageHandlers = [Event.listen(window, 'resize', this.adjustForResize.bind(this)), Event.listen(this.stageWrapper, 'click', this.buttonListener.bind(this)), Event.listen(this.stageWrapper, 'mouseleave', function (event) {
- this.unhiliteAllTags();
- this.hidePagers();
- }.bind(this)), Event.listen(this.stageWrapper, 'mousemove', this.hilitePagerOnMouseMove.bind(this)), Event.listen(this.stageWrapper, 'mousemove', this.hiliteTagsOnMouseMove.bind(this)), Event.listen(this.overlay, 'mouseenter', this.unhiliteAllTags.bind(this))];
- this.stageHandlers.push(Event.listen(this.container, 'click', (function (event) {
- var ab = event.getTarget();
- if (v.byClass(ab, 'rotateRight')) {
- this.rotate('right');
- } else if (v.byClass(ab, 'rotateLeft')) {
- this.rotate('left');
- } else if (v.byClass(ab, 'closeTheater')) {
- if (p.isFullScreen()) {
- p.toggleFullScreen();
- return;
- }
- this.closingAction = x.X;
- this.closeHandler();
- } else if (this.fullscreen) if (v.byClass(ab, 'fbPhotoSnowliftFullScreen')) {
- this.toggleFullScreen();
- } else if (v.byClass(ab, 'fbPhotoSnowliftCollapse')) this.toggleCollapse();
- }).bind(this)));
- var ya = qa('fbPhotoSnowliftFeedback');
- if (ya) this.stageHandlers.push(Event.listen(ya, 'click', function (event) {
- if (v.byClass(event.getTarget(), 'like_link') || v.byClass(event.getTarget(), 'UFILikeLink')) this.toggleLikeButton();
- var ab = v.byClass(event.getTarget(), 'uiUfiCollapsedComment');
- if (ab) l.addClass(ab, 'uiUfiCollapsedCommentToggle');
- }.bind(this)));
- var za = qa('fbPhotoSnowliftOnProfile');
- if (za) this.stageHandlers.push(Event.listen(za, 'click', function (event) {
- if (v.byClass(event.getTarget(), 'fbPhotoRemoveFromProfileLink')) this.refreshOnClose = true;
- }.bind(this)));
- if (this.resetUriStack) this.startingURI = ha.getMostRecentURI().addQueryData({
- closeTheater: 1
- }).getUnqualifiedURI();
- if (!xa) this.setLoadingState(va.STATE_IMAGE_DATA, true);
- if (!this.transitionHandlerRegistered) {
- u.registerHandler(this.transitionHandler.bind(this));
- this.transitionHandlerRegistered = true;
- }
- x.initLogging(x.SNOWLIFT);
- if (this.pivots) x.setRelevantCount(this.pivots.relevantCount);
- },
- toggleFullScreen: function () {
- var wa = p.toggleFullScreen(document.documentElement);
- if (wa) {
- var xa = this.stream.getCurrentImageData();
- if (xa && xa.url && this.image.src !== xa.url && this.shouldShowHiRes(xa))(new Image()).src = xa.url;
- x.logEnterFullScreen(this.stream.getCursor());
- }
- },
- getStream: function () {
- return this.stream;
- },
- fetchInitialData: function () {
- this.ua && this.ua.add_event('init_data');
- this.stream.waitForInitData();
- ga.loadFromEndpoint('PhotoViewerInitPagelet', null, this.loadQuery, {
- usePipe: true,
- jsNonblock: true,
- crossPage: true
- });
- },
- toggleCollapse: function () {
- if (this.rhcCollapsed) {
- this.uncollapseRHC();
- } else this.collapseRHC();
- },
- collapseRHC: function () {
- this.rhcCollapsed = true;
- l.addClass(this.root, 'collapseRHC');
- this.adjustForResize();
- },
- uncollapseRHC: function () {
- this.rhcCollapsed = false;
- l.removeClass(this.root, 'collapseRHC');
- this.adjustForResize();
- },
- closeHandler: function () {
- if (!this.isOpen) return;
- this.closingAction = this.closingAction || x.ESC;
- if (ha.getMostRecentURI().addQueryData({
- closeTheater: 1
- }).getUnqualifiedURI().toString() == this.startingURI.toString()) {
- this.close();
- return;
- }
- this.returnToStartingURI(this.refreshOnClose);
- this.close();
- },
- returnToStartingURI: function (wa, xa) {
- if (!wa) if (xa) {
- this.squashNextTransition(ra.curry(xa));
- } else this.squashNextTransition();
- this.returningToStart = true;
- var ya = g.subscribe('page_transition', function () {
- this.returningToStart = false;
- ya.unsubscribe();
- }),
- za = wa || isNaN(ia.opera()),
- ab = this._uriStack.length;
- if (za && ab < window.history.length) {
- window.history.go(-ab);
- } else {
- var bb = this.startingURI,
- cb = new ha(bb).removeQueryData('closeTheater');
- if (bb.getQueryData().sk == 'approve' && bb.getPath() == '/profile.php') {
- cb.removeQueryData('highlight');
- cb.removeQueryData('notif_t');
- }
- ra(cb);
- }
- },
- squashNextTransition: function (wa) {
- this.squashNext = true;
- u.registerHandler(function xa() {
- if (this.squashNext) {
- this.squashNext = false;
- if (wa) wa.defer();
- u.transitionComplete(true);
- return true;
- }
- return false;
- }.bind(this), 7);
- },
- handleNavigateAway: function (wa) {
- var xa = la(u._most_recent_uri.getQualifiedURI(), wa.getAttribute('href'));
- if (this.isOpen && (xa instanceof ha) && xa.getUnqualifiedURI().toString() != this.startingURI.toString() && xa.getPath() != '/photo.php') {
- if (!this.closingAction) this.closingAction = x.NAVIGATE;
- this.returnToStartingURI(false, xa);
- this.close();
- return false;
- }
- return true;
- },
- close: function () {
- if (!this.isOpen) return;
- this.isOpen = false;
- if (this.fullscreen) p.disableFullScreen();
- ta('snowlift').uai('close');
- this.cropper && this.cropper.disableCropping();
- this.spotlight.hide();
- this.openExplicitly = false;
- this.closeDirty = true;
- this.closeCleanup.bind(this).defer();
- },
- closeCleanup: function () {
- this.closeDirty = false;
- l.removeClass(this.root, 'dataLoading');
- x.logPhotoViews(this.closingAction);
- this.destroy();
- l.hide(this.errorBox);
- l.hide(this.image);
- this.currentImageSize = null;
- this.thumbSrc = null;
- this.shouldStretch = false;
- this.resetUriStack = true;
- l.removeClass(this.stageWrapper, 'showVideo');
- n.empty(this.videoStage);
- this.uncollapseRHC();
- this.currentMinSize = null;
- this.setStagePagersState('reset');
- this.recacheData();
- n.empty(this.sideAdUnit);
- this.stream.destroy();
- var wa = this.closingAction === x.NAVIGATE;
- this.closingAction = null;
- if (!this.openHandlerRegistered) {
- u.registerHandler(this.openHandler.bind(this));
- this.openHandlerRegistered = true;
- }
- g.inform('layer_hidden', {
- type: 'PhotoSnowlift'
- });
- g.inform('PhotoSnowlift.CLOSE', wa);
- this.root.setAttribute('aria-busy', 'true');
- },
- createLoader: function (wa) {
- if (this.currentImageSize === null) {
- this.adjustStageSize(va.STAGE_MIN);
- } else {
- var xa = this.getStageSize(this.currentImageSize);
- xa = new ja(Math.max(xa.x, va.STAGE_MIN.x), Math.max(xa.y, va.STAGE_MIN.y));
- var ya = this.getImageSizeInStage(this.currentImageSize, xa);
- if (this.thumbSrc === null) {
- this.adjustStageSize(ya);
- } else this.useImage(n.create('img', {
- className: 'spotlight',
- alt: '',
- src: this.thumbSrc,
- style: {
- width: ya.x + 'px',
- height: ya.y + 'px'
- }
- }), ya, false);
- }
- this.setLoadingState(this.STATE_IMAGE_PIXELS, true);
- if (wa)(function () {
- var za = new Image();
- za.onload = a.async_callback(function () {
- if (!this.isOpen || this.pendingImageUrl != wa) return;
- if (!this.stream || !this.stream.errorInCurrent()) {
- this.switchImage(wa, this.currentImageSize);
- this.ua && this.ua.add_event('image');
- this.setLoadingState(va.STATE_IMAGE_DATA, false);
- }
- }.bind(this), 'photo_theater');
- za.src = this.pendingImageUrl = wa;
- }).bind(this).defer();
- l.hide(this.stageActions);
- this.setStagePagersState('disabled');
- },
- initDataFetched: function (wa) {
- x.setPhotoSet(this.stream.getPhotoSet());
- x.setLogFbids(wa.logids);
- var xa = this.stream.getCurrentImageData();
- x.addPhotoView(xa.info, this.shouldShowHiRes(xa), this.fullscreen && p.isFullScreen());
- if (!this.pageHandlers) this.pageHandlers = [Event.listen(this.root, 'click', this.pageListener.bind(this)), Event.listen(this.root, 'mouseleave', this.mouseLeaveListener.bind(this))];
- l.show(this.stageActions);
- this.root.setAttribute('aria-busy', 'false');
- this.isLoggedInViewer = wa.loggedin;
- this.disableAdsForSession = wa.disablesessionads || !this.isLoggedInViewer;
- this.disableAds = this.disableAdsForSession || wa.fromad;
- this.loadAds();
- },
- adjustScrollerIfNecessary: function () {
- clearTimeout(this.scrollerTimeout);
- this.scrollerTimeout = this.adjustScroller.bind(this).defer();
- },
- adjustScroller: function () {
- clearTimeout(this.scrollerTimeout);
- this.initializeScroller();
- this.scrollableArea.resize();
- var wa = ja.getElementDimensions(this.rhc),
- xa = wa.y;
- xa -= ja.getElementDimensions(this.rhcHeader).y;
- xa -= ja.getElementDimensions(this.ufiInputContainer).y;
- var ya = ja.getElementDimensions(this.scrollerBody).y;
- if (ya >= xa) {
- ea.set(this.scroller, 'height', xa + 'px');
- l.addClass(this.rhc, 'pinnedUfi');
- xa = 0;
- } else {
- ea.set(this.scroller, 'height', 'auto');
- l.removeClass(this.rhc, 'pinnedUfi');
- xa -= ya;
- }
- var za = ja.getElementDimensions(this.ufiInputContainer).y;
- ea.set(this.ufiForm, 'padding-bottom', za + 'px');
- y.resize(new ja(wa.x, xa));
- this.scrollableArea.adjustGripper();
- },
- adjustForResize: function () {
- this.currentMinSize = null;
- this.adjustStageSize();
- this.adjustForNewData();
- },
- shouldShowHiRes: function (wa) {
- if (!wa || !wa.smallurl) return false;
- var xa = this.getStageSize(wa.dimensions),
- ya = this.getImageSizeInStage(wa.dimensions, xa);
- return (ya.x > va.STAGE_NORMAL_MAX.x || ya.y > va.STAGE_NORMAL_MAX.y);
- },
- getImageURL: function (wa) {
- if (wa.video) {
- return null;
- } else if (wa.smallurl && !this.shouldShowHiRes(wa)) return wa.smallurl;
- return wa.url;
- },
- getImageDimensions: function (wa) {
- if (wa.smalldims && (!this.shouldShowHiRes(wa) || this.image.src === wa.smallurl)) return wa.smalldims;
- return wa.dimensions;
- },
- getStageSize: function (wa, xa) {
- var ya = ja.getViewportDimensions(),
- za = new ja(wa.x, wa.y);
- if (xa) za = new ja(Math.max(wa.x, xa.x), Math.max(wa.y, xa.y));
- var ab, bb;
- if (this.fullscreen && p.isFullScreen()) {
- return new ja((this.rhcCollapsed ? screen.width : screen.width - va.SIDEBAR_SIZE_MAX), screen.height - va.FULL_SCREEN_PADDING * 2);
- } else {
- ab = Math.min(za.x, this.stageMax.x, (ya.x - va.SIDEBAR_SIZE_MAX - va.STAGE_CHROME.x));
- bb = Math.min(za.y, this.stageMax.y, ya.y - va.STAGE_CHROME.y);
- }
- if (ab === 0 && bb === 0) return new ja(0, 0);
- var cb = ab / bb,
- db = za.x / za.y;
- if (cb < db) return new ja(ab, Math.round(ab / db));
- return new ja(Math.round(bb * db), bb);
- },
- getImageSizeInStage: function (wa, xa) {
- var ya = wa.x,
- za = wa.y;
- if (ya >= xa.x || za >= xa.y) {
- var ab = xa.x / xa.y,
- bb = ya / za;
- if (ab < bb) {
- ya = xa.x;
- za = Math.round(ya / bb);
- } else if (ab > bb) {
- za = xa.y;
- ya = Math.round(za * bb);
- } else {
- ya = xa.x;
- za = xa.y;
- }
- }
- return new ja(ya, za);
- },
- adjustStageSize: function (wa) {
- var xa = this.currentImageSize;
- if (wa) {
- xa = wa;
- } else {
- var ya = this.stream && this.stream.getCurrentImageData();
- if (ya) xa = this.getImageDimensions(ya);
- }
- if (!xa) return;
- this.currentImageSize = xa;
- var za = 0;
- if (this.shouldStretch && !this.getVideoOnStage() && xa.x > xa.y && xa.x <= va.TIMELINE_STRETCH_WIDTH && xa.x >= va.TIMELINE_STRETCH_MIN) {
- xa.y = Math.round(xa.y * va.TIMELINE_STRETCH_WIDTH / xa.x);
- xa.x = va.TIMELINE_STRETCH_WIDTH;
- } else if (this.getVideoOnStage()) {
- za = va.VIDEO_BOTTOM_BAR_SPACE * 2;
- xa.y += za;
- }
- var ab = this.getStageSize(xa, this.currentMinSize);
- if (!this.currentMinSize) this.currentMinSize = new ja(0, 0);
- this.currentMinSize = new ja(Math.max(ab.x, va.STAGE_MIN.x, this.currentMinSize.x), Math.max(ab.y, va.STAGE_MIN.y, this.currentMinSize.y));
- var bb = this.getImageSizeInStage(xa, this.currentMinSize),
- cb = this.currentMinSize.x - bb.x,
- db = this.currentMinSize.y - bb.y;
- if (cb > 0 && cb < va.PADDING_MIN) {
- this.currentMinSize.x -= cb;
- } else if (db > 0 && db < va.PADDING_MIN) this.currentMinSize.y -= db;
- var eb = this.currentMinSize.x + va.SIDEBAR_SIZE_MAX;
- if (this.rhcCollapsed) eb = this.currentMinSize.x;
- this.snowliftPopup.style.cssText = 'width:' + eb + 'px;' + 'height:' + this.currentMinSize.y + 'px;';
- var fb = this.currentMinSize.y - za + 'px';
- if (ia.firefox() || ia.ie() < 8) {
- var gb = ea.get(this.stageWrapper, 'font-size');
- if (ia.ie() && gb.indexOf('px') < 0) {
- var hb = n.create('div');
- hb.style.fontSize = gb;
- hb.style.height = '1em';
- gb = hb.style.pixelHeight;
- }
- fb = ((this.currentMinSize.y - za) / parseFloat(gb)) + 'em';
- }
- this.stageWrapper.style.cssText = 'width:' + this.currentMinSize.x + 'px;' + 'line-height:' + fb + ';';
- if (ia.ie() < 8) {
- ea.set(this.root, 'height', ja.getViewportDimensions().y + 'px');
- ea.set(this.container, 'min-height', (this.currentMinSize.y + va.STAGE_CHROME.y) + 'px');
- }
- this.image.style.cssText = 'width:' + bb.x + 'px;' + 'height:' + bb.y + 'px;';
- this.adjustScrollerIfNecessary();
- },
- adjustForNewData: function () {
- if (!this.image) return;
- var wa = n.scry(this.stage, 'div.tagsWrapper')[0],
- xa = ja.getElementDimensions(this.image);
- if (wa) {
- ea.set(wa, 'width', xa.x + 'px');
- ea.set(wa, 'height', xa.y + 'px');
- if (ia.ie() <= 7) {
- var ya = n.scry(this.root, 'div.tagContainer')[0];
- if (ya) l.conditionClass(wa, 'ie7VerticalFix', ja.getElementDimensions(ya).y > xa.y);
- }
- }
- },
- setLoadingState: function (wa, xa) {
- switch (wa) {
- case va.STATE_IMAGE_PIXELS:
- l.conditionClass(this.root, 'imagePixelsLoading', xa);
- break;
- case va.STATE_IMAGE_DATA:
- this.loadingStates[wa] = xa;
- l.conditionClass(this.root, 'imageLoading', xa);
- break;
- case va.STATE_HTML:
- this.loadingStates[wa] = xa;
- l.conditionClass(this.root, 'dataLoading', xa);
- this.rhc.setAttribute('aria-busy', xa ? 'true' : 'false');
- break;
- }
- },
- destroy: function () {
- this.stageHandlers.forEach(function (wa) {
- wa.remove();
- });
- if (this.pageHandlers) {
- this.pageHandlers.forEach(function (wa) {
- wa.remove();
- });
- this.pageHandlers = null;
- }
- },
- checkState: function (wa) {
- if (wa != va.STATE_ERROR && !this.loadingStates[wa]) return;
- switch (wa) {
- case va.STATE_IMAGE_DATA:
- var xa = this.stream.getCurrentImageData();
- if (xa) {
- var ya = this.getImageURL(xa);
- if (ya) {
- this.switchImage(ya, null, true);
- } else if (xa.video) this.switchVideo(xa.video, true);
- this.setLoadingState(wa, false);
- }
- break;
- case va.STATE_HTML:
- if (this.stream.getCurrentHtml()) {
- this.swapData();
- this.setLoadingState(wa, false);
- }
- break;
- default:
- if (this.stream.errorInCurrent()) {
- l.hide(this.image);
- l.show(this.errorBox);
- }
- break;
- }
- },
- buttonListener: function (event) {
- var wa = event.getTarget(),
- xa = Date.now();
- if (v.byClass(wa, 'fbPhotoTagApprovalBox')) return;
- if (xa - this.lastPage < 350) return;
- if (v.byClass(wa, 'fbPhotosPhotoLike')) {
- this.likePhoto();
- } else if (v.byClass(wa, 'tagApproveIgnore')) this.updateTagBox(event, wa);
- },
- likePhoto: function () {
- x.addButtonLike();
- var wa = ka('fbPhotoSnowliftFeedback'),
- xa = n.scry(wa, 'button.like_link')[0];
- if (!xa) xa = n.scry(wa, 'a.UFILikeLink')[0];
- var ya = xa.getAttribute('href');
- if (p.isFullScreen()) if (ia.chrome()) xa.setAttribute('href', 'javascript:;');
- xa.click();
- xa.setAttribute('href', ya);
- },
- toggleLikeButton: function () {
- var wa = n.scry(this.buttonActions, 'a.fbPhotosPhotoLike')[0];
- if (wa) {
- l.toggleClass(wa, 'viewerLikesThis');
- l.removeClass(wa, 'viewerAlreadyLikedThis');
- }
- },
- likePhotoWithKey: function () {
- if (this.isShowingLikePhotoConfirmation) return;
- if (this.skipLikePhotoConfirmation) {
- this.likePhoto();
- } else h.send(new i('/photos/confirm_like.php'), function (wa) {
- this.isShowingLikePhotoConfirmation = true;
- wa.subscribe('confirm', this.onCloseLikePhotoConfirmDialog.bind(this));
- wa.subscribe('cancel', this.onCloseLikePhotoConfirmDialog.bind(this));
- }.bind(this));
- return false;
- },
- likePhotoSkipConfirmation: function (wa) {
- this.skipLikePhotoConfirmation = wa;
- this.likePhoto();
- },
- onCloseLikePhotoConfirmDialog: function () {
- this.isShowingLikePhotoConfirmation = false;
- },
- updateTagBox: function (wa, xa) {
- this.unhiliteAllTags();
- var ya = qa(wa);
- if (!ya) return;
- l.addClass(ya, 'tagBox');
- l.addClass(ya, 'tagBoxPendingResponse');
- l.removeClass(ya, 'tagBoxPending');
- l.hide(n.find(ya, 'span.tagForm'));
- if (xa) {
- l.show(n.find(ya, 'span.tagApproved'));
- } else l.show(n.find(ya, 'span.tagIgnored'));
- },
- rotate: function (wa) {
- var xa = this.stream.getCursor();
- if (this.getVideoOnStage()) {
- var ya = (wa == 'left') ? 270 : 90;
- j.loadModules(['VideoRotate'], function (ab) {
- new ab(xa).motionRotate(ya);
- });
- return;
- }
- var za = ma({
- fbid: xa,
- cs_ver: w.VIEWER_SNOWLIFT
- }, this.stream.getPhotoSetQuery());
- za[wa] = 1;
- this.setLoadingState(va.STATE_IMAGE_DATA, true);
- this.setLoadingState(this.STATE_IMAGE_PIXELS, true);
- l.hide(this.image);
- new i('/ajax/photos/photo/rotate/').setAllowCrossPageTransition(true).setData(za).setErrorHandler(this.rotationError.bind(this, xa)).setFinallyHandler(this.rotationComplete.bind(this, xa)).setMethod('POST').setReadOnly(false).send();
- },
- rotationComplete: function (wa, xa) {
- if (wa == this.stream.getCursor()) {
- this.setLoadingState(va.STATE_IMAGE_DATA, false);
- this.switchImage(this.getImageURL(this.stream.getCurrentImageData()));
- this.swapData();
- }
- },
- rotationError: function (wa, xa) {
- if (wa == this.stream.getCursor()) {
- this.setLoadingState(va.STATE_IMAGE_DATA, false);
- this.switchImage(this.getImageURL(this.stream.getCurrentImageData()));
- j.loadModules(['AsyncResponse'], function (ya) {
- ya.defaultErrorHandler(xa);
- });
- }
- },
- saveTagsFromPayload: function (wa) {
- this.storeFromData(wa);
- if ('data' in wa && this.stream.getCursor() in wa.data) this.swapData();
- },
- saveEdit: function () {
- if (!l.hasClass(this.root, 'fbPhotoSnowliftEditMode')) return;
- j.loadModules(['PhotoInlineEditor', 'Form'], function (wa, xa) {
- var ya = wa.getInstance(this.getViewerConst());
- ya && xa.bootstrap(ya.getForm().controller);
- }.bind(this));
- },
- mouseLeaveListener: function (event) {
- this.unhiliteAllTags();
- this.reHilitePendingTag();
- },
- hilitePagerOnMouseMove: function (event) {
- var wa = ja.getEventPosition(event),
- xa = ja.getElementPosition(this.stage);
- if (t.isRTL()) {
- var ya = ja.getElementDimensions(this.stage);
- this.stagePagerPrev = ya.x - (wa.x - xa.x) < va.GOPREV_AREA;
- } else this.stagePagerPrev = wa.x - xa.x < va.GOPREV_AREA;
- l.conditionClass(this.prevPager, 'hilightPager', this.stagePagerPrev);
- l.conditionClass(this.nextPager, 'hilightPager', !this.stagePagerPrev);
- var za, ab = event.getTarget();
- if (!v.byClass(ab, 'snowliftOverlay') && !v.byClass(ab, 'bottomBarActions') && !v.byClass(ab, 'snowliftPager')) za = va.PAGER_FADE;
- this.showPagers(za);
- },
- showPagers: function (wa) {
- clearTimeout(this.fadePagerTimer);
- this.setStagePagersState('active');
- if (typeof wa !== 'undefined') this.fadePagerTimer = this.hidePagers.bind(this).defer(wa);
- },
- hidePagers: function () {
- var wa = n.scry(this.getRoot(), '.fbPhotosPhotoActionsMenu')[0];
- if (wa) return;
- clearTimeout(this.fadePagerTimer);
- this.setStagePagersState('inactive');
- },
- getTagger: function () {
- if (!this.PhotoTagger) return null;
- var wa = this.PhotoTagger.getInstance(w.VIEWER_SNOWLIFT);
- if (!wa || !wa.tagHoverFacebox) return null;
- return wa;
- },
- unhiliteAllTags: function () {
- n.scry(this.stage, 'div.tagsWrapper div.hover').forEach(function (xa) {
- l.removeClass(xa, 'hover');
- });
- this.hilitedTag = null;
- if (!l.hasClass(this.root, 'taggingMode')) {
- var wa = this.getTagger();
- if (wa) {
- wa.hideTagger();
- wa.setCurrentFacebox(null);
- }
- }
- },
- switchHilitedTags: function (wa, xa) {
- if (this.switchTimer !== null) {
- clearTimeout(this.switchTimer);
- this.switchTimer = null;
- }
- this.unhiliteAllTags();
- var ya = qa(wa);
- if (ya) {
- this.hilitedTag = wa;
- if (!l.hasClass(this.root, 'taggingMode') && aa.isFacebox(this.hilitedTag)) {
- var za = this.getTagger();
- if (za) {
- l.addClass(ya, 'hover');
- var ab = za.getFacebox(wa);
- za.setCurrentFacebox(ab);
- if (ab) za.addTagFromFacebox(ab);
- }
- } else l.addClass(ya, 'hover');
- if (l.hasClass(ya, 'tagBoxPending') && !l.hasClass(ya, 'showPendingTagName') && xa === true) {
- n.scry(this.stage, 'div.tagsWrapper div.showPendingTagName').forEach(function (bb) {
- l.removeClass(bb, 'showPendingTagName');
- });
- l.addClass(ya, 'showPendingTagName');
- }
- }
- },
- reHilitePendingTag: function () {
- var wa = qa(this.hilitedTag);
- if (wa && l.hasClass(wa, 'showPendingTagName')) return;
- var xa = n.scry(this.stage, 'div.tagsWrapper div.showPendingTagName')[0];
- if (xa) this.switchHilitedTags(xa.id);
- },
- hiliteTagsOnMouseMove: function (event) {
- if (!this.stream.getCurrentExtraData() || this.getVideoOnStage()) return;
- if (this.switchTimer !== null) return;
- var wa = event.getTarget();
- if (v.byClass(wa, 'snowliftOverlay') || v.byClass(wa, 'fbPhotoSnowliftTagApproval') || v.byClass(wa, 'tagPointer') || v.byClass(wa, 'photoTagTypeahead')) return;
- var xa = v.byClass(wa, 'tagBoxPending'),
- ya = false;
- if (this.hilitedTag) {
- var za = qa(this.hilitedTag);
- ya = za && l.hasClass(za, 'tagBoxPending');
- }
- var ab = ((!this.hilitedTag && xa) || (!ya && xa));
- if (ab) {
- this.switchHilitedTags(xa.id);
- return;
- }
- if (xa && (xa.id == this.hilitedTag)) return;
- var bb = 250,
- cb = aa.absoluteToNormalizedPosition(this.image, ja.getEventPosition(event));
- if (this.currentTagHasPrecedence(cb)) return;
- var db = aa.getNearestBox(this.stream.getCurrentExtraData().tagRects, cb);
- if (!db) {
- if (!ya) {
- this.unhiliteAllTags();
- this.reHilitePendingTag();
- }
- return;
- }
- var eb = null;
- if (ya) {
- var fb = {};
- fb[this.hilitedTag] = this.stream.getCurrentExtraData().tagRects[this.hilitedTag];
- eb = aa.getNearestBox(fb, cb);
- }
- if (eb !== null && ya) return;
- if (this.hilitedTag != db) if (ya) {
- this.switchTimer = this.switchHilitedTags.bind(this, db).defer(bb);
- } else {
- if (this.showHover) {
- if (!this.seenTags) this.seenTags = [];
- if (!this.seenTags[db]) {
- x.addFaceTagImpression();
- this.seenTags[db] = true;
- }
- }
- this.switchHilitedTags(db);
- }
- },
- currentTagHasPrecedence: function (wa) {
- if (!this.hilitedTag) return false;
- var xa = this.stream.getCurrentExtraData().tagRects[this.hilitedTag],
- ya = new ca(xa.t + (xa.h() / 2), xa.r, xa.b + (aa.isFacebox(this.hilitedTag) ? 10 : 0), xa.l, xa.domain);
- return ya.contains(wa);
- },
- getVideoOnStage: function () {
- var wa = this.stream && this.stream.getCurrentImageData();
- return wa && wa.video;
- },
- shouldPageOnAction: function (wa, xa) {
- if (!this.isOpen || this.isShowingLikePhotoConfirmation) return false;
- var ya = n.isNode(xa) && (v.byClass(xa, 'snowliftPager') || v.byClass(xa, 'stagePagers') || v.byClass(xa, 'pivotPageColumn')),
- za = n.isNode(xa) && v.byClass(xa, 'stage'),
- ab = l.hasClass(xa, 'faceBox'),
- bb = ((za && l.hasClass(this.root, 'taggingMode')) || v.byClass(xa, 'tagBoxPending') || v.byClass(xa, 'tagBoxPendingResponse') || v.byClass(xa, 'fbPhotoTagApprovalBox') || v.byClass(xa, 'tag') || (this.cropper && this.cropper.croppingMode));
- if (bb) return false;
- return wa == r.LEFT || wa == r.RIGHT || (!l.hasClass(this.root, 'taggingMode') && ab) || ya || za;
- },
- keyHandler: function (wa, event) {
- if (event.getModifiers().any) return true;
- switch (Event.getKeyCode(event)) {
- case r.LEFT:
- case r.RIGHT:
- this.pageListener(event);
- return false;
- case 76:
- return this.likePhotoWithKey();
- }
- },
- pageListener: function (event) {
- var wa = Event.getKeyCode(event),
- xa = event.getTarget();
- if (!this.shouldPageOnAction(wa, xa)) return;
- var ya = 0;
- if (wa == r.RIGHT) {
- ya = 1;
- x.setPagingAction('key_right');
- } else if (wa == r.LEFT) {
- ya = -1;
- x.setPagingAction('key_left');
- } else if (v.byClass(xa, 'next')) {
- ya = 1;
- x.setPagingAction('click_next');
- } else if (v.byClass(xa, 'prev')) {
- ya = -1;
- x.setPagingAction('click_prev');
- } else if (!this.stagePagerPrev) {
- ya = 1;
- x.setPagingAction('click_stage');
- } else {
- ya = -1;
- x.setPagingAction('click_stage_back');
- }
- if (l.hasClass(this.root, 'fbPhotoSnowliftEditMode') || (this.cropper && this.cropper.croppingMode)) {
- this.warnLeavePage(ya);
- } else {
- this.page(ya, ia.chrome() && p.isFullScreen());
- ta('snowlift', xa, event).uai(x.pagingAction);
- }
- },
- warnLeavePage: function (wa) {
- new m().setTitle("Are you sure you want to leave this page?").setBody("You have unsaved changes that will be lost if you leave the page.").setButtons([{
- name: 'leave_page',
- label: "Leave this page",
- handler: this.page.bind(this, wa)
- }, {
- name: 'continue_editing',
- label: "Stay on this page",
- className: 'inputaux'
- }]).setModal(true).show();
- },
- page: function (wa, xa) {
- if (!this.stream.isValidMovement(wa)) {
- this.showPagers(va.PAGER_FADE);
- return;
- }
- this.lastPage = Date.now();
- this.unhiliteAllTags();
- this.seenTags = [];
- var ya = this.getVideoOnStage();
- if (ya) this.switchVideo(ya, false);
- if (this.pivots && this.pivots.page(wa)) return;
- g.inform('PhotoSnowlift.PAGE');
- fa.hide();
- this.recacheData();
- this.stream.moveCursor(wa);
- l.hide(this.image);
- if (this.stream.errorInCurrent()) {
- this.setLoadingState(va.STATE_HTML, true);
- l.show(this.errorBox);
- return;
- }
- var za = this.stream.getCurrentImageData();
- if (za) {
- var ab = this.getImageURL(za);
- if (ab) {
- this.switchImage(ab, null, true);
- } else if (za.video) this.switchVideo(za.video, true);
- if (!xa) {
- this.replaceUrl = true;
- ra(za.info.permalink);
- }
- this.setLoadingState(va.STATE_IMAGE_DATA, false);
- } else {
- this.setLoadingState(va.STATE_IMAGE_PIXELS, true);
- this.setLoadingState(va.STATE_IMAGE_DATA, true);
- }
- if (this.stream.getCurrentHtml()) {
- this.swapData();
- } else this.setLoadingState(va.STATE_HTML, true);
- this.disableAds = this.disableAdsForSession;
- this.loadAds();
- if (this.cropper) this.cropper.resetPhoto();
- },
- logImpressionDetailsForPhoto: function () {
- var wa = [].concat(n.scry(ka('fbPhotoSnowliftTagList'), 'input.photoImpressionDetails'), n.scry(ka('fbPhotoSnowliftFeedback'), 'input.photoImpressionDetails'));
- if (wa.length === 0) return;
- var xa = {};
- for (var ya = 0; ya < wa.length; ya++) xa[wa[ya].name] = wa[ya].value;
- if (this.getVideoOnStage()) {
- xa.width = 0;
- xa.height = 0;
- } else {
- var za = this.getImageDimensions(this.stream.getCurrentImageData());
- xa.width = za.x;
- xa.height = za.y;
- }
- x.addDetailData(this.stream.getCursor(), xa);
- y.setIsLogAdData(true);
- },
- loadAds: function () {
- if (this.disableAds) return;
- y.loadAdsFromUserActivity();
- },
- transitionHandler: function (wa) {
- if (wa.getQueryData().closeTheater || wa.getQueryData().permPage || wa.getQueryData().makeprofile || this.returningToStart) {
- if (this.isOpen) this.close();
- this.transitionHandlerRegistered = false;
- return false;
- }
- if (this.replaceUrl) {
- this.replaceUrl = false;
- this._uriStack.push(wa.getQualifiedURI().toString());
- u.transitionComplete(true);
- return true;
- }
- var xa = this._uriStack.length;
- if (xa >= 2 && this._uriStack[xa - 2] == wa.getQualifiedURI().toString()) this._uriStack.pop();
- var ya = this.stream.getCursorForURI(wa.getUnqualifiedURI().toString());
- if (ya) {
- var za = this.stream.getRelativeMovement(ya);
- this.page(za, true);
- u.transitionComplete(false);
- return true;
- }
- if (this.isOpen) {
- u.transitionComplete(true);
- this.close();
- return true;
- }
- this.transitionHandlerRegistered = false;
- return false;
- },
- recacheData: function () {
- if (!this.loadingStates.html) {
- var wa = this.stream.getCurrentHtml();
- for (var xa in wa) {
- wa[xa] = na(ka(xa).childNodes);
- n.empty(ka(xa));
- }
- }
- },
- reloadIfTimeout: function () {
- if (!q.hasLoaded(this.image)) {
- var wa = this.makeNewImage(this.image.src, true);
- Event.listen(wa, 'load', this.useImage.bind(this, wa, null, true));
- }
- },
- useImage: function (wa, xa, ya) {
- if (ya && q.hasLoaded(this.image)) return;
- n.replace(this.image, wa);
- this.image = wa;
- g.inform('Amoeba/instrument', [this.image, 'image'], g.BEHAVIOR_PERSISTENT);
- this.adjustStageSize(xa);
- },
- makeNewImage: function (wa, xa) {
- if (this.imageLoadingTimer) {
- clearTimeout(this.imageLoadingTimer);
- this.imageLoadingTimer = null;
- } else if (!xa) this.imageRefreshTimer = setTimeout(this.reloadIfTimeout.bind(this), va.LOADING_TIMEOUT);
- var ya = n.create('img', {
- className: 'spotlight',
- alt: ''
- });
- ya.setAttribute('aria-describedby', 'fbPhotosSnowliftCaption');
- ya.setAttribute('aria-busy', 'true');
- Event.listen(ya, 'load', a.async_callback(function () {
- clearTimeout(this.imageRefreshTimer);
- this.image.setAttribute('aria-busy', 'false');
- this.setLoadingState(this.STATE_IMAGE_PIXELS, false);
- (function () {
- if (this.isOpen) {
- this.adjustStageSize();
- this.adjustForNewData();
- }
- }).bind(this).defer();
- }.bind(this), 'photo_theater'));
- ya.src = wa;
- return ya;
- },
- switchImage: function (wa, xa, ya) {
- l.hide(this.image);
- l.hide(this.errorBox);
- this.setLoadingState(this.STATE_IMAGE_PIXELS, true);
- var za = this.stream && this.stream.getCurrentImageData();
- if (za) x.addPhotoView(za.info, this.shouldShowHiRes(za), this.fullscreen && p.isFullScreen());
- this.useImage(this.makeNewImage(wa, false), xa, false);
- if (ya) this.stream.preloadImages(this.shouldShowHiRes(za));
- if (this.cropper && this.cropper.croppingMode) this.cropper.resetPhoto();
- g.inform('PhotoSnowlift.SWITCH_IMAGE');
- },
- switchVideo: function (wa, xa) {
- var ya = 'swf_' + wa;
- if (xa) {
- l.addClass(this.stageWrapper, 'showVideo');
- var za = n.create('div', {
- className: 'videoStageContainer'
- });
- n.appendContent(this.videoStage, za);
- za.id = wa;
- if (window[ya] && !qa(ya)) window[ya].write(wa);
- this.adjustStageSizeForVideo.bind(this, ya).defer();
- } else {
- window[ya] && window[ya].addVariable('video_autoplay', 0);
- this.videoLoadTimer && clearTimeout(this.videoLoadTimer);
- n.empty(this.videoStage);
- l.removeClass(this.stageWrapper, 'showVideo');
- }
- },
- checkVideoStatus: function (wa) {
- if (this.videoLoadTimer) clearTimeout(this.videoLoadTimer);
- var xa = this.getVideoOnStage();
- if (!xa) {
- return;
- } else {
- var ya = 'swf_' + xa;
- if (wa !== ya) return;
- this.adjustStageSizeForVideo(wa);
- }
- },
- adjustStageSizeForVideo: function (wa) {
- var xa = qa(wa);
- if (!xa) {
- this.videoLoadTimer = setTimeout(this.checkVideoStatus.bind(this, wa), 200);
- } else this.adjustStageSize(new ja(xa.width, xa.height));
- },
- handleServerError: function (wa, xa) {
- n.setContent(this.errorBox, wa);
- this.storeFromData(xa);
- },
- swapData: function () {
- var wa, xa = this.stream.getCurrentHtml();
- if (xa) {
- this.setLoadingState(va.STATE_HTML, false);
- for (var ya in xa) {
- wa = qa(ya);
- wa && n.setContent(wa, xa[ya]);
- }
- g.inform('PhotoSnowlift.DATA_CHANGE', this.stream.getCurrentImageData().info, g.BEHAVIOR_STATE);
- if (this.stream.getCurrentExtraData()) g.inform('PhotoSnowlift.EXTRA_DATA_CHANGE', this.stream.getCurrentExtraData(), g.BEHAVIOR_STATE);
- }
- this.showPagers(va.PAGER_FADE);
- this.adjustScroller();
- this.scrollableArea.showScrollbar(false);
- this.adjustForNewData();
- this.logImpressionDetailsForPhoto();
- },
- updateTotalCount: function (wa, xa, ya) {
- var za = this.stream.getCurrentHtml();
- if (za) {
- var ab = ka('fbPhotoSnowliftPositionAndCount');
- n.replace(ab, ya);
- ab = ya;
- l.show(ab);
- var bb = 'fbPhotoSnowliftPositionAndCount';
- za[bb] = na(ab.childNodes);
- }
- this.stream.setTotalCount(wa);
- this.stream.setFirstCursorIndex(xa);
- },
- addPhotoFbids: function (wa, xa, ya, za) {
- if (za && this.sessionID && za != this.sessionID) return;
- var ab = this.stream.getCursor() === null;
- this.stream.attachToFbidsList(wa, xa, ya);
- if (ya && ab) this.page(0, true);
- if (this.pivots && ya) this.pivots.setCycleCount(this.stream.calculateDistance(this.stream.getCursor(), this.stream.firstCursor));
- if (!this.pagersShown && this.stream.canPage()) this.setStagePagersState('ready');
- },
- attachTagger: function (wa) {
- n.appendContent(this.stageActions, wa);
- },
- storeFromData: function (wa) {
- if (!this.isOpen) return;
- if (wa.ssid && this.sessionID && this.sessionID != wa.ssid) return;
- var xa = this.stream.storeToCache(wa);
- if ('error' in xa) {
- this.checkState(va.STATE_ERROR);
- return;
- }
- if ('init' in xa) {
- this.initDataFetched(xa.init);
- if (this.openExplicitly) {
- this.replaceUrl = true;
- ra(this.stream.getCurrentImageData().info.permalink);
- }
- if (this.stream.canPage()) this.setStagePagersState('ready');
- this.ua && this.ua.add_event('ufi');
- }
- if ('image' in xa) this.checkState(va.STATE_IMAGE_DATA);
- if ('data' in xa) this.checkState(va.STATE_HTML);
- },
- setStagePagersState: function (wa) {
- switch (wa) {
- case 'ready':
- l.addClass(this.root, 'pagingReady');
- this.pagersShown = true;
- this.ua && this.ua.add_event('arrows');
- return;
- case 'active':
- l.addClass(this.root, 'pagingActivated');
- return;
- case 'inactive':
- l.removeClass(this.root, 'pagingActivated');
- return;
- case 'disabled':
- case 'reset':
- l.removeClass(this.root, 'pagingReady');
- return;
- }
- },
- deletePhoto: function (wa) {
- this.closeRefresh();
- },
- closeRefresh: function () {
- this.refreshOnClose = true;
- this.closeHandler();
- },
- onHiliteTag: function (wa, xa) {
- if (xa.version != w.VIEWER_SNOWLIFT) return;
- var ya = xa.tag;
- if (ya) this.switchHilitedTags(ya, true);
- },
- onUpdateTagBox: function (wa, xa) {
- if (xa.version == w.VIEWER_SNOWLIFT) this.updateTagBox(xa.id, xa.approve);
- }
- });
- e.exports = va;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement