/* -*- 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: template, link: link }; function template(tElem, tAttrs) { var p = _.has(tAttrs, 'sgCalendarGhost')? '' : '::'; return [ '
', '
', // Categories color stripes '
', '
', // Priority ' {{'+p+'block.component.c_priority}}', // Summary ' {{ '+p+'block.component.summary }}', ' ', // Component is reccurent ' ', // Component has an alarm ' ', // Component is confidential ' ', // Component is private ' ', ' ', // Location '
', ' place {{'+p+'block.component.c_location}}', '
', '
', '
', '
{{ block.startHour }}
', '
{{ block.endHour }}
', '
' ].join(''); } function link(scope, iElement, attrs) { var pc, left, right; if (!_.has(attrs, 'sgCalendarGhost')) { // 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 + '%'); if (!scope.block.component || !scope.block.component.c_isallday) { iElement.addClass('starts' + scope.block.start); iElement.addClass('lasts' + scope.block.length); } // Add class for user's participation state if (scope.block.userState) iElement.addClass('sg-event--' + scope.block.userState); if (scope.block.component) { // Set background color iElement.addClass('bg-folder' + scope.block.component.pid); iElement.addClass('contrast-bdr-folder' + scope.block.component.pid); // Add class for transparency if (scope.block.component.c_isopaque === 0) iElement.addClass('sg-event--transparent'); // Add class for cancelled event if (scope.block.component.c_status === 0) iElement.addClass('sg-event--cancelled'); } } } } angular .module('SOGo.SchedulerUI') .directive('sgCalendarDayBlock', sgCalendarDayBlock); })();