-
Notifications
You must be signed in to change notification settings - Fork 559
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca39008
commit 996694f
Showing
73 changed files
with
37,399 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "AngularJS_17_Aumentando_a_Performance_Parte_2", | ||
"homepage": "https://github.com/rodrigobranas/youtube", | ||
"authors": [ | ||
"Rodrigo Branas <[email protected]>" | ||
], | ||
"description": "", | ||
"main": "", | ||
"license": "MIT", | ||
"ignore": [ | ||
"**/.*", | ||
"node_modules", | ||
"bower_components", | ||
"test", | ||
"tests" | ||
], | ||
"dependencies": { | ||
"angular": "^1.5.6", | ||
"angular-route": "^1.5.6", | ||
"angular-i18n": "^1.5.6", | ||
"angular-messages": "^1.5.6", | ||
"bootstrap": "2.3.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
.jumbotron { | ||
width: 700px; | ||
text-align: center; | ||
margin-top: 20px; | ||
margin-left: auto; | ||
margin-right: auto; | ||
position: relative; | ||
padding-top: 60px; | ||
} | ||
h3 { | ||
margin-bottom: 30px; | ||
} | ||
.table { | ||
margin-top: 20px; | ||
} | ||
.form-control { | ||
margin-bottom: 5px; | ||
} | ||
.selecionado { | ||
background-color: yellow; | ||
} | ||
.negrito { | ||
font-weight: bold; | ||
} | ||
hr { | ||
border-color: #999; | ||
} | ||
|
||
.ribbon { | ||
position: absolute; | ||
top: 0px; | ||
right: 30px; | ||
width: 20px; | ||
height: 40px; | ||
border-style: solid; | ||
border-width: 0 10px 10px 10px; | ||
border-color: transparent transparent #EEE transparent; | ||
cursor: pointer; | ||
background-color: #EE0000; | ||
} | ||
.ribbon:hover { | ||
height: 41px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
.ui-alert { | ||
background-color: #F2DEDE; | ||
padding: 20px; | ||
border-radius: 5px; | ||
margin-top: 20px; | ||
margin-bottom: 20px; | ||
} | ||
|
||
.ui-alert-title { | ||
color: #AF4341; | ||
font-weight: bold; | ||
font-size: 24px; | ||
} | ||
|
||
.ui-alert-message { | ||
color: #AF4341; | ||
} | ||
|
||
.ui-accordion-title { | ||
border: 1px solid #CCCCCC; | ||
cursor: pointer; | ||
background: -moz-linear-gradient(top, #CCCCCC, #EEEEEE); | ||
padding: 10px; | ||
font-size: 16px; | ||
font-weight: bold; | ||
border-radius: 5px 5px 0px 0px; | ||
margin-top: 10px; | ||
text-align: left; | ||
} | ||
.ui-accordion-content { | ||
border: 1px dashed #CCCCCC; | ||
border-top: 0px; | ||
border-radius: 0px 0px 5px 5px; | ||
background-color: #FFFFFF; | ||
padding: 10px; | ||
margin-bottom: 10px; | ||
font-size: 14px; | ||
text-align: left; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<html ng-app="listaTelefonica"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Lista Telefonica</title> | ||
<link rel="stylesheet" type="text/css" href="lib/bootstrap/bootstrap.css"> | ||
<link rel="stylesheet" type="text/css" href="css/app.css"> | ||
<link rel="stylesheet" type="text/css" href="css/ui.css"> | ||
<script src="lib/angular/angular.js"></script> | ||
<script src="lib/angular/angular-route.js"></script> | ||
<script src="lib/angular/angular-messages.js"></script> | ||
<script src="lib/angular/angular-locale_pt-br.js"></script> | ||
<script src="lib/serialGenerator/serialGenerator.js"></script> | ||
<script src="lib/ui/ui.js"></script> | ||
<script src="js/app.js"></script> | ||
<script src="js/controllers/listaTelefonicaCtrl.js"></script> | ||
<script src="js/controllers/novoContatoCtrl.js"></script> | ||
<script src="js/controllers/detalhesContatoCtrl.js"></script> | ||
<script src="js/services/contatosAPIService.js"></script> | ||
<script src="js/services/operadorasAPIService.js"></script> | ||
<script src="js/config/serialGeneratorConfig.js"></script> | ||
<script src="js/config/routeConfig.js"></script> | ||
<script src="js/value/configValue.js"></script> | ||
<script src="js/filters/nameFilter.js"></script> | ||
<script src="js/filters/ellipsisFilter.js"></script> | ||
<script src="js/filters/upperFilter.js"></script> | ||
<script src="js/directives/uiAlertDirective.js"></script> | ||
<script src="js/directives/uiDateDirective.js"></script> | ||
<script src="js/interceptors/timestampInterceptor.js"></script> | ||
<script src="js/interceptors/errorInterceptor.js"></script> | ||
<script src="js/interceptors/loadingInterceptor.js"></script> | ||
<script src="js/config/interceptorsConfig.js"></script> | ||
</head> | ||
<body> | ||
<div class="jumbotron" ng-show="loading"> | ||
<h5>Carregando, por favor aguarde...</h5> | ||
</div> | ||
<div ng-hide="loading"> | ||
<div ng-view></div> | ||
<div ng-include="'view/footer.html'"></div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
angular.module("listaTelefonica", ["ngMessages", "serialGenerator", "ui", "ngRoute"]); |
5 changes: 5 additions & 0 deletions
5
AngularJS_17_Aumentando_a_Performance_Parte_2/js/config/interceptorsConfig.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
angular.module("listaTelefonica").config(function ($httpProvider) { | ||
$httpProvider.interceptors.push("timestampInterceptor"); | ||
$httpProvider.interceptors.push("errorInterceptor"); | ||
$httpProvider.interceptors.push("loadingInterceptor"); | ||
}); |
36 changes: 36 additions & 0 deletions
36
AngularJS_17_Aumentando_a_Performance_Parte_2/js/config/routeConfig.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
angular.module("listaTelefonica").config(function ($routeProvider) { | ||
$routeProvider.when("/contatos", { | ||
templateUrl: "view/contatos.html", | ||
controller: "listaTelefonicaCtrl", | ||
resolve: { | ||
contatos: function (contatosAPI) { | ||
return contatosAPI.getContatos(); | ||
}, | ||
operadoras: function (operadorasAPI) { | ||
return operadorasAPI.getOperadoras(); | ||
} | ||
} | ||
}); | ||
$routeProvider.when("/novoContato", { | ||
templateUrl: "view/novoContato.html", | ||
controller: "novoContatoCtrl", | ||
resolve: { | ||
operadoras: function (operadorasAPI) { | ||
return operadorasAPI.getOperadoras(); | ||
} | ||
} | ||
}); | ||
$routeProvider.when("/detalhesContato/:id", { | ||
templateUrl: "view/detalhesContato.html", | ||
controller: "detalhesContatoCtrl", | ||
resolve: { | ||
contato: function (contatosAPI, $route) { | ||
return contatosAPI.getContato($route.current.params.id); | ||
} | ||
} | ||
}); | ||
$routeProvider.when("/error", { | ||
templateUrl: "view/error.html" | ||
}); | ||
$routeProvider.otherwise({redirectTo: "/contatos"}); | ||
}); |
3 changes: 3 additions & 0 deletions
3
AngularJS_17_Aumentando_a_Performance_Parte_2/js/config/serialGeneratorConfig.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
angular.module("listaTelefonica").config(function (serialGeneratorProvider) { | ||
serialGeneratorProvider.setLength(5); | ||
}); |
4 changes: 4 additions & 0 deletions
4
AngularJS_17_Aumentando_a_Performance_Parte_2/js/controllers/detalhesContatoCtrl.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
angular.module("listaTelefonica").controller("detalhesContatoCtrl", function ($scope, $routeParams, contato) { | ||
|
||
$scope.contato = contato.data; | ||
}); |
57 changes: 57 additions & 0 deletions
57
AngularJS_17_Aumentando_a_Performance_Parte_2/js/controllers/listaTelefonicaCtrl.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
angular.module("listaTelefonica").controller("listaTelefonicaCtrl", function ($scope, contatos, operadoras, serialGenerator, $filter) { | ||
$scope.app = $filter('upper')("Lista Telefonica"); | ||
$scope.contatos = contatos.data; | ||
$scope.operadoras = operadoras.data; | ||
|
||
var init = function () { | ||
calcularImpostos($scope.contatos); | ||
generateSerial($scope.contatos); | ||
}; | ||
|
||
var calcularImpostos = function (contatos) { | ||
contatos.forEach(function (contato) { | ||
contato.operadora.precoComImposto = calcularImposto(contato.operadora.preco); | ||
}); | ||
}; | ||
|
||
var generateSerial = function (contatos) { | ||
contatos.forEach(function (item) { | ||
item.serial = serialGenerator.generate(); | ||
}); | ||
}; | ||
|
||
$scope.adicionarContato = function (contato) { | ||
contato.serial = serialGenerator.generate(); | ||
contatosAPI.saveContato(contato).success(function (data) { | ||
delete $scope.contato; | ||
$scope.contatoForm.$setPristine(); | ||
carregarContatos(); | ||
}); | ||
}; | ||
$scope.apagarContatos = function (contatos) { | ||
$scope.contatos = contatos.filter(function (contato) { | ||
if (!contato.selecionado) return contato; | ||
}); | ||
$scope.verificarContatoSelecionado($scope.contatos); | ||
}; | ||
$scope.verificarContatoSelecionado = function (contatos) { | ||
$scope.hasContatoSelecionado = contatos.some(function (contato) { | ||
return contato.selecionado; | ||
}); | ||
}; | ||
$scope.ordenarPor = function (campo) { | ||
$scope.criterioDeOrdenacao = campo; | ||
$scope.direcaoDaOrdenacao = !$scope.direcaoDaOrdenacao; | ||
}; | ||
|
||
var calcularImposto = function (preco) { | ||
var imposto = 1.2; | ||
return preco * imposto; | ||
}; | ||
|
||
$scope.reset = function () { | ||
$scope.contatos = angular.copy($scope.contatos); | ||
}; | ||
|
||
init(); | ||
}); |
12 changes: 12 additions & 0 deletions
12
AngularJS_17_Aumentando_a_Performance_Parte_2/js/controllers/novoContatoCtrl.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
angular.module("listaTelefonica").controller("novoContatoCtrl", function ($scope, contatosAPI, serialGenerator, $location, operadoras) { | ||
$scope.operadoras = operadoras.data; | ||
|
||
$scope.adicionarContato = function (contato) { | ||
contato.serial = serialGenerator.generate(); | ||
contatosAPI.saveContato(contato).success(function (data) { | ||
delete $scope.contato; | ||
$scope.contatoForm.$setPristine(); | ||
$location.path("/contatos"); | ||
}); | ||
}; | ||
}); |
11 changes: 11 additions & 0 deletions
11
AngularJS_17_Aumentando_a_Performance_Parte_2/js/directives/uiAlertDirective.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
angular.module("listaTelefonica").directive("uiAlert", function () { | ||
return { | ||
templateUrl: "view/alert.html", | ||
replace: true, | ||
restrict: "AE", | ||
scope: { | ||
title: "@" | ||
}, | ||
transclude: true | ||
}; | ||
}); |
34 changes: 34 additions & 0 deletions
34
AngularJS_17_Aumentando_a_Performance_Parte_2/js/directives/uiDateDirective.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
angular.module("listaTelefonica").directive("uiDate", function ($filter) { | ||
return { | ||
require: "ngModel", | ||
link: function (scope, element, attrs, ctrl) { | ||
var _formatDate = function (date) { | ||
if (!date) return date; | ||
date = date.replace(/[^0-9]+/g, ""); | ||
if(date.length > 2) { | ||
date = date.substring(0,2) + "/" + date.substring(2); | ||
} | ||
if(date.length > 5) { | ||
date = date.substring(0,5) + "/" + date.substring(5,9); | ||
} | ||
return date; | ||
}; | ||
|
||
element.bind("keyup", function () { | ||
ctrl.$setViewValue(_formatDate(ctrl.$viewValue)); | ||
ctrl.$render(); | ||
}); | ||
|
||
ctrl.$parsers.push(function (value) { | ||
if (value.length === 10) { | ||
var dateArray = value.split("/"); | ||
return new Date(dateArray[2], dateArray[1]-1, dateArray[0]).getTime(); | ||
} | ||
}); | ||
|
||
ctrl.$formatters.push(function (value) { | ||
return $filter("date")(value, "dd/MM/yyyy"); | ||
}); | ||
} | ||
}; | ||
}); |
7 changes: 7 additions & 0 deletions
7
AngularJS_17_Aumentando_a_Performance_Parte_2/js/filters/ellipsisFilter.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
angular.module("listaTelefonica").filter("ellipsis", function () { | ||
return function (input, size) { | ||
if (input.length <= size) return input; | ||
var output = input.substring(0,(size || 2)) + "..."; | ||
return output; | ||
}; | ||
}); |
10 changes: 10 additions & 0 deletions
10
AngularJS_17_Aumentando_a_Performance_Parte_2/js/filters/nameFilter.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
angular.module("listaTelefonica").filter("name", function () { | ||
return function (input) { | ||
var listaDeNomes = input.split(" "); | ||
var listaDeNomesFormatada = listaDeNomes.map(function (nome) { | ||
if (/(da|de)/.test(nome)) return nome; | ||
return nome.charAt(0).toUpperCase() + nome.substring(1).toLowerCase(); | ||
}); | ||
return listaDeNomesFormatada.join(" "); | ||
}; | ||
}); |
8 changes: 8 additions & 0 deletions
8
AngularJS_17_Aumentando_a_Performance_Parte_2/js/filters/upperFilter.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
angular.module("listaTelefonica").filter("upper", function () { | ||
var counter = 0; | ||
return function (input) { | ||
console.log(counter++); | ||
if (!input) return; | ||
return input.toUpperCase(); | ||
}; | ||
}); |
10 changes: 10 additions & 0 deletions
10
AngularJS_17_Aumentando_a_Performance_Parte_2/js/interceptors/errorInterceptor.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
angular.module("listaTelefonica").factory("errorInterceptor", function ($q, $location) { | ||
return { | ||
responseError: function (rejection) { | ||
if (rejection.status === 404) { | ||
$location.path("/error"); | ||
} | ||
return $q.reject(rejection); | ||
} | ||
}; | ||
}); |
Oops, something went wrong.