{"action":"created","comment":{"url":"https://api.github.com/repos/openstax/tutor-js/pulls/comments/40715362","id":40715362,"diff_hunk":"@@ -0,0 +1,116 @@\n+React = require 'react'\n+BS = require 'react-bootstrap'\n+ArbitraryHtml = require './html'\n+\n+TutorPopover = React.createClass\n+  displayName: 'TutorPopover'\n+\n+  getInitialState: ->\n+    firstShow: true\n+    placement: 'right'\n+    show: false\n+    scrollable: false\n+    imageLoading: false\n+\n+  propTypes: ->\n+    contentHtml: React.PropTypes.string.isRequired\n+    popoverProps: React.PropTypes.object\n+    contentProps: React.PropTypes.object\n+    overlayProps: React.PropTypes.object\n+    linkProps: React.PropTypes.object\n+    windowImpl: React.PropTypes.object\n+    maxHeightMultiplier: React.PropTypes.number\n+\n+  getDefaultProps: ->\n+    maxHeightMultiplier: 0.75\n+    windowImpl: window\n+\n+  componentDidMount: ->\n+    @updateOverlayPositioning()\n+\n+  componentDidUpdate: ->\n+    # Make sure the popover re-positions after the image loads\n+    if @refs.popcontent? and @state.firstShow\n+      content = @refs.popcontent.getDOMNode()\n+      images = content.querySelectorAll('img')\n+      for image in images\n+        unless image.onload? or image.complete\n+          @setState(imageLoading: true)\n+          image.onload = @imageLoaded\n+\n+  componentWillUnmount: ->\n+    @imageLoaded = -> null\n+\n+  imageLoaded: ->\n+    @refs.popper?.updateOverlayPosition()\n+    @setState(firstShow: false, imageLoading: false)\n+\n+  updateOverlayPositioning: ->\n+    {windowImpl} = @props\n+    # updates popper positioning function to\n+    # explicitly set height so that content\n+    # can inherit the height for scrolling content\n+    updateOverlayPosition = @refs.popper.updateOverlayPosition\n+    @refs.popper.updateOverlayPosition = =>","path":"src/components/tutor-popover.cjsx","position":64,"original_position":54,"commit_id":"ad355daab787dde044460491b43204adcb145988","original_commit_id":"da0b9464eae08153942f47ae3b419a8ac06133af","user":{"login":"pandafulmanda","id":2483873,"avatar_url":"https://avatars.githubusercontent.com/u/2483873?v=3","gravatar_id":"","url":"https://api.github.com/users/pandafulmanda","html_url":"https://github.com/pandafulmanda","followers_url":"https://api.github.com/users/pandafulmanda/followers","following_url":"https://api.github.com/users/pandafulmanda/following{/other_user}","gists_url":"https://api.github.com/users/pandafulmanda/gists{/gist_id}","starred_url":"https://api.github.com/users/pandafulmanda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pandafulmanda/subscriptions","organizations_url":"https://api.github.com/users/pandafulmanda/orgs","repos_url":"https://api.github.com/users/pandafulmanda/repos","events_url":"https://api.github.com/users/pandafulmanda/events{/privacy}","received_events_url":"https://api.github.com/users/pandafulmanda/received_events","type":"User","site_admin":false},"body":"Addressed with #2c7905c","created_at":"2015-09-29T19:12:22Z","updated_at":"2015-09-29T19:12:22Z","html_url":"https://github.com/openstax/tutor-js/pull/767#discussion_r40715362","pull_request_url":"https://api.github.com/repos/openstax/tutor-js/pulls/767","_links":{"self":{"href":"https://api.github.com/repos/openstax/tutor-js/pulls/comments/40715362"},"html":{"href":"https://github.com/openstax/tutor-js/pull/767#discussion_r40715362"},"pull_request":{"href":"https://api.github.com/repos/openstax/tutor-js/pulls/767"}}},"pull_request":{"url":"https://api.github.com/repos/openstax/tutor-js/pulls/767","id":45927779,"html_url":"https://github.com/openstax/tutor-js/pull/767","diff_url":"https://github.com/openstax/tutor-js/pull/767.diff","patch_url":"https://github.com/openstax/tutor-js/pull/767.patch","issue_url":"https://api.github.com/repos/openstax/tutor-js/issues/767","number":767,"state":"open","locked":false,"title":"Media Previewer","user":{"login":"pandafulmanda","id":2483873,"avatar_url":"https://avatars.githubusercontent.com/u/2483873?v=3","gravatar_id":"","url":"https://api.github.com/users/pandafulmanda","html_url":"https://github.com/pandafulmanda","followers_url":"https://api.github.com/users/pandafulmanda/followers","following_url":"https://api.github.com/users/pandafulmanda/following{/other_user}","gists_url":"https://api.github.com/users/pandafulmanda/gists{/gist_id}","starred_url":"https://api.github.com/users/pandafulmanda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pandafulmanda/subscriptions","organizations_url":"https://api.github.com/users/pandafulmanda/orgs","repos_url":"https://api.github.com/users/pandafulmanda/repos","events_url":"https://api.github.com/users/pandafulmanda/events{/privacy}","received_events_url":"https://api.github.com/users/pandafulmanda/received_events","type":"User","site_admin":false},"body":"Combo #725 and #756 \r\n\r\n# Media/link viewer\r\n* works for both iReadings and reference book\r\n* Especially useful for steps where the image is in another step\r\n\r\nThe jumping links was driving me straight up nuts\r\n![nuts!](http://images2.fanpop.com/image/photos/9800000/Scrat-and-his-nut-animated-ice-age-9854752-128-128.gif)\r\naddresses #758\r\n\r\n## To do\r\n- [x] tests\r\n  - [x] the media flux\r\n  - [x] media previewer component\r\n  - [x] tutor-overlay component\r\n- [x] work out details of UI with @Fredasaurus\r\n  - [x] when media is huge-mungus\r\n    * tables will be truncated/scrollable previews\r\n  - [x] when media is already in viewport\r\n    * media is highlighted like regular targeted\r\n  - [x] when link is clicked\r\n    * will scroll using #724 if media on page\r\n    * will keep previewer open until click blur if media not on page\r\n- [x] handle when media is in another module altogether\r\n  - [x] ask for a real link to figure on another page\r\n    * there was a bug, fixed with openstax/tutor-server#670\r\n  - [x] add test\r\n  - [x] update tests and propTypes\r\n\r\n\r\n\r\n### Table preview\r\n![screen shot 2015-09-08 at 6 23 08 pm](https://cloud.githubusercontent.com/assets/2483873/9749889/d1a67aba-5656-11e5-88b0-2fe407bd7576.png)\r\n\r\n### If media is not even on the current page\r\n![screen shot 2015-09-08 at 6 22 42 pm](https://cloud.githubusercontent.com/assets/2483873/9750904/c6464422-5663-11e5-9765-f9260e8d8327.png)\r\n#### links externally to ref book, but shows preview on hover\r\n![screen shot 2015-09-15 at 5 50 41 pm](https://cloud.githubusercontent.com/assets/2483873/9892203/3ed9415a-5bd2-11e5-903a-ae9ee4a9cc82.png)\r\n\r\n### If media is not visible/partially visible\r\n![screen shot 2015-09-08 at 7 50 47 pm](https://cloud.githubusercontent.com/assets/2483873/9750887/734d9108-5663-11e5-9a1b-b4d10ffecb6d.png)\r\n\r\n### If media is more than half visible\r\n![screen shot 2015-09-08 at 7 51 32 pm](https://cloud.githubusercontent.com/assets/2483873/9750888/7350ef06-5663-11e5-8e0a-76d083e7bb69.png)\r\n\r\n### For table, if partially visible\r\n![screen shot 2015-09-10 at 5 07 30 pm](https://cloud.githubusercontent.com/assets/2483873/9802274/87acca70-57de-11e5-8639-1218fb65aa95.png)\r\n\r\n### Scrollable inner content, esp useful for big tables\r\n![screen shot 2015-09-10 at 8 02 13 pm](https://cloud.githubusercontent.com/assets/2483873/9804791/f1926234-57f6-11e5-8703-969a5da23437.png)\r\n#### Scrollable for figures as well\r\n![screen shot 2015-09-15 at 6 39 03 pm](https://cloud.githubusercontent.com/assets/2483873/9892939/33ff9ab6-5bd9-11e5-87fb-9a757579e5d0.png)\r\n\r\n### Is smart about where to open up viewer\r\nopens to the left when too close to the right\r\n![screen shot 2015-09-11 at 7 21 25 pm](https://cloud.githubusercontent.com/assets/2483873/9828897/5371a460-58ba-11e5-9447-4be67a1df2f0.png)\r\n\r\n## preview for figure in another module/page/whatever\r\nin both iReading and Ref Book\r\n\r\n## Does not link externally in iReading\r\n![screen shot 2015-09-22 at 3 40 04 pm](https://cloud.githubusercontent.com/assets/2483873/10030971/23797eac-6140-11e5-82e4-74eeef9d7b9b.png)\r\n\r\n## Does link externally in reference book view\r\n![screen shot 2015-09-22 at 3 40 09 pm](https://cloud.githubusercontent.com/assets/2483873/10030972/237c4d30-6140-11e5-89be-041d7bdfd656.png)\r\n\r\n## Even makes the moving man in an interactive step\r\nlook cooler\r\n![previewer](https://cloud.githubusercontent.com/assets/2483873/10053158/0337dc14-61f0-11e5-95ba-d9fee2d88b9a.gif)\r\n\r\n## With image loading state\r\n![image-loading](https://cloud.githubusercontent.com/assets/2483873/10036064/4b7bf8c2-6167-11e5-9ef1-21018bb114e6.gif)\r\n","created_at":"2015-09-24T17:50:54Z","updated_at":"2015-09-29T19:12:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"de32e828055501d983845cc6acf8fe3bdd0b7cf1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/openstax/tutor-js/pulls/767/commits","review_comments_url":"https://api.github.com/repos/openstax/tutor-js/pulls/767/comments","review_comment_url":"https://api.github.com/repos/openstax/tutor-js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openstax/tutor-js/issues/767/comments","statuses_url":"https://api.github.com/repos/openstax/tutor-js/statuses/ad355daab787dde044460491b43204adcb145988","head":{"label":"openstax:feature/link-preview-async","ref":"feature/link-preview-async","sha":"ad355daab787dde044460491b43204adcb145988","user":{"login":"openstax","id":3805549,"avatar_url":"https://avatars.githubusercontent.com/u/3805549?v=3","gravatar_id":"","url":"https://api.github.com/users/openstax","html_url":"https://github.com/openstax","followers_url":"https://api.github.com/users/openstax/followers","following_url":"https://api.github.com/users/openstax/following{/other_user}","gists_url":"https://api.github.com/users/openstax/gists{/gist_id}","starred_url":"https://api.github.com/users/openstax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openstax/subscriptions","organizations_url":"https://api.github.com/users/openstax/orgs","repos_url":"https://api.github.com/users/openstax/repos","events_url":"https://api.github.com/users/openstax/events{/privacy}","received_events_url":"https://api.github.com/users/openstax/received_events","type":"Organization","site_admin":false},"repo":{"id":24433756,"name":"tutor-js","full_name":"openstax/tutor-js","owner":{"login":"openstax","id":3805549,"avatar_url":"https://avatars.githubusercontent.com/u/3805549?v=3","gravatar_id":"","url":"https://api.github.com/users/openstax","html_url":"https://github.com/openstax","followers_url":"https://api.github.com/users/openstax/followers","following_url":"https://api.github.com/users/openstax/following{/other_user}","gists_url":"https://api.github.com/users/openstax/gists{/gist_id}","starred_url":"https://api.github.com/users/openstax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openstax/subscriptions","organizations_url":"https://api.github.com/users/openstax/orgs","repos_url":"https://api.github.com/users/openstax/repos","events_url":"https://api.github.com/users/openstax/events{/privacy}","received_events_url":"https://api.github.com/users/openstax/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openstax/tutor-js","description":":mortar_board: Javascript frontend for openstax tutor","fork":false,"url":"https://api.github.com/repos/openstax/tutor-js","forks_url":"https://api.github.com/repos/openstax/tutor-js/forks","keys_url":"https://api.github.com/repos/openstax/tutor-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openstax/tutor-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openstax/tutor-js/teams","hooks_url":"https://api.github.com/repos/openstax/tutor-js/hooks","issue_events_url":"https://api.github.com/repos/openstax/tutor-js/issues/events{/number}","events_url":"https://api.github.com/repos/openstax/tutor-js/events","assignees_url":"https://api.github.com/repos/openstax/tutor-js/assignees{/user}","branches_url":"https://api.github.com/repos/openstax/tutor-js/branches{/branch}","tags_url":"https://api.github.com/repos/openstax/tutor-js/tags","blobs_url":"https://api.github.com/repos/openstax/tutor-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openstax/tutor-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openstax/tutor-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/openstax/tutor-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openstax/tutor-js/statuses/{sha}","languages_url":"https://api.github.com/repos/openstax/tutor-js/languages","stargazers_url":"https://api.github.com/repos/openstax/tutor-js/stargazers","contributors_url":"https://api.github.com/repos/openstax/tutor-js/contributors","subscribers_url":"https://api.github.com/repos/openstax/tutor-js/subscribers","subscription_url":"https://api.github.com/repos/openstax/tutor-js/subscription","commits_url":"https://api.github.com/repos/openstax/tutor-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/openstax/tutor-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/openstax/tutor-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/openstax/tutor-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/openstax/tutor-js/contents/{+path}","compare_url":"https://api.github.com/repos/openstax/tutor-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openstax/tutor-js/merges","archive_url":"https://api.github.com/repos/openstax/tutor-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openstax/tutor-js/downloads","issues_url":"https://api.github.com/repos/openstax/tutor-js/issues{/number}","pulls_url":"https://api.github.com/repos/openstax/tutor-js/pulls{/number}","milestones_url":"https://api.github.com/repos/openstax/tutor-js/milestones{/number}","notifications_url":"https://api.github.com/repos/openstax/tutor-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openstax/tutor-js/labels{/name}","releases_url":"https://api.github.com/repos/openstax/tutor-js/releases{/id}","created_at":"2014-09-24T21:42:26Z","updated_at":"2015-09-14T20:06:46Z","pushed_at":"2015-09-29T18:58:19Z","git_url":"git://github.com/openstax/tutor-js.git","ssh_url":"git@github.com:openstax/tutor-js.git","clone_url":"https://github.com/openstax/tutor-js.git","svn_url":"https://github.com/openstax/tutor-js","homepage":"","size":14802,"stargazers_count":2,"watchers_count":2,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":21,"forks":2,"open_issues":21,"watchers":2,"default_branch":"master"}},"base":{"label":"openstax:master","ref":"master","sha":"cd1e43cdd6d59000fefdba834f245c6c9bd57aa7","user":{"login":"openstax","id":3805549,"avatar_url":"https://avatars.githubusercontent.com/u/3805549?v=3","gravatar_id":"","url":"https://api.github.com/users/openstax","html_url":"https://github.com/openstax","followers_url":"https://api.github.com/users/openstax/followers","following_url":"https://api.github.com/users/openstax/following{/other_user}","gists_url":"https://api.github.com/users/openstax/gists{/gist_id}","starred_url":"https://api.github.com/users/openstax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openstax/subscriptions","organizations_url":"https://api.github.com/users/openstax/orgs","repos_url":"https://api.github.com/users/openstax/repos","events_url":"https://api.github.com/users/openstax/events{/privacy}","received_events_url":"https://api.github.com/users/openstax/received_events","type":"Organization","site_admin":false},"repo":{"id":24433756,"name":"tutor-js","full_name":"openstax/tutor-js","owner":{"login":"openstax","id":3805549,"avatar_url":"https://avatars.githubusercontent.com/u/3805549?v=3","gravatar_id":"","url":"https://api.github.com/users/openstax","html_url":"https://github.com/openstax","followers_url":"https://api.github.com/users/openstax/followers","following_url":"https://api.github.com/users/openstax/following{/other_user}","gists_url":"https://api.github.com/users/openstax/gists{/gist_id}","starred_url":"https://api.github.com/users/openstax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openstax/subscriptions","organizations_url":"https://api.github.com/users/openstax/orgs","repos_url":"https://api.github.com/users/openstax/repos","events_url":"https://api.github.com/users/openstax/events{/privacy}","received_events_url":"https://api.github.com/users/openstax/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openstax/tutor-js","description":":mortar_board: Javascript frontend for openstax tutor","fork":false,"url":"https://api.github.com/repos/openstax/tutor-js","forks_url":"https://api.github.com/repos/openstax/tutor-js/forks","keys_url":"https://api.github.com/repos/openstax/tutor-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openstax/tutor-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openstax/tutor-js/teams","hooks_url":"https://api.github.com/repos/openstax/tutor-js/hooks","issue_events_url":"https://api.github.com/repos/openstax/tutor-js/issues/events{/number}","events_url":"https://api.github.com/repos/openstax/tutor-js/events","assignees_url":"https://api.github.com/repos/openstax/tutor-js/assignees{/user}","branches_url":"https://api.github.com/repos/openstax/tutor-js/branches{/branch}","tags_url":"https://api.github.com/repos/openstax/tutor-js/tags","blobs_url":"https://api.github.com/repos/openstax/tutor-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openstax/tutor-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openstax/tutor-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/openstax/tutor-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openstax/tutor-js/statuses/{sha}","languages_url":"https://api.github.com/repos/openstax/tutor-js/languages","stargazers_url":"https://api.github.com/repos/openstax/tutor-js/stargazers","contributors_url":"https://api.github.com/repos/openstax/tutor-js/contributors","subscribers_url":"https://api.github.com/repos/openstax/tutor-js/subscribers","subscription_url":"https://api.github.com/repos/openstax/tutor-js/subscription","commits_url":"https://api.github.com/repos/openstax/tutor-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/openstax/tutor-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/openstax/tutor-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/openstax/tutor-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/openstax/tutor-js/contents/{+path}","compare_url":"https://api.github.com/repos/openstax/tutor-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openstax/tutor-js/merges","archive_url":"https://api.github.com/repos/openstax/tutor-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openstax/tutor-js/downloads","issues_url":"https://api.github.com/repos/openstax/tutor-js/issues{/number}","pulls_url":"https://api.github.com/repos/openstax/tutor-js/pulls{/number}","milestones_url":"https://api.github.com/repos/openstax/tutor-js/milestones{/number}","notifications_url":"https://api.github.com/repos/openstax/tutor-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openstax/tutor-js/labels{/name}","releases_url":"https://api.github.com/repos/openstax/tutor-js/releases{/id}","created_at":"2014-09-24T21:42:26Z","updated_at":"2015-09-14T20:06:46Z","pushed_at":"2015-09-29T18:58:19Z","git_url":"git://github.com/openstax/tutor-js.git","ssh_url":"git@github.com:openstax/tutor-js.git","clone_url":"https://github.com/openstax/tutor-js.git","svn_url":"https://github.com/openstax/tutor-js","homepage":"","size":14802,"stargazers_count":2,"watchers_count":2,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":21,"forks":2,"open_issues":21,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openstax/tutor-js/pulls/767"},"html":{"href":"https://github.com/openstax/tutor-js/pull/767"},"issue":{"href":"https://api.github.com/repos/openstax/tutor-js/issues/767"},"comments":{"href":"https://api.github.com/repos/openstax/tutor-js/issues/767/comments"},"review_comments":{"href":"https://api.github.com/repos/openstax/tutor-js/pulls/767/comments"},"review_comment":{"href":"https://api.github.com/repos/openstax/tutor-js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openstax/tutor-js/pulls/767/commits"},"statuses":{"href":"https://api.github.com/repos/openstax/tutor-js/statuses/ad355daab787dde044460491b43204adcb145988"}}}}