From 12f5b28c94f4c67ad47cfe015a911fe2d6ba7524 Mon Sep 17 00:00:00 2001 From: Matchu Date: Fri, 22 Jul 2011 17:06:21 -0400 Subject: [PATCH] wardrobe now works with owned/wanted --- app/models/item.rb | 3 ++- app/stylesheets/outfits/_edit.sass | 4 ++-- app/views/outfits/edit.html.haml | 3 ++- public/javascripts/outfits/edit.js | 14 +++++++++----- public/stylesheets/compiled/screen.css | 4 ++-- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/app/models/item.rb b/app/models/item.rb index 6db699cb..09d36126 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -168,7 +168,8 @@ class Item < ActiveRecord::Base :thumbnail_url => thumbnail_url, :zones_restrict => zones_restrict, :rarity_index => rarity_index, - :closeted => closeted? + :owned => owned?, + :wanted => wanted? } end diff --git a/app/stylesheets/outfits/_edit.sass b/app/stylesheets/outfits/_edit.sass index 167a2064..e4ebed1d 100644 --- a/app/stylesheets/outfits/_edit.sass +++ b/app/stylesheets/outfits/_edit.sass @@ -315,7 +315,7 @@ body.outfits-edit +inline-block &[type=submit] margin-right: 2em - #preview-search-form-your-items + .preview-search-form-your-items display: none font-size: 85% margin-right: 1em @@ -563,7 +563,7 @@ body.outfits-edit display: block #save-outfit, #save-current-outfit, #save-outfit-copy, #current-outfit-permalink, #shared-outfit-permalink, #share-outfit, #shared-outfit-url display: none - #preview-search-form-your-items + .preview-search-form-your-items +inline-block &.user-not-signed-in diff --git a/app/views/outfits/edit.html.haml b/app/views/outfits/edit.html.haml index 09e8f65d..ec8cb115 100644 --- a/app/views/outfits/edit.html.haml +++ b/app/views/outfits/edit.html.haml @@ -91,7 +91,8 @@ %h2 Add an item %input{:name => "query", :placeholder => "Search items...", :type => "search"}/ %input{:type => "submit", :value => "Go"}/ - %a#preview-search-form-your-items{:href => '#'} Your Items + %a.preview-search-form-your-items{:href => '#', 'data-search-value' => 'owns'} Items you own + %a.preview-search-form-your-items{:href => '#', 'data-search-value' => 'wants'} Items you want #preview-search-form-pagination %a#preview-search-form-clear{:href => "#"} clear %dl#preview-search-form-help diff --git a/public/javascripts/outfits/edit.js b/public/javascripts/outfits/edit.js index f1008704..a7e766fe 100644 --- a/public/javascripts/outfits/edit.js +++ b/public/javascripts/outfits/edit.js @@ -102,8 +102,12 @@ 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); + if(item.owned || item.wanted) { + var iconsWrapper = $('
', {'class': 'closeted-icons'}).appendTo(li); + if(item.owned) { + $('', {alt: 'Own', title: 'You own this', src: '/images/owned.png'}).appendTo(iconsWrapper); + $('', {alt: 'Want', title: 'You want this', src: '/images/wanted.png'}).appendTo(iconsWrapper); + } } li.append(img).append(controls).append(info_link).append(item.name).appendTo(ul); } @@ -863,7 +867,7 @@ View.Search = function (wardrobe) { loading_el = $('#preview-search-form-loading'), no_results_el = $('#preview-search-form-no-results'), no_results_span = no_results_el.children('span'), - your_items_el = $('#preview-search-form-your-items'), + your_items_links = $('.preview-search-form-your-items'), PAGINATION = { INNER_WINDOW: 4, OUTER_WINDOW: 1, @@ -928,9 +932,9 @@ View.Search = function (wardrobe) { form.submit(); }); - your_items_el.click(function (e) { + your_items_links.click(function (e) { e.preventDefault(); - input_el.val('user:owns'); + input_el.val('user:' + this.getAttribute('data-search-value')); form.submit(); }); diff --git a/public/stylesheets/compiled/screen.css b/public/stylesheets/compiled/screen.css index 13c5cdab..42438842 100644 --- a/public/stylesheets/compiled/screen.css +++ b/public/stylesheets/compiled/screen.css @@ -1616,7 +1616,7 @@ body.outfits-edit #preview-search-form input[type=submit] { margin-right: 2em; } /* line 318, ../../../app/stylesheets/outfits/_edit.sass */ -body.outfits-edit #preview-search-form-your-items { +body.outfits-edit .preview-search-form-your-items { display: none; font-size: 85%; margin-right: 1em; @@ -2555,7 +2555,7 @@ body.outfits-edit.user-signed-in #save-outfit-wrapper.saving-outfit #save-outfit display: none; } /* line 566, ../../../app/stylesheets/outfits/_edit.sass */ -body.outfits-edit.user-signed-in #preview-search-form-your-items { +body.outfits-edit.user-signed-in .preview-search-form-your-items { display: -moz-inline-box; -moz-box-orient: vertical; display: inline-block;