PageRenderTime 45ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/Development/IENM-20150216/Intranet.root/Intranet.Website/Profile/SocialMediaFeed.ascx

#
ASP.NET | 182 lines | 153 code | 29 blank | 0 comment | 23 complexity | c187287e2b1bb955b2fd61fd89548264 MD5 | raw file
Possible License(s): LGPL-2.0, GPL-2.0, LGPL-2.1
  1. <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SocialMediaFeed.ascx.cs" Inherits="Intranet.WebSite.Profile.SocialMediaFeed" %>
  2. <div class="ProfileComponentWrapper">
  3. <div class="ProfileComponent">
  4. <div class="ProfileComponentTitleBar">
  5. <span class="widget_handle"><%= WidgetTitle %></span>
  6. </div>
  7. <asp:Label ID="ErrorMessages" Visible="false" runat="server" />
  8. <asp:Panel ID="Feed" CssClass="socialMediaFeed widget_content collapsed" runat="server">
  9. loading...
  10. </asp:Panel>
  11. <asp:PlaceHolder ID="ScriptConfig" runat="server" />
  12. <script type="text/javascript">
  13. $(document).ready(function () {
  14. var identityType = "<%= IdentityTypeName %>".toLowerCase();
  15. var accessToken = "<%= AccessToken %>";
  16. if (accessToken && identityType) {
  17. if (identityType == "yammer") {
  18. $.ajax({
  19. type: "POST",
  20. data: JSON.stringify({ accessToken: accessToken }),
  21. dataType: "json",
  22. url: Config.YammerServiceUrl + "/GetMessagesSentByUser",
  23. contentType: "application/json; charset=utf-8",
  24. success: function (data, textStatus, jqXHR) {
  25. $("#<%= Feed.ClientID %>").html(data);
  26. $('span.humaneDate').humaneDates();
  27. //$("span.twitterdate").humaneDates();
  28. $('a.ymsgopen').each(YammerMessageLengthToggle);
  29. $(".moreyammerbutton").click(function () {
  30. $(".moreyammerbutton").parent().children(".rssfeed").each(function () {
  31. toggleYammerMSGDisplay($(this));
  32. });
  33. return false;
  34. });
  35. },
  36. error: function (jqXHR, textStatus, errorThrown) {
  37. $("#<%= Feed.ClientID %>").html("<%= currentLanguagePack.GeneralYammerMessageError %><!-- " + jqXHR.responseText + "-->");
  38. }
  39. });
  40. }
  41. else if (identityType == "twitter") {
  42. $.ajax({
  43. type: "GET",
  44. dataType: "json",
  45. url: Config.TwitterServiceUrl + "/GetUserTweets?accessToken=" + accessToken,
  46. contentType: "application/json; charset=utf-8",
  47. success: function (data, textStatus, jqXHR) {
  48. data = Global.GetFirstProperty(data); // Get first property (because we get wrapped JSON objects)
  49. $("#<%= Feed.ClientID %>").html(data);
  50. $('span.humaneDate').humaneDates();
  51. $("span.twitterdate").humaneDates();
  52. //$('a.ymsgopen').each(YammerMessageLengthToggle);
  53. $(".moretwitterbutton").click(function () {
  54. $(".moretwitterbutton").parent().each(function () {
  55. toggleTwitterDisplay($(this));
  56. });
  57. return false;
  58. });
  59. },
  60. error: function (jqXHR, textStatus, errorThrown) {
  61. $("#<%= Feed.ClientID %>").html("<%= currentLanguagePack.GeneralTwitterMessageError %><!-- " + jqXHR.responseText + "-->");
  62. }
  63. });
  64. }
  65. else if (identityType == "linkedin") {
  66. $.ajax({
  67. type: "GET",
  68. dataType: "json",
  69. url: Config.LinkedInServiceUrl + "/GetUserPositions?accessToken=" + accessToken,
  70. contentType: "application/json; charset=utf-8",
  71. success: function (data, textStatus, jqXHR) {
  72. data = Global.GetFirstProperty(data); // Get first property (because we get wrapped JSON objects)
  73. $("#<%= Feed.ClientID %>").html(data);
  74. $('div.linkedInSummary').attr("style", "display: none;");
  75. // using the Jquery Expander plugin, just for slicing text. We don't use the expand functionality from expander
  76. $('div.linkedInSummaryShort').expander({ slicePoint: 135, expandText: '' });
  77. $('div.linkedInSummaryShort').attr("style", "display: block;");
  78. $(".morelinkedinbutton").click(function () {
  79. $(".morelinkedinbutton").parent().each(function () {
  80. toggleLinkedInDisplay($(this));
  81. });
  82. return false;
  83. });
  84. },
  85. error: function (jqXHR, textStatus, errorThrown) {
  86. $("#<%= Feed.ClientID %>").html("Error: " + jqXHR.responseText);
  87. }
  88. });
  89. }
  90. }
  91. });
  92. function toggleTwitterDisplay(list) {
  93. if (list.hasClass("collapsed")) {
  94. var count = 0;
  95. list.children("div").each(function () {
  96. if (count++ >= 1) $(this).slideDown(400);
  97. });
  98. list.removeClass("collapsed");
  99. $('.moretwitterbutton').html('Toon minder').addClass("morebuttonup").removeClass("morebuttondown"); ;
  100. }
  101. else {
  102. var count = 0;
  103. list.children("div").each(function () {
  104. if (count++ >= 1) $(this).slideUp(400);
  105. });
  106. list.addClass("collapsed");
  107. $('.moretwitterbutton').html('Toon meer').addClass("morebuttondown").removeClass("morebuttonup");
  108. }
  109. }
  110. function toggleLinkedInDisplay(list) {
  111. if (list.hasClass("collapsed")) {
  112. $('div.linkedInSummary').attr("style", "display: block;");
  113. $('div.linkedInSummaryShort').attr("style", "display: none;");
  114. var count = 0;
  115. list.children("div").each(function () {
  116. if (count++ >= 1) $(this).slideDown(400);
  117. });
  118. list.removeClass("collapsed");
  119. $('.morelinkedinbutton').html('Toon minder').addClass("morebuttonup").removeClass("morebuttondown"); ;
  120. }
  121. else {
  122. //$('div.linkedInSummary').text($(this).text().substr(0, 4000) + '...');
  123. $('div.linkedInSummary').attr("style", "display: none;");
  124. $('div.linkedInSummaryShort').attr("style", "display: block;");
  125. var count = 0;
  126. list.children("div").each(function () {
  127. if (count++ >= 1) $(this).slideUp(400);
  128. });
  129. list.addClass("collapsed");
  130. $('.morelinkedinbutton').html('Toon meer').addClass("morebuttondown").removeClass("morebuttonup");
  131. }
  132. }
  133. function toggleYammerMSGDisplay(list) {
  134. if (list.parent().hasClass("collapsed")) {
  135. var count = 0;
  136. list.children("div").each(function () {
  137. if (count++ >= 1) $(this).slideDown(400);
  138. });
  139. list.parent().removeClass("collapsed");
  140. $('.moreyammerbutton').html('Toon minder').addClass("morebuttonup").removeClass("morebuttondown"); ;
  141. }
  142. else {
  143. var count = 0;
  144. list.children("div").each(function () {
  145. if (count++ >= 2) $(this).slideUp(400);
  146. });
  147. list.parent().addClass("collapsed");
  148. $('.moreyammerbutton').html('Toon meer').addClass("morebuttondown").removeClass("morebuttonup");
  149. }
  150. }
  151. </script>
  152. </div>
  153. </div>