-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
161 lines (147 loc) · 4.41 KB
/
app.js
File metadata and controls
161 lines (147 loc) · 4.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
(function() {
var app = angular.module('store', []);
app.controller('StoreController', function() {
this.products = gems;
});
app.controller("ReviewController", function() {
this.review = {};
this.addReview = function(product) {
product.reviews.push(this.review);
this.review = {};
}
})
app.directive('productTitle', function() {
return {
// type of directive.
// E = element. Use for UI widgets
// A = attribute. Use for mixin behaviors (like tooltips)
restrict: 'E',
templateUrl: "product-title.html"
};
});
app.directive('productDescription', function() {
return {
restrict: 'E',
templateUrl: "product-description.html"
};
});
app.directive('productReview', function() {
return {
restrict: 'E',
templateUrl: "product-review.html"
};
});
app.directive('productSpecs', function() {
return {
restrict: 'E',
templateUrl: "product-specs.html"
};
});
app.directive('productPanels', function() {
return {
restrict: 'E',
templateUrl: "product-panels.html",
controller: function() {
this.tab = 1;
this.selectTab = function(setTab) {
this.tab = setTab;
}
this.isSelected = function(checkTab) {
return this.tab === checkTab;
}
},
controllerAs: 'panels'
};
});
app.directive('productGallery', function() {
return {
restrict: 'E',
templateUrl: "product-gallery.html",
controller: function() {
this.current = 0;
this.setCurrent = function(newValue) {
this.current = newValue || 0;
}
},
controllerAs: 'gallery'
};
});
var gems = [{
name: 'Azurite',
description: "Some gems have hidden qualities beyond their luster, beyond their shine... Azurite is one of those gems.",
shine: 8,
price: 110.50,
rarity: 7,
color: '#CCC',
faces: 14,
images: [
"resources/images/gem-02.gif",
"resources/images/gem-05.gif",
"resources/images/gem-09.gif"
],
reviews: [{
stars: 5,
body: "I love this gem!",
author: "joe@example.org",
createdOn: 1397490980837
}, {
stars: 1,
body: "This gem sucks.",
author: "tim@example.org",
createdOn: 1397490980837
}]
}, {
name: 'Bloodstone',
description: "Origin of the Bloodstone is unknown, hence its low value. It has a very high shine and 12 sides, however.",
shine: 9,
price: 22.90,
rarity: 6,
color: '#EEE',
faces: 12,
images: [
"resources/images/gem-01.gif",
"resources/images/gem-03.gif",
"resources/images/gem-04.gif",
],
reviews: [{
stars: 3,
body: "I think this gem was just OK, could honestly use more shine, IMO.",
author: "JimmyDean@example.org",
createdOn: 1397490980837
}, {
stars: 4,
body: "Any gem with 12 faces is for me!",
author: "gemsRock@example.org",
createdOn: 1397490980837
}]
}, {
name: 'Zircon',
description: "Zircon is our most coveted and sought after gem. You will pay much to be the proud owner of this gorgeous and high shine gem.",
shine: 70,
price: 1100,
rarity: 2,
color: '#000',
faces: 6,
images: [
"resources/images/gem-06.gif",
"resources/images/gem-07.gif",
"resources/images/gem-08.gif"
],
reviews: [{
stars: 1,
body: "This gem is WAY too expensive for its rarity value.",
author: "turtleguyy@example.org",
createdOn: 1397490980837
}, {
stars: 1,
body: "BBW: High Shine != High Quality.",
author: "LouisW407@example.org",
createdOn: 1397490980837
}, {
stars: 1,
body: "Don't waste your rubles!",
author: "nat@example.org",
createdOn: 1397490980837
}]
}];
})();