added buzz demo, fix undefined() -> undefined

This commit is contained in:
Misko Hevery 2010-07-23 10:48:18 -07:00
parent 2987f7f705
commit 8015e09e38
4 changed files with 87 additions and 24 deletions

View file

@ -1,45 +1,89 @@
body { body {
background: -webkit-gradient(linear, left top, left 400, from(#1C4070), to(#fff)); background: -webkit-gradient(linear, left top, left 100, from(#bbb), to(#fff));
background-repeat: no-repeat; background-repeat: no-repeat;
margin: 0px; margin: 0px;
font-family: sans-serif;
font-size: 12px;
} }
.bar { body > div {
border-top: 1px solid white; border-top: 1px solid white;
border-bottom: 1px solid black; border-bottom: 1px solid black;
text-align: right; text-align: center;
background: -webkit-gradient(linear, left top, left bottom, from(#CCC), to(#888)); background: -webkit-gradient(linear, left top, left bottom, from(#CCC), to(#888));
-webkit-background-origin: padding; -webkit-background-clip: content; -webkit-background-origin: padding; -webkit-background-clip: content;
} }
.bar button { body > div button {
margin: 5px; margin: 5px;
} }
.bar span { body > div span:FIRST-CHILD {
float: left; float: left;
font-family: monospace; font-family: monospace;
font-size: 1.5em; font-size: 1.5em;
color: black; color: black;
padding: 2px 5px;
} }
ul.buzz { body > div span:last-child {
float: right;
}
ul {
list-style: none; list-style: none;
padding: 5px; padding: 10px;
margin: 0; margin: 0;
} }
ul.buzz > li { body > ul > li {
border: 1px solid yellow; border: 1px solid black;
margin: 5px; margin: 15px 5px;
padding: 0; padding: 0;
-webkit-box-shadow: 5px 5px 5px #888;
} }
ul.buzz > li > h1 { body > ul > li > h1 {
border: 1px solid yellow;
margin: 0; margin: 0;
background: -webkit-gradient(linear, left top, left bottom, from(#ddd), to(#999));
font-size: 13px;
border-bottom: 1px solid black;
} }
ul.buzz > li > div { h1 > img,
border: 1px solid yellow; li > img {
margin: 0; max-height: 30px;
max-width: 30px;
vertical-align: middle;
padding: 3px;
} }
a > img {
margin-right: 5px;
margin-top: 5px;
}
body > ul > li > h1 > a:last-child {
float: right;
margin: 10px;
}
body > ul > li > div {
background-color: white;
background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#ddd));
margin: 0;
padding: 10px;
}
body > ul > li ul {
margin: 0;
padding: 0;
margin-left: 5px;
border-left: 5px solid lightgray;
}
body > ul > li ul > li {
margin: 0;
padding: 10px;
background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#ddd));
}

View file

@ -2,32 +2,44 @@
<html xmlns:ng="http://angularjs.org"> <html xmlns:ng="http://angularjs.org">
<head> <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://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="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> <script type="text/javascript" src="buzz.js"></script>
<link rel="stylesheet" type="text/css" href="http://angularjs.org/ng/css/angular.css"/>
<link rel="stylesheet" type="text/css" href="buzz.css"/> <link rel="stylesheet" type="text/css" href="buzz.css"/>
</head> </head>
<body ng:init="$window.$root = this" ng:controller="BuzzController"> <body ng:init="$window.$root = this" ng:controller="BuzzController">
<div class="bar"> <div>
<span>&lt;angular/&gt; Buzz</span> <span>&lt;angular/&gt; Buzz</span>
<input type="text" name="userId" ng:required/> <span>
<button ng:click="$location.hashPath = userId">fetch</button> filter:
<input type="text" name="filterText"/>
</span>
<span>
user:
<input type="text" name="userId" ng:required/>
<button ng:click="$location.hashPath = userId">fetch</button>
</span>
</div> </div>
<ul class="buzz"> <ul>
<li ng:repeat="item in activities.data.items"> <li ng:repeat="item in activities.data.items.$filter(filterText)">
<h1> <h1>
<img src="{{item.actor.thumbnailUrl}}"/> <img src="{{item.actor.thumbnailUrl}}"/>
<a href="{{item.actor.profileUrl}}">{{item.actor.name}}</a> <a href="{{item.actor.profileUrl}}">{{item.actor.name}}</a>
<a href="#" ng:click="expandReplies(item)">Replies: {{item.links.replies[0].count}}</a>
</h1> </h1>
<div> <div>
{{item.object.content | html}} {{item.object.content | html}}
<a href="#" ng:click="expandReplies(item)">Replies: {{item.links.replies[0].count}}</a> <div>
<a href="{{attachment.links.enclosure[0].href}}" ng:repeat="attachment in item.object.attachments">
<img src="{{attachment.links.preview[0].href}}"/>
</a>
</div>
</div> </div>
<my:expand expand="item.replies.show"> <my:expand expand="item.replies.show">
<ul> <ul>
<li ng:repeat="reply in item.replies.data.items"> <li ng:repeat="reply in item.replies.data.items">
<img src="{{reply.actor.thumbnailUrl}}"/> <img src="{{reply.actor.thumbnailUrl}}"/>
<a href="{{reply.actor.profileUrl}}">{{reply.actor.name}}</a> <a href="{{reply.actor.profileUrl}}">{{reply.actor.name}}</a>:
{{reply.content | html}} {{reply.content | html}}
</li> </li>
</ul> </ul>

View file

@ -602,6 +602,8 @@ Parser.prototype = {
var fnPtr = fn(self); var fnPtr = fn(self);
if (typeof fnPtr === 'function') { if (typeof fnPtr === 'function') {
return fnPtr.apply(self, args); return fnPtr.apply(self, args);
} else if (fnPtr === undefined) {
return fnPtr;
} else { } else {
throw "Expression '" + fn.isAssignable + "' is not a function."; throw "Expression '" + fn.isAssignable + "' is not a function.";
} }

View file

@ -15,6 +15,11 @@ describe('scope/model', function(){
expect(model.$root).toEqual(model); expect(model.$root).toEqual(model);
}); });
it('should return noop function when LHS is undefined', function(){
var model = createScope();
expect(model.$eval('x.$filter()')).toEqual(undefined);
});
describe('$eval', function(){ describe('$eval', function(){
it('should eval function with correct this and pass arguments', function(){ it('should eval function with correct this and pass arguments', function(){
var model = createScope(); var model = createScope();