Skip to content

Commit

Permalink
Merge pull request #1331 from NuGet/johtaylo-1283-d3-on-ie7
Browse files Browse the repository at this point in the history
Johtaylo 1283 d3 on ie7
  • Loading branch information
johnataylor committed Jul 18, 2013
2 parents c24863b + 7ce2006 commit 875c365
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 38 deletions.
13 changes: 1 addition & 12 deletions Website/Content/Site.css
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ nav.main ul a:hover {
/* Body */

#body {
padding-bottom: 175px;
padding-bottom: 14px;
padding-top: 20px;
}

Expand Down Expand Up @@ -1099,16 +1099,6 @@ ul.pager li.next { padding-left: 10px; }
top:50px;
}

#downloads-by-nuget-version table
{
display:none;
}

#downloads-per-month table
{
display:none;
}

.axis path,
.axis line {
fill: none;
Expand Down Expand Up @@ -1377,7 +1367,6 @@ input:focus ~ .field-validation-error ~ .field-hint-message { display: none; }
border-top: 1px solid #d3e7fe;
clear: both;
color: #3e483c;
margin-top: -161px;
padding-bottom: 1em;
padding-top: 0px;
position: relative;
Expand Down
22 changes: 22 additions & 0 deletions Website/Controllers/StatisticsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ public virtual async Task<ActionResult> Index()

model.Update();

model.UseD3 = UseD3();

return View(model);
}

Expand Down Expand Up @@ -196,6 +198,8 @@ public virtual async Task<ActionResult> PackageDownloadsByVersion(string id, str

model.SetPackageDownloadsByVersion(id, report);

model.UseD3 = UseD3();

return View(model);
}

Expand All @@ -222,6 +226,8 @@ public virtual async Task<ActionResult> PackageDownloadsDetail(string id, string

model.SetPackageVersionDownloadsByClient(id, version, report);

model.UseD3 = UseD3();

return View(model);
}

Expand Down Expand Up @@ -333,5 +339,21 @@ private static string MakeReportId(string[] groupby)
}
return graphId;
}

private bool UseD3()
{
// the aim here is to explicit eliminate IE 7.0 and IE 8.0 from the browsers that support D3
// we are doing this on the server rather than in the browser because even downloading the D3 script fails
bool f = true;
if (Request != null && Request.Browser != null && Request.Browser.Browser == "IE")
{
float version;
if (float.TryParse(Request.Browser.Version, out version))
{
f = version > 8.0;
}
}
return f;
}
}
}
22 changes: 1 addition & 21 deletions Website/Scripts/statsgraphs.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,4 @@

var displayGraphs = function () {

if ($('#downloads-by-nuget-version').length) {
if (Modernizr.svg) {
drawNugetClientVersionBarChart();
}
else {
$('#downloads-by-nuget-version table').css('display', 'inline');
}
}

if ($('#downloads-per-month').length) {
if (Modernizr.svg) {
drawMonthlyDownloadsLineChart();
}
else {
$('#downloads-per-month table').css('display', 'inline');
}
}
}

var drawNugetClientVersionBarChart = function () {

var margin = { top: 20, right: 30, bottom: 80, left: 80 },
Expand Down Expand Up @@ -165,3 +144,4 @@ var drawMonthlyDownloadsLineChart = function () {
.attr("class", "line")
.attr("d", line);
}

6 changes: 6 additions & 0 deletions Website/ViewModels/StatisticsPackagesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ public StatisticsPackagesReport Report
public string PackageId { get; private set; }
public string PackageVersion { get; private set; }

public bool UseD3
{
get;
set;
}

public void SetPackageDownloadsByVersion(string packageId, StatisticsPackagesReport report)
{
PackageId = packageId;
Expand Down
26 changes: 23 additions & 3 deletions Website/Views/Statistics/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,29 @@
@section BottomScripts
{
@* Right now this is the only page that uses this script. If we increase our usage of it, we should put it in our bundles *@
@Scripts.Render("~/Scripts/d3.v3.min.js")
@Scripts.Render("~/Scripts/statsgraphs.js")

@if (Model.UseD3)
{
@Scripts.Render("~/Scripts/d3.v3.min.js")
@Scripts.Render("~/Scripts/statsgraphs.js")
}

<script>
$(document).ready(displayGraphs);
$(document).ready(function () {
if ($('#downloads-by-nuget-version').length) {
if (Modernizr.svg) {
$('#downloads-by-nuget-version table').css('display', 'none');
drawNugetClientVersionBarChart();
}
}
if ($('#downloads-per-month').length) {
if (Modernizr.svg) {
$('#downloads-per-month table').css('display', 'none');
drawMonthlyDownloadsLineChart();
}
}
});
</script>
}
5 changes: 4 additions & 1 deletion Website/Views/Statistics/PackageDownloadsByVersion.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ else

@section BottomScripts
{
@Scripts.Render("~/Scripts/d3.v3.min.js")
@if (Model.UseD3)
{
@Scripts.Render("~/Scripts/d3.v3.min.js")
}
@Scripts.Render("~/Scripts/statsdimensions.js")
@Scripts.Render("~/Scripts/perpackagestatsgraphs.js")
<script>
Expand Down
5 changes: 4 additions & 1 deletion Website/Views/Statistics/PackageDownloadsDetail.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ else

@section BottomScripts
{
@Scripts.Render("~/Scripts/d3.v3.min.js")
@if (Model.UseD3)
{
@Scripts.Render("~/Scripts/d3.v3.min.js")
}
@Scripts.Render("~/Scripts/statsdimensions.js")
@Scripts.Render("~/Scripts/perpackagestatsgraphs.js")
<script>
Expand Down
2 changes: 2 additions & 0 deletions Website/Views/Statistics/Packages.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
ViewBag.Tab = "Statistics";
}

<div class="statistics-layout">
<h1 class="statistics-report-title">Most Downloaded Packages (Top 100 Over the Last 6 Weeks)</h1>
<table class="sexy-table">
<thead>
Expand All @@ -28,3 +29,4 @@
}
</tbody>
</table>
</div>

0 comments on commit 875c365

Please sign in to comment.