forked from Archives/Athou_commafeed
angular prototype
This commit is contained in:
56
src/main/webapp/js/controllers.js
Normal file
56
src/main/webapp/js/controllers.js
Normal file
@@ -0,0 +1,56 @@
|
||||
var module = angular.module('commafeed.controllers', []);
|
||||
|
||||
module.controller('CategoryTreeCtrl',
|
||||
function($scope, $routeParams, $location) {
|
||||
|
||||
$scope.selectedType = $routeParams._type;
|
||||
$scope.selectedId = $routeParams._id;
|
||||
|
||||
$scope.root = {
|
||||
children : [ {
|
||||
id : "1",
|
||||
name : "News",
|
||||
feeds : [ {
|
||||
id : "2",
|
||||
name : "Cyanide & Happiness"
|
||||
} ],
|
||||
children : [ {
|
||||
id : "2",
|
||||
name : "Comics",
|
||||
feeds : [ {
|
||||
id : "1",
|
||||
name : "Dilbert"
|
||||
} ]
|
||||
} ]
|
||||
}, {
|
||||
id : '3',
|
||||
name : "Blogs",
|
||||
feeds : [ {
|
||||
id : "3",
|
||||
name : "Engadget"
|
||||
} ]
|
||||
} ]
|
||||
};
|
||||
|
||||
$scope.feedClicked = function(id) {
|
||||
$location.path('/feeds/view/feed/' + id);
|
||||
};
|
||||
|
||||
$scope.categoryClicked = function(id) {
|
||||
$location.path('/feeds/view/category/' + id);
|
||||
};
|
||||
});
|
||||
|
||||
module.controller('FeedListCtrl', function($scope, $routeParams, $http) {
|
||||
|
||||
$scope.entries = [ {
|
||||
id : '1',
|
||||
title : '',
|
||||
content : '',
|
||||
date : '',
|
||||
feed : '',
|
||||
url : '',
|
||||
read : false,
|
||||
starred : false,
|
||||
} ];
|
||||
});
|
||||
23
src/main/webapp/js/directives.js
Normal file
23
src/main/webapp/js/directives.js
Normal file
@@ -0,0 +1,23 @@
|
||||
var module = angular.module('commafeed.directives', []);
|
||||
|
||||
module.directive('category', function($compile) {
|
||||
return {
|
||||
scope: {
|
||||
node: '=',
|
||||
selectedType: '=',
|
||||
selectedId: '=',
|
||||
feedClick: '&',
|
||||
categoryClick: '&'
|
||||
},
|
||||
restrict : 'E',
|
||||
replace: true,
|
||||
templateUrl: 'directives/category.html',
|
||||
link: function(scope, element) {
|
||||
if (scope.node.children) {
|
||||
var ul = element.find('ul');
|
||||
ul.prepend('<category ng-repeat="child in node.children" node="child" feed-click="feedClick({id:id})" category-click="categoryClick({id:id})" selected-type="selectedType" selected-id="selectedId"></category>');
|
||||
$compile(ul.contents())(scope);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
11
src/main/webapp/js/main.js
Normal file
11
src/main/webapp/js/main.js
Normal file
@@ -0,0 +1,11 @@
|
||||
var app = angular.module('commafeed', [ 'commafeed.directives',
|
||||
'commafeed.controllers' ]);
|
||||
|
||||
app.config([ '$routeProvider', function($routeProvider) {
|
||||
$routeProvider.when('/feeds/view/:_type/:_id', {
|
||||
templateUrl : 'templates/feeds.html'
|
||||
});
|
||||
$routeProvider.otherwise({
|
||||
redirectTo : '/feeds/view/category/all'
|
||||
});
|
||||
} ]);
|
||||
Reference in New Issue
Block a user