Skip to content

Commit

Permalink
Merge pull request twilson63#10 from adebisi-fa/master
Browse files Browse the repository at this point in the history
Addition of ngUpload to NuGet package library, bug fixes, and feature enhancements.
  • Loading branch information
Tom Wilson committed Mar 8, 2013
2 parents 5163fc1 + eee6866 commit dbd9d91
Show file tree
Hide file tree
Showing 16 changed files with 407 additions and 24 deletions.
10 changes: 5 additions & 5 deletions examples/aspnet.mvc/Content/libs/js/ng-upload.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Version 0.1.0
// Version 0.1.1
// AngularJS simple file upload directive
// this directive uses an iframe as a target
// to enable the uploading of files without
Expand Down Expand Up @@ -34,7 +34,7 @@ angular.module('ngUpload', [])
// }
var options = {};
options.enableControls = attrs['uploadOptionsEnableControls'];

// get scope function to execute on successful form upload
if (attrs['ngUpload']) {

Expand All @@ -45,7 +45,7 @@ angular.module('ngUpload', [])

// Retrieve the callback function
var fn = attrs['ngUpload'].split('(')[0];
var callbackFn = scope[fn];
var callbackFn = scope.$eval(fn);

// Helper function to create new iframe for each form submission
var addNewDisposableIframe = function (submitControl) {
Expand All @@ -59,7 +59,7 @@ angular.module('ngUpload', [])
var content = iframe.contents().find('body').text();

// execute the upload response function in the active scope
scope.$apply(function () { callbackFn(content); });
scope.$apply(function () { callbackFn(content, true /* upload completed */); });

// remove iframe
if (content != "") // Fixes a bug in Google Chrome that dispose the iframe before content is ready.
Expand All @@ -81,7 +81,7 @@ angular.module('ngUpload', [])

addNewDisposableIframe($(this) /* pass the submit control */);

scope.$apply(function () { callbackFn("Please wait..."); });
scope.$apply(function () { callbackFn("Please wait...", false /* upload not completed */); });

//console.log(angular.toJson(options));

Expand Down
45 changes: 45 additions & 0 deletions examples/aspnet.mvc/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,36 @@
</form>
<div class="alert alert-info">Server Response: {{uploadResponse}}</div>
</div>
<div ng-controller="Example4Ctrl">
<h1>Example 4 - Processing Callback Function Contents</h1>
Make use of the additional callback status information to decide what to do with the content.
<br /><br />
<span style="font-size: 15px">Example 4.1: The example below displays all statuses, without inspection.</span>
<br /><br />
<form ng-upload="uploadFile1" action="/upload?delay=yes">
<p>
<label>Select a file to upload:</label>
<input type="file" name="file" />
</p>
<p>
<input type="submit" class="btn upload-submit" value="Submit" />
</p>
</form>
<div class="alert alert-info">Server Response: {{uploadResponse1}}</div>
<br />
<span style="font-size: 15px">Example 4.2: The example below displays only the server response, ignoring other contents</span>
<br /><br />
<form ng-upload="uploadFile2" action="/upload?delay=yes">
<p>
<label>Select a file to upload:</label>
<input type="file" name="file" />
</p>
<p>
<input type="submit" class="btn upload-submit" value="Submit" />
</p>
</form>
<div class="alert alert-info">Server Response: {{uploadResponse2}}</div>
</div>
</div>
<script src="~/Content/libs/js/jquery-1.9.1.min.js"></script>
<script src="~/Content/libs/js/angular.min.js"></script>
Expand Down Expand Up @@ -123,6 +153,21 @@
$scope.uploadResponse = content;
}
});
app.controller('Example4Ctrl', function ($scope) {
$scope.uploadFile1 = function (content, isComplete) {
console.log(content);
$scope.uploadResponse1 = content;
};
$scope.uploadFile2 = function (content, isComplete) {
console.log(content);
if (isComplete)
$scope.uploadResponse2 = "[Status: Completed] " + content;
else
$scope.uploadResponse2 = "[Status: Incomplete] Content ignored. Check log the actual content.";
}
});
</script>
</body>
</html>
45 changes: 45 additions & 0 deletions examples/nodejs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,36 @@ <h1>Example 3 - Submitting forms with any html element</h1>
</form>
<div class="alert alert-info">Server Response: {{uploadResponse}}</div>
</div>
<div ng-controller="Example4Ctrl">
<h1>Example 4 - Processing Callback Function Contents</h1>
Make use of the additional callback status information to decide what to do with the content.
<br /><br />
<span style="font-size: 15px">Example 4.1: The example below displays all statuses, without inspection.</span>
<br /><br />
<form ng-upload="uploadFile1" action="/upload?delay=yes">
<p>
<label>Select a file to upload:</label>
<input type="file" name="file" />
</p>
<p>
<input type="submit" class="btn upload-submit" value="Submit" />
</p>
</form>
<div class="alert alert-info">Server Response: {{uploadResponse1}}</div>
<br />
<span style="font-size: 15px">Example 4.2: The example below displays only the server response, ignoring other contents</span>
<br /><br />
<form ng-upload="uploadFile2" action="/upload?delay=yes">
<p>
<label>Select a file to upload:</label>
<input type="file" name="file" />
</p>
<p>
<input type="submit" class="btn upload-submit" value="Submit" />
</p>
</form>
<div class="alert alert-info">Server Response: {{uploadResponse2}}</div>
</div>
</div>
<script src="libs/js/jquery-1.9.1.min.js"></script>
<script src="libs/js/angular.min.js"></script>
Expand Down Expand Up @@ -119,6 +149,21 @@ <h1>Example 3 - Submitting forms with any html element</h1>
$scope.uploadResponse = content;
}
});

