1. 12 Apr, 2016 3 commits
    • Nick Stenning's avatar
      Merge pull request #3188 from hypothesis/274-excerpt-overflow-checking · d514803e
      Nick Stenning authored
      Re-implement collapsible excerpt overflow state checking
      d514803e
    • Robert Knight's avatar
      Update <excerpt> overflow state when excerpt is shown or hidden via ng-show · 46f3e7c3
      Robert Knight authored
      In addition to the content changing, the window resizing and media loading,
      another way that the excerpt's overflow state can change is if it or a parent
      element's visibility changes.
      
      Since there isn't a generic, performant way to watch the visibility of DOM
      elements, the change here adds a scope watch which tests for the presence of
      the 'ng-hide' class used by the ng-show and ng-hide directives on parent
      elements, since that is the only method of changing visibility that we actually
      need to support at the moment.
      46f3e7c3
    • Robert Knight's avatar
      Trigger a <annotation> scope digest if the collapsible state of an annotation body changes · ce306e60
      Robert Knight authored
      Excerpts update their overflow state outside of the Angular $digest
      cycle. The usual way to deal with this is to wrap the update in a
      $scope.$apply() call. However, this triggers a full $digest cycle, which
      we want to avoid if many excerpts update their state at the same time -
      eg. if we have a large number of annotation cards.
      
      This commit instead explicitly invokes the $digest _only_ in the
      affected annotation card and then only if the collapsible state of an
      annotation body actually changed.
      ce306e60
  2. 11 Apr, 2016 3 commits
    • Robert Knight's avatar
      Extract overflow state recalculation into a helper class · 36069747
      Robert Knight authored
      This makes it possible to write isolated tests for just the overflow
      state and content style recalculation aspects of <excerpt> components.
      
      It also simplifies the <excerpt> component tests by making it easier to
      reason about when the excerpt's overflow state will have been
      recalculated and the directive's state updated accordingly.
      36069747
    • Robert Knight's avatar
      Provide a polyfill for window.requestAnimationFrame() in tests · c5d1c27f
      Robert Knight authored
      rAF is not available in PhantomJS 1.x but is supported by all of our
      target browsers (IE >= 10).
      c5d1c27f
    • Robert Knight's avatar
      Re-implement excerpt overflow state recalculation · 6f49c8f6
      Robert Knight authored
      Previously the overflowing state of the excerpt was computed implicitly
      by the overflowing() method, which was called from several other
      controller functions.
      
      There were several problems with this approach:
      
       1. Since this method calls Element.scrollHeight, it triggered an
          expensive synchronous layout flush.
       2. In certain situations, this could trigger a loop where the
          overflowing flag was continually flipped (see #2960)
       3  It was unpredictable when the overflowing state would be recomputed.
      
      This commit instead opts for a different approach which is more explicit
      about when the state is recomputed, based on the assumption that the
      <excerpt>'s content size is a function of:
      
       1. The inputs to the <excerpt>'s content (eg. the text of a quote, the body
          of an annotation)
       2. The sidebar window's size
       3. The dimensions of any embedded media
      
      The content size is then computed and updated as follows:
      
       1. When the <excerpt> is initially created, an async computation of
          the scrollHeight is scheduled. The calculation unfortunately needs
          to be async because the content may contain Angular directives which
          take several $digest cycles to fully process.
      
       2. The <excerpt> listens for changes to the content's data (via a
          'contentData' property), media 'load' events and window 'resize'
          events and recomputes the overflow state in response to any of
          these.
      
      There are a couple of other fixes here:
      
       - Use an optional boolean property for the 'enabled' input,
         rather than a function. The app passed a function to this property
         but the tests passed a boolean.
      
      Fixes #2960
      6f49c8f6
  3. 08 Apr, 2016 3 commits
  4. 06 Apr, 2016 9 commits
  5. 05 Apr, 2016 4 commits
    • Christof Dorner's avatar
      Merge pull request #3151 from hypothesis/postgres-write-models · 17e6556c
      Christof Dorner authored
      Postgres Write 2/4: Model code for creating new annotations in Postgres
      17e6556c
    • Nick Stenning's avatar
      Merge pull request #3038 from hypothesis/client-live-reload · e80973ec
      Nick Stenning authored
      Live reload development tool for Hypothesis client
      e80973ec
    • Robert Knight's avatar
      Debounce live-reload notifications · 386e3552
      Robert Knight authored
      If multiple asset bundles are regenerated in quick succession, including
      JS or template files, the client might try to reload whilst some of the
      bundles are still being regenerated, resulting in the client failing to
      load.
      
      This commit reduces the likelihood of this happening by debouncing
      live-reload notifications and makes a note of the issue.
      386e3552
    • Robert Knight's avatar
      Live reload dev tool for the Hypothesis client · 70f5676d
      Robert Knight authored
      This implements support and a test environment
      in which the Hypothesis client can live reload
      when scripts, styles etc. are changed.
      
      Live reloading when scripts change currently requires
      support from the hosting page.
      
      There are two parts to this:
      
       - A server which serves test pages
         with the Hypothesis client embedded and notifies
         it when front-end assets (styles, scripts) are changed.
      
         Test pages are served at http://localhost:3000/<any path>
         by default.
      
       - A small client script which connects to the server and
         listens for notifications of asset changes.
      
         When styles change it will reload styles for the page.
      
         When scripts or Angular templates change it will send a
         request to the top-level page to reload.
      
         This enables reloading to work when changing
         both the sidebar app and Annotator code but also avoids
         the need to manually unload the existing Annotator instance
         before reloading.
      70f5676d
  6. 04 Apr, 2016 2 commits
  7. 01 Apr, 2016 16 commits