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

Gadgets/Browser: fixed prev/next button assignments

parent 7e2ccb48
/* global CSS */
.rebate {
color: red !important;
}
@media (max-width: 40em) {
/* convert button with text to icon-only */
/*
......
......@@ -659,7 +659,8 @@ define([
"original_price",
"title",
"media",
"dimensions"
"dimensions",
"currency"
];
query.limit = [];
......
......@@ -8,20 +8,28 @@ define([
var that = {};
// 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) {
var step = next ? 1 : -1, i, id;
for (i = 0; i <= max; i += 1) {
if (i === parseFloat(id)) {
var step = next ? 1 : -1, position, id;
for (position = 1; position < max; position += 1) {
if (position === parseFloat(id)) {
// we have found the position in the array, get prev/next
if (next) {
if (arr[i+1] === undefined) {
if (arr[position] === undefined) {
return false;
}
return arr[i+1].id;
}
if (arr[i-1] === -1) {
return false;
return arr[position].id;
} else {
// less 1 is self, less 2 is previous...
if (arr[position-2] === undefined) {
return false;
}
return arr[position-2].id;
}
return arr[i-1].id;
}
}
};
......@@ -63,19 +71,22 @@ define([
if (err) {
} else {
console.log(response);
// set next
// 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!
next = priv.getPrevNextItem(response.rows, currentId, true, response.total_rows);
if (!next) {
markup = params.source.replace("translate next", "translate next ui-state-disabled");
} else {
markup = params.source.replace(identifier + "=next", identifier + "=" + next);
console.log(markup)
}
// set previous
prev = priv.getPrevNextItem(response.rows, currentId, false, response.total_rows);
if (!prev) {
markup = params.source.replace("translate prev", "translate prev ui-state-disabled");
markup = markup.replace("translate prev", "translate prev ui-state-disabled");
} else {
markup = markup.replace(identifier + "=prev", identifier + "=" + prev);
}
......
......@@ -128,9 +128,6 @@
font-size: .75em;
font-weight: normal;
}
.items_listview .description_items .rebate {
color: red !important;
}
.items_show {
clear: both;
color: #111111 !important;
......
......@@ -61,7 +61,7 @@ define([
// generate results
for (i = 0; i < response.total_rows; i += 1) {
item = response.rows[i].value;
console.log(item);
if (item.price === item.original_price) {
price = item.price + item.currency;
} 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