/**
* @ngdoc directives
* @name FileReaderService
* @module s4c.directives.filereade.FileReader
*
*
* @description Módulo de acesso ao Backend
*
*
*
*/
(function () {
angular.module('s4c.directives.ngFileReader')
.factory('ngFileReader', ngFileReader);
function ngFileReader() {
var service = {
_eventos: {
'fileSelected': [],
'fileSelectedPOI': [],
'fileSelectedROTAS': [],
'fileSelectedCAMERAS': [],
'fileSelectedAREAATUACAO': []
},
files: [],
on: on,
fileSelected: fileSelected,
fileSelectedPOI: fileSelectedPOI,
fileSelectedROTAS: fileSelectedROTAS,
fileSelectedCAMERAS: fileSelectedCAMERAS,
fileSelectedAREAATUACAO: fileSelectedAREAATUACAO
};
/**
* Listener de eventos
*
* @method on
*
* @param eventName {String} nome do evento
* @param callback {Function}
*
*
*/
function on(eventName, callback) {
return service._eventos[eventName].push(callback) - 1;
}
/**
* Listener que fica escutando quando novos arquivos são adicionados
*
* @method fileSelected
*
*
* @param file {File}
*
*
*/
function fileSelected(file) {
_.each(service._eventos.fileSelected, function (callback) {
service.files.push(file);
callback(file);
});
}
/**
* Listener com a implementatação de arquivos importados no módulo de Poi
*
* @method fileSelectedPOI
*
*
* @param file {File}
*
*
*/
function fileSelectedPOI(file) {
_.each(service._eventos.fileSelectedPOI, function (callback) {
service.files.push(file);
callback(file);
});
}
/**
* Listener com a implementatação de arquivos importados no módulo de Rotas
*
* @method fileSelectedROTAS
*
*
* @param file {File}
*
*
*/
function fileSelectedROTAS(file) {
_.each(service._eventos.fileSelectedROTAS, function (callback) {
service.files.push(file);
callback(file);
});
}
/**
* Listener com a implementatação de arquivos importados no módulo de Câmeras
*
* @method fileSelectedCAMERAS
*
*
* @param file {File}
*
*
*/
function fileSelectedCAMERAS(file) {
_.each(service._eventos.fileSelectedCAMERAS, function (callback) {
service.files.push(file);
callback(file);
});
}
/**
* Listener com a implementatação de arquivos importados no módulo de Área de Atuação
*
* @method fileSelectedAREAATUACAO
*
*
* @param file {File}
*
*
*/
function fileSelectedAREAATUACAO(file) {
_.each(service._eventos.fileSelectedAREAATUACAO, function (callback) {
service.files.push(file);
callback(file);
});
}
return service;
}
}());