Commit dd60abee authored by William's avatar William
Browse files

Merge remote-tracking branch 'origin/189-ajouter-le-dessin-a-main-leve' into...

Merge remote-tracking branch 'origin/189-ajouter-le-dessin-a-main-leve' into 192-changer-la-couleur-du-texte
parents a30d92d5 9a25a312
<button class="pull-right"
ng-click="leaveBoard()"
ui-sref="project.workshops.overview">{{::_labels.disconnectWorkshopBtn}}
</button>
<div class="clearfix group-overview">
<div class="group-overview-title">
<h4 style="text-align: center"><span ng-bind="::_labels.workshops"></span></h4>
......@@ -11,7 +17,7 @@
<button>Blue</button>
<button>Red</button>
<button>Cursor</button>
<button>Pen</button>
<button ng-click="paperBoardCtrl.penMode()">Pen</button>
<button>Circle</button>
<button>Square</button>
<button>Add Post-It</button>
......@@ -21,4 +27,4 @@
</label>
</div>
</div>
</div>
\ No newline at end of file
</div>
/*
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
......@@ -7,30 +7,93 @@
/* Controllers */
root.controller('DetailsPaperBoardCtrl', ['$scope', '$stateParams', '$http', '$state', '$paperboardFactory', '$languageFactory', '$utilsFactory', function ($scope, $stateParams, $http, $state, $paperboardFactory, $languageFactory, $utilsFactory) {
var detailsPaperBoardCtrl = this;
root.controller('PaperBoardCtrl', ['$scope', '$stateParams', '$http', '$state', '$paperboardFactory', '$languageFactory', '$utilsFactory', function ($scope, $stateParams, $http, $state, $paperboardFactory, $languageFactory, $utilsFactory) {
var paperBoardCtrl = this;
detailsPaperBoardCtrl.getPaperBoardDetails = function (paperBoardDetails) {
var canvas = document.querySelector('#drawZone');
var ctx = canvas.getContext("2d");
var rect = canvas.getBoundingClientRect();
var mouseX = 0;
var mouseY = 0;
var lineWidth = 3;
var isDrawing = false;
var style = "#000";
var pen = false;
paperBoardCtrl.getPaperBoardDetails = function (paperBoardDetails) {
if (!paperBoardDetails) var paperBoardDetails = {"id": $stateParams.elementId};
$scope._showAlert({status: 2, message: $languageFactory._labels.alerts_loadingpaperBoardDetails});
$paperboardFactory.getPaperBoardDetails($scope._getProject(), paperBoardDetails.id, function (data)
$paperboardFactory.getPaperBoardDetails($scope._getProject(), paperBoardDetails.id, function (data)
{
if (data.status == "success")
if (data.status == "success")
{
var paperboard = data.details[0];
detailsPaperBoardCtrl.paperboard = JSON.parse(paperboard.params);
detailsPaperBoardCtrl.paperboard.id = paperboard.id;
detailsPaperBoardCtrl.paperboard.type = 1;
paperBoardCtrl.paperboard = JSON.parse(paperboard.params);
paperBoardCtrl.paperboard.id = paperboard.id;
paperBoardCtrl.paperboard.type = 1;
$scope._showAlert({status: 1, message: $languageFactory._labels.alerts_loadingpaperBoardDetailsSuccess});
}
else
}
else
{
$scope._showAlert({status: 3, message: $languageFactory._labels.alerts_loadingpaperBoardDetailsFailure});
}
});
}
detailsPaperBoardCtrl.getPaperBoardDetails();
paperBoardCtrl.lineDraw = function (ctx, x1, y1, x2, y2, styleColor, lineWidth)
{
ctx.beginPath();
ctx.moveTo(x1, y1);
ctx.lineTo(x2, y2);
ctx.lineCap = ctx.lineJoin = 'round';
ctx.strokeStyle = styleColor;
ctx.shadowColor = styleColor;
ctx.lineWidth = lineWidth;
ctx.stroke();
ctx.closePath();
}
paperBoardCtrl.penMode = function ()
{
pen = true;
}
$scope.leaveBoard = function(){
alert("Vous venez de quitter l'atelier");
}
paperBoardCtrl.getPaperBoardDetails();
document.querySelector('#lineWidth').addEventListener('change', e =>
{
lineWidth = document.querySelector('#lineWidth').value;
});
canvas.addEventListener('mousedown', e=>
{
mouseX = e.clientX - rect.left;
mouseY = e.clientY - rect.top;
isDrawing = true;
});
canvas.addEventListener('mousemove', e=>
{
if(isDrawing)
{
if(pen)
{
paperBoardCtrl.lineDraw(ctx,mouseX,mouseY,e.clientX - rect.left, e.clientY - rect.top, style, lineWidth);
mouseX = e.clientX - rect.left;
mouseY = e.clientY - rect.top;
}
}
});
}]);
\ No newline at end of file
canvas.addEventListener('mouseup', e =>
{
isDrawing = false;
});
}]);
......@@ -434,8 +434,8 @@ angular.module('myApp', [
$stateProvider.state('project.workshops.paperboard', {
url: '/:elementId',
templateUrl: __root + 'components/projects/workshops/paperboard.html',
controller: 'DetailsPaperBoardCtrl',
controllerAs: "detailsPaperBoardCtrl",
controller: 'PaperBoardCtrl',
controllerAs: "paperBoardCtrl",
params: {
section: {
elementId: true,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment