fix howers which were accidently broken

This commit is contained in:
Misko Hevery 2010-07-22 15:32:57 -07:00
parent 849a05b5a5
commit 2987f7f705
7 changed files with 96 additions and 29 deletions

View file

@ -0,0 +1,45 @@
body {
background: -webkit-gradient(linear, left top, left 400, from(#1C4070), to(#fff));
background-repeat: no-repeat;
margin: 0px;
}
.bar {
border-top: 1px solid white;
border-bottom: 1px solid black;
text-align: right;
background: -webkit-gradient(linear, left top, left bottom, from(#CCC), to(#888));
-webkit-background-origin: padding; -webkit-background-clip: content;
}
.bar button {
margin: 5px;
}
.bar span {
float: left;
font-family: monospace;
font-size: 1.5em;
color: black;
}
ul.buzz {
list-style: none;
padding: 5px;
margin: 0;
}
ul.buzz > li {
border: 1px solid yellow;
margin: 5px;
padding: 0;
}
ul.buzz > li > h1 {
border: 1px solid yellow;
margin: 0;
}
ul.buzz > li > div {
border: 1px solid yellow;
margin: 0;
}

View file

@ -2,28 +2,36 @@
<html xmlns:ng="http://angularjs.org">
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
<!--script type="text/javascript" src="http://angularjs.org/ng/js/angular-debug.js#autobind"></script-->
<script type="text/javascript" src="../../src/angular-bootstrap.js#autobind"></script>
<script type="text/javascript" src="buzz.js"></script>
<link rel="stylesheet" type="text/css" href="style.css"/>
<link rel="stylesheet" type="text/css" href="buzz.css"/>
</head>
<body ng:init="$window.$root = this" ng:controller="BuzzController">
<div class="bar">
<input type="text" name="userId"/>
<span>&lt;angular/&gt; Buzz</span>
<input type="text" name="userId" ng:required/>
<button ng:click="$location.hashPath = userId">fetch</button>
</div>
<ul>
<ul class="buzz">
<li ng:repeat="item in activities.data.items">
<img src="{{item.actor.thumbnailUrl}}"/>
<a href="{{item.actor.profileUrl}}">{{item.actor.name}}</a>
{{item.object.content | html}}
<a href="">Replies: {{item.links.replies[0].count}}</a>
<ul>
<li ng:repeat="reply in item.replies.items">
<img src="{{reply.actor.thumbnailUrl}}"/>
<a href="{{reply.actor.profileUrl}}">{{reply.actor.name}}</a>
{{reply.content | html}}
</li>
</ul>
<h1>
<img src="{{item.actor.thumbnailUrl}}"/>
<a href="{{item.actor.profileUrl}}">{{item.actor.name}}</a>
</h1>
<div>
{{item.object.content | html}}
<a href="#" ng:click="expandReplies(item)">Replies: {{item.links.replies[0].count}}</a>
</div>
<my:expand expand="item.replies.show">
<ul>
<li ng:repeat="reply in item.replies.data.items">
<img src="{{reply.actor.thumbnailUrl}}"/>
<a href="{{reply.actor.profileUrl}}">{{reply.actor.name}}</a>
{{reply.content | html}}
</li>
</ul>
</my:expand>
</li>
</ul>
</body>

View file

@ -15,5 +15,32 @@ BuzzController.prototype = {
userChange: function(){
this.userId = this.$location.hashPath;
this.activities = this.Activity.get({userId:this.userId});
},
expandReplies: function(activity) {
var self = this;
if (activity.replies) {
activity.replies.show = !activity.replies.show;
} else {
activity.replies = this.Activity.replies({userId:this.userId, activityId:activity.id}, function(){
activity.replies.show = true;
});
}
}
};
angular.widget('my:expand', function(element){
element.css('display', 'block');
this.descend(true);
return function(element) {
element.hide();
var watch = element.attr('expand');
this.$watch(watch, function(value){
if (value) {
element.delay(0).slideDown('slow');
} else {
element.slideUp('slow');
}
});
};
});

View file

@ -22,6 +22,7 @@ function Browser(location, document, head) {
this.location = location;
this.document = document;
this.body = jqLite(document[0].body);
this.head = head;
this.idCounter = 0;
}

View file

@ -161,8 +161,6 @@ angularWidget("@ng:repeat", function(expression, element){
valueIdent = match[3] || match[1];
keyIdent = match[2];
if (isUndefined(this.$eval(rhs))) this.$set(rhs, []);
var children = [], currentScope = this;
this.$onEval(function(){
var index = 0, childCount = children.length, childScope, lastElement = reference,

View file

@ -27,7 +27,7 @@ BinderTest.prototype.testChangingTextfieldUpdatesModel = function(){
state.scope.$eval();
assertEquals('abc', state.scope.model.price);
};
BinderTest.prototype.testChangingTextareaUpdatesModel = function(){
var c = this.compile('<textarea name="model.note">abc</textarea>');
c.scope.$eval();
@ -472,13 +472,6 @@ BinderTest.prototype.testRepeaterShouldBindInputsDefaults = function () {
assertEquals("misko", c.scope.$eval('items[1].name'));
};
BinderTest.prototype.testRepeaterShouldCreateArray = function () {
var c = this.compile('<input value="123" name="item.name" ng:repeat="item in items">');
c.scope.$eval();
assertEquals(0, c.scope.$get('items').length);
};
BinderTest.prototype.testShouldTemplateBindPreElements = function () {
var c = this.compile('<pre>Hello {{name}}!</pre>');
c.scope.$set("name", "World");

View file

@ -140,11 +140,6 @@ describe("directives", function(){
expect(element.text()).toEqual('misko:swe;shyam:set;');
});
it('should set ng:repeat to [] if undefinde', function(){
var scope = compile('<ul><li ng:repeat="item in items"></li></ul>');
expect(scope.items).toEqual([]);
});
it('should error on wrong parsing of ng:repeat', function(){
var scope = compile('<ul><li ng:repeat="i dont parse"></li></ul>');
var log = "";