mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-11-21 15:02:40 +00:00
(js) New images viewer for Mail module
This commit is contained in:
1 parent
0a990ff66b
commit
555b7303d1
9 files changed
+121
-14
No files matched your search
@@ -6,13 +6,16 @@
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
MessageController.$inject = ['$window', '$scope', '$state', '$mdMedia', '$mdDialog', 'sgConstant', 'stateAccounts', 'stateAccount', 'stateMailbox', 'stateMessage', 'sgHotkeys', 'encodeUriFilter', 'sgSettings', 'sgFocus', 'Dialog', 'Calendar', 'Component', 'Account', 'Mailbox', 'Message'];
|
||||
function MessageController($window, $scope, $state, $mdMedia, $mdDialog, sgConstant, stateAccounts, stateAccount, stateMailbox, stateMessage, sgHotkeys, encodeUriFilter, sgSettings, focus, Dialog, Calendar, Component, Account, Mailbox, Message) {
|
||||
MessageController.$inject = ['$window', '$scope', '$state', '$mdMedia', '$mdDialog', 'sgConstant', 'stateAccounts', 'stateAccount', 'stateMailbox', 'stateMessage', 'sgHotkeys', 'encodeUriFilter', 'sgSettings', 'ImageGallery', 'sgFocus', 'Dialog', 'Calendar', 'Component', 'Account', 'Mailbox', 'Message'];
|
||||
function MessageController($window, $scope, $state, $mdMedia, $mdDialog, sgConstant, stateAccounts, stateAccount, stateMailbox, stateMessage, sgHotkeys, encodeUriFilter, sgSettings, ImageGallery, focus, Dialog, Calendar, Component, Account, Mailbox, Message) {
|
||||
var vm = this, popupWindow = null, hotkeys = [];
|
||||
|
||||
// Expose controller
|
||||
$window.$messageController = vm;
|
||||
|
||||
// Initialize image gallery service
|
||||
ImageGallery.setMessage(stateMessage);
|
||||
|
||||
vm.$state = $state;
|
||||
vm.accounts = stateAccounts;
|
||||
vm.account = stateAccount;
|
||||
@@ -424,8 +427,8 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
angular
|
||||
.module('SOGo.MailerUI')
|
||||
.controller('MessageController', MessageController);
|
||||
.module('SOGo.MailerUI')
|
||||
.controller('MessageController', MessageController);
|
||||
})();
|
||||
@@ -1,16 +1,17 @@
|
||||
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
|
||||
(function() {
|
||||
/* jshint validthis: true */
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
* sgZoomableImage - Toggle the 'sg-zoom' class when clicking on the image inside the container.
|
||||
* sgZoomableImage - Show the image fullscreen when clicking on the image inside the container.
|
||||
* @memberof SOGo.MailerUI
|
||||
* @restrict attribute
|
||||
* @ngInject
|
||||
* @example:
|
||||
|
||||
<div sg-zoomable-image="sg-zoomable-image">
|
||||
<div sg-zoomable-image="$index">
|
||||
<md-card>
|
||||
<img src="foo.png">
|
||||
</md-card>
|
||||
@@ -19,22 +20,53 @@
|
||||
function sgZoomableImage() {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: link
|
||||
bindToController: {
|
||||
partIndex: '=sgZoomableImage'
|
||||
},
|
||||
controller: sgZoomableImageController
|
||||
};
|
||||
|
||||
function link(scope, iElement, attrs, ctrl) {
|
||||
var parentNode = iElement.parent(),
|
||||
toggleClass;
|
||||
imgElement, showImage, toggleClass;
|
||||
|
||||
imgElement = iElement.find('img');
|
||||
|
||||
toggleClass = function(event) {
|
||||
if (event.target.tagName == 'IMG')
|
||||
parentNode.toggleClass('sg-zoom');
|
||||
};
|
||||
|
||||
iElement.on('click', toggleClass);
|
||||
showImage = function(event) {
|
||||
if (event.target.tagName == 'IMG')
|
||||
ctrl.showGallery(event, imgElement[0].src);
|
||||
};
|
||||
|
||||
if (imgElement.length)
|
||||
ctrl.addImage(imgElement[0].src);
|
||||
|
||||
iElement.on('click', showImage);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
sgZoomableImageController.$inject = ['$element', 'ImageGallery'];
|
||||
function sgZoomableImageController($element, ImageGallery) {
|
||||
var $ctrl = this;
|
||||
|
||||
this.$postLink = function() {
|
||||
ImageGallery.registerImage($element);
|
||||
$element.on('click', this.showImage);
|
||||
};
|
||||
|
||||
this.showImage = function($event) {
|
||||
if ($event.target.tagName == 'IMG')
|
||||
ImageGallery.showGallery($event, $ctrl.partIndex);
|
||||
};
|
||||
}
|
||||
|
||||
angular
|
||||
.module('SOGo.MailerUI')
|
||||
.directive('sgZoomableImage', sgZoomableImage);
|
||||
|
||||
Reference in new issue
Block a user