Skip to content

Commit b5ef52d

Browse files
Added javascript to load files on start
1 parent d26e01b commit b5ef52d

File tree

9 files changed

+111
-12
lines changed

9 files changed

+111
-12
lines changed

jQuery-File-Upload.MVC3/Content/FileUpload/main.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,26 @@ $(function () {
2222
maxFileSize: 500000000,
2323
resizeMaxWidth: 1920,
2424
resizeMaxHeight: 1200
25-
});
25+
});
26+
27+
$('#fileupload').addClass('fileupload-processing');
28+
$.ajax({
29+
// Uncomment the following to send cross-domain cookies:
30+
//xhrFields: {withCredentials: true},
31+
url: '/Upload/UploadHandler.ashx',
32+
dataType: 'json',
33+
context: $('#fileupload')[0]
34+
}).always(function () {
35+
$(this).removeClass('fileupload-processing');
36+
}).done(function (result) {
37+
$(this).fileupload('option', 'done')
38+
.call(this, null, { result: result });
39+
});
40+
41+
$('button.btn btn-danger delete').hide();
42+
43+
44+
45+
2646
});
47+

jQuery-File-Upload.MVC3/Controllers/HomeController.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ public ActionResult Index()
1919
return View();
2020
}
2121

22+
23+
public string LetTheGamesBegin()
24+
{
25+
return "<tr><td colspan=5>HELLO WORLD</td></tr>";
26+
}
2227
//DONT USE THIS IF YOU NEED TO ALLOW LARGE FILES UPLOADS
2328
[HttpGet]
2429
public void Delete(string id)

jQuery-File-Upload.MVC3/Upload/FilesStatus.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class FilesStatus
1717
public string delete_url { get; set; }
1818
public string delete_type { get; set; }
1919
public string error { get; set; }
20+
public string test { get; set; }
2021

2122
public FilesStatus() { }
2223

jQuery-File-Upload.MVC3/Upload/UploadHandler.ashx.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,5 +193,12 @@ private void ListCurrentFiles(HttpContext context)
193193
context.Response.ContentType = "application/json";
194194
}
195195

196+
197+
198+
199+
200+
201+
202+
196203
}
197204
}

jQuery-File-Upload.MVC3/Views/Home/Index.cshtml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
@using ClientDependency.Core.Mvc
1+
@using ClientDependency.Core
2+
@using ClientDependency.Core.Mvc
3+
24

