Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2014
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. //define(['angular', 'jquery', 'services/Article', 'model/Panel'], function (angular, $, articleService, Panel) {
  2. define(['angular', 'services/Article'/*, 'angular-resource', 'angular-route'*/], function (angular, articleService) {
  3. // Content type configuration
  4. var contentTypes = [{
  5. id: 'BingNewsFeed',
  6. column: 1
  7. }, {
  8. id: 'CommunityNewsFeed',
  9. column: 1
  10. }, {
  11. id: 'Community',
  12. column: 2
  13. }, {
  14. id: 'Review',
  15. column: 2
  16. }, {
  17. id: 'Modifications',
  18. column: 3
  19. }, {
  20. id: 'HowToGuide',
  21. column: 3
  22. }, {
  23. id: 'Archive',
  24. column: 4
  25. }];
  26.  
  27. var mx5PortalApp = angular.module('mx5PortalApp', []);
  28.  
  29. mx5PortalApp.controller('PanelController', function () {
  30. var self = this;
  31. self.columns = [];
  32.  
  33. for (var index in contentTypes) {
  34. var contentType = contentTypes[index],
  35. columnIndex = contentType.column - 1;
  36.  
  37. if (!self.columns[columnIndex]) {
  38. self.columns[columnIndex] = [];
  39. }
  40.  
  41. (function () {
  42. articleService.getByContentType(contentType.id, contentType.limit || 5, function (data) {
  43. data = [{
  44. title: 'a-title' + contentType.id,
  45. content: 'content',
  46. type: 'Article'
  47. }, {
  48. title: 'b-title' + contentType.id,
  49. content: 'content',
  50. type: 'Article'
  51. }];
  52.  
  53. contentType.items = data;
  54. self.columns[columnIndex].push(contentType);
  55. });
  56. })();
  57. }
  58. });
  59.  
  60. angular.element(document).ready(function () {
  61. angular.bootstrap(document, ['mx5PortalApp']);
  62. });
  63.  
  64.  
  65.  
  66. /*
  67. var panel = new Panel();
  68.  
  69. for (var contentTypeIndex in contentTypes) {
  70. var contentType = contentTypes[contentTypeIndex];
  71.  
  72. (function (contentType) {
  73. articleService.getByContentType(contentType.id, contentType.limit || 5, function (data) {
  74. data = [{
  75. title: 'a-title' + contentType.id,
  76. content: 'content',
  77. type: 'Article'
  78. }, {
  79. title: 'b-title' + contentType.id,
  80. content: 'content',
  81. type: 'Article'
  82. }];
  83.  
  84. for (var i = 0; i < data.length; i++) {
  85. panel.addItem(data[i], data[i].type, contentType.name || contentType.id, contentType.column);
  86. }
  87.  
  88. // Render
  89. $('.content').html(panel.html());
  90. });
  91. })(contentType);
  92. }
  93. */
  94. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement