Commit 9eecb911 authored by Sven Franck's avatar Sven Franck

Gadgets/Browser: fixed prev/next button assignments

parent 7e2ccb48
/* global CSS */ /* global CSS */
.rebate {
color: red !important;
}
@media (max-width: 40em) { @media (max-width: 40em) {
/* convert button with text to icon-only */ /* convert button with text to icon-only */
/* /*
......
...@@ -659,7 +659,8 @@ define([ ...@@ -659,7 +659,8 @@ define([
"original_price", "original_price",
"title", "title",
"media", "media",
"dimensions" "dimensions",
"currency"
]; ];
query.limit = []; query.limit = [];
......
...@@ -8,20 +8,28 @@ define([ ...@@ -8,20 +8,28 @@ define([
var that = {}; var that = {};
// get previous and next id // get previous and next id
// TODO: this only works with id-numbers!!!
// TODO: problem is also that no other field can be used to iterate
// unless we want to get allDocs(includeDocs)
// TODO: this should receive the total number of results of a query/search!
priv.getPrevNextItem = function (arr, id, next, max) { priv.getPrevNextItem = function (arr, id, next, max) {
var step = next ? 1 : -1, i, id; var step = next ? 1 : -1, position, id;
for (i = 0; i <= max; i += 1) { for (position = 1; position < max; position += 1) {
if (i === parseFloat(id)) { if (position === parseFloat(id)) {
// we have found the position in the array, get prev/next
if (next) { if (next) {
if (arr[i+1] === undefined) { if (arr[position] === undefined) {
return false; return false;
} }
return arr[i+1].id; return arr[position].id;
} } else {
if (arr[i-1] === -1) { // less 1 is self, less 2 is previous...
return false; if (arr[position-2] === undefined) {
return false;
}
return arr[position-2].id;
} }
return arr[i-1].id;
} }
} }
}; };
...@@ -63,19 +71,22 @@ define([ ...@@ -63,19 +71,22 @@ define([
if (err) { if (err) {
} else { } else {
console.log(response);
// set next // set next
// TODO: this is bad, because we can only point to doc_id, no matter what // TODO: this is bad, because we can only point to doc_id, no matter what
// identifier we are setting. item_id itself is... bad... fix! // identifier we are setting. item_id itself is... bad... fix!
next = priv.getPrevNextItem(response.rows, currentId, true, response.total_rows); next = priv.getPrevNextItem(response.rows, currentId, true, response.total_rows);
if (!next) { if (!next) {
markup = params.source.replace("translate next", "translate next ui-state-disabled"); markup = params.source.replace("translate next", "translate next ui-state-disabled");
} else { } else {
markup = params.source.replace(identifier + "=next", identifier + "=" + next); markup = params.source.replace(identifier + "=next", identifier + "=" + next);
console.log(markup)
} }
// set previous // set previous
prev = priv.getPrevNextItem(response.rows, currentId, false, response.total_rows); prev = priv.getPrevNextItem(response.rows, currentId, false, response.total_rows);
if (!prev) { if (!prev) {
markup = params.source.replace("translate prev", "translate prev ui-state-disabled"); markup = markup.replace("translate prev", "translate prev ui-state-disabled");
} else { } else {
markup = markup.replace(identifier + "=prev", identifier + "=" + prev); markup = markup.replace(identifier + "=prev", identifier + "=" + prev);
} }
......
...@@ -128,9 +128,6 @@ ...@@ -128,9 +128,6 @@
font-size: .75em; font-size: .75em;
font-weight: normal; font-weight: normal;
} }
.items_listview .description_items .rebate {
color: red !important;
}
.items_show { .items_show {
clear: both; clear: both;
color: #111111 !important; color: #111111 !important;
......
...@@ -61,7 +61,7 @@ define([ ...@@ -61,7 +61,7 @@ define([
// generate results // generate results
for (i = 0; i < response.total_rows; i += 1) { for (i = 0; i < response.total_rows; i += 1) {
item = response.rows[i].value; item = response.rows[i].value;
console.log(item);
if (item.price === item.original_price) { if (item.price === item.original_price) {
price = item.price + item.currency; price = item.price + item.currency;
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment