Advertisement
Guest User

Untitled

a guest
May 25th, 2015
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.03 KB | None | 0 0
  1. convention to keep in mind: variables starting with a dollar sign refer to jQuery selectors.
  2. In other words this would be the convention
  3. $form = $("form")
  4. form = $form[0]
  5. $form = $(form)
  6.  
  7. window.AroundFeedsAJAX // Object
  8. AdminActions // Object
  9. accessToken // String: initialized as empty string, but set upon login
  10. adminLoggedIn: // Function: returns boolean indicating whether accessToken has been set
  11. getConfirmation // Function: a halting action when called from a form's 'submit' event
  12. // - makes the "Are you sure?" effect on the submit button
  13. // - returning false/true will stop/continue the callback chain
  14. addLoginSubmitListener // Function: adds a 'submit' listener for the admin sign-in form
  15. addFeedHideListener // Function: adds a 'submit' listener for the 'hide-feed' form
  16. addChangeScoreListener // Function: adds a 'submit' listener for the 'change-feed-score' form
  17. addChangeLanguageListener // Function: adds a 'submit' listener for the 'change-feed-language' form
  18. addMemberBanListener // Function: adds a 'submit' listener for the 'delete-member' form
  19. banMember: // Function: called from the 'delete-member' form's 'submit' callback
  20. - AJAX post to ban user (with alert showing result)
  21. - calls removeMemberFeeds
  22. removeMemberFeeds // Function: removes all feeds with the same author from the client's document
  23. hideFeed // Function: AJAX post to hide feed
  24. - calls removeFeedFromPage in success callback
  25. changeFeedScore // Function: AJAX post to change feed score
  26. chageFeedLanguage // Function: AJAX post to change feed language
  27. removeFeedFromPage // Function: Remove single feed from client's document
  28. tryAuthenticate // Function: AJAX post for admin login, calls adminLoginSuccess on success
  29. adminLoginSuccess // Function: adds message for successful login and calls AddAdminActions
  30. addAdminActions // Function: calls many functions which add 'submit' listeners on forms
  31. addSortSwitch // Function: add a button to switch the sorting method (latest / popular)
  32. - only called after admin logs in
  33. resetListeners // Function: calls addAdminActions
  34. - used from Infinite Scroll
  35. - when new feeds are added, event listeners need to be readded
  36. addAdminActionsToggle // Function: adds event listeners for toggling feeds' admin panels open/close
  37. - called from addAdminActions
  38.  
  39. // Minor helper methods
  40. constructChangeFeedScoreParams
  41. constructChangeFeedLanguageParams
  42.  
  43. InfiniteScroll // Object
  44. fetchInProgess // Boolean: indicates if an AJAX request for feeds is currently happening
  45. - Used in debugging the duplicate fetching problem
  46. requests // Array: used for the same purpose as fetchInProgess
  47. $scrollTrigger // Function: returns a jQuery selector of the "#scroll-trigger" element
  48. begin // Function: calls startMasonry, addScrollListener, and removeEmptySpace
  49. $masonryEl // Undefined: used as a cached reference to the Masonry grid
  50. masonryEl // Function: sets up Masonry on the $el passed as input
  51. - defines and returns $masonryEL
  52. fixBodyCss // Function: changes some CSS
  53. startMasonry // FUnction: masonry customization - CSS, imagesLoaded, layoutComplete
  54. addScrollListener // Function: calls addResizeListener & adds the listener on page scroll
  55. - in scroll callback, calls getMoreFeeds if $scrollTrigger is visible
  56. addResizeListener // Function: adds a listener on window resize which calls removeEmptySpace
  57. removeEmptySpace // Function: centers grid
  58. getMoreFeeds // Function: calls sendAJAX.
  59. - orginally prevented duplicate requests by checking
  60. fetchInProgress variable, but this turned out to be unnecessary
  61. sendAJAX // Function: Sends AJAX to get more feeds and calls processResults
  62. constructDataString // Function: Helper for making url required by sendAJAX
  63. processResults // Function: on each new feed, calls addFeed, attaches to DOM, and adds listeners
  64. addFeed // Function: call customizeTemplate to make a template for the feed
  65. - ensure the scroll trigger is by the bottom of the screen
  66. customizeTemplate // Function: duplicate a template and customize it with new feed's data
  67. pictureUrl // Function: helper for getting the picture url of a feed
  68.  
  69. And this is the code that gets run to start everything off:
  70.  
  71. $(function()
  72. if ($(".presentation-feeds_by_user, .presentation-around_feeds").length > 0) {
  73. window.AdminActions = AroundFeedsAJAX.AdminActions
  74. AdminActions.addLoginSubmitListener();
  75.  
  76. window.InfiniteScroll = AroundFeedsAJAX.InfiniteScroll
  77. InfiniteScroll.begin();
  78. }
  79. })
  80.  
  81. Hope this helps and let me know of any questions
  82. maxpleaner@gmail.com
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement