| 27754 |
amit.gupta |
1 |
$(document).on('click', ".web-listing", function() {
|
| 26738 |
amit.gupta |
2 |
loadWebListing("main-content");
|
|
|
3 |
});
|
| 27754 |
amit.gupta |
4 |
$(document).on('click', "a.listing-details", function() {
|
| 26738 |
amit.gupta |
5 |
var webListingId = $(this).data("id");
|
|
|
6 |
doAjaxRequestHandler(`${context}/web-listing/${webListingId}`, "GET", function(response) {
|
|
|
7 |
$('.web-products-container').html(response);
|
| 26731 |
amit.gupta |
8 |
});
|
| 26738 |
amit.gupta |
9 |
|
|
|
10 |
})
|
|
|
11 |
|
| 27754 |
amit.gupta |
12 |
$(document).on('click', "#update-rank", function(){
|
| 26738 |
amit.gupta |
13 |
if(confirm("Are you sure you want to update ranks?")) {
|
|
|
14 |
var webListingId=$(this).data("id");
|
|
|
15 |
var webProductIds=[];
|
|
|
16 |
$("#web-product-listing-tbody").find("tr").each(function(){
|
|
|
17 |
console.log(this);
|
|
|
18 |
webProductIds.push($(this).data("id"));
|
|
|
19 |
});
|
|
|
20 |
doPostAjaxRequestWithJsonHandler(`${context}/web-listing/order/${webListingId}`, JSON.stringify(webProductIds), function(response) {
|
|
|
21 |
$('.web-products-container').html(response);
|
|
|
22 |
});
|
|
|
23 |
}
|
| 26731 |
amit.gupta |
24 |
});
|
| 27754 |
amit.gupta |
25 |
$(document).on('click', "#add-listing", function() {
|
| 26738 |
amit.gupta |
26 |
var webListingId=$(this).data("id");
|
|
|
27 |
var entityIds = [entityId];
|
| 26731 |
amit.gupta |
28 |
|
| 26738 |
amit.gupta |
29 |
var entityIdTxt=$("#entityData").val();
|
|
|
30 |
if(entityIdTxt.length > 0) {
|
|
|
31 |
if(entityIdTxt.indexOf(",") > 0) {
|
|
|
32 |
entityIds = entityIdTxt.split(",");
|
|
|
33 |
}
|
|
|
34 |
} else {
|
|
|
35 |
alert("Please enter items");
|
|
|
36 |
return;
|
|
|
37 |
}
|
|
|
38 |
json = [];
|
|
|
39 |
for(var e of entityIds) {
|
|
|
40 |
json.push({webListingId:webListingId, entityId: e});
|
|
|
41 |
}
|
|
|
42 |
console.log(json);
|
|
|
43 |
console.log(JSON.stringify(json))
|
|
|
44 |
doPostAjaxRequestWithJsonHandler(`${context}/web-product-listing/add`, JSON.stringify(json), function(response) {
|
|
|
45 |
$('.web-products-container').html(response);
|
|
|
46 |
});
|
|
|
47 |
|
|
|
48 |
});
|
|
|
49 |
|
| 26731 |
amit.gupta |
50 |
function loadWebListing(domId) {
|
|
|
51 |
doAjaxRequestHandler(context + "/web-listing", "GET", function(response) {
|
|
|
52 |
$('#' + domId).html(response);
|
|
|
53 |
});
|
|
|
54 |
}
|
| 26738 |
amit.gupta |
55 |
function addWebListing() {
|
|
|
56 |
webListingTitle = $("#web-listing-title").val();
|
|
|
57 |
webListingUrl = $("#web-listing-url").val();
|
| 26731 |
amit.gupta |
58 |
json = {title:webListingTitle, url : webListingUrl};
|
| 26738 |
amit.gupta |
59 |
doPostAjaxRequestWithJsonHandler(context + "/web-listing/add", JSON.stringify(json), function(response) {
|
|
|
60 |
$('#main-content').html(response);
|
| 26731 |
amit.gupta |
61 |
});
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
|
| 27754 |
amit.gupta |
65 |
$(document).on('mousedown', ".grab", function (e) {
|
| 26738 |
amit.gupta |
66 |
var tr = $(e.target).closest("TR"), si = tr.index(), sy = e.pageY, b = $(document.body), drag;
|
|
|
67 |
b.addClass("grabCursor").css("userSelect", "none");
|
|
|
68 |
tr.addClass("grabbed");
|
|
|
69 |
function move (e) {
|
|
|
70 |
console.log(Math.abs(e.pageY - sy));
|
|
|
71 |
if (!drag && Math.abs(e.pageY - sy) < 10) return;
|
|
|
72 |
drag = true;
|
|
|
73 |
tr.siblings().each(function() {
|
|
|
74 |
var s = $(this), i = s.index(), y = s.offset().top;
|
|
|
75 |
if (e.pageY >= y && e.pageY < y + s.outerHeight()) {
|
|
|
76 |
if (e.pageY <= y + (s.outerHeight()/2))
|
|
|
77 |
tr.insertBefore(s);
|
|
|
78 |
else
|
|
|
79 |
tr.insertAfter(s);
|
|
|
80 |
return false;
|
|
|
81 |
}
|
|
|
82 |
});
|
|
|
83 |
}
|
|
|
84 |
function up (e) {
|
|
|
85 |
if (drag && si != tr.index()) {
|
|
|
86 |
drag = false;
|
|
|
87 |
$("#update-rank").prop('disabled', false);
|
|
|
88 |
}
|
|
|
89 |
$(document).unbind("mousemove", move).unbind("mouseup", up);
|
|
|
90 |
b.removeClass("grabCursor").css("userSelect", "none");
|
|
|
91 |
tr.removeClass("grabbed");
|
|
|
92 |
}
|
|
|
93 |
$(document).mousemove(move).mouseup(up);
|
|
|
94 |
});
|
| 26731 |
amit.gupta |
95 |
|
|
|
96 |
|
| 26738 |
amit.gupta |
97 |
|
|
|
98 |
|