forked from OpenNeo/impress
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/>', {
|
info_link = $('<a/>', {
|
||||||
'class': 'object-info',
|
'class': 'object-info',
|
||||||
html: '<span>i</span>',
|
html: '<span>i</span>',
|
||||||
href: '/items/' + item.id,
|
href: item.getURL(),
|
||||||
target: '_blank'
|
target: '_blank'
|
||||||
});
|
});
|
||||||
if(
|
if(
|
||||||
|
|
|
@ -125,6 +125,22 @@ function Wardrobe() {
|
||||||
this.loaded = true;
|
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;
|
Item.cache[id] = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue