sogo/UI/WebServerResources/js/Mailer/sgZoomableImage.directive.js
Francis Lachapelle 8635eab502 Improve display of message attachments
Images are now "zoomable" by clicking on them.
2015-12-02 14:03:10 -05:00

42 lines
905 B
JavaScript

/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
(function() {
'use strict';
/*
* sgZoomableImage - Toggle the 'sg-zoom' class when clicking on the image inside the container.
* @memberof SOGo.MailerUI
* @restrict attribute
* @ngInject
* @example:
<div sg-zoomable-image="sg-zoomable-image">
<md-card>
<img src="foo.png">
</md-card>
</div>
*/
function sgZoomableImage() {
return {
restrict: 'A',
link: link
};
function link(scope, iElement, attrs, ctrl) {
var parentNode = iElement.parent(),
toggleClass;
toggleClass = function(event) {
if (event.target.tagName == 'IMG')
parentNode.toggleClass('sg-zoom');
};
iElement.on('click', toggleClass);
}
}
angular
.module('SOGo.MailerUI')
.directive('sgZoomableImage', sgZoomableImage);
})();