From bcffdc0630ff07129aa5f1c8450cd880049a79ac Mon Sep 17 00:00:00 2001 From: Matchu Date: Mon, 7 Feb 2011 08:46:15 -0500 Subject: [PATCH] stop using radio and label for pet states, to fix ie bug --- app/models/user.rb | 3 ++- app/stylesheets/outfits/_edit.sass | 2 +- public/javascripts/outfits/edit.js | 29 ++++++++++---------------- public/stylesheets/compiled/screen.css | 4 ++-- 4 files changed, 16 insertions(+), 22 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index e843180c..065506e9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/app/stylesheets/outfits/_edit.sass b/app/stylesheets/outfits/_edit.sass index e8d328d4..ab0e96e2 100644 --- a/app/stylesheets/outfits/_edit.sass +++ b/app/stylesheets/outfits/_edit.sass @@ -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 diff --git a/public/javascripts/outfits/edit.js b/public/javascripts/outfits/edit.js index d459c5b6..a94446cd 100644 --- a/public/javascripts/outfits/edit.js +++ b/public/javascripts/outfits/edit.js @@ -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 = $('
  • '); - radio = $('', { + button = $('