forked from twilson63/ngUpload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
201 lines (193 loc) · 7.81 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<meta charset="utf8">
<title>
ngUpload - Examples
</title>
<link href="libs/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<style type="text/css">
body {
font-family: Verdana;
font-size: 12px;
}
h1 {
font-size: 20px;
font-weight: normal;
border-bottom: 1px solid gray;
padding-bottom: 5px;
margin-bottom: 5px;
display: block;
}
</style>
</head>
<body>
<div class="container" ng-app="ngUploadApp">
<div ng-controller="Example1Ctrl">
<h1>
Example 1 - Running with default configuration (requirement: v0.1.1 and above)
</h1><span>Current value of foo is: <b>{{foo}}</b>. <i>(Works with the active $scope.)</i></span><br>
<br>
<form id="foo" ng-upload="bar(content)" method="post" action="/upload?delay=yes" name="foo">
<p>
<label>Select a file to upload:</label> <input type="file" name="file">
</p>
<p>
<input type="submit" class="btn" value="Submit" ng-disabled="$isUploading"><br>
<i>Button is not <b>disabled</b> during upload. (version 0.5 and greater).</i> You can disable by using <b>ng-disabled</b>
</p>
</form>
<div class="alert alert-info">
Server Response:
<div>
{{uploadResponse}}
</div>
</div>
</div>
<div ng-controller="Example2Ctrl">
<h1>
Example 2 - 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)" 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 style="text-align: center; cursor: pointer; padding: 10px; background-color: black; color: white;" upload-submit="">
With a div
</div>
</div>
<div class="span4">
<a ng-href="javascript:void(0)" style="padding: 10px; display: block;" upload-submit="">With a link.</a>
</div>
<div class="span4">
<button class="btn btn-small btn-primary" upload-submit=""> With an image button.</button>
</div>
</div>
</div>
</form>
<div class="alert alert-info">
Server Response: {{uploadResponse}}
</div>
</div>
<div ng-controller="Example3Ctrl">
<h1>
Example 3 - Processing Callback Function Contents (requirement: v0.2.0 and above)
</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 3.1: The example below displays all statuses, without inspection.</span><br>
<br>
<form ng-upload="uploadFile1(content)" action="/upload?delay=yes">
<p>
<label>Select a file to upload:</label> <input type="file" name="file">
</p>
<p>
<input type="submit" class="btn" value="Submit" ng-disabled="$isUploading">
</p>
</form>
<div class="alert alert-info">
Server Response: {{uploadResponse1}}
</div><br>
<span style="font-size: 15px">Example 3.2: The example below displays only the server response, ignoring other contents</span><br>
<br>
<form ng-upload="uploadFile2(content)" ng-upload-loading="startUploading()" action="/upload?delay=yes">
<p>
<label>Select a file to upload:</label> <input type="file" name="file">
</p>
<p>
<input type="submit" class="btn" value="Submit" ng-disabled="$isUploading">
</p>
</form>
<div class="alert alert-info">
Server Response: {{uploadResponse2}}
</div>
</div>
<div ng-controller="Example4Ctrl">
<h1>
Example 4 - Processing a full form (requirement: v0.2.0)
</h1>Post a full form with a file and other inputs (text, etc) to the server and get a JSON result.<br>
<br>
<form ng-upload="uploadComplete(content)" action="/upload-full-form">
<p>
<label>Fullname:</label> <input type="text" name="fullname" ng-model="fullname">
</p>
<p>
<label>Gender:</label> <input type="text" name="gender" ng-model="gender">
</p>
<p>
<label>Favourite Color:</label> <input type="text" name="color" ng-model="color">
</p>
<p>
<label>Your picture (file will not be saved on the server):</label> <input type="file" name="file">
</p>
<p>
<input type="submit" class="btn" value="Submit" ng-disabled="$isUploading">
</p>
</form>
<div class="alert alert-info">
Server Response: {{response | json}}
</div>
<div>
Fullname: <b>{{response.fullname}}</b><br>
Gender: <b>{{response.gender}}</b><br>
Favourite Color: <span ng-style="response.style">{{response.color}}</span><br>
Picture: {{response.pictureUrl}}
</div>
</div>
</div><!-- <script src="libs/js/jquery-1.9.1.min.js"></script> -->
<script src="libs/js/angular.min.js" type="text/javascript"></script>
<script src="libs/js/ng-upload.js" type="text/javascript"></script>
<script type="text/javascript">
// TODO add ng-upload module
var app = angular.module('ngUploadApp', ['ngUpload']);
app.controller('Example1Ctrl', function ($scope) {
$scope.foo = "Hello World";
$scope.disabled = false;
$scope.bar = function(content) {
if (console) console.log(content);
$scope.uploadResponse = content.msg;
}
});
app.controller('Example2Ctrl', function ($scope) {
$scope.uploadFile = function (content) {
if (console) console.log(content);
$scope.uploadResponse = content.msg;
}
});
app.controller('Example3Ctrl', function ($scope) {
$scope.startUploading = function() {
console.log('uploading....');
$scope.uploadResponse2 = "[Status: Uploading] ";
};
$scope.uploadFile1 = function (content, completed) {
if (console) console.log(content);
$scope.uploadResponse1 = content.msg;
};
$scope.uploadFile2 = function (content) {
if (console) console.log(content);
$scope.uploadResponse2 = "[Status: Completed] " + content.msg;
};
});
app.controller('Example4Ctrl', function ($scope) {
$scope.startUploading = function() {
console.log('uploading....')
};
$scope.uploadComplete = function (content) {
if (console) console.log(content);
$scope.response = content; // Presumed content is a json string!
$scope.response.style = {
color: $scope.response.color,
"font-weight": "bold"
};
// Clear form (reason for using the 'ng-model' directive on the input elements)
$scope.fullname = '';
$scope.gender = '';
$scope.color = '';
// Look for way to clear the input[type=file] element
}
});
</script>
</body>
</html>