Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 7 commits
  • 4 files changed
  • 0 comments
  • 3 contributors
2  static/css/custom.css
@@ -256,6 +256,8 @@ table.listing td {
256 256 }
257 257 code{
258 258 background-color: #eee;
  259 + padding: 2px 0px;
  260 + margin: 5px;
259 261 }
260 262 .jq-primaryContent pre code{
261 263 background: none;
2  static/js/router.js
@@ -132,7 +132,7 @@ define([
132 132 };
133 133 _.bindAll(cb, 'fn');
134 134 // match #languageName/:query or #languageName/ or just #languageName
135   - this.route(new RegExp("^" + languageName + '(?:/([^/])?)?$'),
  135 + this.route(new RegExp("^" + languageName + '(?:/([^/]*))?$'),
136 136 languageName, cb.fn);
137 137 }
138 138 },
15 static/js/views/languageview.js
@@ -94,13 +94,26 @@ define([
94 94 this.mainResultsView.startSpinner();
95 95 var self = this;
96 96 this.collection.fetch({
  97 + xhr: function() {
  98 + var xhr = jQuery.ajaxSettings.xhr();
  99 + if (xhr instanceof window.XMLHttpRequest) {
  100 + // XMLHttpRequest 2
  101 + xhr.addEventListener("progress", function(evt) {
  102 + if (evt.lengthComputable) {
  103 + self.mainResultsView.setDownloadProgress(evt.loaded, evt.total);
  104 + }
  105 + }, false);
  106 + }
  107 + return xhr;
  108 + },
97 109 success: function(coll, resp) {
98 110 console.log('[Success fetching ' + self.languageName + '.]');
99 111 self.searchHeaderView.lastQuery = null; // TODO: use abstractions
100 112 self.searchHeaderView.onSearch();
101 113 self.mainResultsView.spinner.stop();
  114 + self.mainResultsView.removeDownlaodProgress();
102 115 self.active = true;
103   - }
  116 + },
104 117 });
105 118 }
106 119 } else if (!active && this.active) {
31 static/js/views/searchresults.js
@@ -27,12 +27,39 @@ define([
27 27 shadow : false // Whether to render a shadow
28 28 };
29 29 this.spinner = new Spinner(opts).spin();
30   - $(this.spinner.el).css('margin-top', $(window).height()/4);
31   - $(this.spinner.el).css('margin-left', $(window).width()/4);
  30 + var halfHeight = opts.radius + opts.length + opts.width;
  31 + $(this.spinner.el).css('margin-top', $(window).height()/4 + halfHeight);
  32 + $(this.spinner.el).css('margin-left', "50%");
  33 + $(this.spinner.el).css("height", halfHeight + "px");
32 34 $(this.el).append(this.spinner.el);
33 35 }
34 36 },
35 37
  38 + setDownloadProgress: function(receivedB, totalB) {
  39 + if (!this.options.spinner)
  40 + return;
  41 + if (!this.progressEl) {
  42 + this.progressEl = $(
  43 + '<div style="text-align:center; width:100%; max-width: 100%;">' +
  44 + ' <progress></progress>' +
  45 + ' <br>' +
  46 + ' <span class="progress-text"></span>' +
  47 + '</div>').get(0);
  48 + $(this.el).append(this.progressEl);
  49 + }
  50 + var receivedMB = Math.round(receivedB/1024/1024*10)/10
  51 + , totalMB = Math.round(totalB/1024/1024*10)/10;
  52 + $(this.progressEl)
  53 + .find("progress").prop("max", totalB).prop("value", receivedB).end()
  54 + .find(".progress-text").text(receivedMB + "MB/" + totalMB + "MB");
  55 + },
  56 + removeDownlaodProgress: function() {
  57 + if (this.progressEl) {
  58 + $(this.progressEl).remove();
  59 + this.progressEl = undefined;
  60 + }
  61 + },
  62 +
36 63 render: function() {
37 64 console.log('[Data loaded, rendering models.]');
38 65 // render a subview for each model in the collection

No commit comments for this range

Something went wrong with that request. Please try again.