wardrobe js now serves pretty item urls
This commit is contained in:
parent
c18a333bd2
commit
fa46a03c91
2 changed files with 17 additions and 1 deletions
|
@ -92,7 +92,7 @@ Partial.ItemSet = function ItemSet(wardrobe, selector) {
|
|||
info_link = $('<a/>', {
|
||||
'class': 'object-info',
|
||||
html: '<span>i</span>',
|
||||
href: '/items/' + item.id,
|
||||
href: item.getURL(),
|
||||
target: '_blank'
|
||||
});
|
||||
if(
|
||||
|
|
|
@ -125,6 +125,22 @@ function Wardrobe() {
|
|||
this.loaded = true;
|
||||
}
|
||||
|
||||
function getNameForSlug() {
|
||||
return item.name.toLowerCase().replace(/ /g, '-');
|
||||
}
|
||||
|
||||
function getSlug() {
|
||||
var slug = item.id.toString();
|
||||
if(this.hasOwnProperty('name')) {
|
||||
slug += '-' + getNameForSlug();
|
||||
}
|
||||
return slug;
|
||||
}
|
||||
|
||||
this.getURL = function() {
|
||||
return "/items/" + getSlug();
|
||||
}
|
||||
|
||||
Item.cache[id] = this;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue