Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'feature/style' into develop

  • Loading branch information...
commit 5dabf9945d2b4516e473cd61830d367620ba225c 2 parents aa57d64 + 5ad419a
@amcnamara amcnamara authored
View
33 resources/public/css/style.css
@@ -217,6 +217,30 @@ a.novisited {color: #00e;}
padding: 15px;
}
+
+/*
+ * By default only show the text label for the "Following" column on
+ * the users page. If they have javascript turned on (detected
+ * via. the js-enabled class set by our page's javascript) then turn
+ * off the text label and turn on the checkbox.
+ */
+#user-table input.following {
+ display: none;
+}
+
+#user-table span.following {
+ display: inline;
+}
+
+#user-table.js-enabled input.following {
+ display: inline;
+}
+
+#user-table.js-enabled span.following {
+ display: none;
+}
+
+
span.error, div.error {
color: red;
}
@@ -254,6 +278,7 @@ div#sub-heading {
}
div#main {
+ width: 100%;
display: block;
float: left;
clear: both;
@@ -368,6 +393,14 @@ table.my-table td {
font-size: 12px;
}
+tr.evenrow {
+ background-color: #E2E4FF;
+}
+
+tr.oddrow {
+ background-color: white;
+}
+
td.oddrank {
background-color: #DDF !important;
}
View
26 resources/public/script/foreclojure.js
@@ -22,7 +22,26 @@ $(document).ready(function() {
$(this).parents("form").attr("action", "/problem/edit").submit();
});
- $("form input.following").live("click", function(e) {
+ $("button.user-follow-button").live("click", function(e) {
+ e.preventDefault();
+ var $form = $(this).parents("form");
+ var $button = $(this);
+ $.ajax({type: "POST",
+ url: "/rest" + $form.attr("action"),
+ dataType: "json",
+ success: function(data) {
+ if (data) {
+ $button.text(data["next-label"]);
+ $form.attr("action", data["next-action"]);
+ }
+ },
+ });
+ return false;
+ });
+
+ $("#user-table").addClass("js-enabled");
+
+ $("#user-table input.following").live("click", function(e) {
e.preventDefault();
var $checkbox = $(this)
var $form = $checkbox.parents("form")
@@ -58,7 +77,7 @@ jQuery.fn.dataTableExt.oSort['difficulty-desc'] = function(a, b) {
function configureDataTables(){
$('#problem-table').dataTable( {
- "iDisplayLength": 25,
+ "iDisplayLength": 100,
"aaSorting": [[5, "desc"], [1, "asc"], [4, "desc"]],
"aoColumns": [
{"sType": "string"},
@@ -88,7 +107,8 @@ function configureDataTables(){
{"sType": "numeric"},
{"sType": "string"},
{"sType": "numeric"},
- {"sType": "string"}
+ {"sType": "string"},
+ {"sType": "string"}
]
} );
}
View
29 src/foreclojure/users.clj
@@ -32,12 +32,14 @@
(group-by #(count (or (:solved %) []))
users)))]
(first
- (reduce (fn [[user-list rank] new-group]
+ (reduce (fn [[user-list position rank] new-group]
[(into user-list
(for [user (sort-by :user new-group)]
- (assoc user :rank rank)))
+ (into user {:rank rank
+ :position position})))
+ (inc position)
(+ rank (count new-group))])
- [[] 1]
+ [[] 1 1]
tied-groups))))
(defn get-top-100-and-current-user [username]
@@ -81,29 +83,28 @@
(defn following-checkbox [current-user-id following user-id user]
(when (and current-user-id (not= current-user-id user-id))
- (let [following? (some #{user-id} following)]
+ (let [following? (contains? following user-id)]
(form-to [:post (follow-url user (not following?))]
- [:input.following {:type "checkbox" :name "following"
- :checked following? :value following?}]))))
+ [:input.following {:type "checkbox" :checked following?}]
+ [:span.following (when following? "yes")]))))
(defn generate-user-list [user-set]
(let [[user-id following]
- (if (session/session-get :user)
+ (when (session/session-get :user)
(with-user [{:keys [_id following]}]
- [_id following])
- [nil nil])]
+ [_id (set following)]))]
(list
[:br]
[:table#user-table.my-table
[:thead
[:tr
- [:th {:style "width: 40px;"} "Rank"]
- [:th "Username"]
- [:th "Problems Solved"]
+ [:th {:style "width: 40px;" } "Rank"]
+ [:th {:style "width: 200px;"} "Username"]
+ [:th {:style "width: 180px;"} "Problems Solved"]
[:th "Following"]]]
- (map-indexed (fn [rownum {:keys [_id rank user contributor solved]}]
+ (map-indexed (fn [rownum {:keys [_id position rank user contributor solved]}]
[:tr (row-class rownum)
- [:td (rank-class rank) rank]
+ [:td (rank-class position) rank]
[:td
(when contributor [:span.contributor "* "])
[:a.user-profile-link {:href (str "/user/" user)} user]]
Please sign in to comment.
Something went wrong with that request. Please try again.