Guest User

Untitled

a guest
Nov 18th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. // finds a conversation in the DOM
  2. function findConv(conversation_id, type) {
  3. // if a current conversation is opened in the messenger
  4. var messenger_conversation = $('body .conversation');
  5. if (messenger_conversation.length) {
  6. // conversation is opened in the messenger
  7. return messenger_conversation;
  8. } else {
  9. // conversation is opened in a popup window
  10. var data_attr = "[data-" + type + "conversation-id='" +
  11. conversation_id +
  12. "']";
  13. var conversation = $('body').find(data_attr);
  14. return conversation;
  15. }
  16. }
  17.  
  18. // checks if a conversation window is rendered and visible on a browser
  19. function ConvRendered(conversation_id, type) {
  20. // if a current conversation is opened in the messenger
  21. if ($('body .conversation').length) {
  22. // conversation is opened in the messenger
  23. // so it automatically means that is visible
  24. return true;
  25. } else {
  26. // conversation is opened in a popup window
  27. var data_attr = "[data-" + type + "conversation-id='" +
  28. conversation_id +
  29. "']";
  30. var conversation = $('body').find(data_attr);
  31. return conversation.is(':visible');
  32. }
  33. }
  34.  
  35. function ConvMessagesVisiblity(conversation) {
  36. // if current conversation is opened in the messenger
  37. if ($('body .conversation').length) {
  38. // conversation is opened in the messenger
  39. // so it is automatically means that messages are visible
  40. return true;
  41. } else {
  42. // conversation is opened in a popup window
  43. // check if the window is collapsed or expanded
  44. var visibility = conversation
  45. .find('.panel-body')
  46. .is(':visible');
  47. return visibility;
  48. }
  49. }
Add Comment
Please, Sign In to add comment