Skip to content

Commit

Permalink
Updated: ng-file-select directive (single and multiple selection)
Browse files Browse the repository at this point in the history
  • Loading branch information
nerv committed Feb 17, 2014
1 parent 729044a commit 88da09e
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 40 deletions.
34 changes: 5 additions & 29 deletions angular-file-upload.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
Angular File Upload v0.3.2
https://github.com/nervgh/angular-file-upload
*/
(function(angular, factory) {
if (typeof define === 'function' && define.amd) {
define('angular-file-upload', ['angular'], function(angular) {
Expand All @@ -7,19 +11,8 @@
return factory(angular);
}
}(angular || null, function(angular) {
/**
* The angular file upload module
* @author: nerv
* @version: 0.3.1, 2014-01-05
*/
var app = angular.module('angularFileUpload', []);

/**
* The angular file upload module
* @author: nerv
* @version: 0.3.1, 2014-01-05
*/

// It is attached to an element that catches the event drop file
app.directive('ngFileDrop', [ '$fileUploader', function ($fileUploader) {
'use strict';
Expand Down Expand Up @@ -54,12 +47,6 @@ app.directive('ngFileDrop', [ '$fileUploader', function ($fileUploader) {
}
};
}])
/**
* The angular file upload module
* @author: nerv
* @version: 0.3.1, 2014-01-05
*/

// It is attached to an element which will be assigned to a class "ng-file-over" or ng-file-over="className"
app.directive('ngFileOver', function () {
'use strict';
Expand All @@ -75,12 +62,6 @@ app.directive('ngFileOver', function () {
}
};
});
/**
* The angular file upload module
* @author: nerv
* @version: 0.3.1, 2014-01-05
*/

// It is attached to <input type="file"> element like <ng-file-select="options">
app.directive('ngFileSelect', [ '$fileUploader', function ($fileUploader) {
'use strict';
Expand All @@ -91,18 +72,13 @@ app.directive('ngFileSelect', [ '$fileUploader', function ($fileUploader) {

element.bind('change', function () {
scope.$emit('file:add', $fileUploader.isHTML5 ? this.files : this, scope.$eval(attributes.ngFileSelect));
$fileUploader.isHTML5 && element.prop('value', null);
($fileUploader.isHTML5 && element.attr('multiple')) && element.prop('value', null);
});

element.prop('value', null); // FF fix
}
};
}]);
/**
* The angular file upload module
* @author: nerv
* @version: 0.3.1, 2014-01-05
*/
app.factory('$fileUploader', [ '$compile', '$rootScope', '$http', '$window', function ($compile, $rootScope, $http, $window) {
'use strict';

Expand Down
6 changes: 5 additions & 1 deletion angular-file-upload.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion angular-file-upload.min.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-file-upload",
"version": "0.3.1",
"version": "0.3.2",
"main": "angular-file-upload.js",
"homepage": "https://github.com/nervgh/angular-file-upload",
"ignore": [],
Expand Down
5 changes: 4 additions & 1 deletion examples/simple/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,11 @@ <h3>Select files</h3>
</div>

<!-- 2. ng-file-select | ng-file-select="options" -->
<input ng-file-select type="file" multiple />
Multiple
<input ng-file-select type="file" multiple /><br/>

Single
<input ng-file-select type="file" />
</div>

<div class="col-md-9" style="margin-bottom: 40px">
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Angular File Upload",
"version": "0.3.1",
"version": "0.3.2",
"homepage": "https://github.com/nervgh/angular-file-upload",
"description": "Angular File Upload is a module for the AngularJS framework",
"author": {
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* The angular file upload module
* @author: nerv
* @version: 0.3.1, 2014-01-05
* @version: 0.3.2, 2014-02-18
*/
var app = angular.module('angularFileUpload', []);
2 changes: 1 addition & 1 deletion src/scripts/directives/ngFileDrop.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* The angular file upload module
* @author: nerv
* @version: 0.3.1, 2014-01-05
* @version: 0.3.2, 2014-02-18
*/

// It is attached to an element that catches the event drop file
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/directives/ngFileOver.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* The angular file upload module
* @author: nerv
* @version: 0.3.1, 2014-01-05
* @version: 0.3.2, 2014-02-18
*/

// It is attached to an element which will be assigned to a class "ng-file-over" or ng-file-over="className"
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/directives/ngFileSelect.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* The angular file upload module
* @author: nerv
* @version: 0.3.1, 2014-01-05
* @version: 0.3.2, 2014-02-18
*/

// It is attached to <input type="file"> element like <ng-file-select="options">
Expand All @@ -14,7 +14,7 @@ app.directive('ngFileSelect', [ '$fileUploader', function ($fileUploader) {

element.bind('change', function () {
scope.$emit('file:add', $fileUploader.isHTML5 ? this.files : this, scope.$eval(attributes.ngFileSelect));
$fileUploader.isHTML5 && element.prop('value', null);
($fileUploader.isHTML5 && element.attr('multiple')) && element.prop('value', null);
});

element.prop('value', null); // FF fix
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/services/$fileUploader.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* The angular file upload module
* @author: nerv
* @version: 0.3.1, 2014-01-05
* @version: 0.3.2, 2014-02-18
*/
app.factory('$fileUploader', [ '$compile', '$rootScope', '$http', '$window', function ($compile, $rootScope, $http, $window) {
'use strict';
Expand Down

0 comments on commit 88da09e

Please sign in to comment.