Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- convention to keep in mind: variables starting with a dollar sign refer to jQuery selectors.
- In other words this would be the convention
- $form = $("form")
- form = $form[0]
- $form = $(form)
- window.AroundFeedsAJAX // Object
- AdminActions // Object
- accessToken // String: initialized as empty string, but set upon login
- adminLoggedIn: // Function: returns boolean indicating whether accessToken has been set
- getConfirmation // Function: a halting action when called from a form's 'submit' event
- // - makes the "Are you sure?" effect on the submit button
- // - returning false/true will stop/continue the callback chain
- addLoginSubmitListener // Function: adds a 'submit' listener for the admin sign-in form
- addFeedHideListener // Function: adds a 'submit' listener for the 'hide-feed' form
- addChangeScoreListener // Function: adds a 'submit' listener for the 'change-feed-score' form
- addChangeLanguageListener // Function: adds a 'submit' listener for the 'change-feed-language' form
- addMemberBanListener // Function: adds a 'submit' listener for the 'delete-member' form
- banMember: // Function: called from the 'delete-member' form's 'submit' callback
- - AJAX post to ban user (with alert showing result)
- - calls removeMemberFeeds
- removeMemberFeeds // Function: removes all feeds with the same author from the client's document
- hideFeed // Function: AJAX post to hide feed
- - calls removeFeedFromPage in success callback
- changeFeedScore // Function: AJAX post to change feed score
- chageFeedLanguage // Function: AJAX post to change feed language
- removeFeedFromPage // Function: Remove single feed from client's document
- tryAuthenticate // Function: AJAX post for admin login, calls adminLoginSuccess on success
- adminLoginSuccess // Function: adds message for successful login and calls AddAdminActions
- addAdminActions // Function: calls many functions which add 'submit' listeners on forms
- addSortSwitch // Function: add a button to switch the sorting method (latest / popular)
- - only called after admin logs in
- resetListeners // Function: calls addAdminActions
- - used from Infinite Scroll
- - when new feeds are added, event listeners need to be readded
- addAdminActionsToggle // Function: adds event listeners for toggling feeds' admin panels open/close
- - called from addAdminActions
- // Minor helper methods
- constructChangeFeedScoreParams
- constructChangeFeedLanguageParams
- InfiniteScroll // Object
- fetchInProgess // Boolean: indicates if an AJAX request for feeds is currently happening
- - Used in debugging the duplicate fetching problem
- requests // Array: used for the same purpose as fetchInProgess
- $scrollTrigger // Function: returns a jQuery selector of the "#scroll-trigger" element
- begin // Function: calls startMasonry, addScrollListener, and removeEmptySpace
- $masonryEl // Undefined: used as a cached reference to the Masonry grid
- masonryEl // Function: sets up Masonry on the $el passed as input
- - defines and returns $masonryEL
- fixBodyCss // Function: changes some CSS
- startMasonry // FUnction: masonry customization - CSS, imagesLoaded, layoutComplete
- addScrollListener // Function: calls addResizeListener & adds the listener on page scroll
- - in scroll callback, calls getMoreFeeds if $scrollTrigger is visible
- addResizeListener // Function: adds a listener on window resize which calls removeEmptySpace
- removeEmptySpace // Function: centers grid
- getMoreFeeds // Function: calls sendAJAX.
- - orginally prevented duplicate requests by checking
- fetchInProgress variable, but this turned out to be unnecessary
- sendAJAX // Function: Sends AJAX to get more feeds and calls processResults
- constructDataString // Function: Helper for making url required by sendAJAX
- processResults // Function: on each new feed, calls addFeed, attaches to DOM, and adds listeners
- addFeed // Function: call customizeTemplate to make a template for the feed
- - ensure the scroll trigger is by the bottom of the screen
- customizeTemplate // Function: duplicate a template and customize it with new feed's data
- pictureUrl // Function: helper for getting the picture url of a feed
- And this is the code that gets run to start everything off:
- $(function()
- if ($(".presentation-feeds_by_user, .presentation-around_feeds").length > 0) {
- window.AdminActions = AroundFeedsAJAX.AdminActions
- AdminActions.addLoginSubmitListener();
- window.InfiniteScroll = AroundFeedsAJAX.InfiniteScroll
- InfiniteScroll.begin();
- }
- })
- Hope this helps and let me know of any questions
- maxpleaner@gmail.com
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement