Skip to content

Commit

Permalink
fixed #276 #277
Browse files Browse the repository at this point in the history
  • Loading branch information
Danial Farid authored and Danial Farid committed Jul 27, 2014
1 parent 609cbfd commit 5116122
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 128 deletions.
88 changes: 0 additions & 88 deletions CHANGELOG.md

This file was deleted.

4 changes: 2 additions & 2 deletions demo/src/com/df/angularfileupload/CORSFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain
HttpServletResponse httpResp = (HttpServletResponse) resp;
HttpServletRequest httpReq = (HttpServletRequest) req;

httpResp.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, OPTION");
httpResp.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, OPTIONS");
httpResp.setHeader("Access-Control-Allow-Origin", "*");
if (httpReq.getMethod().equalsIgnoreCase("OPTIONS")) {
httpResp.setHeader("Access-Control-Allow-Headers",
((HttpServletRequest) req).getHeader("Access-Control-Request-Headers"));
httpReq.getHeader("Access-Control-Request-Headers"));
}
chain.doFilter(req, resp);
}
Expand Down
4 changes: 2 additions & 2 deletions demo/war/WEB-INF/appengine-web.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>angular-file-upload</application>
<version>1-6-0</version>
<application>angular-file-upload-cors-srv</application>
<version>1-6-1</version>

