Advertisement
Guest User

Untitled

a guest
Aug 28th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. var PostCard = function($root) {
  2. this.$root = $root;
  3. this.stuff_id = this.$root.data('stuff_id');
  4. this.id = this.$root.data('id');
  5. this.is_owner = this.$root.data('is_owner');
  6. this.$propose_button = null;
  7. this.$favorite_button = null;
  8. this.$total_favorite = null;
  9. this.$image_view_editor = null;
  10. this.image_view_editor = null;
  11. this.$proposal_box_modal = null;
  12. this.proposal_box = null;
  13. this.$proposal_box = null;
  14. this.init();
  15. this.initEvents();
  16. };
  17.  
  18. PostCard.prototype.initEvents = function() {
  19. var self =this;
  20. this.$propose_button.on("click", function(e) {
  21. if(self.is_owner ) {
  22. return false;
  23. }
  24. if(CommonLibrary.isGuest()) {
  25. return false;
  26. }
  27. self.$proposal_box_modal.modal("show").load($(this).attr("value"));
  28.  
  29. });
  30. }
  31.  
  32. var PostList = function($root) {
  33. this.$root = $root;
  34. this.stuff_ids = '';
  35. this.id = $root.data('id');
  36. this.location = $root.data('location');
  37. this.query = '';
  38. this.post_cards = [];
  39. this.$post_list_area = null;
  40. this.permit_retrieve_post = true;
  41. this.init();
  42. this.initEvents();
  43. };
  44.  
  45. PostList.prototype.retrievePostWhenScroll_ = function(e) {
  46. var self = e.data.self;
  47. var scrollPercentage =
  48. ((document.documentElement.scrollTop + document.body.scrollTop) /
  49. (document.documentElement.scrollHeight - document.documentElement.clientHeight) * 100);
  50. if(scrollPercentage > PostList.prototype.SCROLL_VALUE) {
  51. if(self.permit_retrieve_post) {
  52. self.permit_retrieve_post = false;
  53. $.ajax({
  54. url: $("#base-url").val() + "/site/get-more-posts",
  55. type: 'post',
  56. data: {'ids' : self.stuff_ids, query: self.query, location: self.location},
  57. success: function(data) {
  58. var parsedData = JSON.parse(data);
  59. if(parsedData['status'] === 1) {
  60. self.$post_list_area.append(parsedData['view']);
  61. $(parsedData['view']).filter('.post-card').each(function(index, value) {
  62. self.post_cards.push(new PostCard($(value)));
  63. self.stuff_ids += "," + $(value).data('stuff_id');
  64. });
  65. }
  66. self.permit_retrieve_post = true;
  67. },
  68. error : function(data) {
  69. self.permit_retrieve_post = true;
  70.  
  71. }
  72. });
  73. }
  74. }
  75.  
  76. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement