49 lines
1.5 KiB
JavaScript
49 lines
1.5 KiB
JavaScript
/**
|
|
* Created by lobanovana on 23.03.2016.
|
|
*/
|
|
angular.module("mediaModal")
|
|
.controller("cameraController", ['$scope', '$http', 'upload_url', function ($scope, $http, upload_url) {
|
|
$scope.upload_url = upload_url;
|
|
$scope.options = {
|
|
url: upload_url
|
|
};
|
|
$scope.loadingFiles = true;
|
|
$http.get(upload_url)
|
|
.then(
|
|
function (response) {
|
|
$scope.loadingFiles = false;
|
|
$scope.filequeue = response.data.files || [];
|
|
//console.log($scope.queue);
|
|
},
|
|
function () {
|
|
$scope.loadingFiles = false;
|
|
}
|
|
);
|
|
|
|
$scope.selectImage = function(image){
|
|
|
|
//console.log(image);
|
|
|
|
image.selected = !image.selected;
|
|
image.thumbnail = image.url;
|
|
if ($scope.selectedImages){
|
|
if (image.selected){
|
|
$scope.selectedImages.push(image);
|
|
return;
|
|
}
|
|
var imageIndex = $scope.selectedImages.indexOf(image);
|
|
if (imageIndex != -1){
|
|
$scope.selectedImages.splice(imageIndex, 1);
|
|
}
|
|
}
|
|
};
|
|
|
|
$scope.$on('fileuploaddone', function(e, data){
|
|
// Your code here
|
|
$.each(data.result.files, function (index, file) {
|
|
$scope.selectImage(file);
|
|
});
|
|
});
|
|
|
|
}
|
|
]); |