stop using radio and label for pet states, to fix ie bug

This commit is contained in:
Emi Matchu 2011-02-07 08:46:15 -05:00
parent 50f0adaa4d
commit bcffdc0630
4 changed files with 16 additions and 22 deletions

View file

@ -42,6 +42,7 @@ class User < ActiveRecord::Base
end
def self.points_required_to_pass_top_contributor(offset)
User.top_contributors.select(:points).limit(1).offset(offset).first.points
user = User.top_contributors.select(:points).limit(1).offset(offset).first
user ? user.points : 0
end
end

View file

@ -144,7 +144,7 @@ body.outfits-edit
label
+awesome-button
margin: 0 .25em
li.selected label
li.selected button
+awesome-button-color($marked_button_color)
&.hidden
visibility: hidden

View file

@ -718,42 +718,35 @@ View.PetStateForm = function (wardrobe) {
var INPUT_NAME = 'pet_state_id', form_query = '#pet-state-form',
form = $(form_query),
ul = form.children('ul'),
radio_query = form_query + ' input[name=' + INPUT_NAME + ']';
$(radio_query).live('click', function () {
wardrobe.outfit.setPetStateById(+this.value);
button_query = form_query + ' button';
$(button_query).live('click', function (e) {
e.preventDefault();
wardrobe.outfit.setPetStateById(+$(this).data('value'));
});
function updatePetState(pet_state) {
if(pet_state) {
ul.children('li.selected').removeClass('selected');
$(radio_query + '[value=' + pet_state.id + ']')
.attr('checked', 'checked').parent().addClass('selected');
$(button_query + '[data-value=' + pet_state.id + ']').parent().addClass('selected');
}
}
wardrobe.outfit.bind('petTypeLoaded', function (pet_type) {
var ids = pet_type.pet_state_ids, i, id, li, radio, label;
var ids = pet_type.pet_state_ids, i, id, li, button, label;
ul.children().remove();
if(ids.length == 1) {
form.addClass('hidden');
} else {
form.removeClass('hidden');
for(var i = 0; i < ids.length; i++) {
id = 'pet-state-radio-' + i;
id = 'pet-state-button-' + i;
li = $('<li/>');
radio = $('<input/>', {
button = $('<button/>', {
id: id,
name: INPUT_NAME,
type: 'radio',
value: ids[i]
text: i + 1,
"data-value": ids[i]
});
label = $('<label/>', {
'for': id,
text: i + 1
});
if(i == 0) radio.attr('checked', 'checked');
radio.appendTo(li);
label.appendTo(li);
button.appendTo(li);
li.appendTo(ul);
}
updatePetState(wardrobe.outfit.getPetState());

View file

@ -824,11 +824,11 @@ body.outfits-edit #pet-state-form label:active {
top: 1px;
}
/* line 147, ../../../app/stylesheets/outfits/_edit.sass */
body.outfits-edit #pet-state-form li.selected label {
body.outfits-edit #pet-state-form li.selected button {
background: #0b61a4 url('/images/alert-overlay.png?1296599919') repeat-x;
}
/* line 34, ../../../app/stylesheets/partials/clean/_mixins.sass */
body.outfits-edit #pet-state-form li.selected label:hover {
body.outfits-edit #pet-state-form li.selected button:hover {
background-color: #005093;
}
/* line 149, ../../../app/stylesheets/outfits/_edit.sass */