Permalink
Browse files

Switched the way we were detecting JS for the users page follow check…

…boxes
  • Loading branch information...
1 parent 54c9333 commit adbd030f71c6562c44cce8efa465e852d133d27b @darrenaustin committed Sep 30, 2011
Showing with 17 additions and 21 deletions.
  1. +12 −15 resources/public/css/style.css
  2. +2 −2 resources/public/script/foreclojure.js
  3. +3 −4 src/foreclojure/users.clj
@@ -217,30 +217,27 @@ a.novisited {color: #00e;}
padding: 15px;
}
+
/*
- * If the user has javascript turned on, show the
- * "following" checkboxes and turn off the "following"
- * text labels.
+ * 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: inline;
+#user-table input.following {
+ display: none;
}
#user-table span.following {
- display: none;
+ display: inline;
}
-/*
- * If the user has javascript disabled, hide the
- * "following" checkboxes and fallback to showing
- * the "following" text labels.
- */
-#user-table.javascript-disabled input.following {
- display: none;
+#user-table.js-enabled input.following {
+ display: inline;
}
-#user-table.javascript-disabled span.following {
- display: inline;
+#user-table.js-enabled span.following {
+ display: none;
}
@@ -39,9 +39,9 @@ $(document).ready(function() {
return false;
});
- $("#user-table").removeClass('javascript-disabled');
+ $("#user-table").addClass("js-enabled");
- $("form input.following").live("click", function(e) {
+ $("#user-table input.following").live("click", function(e) {
e.preventDefault();
var $checkbox = $(this)
var $form = $checkbox.parents("form")
@@ -81,10 +81,9 @@
(defn following-checkbox [current-user-id following user-id user]
(when (and current-user-id (not= current-user-id user-id))
- (let [following? (following user-id)]
+ (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]
@@ -94,7 +93,7 @@
[_id (set following)]))]
(list
[:br]
- [:table#user-table.my-table.javascript-disabled
+ [:table#user-table.my-table
[:thead
[:tr
[:th {:style "width: 40px;"} "Rank"]

0 comments on commit adbd030

Please sign in to comment.