forked from OpenNeo/impress
include item name and junk in model button title
This commit is contained in:
parent
eede0b0718
commit
0e9b76b4d4
1 changed files with 14 additions and 4 deletions
|
@ -67,8 +67,9 @@
|
||||||
_createItems: function($) {
|
_createItems: function($) {
|
||||||
this._items = $('#newest-unmodeled-items li').map(function() {
|
this._items = $('#newest-unmodeled-items li').map(function() {
|
||||||
var el = $(this);
|
var el = $(this);
|
||||||
|
var name = el.find('h2').text();
|
||||||
return {
|
return {
|
||||||
component: React.renderComponent(<ModelForItem />,
|
component: React.renderComponent(<ModelForItem itemName={name} />,
|
||||||
el.find('.models').get(0)),
|
el.find('.models').get(0)),
|
||||||
el: el,
|
el: el,
|
||||||
id: el.attr('data-item-id'),
|
id: el.attr('data-item-id'),
|
||||||
|
@ -81,7 +82,10 @@
|
||||||
},
|
},
|
||||||
_loadPetCustomization: function(neopiaPetId) {
|
_loadPetCustomization: function(neopiaPetId) {
|
||||||
return Neopia.Customization.get(neopiaPetId)
|
return Neopia.Customization.get(neopiaPetId)
|
||||||
.done(this._addCustomization.bind(this));
|
.done(this._addCustomization.bind(this))
|
||||||
|
.fail(function() {
|
||||||
|
console.error("couldn't load pet %s", neopiaPetId);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
_loadManyPetsCustomizations: function(neopiaPetIds) {
|
_loadManyPetsCustomizations: function(neopiaPetIds) {
|
||||||
return neopiaPetIds.map(this._loadPetCustomization.bind(this));
|
return neopiaPetIds.map(this._loadPetCustomization.bind(this));
|
||||||
|
@ -89,7 +93,9 @@
|
||||||
_loadUserCustomizations: function(neopiaUserId) {
|
_loadUserCustomizations: function(neopiaUserId) {
|
||||||
return Neopia.User.get(neopiaUserId).then(function(neopiaUser) {
|
return Neopia.User.get(neopiaUserId).then(function(neopiaUser) {
|
||||||
return neopiaUser.links.pets;
|
return neopiaUser.links.pets;
|
||||||
}).then(this._loadManyPetsCustomizations.bind(this));
|
}).then(this._loadManyPetsCustomizations.bind(this)).fail(function() {
|
||||||
|
console.error("couldn't load user %s's customizations", neopiaUserId);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
_loadManyUsersCustomizations: function(neopiaUserIds) {
|
_loadManyUsersCustomizations: function(neopiaUserIds) {
|
||||||
return neopiaUserIds.map(this._loadUserCustomizations.bind(this));
|
return neopiaUserIds.map(this._loadUserCustomizations.bind(this));
|
||||||
|
@ -118,8 +124,10 @@
|
||||||
return {customizations: []};
|
return {customizations: []};
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
|
var itemName = this.props.itemName;
|
||||||
function createModelPet(customization) {
|
function createModelPet(customization) {
|
||||||
return <ModelPet customization={customization}
|
return <ModelPet customization={customization}
|
||||||
|
itemName={itemName}
|
||||||
key={customization.name} />;
|
key={customization.name} />;
|
||||||
}
|
}
|
||||||
var sortedCustomizations = this.state.customizations.sort(function(a, b) {
|
var sortedCustomizations = this.state.customizations.sort(function(a, b) {
|
||||||
|
@ -136,9 +144,11 @@
|
||||||
var ModelPet = React.createClass({
|
var ModelPet = React.createClass({
|
||||||
render: function() {
|
render: function() {
|
||||||
var petName = this.props.customization.name;
|
var petName = this.props.customization.name;
|
||||||
|
var itemName = this.props.itemName;
|
||||||
var imageSrc = "http://pets.neopets.com/cpn/" + petName + "/1/1.png";
|
var imageSrc = "http://pets.neopets.com/cpn/" + petName + "/1/1.png";
|
||||||
// TODO: i18n
|
// TODO: i18n
|
||||||
var title = "submit " + petName + " as a model";
|
var title = "Submit " + petName + " as a model, especially if they're " +
|
||||||
|
"wearing the " + itemName + "!";
|
||||||
return <li><button title={title}>
|
return <li><button title={title}>
|
||||||
<img src={imageSrc} />
|
<img src={imageSrc} />
|
||||||
<span>{petName}</span>
|
<span>{petName}</span>
|
||||||
|
|
Loading…
Reference in a new issue