(function () { 'use strict'; var streamApp = angular.module('streamApp'); streamApp.directive('uploadDropDirective', [UploadDropDirective]); const size = 70; const mb = 1000000; const mbSize = size * mb; function UploadDropDirective() { return { restrict: 'E', scope: { uploader: '=' }, templateUrl: 'App/Directives/uploaderDropDirective.html?v=6.0.0c', link: function (scope, element, attrs) { scope.message = ['File size is too big.', 'Max file size is ' + size + ' MB']; scope.uploader.filters.push({ name: 'imageFilter', fn: function (item /*{File|FileLikeObject}*/, options) { var type = '|' + item.type.slice(0, item.type.lastIndexOf('/')); return '|video|image|'.indexOf(type) !== -1; } }); scope.$watch('uploader.queue.length', function () { if (scope.uploader.queue && scope.uploader.queue.length) { var tooBigIndex = scope.uploader.queue.findIndex(x => x.file.size > mbSize); if (tooBigIndex > -1) { scope.tooBig = true; scope.uploader.queue.splice(tooBigIndex, 1); } } }); } }; }; })();