aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMisko Hevery2010-07-22 15:32:57 -0700
committerMisko Hevery2010-07-22 15:32:57 -0700
commit2987f7f705baffad8081fc4a3a95eab79b0d9695 (patch)
tree95cbcdb3e0dbf39d00b266075f551be8ddd87e9f
parent849a05b5a578f19ddc3d24dc9fbd304e0e07612a (diff)
downloadangular.js-2987f7f705baffad8081fc4a3a95eab79b0d9695.tar.bz2
fix howers which were accidently broken
-rw-r--r--example/buzz/buzz.css45
-rw-r--r--example/buzz/buzz.html36
-rw-r--r--example/buzz/buzz.js27
-rw-r--r--src/Browser.js1
-rw-r--r--src/directives.js2
-rw-r--r--test/BinderTest.js9
-rw-r--r--test/directivesSpec.js5
7 files changed, 96 insertions, 29 deletions
diff --git a/example/buzz/buzz.css b/example/buzz/buzz.css
index e69de29b..e77c3bac 100644
--- a/example/buzz/buzz.css
+++ b/example/buzz/buzz.css
@@ -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;
+}
diff --git a/example/buzz/buzz.html b/example/buzz/buzz.html
index ee2b2bb9..f1916f54 100644
--- a/example/buzz/buzz.html
+++ b/example/buzz/buzz.html
@@ -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>
diff --git a/example/buzz/buzz.js b/example/buzz/buzz.js
index 871982d7..40813d16 100644
--- a/example/buzz/buzz.js
+++ b/example/buzz/buzz.js
@@ -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');
+ }
+ });
+ };
+});
diff --git a/src/Browser.js b/src/Browser.js
index 3299540c..2777dcda 100644
--- a/src/Browser.js
+++ b/src/Browser.js
@@ -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;
}
diff --git a/src/directives.js b/src/directives.js
index 04831131..3e0aeffb 100644
--- a/src/directives.js
+++ b/src/directives.js
@@ -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,
diff --git a/test/BinderTest.js b/test/BinderTest.js
index 44f918e4..b90d1789 100644
--- a/test/BinderTest.js
+++ b/test/BinderTest.js
@@ -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");
diff --git a/test/directivesSpec.js b/test/directivesSpec.js
index dffc8906..8a7da41d 100644
--- a/test/directivesSpec.js
+++ b/test/directivesSpec.js
@@ -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 = "";