closeted icon, all over the place

This commit is contained in:
Emi Matchu 2011-07-13 01:21:48 -04:00
parent a33898a393
commit 3a193d534d
10 changed files with 100 additions and 42 deletions

View file

@ -11,6 +11,7 @@ class ItemsController < ApplicationController
per_page = nil
end
@items = Item.search(@query).alphabetize.paginate :page => params[:page], :per_page => per_page
assign_closeted!
respond_to do |format|
format.html { render }
format.json { render :json => {:items => @items, :total_pages => @items.total_pages} }
@ -24,6 +25,7 @@ class ItemsController < ApplicationController
end
elsif params.has_key?(:ids) && params[:ids].is_a?(Array)
@items = Item.find(params[:ids])
assign_closeted!
respond_to do |format|
format.json { render :json => @items }
end
@ -50,11 +52,16 @@ class ItemsController < ApplicationController
raise ActiveRecord::RecordNotFound, 'Pet type not found'
end
@items = @pet_type.needed_items.alphabetize
assign_closeted!
@pet_name = params[:name]
render :layout => 'application'
end
private
protected
def assign_closeted!
current_user.assign_closeted_to_items!(@items) if user_signed_in?
end
def set_query
@query = params[:q]

View file

@ -48,6 +48,17 @@ module ItemsHelper
end
end
def closeted_icon_for(item)
if item.closeted?
image_tag(
'closeted.png',
:title => 'You own this',
:alt => 'Closet',
:class => 'closeted-icon'
)
end
end
def list_zones(zones, method=:label)
zones.sort { |x,y| x.label <=> y.label }.map(&method).join(', ')
end

View file

@ -10,7 +10,7 @@ class Item < ActiveRecord::Base
has_many :swf_assets, :through => :parent_swf_asset_relationships, :source => :object_asset,
:conditions => {:type => SwfAssetType}
attr_writer :current_body_id
attr_writer :closeted, :current_body_id
NCRarities = [0, 500]
PAINTBRUSH_SET_DESCRIPTION = 'This item is part of a deluxe paint brush set!'
@ -43,7 +43,9 @@ class Item < ActiveRecord::Base
scope :sitemap, select([:id, :name]).order(:id).limit(49999)
# Not defining validations, since this app is currently read-only
def closeted?
!!@closeted
end
def nc?
NCRarities.include?(rarity_index)
@ -155,7 +157,8 @@ class Item < ActiveRecord::Base
:name => name,
:thumbnail_url => thumbnail_url,
:zones_restrict => zones_restrict,
:rarity_index => rarity_index
:rarity_index => rarity_index,
:closeted => closeted?
}
end

View file

