Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
efdc128
add minimum styles/scripts structures
Mar 22, 2015
34f3492
feat: setup angular and dependencies
Mar 22, 2015
cb36a45
add first expression to initilization step-0
Mar 22, 2015
b81713b
feat: add main controleur and data on scope
Mar 22, 2015
7221d41
add step2 filter
Mar 22, 2015
33c425d
rename MainCtrl by RootCtrl
Mar 23, 2015
f323fa1
merge step1 to step2
Mar 23, 2015
85cd7db
fix path to root controller
Mar 23, 2015
4e4c7b5
merge from step-1
Mar 23, 2015
44d2b4e
fix lowercase on scope data
Mar 23, 2015
5cee6e5
Merge branch 'dev-step-1' into dev-step-2
Mar 23, 2015
724b726
fix capitalize on step1
Mar 23, 2015
cf4207b
Merge branch 'dev-step-1' into dev-step-2
Mar 23, 2015
a9cab68
add filter usage on controller
Mar 23, 2015
66d48ea
add simple css and split controller
Mar 23, 2015
12cae9b
add static data to section
Mar 23, 2015
18e2429
add images heroes
Mar 23, 2015
ae5f342
add ng-repeat and ng-class-even
Mar 24, 2015
30f5b84
add to ng-repeat
Mar 24, 2015
a47e3f8
add ng-switch
Mar 24, 2015
65a368d
fix padding css
Mar 24, 2015
e42337d
add select to step
Mar 24, 2015
bf8c8ac
add ng-model and filter
Mar 24, 2015
72d64f9
add ng-click and ng-class
Mar 25, 2015
23c75e6
test
Mar 26, 2015
14b64fe
clean some variable name init some scope variable change some css
Mar 29, 2015
f7af483
Merge branch 'dev-step-8' into dev-step-8
Mar 29, 2015
05733d3
step 8 les directives
Mar 29, 2015
77b4813
change some things in model
Mar 29, 2015
832b645
Merge branch 'dev-step-7' into dev-step-8
Mar 29, 2015
d18077d
add mock preparing step 9
Mar 29, 2015
36703c3
Merge pull request #4 from pebie/dev-step-8
Jun 17, 2015
aff1d76
modification directive
Jun 18, 2015
42363ea
delete old directive
Jun 18, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Angular formation for beginners


- 1.Introduction
- 2.Initialisation
- 3.Les expressions
Expand Down
Binary file added src/images/america.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/giant.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/hulk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/iron.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/thor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/veuve.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 58 additions & 3 deletions src/index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,65 @@
<!doctype html>
<html lang="en">
<html lang="en" ng-app="avengersApp" ng-controller="RootCtrl">
<head>
<meta charset="utf-8">
<title>AngularJs Formation</title>
<title>{{title}}</title>

<link rel="stylesheet" type="text/css" href="styles/app.css">

</head>
<body>
Hello HTML

<header ng-controller="HeaderCtrl">
<h1>{{model.title | capitalize}}</h1>

<h2>{{getTitle()}} : {{currentDate | date:'fullDate'}}</h2>
</header>

<section ng-controller="HeroesCtrl">

<div class="filter">
Filtrer par:
<select ng-model="orderProp">
<option value="name">Ordre Alphabétique</option>
<option value="age">Age</option>
<option value="status">Status</option>
</select>
<hr/>
<div ng-if="selectedHero">
Changer le status de {{selectedHero.name}} :
<select ng-model="selectedHero.status">
<option value="0">Disponible</option>
<option value="1">Occupé</option>
<option value="2">Indisponible</option>
</select>
<hr/>
</div>
</div>

<ul class="heroes-list">
<li ng-repeat="hero in heroes | orderBy:orderProp" class="ng-class-even:'even';ng-class-odd:'odd'"
ng-click="click(hero)"
ng-class="{isSelected:hero.name==selectedHero.name}"
class="hero-block">
<span class="hero-name">{{hero.name}}</span>
<span>{{hero.description}}</span>
<span>Age : {{hero.age}}</span>
<img ng-src="{{hero.image}}">

<div status-info status="hero.status"></div>
</li>
</ul>
</section>

<script src="vendor/angular.js"></script>
<script src="vendor/angular-route.js"></script>
<script src="vendor/moment.js"></script>