<!--
Allows App Engine to send multiple requests to one instance in parallel:
Expand Down
9 changes: 6 additions & 3 deletions demo/war/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
<title>Angular file upload sample</title>
<script type="text/javascript">
FileAPI = {
//debug: true,
debug: true,
//forceLoad: true, html5: false //to debug flash in HTML5 browsers
//wrapInsideDiv: true, //experimental for fixing css issues
//only one of jsPath or jsUrl.
//jsPath: '/js/FileAPI.min.js/folder/',
//jsUrl: 'yourcdn.com/js/FileAPI.min.js',
Expand Down Expand Up @@ -53,12 +54,14 @@ <h3>
<br/>
or multiple files: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="file" ng-file-select="onFileSelect($files)" multiple onclick="this.value=null">
<br/>
or only images: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="file" ng-file-select="onFileSelect($files)" multiple onclick="this.value=null" accept="image/*">
</div>
You can have any element as an upload button: <div ng-file-select="onFileSelect($files)" data-multiple="true" title="aaaa" onclick="this.value = null" class="upload-button">Click here to select file</div>
You can have any element as an upload button: <div ng-file-select="onFileSelect($files)" data-multiple="true" title="select file" onclick="this.value = null" class="upload-button">Click here to select file</div>
<br/>
<br/>
<!-- ng-file-drag-over-class and ng-file-drag-over-delay are optional for styling and css transition handling #277 -->
<div ng-show="dropSupported" class="drop-box" ng-file-drop="onFileSelect($files)" ng-file-drop-available="dropSupported=true"
ng-file-drag-over-class="dragOverClass($event)">or drop files <div>here</div></div>
ng-file-drag-over-class="dragOverClass($event)" ng-file-drag-over-delay="100">or drop files <div>here</div></div>
<div ng-show="!dropSupported">HTML5 Drop File is not supported on this browser</div>
<br/>
<input type="checkbox" ng-model="uploadRightAway">Upload right away
Expand Down
19 changes: 11 additions & 8 deletions demo/war/js/angular-file-upload-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,17 @@ if (!window.FormData || (window.FileAPI && FileAPI.forceLoad)) {
}
var el = angular.element(elem);
if (!el.hasClass('js-fileapi-wrapper') && (elem.getAttribute('ng-file-select') != null || elem.getAttribute('data-ng-file-select') != null)) {
// var wrap = document.createElement('div');
// wrap.innerHTML = '<div class="js-fileapi-wrapper" style="position:relative; overflow:hidden"></div>';
// wrap = wrap.firstChild;
// var parent = elem.parentNode;
// parent.insertBefore(wrap, elem);
// parent.removeChild(elem);
// wrap.appendChild(elem);
el.addClass('js-fileapi-wrapper');
if (FileAPI.wrapInsideDiv) {
var wrap = document.createElement('div');
wrap.innerHTML = '<div class="js-fileapi-wrapper" style="position:relative; overflow:hidden"></div>';
wrap = wrap.firstChild;
var parent = elem.parentNode;
parent.insertBefore(wrap, elem);
parent.removeChild(elem);
wrap.appendChild(elem);
} else {
el.addClass('js-fileapi-wrapper');
}
}
};
var changeFnWrapper = function(fn) {
Expand Down
6 changes: 3 additions & 3 deletions demo/war/js/angular-file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ angularFileUpload.directive('ngFileDrop', [ '$parse', '$timeout', '$location', f
evt.preventDefault();
$timeout.cancel(leaveTimeout);
if (!elem[0].__drag_over_class_) {
var dragOverClassFn = $parse(attr['ngFileDragOverClass']);
if (dragOverClassFn instanceof Function) {
if (attr['ngFileDragOverClass'].search(/\) *$/) > -1) {
dragOverClassFn = $parse(attr['ngFileDragOverClass']);
var dragOverClass = dragOverClassFn(scope, {
$event : evt
});
Expand All @@ -229,7 +229,7 @@ angularFileUpload.directive('ngFileDrop', [ '$parse', '$timeout', '$location', f
leaveTimeout = $timeout(function() {
elem.removeClass(elem[0].__drag_over_class_);
elem[0].__drag_over_class_ = null;
});
}, attr['ngFileDragOverDelay'] || 1);
}, false);
var fn = $parse(attr['ngFileDrop']);
elem[0].addEventListener("drop", function(evt) {
Expand Down
2 changes: 1 addition & 1 deletion demo/war/js/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

angular.module('fileUpload', [ 'angularFileUpload' ]);

var uploadUrl = 'http://angular-file-upload-cors-srv.appspot.com/upload';
//var uploadUrl = 'http://angular-file-upload-cors-srv.appspot.com/upload';
window.uploadUrl = window.uploadUrl || 'upload';

var MyCtrl = [ '$scope', '$http', '$timeout', '$upload', function($scope, $http, $timeout, $upload) {
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-file-upload-html5-shim.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**!
* AngularJS file upload shim for angular XHR HTML5 browsers
* @author Danial <danial.farid@gmail.com>
* @version 1.6.1
* @version 1.6.2
*/
if (window.XMLHttpRequest) {
if (window.FormData) {
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-file-upload-html5-shim.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 12 additions & 9 deletions dist/angular-file-upload-shim.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**!
* AngularJS file upload shim for HTML5 FormData
* @author Danial <danial.farid@gmail.com>
* @version 1.6.1
* @version 1.6.2
*/
(function() {

Expand Down Expand Up @@ -161,14 +161,17 @@ if (!window.FormData || (window.FileAPI && FileAPI.forceLoad)) {
}
var el = angular.element(elem);
if (!el.hasClass('js-fileapi-wrapper') && (elem.getAttribute('ng-file-select') != null || elem.getAttribute('data-ng-file-select') != null)) {
// var wrap = document.createElement('div');
// wrap.innerHTML = '<div class="js-fileapi-wrapper" style="position:relative; overflow:hidden"></div>';
// wrap = wrap.firstChild;
// var parent = elem.parentNode;
// parent.insertBefore(wrap, elem);
// parent.removeChild(elem);
// wrap.appendChild(elem);
el.addClass('js-fileapi-wrapper');
if (FileAPI.wrapInsideDiv) {
var wrap = document.createElement('div');
wrap.innerHTML = '<div class="js-fileapi-wrapper" style="position:relative; overflow:hidden"></div>';
wrap = wrap.firstChild;
var parent = elem.parentNode;
parent.insertBefore(wrap, elem);
parent.removeChild(elem);
wrap.appendChild(elem);
} else {
el.addClass('js-fileapi-wrapper');
}
}
};
var changeFnWrapper = function(fn) {
Expand Down
Loading

0 comments on commit 5116122

Please sign in to comment.