Fix history list not parse and bind events properly on change pagination
This commit is contained in:
parent
f4fe27e26c
commit
f5d471106c
1 changed files with 95 additions and 79 deletions
|
@ -112,28 +112,11 @@ function parseHistoryCallback(list, notehistory) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// parse filter tags
|
||||||
var filtertags = [];
|
var filtertags = [];
|
||||||
$(".item").each(function (key, value) {
|
for (var i = 0, l = list.items.length; i < l; i++) {
|
||||||
var a = $(this).closest("a");
|
var tags = list.items[i]._values.tags;
|
||||||
var pin = $(this).find(".ui-history-pin");
|
if (tags && tags.length > 0) {
|
||||||
var id = a.siblings("span").html();
|
|
||||||
var tagsEl = $(this).find(".tags");
|
|
||||||
var item = historyList.get('id', id);
|
|
||||||
if (item.length > 0 && item[0]) {
|
|
||||||
var values = item[0].values();
|
|
||||||
//parse pinned
|
|
||||||
if (values.pinned) {
|
|
||||||
pin.addClass('active');
|
|
||||||
} else {
|
|
||||||
pin.removeClass('active');
|
|
||||||
}
|
|
||||||
//parse link to element a
|
|
||||||
a.attr('href', serverurl + '/' + values.id);
|
|
||||||
//parse tags
|
|
||||||
if (values.tags) {
|
|
||||||
var tags = values.tags;
|
|
||||||
if (tags.length > 0) {
|
|
||||||
var labels = [];
|
|
||||||
for (var j = 0; j < tags.length; j++) {
|
for (var j = 0; j < tags.length; j++) {
|
||||||
//push info filtertags if not found
|
//push info filtertags if not found
|
||||||
var found = false;
|
var found = false;
|
||||||
|
@ -141,6 +124,35 @@ function parseHistoryCallback(list, notehistory) {
|
||||||
found = true;
|
found = true;
|
||||||
if (!found)
|
if (!found)
|
||||||
filtertags.push(tags[j]);
|
filtertags.push(tags[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buildTagsFilter(filtertags);
|
||||||
|
}
|
||||||
|
|
||||||
|
// update items whenever list updated
|
||||||
|
historyList.on('updated', function (e) {
|
||||||
|
for (var i = 0, l = e.items.length; i < l; i++) {
|
||||||
|
var item = e.items[i];
|
||||||
|
if (item.visible()) {
|
||||||
|
var itemEl = $(item.elm);
|
||||||
|
var values = item._values;
|
||||||
|
var a = itemEl.find("a");
|
||||||
|
var pin = itemEl.find(".ui-history-pin");
|
||||||
|
var tagsEl = itemEl.find(".tags");
|
||||||
|
//parse link to element a
|
||||||
|
a.attr('href', serverurl + '/' + values.id);
|
||||||
|
//parse pinned
|
||||||
|
if (values.pinned) {
|
||||||
|
pin.addClass('active');
|
||||||
|
} else {
|
||||||
|
pin.removeClass('active');
|
||||||
|
}
|
||||||
|
//parse tags
|
||||||
|
var tags = values.tags;
|
||||||
|
if (tags && tags.length > 0 && tagsEl.children().length <= 0) {
|
||||||
|
var labels = [];
|
||||||
|
for (var j = 0; j < tags.length; j++) {
|
||||||
//push into the item label
|
//push into the item label
|
||||||
labels.push("<span class='label label-default'>" + tags[j] + "</span>");
|
labels.push("<span class='label label-default'>" + tags[j] + "</span>");
|
||||||
}
|
}
|
||||||
|
@ -148,22 +160,28 @@ function parseHistoryCallback(list, notehistory) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
$(".ui-history-close").off('click');
|
||||||
$(".ui-history-close").click(function (e) {
|
$(".ui-history-close").on('click', historyCloseClick);
|
||||||
|
$(".ui-history-pin").off('click');
|
||||||
|
$(".ui-history-pin").on('click', historyPinClick);
|
||||||
|
});
|
||||||
|
|
||||||
|
function historyCloseClick(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var id = $(this).closest("a").siblings("span").html();
|
var id = $(this).closest("a").siblings("span").html();
|
||||||
var value = list.get('id', id)[0].values();
|
var value = historyList.get('id', id)[0]._values;
|
||||||
$('.ui-delete-modal-msg').text('Do you really want to delete below history?');
|
$('.ui-delete-modal-msg').text('Do you really want to delete below history?');
|
||||||
$('.ui-delete-modal-item').html('<i class="fa fa-file-text"></i> ' + value.text + '<br><i class="fa fa-clock-o"></i> ' + value.time);
|
$('.ui-delete-modal-item').html('<i class="fa fa-file-text"></i> ' + value.text + '<br><i class="fa fa-clock-o"></i> ' + value.time);
|
||||||
clearHistory = false;
|
clearHistory = false;
|
||||||
deleteId = id;
|
deleteId = id;
|
||||||
});
|
}
|
||||||
$(".ui-history-pin").click(function (e) {
|
|
||||||
|
function historyPinClick(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
var id = $this.closest("a").siblings("span").html();
|
var id = $this.closest("a").siblings("span").html();
|
||||||
var item = list.get('id', id)[0];
|
var item = historyList.get('id', id)[0];
|
||||||
var values = item.values();
|
var values = item._values;
|
||||||
var pinned = values.pinned;
|
var pinned = values.pinned;
|
||||||
if (!values.pinned) {
|
if (!values.pinned) {
|
||||||
pinned = true;
|
pinned = true;
|
||||||
|
@ -197,9 +215,7 @@ function parseHistoryCallback(list, notehistory) {
|
||||||
else
|
else
|
||||||
$this.removeClass('active');
|
$this.removeClass('active');
|
||||||
});
|
});
|
||||||
})
|
|
||||||
});
|
});
|
||||||
buildTagsFilter(filtertags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//auto update item fromNow every minutes
|
//auto update item fromNow every minutes
|
||||||
|
|
Loading…
Reference in a new issue