public
Description: Github flash badge
Homepage: http://spinach.andascarygoat.com/tags/badjo
Clone URL: git://github.com/zmack/badjo.git
Search Repo:
Added extended info. Description basically :<
zmack (author)
Sat May 03 12:03:17 -0700 2008
commit  02766cd496af4f22614c32df21f891c4331d11a5
tree    7b4161af87e2671291657b1dcfa330e1639f0e2a
parent  d78f7e67afd085e5a2d721e31665499ac9b129a8
...
3
4
5
 
 
 
6
7
8
...
69
70
71
72
73
 
 
 
 
 
 
74
75
76
...
105
106
107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
109
110
...
3
4
5
6
7
8
9
10
11
...
72
73
74
 
 
75
76
77
78
79
80
81
82
83
...
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
0
@@ -3,6 +3,9 @@
0
   import flash.display.Sprite;
0
   import flash.display.DisplayObject;
0
   import flash.display.LoaderInfo;
0
+ import flash.text.TextField;
0
+ import flash.text.TextFieldAutoSize;
0
+ import flash.text.StyleSheet;
0
   import flash.net.URLRequest;
0
   import skins.GithubBadgeSkin;
0
   import dataexchange.*;
0
@@ -69,8 +72,12 @@
0
 
0
       _pl.setHeader({image: SpriteWrapper(loadAvatar('http://www.gravatar.com/avatar/' + MD5.hash(user.email || '') + '?s=40')), text: user.name || user.login });
0
       user.repositories.forEach( function(repo:Object, index:uint, arr:Array):void {
0
- _pl.addButton({image: SpriteWrapper(new GithubBadgeSkin.PublicProject()), text: repo.name });
0
- });
0
+ _pl.addButton({
0
+ image: SpriteWrapper(new GithubBadgeSkin.PublicProject()),
0
+ text: repo.name,
0
+ extended_content: SpriteWrapper(this.createTextField(repo.description))
0
+ });
0
+ }, this);
0
 
0
       addChild(_pl);
0
     }
0
@@ -105,6 +112,26 @@
0
       var loader:Loader = new Loader();
0
       loader.load(request);
0
       return loader;
0
+ }
0
+
0
+ private function createStyleSheet():StyleSheet {
0
+ var style:StyleSheet = new StyleSheet();
0
+
0
+ style.parseCSS('p { font-family: "Trebuchet MS"; font-size: 10px; color: #000000; background-color: #FF00FF; }');
0
+ return style;
0
+ }
0
+
0
+ private function createTextField(text:String):TextField {
0
+ var textField:TextField = new TextField();
0
+
0
+ textField.width = 200;
0
+ textField.height = 0;
0
+ textField.autoSize = TextFieldAutoSize.LEFT;
0
+ textField.styleSheet = this.createStyleSheet();
0
+ textField.selectable = false;
0
+ textField.htmlText = '<p>' + text + '</p>';
0
+
0
+ return textField;
0
     }
0
   }
0
 }
...
19
20
21
 
22
23
24
...
28
29
30
 
 
 
31
32
33
34
...
36
37
38
39
40
 
41
42
 
43
44
45
46
47
48
49
...
55
56
57
58
59
60
61
62
63
64
65
 
 
66
67
 
68
69
 
 
 
 
 
70
 
 
 
 
 
71
72
73
74
...
81
82
83
84
 
85
 
86
87
88
89
90
...
97
98
99
100
 
101
102
103
 
104
 
 
105
106
107
108
109
110
...
111
112
113
114
 
115
116
117
118
119
120
 
121
122
123
 
 
 
 
124
125
126
127
128
129
 
 
 
 
 
 
 
 
 
130
131
132
...
19
20
21
22
23
24
25
...
29
30
31
32
33
34
35
36
37
38
...
40
41
42
 
 
43
44
 
45
46
47
48
49
50
51
52
...
58
59
60
 
61
62
63
64
65
 
 
66
67
68
 
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
...
93
94
95
 
96
97
98
99
100
101
102
103
...
110
111
112
 
113
114
 
 
115
116
117
118
119
120
121
122
123
124
...
125
126
127
 
128
129
130
131
132
133
 
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
0
@@ -19,6 +19,7 @@
0
     private var _textField:TextField;
0
     private var _style:StyleSheet;
0
     private var _resizeHeight:uint;
0
+ private var _extendedContainer:Sprite;
0
 
0
     public function PickleButton(options:Object) {
0
       this.itemWidth = options.width || 200;
0
@@ -28,6 +29,9 @@
0
       this._image = options.image || new Sprite();
0
       this._textField = this.createTextField();
0
       this._textField.htmlText = '<p>' + (options.text || 'No text specified') + '</p>';
0
+ if ( options.extended_content != null ) {
0
+ this._extendedContainer = options.extended_content;
0
+ }
0
 
0
       this.resizeComponents();
0
       this.drawBackground();
0
0
@@ -36,10 +40,9 @@
0
       this.addEvents();
0
     }
0
 