app.controller('Example4Ctrl', function ($scope) {
$scope.uploadFile1 = function (content, isComplete) {
console.log(content);
$scope.uploadResponse1 = content;
};

$scope.uploadFile2 = function (content, isComplete) {
console.log(content);
if (isComplete)
$scope.uploadResponse2 = "[Status: Completed] " + content;
else
$scope.uploadResponse2 = "[Status: Incomplete] Content ignored. Check log the actual content.";
}
});
</script>
</body>
</html>
10 changes: 5 additions & 5 deletions examples/nodejs/libs/js/ng-upload.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Version 0.1.0
// Version 0.1.1
// AngularJS simple file upload directive
// this directive uses an iframe as a target
// to enable the uploading of files without
Expand Down Expand Up @@ -34,7 +34,7 @@ angular.module('ngUpload', [])
// }
var options = {};
options.enableControls = attrs['uploadOptionsEnableControls'];

// get scope function to execute on successful form upload
if (attrs['ngUpload']) {

Expand All @@ -45,7 +45,7 @@ angular.module('ngUpload', [])

// Retrieve the callback function
var fn = attrs['ngUpload'].split('(')[0];
var callbackFn = scope[fn];
var callbackFn = scope.$eval(fn);

// Helper function to create new iframe for each form submission
var addNewDisposableIframe = function (submitControl) {
Expand All @@ -59,7 +59,7 @@ angular.module('ngUpload', [])
var content = iframe.contents().find('body').text();

// execute the upload response function in the active scope
scope.$apply(function () { callbackFn(content); });
scope.$apply(function () { callbackFn(content, true /* upload completed */); });

// remove iframe
if (content != "") // Fixes a bug in Google Chrome that dispose the iframe before content is ready.
Expand All @@ -81,7 +81,7 @@ angular.module('ngUpload', [])

addNewDisposableIframe($(this) /* pass the submit control */);

scope.$apply(function () { callbackFn("Please wait..."); });
scope.$apply(function () { callbackFn("Please wait...", false /* upload not completed */); });

//console.log(angular.toJson(options));

Expand Down
8 changes: 4 additions & 4 deletions ng-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ angular.module('ngUpload', [])
// }
var options = {};
options.enableControls = attrs['uploadOptionsEnableControls'];

// get scope function to execute on successful form upload
if (attrs['ngUpload']) {

Expand All @@ -45,7 +45,7 @@ angular.module('ngUpload', [])

// Retrieve the callback function
var fn = attrs['ngUpload'].split('(')[0];
var callbackFn = scope[fn];
var callbackFn = scope.$eval(fn);

// Helper function to create new iframe for each form submission
var addNewDisposableIframe = function (submitControl) {
Expand All @@ -59,7 +59,7 @@ angular.module('ngUpload', [])
var content = iframe.contents().find('body').text();

// execute the upload response function in the active scope
scope.$apply(function () { callbackFn(content); });
scope.$apply(function () { callbackFn(content, true /* upload completed */); });

// remove iframe
if (content != "") // Fixes a bug in Google Chrome that dispose the iframe before content is ready.
Expand All @@ -81,7 +81,7 @@ angular.module('ngUpload', [])

addNewDisposableIframe($(this) /* pass the submit control */);

scope.$apply(function () { callbackFn("Please wait..."); });
scope.$apply(function () { callbackFn("Please wait...", false /* upload not completed */); });

//console.log(angular.toJson(options));

Expand Down
2 changes: 1 addition & 1 deletion ng-upload.min.js

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

4 changes: 2 additions & 2 deletions ng-upload.min.js.map

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

Binary file added nuget/ngUpload/AngularJS.ngUpload.0.1.1.nupkg
Binary file not shown.
28 changes: 28 additions & 0 deletions nuget/ngUpload/AngularJS.ngUpload.0.1.1.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>AngularJS.ngUpload</id>
<version>0.1.1</version>
<title>AngularJS.ngUpload - (using iFrame)</title>
<authors>Tom Wilson,Adebisi-Fa</authors>
<owners>Tom Wilson</owners>
<projectUrl>http://twilson63.github.com/ngUpload</projectUrl>
<iconUrl>http://altdstore.blob.core.windows.net/ngupload/ngUpload-Nuget-Logo.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>An AngularJS Directive that uses hidden iFrame for uploading files. It works across browsers (even non-HTML5 complaint one) down to IE6.</description>
<summary />
<language>en-US</language>
<dependencies>
<dependency id="jQuery" version="1.9.1" />
<dependency id="angularjs" version="1.0.5" />
</dependencies>
</metadata>
<files>
<file src="..\..\examples\nodejs\libs\css\images\glyphicons-halflings-white.png" target="content\Content\css\images\glyphicons-halflings-white.png" />
<file src="..\..\examples\nodejs\libs\css\images\glyphicons-halflings.png" target="content\Content\css\images\glyphicons-halflings.png" />
<file src="..\..\examples\nodejs\libs\css\bootstrap.min.css" target="content\Content\css\bootstrap.min.css" />
<file src="..\..\ng-upload.js" target="content\Scripts\ng-upload.js" />
<file src="..\..\ng-upload.min.js" target="content\Scripts\ng-upload.min.js" />
<file src="..\..\examples\nodejs\index.html" target="content\ng-upload-sample.html" />
</files>
</package>
9 changes: 9 additions & 0 deletions nuget/ngUpload/content/Content/css/bootstrap.min.css

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit dbd9d91

Please sign in to comment.