Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #884 from duckduckgo/jd/octopart
Browse files Browse the repository at this point in the history
Octopart: fix buttons for mobile view
  • Loading branch information
Jag Talon committed Jun 19, 2014
2 parents b89a22d + bf28afd commit b4a28cd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
12 changes: 8 additions & 4 deletions share/spice/octopart/octopart.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
.zci--octopart .btn__datasheet {
margin-right: 2px;
background-color: #e5e5e5;
}
.detail--octopart .btn__datasheet {
margin-right: 2px;
background-color: #e5e5e5;
}

.is-mobile .detail--octopart .detail__body.detail__body--pr {
padding-top: 1em;
}
12 changes: 9 additions & 3 deletions share/spice/octopart/octopart.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,35 @@ function ddg_spice_octopart (api_result) {
// return;
// }

var isMobile = $('.is-mobile').length;

Spice.add({
id: 'octopart',
name: 'Parts',
data: api_result.results,
signal: 'high',

meta: {
itemType: 'Parts',
sourceName: 'Octopart',
sourceUrl : 'http://octopart.com/partsearch#search/requestData&q=' + api_result.request.q
},
normalize: function(item) {
var img = DDG.getProperty(item, "item.images.0.url_90px");
var desc_length = 60;
var description = (isMobile ?
Handlebars.helpers.ellipsis(DDG.strip_html(item.item.short_description), desc_length) :
DDG.strip_html(item.item.short_description));

return {
brand: item.item.manufacturer.displayname,
price: item.item.avg_price[1] + ' ' + item.item.avg_price[0].toFixed(2),
img: img,
img_m: img,
// url_review: item.item.detail_url,
url: item.item.detail_url,
title: DDG.strip_html(item.item.mpn).toUpperCase(),
heading: DDG.strip_html(item.item.mpn).toUpperCase(),
description: DDG.strip_html(item.item.short_description),
description: description,
datasheet: item.item.datasheets[0].url
};
},
Expand All @@ -68,6 +73,7 @@ function ddg_spice_octopart (api_result) {
group: 'products',
options: {
rating: false,
detailVariant: 'light',
buy: Spice.octopart.buy
}
}
Expand Down

0 comments on commit b4a28cd

Please sign in to comment.