Skip to content

Commit 3661444

Browse files
committed
Merge pull request dart-archive#102 from vicb/import
[WIP] Upgrade to Angular 0.9.10 & misc changes
2 parents cee2c1f + 94bddab commit 3661444

35 files changed

+95
-134
lines changed

Chapter_01/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ packages:
8484
unittest:
8585
description: unittest
8686
source: hosted
87-
version: "0.10.1"
87+
version: "0.10.1+1"
8888
utf:
8989
description: utf
9090
source: hosted

Chapter_02/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ packages:
8888
unittest:
8989
description: unittest
9090
source: hosted
91-
version: "0.10.1"
91+
version: "0.10.1+2"
9292
utf:
9393
description: utf
9494
source: hosted

Chapter_03/lib/rating/rating_component.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@ class RatingComponent {
5353
stars = new List.generate(count, (i) => i + 1);
5454
}
5555

56-
String starClass(int star) {
57-
return star > rating ? _STAR_OFF_CLASS : _STAR_ON_CLASS;
58-
}
56+
String starClass(int star) =>
57+
star > rating ? _STAR_OFF_CLASS : _STAR_ON_CLASS;
5958

6059
String starChar(int star) => star > rating ? _STAR_OFF_CHAR : _STAR_ON_CHAR;
6160

Chapter_03/lib/rating/rating_component.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<span class="stars"
2-
ng-if="cmp.rating != null"
32
ng-repeat="star in cmp.stars"
43
ng-click="cmp.handleClick(star)"
54
ng-class="cmp.starClass(star)">

Chapter_03/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ packages:
8888
unittest:
8989
description: unittest
9090
source: hosted
91-
version: "0.10.1"
91+
version: "0.10.1+1"
9292
utf:
9393
description: utf
9494
source: hosted

Chapter_03/web/main.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
library recipe_book;
22

33
import 'package:angular/angular.dart';
4-
import 'package:di/di.dart';
54

65
import 'package:angular_dart_demo/rating/rating_component.dart';
76
import 'package:angular_dart_demo/recipe_book.dart';

Chapter_04/lib/rating/rating_component.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@ class RatingComponent {
5353
stars = new List.generate(count, (i) => i + 1);
5454
}
5555

56-
String starClass(int star) {
57-
return star > rating ? _STAR_OFF_CLASS : _STAR_ON_CLASS;
58-
}
56+
String starClass(int star) =>
57+
star > rating ? _STAR_OFF_CLASS : _STAR_ON_CLASS;
5958

6059
String starChar(int star) => star > rating ? _STAR_OFF_CHAR : _STAR_ON_CHAR;
6160

Chapter_04/lib/rating/rating_component.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<span class="stars"
2-
ng-if="cmp.rating != null"
32
ng-repeat="star in cmp.stars"
43
ng-click="cmp.handleClick(star)"
54
ng-class="cmp.starClass(star)">

Chapter_04/lib/recipe_book.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class RecipeBookController {
2121

2222
// Tooltip
2323
static final tooltip = new Expando<TooltipModel>();
24+
2425
TooltipModel tooltipForRecipe(Recipe recipe) {
2526
if (tooltip[recipe] == null) {
2627
tooltip[recipe] = new TooltipModel(recipe.imgUrl,

Chapter_04/lib/tooltip/tooltip_directive.dart

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,16 @@ import 'package:angular/angular.dart';
77
@NgDirective(
88
selector: '[tooltip]')
99
class Tooltip {
10-
dom.Element element;
10+
final dom.Element element;
1111

1212
@NgOneWay('tooltip')
1313
TooltipModel displayModel;
1414

1515
dom.Element tooltipElem;
1616

1717
Tooltip(this.element) {
18-
element
19-
..onMouseEnter.listen((_) => _createTemplate())
20-
..onMouseLeave.listen((_) => _destroyTemplate());
18+
element..onMouseEnter.listen((_) => _createTemplate())
19+
..onMouseLeave.listen((_) => _destroyTemplate());
2120
}
2221

2322
void _createTemplate() {
@@ -47,19 +46,13 @@ class Tooltip {
4746
..borderRadius = "5px"
4847
..width = "${displayModel.imgWidth.toString()}px";
4948

50-
// find the coordinates of the parent DOM element
51-
Rectangle bounds = element.getBoundingClientRect();
52-
int left = (bounds.left + dom.window.pageXOffset).toInt();
53-
int top = (bounds.top + dom.window.pageYOffset).toInt();
54-
int width = bounds.width.toInt();
55-
int height = bounds.height.toInt();
56-
5749
// position the tooltip.
58-
// Figure out where the containing element sits in the window.
50+
var elTopRight = element.offset.topRight;
51+
5952
tooltipElem.style
6053
..position = "absolute"
61-
..top = "${top - height}px"
62-
..left = "${left + width + 10}px";
54+
..top = "${elTopRight.y}px"
55+
..left = "${elTopRight.x + 10}px";
6356

6457
// Add the tooltip to the document body. We add it here because
6558
// we need to position it absolutely, without reference to its

0 commit comments

Comments
 (0)