Skip to content

Commit

Permalink
fixed examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Wilson committed Apr 27, 2013
1 parent 4e3fd8e commit 6e419b0
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 80 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified examples/nodejs/.DS_Store
Binary file not shown.
20 changes: 10 additions & 10 deletions examples/nodejs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ <h1>Example 2 - Using Options: <b>uploadOptionsEnableControls</b> option (requir
</span>
<br />
<br />
<form ng-upload="uploadFile(content)" action="/upload?delay=yes" upload-options-enable-controls>
<form ng-upload action="/upload?delay=yes" upload-options-enable-controls>
<p>
<label>Select a file to upload:</label>
<input type="file" name="file" />
</p>
<p>
<input type="submit" class="btn upload-submit" value="Submit" />
<input type="submit" class="btn" value="Submit" upload-submit="uploadFile(content, completed)" />
</p>
</form>
<div class="alert alert-info">Server Response: {{uploadResponse}}</div>
Expand All @@ -68,23 +68,23 @@ <h1>Example 2 - Using Options: <b>uploadOptionsEnableControls</b> option (requir
<h1>Example 3 - Submitting forms with any html element (requirement: v0.1.1 and above)</h1>
<span>This examples show how to use any html element to submit your form. It makes use of a 'div', an 'a', and an 'img' tags to submit the same form.</span>
<br />
<form ng-upload="uploadFile(content, completed)" action="/upload?delay=yes">
<form ng-upload action="/upload?delay=yes">
<p>
<label>Select a file to upload:</label>
<input type="file" name="file" />
</p>
<div style="width:550px">
<div class="row-fluid">
<div class="span4">
<div class="upload-submit" style="text-align: center; cursor: pointer; padding: 10px; background-color: black; color: white;">
<div style="text-align: center; cursor: pointer; padding: 10px; background-color: black; color: white;" upload-submit="uploadFile(content, completed)">
With a div
</div>
</div>
<div class="span4">
<a class="upload-submit" href="javascript:void(0)" style="padding: 10px; display: block;">With a link.</a>
<a ng-href="javascript:void(0)" style="padding: 10px; display: block;" upload-submit="uploadFile(content, completed)">With a link.</a>
</div>
<div class="span4">
<button class="btn btn-small btn-primary upload-submit"><i class="icon-arrow-up icon-white"></i>&nbsp;With an image button.</button>
<button class="btn btn-small btn-primary" upload-submit="uploadFile(content, completed)"><i class="icon-arrow-up icon-white"></i>&nbsp;With an image button.</button>
</div>
</div>
</div>
Expand All @@ -97,26 +97,26 @@ <h1>Example 4 - Processing Callback Function Contents (requirement: v0.2.0 and a
<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(content, completed)" action="/upload?delay=yes">
<form ng-upload 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" />
<input type="submit" class="btn" upload-submit="uploadFile1(content, completed)" 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(content, completed)" action="/upload?delay=yes">
<form ng-upload 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" />
<input type="submit" class="btn" upload-submit="uploadFile2(content, completed)" value="Submit" />
</p>
</form>
<div class="alert alert-info">Server Response: {{uploadResponse2}}</div>
Expand Down
Binary file modified examples/nodejs/libs/.DS_Store
Binary file not shown.
18 changes: 8 additions & 10 deletions examples/nodejs/libs/js/ng-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// });
//
angular.module('ngUpload', [])
.directive('uploadSubmit', ['$parse', '$window', '$http', function($parse, $window, $http) {
.directive('uploadSubmit', ['$parse', function($parse) {
return {
restrict: 'AC',
link: function(scope, element, attrs) {
Expand All @@ -38,7 +38,7 @@ angular.module('ngUpload', [])
options.enableControls = attrs.uploadOptionsEnableControls;

// submit the form - requires jQuery
var form = element.parents('form[ng-upload]') || element.parents('form.ng-upload');
var form = angular.element(element.parents('form[ng-upload]')) || angular.element(element.parents('form.ng-upload'));

// Retrieve the callback function
var fn = $parse(attrs.uploadSubmit);
Expand All @@ -47,14 +47,12 @@ angular.module('ngUpload', [])
var message = "The expression on the ngUpload directive does not point to a valid function.";
throw message + "\n";
}
// form.bind('submit', function() {
// return false;
// });


element.bind('click', function($event) {
// prevent default behavior of click
//$event.preventDefault = true;

if ($event) {
$event.preventDefault = true;
}
// create a new iframe
var iframe = angular.element("<iframe id='upload_iframe' name='upload_iframe' border='0' width='0' height='0' style='width: 0px; height: 0px; border: none; display: none' />");

Expand Down Expand Up @@ -91,14 +89,14 @@ angular.module('ngUpload', [])
element.attr('title', (enabled ? '[ENABLED]: ' : '[DISABLED]: ') + 'Uploading, please wait...');

form.submit();
//return false;

}).attr('title', 'Click to start upload.');
}
};
}])
.directive('ngUpload', ['$parse', function ($parse) {
return {
restrict: 'ACE',
restrict: 'AC',
link: function (scope, element, attrs) {
element.attr("target", "upload_iframe");
element.attr("method", "post");
Expand Down
59 changes: 0 additions & 59 deletions examples/nodejs/upload.old

This file was deleted.

2 changes: 1 addition & 1 deletion ng-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ angular.module('ngUpload', [])
options.enableControls = attrs.uploadOptionsEnableControls;

// submit the form - requires jQuery
var form = element.parents('form[ng-upload]') || element.parents('form.ng-upload');
var form = angular.element(element.parents('form[ng-upload]')) || angular.element(element.parents('form.ng-upload'));

// Retrieve the callback function
var fn = $parse(attrs.uploadSubmit);
Expand Down

0 comments on commit 6e419b0

Please sign in to comment.