/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ (function() { 'use strict'; /* * sgCalendarDayBlock - An event block to be displayed in a week * @memberof SOGo.SchedulerUI * @restrict element * @param {object} sgBlock - the event block definition * @param {function} sgClick - the function to call when clicking on a block. * Two variables are available: clickEvent (the event that triggered the mouse click), * and clickComponent (a Component object) * * @example: */ sgCalendarDayBlock.$inject = ['CalendarSettings']; function sgCalendarDayBlock(CalendarSettings) { return { restrict: 'E', scope: { block: '=sgBlock', clickBlock: '&sgClick' }, replace: true, template: [ '
', '
', // Categories color stripes '
', '
{{ block.component.summary }}', ' ', // Component is reccurent ' ', // Component has an alarm ' ', // Component is confidential ' ', // Component is private ' ', ' ', // Location '
', ' place {{block.component.c_location}}', '
', '
', '
', '
' ].join(''), link: link }; function link(scope, iElement, attrs) { var pc, left, right; // Compute overlapping (2%) pc = 100 / scope.block.siblings; left = scope.block.position * pc; right = 100 - (scope.block.position + 1) * pc; if (pc < 100) { if (left > 0) left -= 2; if (right > 0) right -= 2; } // Add some padding (2%) if (left === 0) left = 2; if (right === 0) right = 2; // Set position iElement.css('left', left + '%'); iElement.css('right', right + '%'); iElement.addClass('starts' + scope.block.start); iElement.addClass('lasts' + scope.block.length); // Set background color iElement.addClass('bg-folder' + scope.block.component.pid); } } angular .module('SOGo.SchedulerUI') .directive('sgCalendarDayBlock', sgCalendarDayBlock); })();