Add right-click menu for tracking history list
This commit is contained in:
parent
bf6a4de24b
commit
1e4133cb2d
@ -23,6 +23,9 @@ var app = new Framework7({
|
||||
popover: {
|
||||
backdrop: true
|
||||
},
|
||||
touch: {
|
||||
tapHold: true
|
||||
},
|
||||
init: false,
|
||||
initOnDeviceReady: false,
|
||||
routes: routes
|
||||
|
@ -20,7 +20,7 @@ function addTrackingSuggestions() {
|
||||
$("#tracking-history-list ul").html('<li class="item-content"><div class="item-inner justify-content-center"><div class="item-title" style="color: var(--f7-list-item-footer-text-color);">You haven\'t tracked anything yet.</div></div></li>');
|
||||
} else {
|
||||
for (var i = history.length - 1; i >= 0; i--) {
|
||||
$("#tracking-history-list ul").append('<li><a class="item-link item-content hapticbtn" href="/track/' + history[i] + '">'
|
||||
$("#tracking-history-list ul").append('<li><a class="item-link item-content hapticbtn tracking-code-history-link" data-trackingcode="' + history[i] + '" href="/track/' + history[i] + '">'
|
||||
+ '<div class="item-inner"><div class="item-title">'
|
||||
+ history[i]
|
||||
+ '</div></div></a></li>');
|
||||
@ -177,12 +177,46 @@ function trackOpenAsync( {to, resolve, reject}) {
|
||||
}, "GET");
|
||||
}
|
||||
|
||||
$("#app").on("taphold contextmenu", ".tracking-code-history-link", function (evt) {
|
||||
var code = $(this).data("trackingcode");
|
||||
|
||||
var action = app.actions.create({
|
||||
buttons: [
|
||||
[
|
||||
{
|
||||
text: 'Track',
|
||||
bold: true,
|
||||
onClick: function () {
|
||||
openTrackingInfoPage(code);
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Remove From List',
|
||||
onClick: function () {
|
||||
removeFromTrackingHistory(code);
|
||||
addTrackingSuggestions();
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
text: 'Cancel',
|
||||
color: 'red'
|
||||
}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
action.open();
|
||||
return false;
|
||||
});
|
||||
|
||||
function getTrackingHistory() {
|
||||
var history = getStorage("trackinghistory");
|
||||
if (history != null) {
|
||||
return JSON.parse(history);
|
||||
} else {
|
||||
if (history == "false" || history == "null" || history == null) {
|
||||
return [];
|
||||
} else {
|
||||
return JSON.parse(history);
|
||||
}
|
||||
}
|
||||
|
||||
@ -201,4 +235,21 @@ function addToTrackingHistory(code) {
|
||||
history.shift();
|
||||
}
|
||||
setStorage("trackinghistory", JSON.stringify(history));
|
||||
}
|
||||
|
||||
function removeFromTrackingHistory(code) {
|
||||
var history = getTrackingHistory();
|
||||
|
||||
for (var i = 0; i < history.length; i++) {
|
||||
if (history[i] == code) {
|
||||
history.splice(i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
while (history.length > 10) {
|
||||
history.shift();
|
||||
}
|
||||
setStorage("trackinghistory", JSON.stringify(history));
|
||||
|
||||
$(".tracking-code-history-link[data-trackingcode=\"" + code + "\"]").parent("li").remove();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user