angular prototype

This commit is contained in:
Jeremie Panzer
2013-03-21 16:22:58 +01:00
parent a5ac6b9c44
commit 0161de1f13
19 changed files with 508 additions and 6 deletions

View 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,
} ];
});

View 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);
}
}
};
});

View 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'
});
} ]);