<script src="scripts/app.js"></script>
<script src="scripts/filter/capitalize.js"></script>
<script src="scripts/controller/root.js"></script>
<script src="scripts/controller/heroes.js"></script>
<script src="scripts/controller/header.js"></script>
<script src="scripts/directives/statusInfo.js"></script>
</body>
</html>
50 changes: 50 additions & 0 deletions src/mocks/heroes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[
{
"name": "Captain America",
"description": "Sénile et grabataire",
"status": "0",
"lastActivity": "30-03-1999",
"image": "/images/america.png",
"age": 90
},
{
"name": "Iron Man",
"description": "Riche et célèbre",
"status": "1",
"lastActivity": "31-03-2015",
"image": "/images/iron.png",
"age": 35
},
{
"name": "Giant Man",
"description": "Complètement perché",
"status": "2",
"lastActivity": "24-09-2013",
"image": "/images/giant.png",
"age": 40
},
{
"name": "Hulk",
"description": "Géant vert, vendeur de maïs",
"status": "0",
"lastActivity": "03-10-2014",
"image": "/images/hulk.png",
"age": 39
},
{
"name": "La veuve noire",
"description": "Gorgeous",
"status": "1",
"lastActivity": "10-02-2015",
"image": "/images/veuve.png",
"age": 24
},
{
"name": "Thor",
"description": "Viking body buildé",
"status": "2",
"lastActivity": "07-06-2014",
"image": "/images/thor.png",
"age": 46
}
]
9 changes: 9 additions & 0 deletions src/scripts/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

var app = angular.module("avengersApp", ['ngRoute']);

//app.config()
//app.controller()
//app.filter() etc...


13 changes: 13 additions & 0 deletions src/scripts/controller/header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
angular.module("avengersApp").controller("HeaderCtrl", function ($scope, $filter) {

$scope.currentDate = new Date().getTime();

$scope.model = {
title: "hello avengers !"
};

$scope.getTitle = function () {
return $filter('capitalize')("my first Application");
};

});
60 changes: 60 additions & 0 deletions src/scripts/controller/heroes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
angular.module("avengersApp").controller("HeroesCtrl", function ($scope) {
$scope.orderProp = "status";
$scope.heroes = [
{
name: "Captain America",
description: "Sénile et grabataire",
status:"0",
lastActivity:'30-03-1999',
image:"/images/america.png",
age:90
},
{
name: "Iron Man",
description: "Riche et célèbre",
status:"1",
lastActivity:'31-03-2015',
image:"/images/iron.png",
age:35
},
{
name: "Giant Man",
description: "Complètement perché",
status:"2",
lastActivity:'24-09-2013',
image:"/images/giant.png",
age:40
},
{
name: "Hulk",
description: "Géant vert, vendeur de maïs",
status:"0",
lastActivity:'03-10-2014',
image:"/images/hulk.png",
age:39
},
{
name: "La veuve noire",
description: "Gorgeous",
status:"1",
lastActivity:'10-02-2015',
image:"/images/veuve.png",
age:24
},
{
name: "Thor",
description: "Viking body buildé",
status:"2",
lastActivity:'07-06-2014',
image:"/images/thor.png",
age:46
}
];


$scope.click = function(hero){

$scope.selectedHero = hero;
}

});
5 changes: 5 additions & 0 deletions src/scripts/controller/root.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
angular.module("avengersApp").controller("RootCtrl", function ($scope, $filter) {

$scope.title = "AngularJs Formation";

});
5 changes: 5 additions & 0 deletions src/scripts/directives/statusInfo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div ng-switch on="status" class="status">
<span ng-switch-when="0" class="available">Disponible <span>{{date}}</span> </span>
<span ng-switch-when="1" class="busy">Occupé <span>{{date}}</span></span>
<span ng-switch-when="2" class="unavailable">Blessé <span>{{date}}</span></span>
</div>
31 changes: 31 additions & 0 deletions src/scripts/directives/statusInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Created by Pebie on 18/06/15.
*/
angular.module('avengersApp').directive('status', function($interval,dateFilter){
return {
templateUrl:'/scripts/directives/statusInfo.html',
restrict:'A',
scope:{
status:'='
},
link:link
};

function link(scope, element){
var timeoutId;
updateTime();
function updateTime(){
var date = dateFilter(new Date(),'h:mm:ss');
scope.date = date;
}

element.on('$destroy', function(){
$interval.cancel(timeoutId);
})

timeoutId = $interval(function(){
updateTime();
},1000);
}

});
5 changes: 5 additions & 0 deletions src/scripts/filter/capitalize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
angular.module("avengersApp").filter("capitalize", function () {
return function (input) {
return input.charAt(0).toUpperCase() + input.slice(1);
}
});
78 changes: 78 additions & 0 deletions src/styles/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
body {
margin: 0;
}

header {
background: #000;
margin: 0;
color: #FFF;
padding: 10px 40px;
}

h4 {
margin: 20px 0px 0px 0px;
}

ul {
margin-right: 40px;
}

li {
padding: 5px 20px;
position: relative;
height: 65px;
border-bottom: solid 1px #000;
list-style: none;
}

li img {
position: absolute;
top: 0;
right: 0;
}

li.odd {
background: #f2f2f2;
}

li .status {
position: absolute;
top: 50%;
right: 90px;
transform: translateY(-50%);
}

li .available {
color: #57c300;
}

li .unavailable {
color: #ff0000;
}

li .busy {
color: #ff941e;
}

li.isSelected {
color: #8b0f0e;
}

.filter {
margin: 20px 0px 0px 40px;
}

.heroes-list span {
display: block;
}

.hero-name {
font-weight: bold;
}

.hero{
position: absolute;
width: 100%;
height: 100%;
cursor: pointer;
}
Loading