Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready ->
- page_id = $('#posts-container').data 'page-id'
- $('.facebook-message').live 'mouseover', ->
- $(this).find('.message-tool-box-extras').show()
- $('.facebook-message').live 'mouseout', ->
- $(this).find('.message-tool-box-extras').hide()
- $('#search-container').find(':submit').click ->
- $("#posts-results").empty()
- params =
- q: $('#search_q').val()
- page_id: page_id
- $.read '/posts/search', params, post_result
- post_result = (response) ->
- $('.feed-more img').hide()
- _.each response, (wall_post) ->
- post = wall_post.post
- if post.message != null
- post.message = post.message.replace /\n/,'</br>'
- if post.properties.actions? && post.properties.actions.length > 0
- _.each post.properties.actions, (item) ->
- post.properties["#{item.name.toLowerCase()}_link"] = encodeURIComponent item.link
- event_regex = /event.php/
- if post.properties.link? && post.properties.link.match event_regex
- post.properties['is_event'] = true
- tmpl = $("#post_template").tmpl(response).appendTo "#posts-results"
- $(tmpl).find(".post-time").localTimeFromUTC 'MM/dd/yyyy hh:mm a'
- $(tmpl).find(".post-time").each ->
- time = $(this).html()
- $(this).html $.timeago time
- qtip_show = (event,api) ->
- fb_user_id = $(event.originalEvent.currentTarget).data 'fb-user-id'
- request_params =
- page_id: page_id
- user_id: fb_user_id
- $.read '/fb_users/{user_id}/user-details',request_params,(response) ->
- user_actions_view = $("#user_actions_template").tmpl response
- api.set 'content.text',user_actions_view
- user_actions_view = $ api.elements.content
- user_actions_view.find('.submit-keyword').click (e) ->
- keyword =
- label: 'todo'
- monitorable_id: page_id
- monitorable_type: 'Page'
- data: fb_user_id
- entity_type: 'person'
- action: [user_actions_view.find("select").val()]
- $.create '/keywords', { keyword } , (response) ->
- alert 'tag added'
- user_actions_view.find('.tag-user').click (event) ->
- user_actions_view.find(":hidden").show()
- qtip_params =
- content: 'Loading...'
- hide:
- fixed: true
- delay: 500
- event: 'mouseleave'
- events:
- show: qtip_show
- $('.user-avatar').qtip qtip_params
- $.read '/pages/{page_id}/posts', { page_id: page_id }, post_result
- $('.commentCount').live 'click', (event) ->
- if $(this).parent().parent().find('.comments-container').length
- $(this).parent().parent().find('.comments-container').remove()
- return false
- post_id = $(this).data "post-id"
- is_post_deleted = $(this).data "post-deleted"
- $.read '/posts/{post_id}/comments', { post_id: post_id }, (response) ->
- template_params =
- comments: response
- post_id: post_id
- is_post_deleted: is_post_deleted
- $("#comment_list_template").tmpl(template_params).appendTo "#post-#{post_id}"
- $(".flag-post-comment").live "click", (event) ->
- comment_id = $(this).data("post-comment-id")
- mood = $(this).data("mood")
- request_params =
- post_id: post_id
- comment_id: comment_id
- comment:
- mood: mood
- $.update "/posts/{post_id}/comments/{comment_id}", request_params, (response) ->
- $("#comment-#{comment_id}-flag").children().replaceWith($("#toggle_flag_template").tmpl({data:response.comment,type:'post-comment'}))
- $(".submit-comment").click (event) ->
- request_params =
- post_id: $(this).data "post-id"
- post_as: $(this).parent().parent().find(":checked").val()
- comment:
- post_id: post_id
- message: $(this).parent().parent().find("textarea").val()
- $.create '/posts/{post_id}/comments', request_params, (response) ->
- $("#comment_template").tmpl({ comment: response.comment, is_post_deleted: false, post_id: post_id }).appendTo("#post-" + post_id + "-comments-list")
- $("#comment-entry-" + post_id).val("")
- comment_link = $("#post-" + post_id).find(".commentCount")
- comments_count = parseInt(comment_link.data('comment-count')) + 1
- comment_link.attr("data-comment-count" , comments_count)
- $("#post-" + post_id).find(".commentCount").html(comments_count + " Comments")
- $(".delete-post-comment").live "click", ->
- if confirm 'Are you sure?'
- comment_id = $(this).data("comment-id")
- $.destroy "/comments/{comment_id}", { comment_id: comment_id }, (response) ->
- $("#comment-" + comment_id).replaceWith($("#comment_template").tmpl(response))
- return false
- return false
- #Delete a post listener
- $(".delete-post").live 'click', ->
- if confirm 'Are you sure?'
- post_id = $(this).data('postid')
- $.destroy '/posts/{post_id}', { post_id: post_id }, (response) ->
- $("#post-" + post_id).replaceWith($("#post_template").tmpl(response))
- $("#post-" + post_id).find(".post-time").localTimeFromUTC('MM/dd/yyyy hh:mm a')
- return false
- $("#keywords-link").click ->
- $.read "/pages/{page_id}/keywords", { page_id: page_id }, (response) ->
- dialog = $("#keywords_dialog_template").tmpl({ keywords: response, page: { id: page_id }}).appendTo("body")
- dialog.dialog {modal:true}
- target = $('.keyword-link-container').find('a')
- dialog.dialog "option",{position: {
- my: 'left top',
- at: 'right top',
- of: target
- },resizable: false}
- $("#page-" + page_id + "-keywords").find("form").bind("ajax:success", (xhr,data,status) ->
- $("#keyword_errors").html("")
- $("#keyword_errors").hide()
- $("#keywords_template").tmpl($.parseJSON(data)).appendTo(dialog.find(".keyword-list"))
- dialog.find(".keywords-entry").find(":text").val("")
- dialog.dialog("close")
- $(".ui-widget-overlay").live "click", -> dialog.dialog("close"))
- $(".flag-post").live 'click', ->
- post_id = $(this).data('post-id')
- mood = $(this).data("mood")
- $.update '/posts/{post_id}', { post_id: post_id, post: { mood: mood } }, (response) ->
- console.log(response)
- $("#flag_" + post_id).replaceWith($("#toggle_flag_template").tmpl({data:response.post,type:'post'}))
- $('.feed-more a').click ->
- $('.feed-more img').show()
- page = $(this).data('current-page') + 1
- $(this).data('current-page', page)
- $.read('/pages/{page_id}/posts', { page_id: page_id, page: page }, post_result)
- return false
Add Comment
Please, Sign In to add comment