quantity form on your items page

This commit is contained in:
Emi Matchu 2011-07-15 17:21:18 -04:00
parent d782108e00
commit 437b1c052d
6 changed files with 91 additions and 18 deletions

View file

@ -31,7 +31,7 @@ class ClosetHangersController < ApplicationController
flash[:success] = "Success! You do not own #{@item.name}." flash[:success] = "Success! You do not own #{@item.name}."
end end
redirect_to @item redirect_to params[:return_to] || @item
end end
alias_method :create, :update alias_method :create, :update

View file

@ -32,7 +32,7 @@ module ApplicationHelper
def flashes def flashes
raw(flash.inject('') do |html, pair| raw(flash.inject('') do |html, pair|
key, value = pair key, value = pair
html + content_tag('p', value, :class => key) html + content_tag('p', value, :class => "flash #{key}")
end) end)
end end

View file

@ -1,6 +1,10 @@
body.closet_hangers-index body.closet_hangers-index
#title #title
float: left float: left
margin-bottom: .5em
.flash
clear: both
#import-link #import-link
+awesome-button +awesome-button
@ -13,13 +17,38 @@ body.closet_hangers-index
clear: both clear: both
text-align: center text-align: center
.object .quantity .object
.quantity
+opacity(.75) +opacity(.75)
background: white background: white
font-size: 16px
font-weight: bold
padding: 2px 4px padding: 2px 4px
position: absolute position: absolute
left: ($object-width - $object-img-size) / 2 + $object-padding left: ($object-width - $object-img-size) / 2 + $object-padding
text-align: left
top: $object-img-size - 24px top: $object-img-size - 24px
form
display: none
span, input[type=number]
font-size: 16px
font-weight: bold
&:hover
.quantity
+opacity(1)
top: $object-img-size - 30px
span
display: none
form
display: inline
input[type=number]
padding: 2px
width: 2em
input[type=submit]
font-size: 85%

View file

@ -1,4 +1,9 @@
.object .object
= render :partial => 'items/item_link', :locals => {:item => closet_hanger.item} = render :partial => 'items/item_link', :locals => {:item => closet_hanger.item}
%span.quantity{:title => "You own #{pluralize closet_hanger.quantity, closet_hanger.item.name}"}= closet_hanger.quantity .quantity
%span{:title => "You own #{pluralize closet_hanger.quantity, closet_hanger.item.name}"}= closet_hanger.quantity
= form_for closet_hanger, :url => user_item_closet_hanger_path(current_user, closet_hanger.item) do |f|
= hidden_field_tag :return_to, request.fullpath
= f.number_field :quantity, :min => 0, :required => true, :title => "You own #{pluralize closet_hanger.quantity, closet_hanger.item.name}"
= f.submit "Save"

View file

@ -1,5 +1,6 @@
- if user_is?(@user) - if user_is?(@user)
- title 'Your Items' - title 'Your Items'
- content_for :before_flashes do
= link_to "Import closet from Neopets", new_closet_page_path, :id => 'import-link' = link_to "Import closet from Neopets", new_closet_page_path, :id => 'import-link'
- else - else
- title "#{@user.name}'s Items" - title "#{@user.name}'s Items"

View file

@ -552,8 +552,13 @@ div.jGrowl div.jGrowl-closer {
/* line 2, ../../../app/stylesheets/closet_hangers/_index.sass */ /* line 2, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #title { body.closet_hangers-index #title {
float: left; float: left;
margin-bottom: 0.5em;
} }
/* line 5, ../../../app/stylesheets/closet_hangers/_index.sass */ /* line 6, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index .flash {
clear: both;
}
/* line 9, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #import-link { body.closet_hangers-index #import-link {
/* http://www.zurb.com/blog_uploads/0000/0617/buttons-03.html */ /* http://www.zurb.com/blog_uploads/0000/0617/buttons-03.html */
-moz-border-radius: 5px; -moz-border-radius: 5px;
@ -591,25 +596,58 @@ body.closet_hangers-index #import-link:active {
body.closet_hangers-index #import-link:hover { body.closet_hangers-index #import-link:hover {
background-color: #ee4b00; background-color: #ee4b00;
} }
/* line 12, ../../../app/stylesheets/closet_hangers/_index.sass */ /* line 16, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers { body.closet_hangers-index #closet-hangers {
clear: both; clear: both;
text-align: center; text-align: center;
} }
/* line 16, ../../../app/stylesheets/closet_hangers/_index.sass */ /* line 21, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers .object .quantity { body.closet_hangers-index #closet-hangers .object .quantity {
-moz-opacity: 0.75; -moz-opacity: 0.75;
-webkit-opacity: 0.75; -webkit-opacity: 0.75;
-o-opacity: 0.75; -o-opacity: 0.75;
-khtml-opacity: 0.75; -khtml-opacity: 0.75;
background: white; background: white;
font-size: 16px;
font-weight: bold;
padding: 2px 4px; padding: 2px 4px;
position: absolute; position: absolute;
left: 16px; left: 16px;
text-align: left;
top: 56px; top: 56px;
} }
/* line 30, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers .object .quantity form {
display: none;
}
/* line 33, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers .object .quantity span, body.closet_hangers-index #closet-hangers .object .quantity input[type=number] {
font-size: 16px;
font-weight: bold;
}
/* line 38, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers .object:hover .quantity {
-moz-opacity: 1;
-webkit-opacity: 1;
-o-opacity: 1;
-khtml-opacity: 1;
top: 50px;
}
/* line 42, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers .object:hover .quantity span {
display: none;
}
/* line 45, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers .object:hover .quantity form {
display: inline;
}
/* line 48, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers .object:hover .quantity form input[type=number] {
padding: 2px;
width: 2em;
}
/* line 52, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers .object:hover .quantity input[type=submit] {
font-size: 85%;
}
/* line 3, ../../../app/stylesheets/closet_pages/_new.sass */ /* line 3, ../../../app/stylesheets/closet_pages/_new.sass */
body.closet_pages-new #closet-page-form, body.closet_pages-create #closet-page-form { body.closet_pages-new #closet-page-form, body.closet_pages-create #closet-page-form {