From 3a193d534d70775918dd8b87414d882a50bd79f8 Mon Sep 17 00:00:00 2001 From: Matchu Date: Wed, 13 Jul 2011 01:21:48 -0400 Subject: [PATCH] closeted icon, all over the place --- app/controllers/items_controller.rb | 9 +++- app/helpers/items_helper.rb | 11 ++++ app/models/item.rb | 9 ++-- app/models/user.rb | 11 ++++ app/stylesheets/_layout.sass | 27 ++++++---- app/views/items/_item_link.html.haml | 1 + public/images/closeted.png | Bin 0 -> 537 bytes public/images/nc.png | Bin 738 -> 732 bytes public/javascripts/outfits/edit.js | 3 ++ public/stylesheets/compiled/screen.css | 71 +++++++++++++++---------- 10 files changed, 100 insertions(+), 42 deletions(-) create mode 100644 public/images/closeted.png diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index 961dd770..db12323e 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -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] diff --git a/app/helpers/items_helper.rb b/app/helpers/items_helper.rb index cf586268..b2868693 100644 --- a/app/helpers/items_helper.rb +++ b/app/helpers/items_helper.rb @@ -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 diff --git a/app/models/item.rb b/app/models/item.rb index 91386315..7c426deb 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index fe8f6820..1bdad3ab 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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'], diff --git a/app/stylesheets/_layout.sass b/app/stylesheets/_layout.sass index a4b5722a..58bfc903 100644 --- a/app/stylesheets/_layout.sass +++ b/app/stylesheets/_layout.sass @@ -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 diff --git a/app/views/items/_item_link.html.haml b/app/views/items/_item_link.html.haml index 11a3a979..107b7ed9 100644 --- a/app/views/items/_item_link.html.haml +++ b/app/views/items/_item_link.html.haml @@ -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) diff --git a/public/images/closeted.png b/public/images/closeted.png new file mode 100644 index 0000000000000000000000000000000000000000..a9925a06ab02db30c1e7ead9c701c15bc63145cb GIT binary patch literal 537 zcmV+!0_OdRP)Hs{AQG2a)rMyf zFQK~pm1x3+7!nu%-M`k}``c>^00{o_1pjWJUTfl8mg=3qGEl8H@}^@w`VUx0_$uy4 z2FhRqKX}xI*?Tv1DJd8z#F#0c%*~rM30HE1@2o5m~}ZyoWhqv>ql{V z1ZGE0lgcoK^lx+eqc*rAX1Ky;Xx3U%u#zG!m-;eD1Qsn@kf3|F9qz~|95=&g3(7!X zB}JAT>RU;a%vaNOGnJ%e1=K6eAh43c(QN8RQ6~GP%O}Jju$~Ld*%`mO1p6OYS$}RxL_t(I%Z-rBYg~00hM#lGnW;%kGHI+WUeXI_OA3Ne>e?>c zxb#ox##34*$mpa_E5sId)1CE9?!PCJ=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YJyc8sYjH!{kit5`kWFLqFG!VyYli z&?C?b^nbZIJDS+&zi+jtY>?6t7+!V4v+9J*Uxy3U63B>%u&+2>WXeCAZ#;Km*HNye zCC6LBO1opG voc%uA-_6ZY(aCF$D@pQH`3L#pf8sYdyv!R*(+)jz00000NkvXXu0mjfKSMxC diff --git a/public/javascripts/outfits/edit.js b/public/javascripts/outfits/edit.js index bdb8e2d2..239bfbe5 100644 --- a/public/javascripts/outfits/edit.js +++ b/public/javascripts/outfits/edit.js @@ -102,6 +102,9 @@ Partial.ItemSet = function ItemSet(wardrobe, selector) { ) { $('
', {'class': 'nc-icon', text: 'NC', title: 'NC'}).appendTo(li); } + if(item.closeted) { + $('', {'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()); diff --git a/public/stylesheets/compiled/screen.css b/public/stylesheets/compiled/screen.css index 47b6d943..18d6cbe9 100644 --- a/public/stylesheets/compiled/screen.css +++ b/public/stylesheets/compiled/screen.css @@ -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;