include prank message on wardrobe page

This commit is contained in:
Emi Matchu 2014-03-30 22:37:33 -05:00
parent 2ed3f3d4c6
commit 6e80c228c1
4 changed files with 37 additions and 2 deletions

View file

@ -1289,6 +1289,38 @@ View.Search = function (wardrobe) {
//wardrobe.pet_attributes.bind('update', prepBuildHelper('only', getSpecies));
}
View.PrankColorMessage = function(wardrobe) {
var el = $('#prank-color-message');
var nameEls = el.find('.prank-color-message-name');
var colorsById = null;
var petType = null;
function updateMessage() {
if (colorsById !== null && petType !== null) {
var color = colorsById[petType.color_id];
if (color.prank) {
nameEls.text(color.unfunny_name);
el.show();
} else {
el.hide();
}
}
}
wardrobe.pet_attributes.bind('update', function(attributes) {
colorsById = {};
attributes.color.forEach(function(color) {
colorsById[color.id] = color;
});
updateMessage();
});
wardrobe.outfits.bind('updatePetType', function(newPetType) {
petType = newPetType;
updateMessage();
});
}
var userbar_sessions_link = $('#userbar a:last');
var userbar_message_el = $('#userbar-session-message').prependTo('#userbar');

View file

@ -826,3 +826,6 @@ body.outfits-edit
#current-outfit-permalink
display: none !important
#prank-color-message
display: none
margin: 0 1em

View file

@ -10,7 +10,7 @@ class Color < ActiveRecord::Base
validates :name, presence: true
def as_json(options={})
{:id => id, :name => human_name}
{id: id, name: human_name, unfunny_name: unfunny_human_name, prank: prank?}
end
def human_name

View file

@ -48,7 +48,7 @@
#save-success= t '.sidebar.notifications.outfits.save.success'
#save-error
#preview-closet.sidebar-view
= prank_color_message('%{color}')
= prank_color_message('<span class="prank-color-message-name"></span>'.html_safe)
%ul
#preview-outfits.sidebar-view
%ul#preview-outfits-list