app.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. (function() {
  2. var app = angular.module('gemStore', []);
  3. app.controller('StoreController', function () {
  4. this.products = gems;
  5. });
  6. app.controller('ReviewController', function () {
  7. this.review = {};
  8. this.addReview = function(product) {
  9. this.review.createdOn = Date.now();
  10. product.reviews.push(this.review);
  11. this.review = {};
  12. };
  13. });
  14. app.directive('productTitle', function () {
  15. return {
  16. restrict: 'A',
  17. templateUrl: 'product-title.html'
  18. };
  19. });
  20. app.directive('productSpecs', function () {
  21. return {
  22. restrict: 'A',
  23. templateUrl: 'product-specs.html'
  24. }
  25. });
  26. app.directive('productPanels', function () {
  27. return {
  28. restrict: 'E',
  29. templateUrl: 'product-panels.html',
  30. controller: function () {
  31. this.tab = 1;
  32. this.selectTab = function (setTab) {
  33. this.tab = setTab;
  34. };
  35. this.isSelected = function (checkTab) {
  36. return this.tab === checkTab;
  37. }
  38. },
  39. controllerAs: 'panels'
  40. }
  41. });
  42. var gems = [
  43. {
  44. name: 'Azurite',
  45. description: "Some gems have hidden qualities beyond their luster, beyond their shine... Azurite is one of those gems.",
  46. shine: 8,
  47. price: 110.50,
  48. rarity: 7,
  49. color: '#CCC',
  50. faces: 14,
  51. images: [
  52. "images/gem-02.gif",
  53. "images/gem-05.gif",
  54. "images/gem-09.gif"
  55. ],
  56. reviews: [{
  57. stars: 5,
  58. body: "I love this gem!",
  59. author: "joe@example.org"
  60. }, {
  61. stars: 1,
  62. body: "This gem sucks.",
  63. author: "tim@example.org"
  64. }]
  65. }, {
  66. name: 'Bloodstone',
  67. description: "Origin of the Bloodstone is unknown, hence its low value. It has a very high shine and 12 sides, however.",
  68. shine: 9,
  69. price: 22.90,
  70. rarity: 6,
  71. color: '#EEE',
  72. faces: 12,
  73. images: [
  74. "images/gem-01.gif",
  75. "images/gem-03.gif",
  76. "images/gem-04.gif"
  77. ],
  78. reviews: [{
  79. stars: 3,
  80. body: "I think this gem was just OK, could honestly use more shine, IMO.",
  81. author: "JimmyDean@example.org"
  82. }, {
  83. stars: 4,
  84. body: "Any gem with 12 faces is for me!",
  85. author: "gemsRock@example.org"
  86. }]
  87. }, {
  88. name: 'Zircon',
  89. 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.",
  90. shine: 70,
  91. price: 1100,
  92. rarity: 2,
  93. color: '#000',
  94. faces: 6,
  95. images: [
  96. "images/gem-06.gif",
  97. "images/gem-07.gif",
  98. "images/gem-08.gif"
  99. ],
  100. reviews: [{
  101. stars: 1,
  102. body: "This gem is WAY too expensive for its rarity value.",
  103. author: "turtleguyy@example.org"
  104. }, {
  105. stars: 1,
  106. body: "BBW: High Shine != High Quality.",
  107. author: "LouisW407@example.org"
  108. }, {
  109. stars: 1,
  110. body: "Don't waste your rubles!",
  111. author: "nat@example.org"
  112. }]
  113. }
  114. ];
  115. })();