35
@{
46
ViewBag.Title = "Bootstrap version demo";
@@ -78,7 +80,10 @@ PER ACTION BASIS *@
7880
<div class="fileupload-loading"></div>
7981
<br>
8082
<!-- The table listing the files available for upload/download -->
81-
<table class="table table-striped"><tbody class="files" data-toggle="modal-gallery" data-target="#modal-gallery"></tbody></table>
83+
<table class="table table-striped">
84+
<thead><tr><td style="width:10px;"><td>Thumbnail</td><td>File Name</td><td>File Size</td><td colspan="2"></td></tr></thead>
85+
<tbody class="files" data-toggle="modal-gallery" data-target="#modal-gallery">
86+
</tbody></table>
8287
</form>
8388

8489
<!-- modal-gallery is the modal dialog used for the image gallery -->
@@ -112,6 +117,7 @@ PER ACTION BASIS *@
112117
<script id="template-upload" type="text/x-tmpl">
113118
{% for (var i=0, file; file=o.files[i]; i++) { %}
114119
<tr class="template-upload fade">
120+
<td style="width:10px;"></td>
115121
<td class="preview"><span class="fade"></span></td>
116122
<td class="name"><span>{%=file.name%}</span></td>
117123
<td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
@@ -143,7 +149,14 @@ PER ACTION BASIS *@
143149
<script id="template-download" type="text/x-tmpl">
144150
{% for (var i=0, file; file=o.files[i]; i++) { %}
145151
<tr class="template-download fade">
146-
{% if (file.error) { %}
152+
<td class="delete" style="width:10px;">
153+
<button style="width:0px; visibility: hidden;" class="btn btn-danger" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}">
154+
<i class="icon-trash icon-white"></i>
155+
<span>{%=locale.fileupload.destroy%}</span>
156+
</button>
157+
<input type="checkbox" name="delete" value="1">
158+
</td>
159+
{% if (file.error) { %}
147160
<td></td>
148161
<td class="name"><span>{%=file.name%}</span></td>
149162
<td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
@@ -158,13 +171,8 @@ PER ACTION BASIS *@
158171
<td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
159172
<td colspan="2"></td>
160173
{% } %}
161-
<td class="delete">
162-
<button class="btn btn-danger" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}">
163-
<i class="icon-trash icon-white"></i>
164-
<span>{%=locale.fileupload.destroy%}</span>
165-
</button>
166-
<input type="checkbox" name="delete" value="1">
167-
</td>
174+
<!--
175+
-->
168176
</tr>
169177
{% } %}
170178
</script>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!DOCTYPE html>
2+
@using ClientDependency.Core
3+
@using ClientDependency.Core.Mvc
4+
<html>
5+
<head>
6+
<title>@ViewBag.Title</title>
7+
8+
@MvcHtmlString.Create(Html.RenderCssHere(new List<IClientDependencyPath>
9+
{
10+
new BasicPath("Base", "~/Content/themes/base"),
11+
new BasicPath("Content", "~/Content")
12+
}))
13+
14+
@MvcHtmlString.Create(Html.RenderJsHere(new List<IClientDependencyPath>
15+
{
16+
new BasicPath("Scripts", "~/Scripts"),
17+
new BasicPath("googleCDN", "http://ajax.googleapis.com/ajax/libs/"),
18+
new BasicPath("Content", "~/Content")
19+
20+
}))
21+
22+
@{
23+
Html.RequiresCss("Site.css", "Content", 1);
24+
}
25+
</head>
26+
<body>
27+
<div class="page">
28+
<div id="header">
29+
<div id="title">
30+
<h1>jQuery-File-Upload MVC3 Demo</h1>
31+
</div>
32+
</div>
33+
34+
<div id="main">
35+
@RenderBody()
36+
</div>
37+
<div id="footer">
38+
</div>
39+
</div>
40+
</body>
41+
</html>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@{
2+
Layout = "~/Views/Home/_HomeLayout.cshtml";
3+
}

jQuery-File-Upload.MVC3/Views/Shared/_Layout.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<h1>jQuery-File-Upload MVC3 Demo</h1>
3131
</div>
3232
</div>
33+
<h1>I be here</h1>
3334
<div id="main">
3435
@RenderBody()
3536
</div>

jQuery-File-Upload.MVC3/jQuery-File-Upload.MVC3.csproj

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
<UpgradeBackupLocation>
2222
</UpgradeBackupLocation>
2323
<OldToolsVersion>4.0</OldToolsVersion>
24+
<IISExpressSSLPort />
25+
<IISExpressAnonymousAuthentication />
26+
<IISExpressWindowsAuthentication />
27+
<IISExpressUseClassicPipelineMode />
2428
</PropertyGroup>
2529
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2630
<DebugSymbols>true</DebugSymbols>
@@ -143,7 +147,9 @@
143147
<Content Include="Scripts\jquery.validate.min.js" />
144148
<Content Include="Scripts\modernizr-1.7.js" />
145149
<Content Include="Scripts\modernizr-1.7.min.js" />
146-
<Content Include="Web.config" />
150+
<Content Include="Web.config">
151+
<SubType>Designer</SubType>
152+
</Content>
147153
<Content Include="Web.Debug.config">
148154
<DependentUpon>Web.config</DependentUpon>
149155
</Content>
@@ -177,6 +183,12 @@
177183
<ItemGroup>
178184
<Content Include="Upload\UploadHandler.ashx" />
179185
</ItemGroup>
186+
<ItemGroup>
187+
<Content Include="Views\Home\_HomeLayout.cshtml" />
188+
</ItemGroup>
189+
<ItemGroup>
190+
<Content Include="Views\Home\_ViewStart.cshtml" />
191+
</ItemGroup>
180192
<PropertyGroup>
181193
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
182194
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>

0 commit comments

Comments
 (0)