Skip to content

Instantly share code, notes, and snippets.

View got5's full-sized avatar

Contribution To Tapestry 5 got5

View GitHub Profile
@got5
got5 / Slide 115 - Using the link function
Last active August 29, 2015 14:13
Slide 115 - Using the link function
@got5
got5 / gist:4831ca77e3d68db17f54
Created December 16, 2014 21:35
Slide 95 TP6 ProductUtilsSpec.js
describe("ProductUtils Service", function () {
var ProductUtils,
comments = [
{
"rate": 2,
"user": "Laurent Wroblewski",
"comment": "Test comment"
},
{
"rate": 4,
@got5
got5 / 1-TP5-provider.js
Created December 16, 2014 21:28
Slide 93 TP5
/** Service which handle all user logic. */
var UserService = function ($http, $q, $log, $cookies, $cookieStore, isDebugMode) {
this.logUser = function (login, password) {
// We create a promise to offer the possibility to users to call some functions after the
// asynchronous call of $http.get.
var deferred = $q.defer();
@got5
got5 / 1-TP4-BasicLoginCtrl.js
Last active August 29, 2015 14:11
Slide78 TP4
(function () {
"use strict";
angular.module('app')
.controller('LoginController', ['$scope' , '$http', '$log', '$cookieStore', '$location', function ($scope, $http, $log, $cookieStore, $location) {
$scope.errorMsg = null;
$scope.logUser = function () {
$http.post('/api/login', {login: $scope.login, password: $scope.password})
.success(function (user) {
@got5
got5 / 1-TP3-NewsService.js
Created December 15, 2014 16:42
Slide71 TP3
(function(){
"use strict";
angular.module('app')
.factory('NewsService',['$resource', function ($resource) {
return $resource('/api/news/:op/:id',{id:'@id'},{
like: {method:'GET',params: {op:'like'}},
random: {method:'GET',params:{op:'random'}}
});
}]);
})();
@got5
got5 / 1-TP1-DetailContoiller
Created December 15, 2014 09:40
TP1 Detail Slide 47
$scope.getImage = function (id) {
if (!id) {
return "";
} else {
return "/img/catalog/" + id + ".jpg";
}
};
/** Returns rating for a given product. */
@got5
got5 / gist:fabd51ee4221ebfc347a
Created December 13, 2014 14:24
Slide 144 Using form validation
<form name="myForm">
<h3>Training complaint form</h3>
<alert type="error" ng-if="myForm.txtContent.$error.maxlength">
Complaint message must be five characters long or less!
</alert>
Your name: <input type="text" name="inputName" ng-model="complaint.name" ng-required="true" />
Your mail: <input type="email" ng-required="true" name="inputMail" ng-model="complaint.mail" />
Your complaint: <input type="text" name="txtContent" ng-maxlength="5" ng-model="complaint.content" />
<button ng-disabled="!myForm.$valid" class="btn" ng-click="sendComplaint()">Send</button>
</form>
@got5
got5 / 1-TP9 catalog.html
Last active August 29, 2015 14:11
Slide 140 TP9 filters
<div>
<div class="lateral-form">
Results per page: <br/>
<!-- TODO: Number of products displayed per page. -->
<input type="number" id="nbFilter" name="nbFilter" ng-model="nbResults"/> Filter by name:
<br/>
<!-- TODO -->
<input type="text" id="nameFilter" name="nameFilter" ng-model="nameFilter.name"/> <br/> Order
by: <br/>
<!-- TODO -->
@got5
got5 / gist:136742dc4170e184476b
Created December 13, 2014 13:44
Slide 130 Angular Filters
<div ng-controller="FilterCtrl">
Filter: <input type="text" ng-model="filterName"/>
/ Show <input type="text" ng-model="nbResults"/> results
<table>
<tr>
<th><a href="" ng-click="predicate='name'; reverse=!reverse">Name</a></th>
<th><a href="" ng-click="predicate='phone'; reverse=!reverse">Phone</a></th>
<th><a href="" ng-click="predicate='age'; reverse=!reverse">Age</a></th>
<th><a href="" ng-click="predicate='money'; reverse=!reverse">Money</a></th>
<th><a href="" ng-click="predicate='date'; reverse=!reverse">Birth Date</a></th>
@got5
got5 / 1-TP8-productSummary.js
Last active August 29, 2015 14:11
Slide 113 TP8
(function(){
"use strict";
angular.module('app').directive('productSummary', ['ProductUtils', function (ProductUtils) {
return {
restrict: 'E',
templateUrl: 'templates/partials/productSummary.html',
scope:{