github.com/apremalal/vamps-core@v1.0.1-0.20161221121535-d430b56ec174/server/webapps/app/base/plugins/jquery-file-upload/js/app.js (about) 1 /* 2 * jQuery File Upload Plugin Angular JS Example 1.2.1 3 * https://github.com/blueimp/jQuery-File-Upload 4 * 5 * Copyright 2013, Sebastian Tschan 6 * https://blueimp.net 7 * 8 * Licensed under the MIT license: 9 * http://www.opensource.org/licenses/MIT 10 */ 11 12 /* jshint nomen:false */ 13 /* global window, angular */ 14 15 (function () { 16 'use strict'; 17 18 var isOnGitHub = window.location.hostname === 'blueimp.github.io', 19 url = isOnGitHub ? '//jquery-file-upload.appspot.com/' : 'server/php/'; 20 21 angular.module('demo', [ 22 'blueimp.fileupload' 23 ]) 24 .config([ 25 '$httpProvider', 'fileUploadProvider', 26 function ($httpProvider, fileUploadProvider) { 27 delete $httpProvider.defaults.headers.common['X-Requested-With']; 28 fileUploadProvider.defaults.redirect = window.location.href.replace( 29 /\/[^\/]*$/, 30 '/cors/result.html?%s' 31 ); 32 if (isOnGitHub) { 33 // Demo settings: 34 angular.extend(fileUploadProvider.defaults, { 35 // Enable image resizing, except for Android and Opera, 36 // which actually support image resizing, but fail to 37 // send Blob objects via XHR requests: 38 disableImageResize: /Android(?!.*Chrome)|Opera/ 39 .test(window.navigator.userAgent), 40 maxFileSize: 5000000, 41 acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i 42 }); 43 } 44 } 45 ]) 46 47 .controller('DemoFileUploadController', [ 48 '$scope', '$http', '$filter', '$window', 49 function ($scope, $http) { 50 $scope.options = { 51 url: url 52 }; 53 if (!isOnGitHub) { 54 $scope.loadingFiles = true; 55 $http.get(url) 56 .then( 57 function (response) { 58 $scope.loadingFiles = false; 59 $scope.queue = response.data.files || []; 60 }, 61 function () { 62 $scope.loadingFiles = false; 63 } 64 ); 65 } 66 } 67 ]) 68 69 .controller('FileDestroyController', [ 70 '$scope', '$http', 71 function ($scope, $http) { 72 var file = $scope.file, 73 state; 74 if (file.url) { 75 file.$state = function () { 76 return state; 77 }; 78 file.$destroy = function () { 79 state = 'pending'; 80 return $http({ 81 url: file.deleteUrl, 82 method: file.deleteType 83 }).then( 84 function () { 85 state = 'resolved'; 86 $scope.clear(file); 87 }, 88 function () { 89 state = 'rejected'; 90 } 91 ); 92 }; 93 } else if (!file.$cancel && !file._index) { 94 file.$cancel = function () { 95 $scope.clear(file); 96 }; 97 } 98 } 99 ]); 100 101 }());