<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -21,13 +21,14 @@ package fb.util {
 
     // Simple util builds an html link out of a string and a url
     public static function linkify(str:String, url:String,
-                                   bold:Boolean=true):String {
+                                   bold:Boolean=true,
+                                   color:String='3b5998'):String {
       if (empty(str)) return '';
       var link:String = '&lt;a href=&quot;' + url + '&quot;&gt;' + str + '&lt;/a&gt;';
       if (bold) {
         link = '&lt;b&gt;' + link + '&lt;/b&gt;';
       }
-      return colorize(link, '3b5998');
+      return colorize(link, color);
     }
 
     // Wrap some text in a font color tag</diff>
      <filename>fb/util/StringUtil.as</filename>
    </modified>
    <modified>
      <diff>@@ -13,35 +13,20 @@
   See the License for the specific language governing permissions and
   limitations under the License.
  --&gt;
-&lt;!-- This HBox acts shows who Likes an entry in the Stream.
-     There's exactly one of these in every NileRenderer --&gt;
-&lt;util:AnimatedCanvas xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
-                     xmlns:util=&quot;fbair.util.display.*&quot;
-                     animateOut=&quot;true&quot;
-                     animateOnce=&quot;true&quot; &gt;
+&lt;!-- Sentence of who likes this.
+     eg. &quot;Bobby, Mary, You and 14 others like this.&quot; --&gt;
+&lt;mx:Text xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
+         styleName=&quot;likeText&quot;
+         htmlText=&quot;{data.likes.likeText}&quot; &gt;
 
-  &lt;mx:HBox width=&quot;100%&quot;
-           styleName=&quot;likesRenderer&quot; &gt;
-
-    &lt;mx:Image source=&quot;@Embed('../../assets/like.png')&quot; /&gt;
-
-    &lt;!-- Sentence of who likes this.
-         eg. &quot;Bobby, Mary, You and 14 others like this.&quot; --&gt;
-    &lt;mx:Text id=&quot;likeText&quot;
-             htmlText=&quot;{data.likes.likeText}&quot;
-             width=&quot;100%&quot; /&gt;
-
-  &lt;/mx:HBox&gt;
   &lt;mx:Script&gt;&lt;![CDATA[
     import fb.FBEvent;
     import fb.util.StringUtil;
+    import fb.util.Output;
 
     import fbair.nile.Nile;
     import fbair.util.ProfileCache;
 
-    // Total explicit names provided (friends + others)
-    private var totalNames:int = 0;
-
     // &quot;data&quot; in this context is stream.likes
     override public function set data(new_data:Object):void {
       if (data &amp;&amp; data.likes.likeText)
@@ -56,7 +41,6 @@
         liked_ids = liked_ids.concat(data.likes.friends);
       if (data.likes.sample is Array)
         liked_ids = liked_ids.concat(data.likes.sample);
-      totalNames = liked_ids.length;
 
       // Fetch the names we need, or just update asap if none
       if (liked_ids.length &gt; 0) {
@@ -81,67 +65,64 @@
     // Function painstakingly applies the logic of
     // english to our &quot;Likes&quot; sentence.
     private function buildLikeText():String {
-      var remaining:int = totalNames;
+      var builtText:String = &quot;&quot;;
+      var likePeople:Array = new Array();
+
+      if (data.likes.friends is Array)
+        for each (var friend:int in data.likes.friends)
+          likePeople.push(friend);
+
+      if (data.likes.sample is Array)
+        for each (var sample:int in data.likes.sample)
+          likePeople.push(sample);
+
+      var numToShow:int = data.likes.user_likes ? 1 : 2;
+      if (likePeople.length &gt; numToShow)
+        likePeople = likePeople.slice(-numToShow);
+
+      var remaining:int = likePeople.length;
       if (data.likes.user_likes) remaining++;
       var others:int = data.likes.count - remaining;
       if (others &gt; 0) remaining++;
 
-      var builtText:String = &quot;&quot;;
-
       if (data.likes.user_likes) {
-        builtText += &quot;You&quot;;
         remaining--;
-        if (remaining == 1) builtText += &quot; and &quot;;
-        else if (remaining &gt;= 2) builtText += &quot;, &quot;;
-      }
-
-      if (data.likes.friends is Array) {
-        for each (var friend:int in data.likes.friends) {
-          remaining--;
-          if (ProfileCache.hasProfile(String(friend))) {
-            builtText += StringUtil.linkify(
-              ProfileCache.cache[String(friend)].name,
-              ProfileCache.cache[String(friend)].url);
-            if (remaining == 1) builtText += &quot; and &quot;;
-            else if (remaining &gt;= 2) builtText += &quot;, &quot;;
-          }
-        }
+        builtText += 'You';
+        if (remaining == 1) builtText += ' and ';
+        else if (remaining &gt;= 2) builtText += ', ';
       }
 
-      if (data.likes.sample is Array) {
-        for each (var sample:int in data.likes.sample) {
-          remaining--;
-          if (ProfileCache.hasProfile(String(sample))) {
-            builtText += StringUtil.linkify(
-              ProfileCache.cache[String(sample)].name,
-              ProfileCache.cache[String(sample)].url);
-            if (remaining == 1) builtText += &quot; and &quot;;
-            else if (remaining &gt;= 2) builtText += &quot;, &quot;;
-          }
+      for each (var person:int in likePeople) {
+        remaining--;
+        if (ProfileCache.hasProfile(String(person))) {
+          var prof:Object = ProfileCache.cache[String(person)];
+          builtText +=
+            StringUtil.linkify(prof.name, prof.url, false, '808080');
+          if (remaining == 1) builtText += ' and ';
+          else if (remaining &gt;= 2) builtText += ', ';
         }
       }
 
       if (others &gt; 0) {
         var othersText:String;
-        if (builtText != &quot;&quot;) {
-          othersText = others + &quot; other&quot; + (others == 1 ? &quot;&quot; : &quot;s&quot;);
-        } else {
-          othersText = others + (others == 1 ? &quot; person&quot; : &quot; people&quot;);
-        }
-        if (data.permalink) {
-          builtText += StringUtil.linkify(othersText, data.permalink);
-        } else {
+        if (builtText.length &gt; 0)
+          othersText = StringUtil.pluralize('other', others);
+        else
+          othersText = others + (others == 1 ? ' person' : ' people');
+
+        if (data.permalink)
+          builtText +=
+            StringUtil.linkify(othersText, data.permalink, false, '808080');
+        else
           builtText += othersText;
-        }
       }
 
-      if (totalNames == 1 &amp;&amp; others == 0 &amp;&amp; !data.user_likes) {
-        builtText += &quot; likes this.&quot;;
-      } else {
-        builtText += &quot; like this.&quot;;
-      }
+      if (likePeople.length == 1 &amp;&amp; others == 0 &amp;&amp; !data.user_likes)
+        builtText += ' likes this';
+      else
+        builtText += ' like this';
 
       return builtText;
     }
   ]]&gt;&lt;/mx:Script&gt;
-&lt;/util:AnimatedCanvas&gt;
+&lt;/mx:Text&gt;</diff>
      <filename>fbair/nile/renderers/LikesRenderer.mxml</filename>
    </modified>
    <modified>
      <diff>@@ -17,9 +17,9 @@
      use on facebook for getting and displaying likes and comments about
      stories, photos, and other content --&gt;
 &lt;mx:VBox xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
-                     xmlns:renderer=&quot;fbair.nile.renderers.*&quot;
-                     xmlns:util=&quot;fbair.util.display.*&quot;
-                     creationComplete=&quot;creationComplete(event)&quot; &gt;
+         xmlns:renderer=&quot;fbair.nile.renderers.*&quot;
+         xmlns:util=&quot;fbair.util.display.*&quot;
+         creationComplete=&quot;creationComplete(event)&quot; &gt;
 
   &lt;!-- We use these fades when replacing the preview with the renderer --&gt;
   &lt;mx:Fade id=&quot;fadeOut&quot;
@@ -32,9 +32,9 @@
 
   &lt;!-- The UFI Preview displays if there is any feedback to a stream
        story. Clicking the preview replaces it with the UFI renderer --&gt;
-  &lt;mx:HBox width=&quot;100%&quot;
-           id=&quot;ufiPreview&quot;
-           styleName=&quot;ufiPreview&quot; &gt;
+  &lt;util:FlowBox width=&quot;100%&quot;
+                id=&quot;ufiPreview&quot;
+                styleName=&quot;ufiPreview&quot; &gt;
 
     &lt;!-- Display number of comments, or add a comment --&gt;
     &lt;util:FBButton autoStyle=&quot;true&quot;
@@ -64,19 +64,10 @@
     &lt;/util:FBButton&gt;
 
     &lt;!-- Show how many people like this in the preview --&gt;
-    &lt;mx:HBox id=&quot;likesPreview&quot;
-             styleName=&quot;likesPreview&quot;
-             visible=&quot;{data.likes.count &gt; 0}&quot;
-             includeInLayout=&quot;{data.likes.count &gt; 0}&quot;
-             showEffect=&quot;fadeIn&quot;
-             click=&quot;{ufiMode = ufiMode == UFI_PREVIEW ?
-                     UFI_DETAIL : UFI_PREVIEW}&quot; &gt;
-      &lt;util:LinkLabel styleName=&quot;likesPreviewLabel&quot;
-                    text=&quot;{likeTitle(data.likes.count,
-                           data.likes.user_likes)}&quot; /&gt;
-    &lt;/mx:HBox&gt;
-
-  &lt;/mx:HBox&gt;
+    &lt;renderer:LikesRenderer id=&quot;likesRenderer&quot;
+                            maxWidth=&quot;{width}&quot;
+                            data=&quot;{data}&quot; /&gt;
+  &lt;/util:FlowBox&gt;
 
   &lt;!-- The UFI renderer displays the actual likes and comments --&gt;
   &lt;util:AnimatedCanvas id=&quot;ufiDetail&quot;
@@ -89,12 +80,7 @@
     &lt;mx:VBox width=&quot;100%&quot;
              id=&quot;ufiRenderers&quot;
              styleName=&quot;ufiRenderers&quot; &gt;
-      &lt;!-- These renderers show the Likes and Comments for this entry --&gt;
-      &lt;renderer:LikesRenderer id=&quot;likesRenderer&quot;
-                              width=&quot;100%&quot;
-                              data=&quot;{data}&quot;
-                              animateIn=&quot;{ufiRevealed}&quot; /&gt;
-
+      &lt;!-- These renderers show the Comments for this entry --&gt;
       &lt;renderer:CommentsRenderer id=&quot;commentsRenderer&quot;
                                  width=&quot;100%&quot;
                                  data=&quot;{data}&quot; /&gt;
@@ -167,13 +153,6 @@
         });
     }
 
-    private function likeTitle(number:int, userLikes:Boolean):String {
-      if (number == 1 &amp;&amp; userLikes)
-        return 'You like this';
-      return number + ((number == 1) ? ' person likes this'
-                                     : ' people like this');
-    }
-
     private function commentTitle(comments:Number, mode:int):String {
       if (comments == 0) {
         return mode == UFI_PREVIEW ? 'Comment' : 'Cancel';
@@ -253,7 +232,7 @@
     // Called when we deleted a comment
     private function commentRemoved(event:FBEvent):void {
       // If not revealed, or not us, then don't care
-      if (!commentsRenderer.revealed || 
+      if (!commentsRenderer.revealed ||
           event.data.post_id != data.post_id) return;
 
       commentsRenderer.removeLocalComment(event.data.id);
@@ -284,7 +263,7 @@
 
       // Mark latest update
       commentsRenderer.markLatestUpdate();
-      
+
       // Reveal us, if needed
       if (data.filter_key == NileContainer.CurrentFilter)
         ufiMode = UFI_DETAIL;</diff>
      <filename>fbair/nile/renderers/UFI.mxml</filename>
    </modified>
    <modified>
      <diff>@@ -103,6 +103,12 @@
   paddingBottom: 2;
 }
 
+.likeText {
+  paddingTop: 2;
+  paddingLeft: 2;
+  color: #aaaaaa;
+}
+
 .mediaImage {
   bottom: 1;
   top: 1;
@@ -180,6 +186,7 @@
   paddingTop: -6;
   paddingLeft: -6;
   horizontalGap: -2;
+  verticalGap: -4;
 }
 
 .ufiRenderers {</diff>
      <filename>fbair/styles/renderers.css</filename>
    </modified>
    <modified>
      <diff>@@ -18,12 +18,14 @@ package fbair.util.display {
     private var _childrenChanged:Boolean = false;
 
     public function FlowBox() {
-      this.addEventListener(ResizeEvent.RESIZE, resizeHanlder);
+      this.addEventListener(ResizeEvent.RESIZE, resizeHandler);
     }
 
     // If this component is resized, the child
     //   components must be laid out again
-    private function resizeHanlder(e:Event):void {
+    private function resizeHandler(event:Event):void {
+      //invalidateSize();
+      validateNow();
       relayoutChildren();
     }
 
@@ -144,7 +146,7 @@ package fbair.util.display {
 
     // Flag that the children of this control have changed,
     //   and should be redrawn at the next convenient time
-    private function relayoutChildren():void {
+    public function relayoutChildren(event:Event = null):void {
       _childrenChanged = true;
       invalidateProperties();
     }
@@ -174,37 +176,43 @@ package fbair.util.display {
     public override function addChild(child:DisplayObject):DisplayObject {
       _children.addItem(child);
       relayoutChildren();
+      child.addEventListener(ResizeEvent.RESIZE, relayoutChildren);
       return child;
     }
-    
+
     override public function addChildAt(child:DisplayObject, index:int):DisplayObject {
       _children.addItemAt(child, index);
       relayoutChildren();
+      child.addEventListener(ResizeEvent.RESIZE, relayoutChildren);
       return child;
     }
-    
+
     override public function removeChild(child:DisplayObject):DisplayObject {
       var tmp:DisplayObject = _children.removeItemAt(
         _children.getItemIndex(child)) as DisplayObject;
+      tmp.removeEventListener(ResizeEvent.RESIZE, relayoutChildren);
       relayoutChildren();
       return tmp;
     }
-    
+
     override public function removeChildAt(index:int):DisplayObject {
       var tmp:DisplayObject = _children.removeItemAt(index) as DisplayObject;
+      tmp.removeEventListener(ResizeEvent.RESIZE, relayoutChildren);
       relayoutChildren();
       return tmp;
     }
-    
+
     override public function removeAllChildren():void {
+      for each (var child:DisplayObject in _children)
+        child.removeEventListener(ResizeEvent.RESIZE, relayoutChildren);
       _children.removeAll();
       relayoutChildren();
     }
-    
+
     override public function getChildren():Array {
       return _children.toArray();
     }
-    
+
     override public function getChildIndex(child:DisplayObject):int {
       return _children.getItemIndex(child);
     }
@@ -219,8 +227,10 @@ package fbair.util.display {
         var tmp:Array = value as Array;
         _children = new ArrayCollection();
 
-        for each (var child:DisplayObject in tmp)
-          _children.addItem( child );
+        for each (var child:DisplayObject in tmp) {
+          _children.addItem(child);
+          child.addEventListener(ResizeEvent.RESIZE, relayoutChildren);
+        }
       }
       relayoutChildren();
     }</diff>
      <filename>fbair/util/display/FlowBox.as</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>0b9e3fa457d87ff086bc8faa753447062cfd5d29</id>
    </parent>
  </parents>
  <author>
    <name>Lee Byron</name>
    <email>leebyron@lbyron.wan</email>
  </author>
  <url>http://github.com/jubishop/Facebook-for-Adobe-AIR/commit/fa25a7b8e40027597a29af5cb2cee4d432f9e960</url>
  <id>fa25a7b8e40027597a29af5cb2cee4d432f9e960</id>
  <committed-date>2009-05-28T01:51:48-07:00</committed-date>
  <authored-date>2009-05-28T01:51:48-07:00</authored-date>
  <message>more subtle likes renderer. not quite perfect yet, but getting there</message>
  <tree>cdc4fd5e813bbf687eec7e6a78bcef822818cd2e</tree>
  <committer>
    <name>Lee Byron</name>
    <email>leebyron@lbyron.wan</email>
  </committer>
</commit>
