2015-05-06 04:06:13 +02:00
|
|
|
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
|
|
|
|
(function() {
|
2015-10-14 15:58:32 +02:00
|
|
|
/* jshint validthis: true */
|
2015-05-06 04:06:13 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/*
|
2015-11-14 20:29:21 +01:00
|
|
|
* sgFolderStylesheet - Add CSS stylesheet for a folder's color (addressbook or calendar)
|
2015-05-06 04:06:13 +02:00
|
|
|
* @memberof SOGo.Common
|
|
|
|
* @restrict attribute
|
|
|
|
* @param {object} ngModel - the object literal describing the folder (an Addressbook or Calendar instance)
|
|
|
|
* @example:
|
|
|
|
|
2015-11-14 20:29:21 +01:00
|
|
|
<sg-folder-stylesheet
|
2015-05-06 04:06:13 +02:00
|
|
|
ng-repeat="calendar in calendars.list"
|
|
|
|
ng-model="calendar" />
|
|
|
|
*/
|
|
|
|
function sgFolderStylesheet() {
|
|
|
|
return {
|
2015-11-14 20:29:21 +01:00
|
|
|
restrict: 'E',
|
2015-05-06 04:06:13 +02:00
|
|
|
require: 'ngModel',
|
|
|
|
scope: {
|
|
|
|
ngModel: '='
|
|
|
|
},
|
2015-11-14 20:29:21 +01:00
|
|
|
replace: true,
|
2015-10-14 15:58:32 +02:00
|
|
|
bindToController: true,
|
|
|
|
controller: sgFolderStylesheetController,
|
|
|
|
controllerAs: 'cssCtrl',
|
2015-05-06 04:06:13 +02:00
|
|
|
template: [
|
|
|
|
'<style type="text/css">',
|
2015-10-14 15:58:32 +02:00
|
|
|
/* Background color */
|
|
|
|
' .bg-folder{{ cssCtrl.ngModel.id }},',
|
2016-03-03 19:48:38 +01:00
|
|
|
' .bg-folder{{ cssCtrl.ngModel.id }} label {',
|
2015-10-14 15:58:32 +02:00
|
|
|
' background-color: {{ cssCtrl.ngModel.color }} !important;',
|
|
|
|
' color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;',
|
2015-05-06 04:06:13 +02:00
|
|
|
' }',
|
2015-11-14 20:29:21 +01:00
|
|
|
' .sg-event.bg-folder{{ cssCtrl.ngModel.id }} md-icon {',
|
|
|
|
' color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;',
|
|
|
|
' }',
|
2015-10-14 15:58:32 +02:00
|
|
|
// Set the contrast color of toolbar icons except the one of the background
|
|
|
|
' md-toolbar.bg-folder{{ cssCtrl.ngModel.id }} md-icon:not(.sg-icon-toolbar-bg) {',
|
|
|
|
' color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;',
|
2015-05-06 04:06:13 +02:00
|
|
|
' }',
|
2015-10-14 15:58:32 +02:00
|
|
|
// Set the contrast color of input labels
|
|
|
|
' .bg-folder{{ cssCtrl.ngModel.id }} label {',
|
|
|
|
' color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;',
|
|
|
|
' opacity: 0.8;',
|
2015-09-29 20:01:16 +02:00
|
|
|
' }',
|
2015-10-14 15:58:32 +02:00
|
|
|
/* Foreground color */
|
2015-11-20 19:30:26 +01:00
|
|
|
' .fg-folder{{ cssCtrl.ngModel.id }},',
|
|
|
|
' .sg-event.fg-folder{{ cssCtrl.ngModel.id }} md-icon {',
|
2015-10-14 15:58:32 +02:00
|
|
|
' color: {{ cssCtrl.ngModel.color }} !important;',
|
|
|
|
' }',
|
|
|
|
/* Border color */
|
|
|
|
' .bdr-folder{{ cssCtrl.ngModel.id }} {',
|
|
|
|
' border-color: {{ cssCtrl.ngModel.color }} !important;',
|
|
|
|
' }',
|
|
|
|
/* Checkbox color */
|
|
|
|
' .checkbox-folder{{ cssCtrl.ngModel.id }} .md-icon {',
|
|
|
|
' background-color: {{ cssCtrl.ngModel.color }} !important;',
|
|
|
|
' }',
|
|
|
|
' .checkbox-folder{{ cssCtrl.ngModel.id }}.md-checked .md-icon:after {',
|
|
|
|
' border-color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;',
|
2015-05-06 04:06:13 +02:00
|
|
|
' }',
|
|
|
|
'</style>'
|
|
|
|
].join('')
|
2015-07-24 22:14:53 +02:00
|
|
|
};
|
2015-10-14 15:58:32 +02:00
|
|
|
|
|
|
|
function sgFolderStylesheetController() {
|
|
|
|
var vm = this;
|
|
|
|
|
|
|
|
vm.contrast = contrast;
|
|
|
|
}
|
2015-05-06 04:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
angular
|
|
|
|
.module('SOGo.Common')
|
|
|
|
.directive('sgFolderStylesheet', sgFolderStylesheet);
|
|
|
|
})();
|