0
- public function drawBackground(color:uint = 0xFF00FF):void {
0
- color = this._backgroundColor;
0
+ public function drawBackground():void {
0
       this.graphics.clear();
0
- this.graphics.beginFill(color, 0.4);
0
+ this.graphics.beginFill(this._backgroundColor, 0.4);
0
       this.graphics.drawRoundRect(0, 0, this.itemWidth, this.itemHeight, 15, 15);
0
     }
0
 
0
0
0
0
0
@@ -55,19 +58,28 @@
0
     }
0
 
0
     private function onMouseOut(e:MouseEvent):void {
0
- trace("And we're out");
0
       this._backgroundColor = PickleButton.NORMAL_COLOR;
0
       this.drawBackground();
0
     }
0
 
0
     private function onClick(e:MouseEvent):void {
0
- if ( this.itemHeight == 50 ) {
0
- resizeTo();
0
+ if ( this.itemHeight == this.getExtendedHeight() ) {
0
+ this.retract()
0
       } else {
0
- resizeTo(50);
0
+ this.extend();
0
       }
0
     }
0
+
0
+ private function retract():void {
0
+ this.hideExtended();
0
+ this.resizeTo();
0
+ }
0
 
0
+ private function extend():void {
0
+ this.resizeTo(this.getExtendedHeight());
0
+ this.displayExtended();
0
+ }
0
+
0
     private function createTextField():TextField {
0
       var text:TextField = new TextField();
0
       
0
0
@@ -81,8 +93,9 @@
0
       return text;
0
     }
0
 
0
- private function redraw():void {
0
+ private function redraw(withParent:Boolean = false):void {
0
       this.drawBackground();
0
+ if ( withParent ) (this.parentItem as ProjectList).redraw();
0
     }
0
 
0
     private function resizeTo(height:uint = 0):void {
0
0
0
@@ -97,11 +110,12 @@
0
     }
0
 
0
     private function resizer(e:Event):void {
0
- if ( this.itemHeight != this._resizeHeight ) {
0
+ if ( this.itemHeight < this._resizeHeight ) {
0
         this.itemHeight += ( (itemHeight < this._resizeHeight)? 2 : -2 );
0
- this.drawBackground();
0
- (this.parentItem as ProjectList).redraw();
0
+ this.redraw(true);
0
       } else {
0
+ this.itemHeight = this._resizeHeight;
0
+ this.redraw(true);
0
         this.removeEventListener(Event.ENTER_FRAME, this.resizer);      
0
         trace("Removed listener");
0
       }
0
0
0
0
@@ -111,22 +125,35 @@
0
       this.itemHeight = this.getBaseHeight();
0
       this._textField.x = this._image.width + this.padding;
0
       this._textField.width = this.itemWidth - this._image.width - this.padding;
0
- this._textField.height = this.itemHeight - this.padding * 1;
0
+ this._textField.height = this.itemHeight - this.padding;
0
 
0
       this._image.x = this.padding;
0
       this._image.y = this.padding;
0
     }
0
 
0
- private function getBaseHeight() {
0
+ private function getBaseHeight():uint {
0
       return this._image.height + this.padding * 2;
0
     }
0
 
0
+ private function getExtendedHeight():uint {
0
+ return this.getBaseHeight() + this._extendedContainer.height + this.padding;
0
+ }
0
+
0
     private function createStyleSheet():StyleSheet {
0
       var style:StyleSheet = new StyleSheet();
0
 
0
       style.parseCSS('p { font-family: "Trebuchet MS"; font-size: 11px; color: #000000; background-color: #FF00FF; }');
0
 
0
       return style;
0
+ }
0
+
0
+ private function displayExtended():void {
0
+ this.addChild(this._extendedContainer);
0
+ this._extendedContainer.y = this.getBaseHeight();
0
+ }
0
+
0
+ private function hideExtended():void {
0
+ this._extendedContainer.parent.removeChild(this._extendedContainer);
0
     }
0
 
0
   }
...
41
42
43
44
 
45
46
47
...
53
54
55
56
 
57
58
59
...
41
42
43
 
44
45
46
47
...
53
54
55
 
56
57
58
59
0
@@ -41,7 +41,7 @@
0
       this._maximum_y = AVATAR_SIZE + this.bottomPadding;
0
       this._items.forEach( function(item:PickleButton, index:uint, arr:Array):void {
0
         this.positionButton(item);
0
- this._maximum_y = item.y + item.height;
0
+ this._maximum_y = item.y + item.itemHeight;
0
       }, this);
0
       this.drawBackground();
0
     }
0
@@ -53,7 +53,7 @@
0
       this._container.addChild(button)
0
       this.positionButton(button);
0
 
0
- this._maximum_y = button.y + button.height;
0
+ this._maximum_y = button.y + button.itemHeight;
0
       button.x = this.lateralPadding;
0
 
0
       trace(button.y);
...
40
41
42
43
 
44
45
46
...
40
41
42
 
43
44
45
46
0
@@ -40,7 +40,7 @@
0
       dispatchEvent(newEvent);
0
     }
0
     
0
- private function dataError(event:Event):void {
0
+ private function dataError(e:Event):void {
0
       var newEvent:GatewayEvent = new GatewayEvent(GatewayEvent.DATA_RECEIVED, null, false);
0
       dispatchEvent(newEvent);
0
     }

Comments

    No one has commented yet.