@ -3,6 +3,7 @@ class User < ActiveRecord::Base
PreviewTopContributorsCount = 3
has_many :closet_hangers
has_many :closeted_items, :through => :closet_hangers, :source => :item
has_many :contributions
has_many :outfits
@ -40,6 +41,16 @@ class User < ActiveRecord::Base
new_points
end
def assign_closeted_to_items!(items)
# Assigning these items to a hash by ID means that we don't have to go
# N^2 searching the items list for items that match the given IDs or vice
# versa, and everything stays a lovely O(n)
items_by_id = {}
items.each { |item| items_by_id[item.id] = item }
closeted_item_ids = closeted_items.where(:id => items_by_id.keys).map(&:id)
closeted_item_ids.each { |id| items_by_id[id].closeted = true }
end
def self.find_or_create_from_remote_auth_data(user_data)
user = find_or_initialize_by_remote_id_and_auth_server_id(
user_data['id'],

View file

@ -157,7 +157,8 @@ ul.buttons
.object
+inline-block
padding: .5em
margin: .5em 0
padding: 0 .5em
position: relative
text-align: center
vertical-align: top
@ -174,6 +175,21 @@ ul.buttons
margin: 0 auto
width: $object-img-size
.nc-icon, .closeted-icon
+opacity(1)
height: $nc-icon-size
position: absolute
top: $object-img-size - $nc-icon-size
width: $nc-icon-size
&:hover
+opacity(0.5)
.nc-icon
right: ($object-width - $object-img-size) / 2 + $object-padding
.closeted-icon
left: ($object-width - $object-img-size) / 2 + $object-padding
dt
font-weight: bold
@ -202,15 +218,6 @@ dd
.current
font-weight: bold
.object .nc-icon
height: 16px
position: absolute
right: ($object-width - $object-img-size) / 2 + $object-padding
top: $object-img-size - $nc-icon-size
width: 16px
&:hover
+opacity(0.5)
/* Fonts
/* A font by Jos Buivenga (exljbris) -> www.exljbris.nl

View file

@ -2,4 +2,5 @@
= image_tag item.thumbnail_url, :alt => item.description, :title => item.description
= item.name
= nc_icon_for(item)
= closeted_icon_for(item)

BIN
public/images/closeted.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 738 B

After

Width:  |  Height:  |  Size: 732 B

View file

@ -102,6 +102,9 @@ Partial.ItemSet = function ItemSet(wardrobe, selector) {
) {
$('<div/>', {'class': 'nc-icon', text: 'NC', title: 'NC'}).appendTo(li);
}
if(item.closeted) {
$('<img/>', {'class': 'closeted-icon', alt: 'Closet', title: 'You own this', src: '/images/closeted.png'}).appendTo(li);
}
li.append(img).append(controls).append(info_link).append(item.name).appendTo(ul);
}
setClosetItems(wardrobe.outfit.getClosetItems());

View file

@ -271,49 +271,76 @@ ul.buttons li, ul.buttons li form {
vertical-align: middle;
*display: inline;
*vertical-align: auto;
padding: 0.5em;
margin: 0.5em 0;
padding: 0 0.5em;
position: relative;
text-align: center;
vertical-align: top;
width: 100px;
}
/* line 165, ../../../app/stylesheets/_layout.sass */
/* line 166, ../../../app/stylesheets/_layout.sass */
.object a {
text-decoration: none;
}
/* line 167, ../../../app/stylesheets/_layout.sass */
/* line 168, ../../../app/stylesheets/_layout.sass */
.object a img {
-moz-opacity: 0.75;
-webkit-opacity: 0.75;
-o-opacity: 0.75;
-khtml-opacity: 0.75;
}
/* line 169, ../../../app/stylesheets/_layout.sass */
/* line 170, ../../../app/stylesheets/_layout.sass */
.object a:hover img {
-moz-opacity: 1;
-webkit-opacity: 1;
-o-opacity: 1;
-khtml-opacity: 1;
}
/* line 171, ../../../app/stylesheets/_layout.sass */
/* line 172, ../../../app/stylesheets/_layout.sass */
.object img {
display: block;
height: 80px;
margin: 0 auto;
width: 80px;
}
/* line 178, ../../../app/stylesheets/_layout.sass */
.object .nc-icon, .object .closeted-icon {
-moz-opacity: 1;
-webkit-opacity: 1;
-o-opacity: 1;
-khtml-opacity: 1;
height: 16px;
position: absolute;
top: 64px;
width: 16px;
}
/* line 184, ../../../app/stylesheets/_layout.sass */
.object .nc-icon:hover, .object .closeted-icon:hover {
-moz-opacity: 0.5;
-webkit-opacity: 0.5;
-o-opacity: 0.5;
-khtml-opacity: 0.5;
}
/* line 187, ../../../app/stylesheets/_layout.sass */
.object .nc-icon {
right: 16px;
}
/* line 190, ../../../app/stylesheets/_layout.sass */
.object .closeted-icon {
left: 16px;
}
/* line 177, ../../../app/stylesheets/_layout.sass */
/* line 193, ../../../app/stylesheets/_layout.sass */
dt {
font-weight: bold;
}
/* line 180, ../../../app/stylesheets/_layout.sass */
/* line 196, ../../../app/stylesheets/_layout.sass */
dd {
margin: 0 0 1.5em 1em;
}
/* line 183, ../../../app/stylesheets/_layout.sass */
/* line 199, ../../../app/stylesheets/_layout.sass */
#home-link {
font-family: Delicious, Helvetica, Arial, Verdana, sans-serif;
font-size: 175%;
@ -324,41 +351,25 @@ dd {
position: absolute;
top: 0;
}
/* line 193, ../../../app/stylesheets/_layout.sass */
/* line 209, ../../../app/stylesheets/_layout.sass */
#home-link:hover {
background: #eeffee;
text-decoration: none;
}
/* line 196, ../../../app/stylesheets/_layout.sass */
/* line 212, ../../../app/stylesheets/_layout.sass */
#home-link span:before {
content: "<< ";
}
/* line 200, ../../../app/stylesheets/_layout.sass */
/* line 216, ../../../app/stylesheets/_layout.sass */
.pagination a, .pagination span {
margin: 0 0.5em;
}
/* line 202, ../../../app/stylesheets/_layout.sass */
/* line 218, ../../../app/stylesheets/_layout.sass */
.pagination .current {
font-weight: bold;
}
/* line 205, ../../../app/stylesheets/_layout.sass */
.object .nc-icon {
height: 16px;
position: absolute;
right: 16px;
top: 64px;
width: 16px;
}
/* line 211, ../../../app/stylesheets/_layout.sass */
.object .nc-icon:hover {
-moz-opacity: 0.5;
-webkit-opacity: 0.5;
-o-opacity: 0.5;
-khtml-opacity: 0.5;
}
/* Fonts */
/* A font by Jos Buivenga (exljbris) -> www.exljbris.nl */
@font-face {
@ -1511,7 +1522,11 @@ body.outfits-edit .object:hover ul, body.outfits-edit .object:hover .object-info
}
/* line 415, ../../../app/stylesheets/outfits/_edit.sass */
body.outfits-edit .nc-icon {
<<<<<<< HEAD
background: url('/images/nc.png?1310662236') no-repeat;
=======
background: url('/images/nc.png?1310533288') no-repeat;
>>>>>>> closeted icon, all over the place
height: 16px;
position: absolute;
right: 16px;