Skip to content

Commit

Permalink
Switched the way we were detecting JS for the users page follow check…
Browse files Browse the repository at this point in the history
…boxes
  • Loading branch information
darrenaustin committed Sep 30, 2011
1 parent 54c9333 commit adbd030
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
27 changes: 12 additions & 15 deletions resources/public/css/style.css
Expand Up @@ -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;
}


Expand Down
4 changes: 2 additions & 2 deletions resources/public/script/foreclojure.js
Expand Up @@ -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")
Expand Down
7 changes: 3 additions & 4 deletions src/foreclojure/users.clj
Expand Up @@ -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]
Expand All @@ -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"]
Expand Down

0 comments on commit adbd030

Please sign in to comment.