Commit bdd7bfea authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Merge branch 'master' into doc-tags

parents 84ad05fa a7534820
Loading
Loading
Loading
Loading
+3 −27
Original line number Diff line number Diff line
@@ -26,36 +26,12 @@ module JsDuck

      # Adds small star to new classes in the current version.
      def render_new_label(cls)
        if cls[:new]
          "&nbsp;<span class='new-class' title='New class'>#{stars(1)}</span>"
        else
          n = new_members_count(cls)
          if n > 0
            title = "#{n} new member#{(n>1) ? 's' : ''}"
            "&nbsp;<span class='new-members' title='#{title}'>#{stars(n)}</span>"
        if cls[:meta][:new]
          "&nbsp;<span class='new-class' title='New class'>&#9733;</span>"
        else
          ""
        end
      end
      end

      # Produces string of n stars.
      # First 3 stars are rendered as "<unicode-star>", the following as "+".
      # At max 15 stars are rendered.
      def stars(n)
        if n > 15
          stars(3) + ("+" * (15-3))
        elsif n > 3
          stars(3) + ("+" * (n-3))
        else
          "&#9733;" * n
        end
      end

      # Returns number of new members the class has in the current version
      def new_members_count(cls)
        cls.find_members(:local => true).find_all {|m| m[:new] && !m[:private] }.length
      end

    end

+4 −6
Original line number Diff line number Diff line
@@ -34,12 +34,10 @@
    // A list of links
    .links {
      margin-left: 1.5em;
      .new-class, .new-members {
      .new-class {
        @include border-radius(2px);
        padding: 0 0.5em;
        background: #F5D833; }
      .new-members {
        background: #F5D833;
        position: relative;
        top: -3px;
        font-size: 5px; } } } }
        top: -2px;
        font-size: 7px; } } } }