Skip to content

Commit 2987f7f

Browse files
committed
fix howers which were accidently broken
1 parent 849a05b commit 2987f7f

7 files changed

Lines changed: 96 additions & 29 deletions

File tree

example/buzz/buzz.css

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
body {
2+
background: -webkit-gradient(linear, left top, left 400, from(#1C4070), to(#fff));
3+
background-repeat: no-repeat;
4+
margin: 0px;
5+
}
6+
7+
.bar {
8+
border-top: 1px solid white;
9+
border-bottom: 1px solid black;
10+
text-align: right;
11+
background: -webkit-gradient(linear, left top, left bottom, from(#CCC), to(#888));
12+
-webkit-background-origin: padding; -webkit-background-clip: content;
13+
}
14+
.bar button {
15+
margin: 5px;
16+
}
17+
18+
.bar span {
19+
float: left;
20+
font-family: monospace;
21+
font-size: 1.5em;
22+
color: black;
23+
}
24+
25+
ul.buzz {
26+
list-style: none;
27+
padding: 5px;
28+
margin: 0;
29+
}
30+
31+
ul.buzz > li {
32+
border: 1px solid yellow;
33+
margin: 5px;
34+
padding: 0;
35+
}
36+
37+
ul.buzz > li > h1 {
38+
border: 1px solid yellow;
39+
margin: 0;
40+
}
41+
42+
ul.buzz > li > div {
43+
border: 1px solid yellow;
44+
margin: 0;
45+
}

example/buzz/buzz.html

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,36 @@
22
<html xmlns:ng="http://angularjs.org">
33
<head>
44
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
5+
<!--script type="text/javascript" src="http://angularjs.org/ng/js/angular-debug.js#autobind"></script-->
56
<script type="text/javascript" src="../../src/angular-bootstrap.js#autobind"></script>
67
<script type="text/javascript" src="buzz.js"></script>
7-
<link rel="stylesheet" type="text/css" href="style.css"/>
8+
<link rel="stylesheet" type="text/css" href="buzz.css"/>
89
</head>
910
<body ng:init="$window.$root = this" ng:controller="BuzzController">
1011
<div class="bar">
11-
<input type="text" name="userId"/>
12+
<span>&lt;angular/&gt; Buzz</span>
13+
<input type="text" name="userId" ng:required/>
1214
<button ng:click="$location.hashPath = userId">fetch</button>
1315
</div>
14-
<ul>
16+
<ul class="buzz">
1517
<li ng:repeat="item in activities.data.items">
16-
<img src="{{item.actor.thumbnailUrl}}"/>
17-
<a href="{{item.actor.profileUrl}}">{{item.actor.name}}</a>
18-
{{item.object.content | html}}
19-
<a href="">Replies: {{item.links.replies[0].count}}</a>
20-
<ul>
21-
<li ng:repeat="reply in item.replies.items">
22-
<img src="{{reply.actor.thumbnailUrl}}"/>
23-
<a href="{{reply.actor.profileUrl}}">{{reply.actor.name}}</a>
24-
{{reply.content | html}}
25-
</li>
26-
</ul>
18+
<h1>
19+
<img src="{{item.actor.thumbnailUrl}}"/>
20+
<a href="{{item.actor.profileUrl}}">{{item.actor.name}}</a>
21+
</h1>
22+
<div>
23+
{{item.object.content | html}}
24+
<a href="#" ng:click="expandReplies(item)">Replies: {{item.links.replies[0].count}}</a>
25+
</div>
26+
<my:expand expand="item.replies.show">
27+
<ul>
28+
<li ng:repeat="reply in item.replies.data.items">
29+
<img src="{{reply.actor.thumbnailUrl}}"/>
30+
<a href="{{reply.actor.profileUrl}}">{{reply.actor.name}}</a>
31+
{{reply.content | html}}
32+
</li>
33+
</ul>
34+
</my:expand>
2735
</li>
2836
</ul>
2937
</body>

example/buzz/buzz.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,32 @@ BuzzController.prototype = {
1515
userChange: function(){
1616
this.userId = this.$location.hashPath;
1717
this.activities = this.Activity.get({userId:this.userId});
18+
},
19+
20+
expandReplies: function(activity) {
21+
var self = this;
22+
if (activity.replies) {
23+
activity.replies.show = !activity.replies.show;
24+
} else {
25+
activity.replies = this.Activity.replies({userId:this.userId, activityId:activity.id}, function(){
26+
activity.replies.show = true;
27+
});
28+
}
1829
}
1930
};
31+
32+
angular.widget('my:expand', function(element){
33+
element.css('display', 'block');
34+
this.descend(true);
35+
return function(element) {
36+
element.hide();
37+
var watch = element.attr('expand');
38+
this.$watch(watch, function(value){
39+
if (value) {
40+
element.delay(0).slideDown('slow');
41+
} else {
42+
element.slideUp('slow');
43+
}
44+
});
45+
};
46+
});

src/Browser.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ function Browser(location, document, head) {
2222

2323
this.location = location;
2424
this.document = document;
25+
this.body = jqLite(document[0].body);
2526
this.head = head;
2627
this.idCounter = 0;
2728
}

src/directives.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,6 @@ angularWidget("@ng:repeat", function(expression, element){
161161
valueIdent = match[3] || match[1];
162162
keyIdent = match[2];
163163

164-
if (isUndefined(this.$eval(rhs))) this.$set(rhs, []);
165-
166164
var children = [], currentScope = this;
167165
this.$onEval(function(){
168166
var index = 0, childCount = children.length, childScope, lastElement = reference,

test/BinderTest.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ BinderTest.prototype.testChangingTextfieldUpdatesModel = function(){
2727
state.scope.$eval();
2828
assertEquals('abc', state.scope.model.price);
2929
};
30-
30+
3131
BinderTest.prototype.testChangingTextareaUpdatesModel = function(){
3232
var c = this.compile('<textarea name="model.note">abc</textarea>');
3333
c.scope.$eval();
@@ -472,13 +472,6 @@ BinderTest.prototype.testRepeaterShouldBindInputsDefaults = function () {
472472
assertEquals("misko", c.scope.$eval('items[1].name'));
473473
};
474474

475-
BinderTest.prototype.testRepeaterShouldCreateArray = function () {
476-
var c = this.compile('<input value="123" name="item.name" ng:repeat="item in items">');
477-
c.scope.$eval();
478-
479-
assertEquals(0, c.scope.$get('items').length);
480-
};
481-
482475
BinderTest.prototype.testShouldTemplateBindPreElements = function () {
483476
var c = this.compile('<pre>Hello {{name}}!</pre>');
484477
c.scope.$set("name", "World");

test/directivesSpec.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,6 @@ describe("directives", function(){
140140
expect(element.text()).toEqual('misko:swe;shyam:set;');
141141
});
142142

143-
it('should set ng:repeat to [] if undefinde', function(){
144-
var scope = compile('<ul><li ng:repeat="item in items"></li></ul>');
145-
expect(scope.items).toEqual([]);
146-
});
147-
148143
it('should error on wrong parsing of ng:repeat', function(){
149144
var scope = compile('<ul><li ng:repeat="i dont parse"></li></ul>');
150145
var log = "";

0 commit comments

Comments
 (0)