PageRenderTime 24ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/javascript/intro-package/profile-intro.js

https://gitlab.com/gregtyka/KhanLatest
JavaScript | 260 lines | 203 code | 20 blank | 37 comment | 6 complexity | 42d43bc312c0f991300684d94bc866ca MD5 | raw file
  1. /**
  2. * Out-of-the-box experience logic for the profile page.
  3. * Dependent on the contents of profile-package.
  4. *
  5. * The first time a user visits their profile page, we walk them through
  6. * a full tutorial about all of the pieces.
  7. *
  8. * For the rollout of the discussion history tab, we walk existing users
  9. * through a subset of the full tutorial, highlighting just the discussion tab.
  10. * This is the case when "showDiscussionIntro" is true.
  11. */
  12. if (typeof Profile !== "undefined") {
  13. Profile.showIntro_ = function () {
  14. if (Profile.profile.isPhantom()) {
  15. // For phantom users, don't show a tour flow, but a single dialog
  16. // with clear call-to-action to login.
  17. guiders.createGuider({
  18. buttons:[
  19. {
  20. action:guiders.ButtonAction.CLOSE,
  21. text:"Nee bedankt",
  22. classString:"simple-button"
  23. },
  24. {
  25. action:guiders.ButtonAction.CLOSE,
  26. text:"Cool! Ik wil nu inloggen!",
  27. onclick:function () {
  28. var postLoginUrl = "/postlogin?continue=" +
  29. encodeURIComponent(window.location.href);
  30. window.location.href = "/login?continue=" +
  31. encodeURIComponent(postLoginUrl);
  32. },
  33. classString:"simple-button green"
  34. }
  35. ],
  36. title:"Login om je profiel op te slaan en te personaliseren!",
  37. description:"Jouw profielpagina laat je precies zijn welke " +
  38. "voortgang je hebt geboekt op iktel.nl. Als je " +
  39. "inlogt, kun je jouw profiel aanpassen en delen " +
  40. "met je vrienden!",
  41. overlay:true
  42. }).show();
  43. // The "show()" call above kicks off the guides tutorial. The system
  44. // can then progress to the next defined guide.
  45. return;
  46. }
  47. var isFullyEditable = Profile.profile.isFullyEditable();
  48. var showDiscussionIntro = Profile.showDiscussionIntro;
  49. // If we are only giving the limited discussion tab tutorial, skip these
  50. // steps. However, if we are giving the full tutorial, show them.
  51. if (!showDiscussionIntro) {
  52. guiders.createGuider({
  53. id:"welcome",
  54. next:"basic-profile",
  55. buttons:[
  56. {
  57. action:guiders.ButtonAction.CLOSE,
  58. text:"Nee bedankt, ik weet wat ik doe.",
  59. classString:"simple-button"
  60. },
  61. {
  62. action:guiders.ButtonAction.NEXT,
  63. text:"Cool. Geef me een rondleiding! ",
  64. classString:"simple-button green"
  65. }
  66. ],
  67. title:"Welkom op jouw profielpagina!",
  68. description:"Hier kun je jouw behaalde resultaten delen, " +
  69. "je voortgang bijhouden, " +
  70. "en door je discussie geschiedenis bladeren.",
  71. overlay:true
  72. }).show();
  73. guiders.createGuider({
  74. id:"basic-profile",
  75. next:"display-case",
  76. attachTo:".basic-user-info",
  77. highlight:".basic-user-info",
  78. overlay:true,
  79. position:3,
  80. buttons:[
  81. {
  82. action:guiders.ButtonAction.CLOSE,
  83. text:"Sluit",
  84. classString:"simple-button"
  85. },
  86. {
  87. action:guiders.ButtonAction.NEXT,
  88. text:"Volgende",
  89. classString:"simple-button green"
  90. }
  91. ],
  92. title:"Het gaat allemaal over jou.",
  93. description:isFullyEditable ?
  94. "Je kunt op een afbeelding klikken om een avatar te kiezen " +
  95. "en op je gebruikersnaam om je echte naam in te stellen. " :
  96. "Je kunt op een afbeelding klikken om jouw avatar te kiezen."
  97. });
  98. guiders.createGuider({
  99. id:"display-case",
  100. next:"more-info",
  101. attachTo:".display-case-cover",
  102. highlight:".sticker-book",
  103. overlay:true,
  104. position:6,
  105. buttons:[
  106. {
  107. action:guiders.ButtonAction.CLOSE,
  108. text:"Sluit",
  109. classString:"simple-button"
  110. },
  111. {
  112. action:guiders.ButtonAction.NEXT,
  113. text:"Meer! Laat me meer zien.",
  114. classString:"simple-button green"
  115. }
  116. ],
  117. title:"Laat zien wat je bereikt hebt.",
  118. description:"Je kunt tot vijf badges laten zien aan anderen " +
  119. "in je eigen glanzende prijzenkast!"
  120. });
  121. guiders.createGuider({
  122. id:"more-info",
  123. next:"discussion-history",
  124. attachTo:".accomplishments-statistics-section",
  125. highlight:".accomplishments-statistics-section",
  126. overlay:true,
  127. position:3,
  128. buttons:[
  129. {
  130. action:guiders.ButtonAction.CLOSE,
  131. text:"Sluit",
  132. classString:"simple-button"
  133. },
  134. {
  135. action:guiders.ButtonAction.NEXT,
  136. text:"Wauw! Wat is er nog meer?",
  137. classString:"simple-button green"
  138. }
  139. ],
  140. title:"Check je status.",
  141. description:"Bekijk je badges en krijg inzicht in je statistieken. " +
  142. "Deze tabjes kunnen alleen jij en je coach zien."
  143. });
  144. }
  145. // For both the full tutorial and the discussion tab tutorial, we will show
  146. // the discussion tab step here.
  147. var discussionGuide =
  148. guiders.createGuider({
  149. id:"discussion-history",
  150. next:"privacy-settings",
  151. attachTo:".community-discussion",
  152. highlight:".community-discussion",
  153. overlay:true,
  154. position:3,
  155. // Discussion tutorial: single ok button
  156. // Full tutorial, full access: close + next buttons
  157. // Full tutorial, limited access: close button
  158. buttons:(showDiscussionIntro ?
  159. [
  160. {
  161. action:guiders.ButtonAction.CLOSE,
  162. text:"Ok, bedankt!",
  163. classString:"simple-button green"
  164. }
  165. ] :
  166. isFullyEditable ?
  167. [
  168. {
  169. action:guiders.ButtonAction.CLOSE,
  170. text:"Sluit",
  171. classString:"simple-button"
  172. },
  173. {
  174. action:guiders.ButtonAction.NEXT,
  175. text:"Volgende",
  176. classString:"simple-button green"
  177. }
  178. ] :
  179. [
  180. {
  181. action:guiders.ButtonAction.CLOSE,
  182. text:"Ok! Laat mij de pagina ontdekken!",
  183. classString:"simple-button green"
  184. }
  185. ]
  186. ),
  187. title:"Praat erover!",
  188. description:"Zowel jij als de community kunnen jouw openbare " +
  189. "vragen, antwoorden en commentaar zien. Delen wat " +
  190. "we geleerd hebben is waar het om gaat binnen de community!" +
  191. "<br><br>Check hier de coole discussie pagina's over " +
  192. "deze mensen:<br>"
  193. // "<ul style='list-style-position: inside; " +
  194. // "list-style-type: disc;'>" +
  195. // "<li><a href='/profile/Sphairistrike/discussion' " +
  196. // "target='_blank'>Greg Boyle</a> " +
  197. // "(Art History fan)</li>" +
  198. // "<li><a href='/profile/britcruise/discussion' " +
  199. // "target='_blank'>Brit Cruise</a> " +
  200. // "(Khan Academy's very own)</li>" +
  201. // "<li><a href='/profile/Skywalker94/discussion' " +
  202. // "target='_blank'>Skywalker94</a> " +
  203. // "(over 1400 answers!)</li></ul>"
  204. });
  205. // In the case of giving just the discussion tutorial, we need to kick
  206. // off the guides tutorial.
  207. if (showDiscussionIntro) {
  208. discussionGuide.show();
  209. }
  210. // This tutorial step is only shown for the full tutorial when the user also
  211. // has permission to make their profile public.
  212. if (isFullyEditable && !showDiscussionIntro) {
  213. guiders.createGuider({
  214. id:"privacy-settings",
  215. attachTo:".edit-visibility.visibility-toggler",
  216. highlight:".user-info, .edit-visibility.visibility-toggler",
  217. overlay:true,
  218. position:5,
  219. buttons:[
  220. {
  221. action:guiders.ButtonAction.CLOSE,
  222. text:"Hou mijn profiel nog prive.",
  223. classString:"simple-button"
  224. },
  225. {
  226. onclick:function () {
  227. guiders.hideAll();
  228. Profile.userCardView.toggleProfileVisibility();
  229. },
  230. text:"Maak mijn profiel openbaar",
  231. classString:"simple-button green"
  232. }
  233. ],
  234. title:"Deel met de wereld <span style='font-size:65%'>(alleen als je dat wilt)" +
  235. "</span>",
  236. description:"Maak je profiel openbaar en deel de informatie die hier wordt getoond. Je kunt het altijd weer op privé zetten."
  237. });
  238. }
  239. };
  240. }